@fieldwangai/agentflow 0.1.136 → 0.1.138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,565 +0,0 @@
1
- var k2=Object.defineProperty;var v2=(e,t,n)=>t in e?k2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tn=(e,t,n)=>v2(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var Rd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ma(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jA={exports:{}},Wm={},NA={exports:{}},Mt={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var xf=Symbol.for("react.element"),S2=Symbol.for("react.portal"),j2=Symbol.for("react.fragment"),N2=Symbol.for("react.strict_mode"),_2=Symbol.for("react.profiler"),C2=Symbol.for("react.provider"),A2=Symbol.for("react.context"),E2=Symbol.for("react.forward_ref"),I2=Symbol.for("react.suspense"),P2=Symbol.for("react.memo"),R2=Symbol.for("react.lazy"),sj=Symbol.iterator;function T2(e){return e===null||typeof e!="object"?null:(e=sj&&e[sj]||e["@@iterator"],typeof e=="function"?e:null)}var _A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},CA=Object.assign,AA={};function Qc(e,t,n){this.props=e,this.context=t,this.refs=AA,this.updater=n||_A}Qc.prototype.isReactComponent={};Qc.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};Qc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function EA(){}EA.prototype=Qc.prototype;function Kb(e,t,n){this.props=e,this.context=t,this.refs=AA,this.updater=n||_A}var qb=Kb.prototype=new EA;qb.constructor=Kb;CA(qb,Qc.prototype);qb.isPureReactComponent=!0;var ij=Array.isArray,IA=Object.prototype.hasOwnProperty,Ub={current:null},PA={key:!0,ref:!0,__self:!0,__source:!0};function RA(e,t,n){var r,s={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)IA.call(t,r)&&!PA.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:xf,type:e,key:o,ref:a,props:s,_owner:Ub.current}}function M2(e,t){return{$$typeof:xf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Gb(e){return typeof e=="object"&&e!==null&&e.$$typeof===xf}function $2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var oj=/\/+/g;function wy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?$2(""+e.key):t.toString(36)}function lh(e,t,n,r,s){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case xf:case S2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+wy(a,0):r,ij(s)?(n="",e!=null&&(n=e.replace(oj,"$&/")+"/"),lh(s,t,n,"",function(u){return u})):s!=null&&(Gb(s)&&(s=M2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(oj,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",ij(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+wy(o,l);a+=lh(o,t,n,c,s)}else if(c=T2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+wy(o,l++),a+=lh(o,t,n,c,s);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function hp(e,t,n){if(e==null)return e;var r=[],s=0;return lh(e,r,"","",function(o){return t.call(n,o,s++)}),r}function L2(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Wr={current:null},ch={transition:null},O2={ReactCurrentDispatcher:Wr,ReactCurrentBatchConfig:ch,ReactCurrentOwner:Ub};function TA(){throw Error("act(...) is not supported in production builds of React.")}Mt.Children={map:hp,forEach:function(e,t,n){hp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return hp(e,function(){t++}),t},toArray:function(e){return hp(e,function(t){return t})||[]},only:function(e){if(!Gb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Mt.Component=Qc;Mt.Fragment=j2;Mt.Profiler=_2;Mt.PureComponent=Kb;Mt.StrictMode=N2;Mt.Suspense=I2;Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=O2;Mt.act=TA;Mt.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=CA({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Ub.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)IA.call(t,c)&&!PA.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:xf,type:e.type,key:s,ref:o,props:r,_owner:a}};Mt.createContext=function(e){return e={$$typeof:A2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:C2,_context:e},e.Consumer=e};Mt.createElement=RA;Mt.createFactory=function(e){var t=RA.bind(null,e);return t.type=e,t};Mt.createRef=function(){return{current:null}};Mt.forwardRef=function(e){return{$$typeof:E2,render:e}};Mt.isValidElement=Gb;Mt.lazy=function(e){return{$$typeof:R2,_payload:{_status:-1,_result:e},_init:L2}};Mt.memo=function(e,t){return{$$typeof:P2,type:e,compare:t===void 0?null:t}};Mt.startTransition=function(e){var t=ch.transition;ch.transition={};try{e()}finally{ch.transition=t}};Mt.unstable_act=TA;Mt.useCallback=function(e,t){return Wr.current.useCallback(e,t)};Mt.useContext=function(e){return Wr.current.useContext(e)};Mt.useDebugValue=function(){};Mt.useDeferredValue=function(e){return Wr.current.useDeferredValue(e)};Mt.useEffect=function(e,t){return Wr.current.useEffect(e,t)};Mt.useId=function(){return Wr.current.useId()};Mt.useImperativeHandle=function(e,t,n){return Wr.current.useImperativeHandle(e,t,n)};Mt.useInsertionEffect=function(e,t){return Wr.current.useInsertionEffect(e,t)};Mt.useLayoutEffect=function(e,t){return Wr.current.useLayoutEffect(e,t)};Mt.useMemo=function(e,t){return Wr.current.useMemo(e,t)};Mt.useReducer=function(e,t,n){return Wr.current.useReducer(e,t,n)};Mt.useRef=function(e){return Wr.current.useRef(e)};Mt.useState=function(e){return Wr.current.useState(e)};Mt.useSyncExternalStore=function(e,t,n){return Wr.current.useSyncExternalStore(e,t,n)};Mt.useTransition=function(){return Wr.current.useTransition()};Mt.version="18.3.1";NA.exports=Mt;var m=NA.exports;const pt=ma(m);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var D2=m,F2=Symbol.for("react.element"),z2=Symbol.for("react.fragment"),B2=Object.prototype.hasOwnProperty,W2=D2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,H2={key:!0,ref:!0,__self:!0,__source:!0};function MA(e,t,n){var r,s={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)B2.call(t,r)&&!H2.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:F2,type:e,key:o,ref:a,props:s,_owner:W2.current}}Wm.Fragment=z2;Wm.jsx=MA;Wm.jsxs=MA;jA.exports=Wm;var i=jA.exports,Hw={},$A={exports:{}},xs={},LA={exports:{}},OA={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t($,H){var A=$.length;$.push(H);e:for(;0<A;){var Q=A-1>>>1,K=$[Q];if(0<s(K,H))$[Q]=H,$[A]=K,A=Q;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var H=$[0],A=$.pop();if(A!==H){$[0]=A;e:for(var Q=0,K=$.length,W=K>>>1;Q<W;){var te=2*(Q+1)-1,Z=$[te],G=te+1,ne=$[G];if(0>s(Z,A))G<K&&0>s(ne,Z)?($[Q]=ne,$[G]=A,Q=G):($[Q]=Z,$[te]=A,Q=te);else if(G<K&&0>s(ne,A))$[Q]=ne,$[G]=A,Q=G;else break e}}return H}function s($,H){var A=$.sortIndex-H.sortIndex;return A!==0?A:$.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],p=1,f=null,d=3,h=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x($){for(var H=n(u);H!==null;){if(H.callback===null)r(u);else if(H.startTime<=$)r(u),H.sortIndex=H.expirationTime,t(c,H);else break;H=n(u)}}function _($){if(v=!1,x($),!y)if(n(c)!==null)y=!0,B(S);else{var H=n(u);H!==null&&F(_,H.startTime-$)}}function S($,H){y=!1,v&&(v=!1,g(R),R=-1),h=!0;var A=d;try{for(x(H),f=n(c);f!==null&&(!(f.expirationTime>H)||$&&!O());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,d=f.priorityLevel;var K=Q(f.expirationTime<=H);H=e.unstable_now(),typeof K=="function"?f.callback=K:f===n(c)&&r(c),x(H)}else r(c);f=n(c)}if(f!==null)var W=!0;else{var te=n(u);te!==null&&F(_,te.startTime-H),W=!1}return W}finally{f=null,d=A,h=!1}}var N=!1,P=null,R=-1,z=5,E=-1;function O(){return!(e.unstable_now()-E<z)}function D(){if(P!==null){var $=e.unstable_now();E=$;var H=!0;try{H=P(!0,$)}finally{H?L():(N=!1,P=null)}}else N=!1}var L;if(typeof k=="function")L=function(){k(D)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,V=M.port2;M.port1.onmessage=D,L=function(){V.postMessage(null)}}else L=function(){b(D,0)};function B($){P=$,N||(N=!0,L())}function F($,H){R=b(function(){$(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_continueExecution=function(){y||h||(y=!0,B(S))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(d){case 1:case 2:case 3:var H=3;break;default:H=d}var A=d;d=H;try{return $()}finally{d=A}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,H){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var A=d;d=$;try{return H()}finally{d=A}},e.unstable_scheduleCallback=function($,H,A){var Q=e.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?Q+A:Q):A=Q,$){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=A+K,$={id:p++,callback:H,priorityLevel:$,startTime:A,expirationTime:K,sortIndex:-1},A>Q?($.sortIndex=A,t(u,$),n(c)===null&&$===n(u)&&(v?(g(R),R=-1):v=!0,F(_,A-Q))):($.sortIndex=K,t(c,$),y||h||(y=!0,B(S))),$},e.unstable_shouldYield=O,e.unstable_wrapCallback=function($){var H=d;return function(){var A=d;d=H;try{return $.apply(this,arguments)}finally{d=A}}}})(OA);LA.exports=OA;var V2=LA.exports;/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var K2=m,ys=V2;function Ee(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var DA=new Set,Td={};function gl(e,t){Tc(e,t),Tc(e+"Capture",t)}function Tc(e,t){for(Td[e]=t,e=0;e<t.length;e++)DA.add(t[e])}var fo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Vw=Object.prototype.hasOwnProperty,q2=/^[: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]*$/,aj={},lj={};function U2(e){return Vw.call(lj,e)?!0:Vw.call(aj,e)?!1:q2.test(e)?lj[e]=!0:(aj[e]=!0,!1)}function G2(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 Y2(e,t,n,r){if(t===null||typeof t>"u"||G2(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 Hr(e,t,n,r,s,o,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=o,this.removeEmptyString=a}var br={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){br[e]=new Hr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];br[t]=new Hr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){br[e]=new Hr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){br[e]=new Hr(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){br[e]=new Hr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){br[e]=new Hr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){br[e]=new Hr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){br[e]=new Hr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){br[e]=new Hr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yb=/[\-:]([a-z])/g;function Jb(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(Yb,Jb);br[t]=new Hr(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(Yb,Jb);br[t]=new Hr(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(Yb,Jb);br[t]=new Hr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){br[e]=new Hr(e,1,!1,e.toLowerCase(),null,!1,!1)});br.xlinkHref=new Hr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){br[e]=new Hr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xb(e,t,n,r){var s=br.hasOwnProperty(t)?br[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Y2(t,n,s,r)&&(n=null),r||s===null?U2(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var bo=K2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,mp=Symbol.for("react.element"),tc=Symbol.for("react.portal"),nc=Symbol.for("react.fragment"),Qb=Symbol.for("react.strict_mode"),Kw=Symbol.for("react.profiler"),FA=Symbol.for("react.provider"),zA=Symbol.for("react.context"),Zb=Symbol.for("react.forward_ref"),qw=Symbol.for("react.suspense"),Uw=Symbol.for("react.suspense_list"),ek=Symbol.for("react.memo"),Fo=Symbol.for("react.lazy"),BA=Symbol.for("react.offscreen"),cj=Symbol.iterator;function Lu(e){return e===null||typeof e!="object"?null:(e=cj&&e[cj]||e["@@iterator"],typeof e=="function"?e:null)}var Pn=Object.assign,xy;function td(e){if(xy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);xy=t&&t[1]||""}return`
34
- `+xy+e}var by=!1;function ky(e,t){if(!e||by)return"";by=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(`
35
- `),o=r.stack.split(`
36
- `),a=s.length-1,l=o.length-1;1<=a&&0<=l&&s[a]!==o[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==o[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==o[l]){var c=`
37
- `+s[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{by=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?td(e):""}function J2(e){switch(e.tag){case 5:return td(e.type);case 16:return td("Lazy");case 13:return td("Suspense");case 19:return td("SuspenseList");case 0:case 2:case 15:return e=ky(e.type,!1),e;case 11:return e=ky(e.type.render,!1),e;case 1:return e=ky(e.type,!0),e;default:return""}}function Gw(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 nc:return"Fragment";case tc:return"Portal";case Kw:return"Profiler";case Qb:return"StrictMode";case qw:return"Suspense";case Uw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case zA:return(e.displayName||"Context")+".Consumer";case FA:return(e._context.displayName||"Context")+".Provider";case Zb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ek:return t=e.displayName||null,t!==null?t:Gw(e.type)||"Memo";case Fo:t=e._payload,e=e._init;try{return Gw(e(t))}catch{}}return null}function X2(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 Gw(t);case 8:return t===Qb?"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 aa(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function WA(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Q2(e){var t=WA(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,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,o.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 gp(e){e._valueTracker||(e._valueTracker=Q2(e))}function HA(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=WA(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Mh(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 Yw(e,t){var n=t.checked;return Pn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function uj(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=aa(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 VA(e,t){t=t.checked,t!=null&&Xb(e,"checked",t,!1)}function Jw(e,t){VA(e,t);var n=aa(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")?Xw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Xw(e,t.type,aa(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function dj(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 Xw(e,t,n){(t!=="number"||Mh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var nd=Array.isArray;function xc(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+aa(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Qw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ee(91));return Pn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function fj(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ee(92));if(nd(n)){if(1<n.length)throw Error(Ee(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:aa(n)}}function KA(e,t){var n=aa(t.value),r=aa(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function pj(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function qA(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Zw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?qA(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var yp,UA=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(yp=yp||document.createElement("div"),yp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=yp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Md(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pd={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},Z2=["Webkit","ms","Moz","O"];Object.keys(pd).forEach(function(e){Z2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pd[t]=pd[e]})});function GA(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||pd.hasOwnProperty(e)&&pd[e]?(""+t).trim():t+"px"}function YA(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=GA(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var eO=Pn({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 ex(e,t){if(t){if(eO[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ee(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ee(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ee(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ee(62))}}function tx(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 nx=null;function tk(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var rx=null,bc=null,kc=null;function hj(e){if(e=vf(e)){if(typeof rx!="function")throw Error(Ee(280));var t=e.stateNode;t&&(t=Um(t),rx(e.stateNode,e.type,t))}}function JA(e){bc?kc?kc.push(e):kc=[e]:bc=e}function XA(){if(bc){var e=bc,t=kc;if(kc=bc=null,hj(e),t)for(e=0;e<t.length;e++)hj(t[e])}}function QA(e,t){return e(t)}function ZA(){}var vy=!1;function eE(e,t,n){if(vy)return e(t,n);vy=!0;try{return QA(e,t,n)}finally{vy=!1,(bc!==null||kc!==null)&&(ZA(),XA())}}function $d(e,t){var n=e.stateNode;if(n===null)return null;var r=Um(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(Ee(231,t,typeof n));return n}var sx=!1;if(fo)try{var Ou={};Object.defineProperty(Ou,"passive",{get:function(){sx=!0}}),window.addEventListener("test",Ou,Ou),window.removeEventListener("test",Ou,Ou)}catch{sx=!1}function tO(e,t,n,r,s,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var hd=!1,$h=null,Lh=!1,ix=null,nO={onError:function(e){hd=!0,$h=e}};function rO(e,t,n,r,s,o,a,l,c){hd=!1,$h=null,tO.apply(nO,arguments)}function sO(e,t,n,r,s,o,a,l,c){if(rO.apply(this,arguments),hd){if(hd){var u=$h;hd=!1,$h=null}else throw Error(Ee(198));Lh||(Lh=!0,ix=u)}}function yl(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function tE(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function mj(e){if(yl(e)!==e)throw Error(Ee(188))}function iO(e){var t=e.alternate;if(!t){if(t=yl(e),t===null)throw Error(Ee(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var o=s.alternate;if(o===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===o.child){for(o=s.child;o;){if(o===n)return mj(s),e;if(o===r)return mj(s),t;o=o.sibling}throw Error(Ee(188))}if(n.return!==r.return)n=s,r=o;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=o;break}if(l===r){a=!0,r=s,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=s;break}if(l===r){a=!0,r=o,n=s;break}l=l.sibling}if(!a)throw Error(Ee(189))}}if(n.alternate!==r)throw Error(Ee(190))}if(n.tag!==3)throw Error(Ee(188));return n.stateNode.current===n?e:t}function nE(e){return e=iO(e),e!==null?rE(e):null}function rE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=rE(e);if(t!==null)return t;e=e.sibling}return null}var sE=ys.unstable_scheduleCallback,gj=ys.unstable_cancelCallback,oO=ys.unstable_shouldYield,aO=ys.unstable_requestPaint,Dn=ys.unstable_now,lO=ys.unstable_getCurrentPriorityLevel,nk=ys.unstable_ImmediatePriority,iE=ys.unstable_UserBlockingPriority,Oh=ys.unstable_NormalPriority,cO=ys.unstable_LowPriority,oE=ys.unstable_IdlePriority,Hm=null,Ri=null;function uO(e){if(Ri&&typeof Ri.onCommitFiberRoot=="function")try{Ri.onCommitFiberRoot(Hm,e,void 0,(e.current.flags&128)===128)}catch{}}var li=Math.clz32?Math.clz32:pO,dO=Math.log,fO=Math.LN2;function pO(e){return e>>>=0,e===0?32:31-(dO(e)/fO|0)|0}var wp=64,xp=4194304;function rd(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 Dh(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=rd(l):(o&=a,o!==0&&(r=rd(o)))}else a=n&~s,a!==0?r=rd(a):o!==0&&(r=rd(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-li(t),s=1<<n,r|=e[n],t&=~s;return r}function hO(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function mO(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-li(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=hO(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function ox(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function aE(){var e=wp;return wp<<=1,!(wp&4194240)&&(wp=64),e}function Sy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function bf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-li(t),e[t]=n}function gO(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<n;){var s=31-li(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function rk(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-li(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var rn=0;function lE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var cE,sk,uE,dE,fE,ax=!1,bp=[],Xo=null,Qo=null,Zo=null,Ld=new Map,Od=new Map,Wo=[],yO="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function yj(e,t){switch(e){case"focusin":case"focusout":Xo=null;break;case"dragenter":case"dragleave":Qo=null;break;case"mouseover":case"mouseout":Zo=null;break;case"pointerover":case"pointerout":Ld.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Od.delete(t.pointerId)}}function Du(e,t,n,r,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[s]},t!==null&&(t=vf(t),t!==null&&sk(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function wO(e,t,n,r,s){switch(t){case"focusin":return Xo=Du(Xo,e,t,n,r,s),!0;case"dragenter":return Qo=Du(Qo,e,t,n,r,s),!0;case"mouseover":return Zo=Du(Zo,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Ld.set(o,Du(Ld.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Od.set(o,Du(Od.get(o)||null,e,t,n,r,s)),!0}return!1}function pE(e){var t=Ba(e.target);if(t!==null){var n=yl(t);if(n!==null){if(t=n.tag,t===13){if(t=tE(n),t!==null){e.blockedOn=t,fE(e.priority,function(){uE(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function uh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=lx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);nx=r,n.target.dispatchEvent(r),nx=null}else return t=vf(n),t!==null&&sk(t),e.blockedOn=n,!1;t.shift()}return!0}function wj(e,t,n){uh(e)&&n.delete(t)}function xO(){ax=!1,Xo!==null&&uh(Xo)&&(Xo=null),Qo!==null&&uh(Qo)&&(Qo=null),Zo!==null&&uh(Zo)&&(Zo=null),Ld.forEach(wj),Od.forEach(wj)}function Fu(e,t){e.blockedOn===t&&(e.blockedOn=null,ax||(ax=!0,ys.unstable_scheduleCallback(ys.unstable_NormalPriority,xO)))}function Dd(e){function t(s){return Fu(s,e)}if(0<bp.length){Fu(bp[0],e);for(var n=1;n<bp.length;n++){var r=bp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Xo!==null&&Fu(Xo,e),Qo!==null&&Fu(Qo,e),Zo!==null&&Fu(Zo,e),Ld.forEach(t),Od.forEach(t),n=0;n<Wo.length;n++)r=Wo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Wo.length&&(n=Wo[0],n.blockedOn===null);)pE(n),n.blockedOn===null&&Wo.shift()}var vc=bo.ReactCurrentBatchConfig,Fh=!0;function bO(e,t,n,r){var s=rn,o=vc.transition;vc.transition=null;try{rn=1,ik(e,t,n,r)}finally{rn=s,vc.transition=o}}function kO(e,t,n,r){var s=rn,o=vc.transition;vc.transition=null;try{rn=4,ik(e,t,n,r)}finally{rn=s,vc.transition=o}}function ik(e,t,n,r){if(Fh){var s=lx(e,t,n,r);if(s===null)Ty(e,t,r,zh,n),yj(e,r);else if(wO(s,e,t,n,r))r.stopPropagation();else if(yj(e,r),t&4&&-1<yO.indexOf(e)){for(;s!==null;){var o=vf(s);if(o!==null&&cE(o),o=lx(e,t,n,r),o===null&&Ty(e,t,r,zh,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else Ty(e,t,r,null,n)}}var zh=null;function lx(e,t,n,r){if(zh=null,e=tk(r),e=Ba(e),e!==null)if(t=yl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=tE(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return zh=e,null}function hE(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(lO()){case nk:return 1;case iE:return 4;case Oh:case cO:return 16;case oE:return 536870912;default:return 16}default:return 16}}var Uo=null,ok=null,dh=null;function mE(){if(dh)return dh;var e,t=ok,n=t.length,r,s="value"in Uo?Uo.value:Uo.textContent,o=s.length;for(e=0;e<n&&t[e]===s[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===s[o-r];r++);return dh=s.slice(e,1<r?1-r:void 0)}function fh(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function kp(){return!0}function xj(){return!1}function bs(e){function t(n,r,s,o,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?kp:xj,this.isPropagationStopped=xj,this}return Pn(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=kp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=kp)},persist:function(){},isPersistent:kp}),t}var Zc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ak=bs(Zc),kf=Pn({},Zc,{view:0,detail:0}),vO=bs(kf),jy,Ny,zu,Vm=Pn({},kf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:lk,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==zu&&(zu&&e.type==="mousemove"?(jy=e.screenX-zu.screenX,Ny=e.screenY-zu.screenY):Ny=jy=0,zu=e),jy)},movementY:function(e){return"movementY"in e?e.movementY:Ny}}),bj=bs(Vm),SO=Pn({},Vm,{dataTransfer:0}),jO=bs(SO),NO=Pn({},kf,{relatedTarget:0}),_y=bs(NO),_O=Pn({},Zc,{animationName:0,elapsedTime:0,pseudoElement:0}),CO=bs(_O),AO=Pn({},Zc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),EO=bs(AO),IO=Pn({},Zc,{data:0}),kj=bs(IO),PO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},RO={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},TO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function MO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=TO[e])?!!t[e]:!1}function lk(){return MO}var $O=Pn({},kf,{key:function(e){if(e.key){var t=PO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=fh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?RO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:lk,charCode:function(e){return e.type==="keypress"?fh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?fh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),LO=bs($O),OO=Pn({},Vm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vj=bs(OO),DO=Pn({},kf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:lk}),FO=bs(DO),zO=Pn({},Zc,{propertyName:0,elapsedTime:0,pseudoElement:0}),BO=bs(zO),WO=Pn({},Vm,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),HO=bs(WO),VO=[9,13,27,32],ck=fo&&"CompositionEvent"in window,md=null;fo&&"documentMode"in document&&(md=document.documentMode);var KO=fo&&"TextEvent"in window&&!md,gE=fo&&(!ck||md&&8<md&&11>=md),Sj=" ",jj=!1;function yE(e,t){switch(e){case"keyup":return VO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var rc=!1;function qO(e,t){switch(e){case"compositionend":return wE(t);case"keypress":return t.which!==32?null:(jj=!0,Sj);case"textInput":return e=t.data,e===Sj&&jj?null:e;default:return null}}function UO(e,t){if(rc)return e==="compositionend"||!ck&&yE(e,t)?(e=mE(),dh=ok=Uo=null,rc=!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.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return gE&&t.locale!=="ko"?null:t.data;default:return null}}var GO={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Nj(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!GO[e.type]:t==="textarea"}function xE(e,t,n,r){JA(r),t=Bh(t,"onChange"),0<t.length&&(n=new ak("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var gd=null,Fd=null;function YO(e){IE(e,0)}function Km(e){var t=oc(e);if(HA(t))return e}function JO(e,t){if(e==="change")return t}var bE=!1;if(fo){var Cy;if(fo){var Ay="oninput"in document;if(!Ay){var _j=document.createElement("div");_j.setAttribute("oninput","return;"),Ay=typeof _j.oninput=="function"}Cy=Ay}else Cy=!1;bE=Cy&&(!document.documentMode||9<document.documentMode)}function Cj(){gd&&(gd.detachEvent("onpropertychange",kE),Fd=gd=null)}function kE(e){if(e.propertyName==="value"&&Km(Fd)){var t=[];xE(t,Fd,e,tk(e)),eE(YO,t)}}function XO(e,t,n){e==="focusin"?(Cj(),gd=t,Fd=n,gd.attachEvent("onpropertychange",kE)):e==="focusout"&&Cj()}function QO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Km(Fd)}function ZO(e,t){if(e==="click")return Km(t)}function eD(e,t){if(e==="input"||e==="change")return Km(t)}function tD(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var di=typeof Object.is=="function"?Object.is:tD;function zd(e,t){if(di(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Vw.call(t,s)||!di(e[s],t[s]))return!1}return!0}function Aj(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ej(e,t){var n=Aj(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=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=Aj(n)}}function vE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?vE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function SE(){for(var e=window,t=Mh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Mh(e.document)}return t}function uk(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 nD(e){var t=SE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&vE(n.ownerDocument.documentElement,n)){if(r!==null&&uk(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,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=Ej(n,o);var a=Ej(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(),o>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<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var rD=fo&&"documentMode"in document&&11>=document.documentMode,sc=null,cx=null,yd=null,ux=!1;function Ij(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ux||sc==null||sc!==Mh(r)||(r=sc,"selectionStart"in r&&uk(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}),yd&&zd(yd,r)||(yd=r,r=Bh(cx,"onSelect"),0<r.length&&(t=new ak("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sc)))}function vp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ic={animationend:vp("Animation","AnimationEnd"),animationiteration:vp("Animation","AnimationIteration"),animationstart:vp("Animation","AnimationStart"),transitionend:vp("Transition","TransitionEnd")},Ey={},jE={};fo&&(jE=document.createElement("div").style,"AnimationEvent"in window||(delete ic.animationend.animation,delete ic.animationiteration.animation,delete ic.animationstart.animation),"TransitionEvent"in window||delete ic.transitionend.transition);function qm(e){if(Ey[e])return Ey[e];if(!ic[e])return e;var t=ic[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in jE)return Ey[e]=t[n];return e}var NE=qm("animationend"),_E=qm("animationiteration"),CE=qm("animationstart"),AE=qm("transitionend"),EE=new Map,Pj="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ga(e,t){EE.set(e,t),gl(t,[e])}for(var Iy=0;Iy<Pj.length;Iy++){var Py=Pj[Iy],sD=Py.toLowerCase(),iD=Py[0].toUpperCase()+Py.slice(1);ga(sD,"on"+iD)}ga(NE,"onAnimationEnd");ga(_E,"onAnimationIteration");ga(CE,"onAnimationStart");ga("dblclick","onDoubleClick");ga("focusin","onFocus");ga("focusout","onBlur");ga(AE,"onTransitionEnd");Tc("onMouseEnter",["mouseout","mouseover"]);Tc("onMouseLeave",["mouseout","mouseover"]);Tc("onPointerEnter",["pointerout","pointerover"]);Tc("onPointerLeave",["pointerout","pointerover"]);gl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));gl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));gl("onBeforeInput",["compositionend","keypress","textInput","paste"]);gl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));gl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));gl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sd="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),oD=new Set("cancel close invalid load scroll toggle".split(" ").concat(sd));function Rj(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,sO(r,t,void 0,e),e.currentTarget=null}function IE(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==o&&s.isPropagationStopped())break e;Rj(s,l,u),o=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==o&&s.isPropagationStopped())break e;Rj(s,l,u),o=c}}}if(Lh)throw e=ix,Lh=!1,ix=null,e}function mn(e,t){var n=t[mx];n===void 0&&(n=t[mx]=new Set);var r=e+"__bubble";n.has(r)||(PE(t,e,2,!1),n.add(r))}function Ry(e,t,n){var r=0;t&&(r|=4),PE(n,e,r,t)}var Sp="_reactListening"+Math.random().toString(36).slice(2);function Bd(e){if(!e[Sp]){e[Sp]=!0,DA.forEach(function(n){n!=="selectionchange"&&(oD.has(n)||Ry(n,!1,e),Ry(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Sp]||(t[Sp]=!0,Ry("selectionchange",!1,t))}}function PE(e,t,n,r){switch(hE(t)){case 1:var s=bO;break;case 4:s=kO;break;default:s=ik}n=s.bind(null,t,n,e),s=void 0,!sx||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function Ty(e,t,n,r,s){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.parentNode===s)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;a=a.return}for(;l!==null;){if(a=Ba(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}eE(function(){var u=o,p=tk(n),f=[];e:{var d=EE.get(e);if(d!==void 0){var h=ak,y=e;switch(e){case"keypress":if(fh(n)===0)break e;case"keydown":case"keyup":h=LO;break;case"focusin":y="focus",h=_y;break;case"focusout":y="blur",h=_y;break;case"beforeblur":case"afterblur":h=_y;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=bj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=jO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=FO;break;case NE:case _E:case CE:h=CO;break;case AE:h=BO;break;case"scroll":h=vO;break;case"wheel":h=HO;break;case"copy":case"cut":case"paste":h=EO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=vj}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?d!==null?d+"Capture":null:d;v=[];for(var k=u,x;k!==null;){x=k;var _=x.stateNode;if(x.tag===5&&_!==null&&(x=_,g!==null&&(_=$d(k,g),_!=null&&v.push(Wd(k,_,x)))),b)break;k=k.return}0<v.length&&(d=new h(d,y,null,n,p),f.push({event:d,listeners:v}))}}if(!(t&7)){e:{if(d=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",d&&n!==nx&&(y=n.relatedTarget||n.fromElement)&&(Ba(y)||y[po]))break e;if((h||d)&&(d=p.window===p?p:(d=p.ownerDocument)?d.defaultView||d.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?Ba(y):null,y!==null&&(b=yl(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=bj,_="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=vj,_="onPointerLeave",g="onPointerEnter",k="pointer"),b=h==null?d:oc(h),x=y==null?d:oc(y),d=new v(_,k+"leave",h,n,p),d.target=b,d.relatedTarget=x,_=null,Ba(p)===u&&(v=new v(g,k+"enter",y,n,p),v.target=x,v.relatedTarget=b,_=v),b=_,h&&y)t:{for(v=h,g=y,k=0,x=v;x;x=Hl(x))k++;for(x=0,_=g;_;_=Hl(_))x++;for(;0<k-x;)v=Hl(v),k--;for(;0<x-k;)g=Hl(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Hl(v),g=Hl(g)}v=null}else v=null;h!==null&&Tj(f,d,h,v,!1),y!==null&&b!==null&&Tj(f,b,y,v,!0)}}e:{if(d=u?oc(u):window,h=d.nodeName&&d.nodeName.toLowerCase(),h==="select"||h==="input"&&d.type==="file")var S=JO;else if(Nj(d))if(bE)S=eD;else{S=QO;var N=XO}else(h=d.nodeName)&&h.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(S=ZO);if(S&&(S=S(e,u))){xE(f,S,n,p);break e}N&&N(e,d,u),e==="focusout"&&(N=d._wrapperState)&&N.controlled&&d.type==="number"&&Xw(d,"number",d.value)}switch(N=u?oc(u):window,e){case"focusin":(Nj(N)||N.contentEditable==="true")&&(sc=N,cx=u,yd=null);break;case"focusout":yd=cx=sc=null;break;case"mousedown":ux=!0;break;case"contextmenu":case"mouseup":case"dragend":ux=!1,Ij(f,n,p);break;case"selectionchange":if(rD)break;case"keydown":case"keyup":Ij(f,n,p)}var P;if(ck)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else rc?yE(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(gE&&n.locale!=="ko"&&(rc||R!=="onCompositionStart"?R==="onCompositionEnd"&&rc&&(P=mE()):(Uo=p,ok="value"in Uo?Uo.value:Uo.textContent,rc=!0)),N=Bh(u,R),0<N.length&&(R=new kj(R,e,null,n,p),f.push({event:R,listeners:N}),P?R.data=P:(P=wE(n),P!==null&&(R.data=P)))),(P=KO?qO(e,n):UO(e,n))&&(u=Bh(u,"onBeforeInput"),0<u.length&&(p=new kj("onBeforeInput","beforeinput",null,n,p),f.push({event:p,listeners:u}),p.data=P))}IE(f,t)})}function Wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Bh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=$d(e,n),o!=null&&r.unshift(Wd(e,o,s)),o=$d(e,t),o!=null&&r.push(Wd(e,o,s))),e=e.return}return r}function Hl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Tj(e,t,n,r,s){for(var o=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,s?(c=$d(n,o),c!=null&&a.unshift(Wd(n,c,l))):s||(c=$d(n,o),c!=null&&a.push(Wd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var aD=/\r\n?/g,lD=/\u0000|\uFFFD/g;function Mj(e){return(typeof e=="string"?e:""+e).replace(aD,`
38
- `).replace(lD,"")}function jp(e,t,n){if(t=Mj(t),Mj(e)!==t&&n)throw Error(Ee(425))}function Wh(){}var dx=null,fx=null;function px(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var hx=typeof setTimeout=="function"?setTimeout:void 0,cD=typeof clearTimeout=="function"?clearTimeout:void 0,$j=typeof Promise=="function"?Promise:void 0,uD=typeof queueMicrotask=="function"?queueMicrotask:typeof $j<"u"?function(e){return $j.resolve(null).then(e).catch(dD)}:hx;function dD(e){setTimeout(function(){throw e})}function My(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),Dd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Dd(t)}function ea(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Lj(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var eu=Math.random().toString(36).slice(2),_i="__reactFiber$"+eu,Hd="__reactProps$"+eu,po="__reactContainer$"+eu,mx="__reactEvents$"+eu,fD="__reactListeners$"+eu,pD="__reactHandles$"+eu;function Ba(e){var t=e[_i];if(t)return t;for(var n=e.parentNode;n;){if(t=n[po]||n[_i]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Lj(e);e!==null;){if(n=e[_i])return n;e=Lj(e)}return t}e=n,n=e.parentNode}return null}function vf(e){return e=e[_i]||e[po],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function oc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ee(33))}function Um(e){return e[Hd]||null}var gx=[],ac=-1;function ya(e){return{current:e}}function yn(e){0>ac||(e.current=gx[ac],gx[ac]=null,ac--)}function cn(e,t){ac++,gx[ac]=e.current,e.current=t}var la={},Pr=ya(la),Zr=ya(!1),el=la;function Mc(e,t){var n=e.type.contextTypes;if(!n)return la;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function es(e){return e=e.childContextTypes,e!=null}function Hh(){yn(Zr),yn(Pr)}function Oj(e,t,n){if(Pr.current!==la)throw Error(Ee(168));cn(Pr,t),cn(Zr,n)}function RE(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(Ee(108,X2(e)||"Unknown",s));return Pn({},n,r)}function Vh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||la,el=Pr.current,cn(Pr,e),cn(Zr,Zr.current),!0}function Dj(e,t,n){var r=e.stateNode;if(!r)throw Error(Ee(169));n?(e=RE(e,t,el),r.__reactInternalMemoizedMergedChildContext=e,yn(Zr),yn(Pr),cn(Pr,e)):yn(Zr),cn(Zr,n)}var eo=null,Gm=!1,$y=!1;function TE(e){eo===null?eo=[e]:eo.push(e)}function hD(e){Gm=!0,TE(e)}function wa(){if(!$y&&eo!==null){$y=!0;var e=0,t=rn;try{var n=eo;for(rn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}eo=null,Gm=!1}catch(s){throw eo!==null&&(eo=eo.slice(e+1)),sE(nk,wa),s}finally{rn=t,$y=!1}}return null}var lc=[],cc=0,Kh=null,qh=0,Ps=[],Rs=0,tl=null,no=1,ro="";function Ma(e,t){lc[cc++]=qh,lc[cc++]=Kh,Kh=e,qh=t}function ME(e,t,n){Ps[Rs++]=no,Ps[Rs++]=ro,Ps[Rs++]=tl,tl=e;var r=no;e=ro;var s=32-li(r)-1;r&=~(1<<s),n+=1;var o=32-li(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,no=1<<32-li(t)+s|n<<s|r,ro=o+e}else no=1<<o|n<<s|r,ro=e}function dk(e){e.return!==null&&(Ma(e,1),ME(e,1,0))}function fk(e){for(;e===Kh;)Kh=lc[--cc],lc[cc]=null,qh=lc[--cc],lc[cc]=null;for(;e===tl;)tl=Ps[--Rs],Ps[Rs]=null,ro=Ps[--Rs],Ps[Rs]=null,no=Ps[--Rs],Ps[Rs]=null}var ms=null,ps=null,xn=!1,ri=null;function $E(e,t){var n=$s(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function Fj(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ms=e,ps=ea(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ms=e,ps=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=tl!==null?{id:no,overflow:ro}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=$s(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ms=e,ps=null,!0):!1;default:return!1}}function yx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function wx(e){if(xn){var t=ps;if(t){var n=t;if(!Fj(e,t)){if(yx(e))throw Error(Ee(418));t=ea(n.nextSibling);var r=ms;t&&Fj(e,t)?$E(r,n):(e.flags=e.flags&-4097|2,xn=!1,ms=e)}}else{if(yx(e))throw Error(Ee(418));e.flags=e.flags&-4097|2,xn=!1,ms=e}}}function zj(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ms=e}function Np(e){if(e!==ms)return!1;if(!xn)return zj(e),xn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!px(e.type,e.memoizedProps)),t&&(t=ps)){if(yx(e))throw LE(),Error(Ee(418));for(;t;)$E(e,t),t=ea(t.nextSibling)}if(zj(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ee(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ps=ea(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ps=null}}else ps=ms?ea(e.stateNode.nextSibling):null;return!0}function LE(){for(var e=ps;e;)e=ea(e.nextSibling)}function $c(){ps=ms=null,xn=!1}function pk(e){ri===null?ri=[e]:ri.push(e)}var mD=bo.ReactCurrentBatchConfig;function Bu(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Ee(309));var r=n.stateNode}if(!r)throw Error(Ee(147,e));var s=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=s.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Ee(284));if(!n._owner)throw Error(Ee(290,e))}return e}function _p(e,t){throw e=Object.prototype.toString.call(t),Error(Ee(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Bj(e){var t=e._init;return t(e._payload)}function OE(e){function t(g,k){if(e){var x=g.deletions;x===null?(g.deletions=[k],g.flags|=16):x.push(k)}}function n(g,k){if(!e)return null;for(;k!==null;)t(g,k),k=k.sibling;return null}function r(g,k){for(g=new Map;k!==null;)k.key!==null?g.set(k.key,k):g.set(k.index,k),k=k.sibling;return g}function s(g,k){return g=sa(g,k),g.index=0,g.sibling=null,g}function o(g,k,x){return g.index=x,e?(x=g.alternate,x!==null?(x=x.index,x<k?(g.flags|=2,k):x):(g.flags|=2,k)):(g.flags|=1048576,k)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,k,x,_){return k===null||k.tag!==6?(k=Wy(x,g.mode,_),k.return=g,k):(k=s(k,x),k.return=g,k)}function c(g,k,x,_){var S=x.type;return S===nc?p(g,k,x.props.children,_,x.key):k!==null&&(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Fo&&Bj(S)===k.type)?(_=s(k,x.props),_.ref=Bu(g,k,x),_.return=g,_):(_=xh(x.type,x.key,x.props,null,g.mode,_),_.ref=Bu(g,k,x),_.return=g,_)}function u(g,k,x,_){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=Hy(x,g.mode,_),k.return=g,k):(k=s(k,x.children||[]),k.return=g,k)}function p(g,k,x,_,S){return k===null||k.tag!==7?(k=Ga(x,g.mode,_,S),k.return=g,k):(k=s(k,x),k.return=g,k)}function f(g,k,x){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Wy(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case mp:return x=xh(k.type,k.key,k.props,null,g.mode,x),x.ref=Bu(g,null,k),x.return=g,x;case tc:return k=Hy(k,g.mode,x),k.return=g,k;case Fo:var _=k._init;return f(g,_(k._payload),x)}if(nd(k)||Lu(k))return k=Ga(k,g.mode,x,null),k.return=g,k;_p(g,k)}return null}function d(g,k,x,_){var S=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return S!==null?null:l(g,k,""+x,_);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case mp:return x.key===S?c(g,k,x,_):null;case tc:return x.key===S?u(g,k,x,_):null;case Fo:return S=x._init,d(g,k,S(x._payload),_)}if(nd(x)||Lu(x))return S!==null?null:p(g,k,x,_,null);_p(g,x)}return null}function h(g,k,x,_,S){if(typeof _=="string"&&_!==""||typeof _=="number")return g=g.get(x)||null,l(k,g,""+_,S);if(typeof _=="object"&&_!==null){switch(_.$$typeof){case mp:return g=g.get(_.key===null?x:_.key)||null,c(k,g,_,S);case tc:return g=g.get(_.key===null?x:_.key)||null,u(k,g,_,S);case Fo:var N=_._init;return h(g,k,x,N(_._payload),S)}if(nd(_)||Lu(_))return g=g.get(x)||null,p(k,g,_,S,null);_p(k,_)}return null}function y(g,k,x,_){for(var S=null,N=null,P=k,R=k=0,z=null;P!==null&&R<x.length;R++){P.index>R?(z=P,P=null):z=P.sibling;var E=d(g,P,x[R],_);if(E===null){P===null&&(P=z);break}e&&P&&E.alternate===null&&t(g,P),k=o(E,k,R),N===null?S=E:N.sibling=E,N=E,P=z}if(R===x.length)return n(g,P),xn&&Ma(g,R),S;if(P===null){for(;R<x.length;R++)P=f(g,x[R],_),P!==null&&(k=o(P,k,R),N===null?S=P:N.sibling=P,N=P);return xn&&Ma(g,R),S}for(P=r(g,P);R<x.length;R++)z=h(P,g,R,x[R],_),z!==null&&(e&&z.alternate!==null&&P.delete(z.key===null?R:z.key),k=o(z,k,R),N===null?S=z:N.sibling=z,N=z);return e&&P.forEach(function(O){return t(g,O)}),xn&&Ma(g,R),S}function v(g,k,x,_){var S=Lu(x);if(typeof S!="function")throw Error(Ee(150));if(x=S.call(x),x==null)throw Error(Ee(151));for(var N=S=null,P=k,R=k=0,z=null,E=x.next();P!==null&&!E.done;R++,E=x.next()){P.index>R?(z=P,P=null):z=P.sibling;var O=d(g,P,E.value,_);if(O===null){P===null&&(P=z);break}e&&P&&O.alternate===null&&t(g,P),k=o(O,k,R),N===null?S=O:N.sibling=O,N=O,P=z}if(E.done)return n(g,P),xn&&Ma(g,R),S;if(P===null){for(;!E.done;R++,E=x.next())E=f(g,E.value,_),E!==null&&(k=o(E,k,R),N===null?S=E:N.sibling=E,N=E);return xn&&Ma(g,R),S}for(P=r(g,P);!E.done;R++,E=x.next())E=h(P,g,R,E.value,_),E!==null&&(e&&E.alternate!==null&&P.delete(E.key===null?R:E.key),k=o(E,k,R),N===null?S=E:N.sibling=E,N=E);return e&&P.forEach(function(D){return t(g,D)}),xn&&Ma(g,R),S}function b(g,k,x,_){if(typeof x=="object"&&x!==null&&x.type===nc&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case mp:e:{for(var S=x.key,N=k;N!==null;){if(N.key===S){if(S=x.type,S===nc){if(N.tag===7){n(g,N.sibling),k=s(N,x.props.children),k.return=g,g=k;break e}}else if(N.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Fo&&Bj(S)===N.type){n(g,N.sibling),k=s(N,x.props),k.ref=Bu(g,N,x),k.return=g,g=k;break e}n(g,N);break}else t(g,N);N=N.sibling}x.type===nc?(k=Ga(x.props.children,g.mode,_,x.key),k.return=g,g=k):(_=xh(x.type,x.key,x.props,null,g.mode,_),_.ref=Bu(g,k,x),_.return=g,g=_)}return a(g);case tc:e:{for(N=x.key;k!==null;){if(k.key===N)if(k.tag===4&&k.stateNode.containerInfo===x.containerInfo&&k.stateNode.implementation===x.implementation){n(g,k.sibling),k=s(k,x.children||[]),k.return=g,g=k;break e}else{n(g,k);break}else t(g,k);k=k.sibling}k=Hy(x,g.mode,_),k.return=g,g=k}return a(g);case Fo:return N=x._init,b(g,k,N(x._payload),_)}if(nd(x))return y(g,k,x,_);if(Lu(x))return v(g,k,x,_);_p(g,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,k!==null&&k.tag===6?(n(g,k.sibling),k=s(k,x),k.return=g,g=k):(n(g,k),k=Wy(x,g.mode,_),k.return=g,g=k),a(g)):n(g,k)}return b}var Lc=OE(!0),DE=OE(!1),Uh=ya(null),Gh=null,uc=null,hk=null;function mk(){hk=uc=Gh=null}function gk(e){var t=Uh.current;yn(Uh),e._currentValue=t}function xx(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 Sc(e,t){Gh=e,hk=uc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Jr=!0),e.firstContext=null)}function Os(e){var t=e._currentValue;if(hk!==e)if(e={context:e,memoizedValue:t,next:null},uc===null){if(Gh===null)throw Error(Ee(308));uc=e,Gh.dependencies={lanes:0,firstContext:e}}else uc=uc.next=e;return t}var Wa=null;function yk(e){Wa===null?Wa=[e]:Wa.push(e)}function FE(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,yk(t)):(n.next=s.next,s.next=n),t.interleaved=n,ho(e,r)}function ho(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 zo=!1;function wk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function zE(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 ao(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ta(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,qt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,ho(e,n)}return s=r.interleaved,s===null?(t.next=t,yk(r)):(t.next=s.next,s.next=t),r.interleaved=t,ho(e,n)}function ph(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,rk(e,n)}}function Wj(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=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};o===null?s=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,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 Yh(e,t,n,r){var s=e.updateQueue;zo=!1;var o=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?o=u:a.next=u,a=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==a&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=s.baseState;a=0,p=u=c=null,l=o;do{var d=l.lane,h=l.eventTime;if((r&d)===d){p!==null&&(p=p.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(d=t,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){f=y.call(h,f,d);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,d=typeof y=="function"?y.call(h,f,d):y,d==null)break e;f=Pn({},f,d);break e;case 2:zo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,d=s.effects,d===null?s.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=h,c=f):p=p.next=h,a|=d;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;d=l,l=d.next,d.next=null,s.lastBaseUpdate=d,s.shared.pending=null}}while(!0);if(p===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=p,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);rl|=a,e.lanes=a,e.memoizedState=f}}function Hj(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(Ee(191,s));s.call(r)}}}var Sf={},Ti=ya(Sf),Vd=ya(Sf),Kd=ya(Sf);function Ha(e){if(e===Sf)throw Error(Ee(174));return e}function xk(e,t){switch(cn(Kd,t),cn(Vd,e),cn(Ti,Sf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Zw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Zw(t,e)}yn(Ti),cn(Ti,t)}function Oc(){yn(Ti),yn(Vd),yn(Kd)}function BE(e){Ha(Kd.current);var t=Ha(Ti.current),n=Zw(t,e.type);t!==n&&(cn(Vd,e),cn(Ti,n))}function bk(e){Vd.current===e&&(yn(Ti),yn(Vd))}var An=ya(0);function Jh(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ly=[];function kk(){for(var e=0;e<Ly.length;e++)Ly[e]._workInProgressVersionPrimary=null;Ly.length=0}var hh=bo.ReactCurrentDispatcher,Oy=bo.ReactCurrentBatchConfig,nl=0,In=null,Zn=null,cr=null,Xh=!1,wd=!1,qd=0,gD=0;function _r(){throw Error(Ee(321))}function vk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!di(e[n],t[n]))return!1;return!0}function Sk(e,t,n,r,s,o){if(nl=o,In=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,hh.current=e===null||e.memoizedState===null?bD:kD,e=n(r,s),wd){o=0;do{if(wd=!1,qd=0,25<=o)throw Error(Ee(301));o+=1,cr=Zn=null,t.updateQueue=null,hh.current=vD,e=n(r,s)}while(wd)}if(hh.current=Qh,t=Zn!==null&&Zn.next!==null,nl=0,cr=Zn=In=null,Xh=!1,t)throw Error(Ee(300));return e}function jk(){var e=qd!==0;return qd=0,e}function vi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cr===null?In.memoizedState=cr=e:cr=cr.next=e,cr}function Ds(){if(Zn===null){var e=In.alternate;e=e!==null?e.memoizedState:null}else e=Zn.next;var t=cr===null?In.memoizedState:cr.next;if(t!==null)cr=t,Zn=e;else{if(e===null)throw Error(Ee(310));Zn=e,e={memoizedState:Zn.memoizedState,baseState:Zn.baseState,baseQueue:Zn.baseQueue,queue:Zn.queue,next:null},cr===null?In.memoizedState=cr=e:cr=cr.next=e}return cr}function Ud(e,t){return typeof t=="function"?t(e):t}function Dy(e){var t=Ds(),n=t.queue;if(n===null)throw Error(Ee(311));n.lastRenderedReducer=e;var r=Zn,s=r.baseQueue,o=n.pending;if(o!==null){if(s!==null){var a=s.next;s.next=o.next,o.next=a}r.baseQueue=s=o,n.pending=null}if(s!==null){o=s.next,r=r.baseState;var l=a=null,c=null,u=o;do{var p=u.lane;if((nl&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,In.lanes|=p,rl|=p}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,di(r,t.memoizedState)||(Jr=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do o=s.lane,In.lanes|=o,rl|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Fy(e){var t=Ds(),n=t.queue;if(n===null)throw Error(Ee(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,o=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do o=e(o,a.action),a=a.next;while(a!==s);di(o,t.memoizedState)||(Jr=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function WE(){}function HE(e,t){var n=In,r=Ds(),s=t(),o=!di(r.memoizedState,s);if(o&&(r.memoizedState=s,Jr=!0),r=r.queue,Nk(qE.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||cr!==null&&cr.memoizedState.tag&1){if(n.flags|=2048,Gd(9,KE.bind(null,n,r,s,t),void 0,null),fr===null)throw Error(Ee(349));nl&30||VE(n,t,s)}return s}function VE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=In.updateQueue,t===null?(t={lastEffect:null,stores:null},In.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function KE(e,t,n,r){t.value=n,t.getSnapshot=r,UE(t)&&GE(e)}function qE(e,t,n){return n(function(){UE(t)&&GE(e)})}function UE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!di(e,n)}catch{return!0}}function GE(e){var t=ho(e,1);t!==null&&ci(t,e,1,-1)}function Vj(e){var t=vi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ud,lastRenderedState:e},t.queue=e,e=e.dispatch=xD.bind(null,In,e),[t.memoizedState,e]}function Gd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=In.updateQueue,t===null?(t={lastEffect:null,stores:null},In.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function YE(){return Ds().memoizedState}function mh(e,t,n,r){var s=vi();In.flags|=e,s.memoizedState=Gd(1|t,n,void 0,r===void 0?null:r)}function Ym(e,t,n,r){var s=Ds();r=r===void 0?null:r;var o=void 0;if(Zn!==null){var a=Zn.memoizedState;if(o=a.destroy,r!==null&&vk(r,a.deps)){s.memoizedState=Gd(t,n,o,r);return}}In.flags|=e,s.memoizedState=Gd(1|t,n,o,r)}function Kj(e,t){return mh(8390656,8,e,t)}function Nk(e,t){return Ym(2048,8,e,t)}function JE(e,t){return Ym(4,2,e,t)}function XE(e,t){return Ym(4,4,e,t)}function QE(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ZE(e,t,n){return n=n!=null?n.concat([e]):null,Ym(4,4,QE.bind(null,t,e),n)}function _k(){}function eI(e,t){var n=Ds();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&vk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function tI(e,t){var n=Ds();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&vk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function nI(e,t,n){return nl&21?(di(n,t)||(n=aE(),In.lanes|=n,rl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Jr=!0),e.memoizedState=n)}function yD(e,t){var n=rn;rn=n!==0&&4>n?n:4,e(!0);var r=Oy.transition;Oy.transition={};try{e(!1),t()}finally{rn=n,Oy.transition=r}}function rI(){return Ds().memoizedState}function wD(e,t,n){var r=ra(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},sI(e))iI(t,n);else if(n=FE(e,t,n,r),n!==null){var s=Br();ci(n,e,r,s),oI(n,t,r)}}function xD(e,t,n){var r=ra(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(sI(e))iI(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,l=o(a,n);if(s.hasEagerState=!0,s.eagerState=l,di(l,a)){var c=t.interleaved;c===null?(s.next=s,yk(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=FE(e,t,s,r),n!==null&&(s=Br(),ci(n,e,r,s),oI(n,t,r))}}function sI(e){var t=e.alternate;return e===In||t!==null&&t===In}function iI(e,t){wd=Xh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function oI(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rk(e,n)}}var Qh={readContext:Os,useCallback:_r,useContext:_r,useEffect:_r,useImperativeHandle:_r,useInsertionEffect:_r,useLayoutEffect:_r,useMemo:_r,useReducer:_r,useRef:_r,useState:_r,useDebugValue:_r,useDeferredValue:_r,useTransition:_r,useMutableSource:_r,useSyncExternalStore:_r,useId:_r,unstable_isNewReconciler:!1},bD={readContext:Os,useCallback:function(e,t){return vi().memoizedState=[e,t===void 0?null:t],e},useContext:Os,useEffect:Kj,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,mh(4194308,4,QE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return mh(4194308,4,e,t)},useInsertionEffect:function(e,t){return mh(4,2,e,t)},useMemo:function(e,t){var n=vi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=vi();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=wD.bind(null,In,e),[r.memoizedState,e]},useRef:function(e){var t=vi();return e={current:e},t.memoizedState=e},useState:Vj,useDebugValue:_k,useDeferredValue:function(e){return vi().memoizedState=e},useTransition:function(){var e=Vj(!1),t=e[0];return e=yD.bind(null,e[1]),vi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=In,s=vi();if(xn){if(n===void 0)throw Error(Ee(407));n=n()}else{if(n=t(),fr===null)throw Error(Ee(349));nl&30||VE(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Kj(qE.bind(null,r,o,e),[e]),r.flags|=2048,Gd(9,KE.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=vi(),t=fr.identifierPrefix;if(xn){var n=ro,r=no;n=(r&~(1<<32-li(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=gD++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},kD={readContext:Os,useCallback:eI,useContext:Os,useEffect:Nk,useImperativeHandle:ZE,useInsertionEffect:JE,useLayoutEffect:XE,useMemo:tI,useReducer:Dy,useRef:YE,useState:function(){return Dy(Ud)},useDebugValue:_k,useDeferredValue:function(e){var t=Ds();return nI(t,Zn.memoizedState,e)},useTransition:function(){var e=Dy(Ud)[0],t=Ds().memoizedState;return[e,t]},useMutableSource:WE,useSyncExternalStore:HE,useId:rI,unstable_isNewReconciler:!1},vD={readContext:Os,useCallback:eI,useContext:Os,useEffect:Nk,useImperativeHandle:ZE,useInsertionEffect:JE,useLayoutEffect:XE,useMemo:tI,useReducer:Fy,useRef:YE,useState:function(){return Fy(Ud)},useDebugValue:_k,useDeferredValue:function(e){var t=Ds();return Zn===null?t.memoizedState=e:nI(t,Zn.memoizedState,e)},useTransition:function(){var e=Fy(Ud)[0],t=Ds().memoizedState;return[e,t]},useMutableSource:WE,useSyncExternalStore:HE,useId:rI,unstable_isNewReconciler:!1};function ei(e,t){if(e&&e.defaultProps){t=Pn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function bx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Pn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Jm={isMounted:function(e){return(e=e._reactInternals)?yl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Br(),s=ra(e),o=ao(r,s);o.payload=t,n!=null&&(o.callback=n),t=ta(e,o,s),t!==null&&(ci(t,e,s,r),ph(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Br(),s=ra(e),o=ao(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=ta(e,o,s),t!==null&&(ci(t,e,s,r),ph(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Br(),r=ra(e),s=ao(n,r);s.tag=2,t!=null&&(s.callback=t),t=ta(e,s,r),t!==null&&(ci(t,e,r,n),ph(t,e,r))}};function qj(e,t,n,r,s,o,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,a):t.prototype&&t.prototype.isPureReactComponent?!zd(n,r)||!zd(s,o):!0}function aI(e,t,n){var r=!1,s=la,o=t.contextType;return typeof o=="object"&&o!==null?o=Os(o):(s=es(t)?el:Pr.current,r=t.contextTypes,o=(r=r!=null)?Mc(e,s):la),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Jm,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function Uj(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Jm.enqueueReplaceState(t,t.state,null)}function kx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},wk(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Os(o):(o=es(t)?el:Pr.current,s.context=Mc(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(bx(e,t,o,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Jm.enqueueReplaceState(s,s.state,null),Yh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Dc(e,t){try{var n="",r=t;do n+=J2(r),r=r.return;while(r);var s=n}catch(o){s=`
39
- Error generating stack: `+o.message+`
40
- `+o.stack}return{value:e,source:t,stack:s,digest:null}}function zy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function vx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var SD=typeof WeakMap=="function"?WeakMap:Map;function lI(e,t,n){n=ao(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){em||(em=!0,Rx=r),vx(e,t)},n}function cI(e,t,n){n=ao(-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(){vx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){vx(e,t),typeof r!="function"&&(na===null?na=new Set([this]):na.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Gj(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new SD;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=OD.bind(null,e,t,n),t.then(e,e))}function Yj(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 Jj(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=ao(-1,1),t.tag=2,ta(n,t,1))),n.lanes|=1),e)}var jD=bo.ReactCurrentOwner,Jr=!1;function zr(e,t,n,r){t.child=e===null?DE(t,null,n,r):Lc(t,e.child,n,r)}function Xj(e,t,n,r,s){n=n.render;var o=t.ref;return Sc(t,s),r=Sk(e,t,n,r,o,s),n=jk(),e!==null&&!Jr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,mo(e,t,s)):(xn&&n&&dk(t),t.flags|=1,zr(e,t,r,s),t.child)}function Qj(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!Mk(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,uI(e,t,o,r,s)):(e=xh(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&s)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:zd,n(a,r)&&e.ref===t.ref)return mo(e,t,s)}return t.flags|=1,e=sa(o,r),e.ref=t.ref,e.return=t,t.child=e}function uI(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(zd(o,r)&&e.ref===t.ref)if(Jr=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Jr=!0);else return t.lanes=e.lanes,mo(e,t,s)}return Sx(e,t,n,r,s)}function dI(e,t,n){var r=t.pendingProps,s=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},cn(fc,us),us|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,cn(fc,us),us|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,cn(fc,us),us|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,cn(fc,us),us|=r;return zr(e,t,s,n),t.child}function fI(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Sx(e,t,n,r,s){var o=es(n)?el:Pr.current;return o=Mc(t,o),Sc(t,s),n=Sk(e,t,n,r,o,s),r=jk(),e!==null&&!Jr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,mo(e,t,s)):(xn&&r&&dk(t),t.flags|=1,zr(e,t,n,s),t.child)}function Zj(e,t,n,r,s){if(es(n)){var o=!0;Vh(t)}else o=!1;if(Sc(t,s),t.stateNode===null)gh(e,t),aI(t,n,r),kx(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=n.contextType;typeof u=="object"&&u!==null?u=Os(u):(u=es(n)?el:Pr.current,u=Mc(t,u));var p=n.getDerivedStateFromProps,f=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&Uj(t,a,r,u),zo=!1;var d=t.memoizedState;a.state=d,Yh(t,r,a,s),c=t.memoizedState,l!==r||d!==c||Zr.current||zo?(typeof p=="function"&&(bx(t,n,p,r),c=t.memoizedState),(l=zo||qj(t,n,l,r,d,c,u))?(f||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=c),a.props=r,a.state=c,a.context=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,zE(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:ei(t.type,l),a.props=u,f=t.pendingProps,d=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Os(c):(c=es(n)?el:Pr.current,c=Mc(t,c));var h=n.getDerivedStateFromProps;(p=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||d!==c)&&Uj(t,a,r,c),zo=!1,d=t.memoizedState,a.state=d,Yh(t,r,a,s);var y=t.memoizedState;l!==f||d!==y||Zr.current||zo?(typeof h=="function"&&(bx(t,n,h,r),y=t.memoizedState),(u=zo||qj(t,n,u,r,d,y,c)||!1)?(p||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,y,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,y,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),a.props=r,a.state=y,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return jx(e,t,n,r,o,s)}function jx(e,t,n,r,s,o){fI(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Dj(t,n,!1),mo(e,t,o);r=t.stateNode,jD.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Lc(t,e.child,null,o),t.child=Lc(t,null,l,o)):zr(e,t,l,o),t.memoizedState=r.state,s&&Dj(t,n,!0),t.child}function pI(e){var t=e.stateNode;t.pendingContext?Oj(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Oj(e,t.context,!1),xk(e,t.containerInfo)}function eN(e,t,n,r,s){return $c(),pk(s),t.flags|=256,zr(e,t,n,r),t.child}var Nx={dehydrated:null,treeContext:null,retryLane:0};function _x(e){return{baseLanes:e,cachePool:null,transitions:null}}function hI(e,t,n){var r=t.pendingProps,s=An.current,o=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),cn(An,s&1),e===null)return wx(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=Zm(a,r,0,null),e=Ga(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=_x(n),t.memoizedState=Nx,e):Ck(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return ND(e,t,a,r,l,s,n);if(o){o=r.fallback,a=t.mode,s=e.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=sa(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=sa(l,o):(o=Ga(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?_x(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=Nx,r}return o=e.child,e=o.sibling,r=sa(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(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 Ck(e,t){return t=Zm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Cp(e,t,n,r){return r!==null&&pk(r),Lc(t,e.child,null,n),e=Ck(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ND(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=zy(Error(Ee(422))),Cp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Zm({mode:"visible",children:r.children},s,0,null),o=Ga(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Lc(t,e.child,null,a),t.child.memoizedState=_x(a),t.memoizedState=Nx,o);if(!(t.mode&1))return Cp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Ee(419)),r=zy(o,r,void 0),Cp(e,t,a,r)}if(l=(a&e.childLanes)!==0,Jr||l){if(r=fr,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:s,s!==0&&s!==o.retryLane&&(o.retryLane=s,ho(e,s),ci(r,e,s,-1))}return Tk(),r=zy(Error(Ee(421))),Cp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=DD.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ps=ea(s.nextSibling),ms=t,xn=!0,ri=null,e!==null&&(Ps[Rs++]=no,Ps[Rs++]=ro,Ps[Rs++]=tl,no=e.id,ro=e.overflow,tl=t),t=Ck(t,r.children),t.flags|=4096,t)}function tN(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),xx(e.return,t,n)}function By(e,t,n,r,s){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=s)}function mI(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(zr(e,t,r.children,n),r=An.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&tN(e,n,t);else if(e.tag===19)tN(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(cn(An,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&Jh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),By(t,!1,s,n,o);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Jh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}By(t,!0,n,null,o);break;case"together":By(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function gh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function mo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),rl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ee(153));if(t.child!==null){for(e=t.child,n=sa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function _D(e,t,n){switch(t.tag){case 3:pI(t),$c();break;case 5:BE(t);break;case 1:es(t.type)&&Vh(t);break;case 4:xk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;cn(Uh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(cn(An,An.current&1),t.flags|=128,null):n&t.child.childLanes?hI(e,t,n):(cn(An,An.current&1),e=mo(e,t,n),e!==null?e.sibling:null);cn(An,An.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return mI(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),cn(An,An.current),r)break;return null;case 22:case 23:return t.lanes=0,dI(e,t,n)}return mo(e,t,n)}var gI,Cx,yI,wI;gI=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}};Cx=function(){};yI=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Ha(Ti.current);var o=null;switch(n){case"input":s=Yw(e,s),r=Yw(e,r),o=[];break;case"select":s=Pn({},s,{value:void 0}),r=Pn({},r,{value:void 0}),o=[];break;case"textarea":s=Qw(e,s),r=Qw(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Wh)}ex(n,r);var a;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var l=s[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Td.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(l=s!=null?s[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Td.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&mn("scroll",e),o||l===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};wI=function(e,t,n,r){n!==r&&(t.flags|=4)};function Wu(e,t){if(!xn)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 Cr(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 CD(e,t,n){var r=t.pendingProps;switch(fk(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Cr(t),null;case 1:return es(t.type)&&Hh(),Cr(t),null;case 3:return r=t.stateNode,Oc(),yn(Zr),yn(Pr),kk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Np(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ri!==null&&($x(ri),ri=null))),Cx(e,t),Cr(t),null;case 5:bk(t);var s=Ha(Kd.current);if(n=t.type,e!==null&&t.stateNode!=null)yI(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ee(166));return Cr(t),null}if(e=Ha(Ti.current),Np(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[_i]=t,r[Hd]=o,e=(t.mode&1)!==0,n){case"dialog":mn("cancel",r),mn("close",r);break;case"iframe":case"object":case"embed":mn("load",r);break;case"video":case"audio":for(s=0;s<sd.length;s++)mn(sd[s],r);break;case"source":mn("error",r);break;case"img":case"image":case"link":mn("error",r),mn("load",r);break;case"details":mn("toggle",r);break;case"input":uj(r,o),mn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},mn("invalid",r);break;case"textarea":fj(r,o),mn("invalid",r)}ex(n,o),s=null;for(var a in o)if(o.hasOwnProperty(a)){var l=o[a];a==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&jp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&jp(r.textContent,l,e),s=["children",""+l]):Td.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&mn("scroll",r)}switch(n){case"input":gp(r),dj(r,o,!0);break;case"textarea":gp(r),pj(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Wh)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=qA(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/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[_i]=t,e[Hd]=r,gI(e,t,!1,!1),t.stateNode=e;e:{switch(a=tx(n,r),n){case"dialog":mn("cancel",e),mn("close",e),s=r;break;case"iframe":case"object":case"embed":mn("load",e),s=r;break;case"video":case"audio":for(s=0;s<sd.length;s++)mn(sd[s],e);s=r;break;case"source":mn("error",e),s=r;break;case"img":case"image":case"link":mn("error",e),mn("load",e),s=r;break;case"details":mn("toggle",e),s=r;break;case"input":uj(e,r),s=Yw(e,r),mn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Pn({},r,{value:void 0}),mn("invalid",e);break;case"textarea":fj(e,r),s=Qw(e,r),mn("invalid",e);break;default:s=r}ex(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?YA(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&UA(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Md(e,c):typeof c=="number"&&Md(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Td.hasOwnProperty(o)?c!=null&&o==="onScroll"&&mn("scroll",e):c!=null&&Xb(e,o,c,a))}switch(n){case"input":gp(e),dj(e,r,!1);break;case"textarea":gp(e),pj(e);break;case"option":r.value!=null&&e.setAttribute("value",""+aa(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?xc(e,!!r.multiple,o,!1):r.defaultValue!=null&&xc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Wh)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Cr(t),null;case 6:if(e&&t.stateNode!=null)wI(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ee(166));if(n=Ha(Kd.current),Ha(Ti.current),Np(t)){if(r=t.stateNode,n=t.memoizedProps,r[_i]=t,(o=r.nodeValue!==n)&&(e=ms,e!==null))switch(e.tag){case 3:jp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&jp(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[_i]=t,t.stateNode=r}return Cr(t),null;case 13:if(yn(An),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(xn&&ps!==null&&t.mode&1&&!(t.flags&128))LE(),$c(),t.flags|=98560,o=!1;else if(o=Np(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Ee(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Ee(317));o[_i]=t}else $c(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Cr(t),o=!1}else ri!==null&&($x(ri),ri=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||An.current&1?er===0&&(er=3):Tk())),t.updateQueue!==null&&(t.flags|=4),Cr(t),null);case 4:return Oc(),Cx(e,t),e===null&&Bd(t.stateNode.containerInfo),Cr(t),null;case 10:return gk(t.type._context),Cr(t),null;case 17:return es(t.type)&&Hh(),Cr(t),null;case 19:if(yn(An),o=t.memoizedState,o===null)return Cr(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Wu(o,!1);else{if(er!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Jh(e),a!==null){for(t.flags|=128,Wu(o,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,e=a.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return cn(An,An.current&1|2),t.child}e=e.sibling}o.tail!==null&&Dn()>Fc&&(t.flags|=128,r=!0,Wu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Jh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Wu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!xn)return Cr(t),null}else 2*Dn()-o.renderingStartTime>Fc&&n!==1073741824&&(t.flags|=128,r=!0,Wu(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Dn(),t.sibling=null,n=An.current,cn(An,r?n&1|2:n&1),t):(Cr(t),null);case 22:case 23:return Rk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?us&1073741824&&(Cr(t),t.subtreeFlags&6&&(t.flags|=8192)):Cr(t),null;case 24:return null;case 25:return null}throw Error(Ee(156,t.tag))}function AD(e,t){switch(fk(t),t.tag){case 1:return es(t.type)&&Hh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Oc(),yn(Zr),yn(Pr),kk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return bk(t),null;case 13:if(yn(An),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ee(340));$c()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return yn(An),null;case 4:return Oc(),null;case 10:return gk(t.type._context),null;case 22:case 23:return Rk(),null;case 24:return null;default:return null}}var Ap=!1,Ar=!1,ED=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function dc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Mn(e,t,r)}else n.current=null}function Ax(e,t,n){try{n()}catch(r){Mn(e,t,r)}}var nN=!1;function ID(e,t){if(dx=Fh,e=SE(),uk(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,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,u=0,p=0,f=e,d=null;t:for(;;){for(var h;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==o||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===e)break t;if(d===n&&++u===s&&(l=a),d===o&&++p===r&&(c=a),(h=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(fx={focusedElem:e,selectionRange:n},Fh=!1,Xe=t;Xe!==null;)if(t=Xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Xe=e;else for(;Xe!==null;){t=Xe;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,b=y.memoizedState,g=t.stateNode,k=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:ei(t.type,v),b);g.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ee(163))}}catch(_){Mn(t,t.return,_)}if(e=t.sibling,e!==null){e.return=t.return,Xe=e;break}Xe=t.return}return y=nN,nN=!1,y}function xd(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 o=s.destroy;s.destroy=void 0,o!==void 0&&Ax(t,n,o)}s=s.next}while(s!==r)}}function Xm(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 Ex(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 xI(e){var t=e.alternate;t!==null&&(e.alternate=null,xI(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_i],delete t[Hd],delete t[mx],delete t[fD],delete t[pD])),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 bI(e){return e.tag===5||e.tag===3||e.tag===4}function rN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||bI(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 Ix(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=Wh));else if(r!==4&&(e=e.child,e!==null))for(Ix(e,t,n),e=e.sibling;e!==null;)Ix(e,t,n),e=e.sibling}function Px(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(Px(e,t,n),e=e.sibling;e!==null;)Px(e,t,n),e=e.sibling}var wr=null,ti=!1;function Ro(e,t,n){for(n=n.child;n!==null;)kI(e,t,n),n=n.sibling}function kI(e,t,n){if(Ri&&typeof Ri.onCommitFiberUnmount=="function")try{Ri.onCommitFiberUnmount(Hm,n)}catch{}switch(n.tag){case 5:Ar||dc(n,t);case 6:var r=wr,s=ti;wr=null,Ro(e,t,n),wr=r,ti=s,wr!==null&&(ti?(e=wr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wr.removeChild(n.stateNode));break;case 18:wr!==null&&(ti?(e=wr,n=n.stateNode,e.nodeType===8?My(e.parentNode,n):e.nodeType===1&&My(e,n),Dd(e)):My(wr,n.stateNode));break;case 4:r=wr,s=ti,wr=n.stateNode.containerInfo,ti=!0,Ro(e,t,n),wr=r,ti=s;break;case 0:case 11:case 14:case 15:if(!Ar&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&Ax(n,t,a),s=s.next}while(s!==r)}Ro(e,t,n);break;case 1:if(!Ar&&(dc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Mn(n,t,l)}Ro(e,t,n);break;case 21:Ro(e,t,n);break;case 22:n.mode&1?(Ar=(r=Ar)||n.memoizedState!==null,Ro(e,t,n),Ar=r):Ro(e,t,n);break;default:Ro(e,t,n)}}function sN(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ED),t.forEach(function(r){var s=FD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Js(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var o=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:wr=l.stateNode,ti=!1;break e;case 3:wr=l.stateNode.containerInfo,ti=!0;break e;case 4:wr=l.stateNode.containerInfo,ti=!0;break e}l=l.return}if(wr===null)throw Error(Ee(160));kI(o,a,s),wr=null,ti=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){Mn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)vI(t,e),t=t.sibling}function vI(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Js(t,e),xi(e),r&4){try{xd(3,e,e.return),Xm(3,e)}catch(v){Mn(e,e.return,v)}try{xd(5,e,e.return)}catch(v){Mn(e,e.return,v)}}break;case 1:Js(t,e),xi(e),r&512&&n!==null&&dc(n,n.return);break;case 5:if(Js(t,e),xi(e),r&512&&n!==null&&dc(n,n.return),e.flags&32){var s=e.stateNode;try{Md(s,"")}catch(v){Mn(e,e.return,v)}}if(r&4&&(s=e.stateNode,s!=null)){var o=e.memoizedProps,a=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&VA(s,o),tx(l,a);var u=tx(l,o);for(a=0;a<c.length;a+=2){var p=c[a],f=c[a+1];p==="style"?YA(s,f):p==="dangerouslySetInnerHTML"?UA(s,f):p==="children"?Md(s,f):Xb(s,p,f,u)}switch(l){case"input":Jw(s,o);break;case"textarea":KA(s,o);break;case"select":var d=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?xc(s,!!o.multiple,h,!1):d!==!!o.multiple&&(o.defaultValue!=null?xc(s,!!o.multiple,o.defaultValue,!0):xc(s,!!o.multiple,o.multiple?[]:"",!1))}s[Hd]=o}catch(v){Mn(e,e.return,v)}}break;case 6:if(Js(t,e),xi(e),r&4){if(e.stateNode===null)throw Error(Ee(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){Mn(e,e.return,v)}}break;case 3:if(Js(t,e),xi(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Dd(t.containerInfo)}catch(v){Mn(e,e.return,v)}break;case 4:Js(t,e),xi(e);break;case 13:Js(t,e),xi(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(Ik=Dn())),r&4&&sN(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Ar=(u=Ar)||p,Js(t,e),Ar=u):Js(t,e),xi(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(Xe=e,p=e.child;p!==null;){for(f=Xe=p;Xe!==null;){switch(d=Xe,h=d.child,d.tag){case 0:case 11:case 14:case 15:xd(4,d,d.return);break;case 1:dc(d,d.return);var y=d.stateNode;if(typeof y.componentWillUnmount=="function"){r=d,n=d.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Mn(r,n,v)}}break;case 5:dc(d,d.return);break;case 22:if(d.memoizedState!==null){oN(f);continue}}h!==null?(h.return=d,Xe=h):oN(f)}p=p.sibling}e:for(p=null,f=e;;){if(f.tag===5){if(p===null){p=f;try{s=f.stateNode,u?(o=s.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=GA("display",a))}catch(v){Mn(e,e.return,v)}}}else if(f.tag===6){if(p===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(v){Mn(e,e.return,v)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;p===f&&(p=null),f=f.return}p===f&&(p=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Js(t,e),xi(e),r&4&&sN(e);break;case 21:break;default:Js(t,e),xi(e)}}function xi(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(bI(n)){var r=n;break e}n=n.return}throw Error(Ee(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Md(s,""),r.flags&=-33);var o=rN(e);Px(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=rN(e);Ix(e,l,a);break;default:throw Error(Ee(161))}}catch(c){Mn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function PD(e,t,n){Xe=e,SI(e)}function SI(e,t,n){for(var r=(e.mode&1)!==0;Xe!==null;){var s=Xe,o=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Ap;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ar;l=Ap;var u=Ar;if(Ap=a,(Ar=c)&&!u)for(Xe=s;Xe!==null;)a=Xe,c=a.child,a.tag===22&&a.memoizedState!==null?aN(s):c!==null?(c.return=a,Xe=c):aN(s);for(;o!==null;)Xe=o,SI(o),o=o.sibling;Xe=s,Ap=l,Ar=u}iN(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Xe=o):iN(e)}}function iN(e){for(;Xe!==null;){var t=Xe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Ar||Xm(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Ar)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:ei(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&Hj(t,o,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}Hj(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var f=p.dehydrated;f!==null&&Dd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ee(163))}Ar||t.flags&512&&Ex(t)}catch(d){Mn(t,t.return,d)}}if(t===e){Xe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function oN(e){for(;Xe!==null;){var t=Xe;if(t===e){Xe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function aN(e){for(;Xe!==null;){var t=Xe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Xm(4,t)}catch(c){Mn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Mn(t,s,c)}}var o=t.return;try{Ex(t)}catch(c){Mn(t,o,c)}break;case 5:var a=t.return;try{Ex(t)}catch(c){Mn(t,a,c)}}}catch(c){Mn(t,t.return,c)}if(t===e){Xe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Xe=l;break}Xe=t.return}}var RD=Math.ceil,Zh=bo.ReactCurrentDispatcher,Ak=bo.ReactCurrentOwner,Ls=bo.ReactCurrentBatchConfig,qt=0,fr=null,Kn=null,xr=0,us=0,fc=ya(0),er=0,Yd=null,rl=0,Qm=0,Ek=0,bd=null,Gr=null,Ik=0,Fc=1/0,Zi=null,em=!1,Rx=null,na=null,Ep=!1,Go=null,tm=0,kd=0,Tx=null,yh=-1,wh=0;function Br(){return qt&6?Dn():yh!==-1?yh:yh=Dn()}function ra(e){return e.mode&1?qt&2&&xr!==0?xr&-xr:mD.transition!==null?(wh===0&&(wh=aE()),wh):(e=rn,e!==0||(e=window.event,e=e===void 0?16:hE(e.type)),e):1}function ci(e,t,n,r){if(50<kd)throw kd=0,Tx=null,Error(Ee(185));bf(e,n,r),(!(qt&2)||e!==fr)&&(e===fr&&(!(qt&2)&&(Qm|=n),er===4&&Ho(e,xr)),ts(e,r),n===1&&qt===0&&!(t.mode&1)&&(Fc=Dn()+500,Gm&&wa()))}function ts(e,t){var n=e.callbackNode;mO(e,t);var r=Dh(e,e===fr?xr:0);if(r===0)n!==null&&gj(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&gj(n),t===1)e.tag===0?hD(lN.bind(null,e)):TE(lN.bind(null,e)),uD(function(){!(qt&6)&&wa()}),n=null;else{switch(lE(r)){case 1:n=nk;break;case 4:n=iE;break;case 16:n=Oh;break;case 536870912:n=oE;break;default:n=Oh}n=PI(n,jI.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function jI(e,t){if(yh=-1,wh=0,qt&6)throw Error(Ee(327));var n=e.callbackNode;if(jc()&&e.callbackNode!==n)return null;var r=Dh(e,e===fr?xr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=nm(e,r);else{t=r;var s=qt;qt|=2;var o=_I();(fr!==e||xr!==t)&&(Zi=null,Fc=Dn()+500,Ua(e,t));do try{$D();break}catch(l){NI(e,l)}while(!0);mk(),Zh.current=o,qt=s,Kn!==null?t=0:(fr=null,xr=0,t=er)}if(t!==0){if(t===2&&(s=ox(e),s!==0&&(r=s,t=Mx(e,s))),t===1)throw n=Yd,Ua(e,0),Ho(e,r),ts(e,Dn()),n;if(t===6)Ho(e,r);else{if(s=e.current.alternate,!(r&30)&&!TD(s)&&(t=nm(e,r),t===2&&(o=ox(e),o!==0&&(r=o,t=Mx(e,o))),t===1))throw n=Yd,Ua(e,0),Ho(e,r),ts(e,Dn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ee(345));case 2:$a(e,Gr,Zi);break;case 3:if(Ho(e,r),(r&130023424)===r&&(t=Ik+500-Dn(),10<t)){if(Dh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Br(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=hx($a.bind(null,e,Gr,Zi),t);break}$a(e,Gr,Zi);break;case 4:if(Ho(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-li(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=Dn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*RD(r/1960))-r,10<r){e.timeoutHandle=hx($a.bind(null,e,Gr,Zi),r);break}$a(e,Gr,Zi);break;case 5:$a(e,Gr,Zi);break;default:throw Error(Ee(329))}}}return ts(e,Dn()),e.callbackNode===n?jI.bind(null,e):null}function Mx(e,t){var n=bd;return e.current.memoizedState.isDehydrated&&(Ua(e,t).flags|=256),e=nm(e,t),e!==2&&(t=Gr,Gr=n,t!==null&&$x(t)),e}function $x(e){Gr===null?Gr=e:Gr.push.apply(Gr,e)}function TD(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],o=s.getSnapshot;s=s.value;try{if(!di(o(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ho(e,t){for(t&=~Ek,t&=~Qm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-li(t),r=1<<n;e[n]=-1,t&=~r}}function lN(e){if(qt&6)throw Error(Ee(327));jc();var t=Dh(e,0);if(!(t&1))return ts(e,Dn()),null;var n=nm(e,t);if(e.tag!==0&&n===2){var r=ox(e);r!==0&&(t=r,n=Mx(e,r))}if(n===1)throw n=Yd,Ua(e,0),Ho(e,t),ts(e,Dn()),n;if(n===6)throw Error(Ee(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,$a(e,Gr,Zi),ts(e,Dn()),null}function Pk(e,t){var n=qt;qt|=1;try{return e(t)}finally{qt=n,qt===0&&(Fc=Dn()+500,Gm&&wa())}}function sl(e){Go!==null&&Go.tag===0&&!(qt&6)&&jc();var t=qt;qt|=1;var n=Ls.transition,r=rn;try{if(Ls.transition=null,rn=1,e)return e()}finally{rn=r,Ls.transition=n,qt=t,!(qt&6)&&wa()}}function Rk(){us=fc.current,yn(fc)}function Ua(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,cD(n)),Kn!==null)for(n=Kn.return;n!==null;){var r=n;switch(fk(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Hh();break;case 3:Oc(),yn(Zr),yn(Pr),kk();break;case 5:bk(r);break;case 4:Oc();break;case 13:yn(An);break;case 19:yn(An);break;case 10:gk(r.type._context);break;case 22:case 23:Rk()}n=n.return}if(fr=e,Kn=e=sa(e.current,null),xr=us=t,er=0,Yd=null,Ek=Qm=rl=0,Gr=bd=null,Wa!==null){for(t=0;t<Wa.length;t++)if(n=Wa[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,o=n.pending;if(o!==null){var a=o.next;o.next=s,r.next=a}n.pending=r}Wa=null}return e}function NI(e,t){do{var n=Kn;try{if(mk(),hh.current=Qh,Xh){for(var r=In.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Xh=!1}if(nl=0,cr=Zn=In=null,wd=!1,qd=0,Ak.current=null,n===null||n.return===null){er=1,Yd=t,Kn=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=xr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,f=p.tag;if(!(p.mode&1)&&(f===0||f===11||f===15)){var d=p.alternate;d?(p.updateQueue=d.updateQueue,p.memoizedState=d.memoizedState,p.lanes=d.lanes):(p.updateQueue=null,p.memoizedState=null)}var h=Yj(a);if(h!==null){h.flags&=-257,Jj(h,a,l,o,t),h.mode&1&&Gj(o,u,t),t=h,c=u;var y=t.updateQueue;if(y===null){var v=new Set;v.add(c),t.updateQueue=v}else y.add(c);break e}else{if(!(t&1)){Gj(o,u,t),Tk();break e}c=Error(Ee(426))}}else if(xn&&l.mode&1){var b=Yj(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Jj(b,a,l,o,t),pk(Dc(c,l));break e}}o=c=Dc(c,l),er!==4&&(er=2),bd===null?bd=[o]:bd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=lI(o,c,t);Wj(o,g);break e;case 1:l=c;var k=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof k.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(na===null||!na.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var _=cI(o,l,t);Wj(o,_);break e}}o=o.return}while(o!==null)}AI(n)}catch(S){t=S,Kn===n&&n!==null&&(Kn=n=n.return);continue}break}while(!0)}function _I(){var e=Zh.current;return Zh.current=Qh,e===null?Qh:e}function Tk(){(er===0||er===3||er===2)&&(er=4),fr===null||!(rl&268435455)&&!(Qm&268435455)||Ho(fr,xr)}function nm(e,t){var n=qt;qt|=2;var r=_I();(fr!==e||xr!==t)&&(Zi=null,Ua(e,t));do try{MD();break}catch(s){NI(e,s)}while(!0);if(mk(),qt=n,Zh.current=r,Kn!==null)throw Error(Ee(261));return fr=null,xr=0,er}function MD(){for(;Kn!==null;)CI(Kn)}function $D(){for(;Kn!==null&&!oO();)CI(Kn)}function CI(e){var t=II(e.alternate,e,us);e.memoizedProps=e.pendingProps,t===null?AI(e):Kn=t,Ak.current=null}function AI(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=AD(n,t),n!==null){n.flags&=32767,Kn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{er=6,Kn=null;return}}else if(n=CD(n,t,us),n!==null){Kn=n;return}if(t=t.sibling,t!==null){Kn=t;return}Kn=t=e}while(t!==null);er===0&&(er=5)}function $a(e,t,n){var r=rn,s=Ls.transition;try{Ls.transition=null,rn=1,LD(e,t,n,r)}finally{Ls.transition=s,rn=r}return null}function LD(e,t,n,r){do jc();while(Go!==null);if(qt&6)throw Error(Ee(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Ee(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(gO(e,o),e===fr&&(Kn=fr=null,xr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ep||(Ep=!0,PI(Oh,function(){return jc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Ls.transition,Ls.transition=null;var a=rn;rn=1;var l=qt;qt|=4,Ak.current=null,ID(e,n),vI(n,e),nD(fx),Fh=!!dx,fx=dx=null,e.current=n,PD(n),aO(),qt=l,rn=a,Ls.transition=o}else e.current=n;if(Ep&&(Ep=!1,Go=e,tm=s),o=e.pendingLanes,o===0&&(na=null),uO(n.stateNode),ts(e,Dn()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(em)throw em=!1,e=Rx,Rx=null,e;return tm&1&&e.tag!==0&&jc(),o=e.pendingLanes,o&1?e===Tx?kd++:(kd=0,Tx=e):kd=0,wa(),null}function jc(){if(Go!==null){var e=lE(tm),t=Ls.transition,n=rn;try{if(Ls.transition=null,rn=16>e?16:e,Go===null)var r=!1;else{if(e=Go,Go=null,tm=0,qt&6)throw Error(Ee(331));var s=qt;for(qt|=4,Xe=e.current;Xe!==null;){var o=Xe,a=o.child;if(Xe.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(Xe=u;Xe!==null;){var p=Xe;switch(p.tag){case 0:case 11:case 15:xd(8,p,o)}var f=p.child;if(f!==null)f.return=p,Xe=f;else for(;Xe!==null;){p=Xe;var d=p.sibling,h=p.return;if(xI(p),p===u){Xe=null;break}if(d!==null){d.return=h,Xe=d;break}Xe=h}}}var y=o.alternate;if(y!==null){var v=y.child;if(v!==null){y.child=null;do{var b=v.sibling;v.sibling=null,v=b}while(v!==null)}}Xe=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Xe=a;else e:for(;Xe!==null;){if(o=Xe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:xd(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,Xe=g;break e}Xe=o.return}}var k=e.current;for(Xe=k;Xe!==null;){a=Xe;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Xe=x;else e:for(a=k;Xe!==null;){if(l=Xe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Xm(9,l)}}catch(S){Mn(l,l.return,S)}if(l===a){Xe=null;break e}var _=l.sibling;if(_!==null){_.return=l.return,Xe=_;break e}Xe=l.return}}if(qt=s,wa(),Ri&&typeof Ri.onPostCommitFiberRoot=="function")try{Ri.onPostCommitFiberRoot(Hm,e)}catch{}r=!0}return r}finally{rn=n,Ls.transition=t}}return!1}function cN(e,t,n){t=Dc(n,t),t=lI(e,t,1),e=ta(e,t,1),t=Br(),e!==null&&(bf(e,1,t),ts(e,t))}function Mn(e,t,n){if(e.tag===3)cN(e,e,n);else for(;t!==null;){if(t.tag===3){cN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(na===null||!na.has(r))){e=Dc(n,e),e=cI(t,e,1),t=ta(t,e,1),e=Br(),t!==null&&(bf(t,1,e),ts(t,e));break}}t=t.return}}function OD(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Br(),e.pingedLanes|=e.suspendedLanes&n,fr===e&&(xr&n)===n&&(er===4||er===3&&(xr&130023424)===xr&&500>Dn()-Ik?Ua(e,0):Ek|=n),ts(e,t)}function EI(e,t){t===0&&(e.mode&1?(t=xp,xp<<=1,!(xp&130023424)&&(xp=4194304)):t=1);var n=Br();e=ho(e,t),e!==null&&(bf(e,t,n),ts(e,n))}function DD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),EI(e,n)}function FD(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(Ee(314))}r!==null&&r.delete(t),EI(e,n)}var II;II=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Zr.current)Jr=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Jr=!1,_D(e,t,n);Jr=!!(e.flags&131072)}else Jr=!1,xn&&t.flags&1048576&&ME(t,qh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;gh(e,t),e=t.pendingProps;var s=Mc(t,Pr.current);Sc(t,n),s=Sk(null,t,r,e,s,n);var o=jk();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,es(r)?(o=!0,Vh(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,wk(t),s.updater=Jm,t.stateNode=s,s._reactInternals=t,kx(t,r,e,n),t=jx(null,t,r,!0,o,n)):(t.tag=0,xn&&o&&dk(t),zr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(gh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=BD(r),e=ei(r,e),s){case 0:t=Sx(null,t,r,e,n);break e;case 1:t=Zj(null,t,r,e,n);break e;case 11:t=Xj(null,t,r,e,n);break e;case 14:t=Qj(null,t,r,ei(r.type,e),n);break e}throw Error(Ee(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),Sx(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),Zj(e,t,r,s,n);case 3:e:{if(pI(t),e===null)throw Error(Ee(387));r=t.pendingProps,o=t.memoizedState,s=o.element,zE(e,t),Yh(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=Dc(Error(Ee(423)),t),t=eN(e,t,r,n,s);break e}else if(r!==s){s=Dc(Error(Ee(424)),t),t=eN(e,t,r,n,s);break e}else for(ps=ea(t.stateNode.containerInfo.firstChild),ms=t,xn=!0,ri=null,n=DE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if($c(),r===s){t=mo(e,t,n);break e}zr(e,t,r,n)}t=t.child}return t;case 5:return BE(t),e===null&&wx(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,px(r,s)?a=null:o!==null&&px(r,o)&&(t.flags|=32),fI(e,t),zr(e,t,a,n),t.child;case 6:return e===null&&wx(t),null;case 13:return hI(e,t,n);case 4:return xk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Lc(t,null,r,n):zr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),Xj(e,t,r,s,n);case 7:return zr(e,t,t.pendingProps,n),t.child;case 8:return zr(e,t,t.pendingProps.children,n),t.child;case 12:return zr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,a=s.value,cn(Uh,r._currentValue),r._currentValue=a,o!==null)if(di(o.value,a)){if(o.children===s.children&&!Zr.current){t=mo(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){a=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=ao(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),xx(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Ee(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),xx(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}zr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Sc(t,n),s=Os(s),r=r(s),t.flags|=1,zr(e,t,r,n),t.child;case 14:return r=t.type,s=ei(r,t.pendingProps),s=ei(r.type,s),Qj(e,t,r,s,n);case 15:return uI(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ei(r,s),gh(e,t),t.tag=1,es(r)?(e=!0,Vh(t)):e=!1,Sc(t,n),aI(t,r,s),kx(t,r,s,n),jx(null,t,r,!0,e,n);case 19:return mI(e,t,n);case 22:return dI(e,t,n)}throw Error(Ee(156,t.tag))};function PI(e,t){return sE(e,t)}function zD(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 $s(e,t,n,r){return new zD(e,t,n,r)}function Mk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function BD(e){if(typeof e=="function")return Mk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zb)return 11;if(e===ek)return 14}return 2}function sa(e,t){var n=e.alternate;return n===null?(n=$s(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 xh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")Mk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case nc:return Ga(n.children,s,o,t);case Qb:a=8,s|=8;break;case Kw:return e=$s(12,n,t,s|2),e.elementType=Kw,e.lanes=o,e;case qw:return e=$s(13,n,t,s),e.elementType=qw,e.lanes=o,e;case Uw:return e=$s(19,n,t,s),e.elementType=Uw,e.lanes=o,e;case BA:return Zm(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case FA:a=10;break e;case zA:a=9;break e;case Zb:a=11;break e;case ek:a=14;break e;case Fo:a=16,r=null;break e}throw Error(Ee(130,e==null?e:typeof e,""))}return t=$s(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Ga(e,t,n,r){return e=$s(7,e,r,t),e.lanes=n,e}function Zm(e,t,n,r){return e=$s(22,e,r,t),e.elementType=BA,e.lanes=n,e.stateNode={isHidden:!1},e}function Wy(e,t,n){return e=$s(6,e,null,t),e.lanes=n,e}function Hy(e,t,n){return t=$s(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function WD(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=Sy(0),this.expirationTimes=Sy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Sy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function $k(e,t,n,r,s,o,a,l,c){return e=new WD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=$s(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},wk(o),e}function HD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:tc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function RI(e){if(!e)return la;e=e._reactInternals;e:{if(yl(e)!==e||e.tag!==1)throw Error(Ee(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(es(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ee(171))}if(e.tag===1){var n=e.type;if(es(n))return RE(e,n,t)}return t}function TI(e,t,n,r,s,o,a,l,c){return e=$k(n,r,!0,e,s,o,a,l,c),e.context=RI(null),n=e.current,r=Br(),s=ra(n),o=ao(r,s),o.callback=t??null,ta(n,o,s),e.current.lanes=s,bf(e,s,r),ts(e,r),e}function eg(e,t,n,r){var s=t.current,o=Br(),a=ra(s);return n=RI(n),t.context===null?t.context=n:t.pendingContext=n,t=ao(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ta(s,t,a),e!==null&&(ci(e,s,a,o),ph(e,s,a)),a}function rm(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function uN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Lk(e,t){uN(e,t),(e=e.alternate)&&uN(e,t)}function VD(){return null}var MI=typeof reportError=="function"?reportError:function(e){console.error(e)};function Ok(e){this._internalRoot=e}tg.prototype.render=Ok.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ee(409));eg(e,t,null,null)};tg.prototype.unmount=Ok.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;sl(function(){eg(null,e,null,null)}),t[po]=null}};function tg(e){this._internalRoot=e}tg.prototype.unstable_scheduleHydration=function(e){if(e){var t=dE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Wo.length&&t!==0&&t<Wo[n].priority;n++);Wo.splice(n,0,e),n===0&&pE(e)}};function Dk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function ng(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function dN(){}function KD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=rm(a);o.call(u)}}var a=TI(t,r,e,0,null,!1,!1,"",dN);return e._reactRootContainer=a,e[po]=a.current,Bd(e.nodeType===8?e.parentNode:e),sl(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=rm(c);l.call(u)}}var c=$k(e,0,!1,null,null,!1,!1,"",dN);return e._reactRootContainer=c,e[po]=c.current,Bd(e.nodeType===8?e.parentNode:e),sl(function(){eg(t,c,n,r)}),c}function rg(e,t,n,r,s){var o=n._reactRootContainer;if(o){var a=o;if(typeof s=="function"){var l=s;s=function(){var c=rm(a);l.call(c)}}eg(t,a,e,s)}else a=KD(n,t,e,s,r);return rm(a)}cE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=rd(t.pendingLanes);n!==0&&(rk(t,n|1),ts(t,Dn()),!(qt&6)&&(Fc=Dn()+500,wa()))}break;case 13:sl(function(){var r=ho(e,1);if(r!==null){var s=Br();ci(r,e,1,s)}}),Lk(e,1)}};sk=function(e){if(e.tag===13){var t=ho(e,134217728);if(t!==null){var n=Br();ci(t,e,134217728,n)}Lk(e,134217728)}};uE=function(e){if(e.tag===13){var t=ra(e),n=ho(e,t);if(n!==null){var r=Br();ci(n,e,t,r)}Lk(e,t)}};dE=function(){return rn};fE=function(e,t){var n=rn;try{return rn=e,t()}finally{rn=n}};rx=function(e,t,n){switch(t){case"input":if(Jw(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=Um(r);if(!s)throw Error(Ee(90));HA(r),Jw(r,s)}}}break;case"textarea":KA(e,n);break;case"select":t=n.value,t!=null&&xc(e,!!n.multiple,t,!1)}};QA=Pk;ZA=sl;var qD={usingClientEntryPoint:!1,Events:[vf,oc,Um,JA,XA,Pk]},Hu={findFiberByHostInstance:Ba,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},UD={bundleType:Hu.bundleType,version:Hu.version,rendererPackageName:Hu.rendererPackageName,rendererConfig:Hu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:bo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=nE(e),e===null?null:e.stateNode},findFiberByHostInstance:Hu.findFiberByHostInstance||VD,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ip=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ip.isDisabled&&Ip.supportsFiber)try{Hm=Ip.inject(UD),Ri=Ip}catch{}}xs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=qD;xs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Dk(t))throw Error(Ee(200));return HD(e,t,null,n)};xs.createRoot=function(e,t){if(!Dk(e))throw Error(Ee(299));var n=!1,r="",s=MI;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=$k(e,1,!1,null,null,n,!1,r,s),e[po]=t.current,Bd(e.nodeType===8?e.parentNode:e),new Ok(t)};xs.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Ee(188)):(e=Object.keys(e).join(","),Error(Ee(268,e)));return e=nE(t),e=e===null?null:e.stateNode,e};xs.flushSync=function(e){return sl(e)};xs.hydrate=function(e,t,n){if(!ng(t))throw Error(Ee(200));return rg(null,e,t,!0,n)};xs.hydrateRoot=function(e,t,n){if(!Dk(e))throw Error(Ee(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=MI;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=TI(t,null,e,1,n??null,s,!1,o,a),e[po]=t.current,Bd(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new tg(t)};xs.render=function(e,t,n){if(!ng(t))throw Error(Ee(200));return rg(null,e,t,!1,n)};xs.unmountComponentAtNode=function(e){if(!ng(e))throw Error(Ee(40));return e._reactRootContainer?(sl(function(){rg(null,null,e,!1,function(){e._reactRootContainer=null,e[po]=null})}),!0):!1};xs.unstable_batchedUpdates=Pk;xs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!ng(n))throw Error(Ee(200));if(e==null||e._reactInternals===void 0)throw Error(Ee(38));return rg(e,t,n,!1,r)};xs.version="18.3.1-next-f1338f8080-20240426";function $I(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($I)}catch(e){console.error(e)}}$I(),$A.exports=xs;var lr=$A.exports,fN=lr;Hw.createRoot=fN.createRoot,Hw.hydrateRoot=fN.hydrateRoot;const LI=m.createContext(null);function Lx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function GD(){const e=Lx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function YD({children:e}){const[t,n]=m.useState(GD);m.useEffect(()=>{const o=()=>n(Lx(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=m.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Lx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(LI.Provider,{value:s,children:e})}function rs(){const e=m.useContext(LI);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function JD(){if(console&&console.warn){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&(t[0]=`react-i18next:: ${t[0]}`),console.warn(...t)}}const pN={};function Ox(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&pN[t[0]]||(typeof t[0]=="string"&&(pN[t[0]]=new Date),JD(...t))}const OI=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function hN(e,t,n){e.loadNamespaces(t,OI(e,n))}function mN(e,t,n,r){typeof n=="string"&&(n=[n]),n.forEach(s=>{e.options.ns.indexOf(s)<0&&e.options.ns.push(s)}),e.loadLanguages(t,OI(e,r))}function XD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],s=t.options?t.options.fallbackLng:!1,o=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(o,e)))}function QD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Ox("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,o)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,e))return!1}}):XD(e,t,n)}const ZD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,eF={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},tF=e=>eF[e],nF=e=>e.replace(ZD,tF);let Dx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:nF};function rF(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Dx={...Dx,...e}}function sF(){return Dx}let DI;function iF(e){DI=e}function oF(){return DI}const aF={type:"3rdParty",init(e){rF(e.options.react),iF(e)}},lF=m.createContext();class cF{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const uF=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function Vr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(lF)||{},o=n||r||oF();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new cF),!o){Ox("You will need to pass in an i18next instance by using initReactI18next");const x=(S,N)=>typeof N=="string"?N:N&&typeof N=="object"&&typeof N.defaultValue=="string"?N.defaultValue:Array.isArray(S)?S[S.length-1]:S,_=[x,{},!1];return _.t=x,_.i18n={},_.ready=!1,_}o.options.react&&o.options.react.wait!==void 0&&Ox("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...sF(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||s||o.options&&o.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const p=(o.isInitialized||o.initializedStoreOnce)&&u.every(x=>QD(x,o,a));function f(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[d,h]=m.useState(f);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=uF(y),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:_}=a;b.current=!0,!p&&!l&&(t.lng?mN(o,t.lng,u,()=>{b.current&&h(f)}):hN(o,u,()=>{b.current&&h(f)})),p&&v&&v!==y&&b.current&&h(f);function S(){b.current&&h(f)}return x&&o&&o.on(x,S),_&&o&&o.store.on(_,S),()=>{b.current=!1,x&&o&&x.split(" ").forEach(N=>o.off(N,S)),_&&o&&_.split(" ").forEach(N=>o.store.off(N,S))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{b.current&&!g.current&&h(f),g.current=!1},[o,c]);const k=[d,o,p];if(k.t=d,k.i18n=o,k.ready=p,p||!p&&!l)return k;throw new Promise(x=>{t.lng?mN(o,t.lng,u,()=>x()):hN(o,u,()=>x())})}const FI="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2032%2032'%20fill='none'%20role='img'%20aria-label='AgentFlow'%3e%3ctitle%3eAgentFlow%3c/title%3e%3crect%20width='32'%20height='32'%20rx='9'%20fill='%23131313'/%3e%3crect%20x='4.5'%20y='11'%20width='10.5'%20height='10'%20rx='3'%20fill='%232a2a2a'%20stroke='%237c4dff'%20stroke-width='1.2'/%3e%3cpath%20d='M15.25%2014.25C17.8%2012.2%2019.2%209.8%2022.25%209.25'%20stroke='%23cdbdff'%20stroke-width='1.65'%20stroke-linecap='round'%20/%3e%3cpath%20d='M15.25%2017.75C17.8%2019.8%2019.2%2022.2%2022.25%2022.75'%20stroke='%237c4dff'%20stroke-width='1.65'%20stroke-linecap='round'%20opacity='0.92'%20/%3e%3crect%20x='21.75'%20y='6'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%23e8deff'%20stroke-width='0.95'%20opacity='0.95'/%3e%3crect%20x='21.75'%20y='19'%20width='7.25'%20height='7'%20rx='2.25'%20fill='%23353534'%20stroke='%239ecaff'%20stroke-width='0.95'%20opacity='0.9'/%3e%3c/svg%3e",dF=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/workflows",label:"迭代",icon:"timeline"},{to:"/workspaces",label:"知识库",icon:"folder_managed"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/node-studio",label:"节点编辑器",icon:"draw"},{to:"/schedules",label:"定时任务",icon:"event_busy"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/admin/teams",label:"团队管理",icon:"groups",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],fF=[{href:"https://agentflow-hub.com",icon:"hub",labelKey:"common:links.hub"},{href:"https://docs.agentflow-hub.com",icon:"menu_book",labelKey:"common:links.docs"},{href:"https://github.com/pproject-github/agentflow",icon:"code",labelKey:"common:links.github"}];function pF(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function hF({authUser:e,onLogout:t}){const{path:n,navigate:r}=rs(),{t:s}=Vr(),[o,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),i.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[i.jsxs("div",{className:"af-brand",children:[i.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:i.jsx("img",{src:FI,alt:"",width:"36",height:"36",decoding:"async"})}),i.jsxs("div",{children:[i.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),i.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),i.jsx("nav",{className:"af-nav",children:dF.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(pF(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[i.jsx("span",{className:"material-symbols-outlined",children:l.icon}),i.jsx("span",{children:l.label||s(l.labelKey)})]},l.to))}),i.jsxs("div",{className:"af-sidebar-footer",children:[i.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[i.jsx("span",{className:"material-symbols-outlined",children:"person"}),i.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?i.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,i.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:i.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!o&&fF.map(l=>{const c=s(l.labelKey);return i.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:i.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const mF="agentflow.pipelineRecent",gF=15;function yF(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function wF(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(mF);return e?yF(e).filter(t=>t&&typeof t.flowId=="string"&&(t.flowSource==="user"||t.flowSource==="builtin"||t.flowSource==="admin"||t.flowSource==="workspace")&&t.kind==="opened"&&typeof t.at=="number"):[]}function xF(e,t){const n=e.filter(r=>r.id===t);return n.length===0||n.some(r=>(r.source??"user")==="user")?"user":n.some(r=>r.source==="workspace")?"workspace":n.some(r=>r.source==="admin")?"admin":n.some(r=>r.source==="builtin")?"builtin":n[0].source??"user"}function gN(e,t){const n=Date.now(),r=Math.max(0,n-e),s=Math.floor(r/1e3);if(s<60)return t("flow:time.justNow");const o=Math.floor(s/60);if(o<60)return t("flow:time.minutesAgo",{n:o});const a=Math.floor(o/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const p=Math.floor(a/24);return p<7?t("flow:time.daysAgo",{n:p}):`${l.getMonth()+1}/${l.getDate()}`}function bF(e,t,n){const r=[];for(const s of e)!s||typeof s.flowId!="string"||typeof s.at!="number"||r.push({flowId:s.flowId,flowSource:xF(n,s.flowId),kind:"executed",at:s.at});for(const s of t)r.push({flowId:s.flowId,flowSource:s.flowSource,kind:"opened",at:s.at});return r.sort((s,o)=>o.at-s.at),r.slice(0,gF)}var ds=Uint8Array,pc=Uint16Array,kF=Int32Array,zI=new ds([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),BI=new ds([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),vF=new ds([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),WI=function(e,t){for(var n=new pc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new kF(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)s[o]=o-n[r]<<5|r;return{b:n,r:s}},HI=WI(zI,2),VI=HI.b,SF=HI.r;VI[28]=258,SF[258]=28;var jF=WI(BI,0),NF=jF.b,Fx=new pc(32768);for(var gn=0;gn<32768;++gn){var To=(gn&43690)>>1|(gn&21845)<<1;To=(To&52428)>>2|(To&13107)<<2,To=(To&61680)>>4|(To&3855)<<4,Fx[gn]=((To&65280)>>8|(To&255)<<8)>>1}var vd=function(e,t,n){for(var r=e.length,s=0,o=new pc(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new pc(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new pc(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],p=t-e[s],f=a[e[s]-1]++<<p,d=f|(1<<p)-1;f<=d;++f)l[Fx[f]>>c]=u}else for(l=new pc(r),s=0;s<r;++s)e[s]&&(l[s]=Fx[a[e[s]-1]++]>>15-e[s]);return l},jf=new ds(288);for(var gn=0;gn<144;++gn)jf[gn]=8;for(var gn=144;gn<256;++gn)jf[gn]=9;for(var gn=256;gn<280;++gn)jf[gn]=7;for(var gn=280;gn<288;++gn)jf[gn]=8;var KI=new ds(32);for(var gn=0;gn<32;++gn)KI[gn]=5;var _F=vd(jf,9,1),CF=vd(KI,5,1),Vy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Xs=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Ky=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},AF=function(e){return(e+7)/8|0},Fk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new ds(e.subarray(t,n))},EF=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Is=function(e,t,n){var r=new Error(t||EF[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Is),!n)throw r;return r},IF=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new ds(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new ds(s*3));var u=function(ue){var de=n.length;if(ue>de){var pe=new ds(Math.max(de*2,ue));pe.set(n),n=pe}},p=t.f||0,f=t.p||0,d=t.b||0,h=t.l,y=t.d,v=t.m,b=t.n,g=s*8;do{if(!h){p=Xs(e,f,1);var k=Xs(e,f+1,3);if(f+=3,k)if(k==1)h=_F,y=CF,v=9,b=5;else if(k==2){var N=Xs(e,f,31)+257,P=Xs(e,f+10,15)+4,R=N+Xs(e,f+5,31)+1;f+=14;for(var z=new ds(R),E=new ds(19),O=0;O<P;++O)E[vF[O]]=Xs(e,f+O*3,7);f+=P*3;for(var D=Vy(E),L=(1<<D)-1,M=vd(E,D,1),O=0;O<R;){var V=M[Xs(e,f,L)];f+=V&15;var x=V>>4;if(x<16)z[O++]=x;else{var B=0,F=0;for(x==16?(F=3+Xs(e,f,3),f+=2,B=z[O-1]):x==17?(F=3+Xs(e,f,7),f+=3):x==18&&(F=11+Xs(e,f,127),f+=7);F--;)z[O++]=B}}var $=z.subarray(0,N),H=z.subarray(N);v=Vy($),b=Vy(H),h=vd($,v,1),y=vd(H,b,1)}else Is(1);else{var x=AF(f)+4,_=e[x-4]|e[x-3]<<8,S=x+_;if(S>s){c&&Is(0);break}l&&u(d+_),n.set(e.subarray(x,S),d),t.b=d+=_,t.p=f=S*8,t.f=p;continue}if(f>g){c&&Is(0);break}}l&&u(d+131072);for(var A=(1<<v)-1,Q=(1<<b)-1,K=f;;K=f){var B=h[Ky(e,f)&A],W=B>>4;if(f+=B&15,f>g){c&&Is(0);break}if(B||Is(2),W<256)n[d++]=W;else if(W==256){K=f,h=null;break}else{var te=W-254;if(W>264){var O=W-257,Z=zI[O];te=Xs(e,f,(1<<Z)-1)+VI[O],f+=Z}var G=y[Ky(e,f)&Q],ne=G>>4;G||Is(3),f+=G&15;var H=NF[ne];if(ne>3){var Z=BI[ne];H+=Ky(e,f)&(1<<Z)-1,f+=Z}if(f>g){c&&Is(0);break}l&&u(d+131072);var re=d+te;if(d<H){var se=o-H,ee=Math.min(H,re);for(se+d<0&&Is(3);d<ee;++d)n[d]=r[se+d]}for(;d<re;++d)n[d]=n[d-H]}}t.l=h,t.p=K,t.b=d,t.f=p,h&&(p=1,t.m=v,t.d=y,t.n=b)}while(!p);return d!=n.length&&a?Fk(n,0,d):n.subarray(0,d)},PF=new ds(0),Ci=function(e,t){return e[t]|e[t+1]<<8},si=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},qy=function(e,t){return si(e,t)+si(e,t+4)*4294967296};function RF(e,t){return IF(e,{i:2},t&&t.out,t&&t.dictionary)}var zx=typeof TextDecoder<"u"&&new TextDecoder,TF=0;try{zx.decode(PF,{stream:!0}),TF=1}catch{}var MF=function(e){for(var t="",n=0;;){var r=e[n++],s=(r>127)+(r>223)+(r>239);if(n+s>e.length)return{s:t,r:Fk(e,n-1)};s?s==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):s&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function $F(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else{if(zx)return zx.decode(e);var s=MF(e),o=s.s,n=s.r;return n.length&&Is(8),o}}var LF=function(e,t){return t+30+Ci(e,t+26)+Ci(e,t+28)},OF=function(e,t,n){var r=Ci(e,t+28),s=$F(e.subarray(t+46,t+46+r),!(Ci(e,t+8)&2048)),o=t+46+r,a=si(e,t+20),l=n&&a==4294967295?DF(e,o):[a,si(e,t+24),si(e,t+42)],c=l[0],u=l[1],p=l[2];return[Ci(e,t+10),c,u,s,o+Ci(e,t+30)+Ci(e,t+32),p]},DF=function(e,t){for(;Ci(e,t)!=1;t+=4+Ci(e,t+2));return[qy(e,t+12),qy(e,t+4),qy(e,t+20)]};function FF(e,t){for(var n={},r=e.length-22;si(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Is(13);var s=Ci(e,r+8);if(!s)return{};var o=si(e,r+16),a=o==4294967295||s==65535;if(a){var l=si(e,r-12);a=si(e,l)==101075792,a&&(s=si(e,l+32),o=si(e,l+48))}for(var c=0;c<s;++c){var u=OF(e,o,a),p=u[0],f=u[1],d=u[2],h=u[3],y=u[4],v=u[5],b=LF(e,v);o=y,p?p==8?n[h]=RF(e.subarray(b,b+f),{out:new ds(d)}):Is(14,"unknown compression type "+p):n[h]=Fk(e,b,b+f)}return n}const zF=8*1024*1024,BF=500;function WF(e){if(e==null||typeof e!="string")return null;let t=e.replace(/\\/g,"/").replace(/^\uFEFF/,"");for(;t.startsWith("/");)t=t.slice(1);if(!t||t.includes("\0")||/^[a-zA-Z]:/.test(t))return null;const n=t.split("/").filter(r=>r.length>0);for(const r of n)if(r==="."||r==="..")return null;return n.join("/")}function HF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function VF(e){const t=e.toLowerCase();if(t==="flow.yaml"||t==="flow.yml")return"";const n="/flow.yaml",r="/flow.yml";let s=null;if(t.endsWith(n))s=e.slice(0,-n.length);else if(t.endsWith(r))s=e.slice(0,-r.length);else return null;return s.includes("/")?null:s}const KF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function qF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=FF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const p=WF(c);if(!p||HF(p))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>zF||(o+=1,o>BF))return null;r.set(p,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=VF(c);u!==null&&a.add(u)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const c of r.keys())if(!(c===l||c.startsWith(`${l}/`)))return null;return KF.test(l)?l:null}catch{return null}}const Uy=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function UF({file:e,onClose:t,onImported:n}){const{t:r}=Vr(),s=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,p]=m.useState("user"),[f,d]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),g=v??e;m.useEffect(()=>{const S=requestAnimationFrame(()=>{var N;return(N=o.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(S)},[]),m.useEffect(()=>{let S=!1;return(async()=>{const N=g.name||"",P=N.toLowerCase();let R="";if(P.endsWith(".zip")){if(R=await qF(g)||"",!R){const z=N.replace(/\.zip$/i,"");Uy.test(z)&&(R=z)}}else if(P.endsWith(".yaml")||P.endsWith(".yml")){const z=N.replace(/\.ya?ml$/i,"");Uy.test(z)&&(R=z)}S||c(R)})(),()=>{S=!0}},[g]);const k=l.trim(),x=k.length>0&&Uy.test(k);async function _(S){if(S.preventDefault(),!(!x||f)){d(!0),y("");try{const N=new FormData;N.set("flowId",k),N.set("targetSpace",u),N.set("file",g,g.name);const P=await fetch("/api/flows/import",{method:"POST",body:N}),R=await P.json().catch(()=>({}));if(!P.ok){y(typeof R.error=="string"?R.error:r("project:importModal.importFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(N){y(String((N==null?void 0:N.message)||N))}finally{d(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:S=>{S.target===S.currentTarget&&t()},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:S=>S.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:_,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:g.name})}),i.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:S=>{var P;const N=(P=S.target.files)==null?void 0:P[0];N&&b(N),S.target.value=""}}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:S=>c(S.target.value),"aria-invalid":k.length>0&&!x}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),i.jsx("div",{className:"af-import-repick",children:i.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var S;return(S=a.current)==null?void 0:S.click()},children:r("project:importModal.changeFile")})}),h?i.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const GF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,yN="af:newPipelineGuide";function YF({open:e,onClose:t,onCreated:n}){const{t:r}=Vr(),s=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState("user"),[d,h]=m.useState(!1),[y,v]=m.useState(""),[b,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),h(!1),localStorage.getItem(yN)==="true"&&g(!0);const P=requestAnimationFrame(()=>{var R;return(R=o.current)==null?void 0:R.focus()});return()=>cancelAnimationFrame(P)},[e]);const k=()=>{localStorage.removeItem(yN),g(!1)};if(!e)return null;const x=a.trim(),_=x.length>0&&GF.test(x);async function S(N){if(N.preventDefault(),!(!_||d)){h(!0),v(""),k();try{const P=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:p})}),R=await P.json().catch(()=>({}));if(!P.ok){v(typeof R.error=="string"?R.error:r("project:newPipelineModal.createFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(P){v(String((P==null?void 0:P.message)||P))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&(k(),t())},children:i.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:N=>N.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),b?i.jsx("div",{className:"af-new-pipeline-guide",children:i.jsxs("div",{className:"af-new-pipeline-guide-content",children:[i.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),i.jsxs("div",{className:"af-new-pipeline-guide-text",children:[i.jsx("p",{children:i.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),i.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),i.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:k,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:S,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),i.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:N=>l(N.target.value),"aria-invalid":x.length>0&&!_}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(b?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(b?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:N=>u(N.target.value)}),b?i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),y?i.jsx("p",{className:"af-err af-new-pipeline-err",children:y}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:d,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!_||d,children:r(d?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const qI="agentflow.pipelineViewPreference";function UI(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function GI(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(qI)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function JF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(qI,JSON.stringify(e))}catch{}}function zk(e){return e==="display"?"display":"workspace"}function XF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function YI(e,t){const n=zk(t);return n==="pipeline"&&XF(e==null?void 0:e.source)?"workspace":n}function QF(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function ZF(e,t,n,r=!1){if(!e)return;const s=GI();s[UI(e,t,r)]={view:zk(n),at:Date.now()},JF(s)}function ez(e,t="workspace"){if(!(e!=null&&e.id))return zk(t);const r=GI()[UI(e.id,e.source??"user",!!e.archived)],s=YI(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!QF(e)?"workspace":s}function tz(e,t="workspace"){var s;const n=YI(e,t);if(!(e!=null&&e.id))return n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return(s=e.collaboration)!=null&&s.id&&r.set("workspaceId",e.collaboration.id),e.archived&&r.set("archived","1"),n==="display"&&r.set("view","display"),`/workspace?${r.toString()}`}function Pp(e,t="workspace"){return tz(e,ez(e,t))}function nz(e,t){const n=String(e||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),r=String(t||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),s=Math.max(n.length,r.length);for(let o=0;o<s;o+=1){const a=Number.isFinite(n[o])?n[o]:0,l=Number.isFinite(r[o])?r[o]:0;if(a!==l)return a>l?1:-1}return 0}function Bx(e){return String((e==null?void 0:e.version)||"").trim()}function rz(e){const t=Bx(e),n=[(e==null?void 0:e.agent)||"codex",(e==null?void 0:e.kind)||"skill"];return t&&n.push(`v${t}`),n.join(" · ")}function sz({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,o]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState("keyword"),[d,h]=m.useState([]),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(""),N=m.useCallback(async()=>{x("");try{const[D,L]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),M=await D.json().catch(()=>({}));D.ok&&r({available:!!M.available,version:typeof M.version=="string"?M.version:"",loggedIn:!!M.loggedIn,user:typeof M.user=="string"?M.user:"",error:typeof M.error=="string"?M.error:""});const V=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+L.status);o(Array.isArray(V.skills)?V.skills:[]),l(typeof V.skillsRoot=="string"?V.skillsRoot:""),v({})}catch(D){x(String(D.message||D))}},[]);m.useEffect(()=>{N()},[N]);const P=m.useCallback(async()=>{const D=c.trim();if(D){g("search"),x(""),S("");try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(p)}`),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+L.status);h(Array.isArray(M.items)?M.items:[])}catch(L){x(String(L.message||L))}finally{g("")}}},[c,p]),R=m.useCallback(async(D,L=!1)=>{if(!t)return;const M=D&&typeof D=="object"?D:null,V=String(M?M.slug||M.name||M.collection||M.skillId||M.id:D||"").trim();if(V){g(`install:${V}`),x(""),S("");try{const B=M?{slug:M.slug||"",skillId:M.skillId||"",collection:M.collection||"",collectionName:M.collection&&M.name||"",target:"agentflow",agent:"codex",force:L}:{slug:V,target:"agentflow",agent:"codex",force:L},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);S(L?`已更新 ${V}`:`已安装 ${V}`),await N(),typeof e=="function"&&await e()}catch(B){x(String(B.message||B))}finally{g("")}}},[t,N,e]),z=m.useCallback(async()=>{if(t&&s.length!==0){g("check-updates"),x(""),S("");try{const D=await Promise.all(s.map(async V=>{const B=String(V.name||"").trim();if(!B)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(B)}&mode=keyword`),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);const H=Array.isArray($.items)?$.items:[],A=H.find(te=>te.slug===B||te.name===B||te.id===B)||H[0],Q=Bx(V),K=String((A==null?void 0:A.version)||"").trim();let W="unknown";return A?Q&&K?W=nz(Q,K)<0?"update":"current":K&&(W="remote-only"):W="missing",[B,{state:W,latestVersion:K,installedVersion:Q,summary:(A==null?void 0:A.summary)||""}]}catch(F){return[B,{state:"error",error:String(F.message||F),installedVersion:Bx(V)}]}})),L={};for(const V of D)V&&(L[V[0]]=V[1]);v(L);const M=Object.values(L).filter(V=>V.state==="update").length;S(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,s]),E=m.useCallback(async D=>{if(!t)return;const L=String(D||"").trim();if(L){g(`uninstall:${L}`),x(""),S("");try{const M=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:L,target:"agentflow",agent:"codex"})}),V=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+M.status);S(`已卸载 ${L}`),await N(),typeof e=="function"&&await e()}catch(M){x(String(M.message||M))}finally{g("")}}},[t,N,e]),O=m.useCallback(async()=>{if(t){g("update-cli"),x(""),S("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),L=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+D.status);S("SkillHub CLI 已更新"),await N()}catch(D){x(String(D.message||D))}finally{g("")}}},[t,N]);return i.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",i.jsx("code",{children:a})]}):null]}),i.jsxs("div",{className:"af-set-skillhub-head-actions",children:[i.jsxs("div",{className:"af-set-skillhub-status",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),i.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),i.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),i.jsxs("div",{className:"af-set-skillhub-toolbar",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:!!b,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:!t||!!b||s.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:!t||!!b,children:b==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),i.jsxs("div",{className:"af-set-skillhub-search",children:[i.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:p,onChange:D=>{f(D.target.value),h([])},children:[i.jsx("option",{value:"keyword",children:"关键词"}),i.jsx("option",{value:"skillId",children:"Skill ID"}),i.jsx("option",{value:"collectionId",children:"Collection ID"})]}),i.jsx("input",{className:"af-set-input af-set-input--sm",value:c,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&P()},placeholder:p==="collectionId"?"输入 collection id,例如 1":p==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>P(),disabled:!c.trim()||b==="search",children:[i.jsx("span",{className:"material-symbols-outlined",children:"search"}),b==="search"?"搜索中…":"搜索"]})]}),k?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:k}):null,_?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:_}):null,i.jsxs("div",{className:"af-set-skillhub-grid",children:[i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"已安装"}),i.jsx("span",{children:s.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:s.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):s.map(D=>{const L=y[D.name],M=!L||L.state==="update"||L.state==="remote-only"||L.state==="unknown"||L.state==="error",V=b===`install:${D.name}`?"更新中…":(L==null?void 0:L.state)==="current"?"已最新":(L==null?void 0:L.state)==="update"&&L.latestVersion?`更新到 v${L.latestVersion}`:(L==null?void 0:L.state)==="remote-only"&&L.latestVersion?`安装 v${L.latestVersion}`:"重装";return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:D.displayName||D.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:rz(D)}),i.jsx("div",{className:"af-set-skillhub-version-row",children:L?L.state==="update"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",L.installedVersion?`v${L.installedVersion} -> `:"","v",L.latestVersion]}):L.state==="current"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",L.latestVersion||L.installedVersion]}):L.state==="remote-only"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",L.latestVersion,",本地版本未知"]}):L.state==="missing"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):L.state==="error"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),i.jsxs("div",{className:"af-set-skillhub-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>R(D.name,!0),disabled:!t||!!b||!M,children:V}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>E(D.name),disabled:!t||!!b,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.name}`)})})]}),i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"搜索结果"}),i.jsx("span",{children:d.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(D=>{const L=D.slug||D.name,M=D.kind==="collection"||D.collection,V=!M&&s.some(B=>B.name===L||B.name===D.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:D.name||L}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${D.collection}`:L,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),i.jsx("button",{type:"button",className:V?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>R(D,V),disabled:!t||!!b,children:V?"更新":M?"安装合集":"安装"})]},D.id||L)})})]})]})]})}function Ya(e){return(Array.isArray(e==null?void 0:e.collections)?e.collections:[]).filter(n=>n&&typeof n=="object").map(n=>({id:String(n.id||n.name||"").trim(),name:String(n.name||n.id||"").trim(),skillKeys:Array.from(new Set((Array.isArray(n.skillKeys)?n.skillKeys:[]).map(r=>String(r||"").trim()).filter(Boolean))),builtin:!!n.builtin,createdAt:Number.isFinite(n.createdAt)?Number(n.createdAt):Date.now(),updatedAt:Number.isFinite(n.updatedAt)?Number(n.updatedAt):Date.now()})).filter(n=>n.id&&n.name)}function iz(e){return{version:1,collections:Ya({collections:e})}}function oz(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function JI(e){const t=new Map,n=new Map;for(const r of Array.isArray(e)?e:[])r!=null&&r.key&&t.set(r.key,r.key),r!=null&&r.name&&(r!=null&&r.key)&&!n.has(r.name)&&n.set(r.name,r.key);return r=>{const s=String(r||"").trim();return s&&(t.get(s)||n.get(oz(s)))||""}}function ca(e,t){const n=JI(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function az(e,t){const n=new Set(Array.isArray(e)?e:[]);for(const r of Array.isArray(t)?t:[])r&&n.add(r);return Array.from(n)}function lz(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function cz(e,t,n){const r=ca(e,n);if(r.length===0)return"empty";const s=r.filter(o=>t.has(o)).length;return s===0?"none":s===r.length?"all":"partial"}function uz(e,t,n){const r=String(e).trim().toLowerCase(),s=Ya({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return ca(s,t)}function dz(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Ya({collections:r}),l=uz(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const p=JSON.parse(u);if(Array.isArray(p)){const f=JI(n),d=Array.from(new Set(p.map(f).filter(Boolean)));if(s.length>0&&d.length===s.length)return c;const h=new Set(d),y=new Set(l),v=l.length>0&&l.every(g=>h.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=ca(g,n);return k.length>0&&k.every(x=>h.has(x))});return l.length>0&&b&&!v?c:d}}}catch{}return c}function Vl(e){return e==="builtin"?"af-proj-badge af-proj-badge--builtin":e==="secondary"?"af-proj-badge af-proj-badge--secondary":e==="primary"?"af-proj-badge af-proj-badge--primary":e==="muted"?"af-proj-badge af-proj-badge--muted":"af-proj-badge"}function fz(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function pz(e){return e==="executed"?"material-symbols-outlined af-act-icon af-act-icon--executed":"material-symbols-outlined af-act-icon af-act-icon--opened"}function Wx(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function XI(e){var n;if((n=e.collaboration)!=null&&n.role&&e.collaboration.role!=="owner")return`共享 Project / ${e.collaboration.ownerUsername||e.collaboration.ownerId} / ${e.id}`;const t=e.source??"user";return t==="builtin"?`builtin/pipelines / ${e.id}`:t==="admin"?`admin builtin / ${e.ownerUserId||"-"} / ${e.id}`:t==="workspace"?e.archived?`.workspace/agentflow/pipelines/_archived / ${e.id}`:`.workspace/agentflow/pipelines / ${e.id}`:e.archived?`~/agentflow/pipelines/_archived / ${e.id}`:`~/agentflow/pipelines / ${e.id}`}const hz="project:defaultCardDesc";function QI(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(hz)}function mz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ln({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return i.jsx("span",{className:t,children:s});const o=new RegExp(`(${mz(r)})`,"gi"),a=s.split(o);return i.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?i.jsx("mark",{className:"af-search-hit",children:l},c):i.jsx("span",{children:l},c))})}function gz(e,t,n){const r=[String(e.id),QI(e,n),XI(e),Wx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function yz(e,t,n){return t?gz(e,t,n).includes(t):!0}function wz(e,t){const n=e.trim().toLowerCase();if(!n)return!0;const r=String(t.flowId).toLowerCase(),s=String(t.flowSource??"user").toLowerCase();return r.includes(n)||s.includes(n)}function Gy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function wN(e,t){return e==="flow"?t("project:resourceSource.flow"):e==="marketplace"?t("project:resourceSource.marketplace"):e==="project"?t("project:resourceSource.global"):e||t("project:resourceSource.global")}function xN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const xz=["all","agent","control","provide","marketplace"],bz=["all","agent","control","provide"],ZI="agentflow.projects.activityPanelOpen",Hx="agentflow.projects.activitySelected",eP="agentflow.projects.scopeView";function kz(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(eP)==="team"?"team":"personal"}catch{return"personal"}}function vz(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(ZI);return e!=="0"}function bN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function Sz(){return typeof localStorage>"u"?"":localStorage.getItem(Hx)||""}function Rp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function On(e){return(e==null?void 0:e.key)||`${(e==null?void 0:e.id)||(e==null?void 0:e.name)||""}:${(e==null?void 0:e.source)||""}:${(e==null?void 0:e.packageId)||""}`}function jz(e,t){if((e==null?void 0:e.source)!=="marketplace")return!1;const n=String((e==null?void 0:e.ownerUserId)||(e==null?void 0:e.createdBy)||"").trim();return n?new Set([String((t==null?void 0:t.userId)||"").trim(),String((t==null?void 0:t.username)||"").trim()].filter(Boolean)).has(n):!0}function Mo(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function tP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.instances;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):t&&typeof t=="object"?Object.entries(t).map(([r,s])=>({...s&&typeof s=="object"?s:{},instanceId:(s==null?void 0:s.instanceId)||r})):[]}function nP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.edges;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):[]}function Vx(e,t){return String((e==null?void 0:e.instanceId)||(e==null?void 0:e.id)||(e==null?void 0:e.nodeId)||`node_${t+1}`)}function kN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Vx(e,t))}function Nz(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function vN(e,t){return String(t==="source"?(e==null?void 0:e.source)||(e==null?void 0:e.from)||(e==null?void 0:e.sourceId)||(e==null?void 0:e.fromNode)||(e==null?void 0:e.fromInstanceId)||"":(e==null?void 0:e.target)||(e==null?void 0:e.to)||(e==null?void 0:e.targetId)||(e==null?void 0:e.toNode)||(e==null?void 0:e.toInstanceId)||"")}function _z(e){const t=(e==null?void 0:e.sourceHandle)||(e==null?void 0:e.fromHandle)||(e==null?void 0:e.output)||(e==null?void 0:e.outputName),n=(e==null?void 0:e.targetHandle)||(e==null?void 0:e.toHandle)||(e==null?void 0:e.input)||(e==null?void 0:e.inputName);return t&&n?`${t} -> ${n}`:String(t||n||"")}function Yy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Cz(e){const t=Number(e==null?void 0:e.x),n=Number(e==null?void 0:e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}function Az(e,t){const n=e.map(p=>p.id),r=new Set(n),s=new Map(n.map(p=>[p,0])),o=new Map(n.map(p=>[p,[]]));t.forEach(p=>{var f;!r.has(p.sourceId)||!r.has(p.targetId)||(s.set(p.targetId,(s.get(p.targetId)||0)+1),(f=o.get(p.sourceId))==null||f.push(p.targetId))});const a=new Map,l=n.filter(p=>(s.get(p)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(p=>a.set(p,0));for(let p=0;p<l.length;p+=1){const f=l[p],d=(a.get(f)||0)+1;for(const h of o.get(f)||[])(!a.has(h)||d>a.get(h))&&(a.set(h,d),l.push(h))}n.forEach((p,f)=>{a.has(p)||a.set(p,f%3)});const c=new Map,u=new Map;return n.forEach(p=>{const f=a.get(p)||0,d=c.get(f)||0;c.set(f,d+1),u.set(p,{x:f*190,y:d*86})}),u}function Ez(e){var v,b,g,k;const t=tP(e),n=nP(e),r=new Map(t.map((x,_)=>[Vx(x,_),kN(x,_)])),s=t.map((x,_)=>({id:Vx(x,_),title:kN(x,_),meta:Nz(x)})),o=n.map((x,_)=>{const S=vN(x,"source"),N=vN(x,"target");return{key:(x==null?void 0:x.id)||`${S}-${N}-${_}`,sourceId:S,targetId:N,source:r.get(S)||S||"?",target:r.get(N)||N||"?",label:_z(x)}}),a=(b=(v=e==null?void 0:e.snippet)==null?void 0:v.ui)!=null&&b.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(k=(g=e==null?void 0:e.snippet)==null?void 0:g.ui)!=null&&k.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=Az(s,o),u=s.map(x=>{const _=Cz(a[x.id])||c.get(x.id)||{x:0,y:0},S=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},N=Number(S.width),P=Number(S.height),R=Math.max(132,Math.min(210,Number.isFinite(N)?N*.62:150)),z=Math.max(48,Math.min(76,Number.isFinite(P)?P*.46:54));return{...x,x:_.x,y:_.y,width:R,height:z}}),p=new Map(u.map(x=>[x.id,x])),f=o.map(x=>{const _=p.get(x.sourceId),S=p.get(x.targetId);if(!_||!S)return null;const N=_.x+_.width,P=_.y+_.height/2,R=S.x,z=S.y+S.height/2,E=Math.max(48,Math.abs(R-N)*.45);return{...x,path:`M ${N} ${P} C ${N+E} ${P}, ${R-E} ${z}, ${R} ${z}`,labelX:(N+R)/2,labelY:(P+z)/2}}).filter(Boolean),d=u.reduce((x,_)=>({minX:Math.min(x.minX,_.x),minY:Math.min(x.minY,_.y),maxX:Math.max(x.maxX,_.x+_.width),maxY:Math.max(x.maxY,_.y+_.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,y=`${d.minX-h} ${d.minY-h} ${Math.max(360,d.maxX-d.minX+h*2)} ${Math.max(180,d.maxY-d.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Kl({resourceKind:e="",authUser:t=null}){var Rt,Qt,pn,$n,vs,Ss;const{t:n}=Vr(),{navigate:r,path:s}=rs(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[p,f]=m.useState(kz),[d,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState([]),[k,x]=m.useState([]),[_,S]=m.useState(""),[N,P]=m.useState(!1),[R,z]=m.useState([]),[E,O]=m.useState(""),[D,L]=m.useState(""),[M,V]=m.useState(!1),[B,F]=m.useState(!1),[$,H]=m.useState(!1),[A,Q]=m.useState(null),[K,W]=m.useState(!1),[te,Z]=m.useState(""),[G,ne]=m.useState(vz),[re,se]=m.useState(Sz),[ee,ue]=m.useState("all"),[de,pe]=m.useState(""),[Me,Ne]=m.useState("overview"),[_e,He]=m.useState({}),[ct,yt]=m.useState(""),[Re,at]=m.useState({}),[kt,$t]=m.useState(""),[ye,ze]=m.useState(""),[oe,ke]=m.useState({}),[Be,Qe]=m.useState(""),[Ce,Ct]=m.useState(""),[Xt,Ft]=m.useState(""),[rt,Fn]=m.useState(""),[ie,Ie]=m.useState(""),[et,qe]=m.useState(!1),[Pt,vt]=m.useState(""),[tr,Gn]=m.useState({hiddenBuiltins:[],promoted:[]}),Tr=m.useRef(0),kn=m.useRef(0),nr=m.useRef(0),pr=m.useCallback(async()=>{var we,$e;const U=++kn.current;O("");try{const Ae=await fetch(`/api/flows?view=${encodeURIComponent(p)}`);if(U!==kn.current)return;if(!Ae.ok)throw new Error("HTTP "+Ae.status);const Ze=await Ae.json();if(U!==kn.current)return;u(Array.isArray(Ze)?Ze:[])}catch(Ae){if(U!==kn.current)return;u([]),O(String(Ae.message||Ae))}try{const Ae=await fetch("/api/pipeline-recent-runs");if(U!==kn.current)return;if(Ae.ok){const Ze=await Ae.json();if(U!==kn.current)return;z(Array.isArray(Ze.runs)?Ze.runs:[])}else z([])}catch{if(U!==kn.current)return;z([])}if(t!=null&&t.isAdmin)try{const Ae=await fetch("/api/admin/builtin-flows");if(U!==kn.current)return;const Ze=await Ae.json().catch(()=>({}));Ae.ok&&Gn({hiddenBuiltins:Array.isArray((we=Ze==null?void 0:Ze.config)==null?void 0:we.hiddenBuiltins)?Ze.config.hiddenBuiltins:[],promoted:Array.isArray(($e=Ze==null?void 0:Ze.config)==null?void 0:$e.promoted)?Ze.config.promoted:[]})}catch{if(U!==kn.current)return;Gn({hiddenBuiltins:[],promoted:[]})}else Gn({hiddenBuiltins:[],promoted:[]});V(!0)},[t==null?void 0:t.isAdmin,p]),hr=m.useCallback(async(U,we)=>{if(!(t!=null&&t.isAdmin)||!(U!=null&&U.id))return;const $e=`${we}:${U.source}:${U.id}`;vt($e),O("");try{const Ae=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:we,flowId:U.id,ownerUserId:U.ownerUserId||t.userId})}),Ze=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(Ze.error||"更新内置配置失败");await pr()}catch(Ae){O(String(Ae.message||Ae))}finally{vt("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,pr]),fn=m.useCallback(async()=>{const U=++nr.current;L(""),F(!1);const we="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";h([]),g([]),pe("");try{const[Ae,Ze,wn,Lt]=await Promise.all([fetch(we),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),Sn=await Ae.json().catch(()=>({})),rr=await Ze.json().catch(()=>({})),yr=await wn.json().catch(()=>({})),Zt=await Lt.json().catch(()=>({}));if(!Ae.ok)throw new Error(Sn.error||"Nodes HTTP "+Ae.status);if(!Ze.ok)throw new Error(rr.error||"Skills HTTP "+Ze.status);if(!wn.ok)throw new Error(yr.error||"Collections HTTP "+wn.status);if(!Lt.ok)throw new Error(Zt.error||"Flow snippets HTTP "+Lt.status);if(U!==nr.current)return;h(Array.isArray(Sn.nodes)?Sn.nodes:Array.isArray(Sn)?Sn:[]),v(Array.isArray(rr.skills)?rr.skills:[]),x(Ya(yr)),g(Array.isArray(Zt.snippets)?Zt.snippets:[])}catch(Ae){if(U!==nr.current)return;h([]),v([]),g([]),x([]),L(String(Ae.message||Ae))}finally{if(U!==nr.current)return;F(!0)}},[e]);m.useEffect(()=>{V(!1),pr(),fn()},[pr,fn]),m.useEffect(()=>{try{localStorage.setItem(ZI,G?"1":"0")}catch{}},[G]),m.useEffect(()=>{try{localStorage.setItem(eP,p)}catch{}},[p]),m.useEffect(()=>{try{re?localStorage.setItem(Hx,re):localStorage.removeItem(Hx)}catch{}},[re]),m.useEffect(()=>{let U=!1;return fetch("/api/ui-context").then(we=>we.json()).then(we=>{U||qe(!!we.hideCommunityLinks)}).catch(()=>{}),()=>{U=!0}},[]);const zn=m.useCallback(async U=>{if(!o)return;const we=Ya({collections:U});P(!0),L("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(iz(we))}),Ae=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ae.error||"Collections HTTP "+$e.status);x(Ya(Ae))}catch($e){L(String($e.message||$e))}finally{P(!1)}},[o]),is=m.useCallback(()=>{if(!o)return;const U=_.trim();if(!U)return;const we=U.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(k.map(Lt=>Lt.id));let Ae=we,Ze=2;for(;$e.has(Ae);)Ae=`${we}-${Ze++}`;const wn=Date.now();zn([...k,{id:Ae,name:U,skillKeys:[],createdAt:wn,updatedAt:wn}]),S(""),ue(`collection:${Ae}`)},[o,_,zn,k]),Fs=m.useCallback(U=>{if(!o)return;const we=k.find(Ae=>Ae.id===U);if(we!=null&&we.builtin)return;const $e=k.filter(Ae=>Ae.id!==U);ee===`collection:${U}`&&ue("all"),zn($e)},[o,ee,zn,k]),vn=m.useCallback((U,we,$e)=>{if(!o)return;const Ae=String(we||"").trim();if(!Ae)return;const Ze=Date.now(),wn=k.map(Lt=>{if(Lt.id!==U)return Lt;const Sn=new Set(Lt.skillKeys||[]);return $e?Sn.add(Ae):Sn.delete(Ae),{...Lt,skillKeys:Array.from(Sn),updatedAt:Ze}});zn(wn)},[o,zn,k]),Yn=m.useCallback(async U=>{const we=U==null?void 0:U.packageId,$e=U==null?void 0:U.version;if(!we||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:we,version:$e})))return;const Ae=On(U);Ct(Ae),Ft(""),L("");try{const Ze=new URLSearchParams({id:we,version:$e}),wn=await fetch(`/api/marketplace/node?${Ze.toString()}`,{method:"DELETE"}),Lt=await wn.json().catch(()=>({}));if(!wn.ok||(Lt==null?void 0:Lt.ok)===!1){const Sn=Array.isArray(Lt==null?void 0:Lt.usage)&&Lt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Lt.usage.length})}`:"";throw new Error(((Lt==null?void 0:Lt.error)||"Delete failed")+Sn)}Ft(n("project:deleteMyNodeSuccess",{id:we,version:$e})),at(Sn=>{const rr={...Sn};return delete rr[Ae],rr}),ke(Sn=>{const rr={};for(const[yr,Zt]of Object.entries(Sn))yr.startsWith(`${Ae}:`)||(rr[yr]=Zt);return rr}),pe(""),await fn()}catch(Ze){Ft(String(Ze.message||Ze))}finally{Ct("")}},[fn,n]),ks=m.useCallback(async U=>{const we=U==null?void 0:U.id,$e=(U==null?void 0:U.version)||"1.0.0";if(!we||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:we,version:$e})))return;const Ae=Mo(U);Fn(Ae),Ie(""),L("");try{const Ze=new URLSearchParams({id:we,version:$e}),wn=await fetch(`/api/marketplace/flow-snippet?${Ze.toString()}`,{method:"DELETE"}),Lt=await wn.json().catch(()=>({}));if(!wn.ok||(Lt==null?void 0:Lt.ok)===!1)throw new Error((Lt==null?void 0:Lt.error)||"Delete failed");Ie(n("project:deleteMyFlowSuccess",{id:we,version:$e})),pe(""),await fn()}catch(Ze){Ie(String(Ze.message||Ze))}finally{Fn("")}},[fn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ue("all"),pe(""),Ne("overview");return}l(U=>U==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const U=new URLSearchParams(window.location.search),we=U.get("tab");let $e=!1;if(we==="nodes"){r("/nodes");return}if(we==="my-nodes"){r("/my-nodes");return}if(we==="my-flows"){r("/my-flows");return}if(we==="skills"){r("/skills");return}if(we==="archived"?(l("archived"),U.delete("tab"),$e=!0):we&&(l("all"),U.delete("tab"),$e=!0),U.get("new")==="1"&&(H(!0),U.delete("new"),$e=!0),$e){const Ae=U.toString();window.history.replaceState({},"",Ae?`/projects?${Ae}`:"/projects")}},[s,r]);const Jn=m.useMemo(()=>bF(R,wF(),c),[R,c,s]),Bn=m.useMemo(()=>Jn.filter(U=>wz(te,U)),[Jn,te]),vr=te.trim().toLowerCase(),Sr=m.useMemo(()=>a==="archived"?c.filter(U=>U.archived):c.filter(U=>!U.archived),[c,a]),Wn=m.useMemo(()=>Sr.filter(U=>yz(U,vr,n)),[Sr,vr,n]),Mr=m.useMemo(()=>new Set((tr.promoted||[]).map(U=>String((U==null?void 0:U.id)||"").trim()).filter(Boolean)),[tr.promoted]),$r=m.useMemo(()=>(tr.hiddenBuiltins||[]).map(U=>String(U||"").trim()).filter(Boolean),[tr.hiddenBuiltins]),ce=a==="nodes"||a==="my-nodes",me=a==="my-nodes",tt=a==="my-flows",st=m.useMemo(()=>d.filter(U=>me&&!jz(U,t)?!1:(ee==="all"||(ee==="marketplace"?U.source==="marketplace":U.type===ee))&&Gy(te,[U.id,U.label,U.displayName,U.description,U.type,U.source,U.packageId,U.version])),[t,d,me,te,ee]),zt=m.useMemo(()=>{const U=new Map;for(const we of k)U.set(we.id,new Set(ca(we,y)));return U},[y,k]),Rn=m.useMemo(()=>[{id:"all",label:"全部"},...k.map(U=>{var we;return{id:`collection:${U.id}`,label:U.name,count:((we=zt.get(U.id))==null?void 0:we.size)||0,collection:U}}),{id:"ungrouped",label:"未分组"}],[zt,k]),jr=m.useMemo(()=>y.filter(U=>{var Ae;const we=On(U);let $e=ee==="all";if(ee.startsWith("collection:")){const Ze=ee.slice(11);$e=!!((Ae=zt.get(Ze))!=null&&Ae.has(we))}else ee==="ungrouped"&&($e=!Array.from(zt.values()).some(Ze=>Ze.has(we)));return $e&&Gy(te,[U.name,U.id,U.description,U.sourceLabel,U.source,U.path])}),[y,te,ee,zt]),Nr=m.useMemo(()=>b.filter(U=>Gy(te,[U.id,U.name,U.displayName,U.description,U.version,U.packageDir,Array.isArray(U.tags)?U.tags.join(" "):""])),[b,te]),mr=ce||tt||a==="skills",ut=m.useMemo(()=>st.find(U=>On(U)===de)||st[0]||null,[st,de]),Ut=m.useMemo(()=>jr.find(U=>On(U)===de)||jr[0]||null,[jr,de]),Gt=m.useMemo(()=>Nr.find(U=>Mo(U)===de)||Nr[0]||null,[Nr,de]),Xn=Ut?_e[On(Ut)]:null,ot=ut?Re[On(ut)]:null,gr=ut&&ye?oe[`${On(ut)}:${ye}`]:null,zs=n(ce?"project:searchNodes":tt?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!Ut)return;const U=On(Ut);if(_e[U])return;let we=!1;return yt(U),fetch(`/api/skills/detail?key=${encodeURIComponent(U)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&Ae.skill&&He(Ze=>({...Ze,[U]:Ae.skill}))}).catch(()=>{}).finally(()=>{we||yt("")}),()=>{we=!0}},[a,Ut,_e]),m.useEffect(()=>{if(!ce||!ut)return;const U=On(ut);if(Re[U])return;let we=!1;return $t(U),fetch(`/api/nodes/detail?id=${encodeURIComponent(ut.id)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&at(Ze=>({...Ze,[U]:Ae}))}).catch(()=>{}).finally(()=>{we||$t("")}),()=>{we=!0}},[ce,ut,Re]),m.useEffect(()=>{if(!ce)return;const U=Array.isArray(ot==null?void 0:ot.files)?ot.files:[];ze(we=>{var $e;return we&&U.some(Ae=>Ae.path===we)?we:(($e=U[0])==null?void 0:$e.path)||""})},[ce,ot]),m.useEffect(()=>{if(!ce||!ut||!ye)return;const U=`${On(ut)}:${ye}`;if(oe[U])return;let we=!1;return Qe(U),fetch(`/api/nodes/file?id=${encodeURIComponent(ut.id)}&path=${encodeURIComponent(ye)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&ke(Ze=>({...Ze,[U]:Ae}))}).catch(()=>{}).finally(()=>{we||Qe("")}),()=>{we=!0}},[ce,ut,ye,oe]),m.useEffect(()=>{Ft("")},[de,a]);const Hi=U=>{r(Pp(U,"workspace"))},Bs=U=>{se(bN(U)),r(Pp({id:U.flowId,source:U.flowSource,archived:!!U.archived},"workspace"))},ae=m.useCallback(U=>{var we,$e;U.preventDefault(),U.stopPropagation(),($e=(we=U.dataTransfer)==null?void 0:we.types)!=null&&$e.includes("Files")&&(Tr.current+=1,W(!0))},[]),ve=m.useCallback(U=>{U.preventDefault(),U.stopPropagation(),Tr.current-=1,Tr.current<=0&&(Tr.current=0,W(!1))},[]),Te=m.useCallback(U=>{U.preventDefault(),U.stopPropagation()},[]),bt=m.useCallback(U=>{var Ae,Ze;U.preventDefault(),U.stopPropagation(),Tr.current=0,W(!1);const we=(Ze=(Ae=U.dataTransfer)==null?void 0:Ae.files)==null?void 0:Ze[0];if(!we)return;const $e=we.name.toLowerCase();!$e.endsWith(".yaml")&&!$e.endsWith(".yml")&&!$e.endsWith(".zip")||Q(we)},[]);return i.jsxs("div",{className:"af-projects"+(K?" af-projects--drop-target":""),onDragEnter:ae,onDragLeave:ve,onDragOver:Te,onDrop:bt,children:[i.jsxs("header",{className:"af-projects-top",children:[e?i.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):i.jsxs("div",{className:"af-projects-tabs",children:[i.jsx("button",{type:"button",className:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),i.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),i.jsxs("div",{className:"af-projects-top-right",children:[mr?null:i.jsxs("div",{className:"af-scope-switch af-project-scope-switch","aria-label":"Project 视图",children:[i.jsx("button",{type:"button",className:p==="personal"?"is-active":"",onClick:()=>f("personal"),children:"个人"}),i.jsx("button",{type:"button",className:p==="team"?"is-active":"",onClick:()=>f("team"),children:"团队"})]}),i.jsxs("div",{className:"af-search-wrap",children:[i.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),i.jsx("input",{className:"af-search"+(te.trim()?" af-search--has-clear":""),type:"search",placeholder:zs,"aria-label":zs,autoComplete:"off",value:te,onChange:U=>Z(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(Z(""),U.currentTarget.blur())}}),te.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>Z(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),mr?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>fn(),children:n("project:refreshResources")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(G?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":G,"aria-controls":"af-recent-activity-panel",onClick:()=>ne(U=>!U),children:i.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>H(!0),children:n("project:createNew")})]})]})]}),i.jsxs("div",{className:"af-projects-body",children:[i.jsxs("section",{className:"af-projects-main",children:[i.jsxs("header",{className:"af-projects-section-head",children:[i.jsx("h2",{className:"af-projects-h2",children:n(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:nodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),i.jsx("p",{className:"af-projects-sub",children:vr?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?st.length:a==="my-flows"?Nr.length:a==="skills"?jr.length:Wn.length}):a==="my-nodes"?n("project:myNodesHint",{count:st.length}):a==="my-flows"?n("project:myFlowsHint",{count:Nr.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:y.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),E?i.jsx("p",{className:"af-err af-projects-api-hint",children:E}):null,D&&mr?i.jsx("p",{className:"af-err af-projects-api-hint",children:D}):null]}),mr?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(sz,{onChanged:fn,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:tt?"schema":ce?me?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(tt?"project:myFlowsPurposeTitle":me?"project:myNodesPurposeTitle":ce?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(tt?"project:myFlowsPurposeDesc":me?"project:myNodesPurposeDesc":ce?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),tt?null:i.jsxs(i.Fragment,{children:[ce?i.jsxs("div",{className:"af-resource-filter-row",children:[i.jsx("button",{type:"button",className:"af-resource-filter"+(me?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ue("all"),pe("")},children:n("project:nodeScopeAll")}),i.jsx("button",{type:"button",className:"af-resource-filter"+(me?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),ue("all"),pe("")},children:n("project:nodeScopeMine")})]}):null,i.jsx("div",{className:"af-resource-filter-row",children:(ce?(me?bz:xz).map(U=>({id:U,label:n(`project:resourceFilter.${U}`)})):Rn).map(U=>U.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(ee===U.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ue(U.id),pe("")},children:[U.label,i.jsx("em",{children:U.count}),U.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!U.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${U.collection.name}`,onClick:()=>Fs(U.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},U.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(ee===U.id?" af-resource-filter--active":""),onClick:()=>{ue(U.id),pe("")},children:U.label},U.id))})]}),a==="skills"&&o?i.jsx("div",{className:"af-skill-collections-manager",children:i.jsxs("div",{className:"af-skill-collections-create",children:[i.jsx("input",{className:"af-set-input af-set-input--sm",value:_,onChange:U=>S(U.target.value),onKeyDown:U=>{U.key==="Enter"&&is()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!_.trim()||N,onClick:()=>is(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,ce?i.jsx("div",{className:"af-resource-grid",children:st.length>0?st.map(U=>i.jsxs("button",{type:"button",className:"af-resource-card"+(ut&&On(U)===On(ut)?" af-resource-card--active":""),onClick:()=>pe(On(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Vl(U.type==="control"?"secondary":U.type==="provide"?"primary":"muted"),children:i.jsx(Ln,{query:te,children:U.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Ln,{query:te,children:wN(U.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:te,children:U.label||U.displayName||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Ln,{query:te,children:U.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(U.inputs||{}).length,outputs:Object.keys(U.outputs||{}).length})})]}),U.packageId?i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Ln,{query:te,children:`${U.packageId}${U.version?` / ${U.version}`:""}`})})]}):null]},`${U.id}:${U.source||""}:${U.packageId||""}`)):B?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:vr?n("project:noNodeMatch",{query:te.trim()}):n(me?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):tt?i.jsx("div",{className:"af-resource-grid",children:Nr.length>0?Nr.map(U=>{const we=tP(U),$e=nP(U),Ae=Number.isFinite(Number(U.nodeCount))?Number(U.nodeCount):we.length,Ze=Number.isFinite(Number(U.edgeCount))?Number(U.edgeCount):$e.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Gt&&Mo(U)===Mo(Gt)?" af-resource-card--active":""),onClick:()=>pe(Mo(U)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Vl("primary"),children:i.jsx(Ln,{query:te,children:U.version?`v${U.version}`:"flow"})}),i.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:te,children:U.displayName||U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ae,edges:Ze})}),i.jsx("span",{children:i.jsx(Ln,{query:te,children:U.id})})]}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Ln,{query:te,children:xN(U)})})]})]},Mo(U))}):B?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:vr?n("project:noFlowSnippetMatch",{query:te.trim()}):n("project:noMyFlows")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?i.jsx("div",{className:"af-resource-grid",children:jr.length>0?jr.map(U=>{const we=On(U),$e=k.filter(Ae=>{var Ze;return(Ze=zt.get(Ae.id))==null?void 0:Ze.has(we)});return i.jsxs("button",{type:"button",className:"af-resource-card"+(Ut&&we===On(Ut)?" af-resource-card--active":""),onClick:()=>pe(we),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Vl(U.source==="builtin"?"muted":"primary"),children:i.jsx(Ln,{query:te,children:U.sourceLabel||U.source||"skill"})}),i.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:te,children:U.name||U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:U.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Ln,{query:te,children:U.path||U.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[$e.slice(0,3).map(Ae=>i.jsx("span",{children:Ae.name},Ae.id)),$e.length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},U.key||`${U.source}:${U.name}`)}):B?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:vr?n("project:noSkillMatch",{query:te.trim()}):n("project:noSkills")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i.jsxs(i.Fragment,{children:[t!=null&&t.isAdmin&&a==="all"&&$r.length>0?i.jsxs("div",{className:"af-project-admin-panel",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"已隐藏内置"}),i.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),i.jsx("div",{className:"af-project-admin-hidden-list",children:$r.map(U=>{const we=Pt===`show-builtin:builtin:${U}`;return i.jsxs("button",{type:"button",disabled:we,onClick:()=>hr({id:U,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:U}),i.jsx("em",{children:we?"恢复中":"恢复"})]},U)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[Wn.length>0?Wn.map(U=>{var wn,Lt,Sn,rr,yr;const we=(t==null?void 0:t.isAdmin)&&U.source==="user"&&!U.archived&&!Mr.has(U.id),$e=(t==null?void 0:t.isAdmin)&&U.source==="admin",Ae=(t==null?void 0:t.isAdmin)&&U.source==="builtin",Ze=Pt.endsWith(`:${U.source}:${U.id}`);return i.jsx("div",{className:fz(U.source),role:"button",tabIndex:0,onClick:()=>Hi(U),onKeyDown:Zt=>{(Zt.key==="Enter"||Zt.key===" ")&&(Zt.preventDefault(),Hi(U))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:Vl(Wx(U.source,n).tone),children:i.jsx(Ln,{query:te,children:Wx(U.source,n).label})}),(wn=U.collaboration)!=null&&wn.role?i.jsx("span",{className:Vl(U.collaboration.role==="owner"?"primary":"muted"),children:U.collaboration.role==="owner"?(Lt=U.collaboration.teamShares)!=null&&Lt.length?"已分享团队":"我创建的":U.collaboration.accessSource==="team"?`${((rr=(Sn=U.collaboration.teamShares)==null?void 0:Sn.find(Zt=>Zt.teamId===U.collaboration.teamId))==null?void 0:rr.teamName)||"团队"}共享`:`${U.collaboration.ownerUsername||U.collaboration.ownerId} 分享`}):null,U.archived?i.jsx("span",{className:Vl("muted"),children:i.jsx(Ln,{query:te,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:te,children:U.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:QI(U,n)})}),i.jsxs("div",{className:"af-project-path",children:[i.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),i.jsx("span",{className:"af-path-text",children:i.jsx(Ln,{query:te,children:XI(U)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:Zt=>Zt.stopPropagation(),onKeyDown:Zt=>Zt.stopPropagation(),children:[we?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(U,"promote"),children:"设为内置"}):null,$e?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(U,"unpromote"),children:"取消内置"}):null,Ae?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(U,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${U.id}:${U.source??"user"}:${U.archived?"a":""}:${((yr=U.collaboration)==null?void 0:yr.id)||"own"}`)}):M?Sr.length===0?i.jsxs("div",{className:"af-projects-empty-block",children:[i.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):c.length>0?n("project:noActive"):n(E?"project:loadFailed":"project:noPipelines")}),!E&&c.length===0&&a==="all"?i.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:te.trim()})})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),i.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>H(!0),children:[i.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),i.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),et?null:i.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[i.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),i.jsxs("span",{className:"af-hub-card__eyebrow",children:[i.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),i.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),i.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),i.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),i.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),i.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),mr?i.jsx("aside",{className:"af-resource-detail","aria-label":n(ce?"project:nodeDetail":tt?"project:flowDetail":"project:skillDetail"),children:ce&&ut?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),i.jsxs("div",{children:[i.jsx("h3",{children:ut.label||ut.displayName||ut.id}),i.jsx("p",{children:ut.id})]})]}),i.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(U=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(Me===U?" af-resource-detail-tab--active":""),onClick:()=>Ne(U),children:n(`project:nodeDetailTabs.${U}`)},U))}),kt===On(ut)?i.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):Me==="overview"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-resource-detail-desc",children:ut.description||((Rt=ot==null?void 0:ot.node)==null?void 0:Rt.description)||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailType")}),i.jsx("dd",{children:ut.type||((Qt=ot==null?void 0:ot.node)==null?void 0:Qt.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:wN(ut.source,n)})]}),ut.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:ut.packageId})]}):null,ut.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:ut.version})]}):null,ut.packageDir||ot!=null&&ot.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:ut.packageDir||(ot==null?void 0:ot.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(ot==null?void 0:ot.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),me&&ut.source==="marketplace"?i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myNodeManagement")}),i.jsx("p",{children:n("project:deleteMyNodeHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Ce===On(ut),onClick:()=>Yn(ut),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ce===On(ut)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),Xt?i.jsx("p",{className:"af-resource-action-message",children:Xt}):null]}):null,i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:nodesMeaning")})]})]}):Me==="schema"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeSchema")}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeInputs")}),Rp(((pn=ot==null?void 0:ot.node)==null?void 0:pn.inputs)||ut.inputs).length>0?Rp((($n=ot==null?void 0:ot.node)==null?void 0:$n.inputs)||ut.inputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),Rp(((vs=ot==null?void 0:ot.node)==null?void 0:vs.outputs)||ut.outputs).length>0?Rp(((Ss=ot==null?void 0:ot.node)==null?void 0:Ss.outputs)||ut.outputs).map(U=>i.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):i.jsx("em",{children:n("project:noSlots")})]})]}):Me==="runtime"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeRuntime")}),ot!=null&&ot.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(ot.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),ot!=null&&ot.body?i.jsxs(i.Fragment,{children:[i.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),i.jsx("pre",{className:"af-resource-skill-preview",children:ot.body})]}):i.jsx("p",{children:n("project:noNodeBody")})]}):Me==="files"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(ot==null?void 0:ot.files)&&ot.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:ot.files.map(U=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(ye===U.path?" af-node-file-item--active":""),onClick:()=>ze(U.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:U.path})]},U.path))}),i.jsxs("pre",{className:"af-resource-skill-preview",children:[Be===`${On(ut)}:${ye}`?n("project:loadingResources"):gr!=null&&gr.binary?n("project:binaryFile"):(gr==null?void 0:gr.content)||n("project:selectNodeFile"),gr!=null&&gr.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):i.jsx("p",{children:n("project:noNodeFiles")})]}):i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(ot==null?void 0:ot.usage)&&ot.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:ot.usage.map(U=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:U.flowId}),i.jsxs("span",{children:[U.flowSource,U.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:U.instances.map(we=>we.label||we.instanceId).join(", ")})]},`${U.flowSource}:${U.flowId}:${U.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):tt&&Gt?(()=>{const U=Ez(Gt);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"schema"}),i.jsxs("div",{children:[i.jsx("h3",{children:Gt.displayName||Gt.name||Gt.id}),i.jsx("p",{children:Gt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Gt.description||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:Gt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:xN(Gt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Gt.nodeCount))?Number(Gt.nodeCount):U.nodes.length,edges:Number.isFinite(Number(Gt.edgeCount))?Number(Gt.edgeCount):U.edges.length})})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:myFlowsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[i.jsx("h4",{children:n("project:myFlowManagement")}),i.jsx("p",{children:n("project:deleteMyFlowHint")}),i.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:rt===Mo(Gt),onClick:()=>ks(Gt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),rt===Mo(Gt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),ie?i.jsx("p",{className:"af-resource-action-message",children:ie}):null]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:flowSnippetPreview")}),U.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:U.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:i.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),i.jsx("g",{className:"af-flow-snippet-map__edges",children:U.diagram.edges.map(we=>i.jsxs("g",{children:[i.jsx("path",{d:we.path}),we.label?i.jsx("text",{x:we.labelX,y:we.labelY-5,textAnchor:"middle",children:Yy(we.label,18)}):null]},we.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:U.diagram.nodes.map((we,$e)=>i.jsxs("g",{transform:`translate(${we.x} ${we.y})`,children:[i.jsx("rect",{width:we.width,height:we.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:we.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:we.height/2+4,textAnchor:"middle",children:$e+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:we.height/2-3,children:Yy(we.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:we.height/2+16,children:Yy(we.meta||we.id,20)})]},we.id))})]})}):i.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),i.jsxs("details",{className:"af-flow-snippet-json",children:[i.jsx("summary",{children:n("project:flowSnippetJson")}),i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Gt.snippet||{},null,2)})]})]})]})})():a==="skills"&&Ut?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-resource-detail-head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:Ut.name||Ut.id}),i.jsx("p",{children:Ut.sourceLabel||Ut.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Ut.description||n("project:noDescription")}),i.jsxs("dl",{className:"af-resource-detail-kv",children:[i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:Ut.sourceLabel||Ut.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:Ut.path||Ut.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),k.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:k.map(U=>{const we=On(Ut),$e=zt.get(U.id)||new Set,Ae=$e.has(we);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:Ae,disabled:N||!o,onChange:Ze=>vn(U.id,we,Ze.target.checked)}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:U.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},U.id)})})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:resourceMeaning")}),i.jsx("p",{children:n("project:skillsMeaning")})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:n("project:skillPreview")}),i.jsx("pre",{className:"af-resource-skill-preview",children:ct===On(Ut)?n("project:loadingResources"):(Xn==null?void 0:Xn.body)||(Xn==null?void 0:Xn.content)||n("project:skillPreviewEmpty")})]})]}):i.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):i.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(G?"":" af-activity--hidden"),"aria-hidden":!G,"aria-label":n("project:recentActivity"),children:[i.jsxs("h2",{className:"af-activity-title",children:[i.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),i.jsx("div",{className:"af-activity-list",children:Bn.length===0?i.jsx("p",{className:"af-activity-empty",children:Jn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Bn.map(U=>{const we=re===bN(U);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(we?" af-activity-row--active":""),"aria-current":we?"page":void 0,onClick:()=>Bs(U),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Ln,{query:te,children:U.flowId})}),i.jsx("span",{className:"af-activity-time",children:gN(U.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:pz(U.kind),children:U.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[U.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",gN(U.at,n)]})]})]},`${U.kind}-${U.flowId}-${U.flowSource}-${U.at}`)})})]})]}),i.jsx(YF,{open:$,onClose:()=>H(!1),onCreated:async U=>{H(!1),await pr();const we=U.source??"user";r(Pp({id:U.id,source:we},"workspace"))}}),A?i.jsx(UF,{file:A,onClose:()=>Q(null),onImported:async U=>{Q(null),await pr();const we=U.source??"user";r(Pp({id:U.id,source:we},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}function Un(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Un(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Iz={value:()=>{}};function sg(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new bh(n)}function bh(e){this._=e}function Pz(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}bh.prototype=sg.prototype={constructor:bh,on:function(e,t){var n=this._,r=Pz(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=Rz(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(s=(e=r[o]).type)n[s]=SN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=SN(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new bh(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function Rz(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function SN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Iz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Kx="http://www.w3.org/1999/xhtml";const jN={svg:"http://www.w3.org/2000/svg",xhtml:Kx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ig(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),jN.hasOwnProperty(t)?{space:jN[t],local:e}:e}function Tz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Kx&&t.documentElement.namespaceURI===Kx?t.createElement(e):t.createElementNS(n,e)}}function Mz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function rP(e){var t=ig(e);return(t.local?Mz:Tz)(t)}function $z(){}function Bk(e){return e==null?$z:function(){return this.querySelector(e)}}function Lz(e){typeof e!="function"&&(e=Bk(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=new Array(a),c,u,p=0;p<a;++p)(c=o[p])&&(u=e.call(c,c.__data__,p,o))&&("__data__"in c&&(u.__data__=c.__data__),l[p]=u);return new ws(r,this._parents)}function Oz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dz(){return[]}function sP(e){return e==null?Dz:function(){return this.querySelectorAll(e)}}function Fz(e){return function(){return Oz(e.apply(this,arguments))}}function zz(e){typeof e=="function"?e=Fz(e):e=sP(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var a=t[o],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(r.push(e.call(c,c.__data__,u,a)),s.push(c));return new ws(r,s)}function iP(e){return function(){return this.matches(e)}}function oP(e){return function(t){return t.matches(e)}}var Bz=Array.prototype.find;function Wz(e){return function(){return Bz.call(this.children,e)}}function Hz(){return this.firstElementChild}function Vz(e){return this.select(e==null?Hz:Wz(typeof e=="function"?e:oP(e)))}var Kz=Array.prototype.filter;function qz(){return Array.from(this.children)}function Uz(e){return function(){return Kz.call(this.children,e)}}function Gz(e){return this.selectAll(e==null?qz:Uz(typeof e=="function"?e:oP(e)))}function Yz(e){typeof e!="function"&&(e=iP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=[],c,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new ws(r,this._parents)}function aP(e){return new Array(e.length)}function Jz(){return new ws(this._enter||this._groups.map(aP),this._parents)}function sm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}sm.prototype={constructor:sm,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Xz(e){return function(){return e}}function Qz(e,t,n,r,s,o){for(var a=0,l,c=t.length,u=o.length;a<u;++a)(l=t[a])?(l.__data__=o[a],r[a]=l):n[a]=new sm(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function Zz(e,t,n,r,s,o,a){var l,c,u=new Map,p=t.length,f=o.length,d=new Array(p),h;for(l=0;l<p;++l)(c=t[l])&&(d[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,o[l],l,o)+"",(c=u.get(h))?(r[l]=c,c.__data__=o[l],u.delete(h)):n[l]=new sm(e,o[l]);for(l=0;l<p;++l)(c=t[l])&&u.get(d[l])===c&&(s[l]=c)}function e3(e){return e.__data__}function t3(e,t){if(!arguments.length)return Array.from(this,e3);var n=t?Zz:Qz,r=this._parents,s=this._groups;typeof e!="function"&&(e=Xz(e));for(var o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var p=r[u],f=s[u],d=f.length,h=n3(e.call(p,p&&p.__data__,u,r)),y=h.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(d);n(p,f,v,b,g,h,t);for(var k=0,x=0,_,S;k<y;++k)if(_=v[k]){for(k>=x&&(x=k+1);!(S=b[x])&&++x<y;);_._next=S||null}}return a=new ws(a,r),a._enter=l,a._exit=c,a}function n3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function r3(){return new ws(this._exit||this._groups.map(aP),this._parents)}function s3(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function i3(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,a=Math.min(s,o),l=new Array(s),c=0;c<a;++c)for(var u=n[c],p=r[c],f=u.length,d=l[c]=new Array(f),h,y=0;y<f;++y)(h=u[y]||p[y])&&(d[y]=h);for(;c<s;++c)l[c]=n[c];return new ws(l,this._parents)}function o3(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],a;--s>=0;)(a=r[s])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function a3(e){e||(e=l3);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,c=s[o]=new Array(l),u,p=0;p<l;++p)(u=a[p])&&(c[p]=u);c.sort(t)}return new ws(s,this._parents).order()}function l3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function c3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function u3(){return Array.from(this)}function d3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var a=r[s];if(a)return a}return null}function f3(){let e=0;for(const t of this)++e;return e}function p3(){return!this.node()}function h3(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,a=s.length,l;o<a;++o)(l=s[o])&&e.call(l,l.__data__,o,s);return this}function m3(e){return function(){this.removeAttribute(e)}}function g3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function y3(e,t){return function(){this.setAttribute(e,t)}}function w3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function x3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function b3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function k3(e,t){var n=ig(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?g3:m3:typeof t=="function"?n.local?b3:x3:n.local?w3:y3)(n,t))}function lP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function v3(e){return function(){this.style.removeProperty(e)}}function S3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function j3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function N3(e,t,n){return arguments.length>1?this.each((t==null?v3:typeof t=="function"?j3:S3)(e,t,n??"")):zc(this.node(),e)}function zc(e,t){return e.style.getPropertyValue(t)||lP(e).getComputedStyle(e,null).getPropertyValue(t)}function _3(e){return function(){delete this[e]}}function C3(e,t){return function(){this[e]=t}}function A3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function E3(e,t){return arguments.length>1?this.each((t==null?_3:typeof t=="function"?A3:C3)(e,t)):this.node()[e]}function cP(e){return e.trim().split(/^|\s+/)}function Wk(e){return e.classList||new uP(e)}function uP(e){this._node=e,this._names=cP(e.getAttribute("class")||"")}uP.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function dP(e,t){for(var n=Wk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function fP(e,t){for(var n=Wk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function I3(e){return function(){dP(this,e)}}function P3(e){return function(){fP(this,e)}}function R3(e,t){return function(){(t.apply(this,arguments)?dP:fP)(this,e)}}function T3(e,t){var n=cP(e+"");if(arguments.length<2){for(var r=Wk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?R3:t?I3:P3)(n,t))}function M3(){this.textContent=""}function $3(e){return function(){this.textContent=e}}function L3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function O3(e){return arguments.length?this.each(e==null?M3:(typeof e=="function"?L3:$3)(e)):this.node().textContent}function D3(){this.innerHTML=""}function F3(e){return function(){this.innerHTML=e}}function z3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function B3(e){return arguments.length?this.each(e==null?D3:(typeof e=="function"?z3:F3)(e)):this.node().innerHTML}function W3(){this.nextSibling&&this.parentNode.appendChild(this)}function H3(){return this.each(W3)}function V3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function K3(){return this.each(V3)}function q3(e){var t=typeof e=="function"?e:rP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function U3(){return null}function G3(e,t){var n=typeof e=="function"?e:rP(e),r=t==null?U3:typeof t=="function"?t:Bk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Y3(){var e=this.parentNode;e&&e.removeChild(this)}function J3(){return this.each(Y3)}function X3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Q3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Z3(e){return this.select(e?Q3:X3)}function eB(e){return arguments.length?this.property("__data__",e):this.node().__data__}function tB(e){return function(t){e.call(this,t,this.__data__)}}function nB(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function rB(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function sB(e,t,n){return function(){var r=this.__on,s,o=tB(t);if(r){for(var a=0,l=r.length;a<l;++a)if((s=r[a]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function iB(e,t,n){var r=nB(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,p;c<u;++c)for(s=0,p=l[c];s<o;++s)if((a=r[s]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?sB:rB,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function pP(e,t,n){var r=lP(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function oB(e,t){return function(){return pP(this,e,t)}}function aB(e,t){return function(){return pP(this,e,t.apply(this,arguments))}}function lB(e,t){return this.each((typeof t=="function"?aB:oB)(e,t))}function*cB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,a;s<o;++s)(a=r[s])&&(yield a)}var hP=[null];function ws(e,t){this._groups=e,this._parents=t}function Nf(){return new ws([[document.documentElement]],hP)}function uB(){return this}ws.prototype=Nf.prototype={constructor:ws,select:Lz,selectAll:zz,selectChild:Vz,selectChildren:Gz,filter:Yz,data:t3,enter:Jz,exit:r3,join:s3,merge:i3,selection:uB,order:o3,sort:a3,call:c3,nodes:u3,node:d3,size:f3,empty:p3,each:h3,attr:k3,style:N3,property:E3,classed:T3,text:O3,html:B3,raise:H3,lower:K3,append:q3,insert:G3,remove:J3,clone:Z3,datum:eB,on:iB,dispatch:lB,[Symbol.iterator]:cB};function fs(e){return typeof e=="string"?new ws([[document.querySelector(e)]],[document.documentElement]):new ws([[e]],hP)}function dB(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ni(e,t){if(e=dB(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const fB={passive:!1},Jd={capture:!0,passive:!1};function Jy(e){e.stopImmediatePropagation()}function Nc(e){e.preventDefault(),e.stopImmediatePropagation()}function mP(e){var t=e.document.documentElement,n=fs(e).on("dragstart.drag",Nc,Jd);"onselectstart"in t?n.on("selectstart.drag",Nc,Jd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function gP(e,t){var n=e.document.documentElement,r=fs(e).on("dragstart.drag",null);t&&(r.on("click.drag",Nc,Jd),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Tp=e=>()=>e;function qx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:c,dy:u,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:p}})}qx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function pB(e){return!e.ctrlKey&&!e.button}function hB(){return this.parentNode}function mB(e,t){return t??{x:e.x,y:e.y}}function gB(){return navigator.maxTouchPoints||"ontouchstart"in this}function yP(){var e=pB,t=hB,n=mB,r=gB,s={},o=sg("start","drag","end"),a=0,l,c,u,p,f=0;function d(_){_.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,fB).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(_,S){if(!(p||!e.call(this,_,S))){var N=x(this,t.call(this,_,S),_,S,"mouse");N&&(fs(_.view).on("mousemove.drag",y,Jd).on("mouseup.drag",v,Jd),mP(_.view),Jy(_),u=!1,l=_.clientX,c=_.clientY,N("start",_))}}function y(_){if(Nc(_),!u){var S=_.clientX-l,N=_.clientY-c;u=S*S+N*N>f}s.mouse("drag",_)}function v(_){fs(_.view).on("mousemove.drag mouseup.drag",null),gP(_.view,u),Nc(_),s.mouse("end",_)}function b(_,S){if(e.call(this,_,S)){var N=_.changedTouches,P=t.call(this,_,S),R=N.length,z,E;for(z=0;z<R;++z)(E=x(this,P,_,S,N[z].identifier,N[z]))&&(Jy(_),E("start",_,N[z]))}}function g(_){var S=_.changedTouches,N=S.length,P,R;for(P=0;P<N;++P)(R=s[S[P].identifier])&&(Nc(_),R("drag",_,S[P]))}function k(_){var S=_.changedTouches,N=S.length,P,R;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),P=0;P<N;++P)(R=s[S[P].identifier])&&(Jy(_),R("end",_,S[P]))}function x(_,S,N,P,R,z){var E=o.copy(),O=ni(z||N,S),D,L,M;if((M=n.call(_,new qx("beforestart",{sourceEvent:N,target:d,identifier:R,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:E}),P))!=null)return D=M.x-O[0]||0,L=M.y-O[1]||0,function V(B,F,$){var H=O,A;switch(B){case"start":s[R]=V,A=a++;break;case"end":delete s[R],--a;case"drag":O=ni($||F,S),A=a;break}E.call(B,_,new qx(B,{sourceEvent:F,subject:M,target:d,identifier:R,active:A,x:O[0]+D,y:O[1]+L,dx:O[0]-H[0],dy:O[1]-H[1],dispatch:E}),P)}}return d.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Tp(!!_),d):e},d.container=function(_){return arguments.length?(t=typeof _=="function"?_:Tp(_),d):t},d.subject=function(_){return arguments.length?(n=typeof _=="function"?_:Tp(_),d):n},d.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Tp(!!_),d):r},d.on=function(){var _=o.on.apply(o,arguments);return _===o?d:_},d.clickDistance=function(_){return arguments.length?(f=(_=+_)*_,d):Math.sqrt(f)},d}function Hk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function wP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function _f(){}var Xd=.7,im=1/Xd,_c="\\s*([+-]?\\d+)\\s*",Qd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Mi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",yB=/^#([0-9a-f]{3,8})$/,wB=new RegExp(`^rgb\\(${_c},${_c},${_c}\\)$`),xB=new RegExp(`^rgb\\(${Mi},${Mi},${Mi}\\)$`),bB=new RegExp(`^rgba\\(${_c},${_c},${_c},${Qd}\\)$`),kB=new RegExp(`^rgba\\(${Mi},${Mi},${Mi},${Qd}\\)$`),vB=new RegExp(`^hsl\\(${Qd},${Mi},${Mi}\\)$`),SB=new RegExp(`^hsla\\(${Qd},${Mi},${Mi},${Qd}\\)$`),NN={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Hk(_f,il,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:_N,formatHex:_N,formatHex8:jB,formatHsl:NB,formatRgb:CN,toString:CN});function _N(){return this.rgb().formatHex()}function jB(){return this.rgb().formatHex8()}function NB(){return xP(this).formatHsl()}function CN(){return this.rgb().formatRgb()}function il(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=yB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?AN(t):n===3?new Xr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mp(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=wB.exec(e))?new Xr(t[1],t[2],t[3],1):(t=xB.exec(e))?new Xr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=bB.exec(e))?Mp(t[1],t[2],t[3],t[4]):(t=kB.exec(e))?Mp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=vB.exec(e))?PN(t[1],t[2]/100,t[3]/100,1):(t=SB.exec(e))?PN(t[1],t[2]/100,t[3]/100,t[4]):NN.hasOwnProperty(e)?AN(NN[e]):e==="transparent"?new Xr(NaN,NaN,NaN,0):null}function AN(e){return new Xr(e>>16&255,e>>8&255,e&255,1)}function Mp(e,t,n,r){return r<=0&&(e=t=n=NaN),new Xr(e,t,n,r)}function _B(e){return e instanceof _f||(e=il(e)),e?(e=e.rgb(),new Xr(e.r,e.g,e.b,e.opacity)):new Xr}function Ux(e,t,n,r){return arguments.length===1?_B(e):new Xr(e,t,n,r??1)}function Xr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Hk(Xr,Ux,wP(_f,{brighter(e){return e=e==null?im:Math.pow(im,e),new Xr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Xd:Math.pow(Xd,e),new Xr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Xr(Ja(this.r),Ja(this.g),Ja(this.b),om(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:EN,formatHex:EN,formatHex8:CB,formatRgb:IN,toString:IN}));function EN(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}`}function CB(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}${Va((isNaN(this.opacity)?1:this.opacity)*255)}`}function IN(){const e=om(this.opacity);return`${e===1?"rgb(":"rgba("}${Ja(this.r)}, ${Ja(this.g)}, ${Ja(this.b)}${e===1?")":`, ${e})`}`}function om(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ja(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Va(e){return e=Ja(e),(e<16?"0":"")+e.toString(16)}function PN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ii(e,t,n,r)}function xP(e){if(e instanceof ii)return new ii(e.h,e.s,e.l,e.opacity);if(e instanceof _f||(e=il(e)),!e)return new ii;if(e instanceof ii)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,l=o-s,c=(o+s)/2;return l?(t===o?a=(n-r)/l+(n<r)*6:n===o?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?o+s:2-o-s,a*=60):l=c>0&&c<1?0:a,new ii(a,l,c,e.opacity)}function AB(e,t,n,r){return arguments.length===1?xP(e):new ii(e,t,n,r??1)}function ii(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Hk(ii,AB,wP(_f,{brighter(e){return e=e==null?im:Math.pow(im,e),new ii(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Xd:Math.pow(Xd,e),new ii(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Xr(Xy(e>=240?e-240:e+120,s,r),Xy(e,s,r),Xy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ii(RN(this.h),$p(this.s),$p(this.l),om(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=om(this.opacity);return`${e===1?"hsl(":"hsla("}${RN(this.h)}, ${$p(this.s)*100}%, ${$p(this.l)*100}%${e===1?")":`, ${e})`}`}}));function RN(e){return e=(e||0)%360,e<0?e+360:e}function $p(e){return Math.max(0,Math.min(1,e||0))}function Xy(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Vk=e=>()=>e;function EB(e,t){return function(n){return e+n*t}}function IB(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function PB(e){return(e=+e)==1?bP:function(t,n){return n-t?IB(t,n,e):Vk(isNaN(t)?n:t)}}function bP(e,t){var n=t-e;return n?EB(e,n):Vk(isNaN(e)?t:e)}const am=function e(t){var n=PB(t);function r(s,o){var a=n((s=Ux(s)).r,(o=Ux(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=bP(s.opacity,o.opacity);return function(p){return s.r=a(p),s.g=l(p),s.b=c(p),s.opacity=u(p),s+""}}return r.gamma=e,r}(1);function RB(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=e[s]*(1-o)+t[s]*o;return r}}function TB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function MB(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),o=new Array(n),a;for(a=0;a<r;++a)s[a]=Sd(e[a],t[a]);for(;a<n;++a)o[a]=t[a];return function(l){for(a=0;a<r;++a)o[a]=s[a](l);return o}}function $B(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ji(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function LB(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=Sd(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Gx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qy=new RegExp(Gx.source,"g");function OB(e){return function(){return e}}function DB(e){return function(t){return e(t)+""}}function kP(e,t){var n=Gx.lastIndex=Qy.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Gx.exec(e))&&(s=Qy.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:ji(r,s)})),n=Qy.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?DB(c[0].x):OB(t):(t=c.length,function(u){for(var p=0,f;p<t;++p)l[(f=c[p]).i]=f.x(u);return l.join("")})}function Sd(e,t){var n=typeof t,r;return t==null||n==="boolean"?Vk(t):(n==="number"?ji:n==="string"?(r=il(t))?(t=r,am):kP:t instanceof il?am:t instanceof Date?$B:TB(t)?RB:Array.isArray(t)?MB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?LB:ji)(e,t)}var TN=180/Math.PI,Yx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function vP(e,t,n,r,s,o){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*TN,skewX:Math.atan(c)*TN,scaleX:a,scaleY:l}}var Lp;function FB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Yx:vP(t.a,t.b,t.c,t.d,t.e,t.f)}function zB(e){return e==null||(Lp||(Lp=document.createElementNS("http://www.w3.org/2000/svg","g")),Lp.setAttribute("transform",e),!(e=Lp.transform.baseVal.consolidate()))?Yx:(e=e.matrix,vP(e.a,e.b,e.c,e.d,e.e,e.f))}function SP(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function o(u,p,f,d,h,y){if(u!==f||p!==d){var v=h.push("translate(",null,t,null,n);y.push({i:v-4,x:ji(u,f)},{i:v-2,x:ji(p,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function a(u,p,f,d){u!==p?(u-p>180?p+=360:p-u>180&&(u+=360),d.push({i:f.push(s(f)+"rotate(",null,r)-2,x:ji(u,p)})):p&&f.push(s(f)+"rotate("+p+r)}function l(u,p,f,d){u!==p?d.push({i:f.push(s(f)+"skewX(",null,r)-2,x:ji(u,p)}):p&&f.push(s(f)+"skewX("+p+r)}function c(u,p,f,d,h,y){if(u!==f||p!==d){var v=h.push(s(h)+"scale(",null,",",null,")");y.push({i:v-4,x:ji(u,f)},{i:v-2,x:ji(p,d)})}else(f!==1||d!==1)&&h.push(s(h)+"scale("+f+","+d+")")}return function(u,p){var f=[],d=[];return u=e(u),p=e(p),o(u.translateX,u.translateY,p.translateX,p.translateY,f,d),a(u.rotate,p.rotate,f,d),l(u.skewX,p.skewX,f,d),c(u.scaleX,u.scaleY,p.scaleX,p.scaleY,f,d),u=p=null,function(h){for(var y=-1,v=d.length,b;++y<v;)f[(b=d[y]).i]=b.x(h);return f.join("")}}}var BB=SP(FB,"px, ","px)","deg)"),WB=SP(zB,", ",")",")"),HB=1e-12;function MN(e){return((e=Math.exp(e))+1/e)/2}function VB(e){return((e=Math.exp(e))-1/e)/2}function KB(e){return((e=Math.exp(2*e))-1)/(e+1)}const kh=function e(t,n,r){function s(o,a){var l=o[0],c=o[1],u=o[2],p=a[0],f=a[1],d=a[2],h=p-l,y=f-c,v=h*h+y*y,b,g;if(v<HB)g=Math.log(d/u)/t,b=function(P){return[l+P*h,c+P*y,u*Math.exp(t*P*g)]};else{var k=Math.sqrt(v),x=(d*d-u*u+r*v)/(2*u*n*k),_=(d*d-u*u-r*v)/(2*d*n*k),S=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(_*_+1)-_);g=(N-S)/t,b=function(P){var R=P*g,z=MN(S),E=u/(n*k)*(z*KB(t*R+S)-VB(S));return[l+E*h,c+E*y,u*z/MN(t*R+S)]}}return b.duration=g*1e3*t/Math.SQRT2,b}return s.rho=function(o){var a=Math.max(.001,+o),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Bc=0,id=0,Vu=0,jP=1e3,lm,od,cm=0,ol=0,og=0,Zd=typeof performance=="object"&&performance.now?performance:Date,NP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Kk(){return ol||(NP(qB),ol=Zd.now()+og)}function qB(){ol=0}function um(){this._call=this._time=this._next=null}um.prototype=_P.prototype={constructor:um,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Kk():+n)+(t==null?0:+t),!this._next&&od!==this&&(od?od._next=this:lm=this,od=this),this._call=e,this._time=n,Jx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Jx())}};function _P(e,t,n){var r=new um;return r.restart(e,t,n),r}function UB(){Kk(),++Bc;for(var e=lm,t;e;)(t=ol-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Bc}function $N(){ol=(cm=Zd.now())+og,Bc=id=0;try{UB()}finally{Bc=0,YB(),ol=0}}function GB(){var e=Zd.now(),t=e-cm;t>jP&&(og-=t,cm=e)}function YB(){for(var e,t=lm,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:lm=n);od=e,Jx(r)}function Jx(e){if(!Bc){id&&(id=clearTimeout(id));var t=e-ol;t>24?(e<1/0&&(id=setTimeout($N,e-Zd.now()-og)),Vu&&(Vu=clearInterval(Vu))):(Vu||(cm=Zd.now(),Vu=setInterval(GB,jP)),Bc=1,NP($N))}}function LN(e,t,n){var r=new um;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var JB=sg("start","end","cancel","interrupt"),XB=[],CP=0,ON=1,Xx=2,vh=3,DN=4,Qx=5,Sh=6;function ag(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;QB(e,n,{name:t,index:r,group:s,on:JB,tween:XB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:CP})}function qk(e,t){var n=hi(e,t);if(n.state>CP)throw new Error("too late; already scheduled");return n}function Bi(e,t){var n=hi(e,t);if(n.state>vh)throw new Error("too late; already running");return n}function hi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function QB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=_P(o,0,n.time);function o(u){n.state=ON,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var p,f,d,h;if(n.state!==ON)return c();for(p in r)if(h=r[p],h.name===n.name){if(h.state===vh)return LN(a);h.state===DN?(h.state=Sh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[p]):+p<t&&(h.state=Sh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[p])}if(LN(function(){n.state===vh&&(n.state=DN,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Xx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xx){for(n.state=vh,s=new Array(d=n.tween.length),p=0,f=-1;p<d;++p)(h=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var p=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Qx,1),f=-1,d=s.length;++f<d;)s[f].call(e,p);n.state===Qx&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Sh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function jh(e,t){var n=e.__transition,r,s,o=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){o=!1;continue}s=r.state>Xx&&r.state<Qx,r.state=Sh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function ZB(e){return this.each(function(){jh(this,e)})}function e4(e,t){var n,r;return function(){var s=Bi(this,e),o=s.tween;if(o!==n){r=n=o;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}s.tween=r}}function t4(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Bi(this,e),a=o.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}o.tween=s}}function n4(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=hi(this.node(),n).tween,s=0,o=r.length,a;s<o;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?e4:t4)(n,e,t))}function Uk(e,t,n){var r=e._id;return e.each(function(){var s=Bi(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return hi(s,r).value[t]}}function AP(e,t){var n;return(typeof t=="number"?ji:t instanceof il?am:(n=il(t))?(t=n,am):kP)(e,t)}function r4(e){return function(){this.removeAttribute(e)}}function s4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function i4(e,t,n){var r,s=n+"",o;return function(){var a=this.getAttribute(e);return a===s?null:a===r?o:o=t(r=a,n)}}function o4(e,t,n){var r,s=n+"",o;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?o:o=t(r=a,n)}}function a4(e,t,n){var r,s,o;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l)))}}function l4(e,t,n){var r,s,o;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l)))}}function c4(e,t){var n=ig(e),r=n==="transform"?WB:AP;return this.attrTween(e,typeof t=="function"?(n.local?l4:a4)(n,r,Uk(this,"attr."+e,t)):t==null?(n.local?s4:r4)(n):(n.local?o4:i4)(n,r,t))}function u4(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function d4(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function f4(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&d4(e,o)),n}return s._value=t,s}function p4(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&u4(e,o)),n}return s._value=t,s}function h4(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=ig(e);return this.tween(n,(r.local?f4:p4)(r,t))}function m4(e,t){return function(){qk(this,e).delay=+t.apply(this,arguments)}}function g4(e,t){return t=+t,function(){qk(this,e).delay=t}}function y4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?m4:g4)(t,e)):hi(this.node(),t).delay}function w4(e,t){return function(){Bi(this,e).duration=+t.apply(this,arguments)}}function x4(e,t){return t=+t,function(){Bi(this,e).duration=t}}function b4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?w4:x4)(t,e)):hi(this.node(),t).duration}function k4(e,t){if(typeof t!="function")throw new Error;return function(){Bi(this,e).ease=t}}function v4(e){var t=this._id;return arguments.length?this.each(k4(t,e)):hi(this.node(),t).ease}function S4(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Bi(this,e).ease=n}}function j4(e){if(typeof e!="function")throw new Error;return this.each(S4(this._id,e))}function N4(e){typeof e!="function"&&(e=iP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],a=o.length,l=r[s]=[],c,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new go(r,this._parents,this._name,this._id)}function _4(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=n[l],p=c.length,f=a[l]=new Array(p),d,h=0;h<p;++h)(d=c[h]||u[h])&&(f[h]=d);for(;l<r;++l)a[l]=t[l];return new go(a,this._parents,this._name,this._id)}function C4(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function A4(e,t,n){var r,s,o=C4(t)?qk:Bi;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function E4(e,t){var n=this._id;return arguments.length<2?hi(this.node(),n).on.on(e):this.each(A4(n,e,t))}function I4(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function P4(){return this.on("end.remove",I4(this._id))}function R4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bk(e));for(var r=this._groups,s=r.length,o=new Array(s),a=0;a<s;++a)for(var l=r[a],c=l.length,u=o[a]=new Array(c),p,f,d=0;d<c;++d)(p=l[d])&&(f=e.call(p,p.__data__,d,l))&&("__data__"in p&&(f.__data__=p.__data__),u[d]=f,ag(u[d],t,n,d,u,hi(p,n)));return new go(o,this._parents,t,n)}function T4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sP(e));for(var r=this._groups,s=r.length,o=[],a=[],l=0;l<s;++l)for(var c=r[l],u=c.length,p,f=0;f<u;++f)if(p=c[f]){for(var d=e.call(p,p.__data__,f,c),h,y=hi(p,n),v=0,b=d.length;v<b;++v)(h=d[v])&&ag(h,t,n,v,d,y);o.push(d),a.push(p)}return new go(o,a,t,n)}var M4=Nf.prototype.constructor;function $4(){return new M4(this._groups,this._parents)}function L4(e,t){var n,r,s;return function(){var o=zc(this,e),a=(this.style.removeProperty(e),zc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function EP(e){return function(){this.style.removeProperty(e)}}function O4(e,t,n){var r,s=n+"",o;return function(){var a=zc(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function D4(e,t,n){var r,s,o;return function(){var a=zc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),zc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function F4(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Bi(this,e),u=c.on,p=c.value[o]==null?l||(l=EP(t)):void 0;(u!==n||s!==p)&&(r=(n=u).copy()).on(a,s=p),c.on=r}}function z4(e,t,n){var r=(e+="")=="transform"?BB:AP;return t==null?this.styleTween(e,L4(e,r)).on("end.style."+e,EP(e)):typeof t=="function"?this.styleTween(e,D4(e,r,Uk(this,"style."+e,t))).each(F4(this._id,e)):this.styleTween(e,O4(e,r,t),n).on("end.style."+e,null)}function B4(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function W4(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&B4(e,a,n)),r}return o._value=t,o}function H4(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,W4(e,t,n??""))}function V4(e){return function(){this.textContent=e}}function K4(e){return function(){var t=e(this);this.textContent=t??""}}function q4(e){return this.tween("text",typeof e=="function"?K4(Uk(this,"text",e)):V4(e==null?"":e+""))}function U4(e){return function(t){this.textContent=e.call(this,t)}}function G4(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&U4(s)),t}return r._value=e,r}function Y4(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,G4(e))}function J4(){for(var e=this._name,t=this._id,n=IP(),r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var p=hi(c,t);ag(c,e,n,u,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new go(r,this._parents,e,n)}function X4(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,a){var l={value:a},c={value:function(){--s===0&&o()}};n.each(function(){var u=Bi(this,r),p=u.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&o()})}var Q4=0;function go(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function IP(){return++Q4}var Ji=Nf.prototype;go.prototype={constructor:go,select:R4,selectAll:T4,selectChild:Ji.selectChild,selectChildren:Ji.selectChildren,filter:N4,merge:_4,selection:$4,transition:J4,call:Ji.call,nodes:Ji.nodes,node:Ji.node,size:Ji.size,empty:Ji.empty,each:Ji.each,on:E4,attr:c4,attrTween:h4,style:z4,styleTween:H4,text:q4,textTween:Y4,remove:P4,tween:n4,delay:y4,duration:b4,ease:v4,easeVarying:j4,end:X4,[Symbol.iterator]:Ji[Symbol.iterator]};function Z4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eW={time:null,delay:0,duration:250,ease:Z4};function tW(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function nW(e){var t,n;e instanceof go?(t=e._id,e=e._name):(t=IP(),(n=eW).time=Kk(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)(c=a[u])&&ag(c,e,t,u,a,n||tW(c,t));return new go(r,this._parents,e,t)}Nf.prototype.interrupt=ZB;Nf.prototype.transition=nW;const Op=e=>()=>e;function rW(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function so(e,t,n){this.k=e,this.x=t,this.y=n}so.prototype={constructor:so,scale:function(e){return e===1?this:new so(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new so(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var lg=new so(1,0,0);PP.prototype=so.prototype;function PP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return lg;return e.__zoom}function Zy(e){e.stopImmediatePropagation()}function Ku(e){e.preventDefault(),e.stopImmediatePropagation()}function sW(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function iW(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function FN(){return this.__zoom||lg}function oW(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function aW(){return navigator.maxTouchPoints||"ontouchstart"in this}function lW(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function RP(){var e=sW,t=iW,n=lW,r=oW,s=aW,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=kh,u=sg("start","zoom","end"),p,f,d,h=500,y=150,v=0,b=10;function g(M){M.property("__zoom",FN).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",E).filter(s).on("touchstart.zoom",O).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(M,V,B,F){var $=M.selection?M.selection():M;$.property("__zoom",FN),M!==$?S(M,V,B,F):$.interrupt().each(function(){N(this,arguments).event(F).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},g.scaleBy=function(M,V,B,F){g.scaleTo(M,function(){var $=this.__zoom.k,H=typeof V=="function"?V.apply(this,arguments):V;return $*H},B,F)},g.scaleTo=function(M,V,B,F){g.transform(M,function(){var $=t.apply(this,arguments),H=this.__zoom,A=B==null?_($):typeof B=="function"?B.apply(this,arguments):B,Q=H.invert(A),K=typeof V=="function"?V.apply(this,arguments):V;return n(x(k(H,K),A,Q),$,a)},B,F)},g.translateBy=function(M,V,B,F){g.transform(M,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),a)},null,F)},g.translateTo=function(M,V,B,F,$){g.transform(M,function(){var H=t.apply(this,arguments),A=this.__zoom,Q=F==null?_(H):typeof F=="function"?F.apply(this,arguments):F;return n(lg.translate(Q[0],Q[1]).scale(A.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof B=="function"?-B.apply(this,arguments):-B),H,a)},F,$)};function k(M,V){return V=Math.max(o[0],Math.min(o[1],V)),V===M.k?M:new so(V,M.x,M.y)}function x(M,V,B){var F=V[0]-B[0]*M.k,$=V[1]-B[1]*M.k;return F===M.x&&$===M.y?M:new so(M.k,F,$)}function _(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function S(M,V,B,F){M.on("start.zoom",function(){N(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(F).end()}).tween("zoom",function(){var $=this,H=arguments,A=N($,H).event(F),Q=t.apply($,H),K=B==null?_(Q):typeof B=="function"?B.apply($,H):B,W=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),te=$.__zoom,Z=typeof V=="function"?V.apply($,H):V,G=c(te.invert(K).concat(W/te.k),Z.invert(K).concat(W/Z.k));return function(ne){if(ne===1)ne=Z;else{var re=G(ne),se=W/re[2];ne=new so(se,K[0]-re[0]*se,K[1]-re[1]*se)}A.zoom(null,ne)}})}function N(M,V,B){return!B&&M.__zooming||new P(M,V)}function P(M,V){this.that=M,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,V),this.taps=0}P.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,V){return this.mouse&&M!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var V=fs(this.that).datum();u.call(M,this.that,new rW(M,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),V)}};function R(M,...V){if(!e.apply(this,arguments))return;var B=N(this,V).event(M),F=this.__zoom,$=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),H=ni(M);if(B.wheel)(B.mouse[0][0]!==H[0]||B.mouse[0][1]!==H[1])&&(B.mouse[1]=F.invert(B.mouse[0]=H)),clearTimeout(B.wheel);else{if(F.k===$)return;B.mouse=[H,F.invert(H)],jh(this),B.start()}Ku(M),B.wheel=setTimeout(A,y),B.zoom("mouse",n(x(k(F,$),B.mouse[0],B.mouse[1]),B.extent,a));function A(){B.wheel=null,B.end()}}function z(M,...V){if(d||!e.apply(this,arguments))return;var B=M.currentTarget,F=N(this,V,!0).event(M),$=fs(M.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",W,!0),H=ni(M,B),A=M.clientX,Q=M.clientY;mP(M.view),Zy(M),F.mouse=[H,this.__zoom.invert(H)],jh(this),F.start();function K(te){if(Ku(te),!F.moved){var Z=te.clientX-A,G=te.clientY-Q;F.moved=Z*Z+G*G>v}F.event(te).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=ni(te,B),F.mouse[1]),F.extent,a))}function W(te){$.on("mousemove.zoom mouseup.zoom",null),gP(te.view,F.moved),Ku(te),F.event(te).end()}}function E(M,...V){if(e.apply(this,arguments)){var B=this.__zoom,F=ni(M.changedTouches?M.changedTouches[0]:M,this),$=B.invert(F),H=B.k*(M.shiftKey?.5:2),A=n(x(k(B,H),F,$),t.apply(this,V),a);Ku(M),l>0?fs(this).transition().duration(l).call(S,A,F,M):fs(this).call(g.transform,A,F,M)}}function O(M,...V){if(e.apply(this,arguments)){var B=M.touches,F=B.length,$=N(this,V,M.changedTouches.length===F).event(M),H,A,Q,K;for(Zy(M),A=0;A<F;++A)Q=B[A],K=ni(Q,this),K=[K,this.__zoom.invert(K),Q.identifier],$.touch0?!$.touch1&&$.touch0[2]!==K[2]&&($.touch1=K,$.taps=0):($.touch0=K,H=!0,$.taps=1+!!p);p&&(p=clearTimeout(p)),H&&($.taps<2&&(f=K[0],p=setTimeout(function(){p=null},h)),jh(this),$.start())}}function D(M,...V){if(this.__zooming){var B=N(this,V).event(M),F=M.changedTouches,$=F.length,H,A,Q,K;for(Ku(M),H=0;H<$;++H)A=F[H],Q=ni(A,this),B.touch0&&B.touch0[2]===A.identifier?B.touch0[0]=Q:B.touch1&&B.touch1[2]===A.identifier&&(B.touch1[0]=Q);if(A=B.that.__zoom,B.touch1){var W=B.touch0[0],te=B.touch0[1],Z=B.touch1[0],G=B.touch1[1],ne=(ne=Z[0]-W[0])*ne+(ne=Z[1]-W[1])*ne,re=(re=G[0]-te[0])*re+(re=G[1]-te[1])*re;A=k(A,Math.sqrt(ne/re)),Q=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],K=[(te[0]+G[0])/2,(te[1]+G[1])/2]}else if(B.touch0)Q=B.touch0[0],K=B.touch0[1];else return;B.zoom("touch",n(x(A,Q,K),B.extent,a))}}function L(M,...V){if(this.__zooming){var B=N(this,V).event(M),F=M.changedTouches,$=F.length,H,A;for(Zy(M),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),H=0;H<$;++H)A=F[H],B.touch0&&B.touch0[2]===A.identifier?delete B.touch0:B.touch1&&B.touch1[2]===A.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(A=ni(A,this),Math.hypot(f[0]-A[0],f[1]-A[1])<b)){var Q=fs(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return g.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:Op(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:Op(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:Op(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:Op([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),g):t},g.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],g):[o[0],o[1]]},g.translateExtent=function(M){return arguments.length?(a[0][0]=+M[0][0],a[1][0]=+M[1][0],a[0][1]=+M[0][1],a[1][1]=+M[1][1],g):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},g.constrain=function(M){return arguments.length?(n=M,g):n},g.duration=function(M){return arguments.length?(l=+M,g):l},g.interpolate=function(M){return arguments.length?(c=M,g):c},g.on=function(){var M=u.on.apply(u,arguments);return M===u?g:M},g.clickDistance=function(M){return arguments.length?(v=(M=+M)*M,g):Math.sqrt(v)},g.tapDistance=function(M){return arguments.length?(b=+M,g):b},g}const Fi={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ef=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],TP=["Enter"," ","Escape"],MP={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Wc;(function(e){e.Strict="strict",e.Loose="loose"})(Wc||(Wc={}));var Xa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Xa||(Xa={}));var tf;(function(e){e.Partial="partial",e.Full="full"})(tf||(tf={}));const $P={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Vo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Vo||(Vo={}));var Ai;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ai||(Ai={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));const zN={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top};function LP(e){return e===null?null:e?"valid":"invalid"}const OP=e=>"id"in e&&"source"in e&&"target"in e,cW=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Cf=(e,t=[0,0])=>{const{width:n,height:r}=ko(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},uW=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const o=typeof s=="string";let a=!t.nodeLookup&&!o?s:void 0;t.nodeLookup&&(a=o?t.nodeLookup.get(s):Gk(s)?s:t.nodeLookup.get(s.id));const l=a?dm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return cg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ug(n)},Af=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=cg(n,dm(s)),r=!0)}),r?ug(n):{x:0,y:0,width:0,height:0}},Yk=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...If(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:p,selectable:f=!0,hidden:d=!1}=u;if(a&&!f||d)continue;const h=p.width??u.width??u.initialWidth??null,y=p.height??u.height??u.initialHeight??null,v=nf(l,Vc(u)),b=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},dW=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function fW(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function pW({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=fW(e,a),c=Af(l),u=Jk(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??o,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function DP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:o}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Fi.error005());else{const h=l.measured.width,y=l.measured.height;h&&y&&(f=[[c,u],[c+h,u+y]])}else l&&Kc(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const d=Kc(f)?al(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Fi.error015())),{position:{x:d.x-c+(a.measured.width??0)*p[0],y:d.y-u+(a.measured.height??0)*p[1]},positionAbsolute:d}}async function hW({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(d=>d.id)),a=[];for(const d of n){if(d.deletable===!1)continue;const h=o.has(d.id),y=!h&&d.parentId&&a.find(v=>v.id===d.parentId);(h||y)&&a.push(d)}const l=new Set(t.map(d=>d.id)),c=r.filter(d=>d.deletable!==!1),p=dW(a,c);for(const d of c)l.has(d.id)&&!p.find(y=>y.id===d.id)&&p.push(d);if(!s)return{edges:p,nodes:a};const f=await s({nodes:a,edges:p});return typeof f=="boolean"?f?{edges:p,nodes:a}:{edges:[],nodes:[]}:f}const Hc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),al=(e={x:0,y:0},t,n)=>({x:Hc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Hc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function FP(e,t,n){const{width:r,height:s}=ko(n),{x:o,y:a}=n.internals.positionAbsolute;return al(e,[[o,a],[o+r,a+s]],t)}const BN=(e,t,n)=>e<t?Hc(Math.abs(e-t),1,t)/t:e>n?-Hc(Math.abs(e-n),1,t)/t:0,zP=(e,t,n=15,r=40)=>{const s=BN(e.x,r,t.width-r)*n,o=BN(e.y,r,t.height-r)*n;return[s,o]},cg=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zx=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),ug=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Vc=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Gk(e)?e.internals.positionAbsolute:Cf(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},dm=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Gk(e)?e.internals.positionAbsolute:Cf(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},BP=(e,t)=>ug(cg(Zx(e),Zx(t))),nf=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},WN=e=>oi(e.width)&&oi(e.height)&&oi(e.x)&&oi(e.y),oi=e=>!isNaN(e)&&isFinite(e),mW=(e,t)=>{},Ef=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),If=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?Ef(l,a):l},fm=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function ql(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gW(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ql(e,n),s=ql(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=ql(e.top??e.y??0,n),s=ql(e.bottom??e.y??0,n),o=ql(e.left??e.x??0,t),a=ql(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:o,x:o+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function yW(e,t,n,r,s,o){const{x:a,y:l}=fm(e,[t,n,r]),{x:c,y:u}=fm({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=s-c,f=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(f)}}const Jk=(e,t,n,r,s,o)=>{const a=gW(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),p=Hc(u,r,s),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*p,y=n/2-d*p,v=yW(e,h,y,p,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:h-b.left+b.right,y:y-b.top+b.bottom,zoom:p}},rf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Kc(e){return e!=null&&e!=="parent"}function ko(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function WP(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function HP(e,t={width:0,height:0},n,r,s){const o={...e},a=r.get(n);if(a){const l=a.origin||s;o.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],o.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return o}function HN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function wW(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function xW(e){return{...MP,...e||{}}}function jd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=ai(e),l=If({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?Ef(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Xk=e=>({width:e.offsetWidth,height:e.offsetHeight}),VP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},bW=["INPUT","SELECT","TEXTAREA"];function KP(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:bW.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const qP=e=>"clientX"in e,ai=(e,t)=>{var o,a;const n=qP(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},VN=(e,t,n,r,s)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:s,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...Xk(a)}})};function UP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,u=t*.125+o*.375+l*.375+r*.125,p=Math.abs(c-e),f=Math.abs(u-t);return[c,u,p,f]}function Dp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function KN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ue.Left:return[t-Dp(t-r,o),n];case Ue.Right:return[t+Dp(r-t,o),n];case Ue.Top:return[t,n-Dp(n-s,o)];case Ue.Bottom:return[t,n+Dp(s-n,o)]}}function GP({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top,curvature:a=.25}){const[l,c]=KN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,p]=KN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[f,d,h,y]=UP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:p});return[`M${e},${t} C${l},${c} ${u},${p} ${r},${s}`,f,d,h,y]}function YP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[o,l,s,a]}function kW({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const a=s&&n?r+1e3:r,l=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return a+l}function vW({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=cg(dm(e),dm(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return nf(a,ug(o))>0}const SW=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,jW=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Nh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||SW;let s;return OP(e)?s={...e}:s={...e,id:r(e)},jW(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function JP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=YP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const qN={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},NW=({source:e,sourcePosition:t=Ue.Bottom,target:n})=>t===Ue.Left||t===Ue.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},UN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function _W({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:r=Ue.Top,center:s,offset:o,stepPosition:a}){const l=qN[t],c=qN[r],u={x:e.x+l.x*o,y:e.y+l.y*o},p={x:n.x+c.x*o,y:n.y+c.y*o},f=NW({source:u,sourcePosition:t,target:p}),d=f.x!==0?"x":"y",h=f[d];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,_]=YP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*c[d]===-1){d==="x"?(v=s.x??u.x+(p.x-u.x)*a,b=s.y??(u.y+p.y)/2):(v=s.x??(u.x+p.x)/2,b=s.y??u.y+(p.y-u.y)*a);const R=[{x:v,y:u.y},{x:v,y:p.y}],z=[{x:u.x,y:b},{x:p.x,y:b}];l[d]===h?y=d==="x"?R:z:y=d==="x"?z:R}else{const R=[{x:u.x,y:p.y}],z=[{x:p.x,y:u.y}];if(d==="x"?y=l.x===h?z:R:y=l.y===h?R:z,t===r){const M=Math.abs(e[d]-n[d]);if(M<=o){const V=Math.min(o-1,o-M);l[d]===h?g[d]=(u[d]>e[d]?-1:1)*V:k[d]=(p[d]>n[d]?-1:1)*V}}if(t!==r){const M=d==="x"?"y":"x",V=l[d]===c[M],B=u[M]>p[M],F=u[M]<p[M];(l[d]===1&&(!V&&B||V&&F)||l[d]!==1&&(!V&&F||V&&B))&&(y=d==="x"?R:z)}const E={x:u.x+g.x,y:u.y+g.y},O={x:p.x+k.x,y:p.y+k.y},D=Math.max(Math.abs(E.x-y[0].x),Math.abs(O.x-y[0].x)),L=Math.max(Math.abs(E.y-y[0].y),Math.abs(O.y-y[0].y));D>=L?(v=(E.x+O.x)/2,b=y[0].y):(v=y[0].x,b=(E.y+O.y)/2)}const S={x:u.x+g.x,y:u.y+g.y},N={x:p.x+k.x,y:p.y+k.y};return[[e,...S.x!==y[0].x||S.y!==y[0].y?[S]:[],...y,...N.x!==y[y.length-1].x||N.y!==y[y.length-1].y?[N]:[],n],v,b,x,_]}function CW(e,t,n,r){const s=Math.min(UN(e,t)/2,UN(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+s*u},${a}Q ${o},${a} ${o},${a+s*p}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${a+s*c}Q ${o},${a} ${o+s*l},${a}`}function eb({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:p=.5}){const[f,d,h,y,v]=_W({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:p});let b=`M${f[0].x} ${f[0].y}`;for(let g=1;g<f.length-1;g++)b+=CW(f[g-1],f[g],f[g+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,d,h,y,v]}function GN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function AW(e){var f;const{sourceNode:t,targetNode:n}=e;if(!GN(t)||!GN(n))return null;const r=t.internals.handleBounds||YN(t.handles),s=n.internals.handleBounds||YN(n.handles),o=JN((r==null?void 0:r.source)??[],e.sourceHandle),a=JN(e.connectionMode===Wc.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!o||!a)return(f=e.onError)==null||f.call(e,"008",Fi.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||Ue.Bottom,c=(a==null?void 0:a.position)||Ue.Top,u=ll(t,o,l),p=ll(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:c}}function YN(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function ll(e,t,n=Ue.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??ko(e);if(r)return{x:s+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case Ue.Top:return{x:s+a/2,y:o};case Ue.Right:return{x:s+a,y:o+l/2};case Ue.Bottom:return{x:s+a/2,y:o+l};case Ue.Left:return{x:s,y:o+l/2}}}function JN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function tb(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function EW(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const o=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const u=tb(c,t);o.has(u)||(a.push({id:u,color:c.color||n,...c}),o.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const XP=1e3,IW=10,Qk={nodeOrigin:[0,0],nodeExtent:ef,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},PW={...Qk,checkEquality:!0};function Zk(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function RW(e,t,n){const r=Zk(Qk,n);for(const s of e.values())if(s.parentId)tv(s,e,t,r);else{const o=Cf(s,r.nodeOrigin),a=Kc(s.extent)?s.extent:r.nodeExtent,l=al(o,a,ko(s));s.internals.positionAbsolute=l}}function TW(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const o={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(o):s.type==="target"&&r.push(o)}return{source:n,target:r}}function ev(e){return e==="manual"}function nb(e,t,n,r={}){var p,f;const s=Zk(PW,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!ev(s.zIndexMode)?XP:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let h=a.get(d.id);if(s.checkEquality&&d===(h==null?void 0:h.internals.userNode))t.set(d.id,h);else{const y=Cf(d,s.nodeOrigin),v=Kc(d.extent)?d.extent:s.nodeExtent,b=al(y,v,ko(d));h={...s.defaults,...d,measured:{width:(p=d.measured)==null?void 0:p.width,height:(f=d.measured)==null?void 0:f.height},internals:{positionAbsolute:b,handleBounds:TW(d,h),z:QP(d,l,s.zIndexMode),userNode:d}},t.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),d.parentId&&tv(h,t,n,r,o),u||(u=d.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function MW(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function tv(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Zk(Qk,r),u=e.parentId,p=t.get(u);if(!p){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}MW(e,n),s&&!p.parentId&&p.internals.rootParentIndex===void 0&&c==="auto"&&(p.internals.rootParentIndex=++s.i,p.internals.z=p.internals.z+s.i*IW),s&&p.internals.rootParentIndex!==void 0&&(s.i=p.internals.rootParentIndex);const f=o&&!ev(c)?XP:0,{x:d,y:h,z:y}=$W(e,p,a,l,f,c),{positionAbsolute:v}=e.internals,b=d!==v.x||h!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:d,y:h}:v,z:y}})}function QP(e,t,n){const r=oi(e.zIndex)?e.zIndex:0;return ev(n)?r:r+(e.selected?t:0)}function $W(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=ko(e),u=Cf(e,n),p=Kc(e.extent)?al(u,e.extent,c):u;let f=al({x:a+p.x,y:l+p.y},r,c);e.extent==="parent"&&(f=FP(f,c,t));const d=QP(e,s,o),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function nv(e,t,n,r=[0,0]){var a;const s=[],o=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const u=((a=o.get(l.parentId))==null?void 0:a.expandedRect)??Vc(c),p=BP(u,l.rect);o.set(l.parentId,{expandedRect:p,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const p=c.internals.positionAbsolute,f=ko(c),d=c.origin??r,h=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,y=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,v=Math.max(f.width,Math.round(l.width)),b=Math.max(f.height,Math.round(l.height)),g=(v-f.width)*d[0],k=(b-f.height)*d[1];(h>0||y>0||g||k)&&(s.push({id:u,type:"position",position:{x:c.position.x-h+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(_=>{e.some(S=>S.id===_.id)||s.push({id:_.id,type:"position",position:{x:_.position.x+h,y:_.position.y+y}})})),(f.width<l.width||f.height<l.height||h||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?d[0]*h-g:0),height:b+(y?d[1]*y-k:0)}})}),s}function LW(e,t,n,r,s,o,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],p=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(p.transform),d=[];for(const h of e.values()){const y=t.get(h.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=Xk(h.nodeElement),b=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!y.internals.handleBounds||h.force))){const k=h.nodeElement.getBoundingClientRect(),x=Kc(y.extent)?y.extent:o;let{positionAbsolute:_}=y.internals;y.parentId&&y.extent==="parent"?_=FP(_,v,t.get(y.parentId)):x&&(_=al(_,x,v));const S={...y,measured:v,internals:{...y.internals,positionAbsolute:_,handleBounds:{source:VN("source",h.nodeElement,k,f,y.id),target:VN("target",h.nodeElement,k,f,y.id)}}};t.set(y.id,S),y.parentId&&tv(S,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&d.push({id:y.id,parentId:y.parentId,rect:Vc(S,s)}))}}if(d.length>0){const h=nv(d,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function OW({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,o]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function XN(e,t,n,r,s,o){let a=s;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${s}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),o){a=`${s}-${e}-${o}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function ZP(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:o,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:o,sourceHandle:a,targetHandle:l},u=`${s}-${a}--${o}-${l}`,p=`${o}-${l}--${s}-${a}`;XN("source",c,p,e,s,a),XN("target",c,u,e,o,l),t.set(r.id,r)}}function eR(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:eR(n,t):!1}function QN(e,t,n){var s;let r=e;do{if((s=r==null?void 0:r.matches)!=null&&s.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function DW(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!eR(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(o);l&&s.set(o,{id:o,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return s}function ew({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,p]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:p.position,dragging:r})}if(!e)return[s[0],s];const o=(l=n.get(e))==null?void 0:l.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:r}:s[0],s]}function FW({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const o={x:n-s.distance.x,y:r-s.distance.y},a=Ef(o,t);return{x:a.x-o.x,y:a.y-o.y}}function zW({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},p=null,f=!1,d=null,h=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:_,isSelectable:S,nodeId:N,nodeClickDistance:P=0}){d=fs(_);function R({x:D,y:L}){const{nodeLookup:M,nodeExtent:V,snapGrid:B,snapToGrid:F,nodeOrigin:$,onNodeDrag:H,onSelectionDrag:A,onError:Q,updateNodePositions:K}=t();o={x:D,y:L};let W=!1;const te=l.size>1,Z=te&&V?Zx(Af(l)):null,G=te&&F?FW({dragItems:l,snapGrid:B,x:D,y:L}):null;for(const[ne,re]of l){if(!M.has(ne))continue;let se={x:D-re.distance.x,y:L-re.distance.y};F&&(se=G?{x:Math.round(se.x+G.x),y:Math.round(se.y+G.y)}:Ef(se,B));let ee=null;if(te&&V&&!re.extent&&Z){const{positionAbsolute:pe}=re.internals,Me=pe.x-Z.x+V[0][0],Ne=pe.x+re.measured.width-Z.x2+V[1][0],_e=pe.y-Z.y+V[0][1],He=pe.y+re.measured.height-Z.y2+V[1][1];ee=[[Me,_e],[Ne,He]]}const{position:ue,positionAbsolute:de}=DP({nodeId:ne,nextPosition:se,nodeLookup:M,nodeExtent:ee||V,nodeOrigin:$,onError:Q});W=W||re.position.x!==ue.x||re.position.y!==ue.y,re.position=ue,re.internals.positionAbsolute=de}if(y=y||W,!!W&&(K(l,!0),v&&(r||H||!N&&A))){const[ne,re]=ew({nodeId:N,dragItems:l,nodeLookup:M});r==null||r(v,l,ne,re),H==null||H(v,ne,re),N||A==null||A(v,re)}}async function z(){if(!p)return;const{transform:D,panBy:L,autoPanSpeed:M,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(a);return}const[B,F]=zP(u,p,M);(B!==0||F!==0)&&(o.x=(o.x??0)-B/D[2],o.y=(o.y??0)-F/D[2],await L({x:B,y:F})&&R(o)),a=requestAnimationFrame(z)}function E(D){var te;const{nodeLookup:L,multiSelectionActive:M,nodesDraggable:V,transform:B,snapGrid:F,snapToGrid:$,selectNodesOnDrag:H,onNodeDragStart:A,onSelectionDragStart:Q,unselectNodesAndEdges:K}=t();f=!0,(!H||!S)&&!M&&N&&((te=L.get(N))!=null&&te.selected||K()),S&&H&&N&&(e==null||e(N));const W=jd(D.sourceEvent,{transform:B,snapGrid:F,snapToGrid:$,containerBounds:p});if(o=W,l=DW(L,V,W,N),l.size>0&&(n||A||!N&&Q)){const[Z,G]=ew({nodeId:N,dragItems:l,nodeLookup:L});n==null||n(D.sourceEvent,l,Z,G),A==null||A(D.sourceEvent,Z,G),N||Q==null||Q(D.sourceEvent,G)}}const O=yP().clickDistance(P).on("start",D=>{const{domNode:L,nodeDragThreshold:M,transform:V,snapGrid:B,snapToGrid:F}=t();p=(L==null?void 0:L.getBoundingClientRect())||null,h=!1,y=!1,v=D.sourceEvent,M===0&&E(D),o=jd(D.sourceEvent,{transform:V,snapGrid:B,snapToGrid:F,containerBounds:p}),u=ai(D.sourceEvent,p)}).on("drag",D=>{const{autoPanOnNodeDrag:L,transform:M,snapGrid:V,snapToGrid:B,nodeDragThreshold:F,nodeLookup:$}=t(),H=jd(D.sourceEvent,{transform:M,snapGrid:V,snapToGrid:B,containerBounds:p});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||N&&!$.has(N))&&(h=!0),!h){if(!c&&L&&f&&(c=!0,z()),!f){const A=ai(D.sourceEvent,p),Q=A.x-u.x,K=A.y-u.y;Math.sqrt(Q*Q+K*K)>F&&E(D)}(o.x!==H.xSnapped||o.y!==H.ySnapped)&&l&&f&&(u=ai(D.sourceEvent,p),R(H))}}).on("end",D=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:L,updateNodePositions:M,onNodeDragStop:V,onSelectionDragStop:B}=t();if(y&&(M(l,!1),y=!1),s||V||!N&&B){const[F,$]=ew({nodeId:N,dragItems:l,nodeLookup:L,dragging:!1});s==null||s(D.sourceEvent,l,F,$),V==null||V(D.sourceEvent,F,$),N||B==null||B(D.sourceEvent,$)}}}).filter(D=>{const L=D.target;return!D.button&&(!k||!QN(L,`.${k}`,_))&&(!x||QN(L,x,_))});d.call(O)}function g(){d==null||d.on(".drag",null)}return{update:b,destroy:g}}function BW(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())nf(s,Vc(o))>0&&r.push(o);return r}const WW=250;function HW(e,t,n,r){var l,c;let s=[],o=1/0;const a=BW(e,n,t+WW);for(const u of a){const p=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of p){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:d,y:h}=ll(u,f,f.position,!0),y=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(h-e.y,2));y>t||(y<o?(s=[{...f,x:d,y:h}],o=y):y===o&&s.push({...f,x:d,y:h}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(p=>p.type===u)??s[0]}return s[0]}function tR(e,t,n,r,s,o=!1){var u,p,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...ll(a,c,c.position,!0)}:c}function nR(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function VW(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const rR=()=>!0;function KW(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:p,flowId:f,panBy:d,cancelConnection:h,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=rR,onReconnectEnd:k,updateConnection:x,getTransform:_,getFromHandle:S,autoPanSpeed:N,dragThreshold:P=1,handleDomNode:R}){const z=VP(e.target);let E=0,O;const{x:D,y:L}=ai(e),M=nR(o,R),V=l==null?void 0:l.getBoundingClientRect();let B=!1;if(!V||!M)return;const F=tR(s,M,r,c,t);if(!F)return;let $=ai(e,V),H=!1,A=null,Q=!1,K=null;function W(){if(!p||!V)return;const[ue,de]=zP($,V,N);d({x:ue,y:de}),E=requestAnimationFrame(W)}const te={...F,nodeId:s,type:M,position:F.position},Z=c.get(s);let ne={inProgress:!0,isValid:null,from:ll(Z,te,Ue.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:Z,to:$,toHandle:null,toPosition:zN[te.position],toNode:null,pointer:$};function re(){B=!0,x(ne),y==null||y(e,{nodeId:s,handleId:r,handleType:M})}P===0&&re();function se(ue){if(!B){const{x:He,y:ct}=ai(ue),yt=He-D,Re=ct-L;if(!(yt*yt+Re*Re>P*P))return;re()}if(!S()||!te){ee(ue);return}const de=_();$=ai(ue,V),O=HW(If($,de,!1,[1,1]),n,c,te),H||(W(),H=!0);const pe=sR(ue,{handle:O,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:z,lib:u,flowId:f,nodeLookup:c});K=pe.handleDomNode,A=pe.connection,Q=VW(!!O,pe.isValid);const Me=c.get(s),Ne=Me?ll(Me,te,Ue.Left,!0):ne.from,_e={...ne,from:Ne,isValid:Q,to:pe.toHandle&&Q?fm({x:pe.toHandle.x,y:pe.toHandle.y},de):$,toHandle:pe.toHandle,toPosition:Q&&pe.toHandle?pe.toHandle.position:zN[te.position],toNode:pe.toHandle?c.get(pe.toHandle.nodeId):null,pointer:$};x(_e),ne=_e}function ee(ue){if(!("touches"in ue&&ue.touches.length>0)){if(B){(O||K)&&A&&Q&&(v==null||v(A));const{inProgress:de,...pe}=ne,Me={...pe,toPosition:ne.toHandle?ne.toPosition:null};b==null||b(ue,Me),o&&(k==null||k(ue,Me))}h(),cancelAnimationFrame(E),H=!1,Q=!1,A=null,K=null,z.removeEventListener("mousemove",se),z.removeEventListener("mouseup",ee),z.removeEventListener("touchmove",se),z.removeEventListener("touchend",ee)}}z.addEventListener("mousemove",se),z.addEventListener("mouseup",ee),z.addEventListener("touchmove",se),z.addEventListener("touchend",ee)}function sR(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=rR,nodeLookup:p}){const f=o==="target",d=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y}=ai(e),v=a.elementFromPoint(h,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:d,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=nR(void 0,b),x=b.getAttribute("data-nodeid"),_=b.getAttribute("data-handleid"),S=b.classList.contains("connectable"),N=b.classList.contains("connectableend");if(!x||!k)return g;const P={source:f?x:r,sourceHandle:f?_:s,target:f?r:x,targetHandle:f?s:_};g.connection=P;const z=S&&N&&(n===Wc.Strict?f&&k==="source"||!f&&k==="target":x!==r||_!==s);g.isValid=z&&u(P),g.toHandle=tR(x,k,_,p,n,!0)}return g}const rb={onPointerDown:KW,isValid:sR};function qW({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=fs(e);function o({translateExtent:l,width:c,height:u,zoomStep:p=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const _=n(),S=x.sourceEvent.ctrlKey&&rf()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*p,P=_[2]*Math.pow(2,N*S);t.scaleTo(P)};let v=[0,0];const b=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(v=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},g=x=>{const _=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const S=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],N=[S[0]-v[0],S[1]-v[1]];v=S;const P=r()*Math.max(_[2],Math.log(_[2]))*(h?-1:1),R={x:_[0]-N[0]*P,y:_[1]-N[1]*P},z=[[0,0],[c,u]];t.setViewportConstrained({x:R.x,y:R.y,zoom:_[2]},z,l)},k=RP().on("start",b).on("zoom",f?g:null).on("zoom.wheel",d?y:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:ni}}const dg=e=>({x:e.x,y:e.y,zoom:e.k}),tw=({x:e,y:t,zoom:n})=>lg.translate(e,t).scale(n),hc=(e,t)=>e.target.closest(`.${t}`),iR=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),UW=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,nw=(e,t=0,n=UW,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},oR=e=>{const t=e.ctrlKey&&rf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function GW({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return p=>{if(hc(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(p.ctrlKey&&a){const b=ni(p),g=oR(p),k=f*Math.pow(2,g);r.scaleTo(n,k,b,p);return}const d=p.deltaMode===1?20:1;let h=s===Xa.Vertical?0:p.deltaX*d,y=s===Xa.Horizontal?0:p.deltaY*d;!rf()&&p.shiftKey&&s!==Xa.Vertical&&(h=p.deltaY*d,y=0),r.translateBy(n,-(h/f)*o,-(y/f)*o,{internal:!0});const v=dg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(p,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(p,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,v))}}function YW({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=hc(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function JW({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=dg(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function XW({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&iR(t,e.mouseButton??0)),(a=o.sourceEvent)!=null&&a.sync||r([o.transform.x,o.transform.y,o.transform.k]),s&&!((l=o.sourceEvent)!=null&&l.internal)&&(s==null||s(o.sourceEvent,dg(o.transform)))}}function QW({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:o}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,o&&iR(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=dg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function ZW({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:p}){return f=>{var b;const d=e||t,h=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(hc(f,`${u}-flow__node`)||hc(f,`${u}-flow__edge`)))return!0;if(!r&&!d&&!s&&!o&&!n||a||p&&!y||hc(f,l)&&y||hc(f,c)&&(!y||s&&y&&!e)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&((b=f.touches)==null?void 0:b.length)>1)return f.preventDefault(),!1;if(!d&&!s&&!h&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function e5({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),f=RP().scaleExtent([t,n]).translateExtent(r),d=fs(e).call(f);k({x:s.x,y:s.y,zoom:Hc(s.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=d.on("wheel.zoom"),y=d.on("dblclick.zoom");f.wheelDelta(oR);function v(O,D){return d?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Sd:kh).transform(nw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function b({noWheelClassName:O,noPanClassName:D,onPaneContextMenu:L,userSelectionActive:M,panOnScroll:V,panOnDrag:B,panOnScrollMode:F,panOnScrollSpeed:$,preventScrolling:H,zoomOnPinch:A,zoomOnScroll:Q,zoomOnDoubleClick:K,zoomActivationKeyPressed:W,lib:te,onTransformChange:Z,connectionInProgress:G,paneClickDistance:ne,selectionOnDrag:re}){M&&!u.isZoomingOrPanning&&g();const se=V&&!W&&!M;f.clickDistance(re?1/0:!oi(ne)||ne<0?0:ne);const ee=se?GW({zoomPanValues:u,noWheelClassName:O,d3Selection:d,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:$,zoomOnPinch:A,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):YW({noWheelClassName:O,preventScrolling:H,d3ZoomHandler:h});if(d.on("wheel.zoom",ee,{passive:!1}),!M){const de=JW({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const pe=XW({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!L,onPanZoom:o,onTransformChange:Z});f.on("zoom",pe);const Me=QW({zoomPanValues:u,panOnDrag:B,panOnScroll:V,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",Me)}const ue=ZW({zoomActivationKeyPressed:W,panOnDrag:B,zoomOnScroll:Q,panOnScroll:V,zoomOnDoubleClick:K,zoomOnPinch:A,userSelectionActive:M,noPanClassName:D,noWheelClassName:O,lib:te,connectionInProgress:G});f.filter(ue),K?d.on("dblclick.zoom",y):d.on("dblclick.zoom",null)}function g(){f.on("zoom",null)}async function k(O,D,L){const M=tw(O),V=f==null?void 0:f.constrain()(M,D,L);return V&&await v(V),new Promise(B=>B(V))}async function x(O,D){const L=tw(O);return await v(L,D),new Promise(M=>M(L))}function _(O){if(d){const D=tw(O),L=d.property("__zoom");(L.k!==O.zoom||L.x!==O.x||L.y!==O.y)&&(f==null||f.transform(d,D,null,{sync:!0}))}}function S(){const O=d?PP(d.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function N(O,D){return d?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Sd:kh).scaleTo(nw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function P(O,D){return d?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Sd:kh).scaleBy(nw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function R(O){f==null||f.scaleExtent(O)}function z(O){f==null||f.translateExtent(O)}function E(O){const D=!oi(O)||O<0?0:O;f==null||f.clickDistance(D)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:S,scaleTo:N,scaleBy:P,setScaleExtent:R,setTranslateExtent:z,syncViewport:_,setClickDistance:E}}var qc;(function(e){e.Line="line",e.Handle="handle"})(qc||(qc={}));function t5({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:o}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(c[0]=c[0]*-1),l&&o&&(c[1]=c[1]*-1),c}function ZN(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function $o(e,t){return Math.max(0,t-e)}function Lo(e,t){return Math.max(0,e-t)}function Fp(e,t,n){return Math.max(0,t-e,e-n)}function e1(e,t){return e?!t:t}function n5(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:p,isVertical:f}=t,d=p&&f,{xSnapped:h,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:_,width:S,height:N,aspectRatio:P}=e;let R=Math.floor(p?h-e.pointerX:0),z=Math.floor(f?y-e.pointerY:0);const E=S+(c?-R:R),O=N+(u?-z:z),D=-o[0]*S,L=-o[1]*N;let M=Fp(E,v,b),V=Fp(O,g,k);if(a){let $=0,H=0;c&&R<0?$=$o(x+R+D,a[0][0]):!c&&R>0&&($=Lo(x+E+D,a[1][0])),u&&z<0?H=$o(_+z+L,a[0][1]):!u&&z>0&&(H=Lo(_+O+L,a[1][1])),M=Math.max(M,$),V=Math.max(V,H)}if(l){let $=0,H=0;c&&R>0?$=Lo(x+R,l[0][0]):!c&&R<0&&($=$o(x+E,l[1][0])),u&&z>0?H=Lo(_+z,l[0][1]):!u&&z<0&&(H=$o(_+O,l[1][1])),M=Math.max(M,$),V=Math.max(V,H)}if(s){if(p){const $=Fp(E/P,g,k)*P;if(M=Math.max(M,$),a){let H=0;!c&&!u||c&&!u&&d?H=Lo(_+L+E/P,a[1][1])*P:H=$o(_+L+(c?R:-R)/P,a[0][1])*P,M=Math.max(M,H)}if(l){let H=0;!c&&!u||c&&!u&&d?H=$o(_+E/P,l[1][1])*P:H=Lo(_+(c?R:-R)/P,l[0][1])*P,M=Math.max(M,H)}}if(f){const $=Fp(O*P,v,b)/P;if(V=Math.max(V,$),a){let H=0;!c&&!u||u&&!c&&d?H=Lo(x+O*P+D,a[1][0])/P:H=$o(x+(u?z:-z)*P+D,a[0][0])/P,V=Math.max(V,H)}if(l){let H=0;!c&&!u||u&&!c&&d?H=$o(x+O*P,l[1][0])/P:H=Lo(x+(u?z:-z)*P,l[0][0])/P,V=Math.max(V,H)}}}z=z+(z<0?V:-V),R=R+(R<0?M:-M),s&&(d?E>O*P?z=(e1(c,u)?-R:R)/P:R=(e1(c,u)?-z:z)*P:p?(z=R/P,u=c):(R=z*P,c=u));const B=c?x+R:x,F=u?_+z:_;return{width:S+(c?-R:R),height:N+(u?-z:z),x:o[0]*R*(c?-1:1)+B,y:o[1]*z*(u?-1:1)+F}}const aR={width:0,height:0,x:0,y:0},r5={...aR,pointerX:0,pointerY:0,aspectRatio:1};function s5(e){return[[0,0],[e.measured.width,e.measured.height]]}function i5(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,l=n[0]*o,c=n[1]*a;return[[r-l,s-c],[r+o-l,s+a-c]]}function o5({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=fs(e);let a={controlDirection:ZN("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:p,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...aR},k={...r5};a={boundaries:p,resizeDirection:d,keepAspectRatio:f,controlDirection:ZN(u)};let x,_=null,S=[],N,P,R,z=!1;const E=yP().on("start",O=>{const{nodeLookup:D,transform:L,snapGrid:M,snapToGrid:V,nodeOrigin:B,paneDomNode:F}=n();if(x=D.get(t),!x)return;_=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:H}=jd(O.sourceEvent,{transform:L,snapGrid:M,snapToGrid:V,containerBounds:_});g={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},k={...g,pointerX:$,pointerY:H,aspectRatio:g.width/g.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=D.get(x.parentId),P=N&&x.extent==="parent"?s5(N):void 0),S=[],R=void 0;for(const[A,Q]of D)if(Q.parentId===t&&(S.push({id:A,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const K=i5(Q,x,Q.origin??B);R?R=[[Math.min(K[0][0],R[0][0]),Math.min(K[0][1],R[0][1])],[Math.max(K[1][0],R[1][0]),Math.max(K[1][1],R[1][1])]]:R=K}h==null||h(O,{...g})}).on("drag",O=>{const{transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V}=n(),B=jd(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:M,containerBounds:_}),F=[];if(!x)return;const{x:$,y:H,width:A,height:Q}=g,K={},W=x.origin??V,{width:te,height:Z,x:G,y:ne}=n5(k,a.controlDirection,B,a.boundaries,a.keepAspectRatio,W,P,R),re=te!==A,se=Z!==Q,ee=G!==$&&re,ue=ne!==H&&se;if(!ee&&!ue&&!re&&!se)return;if((ee||ue||W[0]===1||W[1]===1)&&(K.x=ee?G:g.x,K.y=ue?ne:g.y,g.x=K.x,g.y=K.y,S.length>0)){const Ne=G-$,_e=ne-H;for(const He of S)He.position={x:He.position.x-Ne+W[0]*(te-A),y:He.position.y-_e+W[1]*(Z-Q)},F.push(He)}if((re||se)&&(K.width=re&&(!a.resizeDirection||a.resizeDirection==="horizontal")?te:g.width,K.height=se&&(!a.resizeDirection||a.resizeDirection==="vertical")?Z:g.height,g.width=K.width,g.height=K.height),N&&x.expandParent){const Ne=W[0]*(K.width??0);K.x&&K.x<Ne&&(g.x=Ne,k.x=k.x-(K.x-Ne));const _e=W[1]*(K.height??0);K.y&&K.y<_e&&(g.y=_e,k.y=k.y-(K.y-_e))}const de=t5({width:g.width,prevWidth:A,height:g.height,prevHeight:Q,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),pe={...g,direction:de};(b==null?void 0:b(O,pe))!==!1&&(z=!0,y==null||y(O,pe),r(K,F))}).on("end",O=>{z&&(v==null||v(O,{...g}),s==null||s({...g}),z=!1)});o.call(E)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var lR={exports:{}},cR={},uR={exports:{}},dR={};/**
45
- * @license React
46
- * use-sync-external-store-shim.production.js
47
- *
48
- * Copyright (c) Meta Platforms, Inc. and affiliates.
49
- *
50
- * This source code is licensed under the MIT license found in the
51
- * LICENSE file in the root directory of this source tree.
52
- */var Uc=m;function a5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var l5=typeof Object.is=="function"?Object.is:a5,c5=Uc.useState,u5=Uc.useEffect,d5=Uc.useLayoutEffect,f5=Uc.useDebugValue;function p5(e,t){var n=t(),r=c5({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return d5(function(){s.value=n,s.getSnapshot=t,rw(s)&&o({inst:s})},[e,n,t]),u5(function(){return rw(s)&&o({inst:s}),e(function(){rw(s)&&o({inst:s})})},[e]),f5(n),n}function rw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!l5(e,n)}catch{return!0}}function h5(e,t){return t()}var m5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h5:p5;dR.useSyncExternalStore=Uc.useSyncExternalStore!==void 0?Uc.useSyncExternalStore:m5;uR.exports=dR;var fR=uR.exports;/**
53
- * @license React
54
- * use-sync-external-store-shim/with-selector.production.js
55
- *
56
- * Copyright (c) Meta Platforms, Inc. and affiliates.
57
- *
58
- * This source code is licensed under the MIT license found in the
59
- * LICENSE file in the root directory of this source tree.
60
- */var fg=m,g5=fR;function y5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var w5=typeof Object.is=="function"?Object.is:y5,x5=g5.useSyncExternalStore,b5=fg.useRef,k5=fg.useEffect,v5=fg.useMemo,S5=fg.useDebugValue;cR.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=b5(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=v5(function(){function c(h){if(!u){if(u=!0,p=h,h=r(h),s!==void 0&&a.hasValue){var y=a.value;if(s(y,h))return f=y}return f=h}if(y=f,w5(p,h))return y;var v=r(h);return s!==void 0&&s(y,v)?(p=h,y):(p=h,f=v)}var u=!1,p,f,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,s]);var l=x5(e,o[0],o[1]);return k5(function(){a.hasValue=!0,a.value=l},[l]),S5(l),l};lR.exports=cR;var j5=lR.exports;const N5=ma(j5),_5={},t1=e=>{let t;const n=new Set,r=(p,f)=>{const d=typeof p=="function"?p(t):p;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(y=>y(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(_5?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},C5=e=>e?t1(e):t1,{useDebugValue:A5}=pt,{useSyncExternalStoreWithSelector:E5}=N5,I5=e=>e;function pR(e,t=I5,n){const r=E5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return A5(r),r}const n1=(e,t)=>{const n=C5(e),r=(s,o=t)=>pR(n,s,o);return Object.assign(r,n),r},P5=(e,t)=>e?n1(e,t):n1;function bn(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const pg=m.createContext(null),R5=pg.Provider,hR=Fi.error001();function Vt(e,t){const n=m.useContext(pg);if(n===null)throw new Error(hR);return pR(n,e,t)}function dn(){const e=m.useContext(pg);if(e===null)throw new Error(hR);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const r1={display:"none"},T5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},mR="react-flow__node-desc",gR="react-flow__edge-desc",M5="react-flow__aria-live",$5=e=>e.ariaLiveMessage,L5=e=>e.ariaLabelConfig;function O5({rfId:e}){const t=Vt($5);return i.jsx("div",{id:`${M5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:T5,children:t})}function D5({rfId:e,disableKeyboardA11y:t}){const n=Vt(L5);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${mR}-${e}`,style:r1,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${gR}-${e}`,style:r1,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(O5,{rfId:e})]})}const hg=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Un(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});hg.displayName="Panel";function F5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(hg,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:i.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const z5=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},zp=e=>e.id;function B5(e,t){return bn(e.selectedNodes.map(zp),t.selectedNodes.map(zp))&&bn(e.selectedEdges.map(zp),t.selectedEdges.map(zp))}function W5({onSelectionChange:e}){const t=dn(),{selectedNodes:n,selectedEdges:r}=Vt(z5,B5);return m.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const H5=e=>!!e.onSelectionChangeHandlers;function V5({onSelectionChange:e}){const t=Vt(H5);return e||t?i.jsx(W5,{onSelectionChange:e}):null}const sb=typeof window<"u"?m.useLayoutEffect:m.useEffect,yR=[0,0],K5={x:0,y:0,zoom:1},q5=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],s1=[...q5,"rfId"],U5=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),i1={translateExtent:ef,nodeOrigin:yR,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function G5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Vt(U5,bn),u=dn();sb(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=i1,l()}),[]);const p=m.useRef(i1);return sb(()=>{for(const f of s1){const d=e[f],h=p.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?r(d):f==="maxZoom"?s(d):f==="translateExtent"?o(d):f==="nodeExtent"?a(d):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:xW(d)}):f==="fitView"?u.setState({fitViewQueued:d}):f==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[f]:d})))}p.current=e},s1.map(f=>e[f])),null}function o1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Y5(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=o1(),o=()=>n(s!=null&&s.matches?"dark":"light");return o(),s==null||s.addEventListener("change",o),()=>{s==null||s.removeEventListener("change",o)}},[e]),t!==null?t:(r=o1())!=null&&r.matches?"dark":"light"}const a1=typeof document<"u"?document:null;function sf(e=null,t={target:a1,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),o=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),p=u.reduce((f,d)=>f.concat(...d),[]);return[u,p]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??a1,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=h=>{var b,g;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&KP(h))return!1;const v=c1(h.code,l);if(o.current.add(h[v]),l1(a,o.current,!1)){const k=((g=(b=h.composedPath)==null?void 0:b.call(h))==null?void 0:g[0])||h.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const y=c1(h.code,l);l1(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[y]),h.key==="Meta"&&o.current.clear(),s.current=!1},d=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",p),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",p),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function l1(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function c1(e,t){return t.includes(e)?"code":"key"}const J5=()=>{const e=dn();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=Jk(t,r,s,o,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),u={x:t.x-l,y:t.y-c},p=n.snapGrid??s,f=n.snapToGrid??o;return If(u,r,f,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=fm(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function wR(e,t){const n=[],r=new Map,s=[];for(const o of e)if(o.type==="add"){s.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...o};for(const c of a)X5(c,l);n.push(l)}return s.length&&s.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function X5(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Nd(e,t){return wR(e,t)}function pm(e,t){return wR(e,t)}function La(e,t){return{id:e,type:"select",selected:t}}function mc(e,t=new Set,n=!1){const r=[];for(const[s,o]of e){const a=t.has(s);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(La(o.id,a)))}return r}function u1({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,a]of e.entries()){const l=t.get(a.id),c=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function d1(e){return{id:e.id,type:"remove"}}const f1=e=>cW(e),Q5=e=>OP(e);function xR(e){return m.forwardRef(e)}function p1(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>Z5(()=>n(s=>s+BigInt(1))));return sb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function Z5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const bR=m.createContext(null);function eH({children:e}){const t=dn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:p,onNodesChange:f,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=u1({items:v,lookup:d});for(const g of y.values())b=g(b);p&&u(v),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=p1(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:p,onEdgesChange:f,edgeLookup:d}=t.getState();let h=c;for(const y of l)h=typeof y=="function"?y(h):y;p?u(h):f&&f(u1({items:h,lookup:d}))},[]),o=p1(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(bR.Provider,{value:a,children:e})}function tH(){const e=m.useContext(bR);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const nH=e=>!!e.panZoom;function tu(){const e=J5(),t=dn(),n=tH(),r=Vt(nH),s=m.useMemo(()=>{const o=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var g,k;const{nodeLookup:d,nodeOrigin:h}=t.getState(),y=f1(f)?f:d.get(f.id),v=y.parentId?HP(y.position,y.measured,y.parentId,d,h):y.position,b={...y,position:v,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((k=y.measured)==null?void 0:k.height)??y.height};return Vc(b)},u=(f,d,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const b=typeof d=="function"?d(v):d;return h.replace&&f1(b)?b:{...v,...b}}return v}))},p=(f,d,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const b=typeof d=="function"?d(v):d;return h.replace&&Q5(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var d;return(d=o(f))==null?void 0:d.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:h}=t.getState(),[y,v,b]=h;return{nodes:f.map(g=>({...g})),edges:d.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:h,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:_}=t.getState(),{nodes:S,edges:N}=await hW({nodesToRemove:f,edgesToRemove:d,nodes:h,edges:y,onBeforeDelete:_}),P=N.length>0,R=S.length>0;if(P){const z=N.map(d1);b==null||b(N),k(z)}if(R){const z=S.map(d1);v==null||v(S),g(z)}return(R||P)&&(x==null||x({nodes:S,edges:N})),{deletedNodes:S,deletedEdges:N}},getIntersectingNodes:(f,d=!0,h)=>{const y=WN(f),v=y?f:c(f),b=h!==void 0;return v?(h||t.getState().nodes).filter(g=>{const k=t.getState().nodeLookup.get(g.id);if(k&&!y&&(g.id===f.id||!k.internals.positionAbsolute))return!1;const x=Vc(b?g:k),_=nf(x,v);return d&&_>0||_>=x.width*x.height||_>=v.width*v.height}):[]},isNodeIntersecting:(f,d,h=!0)=>{const v=WN(f)?f:c(f);if(!v)return!1;const b=nf(v,d);return h&&b>0||b>=d.width*d.height||b>=v.width*v.height},updateNode:u,updateNodeData:(f,d,h={replace:!1})=>{u(f,y=>{const v=typeof d=="function"?d(y):d;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},updateEdge:p,updateEdgeData:(f,d,h={replace:!1})=>{p(f,y=>{const v=typeof d=="function"?d(y):d;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState();return uW(f,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:f,id:d,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}-${f}${d?`-${d}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:d,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}${f?d?`-${f}-${d}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const d=t.getState().fitViewResolver??wW();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const h1=e=>e.selected,rH=typeof window<"u"?window:void 0;function sH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=dn(),{deleteElements:r}=tu(),s=sf(e,{actInsideInputWithModifier:!1}),o=sf(t,{target:rH});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(h1),edges:a.filter(h1)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function iH(e){const t=dn();m.useEffect(()=>{const n=()=>{var s,o,a,l;if(!e.current||!(((o=(s=e.current).checkVisibility)==null?void 0:o.call(s))??!0))return!1;const r=Xk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Fi.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const mg={position:"absolute",width:"100%",height:"100%",top:0,left:0},oH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function aH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=Xa.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:p,maxZoom:f,zoomActivationKeyCode:d,preventScrolling:h=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:_}){const S=dn(),N=m.useRef(null),{userSelectionActive:P,lib:R,connectionInProgress:z}=Vt(oH,bn),E=sf(d),O=m.useRef();iH(N);const D=m.useCallback(L=>{g==null||g({x:L[0],y:L[1],zoom:L[2]}),k||S.setState({transform:L})},[g,k]);return m.useEffect(()=>{if(N.current){O.current=e5({domNode:N.current,minZoom:p,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:B=>S.setState(F=>F.paneDragging===B?F:{paneDragging:B}),onPanZoomStart:(B,F)=>{const{onViewportChangeStart:$,onMoveStart:H}=S.getState();H==null||H(B,F),$==null||$(F)},onPanZoom:(B,F)=>{const{onViewportChange:$,onMove:H}=S.getState();H==null||H(B,F),$==null||$(F)},onPanZoomEnd:(B,F)=>{const{onViewportChangeEnd:$,onMoveEnd:H}=S.getState();H==null||H(B,F),$==null||$(F)}});const{x:L,y:M,zoom:V}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[L,M,V],domNode:N.current.closest(".react-flow")}),()=>{var B;(B=O.current)==null||B.destroy()}}},[]),m.useEffect(()=>{var L;(L=O.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:E,preventScrolling:h,noPanClassName:b,userSelectionActive:P,noWheelClassName:v,lib:R,onTransformChange:D,connectionInProgress:z,selectionOnDrag:_,paneClickDistance:x})},[e,t,n,r,s,o,a,l,E,h,b,P,v,R,D,z,_,x]),i.jsx("div",{className:"react-flow__renderer",ref:N,style:mg,children:y})}const lH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function cH(){const{userSelectionActive:e,userSelectionRect:t}=Vt(lH,bn);return e&&t?i.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const sw=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},uH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function dH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=tf.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:p,onPaneMouseEnter:f,onPaneMouseMove:d,onPaneMouseLeave:h,children:y}){const v=dn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Vt(uH,bn),_=g&&(e||b),S=m.useRef(null),N=m.useRef(),P=m.useRef(new Set),R=m.useRef(new Set),z=m.useRef(!1),E=$=>{if(z.current||x){z.current=!1;return}c==null||c($),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},O=$=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){$.preventDefault();return}u==null||u($)},D=p?$=>p($):void 0,L=$=>{z.current&&($.stopPropagation(),z.current=!1)},M=$=>{var Z,G;const{domNode:H}=v.getState();if(N.current=H==null?void 0:H.getBoundingClientRect(),!N.current)return;const A=$.target===S.current;if(!A&&!!$.target.closest(".nokey")||!e||!(o&&A||t)||$.button!==0||!$.isPrimary)return;(G=(Z=$.target)==null?void 0:Z.setPointerCapture)==null||G.call(Z,$.pointerId),z.current=!1;const{x:W,y:te}=ai($.nativeEvent,N.current);v.setState({userSelectionRect:{width:0,height:0,startX:W,startY:te,x:W,y:te}}),A||($.stopPropagation(),$.preventDefault())},V=$=>{const{userSelectionRect:H,transform:A,nodeLookup:Q,edgeLookup:K,connectionLookup:W,triggerNodeChanges:te,triggerEdgeChanges:Z,defaultEdgeOptions:G,resetSelectedElements:ne}=v.getState();if(!N.current||!H)return;const{x:re,y:se}=ai($.nativeEvent,N.current),{startX:ee,startY:ue}=H;if(!z.current){const _e=t?0:s;if(Math.hypot(re-ee,se-ue)<=_e)return;ne(),a==null||a($)}z.current=!0;const de={startX:ee,startY:ue,x:re<ee?re:ee,y:se<ue?se:ue,width:Math.abs(re-ee),height:Math.abs(se-ue)},pe=P.current,Me=R.current;P.current=new Set(Yk(Q,de,A,n===tf.Partial,!0).map(_e=>_e.id)),R.current=new Set;const Ne=(G==null?void 0:G.selectable)??!0;for(const _e of P.current){const He=W.get(_e);if(He)for(const{edgeId:ct}of He.values()){const yt=K.get(ct);yt&&(yt.selectable??Ne)&&R.current.add(ct)}}if(!HN(pe,P.current)){const _e=mc(Q,P.current,!0);te(_e)}if(!HN(Me,R.current)){const _e=mc(K,R.current);Z(_e)}v.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},B=$=>{var H,A;$.button===0&&((A=(H=$.target)==null?void 0:H.releasePointerCapture)==null||A.call(H,$.pointerId),!b&&$.target===S.current&&v.getState().userSelectionRect&&(E==null||E($)),v.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(l==null||l($),v.setState({nodesSelectionActive:P.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:Un(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:_?void 0:sw(E,S),onContextMenu:sw(O,S),onWheel:sw(D,S),onPointerEnter:_?void 0:f,onPointerMove:_?V:d,onPointerUp:_?B:void 0,onPointerDownCapture:_?M:void 0,onClickCapture:_?L:void 0,onPointerLeave:h,ref:S,style:mg,children:[y,i.jsx(cH,{})]})}function ib({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Fi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):s([e])}function kR({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=dn(),[c,u]=m.useState(!1),p=m.useRef();return m.useEffect(()=>{p.current=zW({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{ib({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=p.current)==null||f.destroy()}},[n,r,t,o,e,s,a]),c}const fH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function vR(){const e=dn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:p}=e.getState(),f=new Map,d=fH(a),h=s?o[0]:5,y=s?o[1]:5,v=n.direction.x*h*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!d(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};s&&(k=Ef(k,o));const{position:x,positionAbsolute:_}=DP({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:p,onError:l});g.position=x,g.internals.positionAbsolute=_,f.set(g.id,g)}c(f)},[])}const rv=m.createContext(null),pH=rv.Provider;rv.Consumer;const SR=()=>m.useContext(rv),hH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),mH=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,p=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:p,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===Wc.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:p&&u}};function gH({type:e="source",position:t=Ue.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:p,onTouchStart:f,...d},h){var V,B;const y=a||null,v=e==="target",b=dn(),g=SR(),{connectOnClick:k,noPanClassName:x,rfId:_}=Vt(hH,bn),{connectingFrom:S,connectingTo:N,clickConnecting:P,isPossibleEndHandle:R,connectionInProcess:z,clickConnectionInProcess:E,valid:O}=Vt(mH(g,y,e),bn);g||(B=(V=b.getState()).onError)==null||B.call(V,"010",Fi.error010());const D=F=>{const{defaultEdgeOptions:$,onConnect:H,hasDefaultEdges:A}=b.getState(),Q={...$,...F};if(A){const{edges:K,setEdges:W}=b.getState();W(Nh(Q,K))}H==null||H(Q),l==null||l(Q)},L=F=>{if(!g)return;const $=qP(F.nativeEvent);if(s&&($&&F.button===0||!$)){const H=b.getState();rb.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:H.autoPanOnConnect,connectionMode:H.connectionMode,connectionRadius:H.connectionRadius,domNode:H.domNode,nodeLookup:H.nodeLookup,lib:H.lib,isTarget:v,handleId:y,nodeId:g,flowId:H.rfId,panBy:H.panBy,cancelConnection:H.cancelConnection,onConnectStart:H.onConnectStart,onConnectEnd:(...A)=>{var Q,K;return(K=(Q=b.getState()).onConnectEnd)==null?void 0:K.call(Q,...A)},updateConnection:H.updateConnection,onConnect:D,isValidConnection:n||((...A)=>{var Q,K;return((K=(Q=b.getState()).isValidConnection)==null?void 0:K.call(Q,...A))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:H.autoPanSpeed,dragThreshold:H.connectionDragThreshold})}$?p==null||p(F):f==null||f(F)},M=F=>{const{onClickConnectStart:$,onClickConnectEnd:H,connectionClickStartHandle:A,connectionMode:Q,isValidConnection:K,lib:W,rfId:te,nodeLookup:Z,connection:G}=b.getState();if(!g||!A&&!s)return;if(!A){$==null||$(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ne=VP(F.target),re=n||K,{connection:se,isValid:ee}=rb.isValid(F.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:Q,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:re,flowId:te,doc:ne,lib:W,nodeLookup:Z});ee&&se&&D(se);const ue=structuredClone(G);delete ue.inProgress,ue.toPosition=ue.toHandle?ue.toHandle.position:null,H==null||H(F,ue),b.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${_}-${g}-${y}-${e}`,className:Un(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:P,connectingfrom:S,connectingto:N,valid:O,connectionindicator:r&&(!z||R)&&(z||E?o:s)}]),onMouseDown:L,onTouchStart:L,onClick:k?M:void 0,ref:h,...d,children:c})}const qn=m.memo(xR(gH));function yH({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(qn,{type:"source",position:n,isConnectable:t})]})}function wH({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:r=Ue.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(qn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(qn,{type:"source",position:r,isConnectable:t})]})}function xH(){return null}function bH({data:e,isConnectable:t,targetPosition:n=Ue.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(qn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const hm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},m1={input:yH,default:wH,output:bH,group:xH};function kH(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const vH=e=>{const{width:t,height:n,x:r,y:s}=Af(e.nodeLookup,{filter:o=>!!o.selected});return{width:oi(t)?t:null,height:oi(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function SH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=dn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Vt(vH,bn),c=vR(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const p=!l&&s!==null&&o!==null;if(kR({nodeRef:u,disabled:!p}),!p)return null;const f=e?h=>{const y=r.getState().nodes.filter(v=>v.selected);e(h,y)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(hm,h.key)&&(h.preventDefault(),c({direction:hm[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:Un(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:s,height:o}})})}const g1=typeof window<"u"?window:void 0,jH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function jR({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:p,selectionMode:f,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:_,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:P,panOnDrag:R,defaultViewport:z,translateExtent:E,minZoom:O,maxZoom:D,preventScrolling:L,onSelectionContextMenu:M,noWheelClassName:V,noPanClassName:B,disableKeyboardA11y:F,onViewportChange:$,isControlledViewport:H}){const{nodesSelectionActive:A,userSelectionActive:Q}=Vt(jH,bn),K=sf(u,{target:g1}),W=sf(v,{target:g1}),te=W||R,Z=W||_,G=p&&te!==!0,ne=K||Q||G;return sH({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(aH,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:Z,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:P,panOnDrag:!K&&te,defaultViewport:z,translateExtent:E,minZoom:O,maxZoom:D,zoomActivationKeyCode:b,preventScrolling:L,noWheelClassName:V,noPanClassName:B,onViewportChange:$,isControlledViewport:H,paneClickDistance:l,selectionOnDrag:G,children:i.jsxs(dH,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:te,isSelecting:!!ne,selectionMode:f,selectionKeyPressed:K,paneClickDistance:l,selectionOnDrag:G,children:[e,A&&i.jsx(SH,{onSelectionContextMenu:M,noPanClassName:B,disableKeyboardA11y:F})]})})}jR.displayName="FlowRenderer";const NH=m.memo(jR),_H=e=>t=>e?Yk(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function CH(e){return Vt(m.useCallback(_H(e),[e]),bn)}const AH=e=>e.updateNodeInternals;function EH(){const e=Vt(AH),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const o=s.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:s.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function IH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=dn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),p=n&&!!e.internals.handleBounds;return m.useEffect(()=>{o.current&&!e.hidden&&(!p||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[p,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const f=u.current!==t,d=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||d||h)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function PH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:p,resizeObserver:f,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:_,isParent:S}=Vt(re=>{const se=re.nodeLookup.get(e),ee=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:ee}},bn);let N=x.type||"default",P=(b==null?void 0:b[N])||m1[N];P===void 0&&(k==null||k("003",Fi.error003(N)),N="default",P=(b==null?void 0:b.default)||m1.default);const R=!!(x.draggable||l&&typeof x.draggable>"u"),z=!!(x.selectable||c&&typeof x.selectable>"u"),E=!!(x.connectable||u&&typeof x.connectable>"u"),O=!!(x.focusable||p&&typeof x.focusable>"u"),D=dn(),L=WP(x),M=IH({node:x,nodeType:N,hasDimensions:L,resizeObserver:f}),V=kR({nodeRef:M,disabled:x.hidden||!R,noDragClassName:d,handleSelector:x.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:g}),B=vR();if(x.hidden)return null;const F=ko(x),$=kH(x),H=z||R||t||n||r||s,A=n?re=>n(re,{..._.userNode}):void 0,Q=r?re=>r(re,{..._.userNode}):void 0,K=s?re=>s(re,{..._.userNode}):void 0,W=o?re=>o(re,{..._.userNode}):void 0,te=a?re=>a(re,{..._.userNode}):void 0,Z=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:ee}=D.getState();z&&(!se||!R||ee>0)&&ib({id:e,store:D,nodeRef:M}),t&&t(re,{..._.userNode})},G=re=>{if(!(KP(re.nativeEvent)||y)){if(TP.includes(re.key)&&z){const se=re.key==="Escape";ib({id:e,store:D,unselect:se,nodeRef:M})}else if(R&&x.selected&&Object.prototype.hasOwnProperty.call(hm,re.key)){re.preventDefault();const{ariaLabelConfig:se}=D.getState();D.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),B({direction:hm[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Me;if(y||!((Me=M.current)!=null&&Me.matches(":focus-visible")))return;const{transform:re,width:se,height:ee,autoPanOnNodeFocus:ue,setCenter:de}=D.getState();if(!ue)return;Yk(new Map([[e,x]]),{x:0,y:0,width:se,height:ee},re,!0).length>0||de(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:re[2]})};return i.jsx("div",{className:Un(["react-flow__node",`react-flow__node-${N}`,{[h]:R},x.className,{selected:x.selected,selectable:z,parent:S,draggable:R,dragging:V}]),ref:M,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:H?"all":"none",visibility:L?"visible":"hidden",...x.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:A,onMouseMove:Q,onMouseLeave:K,onContextMenu:W,onClick:Z,onDoubleClick:te,onKeyDown:O?G:void 0,tabIndex:O?0:void 0,onFocus:O?ne:void 0,role:x.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${mR}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(pH,{value:e,children:i.jsx(P,{id:e,data:x.data,type:N,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:x.selected??!1,selectable:z,draggable:R,deletable:x.deletable??!0,isConnectable:E,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:V,dragHandle:x.dragHandle,zIndex:_.z,parentId:x.parentId,...F})})})}var RH=m.memo(PH);const TH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function NR(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Vt(TH,bn),a=CH(e.onlyRenderVisibleElements),l=EH();return i.jsx("div",{className:"react-flow__nodes",style:mg,children:a.map(c=>i.jsx(RH,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}NR.displayName="NodeRenderer";const MH=m.memo(NR);function $H(e){return Vt(m.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const o=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);o&&a&&vW({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),bn)}const LH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return i.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},OH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return i.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},y1={[Ai.Arrow]:LH,[Ai.ArrowClosed]:OH};function DH(e){const t=dn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(y1,e)?y1[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Fi.error009(e)),null)},[e])}const FH=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=DH(t);return c?i.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0",children:i.jsx(c,{color:n,strokeWidth:a})}):null},_R=({defaultColor:e,rfId:t})=>{const n=Vt(o=>o.edges),r=Vt(o=>o.defaultEdgeOptions),s=m.useMemo(()=>EW(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?i.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:i.jsx("defs",{children:s.map(o=>i.jsx(FH,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};_R.displayName="MarkerDefinitions";var zH=m.memo(_R);function CR({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...p}){const[f,d]=m.useState({x:1,y:0,width:0,height:0}),h=Un(["react-flow__edge-textwrapper",u]),y=m.useRef(null);return m.useEffect(()=>{if(y.current){const v=y.current.getBBox();d({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?i.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...p,children:[s&&i.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),i.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}CR.displayName="EdgeText";const BH=m.memo(CR);function gg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...p}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...p,d:e,fill:"none",className:Un(["react-flow__edge-path",p.className])}),u?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&oi(t)&&oi(n)?i.jsx(BH,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function w1({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ue.Left||e===Ue.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function AR({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top}){const[a,l]=w1({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=w1({pos:o,x1:r,y1:s,x2:e,y2:t}),[p,f,d,h]=UP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,p,f,d,h]}function ER(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,_]=AR({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),S=e.isInternal?void 0:t;return i.jsx(gg,{id:S,path:k,labelX:x,labelY:_,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const WH=ER({isInternal:!1}),IR=ER({isInternal:!0});WH.displayName="SimpleBezierEdge";IR.displayName="SimpleBezierEdgeInternal";function PR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,sourcePosition:h=Ue.Bottom,targetPosition:y=Ue.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,S]=eb({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:o,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),N=e.isInternal?void 0:t;return i.jsx(gg,{id:N,path:x,labelX:_,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:v,markerStart:b,interactionWidth:k})})}const RR=PR({isInternal:!1}),TR=PR({isInternal:!0});RR.displayName="SmoothStepEdge";TR.displayName="SmoothStepEdgeInternal";function MR(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(RR,{...n,id:r,pathOptions:m.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const HH=MR({isInternal:!1}),$R=MR({isInternal:!0});HH.displayName="StepEdge";$R.displayName="StepEdgeInternal";function LR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:y,interactionWidth:v})=>{const[b,g,k]=JP({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(gg,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:y,interactionWidth:v})})}const VH=LR({isInternal:!1}),OR=LR({isInternal:!0});VH.displayName="StraightEdge";OR.displayName="StraightEdgeInternal";function DR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,S]=GP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),N=e.isInternal?void 0:t;return i.jsx(gg,{id:N,path:x,labelX:_,labelY:S,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const KH=DR({isInternal:!1}),FR=DR({isInternal:!0});KH.displayName="BezierEdge";FR.displayName="BezierEdgeInternal";const x1={default:FR,straight:OR,step:$R,smoothstep:TR,simplebezier:IR},b1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},qH=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,UH=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,k1="react-flow__edgeupdater";function v1({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:a,type:l}){return i.jsx("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:a,className:Un([k1,`${k1}-${l}`]),cx:qH(t,r,e),cy:UH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function GH({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:p,onReconnectEnd:f,setReconnecting:d,setUpdateHover:h}){const y=dn(),v=(_,S)=>{if(_.button!==0)return;const{autoPanOnConnect:N,domNode:P,connectionMode:R,connectionRadius:z,lib:E,onConnectStart:O,cancelConnection:D,nodeLookup:L,rfId:M,panBy:V,updateConnection:B}=y.getState(),F=S.type==="target",$=(Q,K)=>{d(!1),f==null||f(Q,n,S.type,K)},H=Q=>u==null?void 0:u(n,Q),A=(Q,K)=>{d(!0),p==null||p(_,n,S.type),O==null||O(Q,K)};rb.onPointerDown(_.nativeEvent,{autoPanOnConnect:N,connectionMode:R,connectionRadius:z,domNode:P,handleId:S.id,nodeId:S.nodeId,nodeLookup:L,isTarget:F,edgeUpdaterType:S.type,lib:E,flowId:M,cancelConnection:D,panBy:V,isValidConnection:(...Q)=>{var K,W;return((W=(K=y.getState()).isValidConnection)==null?void 0:W.call(K,...Q))??!0},onConnect:H,onConnectStart:A,onConnectEnd:(...Q)=>{var K,W;return(W=(K=y.getState()).onConnectEnd)==null?void 0:W.call(K,...Q)},onReconnectEnd:$,updateConnection:B,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:_.currentTarget})},b=_=>v(_,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=_=>v(_,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>h(!0),x=()=>h(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(v1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(v1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function YH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:p,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Vt(de=>de.edgeLookup.get(e));const _=Vt(de=>de.defaultEdgeOptions);x=_?{..._,...x}:x;let S=x.type||"default",N=(v==null?void 0:v[S])||x1[S];N===void 0&&(g==null||g("011",Fi.error011(S)),S="default",N=(v==null?void 0:v.default)||x1.default);const P=!!(x.focusable||t&&typeof x.focusable>"u"),R=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),z=!!(x.selectable||r&&typeof x.selectable>"u"),E=m.useRef(null),[O,D]=m.useState(!1),[L,M]=m.useState(!1),V=dn(),{zIndex:B,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K}=Vt(m.useCallback(de=>{const pe=de.nodeLookup.get(x.source),Me=de.nodeLookup.get(x.target);if(!pe||!Me)return{zIndex:x.zIndex,...b1};const Ne=AW({id:e,sourceNode:pe,targetNode:Me,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:kW({selected:x.selected,zIndex:x.zIndex,sourceNode:pe,targetNode:Me,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Ne||b1}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),bn),W=m.useMemo(()=>x.markerStart?`url('#${tb(x.markerStart,y)}')`:void 0,[x.markerStart,y]),te=m.useMemo(()=>x.markerEnd?`url('#${tb(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||$===null||H===null||A===null)return null;const Z=de=>{var _e;const{addSelectedEdges:pe,unselectNodesAndEdges:Me,multiSelectionActive:Ne}=V.getState();z&&(V.setState({nodesSelectionActive:!1}),x.selected&&Ne?(Me({nodes:[],edges:[x]}),(_e=E.current)==null||_e.blur()):pe([e])),s&&s(de,x)},G=o?de=>{o(de,{...x})}:void 0,ne=a?de=>{a(de,{...x})}:void 0,re=l?de=>{l(de,{...x})}:void 0,se=c?de=>{c(de,{...x})}:void 0,ee=u?de=>{u(de,{...x})}:void 0,ue=de=>{var pe;if(!k&&TP.includes(de.key)&&z){const{unselectNodesAndEdges:Me,addSelectedEdges:Ne}=V.getState();de.key==="Escape"?((pe=E.current)==null||pe.blur(),Me({edges:[x]})):Ne([e])}};return i.jsx("svg",{style:{zIndex:B},children:i.jsxs("g",{className:Un(["react-flow__edge",`react-flow__edge-${S}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!z&&!s,updating:O,selectable:z}]),onClick:Z,onDoubleClick:G,onContextMenu:ne,onMouseEnter:re,onMouseMove:se,onMouseLeave:ee,onKeyDown:P?ue:void 0,tabIndex:P?0:void 0,role:x.ariaRole??(P?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":P?`${gR}-${y}`:void 0,ref:E,...x.domAttributes,children:[!L&&i.jsx(N,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:z,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:W,markerEnd:te,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),R&&i.jsx(GH,{edge:x,isReconnectable:R,reconnectRadius:p,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K,setUpdateHover:D,setReconnecting:M})]})})}var JH=m.memo(YH);const XH=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function zR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:p,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Vt(XH,bn),_=$H(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(zH,{defaultColor:e,rfId:n}),_.map(S=>i.jsx(JH,{id:S,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:p,reconnectRadius:f,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},S))]})}zR.displayName="EdgeRenderer";const QH=m.memo(zR),ZH=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function e6({children:e}){const t=Vt(ZH);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function t6(e){const t=tu(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const n6=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function r6(e){const t=Vt(n6),n=dn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function s6(e){return e.connection.inProgress?{...e.connection,to:If(e.connection.to,e.transform)}:{...e.connection}}function i6(e){return s6}function o6(e){const t=i6();return Vt(t,bn)}const a6=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function l6({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Vt(a6,bn);return!(o&&s&&c)?null:i.jsx("svg",{style:e,width:o,height:a,className:"react-flow__connectionline react-flow__container",children:i.jsx("g",{className:Un(["react-flow__connection",LP(l)]),children:i.jsx(BR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const BR=({style:e,type:t=Vo.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:p,toHandle:f,toPosition:d,pointer:h}=o6();if(!s)return;if(n)return i.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:d,connectionStatus:LP(r),toNode:p,toHandle:f,pointer:h});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case Vo.Bezier:[y]=GP(v);break;case Vo.SimpleBezier:[y]=AR(v);break;case Vo.Step:[y]=eb({...v,borderRadius:0});break;case Vo.SmoothStep:[y]=eb(v);break;default:[y]=JP(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};BR.displayName="ConnectionLine";const c6={};function S1(e=c6){m.useRef(e),dn(),m.useEffect(()=>{},[e])}function u6(){dn(),m.useRef(!1),m.useEffect(()=>{},[])}function WR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:p,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:h,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:P,deleteKeyCode:R,onlyRenderVisibleElements:z,elementsSelectable:E,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:M,preventScrolling:V,defaultMarkerColor:B,zoomOnScroll:F,zoomOnPinch:$,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:Q,zoomOnDoubleClick:K,panOnDrag:W,onPaneClick:te,onPaneMouseEnter:Z,onPaneMouseMove:G,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:ee,nodeClickDistance:ue,onEdgeContextMenu:de,onEdgeMouseEnter:pe,onEdgeMouseMove:Me,onEdgeMouseLeave:Ne,reconnectRadius:_e,onReconnect:He,onReconnectStart:ct,onReconnectEnd:yt,noDragClassName:Re,noWheelClassName:at,noPanClassName:kt,disableKeyboardA11y:$t,nodeExtent:ye,rfId:ze,viewport:oe,onViewportChange:ke}){return S1(e),S1(t),u6(),t6(n),r6(oe),i.jsx(NH,{onPaneClick:te,onPaneMouseEnter:Z,onPaneMouseMove:G,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:ee,deleteKeyCode:R,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:P,elementsSelectable:E,zoomOnScroll:F,zoomOnPinch:$,zoomOnDoubleClick:K,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:Q,panOnDrag:W,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:M,onSelectionContextMenu:f,preventScrolling:V,noDragClassName:Re,noWheelClassName:at,noPanClassName:kt,disableKeyboardA11y:$t,onViewportChange:ke,isControlledViewport:!!oe,children:i.jsxs(e6,{children:[i.jsx(QH,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:He,onReconnectStart:ct,onReconnectEnd:yt,onlyRenderVisibleElements:z,onEdgeContextMenu:de,onEdgeMouseEnter:pe,onEdgeMouseMove:Me,onEdgeMouseLeave:Ne,reconnectRadius:_e,defaultMarkerColor:B,noPanClassName:kt,disableKeyboardA11y:$t,rfId:ze}),i.jsx(l6,{style:v,type:y,component:b,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(MH,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:p,nodeClickDistance:ue,onlyRenderVisibleElements:z,noPanClassName:kt,noDragClassName:Re,disableKeyboardA11y:$t,nodeExtent:ye,rfId:ze}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}WR.displayName="GraphView";const d6=m.memo(WR),j1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:p,nodeExtent:f,zIndexMode:d="basic"}={})=>{const h=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=p??[0,0],_=f??ef;ZP(v,b,g);const{nodesInitialized:S}=nb(k,h,y,{nodeOrigin:x,nodeExtent:_,zIndexMode:d});let N=[0,0,1];if(a&&s&&o){const P=Af(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:R,y:z,zoom:E}=Jk(P,s,o,c,u,(l==null?void 0:l.padding)??.1);N=[R,z,E]}return{rfId:"1",width:s??0,height:o??0,transform:N,nodes:k,nodesInitialized:S,nodeLookup:h,parentLookup:y,edges:g,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:ef,nodeExtent:_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Wc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...$P},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:mW,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:MP,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},f6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:p,nodeExtent:f,zIndexMode:d})=>P5((h,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:_,height:S,minZoom:N,maxZoom:P}=y();g&&(await pW({nodes:b,width:_,height:S,panZoom:g,minZoom:N,maxZoom:P},k),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...j1({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:p,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:_,fitViewQueued:S,zIndexMode:N,nodesSelectionActive:P}=y(),{nodesInitialized:R,hasSelectedNodes:z}=nb(b,g,k,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:_,checkEquality:!0,zIndexMode:N}),E=P&&z;S&&R?(v(),h({nodes:b,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:E})):h({nodes:b,nodesInitialized:R,nodesSelectionActive:E})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();ZP(g,k,b),h({edges:b})},setDefaultNodesAndEdges:(b,g)=>{if(b){const{setNodes:k}=y();k(b),h({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),h({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:x,domNode:_,nodeOrigin:S,nodeExtent:N,debug:P,fitViewQueued:R,zIndexMode:z}=y(),{changes:E,updatedInternals:O}=LW(b,k,x,_,S,N,z);O&&(RW(k,x,{nodeOrigin:S,nodeExtent:N,zIndexMode:z}),R?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(E==null?void 0:E.length)>0&&(P&&console.log("React Flow: trigger node changes",E),g==null||g(E)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:_,triggerNodeChanges:S,connection:N,updateConnection:P,onNodesChangeMiddlewareMap:R}=y();for(const[z,E]of b){const O=_.get(z),D=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(E!=null&&E.position)),L={id:z,type:"position",position:D?{x:Math.max(0,E.position.x),y:Math.max(0,E.position.y)}:E.position,dragging:g};if(O&&N.inProgress&&N.fromNode.id===O.id){const M=ll(O,N.fromHandle,Ue.Left,!0);P({...N,from:M})}D&&O.parentId&&k.push({id:z,parentId:O.parentId,rect:{...E.internals.positionAbsolute,width:E.measured.width??0,height:E.measured.height??0}}),x.push(L)}if(k.length>0){const{parentLookup:z,nodeOrigin:E}=y(),O=nv(k,_,z,E);x.push(...O)}for(const z of R.values())x=z(x);S(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:_,debug:S}=y();if(b!=null&&b.length){if(_){const N=Nd(b,x);k(N)}S&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:_,debug:S}=y();if(b!=null&&b.length){if(_){const N=pm(b,x);k(N)}S&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=y();if(g){const N=b.map(P=>La(P,!0));_(N);return}_(mc(x,new Set([...b]),!0)),S(mc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=y();if(g){const N=b.map(P=>La(P,!0));S(N);return}S(mc(k,new Set([...b]))),_(mc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:_,triggerNodeChanges:S,triggerEdgeChanges:N}=y(),P=b||x,R=g||k,z=[];for(const O of P){if(!O.selected)continue;const D=_.get(O.id);D&&(D.selected=!1),z.push(La(O.id,!1))}const E=[];for(const O of R)O.selected&&E.push(La(O.id,!1));S(z),N(E)},setMinZoom:b=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([b,k]),h({minZoom:b})},setMaxZoom:b=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,b]),h({maxZoom:b})},setTranslateExtent:b=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(b),h({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:x,elementsSelectable:_}=y();if(!_)return;const S=g.reduce((P,R)=>R.selected?[...P,La(R.id,!1)]:P,[]),N=b.reduce((P,R)=>R.selected?[...P,La(R.id,!1)]:P,[]);k(S),x(N)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:_,elevateNodesOnSelect:S,nodeExtent:N,zIndexMode:P}=y();b[0][0]===N[0][0]&&b[0][1]===N[0][1]&&b[1][0]===N[1][0]&&b[1][1]===N[1][1]||(nb(g,k,x,{nodeOrigin:_,nodeExtent:b,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:P}),h({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:_,translateExtent:S}=y();return OW({delta:b,panZoom:_,transform:g,translateExtent:S,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:_,maxZoom:S,panZoom:N}=y();if(!N)return Promise.resolve(!1);const P=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:S;return await N.setViewport({x:x/2-b*P,y:_/2-g*P,zoom:P},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...$P}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...j1()})}},Object.is);function sv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:p,nodeExtent:f,zIndexMode:d,children:h}){const[y]=m.useState(()=>f6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:p,nodeExtent:f,zIndexMode:d}));return i.jsx(R5,{value:y,children:i.jsx(eH,{children:h})})}function p6({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:p,nodeOrigin:f,nodeExtent:d,zIndexMode:h}){return m.useContext(pg)?i.jsx(i.Fragment,{children:e}):i.jsx(sv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:p,nodeOrigin:f,nodeExtent:d,zIndexMode:h,children:e})}const h6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function m6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:p,onMoveStart:f,onMoveEnd:d,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:S,onNodeDoubleClick:N,onNodeDragStart:P,onNodeDrag:R,onNodeDragStop:z,onNodesDelete:E,onEdgesDelete:O,onDelete:D,onSelectionChange:L,onSelectionDragStart:M,onSelectionDrag:V,onSelectionDragStop:B,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:H,onBeforeDelete:A,connectionMode:Q,connectionLineType:K=Vo.Bezier,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:Z,deleteKeyCode:G="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=tf.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ue=rf()?"Meta":"Control",zoomActivationKeyCode:de=rf()?"Meta":"Control",snapToGrid:pe,snapGrid:Me,onlyRenderVisibleElements:Ne=!1,selectNodesOnDrag:_e,nodesDraggable:He,autoPanOnNodeFocus:ct,nodesConnectable:yt,nodesFocusable:Re,nodeOrigin:at=yR,edgesFocusable:kt,edgesReconnectable:$t,elementsSelectable:ye=!0,defaultViewport:ze=K5,minZoom:oe=.5,maxZoom:ke=2,translateExtent:Be=ef,preventScrolling:Qe=!0,nodeExtent:Ce,defaultMarkerColor:Ct="#b1b1b7",zoomOnScroll:Xt=!0,zoomOnPinch:Ft=!0,panOnScroll:rt=!1,panOnScrollSpeed:Fn=.5,panOnScrollMode:ie=Xa.Free,zoomOnDoubleClick:Ie=!0,panOnDrag:et=!0,onPaneClick:qe,onPaneMouseEnter:Pt,onPaneMouseMove:vt,onPaneMouseLeave:tr,onPaneScroll:Gn,onPaneContextMenu:Tr,paneClickDistance:kn=1,nodeClickDistance:nr=0,children:pr,onReconnect:hr,onReconnectStart:fn,onReconnectEnd:zn,onEdgeContextMenu:is,onEdgeDoubleClick:Fs,onEdgeMouseEnter:vn,onEdgeMouseMove:Yn,onEdgeMouseLeave:ks,reconnectRadius:Jn=10,onNodesChange:Bn,onEdgesChange:vr,noDragClassName:Sr="nodrag",noWheelClassName:Wn="nowheel",noPanClassName:Mr="nopan",fitView:$r,fitViewOptions:ce,connectOnClick:me,attributionPosition:tt,proOptions:st,defaultEdgeOptions:zt,elevateNodesOnSelect:Rn=!0,elevateEdgesOnSelect:jr=!1,disableKeyboardA11y:Nr=!1,autoPanOnConnect:mr,autoPanOnNodeDrag:ut,autoPanSpeed:Ut,connectionRadius:Gt,isValidConnection:Xn,onError:ot,style:gr,id:zs,nodeDragThreshold:Hi,connectionDragThreshold:Bs,viewport:ae,onViewportChange:ve,width:Te,height:bt,colorMode:Rt="light",debug:Qt,onScroll:pn,ariaLabelConfig:$n,zIndexMode:vs="basic",...Ss},U){const we=zs||"1",$e=Y5(Rt),Ae=m.useCallback(Ze=>{Ze.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),pn==null||pn(Ze)},[pn]);return i.jsx("div",{"data-testid":"rf__wrapper",...Ss,onScroll:Ae,style:{...gr,...h6},ref:U,className:Un(["react-flow",s,$e]),id:zs,role:"application",children:i.jsxs(p6,{nodes:e,edges:t,width:Te,height:bt,fitView:$r,fitViewOptions:ce,minZoom:oe,maxZoom:ke,nodeOrigin:at,nodeExtent:Ce,zIndexMode:vs,children:[i.jsx(G5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:He,autoPanOnNodeFocus:ct,nodesConnectable:yt,nodesFocusable:Re,edgesFocusable:kt,edgesReconnectable:$t,elementsSelectable:ye,elevateNodesOnSelect:Rn,elevateEdgesOnSelect:jr,minZoom:oe,maxZoom:ke,nodeExtent:Ce,onNodesChange:Bn,onEdgesChange:vr,snapToGrid:pe,snapGrid:Me,connectionMode:Q,translateExtent:Be,connectOnClick:me,defaultEdgeOptions:zt,fitView:$r,fitViewOptions:ce,onNodesDelete:E,onEdgesDelete:O,onDelete:D,onNodeDragStart:P,onNodeDrag:R,onNodeDragStop:z,onSelectionDrag:V,onSelectionDragStart:M,onSelectionDragStop:B,onMove:p,onMoveStart:f,onMoveEnd:d,noPanClassName:Mr,nodeOrigin:at,rfId:we,autoPanOnConnect:mr,autoPanOnNodeDrag:ut,autoPanSpeed:Ut,onError:ot,connectionRadius:Gt,isValidConnection:Xn,selectNodesOnDrag:_e,nodeDragThreshold:Hi,connectionDragThreshold:Bs,onBeforeDelete:A,debug:Qt,ariaLabelConfig:$n,zIndexMode:vs}),i.jsx(d6,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:S,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:K,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:Z,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:G,multiSelectionKeyCode:ue,panActivationKeyCode:ee,zoomActivationKeyCode:de,onlyRenderVisibleElements:Ne,defaultViewport:ze,translateExtent:Be,minZoom:oe,maxZoom:ke,preventScrolling:Qe,zoomOnScroll:Xt,zoomOnPinch:Ft,zoomOnDoubleClick:Ie,panOnScroll:rt,panOnScrollSpeed:Fn,panOnScrollMode:ie,panOnDrag:et,onPaneClick:qe,onPaneMouseEnter:Pt,onPaneMouseMove:vt,onPaneMouseLeave:tr,onPaneScroll:Gn,onPaneContextMenu:Tr,paneClickDistance:kn,nodeClickDistance:nr,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:H,onReconnect:hr,onReconnectStart:fn,onReconnectEnd:zn,onEdgeContextMenu:is,onEdgeDoubleClick:Fs,onEdgeMouseEnter:vn,onEdgeMouseMove:Yn,onEdgeMouseLeave:ks,reconnectRadius:Jn,defaultMarkerColor:Ct,noDragClassName:Sr,noWheelClassName:Wn,noPanClassName:Mr,rfId:we,disableKeyboardA11y:Nr,nodeExtent:Ce,viewport:ae,onViewportChange:ve}),i.jsx(V5,{onSelectionChange:L}),pr,i.jsx(F5,{proOptions:st,position:tt}),i.jsx(D5,{rfId:we,disableKeyboardA11y:Nr})]})})}var HR=xR(m6);function g6(){const e=dn();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],o=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function y6(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>Nd(s,o)),[]);return[t,n,r]}function w6(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>pm(s,o)),[]);return[t,n,r]}function x6({dimensions:e,lineWidth:t,variant:n,className:r}){return i.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Un(["react-flow__background-pattern",n,r])})}function b6({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Un(["react-flow__background-pattern","dots",t])})}var ia;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ia||(ia={}));const k6={[ia.Dots]:1,[ia.Lines]:1,[ia.Cross]:6},v6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function VR({id:e,variant:t=ia.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:p}){const f=m.useRef(null),{transform:d,patternId:h}=Vt(v6,bn),y=r||k6[t],v=t===ia.Dots,b=t===ia.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*d[2]||1,g[1]*d[2]||1],x=y*d[2],_=Array.isArray(o)?o:[o,o],S=b?[x,x]:k,N=[_[0]*d[2]||1+S[0]/2,_[1]*d[2]||1+S[1]/2],P=`${h}${e||""}`;return i.jsxs("svg",{className:Un(["react-flow__background",u]),style:{...c,...mg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i.jsx("pattern",{id:P,x:d[0]%k[0],y:d[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?i.jsx(b6,{radius:x/2,className:p}):i.jsx(x6,{dimensions:S,lineWidth:s,variant:t,className:p})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}VR.displayName="Background";const KR=m.memo(VR);function S6(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:i.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function j6(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:i.jsx("path",{d:"M0 0h32v4.2H0z"})})}function N6(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:i.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function _6(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function C6(){return i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Bp({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Un(["react-flow__controls-button",t]),...n,children:e})}const A6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function qR({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:p,position:f="bottom-left",orientation:d="vertical","aria-label":h}){const y=dn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Vt(A6,bn),{zoomIn:x,zoomOut:_,fitView:S}=tu(),N=()=>{x(),o==null||o()},P=()=>{_(),a==null||a()},R=()=>{S(s),l==null||l()},z=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},E=d==="horizontal"?"horizontal":"vertical";return i.jsxs(hg,{className:Un(["react-flow__controls",E,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Bp,{onClick:N,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(S6,{})}),i.jsx(Bp,{onClick:P,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:i.jsx(j6,{})})]}),n&&i.jsx(Bp,{className:"react-flow__controls-fitview",onClick:R,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(N6,{})}),r&&i.jsx(Bp,{className:"react-flow__controls-interactive",onClick:z,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(C6,{}):i.jsx(_6,{})}),p]})}qR.displayName="Controls";m.memo(qR);function E6({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:p,shapeRendering:f,selected:d,onClick:h}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return i.jsx("rect",{className:Un(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:p,ry:p,width:r,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?g=>h(g,e):void 0})}const I6=m.memo(E6),P6=e=>e.nodes.map(t=>t.id),iw=e=>e instanceof Function?e:()=>e;function R6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=I6,onClick:a}){const l=Vt(P6,bn),c=iw(t),u=iw(e),p=iw(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(d=>i.jsx(M6,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:f},d))})}function T6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:p,y:f,width:d,height:h}=Vt(y=>{const v=y.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const b=v.internals.userNode,{x:g,y:k}=v.internals.positionAbsolute,{width:x,height:_}=ko(b);return{node:b,x:g,y:k,width:x,height:_}},bn);return!u||u.hidden||!WP(u)?null:i.jsx(l,{x:p,y:f,width:d,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:o,shapeRendering:a,onClick:c,id:u.id})}const M6=m.memo(T6);var $6=m.memo(R6);const L6=200,O6=150,D6=e=>!e.hidden,F6=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?BP(Af(e.nodeLookup,{filter:D6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},z6="react-flow__minimap-desc";function UR({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:p,maskStrokeWidth:f,position:d="bottom-right",onClick:h,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:_=5}){const S=dn(),N=m.useRef(null),{boundingRect:P,viewBB:R,rfId:z,panZoom:E,translateExtent:O,flowWidth:D,flowHeight:L,ariaLabelConfig:M}=Vt(F6,bn),V=(e==null?void 0:e.width)??L6,B=(e==null?void 0:e.height)??O6,F=P.width/V,$=P.height/B,H=Math.max(F,$),A=H*V,Q=H*B,K=_*H,W=P.x-(A-P.width)/2-K,te=P.y-(Q-P.height)/2-K,Z=A+K*2,G=Q+K*2,ne=`${z6}-${z}`,re=m.useRef(0),se=m.useRef();re.current=H,m.useEffect(()=>{if(N.current&&E)return se.current=qW({domNode:N.current,panZoom:E,getTransform:()=>S.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[E]),m.useEffect(()=>{var pe;(pe=se.current)==null||pe.update({translateExtent:O,width:D,height:L,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,O,D,L]);const ee=h?pe=>{var _e;const[Me,Ne]=((_e=se.current)==null?void 0:_e.pointer(pe))||[0,0];h(pe,{x:Me,y:Ne})}:void 0,ue=y?m.useCallback((pe,Me)=>{const Ne=S.getState().nodeLookup.get(Me).internals.userNode;y(pe,Ne)},[]):void 0,de=g??M["minimap.ariaLabel"];return i.jsx(hg,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*H:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Un(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:V,height:B,viewBox:`${W} ${te} ${Z} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:N,onClick:ee,children:[de&&i.jsx("title",{id:ne,children:de}),i.jsx($6,{onClick:ue,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-K},${te-K}h${Z+K*2}v${G+K*2}h${-Z-K*2}z
66
- M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}UR.displayName="MiniMap";m.memo(UR);const B6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,W6={[qc.Line]:"right",[qc.Handle]:"bottom-right"};function H6({nodeId:e,position:t,variant:n=qc.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:h=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=SR(),x=typeof e=="string"?e:k,_=dn(),S=m.useRef(null),N=n===qc.Handle,P=Vt(m.useCallback(B6(N&&h),[N,h]),bn),R=m.useRef(null),z=t??W6[n];m.useEffect(()=>{if(!(!S.current||!x))return R.current||(R.current=o5({domNode:S.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V,domNode:B}=_.getState();return{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V,paneDomNode:B}},onChange:(O,D)=>{const{triggerNodeChanges:L,nodeLookup:M,parentLookup:V,nodeOrigin:B}=_.getState(),F=[],$={x:O.x,y:O.y},H=M.get(x);if(H&&H.expandParent&&H.parentId){const A=H.origin??B,Q=O.width??H.measured.width??0,K=O.height??H.measured.height??0,W={id:H.id,parentId:H.parentId,rect:{width:Q,height:K,...HP({x:O.x??H.position.x,y:O.y??H.position.y},{width:Q,height:K},H.parentId,M,A)}},te=nv([W],M,V,B);F.push(...te),$.x=O.x?Math.max(A[0]*Q,O.x):void 0,$.y=O.y?Math.max(A[1]*K,O.y):void 0}if($.x!==void 0&&$.y!==void 0){const A={id:x,type:"position",position:{...$}};F.push(A)}if(O.width!==void 0&&O.height!==void 0){const Q={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};F.push(Q)}for(const A of D){const Q={...A,type:"position"};F.push(Q)}L(F)},onEnd:({width:O,height:D})=>{const L={id:x,type:"dimensions",resizing:!1,dimensions:{width:O,height:D}};_.getState().triggerNodeChanges([L])}})),R.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:p},keepAspectRatio:f,resizeDirection:d,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var O;(O=R.current)==null||O.destroy()}},[z,l,c,u,p,f,v,b,g,y]);const E=z.split("-");return i.jsx("div",{className:Un(["react-flow__resize-control","nodrag",...E,n,r]),ref:S,style:{...s,scale:P,...a&&{[N?"backgroundColor":"borderColor"]:a}},children:o})}const iv=m.memo(H6),V6="modulepreload",K6=function(e){return"/"+e},N1={},q6=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=K6(c),c in N1)return;N1[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":V6,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function U6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const G6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Y6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,J6={};function _1(e,t){return(J6.jsx?Y6:G6).test(e)}const X6=/[ \t\n\f\r]/g;function Q6(e){return typeof e=="object"?e.type==="text"?C1(e.value):!1:C1(e)}function C1(e){return e.replace(X6,"")===""}class Pf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Pf.prototype.normal={};Pf.prototype.property={};Pf.prototype.space=void 0;function GR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Pf(n,r,t)}function ob(e){return e.toLowerCase()}class ss{constructor(t,n){this.attribute=n,this.property=t}}ss.prototype.attribute="";ss.prototype.booleanish=!1;ss.prototype.boolean=!1;ss.prototype.commaOrSpaceSeparated=!1;ss.prototype.commaSeparated=!1;ss.prototype.defined=!1;ss.prototype.mustUseProperty=!1;ss.prototype.number=!1;ss.prototype.overloadedBoolean=!1;ss.prototype.property="";ss.prototype.spaceSeparated=!1;ss.prototype.space=void 0;let Z6=0;const jt=wl(),Vn=wl(),ab=wl(),Pe=wl(),ln=wl(),Cc=wl(),cs=wl();function wl(){return 2**++Z6}const lb=Object.freeze(Object.defineProperty({__proto__:null,boolean:jt,booleanish:Vn,commaOrSpaceSeparated:cs,commaSeparated:Cc,number:Pe,overloadedBoolean:ab,spaceSeparated:ln},Symbol.toStringTag,{value:"Module"})),ow=Object.keys(lb);class ov extends ss{constructor(t,n,r,s){let o=-1;if(super(t,n),A1(this,"space",s),typeof r=="number")for(;++o<ow.length;){const a=ow[o];A1(this,ow[o],(r&lb[a])===lb[a])}}}ov.prototype.defined=!0;function A1(e,t,n){n&&(e[t]=n)}function nu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new ov(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[ob(r)]=r,n[ob(o.attribute)]=r}return new Pf(t,n,e.space)}const YR=nu({properties:{ariaActiveDescendant:null,ariaAtomic:Vn,ariaAutoComplete:null,ariaBusy:Vn,ariaChecked:Vn,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:ln,ariaCurrent:null,ariaDescribedBy:ln,ariaDetails:null,ariaDisabled:Vn,ariaDropEffect:ln,ariaErrorMessage:null,ariaExpanded:Vn,ariaFlowTo:ln,ariaGrabbed:Vn,ariaHasPopup:null,ariaHidden:Vn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ln,ariaLevel:Pe,ariaLive:null,ariaModal:Vn,ariaMultiLine:Vn,ariaMultiSelectable:Vn,ariaOrientation:null,ariaOwns:ln,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:Vn,ariaReadOnly:Vn,ariaRelevant:null,ariaRequired:Vn,ariaRoleDescription:ln,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:Vn,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function JR(e,t){return t in e?e[t]:t}function XR(e,t){return JR(e,t.toLowerCase())}const e8=nu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Cc,acceptCharset:ln,accessKey:ln,action:null,allow:null,allowFullScreen:jt,allowPaymentRequest:jt,allowUserMedia:jt,alt:null,as:null,async:jt,autoCapitalize:null,autoComplete:ln,autoFocus:jt,autoPlay:jt,blocking:ln,capture:null,charSet:null,checked:jt,cite:null,className:ln,cols:Pe,colSpan:null,content:null,contentEditable:Vn,controls:jt,controlsList:ln,coords:Pe|Cc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:jt,defer:jt,dir:null,dirName:null,disabled:jt,download:ab,draggable:Vn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:jt,formTarget:null,headers:ln,height:Pe,hidden:ab,high:Pe,href:null,hrefLang:null,htmlFor:ln,httpEquiv:ln,id:null,imageSizes:null,imageSrcSet:null,inert:jt,inputMode:null,integrity:null,is:null,isMap:jt,itemId:null,itemProp:ln,itemRef:ln,itemScope:jt,itemType:ln,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:jt,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:jt,muted:jt,name:null,nonce:null,noModule:jt,noValidate:jt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:jt,optimum:Pe,pattern:null,ping:ln,placeholder:null,playsInline:jt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:jt,referrerPolicy:null,rel:ln,required:jt,reversed:jt,rows:Pe,rowSpan:Pe,sandbox:ln,scope:null,scoped:jt,seamless:jt,selected:jt,shadowRootClonable:jt,shadowRootDelegatesFocus:jt,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:Vn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:jt,useMap:null,value:Vn,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ln,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:jt,declare:jt,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:jt,noHref:jt,noShade:jt,noWrap:jt,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:Vn,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:jt,disableRemotePlayback:jt,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:XR}),t8=nu({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:cs,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:ln,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:jt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Cc,g2:Cc,glyphName:Cc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:cs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Pe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ln,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:cs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:cs,rev:cs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:cs,requiredFeatures:cs,requiredFonts:cs,requiredFormats:cs,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:cs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:cs,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:cs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:JR}),QR=nu({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),ZR=nu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:XR}),eT=nu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),n8={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},r8=/[A-Z]/g,E1=/-[a-z]/g,s8=/^data[-\w.:]+$/i;function i8(e,t){const n=ob(t);let r=t,s=ss;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&s8.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(E1,a8);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!E1.test(o)){let a=o.replace(r8,o8);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=ov}return new s(r,t)}function o8(e){return"-"+e.toLowerCase()}function a8(e){return e.charAt(1).toUpperCase()}const l8=GR([YR,e8,QR,ZR,eT],"html"),av=GR([YR,t8,QR,ZR,eT],"svg");function c8(e){return e.join(" ").trim()}var lv={},I1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,u8=/\n/g,d8=/^\s*/,f8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,p8=/^:\s*/,h8=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,m8=/^[;\s]*/,g8=/^\s+|\s+$/g,y8=`
67
- `,P1="/",R1="*",Da="",w8="comment",x8="declaration";function b8(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(y){var v=y.match(u8);v&&(n+=v.length);var b=y.lastIndexOf(y8);r=~b?y.length-b:r+y.length}function o(){var y={line:n,column:r};return function(v){return v.position=new a(y),u(),v}}function a(y){this.start=y,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(y){var v=new Error(t.source+":"+n+":"+r+": "+y);if(v.reason=y,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function c(y){var v=y.exec(e);if(v){var b=v[0];return s(b),e=e.slice(b.length),v}}function u(){c(d8)}function p(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(P1!=e.charAt(0)||R1!=e.charAt(1))){for(var v=2;Da!=e.charAt(v)&&(R1!=e.charAt(v)||P1!=e.charAt(v+1));)++v;if(v+=2,Da===e.charAt(v-1))return l("End of comment missing");var b=e.slice(2,v-2);return r+=2,s(b),e=e.slice(v),r+=2,y({type:w8,comment:b})}}function d(){var y=o(),v=c(f8);if(v){if(f(),!c(p8))return l("property missing ':'");var b=c(h8),g=y({type:x8,property:T1(v[0].replace(I1,Da)),value:b?T1(b[0].replace(I1,Da)):Da});return c(m8),g}}function h(){var y=[];p(y);for(var v;v=d();)v!==!1&&(y.push(v),p(y));return y}return u(),h()}function T1(e){return e?e.replace(g8,Da):Da}var k8=b8,v8=Rd&&Rd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lv,"__esModule",{value:!0});lv.default=j8;const S8=v8(k8);function j8(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,S8.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;s?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var yg={};Object.defineProperty(yg,"__esModule",{value:!0});yg.camelCase=void 0;var N8=/^--[a-zA-Z0-9_-]+$/,_8=/-([a-z])/g,C8=/^[^-]+$/,A8=/^-(webkit|moz|ms|o|khtml)-/,E8=/^-(ms)-/,I8=function(e){return!e||C8.test(e)||N8.test(e)},P8=function(e,t){return t.toUpperCase()},M1=function(e,t){return"".concat(t,"-")},R8=function(e,t){return t===void 0&&(t={}),I8(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(E8,M1):e=e.replace(A8,M1),e.replace(_8,P8))};yg.camelCase=R8;var T8=Rd&&Rd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},M8=T8(lv),$8=yg;function cb(e,t){var n={};return!e||typeof e!="string"||(0,M8.default)(e,function(r,s){r&&s&&(n[(0,$8.camelCase)(r,t)]=s)}),n}cb.default=cb;var L8=cb;const O8=ma(L8),tT=nT("end"),cv=nT("start");function nT(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function D8(e){const t=cv(e),n=tT(e);if(t&&n)return{start:t,end:n}}function _d(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?$1(e.position):"start"in e||"end"in e?$1(e):"line"in e||"column"in e?ub(e):""}function ub(e){return L1(e&&e.line)+":"+L1(e&&e.column)}function $1(e){return ub(e&&e.start)+"-"+ub(e&&e.end)}function L1(e){return e&&typeof e=="number"?e:1}class Rr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(a=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=_d(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Rr.prototype.file="";Rr.prototype.name="";Rr.prototype.reason="";Rr.prototype.message="";Rr.prototype.stack="";Rr.prototype.column=void 0;Rr.prototype.line=void 0;Rr.prototype.ancestors=void 0;Rr.prototype.cause=void 0;Rr.prototype.fatal=void 0;Rr.prototype.place=void 0;Rr.prototype.ruleId=void 0;Rr.prototype.source=void 0;const uv={}.hasOwnProperty,F8=new Map,z8=/[A-Z]/g,B8=new Set(["table","tbody","thead","tfoot","tr"]),W8=new Set(["td","th"]),rT="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function H8(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=X8(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=J8(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?av:l8,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=sT(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function sT(e,t,n){if(t.type==="element")return V8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return K8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return U8(e,t,n);if(t.type==="mdxjsEsm")return q8(e,t);if(t.type==="root")return G8(e,t,n);if(t.type==="text")return Y8(e,t)}function V8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=av,e.schema=s),e.ancestors.push(t);const o=oT(e,t.tagName,!1),a=Q8(e,t);let l=fv(e,t);return B8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!Q6(c):!0})),iT(e,a,o,t),dv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function K8(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}of(e,t.position)}function q8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);of(e,t.position)}function U8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=av,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:oT(e,t.name,!0),a=Z8(e,t),l=fv(e,t);return iT(e,a,o,t),dv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function G8(e,t,n){const r={};return dv(r,fv(e,t)),e.create(t,e.Fragment,r,n)}function Y8(e,t){return t.value}function iT(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function dv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function J8(e,t,n){return r;function r(s,o,a,l){const u=Array.isArray(a.children)?n:t;return l?u(o,a,l):u(o,a)}}function X8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=cv(r);return t(s,o,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Q8(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&uv.call(t.properties,s)){const o=e9(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&W8.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Z8(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else of(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else of(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function fv(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:F8;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=s.get(c)||0;a=c+"-"+u,s.set(c,u+1)}}const l=sT(e,o,a);l!==void 0&&n.push(l)}return n}function e9(e,t,n){const r=i8(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?U6(n):c8(n)),r.property==="style"){let s=typeof n=="object"?n:t9(e,String(n));return e.stylePropertyNameCase==="css"&&(s=n9(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?n8[r.property]||r.property:r.attribute,n]}}function t9(e,t){try{return O8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Rr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=rT+"#cannot-parse-style-attribute",s}}function oT(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,a;for(;++o<s.length;){const l=_1(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=_1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return uv.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);of(e)}function of(e,t){const n=new Rr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=rT+"#cannot-handle-mdx-estrees-without-createevaluater",n}function n9(e){const t={};let n;for(n in e)uv.call(e,n)&&(t[r9(n)]=e[n]);return t}function r9(e){let t=e.replace(z8,s9);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function s9(e){return"-"+e.toLowerCase()}const aw={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},i9={};function o9(e,t){const n=i9,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return aT(e,r,s)}function aT(e,t,n){if(a9(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return O1(e.children,t,n)}return Array.isArray(e)?O1(e,t,n):""}function O1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=aT(e[s],t,n);return r.join("")}function a9(e){return!!(e&&typeof e=="object")}const D1=document.createElement("i");function pv(e){const t="&"+e+";";D1.innerHTML=t;const n=D1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function zi(e,t,n,r){const s=e.length;let o=0,a;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function Ts(e,t){return e.length>0?(zi(e,e.length,0,t),e):t}const F1={}.hasOwnProperty;function l9(e){const t={};let n=-1;for(;++n<e.length;)c9(t,e[n]);return t}function c9(e,t){let n;for(n in t){const s=(F1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){F1.call(s,a)||(s[a]=[]);const l=o[a];u9(s[a],Array.isArray(l)?l:l?[l]:[])}}}function u9(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);zi(e,0,0,r)}function lT(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ac(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ei=xa(/[A-Za-z]/),hs=xa(/[\dA-Za-z]/),d9=xa(/[#-'*+\--9=?A-Z^-~]/);function db(e){return e!==null&&(e<32||e===127)}const fb=xa(/\d/),f9=xa(/[\dA-Fa-f]/),p9=xa(/[!-/:-@[-`{-~]/);function wt(e){return e!==null&&e<-2}function ns(e){return e!==null&&(e<0||e===32)}function Jt(e){return e===-2||e===-1||e===32}const h9=xa(new RegExp("\\p{P}|\\p{S}","u")),m9=xa(/\s/);function xa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ru(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&hs(e.charCodeAt(n+1))&&hs(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),s=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+s+1,a=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function un(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return Jt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Jt(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const g9={tokenize:y9};function y9(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),un(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),o(l)}function o(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return wt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const w9={tokenize:x9},z1={tokenize:b9};function x9(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const _=n[r];return t.containerState=_[1],e.attempt(_[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const _=t.events.length;let S=_,N;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){N=t.events[S][1].end;break}g(r);let P=_;for(;P<t.events.length;)t.events[P][1].end={...N},P++;return zi(t.events,S+1,0,t.events.slice(_)),t.events.length=P,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return d(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(z1,p,f)(x)}function p(x){return s&&k(),g(r),d(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function d(x){return t.containerState={},e.attempt(z1,h,y)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),d(x)}function y(x){if(x===null){s&&k(),g(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),v(x)}function v(x){if(x===null){b(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return wt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,_){const S=t.sliceStream(x);if(_&&S.push(null),x.previous=o,o&&(o.next=x),o=x,s.defineSkip(x.start),s.write(S),t.parser.lazy[x.start.line]){let N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<a&&(!s.events[N][1].end||s.events[N][1].end.offset>a))return;const P=t.events.length;let R=P,z,E;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(z){E=t.events[R][1].end;break}z=!0}for(g(r),N=P;N<t.events.length;)t.events[N][1].end={...E},N++;zi(t.events,R+1,0,t.events.slice(P)),t.events.length=N}}function g(x){let _=n.length;for(;_-- >x;){const S=n[_];t.containerState=S[1],S[0].exit.call(t,e)}n.length=x}function k(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function b9(e,t,n){return un(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function B1(e){if(e===null||ns(e)||m9(e))return 1;if(h9(e))return 2}function hv(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const pb={name:"attention",resolveAll:k9,tokenize:v9};function k9(e,t){let n=-1,r,s,o,a,l,c,u,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},d={...e[n][1].start};W1(f,-c),W1(d,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ts(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ts(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Ts(u,hv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ts(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,u=Ts(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,zi(e,r-1,n-r+3,u),n=r+u.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function v9(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=B1(r);let o;return a;function a(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;const u=e.exit("attentionSequence"),p=B1(c),f=!p||p===2&&s||n.includes(c),d=!s||s===2&&p||n.includes(r);return u._open=!!(o===42?f:f&&(s||!d)),u._close=!!(o===42?d:d&&(p||!f)),t(c)}}function W1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const S9={name:"autolink",tokenize:j9};function j9(e,t,n){let r=0;return s;function s(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return Ei(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||hs(h)?(r=1,l(h)):u(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||hs(h))&&r++<32?(e.consume(h),l):(r=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||db(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),p):d9(h)?(e.consume(h),u):n(h)}function p(h){return hs(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,p):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):d(h)}function d(h){if((h===45||hs(h))&&r++<63){const y=h===45?d:f;return e.consume(h),y}return n(h)}}const wg={partial:!0,tokenize:N9};function N9(e,t,n){return r;function r(o){return Jt(o)?un(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||wt(o)?t(o):n(o)}}const cT={continuation:{tokenize:C9},exit:A9,name:"blockQuote",tokenize:_9};function _9(e,t,n){const r=this;return s;function s(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return Jt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function C9(e,t,n){const r=this;return s;function s(a){return Jt(a)?un(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(cT,t,n)(a)}}function A9(e){e.exit("blockQuote")}const uT={name:"characterEscape",tokenize:E9};function E9(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return p9(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const dT={name:"characterReference",tokenize:I9};function I9(e,t,n){const r=this;let s=0,o,a;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=hs,p(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=f9,p):(e.enter("characterReferenceValue"),o=7,a=fb,p(f))}function p(f){if(f===59&&s){const d=e.exit("characterReferenceValue");return a===hs&&!pv(r.sliceSerialize(d))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<o?(e.consume(f),p):n(f)}}const H1={partial:!0,tokenize:R9},V1={concrete:!0,name:"codeFenced",tokenize:P9};function P9(e,t,n){const r=this,s={partial:!0,tokenize:S};let o=0,a=0,l;return c;function c(N){return u(N)}function u(N){const P=r.events[r.events.length-1];return o=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(N)}function p(N){return N===l?(a++,e.consume(N),p):a<3?n(N):(e.exit("codeFencedFenceSequence"),Jt(N)?un(e,f,"whitespace")(N):f(N))}function f(N){return N===null||wt(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(H1,v,_)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(N))}function d(N){return N===null||wt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):Jt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),un(e,h,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),d)}function h(N){return N===null||wt(N)?f(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(N))}function y(N){return N===null||wt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(N)):N===96&&N===l?n(N):(e.consume(N),y)}function v(N){return e.attempt(s,_,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),g}function g(N){return o>0&&Jt(N)?un(e,k,"linePrefix",o+1)(N):k(N)}function k(N){return N===null||wt(N)?e.check(H1,v,_)(N):(e.enter("codeFlowValue"),x(N))}function x(N){return N===null||wt(N)?(e.exit("codeFlowValue"),k(N)):(e.consume(N),x)}function _(N){return e.exit("codeFenced"),t(N)}function S(N,P,R){let z=0;return E;function E(V){return N.enter("lineEnding"),N.consume(V),N.exit("lineEnding"),O}function O(V){return N.enter("codeFencedFence"),Jt(V)?un(N,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):D(V)}function D(V){return V===l?(N.enter("codeFencedFenceSequence"),L(V)):R(V)}function L(V){return V===l?(z++,N.consume(V),L):z>=a?(N.exit("codeFencedFenceSequence"),Jt(V)?un(N,M,"whitespace")(V):M(V)):R(V)}function M(V){return V===null||wt(V)?(N.exit("codeFencedFence"),P(V)):R(V)}}}function R9(e,t,n){const r=this;return s;function s(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const lw={name:"codeIndented",tokenize:M9},T9={partial:!0,tokenize:$9};function M9(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),un(e,o,"linePrefix",5)(u)}function o(u){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):wt(u)?e.attempt(T9,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||wt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function $9(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):un(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):wt(a)?s(a):n(a)}}const L9={name:"codeText",previous:D9,resolve:O9,tokenize:F9};function O9(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function D9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function F9(e,t,n){let r=0,s,o;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),s=0,p(f)):wt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||wt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function p(f){return f===96?(e.consume(f),s++,p):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class z9{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&qu(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),qu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),qu(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);qu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);qu(this.left,n.reverse())}}}function qu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function fT(e){const t={};let n=-1,r,s,o,a,l,c,u;const p=new z9(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,B9(p,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=p.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(p.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...p.get(s)[1].start},l=p.slice(s,n),l.unshift(r),p.splice(s,n-s+1,l))}}return zi(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!u}function B9(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],u={};let p,f,d=-1,h=n,y=0,v=0;const b=[v];for(;h;){for(;e.get(++s)[1]!==h;);o.push(s),h._tokenizer||(p=r.sliceStream(h),h.next||p.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(v=d+1,b.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),d=b.length;d--;){const g=l.slice(b[d],b[d+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),d=-1;++d<c.length;)u[y+c[d][0]]=y+c[d][1],y+=c[d][1]-c[d][0]-1;return u}const W9={resolve:V9,tokenize:K9},H9={partial:!0,tokenize:q9};function V9(e){return fT(e),e}function K9(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?o(l):wt(l)?e.check(H9,a,o)(l):(e.consume(l),s)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function q9(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),un(e,o,"linePrefix")}function o(a){if(a===null||wt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function pT(e,t,n,r,s,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let p=0;return f;function f(g){return g===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(g),e.exit(o),d):g===null||g===32||g===41||db(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function d(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(l),d(g)):g===null||g===60||wt(g)?n(g):(e.consume(g),g===92?y:h)}function y(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function v(g){return!p&&(g===null||g===41||ns(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):p<u&&g===40?(e.consume(g),p++,v):g===41?(e.consume(g),p--,v):g===null||g===32||g===40||db(g)?n(g):(e.consume(g),g===92?b:v)}function b(g){return g===40||g===41||g===92?(e.consume(g),v):v(g)}}function hT(e,t,n,r,s,o){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(o),p}function p(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):wt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||wt(h)||l++>999?(e.exit("chunkString"),p(h)):(e.consume(h),c||(c=!Jt(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function mT(e,t,n,r,s,o){let a;return l;function l(d){return d===34||d===39||d===40?(e.enter(r),e.enter(s),e.consume(d),e.exit(s),a=d===40?41:d,c):n(d)}function c(d){return d===a?(e.enter(s),e.consume(d),e.exit(s),e.exit(r),t):(e.enter(o),u(d))}function u(d){return d===a?(e.exit(o),c(a)):d===null?n(d):wt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),un(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===a||d===null||wt(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?f:p)}function f(d){return d===a||d===92?(e.consume(d),p):p(d)}}function Cd(e,t){let n;return r;function r(s){return wt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Jt(s)?un(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const U9={name:"definition",tokenize:Y9},G9={partial:!0,tokenize:J9};function Y9(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return hT.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=Ac(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return ns(h)?Cd(e,u)(h):u(h)}function u(h){return pT(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function p(h){return e.attempt(G9,f,f)(h)}function f(h){return Jt(h)?un(e,d,"whitespace")(h):d(h)}function d(h){return h===null||wt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function J9(e,t,n){return r;function r(l){return ns(l)?Cd(e,s)(l):n(l)}function s(l){return mT(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return Jt(l)?un(e,a,"whitespace")(l):a(l)}function a(l){return l===null||wt(l)?t(l):n(l)}}const X9={name:"hardBreakEscape",tokenize:Q9};function Q9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return wt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const Z9={name:"headingAtx",resolve:eV,tokenize:tV};function eV(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},zi(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function tV(e,t,n){let r=0;return s;function s(p){return e.enter("atxHeading"),o(p)}function o(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||ns(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),c(p)):p===null||wt(p)?(e.exit("atxHeading"),t(p)):Jt(p)?un(e,l,"whitespace")(p):(e.enter("atxHeadingText"),u(p))}function c(p){return p===35?(e.consume(p),c):(e.exit("atxHeadingSequence"),l(p))}function u(p){return p===null||p===35||ns(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),u)}}const nV=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],K1=["pre","script","style","textarea"],rV={concrete:!0,name:"htmlFlow",resolveTo:oV,tokenize:aV},sV={partial:!0,tokenize:cV},iV={partial:!0,tokenize:lV};function oV(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function aV(e,t,n){const r=this;let s,o,a,l,c;return u;function u(W){return p(W)}function p(W){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(W),f}function f(W){return W===33?(e.consume(W),d):W===47?(e.consume(W),o=!0,v):W===63?(e.consume(W),s=3,r.interrupt?t:A):Ei(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function d(W){return W===45?(e.consume(W),s=2,h):W===91?(e.consume(W),s=5,l=0,y):Ei(W)?(e.consume(W),s=4,r.interrupt?t:A):n(W)}function h(W){return W===45?(e.consume(W),r.interrupt?t:A):n(W)}function y(W){const te="CDATA[";return W===te.charCodeAt(l++)?(e.consume(W),l===te.length?r.interrupt?t:D:y):n(W)}function v(W){return Ei(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function b(W){if(W===null||W===47||W===62||ns(W)){const te=W===47,Z=a.toLowerCase();return!te&&!o&&K1.includes(Z)?(s=1,r.interrupt?t(W):D(W)):nV.includes(a.toLowerCase())?(s=6,te?(e.consume(W),g):r.interrupt?t(W):D(W)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(W):o?k(W):x(W))}return W===45||hs(W)?(e.consume(W),a+=String.fromCharCode(W),b):n(W)}function g(W){return W===62?(e.consume(W),r.interrupt?t:D):n(W)}function k(W){return Jt(W)?(e.consume(W),k):E(W)}function x(W){return W===47?(e.consume(W),E):W===58||W===95||Ei(W)?(e.consume(W),_):Jt(W)?(e.consume(W),x):E(W)}function _(W){return W===45||W===46||W===58||W===95||hs(W)?(e.consume(W),_):S(W)}function S(W){return W===61?(e.consume(W),N):Jt(W)?(e.consume(W),S):x(W)}function N(W){return W===null||W===60||W===61||W===62||W===96?n(W):W===34||W===39?(e.consume(W),c=W,P):Jt(W)?(e.consume(W),N):R(W)}function P(W){return W===c?(e.consume(W),c=null,z):W===null||wt(W)?n(W):(e.consume(W),P)}function R(W){return W===null||W===34||W===39||W===47||W===60||W===61||W===62||W===96||ns(W)?S(W):(e.consume(W),R)}function z(W){return W===47||W===62||Jt(W)?x(W):n(W)}function E(W){return W===62?(e.consume(W),O):n(W)}function O(W){return W===null||wt(W)?D(W):Jt(W)?(e.consume(W),O):n(W)}function D(W){return W===45&&s===2?(e.consume(W),B):W===60&&s===1?(e.consume(W),F):W===62&&s===4?(e.consume(W),Q):W===63&&s===3?(e.consume(W),A):W===93&&s===5?(e.consume(W),H):wt(W)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(sV,K,L)(W)):W===null||wt(W)?(e.exit("htmlFlowData"),L(W)):(e.consume(W),D)}function L(W){return e.check(iV,M,K)(W)}function M(W){return e.enter("lineEnding"),e.consume(W),e.exit("lineEnding"),V}function V(W){return W===null||wt(W)?L(W):(e.enter("htmlFlowData"),D(W))}function B(W){return W===45?(e.consume(W),A):D(W)}function F(W){return W===47?(e.consume(W),a="",$):D(W)}function $(W){if(W===62){const te=a.toLowerCase();return K1.includes(te)?(e.consume(W),Q):D(W)}return Ei(W)&&a.length<8?(e.consume(W),a+=String.fromCharCode(W),$):D(W)}function H(W){return W===93?(e.consume(W),A):D(W)}function A(W){return W===62?(e.consume(W),Q):W===45&&s===2?(e.consume(W),A):D(W)}function Q(W){return W===null||wt(W)?(e.exit("htmlFlowData"),K(W)):(e.consume(W),Q)}function K(W){return e.exit("htmlFlow"),t(W)}}function lV(e,t,n){const r=this;return s;function s(a){return wt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function cV(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(wg,t,n)}}const uV={name:"htmlText",tokenize:dV};function dV(e,t,n){const r=this;let s,o,a;return l;function l(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),c}function c(A){return A===33?(e.consume(A),u):A===47?(e.consume(A),S):A===63?(e.consume(A),x):Ei(A)?(e.consume(A),R):n(A)}function u(A){return A===45?(e.consume(A),p):A===91?(e.consume(A),o=0,y):Ei(A)?(e.consume(A),k):n(A)}function p(A){return A===45?(e.consume(A),h):n(A)}function f(A){return A===null?n(A):A===45?(e.consume(A),d):wt(A)?(a=f,F(A)):(e.consume(A),f)}function d(A){return A===45?(e.consume(A),h):f(A)}function h(A){return A===62?B(A):A===45?d(A):f(A)}function y(A){const Q="CDATA[";return A===Q.charCodeAt(o++)?(e.consume(A),o===Q.length?v:y):n(A)}function v(A){return A===null?n(A):A===93?(e.consume(A),b):wt(A)?(a=v,F(A)):(e.consume(A),v)}function b(A){return A===93?(e.consume(A),g):v(A)}function g(A){return A===62?B(A):A===93?(e.consume(A),g):v(A)}function k(A){return A===null||A===62?B(A):wt(A)?(a=k,F(A)):(e.consume(A),k)}function x(A){return A===null?n(A):A===63?(e.consume(A),_):wt(A)?(a=x,F(A)):(e.consume(A),x)}function _(A){return A===62?B(A):x(A)}function S(A){return Ei(A)?(e.consume(A),N):n(A)}function N(A){return A===45||hs(A)?(e.consume(A),N):P(A)}function P(A){return wt(A)?(a=P,F(A)):Jt(A)?(e.consume(A),P):B(A)}function R(A){return A===45||hs(A)?(e.consume(A),R):A===47||A===62||ns(A)?z(A):n(A)}function z(A){return A===47?(e.consume(A),B):A===58||A===95||Ei(A)?(e.consume(A),E):wt(A)?(a=z,F(A)):Jt(A)?(e.consume(A),z):B(A)}function E(A){return A===45||A===46||A===58||A===95||hs(A)?(e.consume(A),E):O(A)}function O(A){return A===61?(e.consume(A),D):wt(A)?(a=O,F(A)):Jt(A)?(e.consume(A),O):z(A)}function D(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),s=A,L):wt(A)?(a=D,F(A)):Jt(A)?(e.consume(A),D):(e.consume(A),M)}function L(A){return A===s?(e.consume(A),s=void 0,V):A===null?n(A):wt(A)?(a=L,F(A)):(e.consume(A),L)}function M(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||ns(A)?z(A):(e.consume(A),M)}function V(A){return A===47||A===62||ns(A)?z(A):n(A)}function B(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function F(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),$}function $(A){return Jt(A)?un(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):H(A)}function H(A){return e.enter("htmlTextData"),a(A)}}const mv={name:"labelEnd",resolveAll:mV,resolveTo:gV,tokenize:yV},fV={tokenize:wV},pV={tokenize:xV},hV={tokenize:bV};function mV(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&zi(e,0,e.length,n),e}function gV(e,t){let n=e.length,r=0,s,o,a,l;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Ts(l,e.slice(o+1,o+r+3)),l=Ts(l,[["enter",p,t]]),l=Ts(l,hv(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Ts(l,[["exit",p,t],e[a-2],e[a-1],["exit",u,t]]),l=Ts(l,e.slice(a+1)),l=Ts(l,[["exit",c,t]]),zi(e,o,e.length,l),e}function yV(e,t,n){const r=this;let s=r.events.length,o,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return l;function l(d){return o?o._inactive?f(d):(a=r.parser.defined.includes(Ac(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),c):n(d)}function c(d){return d===40?e.attempt(fV,p,a?p:f)(d):d===91?e.attempt(pV,p,a?u:f)(d):a?p(d):f(d)}function u(d){return e.attempt(hV,p,f)(d)}function p(d){return t(d)}function f(d){return o._balanced=!0,n(d)}}function wV(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return ns(f)?Cd(e,o)(f):o(f)}function o(f){return f===41?p(f):pT(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return ns(f)?Cd(e,c)(f):p(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?mT(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):p(f)}function u(f){return ns(f)?Cd(e,p)(f):p(f)}function p(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function xV(e,t,n){const r=this;return s;function s(l){return hT.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(Ac(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function bV(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const kV={name:"labelStartImage",resolveAll:mv.resolveAll,tokenize:vV};function vV(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const SV={name:"labelStartLink",resolveAll:mv.resolveAll,tokenize:jV};function jV(e,t,n){const r=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const cw={name:"lineEnding",tokenize:NV};function NV(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),un(e,t,"linePrefix")}}const _h={name:"thematicBreak",tokenize:_V};function _V(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||wt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Jt(u)?un(e,l,"whitespace")(u):l(u))}}const Ur={continuation:{tokenize:IV},exit:RV,name:"list",tokenize:EV},CV={partial:!0,tokenize:TV},AV={partial:!0,tokenize:PV};function EV(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(h){const y=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:fb(h)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(_h,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return fb(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(wg,r.interrupt?n:p,e.attempt(CV,d,f))}function p(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return Jt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function IV(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(wg,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,un(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!Jt(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(AV,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,un(e,e.attempt(Ur,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function PV(e,t,n){const r=this;return un(e,s,"listItemIndent",r.containerState.size+1);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function RV(e){e.exit(this.containerState.type)}function TV(e,t,n){const r=this;return un(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const a=r.events[r.events.length-1];return!Jt(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const q1={name:"setextUnderline",resolveTo:MV,tokenize:$V};function MV(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function $V(e,t,n){const r=this;let s;return o;function o(u){let p=r.events.length,f;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){f=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===s?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),Jt(u)?un(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||wt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const LV={tokenize:OV};function OV(e){const t=this,n=e.attempt(wg,r,e.attempt(this.parser.constructs.flowInitial,s,un(e,e.attempt(this.parser.constructs.flow,s,e.attempt(W9,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const DV={resolveAll:yT()},FV=gT("string"),zV=gT("text");function gT(e){return{resolveAll:yT(e==="text"?BV:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,a,l);return a;function a(p){return u(p)?o(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),c}function c(p){return u(p)?(n.exit("data"),o(p)):(n.consume(p),c)}function u(p){if(p===null)return!0;const f=s[p];let d=-1;if(f)for(;++d<f.length;){const h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function yT(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function BV(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,a=-1,l=0,c;for(;o--;){const u=s[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const WV={42:Ur,43:Ur,45:Ur,48:Ur,49:Ur,50:Ur,51:Ur,52:Ur,53:Ur,54:Ur,55:Ur,56:Ur,57:Ur,62:cT},HV={91:U9},VV={[-2]:lw,[-1]:lw,32:lw},KV={35:Z9,42:_h,45:[q1,_h],60:rV,61:q1,95:_h,96:V1,126:V1},qV={38:dT,92:uT},UV={[-5]:cw,[-4]:cw,[-3]:cw,33:kV,38:dT,42:pb,60:[S9,uV],91:SV,92:[X9,uT],93:mv,95:pb,96:L9},GV={null:[pb,DV]},YV={null:[42,95]},JV={null:[]},XV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:YV,contentInitial:HV,disable:JV,document:WV,flow:KV,flowInitial:VV,insideSpan:GV,string:qV,text:UV},Symbol.toStringTag,{value:"Module"}));function QV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let a=[],l=[];const c={attempt:P(S),check:P(N),consume:k,enter:x,exit:_,interrupt:P(N,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:f};let p=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(O){return a=Ts(a,O),b(),a[a.length-1]!==null?[]:(R(t,0),u.events=hv(o,u.events,u),u.events)}function d(O,D){return eK(h(O),D)}function h(O){return ZV(a,O)}function y(){const{_bufferIndex:O,_index:D,line:L,column:M,offset:V}=r;return{_bufferIndex:O,_index:D,line:L,column:M,offset:V}}function v(O){s[O.line]=O.column,E()}function b(){let O;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<D.length;)g(D.charCodeAt(r._bufferIndex));else g(D)}}function g(O){p=p(O)}function k(O){wt(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,E()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=O}function x(O,D){const L=D||{};return L.type=O,L.start=y(),u.events.push(["enter",L,u]),l.push(L),L}function _(O){const D=l.pop();return D.end=y(),u.events.push(["exit",D,u]),D}function S(O,D){R(O,D.from)}function N(O,D){D.restore()}function P(O,D){return L;function L(M,V,B){let F,$,H,A;return Array.isArray(M)?K(M):"tokenize"in M?K([M]):Q(M);function Q(G){return ne;function ne(re){const se=re!==null&&G[re],ee=re!==null&&G.null,ue=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(ee)?ee:ee?[ee]:[]];return K(ue)(re)}}function K(G){return F=G,$=0,G.length===0?B:W(G[$])}function W(G){return ne;function ne(re){return A=z(),H=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?Z():G.tokenize.call(D?Object.assign(Object.create(u),D):u,c,te,Z)(re)}}function te(G){return O(H,A),V}function Z(G){return A.restore(),++$<F.length?W(F[$]):B}}}function R(O,D){O.resolveAll&&!o.includes(O)&&o.push(O),O.resolve&&zi(u.events,D,u.events.length-D,O.resolve(u.events.slice(D),u)),O.resolveTo&&(u.events=O.resolveTo(u.events,u))}function z(){const O=y(),D=u.previous,L=u.currentConstruct,M=u.events.length,V=Array.from(l);return{from:M,restore:B};function B(){r=O,u.previous=D,u.currentConstruct=L,u.events.length=M,l=V,E()}}function E(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function ZV(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,o)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[s].slice(0,o))}return a}function eK(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
68
- `;break}case-3:{a=`\r
69
- `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&s)continue;a=" ";break}default:a=String.fromCharCode(o)}s=o===-2,r.push(a)}return r.join("")}function tK(e){const r={constructs:l9([XV,...(e||{}).extensions||[]]),content:s(g9),defined:[],document:s(w9),flow:s(LV),lazy:{},string:s(FV),text:s(zV)};return r;function s(o){return a;function a(l){return QV(r,o,l)}}}function nK(e){for(;!fT(e););return e}const U1=/[\0\t\n\r]/g;function rK(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,p,f,d,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(U1.lastIndex=f,u=U1.exec(o),d=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(d),!u){t=o.slice(f);break}if(h===10&&f===d&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<d&&(c.push(o.slice(f,d)),e+=d-f),h){case 0:{c.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,c.push(-2);e++<p;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=d+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const sK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function iK(e){return e.replace(sK,oK)}function oK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return lT(n.slice(o?2:1),o?16:10)}return pv(n)||e}const wT={}.hasOwnProperty;function aK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),lK(n)(nK(tK(n).document().write(rK()(e,t,!0))))}function lK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(yt),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(Ne),blockQuote:o(ee),characterEscape:z,characterReference:z,codeFenced:o(ue),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ue,a),codeText:o(de,a),codeTextData:z,data:z,codeFlowValue:z,definition:o(pe),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Me),hardBreakEscape:o(_e),hardBreakTrailing:o(_e),htmlFlow:o(He,a),htmlFlowData:z,htmlText:o(He,a),htmlTextData:z,image:o(ct),label:a,link:o(yt),listItem:o(at),listItemValue:d,listOrdered:o(Re,f),listUnordered:o(Re),paragraph:o(kt),reference:W,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ne),strong:o($t),thematicBreak:o(ze)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:se,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:Z,characterReferenceMarkerNumeric:Z,characterReferenceValue:G,characterReference:ne,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:c(g),codeText:c(V),codeTextData:E,data:E,definition:c(),definitionDestinationString:_,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(L),htmlFlowData:E,htmlText:c(M),htmlTextData:E,image:c(F),label:H,labelText:$,lineEnding:O,link:c(B),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:te,resourceDestinationString:A,resourceTitleString:Q,resource:K,setextHeading:c(R),setextHeadingLineSequence:P,setextHeadingText:N,strong:c(),thematicBreak:c()}};xT(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(oe){let ke={type:"root",children:[]};const Be={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:p,data:n},Qe=[];let Ce=-1;for(;++Ce<oe.length;)if(oe[Ce][1].type==="listOrdered"||oe[Ce][1].type==="listUnordered")if(oe[Ce][0]==="enter")Qe.push(Ce);else{const Ct=Qe.pop();Ce=s(oe,Ct,Ce)}for(Ce=-1;++Ce<oe.length;){const Ct=t[oe[Ce][0]];wT.call(Ct,oe[Ce][1].type)&&Ct[oe[Ce][1].type].call(Object.assign({sliceSerialize:oe[Ce][2].sliceSerialize},Be),oe[Ce][1])}if(Be.tokenStack.length>0){const Ct=Be.tokenStack[Be.tokenStack.length-1];(Ct[1]||G1).call(Be,void 0,Ct[0])}for(ke.position={start:Oo(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:Oo(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce<t.transforms.length;)ke=t.transforms[Ce](ke)||ke;return ke}function s(oe,ke,Be){let Qe=ke-1,Ce=-1,Ct=!1,Xt,Ft,rt,Fn;for(;++Qe<=Be;){const ie=oe[Qe];switch(ie[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ie[0]==="enter"?Ce++:Ce--,Fn=void 0;break}case"lineEndingBlank":{ie[0]==="enter"&&(Xt&&!Fn&&!Ce&&!rt&&(rt=Qe),Fn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Fn=void 0}if(!Ce&&ie[0]==="enter"&&ie[1].type==="listItemPrefix"||Ce===-1&&ie[0]==="exit"&&(ie[1].type==="listUnordered"||ie[1].type==="listOrdered")){if(Xt){let Ie=Qe;for(Ft=void 0;Ie--;){const et=oe[Ie];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;Ft&&(oe[Ft][1].type="lineEndingBlank",Ct=!0),et[1].type="lineEnding",Ft=Ie}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"||et[1].type==="blockQuoteMarker"||et[1].type==="listItemIndent"))break}rt&&(!Ft||rt<Ft)&&(Xt._spread=!0),Xt.end=Object.assign({},Ft?oe[Ft][1].start:ie[1].end),oe.splice(Ft||Qe,0,["exit",Xt,ie[2]]),Qe++,Be++}if(ie[1].type==="listItemPrefix"){const Ie={type:"listItem",_spread:!1,start:Object.assign({},ie[1].start),end:void 0};Xt=Ie,oe.splice(Qe,0,["enter",Ie,ie[2]]),Qe++,Be++,rt=void 0,Fn=!0}}}return oe[ke][1]._spread=Ct,Be}function o(oe,ke){return Be;function Be(Qe){l.call(this,oe(Qe),Qe),ke&&ke.call(this,Qe)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(oe,ke,Be){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([ke,Be||void 0]),oe.position={start:Oo(ke.start),end:void 0}}function c(oe){return ke;function ke(Be){oe&&oe.call(this,Be),u.call(this,Be)}}function u(oe,ke){const Be=this.stack.pop(),Qe=this.tokenStack.pop();if(Qe)Qe[0].type!==oe.type&&(ke?ke.call(this,oe,Qe[0]):(Qe[1]||G1).call(this,oe,Qe[0]));else throw new Error("Cannot close `"+oe.type+"` ("+_d({start:oe.start,end:oe.end})+"): it’s not open");Be.position.end=Oo(oe.end)}function p(){return o9(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(oe){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function h(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=oe}function y(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=oe}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe.replace(/(\r?\n|\r)$/g,"")}function k(oe){const ke=this.resume(),Be=this.stack[this.stack.length-1];Be.label=ke,Be.identifier=Ac(this.sliceSerialize(oe)).toLowerCase()}function x(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.title=oe}function _(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.url=oe}function S(oe){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Be=this.sliceSerialize(oe).length;ke.depth=Be}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function P(oe){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function z(oe){const Be=this.stack[this.stack.length-1].children;let Qe=Be[Be.length-1];(!Qe||Qe.type!=="text")&&(Qe=ye(),Qe.position={start:Oo(oe.start),end:void 0},Be.push(Qe)),this.stack.push(Qe)}function E(oe){const ke=this.stack.pop();ke.value+=this.sliceSerialize(oe),ke.position.end=Oo(oe.end)}function O(oe){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Be=ke.children[ke.children.length-1];Be.position.end=Oo(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(z.call(this,oe),E.call(this,oe))}function D(){this.data.atHardBreak=!0}function L(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe}function M(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe}function V(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.value=oe}function B(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ke,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function F(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=ke,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function $(oe){const ke=this.sliceSerialize(oe),Be=this.stack[this.stack.length-2];Be.label=iK(ke),Be.identifier=Ac(ke).toLowerCase()}function H(){const oe=this.stack[this.stack.length-1],ke=this.resume(),Be=this.stack[this.stack.length-1];if(this.data.inReference=!0,Be.type==="link"){const Qe=oe.children;Be.children=Qe}else Be.alt=ke}function A(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.url=oe}function Q(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.title=oe}function K(){this.data.inReference=void 0}function W(){this.data.referenceType="collapsed"}function te(oe){const ke=this.resume(),Be=this.stack[this.stack.length-1];Be.label=ke,Be.identifier=Ac(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function Z(oe){this.data.characterReferenceType=oe.type}function G(oe){const ke=this.sliceSerialize(oe),Be=this.data.characterReferenceType;let Qe;Be?(Qe=lT(ke,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Qe=pv(ke);const Ce=this.stack[this.stack.length-1];Ce.value+=Qe}function ne(oe){const ke=this.stack.pop();ke.position.end=Oo(oe.end)}function re(oe){E.call(this,oe);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(oe)}function se(oe){E.call(this,oe);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(oe)}function ee(){return{type:"blockquote",children:[]}}function ue(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Me(){return{type:"emphasis",children:[]}}function Ne(){return{type:"heading",depth:0,children:[]}}function _e(){return{type:"break"}}function He(){return{type:"html",value:""}}function ct(){return{type:"image",title:null,url:"",alt:null}}function yt(){return{type:"link",title:null,url:"",children:[]}}function Re(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function at(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function kt(){return{type:"paragraph",children:[]}}function $t(){return{type:"strong",children:[]}}function ye(){return{type:"text",value:""}}function ze(){return{type:"thematicBreak"}}}function Oo(e){return{line:e.line,column:e.column,offset:e.offset}}function xT(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?xT(e,r):cK(e,r)}}function cK(e,t){let n;for(n in t)if(wT.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function G1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+_d({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+_d({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+_d({start:t.start,end:t.end})+") is still open")}function uK(e){const t=this;t.parser=n;function n(r){return aK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function dK(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function fK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function pK(e,t){const n=t.value?t.value+`
71
- `:"",r={},s=t.lang?t.lang.split(/\s+/):[];s.length>0&&(r.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function hK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=ru(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+s,id:n+"fnref-"+s+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function yK(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function bT(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const s=e.all(t),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=r:s.push({type:"text",value:r}),s}function xK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return bT(e,t);const s={src:ru(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,o),e.applyData(t,o)}function bK(e,t){const n={src:ru(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function kK(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function vK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return bT(e,t);const s={href:ru(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const o={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function SK(e,t){const n={href:ru(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function jK(e,t,n){const r=e.all(t),s=n?NK(n):kT(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let f;p&&p.type==="element"&&p.tagName==="p"?f=p:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const p=r[l];(s||l!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),p.type==="element"&&p.tagName==="p"&&!s?a.push(...p.children):a.push(p)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function NK(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=kT(n[r])}return t}function kT(e){const t=e.spread;return t??e.children.length>1}function _K(e,t){const n={},r=e.all(t);let s=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++s<r.length;){const a=r[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function CK(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function AK(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function EK(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function IK(e,t){const n=e.all(t),r=n.shift(),s=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),s.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=cv(t.children[1]),c=tT(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function PK(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<l;){const f=t.children[c],d={},h=a?a[c]:void 0;h&&(d.align=h);let y={type:"element",tagName:o,properties:d,children:[]};f&&(y.children=e.all(f),e.patch(f,y),y=e.applyData(f,y)),u.push(y)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,p),e.applyData(t,p)}function RK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Y1=9,J1=32;function TK(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(X1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(X1(t.slice(s),s>0,!1)),o.join("")}function X1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===Y1||o===J1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===Y1||o===J1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function MK(e,t){const n={type:"text",value:TK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function $K(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const LK={blockquote:dK,break:fK,code:pK,delete:hK,emphasis:mK,footnoteReference:gK,heading:yK,html:wK,imageReference:xK,image:bK,inlineCode:kK,linkReference:vK,link:SK,listItem:jK,list:_K,paragraph:CK,root:AK,strong:EK,table:IK,tableCell:RK,tableRow:PK,text:MK,thematicBreak:$K,toml:Wp,yaml:Wp,definition:Wp,footnoteDefinition:Wp};function Wp(){}const vT=-1,xg=0,Ad=1,mm=2,gv=3,yv=4,wv=5,xv=6,ST=7,jT=8,Q1=typeof self=="object"?self:globalThis,OK=(e,t)=>{const n=(s,o)=>(e.set(o,s),s),r=s=>{if(e.has(s))return e.get(s);const[o,a]=t[s];switch(o){case xg:case vT:return n(a,s);case Ad:{const l=n([],s);for(const c of a)l.push(r(c));return l}case mm:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case gv:return n(new Date(a),s);case yv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case wv:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case xv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case ST:{const{name:l,message:c}=a;return n(new Q1[l](c),s)}case jT:return n(BigInt(a),s);case"BigInt":return n(Object(BigInt(a)),s);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:l}=new Uint8Array(a);return n(new DataView(l),a)}}return n(new Q1[o](a),s)};return r},Z1=e=>OK(new Map,e)(0),Ul="",{toString:DK}={},{keys:FK}=Object,Uu=e=>{const t=typeof e;if(t!=="object"||!e)return[xg,t];const n=DK.call(e).slice(8,-1);switch(n){case"Array":return[Ad,Ul];case"Object":return[mm,Ul];case"Date":return[gv,Ul];case"RegExp":return[yv,Ul];case"Map":return[wv,Ul];case"Set":return[xv,Ul];case"DataView":return[Ad,n]}return n.includes("Array")?[Ad,n]:n.includes("Error")?[ST,n]:[mm,n]},Hp=([e,t])=>e===xg&&(t==="function"||t==="symbol"),zK=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},o=a=>{if(n.has(a))return n.get(a);let[l,c]=Uu(a);switch(l){case xg:{let p=a;switch(c){case"bigint":l=jT,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);p=null;break;case"undefined":return s([vT],a)}return s([l,p],a)}case Ad:{if(c){let d=a;return c==="DataView"?d=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(d=new Uint8Array(a)),s([c,[...d]],a)}const p=[],f=s([l,p],a);for(const d of a)p.push(o(d));return f}case mm:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const p=[],f=s([l,p],a);for(const d of FK(a))(e||!Hp(Uu(a[d])))&&p.push([o(d),o(a[d])]);return f}case gv:return s([l,a.toISOString()],a);case yv:{const{source:p,flags:f}=a;return s([l,{source:p,flags:f}],a)}case wv:{const p=[],f=s([l,p],a);for(const[d,h]of a)(e||!(Hp(Uu(d))||Hp(Uu(h))))&&p.push([o(d),o(h)]);return f}case xv:{const p=[],f=s([l,p],a);for(const d of a)(e||!Hp(Uu(d)))&&p.push(o(d));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},e_=(e,{json:t,lossy:n}={})=>{const r=[];return zK(!(t||n),!!t,new Map,r)(e),r},gm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Z1(e_(e,t)):structuredClone(e):(e,t)=>Z1(e_(e,t));function BK(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function WK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function HK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||BK,r=e.options.footnoteBackLabel||WK,s=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const p=e.all(u),f=String(u.identifier).toUpperCase(),d=ru(f.toLowerCase());let h=0;const y=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,h);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+d+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=p[p.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const k=b.children[b.children.length-1];k&&k.type==="text"?k.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...y)}else p.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(p,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...gm(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
74
- `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
75
- `}]}}const NT=function(e){if(e==null)return UK;if(typeof e=="function")return bg(e);if(typeof e=="object")return Array.isArray(e)?VK(e):KK(e);if(typeof e=="string")return qK(e);throw new Error("Expected function, string, or object as test")};function VK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=NT(e[n]);return bg(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function KK(e){const t=e;return bg(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function qK(e){return bg(t);function t(n){return n&&n.type===e}}function bg(e){return t;function t(n,r,s){return!!(GK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function UK(){return!0}function GK(e){return e!==null&&typeof e=="object"&&"type"in e}const _T=[],YK=!0,t_=!1,JK="skip";function XK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=NT(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,p){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=_T,y,v,b;if((!t||o(c,u,p[p.length-1]||void 0))&&(h=QK(n(c,p)),h[0]===t_))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==JK)for(v=(r?g.children.length:-1)+a,b=p.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===t_)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function QK(e){return Array.isArray(e)?e:typeof e=="number"?[YK,e]:e==null?_T:[e]}function CT(e,t,n,r){let s,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,s=n):(o=t,a=n,s=r),XK(e,o,l,s);function l(c,u){const p=u[u.length-1],f=p?p.children.indexOf(c):void 0;return a(c,f,p)}}const hb={}.hasOwnProperty,ZK={};function e7(e,t){const n=t||ZK,r=new Map,s=new Map,o=new Map,a={...LK,...n.handlers},l={all:u,applyData:n7,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:t7,wrap:s7};return CT(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const f=p.type==="definition"?r:s,d=String(p.identifier).toUpperCase();f.has(d)||f.set(d,p)}}),l;function c(p,f){const d=p.type,h=l.handlers[d];if(hb.call(l.handlers,d)&&h)return h(l,p,f);if(l.options.passThrough&&l.options.passThrough.includes(d)){if("children"in p){const{children:v,...b}=p,g=gm(b);return g.children=l.all(p),g}return gm(p)}return(l.options.unknownHandler||r7)(l,p,f)}function u(p){const f=[];if("children"in p){const d=p.children;let h=-1;for(;++h<d.length;){const y=l.one(d[h],p);if(y){if(h&&d[h-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=n_(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=n_(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function t7(e,t){e.position&&(t.position=D8(e))}function n7(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,gm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function r7(e,t){const n=t.data||{},r="value"in t&&!(hb.call(n,"hProperties")||hb.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function s7(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
76
- `});++r<e.length;)r&&n.push({type:"text",value:`
77
- `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
78
- `}),n}function n_(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function r_(e,t){const n=e7(e,t),r=n.one(e,void 0),s=HK(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
79
- `},s),o}function i7(e,t){return e&&"run"in e?async function(n,r){const s=r_(n,{file:r,...t});await e.run(s,r)}:function(n,r){return r_(n,{file:r,...e||t})}}function s_(e){if(e)throw e}var Ch=Object.prototype.hasOwnProperty,AT=Object.prototype.toString,i_=Object.defineProperty,o_=Object.getOwnPropertyDescriptor,a_=function(t){return typeof Array.isArray=="function"?Array.isArray(t):AT.call(t)==="[object Array]"},l_=function(t){if(!t||AT.call(t)!=="[object Object]")return!1;var n=Ch.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Ch.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Ch.call(t,s)},c_=function(t,n){i_&&n.name==="__proto__"?i_(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},u_=function(t,n){if(n==="__proto__")if(Ch.call(t,n)){if(o_)return o_(t,n).value}else return;return t[n]},o7=function e(){var t,n,r,s,o,a,l=arguments[0],c=1,u=arguments.length,p=!1;for(typeof l=="boolean"&&(p=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=u_(l,n),s=u_(t,n),l!==s&&(p&&s&&(l_(s)||(o=a_(s)))?(o?(o=!1,a=r&&a_(r)?r:[]):a=r&&l_(r)?r:{},c_(l,{name:n,newValue:e(p,a,s)})):typeof s<"u"&&c_(l,{name:n,newValue:s}));return l};const uw=ma(o7);function mb(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function a7(){const e=[],t={run:n,use:r};return t;function n(...s){let o=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(c,...u){const p=e[++o];let f=-1;if(c){a(c);return}for(;++f<s.length;)(u[f]===null||u[f]===void 0)&&(u[f]=s[f]);s=u,p?l7(p,l)(...u):a(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function l7(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(u){const p=u;if(l&&n)throw p;return s(p)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,s):c instanceof Error?s(c):o(c))}function s(a,...l){n||(n=!0,t(a,...l))}function o(a){s(null,a)}}const Si={basename:c7,dirname:u7,extname:d7,join:f7,sep:"/"};function c7(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Rf(e);let n=0,r=-1,s=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else r<0&&(o=!0,r=s+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){n=s+1;break}}else a<0&&(o=!0,a=s+1),l>-1&&(e.codePointAt(s)===t.codePointAt(l--)?l<0&&(r=s):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function u7(e){if(Rf(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function d7(e){Rf(e);let t=e.length,n=-1,r=0,s=-1,o=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?s<0?s=t:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||n<0||o===0||o===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function f7(...e){let t=-1,n;for(;++t<e.length;)Rf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":p7(n)}function p7(e){Rf(e);const t=e.codePointAt(0)===47;let n=h7(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function h7(e,t){let n="",r=0,s=-1,o=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(s===a-1||o===1))if(s!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),s=a,o=0;continue}}else if(n.length>0){n="",r=0,s=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),r=a-s-1;s=a,o=0}else l===46&&o>-1?o++:o=-1}return n}function Rf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const m7={cwd:g7};function g7(){return"/"}function gb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function y7(e){if(typeof e=="string")e=new URL(e);else if(!gb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return w7(e)}function w7(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(t)}const dw=["history","path","basename","stem","extname","dirname"];class ET{constructor(t){let n;t?gb(t)?n={path:t}:typeof t=="string"||x7(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":m7.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<dw.length;){const o=dw[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let s;for(s in n)dw.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Si.basename(this.path):void 0}set basename(t){pw(t,"basename"),fw(t,"basename"),this.path=Si.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Si.dirname(this.path):void 0}set dirname(t){d_(this.basename,"dirname"),this.path=Si.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Si.extname(this.path):void 0}set extname(t){if(fw(t,"extname"),d_(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Si.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){gb(t)&&(t=y7(t)),pw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Si.basename(this.path,this.extname):void 0}set stem(t){pw(t,"stem"),fw(t,"stem"),this.path=Si.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const s=this.message(t,n,r);throw s.fatal=!0,s}info(t,n,r){const s=this.message(t,n,r);return s.fatal=void 0,s}message(t,n,r){const s=new Rr(t,n,r);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function fw(e,t){if(e&&e.includes(Si.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Si.sep+"`")}function pw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function d_(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function x7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const b7=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},k7={}.hasOwnProperty;class bv extends b7{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=a7()}copy(){const t=new bv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(uw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(gw("data",this.frozen),this.namespace[t]=n,this):k7.call(this.namespace,t)&&this.namespace[t]||void 0:t?(gw("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Vp(t),r=this.parser||this.Parser;return hw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),hw("process",this.parser||this.Parser),mw("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Vp(t),c=r.parse(l);r.run(c,l,function(p,f,d){if(p||!f||!d)return u(p);const h=f,y=r.stringify(h,d);j7(y)?d.value=y:d.result=y,u(p,d)});function u(p,f){p||!f?a(p):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),hw("processSync",this.parser||this.Parser),mw("processSync",this.compiler||this.Compiler),this.process(t,s),p_("processSync","process",n),r;function s(o,a){n=!0,s_(o),r=a}}run(t,n,r){f_(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const c=Vp(n);s.run(t,c,u);function u(p,f,d){const h=f||t;p?l(p):a?a(h):r(void 0,h,d)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),p_("runSync","run",r),s;function o(a,l){s_(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Vp(n),s=this.compiler||this.Compiler;return mw("stringify",s),f_(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(gw("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[p,...f]=u;c(p,f)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(s.settings=uw(!0,s.settings,u.settings))}function l(u){let p=-1;if(u!=null)if(Array.isArray(u))for(;++p<u.length;){const f=u[p];o(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,p){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===u){d=f;break}if(d===-1)r.push([u,...p]);else if(p.length>0){let[h,...y]=p;const v=r[d][1];mb(v)&&mb(h)&&(h=uw(!0,v,h)),r[d]=[u,h,...y]}}}}const v7=new bv().freeze();function hw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function mw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function gw(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function f_(e){if(!mb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function p_(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Vp(e){return S7(e)?e:new ET(e)}function S7(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function j7(e){return typeof e=="string"||N7(e)}function N7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const _7="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",h_=[],m_={allowDangerousHtml:!0},C7=/^(https?|ircs?|mailto|xmpp)$/i,A7=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function IT(e){const t=E7(e),n=I7(e);return P7(t.runSync(t.parse(n),n),e)}function E7(e){const t=e.rehypePlugins||h_,n=e.remarkPlugins||h_,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...m_}:m_;return v7().use(uK).use(n).use(i7,r).use(t)}function I7(e){const t=e.children||"",n=new ET;return typeof t=="string"&&(n.value=t),n}function P7(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||R7;for(const p of A7)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+_7+p.id,void 0);return CT(e,u),H8(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function u(p,f,d){if(p.type==="raw"&&d&&typeof f=="number")return a?d.children.splice(f,1):d.children[f]={type:"text",value:p.value},f;if(p.type==="element"){let h;for(h in aw)if(Object.hasOwn(aw,h)&&Object.hasOwn(p.properties,h)){const y=p.properties[h],v=aw[h];(v===null||v.includes(p.tagName))&&(p.properties[h]=c(String(y||""),h,p))}}if(p.type==="element"){let h=n?!n.includes(p.tagName):o?o.includes(p.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(p,f,d)),h&&d&&typeof f=="number")return l&&p.children?d.children.splice(f,1,...p.children):d.children.splice(f,1),f}}}function R7(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),s=e.indexOf("/");return t===-1||s!==-1&&t>s||n!==-1&&t>n||r!==-1&&t>r||C7.test(e.slice(0,t))?e:""}const T7=new Set(["echarts"]),M7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),$7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),L7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function oa(e){return e&&typeof e=="object"&&!Array.isArray(e)}function cl(e,t){if(!oa(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:oa(n[r])&&oa(s)&&(n[r]=cl(n[r],s));return n}function kg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>oa(n)?cl(n,t):n):oa(e)?cl(e,t):e}function O7(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:json|chart|echarts)?\s*\n?([\s\S]*?)```/i);if(n!=null&&n[1])t=n[1].trim();else{const r=t.indexOf("{"),s=t.lastIndexOf("}");r>=0&&s>r&&(t=t.slice(r,s+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function yb(e,t="$"){if(e!=null){if(typeof e=="string"){if(/<\s*(script|iframe|object|embed|link|meta)\b/i.test(e))throw new Error(`${t} contains unsafe HTML`);if(/\bjavascript\s*:/i.test(e)||/\bdata\s*:\s*text\/html/i.test(e))throw new Error(`${t} contains unsafe URL text`);return}if(Array.isArray(e)){e.forEach((n,r)=>yb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||$7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);yb(r,`${t}.${n}`)}}}function D7(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!M7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function F7(e){const t={trigger:"item",renderMode:"richText",backgroundColor:"rgba(20, 22, 28, 0.96)",borderColor:"rgba(124, 156, 255, 0.28)",textStyle:{color:"rgba(255, 255, 255, 0.92)"}};return!e||typeof e!="object"||Array.isArray(e)?t:cl(e,t)}function z7(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!oa(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return cl(o,n)}):oa(e)?cl(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function B7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:kg(e,n)}function g_(e,t="rgba(255, 255, 255, 0.62)"){return kg(e,{nameTextStyle:{color:t},axisLabel:{color:"rgba(255, 255, 255, 0.58)"},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.22)"}},axisTick:{lineStyle:{color:"rgba(255, 255, 255, 0.18)"}},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}}})}function W7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:kg(e,n)}function H7(e){const t={axisName:{color:"rgba(255, 255, 255, 0.68)"},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}},splitArea:{areaStyle:{color:["rgba(255, 255, 255, 0.025)","rgba(255, 255, 255, 0.045)"]}},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.16)"}}};return e==null?e:kg(e,t)}function V7(e,t,n){const r=z7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>oa(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??L7,textStyle:cl(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:F7(e.tooltip),legend:B7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?W7(e.grid,s||o):e.grid,xAxis:g_(e.xAxis),yAxis:g_(e.yAxis),radar:H7(e.radar),series:t}}function K7(e){const t=O7(e);if(!t)return{ok:!1,error:"No chart content"};try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("ChartSpec must be a JSON object");if(n.type!=="chart")throw new Error('type must be "chart"');if(n.version!=="1.0")throw new Error('version must be "1.0"');if(!T7.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");yb(n);const r=D7(n.option.series),s=n.title==null?"":String(n.title),o=V7(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:o}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function Kp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function q7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function io(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!Kp(t,t.length-1)&&(t=t.slice(0,-1));const n=[];let r="",s=0;for(let o=0;o<t.length;o+=1){const a=t[o];if(a==="`"&&!Kp(t,o)){const l=q7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!Kp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&Kp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function PT(e,t){if(!t)return e;const n=e.slice(0,t);for(e.length>t&&(n[t-1]=[e[t-1],...e.slice(t)].filter(Boolean).join(" | "));n.length<t;)n.push("");return n}function RT(e){const t=io(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function TT(e){return io(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function U7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function G7(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const o=(l,c="")=>{const u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[1]):o(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){s=c[2].toUpperCase();continue}const u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function Y7({code:e}){const t=m.useMemo(()=>G7(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,s=46,o=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((p,f)=>{l.set(p.id,{x:28+(n?f*(r+o):f%3*(r+o)),y:28+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(p=>p.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(p=>p.y+s+28));return i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid flowchart preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-md-mermaid-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,f)=>{const d=l.get(p.from),h=l.get(p.to);if(!d||!h)return null;const y=n?`M ${d.x+r} ${d.y+s/2} C ${(d.x+h.x+r)/2} ${d.y+s/2}, ${(d.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${d.x+r/2} ${d.y+s} C ${d.x+r/2} ${d.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${p.from}-${p.to}-${f}`)}),t.nodes.map(p=>{const f=l.get(p.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,24)})]},p.id)})]})}function J7(e){const t=String(e||"").split(/\r?\n/).map(o=>o.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],s=(o,a="")=>{const l=String(o||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const o of t){if(/^sequenceDiagram\b/i.test(o))continue;const a=o.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){s(a[2],a[3]||a[2]);continue}const l=o.match(/^([A-Za-z0-9_]+)\s*[-=]+>>\+?\s*([A-Za-z0-9_]+)\s*:\s*(.+)$/);if(l){s(l[1]),s(l[2]),r.push({type:"message",from:l[1],to:l[2],text:l[3]});continue}const c=o.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:c?c[2]:o})}return{participants:Array.from(n,([o,a])=>({id:o,label:a})),rows:r}}function X7({code:e}){const t=m.useMemo(()=>J7(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,s=48,o=26,a=44,l=48,c=Math.max(620,s*2+n.length*r),u=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),p=f=>{const d=Math.max(0,n.findIndex(h=>h.id===f));return s+d*r+r/2};return i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-md-sequence-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((f,d)=>{const h=s+d*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:h,y:o+22,textAnchor:"middle",children:f.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,d)=>{const h=o+a+d*l+24;if(f.type!=="message")return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-sequence-note",x:s,y:h-17,width:c-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:f.text.slice(0,120)})]},`note-${d}`);const y=p(f.from),v=p(f.to),b=(y+v)/2;return i.jsxs("g",{children:[i.jsx("line",{className:"af-md-mermaid-edge",x1:y,y1:h,x2:v,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:b,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${d}`)})]})}function MT({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return i.jsx("div",{className:"af-md-mermaid-preview",children:n?i.jsx(X7,{code:t}):i.jsx(Y7,{code:t})})}function Q7(e){const t=String(e||"").replace(/\r\n/g,`
80
- `).split(`
81
- `),n=[];let r=[],s=!1;const o=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
82
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!s&&c){o();const u=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)u.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:u.join(`
83
- `)});continue}if(!s&&U7(l)){o();const u=[];for(;a<t.length;){const p=t[a]||"";if(u.length>0&&(!p.trim()||/^-{3,}\s*$/.test(p)||/^#{1,6}\s+/.test(p)))break;u.push(p),a++}n.push({type:"mermaid",text:u.join(`
84
- `)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&io(l).length>1&&RT(t[a+1])){o();const u=io(l),p=TT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&io(t[a]).length>1;)f.push(PT(io(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:p,rows:f});continue}r.push(l),a++}return o(),n}function y_(e,t=""){const n=String(e||"").trim();if(!n||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n)||n.startsWith("/")||n.startsWith("#")||!t||n.startsWith("outputs/"))return n;const r=String(t||"").split("/").filter(Boolean);r.pop();const s=[...r,...n.split("/")].filter(Boolean),o=[];for(const a of s)if(a!=="."){if(a===".."){if(o.length===0)return n;o.pop();continue}o.push(a)}return o.join("/")}function $T(e){const t=String(e||"").replace(/\r\n/g,`
85
- `).split(`
86
- `);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",o=0,a=!1;for(;o<r.length;){const l=r[o];if(l==="`"){a=!a,s+=l,o+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(o)))){s+=l,o+=1;continue}if((o>0?r[o-1]:"")==="("){s+=l,o+=1;continue}let p=o;for(;p<r.length&&!/\s|<|>/.test(r[p]);)p+=1;let f=r.slice(o,p),d="";for(;/[.,;:!?)}\]]$/.test(f);)d=f.slice(-1)+d,f=f.slice(0,-1);f?s+=`[${f}](${f})${d}`:s+=r.slice(o,p),o=p}return s}).join(`
87
- `)}function LT(e,t=!1,n=""){const r=o=>{const a=String(o||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=y_(a,n);return e?e(l,{kind:"link",download:!0}):l},s=(o,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(o.stopPropagation(),!(o.defaultPrevented||o.button!==0)&&(o.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:o})=>i.jsx(i.Fragment,{children:o})}:{},code:({inline:o,className:a,children:l})=>{var p;const c=((p=String(a||"").match(/language-(\w+)/i))==null?void 0:p[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?i.jsx(MT,{code:u}):o?i.jsx("code",{className:a,children:l}):i.jsx("code",{className:a,children:l})},img:({src:o,alt:a})=>i.jsx("img",{src:e?e(y_(o,n)):o||"",alt:a||"",loading:"lazy"}),a:({href:o,children:a})=>i.jsx("a",{href:r(o),target:"_blank",rel:"noopener noreferrer",onClick:l=>s(l,o),children:a})}}function w_({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(IT,{components:LT(t,!0,n),children:$T(e)})}function kv({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>Q7(e),[e]),s=m.useMemo(()=>LT(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(MT,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(IT,{components:s,children:$T(o.text)},`md-${a}`):i.jsx("div",{className:"af-work-display-table-wrap",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:o.headers.map((l,c)=>i.jsx("th",{style:{textAlign:o.align[c]||"left"},children:i.jsx(w_,{resolveSrc:t,basePath:n,children:l})},c))})}),i.jsx("tbody",{children:o.rows.map((l,c)=>i.jsx("tr",{children:o.headers.map((u,p)=>i.jsx("td",{style:{textAlign:o.align[p]||"left"},children:i.jsx(w_,{resolveSrc:t,basePath:n,children:l[p]||""})},p))},c))})]})},`table-${a}`))})}function Z7(e,t=","){const n=[];let r=[],s="",o=!1;const a=String(e||"").replace(/\r\n/g,`
88
- `);for(let l=0;l<a.length;l+=1){const c=a[l],u=a[l+1];if(o){c==='"'&&u==='"'?(s+='"',l+=1):c==='"'?o=!1:s+=c;continue}c==='"'?o=!0:c===t?(r.push(s.trim()),s=""):c===`
89
- `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function ki(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function eq(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(o=>Object.keys(o))));return{columns:s.map(o=>({key:o,label:o,align:"left"})),rows:e.map(o=>s.map(a=>ki(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>ki(o)||`Column ${a+1}`);return{columns:s.map((o,a)=>({key:String(a),label:o,align:"left"})),rows:e.slice(1).map(o=>s.map((a,l)=>ki(o[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,o)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||o),label:String(s.label||s.title||s.name||s.key||`Column ${o+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(o),label:ki(s)||`Column ${o+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,o)=>({key:String(o),label:ki(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>ki(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>ki(s[a])):s&&typeof s=="object"?r.map(o=>ki(s[o.key])):r.map((o,a)=>a===0?ki(s):""))}}function tq(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=eq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
90
- `).split(`
91
- `).filter(l=>l.trim());if(s.length>=2&&io(s[0]).length>1&&RT(s[1])){const l=io(s[0]),c=TT(s[1]);return{columns:l.map((u,p)=>({key:String(p),label:u,align:c[p]||"left"})),rows:s.slice(2).map(u=>PT(io(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=Z7(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((c,u)=>c||`Column ${u+1}`).map((c,u)=>({key:String(u),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function vv({content:e}){const t=m.useMemo(()=>tq(e),[e]);return t.error||t.columns.length===0?i.jsxs("div",{className:"af-work-display-table-empty",children:[i.jsx("strong",{children:"Table data error"}),i.jsx("span",{children:t.error||"No columns found"})]}):i.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:t.columns.map((n,r)=>i.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),i.jsx("tbody",{children:t.rows.map((n,r)=>i.jsx("tr",{children:t.columns.map((s,o)=>i.jsx("td",{style:{textAlign:s.align||"left"},children:ki(n[o])},`${s.key}-${o}`))},r))})]})})}function Sv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>K7(e),[e]),[r,s]=m.useState({loading:!1,error:""});return m.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),q6(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{o||!t.current||(a=u.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||s({loading:!1,error:""}))}).catch(u=>{o||s({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,p;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(p=a==null?void 0:a.dispose)==null||p.call(a)}},[n]),!n.ok||r.error?i.jsxs("div",{className:"af-work-display-chart-error",children:[i.jsx("strong",{children:"Chart configuration error"}),i.jsx("span",{children:r.error||n.error})]}):i.jsxs("div",{className:"af-work-display-chart",children:[i.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?i.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function OT(e){return typeof e>"u"||e===null}function nq(e){return typeof e=="object"&&e!==null}function rq(e){return Array.isArray(e)?e:OT(e)?[]:[e]}function sq(e,t){var n,r,s,o;if(t)for(o=Object.keys(t),n=0,r=o.length;n<r;n+=1)s=o[n],e[s]=t[s];return e}function iq(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function oq(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var aq=OT,lq=nq,cq=rq,uq=iq,dq=oq,fq=sq,jv={isNothing:aq,isObject:lq,toArray:cq,repeat:uq,isNegativeZero:dq,extend:fq};function DT(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
92
-
93
- `+e.mark.snippet),r+" "+n):r}function af(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=DT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}af.prototype=Object.create(Error.prototype);af.prototype.constructor=af;af.prototype.toString=function(t){return this.name+": "+DT(this,t)};var Fa=af,pq=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],hq=["scalar","sequence","mapping"];function mq(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function gq(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(pq.indexOf(n)===-1)throw new Fa('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=mq(t.styleAliases||null),hq.indexOf(this.kind)===-1)throw new Fa('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Er=gq;function x_(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(s=a)}),n[s]=r}),n}function yq(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(s){s.multi?(e.multi[s.kind].push(s),e.multi.fallback.push(s)):e[s.kind][s.tag]=e.fallback[s.tag]=s}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function wb(e){return this.extend(e)}wb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Er)r.push(t);else if(Array.isArray(t))r=r.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(r=r.concat(t.explicit));else throw new Fa("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Er))throw new Fa("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Fa("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new Fa("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof Er))throw new Fa("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(wb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=x_(s,"implicit"),s.compiledExplicit=x_(s,"explicit"),s.compiledTypeMap=yq(s.compiledImplicit,s.compiledExplicit),s};var wq=wb,xq=new Er("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),bq=new Er("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),kq=new Er("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),vq=new wq({explicit:[xq,bq,kq]});function Sq(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function jq(){return null}function Nq(e){return e===null}var _q=new Er("tag:yaml.org,2002:null",{kind:"scalar",resolve:Sq,construct:jq,predicate:Nq,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Cq(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function Aq(e){return e==="true"||e==="True"||e==="TRUE"}function Eq(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Iq=new Er("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Cq,construct:Aq,predicate:Eq,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Pq(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Rq(e){return 48<=e&&e<=55}function Tq(e){return 48<=e&&e<=57}function Mq(e){if(e===null)return!1;var t=e.length,n=0,r=!1,s;if(!t)return!1;if(s=e[n],(s==="-"||s==="+")&&(s=e[++n]),s==="0"){if(n+1===t)return!0;if(s=e[++n],s==="b"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(s!=="0"&&s!=="1")return!1;r=!0}return r&&s!=="_"}if(s==="x"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!Pq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!Rq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!Tq(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function $q(e){var t=e,n=1,r;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),r=t[0],(r==="-"||r==="+")&&(r==="-"&&(n=-1),t=t.slice(1),r=t[0]),t==="0")return 0;if(r==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function Lq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!jv.isNegativeZero(e)}var Oq=new Er("tag:yaml.org,2002:int",{kind:"scalar",resolve:Mq,construct:$q,predicate:Lq,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Dq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Fq(e){return!(e===null||!Dq.test(e)||e[e.length-1]==="_")}function zq(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var Bq=/^[-+]?[0-9]+e/;function Wq(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(jv.isNegativeZero(e))return"-0.0";return n=e.toString(10),Bq.test(n)?n.replace("e",".e"):n}function Hq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||jv.isNegativeZero(e))}var Vq=new Er("tag:yaml.org,2002:float",{kind:"scalar",resolve:Fq,construct:zq,predicate:Hq,represent:Wq,defaultStyle:"lowercase"}),Kq=vq.extend({implicit:[_q,Iq,Oq,Vq]}),qq=Kq,FT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),zT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Uq(e){return e===null?!1:FT.exec(e)!==null||zT.exec(e)!==null}function Gq(e){var t,n,r,s,o,a,l,c=0,u=null,p,f,d;if(t=FT.exec(e),t===null&&(t=zT.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,s=+t[3],!t[4])return new Date(Date.UTC(n,r,s));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(p=+t[10],f=+(t[11]||0),u=(p*60+f)*6e4,t[9]==="-"&&(u=-u)),d=new Date(Date.UTC(n,r,s,o,a,l,c)),u&&d.setTime(d.getTime()-u),d}function Yq(e){return e.toISOString()}var Jq=new Er("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Uq,construct:Gq,instanceOf:Date,represent:Yq});function Xq(e){return e==="<<"||e===null}var Qq=new Er("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Xq}),Nv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
- \r`;function Zq(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=Nv;for(n=0;n<s;n++)if(t=o.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function eU(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=Nv,a=0,l=[];for(t=0;t<s;t++)t%4===0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|o.indexOf(r.charAt(t));return n=s%4*6,n===0?(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)):n===18?(l.push(a>>10&255),l.push(a>>2&255)):n===12&&l.push(a>>4&255),new Uint8Array(l)}function tU(e){var t="",n=0,r,s,o=e.length,a=Nv;for(r=0;r<o;r++)r%3===0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];return s=o%3,s===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):s===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):s===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function nU(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var rU=new Er("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Zq,construct:eU,predicate:nU,represent:tU}),sU=Object.prototype.hasOwnProperty,iU=Object.prototype.toString;function oU(e){if(e===null)return!0;var t=[],n,r,s,o,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,iU.call(s)!=="[object Object]")return!1;for(o in s)if(sU.call(s,o))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function aU(e){return e!==null?e:[]}var lU=new Er("tag:yaml.org,2002:omap",{kind:"sequence",resolve:oU,construct:aU}),cU=Object.prototype.toString;function uU(e){if(e===null)return!0;var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],cU.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function dU(e){if(e===null)return[];var t,n,r,s,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),o[t]=[s[0],r[s[0]]];return o}var fU=new Er("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:uU,construct:dU}),pU=Object.prototype.hasOwnProperty;function hU(e){if(e===null)return!0;var t,n=e;for(t in n)if(pU.call(n,t)&&n[t]!==null)return!1;return!0}function mU(e){return e!==null?e:{}}var gU=new Er("tag:yaml.org,2002:set",{kind:"mapping",resolve:hU,construct:mU});qq.extend({implicit:[Jq,Qq],explicit:[rU,lU,fU,gU]});function b_(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
95
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}var yU=new Array(256),wU=new Array(256);for(var Gl=0;Gl<256;Gl++)yU[Gl]=b_(Gl)?1:0,wU[Gl]=b_(Gl);const lf=["requirement","planning","code","test","normal"],k_={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function _v(e,t){var s,o,a,l,c,u,p,f,d,h,y,v,b,g;const n=k=>{const x={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(x.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(x.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(x.showOnNode=!!k.showOnNode),x},r={};for(const k of e){if((s=k==null?void 0:k.data)!=null&&s.isWorkspaceGroup)continue;const x=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},_=((o=k.data)==null?void 0:o.definitionId)||k.id,S=((a=k.data)==null?void 0:a.inputs)??[],N=((l=k.data)==null?void 0:l.outputs)??[],P=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",R=x.role!=null?String(x.role).trim():"",z=k_[P]||P,E=k_[R]||R,O=lf.includes(z)?z:lf.includes(E)?E:"normal",D=Array.isArray(S)?S.map(n):Array.isArray(x.input)?x.input.map(Z=>n(Z)):[],L=Array.isArray(N)?N.map(n):Array.isArray(x.output)?x.output.map(Z=>n(Z)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,V=(p=k.data)==null?void 0:p.body,B=V!=null?String(V):x.body!=null?String(x.body):"";let F=((f=k.data)==null?void 0:f.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(F===""||F==="default")&&(F=void 0);const $={...x,definitionId:_,label:M,role:O,model:F,input:D,output:L},H=((d=k.data)==null?void 0:d.marketplaceRef)||x.marketplaceRef;H?$.marketplaceRef=String(H):delete $.marketplaceRef;const A=((h=k.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;A?$.marketplacePackageId=String(A):delete $.marketplacePackageId;const Q=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;Q?$.marketplaceVersion=String(Q):delete $.marketplaceVersion,_.startsWith("provide_")||B.trim()===""?delete $.body:$.body=B;const K=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(x.images)?x.images:[];K.length>0?$.images=K:delete $.images;const W=(b=k.data)==null?void 0:b.script,te=W!=null?String(W):x.script!=null?String(x.script):"";te.trim()===""?delete $.script:$.script=te;for(const Z of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[Z],ne=G!=null?String(G):x[Z]!=null?String(x[Z]):"";ne.trim()===""?delete $[Z]:$[Z]=ne.trim()}delete $.temperature,delete $.maxTokens,delete $.description,r[k.id]=$}return r}function Ed(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function xU(e,t){const n=String(e||"node").replace(/_copy(?:_\d+)?$/i,"");let r=`${n}_copy`,s=2;for(;t.has(r);)r=`${n}_copy_${s}`,s+=1;return t.add(r),r}function bU(e,t,n){const r=(e||[]).filter(a=>a==null?void 0:a.selected);if(r.length===0)return null;const s=new Set(r.map(a=>a.id)),o=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>Ed(a)),edges:o.map(a=>Ed(a)),instances:_v(r,n||{})}}function kU(e,t,n,r,s={}){var f;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const o=s.offset||{x:48,y:48},a=new Set((t||[]).map(d=>d.id)),l=new Map;for(const d of e.nodes)l.set(d.id,xU(d.id,a));const c=e.nodes.map(d=>{var y,v;const h=l.get(d.id);return{...Ed(d),id:h,selected:!0,dragging:!1,position:{x:Number(((y=d.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=d.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(d=>l.has(d.source)&&l.has(d.target)).map((d,h)=>{const y=l.get(d.source),v=l.get(d.target);return{...Ed(d),id:`e-${y}-${v}-${Date.now()}-${h}`,source:y,target:v,selected:!1}}),p={...r||{}};for(const[d,h]of l.entries()){const y=(f=e.instances)==null?void 0:f[d];y&&(p[h]={...Ed(y),label:y.label!=null?String(y.label):h})}return{nodes:[...(t||[]).map(d=>({...d,selected:!1})),...c],edges:[...(n||[]).map(d=>({...d,selected:!1})),...u],instances:p,pastedNodeIds:c.map(d=>d.id)}}function En(e){switch(ym(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function ym(e){const t=String(e??"").trim().toLowerCase();return t==="文本"||t==="str"||t==="string"?"text":t==="文件"||t==="path"?"file":t==="节点"||t==="flow"||t==="control"?"node":t==="boolean"||t==="布尔"?"bool":t||"node"}function vU(e,t){const n=ym(e),r=ym(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const SU=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function xb(e){const t=ym(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&SU.has(n)?`${t}+${n}`:t}function jU(e){return xb(e)}function cf(e,t){if(!e||!t||!vU(e.type,t.type))return!1;const n=xb(e),r=xb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function NU(e,t){const n=new RegExp(`^${t}-(\\d+)$`).exec(String(e||""));if(!n)return-1;const r=Number.parseInt(n[1],10);return Number.isFinite(r)?r:-1}function bb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=NU(t,n==="source"?"output":"input");return o<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[o]||null}const wm=/\[image\s+(\d+)\]/gi;function vo(e){return Array.isArray(e)?e.filter(t=>t&&typeof t=="object").map((t,n)=>({id:String(t.id||`image-${n+1}`),label:String(t.label||`image ${n+1}`),name:String(t.name||`image-${n+1}`),mimeType:String(t.mimeType||t.type||"image/png"),dataUrl:String(t.dataUrl||t.data||"")})).filter(t=>t.dataUrl.startsWith("data:image/")):[]}function _U(e){return`image ${vo(e).length+1}`}function CU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function AU(e,t){const n=vo(e),r=String(t||""),s=new Set;wm.lastIndex=0;let o;for(;o=wm.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function EU(e){return new Promise((t,n)=>{if(!e||!String(e.type||"").startsWith("image/")){n(new Error("Only image files are supported"));return}const r=new FileReader;r.onload=()=>{t({name:e.name||"image",mimeType:e.type||"image/png",dataUrl:String(r.result||"")})},r.onerror=()=>n(r.error||new Error("Failed to read image")),r.readAsDataURL(e)})}function BT(e){var n;return Array.from(((n=e==null?void 0:e.clipboardData)==null?void 0:n.items)||[]).filter(r=>r.kind==="file"&&String(r.type||"").startsWith("image/")).map(r=>r.getAsFile()).filter(Boolean)}function Id(e){var t;return Array.from(((t=e==null?void 0:e.dataTransfer)==null?void 0:t.files)||[]).filter(n=>String(n.type||"").startsWith("image/"))}async function WT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=vo(n);for(const a of r){const l=await EU(a),c=_U(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=CU(s,c)}return{body:s,images:o}}function As(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function IU(e){var r;const t=(r=e==null?void 0:e.definitionId)==null?void 0:r.trim();if(t&&t!=="普通")return t;const n=((e==null?void 0:e.schemaType)??"agent").toLowerCase();return n&&n!=="普通"?n:"agent"}function PU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function tn(e){e.stopPropagation()}function RU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function TU(e,t){const n=`\\[${RU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
- `).replace(/\n{3,}/g,`
97
-
98
- `).trimEnd()}function yw(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function MU(e){const t=String(e||"");let n="",r=0;wm.lastIndex=0;let s;for(;s=wm.exec(t);)n+=yw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${yw(s[0])}</span>`,r=s.index+s[0].length;return n+=yw(t.slice(r)),n||" "}function $U(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,o=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,u=Math.min(Math.max(c,2),8);return Math.ceil(u*r+s+o+a+l)}function LU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:p=!1}){var Mr,$r;const{t:f}=Vr(),d=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=IU(e),b=(e==null?void 0:e.isRunMode)??!1,g=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,x=(e==null?void 0:e.isDim)??!1,_=(e==null?void 0:e.nodeStatus)??null,S=(e==null?void 0:e.nodeElapsed)??null,N=(e==null?void 0:e.definitionId)||"",P=N.startsWith("provide_"),R=N==="provide_bool",z=N==="provide_str",E=N==="provide_file",O=N==="provide_password",D=N==="agent_subAgent",L=N==="control_agent_toBool",M=(D||L)&&!b,V=R?PU(h[0]):!1,B=P?String(((Mr=h[0])==null?void 0:Mr.value)??(($r=h[0])==null?void 0:$r.default)??(e==null?void 0:e.body)??""):"",F=String((e==null?void 0:e.body)||""),$=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),H=!P&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",A=vo(e==null?void 0:e.images),Q=R||z||E||O||M||!!H,K=m.useRef(!1),W=m.useRef(!1),te=m.useRef(null),Z=m.useRef(null),G=m.useRef(null),ne=m.useRef(null),re=m.useRef(null),[se,ee]=m.useState(B),[ue,de]=m.useState(!1),[pe,Me]=m.useState(F),[Ne,_e]=m.useState(!1),[He,ct]=m.useState({visible:!1,top:0,height:100}),[yt,Re]=m.useState(!1),at=m.useCallback(()=>{const ce=Z.current;if(!ce)return;const me=Math.max(1,ce.scrollHeight),tt=Math.max(1,ce.clientHeight),st=me>tt+1,zt=st?Math.max(12,tt/me*100):100,Rn=Math.max(0,100-zt),jr=st?Math.min(Rn,ce.scrollTop/Math.max(1,me-tt)*Rn):0;ct({visible:st,top:jr,height:zt})},[]);m.useEffect(()=>{K.current||ee(B)},[n,B]),m.useEffect(()=>{W.current||Me(F)},[n,F]),m.useEffect(()=>{const ce=Z.current;if(!ce)return;if(M){ce.style.minHeight="",ce.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const me=$U(ce,pe);ce.style.minHeight=`${me}px`,ce.style.height="",G.current&&(G.current.style.minHeight=`${me}px`,G.current.style.height="")},[pe,M]),m.useEffect(()=>{if(!M)return;const ce=window.requestAnimationFrame(at),me=Z.current;if(!me||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(ce);const tt=new ResizeObserver(at);return tt.observe(me),()=>{window.cancelAnimationFrame(ce),tt.disconnect()}},[pe,M,at]),m.useEffect(()=>{const ce=te.current,me=e==null?void 0:e.onNodeContentResize;if(!M||!ce||!me||typeof ResizeObserver>"u")return;let tt=0;const st=()=>{window.cancelAnimationFrame(tt),tt=window.requestAnimationFrame(()=>me(n))},zt=new ResizeObserver(st);return zt.observe(ce),st(),()=>{window.cancelAnimationFrame(tt),zt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),m.useEffect(()=>{if(!yt)return;const ce=window.setTimeout(()=>{const me=re.current;if(!me)return;me.focus();const tt=me.value.length;me.setSelectionRange(tt,tt)},0);return()=>window.clearTimeout(ce)},[yt]);const kt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],$t=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],ye=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],ze=Array.isArray(c==null?void 0:c.codex)?c.codex:[],oe=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!N.startsWith("tool_nodejs"),Be=new Set(kt.map(As)),Qe=new Set($t.map(As)),Ce=new Set(ye.map(As)),Ct=new Set(ze.map(As)),Xt=oe?oe.startsWith("cursor:")||oe.startsWith("opencode:")||oe.startsWith("codex:")||oe.startsWith("claude-code:")?oe:Ce.has(oe)?`claude-code:${oe}`:Ct.has(oe)?`codex:${oe}`:Qe.has(oe)?`opencode:${oe}`:Be.has(oe)?`cursor:${oe}`:oe:"",Ft=oe&&!Xt.startsWith("cursor:")&&!Xt.startsWith("opencode:")&&!Xt.startsWith("codex:")&&!Xt.startsWith("claude-code:")&&!Be.has(oe)&&!Qe.has(oe)&&!Ce.has(oe)&&!Ct.has(oe),rt=oe.startsWith("cursor:")?oe.slice(7):oe.startsWith("opencode:")?oe.slice(9):oe.startsWith("codex:")?oe.slice(6):oe.startsWith("claude-code:")?oe.slice(12):oe,Fn=ce=>{if(g)return;const me=ce.target.value;u&&u(n,me)},ie=ce=>{ce.stopPropagation(),!g&&r&&r(n)},Ie=ce=>{ce.stopPropagation(),s&&s()},et=ce=>{ce.stopPropagation(),!g&&(o==null||o(n,ce.target.value==="true"?"true":"false"))},qe=ce=>{if(ce.stopPropagation(),g)return;const me=ce.target.value;ee(me),!p&&!K.current&&(o==null||o(n,me))},Pt=ce=>{ce.stopPropagation(),K.current=!0},vt=ce=>{if(ce.stopPropagation(),g)return;K.current=!1;const me=ce.currentTarget.value;ee(me),p||o==null||o(n,me)},tr=()=>{g||p&&se===B||o==null||o(n,se)},Gn=ce=>{if(ce.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,se);return}const me=window.prompt("文件路径",se);me!=null&&(ee(me),o==null||o(n,me))},Tr=ce=>{ce.stopPropagation(),de(me=>!me)},kn=ce=>{if(Me(ce),a==null||a(n,ce),l){const me=AU(A,ce);(me.length!==A.length||me.some((tt,st)=>{var zt;return tt.id!==((zt=A[st])==null?void 0:zt.id)}))&&l(n,me)}},nr=ce=>{if(ce.stopPropagation(),g)return;const me=ce.target.value;p||W.current?Me(me):kn(me)},pr=ce=>{ce.stopPropagation(),!g&&(W.current=!0,_e(!0))},hr=ce=>{if(ce.stopPropagation(),g)return;W.current=!1,_e(!1);const me=ce.currentTarget.value;p?Me(me):kn(me)},fn=()=>{g||(W.current=!1,_e(!1),!(p&&pe===F)&&kn(pe))},zn=ce=>{ce.stopPropagation(),ce.preventDefault(),!g&&Re(!0)},is=()=>{Re(!1),fn()},Fs=ce=>{ce.stopPropagation(),ce.key==="Escape"&&(ce.preventDefault(),is())},vn=m.useCallback(ce=>{const me=Z.current;if(!me)return;const tt=Math.max(0,me.scrollHeight-me.clientHeight);me.scrollTop=Math.min(1,Math.max(0,ce))*tt,at()},[at]),Yn=m.useCallback((ce,me=0)=>{const tt=ne.current;if(!tt)return 0;const st=tt.getBoundingClientRect(),zt=He.height/100*st.height,Rn=Math.max(1,st.height-zt);return(ce-st.top-me)/Rn},[He.height]),ks=m.useCallback(ce=>{var Ut,Gt;if(!He.visible)return;ce.preventDefault(),ce.stopPropagation();const me=ne.current;if(!me)return;const tt=me.getBoundingClientRect(),st=He.top/100*tt.height,zt=He.height/100*tt.height,jr=ce.clientY>=tt.top+st&&ce.clientY<=tt.top+st+zt?ce.clientY-tt.top-st:zt/2;vn(Yn(ce.clientY,jr));const Nr=ce.pointerId;(Gt=(Ut=ce.currentTarget).setPointerCapture)==null||Gt.call(Ut,Nr);const mr=Xn=>{Xn.preventDefault(),vn(Yn(Xn.clientY,jr))},ut=()=>{window.removeEventListener("pointermove",mr),window.removeEventListener("pointerup",ut),window.removeEventListener("pointercancel",ut)};window.addEventListener("pointermove",mr),window.addEventListener("pointerup",ut),window.addEventListener("pointercancel",ut)},[Yn,He.height,He.top,He.visible,vn]),Jn=async ce=>{if(g)return;const me=await WT({files:ce,body:pe,images:A});me&&(Me(me.body),a==null||a(n,me.body),l==null||l(n,me.images))},Bn=(ce,me)=>{if(ce.stopPropagation(),g)return;const tt=A.filter(zt=>zt.id!==me.id),st=TU(pe,me.label);Me(st),a==null||a(n,st),l==null||l(n,tt)},vr=ce=>{if(g)return;const me=BT(ce);me.length!==0&&(ce.preventDefault(),ce.stopPropagation(),Jn(me).catch(()=>{}))},Sr=ce=>{if(g)return;const me=Id(ce);me.length!==0&&(ce.preventDefault(),ce.stopPropagation(),Jn(me).catch(()=>{}))},Wn=()=>{const ce=Z.current,me=G.current;!ce||!me||(me.scrollTop=ce.scrollTop,me.scrollLeft=ce.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(_==="success"?" af-flow-node--done":"")+(_==="failed"?" af-flow-node--failed":"")+(_==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+(z?" af-flow-node--provide-text":"")+(O?" af-flow-node--provide-password":"")+" af-flow-node--"+y.replace(/[^a-z0-9_-]/g,""),"data-schema":y,children:[i.jsxs("div",{className:"af-flow-node__chrome",children:[i.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${$}${n?` (${n})`:""}${v?` · ${v}`:""}`,children:$}),!b&&ke&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:Xt,onChange:Fn,onPointerDown:tn,onMouseDown:tn,onClick:tn,"aria-label":f("flow:node.model"),title:rt||f("flow:node.defaultModel"),disabled:g,children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),Ft&&i.jsx("option",{value:oe,children:oe}),kt.length>0&&i.jsx("optgroup",{label:"Cursor",children:kt.map(ce=>i.jsx("option",{value:`cursor:${As(ce)}`,children:As(ce)},`c-${ce}`))}),$t.length>0&&i.jsx("optgroup",{label:"OpenCode",children:$t.map(ce=>i.jsx("option",{value:`opencode:${As(ce)}`,children:As(ce)},`o-${ce}`))}),ze.length>0&&i.jsx("optgroup",{label:"Codex",children:ze.map(ce=>i.jsx("option",{value:`codex:${As(ce)}`,children:As(ce)},`codex-${ce}`))}),ye.length>0&&i.jsx("optgroup",{label:"Claude Code",children:ye.map(ce=>i.jsx("option",{value:`claude-code:${As(ce)}`,children:As(ce)},`cc-${ce}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),_==="running"&&!k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),_==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),_==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&P&&!R&&!z&&!E&&!O&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Ie,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!b&&i.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:g,onClick:ie,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-node__body",children:[i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:d.map((ce,me)=>{if(ce.showOnNode===!1)return null;const tt=f("flow:node.inputTooltip",{name:ce.name||`#${me}`,type:ce.type})+(ce.default!=null&&ce.default!==""?f("flow:node.defaultSuffix",{value:ce.default}):""),st=ce.name||`#${me+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:tt,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[st,ce.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${me}`,className:"af-flow-node__handle",style:{background:En(ce.type)},title:tt})]},`in-${me}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[R?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(V?" af-flow-node__bool-select--true":""),value:V?"true":"false",onChange:et,onPointerDown:tn,onMouseDown:tn,onClick:tn,"aria-label":"Boolean value",title:V?"true":"false",disabled:g,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):z?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:se,onChange:qe,onCompositionStart:Pt,onCompositionEnd:vt,onBlur:tr,onPointerDown:tn,onMouseDown:tn,onClick:tn,placeholder:"输入文本",rows:2,readOnly:g}):E?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:se,onChange:qe,onCompositionStart:Pt,onCompositionEnd:vt,onBlur:tr,placeholder:"选择或输入文件路径",title:se||"选择或输入文件路径",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:Gn,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):O?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ue?"text":"password",value:se,onChange:qe,onCompositionStart:Pt,onCompositionEnd:vt,onBlur:tr,placeholder:"输入密码或密钥",title:ue?se:"密码已隐藏",autoComplete:"off",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:Tr,"aria-label":ue?"隐藏密码":"预览密码",title:ue?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:ue?"visibility_off":"visibility"})})]}):M?i.jsxs("div",{ref:te,className:"af-flow-node__prompt-stack nodrag"+(Ne?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:MU(pe)+`
99
- `}}),i.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:pe,onChange:nr,onCompositionStart:pr,onCompositionEnd:hr,onBlur:fn,onPaste:vr,onDrop:Sr,onScroll:ce=>{Wn(),at()},onPointerDown:tn,onMouseDown:tn,onClick:tn,onKeyDown:tn,onDragOver:ce=>{Id(ce).length>0&&ce.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&i.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:tn,onMouseDown:tn,onClick:zn,"aria-label":"放大编辑",title:"放大编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsx("div",{ref:ne,className:"af-flow-node__prompt-scrollbar"+(He.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:ks,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${He.height}%`,top:`${He.top}%`}})})]}):null,M&&A.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:A.map((ce,me)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:ce.name,children:[i.jsx("img",{src:ce.dataUrl,alt:""}),i.jsxs("span",{children:["[",ce.label||`image ${me+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:tt=>Bn(tt,ce),onPointerDown:tn,onMouseDown:tn,"aria-label":`删除 ${ce.label||`image ${me+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ce.id||me))}):null,H?i.jsx("span",{className:"af-flow-node__prompt-preview",title:H,children:H}):null,Q?null:i.jsx("span",{className:"af-flow-node__body-title",title:$,children:$})]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:h.map((ce,me)=>{if(ce.showOnNode===!1)return null;const tt=f("flow:node.outputTooltip",{name:ce.name||`#${me}`,type:ce.type})+(ce.default!=null&&ce.default!==""?f("flow:node.defaultSuffix",{value:ce.default}):""),st=ce.name||`#${me+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:tt,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[st,ce.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${me}`,className:"af-flow-node__handle",style:{background:En(ce.type)},title:tt})]},`out-${me}`)})})]}),yt?lr.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,onWheel:tn,children:i.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[i.jsxs("div",{className:"af-flow-node-full-editor__header",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-flow-node-full-editor__title",children:$}),i.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),i.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:is,"aria-label":"关闭",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("textarea",{ref:re,className:"af-flow-node-full-editor__textarea",value:pe,onChange:nr,onCompositionStart:pr,onCompositionEnd:hr,onPaste:vr,onDrop:Sr,onKeyDown:Fs,onDragOver:ce=>{Id(ce).length>0&&ce.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const Ec="flowNode";function kb(e){const t=e.type||"node",n=e.showOnNode!=null,r={type:t,name:e.name||"",default:e.value!==void 0&&e.value!==null?String(e.value):e.default!==void 0?String(e.default):""};return e.required!=null&&(r.required=!!e.required),e.description!=null&&(r.description=String(e.description)),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const OU={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace","Load Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],workspace_scheduled_run:["Scheduled Run"],workspace_run:["Run"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_set_run_env:["Set Run Env","Set Env"],tool_display_share_link:["Display Share Link","Share Link"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_password:["Password"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_react_app:["React App"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function DU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(OU[e]||[]).includes(s)?r:s}const FU={tool_git_checkout:new Set(["targetDir","pullIfExists","includeSubmodules","workspaceContext","commit","changed"]),control_load_skills:new Set(["mergeMode","workspaceContext","skillsContext","loadedCount","summary"]),control_load_mcp:new Set(["workspaceContext","mcpContext","loadedCount","summary"]),agent_subAgent:new Set(["workspaceContext","skillsContext","mcpContext"])},zU={control_cd_workspace:new Set(["mode","label","workspaceContext","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_react_app:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},BU={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},WU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function HU(e,t){if(!WU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function VU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function KU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function HT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function qU(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function UU(e){const t=String(e??"").trim();return t?t.includes("${")?t:HT(t):""}function GU(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const r=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),s=r?`${r}/${n}`:`\${flowDir}/${n}`,o=Array.isArray(t.args)?t.args.map(UU).filter(Boolean):[];return[qU(t,n),HT(s),...o].join(" ")}return String(t.command||"").trim()}function v_(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,p,f;const o=n[s],l=n.find(d=>(d==null?void 0:d.name)&&d.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=FU[e])==null?void 0:u.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...c?{showOnNode:!0}:{},...!r._showOnNodeExplicit&&l.showOnNode!=null?{showOnNode:!!l.showOnNode}:{},...!r._showOnNodeExplicit&&l.showOnNode==null?{showOnNode:!!r.required||String(r.type||"").trim().toLowerCase()==="node"}:{},...!r._showOnNodeExplicit&&HU(e,r)?{showOnNode:!0}:{},...(p=BU[e])!=null&&p.has(r.name)?{showOnNode:!0}:{},...(f=zU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function YU(e){var s,o;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((o=e==null?void 0:e.data)==null?void 0:o.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=kb(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,description:String(c.description??""),showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function vb(e,t,n,r,s){var $,H,A,Q,K,W,te,Z,G,ne,re,se,ee,ue,de,pe,Me,Ne,_e,He,ct,yt;const o=(($=e.data)==null?void 0:$.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Re=>Re.id===o),l=t[e.id];let c=[],u=[],p=((H=e.data)==null?void 0:H.label)??e.id,f,d,h,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(kb)),Array.isArray(l.output)&&(u=l.output.map(kb)),l.label&&(p=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(d=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(y=l.images),l.script!=null&&(v=String(l.script)));const g=f??(typeof((A=e.data)==null?void 0:A.role)=="string"?e.data.role:"普通"),k=d??((Q=e.data)==null?void 0:Q.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",_=x!==""?x:void 0,S=h??((K=e.data)==null?void 0:K.body)??"",N=Array.isArray(y)?y:Array.isArray((W=e.data)==null?void 0:W.images)?e.data.images:[],P=GU(a),R=v!==void 0?v:((te=e.data)==null?void 0:te.script)!=null?String(e.data.script):P,z=String(e.id),E=(Z=r==null?void 0:r[s])==null?void 0:Z[z],O=(G=E==null?void 0:E.label)==null?void 0:G.label,D=E==null?void 0:E.body,L=E==null?void 0:E.description;b||(c.length===0&&((ne=a==null?void 0:a.inputs)!=null&&ne.length)&&(c=a.inputs.map(Re=>({...Re}))),u.length===0&&((re=a==null?void 0:a.outputs)!=null&&re.length)&&(u=a.outputs.map(Re=>({...Re}))));const M=KU(a,(a==null?void 0:a.id)??o),V=(l==null?void 0:l.marketplaceRef)||((se=e.data)==null?void 0:se.marketplaceRef)||VU(a);if(M==="agent_subAgent"&&!u.some(Re=>(Re==null?void 0:Re.name)==="result")){const Re=(ee=a==null?void 0:a.outputs)==null?void 0:ee.find(at=>(at==null?void 0:at.name)==="result");u=[...u,Re?{...Re}:{type:"text",name:"result",default:""}]}if(M==="agent_subAgent"&&!c.some(Re=>(Re==null?void 0:Re.name)==="knowledgeContext")){const Re=(ue=a==null?void 0:a.inputs)==null?void 0:ue.find(at=>(at==null?void 0:at.name)==="knowledgeContext");c=[...c,Re?{...Re}:{type:"text",name:"knowledgeContext",default:"",showOnNode:!0}]}if((M==="display_markdown"||M==="display_mermaid"||M==="display_ascii"||M==="display_chart"||M==="display_table")&&!u.some(Re=>(Re==null?void 0:Re.name)==="next")){const Re=(de=a==null?void 0:a.outputs)==null?void 0:de.find(at=>(at==null?void 0:at.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}if(M==="workspace_run"){if(!c.some(Re=>(Re==null?void 0:Re.name)==="prev")){const Re=(pe=a==null?void 0:a.inputs)==null?void 0:pe.find(at=>(at==null?void 0:at.name)==="prev");c=[Re?{...Re}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Re=>(Re==null?void 0:Re.name)==="next")){const Re=(Me=a==null?void 0:a.outputs)==null?void 0:Me.find(at=>(at==null?void 0:at.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}}c=v_(M,c,a==null?void 0:a.inputs),u=v_(M,u,a==null?void 0:a.outputs),M.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(S).trim()!==""&&(u=u.map((Re,at)=>at===0?{...Re,default:S,value:S}:Re));const B=DU(M,p,a),F=M==="tool_nodejs"||String(R).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:O||p,displayLabel:B,definitionDisplayName:a==null?void 0:a.displayName,definitionId:M,...V?{marketplaceRef:V}:{},...l!=null&&l.marketplacePackageId||(Ne=e.data)!=null&&Ne.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((_e=e.data)==null?void 0:_e.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(He=e.data)!=null&&He.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((ct=e.data)==null?void 0:ct.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((yt=e.data)==null?void 0:yt.schemaType)??e.type??"agent",role:g,model:k,body:D||S,images:N,script:R,inputs:c,outputs:u,description:L||_,originalLabel:p,originalBody:S,...F?{script:R}:{}}}}function JU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var p,f,d,h;const s=n.get(r.source),o=n.get(r.target),a=((f=(p=s==null?void 0:s.data)==null?void 0:p.outputs)==null?void 0:f.length)??0,l=((h=(d=o==null?void 0:o.data)==null?void 0:d.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&o&&c>=0&&c<a&&u>=0&&u<l})}function S_(e,t){const n=new RegExp(`^${t}-(\\d+)$`).exec(String(e||""));if(!n)return 0;const r=Number.parseInt(n[1],10);return Number.isFinite(r)&&r>=0?r:0}function j_(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function ww(e,t){const n=String((t==null?void 0:t.source)||""),r=String((t==null?void 0:t.target)||"");if(!n||!r)return e;const s=S_(t==null?void 0:t.sourceHandle,"output"),o=S_(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,p,f,d;if(c.id===n){const h=j_((u=c.data)==null?void 0:u.outputs,s);if(h!==((p=c.data)==null?void 0:p.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=j_((f=c.data)==null?void 0:f.inputs,o);if(h!==((d=c.data)==null?void 0:d.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function XU(e){if(!e||!(e instanceof Element))return!1;if(e.closest('[contenteditable="true"]'))return!0;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function N_(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function QU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function ZU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Qs({keys:e}){return i.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>i.jsxs("span",{children:[n>0?i.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,i.jsx(ZU,{children:t})]},n))})}function eG({open:e,onClose:t}){const{t:n}=Vr(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const o=QU()?"⌘":"Ctrl";return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:i.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body",children:[i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),i.jsx(Qs,{keys:[o,"S"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),i.jsx(Qs,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Qs,{keys:[o,"K"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),i.jsx(Qs,{keys:["A"]})]})]})]}),i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),i.jsx(Qs,{keys:["V"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),i.jsx(Qs,{keys:["H"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),i.jsx(Qs,{keys:["Space"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),i.jsx(Qs,{keys:["F"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),i.jsx(Qs,{keys:[o,"A"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),i.jsx(Qs,{keys:[o,"Z"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),i.jsx(Qs,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function tG(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),o=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:o.includes(n)?15:0}function nG({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Vr(),[o,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var v;return(v=u.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e]);const f=m.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,_;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((_=g.data)==null?void 0:_.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:tG(g,v)})).filter(g=>g.s>0);return b.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),b.slice(0,50).map(g=>g.e)},[r,o]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var v;const y=(v=p.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const d=y=>{const v=f[y];v&&(n(v.id),t())},h=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(v=>Math.min(f.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),d(l))};return i.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:i.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-jump-panel__input-wrap",children:[i.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:u,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:o,onChange:y=>{a(y.target.value),c(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:p,className:"af-jump-panel__list",role:"listbox",children:f.map((y,v)=>i.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(v),onMouseDown:b=>{b.preventDefault(),d(v)},children:[i.jsx("span",{className:"af-jump-panel__id",children:y.id}),y.label&&y.label!==y.id&&i.jsx("span",{className:"af-jump-panel__label",children:y.label}),y.definitionId&&i.jsx("span",{className:"af-jump-panel__tag",children:y.definitionId})]},y.id))}),i.jsxs("div",{className:"af-jump-panel__hint",children:[i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"↑"}),i.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function __(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=s=>String(s).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function rG(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";if(t<1e3)return`${Math.round(t)}ms`;const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60),s=n%60;return`${r}m${String(s).padStart(2,"0")}s`}function C_(e){if(!e||typeof e!="object")return"";if(e.line)return String(e.line);if(e.text)return String(e.text);if(e.error)return String(e.error);if(e.message)return String(e.message);if(e.status)return String(e.status);if(e.type==="graph"){const n=Array.isArray(e.displayNodeIds)?e.displayNodeIds.join(", "):"";return n?`graph updated: ${n}`:"graph updated"}const t=JSON.stringify(e);return t.length>4e3?`${t.slice(0,4e3)}
100
- ... [truncated]`:t}function xw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function A_(e){const t=String(e||"").toLowerCase();return t.includes("success")?"success":t.includes("fail")||t.includes("error")?"failed":t.includes("skip")||t.includes("disabled")?"skipped":t.includes("running")?"running":t.includes("stop")?"stopped":"idle"}function sG({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:o}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[p,f]=m.useState(null),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),_=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const R=new URLSearchParams;R.set("flowId",e.flowId),R.set("flowSource",e.flowSource||"user"),t?R.set("scheduleNodeId",t):n&&R.set("runNodeId",n),R.set("limit","80");const z=await fetch(`/api/workspace/run-logs?${R.toString()}`),E=await z.json().catch(()=>({}));if(!z.ok)throw new Error(E.error||"读取日志失败");const O=Array.isArray(E.runs)?E.runs:[];l(O),u(D=>{const L=O[0]||null;return L&&String(L.status||"")==="running"&&L.runId!==D?L.runId:D&&O.some(M=>M.runId===D)?D:r&&O.some(M=>M.runId===r)?r:(L==null?void 0:L.runId)||""})}catch(R){g(String(R.message||R)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),S=m.useCallback(async R=>{if(!R){f(null);return}v(!0);try{const z=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&z.set("archived","1");const E=await fetch(`/api/workspace/run-logs/${encodeURIComponent(R)}?${z.toString()}`),O=await E.json().catch(()=>({}));if(!E.ok)throw new Error(O.error||"读取日志详情失败");f(O)}catch(z){f({error:String(z.message||z),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{_()},[_]),m.useEffect(()=>{S(c)},[S,c]),m.useEffect(()=>{const R=a.find(E=>E.runId===c),z=window.setInterval(()=>{_(),(!R||R.status==="running")&&c&&S(c)},2e3);return()=>window.clearInterval(z)},[S,_,a,c]);const N=m.useMemo(()=>{const R=Array.isArray(p==null?void 0:p.events)?p.events:[],z=k.trim().toLowerCase();return z?R.filter(E=>String(E.type||"").toLowerCase().includes(z)||xw(E).toLowerCase().includes(z)||C_(E).toLowerCase().includes(z)):R},[p==null?void 0:p.events,k]),P=(p==null?void 0:p.run)||a.find(R=>R.runId===c)||null;return i.jsxs("div",{className:"af-work-run-logs",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:o,"aria-label":"关闭日志侧栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-run-logs__meta",children:[i.jsx("span",{children:s||t||n||"Workspace Run"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void _(),title:"刷新日志","aria-label":"刷新日志",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),b?i.jsx("div",{className:"af-work-run-logs__error",children:b}):null,i.jsxs("div",{className:"af-work-run-logs__body",children:[i.jsxs("div",{className:"af-work-run-logs__list",children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),d?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!d&&a.length===0?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(R=>i.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(R.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(R.runId),title:R.runId,children:[i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${A_(R.status)}`,children:R.status||"unknown"}),i.jsx("span",{className:"af-work-run-logs__run-label",children:R.label||R.runNodeId||R.scheduleNodeId||"Workspace Run"}),i.jsx("span",{children:__(R.startedAt)}),i.jsx("span",{children:rG(R.durationMs)})]},R.runId))]}),i.jsxs("div",{className:"af-work-run-logs__detail",children:[i.jsxs("div",{className:"af-work-run-logs__detail-head",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),P!=null&&P.label?i.jsx("div",{className:"af-work-run-logs__detail-label",children:P.label}):null,i.jsx("div",{className:"af-work-run-logs__run-id",children:(P==null?void 0:P.runId)||"-"})]}),P?i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${A_(P.status)}`,children:P.status}):null]}),i.jsxs("label",{className:"af-work-run-logs__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:k,onChange:R=>x(R.target.value),placeholder:"搜索事件、节点、错误"})]}),y?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,p!=null&&p.error?i.jsx("div",{className:"af-work-run-logs__error",children:p.error}):null,!y&&!N.length?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,i.jsx("div",{className:"af-work-run-logs__events",children:N.map((R,z)=>i.jsxs("div",{className:"af-work-run-logs__event",children:[i.jsx("span",{className:"af-work-run-logs__event-time",children:__(R.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:R.type||"event"}),xw(R)?i.jsx("span",{className:"af-work-run-logs__event-node",children:xw(R)}):null,i.jsx("pre",{children:C_(R)})]},`${R.ts||z}-${z}`))})]})]})]})}function iG(e){let t=String(e||"").trim();const n=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*?)```/i);if(n&&n[1])t=n[1].trim();else{const r=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*)$/i);r&&r[1]&&(t=r[1].trim())}return t.replace(/```\s*$/g,"").trim()}function VT(e){const t=iG(e);if(!t)return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":"export default function App() { return <main><h1>React App</h1><p>No project files yet.</p></main>; }"},inputs:{}};try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.files&&typeof n.files=="object"&&!Array.isArray(n.files)?n.files:{};return{title:String(n.title||n.name||"React App"),entry:String(n.entry||n.main||"src/App.jsx"),files:Object.fromEntries(Object.entries(r).map(([s,o])=>[String(s),String(o??"")])),packageJson:n.packageJson&&typeof n.packageJson=="object"?n.packageJson:null,inputs:n.inputs&&typeof n.inputs=="object"&&!Array.isArray(n.inputs)?n.inputs:{}}}}catch{}return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":t},inputs:{}}}function oG(e){let t=String(e||"");return t=t.replace(/^\s*import\s+[^;]+;\s*$/gm,""),t=t.replace(/^\s*import\s+["'][^"']+["'];\s*$/gm,""),t=t.replace(/\bexport\s+default\s+function\s+([A-Za-z_$][\w$]*)\s*\(/g,"const __AgentFlowDefault = function $1("),t=t.replace(/\bexport\s+default\s+function\s*\(/g,"const __AgentFlowDefault = function App("),t=t.replace(/\bexport\s+default\s+class\s+([A-Za-z_$][\w$]*)\s+extends/g,"const __AgentFlowDefault = class $1 extends"),t=t.replace(/\bexport\s+default\s+class\s+extends/g,"const __AgentFlowDefault = class extends"),t=t.replace(/\bexport\s+default\s+(\([^)]*\)\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;?/g,"const __AgentFlowDefault = $1;"),t=t.replace(/\bexport\s+(const|let|var|function|class)\s+/g,"$1 "),t=t.replace(/^\s*export\s+\{[^}]+\};?\s*$/gm,""),t.trim()}function aG(e){return String(e).replace(/<\/script/gi,"<\\/script")}function vg(e){const t=VT(e);return JSON.stringify({title:t.title,entry:t.entry,packageJson:t.packageJson||{scripts:{dev:"vite --host 0.0.0.0",build:"vite build"},dependencies:{"@vitejs/plugin-react":"latest",vite:"latest",react:"latest","react-dom":"latest"},devDependencies:{}},files:t.files,inputs:t.inputs},null,2)}function Cv(e,t=""){const n=VT(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(d=>/(?:^|\/)App\.[jt]sx$/i.test(d))||Object.keys(r).find(d=>/\.[jt]sx?$/i.test(d))||n.entry,o=oG(r[s]||""),a=Object.entries(r).filter(([d])=>/\.css$/i.test(d)).map(([,d])=>String(d||"")).join(`
101
-
102
- `),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),p=aG(o||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),f=a||`
103
- * { box-sizing: border-box; }
104
- body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
105
- main { min-height: 100vh; padding: 24px; }
106
- button, input, select, textarea { font: inherit; }
107
- `;return`<!doctype html>
108
- <html>
109
- <head>
110
- <meta charset="utf-8" />
111
- <meta name="viewport" content="width=device-width, initial-scale=1" />
112
- <base target="_blank" />
113
- <title>${l.replace(/[<&>]/g,d=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[d])}</title>
114
- <style>${f.replace(/<\/style/gi,"<\\/style")}</style>
115
- </head>
116
- <body>
117
- <div id="root"></div>
118
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
119
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
120
- <script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>
121
- <script>
122
- window.AGENTFLOW_INPUTS = ${u};
123
- window.addEventListener("error", (event) => {
124
- const root = document.getElementById("root");
125
- if (root && !root.__agentflowRendered) {
126
- root.innerHTML = '<pre style="margin:16px;padding:16px;border:1px solid rgba(255,117,117,.35);border-radius:8px;background:rgba(127,29,29,.18);color:#ffb8b8;white-space:pre-wrap;">' + String(event.message || event.error || 'React app failed').replace(/[<>&]/g, (ch) => ({'<':'&lt;','>':'&gt;','&':'&amp;'}[ch])) + '</pre>';
127
- }
128
- });
129
- document.addEventListener("click", (event) => {
130
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
131
- if (!link) return;
132
- const rawHref = String(link.getAttribute("href") || "").trim();
133
- if (!rawHref || rawHref.startsWith("#")) return;
134
- if (/^javascript:/i.test(rawHref)) {
135
- event.preventDefault();
136
- return;
137
- }
138
- event.preventDefault();
139
- window.open(link.href, "_blank", "noopener,noreferrer");
140
- }, true);
141
- <\/script>
142
- <script type="text/babel">
143
- const { useCallback, useEffect, useMemo, useRef, useState } = React;
144
- ${p}
145
- const RootComponent = typeof __AgentFlowDefault !== "undefined" ? __AgentFlowDefault : (typeof App !== "undefined" ? App : function MissingApp() {
146
- return <main><h1>React App</h1><p>Entry file must export or define an App component.</p></main>;
147
- });
148
- ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent inputs={window.AGENTFLOW_INPUTS} />);
149
- document.getElementById("root").__agentflowRendered = true;
150
- <\/script>
151
- <script>
152
- (() => {
153
- const frameId = ${c};
154
- const postSize = () => {
155
- const doc = document.documentElement;
156
- const body = document.body;
157
- const height = Math.ceil(Math.max(
158
- doc ? doc.scrollHeight : 0,
159
- doc ? doc.offsetHeight : 0,
160
- doc ? doc.clientHeight : 0,
161
- body ? body.scrollHeight : 0,
162
- body ? body.offsetHeight : 0,
163
- body ? body.clientHeight : 0,
164
- window.innerHeight || 0
165
- ));
166
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
167
- };
168
- window.addEventListener("load", postSize);
169
- window.addEventListener("resize", postSize);
170
- requestAnimationFrame(postSize);
171
- setTimeout(postSize, 300);
172
- setTimeout(postSize, 1000);
173
- if (typeof ResizeObserver !== "undefined") {
174
- const resizeObserver = new ResizeObserver(postSize);
175
- resizeObserver.observe(document.documentElement);
176
- if (document.body) resizeObserver.observe(document.body);
177
- }
178
- })();
179
- <\/script>
180
- </body>
181
- </html>`}const KT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),lG=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function cG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function uG(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function E_(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function qT(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(KT.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function UT(e){return{inputNames:E_(e==null?void 0:e.inputs),outputNames:E_(e==null?void 0:e.outputs)}}function dG(e,t,n){const r=UT(t),s=uG(e),o=[];for(const a of s)if(!qT(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function fG(e,t){const n=UT(t),r=/\$\{([^}]*)\}/g,s=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&s.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=qT(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&s.push({kind:"plain",text:e.slice(o)}),s}function pG(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function hG(e){return e.map(t=>{const n=pG(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function mG(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of lG)KT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function gG(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function yG(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;s.style.width=`${o}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="​",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function qp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:p}=Vr(),f=m.useId(),d=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),_=m.useMemo(()=>vo(c),[c]),S=m.useMemo(()=>dG(e,a,p),[e,a,p]),N=S.length>0,P=m.useMemo(()=>fG(e,a),[e,a]),R=m.useMemo(()=>hG(P),[P]),z=m.useMemo(()=>n?null:cG(e,y),[e,y,n]),E=m.useMemo(()=>{if(!z)return[];const B=mG(a,p);return gG(B,z.query)},[z,a,p]);m.useEffect(()=>{g(B=>{const F=Math.max(0,E.length-1);return Math.min(Math.max(0,B),F)})},[E.length]);const O=m.useCallback(()=>{const B=d.current;if(!B||!z||E.length===0){x(null);return}const F=yG(B,y);if(!F){x(null);return}const $=4,H=44,A=13.5*16,Q=Math.min(E.length*H+8,A);let K=F.bottom+$;K+Q>window.innerHeight-8&&(K=Math.max(8,F.top-Q-$));const W=288;let te=F.left;te=Math.max(8,Math.min(te,window.innerWidth-W-8)),x({top:K,left:te})},[z,E.length,y]);m.useLayoutEffect(()=>{if(!z||E.length===0){x(null);return}const B=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(B)},[z,E.length,y,e,O]),m.useEffect(()=>{if(!z||E.length===0)return;const B=()=>O();return window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[z,E.length,O]);const D=m.useCallback(B=>{if(!z)return;const{atIndex:F}=z,$=e.slice(0,F)+"${"+B+"}"+e.slice(y);t($);const H=F+B.length+3;queueMicrotask(()=>{const A=d.current;A&&(A.focus(),A.setSelectionRange(H,H)),v(H)})},[z,e,y,t]),L=m.useCallback(()=>{const B=d.current,F=h.current;!B||!F||(F.scrollTop=B.scrollTop,F.scrollLeft=B.scrollLeft,z&&E.length>0&&queueMicrotask(()=>O()))},[z,E.length,O]),M=m.useCallback(B=>{if(!n&&z&&E.length>0&&(B.key==="ArrowDown"||B.key==="ArrowUp"||B.key==="Enter")){if(B.key==="ArrowDown")B.preventDefault(),g(F=>(F+1)%E.length);else if(B.key==="ArrowUp")B.preventDefault(),g(F=>(F-1+E.length)%E.length);else if(B.key==="Enter"&&!B.shiftKey){B.preventDefault();const F=E[b];F&&D(F.insert)}}},[n,z,E,b,D]),V=m.useCallback(async B=>{if(n||typeof u!="function")return!1;const F=await WT({files:B,body:e,images:_});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=d.current;if(!$)return;$.focus();const H=F.body.length;$.setSelectionRange(H,H),v(H)}),!0):!1},[n,_,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[_.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:_.map((B,F)=>i.jsxs("span",{className:"af-body-image-chip",title:B.name,children:[i.jsx("img",{src:B.dataUrl,alt:""}),i.jsxs("span",{children:["[",B.label||`image ${F+1}`,"]"]})]},B.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
182
- `}}),i.jsx("textarea",{ref:d,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?f:void 0,onChange:B=>{t(B.target.value),v(B.target.selectionStart??B.target.value.length)},onSelect:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:M,onPaste:B=>{const F=BT(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onDragOver:B=>{Id(B).length>0&&B.preventDefault()},onDrop:B=>{const F=Id(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onScroll:L})]}),z&&E.length>0&&k?lr.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:E.map((B,F)=>i.jsx("li",{role:"option","aria-selected":F===b,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===b?" af-composer-mention-item--active":""),onMouseDown:$=>$.preventDefault(),onMouseEnter:()=>g(F),onClick:()=>D(B.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${B.insert}}`}),B.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:B.subtitle}):null]})},`${B.section}-${B.insert}`))}),document.body):null,N?i.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:S.map(B=>B.message).join(" · ")}):null]})}const wG=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Gu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function I_({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=Vr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((d,h)=>h!==f)),u=(f,d,h)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[d]:h};return d==="required"&&h===!0&&(g.showOnNode=!0),g});r(y)},p=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((f,d)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${d}`,children:[p,"-",d]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(d,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:d}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>u(d,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:d})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>u(d,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:d})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(d,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:d})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!f.required,onChange:h=>{o||u(d,"required",h.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:d})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:h=>u(d,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:d})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(d),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:d}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${d}`))]}):null]})}function xG({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:p,ioSlots:f}){const{t:d}=Vr(),[h,y]=m.useState(!1),[v,b]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),x=m.useCallback(L=>{t(M=>M&&{...M,...L})},[t]),{cursorList:_,opencodeList:S,claudeCodeList:N,codexList:P,currentNotInLists:R}=m.useMemo(()=>{const L=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],M=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],V=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],B=Array.isArray(s==null?void 0:s.codex)?s.codex:[],F=new Set([...L,...M,...V,...B].map(Gu)),$=((e==null?void 0:e.model)??"").trim(),H=$.startsWith("cursor:")?$.slice(7):$.startsWith("opencode:")?$.slice(9):$.startsWith("codex:")?$.slice(6):$.startsWith("claude-code:")?$.slice(12):$,A=$&&!F.has(H)?$:"";return{cursorList:L,opencodeList:M,claudeCodeList:V,codexList:B,currentNotInLists:A}},[s,e==null?void 0:e.model]);if(!e)return null;const z=String(e.script??""),E=n==="tool_nodejs"||z.trim()!=="",O=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(O){k({status:"running",message:d("flow:nodeProps.publishRunning")});try{const L=await c(e,n);k({status:"success",message:L!=null&&L.definitionId?d("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):d("flow:nodeProps.publishSuccess")})}catch(L){k({status:"error",message:String((L==null?void 0:L.message)||L)})}}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:d("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!O||g.status==="running",title:d("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?d("flow:nodeProps.publishing"):d("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:d("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?i.jsx("p",{className:"af-err af-node-props-err",children:p}):null,g.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:d("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[d("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:d("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:L=>x({newId:L.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":d("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:L=>x({label:L.target.value}),disabled:o,spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:lf.includes(e.role)?e.role:d("flow:roles.normal"),onChange:L=>x({role:L.target.value}),disabled:o,children:lf.map(L=>i.jsx("option",{value:L,children:L},L))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:d("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const L=(e.model||"").trim();return L?R||L:""})(),onChange:L=>x({model:L.target.value}),disabled:o,"aria-label":d("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:d("flow:node.defaultModel")}),R?i.jsxs("option",{value:R,children:[R,d("flow:nodeProps.yamlValueNotInList")]}):null,_.length>0?i.jsx("optgroup",{label:"Cursor",children:_.map(L=>i.jsx("option",{value:Gu(L),children:L},`c-${L}`))}):null,S.length>0?i.jsx("optgroup",{label:"OpenCode",children:S.map(L=>i.jsx("option",{value:`opencode:${Gu(L)}`,children:L},`o-${L}`))}):null,P.length>0?i.jsx("optgroup",{label:"Codex",children:P.map(L=>i.jsx("option",{value:`codex:${Gu(L)}`,children:L},`codex-${L}`))}):null,N.length>0?i.jsx("optgroup",{label:"Claude Code",children:N.map(L=>i.jsx("option",{value:`claude-code:${Gu(L)}`,children:L},`cc-${L}`))}):null]})]}),i.jsx(I_,{kind:"input",label:d("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>x({inputs:L}),disabled:o,requiredReadonly:!u}),i.jsx(I_,{kind:"output",label:d("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>x({outputs:L}),disabled:o,requiredReadonly:!u}),E?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:d("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":d("flow:nodeProps.expandEditScript"),title:d("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(qp,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:f,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:L=>x({scriptRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:L=>x({implementationRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),i.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:L=>x({implementationMode:L.target.value}),disabled:o,children:[i.jsx("option",{value:"",children:"auto"}),i.jsx("option",{value:"script",children:"script"}),i.jsx("option",{value:"steps",children:"steps"}),i.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsx("span",{className:"af-node-props-label",children:d("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":d("flow:nodeProps.expandEdit"),title:d("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(qp,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:d("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||d("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editScript"),onMouseDown:L=>{L.target===L.currentTarget&&b(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":d("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(qp,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&y(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":d("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(qp,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function bG({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=Vr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||p)){f(!0),h("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){h(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(k){h(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),d?i.jsx("p",{className:"af-err af-new-pipeline-err",children:d}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||p,children:o(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function kG({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Vr(),u=m.useId(),p=m.useRef(null),[f,d]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),b(""),y(!1);const _=requestAnimationFrame(()=>{var S;return(S=p.current)==null?void 0:S.focus()});return()=>cancelAnimationFrame(_)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(_){if(_.preventDefault(),!k||h)return;y(!0),b("");let S=null;try{const N=new AbortController;S=setTimeout(()=>N.abort(),15e3);const P=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:s,workspaceId:o}),signal:N.signal}),R=await P.json().catch(()=>({}));if(!P.ok){b(typeof R.error=="string"?R.error:c("project:deleteModal.deleteFailed"));return}try{for(let z=localStorage.length-1;z>=0;z--){const E=localStorage.key(z);E&&(E.startsWith(`af:composer-sessions:${n}:${r}`)||E.startsWith(`af:composer-active-session:${n}:${r}`)||E.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(E)}}catch{}await l()}catch(N){if((N==null?void 0:N.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((N==null?void 0:N.message)||N))}finally{S&&clearTimeout(S),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&t()},children:i.jsxs("div",{ref:p,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:_=>_.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:x,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:_=>d(_.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?i.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const P_=80,vG=220;function SG(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function jG(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Up(e,t,n){const r={nodes:Array.isArray(e)?e.map(SG):[],edges:Array.isArray(t)?t.map(jG):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function bw(e,t){const n=[...e,t];return n.length>P_?n.slice(n.length-P_):n}function NG({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),p=m.useRef(null),f=m.useRef(null),d=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(S=>S+1),[]),v=m.useCallback(()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},[]),b=m.useCallback(()=>{v();const S=p.current,N=f.current;return p.current=null,f.current=null,!S||!N||S.signature===N.signature?(N&&(u.current=N),!1):(l.current=bw(l.current,S),c.current=[],u.current=N,y(),!0)},[y,v]),g=m.useCallback((S=[],N=[],P={})=>{v(),l.current=[],c.current=[],p.current=null,f.current=null,u.current=Up(S,N,P),h.current=!1,y()},[y,v]),k=m.useCallback(S=>{h.current=!0,u.current=S,p.current=null,f.current=null,v(),s==null||s(S.value),y()},[y,v,s]),x=m.useCallback(()=>{b();const S=u.current||Up(e,t,n),N=l.current.pop();return N?(c.current=bw(c.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]),_=m.useCallback(()=>{b();const S=u.current||Up(e,t,n),N=c.current.pop();return N?(l.current=bw(l.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const S=Up(e,t,n);if(!u.current){u.current=S;return}if(h.current){h.current=!1,u.current=S;return}S.signature!==u.current.signature&&(p.current||(p.current=u.current),f.current=S,v(),d.current=window.setTimeout(()=>{b()},vG))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:_,version:o}}function yo(e){return String(e??"").trim()}function R_(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(yo(e).toLowerCase())}function _G(e){return e===!1?!0:["false","no","not_required","waived"].includes(yo(e).toLowerCase())}function CG(e,t=""){return yo((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||t)}function GT(e){return yo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function YT(e){return GT(e)==="all"}function AG(e,t=[]){const n=yo((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||(e==null?void 0:e.parent));if(n)return n;const r=GT(e),s=CG(e);if(!s||!["android","ios"].includes(r))return"";const o=`-${r}`;if(!s.endsWith(o))return"";const a=s.slice(0,-o.length);return new Set(t.map(l=>yo(l))).has(a)?a:""}function xm(e){const t=yo(e==null?void 0:e.label).toLowerCase(),n=yo((e==null?void 0:e.href)||(e==null?void 0:e.url)).toLowerCase();return/\/merge_requests\/\d+/.test(n)||/\bmr\b|merge request|合并请求|实现 mr|修复 mr|提测 mr|集成 mr/i.test(t)?"mr":/\/issues\/\d+/.test(n)||/gitlab issue/i.test(t)?"issue":"other"}function EG(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[xm(n)]-t[xm(r)])}function IG(e){const t=yo((e==null?void 0:e.noMrReason)||(e==null?void 0:e.no_mr_reason)||(e==null?void 0:e.mrWaiverReason)||(e==null?void 0:e.mr_waiver_reason)||(e==null?void 0:e.implementationNotRequiredReason)||(e==null?void 0:e.implementation_not_required_reason));return/user confirmed self-test completion without implementation mr evidence/i.test(t)?"自测确认,无需实现 MR":t}function PG(e,t=[]){if(YT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(xm);if(n.includes("mr"))return{kind:"linked",label:"MR 已关联",detail:""};const r=(e==null?void 0:e.mrRequired)??(e==null?void 0:e.mr_required)??(e==null?void 0:e.requiresMr)??(e==null?void 0:e.requires_mr);return R_(e==null?void 0:e.implementationNotRequired)||R_(e==null?void 0:e.implementation_not_required)||_G(r)?{kind:"not-required",label:IG(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function Sb(e=[]){return e.reduce((t,n)=>t+1+Sb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function ur(e){return String(e||"").trim()}function Ko(e){return ur(e).toLowerCase()}function bm(e){return typeof e=="string"?Ko(e):!e||typeof e!="object"||Array.isArray(e)?"":Ko(e.kind||e.type||e.persistence||e.durability)}function JT(e,t="http://localhost"){const n=ur(e);if(!n)return"";try{const r=new URL(n,t);return r.origin==="null"?`${r.protocol}//${r.host}${r.pathname}`:`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function XT(e={}){const t=ur(e.href||e.url);if(!t)return!1;const n=Ko(e.kind||e.type),r=Ko(e.durability),s=Ko(e.persistence),o=Ko(e.truth||e.stateTruth||e.state_truth),a=Ko(e.authority),l=bm(e.source)||bm(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(ur).join(" "),u=[e.label,e.title,n,s,a,l,t].map(ur).join(" ");if(r==="temporary"||s==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const d=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&d,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function QT(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(ur).join(" ");return/技术方案|tech(?:nical)?[-_ ]?design/i.test(t)?"tech-design":/方案文档|方案已确认|plan(?:[-_ ]?doc)?/i.test(t)?"plan":/代码审查|code[-_ ]?review/i.test(t)?"code-review":/设计文档|design[-_ ]?doc/i.test(t)?"design":"document"}function RG(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=ur(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(ur(t)?ur(t):QT(e)==="tech-design"&&ur(n)?ur(n):ur(e.title||e.label))}function TG(e={},t="http://localhost"){const n=ur(e.issueKey||e.issue_key||e.issue),r=QT(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=ur(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${JT(e.href||e.url,t)}`}function T_(e={}){const t=ur(e.href||e.url),n=Ko(e.kind||e.type),r=bm(e.source)||bm(e.sourceArtifact||e.source_artifact),s=ur(e.label);let o=0;return e.confirmed===!0&&(o+=100),r==="ai-doc"&&(o+=80),n==="ai-doc"&&(o+=70),/^https?:\/\//i.test(t)&&(o+=30),/\/api\/prd-workflow\/review\//.test(t)&&(o+=20),/预览|review/i.test(s)||(o+=10),o}function MG(e,t){const n=T_(t)>T_(e)?t:e,r=n===t?e:t;return{...r,...n,title:M_(e.title)>=M_(t.title)?e.title:t.title,issueKey:e.issueKey||t.issueKey,platform:e.platform||t.platform,documentPath:n.documentPath||r.documentPath,source:n.source||r.source}}function M_(e){const t=ur(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function kw(e,t){const n=new Map,r=[];for(const s of e){const o=t(s);if(!o){r.push(s);continue}const a=n.get(o);if(a===void 0){n.set(o,r.length),r.push(s);continue}r[a]=MG(r[a],s)}return r}function $G(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>XT(o)),r=kw(n,o=>JT(o.href||o.url,t)),s=kw(r,o=>ur(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return kw(s,o=>TG(o,t))}function It(e){return String(e||"").trim()}function wo(e){return typeof e=="string"?It(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":It(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function gc(e){return It((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function ZT(e){return It((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function eM(e){const t=It(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function LG(e){const t=It(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return n.hash="",n.searchParams.sort(),n.href}catch{return t.split("#")[0]}}function OG(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=It(e.issueKey||e.issue_key||e.issue),n=It(e.action||e.actionId||e.action_id),r=It(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),s=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>It(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(s)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function DG(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||It(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!It(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=It(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",s=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||s===!1)}function Gc(e){const t=gc(e);if(/^prd-review:/i.test(t)||It((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(ZT(e)))return!0;const n=It((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=It((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),s=It(e==null?void 0:e.durability).toLowerCase(),o=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||s==="temporary"||s==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function $_(e){const t=[e==null?void 0:e.label,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,wo(e==null?void 0:e.source)].map(It).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function L_(e){const t=[],n=gc(e);if(n&&t.push(`key:${n}`),Gc(e)){const s=eM(ZT(e));s&&t.push(`review:${s}`)}const r=LG((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${It(e==null?void 0:e.label)}
183
- ${r}`),t}function FG(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=L_(r),o=s.map(h=>n.get(h)).find(h=>h!=null);if(o==null){s.forEach(h=>n.set(h,t.length)),t.push(r);continue}const a=t[o],l=$_(r)>=$_(a)?It(r==null?void 0:r.label)||It(a==null?void 0:a.label):It(a==null?void 0:a.label)||It(r==null?void 0:r.label),c=!!gc(a),u=!!gc(r),p=c&&!u?a:r,f=p===a?r:a,d=gc(p)&&!gc(f)&&It(p==null?void 0:p.label)||l;t[o]={...f,...p,...d?{label:d}:{}},L_(t[o]).forEach(h=>n.set(h,o))}return t}function tM(e){const t=It((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=It(e==null?void 0:e.durability).toLowerCase(),r=It(e==null?void 0:e.persistence).toLowerCase(),s=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(It).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function zG(e){if(!Gc(e)||tM(e))return!1;const t=It((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=It(e==null?void 0:e.durability).toLowerCase(),r=It(e==null?void 0:e.persistence).toLowerCase(),s=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(It).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function BG(e){if(Gc(e))return!1;const t=It((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=It(e==null?void 0:e.persistence).toLowerCase(),r=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(It).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function WG(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(It).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function HG(e=[],t={}){const n=FG(Array.isArray(e)?e:[]);if(!WG(t))return n;const r=n.filter(Gc);if(r.length===0)return n;const s=r.filter(zG),a=s.length>0||n.some(BG)?s.at(-1):r.filter(tM).at(-1);return n.filter(l=>!Gc(l)||l===a)}function Ii(e,t){const n=[],r=new Map,s=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=It(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=eM(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const p=It(a.path);return p&&l.push(`path:${p}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=s(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(p=>r.set(p,u));return}n[c]=a,s(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function Yr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function km(e){return Array.isArray(e)?e.map(km):Yr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,km(e[t])])):e}function lo(e,t){return JSON.stringify(km(e))===JSON.stringify(km(t))}function nM(e){return Yr(e==null?void 0:e.instances)?e.instances:{}}function uf(e){return Yr(e==null?void 0:e.ui)?e.ui:{}}function Gp(e,t){if(!Yr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function VG(e,t){if(!Yr(e)||!Yr(t)||!Yr(e.instances)||!Yr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!Yr(e.ui)||!Yr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Gp(e,["version","instances","edges","ui"]),r=Gp(t,["version","instances","edges","ui"]);if(!lo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return lo(Gp(e.ui,s),Gp(t.ui,s))}function rM(e){const t=Array.isArray(uf(e).groups)?uf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function O_(e){const t=new Set(Object.keys(nM(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of rM(e).keys())t.add(n);return t}function D_(e,t){const n=nM(e),r=uf(e),s=rM(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:Yr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:Yr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function F_(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),s=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(s)})}function KG(e,t){if(!VG(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...O_(e),...O_(t)]),r=Array.from(n).filter(s=>!lo(D_(e,s),D_(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!lo(F_(e),F_(t)),displayPageChanged:!lo(uf(e).displayPage||null,uf(t).displayPage||null)}}function qG(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),s=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!s.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function z_(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function B_(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function UG(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[z_(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(z_(r));return s?lo(B_(s),B_(r))?s:{...r,selected:s.selected===!0}:r})}function GG(e,t,n){const r=Yr(e)?e:{},s=Yr(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(s).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function YG({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:s=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==s||l!==a)?"local-edits":""}function JG({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function sM(e=[]){let t=!1,n=!1,r=!1;for(const s of Array.isArray(e)?e:[]){if((s==null?void 0:s.type)==="position"&&s.position){r=!0,s.dragging===!0&&(t=!0),s.dragging===!1&&(n=!0);continue}if((s==null?void 0:s.type)==="dimensions"&&s.dimensions){r=!0,s.resizing===!0&&(t=!0),s.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(s==null?void 0:s.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function XG({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function QG(e=[]){const t=sM(e);return t.mutated&&!t.active}function ZG(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function eY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function tY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(ZG(s)){t.push(s);continue}n.push(s),eY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function jb(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const s=String((r==null?void 0:r.id)||"").trim();if(!(s&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${s}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function nY(e=[]){return jb(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function W_(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function rY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function sY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const iY="af:workspace-graph:v2",H_="agentflow.workspace.sidebarCollapsed",Ql=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],oY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),aY={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},lY={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},cY={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},uY={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},dY={id:"control_cd_workspace",displayName:"加载知识库",label:"加载知识库",description:"Select one or more knowledge sources and pass knowledgeContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"knowledgeContext",default:"",showOnNode:!0},{type:"text",name:"workspaceContext",default:"",showOnNode:!1},{type:"file",name:"cwd",default:"",showOnNode:!1}]},fY={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},pY=new Set(["png","jpg","jpeg","gif","webp","svg"]),iM=320,oM=180,aM=960,vm=96,lM=900,Nb=520,_b=320,Yp=52,ul=240,dl=160,Cb="display-ref:",df="0 9 * * *",hY="Asia/Shanghai",mY="0.1.136";function gY(){const e=new URLSearchParams(window.location.search),t=String(e.get("returnTo")||"").trim();return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1",returnTo:t==="/workflows"?t:"",workflowDemo:e.get("workflowDemo")==="1"}}function Fr(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),e.returnTo&&t.set("returnTo",e.returnTo),e.workflowDemo&&t.set("workflowDemo","1"),t}function yY(e){const t=String(e||"").trim();if(!t)return null;try{const n=JSON.parse(window.sessionStorage.getItem(`agentflow.workflow.demo:${t}`)||"null");return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Av(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
184
- ...[truncated ${n.length-t} chars]`:n:""}function wY(e){const t=Av(e==null?void 0:e.text,4e3);return t?{role:(e==null?void 0:e.role)==="user"?"user":"assistant",...e!=null&&e.kind?{kind:String(e.kind)}:{},text:t,...e!=null&&e.error?{error:!0}:{},at:Number.isFinite(Number(e==null?void 0:e.at))?Number(e.at):Date.now()}:null}function Ev(e,t=80){return(Array.isArray(e)?e:[]).map(wY).filter(Boolean).slice(-t)}function xY(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,s]of Object.entries(t).slice(-80)){const o=String(r||"").trim();if(!o||!s||typeof s!="object")continue;const a=Ev(s.messages,40),l=Av(s.draft||"",2e3);!a.length&&!l||(n[o]={sessionId:String(s.sessionId||`nodechat_${o}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function bY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Ev(t==null?void 0:t.messages,80);if(!r.length)return null;const s=String((t==null?void 0:t.status)||"done");return{id:n,label:Av((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function V_(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=t.composer&&typeof t.composer=="object"&&!Array.isArray(t.composer)?t.composer:{};return{composer:{activeSessionId:String(n.activeSessionId||"workspace").trim()||"workspace",messages:Ev(n.messages,100),runSessions:bY(n.runSessions)},nodeChats:xY(t.nodeChats)}}function Sm(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return pY.has(n)}function ff(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=Fr(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function kY(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function vY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${H_}:${t}`:H_}function SY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function K_(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function jY(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function NY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!jY(e)}function _Y(e){const t=String(e||"").trim();if(!t||CY(t))return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function CY(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function AY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function vw(e,t,n,r="Workspace Run"){var c;const s=String(n||"").trim(),o=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===s):null,a=t&&typeof t=="object"?t[s]:null;return String(((c=o==null?void 0:o.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||s||r}function Sw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function za(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function q_(e){const t=String(e||"").trim().toLowerCase();return{unselected:"未选择需求",unavailable:"未连接",json_unsupported:"待升级",command_failed:"读取失败",uninitialized:"未初始化",preflight_blocked:"环境阻塞",tech_design_missing:"缺技术方案",tech_design_draft_review:"方案待确认",tech_design_confirmed:"方案已确认",baseline_missing:"缺基线",plan_missing:"缺计划",plan_draft_review:"计划待确认",issue_binding_missing:"待绑定 Issue",ready_for_implementation:"待实现",implementation_ready:"待实现",implementing:"实现中",implementation_in_progress:"实现中",implementation_review:"实现待审",self_test_ready:"待自测",bugfix:"修 Bug",fix_ready:"待修复",fix_in_progress:"修复中",testing:"已提测",done:"完成",blocked:"阻塞",conflict:"冲突",requirement_changed:"需求变更"}[t]||t||"未知"}function EY(e){const t=String(e||"").trim().toLowerCase();return!t||["unselected","unavailable","json_unsupported","command_failed","uninitialized","preflight_blocked"].includes(t)?-1:/done|complete|closed|finished/.test(t)?3:/bug|fix|testing|test|self_test|submit_test/.test(t)?2:/implement|development|ready_for_implementation|issue_binding|gitlab|mr/.test(t)?1:0}function IY(e){const t=EY(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let s="pending";return t>r?s="done":t===r&&(s=r===3?"done":"current"),{label:n,status:s}})}function cM(e){const t=String(e||"").trim();if(!/^https?:\/\//i.test(t))return t;try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const s=window.location.hostname;n.hostname=s&&s!=="0.0.0.0"&&s!=="::"?s:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function Ic(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return cM(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ba(e){const t=String(e||"").trim().toLowerCase();return["done","success","completed","passed"].includes(t)?"done":["current","running","active","next"].includes(t)?"current":["observed","observation"].includes(t)?"observed":["superseded","stale","replaced"].includes(t)?"superseded":["blocked","failed","error","conflict"].includes(t)?"blocked":"pending"}function ua(e){if(!e||typeof e!="object")return"";const t=String(e.truth||e.stateTruth||e.state_truth||"").trim().toLowerCase();return t||(String(e.idempotencyKey||e.idempotency_key||"").trim().startsWith("snapshot-action:")||String(e.source||"")==="prd-flow-client"&&String(e.type||"")==="workflow-action"?"observation":String(e.type||"")==="review-link"?"runtime_event":"")}function Iv(e){return ba(e==null?void 0:e.status)==="done"&&ua(e)!=="observation"}function co(e,t){return!e||typeof e!="object"?`Action ${t+1}`:String(e.title||e.label||e.name||e.actionLabel||e.action_label||e.id||e.action||`Action ${t+1}`)}function Ah(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function Pv(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function PY(e,t="当前任务"){const r=[e==null?void 0:e.issueLabel,e==null?void 0:e.issue_label,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.name].map(s=>String(s||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function RY(e,t){const n=co(e,t),r=ba(e==null?void 0:e.status),s=Iv(e),a=`${fl(e)} ${Pv(e)}`,l=PY(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)){if(s)return`${l} 方案已确认`;if(r==="observed"||r==="superseded"||ua(e)==="observation")return`${l} 方案状态已观察`;if(r==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)){if(s)return`已为 ${l} 创建/绑定 GitLab Issue`;if(r==="observed"||r==="superseded"||ua(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function TY(e){if(!e||typeof e!="object")return"";const t=ba(e.status),n=ua(e),r=Iv(e),o=`${fl(e)} ${Pv(e)}`,a=Rv(e),l=a.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),c=a.some(f=>/gitlab issue/i.test(String(f.label||""))),u=a.some(f=>/gitlab epic/i.test(String(f.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(o))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(o))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(o))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(o))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const p=Ah(e);return p?p.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":p:""}function jm(e){return!e||typeof e!="object"?"":String(e.stageEnteredAt||e.stage_entered_at||e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const uM="Asia/Shanghai",MY=new Intl.DateTimeFormat("zh-CN",{timeZone:uM,year:"numeric",month:"2-digit",day:"2-digit"}),$Y=new Intl.DateTimeFormat("zh-CN",{timeZone:uM,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function dM(e){const t=jm(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function LY(e){const t=dM(e);return t?MY.format(t).replace(/\//g,"-"):"无时间"}function OY(e){const t=dM(e);return t?$Y.format(t):""}function DY(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=LY(n);let o=t[t.length-1];(!o||o.day!==s)&&(o={day:s,items:[]},t.push(o)),o.items.push({item:n,index:r})}),t}function fM(e){const t=ba(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function qo(e){const t=String(e||"").trim(),n=t.toLowerCase();return n==="android"?"Android":n==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(n)?"双端":t}function FY(e){const t=ba(e==null?void 0:e.status);return ua(e)==="observation"&&t==="done"?"已观察":fM(t)}function pM(e){if(!e||typeof e!="object")return[];const t=[],n=(o,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${o}:${c}`,type:o,label:String(a||c),value:c})},r=ba(e.status),s=ua(e)==="observation"&&r==="done"?"observed":r;return n("status",fM(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",qo(e.platform),e.platform),t}function zY(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{pM(n).forEach(r=>{const s=t.get(r.key);t.set(r.key,{...r,count:((s==null?void 0:s.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const s={status:0,issue:1,platform:2,source:3,actor:4};return(s[n.type]??9)-(s[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function BY(e,t){const n=String(t||"all");return!n||n==="all"?!0:pM(e).some(r=>r.key===n)}function WY(e){if(!e||typeof e!="object")return[];const t=[],n=(r,s)=>{const o=String(s||"").trim();o&&t.push({label:r,value:o})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",qo(e.platform)),t}function Rv(e){const t=[],n=(c,u,p={})=>{const f=cM(u);f&&t.push({...p,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",p=0)=>{if(p>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((d,h)=>r(d,`${u} ${h+1}`,p+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const d of["links","urls","artifacts","outputs","output","results","result","files"])c[d]!=null&&r(c[d],d,p+1)},s=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of s)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href),c);for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",Ic(c),c);n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const o=c=>{const u=String(c||"").trim();try{const p=new URL(u,window.location.origin);return`${p.origin}${p.pathname}`}catch{return u.split(/[?#]/)[0]}},a=c=>{const u=String(c||"");return/方案文档/.test(u)?50:/临时/.test(u)?40:/Markdown Review/i.test(u)?20:/预览|review/i.test(u)?10:0},l=new Map;for(const c of t){const u=Gc(c),p=String(c.key||c.artifactKey||c.artifact_key||"").trim(),f=p?`key:${p}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
185
- ${c.href}`,d=l.get(f);if(!d){l.set(f,c);continue}if(u){const h=a(d.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(d.label||"").length)&&l.set(f,c)}}return HG(Array.from(l.values()),e)}function HY(e,t=[]){var l,c,u,p,f;const n=[],r=new Map,s=String(((c=(l=e==null?void 0:e.overall)==null?void 0:l.requirement)==null?void 0:c.title)||((p=(u=e==null?void 0:e.overall)==null?void 0:u.requirement)==null?void 0:p.name)||"").trim();for(const d of Ab(e)){const h=$i(d),y=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();h&&y&&r.set(h,y)}const o=(d,h={})=>{if(!d||typeof d!="object")return;const y=(b,g={})=>{if(!b||typeof b!="object")return;const k=String(h.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),x=b.source||b.sourceArtifact||b.source_artifact||d.sourceArtifact||d.source_artifact||d.source||h.source||null,_=RG({...b,title:b.title||h.documentTitle||(d==null?void 0:d.title)||"",documentTitle:b.documentTitle||b.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(k)||"",requirementTitle:s}),S={label:String(b.label||"ai-doc").trim()||"ai-doc",href:String(b.href||b.url||"").trim(),kind:String(b.kind||b.type||d.kind||d.type||"").trim(),title:_,issueKey:k,platform:h.platform||qo(d.platform),durability:b.durability||d.durability||h.durability||"",persistence:b.persistence||d.persistence||h.persistence||"",truth:b.truth||b.stateTruth||b.state_truth||ua(d)||h.truth||"",authority:b.authority||d.authority||h.authority||"",confirmed:b.confirmed??d.confirmed??h.confirmed,source:x,documentPath:b.documentPath||b.document_path||b.path||g.documentPath||(x==null?void 0:x.path)||(x==null?void 0:x.documentPath)||(x==null?void 0:x.document_path)||""};S.href&&n.push(S)};for(const b of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Ic(b)},{documentPath:b.path});for(const b of Array.isArray(d==null?void 0:d.links)?d.links:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Ic(b)},{documentPath:b.path});const v=Ic(d);v&&y({...d,label:d.label||d.title||d.kind||"ai-doc",href:v},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:qo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const h of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(h,{issueKey:String((h==null?void 0:h.issueKey)||(h==null?void 0:h.issue_key)||(h==null?void 0:h.issue)||"").trim(),platform:qo(h==null?void 0:h.platform),documentTitle:String((h==null?void 0:h.documentTitle)||(h==null?void 0:h.document_title)||(h==null?void 0:h.title)||"").trim()});for(const d of Ab(e))o(d,{issueKey:$i(d),platform:qo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});const a=(f=e==null?void 0:e.extensions)!=null&&f["prd-flow"]&&typeof e.extensions["prd-flow"]=="object"?e.extensions["prd-flow"]:{};for(const d of[...Array.isArray(e==null?void 0:e.aiDocs)?e.aiDocs:[],...Array.isArray(e==null?void 0:e.ai_docs)?e.ai_docs:[],...Array.isArray(a.aiDocs)?a.aiDocs:[],...Array.isArray(a.ai_docs)?a.ai_docs:[]])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||"").trim(),platform:qo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.label)||"").trim()});return $G(n,window.location.origin)}function VY(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function $i(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function KY(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||$i(e,t)||`Issue ${t+1}`).trim()}function qY(e){return String((e==null?void 0:e.epicKey)||(e==null?void 0:e.epic_key)||(e==null?void 0:e.epic)||(e==null?void 0:e.epicTitle)||(e==null?void 0:e.epic_title)||(e==null?void 0:e.parentEpic)||(e==null?void 0:e.parent_epic)||"未归类").trim()}function UY(e){return String((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parent)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||"").trim()}function GY(e){const t=Rv(e),n=(s,o)=>{if(Array.isArray(s)){for(const a of s)if(a)if(typeof a=="string")t.push({label:o,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||o,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(s=>{const o=String(s.href||"").trim();if(!o)return!1;const a=`${s.label}
186
- ${o}`;return r.has(a)?!1:(r.add(a),!0)})}function YY(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,s=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=s(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const p of u)p&&typeof p=="object"&&c.issues.push({...p,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)s(qY(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((p,f)=>$i(p,f));return a.forEach((p,f)=>{const d=$i(p,f);l.set(d,{issue:p,children:[]})}),a.forEach((p,f)=>{const d=$i(p,f),h=UY(p)||AG(p,u),y=l.get(d);h&&l.has(h)?l.get(h).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function Nm(e){return String((e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.action)||(e==null?void 0:e.id)||"").trim()}function fl(e){return OG(e)}function _m(e){const t=jm(e)||String((e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)||""),n=Date.parse(t);return Number.isFinite(n)?n:NaN}function Ab(e){var s,o,a,l,c,u,p,f,d,h,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:f.epics,(h=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:h.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function JY(e,t){const n=String(t||"").trim();return n&&Ab(e).find((r,s)=>$i(r,s)===n)||null}function XY(e){var t,n,r,s,o,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((s=e==null?void 0:e.raw)==null?void 0:s.gitlab_epic)||((a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function QY(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=JY(e,n),s=String(t.platform||(r==null?void 0:r.platform)||"").trim(),o=s&&!t.platform?{...t,platform:s}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||o.gitlabIssue||o.gitlab_issue||"").trim(),l=XY(e);if(!a&&!l)return o;const c=fl(o),u=`${c} ${Pv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({key:`gitlab-issue:${n}:${(s||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const d=ba(o.status),h=a&&d==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:Ii(o.artifacts,f)}}function U_(e,t){const n=_m(t),r=_m(e),s=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,o=(s==null?void 0:s.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:co(s,0)||co(t,0)||co(e,0),detail:Ah(s)||Ah(t)||Ah(e),status:o,links:Ii(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Ii(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Ii(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Ii(e==null?void 0:e.results,t==null?void 0:t.results),events:Ii(e==null?void 0:e.events,t==null?void 0:t.events),createdAt:(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(t==null?void 0:t.createdAt)||(t==null?void 0:t.created_at),startedAt:(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(t==null?void 0:t.startedAt)||(t==null?void 0:t.started_at),updatedAt:(s==null?void 0:s.updatedAt)||(s==null?void 0:s.updated_at)||(t==null?void 0:t.updatedAt)||(t==null?void 0:t.updated_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)}}function ZY(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=f=>{var d,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||DG(f)||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((d=f.conflict)==null?void 0:d.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,d)=>({...f,links:Ii(f==null?void 0:f.links,d==null?void 0:d.links),artifacts:Ii(f==null?void 0:f.artifacts,d==null?void 0:d.artifacts),outputs:Ii(f==null?void 0:f.outputs,d==null?void 0:d.outputs),results:Ii(f==null?void 0:f.results,d==null?void 0:d.results)}),c=(f,d)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],d);return}o.set(f,l(o.get(f)||{},d))},u=(f,d)=>f&&o.has(f)?l(d,o.get(f)):d,p=f=>{if(Array.isArray(f))for(const d of f){const h=fl(d);if(a(d)){c(h,d);continue}const y=String(d.id||d.eventId||d.event_id||d.actionId||d.action_id||"").trim(),v=h||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(h,U_(n[b],d)),h&&r.set(h,b),y&&s.set(y,b)):(v&&r.set(v,n.length),y&&s.set(y,n.length),n.push(u(h,d)))}};if(p(e==null?void 0:e.actions),p(e==null?void 0:e.workflowActions),p(e==null?void 0:e.workflow_actions),p(e==null?void 0:e.timeline),p(e==null?void 0:e.history),p(e==null?void 0:e.events),p(e==null?void 0:e.runtimeEvents),p(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=Nm(t),d=fl(t),h=d?r.get(d):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=U_(n[h],y))}return n.map((f,d)=>({item:f,index:d,ts:_m(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,d)=>d.ts-f.ts||f.index-d.index).map(f=>QY(e,f.item))}function eJ(e){const t=Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[],n=Array.isArray(e==null?void 0:e.snapshotAudit)?e.snapshotAudit:Array.isArray(e==null?void 0:e.snapshot_audit)?e.snapshot_audit:[];return[...t,...n].filter(s=>s&&typeof s=="object").map((s,o)=>({item:s,index:o,ts:_m(s)})).sort((s,o)=>{const a=Number.isFinite(s.ts),l=Number.isFinite(o.ts);return a&&l?o.ts-s.ts||o.index-s.index:a?-1:l?1:o.index-s.index}).slice(0,8).map(s=>s.item)}function tJ(e,t){const n=String(t||"all");if(n==="all")return!0;const r=[e==null?void 0:e.status,e==null?void 0:e.type,e==null?void 0:e.kind,e==null?void 0:e.title,e==null?void 0:e.detail,e==null?void 0:e.error,JSON.stringify((e==null?void 0:e.links)||[]),JSON.stringify((e==null?void 0:e.artifacts)||[])].join(" ").toLowerCase();return n==="errors"?/error|failed|conflict|blocked|stale|revision|冲突|失败/.test(r):n==="review"?/review|temporary-review|临时/.test(r):n==="external"?/mr|merge request|gitlab|jenkins|package|build|tapd/.test(r):!0}function nJ(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(s)?`(+${za(r)} / 总 ${za(s)})`:"";return`${t+1}. ${n}${o}`}function hM(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Zl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function rJ(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function sJ(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function iJ(e,t){var s;const n=String(((s=t==null?void 0:t.args)==null?void 0:s.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function oJ(e){var o,a,l;const t=hM(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Zl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=sJ(t),u=rJ(t),p=Zl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Zl(t.completedAtMs,c==null?void 0:c.completedAtMs),d=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(p)&&Number.isFinite(f)?Math.max(0,f-p):Zl(d.executionTime,d.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||d.command||"").trim(),v=y?y.split(`
187
- `).find(Boolean)||y:"";return{kind:"tool",label:iJ(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Zl(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:s,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:s,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:s,detail:""}:null}function G_(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(b=>typeof b=="string"?{text:b}:b).filter(b=>b&&String(b.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(b=>(b==null?void 0:b.kind)==="total"&&Number.isFinite(Number(b.durationMs))),l=[...s].reverse().find(b=>Number.isFinite(Number(b.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=Zl(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),p=s.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),f=o.filter(b=>(b==null?void 0:b.kind)==="tool"),d=f.reduce((b,g)=>b+(Number(g.durationMs)||0),0),h=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...s.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${za(u)}`),p>0&&v.push(`- 模型相关间隔:约 ${za(p)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${za(d)}(${f.length} 次完成事件)`),h>0&&v.push(`- 网络/会话恢复事件:${h} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${za(b.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((b,g)=>{v.push(nJ(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${za(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
188
- `)}function Y_(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=hM(e);if((t==null?void 0:t.type)!=="thinking")return"";const n=String((t==null?void 0:t.subtype)||"");return n&&n!=="delta"?"":String((t==null?void 0:t.text)||(t==null?void 0:t.delta)||(t==null?void 0:t.thinking)||"").trim()}function mM(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function gM(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Tv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function yM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function aJ(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function lJ(e){const t=String(e??"").trim();return t?t.includes("${")?t:yM(t):""}function wM(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const s=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),o=s?`${s}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(lJ).filter(Boolean):[];return[aJ(t,n),yM(o),...a].join(" ")}return String(t.command||"").trim()}function ad(e){const t=String(Tv(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function J_(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Cm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function ld(e){return Cm(e)}function Eb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Jp(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function X_(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function Q_(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function jw(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),o=bb(s.get(n),e.sourceHandle||"output-0","source"),a=bb(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&cf(o,a))}function cJ(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const o=t.find(l=>l.id===n),a=bb(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:jU(a)}:null}function uJ(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let o=0;o<s.length;o+=1){const a=s[o];if(!(t.handleType==="source"?cf(t.slot,a):cf(a,t.slot)))continue;const c=ad(n);return{def:n,order:r,category:c,categoryRank:Ql.indexOf(c),slot:a,slotIndex:o,displayLabel:ld(n),description:Eb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function dJ(e,t,n){var o,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const p=Array.isArray(s?(o=u.data)==null?void 0:o.inputs:(a=u.data)==null?void 0:a.outputs)?s?u.data.inputs:u.data.outputs:[];for(let f=0;f<p.length;f+=1){const d=p[f];if((d==null?void 0:d.showOnNode)===!1||!(s?cf(n.slot,d):cf(d,n.slot)))continue;const y=s?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${f}`}:{source:u.id,sourceHandle:`output-${f}`,target:n.nodeId,targetHandle:n.handleId},v=(t||[]).some(b=>b.target===y.target&&b.targetHandle===y.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:d,slotIndex:f,handleId:s?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,p)=>{var v,b,g,k,x,_,S,N;const f=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),d=Number(((k=(g=p.node)==null?void 0:g.position)==null?void 0:k.y)||0),h=Number(((_=(x=u.node)==null?void 0:x.position)==null?void 0:_.x)||0),y=Number(((N=(S=p.node)==null?void 0:S.position)==null?void 0:N.x)||0);return f-d||h-y||u.slotIndex-p.slotIndex||String(u.nodeId).localeCompare(String(p.nodeId))})}function yc(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function fJ(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const o=`${n}_${s}`;if(!r.has(o))return o}return`${n}_${Date.now().toString(36)}`}function pJ(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function hJ(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return df;const n=Math.max(1,Math.min(1440,Math.round(t)));return n<60?`*/${n} * * * *`:n===60?"0 * * * *":n<1440&&n%60===0?`0 */${n/60} * * *`:df}function Yo(e,t=0,n=0,r=59){const s=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(s).padStart(2,"0")}function Mv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Yo(t[1],9,0,23)}:${Yo(t[2],0,0,59)}`:"09:00"}function cd(e,t,n,r,s){const o=Mv(t),[a,l]=o.split(":").map(u=>Number.parseInt(u,10)),c=String(e||"daily");if(c==="weekly"){const u=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${u}`}if(c==="monthly"){const u=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${u} * *`}return c==="custom"?String(s||"").trim()||df:`${l} ${a} * * *`}function mJ(e){const n=String(e||df).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,s,o,a,l]=n,c=Number.parseInt(r,10),u=Number.parseInt(s,10),p=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),f=p?`${Yo(u,9,0,23)}:${Yo(c,0,0,59)}`:"09:00";return p&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:p&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:p&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:f,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:f,weekday:1,monthDay:1}}function $v(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=hJ(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=mJ(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=Mv(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),p=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=cd(l,c,u,p,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:p,cron:f,timezone:hY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function gJ(e){const t=$v(JSON.stringify(e||{}));return JSON.stringify(t)}function yJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function wJ(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function Z_(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function Xp(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:Z_(n.nextRunAt),lastAt:Z_(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function Am(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Em(e){return e>0?`Group ${e+1}`:"Group"}function xJ(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const s=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),o=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!s||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:s,title:String((n==null?void 0:n.title)||Em(r)).trim()||Em(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(ul,Math.round(l)),height:Math.max(dl,Math.round(c))}}).filter(Boolean)}function bJ(e){var n;return xJ((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Ec,position:{x:r.x,y:r.y},width:r.width,height:r.height,selected:!1,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:r.title,title:r.title,color:r.color,nodeSize:{width:r.width,height:r.height}}}))}function Ib(e){const t=Number(e==null?void 0:e.width),n=Number(e==null?void 0:e.height);return!Number.isFinite(t)||!Number.isFinite(n)?null:{width:Math.max(ul,Math.round(t)),height:Math.max(dl,Math.round(n))}}function ud(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:pJ(t),required:!!(t!=null&&t.required),description:String((t==null?void 0:t.description)||""),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function xM(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function kJ(e){var o,a,l,c;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{},s=Sg(t);return[xM(e),Cn(t)||"",s?"has-result":"",(t==null?void 0:t.contextRunResultNonce)||"",Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.width)||0)||"",Number(((a=e==null?void 0:e.measured)==null?void 0:a.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(c=(l=t==null?void 0:t.runningRunNodeIds)==null?void 0:l.has)!=null&&c.call(l,e==null?void 0:e.id)?"running-run":""].join("::")}function eC(e,t){return!e||!t?!1:e.selected===t.selected&&e.isExecuting===t.isExecuting&&e.nodeStatus===t.nodeStatus&&e.nodeElapsed===t.nodeElapsed&&e.optimizingRun===t.optimizingRun&&e.scheduledRunState===t.scheduledRunState&&e.nodeChatActive===t.nodeChatActive&&e.nodeChat===t.nodeChat}const vJ=new Map,SJ=[];function Yu(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=vM(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(h=e==null?void 0:e.ui)!=null&&h.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(y=e==null?void 0:e.ui)!=null&&y.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const v of s)v!=null&&v.source&&l.add(String(v.source)),v!=null&&v.target&&l.add(String(v.target));const u=Array.from(l).map(v=>{const b=r[v]||{},g=b.definitionId||v,k=t.find(D=>D.id===g),x=Tv(k)||g,_=t.find(D=>D.id===x)||k,S=b.marketplaceRef||gM(k),N=wM(k),P=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},R=!!Cn({definitionId:x,inputs:b.input,outputs:b.output}),z=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,E=Qa(z,{display:R}),O=E&&!ui(x);return{id:v,type:Ec,position:P,...O?{width:E.width,height:E.height}:{},data:{label:b.label||Cm(k)||Cm(_)||v,definitionId:x,...S?{marketplaceRef:S}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:mM(x,_||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||N||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...O?{nodeSize:E}:{},...R&&O?{displaySize:E}:{}}}}).map(v=>vb(v,r,t)),p=bJ(e),f=s.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!p.some(b=>b.id===String(v.source)||b.id===String(v.target))).map((v,b)=>({id:v.id||`we-${v.source}-${v.target}-${b}`,source:String(v.source),target:String(v.target),sourceHandle:v.sourceHandle??void 0,targetHandle:v.targetHandle??void 0,markerEnd:{type:Ai.ArrowClosed}})),d=[...p,...u];return{nodes:d,edges:JU(f,d),instances:r}}function tC(e){return`${Cb}${e}`}function Qp(e){const t=String(e||"");return t.startsWith(Cb)?t.slice(Cb.length):t}function Pb(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Eh(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var d;return pl((d=f==null?void 0:f.data)==null?void 0:d.definitionId)}).map(f=>[f.id,f])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const f of r){const d=String(f||"").trim();!d||o.has(d)||!n.has(d)||(o.add(d),s.push(d))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((f,d)=>{const h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+d*36,y:120+d*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(f=>{const d=Qa(u[f],{display:!0});d&&(c[f]=d)});const p=Pb(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...p?{viewport:p}:{}}}function nC(e,t=[]){return Eh(e,t)}const Nw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function _w(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function rC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function sC(e={}){if(e.permanent)return{expiresMode:"permanent",permanent:!0};const t=Number(e.expiresInDays||30);return{expiresMode:"days",expiresInDays:Number.isFinite(t)?t:30}}function jJ(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function iC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const bM="af:workspace:canvas-clipboard",kM="agentflow.workspace.canvas-clipboard";function NJ(e){return JSON.stringify({type:kM,version:1,clipboard:e})}function _J(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==kM)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function CJ(e){try{localStorage.setItem(bM,NJ(e))}catch{}}function AJ(){try{return _J(localStorage.getItem(bM))}catch{return null}}function EJ(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Rb(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function oC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Qa(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:oC(n,oM,aM)||iM,height:oC(r,vm,lM)||vm}}function Im(e){const t=Qa(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function IJ(e){const t=String(e||"").trim().toLowerCase();return t==="html"||t==="react"?{width:720,height:520}:t==="table"||t==="chart"?{width:640,height:380}:t==="image"?{width:520,height:360}:{width:Nb,height:_b}}function PJ(e,t=""){const n=Im(e==null?void 0:e.displaySize);if(n)return n;const r=Im(e==null?void 0:e.nodeSize);if(r)return r;const s=pl(t)||Tf(fa((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return IJ(s)}function ec(e){var s,o,a,l,c,u,p,f,d,h,y;if(ui((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!Cn(e==null?void 0:e.data),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((f=(p=e==null?void 0:e.data)==null?void 0:p.displaySize)==null?void 0:f.height)||((h=(d=e==null?void 0:e.data)==null?void 0:d.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return Qa({width:n,height:r},{display:t})}function Yl(e,t,n){var p,f,d,h,y,v,b,g,k,x,_,S,N;const r=(e||[]).filter(P=>!Am(P)),s=(e||[]).filter(Am),o=vM(_v(r,n||{})),a=t.map(P=>({source:P.source,target:P.target,sourceHandle:P.sourceHandle??null,targetHandle:P.targetHandle??null})).filter(P=>!s.some(R=>R.id===P.source||R.id===P.target)),l={},c={},u=[];for(const P of r){l[P.id]={x:((p=P.position)==null?void 0:p.x)||0,y:((f=P.position)==null?void 0:f.y)||0};const R=ec(P);R&&(c[P.id]=R)}for(const P of s){const R=Number(((h=(d=P.data)==null?void 0:d.nodeSize)==null?void 0:h.width)||P.width||((y=P.measured)==null?void 0:y.width)||0),z=Number(((b=(v=P.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||P.height||((g=P.measured)==null?void 0:g.height)||0);u.push({id:P.id,title:String(((k=P.data)==null?void 0:k.title)||((x=P.data)==null?void 0:x.label)||"Group"),color:String(((_=P.data)==null?void 0:_.color)||"purple"),x:Number(((S=P.position)==null?void 0:S.x)||0),y:Number(((N=P.position)==null?void 0:N.y)||0),width:Math.max(ul,Math.round(R||ul)),height:Math.max(dl,Math.round(z||dl))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function vM(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!pl(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function pl(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_react_app"?"react":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Cn(e){const t=pl(e==null?void 0:e.definitionId);return t||(ui(e==null?void 0:e.definitionId)&&Sg(e)?Tf(fa((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function uo(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=Cn(e),r=ui(e==null?void 0:e.definitionId),s=n==="image"?"src":"content",o=u=>String((u==null?void 0:u.value)??(u==null?void 0:u.default)??""),a=u=>o(u).trim(),l=t.find(u=>(u==null?void 0:u.name)===s&&a(u))||t.find(u=>(u==null?void 0:u.name)==="filePath"&&a(u))||t.find(u=>(u==null?void 0:u.type)==="text"&&a(u)),c=l?o(l):"";return String(r?c:(e==null?void 0:e.body)||c)}function da(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),react:new Set(["json","jsx","tsx","js","txt"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function RJ(e){let t=String(e||"").replace(/\r\n/g,`
189
- `).trim();return t.includes(`
190
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
191
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
192
- $2`)),t}function Li(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=RJ(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
193
- `).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
194
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function hl(e,t){const n=Fr(e);n.set("path",t);const r=await fetch(`/api/workspace/file?${n.toString()}`),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error||`读取文件失败:${t}`);return String(s.content||"")}async function Tb(e,t,n){const r=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,path:t,content:String(n||"")})}),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error||`写入文件失败:${t}`);return s.path||t}function TJ(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(o=>[o.id,o]));return(Array.isArray(n)?n:[]).filter(o=>String((o==null?void 0:o.target)||"")===r).slice(0,4).map(o=>{const a=s.get(String((o==null?void 0:o.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
195
- `)}).filter(Boolean).join(`
196
-
197
- `)}function su(e){let t=Li(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return s>0&&(t=t.slice(s).trim()),t}function MJ(e){const t=su(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ka(e,t){return e==="html"?MJ(t):""}function SM(e,t=""){const n=su(e);if(!n.trim())return"";const s=`<base target="_blank"><script data-agentflow-display-link-guard="1">
198
- (() => {
199
- const frameId = ${JSON.stringify(String(t||""))};
200
- const postSize = () => {
201
- const doc = document.documentElement;
202
- const body = document.body;
203
- const height = Math.ceil(Math.max(
204
- doc ? doc.scrollHeight : 0,
205
- doc ? doc.offsetHeight : 0,
206
- doc ? doc.clientHeight : 0,
207
- body ? body.scrollHeight : 0,
208
- body ? body.offsetHeight : 0,
209
- body ? body.clientHeight : 0,
210
- window.innerHeight || 0
211
- ));
212
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
213
- };
214
- document.addEventListener("click", (event) => {
215
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
216
- if (!link) return;
217
- const rawHref = String(link.getAttribute("href") || "").trim();
218
- if (!rawHref || rawHref.startsWith("#")) return;
219
- if (/^javascript:/i.test(rawHref)) {
220
- event.preventDefault();
221
- return;
222
- }
223
- event.preventDefault();
224
- window.open(link.href, "_blank", "noopener,noreferrer");
225
- }, true);
226
- window.addEventListener("load", postSize);
227
- window.addEventListener("resize", postSize);
228
- requestAnimationFrame(postSize);
229
- setTimeout(postSize, 60);
230
- setTimeout(postSize, 300);
231
- if (typeof ResizeObserver !== "undefined") {
232
- const resizeObserver = new ResizeObserver(postSize);
233
- resizeObserver.observe(document.documentElement);
234
- if (document.body) resizeObserver.observe(document.body);
235
- }
236
- if (typeof MutationObserver !== "undefined") {
237
- const mutationObserver = new MutationObserver(postSize);
238
- mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
239
- }
240
- })();
241
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${s}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${n}</body></html>`}function $J(e,t){const n=String(e).trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-").replace(/^-+|-+$/g,"")||"html-render",r=String(t).replace(/^\.+/,"")||"png";return`${n}.${r}`}function LJ(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function OJ(e,t){const n=URL.createObjectURL(e);try{LJ(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function jM(e){var t;try{return(e==null?void 0:e.contentDocument)||((t=e==null?void 0:e.contentWindow)==null?void 0:t.document)||null}catch{return null}}function DJ(e){const t=jM(e);return t!=null&&t.documentElement?`${t.doctype?`<!DOCTYPE ${t.doctype.name}${t.doctype.publicId?` PUBLIC "${t.doctype.publicId}"`:""}${t.doctype.systemId?` "${t.doctype.systemId}"`:""}>`:"<!DOCTYPE html>"}
242
- ${t.documentElement.outerHTML}`:""}function Cw(e){var n;if(!e)return null;const t=(n=e.getBoundingClientRect)==null?void 0:n.call(e);return{rectWidth:t!=null&&t.width?Math.round(t.width):null,rectHeight:t!=null&&t.height?Math.round(t.height):null,clientWidth:e.clientWidth||null,clientHeight:e.clientHeight||null,scrollWidth:e.scrollWidth||null,scrollHeight:e.scrollHeight||null,offsetWidth:e.offsetWidth||null,offsetHeight:e.offsetHeight||null}}function FJ(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=jM(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,p=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,d={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((f==null?void 0:f.width)||0)||null,displaySizeHeight:Number((f==null?void 0:f.height)||0)||null,rectWidth:s!=null&&s.width?Math.round(s.width):null,rectHeight:s!=null&&s.height?Math.round(s.height):null,iframeClientWidth:(e==null?void 0:e.clientWidth)||null,iframeClientHeight:(e==null?void 0:e.clientHeight)||null,docScrollWidth:(a==null?void 0:a.scrollWidth)||null,docScrollHeight:(a==null?void 0:a.scrollHeight)||null,bodyScrollWidth:(l==null?void 0:l.scrollWidth)||null,bodyScrollHeight:(l==null?void 0:l.scrollHeight)||null,docOffsetWidth:(a==null?void 0:a.offsetWidth)||null,bodyOffsetWidth:(l==null?void 0:l.offsetWidth)||null,card:Cw(c),displayBody:Cw(u),scroller:Cw(p)},h=[Number(t)||0,Number((f==null?void 0:f.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((p==null?void 0:p.clientWidth)||0),Number((p==null?void 0:p.scrollWidth)||0),Number(s==null?void 0:s.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(g=>Math.ceil(g)).filter(g=>g>0),y=Math.max(1,...h.length?h:[960]),v=Math.max(1,Math.round(Number(n)||(s==null?void 0:s.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:y,height:v,debug:d}}async function zJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=FJ(r,s,o,{...l||{},displaySize:c}),p=DJ(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:p||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!f.ok){const h=await f.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const d=await f.blob();OJ(d,a)}function BJ(e){const n=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]].find(r=>(r==null?void 0:r.name)==="alt");return String((n==null?void 0:n.value)||(n==null?void 0:n.default)||(e==null?void 0:e.label)||"Image preview")}function NM(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function WJ(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const o=(l,c="")=>{const u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[1]):o(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){s=c[2].toUpperCase();continue}const u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function _M({code:e}){const t=m.useMemo(()=>WJ(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,o=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((p,f)=>{l.set(p.id,{x:24+(n?f*(r+o):f%3*(r+o)),y:24+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(p=>p.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(p=>p.y+s+24));return i.jsx("div",{className:"af-work-node__mermaid-preview",children:i.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid preview",children:[i.jsx("defs",{children:i.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,f)=>{const d=l.get(p.from),h=l.get(p.to);if(!d||!h)return null;const y=n?`M ${d.x+r} ${d.y+s/2} C ${(d.x+h.x+r)/2} ${d.y+s/2}, ${(d.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${d.x+r/2} ${d.y+s} C ${d.x+r/2} ${d.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${p.from}-${p.to}-${f}`)}),t.nodes.map(p=>{const f=l.get(p.id);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-work-node__mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),i.jsx("text",{className:"af-work-node__mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:p.label.slice(0,22)})]},p.id)})]})})}function bi({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,y=h?Math.max(12,d/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,p.scrollTop/Math.max(1,f-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const d=new ResizeObserver(a);d.observe(f);for(const h of Array.from(f.children))d.observe(h);return()=>{cancelAnimationFrame(p),d.disconnect()}},[t,a]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(p-h.top-f)/v},[s.height]),u=m.useCallback(p=>{var _,S;if(!s.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=s.top/100*d.height,y=s.height/100*d.height,b=p.clientY>=d.top+h&&p.clientY<=d.top+h+y?p.clientY-d.top-h:y/2;l(c(p.clientY,b));const g=p.pointerId;(S=(_=p.currentTarget).setPointerCapture)==null||S.call(_,g);const k=N=>{N.preventDefault(),l(c(N.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[i.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function CM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Cn(e),o=uo(e),a=s==="image"?o:Li(o),l=s==="image"?"":da(a,s),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState(!1);m.useEffect(()=>{let k=!1;return l?(h(!0),f(""),u(""),hl(t,l).then(x=>{k||u(x)}).catch(x=>{k||f(String(x.message||x))}).finally(()=>{k||h(!1)}),()=>{k=!0}):(u(""),f(""),h(!1),()=>{k=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const y=l?c:a,v=s==="html"?su(y):s==="react"?vg(y):Li(y),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=Ka(s,v);if(d)return i.jsxs(bi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(p)return i.jsx(bi,{className:"af-work-display-empty",children:p});if(g)return i.jsx(bi,{className:"af-work-display-empty",children:g});if(!v.trim())return i.jsx(bi,{className:"af-work-display-empty",children:"No display content"});if(s==="html"||s==="react")return i.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:i.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(s==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:s==="react"?Cv(v,b.current):SM(v,b.current)},r)});if(s==="image"){const k=ff(v,t);return i.jsx(bi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:k,alt:BJ(e),loading:"lazy"})})}return s==="markdown"?i.jsx(bi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(kv,{content:v,basePath:l,resolveSrc:(k,x)=>ff(k,t,x)})}):s==="chart"?i.jsx(bi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(Sv,{content:v})}):s==="table"?i.jsx(bi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(vv,{content:v})}):s==="mermaid"?i.jsxs(bi,{className:"af-work-display-body",children:[i.jsx(_M,{code:v}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):i.jsx(bi,{className:"af-work-display-body af-work-display-body--ascii",children:i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:v})})}function HJ({node:e,onClose:t}){var k,x,_,S,N,P,R,z,E,O,D;const n=m.useRef(null),r=Cn(e==null?void 0:e.data),s=((k=e==null?void 0:e.data)==null?void 0:k.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),o=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=m.useState(!1),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState(!1),y=uo(e==null?void 0:e.data),v=r==="markdown"?Li(y):"",b=r==="markdown"?da(v,"markdown"):"",g=r==="markdown"?b?p:v:"";return m.useEffect(()=>{const L=M=>{if(M.key==="Escape"){if(a){u(String(g||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[g,a,t]),m.useEffect(()=>{var M;let L=!1;return r!=="markdown"||!b?(f(""),h(!1),()=>{L=!0}):(h(!0),hl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},b).then(V=>{L||f(V)}).catch(V=>{var B,F;L||(f(""),(F=(B=e==null?void 0:e.data)==null?void 0:B.onStatus)==null||F.call(B,String(V.message||V)))}).finally(()=>{L||h(!1)}),()=>{L=!0})},[r,b,(S=(_=e==null?void 0:e.data)==null?void 0:_.flowParams)==null?void 0:S.flowId,(P=(N=e==null?void 0:e.data)==null?void 0:N.flowParams)==null?void 0:P.flowSource,(z=(R=e==null?void 0:e.data)==null?void 0:R.flowParams)==null?void 0:z.archived,(E=e==null?void 0:e.data)==null?void 0:E.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?lr.createPortal(i.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:i.jsxs("div",{className:"af-display-preview-shell",children:[i.jsxs("div",{className:"af-display-preview-head",children:[i.jsxs("div",{className:"af-display-preview-title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:NM(r)}),i.jsx("strong",{children:s}),i.jsx("span",{children:e.id})]}),i.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||d,onClick:async()=>{var L,M;try{await EM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:f}),l(!1)}catch(V){(M=(L=e==null?void 0:e.data)==null?void 0:L.onStatus)==null||M.call(L,String(V.message||V))}},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"done"})}),i.jsx("button",{type:"button",className:"af-display-preview-action",onClick:()=>{u(String(g||"")),l(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||d,onClick:()=>{u(String(g||"")),l(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"})}):null,i.jsx("button",{type:"button",className:"af-display-preview-action",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close_fullscreen"})})]})]}),i.jsx("div",{className:"af-display-preview-content",children:r==="markdown"&&a?i.jsx(AM,{value:c,onChange:u,onUploadImage:(O=e.data)==null?void 0:O.onUploadWorkspaceImage,readOnly:o}):i.jsx(CM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function VJ({node:e}){var d,h,y,v,b,g,k,x,_,S;const t=Cn(e==null?void 0:e.data),n=uo(e==null?void 0:e.data),r=t==="image"?n:Li(n),s=t==="image"?"":da(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var P;let N=!1;return s?(c(!0),a(""),hl(((P=e==null?void 0:e.data)==null?void 0:P.flowParams)||{},s).then(R=>{N||a(R)}).catch(()=>{N||a("")}).finally(()=>{N||c(!1)}),()=>{N=!0}):(a(""),c(!1),()=>{N=!0})},[s,(h=(d=e==null?void 0:e.data)==null?void 0:d.flowParams)==null?void 0:h.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:g.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const u=s?o:r,p=t==="html"?su(u):t==="react"?vg(u):Li(u),f=Ka(t,p);return l?i.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?i.jsx("div",{className:"af-display-picker-preview__empty",children:f}):p.trim()?t==="html"||t==="react"?i.jsx("iframe",{title:((x=e==null?void 0:e.data)==null?void 0:x.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?Cv(p):SM(p)}):t==="image"?i.jsx("img",{src:ff(p,(_=e==null?void 0:e.data)==null?void 0:_.flowParams),alt:((S=e==null?void 0:e.data)==null?void 0:S.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(kv,{content:p,basePath:s,resolveSrc:(N,P)=>{var R;return ff(N,(R=e==null?void 0:e.data)==null?void 0:R.flowParams,P)}})}):t==="chart"?i.jsx(Sv,{content:p}):t==="table"?i.jsx(vv,{content:p}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(_M,{code:p}),i.jsx("pre",{children:p})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:p}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function AM({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,p]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const g=s.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),_=k>x+1,S=_?Math.max(12,x/k*100):100,N=Math.max(0,100-S),P=_?Math.min(N,g.scrollTop/Math.max(1,k-x)*N):0;p({visible:_,top:P,height:S})},[]);m.useEffect(()=>{const g=requestAnimationFrame(f),k=s.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(f);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[f,e]);const d=m.useCallback(g=>{const k=s.current;if(!k)return;const x=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*x,f()},[f]),h=m.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const _=x.getBoundingClientRect(),S=u.height/100*_.height,N=Math.max(1,_.height-S);return(g-_.top-k)/N},[u.height]),y=m.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),_=u.top/100*x.height,S=u.height/100*x.height,P=g.clientY>=x.top+_&&g.clientY<=x.top+_+S?g.clientY-x.top-_:S/2;d(h(g.clientY,P));const R=E=>{E.preventDefault(),d(h(E.clientY,P))},z=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z)},[h,d,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),x=s.current,_=Number((x==null?void 0:x.selectionStart)??k.length),S=Number((x==null?void 0:x.selectionEnd)??_),N=k.slice(0,_),P=k.slice(S),R=N&&!N.endsWith(`
243
- `)?`
244
- `:"",z=P&&!P.startsWith(`
245
- `)?`
246
- `:"",E=`${N}${R}${g}${z}${P}`;t==null||t(E),window.requestAnimationFrame(()=>{var D,L;const O=N.length+R.length+g.length;(D=s.current)==null||D.focus(),(L=s.current)==null||L.setSelectionRange(O,O)})},[t,e]),b=m.useCallback(async g=>{if(!r&&!(!g||l)){c(!0);try{const k=await(n==null?void 0:n(g)),x=String(k||"").trim();if(x){const _=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(`![${_}](${x})`)}}finally{c(!1)}}},[v,n,r,l]);return i.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:g=>g.stopPropagation(),onDragOver:g=>{var x;Array.from(((x=g.dataTransfer)==null?void 0:x.items)||[]).some(_=>String((_==null?void 0:_.type)||"").startsWith("image/"))&&(g.preventDefault(),g.dataTransfer.dropEffect="copy")},onDrop:g=>{var x;const k=Array.from(((x=g.dataTransfer)==null?void 0:x.files)||[]).find(Sm);k&&(g.preventDefault(),b(k))},children:[i.jsxs("div",{className:"af-work-display-editor__toolbar",children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var g;return(g=o.current)==null?void 0:g.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),i.jsx("input",{ref:o,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:g=>{var x;const k=(x=g.target.files)==null?void 0:x[0];g.target.value="",k&&b(k)}})]}),i.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:g=>t==null?void 0:t(g.target.value),onScroll:f,onKeyDown:g=>{g.key==="Escape"&&g.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),i.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:y,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function KJ({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=m.useState(a),u=m.useRef(!1),p=String(s.candidateContent||""),f=!!s.running,d=!!(t!=null&&t.readOnly),h=String(s.error||""),y=o.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?i.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:v=>v.stopPropagation(),children:[i.jsxs("div",{className:"af-work-node-chat__head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"继续微调"}),i.jsx("span",{children:(t==null?void 0:t.label)||e})]}),i.jsx("button",{type:"button",onClick:()=>{var v;return(v=t==null?void 0:t.onCloseNodeChat)==null?void 0:v.call(t)},"aria-label":"关闭节点微调",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||f||h?i.jsxs("div",{className:"af-work-node-chat__messages",children:[y.map((v,b)=>i.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${v.role==="assistant"?"assistant":"user"}`,children:[i.jsx("span",{children:v.role==="assistant"?"AI":"你"}),i.jsx("p",{children:v.text})]},`${v.at||b}-${b}`)),f?i.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?i.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,i.jsxs("div",{className:"af-work-node-chat__composer",children:[i.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f||d,"aria-label":"添加上下文",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),i.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:f||d,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:v=>{var g;u.current=!1;const b=v.currentTarget.value;c(b),(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onChange:v=>{var g;const b=v.target.value;c(b),u.current||(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onKeyDown:v=>{var b,g;v.isComposing||(b=v.nativeEvent)!=null&&b.isComposing||v.keyCode===229||(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),(g=t==null?void 0:t.onSendNodeChat)==null||g.call(t,e,l))}}),i.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||d||!l.trim(),onClick:()=>{var v;return(v=t==null?void 0:t.onSendNodeChat)==null?void 0:v.call(t,e,l)},"aria-label":"发送",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),p.trim()?i.jsx("div",{className:"af-work-node-chat__messages",children:i.jsxs("div",{className:"af-work-node-chat__msg af-work-node-chat__msg--assistant",children:[i.jsx("span",{children:"AI"}),i.jsx("p",{children:p})]})}):null]}):i.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:v=>{var b;v.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function qJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function UJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function GJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function aC(e,t=""){const n=da(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function YJ(e,t){const n=GJ(e),r=new Set,s=Cn(t)||"";ui(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=aC(uo(t),s);return o&&r.add(o),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),p=aC(u,s);return p&&r.add(p),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function lC(e,t){const n=Cn(t)||"markdown";return`outputs/${UJ((t==null?void 0:t.label)||e||n)}.${qJ(n)}`}async function EM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await Tb((t==null?void 0:t.flowParams)||{},n,r);s==null||s(r),(o=t==null?void 0:t.onSetDisplayNodeContent)==null||o.call(t,e,l,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${l}`});return}(a=t==null?void 0:t.onSetDisplayNodeContent)==null||a.call(t,e,r,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"})}function IM({id:e,data:t,selected:n,deleteNode:r}){var ne,re,se;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((ee,ue)=>({slot:ee,idx:ue})).sort((ee,ue)=>{var _e,He,ct,yt;const de=String(((_e=ee.slot)==null?void 0:_e.name)||"").trim(),pe=String(((He=ue.slot)==null?void 0:He.name)||"").trim();if(de==="next"&&pe!=="next")return-1;if(pe==="next"&&de!=="next")return 1;const Me=String(((ct=ee.slot)==null?void 0:ct.type)||"").trim(),Ne=String(((yt=ue.slot)==null?void 0:yt.type)||"").trim();return Me==="node"&&Ne!=="node"?-1:Ne==="node"&&Me!=="node"?1:ee.idx-ue.idx}),l=Cn(t),c=m.useRef(null),u=m.useRef(null),[p,f]=m.useState(0),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(!1),[k,x]=m.useState(""),[_,S]=m.useState(""),[N,P]=m.useState(!1),[R,z]=m.useState(!1),E=m.useRef(null),O=uo(t),D=l==="markdown"?Li(O):"",L=l==="markdown"?da(D,"markdown"):"",M=l==="markdown"?L?_:D:"",V=!!(t!=null&&t.readOnly),B=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let ee=!1;return l!=="markdown"||!L?(S(""),P(!1),()=>{ee=!0}):(P(!0),hl((t==null?void 0:t.flowParams)||{},L).then(ue=>{ee||S(ue)}).catch(ue=>{var de;ee||(S(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(ue.message||ue)))}).finally(()=>{ee||P(!1)}),()=>{ee=!0})},[l,L,(ne=t==null?void 0:t.flowParams)==null?void 0:ne.flowId,(re=t==null?void 0:t.flowParams)==null?void 0:re.flowSource,(se=t==null?void 0:t.flowParams)==null?void 0:se.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!y)return;const ee=()=>v(!1);return window.addEventListener("pointerup",ee,!0),window.addEventListener("pointercancel",ee,!0),window.addEventListener("mouseup",ee,!0),window.addEventListener("blur",ee),()=>{window.removeEventListener("pointerup",ee,!0),window.removeEventListener("pointercancel",ee,!0),window.removeEventListener("mouseup",ee,!0),window.removeEventListener("blur",ee)}},[y]),m.useEffect(()=>{b||x(String(M||""))},[M,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),$=String((t==null?void 0:t.sourceNodeId)||e),H=(t==null?void 0:t.sharingDisplayNodeId)===$,A=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Re,at,kt,$t,ye,ze,oe,ke,Be,Qe;if(l!=="html"||d)return;const ee=uo(t),ue=da(ee,l);let de=ee;if(ue)try{de=await hl((t==null?void 0:t.flowParams)||{},ue)}catch(Ce){h(!1),console.warn("Failed to read HTML display file before saving image.",Ce);return}const pe=su(de);if(!pe.trim())return;const Me=Ka(l,pe);if(Me){console.warn(Me);return}const Ne=(at=(Re=u.current)==null?void 0:Re.getBoundingClientRect)==null?void 0:at.call(Re),_e=($t=(kt=c.current)==null?void 0:kt.querySelector)==null?void 0:$t.call(kt,".af-work-display-body"),He=(ze=(ye=c.current)==null?void 0:ye.querySelector)==null?void 0:ze.call(ye,".af-visible-scroll-frame__scroller"),ct=Math.round(Math.max(Number((Ne==null?void 0:Ne.width)||0),Number((A==null?void 0:A.width)||0),Number(((oe=c.current)==null?void 0:oe.clientWidth)||0),Number((_e==null?void 0:_e.clientWidth)||0),Number((He==null?void 0:He.clientWidth)||0),Math.max(320,Number((A==null?void 0:A.width)||960)-2))),yt=Math.round(Math.max(Number((Ne==null?void 0:Ne.height)||0),Number((A==null?void 0:A.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((_e==null?void 0:_e.clientHeight)||0),Number((He==null?void 0:He.clientHeight)||0),Math.max(180,Number((A==null?void 0:A.height)||640)-46)));h(!0);try{await zJ({flowParams:(t==null?void 0:t.flowParams)||{},content:pe,sourceFilePath:ue,iframe:u.current,width:ct,height:yt,filename:$J((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:_e,scroller:He},displaySize:A}),(Be=t==null?void 0:t.onStatus)==null||Be.call(t,"已导出 HTML 展示截图")}catch(Ce){const Ct=String((Ce==null?void 0:Ce.message)||Ce||"截图失败");(Qe=t==null?void 0:t.onStatus)==null||Qe.call(t,`HTML 截图失败:${Ct}`),console.warn("Failed to save HTML display as PNG.",Ce)}finally{h(!1)}},[t,A==null?void 0:A.height,A==null?void 0:A.width,e,l,d]),K=m.useCallback(ee=>{var ue;V||!ee||l!=="image"||(ue=t==null?void 0:t.onUploadImageToDisplayNode)==null||ue.call(t,e,ee)},[t,e,l,V]),W=m.useCallback(ee=>{var ue,de;(ue=ee==null?void 0:ee.stopPropagation)==null||ue.call(ee),!V&&((de=t==null?void 0:t.onSetDisplayNodeContent)==null||de.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),g(!1)))},[t,e,l,V]),te=m.useCallback(ee=>{var pe,Me;V||l!=="image"||!(Array.from(((pe=ee.dataTransfer)==null?void 0:pe.files)||[]).some(Sm)||Array.from(((Me=ee.dataTransfer)==null?void 0:Me.items)||[]).some(Ne=>String((Ne==null?void 0:Ne.type)||"").startsWith("image/")))||(ee.preventDefault(),ee.stopPropagation(),ee.dataTransfer.dropEffect="copy",z(!0))},[l,V]),Z=m.useCallback(ee=>{l==="image"&&(ee.currentTarget.contains(ee.relatedTarget)||z(!1))},[l]),G=m.useCallback(ee=>{var de;if(l!=="image")return;const ue=Array.from(((de=ee.dataTransfer)==null?void 0:de.files)||[]).find(Sm);ue&&(ee.preventDefault(),ee.stopPropagation(),z(!1),K(ue))},[l,K]);return i.jsxs("div",{className:"af-work-display-card"+(A?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(R?" af-work-display-card--image-drop":"")+(B?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:A?{width:A.width,height:A.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:te,onDragLeave:Z,onDrop:G,children:[i.jsx(iv,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>v(!0),onResizeEnd:()=>v(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((ee,ue)=>{if(ee.showOnNode===!1)return null;const de=`${4.15+ue*1.75}rem`,pe=ee.name||`#${ue+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:de},children:pe}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${ue}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:En(ee.type)},title:`${pe} · ${ee.type}`})]},`in-${ue}`)}),a.map(({slot:ee,idx:ue},de)=>{if(ee.showOnNode===!1)return null;const pe=`${4.15+de*1.75}rem`,Me=ee.name||`#${ue+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:pe},children:Me}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${ue}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:pe,background:En(ee.type)},title:`${Me} · ${ee.type}`})]},`out-${ue}`)}),i.jsxs("div",{className:"af-work-display-card__head",children:[i.jsxs("div",{className:"af-work-display-card__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:NM(l)}),i.jsx("strong",{children:F}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:ee=>ee.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var ee,ue,de,pe;try{(pe=(de=(ue=(ee=u.current)==null?void 0:ee.contentWindow)==null?void 0:ue.history)==null?void 0:de.back)==null||pe.call(de)}catch{}},"aria-label":"后退",title:"后退",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var ee,ue,de,pe;try{(pe=(de=(ue=(ee=u.current)==null?void 0:ee.contentWindow)==null?void 0:ue.history)==null?void 0:de.forward)==null||pe.call(de)}catch{}},"aria-label":"前进",title:"前进",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>f(ee=>ee+1),"aria-label":"刷新",title:"刷新",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:d,onClick:Q,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:d?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:ee=>ee.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:V||N,onClick:async()=>{var ee;try{await EM({nodeId:e,data:t,filePath:L,content:k,setFileContent:S}),g(!1)}catch(ue){(ee=t==null?void 0:t.onStatus)==null||ee.call(t,String(ue.message||ue))}},"aria-label":"保存并预览",title:"保存并预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"done"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{x(String(M||"")),g(!1)},"aria-label":"取消编辑",title:"取消编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V||N,onClick:ee=>{ee.stopPropagation(),x(String(M||"")),g(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:E,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:ee=>{var de;const ue=(de=ee.target.files)==null?void 0:de[0];ee.target.value="",ue&&K(ue)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:ee=>{var ue;ee.stopPropagation(),(ue=E.current)==null||ue.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:ee=>{var ue;ee.stopPropagation(),(ue=t==null?void 0:t.onOpenDisplayPreview)==null||ue.call(t,$)},"aria-label":"全屏预览",title:"全屏预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:H,onClick:ee=>{var ue;ee.stopPropagation(),(ue=t==null?void 0:t.onShareDisplayNode)==null||ue.call(t,$)},"aria-label":"分享展示",title:"分享展示",children:i.jsx("span",{className:"material-symbols-outlined",children:H?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:W,"aria-label":"清空内容",title:"清空内容",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:()=>{var ee;return(ee=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:ee.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"save"})}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:V,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?i.jsx(AM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:V}):i.jsx(CM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:p}),i.jsx(KJ,{nodeId:e,data:t})]})}function JJ({id:e,data:t,selected:n,deleteNode:r}){var p,f,d;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((f=(p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p.has)==null?void 0:f.call(p,e))||((d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return i.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(c?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:b}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:En(h.type)},title:`${b} · ${h.type}`})]},`in-${y}`)}),o.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:b}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:En(h.type)},title:`${b} · ${h.type}`})]},`out-${y}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-run-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:h=>{var y,v;h.stopPropagation(),a?(y=t==null?void 0:t.onStopWorkspaceNode)==null||y.call(t,e):(v=t==null?void 0:t.onRunWorkspaceNode)==null||v.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),i.jsx("span",{children:a?"Stop":"Run line"})]}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOptimizeWorkspaceRun)==null||y.call(t,e)},children:i.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||y.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:i.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function XJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var Qe,Ce,Ct,Xt,Ft,rt,Fn;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=pX(t),[p,f]=m.useState(u.task),d=m.useRef(!1),h=m.useRef(u.task),y=((Ce=(Qe=t==null?void 0:t.runningRunNodeIds)==null?void 0:Qe.has)==null?void 0:Ce.call(Qe,e))||((Ct=t==null?void 0:t.runningRunNodeIds)==null?void 0:Ct[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",v=(t==null?void 0:t.nodeStatus)==="stopped",b=!!(t!=null&&t.readOnly),g=Array.isArray(s)?s:[],k=Array.isArray(o)?o:[],x=m.useMemo(()=>(Array.isArray(a)?a:[]).map(ie=>({id:String((ie==null?void 0:ie.id)||""),label:String((ie==null?void 0:ie.label)||(ie==null?void 0:ie.name)||"知识库"),kind:(ie==null?void 0:ie.kind)==="git"?"git":"local",path:String((ie==null?void 0:ie.path)||""),repoUrl:String((ie==null?void 0:ie.repoUrl)||""),branch:String((ie==null?void 0:ie.branch)||""),mountPath:String((ie==null?void 0:ie.mountPath)||""),builtin:(ie==null?void 0:ie.builtin)===!0,exists:(ie==null?void 0:ie.exists)!==!1,type:String((ie==null?void 0:ie.type)||"")})).filter(ie=>ie.path),[a]),[_,S]=m.useState(!1),[N,P]=m.useState(""),[R,z]=m.useState(()=>new Set),[E,O]=m.useState(!1),[D,L]=m.useState(""),[M,V]=m.useState("config"),B=Sg(t),F=!!B,$=OM(u.displayType),H=m.useMemo(()=>PJ(t,$),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,$]),A=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:$,displaySize:H,nodeSize:H,body:B,inputs:[{type:"text",name:$==="display_image"?"src":"content",value:B,default:B}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,$,e,B,c,H]),Q=Array.isArray((Xt=t==null?void 0:t.modelLists)==null?void 0:Xt.cursor)?t.modelLists.cursor:[],K=Array.isArray((Ft=t==null?void 0:t.modelLists)==null?void 0:Ft.opencode)?t.modelLists.opencode:[],W=Array.isArray((rt=t==null?void 0:t.modelLists)==null?void 0:rt.claudeCode)?t.modelLists.claudeCode:[],te=Array.isArray((Fn=t==null?void 0:t.modelLists)==null?void 0:Fn.codex)?t.modelLists.codex:[],Z=m.useMemo(()=>new Set(Q.map(Es)),[Q]),G=m.useMemo(()=>new Set(K.map(Es)),[K]),ne=m.useMemo(()=>new Set(W.map(Es)),[W]),re=m.useMemo(()=>new Set(te.map(Es)),[te]),se=u.model,ee=m.useMemo(()=>se?se.startsWith("cursor:")||se.startsWith("opencode:")||se.startsWith("codex:")||se.startsWith("claude-code:")?se:ne.has(se)?`claude-code:${se}`:re.has(se)?`codex:${se}`:G.has(se)?`opencode:${se}`:Z.has(se)?`cursor:${se}`:se:"",[ne,re,Z,G,se]),ue=se.startsWith("cursor:")?se.slice(7):se.startsWith("opencode:")?se.slice(9):se.startsWith("codex:")?se.slice(6):se.startsWith("claude-code:")?se.slice(12):se,de=ue,pe=!!se&&!Z.has(de)&&!G.has(de)&&!ne.has(de)&&!re.has(de),Me=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ne=m.useMemo(()=>new Map(g.map(ie=>[ie.key,ie])),[g]),_e=m.useMemo(()=>{const ie=new Set,Ie=k.map(qe=>{const Pt=ca(qe,g).map(vt=>Ne.get(vt)).filter(Boolean);for(const vt of Pt)ie.add(vt.key);return{...qe,skills:Pt}}).filter(qe=>qe.skills.length>0),et=g.filter(qe=>!ie.has(qe.key));return{collectionGroups:Ie,ungrouped:et}},[k,Ne,g]);m.useEffect(()=>{z(ie=>{let Ie=!1;const et=new Set(ie);for(const qe of _e.collectionGroups)et.has(qe.id)||(et.add(qe.id),Ie=!0);return Ie?et:ie})},[_e.collectionGroups]);const He=m.useMemo(()=>{const ie=N.trim().toLowerCase();if(!ie)return _e;const Ie=qe=>[qe==null?void 0:qe.key,qe==null?void 0:qe.name,qe==null?void 0:qe.description].map(Pt=>String(Pt||"").toLowerCase()).join(" ").includes(ie);return{collectionGroups:_e.collectionGroups.map(qe=>{const Pt=[qe==null?void 0:qe.id,qe==null?void 0:qe.name,qe==null?void 0:qe.description].map(vt=>String(vt||"").toLowerCase()).join(" ").includes(ie);return{...qe,skills:Pt?qe.skills:qe.skills.filter(Ie)}}).filter(qe=>qe.skills.length>0),ungrouped:_e.ungrouped.filter(Ie)}},[_e,N]),ct=Mb(_,[He.collectionGroups.length,He.ungrouped.length,R.size,u.skillKeys.length,N]),yt=m.useMemo(()=>{const ie=D.trim().toLowerCase();return ie?x.filter(Ie=>[Ie.id,Ie.label,Ie.path,Ie.repoUrl,Ie.branch,Ie.mountPath,Ie.type].join(" ").toLowerCase().includes(ie)):x},[x,D]),Re=m.useMemo(()=>BM(u.knowledgeContext),[u.knowledgeContext]),at=m.useMemo(()=>new Set(Re.map(ie=>ie.id||ie.path||ie.repoPath).filter(Boolean)),[Re]),kt=Mb(E,[yt.length,Re.length,D]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,d.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!F){V("config");return}y||V("result")},[F,B,y]),m.useEffect(()=>{var Ie,et;if(!(M==="result"&&F))return;(Ie=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Ie.call(t,e,H),(et=t==null?void 0:t.onRefreshNodeInternals)==null||et.call(t,e);const ie=window.setTimeout(()=>{var qe;return(qe=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:qe.call(t,e)},120);return()=>window.clearTimeout(ie)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,$,F,e,B,H,M]);const $t=ie=>{var Ie;(Ie=t==null?void 0:t.onChangeContextRunConfig)==null||Ie.call(t,e,{...u,task:p,...ie})},ye=(ie=p)=>{var et;const Ie=String(ie??"");Ie!==u.task&&(h.current=Ie,(et=t==null?void 0:t.onChangeContextRunConfig)==null||et.call(t,e,{...u,task:Ie}))},ze=(ie,Ie)=>{const et=new Set(u.skillKeys);for(const qe of ie){const Pt=String(qe||"").trim();Pt&&(Ie?et.add(Pt):et.delete(Pt))}$t({skillKeys:Array.from(et)})},oe=ie=>{z(Ie=>{const et=new Set(Ie);return et.has(ie)?et.delete(ie):et.add(ie),et})},ke=(ie,Ie)=>{const et=(ie==null?void 0:ie.id)||(ie==null?void 0:ie.path)||"";if(!et)return;const qe=x.filter(Pt=>{const vt=Pt.id||Pt.path||"";return vt===et?Ie:at.has(vt)});$t({knowledgeContext:jg(qe)})},Be=()=>{$t({knowledgeContext:null})};return M==="result"&&F?i.jsx(IM,{id:e,data:{...A,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):i.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+(M==="result"&&F?" af-work-context-run-card--result":"")+(y?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(v?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((ie,Ie)=>{if(ie.showOnNode===!1)return null;const et=`${2.25+Ie*1.75}rem`,qe=ie.name||`#${Ie+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:et},children:qe}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${Ie}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:et,background:En(ie.type)},title:`${qe} · ${ie.type}`})]},`in-${Ie}`)}),c.map((ie,Ie)=>{if(ie.showOnNode===!1)return null;const et=`${2.25+Ie*1.75}rem`,qe=ie.name||`#${Ie+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:et},children:qe}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${Ie}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:et,background:En(ie.type)},title:`${qe} · ${ie.type}`})]},`out-${Ie}`)}),i.jsxs("div",{className:"af-work-context-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"automation"}),i.jsx("strong",{children:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"}),i.jsxs("div",{className:"af-work-context-run-card__model-wrap nodrag",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>ie.stopPropagation(),children:[i.jsxs("select",{className:"af-work-context-run-card__model",value:ee,disabled:b,"aria-label":"模型",title:ue||"默认模型",onChange:ie=>$t({model:ie.target.value}),children:[i.jsx("option",{value:"",children:"默认"}),pe?i.jsx("option",{value:se,children:se}):null,Q.length?i.jsx("optgroup",{label:"Cursor",children:Q.map(ie=>i.jsx("option",{value:`cursor:${Es(ie)}`,children:Es(ie)},`context-cursor-${ie}`))}):null,K.length?i.jsx("optgroup",{label:"OpenCode",children:K.map(ie=>i.jsx("option",{value:`opencode:${Es(ie)}`,children:Es(ie)},`context-opencode-${ie}`))}):null,te.length?i.jsx("optgroup",{label:"Codex",children:te.map(ie=>i.jsx("option",{value:`codex:${Es(ie)}`,children:Es(ie)},`context-codex-${ie}`))}):null,W.length?i.jsx("optgroup",{label:"Claude Code",children:W.map(ie=>i.jsx("option",{value:`claude-code:${Es(ie)}`,children:Es(ie)},`context-claude-${ie}`))}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"expand_more"})]}),i.jsx("span",{className:"af-work-context-run-card__kind",children:ui(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),F?i.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:ie=>ie.stopPropagation(),children:[i.jsx("button",{type:"button",className:M==="config"?"is-active":"",onClick:()=>V("config"),"aria-label":"切换到任务配置",children:i.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),i.jsx("button",{type:"button",className:M==="result"?"is-active":"",onClick:()=>V("result"),"aria-label":"切换到展示结果",children:i.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:b,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-context-run-card__body nodrag",children:[i.jsxs(i.Fragment,{children:[i.jsx("textarea",{value:p,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{d.current=!0},onCompositionEnd:ie=>{d.current=!1,f(ie.currentTarget.value),ye(ie.currentTarget.value)},onChange:ie=>{f(ie.target.value)},onBlur:ie=>ye(ie.currentTarget.value)}),i.jsxs("div",{className:"af-work-context-run-card__grid",children:[i.jsxs("div",{className:"af-work-context-run-card__skills",children:[i.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:ie=>{var Ie;ie.stopPropagation(),_||(Ie=t==null?void 0:t.onRefreshSkills)==null||Ie.call(t),S(et=>!et)},children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsx("span",{children:u.skillKeys.length?`${u.skillKeys.length} skills`:"Skills"}),i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),_?i.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:ie=>ie.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:N,onChange:ie=>P(ie.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),N?i.jsx("button",{type:"button",onClick:()=>P(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:ct.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:ct.updateMenuScrollbar,children:[He.collectionGroups.map(ie=>{const Ie=ie.skills.map(vt=>vt.key),et=Ie.filter(vt=>Me.has(vt)).length,qe=Ie.length>0&&et===Ie.length,Pt=R.has(ie.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Pt?" af-work-load-skills-menu__group--collapsed":""),children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[i.jsx("input",{type:"checkbox",checked:qe,disabled:b,onChange:vt=>ze(Ie,vt.target.checked),"aria-label":`选择 ${ie.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>oe(ie.id),"aria-expanded":!Pt,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:ie.name}),ie.description?i.jsx("em",{children:ie.description}):null]})}),i.jsxs("small",{children:[et,"/",Ie.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>oe(ie.id),"aria-label":Pt?`展开 ${ie.name}`:`收起 ${ie.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Pt?"chevron_right":"expand_more"})})]}),Pt?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:ie.skills.map(vt=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:Me.has(vt.key),disabled:b,onChange:tr=>ze([vt.key],tr.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:vt.name}),vt.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:vt.description}):null]})]},`${ie.id}:${vt.key}`))})]},ie.id)}),He.ungrouped.length>0?i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("small",{children:He.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:He.ungrouped.map(ie=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:Me.has(ie.key),disabled:b,onChange:Ie=>ze([ie.key],Ie.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:ie.name}),ie.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:ie.description}):null]})]},`ungrouped:${ie.key}`))})]}):null,He.collectionGroups.length===0&&He.ungrouped.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>$t({skillKeys:[]}),children:"清空"})]}),i.jsx("div",{ref:ct.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(ct.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:ct.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${ct.scrollbar.height}%`,top:`${ct.scrollbar.top}%`}})})]}):null]}),i.jsxs("div",{className:"af-work-context-run-card__workspace",children:[i.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:ie=>{var Ie;ie.stopPropagation(),E||(Ie=t==null?void 0:t.onRefreshWorkspaces)==null||Ie.call(t),O(et=>!et)},children:[i.jsx("span",{className:"material-symbols-outlined",children:Re.length?"folder_open":"folder_off"}),i.jsx("span",{children:Re.length?`${Re.length} 知识库`:"知识库"}),i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),E?i.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:ie=>ie.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:D,onChange:ie=>L(ie.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),D?i.jsx("button",{type:"button",onClick:()=>L(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:kt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:kt.updateMenuScrollbar,children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"知识库"}),i.jsx("small",{children:yt.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:yt.map(ie=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:at.has(ie.id||ie.path),disabled:b,onChange:Ie=>ke(ie,Ie.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:ie.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[ie.kind==="git"&&ie.repoUrl?`${ie.repoUrl}${ie.branch?` · ${ie.branch}`:""}${ie.mountPath?` · ${ie.mountPath}`:""}`:ie.path,ie.exists?"":" · 路径未就绪"]})]})]},`${ie.id}:${ie.path}`))})]}),yt.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:Be,children:"清空知识库"})]}),i.jsx("div",{ref:kt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(kt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:kt.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${kt.scrollbar.height}%`,top:`${kt.scrollbar.top}%`}})})]}):null]}),i.jsxs("select",{value:u.displayType,disabled:b,onChange:ie=>$t({displayType:ie.target.value}),children:[i.jsx("option",{value:"markdown",children:"Markdown"}),i.jsx("option",{value:"html",children:"HTML"}),i.jsx("option",{value:"react",children:"React"}),i.jsx("option",{value:"table",children:"Table"}),i.jsx("option",{value:"chart",children:"Chart"}),i.jsx("option",{value:"ascii",children:"ASCII"}),i.jsx("option",{value:"mermaid",children:"Mermaid"})]})]}),B?i.jsx("pre",{className:"af-work-context-run-card__preview",children:B.slice(0,520)}):null]}),i.jsxs("div",{className:"af-work-context-run-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(y?" af-work-run-card__button--stop":""),disabled:b,onClick:ie=>{var Ie,et;ie.stopPropagation(),ye(),y?(Ie=t==null?void 0:t.onStopWorkspaceNode)==null||Ie.call(t,e):(et=t==null?void 0:t.onRunWorkspaceNode)==null||et.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:y?"stop_circle":"play_arrow"}),i.jsx("span",{children:y?"Stop":"Run"})]}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__logs nodrag",onClick:ie=>{var Ie;ie.stopPropagation(),(Ie=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Ie.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"})},children:i.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})]})}function QJ({id:e,data:t,selected:n,deleteNode:r}){var P,R,z;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=$v((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},p=((R=(P=t==null?void 0:t.runningRunNodeIds)==null?void 0:P.has)==null?void 0:R.call(P,e))||((z=t==null?void 0:t.runningRunNodeIds)==null?void 0:z[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",f=(t==null?void 0:t.optimizingRun)===!0,d=(t==null?void 0:t.nodeStatus)==="stopped",h=!!(t!=null&&t.readOnly),y=E=>{var O;(O=t==null?void 0:t.onChangeScheduledRunConfig)==null||O.call(t,e,{...a,...E})},v=E=>{y({scheduleType:E,cron:cd(E,a.time,a.weekday,a.monthDay,a.cron)})},b=E=>{y({time:E,cron:cd(a.scheduleType,E,a.weekday,a.monthDay,a.cron)})},[g,k]=Mv(a.time).split(":"),x=(E,O)=>{b(`${Yo(E,9,0,23)}:${Yo(O,0,0,59)}`)},_=E=>{y({weekday:E,cron:cd(a.scheduleType,a.time,E,a.monthDay,a.cron)})},S=E=>{y({monthDay:E,cron:cd(a.scheduleType,a.time,a.weekday,E,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const N=()=>{h||l===a.cron||y({cron:l})};return i.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(p?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(d?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((E,O)=>{if(E.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=E.name||`#${O+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:L}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${O}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:En(E.type)},title:`${L} · ${E.type}`})]},`in-${O}`)}),o.map((E,O)=>{if(E.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=E.name||`#${O+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:L}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${O}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:En(E.type)},title:`${L} · ${E.type}`})]},`out-${O}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:h,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[i.jsxs("label",{className:"af-work-schedule-card__toggle",children:[i.jsx("input",{type:"checkbox",checked:a.enabled,disabled:h,onChange:E=>y({enabled:E.target.checked})}),i.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:a.scheduleType,disabled:h,onChange:E=>v(E.target.value),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"}),i.jsx("option",{value:"monthly",children:"每月"}),i.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{className:"af-work-schedule-time-selects",children:[i.jsx("select",{value:g,disabled:h,"aria-label":"小时",onChange:E=>x(E.target.value,k),children:Array.from({length:24},(E,O)=>Yo(O,0,0,23)).map(E=>i.jsxs("option",{value:E,children:[E," 时"]},E))}),i.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:E=>x(g,E.target.value),children:Array.from({length:12},(E,O)=>Yo(O*5,0,0,59)).map(E=>i.jsxs("option",{value:E,children:[E," 分"]},E))})]})]}):null,a.scheduleType==="weekly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"星期"}),i.jsxs("select",{value:a.weekday,disabled:h,onChange:E=>_(E.target.value),children:[i.jsx("option",{value:1,children:"周一"}),i.jsx("option",{value:2,children:"周二"}),i.jsx("option",{value:3,children:"周三"}),i.jsx("option",{value:4,children:"周四"}),i.jsx("option",{value:5,children:"周五"}),i.jsx("option",{value:6,children:"周六"}),i.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"日期"}),i.jsx("select",{value:a.monthDay,disabled:h,onChange:E=>S(E.target.value),children:Array.from({length:31},(E,O)=>O+1).map(E=>i.jsxs("option",{value:E,children:[E," 日"]},E))})]}):null,a.scheduleType==="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"Cron"}),i.jsx("input",{type:"text",value:l,disabled:h,spellCheck:!1,placeholder:df,onChange:E=>c(E.target.value),onBlur:N,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[wJ(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",yJ(u.nextAt)]}),i.jsx("span",{children:p?"running":u.lastStatus||"idle"})]}),u.lastError?i.jsx("div",{className:"af-work-schedule-card__error",children:u.lastError}):null,i.jsxs("div",{className:"af-work-schedule-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(p?" af-work-run-card__button--stop":""),disabled:h||f,onClick:E=>{var O,D;E.stopPropagation(),p?(O=t==null?void 0:t.onStopWorkspaceNode)==null||O.call(t,e):(D=t==null?void 0:t.onRunWorkspaceNode)==null||D.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:p?"stop_circle":"play_arrow"}),i.jsx("span",{children:p?"停止":"立即运行"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(f?" af-work-schedule-card__optimize--running":""),disabled:h||p||f,title:"为下游节点提前生成 implementation",onClick:E=>{var O;E.stopPropagation(),(O=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||O.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:f?"sync":"auto_fix_high"}),i.jsx("span",{children:f?"优化中":"优化"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:E=>{var O;E.stopPropagation(),(O=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||O.call(t,{nodeId:e,scheduleNodeId:e,runNodeId:u.targetRunNodeId||e,lastRunId:u.lastRunId||"",label:(t==null?void 0:t.label)||"Scheduled Run"})},children:[i.jsx("span",{className:"material-symbols-outlined",children:"article"}),i.jsx("span",{children:"日志"})]})]})]})]})}function ZJ({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=tu(),o=!!(t!=null&&t.readOnly),a=Ib(t==null?void 0:t.nodeSize)||{width:ul,height:dl},l=m.useCallback(c=>{var u,p;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(p=(u=c.target)==null?void 0:u.closest)!=null&&p.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(f=>TM(f,e))},[e,s]);return i.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[o?null:i.jsx(iv,{className:"af-work-group-node__resize nodrag",minWidth:ul,minHeight:dl,position:"bottom-right",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsxs("div",{className:"af-work-group-node__title nodrag",children:[i.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),i.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:o,onClick:c=>{c.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function eX(e){var y,v,b,g,k,x,_,S,N,P,R,z,E,O,D,L,M,V,B,F,$,H,A,Q,K,W,te,Z;const{setEdges:t,setNodes:n}=tu(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,s=!!((v=e.data)!=null&&v.readOnly),[o,a]=m.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=m.useCallback(G=>{var se,ee,ue;if(s)return;(ee=(se=e.data)==null?void 0:se.onCleanupWorkspaceNodeOutputs)==null||ee.call(se,G,e.data);const ne=ui((ue=e.data)==null?void 0:ue.definitionId)?DM(G):"",re=new Set([G,ne].filter(Boolean));n(de=>de.filter(pe=>!re.has(pe.id))),t(de=>de.filter(pe=>!re.has(pe.source)&&!re.has(pe.target)))},[e.data,s,t,n]),u=m.useCallback(G=>{var ne,re;G.button!==0||G.metaKey||G.ctrlKey||G.shiftKey||(re=(ne=G.target)==null?void 0:ne.closest)!=null&&re.call(ne,".react-flow__handle, .af-work-display-resize")||(n(se=>TM(se,e.id)),t(se=>sX(se)))},[e.id,t,n]),p=m.useCallback((G,ne)=>{s||(n(re=>re.map(se=>se.id===G?{...se,data:{...se.data,model:ne}}:se)),r==null||r(G,{model:ne}))},[s,n,r]),f=m.useCallback((G,ne)=>{s||(n(re=>re.map(se=>{var ue;if(se.id!==G)return se;const ee=Array.isArray((ue=se.data)==null?void 0:ue.outputs)&&se.data.outputs.length?se.data.outputs.map((de,pe)=>pe===0?{...de,default:ne,value:ne}:de):[{type:"bool",name:"value",default:ne,value:ne}];return{...se,data:{...se.data,body:"",outputs:ee}}})),r==null||r(G,re=>({body:"",outputs:Array.isArray(re==null?void 0:re.outputs)&&re.outputs.length?re.outputs.map((ee,ue)=>ue===0?{...ee,default:ne,value:ne}:ee):[{type:"bool",name:"value",default:ne,value:ne}]})))},[s,n,r]),d=m.useCallback((G,ne)=>{s||(n(re=>re.map(se=>se.id===G?{...se,data:{...se.data,body:ne}}:se)),r==null||r(G,{body:ne}))},[s,n,r]),h=m.useCallback((G,ne)=>{if(s)return;const re=vo(ne);n(se=>se.map(ee=>ee.id===G?{...ee,data:{...ee.data,images:re}}:ee)),r==null||r(G,{images:re})},[s,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?i.jsx(ZJ,{...e,deleteNode:c}):pl((k=e.data)==null?void 0:k.definitionId)?i.jsx(IM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(JJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((_=e.data)==null?void 0:_.definitionId)==="workspace_scheduled_run"?i.jsx(QJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):ui((S=e.data)==null?void 0:S.definitionId)?i.jsx(XJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(N=e.data)==null?void 0:N.skills,skillCollections:(P=e.data)==null?void 0:P.skillCollections,workspaces:(R=e.data)==null?void 0:R.workspaceTargets}):((z=e.data)==null?void 0:z.definitionId)==="control_load_skills"?i.jsx(bX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(E=e.data)==null?void 0:E.skills,skillCollections:(O=e.data)==null?void 0:O.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((L=e.data)==null?void 0:L.definitionId)==="control_load_mcp"?i.jsx(kX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:(M=e.data)==null?void 0:M.mcpServers,onChangeMcpNames:(V=e.data)==null?void 0:V.onChangeLoadMcpNames}):((B=e.data)==null?void 0:B.definitionId)==="control_cd_workspace"?i.jsx(vX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(F=e.data)==null?void 0:F.workspaceTargets,onChangeWorkspace:($=e.data)==null?void 0:$.onChangeLoadWorkspace,onRefreshWorkspaces:(H=e.data)==null?void 0:H.onRefreshWorkspaces}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((A=e.data)!=null&&A.isExecuting||((Q=e.data)==null?void 0:Q.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((K=e.data)==null?void 0:K.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((W=e.data)==null?void 0:W.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((te=e.data)==null?void 0:te.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:i.jsx(iv,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:oM,minHeight:vm,maxWidth:aM,maxHeight:lM,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(LU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(Z=e.data)==null?void 0:Z.modelLists,onModelChange:p,onProvideValueChange:f,onNodeBodyChange:d,onNodeImagesChange:h})]})}const tX={[Ec]:m.memo(eX)};function Lv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Lv(n.children,t);return t}function PM(e,t){const n=String(t||"");if(!n)return null;for(const r of e||[]){if(r.path===n)return r;const s=Array.isArray(r.children)?PM(r.children,n):null;if(s)return s}return null}function nX(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function RM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&RM(n.children,t));return t}function Zp(e){const t=String(e||"").replace(/\\/g,"/").split("/").filter(Boolean),n=[];for(let r=1;r<t.length;r++)n.push(t.slice(0,r).join("/"));return n}function rX(e,t){const n=String(t||"");let r=!1;const s=(e||[]).map(o=>{const a=o.id===n;return o.selected===a?o:(r=!0,{...o,selected:a})});return r?s:e}function TM(e,t){const n=String(t||""),r=(e||[]).find(o=>o.id===n),s=(e||[]).reduce((o,a)=>o+(a.selected?1:0),0);return r!=null&&r.selected&&s>1?e:rX(e,n)}function sX(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function iX(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function oX(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(o,a,l)=>{const c=r[a],u=l?`${l}/${c}`:c,p=a===r.length-1;let f=!1;const d=(Array.isArray(o)?o:[]).map(h=>h.name!==c?h:(f=!0,p?{...h,type:"file",name:c,path:u,icon:yc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:yc(c,!0),children:s(h.children||[],a+1,u)}));return f||d.push(p?{type:"file",name:c,path:u,icon:yc(c),size:n}:{type:"directory",name:c,path:u,icon:yc(c,!0),children:s([],a+1,u)}),iX(d)};return s(e||[],0,"")}function aX(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"":t<1024?`${t} B`:t<1024*1024?`${Math.round(t/102.4)/10} KB`:`${Math.round(t/1024/102.4)/10} MB`}function MM({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}){return i.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const p=u.type==="directory",f=p&&(r==null?void 0:r.has(u.path)),d=n===u.path;return i.jsxs("li",{children:[i.jsxs("div",{className:"af-work-file-row",children:[i.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+u.type+(d?" af-work-file--selected":""),draggable:!p,onDragStart:y=>{p||a==null||a(y,u)},onClick:()=>{o==null||o(u),p&&(s==null||s(u.path))},onDoubleClick:()=>{p||t(u)},title:u.path,children:[p?i.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:f?"chevron_right":"expand_more"}):null,i.jsx("span",{className:"material-symbols-outlined",children:u.icon||yc(u.name,p)}),i.jsx("span",{children:u.name})]}),d?i.jsxs("div",{className:"af-work-file-actions",children:[p?null:i.jsx("button",{type:"button",className:"af-work-file-action",onClick:y=>{y.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),i.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:y=>{y.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),p&&!f&&((h=u.children)!=null&&h.length)?i.jsx(MM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function lX({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=m.useMemo(()=>Lv(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(u=>l?`${u.path} ${u.name}`.toLowerCase().includes(l):!0);return i.jsx("div",{className:"af-flow-snippet-modal-overlay",onMouseDown:o,children:i.jsxs("div",{className:"af-flow-snippet-modal af-work-file-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择文件",onMouseDown:u=>u.stopPropagation(),children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"选择文件"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:o,"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("div",{className:"af-work-file-picker-modal__tools",children:[i.jsx("input",{value:t,onChange:u=>n(u.target.value),placeholder:"搜索文件路径...",autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(""),children:[i.jsx("span",{className:"material-symbols-outlined",children:"upload_file"}),"上传"]})]}),i.jsxs("div",{className:"af-work-file-picker-modal__list",children:[c.map(u=>i.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(u),children:[i.jsx("span",{className:"material-symbols-outlined",children:u.icon||yc(u.name)}),i.jsxs("span",{className:"af-work-file-picker-modal__main",children:[i.jsx("strong",{children:u.name}),i.jsx("small",{children:u.path})]}),u.size?i.jsx("em",{children:aX(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function cC({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return i.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,o)=>{const a=s.kind==="run-log"||s.kind==="run-summary"||s.kind==="activity"||s.kind==="prompt"||s.kind==="raw"||s.kind==="thinking"||s.kind==="result"||s.kind==="assistant"?"reply":s.role==="user"?"user-msg":s.error?"error":"reply",l=s.kind==="run-summary"?"Steps":s.kind==="run-log"?"Run":s.kind==="activity"?"Activity":s.kind==="prompt"?"Prompt":s.kind==="raw"?"Raw Trace":s.kind==="thinking"?"Thinking":s.kind==="result"?"Result":s.kind==="assistant"?"Response":s.role==="user"?"You":s.error?"Error":"Reply";return i.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[i.jsx("div",{className:"af-composer-ai-block-label",children:l}),i.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${o}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),i.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),i.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function $M(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function cX(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!$M(o));if(r.length>0)return r;const s=[...n].reverse().find(o=>(o==null?void 0:o.kind)==="result"||(o==null?void 0:o.kind)==="assistant"||(o==null?void 0:o.error));return s?[s]:n.length>0||t?[{role:"assistant",kind:"assistant",text:t?"正在执行,可以在完成后继续追问或要求调整。":"运行已完成。可以在下方继续追问、要求总结或调整结果。",at:0}]:[]}function uX(e){return(Array.isArray(e)?e:[]).filter($M)}function pf(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return n.map(String).filter(Boolean)}catch{}return t.split(/[\n,]+/).map(n=>n.trim()).filter(Boolean)}function dX(e){const t=pf((e==null?void 0:e.body)||"");if(t.length>0)return t;const r=(Array.isArray(e==null?void 0:e.inputs)?e.inputs:[]).find(s=>(s==null?void 0:s.name)==="skillsContext"||(s==null?void 0:s.name)==="skillKeys"||(s==null?void 0:s.type)==="text");return pf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function fX(e){const n=[...Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],...Array.isArray(e==null?void 0:e.outputs)?e.outputs:[]].find(r=>(r==null?void 0:r.name)==="skillKeys"||(r==null?void 0:r.name)==="skillsContext");return pf((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function LM(e,t,n=1){const r=(Array.isArray(e)?e:[]).map(o=>String(o||"").trim()).filter(Boolean);return r.length?{head:r.slice(0,n).join("、"),extra:r.length>n?`等 ${r.length} 个`:"",title:r.join(", ")}:{head:t,extra:"",title:""}}function uC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function fa(e,t,n=""){const r=(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.name)===t);return String((r==null?void 0:r.value)??(r==null?void 0:r.default)??"").trim()||n}function Pm(e,t){const n=fa(e,t,"");if(!n)return null;try{const r=JSON.parse(n);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function Tf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Es(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function OM(e){const t=Tf(e);return t==="html"?"display_html":t==="react"?"display_react_app":t==="table"?"display_table":t==="chart"?"display_chart":t==="ascii"?"display_ascii":t==="mermaid"?"display_mermaid":"display_markdown"}function DM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function FM(e){return e==="display_image"?"src":"content"}function dC(e,t,n){const r=FM(t),s=ud(e);let o=!1;const a=s.map(l=>(l==null?void 0:l.name)===r?(o=!0,{...l,default:n,value:n,showOnNode:l.showOnNode!==!1}):(l==null?void 0:l.name)==="filePath"?{...l,default:"",value:""}:l);return o||a.push({type:"text",name:r,default:n,value:n,required:!0,showOnNode:!0}),a}function fC(e,t,n=[],r=[]){const s=Array.isArray(e)?e:[],o=new Set((Array.isArray(n)?n:[]).map(u=>String(u||"").trim()).filter(Boolean)),a=new Set((Array.isArray(r)?r:[]).map(u=>String(u||"").trim()).filter(Boolean)),l=u=>(u==null?void 0:u.showOnNode)!==!1;let c=s.findIndex(u=>l(u)&&o.has(String((u==null?void 0:u.name)||"").trim()));return c<0&&(c=s.findIndex(u=>o.has(String((u==null?void 0:u.name)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u)&&a.has(String((u==null?void 0:u.type)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u))),c<0&&(c=0),`${t}-${c}`}function pC(e){return(Array.isArray(e)?e:[]).map(t=>(t==null?void 0:t.type)==="node"||(t==null?void 0:t.name)==="next"?t:{...t,default:"",value:""})}function Sg(e){const t=Array.isArray(e==null?void 0:e.outputs)?e.outputs:Array.isArray(e==null?void 0:e.output)?e.output:[],n=s=>String((s==null?void 0:s.value)??(s==null?void 0:s.default)??"").trim(),r=t.find(s=>((s==null?void 0:s.name)==="content"||(s==null?void 0:s.name)==="result")&&n(s))||t.find(s=>(s==null?void 0:s.name)==="resultFile"&&n(s))||t.find(s=>(s==null?void 0:s.type)!=="node"&&(s==null?void 0:s.name)!=="next"&&(s==null?void 0:s.name)!=="displayType"&&n(s));return r?n(r):""}function pX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=fa(t,"includeWorkspaceContext","true").toLowerCase(),r=Pm(t,"knowledgeContext"),s=Pm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:fX(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?jg([s]):null),workspaceContext:s,displayType:Tf(fa(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function ui(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function hX(e){const t=pf((e==null?void 0:e.body)||"");if(t.length>0)return t;const r=(Array.isArray(e==null?void 0:e.inputs)?e.inputs:[]).find(s=>(s==null?void 0:s.name)==="mcpContext"||(s==null?void 0:s.name)==="serverNames"||(s==null?void 0:s.type)==="text");return pf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function mX(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function zM(e={},t="context"){const n=String((e==null?void 0:e.cwd)||(e==null?void 0:e.workspaceRoot)||(e==null?void 0:e.path)||"").trim(),r=String((e==null?void 0:e.id)||"").trim(),s=String((e==null?void 0:e.label)||(e==null?void 0:e.name)||"").trim();if(!n&&!r&&!s)return null;const o=String(s||r||"知识库").trim();return{id:r,label:o,kind:(e==null?void 0:e.kind)==="git"?"git":"local",type:String((e==null?void 0:e.type)||""),repoPath:n,path:n,mountPath:String((e==null?void 0:e.mountPath)||r||o).trim(),repoUrl:String((e==null?void 0:e.repoUrl)||"").trim(),branch:String((e==null?void 0:e.branch)||"").trim(),readonly:!0,role:t}}function jg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>zM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function BM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>zM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function gX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=Pm(t,"knowledgeContext"),r=Pm(t,"workspaceContext");return{sources:BM(n||(r?jg([r]):null)),path:fa(t,"path",""),label:fa(t,"label","")}}function hC(e){var r,s,o,a,l,c,u,p,f;if(!e)return null;const{inputs:t,outputs:n}=YU(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((s=e.data)==null?void 0:s.role)??"normal"),model:String(((o=e.data)==null?void 0:o.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:vo((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((u=e.data)==null?void 0:u.scriptRef)??""),implementationRef:String(((p=e.data)==null?void 0:p.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function mC(e,t,n,r=""){var c,u;const s=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(p=>String((p==null?void 0:p.id)||"")===s),a=String(((c=o==null?void 0:o.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[s])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function gC(e){return(Array.isArray(e)?e:[]).map(t=>({type:String((t==null?void 0:t.type)??"node").trim()||"node",name:String((t==null?void 0:t.name)??""),default:String((t==null?void 0:t.default)??""),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)??"node").trim().toLowerCase()==="node"}))}function yX(e,t,n){var p,f;const r=String(((p=e==null?void 0:e.data)==null?void 0:p.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=lf.includes(o)?o:"normal",l=String((t==null?void 0:t.model)||"").trim(),c={...e.data,label:String((t==null?void 0:t.label)||"").trim()||n,role:a,model:l===""||l==="default"?void 0:l,body:s?"":String((t==null?void 0:t.body)??""),images:s?[]:vo(t==null?void 0:t.images),inputs:gC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:gC(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const d of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[d])??"").trim();h?c[d]=h:delete c[d]}return c}function yC({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:o=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),c=o?l:a;if(o){if(!wG.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(v=>v.id===c&&v.id!==a))return{ok:!1,error:"Duplicate instance id"}}const u=yX(r,s,c),p=r.data||{};if(!(c!==a||p.label!==u.label||p.role!==u.role||p.model!==u.model||p.body!==u.body||JSON.stringify(vo(p.images))!==JSON.stringify(u.images)||(p.script??void 0)!==(u.script??void 0)||(p.scriptRef??void 0)!==(u.scriptRef??void 0)||(p.implementationRef??void 0)!==(u.implementationRef??void 0)||(p.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(p.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(p.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const d=e.map(v=>v.id===a?{...v,id:c,selected:!0,data:u}:v);let h=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,h=t.map((b,g)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:d,edges:h,instances:y}}function wX(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function xX(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","scriptRef","implementationRef","implementationMode","inputs","outputs"])wX(e[s],t[s])&&(r[s]=n[s]);return r}function Mb(e,t=[]){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,y=h?Math.max(12,d/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,p.scrollTop/Math.max(1,f-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{if(!e)return;const p=requestAnimationFrame(a);return()=>cancelAnimationFrame(p)},[e,a,...t]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(p-h.top-f)/v},[s.height]),u=m.useCallback(p=>{var _,S;if(!s.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=s.top/100*d.height,y=s.height/100*d.height,b=p.clientY>=d.top+h&&p.clientY<=d.top+h+y?p.clientY-d.top-h:y/2;l(c(p.clientY,b));const g=p.pointerId;(S=(_=p.currentTarget).setPointerCapture)==null||S.call(_,g);const k=N=>{N.preventDefault(),l(c(N.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:s,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function bX({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=Array.isArray(s)?s:[],p=Array.isArray(o)?o:[],[f,d]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[x,_]=m.useState({visible:!1,top:0,height:100}),S=m.useMemo(()=>new Set(dX(t)),[t]),N=m.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),P=m.useMemo(()=>Array.from(S).map(F=>{var $;return(($=N.get(F))==null?void 0:$.name)||F}),[N,S]),R=m.useMemo(()=>LM(P,"选择 Skills"),[P]),z=m.useMemo(()=>{const F=new Set,$=p.map(A=>{const Q=ca(A,u).map(K=>N.get(K)).filter(Boolean);for(const K of Q)F.add(K.key);return{...A,skills:Q}}).filter(A=>A.skills.length>0),H=u.filter(A=>!F.has(A.key));return{collectionGroups:$,ungrouped:H}},[N,p,u]);m.useEffect(()=>{b(F=>{let $=!1;const H=new Set(F);for(const A of z.collectionGroups)H.has(A.id)||(H.add(A.id),$=!0);return $?H:F})},[z.collectionGroups]);const E=m.useMemo(()=>{const F=h.trim().toLowerCase();if(!F)return z;const $=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(K=>String(K||"").toLowerCase()).join(" ").includes(F);return{collectionGroups:z.collectionGroups.map(A=>{const K=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(W=>String(W||"").toLowerCase()).join(" ").includes(F)?A.skills:A.skills.filter($);return{...A,skills:K}}).filter(A=>A.skills.length>0),ungrouped:z.ungrouped.filter($)}},[z,h]),O=m.useCallback((F,$)=>{const H=new Set(S);for(const A of F)$?H.add(A):H.delete(A);a==null||a(e,Array.from(H))},[e,S,a]),D=m.useCallback(F=>{b($=>{const H=new Set($);return H.has(F)?H.delete(F):H.add(F),H})},[]),L=m.useCallback(()=>{const F=g.current;if(!F)return;const $=Math.max(1,F.scrollHeight),H=Math.max(1,F.clientHeight),A=$>H+1,Q=A?Math.max(12,H/$*100):100,K=Math.max(0,100-Q),W=A?Math.min(K,F.scrollTop/Math.max(1,$-H)*K):0;_({visible:A,top:W,height:Q})},[]);m.useEffect(()=>{if(!f)return;const F=requestAnimationFrame(L);return()=>cancelAnimationFrame(F)},[v,E,S.size,f,L]);const M=m.useCallback(F=>{const $=g.current;if(!$)return;const H=Math.max(0,$.scrollHeight-$.clientHeight);$.scrollTop=Math.min(1,Math.max(0,F))*H,L()},[L]),V=m.useCallback((F,$=0)=>{const H=k.current;if(!H)return 0;const A=H.getBoundingClientRect(),Q=x.height/100*A.height,K=Math.max(1,A.height-Q);return(F-A.top-$)/K},[x.height]),B=m.useCallback(F=>{var ne,re;if(!x.visible)return;F.preventDefault(),F.stopPropagation();const $=k.current;if(!$)return;const H=$.getBoundingClientRect(),A=x.top/100*H.height,Q=x.height/100*H.height,W=F.clientY>=H.top+A&&F.clientY<=H.top+A+Q?F.clientY-H.top-A:Q/2;M(V(F.clientY,W));const te=F.pointerId;(re=(ne=F.currentTarget).setPointerCapture)==null||re.call(ne,te);const Z=se=>{se.preventDefault(),M(V(se.clientY,W))},G=()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G)},[V,M,x.height,x.top,x.visible]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(f?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((F,$)=>{if(F.showOnNode===!1)return null;const H=`${2.6+$*1.7}rem`,A=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:H},children:A}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${$}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:H,background:En(F.type)},title:`${A} · ${F.type}`})]},`in-${$}`)}),c.map((F,$)=>{if(F.showOnNode===!1)return null;const H=`${2.6+$*1.7}rem`,A=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:H},children:A}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${$}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:H,background:En(F.type)},title:`${A} · ${F.type}`})]},`out-${$}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:F=>{var $;F.stopPropagation(),f||($=t==null?void 0:t.onRefreshSkills)==null||$.call(t),d(H=>!H)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:R.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:R.head}),R.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:R.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:F=>F.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:h,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?i.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:g,className:"af-work-load-skills-menu",onScroll:L,children:[E.collectionGroups.map(F=>{const $=F.skills.map(K=>K.key),H=$.filter(K=>S.has(K)).length,A=$.length>0&&H===$.length,Q=v.has(F.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Q?" af-work-load-skills-menu__group--collapsed":""),children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[i.jsx("input",{type:"checkbox",checked:A,onChange:K=>O($,K.target.checked),"aria-label":`选择 ${F.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>D(F.id),"aria-expanded":!Q,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:F.name}),F.description?i.jsx("em",{children:F.description}):null]})}),i.jsxs("small",{children:[H,"/",$.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>D(F.id),"aria-label":Q?`展开 ${F.name}`:`收起 ${F.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Q?"chevron_right":"expand_more"})})]}),Q?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:F.skills.map(K=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:S.has(K.key),onChange:W=>O([K.key],W.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:K.name}),K.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:K.description}):null]})]},`${F.id}:${K.key}`))})]},F.id)}),E.ungrouped.length>0?i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("small",{children:E.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:E.ungrouped.map(F=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:S.has(F.key),onChange:$=>O([F.key],$.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:F.name}),F.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:F.description}):null]})]},`ungrouped:${F.key}`))})]}):null,E.collectionGroups.length===0&&E.ungrouped.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),i.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:B,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function kX({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,u]=m.useState(!1),[p,f]=m.useState(""),d=m.useMemo(()=>new Set(hX(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>({name:String((b==null?void 0:b.name)||""),description:String((b==null?void 0:b.description)||""),detail:String((b==null?void 0:b.url)||[b==null?void 0:b.command,...Array.isArray(b==null?void 0:b.args)?b.args:[]].filter(Boolean).join(" ")||""),type:String((b==null?void 0:b.type)||"")})).filter(b=>b.name),[s]),y=m.useMemo(()=>{const b=p.trim().toLowerCase();return b?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):h},[p,h]),v=m.useCallback((b,g)=>{const k=new Set(d);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,d,o]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(c?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:x}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:En(b.type)},title:`${x} · ${b.type}`})]},`in-${g}`)}),l.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:x}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:En(b.type)},title:`${x} · ${b.type}`})]},`out-${g}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"hub"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:b=>{var g;b.stopPropagation(),c||(g=t==null?void 0:t.onRefreshMcps)==null||g.call(t),u(k=>!k)},children:[i.jsx("span",{children:d.size>0?`${d.size} MCP selected`:"选择 MCP"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:b=>b.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:p,onChange:b=>f(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),p?i.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{className:"af-work-load-skills-menu",children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"MCP Servers"}),i.jsx("small",{children:y.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:y.map(b=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:d.has(b.name),onChange:g=>v([b.name],g.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:b.name}),b.description||b.detail?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:b.description||b.detail}):null]})]},b.name))})]}),y.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空"})]})]}):null]})]})}function vX({id:e,data:t,selected:n,deleteNode:r,workspaces:s=[],onChangeWorkspace:o,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,p]=m.useState(!1),[f,d]=m.useState(""),h=gX(t),y=m.useMemo(()=>(Array.isArray(s)?s:[]).map(S=>({id:String((S==null?void 0:S.id)||""),label:String((S==null?void 0:S.label)||(S==null?void 0:S.name)||"知识库"),kind:(S==null?void 0:S.kind)==="git"?"git":"local",path:String((S==null?void 0:S.path)||""),repoUrl:String((S==null?void 0:S.repoUrl)||""),branch:String((S==null?void 0:S.branch)||""),mountPath:String((S==null?void 0:S.mountPath)||""),builtin:(S==null?void 0:S.builtin)===!0,exists:(S==null?void 0:S.exists)!==!1})).filter(S=>S.path),[s]),v=m.useMemo(()=>{const S=f.trim().toLowerCase();return S?y.filter(N=>[N.id,N.label,N.path,N.repoUrl,N.branch,N.mountPath].join(" ").toLowerCase().includes(S)):y},[f,y]),b=m.useMemo(()=>new Set((h.sources||[]).map(S=>S.id||S.path||S.repoPath).filter(Boolean)),[h.sources]),g=m.useMemo(()=>(h.sources||[]).map(S=>S.label||S.id||S.mountPath||S.path),[h.sources]),k=m.useMemo(()=>LM(g,"选择知识库"),[g]),x=Mb(u,[v.length,g.length,f]),_=(S,N)=>{const P=(S==null?void 0:S.id)||(S==null?void 0:S.path)||"",R=y.filter(z=>{const E=z.id||z.path||"";return E===P?N:b.has(E)});o==null||o(e,R)};return i.jsxs("div",{className:"af-work-load-skills-card af-work-load-workspace-card"+(n?" af-work-load-skills-card--selected":"")+(u?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((S,N)=>{if(S.showOnNode===!1)return null;const P=`${2.6+N*1.7}rem`,R=S.name||`#${N+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:P},children:R}),i.jsx(qn,{type:"target",position:Ue.Left,id:`input-${N}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:P,background:En(S.type)},title:`${R} · ${S.type}`})]},`in-${N}`)}),c.map((S,N)=>{if(S.showOnNode===!1)return null;const P=`${2.6+N*1.7}rem`,R=S.name||`#${N+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:P},children:R}),i.jsx(qn,{type:"source",position:Ue.Right,id:`output-${N}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:P,background:En(S.type)},title:`${R} · ${S.type}`})]},`out-${N}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"加载知识库"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:S=>{S.stopPropagation(),u||a==null||a(),p(N=>!N)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:k.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:k.head}),k.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:k.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:S=>S.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:f,onChange:S=>d(S.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),f?i.jsx("button",{type:"button",onClick:()=>d(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:x.menuRef,className:"af-work-load-skills-menu",onScroll:x.updateMenuScrollbar,children:[i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"知识库"}),i.jsx("small",{children:v.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:v.map(S=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:b.has(S.id||S.path),onChange:N=>_(S,N.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:S.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[S.kind==="git"&&S.repoUrl?`${S.repoUrl}${S.branch?` · ${S.branch}`:""}${S.mountPath?` · ${S.mountPath}`:""}`:S.path,S.exists?"":" · 路径未就绪"]})]})]},`${S.id}:${S.path}`))})]}),v.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空知识库"})]}),i.jsx("div",{ref:x.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(x.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:x.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.scrollbar.height}%`,top:`${x.scrollbar.top}%`}})})]}):null]})]})}function WM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=YT(r),o=EG(GY(r)),a=s?o.filter(d=>!["issue","mr"].includes(xm(d))):o,l=PG(r,o),c=$i(r,t),u=s?"":qo(r.platform),p=Array.isArray(e==null?void 0:e.children)?e.children.length:0,f=[c,s&&p?`${p} 个端侧 Issue`:u,r.status].filter(Boolean);return i.jsxs("div",{className:`af-prd-workflow-issue${n?" af-prd-workflow-issue--child":""}${s?" af-prd-workflow-issue--aggregate":""}`,children:[i.jsx("strong",{children:KY(r,t)}),i.jsx("small",{children:f.join(" · ")}),i.jsxs("div",{className:"af-prd-workflow-issue__state-row",children:[i.jsx("span",{className:`af-prd-workflow-issue__state af-prd-workflow-issue__state--${l.kind}`,children:l.label}),l.detail?i.jsx("small",{children:l.detail}):null]}),a.length?i.jsx("div",{className:"af-prd-workflow-issue__links",children:a.map(d=>i.jsx("a",{href:d.href,target:"_blank",rel:"noreferrer",children:d.label},`${d.label}-${d.href}`))}):null,p?i.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((d,h)=>i.jsx(WM,{row:d,index:h,child:!0},$i((d==null?void 0:d.issue)||{},h)))}):null]})}function HM(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e).trim():typeof e!="object"||Array.isArray(e)?"":String(e.label||e.name||e.value||e.key||e.code||e.username||e.userId||"").trim()}function VM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>HM(n)).filter(Boolean)}function SX({fieldKey:e,field:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=String(t.label||e||"").trim(),r=String(t.type||"text").trim().toLowerCase(),s=["text","user","chips","list","link"].includes(r)?r:"text",o=VM(t.value);if(!o.length)return null;if(s==="list")return i.jsxs("div",{className:"af-prd-overall-platform__rules",children:[i.jsx("small",{children:n}),i.jsx("ul",{children:o.map((a,l)=>i.jsx("li",{children:a},`${e}-${l}-${a}`))})]});if(s==="link"){const a=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},l=String(t.href||t.url||a.href||a.url||"").trim();return i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[i.jsx("small",{children:n}),l?i.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:o[0]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):i.jsx("strong",{children:o[0]})]})}return i.jsxs("div",{className:`af-prd-overall-platform__row af-prd-overall-platform__row--${s}`,children:[i.jsx("small",{children:n}),i.jsx("div",{children:o.map((a,l)=>i.jsx("span",{children:a},`${e}-${l}-${a}`))})]})}function jX({sectionKey:e,section:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=(t.fields&&typeof t.fields=="object"&&!Array.isArray(t.fields)?Object.entries(t.fields):[]).filter(([,o])=>o&&typeof o=="object"&&VM(o.value).length);if(!r.length)return null;const s=e==="progress";return i.jsxs("section",{className:`af-prd-overall-platform${s?" af-prd-overall-platform--compact":""}`,children:[i.jsx("div",{className:"af-prd-overall-platform__head",children:i.jsx("strong",{children:String(t.title||e||"").trim()})}),i.jsx("div",{className:"af-prd-overall-platform__fields",children:r.map(([o,a])=>i.jsx(SX,{fieldKey:o,field:a},o))})]})}function NX({globalState:e,tapdId:t}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=n.workflow&&typeof n.workflow=="object"&&!Array.isArray(n.workflow)?n.workflow:{},s=n.sections&&typeof n.sections=="object"&&!Array.isArray(n.sections)?n.sections:{},o=String(n.title||"").trim(),a=String(n.url||"").trim(),l=HM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(s).filter(([f,d])=>f&&d&&typeof d=="object"&&!Array.isArray(d)),p=!!(o||a||l||u.length);return!c&&!p?null:i.jsxs("article",{className:"af-prd-workflow-card af-prd-overall",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"需求概览"}),l?i.jsx("span",{className:"af-prd-overall__status",children:l}):null]}),o||a||c?i.jsx("div",{className:"af-prd-overall__requirement",children:a?i.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",children:[i.jsx("strong",{children:o||`${r.namespace||"Workflow"} ${c}`}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):i.jsx("strong",{children:o||`${r.namespace==="tapd"?"TAPD":"Workflow"} ${c}`})}):null,p?i.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([f,d])=>i.jsx(jX,{sectionKey:f,section:d},f))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function _X({flowParams:e={},tapdId:t,setTapdId:n,snapshot:r,loading:s,error:o,actionRunning:a,actionOutput:l,pendingConfirm:c,conflict:u,reviewPublishing:p,onRefresh:f,onRunDryRun:d,onConfirmAction:h,onRetryConflict:y,onPublishReview:v}){const[b,g]=m.useState("all"),[k,x]=m.useState("all"),[_,S]=m.useState(!1),[N,P]=m.useState(!1),[R,z]=m.useState(!1),[E,O]=m.useState(""),[D,L]=m.useState(!1),[M,V]=m.useState(""),[B,F]=m.useState(null),$=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),H=Array.isArray(r==null?void 0:r.issues)?r.issues:[],A=YY(r),Q=A.reduce((ye,ze)=>ye+Sb(ze.issues),0),K=Array.isArray(r==null?void 0:r.artifacts)?r.artifacts:[];Array.isArray(r==null?void 0:r.optionalGaps)&&r.optionalGaps;const W=r!=null&&r.nextAction&&typeof r.nextAction=="object"?r.nextAction:null,te=ZY(r,W),Z=HY(r,te),G=K.filter(ye=>!XT({...ye,href:Ic(ye)})),ne=m.useMemo(()=>zY(te),[te]);m.useEffect(()=>{k!=="all"&&(ne.some(ye=>ye.key===k)||x("all"))},[k,ne]);const re=te.filter(ye=>BY(ye,k)),se=DY(re),ee=eJ(r),ue=ee.filter(ye=>tJ(ye,b)),de=re.filter(ye=>Iv(ye)).length,pe=r!=null&&r.collaboration&&typeof r.collaboration=="object"?r.collaboration:{},Me=pe.activeAction&&typeof pe.activeAction=="object"?pe.activeAction:null;Array.isArray(r==null?void 0:r.clientObservations)&&r.clientObservations;const Ne=String((r==null?void 0:r.rawOutput)||""),_e=r!=null&&r.globalState&&typeof r.globalState=="object"?r.globalState:null,He=IY($),ct=m.useCallback(async()=>{const ye=String(t||"").trim();if(!ye){F(null);return}P(!0),O(""),V("");try{const ze=new URLSearchParams({tapdId:ye});e.workflowShare&&ze.set("workflowShare",e.workflowShare);const oe=await fetch(`/api/prd-workflow/share?${ze.toString()}`),ke=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(ke.error||"读取 Workflow 分享状态失败");let Be=ke.share||null;const Qe=ke.canCreate===!0&&!e.workflowShare;if(L(Qe),!Be&&Qe){const Ce=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:ye})}),Ct=await Ce.json().catch(()=>({}));if(!Ce.ok)throw new Error(Ct.error||"生成 Workflow 分享链接失败");Be=Ct.share||null}F(Be)}catch(ze){O(String(ze.message||ze))}finally{P(!1)}},[e,t]),yt=()=>{S(!0),ct()},Re=async()=>{if(!(!t||R||e.workflowShare)){z(!0),O(""),V("");try{const ye=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),ze=await ye.json().catch(()=>({}));if(!ye.ok)throw new Error(ze.error||"生成 Workflow 分享链接失败");F(ze.share||null),L(!0)}catch(ye){O(String(ye.message||ye))}finally{z(!1)}}},at=async()=>{const ye=await Rb((B==null?void 0:B.shortUrl)||(B==null?void 0:B.url)||"");V(ye?"已复制":"复制失败")},kt=async()=>{if(!(!t||R||!(B!=null&&B.canManage))){z(!0),O(""),V("");try{const ye=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),ze=await ye.json().catch(()=>({}));if(!ye.ok)throw new Error(ze.error||"取消 Workflow 分享链接失败");F(null),L(!0)}catch(ye){O(String(ye.message||ye))}finally{z(!1)}}},$t=(B==null?void 0:B.shortUrl)||(B==null?void 0:B.url)||"";return i.jsxs("main",{className:"af-prd-workflow af-prd-workflow--timeline","aria-label":"PRD Workflow",children:[i.jsxs("section",{className:"af-prd-workflow__statusbar",children:[i.jsxs("div",{className:"af-prd-workflow__status-main",children:[i.jsx("span",{className:`af-prd-workflow-phase af-prd-workflow-phase--${$.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:q_($)}),i.jsx("h1",{children:(r==null?void 0:r.pointer)||(t?"等待 prd-flow 返回状态":"选择 TAPD 需求后读取状态")}),i.jsx("p",{className:"af-prd-workflow__status-subtitle",children:t?i.jsxs(i.Fragment,{children:["TAPD ",i.jsx("strong",{children:t})," · ",e.workflowDemo?"本地只读示例":"独立需求 Workflow"]}):i.jsx(i.Fragment,{children:"尚未选择 TAPD 需求"})}),o?i.jsx("p",{className:"af-prd-workflow-error",children:o}):null,Me||pe.subscribers?i.jsxs("div",{className:"af-prd-workflow-collab",children:[Me?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),Me.title||Me.action||"Workflow action"," 执行中",Me.userId?i.jsx("small",{children:Me.userId}):null]}):null,pe.subscribers?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),pe.subscribers," 个连接"]}):null]}):null]}),i.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:ye=>{ye.preventDefault(),f==null||f()},children:[i.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:He.map(ye=>i.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${ye.status}`,children:[i.jsx("span",{"aria-hidden":"true"}),i.jsx("small",{children:ye.label})]},ye.label))}),i.jsxs("div",{className:"af-prd-workflow__lookup-row",children:[i.jsxs("label",{children:[i.jsx("span",{children:"TAPD Workflow"}),i.jsx("input",{value:t,onChange:ye=>n(ye.target.value),readOnly:e.workflowDemo,placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),i.jsxs("button",{type:"submit",disabled:s,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"hourglass_empty":"sync"}),s?"读取中":t?"刷新":"读取"]}),i.jsxs("button",{type:"button",disabled:!t||e.workflowDemo,onClick:yt,title:e.workflowDemo?"本地示例不可分享":"分享 Workflow",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"share"}),"分享"]})]})]})]}),u?i.jsxs("section",{className:"af-prd-workflow-conflict","aria-label":"Workflow conflict",children:[i.jsxs("div",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"sync_problem"}),i.jsxs("div",{children:[i.jsx("strong",{children:"状态已变化,需要重新确认"}),i.jsx("p",{children:u.message||"当前 workflow 状态和执行前不一致。"})]})]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"执行时 revision"}),i.jsx("dd",{children:u.expectedRevision||"空"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前 revision"}),i.jsx("dd",{children:u.currentRevision||"未知"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"当前状态"}),i.jsx("dd",{children:[q_(u.currentPhase),u.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),i.jsx("div",{className:"af-prd-workflow-conflict__actions",children:i.jsx("button",{type:"button",onClick:()=>f==null?void 0:f(),disabled:s||a,children:"刷新状态"})})]}):null,i.jsxs("section",{className:"af-prd-workflow__main",children:[i.jsxs("article",{className:"af-prd-workflow-actions","aria-label":"Workflow actions",children:[i.jsxs("div",{className:"af-prd-workflow-actions__head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Action 时间线"}),i.jsx("p",{children:te.length?`${de}/${re.length} 已完成${k!=="all"?` · 共 ${te.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),W&&Nm(W)?i.jsxs("div",{className:"af-prd-workflow-local-command",children:[i.jsx("span",{children:"本地 agent 执行"}),i.jsx("code",{children:W.command||co(W,0)})]}):null]}),ne.length?i.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[i.jsxs("button",{type:"button",className:k==="all"?"is-active":"","aria-pressed":k==="all",onClick:()=>x("all"),children:["全部 ",i.jsx("span",{children:te.length})]}),ne.map(ye=>i.jsxs("button",{type:"button",className:k===ye.key?"is-active":"","aria-pressed":k===ye.key,onClick:()=>x(ye.key),children:[ye.label," ",i.jsx("span",{children:ye.count})]},ye.key))]}):null,i.jsx("div",{className:"af-prd-workflow-action-list",children:re.length?se.map(ye=>i.jsxs("section",{className:"af-prd-workflow-action-day",children:[i.jsxs("div",{className:"af-prd-workflow-action-day__label",children:[i.jsx("span",{children:ye.day}),i.jsx("small",{children:"北京时间"})]}),i.jsx("div",{className:"af-prd-workflow-action-day__items",children:ye.items.map(({item:ze,index:oe})=>{const ke=ba(ze.status),Be=ua(ze)==="observation"&&ke==="done"?"observed":ke,Qe=Rv(ze),Ce=OY(ze),Ct=WY(ze),Xt=RY(ze,oe),Ft=TY(ze);return i.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${Be}`,children:[i.jsx("div",{className:"af-prd-workflow-action__rail",children:i.jsx("span",{className:"af-prd-workflow-action__dot"})}),i.jsxs("div",{className:"af-prd-workflow-action__body",children:[i.jsxs("div",{className:"af-prd-workflow-action__top",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-prd-workflow-action__title",children:[Ce?i.jsx("time",{dateTime:jm(ze),children:Ce}):null,i.jsx("strong",{children:Xt})]}),Ft?i.jsx("p",{children:Ft}):null,Ct.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:Ct.map(rt=>i.jsxs("span",{className:`af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--${rt.label==="Issue"?"issue":"platform"}`,title:`${rt.label} · ${rt.value}`,children:[i.jsx("b",{children:rt.label}),i.jsx("span",{className:"af-prd-workflow-action__meta-value",children:rt.value})]},`${rt.label}-${rt.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:FY(ze)})]}),Qe.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Qe.map(rt=>i.jsxs("a",{href:rt.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:rt.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${rt.label}-${rt.href}`))}):null]})]},ze.id||ze.actionId||`${co(ze,oe)}-${oe}`)})})]},ye.day)):i.jsxs("div",{className:"af-prd-workflow-action-empty",children:[i.jsx("strong",{children:t?te.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),i.jsx("p",{children:t?te.length?"切换到其它 tag 或查看全部。":"Workflow tab 不会生成默认步骤;需要 prd-flow snapshot 返回 actions/timeline/events/history 或 nextAction。":"选择后从 prd-flow 读取真实 action、产物和 URL。"})]})})]}),i.jsxs("aside",{className:"af-prd-workflow-side","aria-label":"Workflow related links",children:[i.jsx(NX,{globalState:_e,tapdId:t}),G.length?i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"关联产物"}),i.jsx("span",{children:G.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:G.map((ye,ze)=>{const oe=Ic(ye),ke=String(ye.label||ye.title||ye.kind||oe||`Artifact ${ze+1}`);return oe?i.jsxs("a",{href:oe,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:ke}),i.jsx("small",{children:ye.kind||oe})]},`${oe}-${ze}`):i.jsxs("div",{children:[i.jsx("span",{children:ke}),i.jsx("small",{children:ye.kind||""})]},`${ke}-${ze}`)})})]}):null,i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"AI Docs"}),i.jsx("span",{children:Z.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:Z.length?Z.map(ye=>{const ze=String(ye.title||ye.label||"ai-doc").trim(),oe=[ye.label&&ye.label!==ze?ye.label:"",ye.platform,ye.issueKey].filter(Boolean);return i.jsxs("a",{className:"af-prd-ai-doc",href:ye.href,target:"_blank",rel:"noreferrer",title:ze,children:[i.jsx("span",{className:"af-prd-ai-doc__title",children:ze}),i.jsx("small",{className:"af-prd-ai-doc__meta",children:oe.join(" · ")||ye.kind||"ai-doc"})]},ye.href)}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 ai-doc 文档。"})})]}),i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"Issues"}),i.jsx("span",{children:Q||H.length})]}),i.jsx("div",{className:"af-prd-workflow-issues",children:A.length?A.map(ye=>i.jsxs("div",{className:"af-prd-workflow-epic",children:[i.jsxs("div",{className:"af-prd-workflow-epic__head",children:[i.jsx("strong",{children:ye.title||ye.key}),i.jsx("small",{children:Sb(ye.issues)})]}),ye.issues.map((ze,oe)=>i.jsx(WM,{row:ze,index:oe},$i((ze==null?void 0:ze.issue)||{},oe)))]},ye.key)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 Issue 信息。"})})]}),i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"运行审计"}),i.jsxs("span",{children:[ue.length,"/",ee.length]})]}),i.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([ye,ze])=>i.jsx("button",{type:"button",className:b===ye?"is-active":"",onClick:()=>g(ye),children:ze},ye))}),i.jsx("div",{className:"af-prd-workflow-audit",children:ue.length?ue.map((ye,ze)=>i.jsxs("div",{children:[i.jsx("strong",{children:co(ye,ze)}),i.jsx("small",{children:[ye.status,ye.type,jm(ye)].filter(Boolean).join(" · ")})]},ye.id||`${ye.type}-${ze}`)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),Ne||l?i.jsxs("article",{className:"af-prd-workflow-card af-prd-workflow-card--raw",children:[i.jsx("div",{className:"af-prd-workflow-card__head",children:i.jsx("h2",{children:"Raw"})}),i.jsx("pre",{children:l||Ne})]}):null]})]}),_?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"分享需求 Workflow",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"share"}),"分享需求 Workflow"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>S(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("p",{className:"af-display-link-modal__empty",children:["通过只读链接分享 TAPD ",t," 的需求流程;不会分享当前 Project、画布或项目文件。"]}),N?i.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!N&&$t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",value:$t,readOnly:!0,onFocus:ye=>ye.currentTarget.select(),"aria-label":"Workflow 分享链接"}),i.jsxs("button",{type:"button",disabled:R,onClick:()=>void at(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),M||"复制链接"]}),B.canManage?i.jsx("button",{type:"button",disabled:R,onClick:()=>void kt(),children:R?"处理中...":"取消分享"}):null]}),i.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的人无需登录即可只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!N&&!$t&&D?i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:R,onClick:()=>void Re(),children:R?"生成中...":"生成分享链接"}):null,E?i.jsx("div",{className:"af-flow-snippet-error",children:E}):null]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>S(!1),children:"完成"})})]})}),document.body):null]})}function wC(e,t){if(!(e!=null&&e[`has${t[0].toUpperCase()}${t.slice(1)}`]))return"(删除该字段)";const n=e==null?void 0:e[t];if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Ju(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function CX(e,t,n,r=!0){const s=JSON.parse(JSON.stringify(e||{})),o=Array.isArray(t)?t:[];if(!o.length)return r?n:{};let a=s;for(let c=0;c<o.length-1;c+=1){const u=o[c],p=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(p)?[]:{}),a=a[u]}const l=o[o.length-1];return r?a[l]=n:Array.isArray(a)&&Number.isInteger(l)?a.splice(l,1):delete a[l],s}function AX(){var z0,B0,W0,H0;const{t:e,i18n:t}=Vr(),{navigate:n}=rs(),r=tu(),s=dn(),o=g6(),a=m.useMemo(gY,[]),l=!!a.workflowShare,c=m.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=m.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[p,f]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=y6([]),[k,x]=w6([]),_=m.useRef([]),S=m.useRef([]),N=m.useRef(null),[P,R]=m.useState(()=>Eh(null,[])),z=m.useRef(P),[E,O]=m.useState(null),D=m.useRef(null),L=m.useRef(!1),[M,V]=m.useState([]),B=m.useRef(new Map),F=m.useRef(new Map),$=m.useRef(new Set),H=m.useRef(new Set),A=m.useRef(null),Q=m.useRef(null),K=m.useRef([]),W=m.useRef(null),te=m.useRef(null),Z=m.useRef(null),[G,ne]=m.useState(null),[re,se]=m.useState({}),ee=m.useRef({}),ue=m.useRef(!1),de=m.useRef(null),pe=m.useRef(""),Me=m.useRef(null),Ne=m.useRef(Promise.resolve()),_e=m.useRef({running:!1,pending:null}),He=m.useRef(0),ct=m.useRef(!1),yt=m.useRef(0),Re=m.useRef(null),at=m.useRef(!1),kt=m.useRef(!1),$t=m.useRef(""),ye=m.useRef(!1),ze=m.useRef(null),oe=m.useRef(!1),ke=m.useRef(new Set),Be=m.useRef(!1),Qe=m.useRef(!1),Ce=m.useCallback(()=>XG({nodeInteraction:oe.current,pointerCount:ke.current.size,viewportInteraction:Be.current}),[]),Ct=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),Xt=m.useRef(!1),Ft=m.useRef(null),[rt,Fn]=m.useState([]),ie=m.useRef([]),[Ie,et]=m.useState(""),[qe,Pt]=m.useState("nodes"),[vt,tr]=m.useState([]),[Gn,Tr]=m.useState(!1),[kn,nr]=m.useState(""),[pr,hr]=m.useState(!1),[fn,zn]=m.useState({name:"",id:"",description:""}),[is,Fs]=m.useState(!1),[vn,Yn]=m.useState(""),[ks,Jn]=m.useState(""),Bn=m.useRef(null),[vr,Sr]=m.useState(!1),[Wn,Mr]=m.useState(!1),[$r,ce]=m.useState(""),[me,tt]=m.useState(null),[st,zt]=m.useState(()=>_w()),[Rn,jr]=m.useState(""),[Nr,mr]=m.useState(!1),[ut,Ut]=m.useState(""),[Gt,Xn]=m.useState(!1),[ot,gr]=m.useState([]),[zs,Hi]=m.useState(!1),[Bs,ae]=m.useState(""),[ve,Te]=m.useState(""),[bt,Rt]=m.useState(""),[Qt,pn]=m.useState(!1),[$n,vs]=m.useState(""),[Ss,U]=m.useState(""),[we,$e]=m.useState(!1),[Ae,Ze]=m.useState("nodes"),[wn,Lt]=m.useState(""),[Sn,rr]=m.useState(0),[yr,Zt]=m.useState(""),Xv=m.useRef(""),[gt,js]=m.useState(null),Qv=m.useRef(null),[B$,xl]=m.useState(""),[bl,Zv]=m.useState([]),[eS,W$]=m.useState(""),[Se,H$]=m.useState(!a.adminOwnerId),[Ff,V$]=m.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[Tt,zf]=m.useState(null),[K$,Pg]=m.useState(!1),[Rg,tS]=m.useState(!1),[nS,jo]=m.useState(""),[uu,rS]=m.useState(""),[sS,iS]=m.useState(""),[Ws,q$]=m.useState(null),[Tg,oS]=m.useState("viewer"),[du,aS]=m.useState(!1),[jn,kl]=m.useState(null),[U$,ka]=m.useState(!1),[Mg,vl]=m.useState({}),[Bf,lS]=m.useState(!1),[cS,fu]=m.useState(""),[$g,G$]=m.useState(""),[Y$,Sl]=m.useState(()=>new Set),[Lg,Og]=m.useState(""),[pu,Dg]=m.useState({nodeId:"",query:""}),[uS,dS]=m.useState(!1),Fg=m.useRef(null),fS=m.useRef(null),pS=m.useRef(""),[zg,hS]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[J$,mS]=m.useState(!1),[va,X$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Vi,Q$]=m.useState(""),[Hs,Z$]=m.useState([]),[gS,yS]=m.useState(!1),[Vs,hu]=m.useState([]),[jl,eL]=m.useState([]),[wS,tL]=m.useState(!1),[xS,bS]=m.useState([]),[kS,vS]=m.useState([]),[sr,nL]=m.useState(()=>{try{const w=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return w||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`)||"").trim()}catch{return""}}),[sn,mu]=m.useState(null),[rL,SS]=m.useState(!1),[sL,Nl]=m.useState(""),[Bg,jS]=m.useState(!1),[Wg,gu]=m.useState(""),[Ns,yu]=m.useState(null),[Hg,NS]=m.useState(!1),[wu,_l]=m.useState(null),_S=m.useCallback(w=>{Bn.current&&window.clearTimeout(Bn.current),Jn(w),Bn.current=window.setTimeout(()=>{Jn(""),Bn.current=null},3800)},[]),Kr=m.useCallback(w=>{const j=Array.isArray(w)||w instanceof Set?w:[w];for(const C of j){const I=String(C||"").trim();I&&($.current.add(I),H.current.add(I))}$.current.size!==0&&(A.current==null&&(A.current=window.requestAnimationFrame(()=>{A.current=null;const C=Array.from($.current);$.current.clear(),C.forEach(I=>o(I))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const C=Array.from(H.current);H.current.clear(),C.forEach(I=>o(I))},80))},[o]);m.useEffect(()=>()=>{A.current!=null&&window.cancelAnimationFrame(A.current),Q.current!=null&&window.clearTimeout(Q.current),$.current.clear(),H.current.clear()},[]);const CS=m.useCallback((w,j)=>{const C=String(w||"").trim(),I=Im(j);!C||!I||(g(T=>T.map(q=>{var le;if(q.id!==C)return q;const X=Im((le=q.data)==null?void 0:le.displaySize),J=X&&X.width===I.width&&X.height===I.height,Y=Math.round(Number(q.width||0))===I.width&&Math.round(Number(q.height||0))===I.height;return J&&Y?q:{...q,width:I.width,height:I.height,data:{...q.data,nodeSize:I,displaySize:I}}})),Kr(C))},[Kr,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(zg)))}catch{}},[zg]);const Vg=m.useCallback(w=>{const j=Fg.current;if(!j)return null;const C=j.getBoundingClientRect(),I=16,T=150,q=230,X=C.top+I,J=C.bottom-I,Y=Math.max(T,J-X-q);return Math.min(Math.max(w-X,T),Y)},[]),iL=m.useCallback(w=>{w.preventDefault(),w.stopPropagation();const j=Fg.current;if(!j)return;let C=Vg(w.clientY);if(!Number.isFinite(C))return;mS(!0),hS(C);const I=q=>{q.preventDefault();const X=Vg(q.clientY);Number.isFinite(X)&&(C=X,j.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},T=()=>{hS(C),mS(!1),window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",T,!0),window.removeEventListener("pointercancel",T,!0)};window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",T,!0),window.addEventListener("pointercancel",T,!0)},[Vg]);m.useEffect(()=>()=>{Bn.current&&window.clearTimeout(Bn.current),Ft.current&&window.clearTimeout(Ft.current)},[]);const[oL,AS]=m.useState(()=>new Set),[Wf,Kg]=m.useState(!1),qg=m.useRef(null),ES=m.useRef(null),IS=m.useRef(null),[aL,lL]=m.useState({}),[Sa,Ug]=m.useState(""),[os,PS]=m.useState(!1),[ja,Cl]=m.useState([]),[Ks,Hn]=m.useState([]),[qr,_s]=m.useState("workspace"),[xu,Al]=m.useState(!1),RS=m.useRef(null),Gg=m.useRef(null),[bu,El]=m.useState(null),[cL,Yg]=m.useState(!0),[TS,MS]=m.useState(""),[Na,No]=m.useState({}),[Lr,Jg]=m.useState(null),[$S,Xg]=m.useState(!1),Il=m.useMemo(()=>$S?vY(Lr):"",[$S,Lr]),[ku,Hf]=m.useState(!0);m.useEffect(()=>{Il&&Hf(SY(Il))},[Il]),m.useEffect(()=>{if(Il)try{window.localStorage.setItem(Il,ku?"true":"false")}catch{}},[ku,Il]);const[Qg,Vf]=m.useState(!1),[Zg,LS]=m.useState(!1),[ey,OS]=m.useState("pan"),[DS,uL]=m.useState({}),vu=m.useRef({}),[FS,_a]=m.useState({}),Su=m.useRef(new Map),ju=m.useRef(new Set),[zS,Pl]=m.useState(()=>new Set),[ty,Rl]=m.useState({}),[BS,WS]=m.useState(""),[ode,ge]=m.useState(""),[HS,qs]=m.useState("loading"),[VS,Us]=m.useState("正在载入 Project"),Ki=m.useMemo(()=>kY(a),[a]),[KS,qS]=m.useState(""),Nu=a.flowSource||"user",US=m.useMemo(()=>new Set(Object.values(DS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[DS]),qi=m.useCallback(w=>{const j=vu.current||{},C=typeof w=="function"?w(j):w,I=C&&typeof C=="object"&&!Array.isArray(C)?C:{};return vu.current=I,uL(I),I},[]),GS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(Tt!=null&&Tt.role?Tt.role==="owner":Nu==="user"||Nu==="workspace")),_u=!!(!a.adminOwnerId&&Nu==="workspace"&&(Tt!=null&&Tt.role)&&Tt.role!=="owner"),YS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[HS]||"同步状态",gi=m.useCallback(()=>{!ue.current||!Se||(ye.current=!1,He.current+=1,ct.current=!0,qs("dirty"),Us("本地修改等待同步"))},[Se]);m.useEffect(()=>{a.flowId&&ZF(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const w=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{Cl([]),Hn([]),_s("workspace"),Yg(!0)},[a]);const Nn=m.useCallback(async()=>{const w=Fr(a),j=await fetch(`/api/workspace/files?${w.toString()}`),C=await j.json();if(!j.ok)throw new Error(C.error||"读取 workspace 失败");const I=C.files||[];Zv(I),Sl(new Set(RM(I))),W$(C.root||"")},[a]),Kf=m.useCallback(async()=>{Tr(!0),nr("");try{const w=await fetch("/api/marketplace/flow-snippets"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error(j.error||"读取流程片段失败");tr(Array.isArray(j.snippets)?j.snippets:[])}catch(w){nr(String(w.message||w)),tr([])}finally{Tr(!1)}},[]),JS=m.useCallback(async(w,j,C)=>{var Y,le,he;if(!ue.current)return;if(!Se)throw ge("Readonly workspace"),qs("readonly"),Us("只读 Project"),new Error("Readonly workspace");qs("saving"),Us("正在同步修改");const I=Yl(w,j,ee.current);I.ui={...I.ui||{},displayPage:nC(z.current,w)};const T=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:I,baseRevision:pe.current,baseGraph:Me.current,clientId:Ct.current})}),q=await T.json().catch(()=>({}));if(!T.ok){if(T.status===409||T.status===428){const je=Array.isArray(q.conflictItems)?q.conflictItems:[];kl({currentRevision:String(q.currentRevision||""),message:q.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(q.conflictPaths)?q.conflictPaths:[],conflictItems:je,mergeGraph:q.mergeGraph||null,currentGraph:q.currentGraph||null}),vl(Object.fromEntries(je.map((We,Le)=>[String(Le),{mode:"local",manual:Ju(We)}]))),fu(""),ka(je.length>0),qs("conflict"),Us(q.error||"存在需要处理的字段冲突");const Ve=Array.isArray(q.conflictPaths)?q.conflictPaths:[],Fe=Ve.length?`${q.error||"Workspace 已被其他成员更新"}:${Ve.join("、")}`:q.error||"Workspace 已被其他成员更新",Ke=new Error(Fe);throw Ke.code="WORKSPACE_REVISION_CONFLICT",Ke.currentRevision=q.currentRevision||"",Ke}const fe=new Error(q.error||"保存 workspace graph 失败");throw qs("error"),Us(fe.message),fe}const X=He.current!==C,J=JG({savedGraph:q.graph,sentGraph:I,savedRevision:q.revision,currentRevision:pe.current});if(pe.current=J.revision,Me.current=J.graph,!X){if(ee.current=((Y=q.graph)==null?void 0:Y.instances)||I.instances,se(ee.current),q.merged&&q.graph){const fe=Yu(q.graph,rt),je=Eh((he=(le=q.graph)==null?void 0:le.ui)==null?void 0:he.displayPage,fe.nodes);ee.current=fe.instances,se(fe.instances),g(fe.nodes),x(fe.edges),z.current=je,R(je)}ct.current=!1}return _a(Xp(q.workspaceSchedules||[])),kl(null),ka(!1),qs(X?"dirty":"synced"),Us(X?"本地仍有修改等待同步":"所有修改已同步"),ge(X?"已保存上一版,本地新修改正在排队":q.merged?"Workspace graph merged and saved":"Workspace graph saved"),q},[a,rt,x,g,Se]),en=m.useCallback((w=b,j=k)=>{const C=_e.current,I={nextNodes:w,nextEdges:j,saveEditVersion:He.current,waiters:[]},T=new Promise((J,Y)=>{I.waiters.push({resolve:J,reject:Y})});if(C.running)return C.pending=W_(C.pending,I),T;C.running=!0;const q=async()=>{let J=I;for(;J;){C.pending&&(J=W_(J,C.pending),C.pending=null);try{const Y=await JS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:le})=>le(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(qs("error"),Us(String(Y.message||Y))),J.waiters.forEach(({reject:le})=>le(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&C.pending&&(C.pending.waiters.forEach(({reject:le})=>le(Y)),C.pending=null)}J=C.pending,C.pending=null}C.running=!1},X=Ne.current.catch(()=>{}).then(q);return Ne.current=X,T},[k,b,JS]),dL=m.useCallback(w=>{var C;const j=(C=w==null?void 0:w.extra)!=null&&C.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};ee.current=j,se(j),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),Zt(""),ne(null)},[x,g]),fL=m.useMemo(()=>({instances:re}),[re]),pL=NG({nodes:b,edges:k,extra:fL,enabled:ue.current,onRestore:dL}),{resetHistory:Cu,undo:XS,redo:QS}=pL,Cs=m.useCallback(async(w={})=>{var Oe,Ot;const j=(w==null?void 0:w.background)===!0,C=yt.current+1;yt.current=C;const I=He.current,T=pe.current;j||(ue.current=!1);const q=rY({background:j}),X=Fr(a);let J=null,Y;if(!q.nodes&&!q.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const De=Fr(a);De.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[ft,At]=await Promise.all([fetch(`/api/nodes?${De.toString()}`),fetch(`/api/workspace/graph?${X.toString()}`),Nn()]);if(J=await ft.json(),!ft.ok)throw new Error(J.error||"读取节点定义失败");Y=At}const le=await Y.json();if(!Y.ok)throw new Error(le.error||"读取 workspace graph 失败");const he=YG({background:j,requestId:C,currentRequestId:yt.current,dirty:ct.current,startedEditVersion:I,currentEditVersion:He.current,startedRevision:T,currentRevision:pe.current});if(he==="superseded")return{skipped:!0,reason:he};if(he==="local-edits")return ge("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:he};const fe=j?ie.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(De=>!oY.has(De.id)),fY,dY,cY,uY,aY,lY];j||(ie.current=fe,Fn(fe));const je=le.graph||JSON.parse(localStorage.getItem(iY)||"null")||{},Ve=Yu(je,fe),Fe=Eh((Oe=je==null?void 0:je.ui)==null?void 0:Oe.displayPage,Ve.nodes),Ke=!L.current;let We=D.current;if(Ke){let De=null;try{De=JSON.parse(window.localStorage.getItem(u)||"null")}catch{De=null}We=Pb(De)||Pb((Ot=je==null?void 0:je.ui)==null?void 0:Ot.viewport)}const Le=j?KG(Me.current,je):null;if(j&&(Le!=null&&Le.safe)){const De=Le.nodesChanged?qG(_.current,Ve.nodes,Le.changedNodeIds):_.current,ft=Le.edgesChanged?UG(S.current,Ve.edges):S.current,At=Le.displayPageChanged||!lo(z.current,Fe),Wl=Le.nodesChanged||Le.edgesChanged||At;if(Wl&&(ye.current=!0),Le.nodesChanged){const yi=GG(ee.current,Ve.instances,Le.changedNodeIds);ee.current=yi,_.current=De,se(yi),g(De)}if(Le.edgesChanged&&(S.current=ft,x(ft)),At&&(z.current=Fe,R(Fe)),Wl&&Cu(De,ft,{instances:Le.nodesChanged?ee.current:Ve.instances}),Le.nodesChanged||At){const yi=new Set(Fe.nodeIds);V(Ea=>{const Ia=Ea.filter(lp=>yi.has(lp));return Ia.length===Ea.length?Ea:Ia})}}else ee.current=Ve.instances,_.current=Ve.nodes,S.current=Ve.edges,z.current=Fe,ye.current=!0,se(Ve.instances),g(Ve.nodes),x(Ve.edges),R(Fe),V([]),Cu(Ve.nodes,Ve.edges,{instances:Ve.instances});const Wt=Xp(le.workspaceSchedules||[]);_a(De=>lo(De,Wt)?De:Wt),pe.current=String(le.revision||""),Me.current=je,ct.current=!1;const it=le.collaboration||null;zf(De=>lo(De,it)?De:it),V$(le.adminReview||null),kl(null),Ke&&(O(We),D.current=We,L.current=!0);const Ge=le.writable!==!1;return H$(Ge),ge(Ge?"Workspace ready":"Readonly workspace"),qs(Ge?"synced":"readonly"),Us(Ge?"所有修改已同步":le.adminReview?`管理员只读查看:${le.adminReview.ownerUsername||le.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),ue.current=!0,{skipped:!1}},[a,t.language,Nn,Cu,x,g,u]),Tl=m.useCallback((w={})=>{if(!ue.current)return;const j=String(w.revision||""),C=w.type==="graph.committed",I=!!(Re.current||at.current||kt.current);if(sY({eventType:w.type,revision:j,currentRevision:pe.current,targetRevision:$t.current,refreshPending:I}))return;if(C&&j&&($t.current=j),ct.current){kt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(kt.current=!0,Re.current||at.current)return;const T=async()=>{if(Re.current=null,Ce()){kt.current=!0;return}if(ct.current){kt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}kt.current=!1,at.current=!0;try{await Cs({background:!0}),$t.current=pe.current}catch(q){$t.current="",ge(String(q.message||q))}finally{at.current=!1,kt.current&&!ct.current&&(Re.current=window.setTimeout(T,40))}};Re.current=window.setTimeout(T,40)},[Cs,Ce]),Au=m.useCallback(async(w=sr)=>{const j=String(w||"").trim();SS(!0),Nl("");try{if(a.workflowDemo){const q=yY(j);if(!q)throw new Error("本地示例数据已失效,请返回迭代页重新载入示例");mu(q),gu(""),yu(null),_l(null);return}const C=Fr(a);C.set("tapdId",j),C.set("runtimeOnly","1");const I=await fetch(`/api/prd-workflow/snapshot?${C.toString()}`),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"读取 PRD Workflow 失败");mu(T.snapshot||null),gu(""),yu(null),_l(null);try{const q=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;j?window.localStorage.setItem(q,j):window.localStorage.removeItem(q)}catch{}}catch(C){Nl(String(C.message||C))}finally{SS(!1)}},[a,sr]),Ml=m.useCallback(async(w=null,j={})=>{const C=w&&typeof w=="object"?w:sn==null?void 0:sn.nextAction,I=Nm(C);if(!I||Bg)return;const T=(j==null?void 0:j.confirm)===!0,q=String((j==null?void 0:j.expectedRevision)||(sn==null?void 0:sn.revision)||"");jS(!0),Nl(""),T||(gu(""),yu(null),_l(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:sr,action:I,stage:fl(C),title:co(C,0),...VY(C),dryRun:!T,confirm:T,issueKey:C.issueKey||C.issue_key||"",expectedRevision:q,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw J.snapshot&&mu(J.snapshot),J.conflict&&_l({...J.conflict,action:C}),new Error(J.error||"执行 PRD Workflow action 失败");gu(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),mu(J.snapshot||sn),_l(null),yu(T?null:{action:C,output:J.output||null,expectedRevision:q,at:new Date().toISOString()})}catch(X){Nl(String(X.message||X))}finally{jS(!1)}},[a,Bg,sn,sr]),hL=m.useCallback((w=null)=>Ml(w,{confirm:!1}),[Ml]),mL=m.useCallback(()=>{const w=(Ns==null?void 0:Ns.action)||(sn==null?void 0:sn.nextAction);return Ml(w,{confirm:!0,expectedRevision:(Ns==null?void 0:Ns.expectedRevision)||""})},[Ml,Ns,sn]),gL=m.useCallback(()=>{const w=(wu==null?void 0:wu.action)||(sn==null?void 0:sn.nextAction);return _l(null),Ml(w,{confirm:!1})},[Ml,wu,sn]),yL=m.useCallback(async()=>{var q,X;const w=String(Wg||(sn==null?void 0:sn.rawOutput)||"").trim();if(!w||Hg)return;const j=(Ns==null?void 0:Ns.action)||(sn==null?void 0:sn.nextAction)||{},C=`Review: ${co(j,0)||(sn==null?void 0:sn.pointer)||sr||"PRD Workflow"}`,I=/^[\[{]/.test(w),T=w.startsWith("#")?w:`# ${C}
247
-
248
- ${I?`\`\`\`json
249
- ${w}
250
- \`\`\``:w}`;NS(!0),Nl("");try{const J=await fetch("/api/workflow-artifacts/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,workflow:{namespace:"tapd",id:sr},title:C,markdown:T,action:Nm(j),stage:fl(j),issueKey:j.issueKey||j.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");mu(Y.snapshot||sn);const le=((q=Y.review)==null?void 0:q.shortUrl)||((X=Y.review)==null?void 0:X.url)||"";le&&gu(he=>`${he||w}
251
-
252
- Review link: ${le}`)}catch(J){Nl(String(J.message||J))}finally{NS(!1)}},[a,Wg,Ns,Hg,sn,sr]),wL=m.useCallback(async(w,j)=>{const C={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:j,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",scriptRef:(w==null?void 0:w.scriptRef)||"",implementationRef:(w==null?void 0:w.implementationRef)||"",implementationMode:(w==null?void 0:w.implementationMode)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:a.flowId,flowSource:a.flowSource||"user",archived:!!a.archived},I=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),T=await I.json().catch(()=>({}));if(!I.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||"Publish failed");return await Cs(),ge(`Published node ${T.definitionId||T.id||C.packageId}`),T},[a,Cs]),Ca=m.useCallback((w=Ks)=>{const j=Array.isArray(w)?w:[],I=[...j].reverse().find(T=>(T==null?void 0:T.status)==="running"||(T==null?void 0:T.status)==="stopping")||[...j].reverse().find(T=>T==null?void 0:T.id);return String((I==null?void 0:I.id)||"workspace")},[Ks]),xL=m.useCallback(w=>{const j=String(w||"").trim();!j||j==="workspace"||Hn(C=>{const I=(Array.isArray(C)?C:[]).filter(T=>T.id!==j);return _s(T=>T===j?Ca(I):T),I})},[Ca]);m.useCallback((w="")=>{Al(!0),El(null),js(null),_s(w||Ca())},[Ca]);const ZS=m.useCallback((w={})=>{El({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),Al(!1),js(null),Zt("")},[]),ny=m.useCallback(async(w="")=>{const j=String(w||"").trim();if(!(!j||!Se)){WS(j),ge(`Optimizing run: ${j}`);try{await en(_.current,S.current);const C=Yl(_.current,S.current,ee.current),I=mC(_.current,ee.current,j,Vi),T=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:j,graph:C,model:I})}),q=await T.json().catch(()=>({}));if(!T.ok||q.ok===!1)throw new Error(q.error||"优化失败");const X=q.graph||C,J=Yu(X,rt);ee.current=J.instances,se(J.instances),g(J.nodes),x(J.edges),_a(Xp(q.workspaceSchedules||[])),Cu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(q.optimized)?q.optimized.length:0;ge(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(C){ge(String(C.message||C))}finally{WS("")}}},[Vi,S,a,_,rt,Cu,en,x,g,Se]),e0=m.useCallback(async(w="")=>{const j=String(w||"").trim(),C=vu.current||{},I=Object.entries(C).find(([Y,le])=>Y===j||String((le==null?void 0:le.runNodeId)||"")===j)||Object.entries(C)[0]||null,T=(I==null?void 0:I[0])||"",q=(I==null?void 0:I[1])||null,X=String((q==null?void 0:q.runNodeId)||j||"").trim();if((q==null?void 0:q.status)==="stopping")return;const J=new Set([X,...Array.isArray(q==null?void 0:q.plannedNodeIds)?q.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));T&&qi(Y=>{const le={...Y};return le[T]&&(le[T]={...le[T],status:"stopping"}),le}),ge(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Hn(Y=>Y.map(le=>(T?le.id===T:!X||le.runNodeId===X)&&le.status==="running"?{...le,status:"stopping"}:le));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:T,runNodeId:X})}),le=await Y.json().catch(()=>({}));if(!Y.ok||(le==null?void 0:le.stopped)!==!0)throw new Error(le.error||"Workspace run stop failed");const he=T?Su.current.get(T):null;he&&(he.abort(),Su.current.delete(T)),T&&qi(fe=>{const je={...fe};return delete je[T],je}),Pl(fe=>{const je=new Set(fe);for(const Ve of J)je.delete(Ve);return je}),Rl(fe=>{var Ve;const je={...fe};for(const Fe of J)Fe&&(!je[Fe]||((Ve=je[Fe])==null?void 0:Ve.status)==="running")&&(je[Fe]={status:"stopped"});return je}),ge(X?`Workspace run stopped: ${X}`:"Workspace run stopped"),Hn(fe=>fe.map(je=>(T?je.id===T:!X||je.runNodeId===X)?{...je,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(je.messages)?je.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:je))}catch(Y){T&&qi(he=>{const fe={...he};return fe[T]&&(fe[T]={...fe[T],status:"running"}),fe});const le=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ge(`停止失败:${le}`),Hn(he=>he.map(fe=>(T?fe.id===T:!X||fe.runNodeId===X)?{...fe,status:"running",messages:[...Array.isArray(fe.messages)?fe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${le}`,at:Date.now()}].slice(-160)}:fe))}},[a,qi]),qf=m.useCallback(async()=>{if(a.flowId)try{const w=Fr(a),j=await fetch(`/api/workspace/run/status?${w.toString()}`),C=await j.json().catch(()=>({}));if(!j.ok||!C.running)return;const I=Array.isArray(C.runs)&&C.runs.length?C.runs:[{runId:`run-restored-${C.startedAt||Date.now()}`,runNodeId:C.runNodeId||"",startedAt:C.startedAt||Date.now(),plannedNodeIds:[]}],T={},q=[];for(const X of I){const J=String((X==null?void 0:X.runNodeId)||"").trim(),Y=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const le=String((X==null?void 0:X.label)||"").trim()||vw(_.current,ee.current,J,"Workspace Run");T[Y]={id:Y,runNodeId:J,label:le,status:(X==null?void 0:X.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(X==null?void 0:X.plannedNodeIds)?X.plannedNodeIds:[],startedAt:(X==null?void 0:X.startedAt)||Date.now()},J&&q.push(J)}if(!Object.keys(T).length)return;qi(X=>({...X,...T})),Pl(X=>{const J=new Set(X);for(const Y of q)J.add(Y);return J}),Rl(X=>{const J={...X};for(const Y of q)J[Y]={status:"running"};return J}),ge(q.length?`Workspace run still running: ${q.join(", ")}`:"Workspace run still running"),Hn(X=>{const J=[...X];for(const[Y,le]of Object.entries(T)){if(J.some(je=>je.id===Y||["running","stopping"].includes(je.status)&&je.runNodeId===le.runNodeId))continue;const he=String(le.runNodeId||""),fe=String(le.label||"").trim()||vw(_.current,ee.current,he,"Workspace Run");J.push({id:Y,label:Sw(fe,he,"Workspace Run"),alias:fe,runNodeId:he,status:le.status,startedAt:le.startedAt||Date.now(),steps:he?[{id:he,label:Sw(fe,he,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:le.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[a,_,qi]),t0=m.useCallback(async w=>{if(!Se){ge("Readonly workspace");return}if(!w)return;if(Object.values(vu.current||{}).find(it=>String((it==null?void 0:it.runNodeId)||"")===String(w||""))){ge(`Workspace run already running: ${w}`);return}let C=_.current,I=S.current,T=ee.current;const q=Qv.current;if(q!=null&&q.id){const it=C.find(Oe=>Oe.id===q.id),Ge=yC({nodes:C,edges:I,instances:T,selectedNode:it,draft:q,allowRename:!1});if(Ge!=null&&Ge.error){xl(Ge.error),ge(Ge.error);return}Ge!=null&&Ge.ok&&Ge.changed&&(C=Ge.nodes,I=Ge.edges,T=Ge.instances,ee.current=T,_.current=C,S.current=I,se(T),g(C),x(I),Kr(Ge.nextId||q.id))}const X=Yl(C,I,T),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=vw(C,T,w,"Workspace Run"),le=Sw(Y,w,"Workspace Run");let he=[w];try{const it=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:X,runNodeId:w})}),Ge=await it.json().catch(()=>({}));if(!it.ok||(Ge==null?void 0:Ge.ok)===!1)throw new Error(Ge.error||"Workspace run plan failed");he=Array.isArray(Ge.plannedNodeIds)&&Ge.plannedNodeIds.length?Ge.plannedNodeIds.map(Ot=>String(Ot||"").trim()).filter(Boolean):[w],he=Array.from(new Set([w,...he].filter(Boolean)));const Oe=Ge.conflict||null;if(Oe!=null&&Oe.runNodeId||Oe!=null&&Oe.runId){const Ot=Array.isArray(Oe.conflictNodeIds)&&Oe.conflictNodeIds.length?`: ${Oe.conflictNodeIds.join(", ")}`:"";ge(`Run ${w} conflicts with running ${Oe.runNodeId||Oe.runId}${Ot}`);return}}catch(it){ge(String(it.message||it));return}const fe=new Set(he),je=Object.values(vu.current||{}).find(it=>(Array.isArray(it==null?void 0:it.plannedNodeIds)?it.plannedNodeIds:[]).some(Ge=>fe.has(String(Ge||"").trim())));if(je){const it=(Array.isArray(je.plannedNodeIds)?je.plannedNodeIds:[]).map(Ge=>String(Ge||"").trim()).filter(Ge=>Ge&&fe.has(Ge));ge(`Run ${w} conflicts with running ${je.runNodeId||"workspace run"}${it.length?`: ${it.join(", ")}`:""}`);return}const Ve=new AbortController;Su.current.set(J,Ve),ju.current.delete(J),qi(it=>({...it,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:he,startedAt:Date.now()}})),Pl(it=>new Set([...it,w])),Rl(it=>({...it,[w]:{status:"running"}})),ge(`Running ${le}...`),_s(J),Hn(it=>[...it.slice(-7),{id:J,label:le,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let Fe=w;const Ke=new Map,We=()=>ju.current.has(J),Le=it=>{const Ge=new Set((it||[]).map(Oe=>String(Oe||"").trim()).filter(Boolean));Ge.size||Ge.add(String(w||"")),Pl(Oe=>{const Ot=new Set(Oe);for(const De of Ge)Ot.delete(De);return Ot})},Wt=(it,Ge)=>{const Oe=new Set((it||[]).map(Ot=>String(Ot||"").trim()).filter(Boolean));Oe.size||Oe.add(String(w||"")),Rl(Ot=>{var ft;const De={...Ot};for(const At of Oe)At&&(!De[At]||((ft=De[At])==null?void 0:ft.status)==="running")&&(De[At]={status:Ge});return De})};try{await en(C,I);const it=mC(C,T,w,Vi),Ge=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:Ve.signal,body:JSON.stringify({...a,graph:X,runNodeId:w,runAlias:Y,runSessionId:J,expectedRevision:pe.current,clientId:Ct.current,model:it,selectedSkills:Vs,stream:!0})});if(!Ge.ok){const xe=await Ge.json().catch(()=>({}));throw new Error(xe.error||"Workspace run failed")}if(!Ge.body)throw new Error("Workspace run stream unavailable");const Oe=Ge.body.getReader(),Ot=new TextDecoder;let De="",ft=[],At=[];const Wl=(xe,nt)=>{var lt,_t;const Ye=b.find(Bt=>Bt.id===xe),ht=String(((lt=Ye==null?void 0:Ye.data)==null?void 0:lt.label)||xe||"").trim(),be=String(nt||((_t=Ye==null?void 0:Ye.data)==null?void 0:_t.definitionId)||"").trim();return be&&be!==ht?`${ht} (${be})`:ht},yi=(xe,nt,Ye)=>{const ht=String(xe||"").trim();ht&&Hn(be=>be.map(lt=>{if(lt.id!==J)return lt;const Bt=[...Array.isArray(lt.steps)?lt.steps:[]],mt=Bt.findIndex(an=>an.id===ht),St={id:ht,label:Wl(ht,nt),status:Ye};mt>=0?Bt[mt]={...Bt[mt],...St}:Bt.push(St);const on=Bt.map((an,Eo)=>{const Yi=an.status==="done"?"[done]":an.status==="failed"?"[failed]":"[running]";return`${Eo+1}. ${Yi} ${an.label}`}).join(`
253
- `),Yt=Array.isArray(lt.messages)?lt.messages:[],nn=Yt.findIndex(an=>an.kind==="run-summary"),hn={role:"assistant",kind:"run-summary",text:on||"准备运行...",at:Date.now()},Ht=[...Yt];return nn>=0?Ht[nn]=hn:Ht.unshift(hn),{...lt,steps:Bt,messages:Ht.slice(-160)}}))},Ea=(xe,nt)=>{var G0,Y0,J0,X0,Q0,Z0,ej,tj,nj,rj;const Ye=String(xe||"").trim(),ht=String(nt||"").trim();if(!Ye||!ht)return;const be=(G0=ee.current)==null?void 0:G0[Ye];if(!ui(be==null?void 0:be.definitionId))return;const lt=fa(be==null?void 0:be.input,"displayType","markdown"),_t=OM(lt),Bt=DM(Ye),mt=rt.find(Or=>Or.id===_t),St=dC(mt==null?void 0:mt.inputs,_t,ht),on=dC(mt==null?void 0:mt.outputs,_t,ht),Yt=String((be==null?void 0:be.label)||Ye||"一键任务").trim(),nn={...ee.current||{},[Ye]:{...be||{},output:pC(be==null?void 0:be.output)},[Bt]:{...((Y0=ee.current)==null?void 0:Y0[Bt])||{},definitionId:_t,label:Yt,role:"normal",body:ht,input:St,output:on,sourceContextRunNodeId:Ye,displayReloadKey:String(Date.now())}};ee.current=nn,se(nn);const hn=_.current||[],Ht=hn.find(Or=>Or.id===Ye),an=hn.find(Or=>Or.id===Bt),Eo=Number(((J0=Ht==null?void 0:Ht.measured)==null?void 0:J0.width)||(Ht==null?void 0:Ht.width)||((Q0=(X0=Ht==null?void 0:Ht.data)==null?void 0:X0.nodeSize)==null?void 0:Q0.width)||520),Yi=(an==null?void 0:an.position)||{x:Number(((Z0=Ht==null?void 0:Ht.position)==null?void 0:Z0.x)||0)+Eo+120,y:Number(((ej=Ht==null?void 0:Ht.position)==null?void 0:ej.y)||0)},or=((tj=an==null?void 0:an.data)==null?void 0:tj.displaySize)||((nj=an==null?void 0:an.data)==null?void 0:nj.nodeSize)||{width:Nb,height:_b},wi=vb({id:Bt,type:Ec,position:Yi,width:Number(or.width)||Nb,height:Number(or.height)||_b,data:{label:Yt,definitionId:_t,role:"normal",body:ht,inputs:St,outputs:on,sourceContextRunNodeId:Ye,displayReloadKey:nn[Bt].displayReloadKey,nodeSize:or,displaySize:or}},nn,rt),Io=hn.map(Or=>{if(Or.id===Ye){const{width:ade,height:lde,measured:cde,...b2}=Or,{nodeSize:ude,displaySize:dde,...pp}=Or.data||{};return{...b2,data:{...pp,outputs:pC(pp==null?void 0:pp.outputs),contextRunResultNonce:Date.now()}}}return Or.id===Bt?{...wi,selected:Or.selected}:Or});an||Io.push(wi),_.current=Io,g(Io);const Po=S.current||[],fp=FM(_t),yy=fC((be==null?void 0:be.output)||((rj=Ht==null?void 0:Ht.data)==null?void 0:rj.outputs),"output",["content","result"],["text"]),w2=fC(St,"input",[fp,"content"],["text"]),x2={id:`we-${Ye}-${Bt}`,source:Ye,target:Bt,sourceHandle:yy,targetHandle:w2,markerEnd:{type:Ai.ArrowClosed}},U0=[...Po.filter(Or=>!(Or.source===Ye&&Or.target===Bt)),x2];S.current=U0,x(U0),window.requestAnimationFrame(()=>{o(Ye),o(Bt)})},Ia=(xe,nt=null)=>{const Ye=xe!=null&&xe.instances&&typeof xe.instances=="object"?xe.instances:{},ht=nt instanceof Set?nt:null;for(const[be,lt]of Object.entries(Ye)){if(ht&&!ht.has(be)||!ui(lt==null?void 0:lt.definitionId))continue;const _t=Sg({outputs:lt.output});_t&&Ea(be,_t)}},lp=xe=>{const nt=String(xe||"").trim();if(!nt)return;const Ye=Fe;Fe=nt,Pl(ht=>{const be=new Set(ht);return Ye&&Ye!==nt&&Ye!==w&&be.delete(Ye),w&&be.add(w),be.add(nt),be}),Rl(ht=>{var be;return{...ht,...Ye&&Ye!==nt&&Ye!==w&&((be=ht[Ye])==null?void 0:be.status)==="running"?{[Ye]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},V0=xe=>{const nt=String(xe||"").trim();nt&&(Pl(Ye=>{const ht=new Set(Ye);return ht.delete(nt),ht}),Rl(Ye=>({...Ye,[nt]:{status:"success"}})))},K0=(xe,nt)=>{const Ye=String(nt||"");if(!Ye.trim())return;const ht=["assistant","thinking","result","error","prompt"].includes(xe)?xe:"assistant";Hn(be=>be.map(lt=>{if(lt.id!==J)return lt;let _t=Array.isArray(lt.messages)?lt.messages:[];if(ht==="result"){const St=[..._t].reverse().find(on=>on.kind==="assistant");if(String((St==null?void 0:St.text)||"").trim()===Ye.trim())return lt}if(ht==="assistant"){const St=_t.findIndex(on=>on.kind==="result"&&String(on.text||"").trim()===Ye.trim());St>=0&&(_t=_t.filter((on,Yt)=>Yt!==St))}const Bt=[..._t],mt=Bt[Bt.length-1];return mt&&mt.kind===ht&&!mt.error?Bt[Bt.length-1]={...mt,text:`${mt.text||""}${mt.text?`
254
- `:""}${Ye}`}:Bt.push({role:"assistant",kind:ht,text:Ye,...ht==="error"?{error:!0}:{},at:Date.now()}),{...lt,messages:Bt.slice(-160)}}))},cp=xe=>{const nt=String(xe||"");nt.trim()&&Hn(Ye=>Ye.map(ht=>{var Bt;if(ht.id!==J)return ht;const be=Array.isArray(ht.messages)?ht.messages:[],lt=be.findIndex(mt=>mt.kind==="thinking"),_t=[...be];if(lt>=0){const mt=String(((Bt=_t[lt])==null?void 0:Bt.text)||"");_t[lt]={..._t[lt],text:`${mt}${mt&&!mt.endsWith(`
255
- `),""}${nt}`,at:Date.now()}}else{const mt=_t.findIndex(St=>St.kind==="activity");_t.splice(mt>=0?mt+1:_t.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...ht,messages:_t.slice(-160)}}))},Ao=(xe,nt=null)=>{const Ye=_Y(xe);Ye&&Hn(ht=>ht.map(be=>{if(be.id!==J)return be;const lt=Number(nt==null?void 0:nt.ts)||Date.now(),_t=Number(be.startedAt)||lt,Bt=Number(be.lastActivityAt)||_t,mt=Math.max(0,lt-Bt),St=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,lt-_t),on=Array.isArray(be.activities)?be.activities:[],Yt=on[on.length-1],hn=(typeof Yt=="string"?Yt:String((Yt==null?void 0:Yt.text)||""))===Ye?on:[...on,{text:Ye,kind:AY(Ye),stepMs:mt,totalMs:St,at:lt}].slice(-30),Ht=Array.isArray(be.timingEntries)?be.timingEntries:[],an=Array.isArray(be.messages)?be.messages:[],Eo=an.findIndex(wi=>wi.kind==="activity"),Yi={role:"assistant",kind:"activity",text:G_(hn,Ht,_t,lt),at:Date.now()},or=[...an];if(Eo>=0)or[Eo]=Yi;else{const wi=or.findIndex(Io=>Io.kind==="run-summary");or.splice(wi>=0?wi+1:0,0,Yi)}return{...be,activities:hn,lastActivityAt:lt,messages:or.slice(-160)}}))},q0=xe=>{const nt=String((xe==null?void 0:xe.source)||"runner"),Ye=String((xe==null?void 0:xe.stream)||""),ht=String((xe==null?void 0:xe.eventType)||"event"),be=String((xe==null?void 0:xe.text)||"").trim();if(!be)return;const lt=`[${nt}${Ye?`:${Ye}`:""}] ${ht}
256
- ${be}`,_t=oJ(xe);Hn(Bt=>Bt.map(mt=>{if(mt.id!==J)return mt;const on=[...Array.isArray(mt.rawTrace)?mt.rawTrace:[],lt].slice(-80),Yt=Array.isArray(mt.timingEntries)?mt.timingEntries:[],nn=_t?[...Yt,_t].slice(-80):Yt,hn=Array.isArray(mt.activities)?mt.activities:[],Ht=Number(mt.startedAt)||Number(xe==null?void 0:xe.ts)||Date.now(),an=Number(_t==null?void 0:_t.at)||Number(xe==null?void 0:xe.ts)||Date.now(),Eo=Array.isArray(mt.messages)?mt.messages:[],Yi={role:"assistant",kind:"raw",text:on.join(`
257
-
258
- ---
259
-
260
- `),at:Date.now()},or=[...Eo],wi=or.findIndex(Po=>Po.kind==="activity");if(_t){const Po={role:"assistant",kind:"activity",text:G_(hn,nn,Ht,an),at:Date.now()};if(wi>=0)or[wi]=Po;else{const fp=or.findIndex(yy=>yy.kind==="run-summary");or.splice(fp>=0?fp+1:0,0,Po)}}const Io=or.findIndex(Po=>Po.kind==="raw");return Io>=0?or[Io]=Yi:or.push(Yi),{...mt,rawTrace:on,timingEntries:nn,messages:or.slice(-160)}}))},y2=xe=>{Hn(nt=>nt.map(Ye=>Ye.id===J?{...Ye,status:xe,endedAt:Date.now()}:Ye))},up=xe=>{const nt=new Set,Ye=String((xe==null?void 0:xe.nodeId)||"").trim();Ye&&nt.add(Ye);for(const ht of Array.isArray(xe==null?void 0:xe.displayNodeIds)?xe.displayNodeIds:[]){const be=String(ht||"").trim();be&&nt.add(be)}for(const ht of Array.isArray(xe==null?void 0:xe.touchedNodeIds)?xe.touchedNodeIds:[]){const be=String(ht||"").trim();be&&nt.add(be)}if(nt.size===0)for(const ht of Array.isArray(xe==null?void 0:xe.order)?xe.order:[]){const be=String(ht||"").trim();be&&nt.add(be)}return nt},dp=(xe,nt=null)=>{const Ye=Yu(xe||X,rt),ht=new Map(Ye.nodes.map(mt=>[mt.id,mt])),be=Ye.instances||{},lt=nt instanceof Set?nt:null,_t=(mt,St)=>{const on={...mt||St};Array.isArray(St==null?void 0:St.output)&&(on.output=St.output);for(const Yt of["scriptRef","implementationRef","implementationMode"])(St==null?void 0:St[Yt])!=null&&String(St[Yt]).trim()!==""&&(on[Yt]=St[Yt]);return on},Bt=(mt,St)=>{const on={...mt||{}};Array.isArray(St==null?void 0:St.outputs)&&(on.outputs=St.outputs);for(const Yt of["scriptRef","implementationRef","implementationMode"])(St==null?void 0:St[Yt])!=null&&String(St[Yt]).trim()!==""&&(on[Yt]=St[Yt]);return on};g(mt=>{const St=new Set(mt.map(nn=>nn.id)),Yt={...Yl(mt,S.current,ee.current).instances||{}};for(const[nn,hn]of Object.entries(be)){if(lt&&!lt.has(nn)||!St.has(nn))continue;const Ht=Yt[nn];pl((hn==null?void 0:hn.definitionId)||(Ht==null?void 0:Ht.definitionId))?Yt[nn]=hn:Array.isArray(hn==null?void 0:hn.output)&&(Yt[nn]=_t(Ht,hn))}return ee.current=Yt,se(Yt),mt.map(nn=>{var Ht,an;if(lt&&!lt.has(nn.id))return nn;const hn=ht.get(nn.id);return hn?pl(((Ht=hn.data)==null?void 0:Ht.definitionId)||((an=nn.data)==null?void 0:an.definitionId))?{...nn,data:{...nn.data,...hn.data}}:{...nn,data:Bt(nn.data,hn.data)}:nn})})};for(;;){const{value:xe,done:nt}=await Oe.read();if(nt)break;De+=Ot.decode(xe,{stream:!0});const Ye=De.split(`
261
- `);De=Ye.pop()||"";for(const ht of Ye){if(!ht.trim())continue;const be=JSON.parse(ht);if(be.type==="error")throw new Error(be.error||"Workspace run failed");if(be.type==="stopped"){ju.current.add(J),ft=Array.isArray(be.order)?be.order:ft,Ao("运行停止",be);continue}if(be.type==="node-start"&&(ge(`Running ${be.nodeId}...`),lp(be.nodeId),yi(be.nodeId,be.definitionId,"running")),be.type==="node-done"){const lt=Ke.get(String(be.nodeId||"").trim());lt&&Ea(be.nodeId,lt),V0(be.nodeId),yi(be.nodeId,be.definitionId,"done")}if(be.type==="status"&&Ao(be.line||be.message||"",be),be.type==="paused"&&(At=Array.isArray(be.nodeIds)?be.nodeIds:[],Ao("运行暂停",be)),be.type==="natural"&&((be.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(be.text||"")))&&be.nodeId&&Ke.set(String(be.nodeId||"").trim(),String(be.text||"")),be.kind==="thinking"?cp(be.text||""):K0(be.kind,be.text||"")),be.type==="raw"){const lt=Y_(be);lt&&cp(lt),q0(be)}if(be.type==="graph"&&be.graph){const lt=up(be);dp(be.graph,lt),Ia(be.graph,lt)}if(be.type==="done"){if(be.revision&&(pe.current=String(be.revision)),be.graph){Me.current=be.graph;const lt=up(be);dp(be.graph,lt),Ia(be.graph,lt)}ft=Array.isArray(be.order)?be.order:[],At=Array.isArray(be.pauseNodeIds)?be.pauseNodeIds:At,Ao(At.length?"运行暂停":"运行完成",be)}}}if(De.trim()){const xe=JSON.parse(De);if(xe.type==="error")throw new Error(xe.error||"Workspace run failed");if(xe.type==="stopped"&&(ju.current.add(J),Ao("运行停止",xe)),xe.type==="node-start"&&(ge(`Running ${xe.nodeId}...`),lp(xe.nodeId),yi(xe.nodeId,xe.definitionId,"running")),xe.type==="node-done"){const nt=Ke.get(String(xe.nodeId||"").trim());nt&&Ea(xe.nodeId,nt),V0(xe.nodeId),yi(xe.nodeId,xe.definitionId,"done")}if(xe.type==="status"&&Ao(xe.line||xe.message||"",xe),xe.type==="paused"&&(At=Array.isArray(xe.nodeIds)?xe.nodeIds:[],Ao("运行暂停",xe)),xe.type==="natural"&&((xe.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(xe.text||"")))&&xe.nodeId&&Ke.set(String(xe.nodeId||"").trim(),String(xe.text||"")),xe.kind==="thinking"?cp(xe.text||""):K0(xe.kind,xe.text||"")),xe.type==="raw"){const nt=Y_(xe);nt&&cp(nt),q0(xe)}if(xe.type==="graph"&&xe.graph){const nt=up(xe);dp(xe.graph,nt),Ia(xe.graph,nt)}if(xe.type==="done"){if(xe.revision&&(pe.current=String(xe.revision)),xe.graph){Me.current=xe.graph;const nt=up(xe);dp(xe.graph,nt),Ia(xe.graph,nt)}ft=Array.isArray(xe.order)?xe.order:[],At=Array.isArray(xe.pauseNodeIds)?xe.pauseNodeIds:At,Ao(At.length?"运行暂停":"运行完成",xe)}}We()&&(Le(he),Wt(he,"stopped"));const gy=We()?`Workspace run stopped: ${w}`:At.length?`Workspace run paused at ${At.join(", ")}`:`Workspace run done: ${ft.length?ft.join(" -> "):w}`;if(ge(gy),We()||Wt(he,At.length?"paused":"success"),y2(We()?"stopped":At.length?"paused":"done"),!We()){try{await en(_.current,S.current),ge(gy)}catch(xe){ge(`${gy},但保存结果失败:${String(xe.message||xe)}`)}await Nn()}}catch(it){if(We()||(it==null?void 0:it.name)==="AbortError"){Le(he),Wt(he,"stopped"),ge(`Workspace run stopped: ${w}`),Hn(Ge=>Ge.map(Oe=>Oe.id===J?{...Oe,status:"stopped",endedAt:Date.now()}:Oe));return}Le(he),Wt([w,Fe].filter(Boolean),"failed"),ge(String(it.message||it)),Hn(Ge=>Ge.map(Oe=>Oe.id===J?{...Oe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Oe.messages)?Oe.messages:[],{role:"assistant",error:!0,text:String(it.message||it),at:Date.now()}].slice(-160)}:Oe))}finally{Su.current.get(J)===Ve&&Su.current.delete(J),qi(it=>{const Ge={...it};return delete Ge[J],Ge}),ju.current.delete(J),Le(he)}},[Vi,k,a,Nn,b,rt,Kr,en,Vs,x,g,qi,o,Se]),Uf=m.useCallback(async()=>{try{const j=await(await fetch("/api/skills")).json().catch(()=>({})),C=Array.isArray(j.skills)?j.skills.map(I=>({key:String(I.key),name:String(I.name||I.id||I.key),description:I.description?String(I.description):"",sourceLabel:I.sourceLabel?String(I.sourceLabel):""})):[];Z$(C),yS(!0)}catch{yS(!0)}},[]),Gf=m.useCallback(async()=>{try{const j=await(await fetch("/api/mcps")).json().catch(()=>({})),C=Array.isArray(j.servers)?j.servers.map(I=>({name:String((I==null?void 0:I.name)||""),type:String((I==null?void 0:I.type)||""),url:String((I==null?void 0:I.url)||""),command:String((I==null?void 0:I.command)||""),args:Array.isArray(I==null?void 0:I.args)?I.args.map(String):[],description:String((I==null?void 0:I.description)||"")})).filter(I=>I.name):[];bS(C)}catch{bS([])}},[]),Yf=m.useCallback(async()=>{try{const w=Fr(a),C=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),I=Array.isArray(C.workspaces)?C.workspaces.map(T=>({id:String((T==null?void 0:T.id)||""),label:String((T==null?void 0:T.label)||(T==null?void 0:T.name)||"知识库"),path:String((T==null?void 0:T.path)||""),kind:(T==null?void 0:T.kind)==="git"?"git":"local",repoUrl:String((T==null?void 0:T.repoUrl)||""),branch:String((T==null?void 0:T.branch)||""),mountPath:String((T==null?void 0:T.mountPath)||""),type:String((T==null?void 0:T.type)||""),builtin:(T==null?void 0:T.builtin)===!0,exists:(T==null?void 0:T.exists)!==!1})).filter(T=>T.path):[];vS(I)}catch{vS([])}},[a]),n0=m.useCallback(async()=>{Xt.current=!1;try{const w=Fr(a),j=await fetch(`/api/workspace/conversations?${w.toString()}`),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||`HTTP ${j.status}`);const I=V_(C.conversations||{});Cl(I.composer.messages),Hn(I.composer.runSessions),_s(I.composer.activeSessionId||"workspace"),No(I.nodeChats)}catch{Cl([]),Hn([]),_s("workspace"),No({})}finally{Xt.current=!0}},[a]),r0=m.useCallback(async()=>{if(!Se||a.archived)return;const w=V_({composer:{activeSessionId:qr,messages:ja,runSessions:Ks},nodeChats:Na});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async j=>{if(!j.ok){const C=await j.json().catch(()=>({}));throw new Error(C.error||`HTTP ${j.status}`)}})},[qr,ja,Ks,a,Na,Se]);m.useEffect(()=>{let w=!1;return l?(Jg(null),Xg(!0),()=>{w=!0}):((async()=>{const C=new URL(window.location.href),I=String(C.searchParams.get("invite")||"").trim();if(I){ge("正在加入共享 Workspace...");const T=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:I})}),q=await T.json().catch(()=>({}));if(!T.ok)throw new Error(q.error||"加入共享 Workspace 失败");C.searchParams.delete("invite"),window.history.replaceState({},"",`${C.pathname}${C.search}${C.hash}`)}w||(await Cs(),w||await n0())})().catch(C=>{const I=String(C.message||C);ge(I),qs("error"),Us(I)}),Kf(),fetch("/api/model-lists").then(C=>C.json()).then(C=>X$({cursor:Array.isArray(C.cursor)?C.cursor.map(String):[],opencode:Array.isArray(C.opencode)?C.opencode.map(String):[],claudeCode:Array.isArray(C.claudeCode)?C.claudeCode.map(String):[],codex:Array.isArray(C.codex)?C.codex.map(String):[]})).catch(()=>{}),Uf(),Gf(),Yf(),qf(),fetch("/api/skill-collections").then(C=>C.json()).then(C=>{eL(Ya(C)),tL(!0)}).catch(()=>{}),fetch("/api/auth/me").then(C=>C.json()).then(C=>{Jg(C.user||null),Xg(!0)}).catch(()=>{Jg(null),Xg(!0)}),()=>{w=!0})},[l,Cs,n0,Kf,Gf,Uf,qf,Yf,Ki]),m.useEffect(()=>{if(qS(""),!(!gS||!wS)){if(!Ki){hu([]);return}hu(dz(Ki,"workspace",Hs,jl)),qS(Ki)}},[jl,wS,Hs,gS,Ki]),m.useEffect(()=>{if(!(KS!==Ki||!Ki))try{localStorage.setItem(Ki,JSON.stringify(Vs))}catch{}},[Vs,Ki,KS]),m.useEffect(()=>{ee.current=re},[re]),m.useEffect(()=>{_.current=b},[b]),m.useEffect(()=>{if(oe.current)return;const w=B.current,j=new Map,C=[];for(const I of b){const T=xM(I);j.set(I.id,T),w.get(I.id)!==T&&C.push(I.id)}B.current=j,C.length!==0&&Kr(C)},[b,Kr]),m.useEffect(()=>{S.current=k},[k]),m.useEffect(()=>{z.current=P},[P]),m.useEffect(()=>{D.current=E},[E]),m.useEffect(()=>{Qv.current=gt},[gt]),m.useEffect(()=>{Xv.current=yr},[yr]),m.useEffect(()=>{Z.current=G},[G]),m.useEffect(()=>{if(!G)return;const w=C=>{C.key==="Escape"&&ne(null)},j=C=>{var I,T;(T=(I=C.target)==null?void 0:I.closest)!=null&&T.call(I,".af-connect-node-menu")||ne(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",j)}},[G]),m.useEffect(()=>{if(!ue.current||!Se)return;if(oe.current){de.current&&window.clearTimeout(de.current);return}const w=ze.current;if(ze.current=null,(w==null?void 0:w.nodes)===b&&w.edges===k&&w.displayPage===P)return;if(ye.current){ye.current=!1;return}gi(),de.current&&window.clearTimeout(de.current);const j=Qe.current?0:650;return Qe.current=!1,de.current=window.setTimeout(()=>{en().catch(C=>ge(String(C.message||C)))},j),()=>{de.current&&window.clearTimeout(de.current)}},[b,k,P,gi,en,Se]),m.useEffect(()=>{if(Xt.current&&!(!Se||a.archived))return Ft.current&&window.clearTimeout(Ft.current),Ft.current=window.setTimeout(()=>{r0().catch(w=>ge(String(w.message||w)))},900),()=>{Ft.current&&window.clearTimeout(Ft.current)}},[qr,ja,Ks,a.archived,Na,r0,Se]);const Eu=m.useMemo(()=>b.filter(w=>{var j;return((j=w==null?void 0:w.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"}).map(w=>{var j;return{id:w.id,config:$v(((j=w.data)==null?void 0:j.body)||"")}}),[b]),bL=m.useMemo(()=>Eu.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[Eu]);m.useEffect(()=>{if(!ue.current||p!=="workspace"||!a.flowId){_a({});return}if(!Eu.length){_a({});return}let w=!1;const j=async()=>{try{const I=Fr(a),T=await fetch(`/api/workspace/schedules?${I.toString()}`),q=await T.json().catch(()=>({}));if(!T.ok)throw new Error(q.error||"读取 Workspace 定时状态失败");w||_a(Xp(q.schedules||[]))}catch{w||_a(I=>{var q;const T={};for(const X of Eu)T[X.id]={...I[X.id]||{},lastStatus:((q=I[X.id])==null?void 0:q.lastStatus)||"unknown"};return T})}};j();const C=window.setInterval(j,5e3);return()=>{w=!0,window.clearInterval(C)}},[a,Eu,bL,p]);const s0=m.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const C=uC(j),I=Y=>Array.isArray(Y)?Y.map(le=>(le==null?void 0:le.name)!=="skillKeys"&&(le==null?void 0:le.name)!=="skillsContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:C,value:C}):[],T=b.map(Y=>{var le;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:I((le=Y.data)==null?void 0:le.inputs)}}}),q=ee.current||{},X=q[w]&&typeof q[w]=="object"?q[w]:{},J={...q,[w]:{...X,body:C,input:I(X.input)}};ee.current=J,g(T),se(J),js(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:I(Y.inputs)}),en(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,en,g,Se]),i0=m.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const C=mX(j),I=Y=>Array.isArray(Y)?Y.map(le=>(le==null?void 0:le.name)!=="serverNames"&&(le==null?void 0:le.name)!=="mcpContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:C,value:C}):[],T=b.map(Y=>{var le;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:I((le=Y.data)==null?void 0:le.inputs)}}}),q=ee.current||{},X=q[w]&&typeof q[w]=="object"?q[w]:{},J={...q,[w]:{...X,body:C,input:I(X.input)}};ee.current=J,g(T),se(J),js(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:I(Y.inputs)}),en(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,en,g,Se]),o0=m.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const C=(Array.isArray(j)?j:j?[j]:[]).filter(Fe=>String((Fe==null?void 0:Fe.path)||"").trim()),I=C[0]||null,T=String((I==null?void 0:I.path)||"").trim(),q=C.length===1?String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim():C.length?`${C.length} 个知识库`:"",X=C.length?JSON.stringify(jg(C)):"",J=I?JSON.stringify({version:1,id:(I==null?void 0:I.id)||"",label:String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim(),kind:(I==null?void 0:I.kind)||"local",cwd:T,workspaceRoot:T,repoUrl:(I==null?void 0:I.repoUrl)||"",branch:(I==null?void 0:I.branch)||"",mountPath:(I==null?void 0:I.mountPath)||"",type:(I==null?void 0:I.type)||""}):"",Y=Fe=>Array.isArray(Fe)?Fe.map(Ke=>(Ke==null?void 0:Ke.name)==="path"?{...Ke,default:T,value:T}:(Ke==null?void 0:Ke.name)==="label"?{...Ke,default:q,value:q}:(Ke==null?void 0:Ke.name)==="knowledgeContext"?{...Ke,default:X,value:X}:(Ke==null?void 0:Ke.name)==="workspaceContext"?{...Ke,default:J,value:J}:(Ke==null?void 0:Ke.name)==="mode"?{...Ke,default:"set",value:"set"}:Ke):[],le=Fe=>Array.isArray(Fe)?Fe.map(Ke=>(Ke==null?void 0:Ke.name)==="knowledgeContext"?{...Ke,default:X,value:X}:(Ke==null?void 0:Ke.name)==="workspaceContext"?{...Ke,default:J,value:J,showOnNode:!1}:(Ke==null?void 0:Ke.name)==="cwd"?{...Ke,default:T,value:T,showOnNode:!1}:Ke):[],he=b.map(Fe=>{var Ke,We,Le;return Fe.id===w?{...Fe,data:{...Fe.data,label:((Ke=Fe.data)==null?void 0:Ke.label)||"加载知识库",inputs:Y((We=Fe.data)==null?void 0:We.inputs),outputs:le((Le=Fe.data)==null?void 0:Le.outputs)}}:Fe}),fe=ee.current||{},je=fe[w]&&typeof fe[w]=="object"?fe[w]:{},Ve={...fe,[w]:{...je,label:je.label||"加载知识库",input:Y(je.input),output:le(je.output)}};ee.current=Ve,g(he),se(Ve),js(Fe=>(Fe==null?void 0:Fe.id)===w?{...Fe,inputs:Y(Fe.inputs),outputs:le(Fe.outputs)}:Fe),en(he,k).catch(Fe=>ge(String(Fe.message||Fe)))},[k,b,en,g,Se]),a0=m.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const C=String(w||"");if(!C)return;const I=uC((j==null?void 0:j.skillKeys)||[]),T=Tf((j==null?void 0:j.displayType)||"markdown"),q=String((j==null?void 0:j.model)||"").trim(),X=(j==null?void 0:j.includeWorkspaceContext)===!1?"false":"true",J=j!=null&&j.workspaceContext&&typeof j.workspaceContext=="object"?JSON.stringify(j.workspaceContext):"",Y=j!=null&&j.knowledgeContext&&typeof j.knowledgeContext=="object"?JSON.stringify(j.knowledgeContext):"",le=We=>Array.isArray(We)?We.map(Le=>(Le==null?void 0:Le.name)==="skillKeys"?{...Le,default:I,value:I}:(Le==null?void 0:Le.name)==="displayType"?{...Le,default:T,value:T}:(Le==null?void 0:Le.name)==="includeWorkspaceContext"?{...Le,default:X,value:X}:(Le==null?void 0:Le.name)==="knowledgeContext"?{...Le,default:Y,value:Y}:(Le==null?void 0:Le.name)==="workspaceContext"?{...Le,default:J,value:J}:Le):[],he=We=>Array.isArray(We)?We.map(Le=>(Le==null?void 0:Le.name)==="displayType"?{...Le,default:T,value:T}:Le):[],fe=String((j==null?void 0:j.task)??""),je=b.map(We=>{var Le,Wt;return We.id===C?{...We,data:{...We.data,body:fe,model:q,inputs:le((Le=We.data)==null?void 0:Le.inputs),outputs:he((Wt=We.data)==null?void 0:Wt.outputs)}}:We}),Ve=ee.current||{},Fe=Ve[C]&&typeof Ve[C]=="object"?Ve[C]:{},Ke={...Ve,[C]:{...Fe,body:fe,model:q,input:le(Fe.input),output:he(Fe.output)}};ee.current=Ke,g(je),se(Ke),js(We=>(We==null?void 0:We.id)===C?{...We,body:fe,model:q,inputs:le(We.inputs),outputs:he(We.outputs)}:We),en(je,k).catch(We=>ge(String(We.message||We)))},[k,b,en,g,Se]),l0=m.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const C=gJ(j),I=b.map(J=>J.id===w?{...J,data:{...J.data,body:C}}:J),T=ee.current||{},q=T[w]&&typeof T[w]=="object"?T[w]:{},X={...T,[w]:{...q,body:C}};ee.current=X,ye.current=!0,g(I),se(X),js(J=>(J==null?void 0:J.id)===w?{...J,body:C}:J),en(I,k).catch(J=>ge(String(J.message||J)))},[k,b,en,g,Se]),c0=m.useCallback(w=>{const j=String(w||"").trim();j&&(MS(C=>C===j?"":j),No(C=>({...C,[j]:C[j]||{sessionId:`nodechat_${Date.now()}_${j.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),u0=m.useCallback(()=>MS(""),[]),d0=m.useCallback((w,j)=>{const C=String(w||"").trim();C&&No(I=>({...I,[C]:{...I[C]||{sessionId:`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(j||""),error:""}}))},[]),Gs=m.useCallback((w,j,C="replace",I={})=>{var it,Ge;if(!Se){ge("Readonly workspace");return}const T=String(w||"").trim();if(!T)return;const q=_.current.find(Oe=>Oe.id===T),X=Cn(q==null?void 0:q.data),J=ui((it=q==null?void 0:q.data)==null?void 0:it.definitionId),Y=Li(j),le=X==="html"?su(Y):X==="react"?vg(Y):String(Y||""),he=q?uo(q.data):"",fe=C==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
262
-
263
- ${le.trim()}`:le,je=X==="image"?"src":"content",Ve=I!=null&&I.reloadDisplay?Date.now():(Ge=q==null?void 0:q.data)==null?void 0:Ge.displayReloadKey,Fe=Oe=>{let Ot=!1;return(Array.isArray(Oe)?Oe:[]).map(ft=>{const At=String((ft==null?void 0:ft.name)||""),Wl=String((ft==null?void 0:ft.type)||"");return(J?At===je||At==="result"||At==="filePath":At===je||At==="filePath"||Wl==="text")?Ot?{...ft,default:"",value:""}:(Ot=!0,{...ft,default:fe,value:fe}):ft})},Ke=_.current.map(Oe=>{var Ot,De;return Oe.id!==T?Oe:{...Oe,data:{...Oe.data,body:J?Oe.data.body:fe,...Ve?{displayReloadKey:Ve}:{},inputs:Fe((Ot=Oe.data)==null?void 0:Ot.inputs),outputs:Fe((De=Oe.data)==null?void 0:De.outputs)}}}),We=ee.current||{},Le=We[T]&&typeof We[T]=="object"?We[T]:{},Wt={...We,[T]:{...Le,body:J?Le.body:fe,input:Fe(Le.input),output:Fe(Le.output)}};ee.current=Wt,g(Ke),se(Wt),js(Oe=>(Oe==null?void 0:Oe.id)===T?{...Oe,...J?{}:{body:fe}}:Oe),(I==null?void 0:I.logChat)!==!1&&No(Oe=>{var Ot;return{...Oe,[T]:{...Oe[T]||{},candidateContent:"",messages:[...(Ot=Oe[T])!=null&&Ot.messages&&Array.isArray(Oe[T].messages)?Oe[T].messages:[],{role:"assistant",text:C==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),en(Ke,S.current).catch(Oe=>ge(String(Oe.message||Oe))),ge(String((I==null?void 0:I.statusMessage)||"")||(C==="append"?"已追加节点内容":"已替换节点内容"))},[en,g,Se]),Jf=m.useCallback(async(w,j="")=>{if(!Se)return ge("Readonly workspace"),"";if(!w)return"";try{const C=new FormData;C.set("file",w),C.set("dir",String(j||"")),a.flowId&&C.set("flowId",a.flowId),a.flowSource&&C.set("flowSource",a.flowSource),a.adminOwnerId&&C.set("adminOwnerId",a.adminOwnerId),a.archived&&C.set("archived","1");const I=await fetch("/api/workspace/upload",{method:"POST",body:C}),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"上传文件失败");const q=String(T.path||"").trim();if(!q)throw new Error("上传文件失败:未返回路径");return await Nn(),Sl(X=>{const J=new Set(X);for(const Y of Zp(q))J.delete(Y);return J}),ge(`已上传 ${q}`),q}catch(C){return ge(String(C.message||C)),""}},[a,Nn,Se]),Xf=m.useCallback(async w=>Sm(w)?Jf(w,"img"):(ge("请选择图片文件"),""),[Jf]),f0=m.useCallback((w="")=>{var j;if(!Se){ge("Readonly workspace");return}pS.current=String(w||""),(j=fS.current)==null||j.click()},[Se]),kL=m.useCallback(async w=>{const j=Array.from(w.target.files||[]);if(w.target.value="",!j.length)return;const C=pS.current||"";dS(!0);try{let I="";for(const T of j){const q=await Jf(T,C);q&&(I=q)}j.length>1&&ge(`已上传 ${j.length} 个文件${I?`,最后一个:${I}`:""}`)}catch(I){ge(String(I.message||I))}finally{dS(!1)}},[Jf]),p0=m.useCallback(async(w,j)=>{const C=String(w||"").trim();if(!C)return;const I=await Xf(j);I&&Gs(C,I,"replace",{logChat:!1,statusMessage:`已上传图片 ${I}`})},[Gs,Xf]),h0=m.useCallback(async(w,j=void 0)=>{var Fe,Ke;if(!Se){ge("Readonly workspace");return}const C=String(w||"").trim();if(!C)return;const I=Na[C]||{},T=String(j!==void 0?j:I.draft||"").trim();if(!T||I.running)return;const q=_.current.find(We=>We.id===C);if(!q)return;const X=Cn(q.data)||"markdown",J=uo(q.data);let Y=da(J,X),le=Li(J);if(Y)try{le=await hl(a,Y)}catch(We){ge(String(We.message||We))}else if(X!=="image"&&String(le||"").trim()){const We=Ka(X,le);if(We){ge(`${We} 未进入微调。`);return}try{const Le=await Tb(a,lC(C,q.data),le);await Nn(),Gs(C,Le,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Le}`}),Y=Le,le=""}catch(Le){ge(String(Le.message||Le));return}}const he=TJ(C,_.current,S.current),fe={role:"user",text:T,at:Date.now()},je=Array.isArray(I.messages)?I.messages:[],Ve=I.sessionId||`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`;No(We=>({...We,[C]:{...I,sessionId:Ve,messages:[...je,fe],draft:"",running:!0,error:""}}));try{const We=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:Ve,node:{id:C,label:((Fe=q.data)==null?void 0:Fe.label)||C,definitionId:((Ke=q.data)==null?void 0:Ke.definitionId)||""},nodeKind:X,currentContent:Y?"":le,sourceContext:he,targetFilePath:Y,messages:je,message:T,model:Vi})}),Le=await We.json().catch(()=>({}));if(!We.ok)throw new Error(Le.error||"节点微调失败");const Wt=String(Le.candidateContent||Le.reply||"").trim(),it=!!Le.directFileEdit,Ge=String(Le.artifactPath||Y||"").trim();if(it&&Ge){const Oe=Ka(X,Wt);if(Oe)throw new Error(`${Oe} 文件已由 agent 修改,请检查 ${Ge}。`);await Nn(),Gs(C,Ge,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ge}`})}else if(Wt){const Oe=Ka(X,Wt);if(Oe)throw new Error(`${Oe} 已取消写入,避免覆盖当前展示文件。`);if(Y){const Ot=await Tb(a,Y,Wt);await Nn(),Gs(C,Ot,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ot}`})}else Gs(C,Wt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}No(Oe=>{var Ot;return{...Oe,[C]:{...Oe[C]||{},sessionId:String(Le.sessionId||Ve),running:!1,candidateContent:"",messages:[...(Ot=Oe[C])!=null&&Ot.messages&&Array.isArray(Oe[C].messages)?Oe[C].messages:[...je,fe],{role:"assistant",text:Wt||it?Ge?`已更新文件 ${Ge}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(We){const Le=String(We.message||We);No(Wt=>({...Wt,[C]:{...Wt[C]||{},running:!1,error:Le}})),ge(Le)}},[Vi,a,Nn,Na,Gs,Se]),m0=m.useCallback(async(w,j)=>{if(!Se){ge("Readonly workspace");return}const C=Cn(j)||"markdown",I=uo(j),T=da(I,C);let q=Li(I);if(T)try{q=await hl(a,T)}catch(le){ge(String(le.message||le));return}if(!String(q||"").trim()){ge("展示节点没有可保存内容");return}const X=Ka(C,q);if(X){ge(`${X} 未保存文件。`);return}const J=lC(w,j),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const le=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:q})}),he=await le.json().catch(()=>({}));if(!le.ok)throw new Error(he.error||"保存文件失败");const fe=he.path||Y,je=Fr(a);je.set("path",fe);const Ve=await fetch(`/api/workspace/file?${je.toString()}`);if(!Ve.ok){const Fe=await Ve.json().catch(()=>({}));throw new Error(Fe.error||`保存后读取失败:${fe}`)}await Nn(),Zv(Fe=>oX(Fe,fe,String(q||"").length)),Sl(Fe=>{const Ke=new Set(Fe);for(const We of Zp(fe))Ke.delete(We);return Ke}),Gs(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ge(`已保存 ${fe}`)}catch(le){ge(String(le.message||le))}},[a,Nn,Gs,Se]),g0=m.useCallback(w=>{var T,q;const j=String(w||"").trim();if(!j||Rn)return;const C=_.current.find(X=>X.id===j);if(!C||!Cn(C==null?void 0:C.data)){ge("展示节点不可用");return}const I=String(((T=C.data)==null?void 0:T.label)||((q=C.data)==null?void 0:q.displayName)||j).trim()||"AgentFlow Display";zt(_w({title:I,layout:"single",nodeIds:[j],mode:"single-node",sourceNodeId:j})),ce(""),tt(null),Sr(!0)},[Rn]),Qf=m.useCallback((w,j)=>{const C=String(w||"");C&&js(I=>{if(!I||I.id!==C)return I;const T=typeof j=="function"?j(I):j;return!T||typeof T!="object"?I:{...I,...T}})},[]),y0=m.useCallback((w,j)=>{const C=String(w||"");!C||!Se||(g(I=>I.map(T=>{var X;if(T.id!==C)return T;const q=Array.isArray((X=T.data)==null?void 0:X.outputs)&&T.data.outputs.length?T.data.outputs.map((J,Y)=>Y===0?{...J,default:j,value:j}:J):[{type:"file",name:"value",default:j,value:j}];return{...T,data:{...T.data,body:"",outputs:q}}})),Qf(C,I=>({body:"",outputs:Array.isArray(I==null?void 0:I.outputs)&&I.outputs.length?I.outputs.map((q,X)=>X===0?{...q,default:j,value:j}:q):[{type:"file",name:"value",default:j,value:j}]})),ge(`已选择文件 ${j}`))},[g,Qf,Se]),w0=m.useCallback(w=>{Dg({nodeId:String(w||""),query:""})},[]),ry=m.useCallback(()=>{Dg({nodeId:"",query:""})},[]),vL=m.useCallback(w=>{const j=String((w==null?void 0:w.path)||"").trim();!j||!pu.nodeId||(y0(pu.nodeId,j),ry())},[ry,pu.nodeId,y0]),x0=m.useCallback(async(w,j)=>{if(!Se)return;const C=YJ(w,j);if(C.length===0)return;const I=[];try{for(const T of C){const q=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:T})});if(q.status===404)continue;const X=await q.json().catch(()=>({}));if(!q.ok)throw new Error(X.error||"清理节点输出失败");I.push(X.path||T)}if(I.length===0)return;ge(`已清理 ${I.join(", ")}`),await Nn(),Og(T=>C.some(q=>T===q||T.startsWith(`${q}/`))?"":T)}catch(T){ge(String(T.message||T))}},[a,Nn,Se]),Iu=m.useMemo(()=>({modelLists:va,showBodyPreview:!0,flowParams:a,readOnly:!Se,onRunWorkspaceNode:t0,onStopWorkspaceNode:e0,onOpenWorkspaceRunLogs:ZS,onOptimizeWorkspaceRun:ny,onOptimizeWorkspaceSchedule:ny,runningRunNodeIds:US,onChangeScheduledRunConfig:l0,onChangeContextRunConfig:a0,skills:Hs,skillCollections:jl,onChangeLoadSkillKeys:s0,onRefreshSkills:Uf,mcpServers:xS,onChangeLoadMcpNames:i0,onRefreshMcps:Gf,workspaceTargets:kS,onChangeLoadWorkspace:o0,onRefreshWorkspaces:Yf,onSaveDisplayNodeToFile:m0,onShareDisplayNode:g0,onOpenDisplayPreview:U,onRefreshNodeInternals:Kr,onEnsureWorkspaceNodeDisplaySize:CS,sharingDisplayNodeId:Rn,onUploadWorkspaceImage:Xf,onUploadImageToDisplayNode:p0,onOpenProvideFilePicker:w0,onStatus:ge,onSetDisplayNodeContent:Gs,onToggleNodeChat:c0,onCloseNodeChat:u0,onUpdateNodeChatDraft:d0,onSendNodeChat:h0,onSyncNodePropDraft:Qf,onCleanupWorkspaceNodeOutputs:x0}),[a0,i0,s0,o0,l0,x0,u0,CS,a,xS,va,w0,ZS,ny,Gf,Kr,Uf,Yf,t0,US,m0,h0,Gs,g0,Rn,jl,Hs,e0,Qf,c0,d0,p0,Xf,kS,Se]),SL=m.useRef(new Map),as=m.useMemo(()=>{const w=SL.current,j=new Set,C=b.map(I=>{var Y,le,he;const T={selected:I.selected===!0,isExecuting:zS.has(I.id),nodeStatus:((Y=ty[I.id])==null?void 0:Y.status)??null,nodeElapsed:((le=ty[I.id])==null?void 0:le.elapsed)??null,optimizingRun:BS===I.id,scheduledRunState:FS[I.id]||null,nodeChatActive:TS===I.id,nodeChat:Na[I.id]||null},q=w.get(I.id);if(q&&q.source===I&&q.commonData===Iu&&eC(q.runtime,T))return j.add(I.id),q.node;const X=!!(q&&((he=q.source)==null?void 0:he.data)===I.data&&q.commonData===Iu&&eC(q.runtime,T)),J={...I,data:X?q.node.data:{...I.data,...Iu,...T}};return w.set(I.id,{source:I,commonData:Iu,runtime:T,node:J}),j.add(I.id),J});for(const I of w.keys())j.has(I)||w.delete(I);return C},[TS,Iu,Na,b,BS,FS,zS,ty]),dt=p==="display",_n=p==="workflow",b0=m.useMemo(()=>dt?new Map(as.map(w=>[w.id,w])):vJ,[as,dt]),k0=m.useMemo(()=>Ss&&as.find(w=>w.id===Ss)||null,[Ss,as]),v0=m.useRef(new Map),Pu=m.useMemo(()=>{if(!dt)return v0.current.clear(),SJ;const w=new Set(M),j=v0.current,C=new Set,I=P.nodeIds.map((T,q)=>{var Ve,Fe,Ke,We;const X=b0.get(T);if(!X||!Cn(X.data))return null;const J=ec(X)||{width:520,height:320},Y=Qa(P.nodeSizes[T]||J,{display:!0})||J,le=P.nodePositions[T]||{x:180+q*36,y:120+q*28},he=w.has(T),fe=j.get(T);if(fe&&fe.source===X&&((Ve=fe.position)==null?void 0:Ve.x)===le.x&&((Fe=fe.position)==null?void 0:Fe.y)===le.y&&((Ke=fe.size)==null?void 0:Ke.width)===Y.width&&((We=fe.size)==null?void 0:We.height)===Y.height&&fe.selected===he)return C.add(T),fe.node;const je={...X,id:tC(T),position:le,selected:he,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:T,displayPageMode:!0,readOnly:!0,selected:he,displaySize:Y,nodeSize:Y}};return j.set(T,{source:X,position:le,size:Y,selected:he,node:je}),C.add(T),je}).filter(Boolean);for(const T of j.keys())C.has(T)||j.delete(T);return I},[P,b0,dt,M]),$l=m.useMemo(()=>as.filter(w=>Cn(w==null?void 0:w.data)),[as]);m.useEffect(()=>{if(!dt||!P.viewport)return;const w=P.viewport,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(C)},[P.viewport,dt,r]),m.useEffect(()=>{if(dt||_n||!E)return;const w=E,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(C)},[dt,_n,r,E]),m.useEffect(()=>{_n&&Au(sr)},[_n]),m.useEffect(()=>{if(!_n||!sr||a.workflowDemo)return;const w=Fr(a);w.set("tapdId",sr);let j=null,C=null,I=!1;const T=()=>{C&&(window.clearTimeout(C),C=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},q=()=>{I||document.hidden||j||(j=new EventSource(`/api/prd-workflow/events?${w.toString()}`),j.onmessage=()=>{Au(sr)},j.onerror=()=>{T(),!I&&!document.hidden&&(C=window.setTimeout(q,5e3))})},X=()=>{if(document.hidden){T();return}Au(sr),q()};return q(),document.addEventListener("visibilitychange",X),()=>{I=!0,document.removeEventListener("visibilitychange",X),T()}},[a,_n,Au,sr]),m.useEffect(()=>{if(!a.flowId||_n)return;const w=Fr(a);w.set("clientId",Ct.current);let j=null,C=null,I=!1;const T=()=>{C&&(window.clearTimeout(C),C=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},q=()=>{I||document.hidden||j||(j=new EventSource(`/api/workspace/events?${w.toString()}`),j.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===Ct.current)){if(Y.type==="graph.committed"){Tl(Y);return}if(Y.type==="runtime.committed"){Tl(Y);return}if(String(Y.type||"").startsWith("file.")){Nn();return}String(Y.type||"").startsWith("run.")&&qf()}},j.onerror=()=>{T(),!I&&!document.hidden&&(C=window.setTimeout(q,5e3))})},X=()=>{if(document.hidden){T();return}Tl({type:"visibility.resume"}),q()};return q(),document.addEventListener("visibilitychange",X),()=>{I=!0,document.removeEventListener("visibilitychange",X),T(),Re.current&&(window.clearTimeout(Re.current),Re.current=null),kt.current=!1}},[a,_n,Nn,qf,Tl]),m.useEffect(()=>{if(oe.current)return;const w=F.current,j=new Map,C=[];for(const I of[...as,...Pu]){const T=kJ(I);j.set(I.id,T),w.get(I.id)!==T&&C.push(I.id)}F.current=j,C.length!==0&&Kr(C)},[Pu,as,Kr]);const Kt=m.useMemo(()=>b.find(w=>w.id===yr)||null,[b,yr]),sy=m.useRef({id:"",draft:null}),jL=m.useMemo(()=>{const w=hC(Kt);return w?JSON.stringify(w):""},[Kt==null?void 0:Kt.data,Kt==null?void 0:Kt.id]);m.useEffect(()=>{if(!Kt){sy.current={id:"",draft:null},js(null),xl("");return}const w=hC(Kt),j=sy.current;sy.current={id:Kt.id,draft:w},js(C=>!C||C.id!==Kt.id||j.id!==Kt.id||!j.draft?w:xX(C,j.draft,w)),xl("")},[Kt==null?void 0:Kt.id,jL]);const iy=m.useCallback((w=!1)=>{if(!gt||!Kt)return!1;if(!Se)return xl("Readonly workspace"),ge("Readonly workspace"),!1;xl("");const j=yC({nodes:b,edges:k,instances:ee.current,selectedNode:Kt,draft:gt,allowRename:w});return j!=null&&j.error?(xl(j.error),!1):(!(j!=null&&j.ok)||!j.changed||(ee.current=j.instances,se(j.instances),g(j.nodes),x(j.edges),j.nextId!==Kt.id&&Zt(j.nextId),Kr(j.nextId)),!0)},[k,gt,b,Kt,x,g,Kr,Se]);m.useEffect(()=>{if(!Se||!gt||!Kt)return;const w=window.setTimeout(()=>{iy(!1)},350);return()=>window.clearTimeout(w)},[gt==null?void 0:gt.label,gt==null?void 0:gt.role,gt==null?void 0:gt.model,gt==null?void 0:gt.body,JSON.stringify((gt==null?void 0:gt.images)||[]),gt==null?void 0:gt.script,gt==null?void 0:gt.scriptRef,gt==null?void 0:gt.implementationRef,gt==null?void 0:gt.implementationMode,JSON.stringify((gt==null?void 0:gt.inputs)||[]),JSON.stringify((gt==null?void 0:gt.outputs)||[]),iy,Kt==null?void 0:Kt.id,Se]);const S0=m.useRef({refs:new Map,nodeDataById:new Map}),oy=m.useMemo(()=>{const w=S0.current;let j=w.refs.size!==b.length;const C=new Map;for(const T of b)C.set(T.id,T.data),(!w.refs.has(T.id)||w.refs.get(T.id)!==T.data)&&(j=!0);if(!j)return w.nodeDataById;const I=new Map(b.map(T=>[T.id,T.data]));return S0.current={refs:C,nodeDataById:I},I},[b]),NL=m.useMemo(()=>k.map(w=>{var Y,le;const j=oy.get(w.source),C=oy.get(w.target),I=/^output-(\d+)$/.exec(w.sourceHandle||""),T=/^input-(\d+)$/.exec(w.targetHandle||""),q=j&&I?(Y=j.outputs)==null?void 0:Y[parseInt(I[1],10)]:null,X=C&&T?(le=C.inputs)==null?void 0:le[parseInt(T[1],10)]:null,J=q!=null&&q.type?En(q.type):X!=null&&X.type?En(X.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:Ai.ArrowClosed,color:J}}:w}),[oy,k]),Zf=dt?Pu:as,_L=dt?[]:NL,j0=m.useRef(Zf),Ll=m.useRef([]);oe.current||(j0.current=Zf);const CL=m.useMemo(()=>dt?Pu.map(w=>({...w,id:Qp(w.id)})):as,[Pu,as,dt]),ay=m.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const C=dt?tC(j):j;dt?V([j]):(g(T=>T.map(q=>({...q,selected:q.id===C}))),x(T=>T.map(q=>({...q,selected:!1}))),Zt(C));const I=()=>{var le,he,fe;const T=r.getNode(C);if(!T)return;const q=(le=r.getInternalNode)==null?void 0:le.call(r,C),X=((he=q==null?void 0:q.measured)==null?void 0:he.width)??(q==null?void 0:q.width)??T.width??260,J=((fe=q==null?void 0:q.measured)==null?void 0:fe.height)??(q==null?void 0:q.height)??T.height??120,{zoom:Y}=r.getViewport();r.setCenter(T.position.x+X/2,T.position.y+J/2,{zoom:EJ(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(I))},[dt,r,x,g]);m.useEffect(()=>{const w=String(c.current||"").trim();!w||!ue.current||p!=="workspace"||as.some(j=>j.id===w)&&(c.current="",ye.current=!0,ay(w))},[as,ay,p]);const N0=m.useCallback(()=>{const w=r.getViewport(),j={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(dt){const C={...z.current,viewport:j};z.current=C,R(C),ge("已固定 Display 进入视角")}else{D.current=j,O(j);try{window.localStorage.setItem(u,JSON.stringify(j))}catch{}ge("已固定 Workspace 进入视角");return}en(_.current,S.current).catch(C=>ge(String(C.message||C)))},[dt,r,en,u]),ly=m.useMemo(()=>{const w=Ie.trim().toLowerCase(),j={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const C of rt)w&&![C.id,C.label,C.displayName,C.description].some(I=>String(I||"").toLowerCase().includes(w))||j[ad(C)].push(C);for(const C of Ql)j[C].sort((I,T)=>I.id.localeCompare(T.id));return j},[rt,Ie]),Ru=m.useMemo(()=>{const w=wn.trim().toLowerCase();return rt.filter(j=>!w||[j.id,j.label,j.displayName,j.description].some(C=>String(C||"").toLowerCase().includes(w))).sort((j,C)=>{const I=Ql.indexOf(ad(j)),T=Ql.indexOf(ad(C));return I!==T?I-T:ld(j).localeCompare(ld(C))}).slice(0,30)},[rt,wn]),Tu=m.useMemo(()=>{const w=wn.trim().toLowerCase();return vt.filter(j=>!w||[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].some(C=>String(C||"").toLowerCase().includes(w))).sort((j,C)=>String(j.displayName||j.name||j.id).localeCompare(String(C.displayName||C.name||C.id))).slice(0,30)},[vt,wn]);m.useEffect(()=>{rr(0)},[wn,we,Ae]),m.useEffect(()=>{if(!we)return;const w=window.setTimeout(()=>{var j;return(j=IS.current)==null?void 0:j.focus()},0);return()=>window.clearTimeout(w)},[we]);const AL=m.useMemo(()=>{const w=$g.trim().toLowerCase();return w?Lv(bl).filter(j=>j.path.toLowerCase().includes(w)):bl},[$g,bl]),Aa=m.useMemo(()=>PM(bl,Lg),[bl,Lg]),Ui=(Aa==null?void 0:Aa.type)==="directory"?Aa.path:nX((Aa==null?void 0:Aa.path)||""),EL=m.useCallback(w=>{var j,C;(C=(j=w.target)==null?void 0:j.closest)!=null&&C.call(j,".af-work-file")||Og("")},[]),IL=[...(va.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(va.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(va.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(va.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],cy=m.useMemo(()=>new Set(Vs),[Vs]),Ol=m.useMemo(()=>{const w=new Map(Hs.map(q=>[q.key,q])),j=new Set,C=new Set,I=jl.map(q=>{const X=ca(q,Hs).map(J=>w.get(J)).filter(Boolean);for(const J of X)j.add(J.key),C.add(String(J.name||J.id||J.key||"").trim());return{...q,skills:X}}).filter(q=>q.skills.length>0),T=Hs.filter(q=>{const X=String(q.name||q.id||q.key||"").trim();return!j.has(q.key)&&!C.has(X)});return{groups:I,ungrouped:T}},[jl,Hs]);m.useEffect(()=>{AS(w=>{let j=!1;const C=new Set(w);for(const I of Ol.groups)C.has(I.id)||(C.add(I.id),j=!0);return j?C:w})},[Ol.groups]);const Qn=m.useMemo(()=>{const w=b.filter(j=>j.selected);return w.length>0?w:yr?b.filter(j=>j.id===yr):[]},[b,yr]),ep=m.useMemo(()=>Qn.map(w=>w.id),[Qn]),_0=m.useCallback(()=>{if(dt)return;if(!Se){ge("Readonly workspace");return}const w=(_.current||[]).filter(J=>(J==null?void 0:J.selected)&&!Am(J));if(w.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const j=w.reduce((J,Y)=>{var Ve,Fe,Ke,We,Le,Wt,it,Ge,Oe,Ot,De,ft;const le=Number(((Ve=Y.position)==null?void 0:Ve.x)||0),he=Number(((Fe=Y.position)==null?void 0:Fe.y)||0),fe=Number(((Ke=Y.measured)==null?void 0:Ke.width)||Y.width||((Le=(We=Y.data)==null?void 0:We.nodeSize)==null?void 0:Le.width)||((it=(Wt=Y.data)==null?void 0:Wt.displaySize)==null?void 0:it.width)||iM),je=Number(((Ge=Y.measured)==null?void 0:Ge.height)||Y.height||((Ot=(Oe=Y.data)==null?void 0:Oe.nodeSize)==null?void 0:Ot.height)||((ft=(De=Y.data)==null?void 0:De.displaySize)==null?void 0:ft.height)||vm);return{minX:Math.min(J.minX,le),minY:Math.min(J.minY,he),maxX:Math.max(J.maxX,le+fe),maxY:Math.max(J.maxY,he+je)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(j.minX)||!Number.isFinite(j.minY))return;const C=new Set((_.current||[]).map(J=>J.id));let I=1,T=`group_${I}`;for(;C.has(T);)I+=1,T=`group_${I}`;const q=Ib({width:j.maxX-j.minX+Yp*2,height:j.maxY-j.minY+Yp*2})||{width:ul,height:dl},X={id:T,type:Ec,position:{x:j.minX-Yp,y:j.minY-Yp},width:q.width,height:q.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:Em(I-1),title:Em(I-1),color:"purple",nodeSize:q}};g(J=>[X,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),Zt(""),ge(`Created group for ${w.length} nodes`)},[dt,x,g,Se]),Mu=m.useMemo(()=>b.filter(w=>Cn(w==null?void 0:w.data)),[b]),uy=m.useMemo(()=>Qn.filter(w=>Cn(w==null?void 0:w.data)).map(w=>w.id),[Qn]),PL=m.useMemo(()=>{const w=String((Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Lr]),dy=m.useMemo(()=>new Set(ep),[ep]),tp=m.useMemo(()=>k.filter(w=>dy.has(w.source)&&dy.has(w.target)),[k,dy]),fy=m.useCallback(w=>{const j=w==="display"?"display":w==="workflow"?"workflow":"workspace";f(j),Zt(""),V([]),ne(null),$e(!1),pn(!1);const C=Fr(a);j==="display"&&C.set("view","display"),j==="workflow"&&(C.set("view","workflow"),sr.trim()&&C.set("tapdId",sr.trim()));const I=`/workspace${C.toString()?`?${C.toString()}`:""}`;window.history.pushState({},"",I)},[a,sr]),C0=m.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const C=_.current.find(I=>I.id===j);if(!C||!Cn(C.data)){ge("展示节点不可用");return}R(I=>{if(I.nodeIds.includes(j))return I;const T=I.nodeIds.length,q=ec(C);return{nodeIds:[...I.nodeIds,j],nodePositions:{...I.nodePositions,[j]:{x:180+T*36,y:120+T*28}},nodeSizes:{...I.nodeSizes,...q?{[j]:q}:{}}}}),V([j])},[]),A0=m.useCallback(w=>{const j=String(w||"").trim();j&&(R(C=>{const I=C.nodeIds.filter(X=>X!==j),T={...C.nodePositions},q={...C.nodeSizes};return delete T[j],delete q[j],{nodeIds:I,nodePositions:T,nodeSizes:q}}),V(C=>C.filter(I=>I!==j)))},[]),E0=m.useCallback(w=>{const j=String(w||"").trim();j&&(z.current.nodeIds.includes(j)?A0(j):C0(j))},[C0,A0]),np=m.useMemo(()=>{const w=$n.trim().toLowerCase();return w?$l.filter(j=>{var C,I;return[j.id,(C=j.data)==null?void 0:C.label,(I=j.data)==null?void 0:I.definitionId].filter(Boolean).some(T=>String(T).toLowerCase().includes(w))}):$l},[$l,$n]),I0=m.useMemo(()=>{const w=np.length,j=w<=1?1:w<=4?2:3,C=Array.from({length:j},()=>({height:0,nodes:[]}));for(const I of np){const T=ec(I)||{width:420,height:260},q=Math.max(1,Number(T.width)||420),X=Math.max(1,Number(T.height)||260),J=Math.min(26,Math.max(5.5,X/q*16))+3.2;let Y=C[0];for(const le of C)le.height<Y.height&&(Y=le);Y.nodes.push(I),Y.height+=J}return C.map(I=>I.nodes)},[np]),RL=m.useCallback(w=>{var q;const j=P.nodeIds.includes(w.id),C=ec(w)||{width:420,height:260},I=Math.max(1,Math.round(Number(C.width)||420)),T=Math.max(1,Math.round(Number(C.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(j?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${I} / ${T}`},onClick:()=>E0(w.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:j,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(VJ,{node:w})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((q=w.data)==null?void 0:q.label)||w.id}),i.jsxs("small",{children:[Cn(w.data)," · ",w.id]})]})]},w.id)},[P.nodeIds,E0]),P0=m.useMemo(()=>{const w=Ie.trim().toLowerCase();return w?vt.filter(j=>[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].filter(Boolean).some(C=>String(C).toLowerCase().includes(w))):vt},[vt,Ie]),R0=m.useCallback((w,j)=>{const C=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let I=`${C}_${Date.now().toString(36)}`,T=2;for(;j.has(I);)I=`${C}_${Date.now().toString(36)}_${T}`,T+=1;return j.add(I),I},[]),$u=m.useCallback((w,j)=>{var Oe,Ot;if(!Se){ge("Readonly workspace");return}const C=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},I=C.instances&&typeof C.instances=="object"?C.instances:{},T=Object.keys(I);if(T.length===0)return;const q=new Set(_.current.map(De=>De.id)),X={};for(const De of T)X[De]=R0(De,q);const J=(Oe=C.ui)!=null&&Oe.nodePositions&&typeof C.ui.nodePositions=="object"?C.ui.nodePositions:{},Y=(Ot=C.ui)!=null&&Ot.nodeSizes&&typeof C.ui.nodeSizes=="object"?C.ui.nodeSizes:{},le=T.map(De=>{const ft=J[De];return{id:De,x:typeof(ft==null?void 0:ft.x)=="number"?ft.x:0,y:typeof(ft==null?void 0:ft.y)=="number"?ft.y:0}}),he=Math.min(...le.map(De=>De.x)),fe=Math.min(...le.map(De=>De.y));let je=j||{x:360+_.current.length*24,y:180+_.current.length*18};if(!j){const De=document.querySelector(".af-workspace-canvas .react-flow");if(De){const ft=De.getBoundingClientRect();je=r.screenToFlowPosition({x:ft.left+ft.width*.48,y:ft.top+ft.height*.32})}}const Ve={},Fe={},Ke={};for(const De of le){const ft=X[De.id];Ve[ft]={...I[De.id]||{}},Fe[ft]={x:je.x+(De.x-he),y:je.y+(De.y-fe)};const At=Y[De.id];typeof(At==null?void 0:At.width)=="number"&&typeof(At==null?void 0:At.height)=="number"&&(Ke[ft]={width:At.width,height:At.height})}const We=new Set(T),Le=(Array.isArray(C.edges)?C.edges:[]).filter(De=>We.has(De==null?void 0:De.source)&&We.has(De==null?void 0:De.target)).map(De=>({source:X[De.source],target:X[De.target],sourceHandle:De.sourceHandle??null,targetHandle:De.targetHandle??null})),Wt=Yu({instances:Ve,edges:Le,ui:{nodePositions:Fe,nodeSizes:Ke}},rt),it=Wt.nodes.map(De=>De.id),Ge=Wt.nodes.map(De=>({...De,selected:!0}));ee.current={...ee.current,...Wt.instances},se(ee.current),g(De=>[...De.map(ft=>({...ft,selected:!1})),...Ge]),x(De=>[...De.map(ft=>({...ft,selected:!1})),...Wt.edges.map(ft=>({...ft,selected:!1}))]),Zt(""),V([]),ge(`已添加流程片段:${w.displayName||w.id}(已选中 ${it.length} 个节点)`)},[R0,rt,r,x,g,Se]),TL=m.useCallback(()=>{var C,I;if(Qn.length<2){nr("请先在 workspace 画布上选择至少两个节点。"),Pt("flows");return}const w=Qn[0],j=Qn.length===2?`${((C=w.data)==null?void 0:C.label)||w.id} 片段`:`${((I=w.data)==null?void 0:I.label)||w.id} 等 ${Qn.length} 个节点`;zn({name:j,id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Yn(""),hr(!0),Pt("flows")},[Qn]),ML=m.useCallback(async()=>{var T,q;if(Qn.length<2)return;const w=fn.name.trim();if(!w){Yn("请填写片段名称。");return}const j={},C={};for(const X of Qn){j[X.id]={x:((T=X.position)==null?void 0:T.x)||0,y:((q=X.position)==null?void 0:q.y)||0};const J=ec(X);J&&(C[X.id]=J)}const I=tp.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));Fs(!0),Yn("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:fn.id,name:w,displayName:w,version:"1.0.0",description:fn.description,snippet:{instances:_v(Qn,ee.current),edges:I,ui:{nodePositions:j,nodeSizes:C}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");hr(!1),ge(`流程片段已发布:${J.id||w}`),_S(`流程片段已发布:${J.id||w}`),await Kf(),Pt("flows")}catch(X){Yn(String(X.message||X))}finally{Fs(!1)}},[Kf,fn,tp,Qn,_S]),T0=m.useCallback(async()=>{var j;const w=uu.trim();if(w){tS(!0),jo("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),I=await C.json().catch(()=>({}));if(!C.ok)throw new Error(I.error||"添加协作成员失败");zf(I.workspace||null),rS(""),ge(`已将 Workspace 分享给 ${((j=I.member)==null?void 0:j.username)||w}`)}catch(C){jo(String(C.message||C))}finally{tS(!1)}}},[a,uu]),$L=m.useCallback(()=>{jo(""),Pg(!0),fetch("/api/teams/me").then(w=>w.json().then(j=>({response:w,payload:j}))).then(({response:w,payload:j})=>{var T;if(!w.ok)throw new Error(j.error||"读取团队失败");const C=j.team||null;q$(C);const I=(T=Tt==null?void 0:Tt.teamShares)==null?void 0:T.find(q=>q.teamId===(C==null?void 0:C.id));oS((I==null?void 0:I.role)==="editor"?"editor":"viewer")}).catch(w=>jo(String(w.message||w)))},[Tt==null?void 0:Tt.teamShares]),py=m.useCallback(async(w=!1)=>{if(Ws!=null&&Ws.id){aS(!0),jo("");try{const j=await fetch("/api/workspace/collaboration/team-share",{method:w?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,teamId:Ws.id,role:Tg})}),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||(w?"取消团队分享失败":"分享到团队失败"));zf(C.workspace||null),ge(w?`已取消对「${Ws.name}」的分享`:`已分享到「${Ws.name}」`)}catch(j){jo(String(j.message||j))}finally{aS(!1)}}},[a,Ws,Tg]),LL=m.useCallback(async w=>{const j=String((w==null?void 0:w.userId)||"").trim();if(!(!j||j===(Tt==null?void 0:Tt.ownerId))){iS(j),jo("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:j})}),I=await C.json().catch(()=>({}));if(!C.ok)throw new Error(I.error||"取消成员分享失败");zf(I.workspace||null),ge(`已取消对 ${(w==null?void 0:w.username)||j} 的分享`)}catch(C){jo(String(C.message||C))}finally{iS("")}}},[a,Tt==null?void 0:Tt.ownerId]),M0=m.useCallback(async()=>{const w=Yl(_.current,S.current,ee.current);w.ui={...w.ui||{},...D.current?{viewport:D.current}:{},displayPage:nC(z.current,_.current)};const j=new Blob([`${JSON.stringify(w,null,2)}
264
- `],{type:"application/json"}),C=URL.createObjectURL(j),I=document.createElement("a");I.href=C,I.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(I),I.click(),I.remove(),URL.revokeObjectURL(C),await Cs(),kl(null),ka(!1),ge("已备份本地草稿并载入远端最新版本")},[S,a.flowId,Cs,_]),OL=m.useCallback(async()=>{const w=Array.isArray(jn==null?void 0:jn.conflictItems)?jn.conflictItems:[];if(!w.length||!(jn!=null&&jn.mergeGraph)||!(jn!=null&&jn.currentGraph)){fu("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let j=jn.mergeGraph;try{w.forEach((I,T)=>{const q=Mg[String(T)]||{mode:"local"};let X,J=!0;q.mode==="remote"?(X=I.current,J=I.hasCurrent!==!1):q.mode==="manual"?X=JSON.parse(String(q.manual||"")):(X=I.incoming,J=I.hasIncoming!==!1),j=CX(j,I.pathParts,X,J)})}catch(I){fu(`手动值不是有效 JSON:${String(I.message||I)}`);return}lS(!0),fu(""),qs("saving"),Us("正在提交冲突解决结果");const C=Ne.current.catch(()=>{}).then(async()=>{const I=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:j,baseRevision:jn.currentRevision,baseGraph:jn.currentGraph,clientId:Ct.current})}),T=await I.json().catch(()=>({}));if(!I.ok){if(I.status===409&&Array.isArray(T.conflictItems)){const q=T.conflictItems;kl({currentRevision:String(T.currentRevision||""),message:T.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(T.conflictPaths)?T.conflictPaths:[],conflictItems:q,mergeGraph:T.mergeGraph||null,currentGraph:T.currentGraph||null}),vl(Object.fromEntries(q.map((X,J)=>[String(J),{mode:"local",manual:Ju(X)}])))}throw new Error(T.error||"提交冲突解决结果失败")}await Cs(),kl(null),ka(!1),ge("冲突已解决并保存")});Ne.current=C;try{await C}catch(I){fu(String(I.message||I)),qs("error"),Us(String(I.message||I))}finally{lS(!1)}},[a,Cs,jn,Mg]);m.useCallback(()=>{if(Mu.length===0){ge("当前 workspace 没有 display 节点");return}const w=uy.length>0?uy:Mu.map(C=>C.id),j=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";zt(_w({title:j,layout:"gallery",nodeIds:w,mode:"multi-node"})),ce(""),tt(null),Sr(!0)},[a.flowId,uy,Mu]);const DL=m.useCallback(w=>{zt(j=>{const C=Array.isArray(j.nodeIds)?j.nodeIds:[];return C.includes(w)?{...j,nodeIds:C.filter(I=>I!==w)}:{...j,nodeIds:[...C,w]}})},[]),Ys=m.useCallback(async()=>{Hi(!0),ae("");try{const w=await fetch("/api/display/shares"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error(j.error||"读取分享列表失败");gr(Array.isArray(j.shares)?j.shares:[])}catch(w){ae(String(w.message||w)),gr([])}finally{Hi(!1)}},[]),FL=m.useCallback(()=>{Xn(!0),Rt(""),Ys()},[Ys]),zL=m.useCallback(async()=>{var C,I;const w=st.title.trim(),j=Array.isArray(st.nodeIds)?st.nodeIds:[];if(j.length===0){ce("请选择至少一个 display 节点。");return}Mr(!0),ce(""),tt(null);try{await en(b,k);const T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:st.layout,nodeIds:j,...sC(st)})}),q=await T.json().catch(()=>({}));if(!T.ok||q.ok===!1)throw new Error(q.error||"发布展示页失败");const X=new URL(q.url||`/display/${((C=q.share)==null?void 0:C.id)||""}`,window.location.origin).href;tt({...q,absoluteUrl:X}),ge((I=q.share)!=null&&I.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Gt&&Ys()}catch(T){ce(String(T.message||T))}finally{Mr(!1)}},[st,Gt,k,a,Ys,b,en]),BL=m.useCallback(async()=>{var j,C;const w=Array.isArray(P.nodeIds)?P.nodeIds:[];if(w.length===0){ce("请先添加至少一个展示节点。"),ge("请先添加至少一个展示节点"),pn(!0);return}Mr(!0),ce("");try{await en(b,k);const I=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:I,layout:"canvas",nodeIds:w,...sC(st)})}),q=await T.json().catch(()=>({}));if(!T.ok||q.ok===!1)throw new Error(q.error||"生成展示链接失败");const X=new URL(q.url||`/display/${((j=q.share)==null?void 0:j.id)||""}`,window.location.origin).href;tt({...q,absoluteUrl:X}),mr(!0),ge((C=q.share)!=null&&C.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Gt&&Ys()}catch(I){const T=String(I.message||I);ce(T),ge(T)}finally{Mr(!1)}},[P.nodeIds,st,Gt,k,a,Ys,b,en]),$0=m.useCallback(async()=>{const w=me==null?void 0:me.absoluteUrl;if(!w)return;const j=await Rb(w);Ut(j?"copied":"failed"),window.setTimeout(()=>Ut(""),1600)},[me==null?void 0:me.absoluteUrl]),WL=m.useCallback(async w=>{const j=iC(w),C=await Rb(j);Rt(C?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>Rt(""),1600)},[]),HL=m.useCallback(async(w,j)=>{const C=String((w==null?void 0:w.id)||"");if(C){Te(C),ae("");try{const I=j==="permanent"?{id:C,expiresMode:"permanent",permanent:!0}:{id:C,expiresMode:"days",expiresInDays:Number(j||30)},T=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),q=await T.json().catch(()=>({}));if(!T.ok||q.ok===!1)throw new Error(q.error||"更新分享有效期失败");await Ys(),ge("分享有效期已更新")}catch(I){ae(String(I.message||I))}finally{Te("")}}},[Ys]),VL=m.useCallback(async w=>{const j=String((w==null?void 0:w.id)||"");if(j){Te(j),ae("");try{const C=await fetch(`/api/display/share?id=${encodeURIComponent(j)}`,{method:"DELETE"}),I=await C.json().catch(()=>({}));if(!C.ok||I.ok===!1)throw new Error(I.error||"撤销分享失败");await Ys(),ge("分享已撤销")}catch(C){ae(String(C.message||C))}finally{Te("")}}},[Ys]),KL=m.useCallback(w=>{g(j=>j.map(C=>C.id===w?{...C,selected:!1}:C)),Zt(j=>j===w?"":j)},[g]),Dl=m.useCallback(()=>{const w=qg.current;if(!w)return;const j=w.getBoundingClientRect(),C=Math.min(420,Math.max(320,j.width+160)),I=12,T=Math.max(180,j.top-I*2),q=Math.min(560,T);lL({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-C-12,j.left)),top:Math.max(I,j.top-q-I),width:C,maxHeight:q,zIndex:1e4})},[]);m.useEffect(()=>{if(!Wf)return;Dl();const w=C=>{var T,q;const I=C.target;(T=qg.current)!=null&&T.contains(I)||(q=ES.current)!=null&&q.contains(I)||Kg(!1)},j=C=>{C.key==="Escape"&&Kg(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",j),window.addEventListener("resize",Dl),window.addEventListener("scroll",Dl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",j),window.removeEventListener("resize",Dl),window.removeEventListener("scroll",Dl,!0)}},[Wf,Dl]);const rp=m.useCallback(w=>{const j=sM(w);if(j.active&&(oe.current=!0),j.finished&&(oe.current=!1,Qe.current=!0),QG(w)&&gi(),p==="display"){R(T=>{var Y,le;let q=T.nodePositions,X=T.nodeSizes;for(const he of w||[]){const fe=Qp(he==null?void 0:he.id);if(!(!fe||!T.nodeIds.includes(fe))&&he.type!=="select"){if(he.type==="position"&&he.position){const je=q[fe];if((je==null?void 0:je.x)===he.position.x&&(je==null?void 0:je.y)===he.position.y)continue;q===T.nodePositions&&(q={...T.nodePositions}),q[fe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((Y=he.dimensions)!=null&&Y.width)&&((le=he.dimensions)!=null&&le.height)){const je=Qa({width:Math.round(Number(he.dimensions.width)),height:Math.round(Number(he.dimensions.height))},{display:!0});if(je){const Ve=X[fe];if((Ve==null?void 0:Ve.width)===je.width&&(Ve==null?void 0:Ve.height)===je.height)continue;X===T.nodeSizes&&(X={...T.nodeSizes}),X[fe]=je}}}}if(q===T.nodePositions&&X===T.nodeSizes)return T;const J={...T,nodePositions:q,nodeSizes:X};return z.current=J,J});const I=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");I.length>0&&V(T=>{const q=new Set(T);for(const J of I){const Y=Qp(J==null?void 0:J.id);Y&&(J.selected?q.add(Y):q.delete(Y))}const X=Array.from(q);return X.length===T.length&&X.every((J,Y)=>J===T[Y])?T:X});return}if(!Se){const I=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");I.length>0&&g(T=>Nd(I,T));return}const C=(w||[]).filter(I=>{var T,q;return(I==null?void 0:I.type)==="dimensions"&&((T=I.dimensions)==null?void 0:T.width)&&((q=I.dimensions)==null?void 0:q.height)});g(I=>{const T=new Map;if(C.length>0){const J=new Map(I.map(Y=>[Y.id,Y]));for(const Y of C){const le=J.get(Y.id),he={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=Am(le)?Ib(he):Qa(he,{display:!!Cn(le==null?void 0:le.data)});fe&&T.set(Y.id,fe)}}const q=Nd(w,I),X=T.size===0?q:q.map(J=>{const Y=T.get(J.id);if(!Y)return J;const le={...J.data,nodeSize:Y};return Cn(J.data)&&(le.displaySize=Y),{...J,width:Y.width,height:Y.height,data:le}});return j.mutated||(ze.current={nodes:X,edges:S.current,displayPage:z.current}),_.current=X,X}),C.length>0&&Kr(C.map(I=>I.id))},[gi,Kr,g,p,Se]),sp=m.useCallback((w=[],{finish:j=!1}={})=>{const C=j?nY([...K.current,...w]):jb(w);j&&(K.current=[]),C.length>0&&rp(C)},[rp]),qL=m.useCallback(w=>{const{transient:j,committed:C,finishesInteraction:I}=tY(w);if(j.length>0){de.current&&(window.clearTimeout(de.current),de.current=null),oe.current||(oe.current=!0,Ll.current=j0.current),K.current=jb([...K.current,...j]);const T=Nd(j,Ll.current);Ll.current=T,s.getState().setNodes(T)}if(I){Ll.current=[],sp(C,{finish:!0});return}C.length>0&&rp(C)},[rp,sp,s]),Fl=m.useCallback(()=>{ke.current.size>0||Be.current||((oe.current||K.current.length>0)&&(sp([],{finish:!0}),Ll.current=[]),kt.current&&Tl({type:"interaction.finished"}))},[sp,Tl]),UL=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.add(w.pointerId)},[]),_o=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.delete(w.pointerId),window.queueMicrotask(Fl)},[Fl]),GL=m.useCallback(()=>{Be.current=!0},[]),YL=m.useCallback(()=>{Be.current=!1,window.queueMicrotask(Fl)},[Fl]);m.useEffect(()=>{const w=()=>{ke.current.clear(),Be.current=!1,Fl()},j=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",_o,!0),window.addEventListener("pointercancel",_o,!0),window.addEventListener("lostpointercapture",_o,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("pointerup",_o,!0),window.removeEventListener("pointercancel",_o,!0),window.removeEventListener("lostpointercapture",_o,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",j),ke.current.clear(),Be.current=!1,K.current=[],Ll.current=[]}},[_o,Fl]);const JL=m.useCallback(w=>{if(p!=="display"){if(!Se){const j=(w||[]).filter(C=>(C==null?void 0:C.type)==="select");j.length>0&&x(C=>{const I=pm(j,C);return S.current=I,I});return}(w||[]).some(j=>(j==null?void 0:j.type)!=="select")&&gi(),x(j=>{const C=pm(w,j);return S.current=C,C})}},[gi,x,p,Se]),zl=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const j=w.getBoundingClientRect();return r.screenToFlowPosition({x:j.left+j.width*.48,y:j.top+j.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),ip=m.useCallback(()=>{var w,j,C;if(Kt){const I=Number(((w=Kt.measured)==null?void 0:w.width)||Kt.width||260);return{x:Number(((j=Kt.position)==null?void 0:j.x)||0)+I+140,y:Number(((C=Kt.position)==null?void 0:C.y)||0)}}return zl()},[zl,Kt]),Gi=m.useCallback((w,j={})=>{if(!Se)return ge("Readonly workspace"),null;if(!w)return null;const C=Tv(w)||w.id,I=gM(w),T=wM(w),q=j.id||fJ(C,b),X=ud(w.inputs),J=ud(w.outputs),Y={definitionId:C,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:j.label||Cm(w),role:"normal",body:j.body||"",...j.script||T?{script:j.script||T}:{},...j.scriptRef?{scriptRef:j.scriptRef}:{},...j.implementationRef?{implementationRef:j.implementationRef}:{},...j.implementationMode?{implementationMode:j.implementationMode}:{},input:j.inputs||X,output:j.outputs||J},le={id:q,type:Ec,position:j.position||zl(),data:{label:Y.label,definitionId:C,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:mM(C,w),role:"normal",body:Y.body,...Y.script?{script:Y.script}:{},...Y.scriptRef?{scriptRef:Y.scriptRef}:{},...Y.implementationRef?{implementationRef:Y.implementationRef}:{},...Y.implementationMode?{implementationMode:Y.implementationMode}:{},inputs:Y.input,outputs:Y.output}},he={...vb(le,{...ee.current,[q]:Y},rt),selected:!0};return gi(),g(fe=>[...fe.map(je=>({...je,selected:!1})),he]),j.openProperties&&Zt(q),q},[zl,gi,b,rt,g,Se]),XL=m.useCallback(w=>jw(w,_.current),[]),QL=m.useCallback(w=>{if(!Se){ge("Readonly workspace");return}if(!jw(w,_.current)){ge("端口类型不匹配,已取消连线");return}ne(null),gi(),g(j=>ww(j,w)),x(j=>{const C=j.filter(T=>!(T.target===w.target&&T.targetHandle===w.targetHandle)),I=Nh({...w,markerEnd:{type:Ai.ArrowClosed}},C);return S.current=I,I})},[gi,x,g,Se]),ZL=m.useCallback((w,j)=>{if(!Se)return;const C=cJ(j,_.current);te.current=C?{...C,preferExisting:!!(w!=null&&w.shiftKey)}:null,ne(null)},[Se]),e2=m.useCallback((w,j)=>{var We,Le,Wt,it;if(!Se)return;const C=te.current;if(te.current=null,!C||j!=null&&j.toNode)return;const I=uJ(rt,C),T=dJ(_.current,S.current,C);if(I.length===0&&T.length===0){ge(`没有匹配 ${C.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||C.preferExisting)?T.length>0?"existing":"create":I.length>0?"create":"existing",J=((Le=(We=w==null?void 0:w.changedTouches)==null?void 0:We[0])==null?void 0:Le.clientX)??(w==null?void 0:w.clientX),Y=((it=(Wt=w==null?void 0:w.changedTouches)==null?void 0:Wt[0])==null?void 0:it.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const le=document.querySelector(".af-workspace-canvas .react-flow");if(!le)return;const he=le.getBoundingClientRect(),fe=320,je=Math.max(I.length,T.length),Ve=Math.min(480,150+je*58),Fe=Math.max(12,Math.min(J-he.left,he.width-fe-12)),Ke=Math.max(12,Math.min(Y-he.top,he.height-Ve-12));ne({left:Fe,top:Ke,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:C,candidates:I,existingCandidates:T,mode:X,query:""})},[rt,r,Se]),t2=m.useCallback(w=>{if(!Se){ge("Readonly workspace"),ne(null);return}const j=Z.current;if(!j||!(w!=null&&w.def))return;const C=Gi(w.def,{position:j.flowPosition});if(!C)return;const I=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:C,targetHandle:`input-${w.slotIndex}`}:{source:C,sourceHandle:`output-${w.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};g(T=>ww(T,I)),x(T=>{const q=T.filter(J=>!(J.target===I.target&&J.targetHandle===I.targetHandle)),X=Nh({...I,markerEnd:{type:Ai.ArrowClosed}},q);return S.current=X,X}),ne(null)},[Gi,x,Se]),n2=m.useCallback(w=>{if(!Se){ge("Readonly workspace"),ne(null);return}const j=w==null?void 0:w.connection;if(!j||!jw(j,_.current)){ge("端口类型不匹配,已取消连线"),ne(null);return}g(C=>ww(C,j)),x(C=>{const I=C.filter(q=>!(q.target===j.target&&q.targetHandle===j.targetHandle)),T=Nh({...j,markerEnd:{type:Ai.ArrowClosed}},I);return S.current=T,T}),ne(null)},[x,g,Se]),L0=m.useCallback(w=>{w&&(Gi(w,{position:ip()}),$e(!1),Lt(""))},[Gi,ip]),O0=m.useCallback(w=>{w&&($u(w,ip()),$e(!1),Lt(""))},[$u,ip]),r2=m.useCallback(w=>{var C,I,T;if(dt||_n)return;const j=w==null?void 0:w.target;K_(j)||(C=j==null?void 0:j.closest)!=null&&C.call(j,"button, a, [role='button'], .react-flow__handle")||(T=(I=N.current)==null?void 0:I.focus)==null||T.call(I,{preventScroll:!0})},[dt,_n]);m.useEffect(()=>{const w=j=>{var le;if(j.defaultPrevented)return;const C=XU(j.target)||K_(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){j.preventDefault(),en().catch(he=>ge(String(he.message||he)));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),LS(he=>!he);return}if(Zg)return;if(Qg){(j.key==="Escape"||N_(j))&&(j.preventDefault(),Vf(!1));return}const I=j.key.toLowerCase(),T=(j.metaKey||j.ctrlKey)&&I==="c",q=(j.metaKey||j.ctrlKey)&&I==="v",X=C&&T&&NY(j.target);if(C&&!X)return;const J=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&I==="z",Y=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&I==="z"||I==="y");if(J||Y){if(dt){j.preventDefault(),j.stopPropagation(),ge("展示页布局会自动保存");return}if(!Se){j.preventDefault(),ge("Readonly workspace");return}j.preventDefault(),j.stopPropagation();const he=J?XS():QS();ge(he?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(T){if(dt)return;const he=Xv.current,fe=(_.current||[]).some(Ve=>Ve==null?void 0:Ve.selected)?_.current:(_.current||[]).map(Ve=>he&&Ve.id===he?{...Ve,selected:!0}:Ve),je=bU(fe,S.current,ee.current);je&&(j.preventDefault(),j.stopPropagation(),W.current=je,CJ(je),X&&typeof((le=j.target)==null?void 0:le.blur)=="function"&&j.target.blur(),ge(`Copied ${je.nodes.length} node${je.nodes.length>1?"s":""}`));return}if(q){if(dt){j.preventDefault(),j.stopPropagation();return}if(!Se){j.preventDefault(),ge("Readonly workspace");return}const he=W.current||AJ();he&&!W.current&&(W.current=he);const fe=kU(he,_.current,S.current,ee.current);fe&&(j.preventDefault(),j.stopPropagation(),ee.current=fe.instances,se(fe.instances),g(fe.nodes),x(fe.edges),ge(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(N_(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Vf(!0);return}if(I==="g"&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),_0();return}if(j.key==="a"||j.key==="A"){if(j.metaKey||j.ctrlKey){j.preventDefault(),dt?V(z.current.nodeIds):(g(he=>he.map(fe=>({...fe,selected:!0}))),x(he=>he.map(fe=>({...fe,selected:!1}))));return}if(j.altKey)return;if(dt){j.preventDefault(),pn(!0);return}if(!Se){j.preventDefault(),ge("Readonly workspace");return}j.preventDefault(),$e(!0);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),OS("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),OS("pan");return}(j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&(j.preventDefault(),N0())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[_0,dt,Zg,N0,QS,en,Qg,x,g,XS,Se]);const s2=m.useCallback(w=>{Sl(j=>{const C=new Set(j);return C.has(w)?C.delete(w):C.add(w),C})},[]),i2=m.useCallback((w,j)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:j.path,name:j.name,type:j.type})),w.dataTransfer.setData("text/plain",j.path)},[]),o2=m.useCallback((w,j)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",j.id),w.dataTransfer.setData("text/plain",j.id)},[]),op=m.useCallback(async(w,j)=>{const C=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),I=C.split(".").pop(),T=["jsx","tsx","js"].includes(I)?"display_react_app":I==="html"?"display_html":I==="csv"||I==="tsv"||I==="json"&&/\b(table|data|rows|report)\b/i.test(C)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(I)?"display_image":"display_markdown",q=rt.find(fe=>fe.id===T);if(!q){ge("展示节点不可用");return}const X=T==="display_image";let J=String(w.path||"");if(!X){const fe=Fr(a);fe.set("path",w.path);const je=await fetch(`/api/workspace/file?${fe.toString()}`),Ve=await je.json();if(!je.ok)throw new Error(Ve.error||"读取文件失败");J=String(Ve.content||"")}const Y=T==="display_image"?"src":"content",le=ud(q.inputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe),he=ud(q.outputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe);Gi(q,{label:w.name||"Display",body:J,inputs:le,outputs:he,position:j}),ge(`已创建展示:${w.path}`)},[Gi,a,rt]),a2=m.useCallback(w=>{if(!Se){ge("Readonly workspace");return}op(w,zl()).catch(j=>ge(String(j.message||j)))},[op,zl,Se]),l2=m.useCallback(w=>{if(!Se){w.preventDefault(),ge("Readonly workspace");return}const j=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(j){w.preventDefault();let X;try{X=JSON.parse(j)}catch{return}if(!(X!=null&&X.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});op(X,J).catch(Y=>ge(String(Y.message||Y)));return}const C=w.dataTransfer.getData("application/agentflow-snippet");if(C){const X=vt.find(Y=>`${Y.id}@${Y.version}`===C);if(!X)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});$u(X,J);return}const I=w.dataTransfer.getData("application/agentflow-node");if(!I)return;const T=rt.find(X=>X.id===I);if(!T)return;w.preventDefault();const q=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Gi(T,{position:q})},[op,Gi,vt,$u,rt,r,Se]),c2=m.useCallback(w=>{if(!Se)return;const j=Array.from(w.dataTransfer.types||[]);!j.includes("application/x-agentflow-workspace-file")&&!j.includes("application/agentflow-node")&&!j.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=j.includes("application/agentflow-node")||j.includes("application/agentflow-snippet")?"move":"copy")},[Se]),u2=m.useCallback(async(w="")=>{if(!Se){ge("Readonly workspace");return}const j=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!j)return;const C=w&&!j.includes("/")?`${w}/${j}`:j;try{const I=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C,content:""})}),T=await I.json();if(!I.ok)throw new Error(T.error||"创建文件失败");await Nn(),Sl(q=>{const X=new Set(q);for(const J of Zp(T.path||C))X.delete(J);return X}),ge(`已创建 ${T.path}`)}catch(I){ge(String(I.message||I))}},[a,Nn,Se]),d2=m.useCallback(async(w="")=>{if(!Se){ge("Readonly workspace");return}const j=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!j)return;const C=w&&!j.includes("/")?`${w}/${j}`:j;try{const I=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C})}),T=await I.json();if(!I.ok)throw new Error(T.error||"创建文件夹失败");await Nn(),Sl(q=>{const X=new Set(q);for(const J of Zp(T.path||C))X.delete(J);return T.path&&X.delete(T.path),X}),ge(`已创建 ${T.path}`)}catch(I){ge(String(I.message||I))}},[a,Nn,Se]),f2=m.useCallback(async w=>{if(!Se){ge("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const j=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),C=await j.json();if(!j.ok)throw new Error(C.error||"删除失败");ge(`已删除 ${C.path}`),await Nn()}catch(j){ge(String(j.message||j))}},[a,Nn,Se]),p2=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const j=ff(w.path,a,{download:!0});if(!j)return;const C=document.createElement("a");C.href=j,C.download=w.name||w.path.split("/").pop()||"download",C.rel="noopener",document.body.appendChild(C),C.click(),C.remove()},[a]),ap=m.useCallback(async()=>{if(!Se){ge("Readonly workspace");return}const w=Sa.trim(),j=qr,C=Ks.find(X=>X.id===j)||null;if(!w||os||(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="stopping")return;const I=C?Array.isArray(C.messages)?C.messages:[]:ja,T=Yl(b,k,ee.current);Ug(""),PS(!0),Al(!0),El(null);const q={role:"user",text:w,at:Date.now()};C?Hn(X=>X.map(J=>J.id===j?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],q].slice(-180)}:J)):(_s("workspace"),Cl(X=>[...X,q]));try{await en(b,k);const X=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,prompt:w,outputKind:"markdown",workspaceGraph:T,allowFlowYaml:!1,model:Vi,selectedSkills:Vs,selectedNodeIds:ep,messages:I})}),J=await X.json();if(!X.ok)throw new Error(J.error||"生成失败");const le={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};C?Hn(he=>he.map(fe=>fe.id===j?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],le].slice(-180)}:fe)):Cl(he=>[...he,le]),await Cs(),ge("AI 生成完成")}catch(X){const J=String(X.message||X),Y={role:"assistant",text:J,error:!0,at:Date.now()};C?Hn(le=>le.map(he=>he.id===j?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],Y].slice(-180)}:he)):Cl(le=>[...le,Y]),ge(J)}finally{PS(!1)}},[qr,ja,Vi,Ks,os,Sa,k,a,Cs,b,en,ep,Vs,Se]),ir=Ks.find(w=>w.id===qr)||null,hy=ir?Array.isArray(ir.messages)?ir.messages:[]:ja,Bl=ir&&(ir.status==="running"||ir.status==="stopping")||os,h2=cX(hy,Bl),my=uX(hy),D0=ir?ir.status==="stopping"?`${ir.label} stopping`:ir.status==="running"?`${ir.label} running`:ir.status==="paused"?`${ir.label} paused`:ir.status==="failed"?`${ir.label} failed`:`${ir.label} done`:os?"Workspace agent running":ja.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{qr!=="workspace"&&(Ks.some(w=>w.id===qr)||_s(Ca()))},[qr,Ks,Ca]),m.useEffect(()=>{if(!xu)return;const w=window.requestAnimationFrame(()=>{var C,I;const j=RS.current;j&&(j.scrollTop=j.scrollHeight),(I=(C=Gg.current)==null?void 0:C.scrollIntoView)==null||I.call(C,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[hy.length,qr,D0,my.length,xu]);const m2=String(a.flowId||"").trim()||"Workspace",Co=(st==null?void 0:st.mode)==="single-node",F0=Co&&Mu.find(w=>{var j;return w.id===st.sourceNodeId||((j=st.nodeIds)==null?void 0:j.includes(w.id))})||null,g2=Co&&F0?[F0]:Mu;return i.jsxs("div",{className:"af-workspace-page",children:[l?null:i.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[i.jsxs("div",{className:"af-pipeline-top-left",children:[i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n(a.adminOwnerId?"/admin/usage":a.returnTo||"/projects"),"aria-label":"返回",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",title:a.flowId?`${a.flowId} · ${eS}`:eS||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:m2}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",mY,"-STABLE"]})]}),Ff?i.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",Ff.ownerUsername||Ff.ownerUserId]}):null,i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:p==="workspace"?"af-view-switch__active":"",onClick:()=>fy("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:p==="display"?"af-view-switch__active":"",onClick:()=>fy("display"),children:"Display"}),i.jsx("button",{type:"button",className:p==="workflow"?"af-view-switch__active":"",onClick:()=>fy("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${HS}`,title:`${YS} · ${VS}`,role:"status","aria-label":`${YS}:${VS}`,children:i.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),jn?i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=jn.conflictItems)!=null&&w.length?ka(!0):M0()},title:["先下载当前本地草稿,再载入远端最新版本",...jn.conflictPaths||[]].join(`
265
- `),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,dt?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||Wn||!(me!=null&&me.absoluteUrl)&&P.nodeIds.length===0,onClick:()=>{Ut(""),mr(!0)},title:me!=null&&me.absoluteUrl?"查看展示链接":P.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Wn?"hourglass_empty":"ios_share"}),Wn?"生成中":me!=null&&me.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||$l.length===0,onClick:()=>pn(!0),title:$l.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||!!(Tt!=null&&Tt.role&&Tt.role!=="owner"),onClick:$L,title:Tt!=null&&Tt.role&&Tt.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),Ff?null:i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:FL,title:"查看我的展示分享",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!GS,onClick:()=>h(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:i.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),i.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!GS&&!_u,onClick:()=>v(!0),"aria-label":_u?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:_u?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:_u?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Vf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(xu?" af-composer-topbar-btn--active":"")+(os?" af-composer-topbar-btn--running":""),disabled:!Se||dt||_n,onClick:()=>{El(null),Al(w=>(w||_s(Ca()),!w))},children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Se,onClick:()=>en().catch(w=>ge(String(w.message||w))),children:"Save"})]})]}),ks?i.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsx("span",{children:ks}),i.jsx("button",{type:"button",onClick:()=>Jn(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!dt&&!_n&&(xu||gt)?" af-workspace-body--drawer":"")+(!dt&&!_n&&ku?" af-workspace-body--sidebar-collapsed":"")+(dt?" af-workspace-body--display-mode":"")+(_n?" af-workspace-body--workflow-mode":""),children:[!dt&&!_n&&ku?i.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:i.jsxs("div",{className:"af-workspace-rail__stack",children:[i.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>$e(!0),"aria-label":"添加节点",title:"添加节点",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),i.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>Hf(!1),"aria-label":"展开文件",title:"展开文件",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),i.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),i.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>Hf(!1),"aria-label":"展开侧边栏",title:(Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"展开侧边栏",children:PL})]})}):null,!dt&&!_n?i.jsxs("aside",{ref:Fg,className:"af-workspace-sidebar"+(J$?" af-workspace-sidebar--resizing":""),"aria-hidden":ku,style:{"--af-work-files-pane-height":`${Math.round(zg)}px`},children:[i.jsxs("section",{className:"af-workspace-files-section",children:[i.jsxs("div",{className:"af-workspace-sidebar-head",children:[i.jsx("h2",{children:"Files"}),i.jsxs("div",{className:"af-workspace-sidebar-actions",children:[i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Hf(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>u2(Ui),"aria-label":"新增文件",title:Ui?`在 ${Ui} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>d2(Ui),"aria-label":"新增文件夹",title:Ui?`在 ${Ui} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se||uS,onClick:()=>f0(Ui),"aria-label":"上传文件",title:Ui?`上传到 ${Ui}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:uS?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Nn(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:fS,type:"file",multiple:!0,className:"af-visually-hidden",onChange:kL})]})]}),i.jsx("input",{className:"af-workspace-search",value:$g,onChange:w=>G$(w.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:EL,children:i.jsx(MM,{items:AL,onOpen:a2,selectedPath:Lg,collapsedDirs:Y$,onToggleDir:s2,onSelect:w=>Og(w.path||""),onFileDragStart:i2,onDelete:f2,onDownload:p2})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:iL,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),i.jsxs("section",{className:"af-workspace-nodes-section",children:[i.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[i.jsxs("h2",{className:"af-node-palette-title",children:[i.jsx("span",{children:"Palette"}),i.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),i.jsxs("label",{className:"af-palette-search-wrap",children:[i.jsx("span",{className:"af-visually-hidden",children:qe==="flows"?"搜索流程片段":"搜索节点"}),i.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",className:"af-palette-search-input",value:Ie,onChange:w=>et(w.target.value),placeholder:qe==="flows"?"搜索流程片段...":"搜索节点...","aria-label":qe==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":qe==="nodes",className:"af-palette-tab"+(qe==="nodes"?" af-palette-tab--active":""),onClick:()=>Pt("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":qe==="flows",className:"af-palette-tab"+(qe==="flows"?" af-palette-tab--active":""),onClick:()=>Pt("flows"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),i.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:qe==="flows"?i.jsxs(i.Fragment,{children:[i.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:i.jsxs("div",{className:"af-flow-snippet-actions",children:[i.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:TL,disabled:Qn.length<2,title:Qn.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),i.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Qn.length," 节点 / ",tp.length," 连线"]})]})}),kn?i.jsx("p",{className:"af-err af-palette-list-err",children:kn}):null,Gn?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):P0.length>0?i.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[i.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),i.jsx("div",{className:"af-palette-cards",children:P0.map(w=>{const j=`${w.id}@${w.version}`,C=w.displayName||w.name||w.id,I=w.description||`${w.nodeCount||0} 个节点,${w.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:T=>{T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("application/agentflow-snippet",j),T.dataTransfer.setData("text/plain",j)},onClick:()=>$u(w),title:I,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:C}),i.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),I?i.jsx("span",{className:"af-palette-card-desc",children:I}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[w.nodeCount||0," nodes"]}),i.jsxs("span",{children:[w.edgeCount||0," edges"]})]})]},j)})})]}):i.jsx("p",{className:"af-palette-empty",children:Ie.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Ql.map(w=>{var j;return(j=ly[w])!=null&&j.length?i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${w}`,children:[i.jsx("h3",{className:"af-palette-cat",children:w}),i.jsx("div",{className:"af-palette-cards",children:ly[w].map(C=>{const I=Q_(C.inputs,"input"),T=Q_(C.outputs,"output"),q=Eb(C),X=ld(C);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>o2(J,C),onClick:()=>Gi(C),title:q||C.id,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:J_(w)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:X}),X!==C.id?i.jsx("span",{className:"af-palette-card-id",children:C.id}):null]})]}),q?i.jsx("span",{className:"af-palette-card-desc",children:q}):null,i.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[I.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[I.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:X_("input",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:En(J==null?void 0:J.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:Jp(J,Y)})]},`in-${Y}`)),I.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",I.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[T.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[T.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:X_("output",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Jp(J,Y)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:En(J==null?void 0:J.type)}})]},`out-${Y}`)),T.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",T.hidden]}):null]})]})]})]},C.id)})})]},w):null}),rt.length>0&&Ie.trim()&&Ql.every(w=>{var j;return!((j=ly[w])!=null&&j.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,_n?i.jsx(_X,{flowParams:a,tapdId:sr,setTapdId:nL,snapshot:sn,loading:rL,error:sL,actionRunning:Bg,actionOutput:Wg,pendingConfirm:Ns,conflict:wu,reviewPublishing:Hg,onRefresh:()=>Au(sr),onRunDryRun:hL,onConfirmAction:mL,onRetryConflict:gL,onPublishReview:yL}):i.jsxs("main",{ref:N,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:w=>{r2(w),UL(w)},onLostPointerCaptureCapture:_o,children:[i.jsx(HR,{className:"af-flow-canvas af-workspace-flow"+(ey==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(dt?" af-workspace-flow--display-mode":""),nodes:Zf,edges:_L,nodeTypes:tX,onNodesChange:qL,onEdgesChange:JL,onMoveStart:GL,onMoveEnd:YL,onConnect:dt?void 0:QL,onConnectStart:dt?void 0:ZL,onConnectEnd:dt?void 0:e2,isValidConnection:dt?void 0:XL,onNodeClick:(w,j)=>{var C;if(dt){V([Qp(j.id)]);return}if((C=j==null?void 0:j.data)!=null&&C.isWorkspaceGroup){Zt("");return}if(w.detail>=3){Al(!1),g(I=>I.map(T=>({...T,selected:T.id===j.id}))),x(I=>I.map(T=>({...T,selected:!1}))),Zt(j.id);return}yr&&Zt(j.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{dt?V([]):Zt("")},onDrop:dt?void 0:l2,onDragOver:dt?void 0:c2,nodesDraggable:Se,nodesConnectable:dt?!1:Se,edgesReconnectable:dt?!1:Se,onlyRenderVisibleElements:Zf.length>=80,deleteKeyCode:dt?null:Se?["Backspace","Delete"]:null,selectionOnDrag:ey==="select",panOnDrag:ey==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(KR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!dt&&G?(()=>{var J;const w=String(G.query||"").trim().toLowerCase(),j=G.mode==="create"?"create":"existing",C=Array.isArray(G.candidates)?G.candidates:[],I=Array.isArray(G.existingCandidates)?G.existingCandidates:[],T=w?C.filter(Y=>{var le,he,fe;return[(le=Y.def)==null?void 0:le.id,Y.displayLabel,Y.description,(he=Y.slot)==null?void 0:he.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(je=>String(je).toLowerCase().includes(w))}):C,q=w?I.filter(Y=>{var le,he;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(le=Y.slot)==null?void 0:le.name,(he=Y.slot)==null?void 0:he.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):I,X=G.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:G.left,top:G.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:En((J=G.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",G.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>ne(null),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[i.jsxs("button",{type:"button",className:j==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:I.length===0,onClick:()=>ne(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:I.length})]}),i.jsxs("button",{type:"button",className:j==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:C.length===0,onClick:()=>ne(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:C.length})]})]}),i.jsxs("label",{className:"af-connect-node-menu__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:G.query,onChange:Y=>ne(le=>le&&{...le,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[j==="create"?T.map(Y=>{var fe,je;const le=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),he=Jp(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>t2(Y),title:Y.description||Y.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:le}),le!==Y.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:En((je=Y.slot)==null?void 0:je.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he})]})]},`${Y.def.id}-${Y.slotIndex}`)}):q.map(Y=>{var fe;const le=Y.nodeLabel||Y.nodeId,he=Jp(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>n2(Y),title:`${Y.definitionId||Y.nodeId} · ${he}`,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:le}),i.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:En((fe=Y.slot)==null?void 0:fe.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he}),Y.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(j==="create"?T.length:q.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!dt&&!_n&&!cL?i.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:i.jsxs("div",{className:"af-pipeline-composer-inner",children:[i.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Yg(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),i.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:Qn.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Qn.map(w=>{var T,q;const j=String(((T=w.data)==null?void 0:T.label)??w.id),C=(q=w.data)!=null&&q.definitionId?String(w.data.definitionId):"",I=C&&C!==j?`${j} · ${w.id} · ${C}`:`${j} · ${w.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:I,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:C||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:j}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>KL(w.id),"aria-label":`取消选择 ${w.id}`,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},w.id)})}),i.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[i.jsx("div",{className:"af-composer-input-wrap",children:i.jsx("textarea",{className:"af-composer-textarea",value:Sa,rows:2,onChange:w=>Ug(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),ap())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Se})}),i.jsxs("div",{className:"af-composer-toolbar",children:[i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:qg,type:"button",className:"af-composer-skills-button"+(Vs.length>0?" af-composer-skills-button--active":""),disabled:os||!Se,"aria-haspopup":"listbox","aria-expanded":Wf,onClick:()=>Kg(w=>!w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Vs.length>0?`Skills ${Vs.length}`:"Skills"})]}),Wf&&!os?lr.createPortal(i.jsx("div",{ref:ES,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:aL,children:Hs.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[Ol.groups.map(w=>{const j=ca(w,Hs),C=cz(w,cy,Hs),I=oL.has(w.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(I?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:C==="all",disabled:j.length===0,onChange:T=>{const q=T.target.checked;hu(X=>q?az(X,j):lz(X,j))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:w.name}),w.builtin?i.jsx("em",{children:"built-in"}):null,C==="partial"?i.jsx("em",{children:"partial"}):null]})]}),i.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":I?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{AS(T=>{const q=new Set(T);return q.has(w.id)?q.delete(w.id):q.add(w.id),q})},children:[i.jsx("span",{children:w.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:I?"expand_more":"expand_less"})]})]}),I?null:i.jsx("div",{className:"af-composer-skill-group-items",children:w.skills.map(T=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:cy.has(T.key),onChange:q=>{const X=q.target.checked;hu(J=>X?J.includes(T.key)?J:[...J,T.key]:J.filter(Y=>Y!==T.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:T.name}),T.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:T.description}):null]})]},`${w.id}:${T.key}`))})]},w.id)}),Ol.ungrouped.length>0?i.jsxs("div",{className:"af-composer-skill-group",children:[i.jsxs("div",{className:"af-composer-skill-group-title",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("span",{children:Ol.ungrouped.length})]}),Ol.ungrouped.map(w=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:cy.has(w.key),onChange:j=>{const C=j.target.checked;hu(I=>C?I.includes(w.key)?I:[...I,w.key]:I.filter(T=>T!==w.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:w.name}),w.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:w.description}):null]})]},`ungrouped:${w.key}`))]}):null]})}),document.body):null]}),i.jsx("label",{className:"af-composer-model-field",children:i.jsxs("select",{className:"af-composer-model-select",value:Vi,onChange:w=>Q$(w.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),IL.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(Sa.trim()&&!os?" af-composer-send--active":"")+(os?" af-composer-send--stop":""),disabled:os||!Sa.trim()||!Se,"aria-label":os?"Running":"Send",onClick:()=>void ap(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:os?"sync":"arrow_upward"})})]})]})]})}):!dt&&!_n?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Yg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!dt&&!_n&&xu?i.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:i.jsxs("div",{className:"af-composer-sidebar",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Al(!1),"aria-label":"关闭 AI 对话侧栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-composer-session-tabs",children:[i.jsx("button",{type:"button",className:"af-composer-session-tab"+(qr==="workspace"?" af-composer-session-tab--active":""),ref:qr==="workspace"?Gg:null,onClick:()=>_s("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Ks.map(w=>i.jsxs("div",{role:"tab",tabIndex:0,ref:qr===w.id?Gg:null,className:"af-composer-session-tab"+(qr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>_s(w.id),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_s(w.id))},title:w.runNodeId||w.label,children:[i.jsx("span",{className:"af-composer-session-label",children:w.label}),i.jsx("button",{type:"button",className:"af-composer-session-close",onClick:j=>{j.preventDefault(),j.stopPropagation(),xL(w.id)},"aria-label":`关闭 ${w.label}`,title:"关闭 tab",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]},w.id))]}),i.jsx("div",{className:"af-composer-sidebar-status"+(Bl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:D0}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:RS,children:[i.jsx(cC,{messages:h2,running:Bl,showRunningIndicator:!ir}),my.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",...Bl?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(cC,{messages:my,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:Sa,rows:3,onChange:w=>Ug(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),ap())},placeholder:ir?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!Se||Bl}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!Se||Bl||!Sa.trim(),onClick:()=>void ap(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!dt&&!_n&&gt&&Kt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(xG,{draft:gt,setDraft:js,definitionId:String(((z0=Kt.data)==null?void 0:z0.definitionId)||Kt.id),systemPromptReadonly:String(((B0=Kt.data)==null?void 0:B0.description)||""),modelLists:va,disabled:!Se,onIdBlur:()=>iy(!0),onClose:()=>Zt(""),onPublishToMarketplace:wL,error:B$,ioSlots:{inputs:Array.isArray(gt==null?void 0:gt.inputs)?gt.inputs:[],outputs:Array.isArray(gt==null?void 0:gt.outputs)?gt.outputs:[]}})}):null,!dt&&!_n&&bu?lr.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>El(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:i.jsx(sG,{flowParams:a,scheduleNodeId:bu.scheduleNodeId,runNodeId:bu.runNodeId,lastRunId:bu.lastRunId,label:bu.label,onClose:()=>El(null)})})}),document.body):null,i.jsx(eG,{open:Qg,onClose:()=>Vf(!1)}),i.jsx(nG,{open:Zg,onClose:()=>LS(!1),onJump:ay,nodes:CL}),i.jsx(bG,{open:d,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:Nu,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),i.jsx(kG,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:Nu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:_u,onDeleted:async()=>{v(!1),n("/projects")}}),U$&&jn?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-workspace-conflict-modal",role:"dialog","aria-modal":"true","aria-label":"解决 Workspace 冲突",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"解决 ",((W0=jn.conflictItems)==null?void 0:W0.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ka(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("div",{className:"af-workspace-conflict-summary",children:["未冲突的改动已经自动合并。这里只需要决定双方同时修改的字段。",i.jsxs("div",{className:"af-workspace-conflict-bulk",children:[i.jsx("button",{type:"button",onClick:()=>vl(Object.fromEntries((jn.conflictItems||[]).map((w,j)=>[String(j),{mode:"local",manual:Ju(w)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>vl(Object.fromEntries((jn.conflictItems||[]).map((w,j)=>[String(j),{mode:"remote",manual:Ju(w)}]))),children:"全部使用远端"})]})]}),(jn.conflictItems||[]).map((w,j)=>{const C=Mg[String(j)]||{mode:"local",manual:Ju(w)};return i.jsxs("section",{className:"af-workspace-conflict-item",children:[i.jsx("code",{className:"af-workspace-conflict-path",children:w.path}),i.jsx("div",{className:"af-workspace-conflict-options",children:[["local","保留我的"],["remote","使用远端"],["manual","手动编辑"]].map(([I,T])=>i.jsx("button",{type:"button",className:C.mode===I?"is-active":"",onClick:()=>vl(q=>({...q,[String(j)]:{...C,mode:I}})),children:T},I))}),i.jsxs("div",{className:"af-workspace-conflict-values",children:[i.jsxs("div",{className:C.mode==="local"?"is-selected":"",children:[i.jsx("span",{children:"我的修改"}),i.jsx("pre",{children:wC(w,"incoming")})]}),i.jsxs("div",{className:C.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:wC(w,"current")})]})]}),C.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:C.manual,onChange:I=>vl(T=>({...T,[String(j)]:{...C,manual:I.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${j}`)}),cS?i.jsx("div",{className:"af-flow-snippet-error",children:cS}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot af-workspace-conflict-foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Bf,onClick:()=>void M0(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Bf,onClick:()=>ka(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Bf||!(jn.conflictItems||[]).length,onClick:()=>void OL(),children:Bf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,pr?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>hr(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"名称"}),i.jsx("input",{type:"text",value:fn.name,onChange:w=>{const j=w.target.value;zn(C=>({...C,name:j,id:C.id?C.id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"ID"}),i.jsx("input",{type:"text",value:fn.id,onChange:w=>zn(j=>({...j,id:w.target.value})),placeholder:"content-cleanup-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:fn.description,onChange:w=>zn(j=>({...j,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Qn.length," 个节点和 ",tp.length," 条内部连线。"]}),vn?i.jsx("div",{className:"af-flow-snippet-error",children:vn}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>hr(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:is||!fn.name.trim(),onClick:()=>void ML(),children:is?"发布中...":"发布"})]})]})}),document.body):null,k0?i.jsx(HJ,{node:k0,onClose:()=>U("")}):null,vr?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":Co?"新建分享":"发布展示页",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),Co?"新建分享":"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Sr(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{type:"text",value:st.title,onChange:w=>zt(j=>({...j,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),Co?null:i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:st.layout,onChange:w=>zt(j=>({...j,layout:w.target.value})),children:[i.jsx("option",{value:"gallery",children:"Gallery"}),i.jsx("option",{value:"document",children:"Document"}),i.jsx("option",{value:"slides",children:"Slides"})]})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"有效期"}),i.jsx("select",{className:"af-display-share-select",value:rC(st),onChange:w=>{const j=w.target.value;zt(C=>({...C,permanent:j==="permanent",expiresInDays:j==="permanent"?C.expiresInDays||30:Number(j)}))},children:Nw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),i.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":Co?"分享内容":"选择展示节点",children:[Co?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,g2.map(w=>{var C;const j=Array.isArray(st.nodeIds)&&st.nodeIds.includes(w.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:j,disabled:Co,onChange:()=>DL(w.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((C=w.data)==null?void 0:C.label)||w.id}),i.jsxs("small",{children:[Cn(w.data)," · ",w.id]})]})]},w.id)})]}),me!=null&&me.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:me.absoluteUrl,onFocus:w=>w.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(me.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void $0(),children:ut==="copied"?"已复制":ut==="failed"?"复制失败":"复制"})]}):null,$r?i.jsx("div",{className:"af-flow-snippet-error",children:$r}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Sr(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Wn||!Array.isArray(st.nodeIds)||st.nodeIds.length===0,onClick:()=>void zL(),children:Wn?"生成中...":"生成链接"})]})]})}),document.body):null,Nr?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{Ut(""),mr(!1)},"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[me!=null&&me.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:me.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(me.absoluteUrl,"_blank","noopener,noreferrer"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),i.jsxs("button",{type:"button",onClick:()=>void $0(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ut==="copied"?"check":"content_copy"}),ut==="copied"?"已复制":ut==="failed"?"复制失败":"复制"]})]}):i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"新链接有效期"}),i.jsx("select",{className:"af-display-share-select",value:rC(st),onChange:w=>{const j=w.target.value;zt(C=>({...C,permanent:j==="permanent",expiresInDays:j==="permanent"?C.expiresInDays||30:Number(j)}))},children:Nw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),$r?i.jsx("div",{className:"af-flow-snippet-error",children:$r}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{Ut(""),mr(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Wn||P.nodeIds.length===0,onClick:()=>void BL(),children:Wn?"生成中...":me!=null&&me.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,K$?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"协作分享",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Pg(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("div",{className:"af-workspace-team-share",children:[i.jsxs("div",{className:"af-workspace-team-share__head",children:[i.jsx("strong",{children:"分享到团队"}),i.jsx("span",{children:Ws?Ws.name:"尚未加入团队"})]}),Ws?i.jsxs("div",{className:"af-workspace-team-share__actions",children:[i.jsxs("select",{value:Tg,onChange:w=>oS(w.target.value),"aria-label":"团队权限",children:[i.jsx("option",{value:"viewer",children:"只读"}),i.jsx("option",{value:"editor",children:"可编辑和运行"})]}),(H0=Tt==null?void 0:Tt.teamShares)!=null&&H0.some(w=>w.teamId===Ws.id)?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:du,onClick:()=>void py(!1),children:du?"处理中...":"更新权限"}),i.jsx("button",{type:"button",disabled:du,onClick:()=>void py(!0),children:"取消分享"})]}):i.jsx("button",{type:"button",disabled:du,onClick:()=>void py(!1),children:du?"分享中...":"分享到团队"})]}):i.jsx("p",{className:"af-display-link-modal__empty",children:"联系超级管理员将你加入团队后,即可在这里分享。"})]}),i.jsx("p",{className:"af-display-link-modal__empty",children:"输入已注册用户名。添加后,这个 Workspace 会直接出现在对方的项目列表中。"}),i.jsxs("div",{className:"af-workspace-member-add",children:[i.jsx("input",{type:"text",value:uu,onChange:w=>rS(w.target.value),onKeyDown:w=>{w.key==="Enter"&&uu.trim()&&!Rg&&(w.preventDefault(),T0())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:Rg||!uu.trim(),onClick:()=>void T0(),children:Rg?"添加中...":"添加成员"})]}),nS?i.jsx("div",{className:"af-flow-snippet-error",children:nS}):null,i.jsx("div",{className:"af-workspace-member-list",children:((Tt==null?void 0:Tt.members)||[]).map(w=>{const j=w.userId===(Tt==null?void 0:Tt.ownerId)||w.role==="owner";return i.jsxs("div",{className:"af-workspace-member-row",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:j?"shield_person":"person"}),i.jsxs("div",{children:[i.jsx("strong",{children:w.username||w.userId}),i.jsx("small",{children:j?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),j?null:i.jsx("button",{type:"button",disabled:sS===w.userId,onClick:()=>void LL(w),children:sS===w.userId?"移除中...":"取消分享"})]},w.userId)})})]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Pg(!1),children:"完成"})})]})}),document.body):null,Gt?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-shares-modal",role:"dialog","aria-modal":"true","aria-label":"我的分享",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Xn(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("div",{className:"af-display-shares-toolbar",children:[i.jsx("span",{children:ot.length?`${ot.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void Ys(),disabled:zs,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),Bs?i.jsx("div",{className:"af-flow-snippet-error",children:Bs}):null,zs?i.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!zs&&ot.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:ot.map(w=>{const j=iC(w),C=ve===w.id,I=w.expiresAt?String(w.expiresInDays||30):"permanent";return i.jsxs("article",{className:"af-display-share-item",children:[i.jsxs("div",{className:"af-display-share-item__main",children:[i.jsx("strong",{children:w.title||"AgentFlow Display"}),i.jsxs("span",{children:[w.flowId||"-"," · ",w.layout||"gallery"," · ",Array.isArray(w.nodeIds)?w.nodeIds.length:0," nodes"]}),i.jsx("small",{children:jJ(w)})]}),i.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:j,onFocus:T=>T.target.select()}),i.jsx("select",{className:"af-display-share-select",value:I,disabled:C,onChange:T=>void HL(w,T.target.value),"aria-label":"修改分享有效期",children:Nw.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsxs("div",{className:"af-display-share-item__actions",children:[i.jsxs("button",{type:"button",onClick:()=>window.open(j,"_blank","noopener,noreferrer"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),i.jsxs("button",{type:"button",onClick:()=>void WL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:bt===w.id?"check":"content_copy"}),bt===w.id?"已复制":"复制"]}),i.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:C,onClick:()=>void VL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:C?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,Qt?lr.createPortal(i.jsx("div",{className:"af-flow-snippet-modal-overlay",children:i.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[i.jsxs("div",{className:"af-flow-snippet-modal__head",children:[i.jsxs("span",{className:"af-flow-snippet-modal__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>pn(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-display-picker-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:$n,onChange:w=>vs(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":I0.length||1},children:np.length>0?I0.map((w,j)=>i.jsx("div",{className:"af-display-picker-column",children:w.map(RL)},`display-picker-column-${j}`)):i.jsx("div",{className:"af-display-picker-empty",children:$l.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>pn(!1),children:"完成"})})]})}),document.body):null,pu.nodeId?lr.createPortal(i.jsx(lX,{files:bl,query:pu.query,onQueryChange:w=>Dg(j=>({...j,query:w})),onSelect:vL,onUpload:f0,onClose:ry}),document.body):null,!dt&&!_n&&we?lr.createPortal(i.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>$e(!1),children:i.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:w=>w.stopPropagation(),children:[i.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[i.jsx("button",{type:"button",role:"tab","aria-selected":Ae==="nodes",className:"af-workspace-quick-add__tab"+(Ae==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ze("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":Ae==="flows",className:"af-workspace-quick-add__tab"+(Ae==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>Ze("flows"),children:"流程"})]}),i.jsxs("div",{className:"af-workspace-quick-add__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:IS,value:wn,onChange:w=>Lt(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),$e(!1);else if(w.key==="ArrowDown"){w.preventDefault();const j=Ae==="flows"?Tu.length:Ru.length;rr(C=>Math.min(Math.max(0,j-1),C+1))}else w.key==="ArrowUp"?(w.preventDefault(),rr(j=>Math.max(0,j-1))):w.key==="Tab"?(w.preventDefault(),Ze(j=>j==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),Ae==="flows"?O0(Tu[Sn]||Tu[0]):L0(Ru[Sn]||Ru[0]))},placeholder:Ae==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ae==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:Ae==="flows"?Tu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:Gn?"正在加载流程片段...":kn||"没有匹配的流程片段"}):Tu.map((w,j)=>{const C=w.displayName||w.name||w.id,I=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,T=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,q=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(I||{}).length,X=Number.isFinite(Number(w.edgeCount))?Number(w.edgeCount):Array.isArray(T)?T.length:0;return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(j===Sn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>rr(j),onClick:()=>O0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:C}),i.jsxs("span",{className:"af-workspace-quick-add__meta",children:[w.id,w.version?` · v${w.version}`:""]}),i.jsx("span",{className:"af-workspace-quick-add__desc",children:w.description||`${q} 节点 / ${X} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):Ru.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Ru.map((w,j)=>{const C=ad(w),I=ld(w),T=Eb(w);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(j===Sn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>rr(j),onClick:()=>L0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:J_(C)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:I}),i.jsx("span",{className:"af-workspace-quick-add__meta",children:w.id}),T?i.jsx("span",{className:"af-workspace-quick-add__desc",children:T}):null]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:C})]},w.id)})})]})}),document.body):null]})]})}function KM(){return i.jsx(sv,{children:i.jsx(AX,{})})}function EX(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=(e==null?void 0:e.kind)==="image"?"src":"content",r=a=>String((a==null?void 0:a.value)??(a==null?void 0:a.default)??""),s=a=>r(a).trim(),o=t.find(a=>(a==null?void 0:a.name)===n&&s(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&s(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&s(a));return String((e==null?void 0:e.body)||(o?r(o):""))}function IX(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function PX(e){let t=String(e||"").replace(/\r\n/g,`
266
- `).trim();return t.includes(`
267
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
268
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
269
- $2`)),t}function qM(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=PX(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
270
- `).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
271
- `).replace(/\s+$/g,""):p.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function Ov(e){let t=qM(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const s=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return s>0&&(t=t.slice(s).trim()),t}function RX(e){const t=Ov(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function TX(e){const t=Ov(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
272
- (() => {
273
- document.addEventListener("click", (event) => {
274
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
275
- if (!link) return;
276
- const rawHref = String(link.getAttribute("href") || "").trim();
277
- if (!rawHref || rawHref.startsWith("#")) return;
278
- if (/^javascript:/i.test(rawHref)) {
279
- event.preventDefault();
280
- return;
281
- }
282
- event.preventDefault();
283
- window.open(link.href, "_blank", "noopener,noreferrer");
284
- }, true);
285
- })();
286
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function UM(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=new URLSearchParams;return s.set("id",t),s.set("path",r),n.download&&s.set("download","1"),`/api/display/file/raw?${s.toString()}`}function MX(e,t,n={}){const r=String(e||"").trim();return r?UM(r,t,n):""}function $X({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,y=h?Math.max(12,d/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,p.scrollTop/Math.max(1,f-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const d=new ResizeObserver(a);d.observe(f);for(const h of Array.from(f.children))d.observe(h);return()=>{cancelAnimationFrame(p),d.disconnect()}},[t,a]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(p-h.top-f)/v},[s.height]),u=m.useCallback(p=>{if(!s.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=s.top/100*d.height,y=s.height/100*d.height,b=p.clientY>=d.top+h&&p.clientY<=d.top+h+y?p.clientY-d.top-h:y/2;l(c(p.clientY,b));const g=x=>{x.preventDefault(),l(c(x.clientY,b))},k=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[c,l,s.height,s.top,s.visible]);return i.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[i.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),i.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function $b({node:e,shareId:t,style:n,bare:r=!1}){const s=EX(e),o=e.kind==="html"?Ov(s):e.kind==="react"?vg(s):qM(s),a=e.kind==="html"?RX(o):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return i.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}${r?" af-public-display-node--bare":""}`,style:n,children:[r?null:i.jsx("div",{className:"af-public-display-node__head",children:i.jsxs("div",{className:"af-public-display-node__title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:IX(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx($X,{className:l,children:a?i.jsx("div",{className:"af-public-display-empty",children:a}):o.trim()?i.jsxs(i.Fragment,{children:[e.kind==="html"?i.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:TX(o)}):null,e.kind==="react"?i.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:Cv(o)}):null,e.kind==="image"?i.jsx("img",{src:UM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(kv,{content:o,resolveSrc:(c,u)=>MX(c,t,u)})}):null,e.kind==="chart"?i.jsx(Sv,{content:o}):null,e.kind==="table"?i.jsx(vv,{content:o}):null,e.kind==="mermaid"||e.kind==="ascii"?i.jsx("pre",{children:o}):null]}):i.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function LX({data:e}){return i.jsx($b,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const OX={publicDisplay:LX};function DX(e){const t=String(e||"").split("/").filter(Boolean);return t[0]==="display"&&t[1]?decodeURIComponent(t[1]):new URLSearchParams(window.location.search).get("id")||""}function GM(){var l,c,u,p;const{path:e}=rs(),t=m.useMemo(()=>DX(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function d(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(y.error||"展示页不存在");f||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return d(),()=>{f=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((d,h)=>{const y=d.position&&typeof d.position.x=="number"&&typeof d.position.y=="number"?d.position:{x:120+h*40,y:100+h*32},v=d.size&&typeof d.size.width=="number"&&typeof d.size.height=="number"?d.size:{width:520,height:320};return{id:d.id,type:"publicDisplay",position:y,data:{node:d,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(v.width)||520),height:Math.max(1,Number(v.height)||320)}}}),[t,n.nodes]),o=m.useMemo(()=>{var v;const f=(v=n.share)==null?void 0:v.viewport;if(!f||typeof f!="object")return null;const d=Number(f.x),h=Number(f.y),y=Number(f.zoom);return!Number.isFinite(d)||!Number.isFinite(h)||!Number.isFinite(y)?null:{x:d,y:h,zoom:Math.min(Math.max(y,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return i.jsx("main",{className:"af-public-display-page",children:i.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return i.jsx("main",{className:"af-public-display-page",children:i.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),i.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return i.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>i.jsx($b,{node:d,shareId:t,bare:!0},d.id))})});const f=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return i.jsxs("main",{className:`af-public-display-page ${f}`,children:[i.jsxs("header",{className:"af-public-display-hero",children:[i.jsxs("div",{children:[i.jsx("p",{children:"AgentFlow Display"}),i.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),i.jsx("span",{children:(p=n.share)!=null&&p.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>i.jsx($b,{node:d,shareId:t},d.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(sv,{children:i.jsx(HR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:OX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:o||void 0,fitView:!o,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:i.jsx(KR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const xt=e=>typeof e=="string",Xu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},xC=e=>e==null?"":""+e,FX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},zX=/###/g,bC=e=>e&&e.indexOf("###")>-1?e.replace(zX,"."):e,kC=e=>!e||xt(e),Pd=(e,t,n)=>{const r=xt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(kC(e))return{};const o=bC(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return kC(e)?{}:{obj:e,k:bC(r[s])}},vC=(e,t,n)=>{const{obj:r,k:s}=Pd(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let o=t[t.length-1],a=t.slice(0,t.length-1),l=Pd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Pd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},BX=(e,t,n,r)=>{const{obj:s,k:o}=Pd(e,t,Object);s[o]=s[o]||[],s[o].push(n)},Rm=(e,t)=>{const{obj:n,k:r}=Pd(e,t);if(n)return n[r]},WX=(e,t,n)=>{const r=Rm(e,n);return r!==void 0?r:Rm(t,n)},YM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?xt(e[r])||e[r]instanceof String||xt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):YM(e[r],t[r],n):e[r]=t[r]);return e},Jl=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var HX={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const VX=e=>xt(e)?e.replace(/[&<>"'\/]/g,t=>HX[t]):e;class KX{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const n=this.regExpMap.get(t);if(n!==void 0)return n;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const qX=[" ",",","?","!",";"],UX=new KX(20),GX=(e,t,n)=>{t=t||"",n=n||"";const r=qX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=UX.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!s.test(e);if(!o){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(o=!0)}return o},Lb=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let o=0;o<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=o;c<r.length;++c)if(c!==o&&(l+=n),l+=r[c],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;o+=c-o+1;break}s=a}return s},Tm=e=>e&&e.replace("_","-"),YX={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console&&console[e]&&console[e].apply(console,t)}};class Mm{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(t,n)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||YX,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(xt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Mm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Mm(this.logger,t)}}var Pi=new Mm;class Ng{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l.apply(l,[t,...r])})}}class SC extends Ng{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):xt(r)&&o?l.push(...r.split(o)):l.push(r)));const c=Rm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!xt(r)?c:Lb(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,s){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),s=n,n=l[1]),this.addNamespaces(n),vC(this.data,l,s),o.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(xt(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=Rm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?YM(c,r,o):c={...c,...r},vC(this.data,l,c),a.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(s=>n[s]&&Object.keys(n[s]).length>0)}toJSON(){return this.data}}var JM={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,s))}),t}};const jC={};class $m extends Ng{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),FX(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Pi.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;const r=this.resolve(t,n);return r&&r.res!==void 0}extractFromKey(t,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!GX(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:xt(o)?[o]:o};const u=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(s)}return{key:t,namespaces:xt(o)?[o]:o}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(p){const _=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${_}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${_}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let d=f&&f.res;const h=f&&f.usedKey||a,y=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(d),b=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!xt(d)&&typeof d!="boolean"&&typeof d!="number";if(k&&d&&x&&b.indexOf(v)<0&&!(xt(g)&&Array.isArray(d))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,d,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=_,f.usedParams=this.getUsedParamsDetails(n),f):_}if(o){const _=Array.isArray(d),S=_?[]:{},N=_?y:h;for(const P in d)if(Object.prototype.hasOwnProperty.call(d,P)){const R=`${N}${o}${P}`;S[P]=this.translate(R,{...n,joinArrays:!1,ns:l}),S[P]===R&&(S[P]=d[P])}d=S}}else if(k&&xt(g)&&Array.isArray(d))d=d.join(g),d&&(d=this.extendTranslation(d,t,n,r));else{let _=!1,S=!1;const N=n.count!==void 0&&!xt(n.count),P=$m.hasDefaultValue(n),R=N?this.pluralResolver.getSuffix(u,n.count,n):"",z=n.ordinal&&N?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",E=N&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),O=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${R}`]||n[`defaultValue${z}`]||n.defaultValue;!this.isValidLookup(d)&&P&&(_=!0,d=O),this.isValidLookup(d)||(S=!0,d=a);const L=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&S?void 0:d,M=P&&O!==d&&this.options.updateMissing;if(S||_||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?O:d),o){const $=this.resolve(a,{...n,keySeparator:!1});$&&$.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let V=[];const B=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&B&&B[0])for(let $=0;$<B.length;$++)V.push(B[$]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(n.lng||this.language):V.push(n.lng||this.language);const F=($,H,A)=>{const Q=P&&A!==d?A:L;this.options.missingKeyHandler?this.options.missingKeyHandler($,c,H,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing($,c,H,Q,M,n),this.emit("missingKey",$,c,H,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?V.forEach($=>{const H=this.pluralResolver.getSuffixes($,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(A=>{F([$],a+A,n[`defaultValue${A}`]||O)})}):F(V,a,O))}d=this.extendTranslation(d,t,n,f,r),S&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${c}:${a}`),(S||_)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,_?d:void 0):d=this.options.parseMissingKeyHandler(d))}return s?(f.res=d,f.usedParams=this.getUsedParamsDetails(n),f):d}extendTranslation(t,n,r,s,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=xt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(u){const d=t.match(this.interpolator.nestingRegexp);p=d&&d.length}let f=r.replace&&!xt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),u){const d=t.match(this.interpolator.nestingRegexp),h=d&&d.length;p<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var d=arguments.length,h=new Array(d),y=0;y<d;y++)h[y]=arguments[y];return o&&o[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=xt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=JM.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,s,o,a,l;return xt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),p=u.key;s=p;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const d=n.count!==void 0&&!xt(n.count),h=d&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(xt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!jC[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(jC[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${s}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(g=>{if(this.isValidLookup(r))return;a=g;const k=[p];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,p,g,b,n);else{let _;d&&(_=this.pluralResolver.getSuffix(g,n.count,n));const S=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(k.push(p+_),n.ordinal&&_.indexOf(N)===0&&k.push(p+_.replace(N,this.options.pluralSeparator)),h&&k.push(p+S)),y){const P=`${p}${this.options.contextSeparator}${n.context}`;k.push(P),d&&(k.push(P+_),n.ordinal&&_.indexOf(N)===0&&k.push(P+_.replace(N,this.options.pluralSeparator)),h&&k.push(P+S))}}let x;for(;x=k.pop();)this.isValidLookup(r)||(o=x,r=this.getResource(g,b,x,n))}))})}),{res:r,usedKey:s,exactUsedKey:o,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!xt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const o of n)delete s[o]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const Aw=e=>e.charAt(0).toUpperCase()+e.slice(1);class NC{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Pi.create("languageUtils")}getScriptPartFromCode(t){if(t=Tm(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=Tm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(xt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Aw(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Aw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Aw(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),xt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],o=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return xt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):xt(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let JX=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],XX={1:e=>+(e>1),2:e=>+(e!=1),3:e=>0,4:e=>e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,5:e=>e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5,6:e=>e==1?0:e>=2&&e<=4?1:2,7:e=>e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2,8:e=>e==1?0:e==2?1:e!=8&&e!=11?2:3,9:e=>+(e>=2),10:e=>e==1?0:e==2?1:e<7?2:e<11?3:4,11:e=>e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3,12:e=>+(e%10!=1||e%100==11),13:e=>+(e!==0),14:e=>e==1?0:e==2?1:e==3?2:3,15:e=>e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2,16:e=>e%10==1&&e%100!=11?0:e!==0?1:2,17:e=>e==1||e%10==1&&e%100!=11?0:1,18:e=>e==0?0:e==1?1:2,19:e=>e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3,20:e=>e==1?0:e==0||e%100>0&&e%100<20?1:2,21:e=>e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0,22:e=>e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3};const QX=["v1","v2","v3"],ZX=["v4"],_C={zero:0,one:1,two:2,few:3,many:4,other:5},eQ=()=>{const e={};return JX.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:XX[t.fc]}})}),e};class tQ{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Pi.create("pluralResolver"),(!this.options.compatibilityJSON||ZX.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=eQ(),this.pluralRulesCache={}}addRule(t,n){this.rules[t]=n}clearCache(){this.pluralRulesCache={}}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const r=Tm(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:s});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[o]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(s=>`${n}${s}`)}getSuffixes(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort((s,o)=>_C[s]-_C[o]).map(s=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${s}`):r.numbers.map(s=>this.getSuffix(t,s,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=this.getRule(t,r);return s?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s.select(n)}`:this.getSuffixRetroCompatible(s,n):(this.logger.warn(`no plural rule found for: ${t}`),"")}getSuffixRetroCompatible(t,n){const r=t.noAbs?t.plurals(n):t.plurals(Math.abs(n));let s=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(s===2?s="plural":s===1&&(s=""));const o=()=>this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString();return this.options.compatibilityJSON==="v1"?s===1?"":typeof s=="number"?`_plural_${s.toString()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!QX.includes(this.options.compatibilityJSON)}}const CC=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=WX(e,t,n);return!o&&s&&xt(n)&&(o=Lb(e,n,r),o===void 0&&(o=Lb(t,n,r))),o},Ew=e=>e.replace(/\$/g,"$$$$");class nQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pi.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||(n=>n),this.init(t)}init(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:s,prefix:o,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:p,unescapePrefix:f,nestingPrefix:d,nestingPrefixEscaped:h,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:VX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?Jl(o):a||"{{",this.suffix=l?Jl(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=d?Jl(d):h||Jl("$t("),this.nestingSuffix=y?Jl(y):v||Jl(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=g||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let o,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const g=CC(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...s,...n,interpolationkey:h}):g}const y=h.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(CC(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const p=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Ew(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Ew(this.escape(h)):Ew(h)}].forEach(h=>{for(l=0;o=h.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof p=="function"){const b=p(t,o,s);a=xt(b)?b:""}else if(s&&Object.prototype.hasOwnProperty.call(s,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!xt(a)&&!this.useRawValueToEscape&&(a=xC(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,o,a;const l=(c,u)=>{const p=this.nestingOptionsSeparator;if(c.indexOf(p)<0)return c;const f=c.split(new RegExp(`${p}[ ]*{`));let d=`{${f[1]}`;c=f[0],d=this.interpolate(d,a);const h=d.match(/'/g),y=d.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(d=d.replace(/'/g,'"'));try{a=JSON.parse(d),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${p}${d}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!xt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const p=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=p.shift(),c=p,u=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!xt(o))return o;xt(o)||(o=xC(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((p,f)=>this.format(p,f,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const rQ=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),p=l.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Xl=e=>{const t={};return(n,r,s)=>{let o=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(o={...o,[s.interpolationkey]:void 0});const a=r+JSON.stringify(o);let l=t[a];return l||(l=e(Tm(r),s),t[a]=l),l(n)}};class sQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Pi.create("formatter"),this.options=t,this.formats={number:Xl((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Xl((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Xl((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Xl((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Xl((n,r)=>{const s=new Intl.ListFormat(n,{...r});return o=>s.format(o)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Xl(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(l=>l.indexOf(")")>-1)){const l=o.findIndex(c=>c.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,l)].join(this.formatSeparator)}return o.reduce((l,c)=>{const{formatName:u,formatOptions:p}=rQ(c);if(this.formats[u]){let f=l;try{const d=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=d.locale||d.lng||s.locale||s.lng||r;f=this.formats[u](l,h,{...p,...s,...d})}catch(d){this.logger.warn(d)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const iQ=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class oQ extends Ng{constructor(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=t,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=s,this.logger=Pi.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,s.backend,s)}queueLoad(t,n,r,s){const o={},a={},l={},c={};return t.forEach(u=>{let p=!0;n.forEach(f=>{const d=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?a[d]===void 0&&(a[d]=!0):(this.state[d]=1,p=!1,a[d]===void 0&&(a[d]=!0),o[d]===void 0&&(o[d]=!0),c[f]===void 0&&(c[f]=!0)))}),p||(l[u]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const s=t.split("|"),o=s[0],a=s[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{BX(c.loaded,[o],a),iQ(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const p=c.loaded[u];p.length&&p.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:o,callback:a});return}this.readingCalls++;const l=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&p&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(u,p)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(p=>l(null,p)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();xt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),xt(n)&&(n=[n]);const o=this.queueLoad(t,n,r,s);if(!o.toLoad.length)return o.pending.length||s(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],o=r[1];this.read(s,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let p;u.length===5?p=u(t,n,r,s,c):p=u(t,n,r,s),p&&typeof p.then=="function"?p.then(f=>l(null,f)).catch(l):l(null,p)}catch(p){l(p)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const AC=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),xt(e[1])&&(t.defaultValue=e[1]),xt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),EC=e=>(xt(e.ns)&&(e.ns=[e.ns]),xt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),xt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),eh=()=>{},aQ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class hf extends Ng{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=EC(t),this.services={},this.logger=Pi,this.modules={external:[]},aQ(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(xt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=AC();this.options={...s,...this.options,...EC(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...s.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?Pi.init(o(this.modules.logger),this.options):Pi.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:typeof Intl<"u"&&(p=sQ);const f=new NC(this.options);this.store=new SC(this.options.resources,this.options);const d=this.services;d.logger=Pi,d.resourceStore=this.store,d.languageUtils=f,d.pluralResolver=new tQ(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(d.formatter=o(p),d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new nQ(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new oQ(o(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.languageDetector&&(d.languageDetector=o(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=o(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new $m(this.services,this.options),this.translator.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=eh),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return t.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return t.store[p](...arguments),t}});const c=Xu(),u=()=>{const p=(f,d)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(d),r(f,d)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:eh;const s=xt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Xu();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=eh),this.services.backendConnector.reload(t,n,o=>{s.resolve(),r(o)}),s}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&JM.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const s=Xu();this.emit("languageChanging",t);const o=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const u=xt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,p=>{a(p,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const o=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),f=2;f<u;f++)p[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(p))}else c={...l};c.lng=c.lng||o.lng,c.lngs=c.lngs||o.lngs,c.ns=c.ns||o.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||o.keyPrefix);const d=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${d}${y}`):h=c.keyPrefix?`${c.keyPrefix}${d}${a}`:a,s.t(h,c)};return xt(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(o,t)))}loadNamespaces(t,n){const r=Xu();return this.options.ns?(xt(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Xu();xt(t)&&(t=[t]);const s=this.options.preload||[],o=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=s.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new NC(AC());return n.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new hf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:eh;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new hf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(l=>{o[l]=this[l]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new SC(this.store.data,s),o.services.resourceStore=o.store),o.translator=new $m(o.services,s),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),p=1;p<c;p++)u[p-1]=arguments[p];o.emit(l,...u)}),o.init(s,n),o.translator.options=s,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const kr=hf.createInstance();kr.createInstance=hf.createInstance;kr.createInstance;kr.dir;kr.init;kr.loadResources;kr.reloadResources;kr.use;kr.changeLanguage;kr.getFixedT;kr.t;kr.exists;kr.setDefaultNamespace;kr.hasLoadedNamespace;kr.loadNamespaces;kr.loadLanguages;function lQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mf(e){"@babel/helpers - typeof";return mf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mf(e)}function cQ(e,t){if(mf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(mf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function uQ(e){var t=cQ(e,"string");return mf(t)=="symbol"?t:t+""}function dQ(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,uQ(r.key),r)}}function fQ(e,t,n){return t&&dQ(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var XM=[],pQ=XM.forEach,hQ=XM.slice;function mQ(e){return pQ.call(hQ.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var IC=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,gQ=function(t,n,r){var s=r||{};s.path=s.path||"/";var o=encodeURIComponent(n),a="".concat(t,"=").concat(o);if(s.maxAge>0){var l=s.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(s.domain){if(!IC.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!IC.test(s.path))throw new TypeError("option path is invalid");a+="; Path=".concat(s.path)}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(s.expires.toUTCString())}if(s.httpOnly&&(a+="; HttpOnly"),s.secure&&(a+="; Secure"),s.sameSite){var c=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(c){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a},PC={create:function(t,n,r,s){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),s&&(o.domain=s),document.cookie=gQ(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var o=r[s];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},yQ={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=PC.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&PC.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},wQ={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),o=s.split("&"),a=0;a<o.length;a++){var l=o[a].indexOf("=");if(l>0){var c=o[a].substring(0,l);c===t.lookupQuerystring&&(n=o[a].substring(l+1))}}}return n}},Qu=null,RC=function(){if(Qu!==null)return Qu;try{Qu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Qu=!1}return Qu},xQ={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&RC()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&RC()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Zu=null,TC=function(){if(Zu!==null)return Zu;try{Zu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zu=!1}return Zu},bQ={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&TC()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&TC()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},kQ={name:"navigator",lookup:function(t){var n=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)n.push(navigator.languages[r]);navigator.userLanguage&&n.push(navigator.userLanguage),navigator.language&&n.push(navigator.language)}return n.length>0?n:void 0}},vQ={name:"htmlTag",lookup:function(t){var n,r=t.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},SQ={name:"path",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof t.lookupFromPathIndex=="number"){if(typeof r[t.lookupFromPathIndex]!="string")return;n=r[t.lookupFromPathIndex].replace("/","")}else n=r[0].replace("/","")}return n}},jQ={name:"subdomain",lookup:function(t){var n=typeof t.lookupFromSubdomainIndex=="number"?t.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},QM=!1;try{document.cookie,QM=!0}catch{}var ZM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];QM||ZM.splice(1,1);function NQ(){return{order:ZM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var e$=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};lQ(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return fQ(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=mQ(r,this.options||{},NQ()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(yQ),this.addDetector(wQ),this.addDetector(xQ),this.addDetector(bQ),this.addDetector(kQ),this.addDetector(vQ),this.addDetector(SQ),this.addDetector(jQ)}},{key:"addDetector",value:function(n){return this.detectors[n.name]=n,this}},{key:"detect",value:function(n){var r=this;n||(n=this.options.order);var s=[];return n.forEach(function(o){if(r.detectors[o]){var a=r.detectors[o].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(o){return r.options.convertDetectedLanguage(o)}),this.services.languageUtils.getBestMatchFromCodes?s:s.length>0?s[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var s=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){s.detectors[o]&&s.detectors[o].cacheUserLanguage(n,s.options)}))}}])}();e$.type="languageDetector";const _Q={name:"AgentFlow",tagline:"AI Workflow Orchestration"},CQ={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},AQ={loading:"Loading...",saving:"Saving...",save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",create:"Create",close:"Close",confirm:"Confirm",copy:"Copy",copied:"Copied!",refresh:"Refresh",search:"Search",filter:"Filter",success:"Success",error:"Error",warning:"Warning",info:"Info",done:"Done",pending:"Pending",running:"Running",notFound:"Not found",required:"Required",optional:"Optional"},EQ={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},IQ={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},PQ={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},RQ={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},TQ={app:_Q,nav:CQ,common:AQ,status:EQ,nodeTypes:IQ,engine:PQ,links:RQ},MQ="Flow Editor",$Q="Nodes",LQ="Edges",OQ="Properties",DQ={label:"Node Label",type:"Node Type",model:"Model",body:"Body",inputs:"Inputs",outputs:"Outputs",addInput:"Add Input",addOutput:"Add Output",remove:"Remove Node",duplicate:"Duplicate Node",nodeType:"Node Type",displayName:"Display Name",displayNameHint:"(letters, numbers, underscores, hyphens, do not start with a number)",role:"Role",modelHint:"From ~/agentflow/model-lists.json; UI service runs agentflow update-model-lists in background on startup",defaultModel:"Default",userPrompt:"User Prompt (USER PROMPT / body)",systemDescription:"System Description (read-only, from node definition)",directCommand:"Direct Command (script)",scriptHint:"(tool_nodejs: skips AI when script exists, executed by pipeline)",diskRunning:"Disk record shows running",deleteNode:"Delete node",inputTooltip:"Input {{name}} | Type: {{type}}",outputTooltip:"Output {{name}} | Type: {{type}}",defaultSuffix:" | Default: {{value}}",fallbackLabel:"Node",expandProvide:"Edit content"},FQ={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",description:"Description / format",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",pinDescriptionAriaLabel:"{{label}} {{index}} format description",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},zQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},BQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},WQ={workspace:"Workspace",loading:"Loading...",archived:"Archived",noPipelines:"No pipelines",more:"more",moreFlows:"more flows",noRuns:"No run records",searchNodes:"Search nodes",noComponents:"No components available (check node library directory)",noMatch:"No matching nodes, adjust search terms",selectPipeline:"Select a pipeline from above to load components and canvas",validationWarnings:"Validation warnings (consistent with agentflow validate slot checks)",output:"Output",model:"Model",userDir:"User Directory",toggleRecentActivity:"Toggle recent opened or recent runs"},HQ={selectPipeline:"Please select a pipeline from the dropdown above",loadingProps:"Loading node properties...",pipelineId:"Pipeline ID",diskPath:"Disk Path",storageLocation:"Storage Location",introduction:"Introduction",introductionPlaceholder:"Briefly describe this pipeline (saved as flow.yaml ui.description)",metadata:"Metadata",nodeCount:"Node Count",nodesUnit:"nodes",loading:"Loading...",noRuns:"No run records (run records are generated in the workspace after terminal execution)"},VQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},KQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},qQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},UQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},GQ={title:"Node Execution Context",resizeHandle:"Drag to resize node context width",apiConnectError:"Cannot connect to API (please open the page with agentflow ui, or configure /api proxy for Vite dev)",invalidJson:"Response is not valid JSON",requestTimeout:"Request timed out, please retry or check agentflow ui",executingNoArtifacts:"Executing, artifacts not yet written to workspace…",noData:"No data (this run has not reached this node or produced artifacts)",latest:"Latest",detectedContentType:"Detected content type",roundNoContent:"No content in this round",empty:"(empty)",imageTruncated:"Image truncated (exceeds size limit)",statusSuccess:"Success",statusFailed:"Failed",statusRunning:"Running",statusCacheMiss:"Cache miss",statusPending:"Pending"},YQ={title:"Keyboard Shortcuts",general:"General",saveDesc:"Save; when node properties sidebar is open, submit node first then save flow",shortcutsLabel:"Keyboard Shortcuts",jumpToNode:"Jump to node by ID",openNodePalette:"Open node palette",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",saveViewport:"Save current entry view",selectAll:"Select all nodes",undo:"Undo canvas change",redo:"Redo canvas change"},JQ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},XQ={title:"Start Building Your Flow",text:"Describe your workflow in the AI input box below, or drag nodes from the left panel to the canvas",composerHint:"Build AgentFlow with AI Composer",composerSub:"Drag nodes from the left panel, or describe your workflow in the <strong>input box below</strong>.<br/>Press <kbd>?</kbd> to view shortcuts."},QQ={mainNav:"Main Navigation"},ZQ={flowWarningAriaLabel:"Flow validation warnings",reloadFromServer:"Reload flow from server and refresh validation",reloadFromServerShort:"Reload from server",closeBanner:"Close validation warning banner",nodePrefix:"Node",focusNodeAriaLabel:"Select and focus node {{nodeId}} on canvas",slotWarningCount:"Slot validation: {{count}} warnings (hidden)",show:"Show",shortcutHint:"Press ? to view keyboard shortcuts",shortcutHintLabel:"shortcuts",inputSlotNoEdge:' input slot "{{slotName}}" ({{handle}}) has no edge connection',outputSlotNoEdge:' output slot "{{slotName}}" ({{handle}}) has no edge connection'},eZ={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
287
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
288
- Current: {{current}}`,phaseComplete:"{{phaseName}} completed. Next phase: {{nextPhase}}",nextPhase:"Next phase",continuePhase:"Continue {{label}}",skipRemainingPhases:"Please complete all remaining steps at once (skip phased confirmation)",phaseProgress:"Phase progress",phaseReviewLabel:"Phase options",phaseReviewHint:'This phase is complete. Review the canvas, then continue to "{{nextPhase}}".',phaseReviewContinue:"Continue: {{label}}",phaseReviewSkip:"Skip — finish remaining in one pass",stepsAriaLabel:"Task steps progress",phasesAriaLabel:"Generation phases progress",phaseNumber:"Phase {{index}}",stepRoleLabel:"Role: {{role}}",stepInstanceLabel:"Instance: {{instanceId}}",pageRefreshReset:"Reset after page refresh",conversationLabel:"Conversation {{n}}"},tZ={currentPipeline:"Current Pipeline",backToEdit:"Back to edit",backToProjects:"Back to projects",executionLog:"Execution log",history:"History",pipelineSettings:"Pipeline settings",shortcutsLabel:"Shortcuts",shortcutsTitle:"Shortcuts (?)",deletePipeline:"Delete pipeline",resumeTitle:"Resume in same run directory (uuid={{uuid}})",resumeTitleNoUuid:"No apply-start received, will start a new run",rerunTitle:"Start a new run from scratch",runOptions:"Run options",runWithParams:"Run with params",runWithPreset:"Run with preset",editRun:"Edit run parameters",startRun:"Start run",stopRun:"Stop background run"},nZ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},rZ={connectingApi:"Connecting to /api/flow/run…",connectingApiResume:"Connecting to /api/flow/run (resuming run uuid={{uuid}})…",connectedReceiving:"Connected to execution stream, receiving NDJSON output…",noBody:"Response has no body (cannot stream), please check browser and agentflow ui version",nodeStart:"▶ Starting: {{instanceId}}",nodeStartWithLabel:"▶ Starting: {{instanceId}} ({{label}})",nodeDone:"✓ Done: {{instanceId}}",nodeDoneWithElapsed:"✓ Done: {{instanceId}} ({{elapsed}})",nodeFailed:"✗ Failed: {{instanceId}}",pipelineStart:"Pipeline started (uuid={{uuid}})",pipelineDone:"Pipeline completed",pipelineDoneWithElapsed:"Pipeline completed ({{elapsed}})",pipelinePaused:"Pipeline paused: waiting for user input ({{nodes}})",unknownError:"Unknown error",executionEnd:"Execution ended (exit code: {{exitCode}})",executionStopped:"Execution paused",pauseRun:"Pause run (can resume later)",pauseConfirm:"Pause the current run? You can resume from the interrupted node later.",pauseTitle:"Pause run",pauseConfirmOk:"Pause",backPromptTitle:"Back to projects",backPromptMessage:"Pipeline still running. Keep it in the background and exit, or stop it and return to edit mode?",backBackground:"Run in background & exit",backStopEdit:"Stop & enter edit",resizeConsole:"Drag to resize execution log height",closeLog:"Close log",userCheckContent:"Waiting for user to confirm content for node {{instanceId}}",userAskPrompt:"Waiting for user to choose branch for node {{instanceId}}"},sZ={close:"Close",loading:"Loading…",placeholder:"File content",largeFileWarning:"Large file, editor performance may be affected",reset:"Reset",aiEdit:"AI Edit",aiRunning:"AI processing…",save:"Save",saving:"Saving…",saved:"Saved"},iZ={title:"Pipeline Settings",subtitle:"Manage basic information, storage, node marketplace, scheduled runs, and metadata.",sectionNav:"Settings sections",basicInfo:"Basic Info",storageAndPath:"Storage & Path",nodeMarketplace:"Node Marketplace",overview:"Pipeline Overview",owner:"Owner",source:"Source",marketplaceNodes:"Marketplace nodes",marketNodesUnit:"market nodes",marketplaceHint:"Local marketplace nodes can be added to this pipeline; installed nodes can then be placed on the canvas.",marketplaceEmpty:"No local marketplace nodes are installed in this workspace yet. Publish one from the node properties panel.",addNodeFromMarket:"Back to canvas",quickActions:"Quick Actions",saveChanges:"Save changes",savingChanges:"Saving…",installNode:"Add to pipeline",installingNode:"Adding…",addInstalledNode:"Add to canvas",previewNode:"Preview",nodePreviewTitle:"Node preview",nodeStylePreview:"Node style preview",closePreview:"Close preview",nodeFunction:"Node purpose",nodePackageInfo:"Package info",definitionId:"Definition ID",version:"Version",packagePath:"Package path",packagedFiles:"Packaged files",marketplaceNoDescription:"No node purpose has been provided.",noInputs:"No inputs",noOutputs:"No outputs",backToCanvas:"Back to canvas",help:"Help",helpText:"Publish nodes from the node properties panel; installed collections sync into the local node marketplace.",archived:"Archived",archivedNote:"This pipeline is in the archive directory (_archived) and cannot be moved between user directory and workspace.",builtinNote:"Built-in templates are read-only; first save will write to workspace .workspace/agentflow/pipelines (pipelines), .workspace/agentflow/nodes (custom nodes), etc.",moveBusy:"Moving…",moveToWorkspace:"Move to workspace",moveToUserDir:"Move to user directory",globalSettings:"Global settings",currentPipeline:"Current pipeline:",builtin:"Built-in",rename:"Rename",renameBusy:"Renaming…",renameSuccess:"Renamed",copyPath:"Copy path",pathCopied:"Copied"},oZ={title:"Scheduled Run",enabled:"Enable scheduled trigger",cron:"Cron expression",timezone:"Timezone",preset:"Run preset",defaultPreset:"Default inputs",overlapSkip:"Overlap policy: skip this trigger while the pipeline is running",nextRun:"Next estimated trigger: {{time}}",noNextRun:"No next trigger is configured",runtime:"Scheduler state",running:"Running",waiting:"Waiting",disabled:"Disabled",lastTriggeredAt:"Last triggered",lastSkippedAt:"Last skipped",lastRun:"Last run",lastExit:"Last exit code",lastFinishedAt:"Last finished",readonlyNote:"Built-in or archived pipelines cannot save schedule settings.",save:"Save schedule",saving:"Saving…",saved:"Schedule saved"},aZ={title:"Execution History",summary:"Execution results summary",successCount:"{{count}} succeeded",failedCount:"{{count}} failed",stoppedCount:"{{count}} stopped",interruptedCount:"{{count}} interrupted",runningCount:"{{count}} running",success:"Success",failed:"Failed",stopped:"Stopped",interrupted:"Interrupted",running:"Running",unknown:"Unknown",runLabel:"Run #{{id}}",enterRunView:"Enter run view with canvas and log"},lZ={invalidInstanceId:"Invalid Instance ID: only letters, numbers, underscores, and hyphens allowed, must not start with a number.",duplicateInstanceId:"This Instance ID already exists, please choose another.",loadFlowFailed:"Failed to load flow",loadNodesFailed:"Failed to load node library"},cZ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},uZ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},dZ={title:"User Confirmation ({{instanceId}})",edit:"Edit",save:"Save",cancel:"Cancel",aiEditPlaceholder:"Enter AI edit instruction, e.g., remove item 2, merge first two items…",aiEditBtn:"AI Edit",aiEditStarted:"AI is modifying content…",aiEditDone:"AI modification complete",aiEditFailed:"AI modification failed",contentSaved:"Content saved",saveFailed:"Save failed",close:"Close",continue:"Continue Execution",hint:"Edit or use AI to modify, then save. Click 'Continue Execution' to resume the flow"},fZ={title:"User Choice ({{instanceId}})",hint:"Pick an option below to continue the flow",submitting:"Submitting…",submitFailed:"Submit failed",close:"Close",noOptions:"No options configured on this node. Add items to the output slots in the editor first."},pZ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},hZ={save:"Save",cancel:"Cancel"},mZ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},gZ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},yZ={preset:"Preset",default:"Default",newPreset:"New preset",deletePreset:"Delete preset",presetNamePlaceholder:"Preset name",inputParams:"Input Parameters",noProvideNodes:"No provide nodes in this flow",filePathPlaceholder:"File path…",stringValuePlaceholder:"Value…",presetSaved:"Preset saved",presetDeleted:"Preset Deleted",savePreset:"Save current preset",expandInput:"Edit content"},wZ={title:MQ,nodes:$Q,edges:LQ,properties:OQ,node:DQ,nodeProps:FQ,actions:zQ,panel:BQ,palette:WQ,pipeline:HQ,status:VQ,roles:KQ,phases:qQ,types:UQ,runContext:GQ,shortcuts:YQ,jumpPalette:JQ,emptyCanvas:XQ,sidebar:QQ,validation:ZQ,composer:eZ,topbar:tZ,palette2:nZ,run:rZ,fileEdit:sZ,settings:iZ,schedule:oZ,history:aZ,nodePropsError:lZ,placeholder:cZ,time:uZ,userCheck:dZ,userAsk:fZ,toolPrint:pZ,provideEdit:hZ,runParams:mZ,runPreset:gZ,runConfig:yZ},xZ="Settings",bZ={engine:"Engine Settings",preferences:"Global Preferences"},kZ={title:"Workspace",currentPath:"Current Workspace Root",placeholder:"Loading...",copyPath:"Copy path",description:"Pipelines and node lists are resolved relative to this directory (passed when starting the UI)."},vZ={title:"Cursor CLI",status:{cached:"Cached",notCached:"Not cached"},modelPreviewLabel:"Cursor model id list",modelList:{cached:"Model list cached",empty:"No model list",count:"{{count}} items",fetchedAt:"Updated {{time}}",never:"Never fetched",refresh:"Refresh List",fetching:"Fetching..."}},SZ={modelPreviewLabel:"OpenCode model id list",title:"OpenCode CLI",status:{ready:"Ready",notFound:"Not found"},provider:"Plan / Provider ID",providerPlaceholder:"e.g., bailian-coding-plan",saving:"Saving and updating list...",description:"Corresponds to CLI opencode models <provider> parameter; written to user directory config and triggers model-lists.json refresh after typing stops."},jZ={title:"Claude Code CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Claude Code model id list",description:"Built-in model list (Claude Code CLI has no models subcommand); refresh probes the claude binary in PATH. Run 'claude /login' first."},NZ={title:"Codex CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Codex model id list",description:"Model list comes from codex debug models --bundled. Run 'codex login' first."},_Z={title:"Environment Variables",note:"Private to the current signed-in user; overrides service-level env at runtime",noteAdmin:"Configure personal or global env; personal values override global values",saving:"Saving...",key:"Key",value:"Value",scope:"Scope",personal:"Personal",global:"Global",add:"Add",delete:"Delete {{key}}",invalidKey:"Env key must start with a letter or underscore, and only contain letters, numbers, and underscores.",newKey:"New env key",newValue:"Value (be careful with secrets)"},CZ={title:"User Allowlist",description:"Only controls which usernames may register or sign in. Users set their own password on first sign-in.",enabled:"Allowlist enabled",open:"Open registration",refreshing:"Refreshing...",saving:"Saving...",file:"File",fileList:"File allowlist",envList:"Environment allowlist",readonly:"Read-only",userCount:"{{count}} users",remove:"Remove {{username}}",emptyFile:"No file allowlist configured. If env allowlist is also empty, every username can register.",emptyEnv:"AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS is not configured",unionHint:"The file allowlist and env allowlist are combined. This only stores usernames, never passwords.",add:"Add"},AZ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},EZ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},IZ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},PZ={title:"Onboarding Tour",description:"Restart the product tour to learn about AgentFlow's core features.",reset:"Reset Tour",resetSuccess:"Reset complete. Tour will start automatically on next visit."},RZ={title:xZ,crumb:bZ,workspace:kZ,cursor:vZ,opencode:SZ,claudeCode:jZ,codex:NZ,env:_Z,allowlist:CZ,system:AZ,shortcuts:EZ,language:IZ,onboarding:PZ},TZ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},MZ={input:"Ask AI to help edit this node...",waiting:"Waiting for response...",selectedEmpty:"Select a node on the canvas, or use @ in the input to select instances or node types",textarea:"Describe your workflow or ask AI to help (⌘/Ctrl+Enter to send)"},$Z={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},LZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},OZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},DZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},FZ={aiLabels:TZ,placeholders:MZ,actions:$Z,labels:LZ,tooltips:OZ,rightPanel:DZ},zZ="Projects",BZ="All",WZ="Archived",HZ="Nodes",VZ="My Nodes",KZ="My Flows",qZ="Skills",UZ="Active Projects",GZ="Archived Pipelines",YZ="Global Nodes",JZ="All Nodes",XZ="My Nodes",QZ="Manage node versions published to the current workspace marketplace, {{count}} total.",ZZ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",eee="Global Skills",tee="Create New Project",nee="New Pipeline",ree="SEARCH PIPELINES...",see="SEARCH NODES...",iee="SEARCH FLOW SNIPPETS...",oee="SEARCH SKILLS...",aee="Refresh Resources",lee="Loading pipelines...",cee="Loading global resources...",uee="Filter result: {{count}} items (matching title, description, path and tags)",dee="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",fee="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",pee="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",hee="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",mee="Executable building blocks for pipeline runtime",gee="Nodes define what can be placed on the canvas, which inputs and outputs exist, and whether runtime behavior is agent, control, provide, or marketplace logic.",yee="Published local node packages",wee="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",xee="Published flow snippets",bee="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",kee="Operating guides for Composer and agents",vee="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",See="No archived projects.",jee="No active pipelines; archived items are in the Archived tab.",Nee="No global nodes available.",_ee="No marketplace nodes have been published.",Cee="No flow snippets have been published. Select multiple canvas nodes and publish them first.",Aee="No skills available.",Eee="No description.",Iee='No node matches "{{query}}".',Pee='No flow snippet matches "{{query}}".',Ree='No skill matches "{{query}}".',Tee="{{inputs}} in / {{outputs}} out",Mee="Flow Snippet",$ee="{{nodes}} nodes / {{edges}} edges",Lee="Skill",Oee="Node detail",Dee="Flow snippet detail",Fee="Skill detail",zee="Type",Bee="Source",Wee="Package",Hee="Version",Vee="Path",Kee="Editable",qee="Read only",Uee="Editable",Gee="Schema",Yee="Inputs",Jee="Outputs",Xee="Runtime",Qee="Node Body",Zee="Files",ete="Usage",tte="No runtime manifest.",nte="No node body or README.",rte="No previewable files.",ste="Select a file to preview.",ite="Binary file preview is not supported.",ote="Large file; showing the first 256KB only.",ate="No pipelines using this node were found.",lte="Node Management",cte="Delete Node Version",ute="Deleting...",dte="AgentFlow checks all flow references before deleting; installed or used versions are kept.",fte="Delete {{id}}@{{version}}? This cannot be undone.",pte="Deleted {{id}}@{{version}}.",hte="{{count}} flow(s) still use it.",mte="Flow Snippet Management",gte="Delete Flow Snippet",yte="Deleting...",wte="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",xte="Delete {{id}}@{{version}}? This cannot be undone.",bte="Deleted {{id}}@{{version}}.",kte="No slots",vte="Purpose",Ste="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",jte="A flow snippet is a reusable part of a fixed workflow. Loading it copies its nodes, edges, and layout into the current canvas without replacing existing content.",Nte="Scale",_te="Flow Preview",Cte="Edges",Ate="Snippet JSON",Ete="{{count}} more edge(s)",Ite="No previewable nodes.",Pte="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Rte="SKILL.md Preview",Tte="No preview content available.",Mte="Select a resource to inspect details.",$te="Failed to load pipeline list.",Lte="No pipelines in current workspace.",Ote="Run {{code1}} in the repository root and ensure the workspace contains {{code2}} or pipelines in the user directory; or click New Pipeline to create one.",Dte='No pipelines found matching "{{query}}". Try different keywords or clear the search.',Fte="Recent Activity",zte="No recent activity",Bte="No recent activity matching the keyword",Wte="Recent Run",Hte="Recent Open",Vte={builtin:"Built-in",workspace:"Workspace",user:"User"},Kte={flow:"Flow",global:"Global",marketplace:"Marketplace"},qte={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Ute={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Gte="Open to edit this pipeline in the node canvas.",Yte={eyebrow:"AgentFlow Hub",title:"Browse community flows",desc:"Discover and install ready-made pipelines shared by the community.",cta:"Explore Hub",cliHint:"Or install via CLI: agentflow download <slug>"},Jte={title:"Create New Pipeline",lead:"Enter a pipeline name (English identifier); description is optional and will be saved in flow's ui.description.",nameLabel:"Name (required)",namePlaceholder:"e.g., my_feature_flow",nameHint:"Must start with a letter, only letters, numbers, underscores _ and hyphens - allowed",descLabel:"Description (optional)",descPlaceholder:"Briefly describe the purpose of this pipeline...",locationLabel:"Save Location",userDir:"User Directory (~/agentflow/pipelines)",workspaceDir:"Current Workspace (.workspace/agentflow/pipelines)",createFailed:"Creation failed",creating:"Creating...",createAndOpen:"Create and Open",cancel:"Cancel",close:"Close"},Xte={title:"Import Pipeline",lead:'File "{{filename}}" selected. Please confirm the pipeline name and save location; ZIP will preserve scripts and other files in the directory.',nameLabel:"Name (required)",namePlaceholder:"e.g., my_shared_flow",nameHint:"Must start with a letter, only letters, numbers, underscores _ and hyphens - allowed",locationLabel:"Save Location",userDir:"User Directory (~/agentflow/pipelines)",workspaceDir:"Current Workspace (.workspace/agentflow/pipelines)",changeFile:"Change File...",importFailed:"Import failed",importing:"Importing...",importAndOpen:"Import and Open",cancel:"Cancel",close:"Close"},Qte={title:"Delete Pipeline",lead:'This will permanently delete the pipeline directory from disk (including flow.yaml, scripts, etc.) and cannot be undone. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",deleteFailed:"Delete failed",deleteTimeout:"Delete request timed out, please retry (check UI service logs in terminal)",delete:"Delete",deleting:"Deleting...",confirmDelete:"Confirm Delete",cancel:"Cancel",close:"Close"},Zte={title:"Archive Pipeline",lead:'After archiving, the pipeline will be moved to the "Archived" list and can still be opened and edited from there. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",archiveFailed:"Archive failed",archive:"Archive",archiving:"Archiving...",confirmArchive:"Confirm Archive",cancel:"Cancel",close:"Close"},ene={title:zZ,all:BZ,archived:WZ,nodes:HZ,myNodes:VZ,myFlows:KZ,skills:qZ,activeProjects:UZ,archivedPipelines:GZ,globalNodes:YZ,nodeScopeAll:JZ,nodeScopeMine:XZ,myNodesHint:QZ,myFlowsHint:ZZ,globalSkills:eee,createNew:tee,newPipeline:nee,searchPipelines:ree,searchNodes:see,searchFlows:iee,searchSkills:oee,refreshResources:aee,loadingPipelines:lee,loadingResources:cee,filterResult:uee,archivedHint:dee,activeHint:fee,nodesHint:pee,skillsHint:hee,nodesPurposeTitle:mee,nodesPurposeDesc:gee,myNodesPurposeTitle:yee,myNodesPurposeDesc:wee,myFlowsPurposeTitle:xee,myFlowsPurposeDesc:bee,skillsPurposeTitle:kee,skillsPurposeDesc:vee,noArchived:See,noActive:jee,noNodes:Nee,noMyNodes:_ee,noMyFlows:Cee,noSkills:Aee,noDescription:Eee,noNodeMatch:Iee,noFlowSnippetMatch:Pee,noSkillMatch:Ree,nodeSlots:Tee,flowSnippet:Mee,flowSnippetNodes:$ee,skill:Lee,nodeDetail:Oee,flowDetail:Dee,skillDetail:Fee,detailType:zee,detailSource:Bee,detailPackage:Wee,detailVersion:Hee,detailPath:Vee,detailEditable:Kee,readOnly:qee,editable:Uee,nodeSchema:Gee,nodeInputs:Yee,nodeOutputs:Jee,nodeRuntime:Xee,nodeBody:Qee,nodeFiles:Zee,nodeUsage:ete,noRuntimeManifest:tte,noNodeBody:nte,noNodeFiles:rte,selectNodeFile:ste,binaryFile:ite,fileTruncated:ote,noNodeUsage:ate,myNodeManagement:lte,deleteMyNode:cte,deletingMyNode:ute,deleteMyNodeHint:dte,deleteMyNodeConfirm:fte,deleteMyNodeSuccess:pte,deleteMyNodeUsedBy:hte,myFlowManagement:mte,deleteMyFlow:gte,deletingMyFlow:yte,deleteMyFlowHint:wte,deleteMyFlowConfirm:xte,deleteMyFlowSuccess:bte,noSlots:kte,resourceMeaning:vte,nodesMeaning:Ste,myFlowsMeaning:jte,flowSnippetScale:Nte,flowSnippetPreview:_te,flowSnippetEdges:Cte,flowSnippetJson:Ate,flowSnippetMoreEdges:Ete,noFlowSnippetPreview:Ite,skillsMeaning:Pte,skillPreview:Rte,skillPreviewEmpty:Tte,selectResource:Mte,loadFailed:$te,noPipelines:Lte,emptyHint:Ote,noMatch:Dte,recentActivity:Fte,noRecentActivity:zte,noMatchRecent:Bte,recentRun:Wte,recentOpen:Hte,sourceBadge:Vte,resourceSource:Kte,resourceFilter:qte,nodeDetailTabs:Ute,defaultCardDesc:Gte,hubCard:Yte,newPipelineModal:Jte,importModal:Xte,deleteModal:Qte,archiveModal:Zte},tne="Back",nne="Next",rne="Skip",sne="Done",ine="Start Creating",one={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
289
-
290
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
291
-
292
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},ane={intro:`Now you're in the flow editor.
293
-
294
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
295
-
296
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
297
-
298
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
299
-
300
- The left node panel allows you to freely drag, delete, and adjust connections.`},lne={guideTitle:"First-time Creation Guide",guideDesc:"After entering the name and description, AI will automatically generate the flow graph. You can freely adjust nodes and connections in the editor.",nameHintGuide:"e.g., MyFirstFlow (starts with a letter, supports numbers and underscores)",descPlaceholderGuide:"e.g., Implement user login functionality with registration, verification, and authorization",descHintGuide:"More detailed description leads to more accurate AI-generated flow",createGuide:"Create & Start Editing",typeNode:"Node reference type",typeStr:"String type",typeFile:"File path type",typeBool:"Boolean type"},cne={back:tne,next:nne,skip:rne,done:sne,startCreate:ine,projects:one,flow:ane,newPipeline:lne},une={name:"AgentFlow",tagline:"AI 工作流编排"},dne={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},fne={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},pne={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},hne={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},mne={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},gne={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},yne={app:une,nav:dne,common:fne,status:pne,nodeTypes:hne,engine:mne,links:gne},wne="流程编辑器",xne="节点",bne="连线",kne="属性",vne={label:"节点标签",type:"节点类型",model:"模型",body:"内容",inputs:"输入",outputs:"输出",addInput:"添加输入",addOutput:"添加输出",remove:"删除节点",duplicate:"复制节点",nodeType:"节点类型",displayName:"显示名称",displayNameHint:"(字母、数字、下划线、短横线,勿以数字开头)",role:"角色",modelHint:"来自 ~/agentflow/model-lists.json;UI 服务启动时会后台执行 agentflow update-model-lists",defaultModel:"默认",userPrompt:"用户提示(USER PROMPT / body)",systemDescription:"系统说明(只读,来自节点定义)",directCommand:"直接执行命令",scriptHint:"(tool_nodejs:有 script 时跳过 AI,由流水线执行)",diskRunning:"磁盘记录为执行中",deleteNode:"删除节点",inputTooltip:"输入 {{name}} | 类型: {{type}}",outputTooltip:"输出 {{name}} | 类型: {{type}}",defaultSuffix:" | 默认: {{value}}",fallbackLabel:"节点",expandProvide:"编辑内容"},Sne={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",description:"描述 / 格式",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",pinDescriptionAriaLabel:"{{label}} {{index}} 格式描述",conversationOutput:"对话与输出",addPin:"添加引脚",addPinAriaLabel:"添加{{label}}",handleHint:"与画布上 Handle 序号一致({{prefix}}-0、{{prefix}}-1…)。增删或调整顺序后,原有连线可能失效,保存后请留意校验提示。",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} 类型",pinNameAriaLabel:"{{label}} {{index}} 名称",pinDefaultAriaLabel:"{{label}} {{index}} 默认值",deletePinAriaLabel:"删除 {{label}} {{index}}",deletePin:"删除此引脚",instanceId:"节点 ID",yamlValueNotInList:"(YAML 中的值,不在当前列表)",inputPins:"输入引脚(INPUT)",outputPins:"输出引脚(OUTPUT)",expand:"展开",collapse:"收起",expandEditScript:"展开编辑 script",expandEdit:"展开编辑",editScript:"编辑 script",editUserPrompt:"编辑用户提示",scriptPlaceholder:"instances.*.script,完整 shell 命令;支持 ${workspaceRoot}、${pipelineWorkspace}、${flowDir}、${runDir} 与各槽位名(勿对占位符再包双引号)",scriptPlaceholderExpand:"instances.*.script,完整 shell 命令;勿对 ${workspaceRoot}、${pipelineWorkspace}、${flowDir} 等占位符再包双引号",bodyPlaceholder:"instances.*.body,支持多行与 ${变量};输入 ${ 选择槽位",bodyPlaceholderExpand:"instances.*.body,支持多行与 ${变量}",noDescription:"(当前节点定义无 description)",modelAriaLabel:"模型",placeholderSlots:"占位符:输入输出槽位",publishToMarketplace:"发布节点",publishToMarketplaceHint:"将当前节点发布到 Workspace 本地节点市场",publishing:"发布中…",publishRunning:"正在发布到本地节点市场…",publishSuccess:"节点已发布到本地节点市场",publishSuccessWithId:"节点已发布:{{id}}"},jne={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},Nne={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},_ne={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},Cne={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},Ane={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},Ene={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},Ine={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},Pne={node:"节点",text:"文本",file:"文件",bool:"布尔"},Rne={title:"节点执行上下文",resizeHandle:"拖动调整节点上下文宽度",apiConnectError:"无法连接 API(请使用 agentflow ui 打开页面,或为 Vite 开发配置 /api 代理)",invalidJson:"响应不是有效 JSON",requestTimeout:"请求超时,请稍后重试或检查 agentflow ui",executingNoArtifacts:"执行中,产物尚未写入工作区…",noData:"暂无数据(本 run 尚未执行到该节点或未产生产物)",latest:"最新",detectedContentType:"检测到的内容类型",roundNoContent:"该轮次暂无内容",empty:"(空)",imageTruncated:"图像已截断(超过大小上限)",statusSuccess:"成功",statusFailed:"失败",statusRunning:"运行中",statusCacheMiss:"缓存失效",statusPending:"等待"},Tne={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},Mne={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},$ne={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},Lne={mainNav:"主导航"},One={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Dne={title:"AI 助手",placeholder:"让 AI 协助编辑此节点…",thinking:"思考",reply:"回复",result:"结果",error:"错误",waiting:"等待响应…",yourQuestion:"您的问题",send:"发送",expand:"展开对话",collapse:"收起",connecting:"连接中…",requestFailed:"请求失败",cannotReadStream:"无法读取响应流",connectTimeout:"连接超时(120s),请确认 UI 服务正在运行并重试。[CONNECT_TIMEOUT]",aborted:"已中止",executing:"执行中…",ready:"就绪",done:"完成",inputPlaceholder:"在此输入问题(⌘/Ctrl+Enter 发送)",inputAriaLabel:"问题输入",mentionAriaLabel:"提及:实例与节点类型",modelLabel:"模型",modelAriaLabel:"对话模型",modelDefault:"默认",modelNotInList:"(不在当前列表)",stopGeneration:"停止生成",conversationOutput:"对话与输出",collapseAriaLabel:"收起",closeSidebar:"关闭侧栏",endConversation:"结束对话(将停止生成)",closeConversation:"关闭对话",newConversation:"新建对话",switchConversation:"切换对话",selectedNodesAriaLabel:"已选节点列表",selectedNodesEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",removeFromInput:"从输入中移除 @{{id}}",deselectNode:"取消选中 {{id}}",taskPlan:`📋 任务规划({{count}} 步):
301
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
302
- 当前:{{current}}`,phaseComplete:"{{phaseName}}已完成。下一阶段:{{nextPhase}}",nextPhase:"下一阶段",continuePhase:"继续{{label}}",skipRemainingPhases:"请一次性完成剩余所有步骤(跳过分阶段确认)",phaseProgress:"分阶段进度",phaseReviewLabel:"分阶段选项",phaseReviewHint:"当前阶段完成,请在画布上检查结果,确认无误后进入「{{nextPhase}}」",phaseReviewContinue:"继续:{{label}}",phaseReviewSkip:"跳过,一次性完成剩余",stepsAriaLabel:"任务步骤进度",phasesAriaLabel:"生成阶段进度",phaseNumber:"第 {{index}} 阶段",stepRoleLabel:"角色:{{role}}",stepInstanceLabel:"实例:{{instanceId}}",pageRefreshReset:"页面刷新后重置",conversationLabel:"对话 {{n}}"},Fne={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},zne={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Bne={connectingApi:"正在连接 /api/flow/run…",connectingApiResume:"正在连接 /api/flow/run(恢复 run uuid={{uuid}})…",connectedReceiving:"已连接执行流,正在接收 NDJSON 输出…",noBody:"响应无 body(无法流式读取),请检查浏览器与 agentflow ui 版本",nodeStart:"▶ 开始执行: {{instanceId}}",nodeStartWithLabel:"▶ 开始执行: {{instanceId}} ({{label}})",nodeDone:"✓ 完成: {{instanceId}}",nodeDoneWithElapsed:"✓ 完成: {{instanceId}} ({{elapsed}})",nodeFailed:"✗ 失败: {{instanceId}}",pipelineStart:"流水线开始执行 (uuid={{uuid}})",pipelineDone:"流水线执行完成",pipelineDoneWithElapsed:"流水线执行完成 ({{elapsed}})",pipelinePaused:"流水线暂停: 等待用户输入 ({{nodes}})",unknownError:"未知错误",executionEnd:"执行结束 (exit code: {{exitCode}})",executionStopped:"执行已暂停",pauseRun:"暂停运行(可稍后恢复)",pauseConfirm:"确认暂停当前 run?之后可从中断节点恢复。",pauseTitle:"暂停运行",pauseConfirmOk:"暂停",backPromptTitle:"返回项目列表",backPromptMessage:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。",backBackground:"后台运行并退出",backStopEdit:"停止并进入编辑",resizeConsole:"拖动调整执行日志高度",closeLog:"关闭日志",userCheckContent:"等待用户确认节点 {{instanceId}} 的内容",userAskPrompt:"等待用户选择节点 {{instanceId}} 的分支"},Wne={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Hne={title:"流水线设置",subtitle:"管理流水线的基础信息、存储位置、节点市场、定时任务与元数据。",sectionNav:"设置分区",basicInfo:"基础信息",storageAndPath:"存储与路径",nodeMarketplace:"节点市场配置",overview:"流水线概览",owner:"所有者",source:"来源",marketplaceNodes:"市场节点",marketNodesUnit:"个市场节点",marketplaceHint:"本地市场中的节点可加入当前流水线;已加入后可直接添加到画布。",marketplaceEmpty:"当前工作区还没有安装本地市场节点。可在节点属性面板发布节点。",addNodeFromMarket:"返回画布添加节点",quickActions:"快捷操作",saveChanges:"保存更改",savingChanges:"保存中…",installNode:"加入流水线",installingNode:"加入中…",addInstalledNode:"添加到画布",previewNode:"预览",nodePreviewTitle:"节点预览",nodeStylePreview:"节点样式预览",closePreview:"关闭预览",nodeFunction:"节点用途",nodePackageInfo:"包信息",definitionId:"Definition ID",version:"版本",packagePath:"包路径",packagedFiles:"打包文件",marketplaceNoDescription:"暂无节点用途说明。",noInputs:"无输入",noOutputs:"无输出",backToCanvas:"返回画布",help:"帮助中心",helpText:"节点发布入口在节点属性面板;合集安装后会同步进入本地节点市场。",archived:"已归档",archivedNote:"此流水线位于归档目录(_archived),无法在用户目录与工作区之间移动。",builtinNote:"内置模板只读;首次保存将写入工作区 .workspace/agentflow/pipelines(流水线)、.workspace/agentflow/nodes(自定义节点)等;旧 .cursor/agentflow/ 下文件仍可读。",moveBusy:"移动中…",moveToWorkspace:"移动到工作区",moveToUserDir:"移动到用户目录",globalSettings:"全局设置",currentPipeline:"当前流水线:",builtin:"内置",rename:"重命名",renameBusy:"重命名中…",renameSuccess:"已重命名",copyPath:"复制路径",pathCopied:"已复制"},Vne={title:"定时执行",enabled:"启用定时触发",cron:"Cron 表达式",timezone:"时区",preset:"运行参数预设",defaultPreset:"默认参数",overlapSkip:"重叠策略:运行中则跳过本次触发",nextRun:"下一次预计触发:{{time}}",noNextRun:"未设置下一次触发时间",runtime:"调度状态",running:"运行中",waiting:"等待触发",disabled:"未启用",lastTriggeredAt:"最近触发",lastSkippedAt:"最近跳过",lastRun:"最近 Run",lastExit:"最近退出码",lastFinishedAt:"最近结束",readonlyNote:"内置或归档流水线不可保存定时配置。",save:"保存定时配置",saving:"保存中…",saved:"定时配置已保存"},Kne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},qne={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},Une={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Gne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},Yne={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},Jne={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},Xne={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},Qne={save:"保存",cancel:"取消"},Zne={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},ere={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},tre={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},nre={title:wne,nodes:xne,edges:bne,properties:kne,node:vne,nodeProps:Sne,actions:jne,panel:Nne,palette:_ne,pipeline:Cne,status:Ane,roles:Ene,phases:Ine,types:Pne,runContext:Rne,shortcuts:Tne,jumpPalette:Mne,emptyCanvas:$ne,sidebar:Lne,validation:One,composer:Dne,topbar:Fne,palette2:zne,run:Bne,fileEdit:Wne,settings:Hne,schedule:Vne,history:Kne,nodePropsError:qne,placeholder:Une,time:Gne,userCheck:Yne,userAsk:Jne,toolPrint:Xne,provideEdit:Qne,runParams:Zne,runPreset:ere,runConfig:tre},rre="设置",sre={engine:"引擎设置",preferences:"全局首选项"},ire={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},ore={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},are={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},lre={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},cre={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},ure={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},dre={title:"用户白名单",description:"只控制 username 是否允许注册或登录,密码由用户首次登录时自行设置。",enabled:"白名单已启用",open:"开放注册",refreshing:"刷新中...",saving:"保存中...",file:"文件",fileList:"文件白名单",envList:"环境变量白名单",readonly:"只读",userCount:"{{count}} 个用户",remove:"删除 {{username}}",emptyFile:"未配置文件白名单;如果环境变量也为空,则所有用户可注册。",emptyEnv:"未配置 AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS",unionHint:"文件白名单与环境变量白名单取并集;这里只会保存用户名,不保存密码。",add:"添加"},fre={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},pre={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},hre={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},mre={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},gre={title:rre,crumb:sre,workspace:ire,cursor:ore,opencode:are,claudeCode:lre,codex:cre,env:ure,allowlist:dre,system:fre,shortcuts:pre,language:hre,onboarding:mre},yre={thinking:"思考",result:"结果",reply:"回复",error:"错误"},wre={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},xre={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},bre={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},kre={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},vre={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Sre={aiLabels:yre,placeholders:wre,actions:xre,labels:bre,tooltips:kre,rightPanel:vre},jre="项目",Nre="全部",_re="已归档",Cre="Nodes",Are="我的 Nodes",Ere="我的流程",Ire="Skills",Pre="活跃项目",Rre="已归档流水线",Tre="全局 Nodes",Mre="全部 Nodes",$re="我的 Nodes",Lre="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Ore="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Dre="全局 Skills",Fre="创建新项目",zre="新建流水线",Bre="搜索流水线…",Wre="搜索 nodes…",Hre="搜索流程片段…",Vre="搜索 skills…",Kre="刷新资源",qre="加载流水线列表…",Ure="加载全局资源…",Gre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",Yre="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",Jre="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",Xre="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",Qre="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",Zre="流程运行时的可执行积木",ese="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",tse="已发布的本地节点包",nse="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",rse="已发布的流程片段",sse="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",ise="Composer/Agent 的操作指南",ose="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",ase="暂无归档项目。",lse="暂无未归档流水线;已归档项在 Archived 标签中查看。",cse="暂无可用全局 nodes。",use="暂无已发布的 marketplace nodes。",dse="暂无已发布的流程片段。可在画布中选中多个节点后发布。",fse="暂无可用 skills。",pse="暂无描述。",hse="未找到与「{{query}}」匹配的 node。",mse="未找到与「{{query}}」匹配的流程片段。",gse="未找到与「{{query}}」匹配的 skill。",yse="{{inputs}} in / {{outputs}} out",wse="流程片段",xse="{{nodes}} 节点 / {{edges}} 连线",bse="Skill",kse="Node 详情",vse="流程片段详情",Sse="Skill 详情",jse="类型",Nse="来源",_se="包",Cse="版本",Ase="路径",Ese="可编辑",Ise="只读",Pse="可编辑",Rse="Schema",Tse="输入",Mse="输出",$se="Runtime",Lse="节点内容",Ose="Files",Dse="Usage",Fse="暂无 runtime manifest。",zse="暂无节点正文或 README。",Bse="暂无可预览文件。",Wse="请选择文件查看内容。",Hse="二进制文件暂不支持预览。",Vse="文件较大,仅显示前 256KB。",Kse="暂未发现使用此 node 的流水线。",qse="节点管理",Use="删除节点版本",Gse="删除中…",Yse="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",Jse="确定删除 {{id}}@{{version}}?此操作不可撤销。",Xse="已删除 {{id}}@{{version}}。",Qse="仍有 {{count}} 个 Flow 使用它。",Zse="流程片段管理",eie="删除流程片段",tie="删除中…",nie="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",rie="确定删除 {{id}}@{{version}}?此操作不可撤销。",sie="已删除 {{id}}@{{version}}。",iie="无槽位",oie="作用",aie="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",lie="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",cie="规模",uie="流程预览",die="连线",fie="片段 JSON",pie="还有 {{count}} 条连线",hie="暂无可预览节点。",mie="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",gie="SKILL.md 预览",yie="暂无可预览内容。",wie="请选择一个资源查看详情。",xie="未能加载流水线列表。",bie="当前工作区暂无流水线。",kie="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",vie="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Sie="最近打开或最近运行",jie="暂无打开或运行记录",Nie="暂无与关键词匹配的最近记录",_ie="最近运行",Cie="最近打开",Aie={builtin:"内置",workspace:"工作区",user:"用户"},Eie={flow:"Flow",global:"Global",marketplace:"Marketplace"},Iie={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Pie={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Rie="打开以在节点画布中编辑此流水线。",Tie={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Mie={title:"新建空流水线",lead:"请先填写流水线名称(英文标识);介绍可选,将保存在 flow 的 ui.description。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_feature_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",descLabel:"介绍(可选)",descPlaceholder:"简要说明此流水线的用途…",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",createFailed:"创建失败",creating:"创建中…",createAndOpen:"创建并打开",cancel:"取消",close:"关闭"},$ie={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Lie={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Oie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Die={title:jre,all:Nre,archived:_re,nodes:Cre,myNodes:Are,myFlows:Ere,skills:Ire,activeProjects:Pre,archivedPipelines:Rre,globalNodes:Tre,nodeScopeAll:Mre,nodeScopeMine:$re,myNodesHint:Lre,myFlowsHint:Ore,globalSkills:Dre,createNew:Fre,newPipeline:zre,searchPipelines:Bre,searchNodes:Wre,searchFlows:Hre,searchSkills:Vre,refreshResources:Kre,loadingPipelines:qre,loadingResources:Ure,filterResult:Gre,archivedHint:Yre,activeHint:Jre,nodesHint:Xre,skillsHint:Qre,nodesPurposeTitle:Zre,nodesPurposeDesc:ese,myNodesPurposeTitle:tse,myNodesPurposeDesc:nse,myFlowsPurposeTitle:rse,myFlowsPurposeDesc:sse,skillsPurposeTitle:ise,skillsPurposeDesc:ose,noArchived:ase,noActive:lse,noNodes:cse,noMyNodes:use,noMyFlows:dse,noSkills:fse,noDescription:pse,noNodeMatch:hse,noFlowSnippetMatch:mse,noSkillMatch:gse,nodeSlots:yse,flowSnippet:wse,flowSnippetNodes:xse,skill:bse,nodeDetail:kse,flowDetail:vse,skillDetail:Sse,detailType:jse,detailSource:Nse,detailPackage:_se,detailVersion:Cse,detailPath:Ase,detailEditable:Ese,readOnly:Ise,editable:Pse,nodeSchema:Rse,nodeInputs:Tse,nodeOutputs:Mse,nodeRuntime:$se,nodeBody:Lse,nodeFiles:Ose,nodeUsage:Dse,noRuntimeManifest:Fse,noNodeBody:zse,noNodeFiles:Bse,selectNodeFile:Wse,binaryFile:Hse,fileTruncated:Vse,noNodeUsage:Kse,myNodeManagement:qse,deleteMyNode:Use,deletingMyNode:Gse,deleteMyNodeHint:Yse,deleteMyNodeConfirm:Jse,deleteMyNodeSuccess:Xse,deleteMyNodeUsedBy:Qse,myFlowManagement:Zse,deleteMyFlow:eie,deletingMyFlow:tie,deleteMyFlowHint:nie,deleteMyFlowConfirm:rie,deleteMyFlowSuccess:sie,noSlots:iie,resourceMeaning:oie,nodesMeaning:aie,myFlowsMeaning:lie,flowSnippetScale:cie,flowSnippetPreview:uie,flowSnippetEdges:die,flowSnippetJson:fie,flowSnippetMoreEdges:pie,noFlowSnippetPreview:hie,skillsMeaning:mie,skillPreview:gie,skillPreviewEmpty:yie,selectResource:wie,loadFailed:xie,noPipelines:bie,emptyHint:kie,noMatch:vie,recentActivity:Sie,noRecentActivity:jie,noMatchRecent:Nie,recentRun:_ie,recentOpen:Cie,sourceBadge:Aie,resourceSource:Eie,resourceFilter:Iie,nodeDetailTabs:Pie,defaultCardDesc:Rie,hubCard:Tie,newPipelineModal:Mie,importModal:$ie,deleteModal:Lie,archiveModal:Oie},Fie="返回",zie="下一步",Bie="跳过",Wie="完成",Hie="开始创建",Vie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
303
-
304
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
305
-
306
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Kie={intro:`现在进入流程编辑器。
307
-
308
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
309
-
310
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
311
-
312
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
313
-
314
- 左侧节点面板可以自由拖拽、删除和调整连接。`},qie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Uie={back:Fie,next:zie,skip:Bie,done:Wie,startCreate:Hie,projects:Vie,flow:Kie,newPipeline:qie},Gie={en:{common:TQ,flow:wZ,settings:RZ,composer:FZ,project:ene,onboarding:cne},zh:{common:yne,flow:nre,settings:gre,composer:Sre,project:Die,onboarding:Uie}};kr.use(e$).use(aF).init({resources:Gie,fallbackLng:"en",debug:!1,ns:["common","flow","settings","composer","project","onboarding"],defaultNS:"common",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"agentflow-lang",caches:["localStorage"]}});const Yie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Jie(e){return kr.changeLanguage(e)}const Ob="agentflow-settings-opencode-plan-v1",dd="CURSOR_API_KEYS",fd="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",Iw=new Set([dd,fd,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),t$=["cursor","opencode","claudeCode","codex"];function n$(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function Db(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function Pa(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of t$)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(Db).filter(Boolean))]:[];return n}function Xi(e){if(!e||typeof e!="object")return n$();const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],codex:Array.isArray(t.codex)?t.codex.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null,codexFetchedAt:t.codexFetchedAt??null}}function Pc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Xie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Oa(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const s=String(r.key??"").trim(),o=String(r.value??""),a=String(r.id??"").trim()||Pc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function MC(e){return Oa(e).map(({key:t,value:n})=>({key:t,value:n}))}function $C(){try{return localStorage.getItem(Ob)??""}catch{return""}}function r$(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function Qie(e){const t=String(e||"").trim();if(!t)return[];const n=(r,s)=>{if(typeof r=="string"){const a=r.trim();return a?{id:`legacy_${s}_${a.slice(-6)}`,name:`Key ${s+1}`,key:a,createdAt:""}:null}if(!r||typeof r!="object")return null;const o=String(r.key??"").trim();return o?{id:String(r.id??"").trim()||Pc(),name:String(r.name??"").trim()||`Key ${s+1}`,key:o,createdAt:String(r.createdAt??"").trim()}:null};try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n).filter(Boolean)}catch{}return t.split(",").map((r,s)=>n(r,s)).filter(Boolean)}function LC(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||Pc(),name:String((n==null?void 0:n.name)||"").trim()||`Key ${r+1}`,key:String((n==null?void 0:n.key)||"").trim(),createdAt:String((n==null?void 0:n.createdAt)||"").trim()||new Date().toISOString()})).filter(n=>n.key):[];return JSON.stringify(t)}function Zie(e){const t=String(e||"").trim();return t?t.length<=10?r$(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function eoe(e,t="zh"){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return String(e);try{const r=t==="en"?"en-US":t==="ja"?"ja-JP":"zh-CN";return new Intl.DateTimeFormat(r,{dateStyle:"short",timeStyle:"medium"}).format(new Date(n))}catch{return String(e)}}function toe({authUser:e}){const{t,i18n:n}=Vr(["common","settings"]),r=n.language||"zh",[s,o]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[p,f]=m.useState(n$()),[d,h]=m.useState(()=>Pa({})),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(!1),[N,P]=m.useState(!1),[R,z]=m.useState(""),[E,O]=m.useState([]),[D,L]=m.useState(""),[M,V]=m.useState(!1),[B,F]=m.useState(""),[$,H]=m.useState(""),[A,Q]=m.useState(!1),[K,W]=m.useState(()=>new Set),[te,Z]=m.useState(""),[G,ne]=m.useState(""),[re,se]=m.useState(!!(e!=null&&e.isAdmin)),[ee,ue]=m.useState(""),[de,pe]=m.useState([]),[Me,Ne]=m.useState([]),[_e,He]=m.useState(""),[ct,yt]=m.useState(""),[Re,at]=m.useState(!1),[kt,$t]=m.useState(!1),[ye,ze]=m.useState(""),[oe,ke]=m.useState(""),[Be,Qe]=m.useState(""),[Ce,Ct]=m.useState(null),[Xt,Ft]=m.useState(!1),[rt,Fn]=m.useState(!1),[ie,Ie]=m.useState(""),et=m.useRef(null),qe=m.useRef(!1),Pt=m.useRef(!1),vt=m.useRef(""),tr=m.useCallback(async()=>{l("");try{const ae=await fetch("/api/ui-context");if(!ae.ok)throw new Error("HTTP "+ae.status);const ve=await ae.json();o(typeof ve.workspaceRoot=="string"?ve.workspaceRoot:"")}catch(ae){l(String(ae.message||ae)),o("")}},[]),Gn=m.useCallback(async()=>{x(""),S(!0),g("");try{const ae=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!ae.ok)throw new Error("HTTP "+ae.status);const ve=await ae.json();if(e!=null&&e.isAdmin)u(Xi(ve.modelLists)),f(Xi(ve.allModelLists)),h(Pa(ve.hiddenModels));else{const Te=Xi(ve);u(Te),f(Te),h(Pa({}))}}catch(ae){x(String(ae.message||ae))}finally{S(!1)}},[e==null?void 0:e.isAdmin]),Tr=m.useCallback(async()=>{L("");try{const ae=await fetch("/api/user-env"),ve=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+ae.status);const Te=Oa(Array.isArray(ve.env)?ve.env:[],"user").map(Qt=>({...Qt,scope:"user"})),Rt=[...e!=null&&e.isAdmin?Oa(Array.isArray(ve.globalEnv)?ve.globalEnv:[],"global").map(Qt=>({...Qt,scope:"global"})):[],...Te];vt.current=JSON.stringify(Rt),O(Rt)}catch(ae){O([]),L(String(ae.message||ae))}finally{Pt.current=!0}},[e==null?void 0:e.isAdmin]),kn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){at(!0),ze("");try{const ae=await fetch("/api/admin/user-allowlist"),ve=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+ae.status);const Te=ve.allowlist&&typeof ve.allowlist=="object"?ve.allowlist:{};pe(Array.isArray(Te.fileUsers)?Te.fileUsers.map(String):[]),Ne(Array.isArray(Te.envUsers)?Te.envUsers.map(String):[]),He(typeof Te.path=="string"?Te.path:"")}catch(ae){ze(String(ae.message||ae))}finally{at(!1)}}},[e==null?void 0:e.isAdmin]),nr=m.useCallback(async ae=>{if(e!=null&&e.isAdmin){$t(!0),ze("");try{const ve=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ae})}),Te=await ve.json().catch(()=>({}));if(!ve.ok)throw new Error(typeof Te.error=="string"?Te.error:"HTTP "+ve.status);const bt=Te.allowlist&&typeof Te.allowlist=="object"?Te.allowlist:{};pe(Array.isArray(bt.fileUsers)?bt.fileUsers.map(String):[]),Ne(Array.isArray(bt.envUsers)?bt.envUsers.map(String):[]),He(typeof bt.path=="string"?bt.path:"")}catch(ve){ze(String(ve.message||ve))}finally{$t(!1)}}},[e==null?void 0:e.isAdmin]),pr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Ft(!0),Ie("");try{const ae=await fetch("/api/admin/storage-config"),ve=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+ae.status);const Te=ve.config&&typeof ve.config=="object"?ve.config:{};Ct(Te),ke(typeof Te.dataRoot=="string"?Te.dataRoot:""),Qe(typeof Te.skillsRoot=="string"?Te.skillsRoot:"")}catch(ae){Ie(String(ae.message||ae))}finally{Ft(!1)}}},[e==null?void 0:e.isAdmin]),hr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Fn(!0),Ie("");try{const ae=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:oe.trim(),skillsRoot:Be.trim(),migrateLegacySkills:!0})}),ve=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+ae.status);const Te=ve.config&&typeof ve.config=="object"?ve.config:{};Ct(Te),ke(typeof Te.dataRoot=="string"?Te.dataRoot:""),Qe(typeof Te.skillsRoot=="string"?Te.skillsRoot:"")}catch(ae){Ie(String(ae.message||ae))}finally{Fn(!1)}}},[e==null?void 0:e.isAdmin,oe,Be]),fn=m.useCallback(async ae=>{const ve=Oa(ae),Te=ve.filter(Rt=>Rt.scope!=="global"),bt=ve.filter(Rt=>Rt.scope==="global");V(!0),L("");try{const Rt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:MC(Te),...e!=null&&e.isAdmin?{globalEnv:MC(bt)}:{}})}),Qt=await Rt.json().catch(()=>({}));if(!Rt.ok)throw new Error(typeof Qt.error=="string"?Qt.error:"HTTP "+Rt.status);const pn=Oa(Array.isArray(Qt.env)?Qt.env:[],"user").map(Ss=>({...Ss,scope:"user"})),vs=[...e!=null&&e.isAdmin?Oa(Array.isArray(Qt.globalEnv)?Qt.globalEnv:[],"global").map(Ss=>({...Ss,scope:"global"})):[],...pn];vt.current=JSON.stringify(vs),O(vs)}catch(Rt){L(String(Rt.message||Rt))}finally{V(!1)}},[e==null?void 0:e.isAdmin]),zn=m.useCallback(async()=>{x(""),S(!0);try{const ae=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ee.trim()})}),ve=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+ae.status);u(Xi(ve.modelLists)),e!=null&&e.isAdmin?await Gn():f(Xi(ve.modelLists))}catch(ae){x(String(ae.message||ae))}finally{S(!1)}},[e==null?void 0:e.isAdmin,Gn,ee]),is=m.useCallback(async ae=>{if(!(e!=null&&e.isAdmin))return;const ve=Pa(ae);h(ve),v(!0),g("");try{const Te=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:ve})}),bt=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(typeof bt.error=="string"?bt.error:"HTTP "+Te.status);u(Xi(bt.modelLists)),f(Xi(bt.allModelLists)),h(Pa(bt.hiddenModels))}catch(Te){g(String(Te.message||Te)),Gn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,Gn]),Fs=m.useCallback((ae,ve,Te)=>{const bt=t$.includes(ae)?ae:"cursor",Rt=Db(ve);if(!Rt)return;const Qt=Pa(d),pn=new Set(Qt[bt]);Te?pn.delete(Rt):pn.add(Rt),is({...Qt,[bt]:Array.from(pn)})},[d,is]);m.useEffect(()=>{Tr(),e!=null&&e.isAdmin?(tr(),Gn(),kn(),pr(),(async()=>{try{const ae=await fetch("/api/agentflow-config");if(ae.ok){const ve=await ae.json(),Te=typeof ve.opencodeProvider=="string"?ve.opencodeProvider:"";ue(Te),et.current=Te;try{localStorage.setItem(Ob,Te)}catch{}}else{const ve=$C();ue(ve),et.current=ve}}catch{const ae=$C();ue(ae),et.current=ae}finally{qe.current=!0}})()):(o(""),qe.current=!1)},[e==null?void 0:e.isAdmin,tr,Gn,pr,kn,Tr]),m.useEffect(()=>{if(!Pt.current||JSON.stringify(Oa(E))===vt.current)return;const ve=setTimeout(()=>{fn(E)},350);return()=>clearTimeout(ve)},[E,fn]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!qe.current)return;const ae=ee.trim();if(ae===et.current)return;const ve=setTimeout(()=>{(async()=>{P(!0),z("");try{const Te=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ae})}),bt=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(typeof bt.error=="string"?bt.error:"HTTP "+Te.status);et.current=ae;try{localStorage.setItem(Ob,ae)}catch{}bt.modelLists&&(u(Xi(bt.modelLists)),e!=null&&e.isAdmin?Gn():f(Xi(bt.modelLists)))}catch(Te){z(String(Te.message||Te))}finally{P(!1)}})()},450);return()=>clearTimeout(ve)},[e==null?void 0:e.isAdmin,Gn,ee]);const vn=e!=null&&e.isAdmin?p:c,Yn=vn.cursor.length>0,ks=vn.opencode.length>0,Jn=vn.claudeCode.length>0,Bn=vn.codex.length>0,vr=Pa(d),Sr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},Wn=m.useCallback((ae,ve,Te)=>{const bt=Array.isArray(ve)?ve:[];if(!(e!=null&&e.isAdmin))return i.jsx("pre",{className:"af-set-model-preview","aria-label":Te,children:bt.join(`
315
- `)});const Rt=new Set(vr[ae]||[]);return i.jsxs("div",{className:"af-set-model-visibility","aria-label":Te,children:[i.jsxs("div",{className:"af-set-model-visibility-head",children:[i.jsxs("span",{children:["展示 ",Sr[ae]||0," / ",bt.length]}),i.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),i.jsx("div",{className:"af-set-model-visibility-list",children:bt.map(Qt=>{const pn=Db(Qt),$n=!Rt.has(pn);return i.jsxs("label",{className:"af-set-model-visibility-row",children:[i.jsx("input",{type:"checkbox",checked:$n,disabled:y,onChange:vs=>Fs(ae,Qt,vs.target.checked)}),i.jsx("span",{children:Qt})]},`${ae}-${Qt}`)})})]})},[e==null?void 0:e.isAdmin,vr,y,Sr,Fs]),Mr=de.length>0||Me.length>0,$r=e!=null&&e.isAdmin?E:E.filter(ae=>!Iw.has(String((ae==null?void 0:ae.key)||"").trim())),ce=e!=null&&e.isAdmin&&re?"global":"user",me=m.useMemo(()=>E.find(ae=>ae.key===dd&&(ae.scope||"user")===ce)||null,[ce,E]),tt=m.useMemo(()=>Qie((me==null?void 0:me.value)||""),[me==null?void 0:me.value]),st=m.useMemo(()=>E.find(ae=>ae.key===fd&&(ae.scope||"user")===ce)||null,[ce,E]),zt=st!=null&&st.value?String(st.value):"30",Rn=m.useCallback((ae,ve,Te)=>{const bt=String(ae||"").trim();if(!bt)return;const Rt=String(ve??"");O(Qt=>{const pn=Qt.find($n=>$n.key===bt&&($n.scope||"user")===Te);return Rt?pn?Qt.map($n=>$n.id===pn.id?{...$n,value:Rt,scope:Te}:$n):[{id:Pc(),key:bt,value:Rt,scope:Te},...Qt]:Qt.filter($n=>!($n.key===bt&&($n.scope||"user")===Te))})},[]),jr=m.useCallback(()=>{const ae=G.trim();if(!ae)return;const ve=[...tt,{id:Pc(),name:te.trim()||`Key ${tt.length+1}`,key:ae,createdAt:new Date().toISOString()}];Rn(dd,LC(ve),ce),Z(""),ne("")},[te,tt,ce,G,Rn]),Nr=m.useCallback(ae=>{const ve=tt.filter(Te=>Te.id!==ae);Rn(dd,ve.length?LC(ve):"",ce)},[tt,ce,Rn]),mr=m.useCallback(ae=>{const ve=String(ae||"").replace(/[^\d]/g,"");if(!ve){Rn(fd,"",ce);return}const Te=Math.min(1440,Math.max(1,Number(ve)||30));Rn(fd,String(Te),ce)},[ce,Rn]),ut=m.useCallback(()=>{var ae;s&&((ae=navigator.clipboard)==null||ae.writeText(s))},[s]),Ut=m.useCallback(()=>{const ae=B.trim(),ve=$;if(ae){if(!Xie(ae)){L(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&Iw.has(ae)){L("该运行基础设施变量仅管理员可配置。");return}O(Te=>[{id:Pc(),key:ae,value:ve,scope:e!=null&&e.isAdmin&&A?"global":"user"},...Te]),F(""),H("")}},[e==null?void 0:e.isAdmin,A,B,$,t]),Gt=m.useCallback(ae=>{O(ve=>ve.filter(Te=>Te.id!==ae))},[]),Xn=m.useCallback((ae,ve)=>{const Te=String((ve==null?void 0:ve.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Te&&Iw.has(Te)){L("该运行基础设施变量仅管理员可配置。");return}O(bt=>bt.map(Rt=>Rt.id===ae?{...Rt,...ve}:Rt))},[e==null?void 0:e.isAdmin]),ot=m.useCallback(ae=>{W(ve=>{const Te=new Set(ve);return Te.has(ae)?Te.delete(ae):Te.add(ae),Te})},[]),gr=m.useCallback(()=>{const ae=ct.trim();if(!ae)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ae)){ze("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Te=>String(Te||"").trim().toLowerCase())).has(ae.toLowerCase())){yt("");return}yt(""),nr([...de,ae])},[ct,de,nr]),zs=m.useCallback(ae=>{const ve=String(ae||"").trim().toLowerCase();ve&&nr(de.filter(Te=>String(Te||"").trim().toLowerCase()!==ve))},[de,nr]),Hi=m.useCallback(ae=>{const ve=ae.target.value;Jie(ve)},[]),Bs=ae=>{const ve=eoe(ae,r);return ve?t("settings:cursor.modelList.fetchedAt",{time:ve}):t("settings:cursor.modelList.never")};return i.jsxs("div",{className:"af-settings-page",children:[i.jsx("header",{className:"af-settings-top",children:i.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[i.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),i.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),i.jsx("p",{className:"af-settings-lead",children:e!=null&&e.isAdmin?t("settings:workspace.description"):t("settings:env.note")}),e!=null&&e.isAdmin&&a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,e!=null&&e.isAdmin&&k?i.jsx("p",{className:"af-err af-settings-api-hint",children:k}):null,D?i.jsx("p",{className:"af-err af-settings-api-hint",children:D}):null,ie?i.jsx("p",{className:"af-err af-settings-api-hint",children:ie}):null]}),i.jsx("div",{className:"af-settings-layout",children:i.jsxs("div",{className:"af-settings-bento",children:[e!=null&&e.isAdmin?i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[i.jsxs("div",{className:"af-set-card-inner",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),i.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),i.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:ut,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:i.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),i.jsx("p",{className:"af-set-hint",children:"当前页面只展示运行时根目录。可被节点加载的代码库和文档目录请在左侧“知识库”里维护。"})]}),i.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),i.jsx("span",{className:"af-set-badge"+(Yn?" af-set-badge--ok":" af-set-badge--muted"),children:t(Yn?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Yn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Yn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Yn?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${vn.cursor.length}`:"")+" · "+Bs(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Yn?Wn("cursor",vn.cursor,t("settings:cursor.modelPreviewLabel")):null,b?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:b}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-cursor-pool",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"key"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"Cursor API Key 池"}),i.jsx("p",{className:"af-set-card-subtitle",children:"按请求轮换,遇到 usage limit 或 resource_exhausted 会自动尝试下一个 Key。"})]})]}),i.jsxs("span",{className:"af-set-badge"+(tt.length?" af-set-badge--ok":" af-set-badge--muted"),children:[tt.length," keys"]})]}),i.jsxs("div",{className:"af-set-cursor-pool-controls",children:[e!=null&&e.isAdmin?i.jsxs("div",{className:"af-set-env-scope-switch af-set-cursor-scope",role:"group","aria-label":"Cursor API Key scope",children:[i.jsx("button",{type:"button",className:re?"":"is-active",onClick:()=>se(!1),children:"个人"}),i.jsx("button",{type:"button",className:re?"is-active":"",onClick:()=>se(!0),children:"全局"})]}):null,i.jsxs("label",{className:"af-set-cursor-cooldown",children:[i.jsx("span",{children:"限额冷却"}),i.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",inputMode:"numeric",value:zt,onChange:ae=>mr(ae.target.value)}),i.jsx("span",{children:"分钟"})]}),i.jsx("span",{className:"af-set-env-note",children:M?"保存中":ce==="global"?"全局配置":"个人配置"})]}),i.jsx("div",{className:"af-set-cursor-key-list",children:tt.length?tt.map(ae=>i.jsxs("div",{className:"af-set-cursor-key-row",children:[i.jsxs("div",{className:"af-set-cursor-key-main",children:[i.jsx("strong",{children:ae.name}),i.jsx("code",{children:Zie(ae.key)})]}),i.jsx("span",{className:"af-set-cursor-key-meta",children:ae.createdAt?new Date(ae.createdAt).toLocaleString():"历史 Key"}),i.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${ae.name}`,onClick:()=>Nr(ae.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ae.id)):i.jsx("div",{className:"af-set-cursor-key-empty",children:"还没有配置 Key。配置后 Cursor CLI runner 会自动轮换使用。"})}),i.jsxs("div",{className:"af-set-cursor-key-add",children:[i.jsx("input",{className:"af-set-input",value:te,onChange:ae=>Z(ae.target.value),placeholder:"名称,例如 Team Key 1"}),i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:G,onChange:ae=>ne(ae.target.value),placeholder:"Cursor API Key"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:jr,disabled:!G.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",dd,";冷却时间保存到 ",fd,"。个人配置会覆盖全局配置。"]})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),i.jsx("span",{className:"af-set-badge"+(ks?" af-set-badge--ok":" af-set-badge--err"),children:t(ks?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),i.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),i.jsxs("div",{children:[i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),i.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:ee,onChange:ae=>ue(ae.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),N?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,R?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:R}):null]}),ks?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+(e!=null&&e.isAdmin?` / ${vn.opencode.length}`:"")+" · "+Bs(c.opencodeFetchedAt)}),Wn("opencode",vn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),i.jsx("span",{className:"af-set-badge"+(Jn?" af-set-badge--ok":" af-set-badge--err"),children:t(Jn?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Jn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Jn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Jn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${vn.claudeCode.length}`:"")+" · "+Bs(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),Jn?Wn("claudeCode",vn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:codex.title")}),i.jsx("span",{className:"af-set-badge"+(Bn?" af-set-badge--ok":" af-set-badge--err"),children:t(Bn?"settings:codex.status.ready":"settings:codex.status.notFound")})]}),i.jsxs("div",{className:"af-set-cli-block",children:[i.jsx("div",{className:"af-set-cli-icon",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Bn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Bn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Bn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${vn.codex.length}`:"")+" · "+Bs(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Bn?Wn("codex",vn.codex,t("settings:codex.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]})]}):null,i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),i.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),i.jsx("span",{className:"af-set-env-note",children:M?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),i.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[i.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[i.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?i.jsx("span",{children:t("settings:env.scope")}):null,i.jsx("span",{children:t("settings:env.value")}),i.jsx("span",{})]}),i.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:B,onChange:ae=>F(ae.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:A?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:A?"is-active":"",onClick:()=>Q(!0),children:t("settings:env.global")})]})}):null,i.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:$,onChange:ae=>H(ae.target.value),"aria-label":t("settings:env.newValue")})}),i.jsx("div",{className:"af-set-env-actions",children:i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Ut,disabled:!B.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),$r.map(ae=>i.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:ae.key,onChange:ve=>Xn(ae.id,{key:ve.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:ae.scope!=="global"?"is-active":"",onClick:()=>Xn(ae.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:ae.scope==="global"?"is-active":"",onClick:()=>Xn(ae.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,i.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:K.has(ae.id)?"text":"password",value:ae.value,onChange:ve=>Xn(ae.id,{value:ve.target.value}),placeholder:r$(ae.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>ot(ae.id),"aria-label":K.has(ae.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:K.has(ae.id)?"visibility_off":"visibility"})})]}),i.jsx("div",{className:"af-set-env-actions",children:i.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ae.key}),onClick:()=>Gt(ae.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ae.id))]})]}),e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"hard_drive_2"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),i.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),i.jsx("span",{className:"af-set-badge"+(Ce!=null&&Ce.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:Ce!=null&&Ce.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void pr(),disabled:Xt||rt,children:Xt?"刷新中...":"刷新"})]}),ie?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ie}):null,i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:oe,onChange:ae=>ke(ae.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(Ce!=null&&Ce.envLocked)||rt}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Data Root",disabled:rt||!!(Ce!=null&&Ce.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:rt?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(Ce==null?void 0:Ce.dataRoot)||oe||"-"}),Ce!=null&&Ce.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:Ce.configPath})]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",i.jsx("code",{children:"users/"}),"、",i.jsx("code",{children:"pipelines/"}),"、",i.jsx("code",{children:"runBuild/"}),"、",i.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",Ce!=null&&Ce.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]}),i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-skills-root",children:"Skills Root"}),i.jsxs("div",{className:"af-set-input-wrap",children:[i.jsx("input",{id:"af-agentflow-skills-root",className:"af-set-input af-set-input--mono",type:"text",value:Be,onChange:ae=>Qe(ae.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(Ce!=null&&Ce.skillsEnvLocked)||rt}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Skills Root",disabled:rt||!!(Ce!=null&&Ce.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:rt?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(Ce==null?void 0:Ce.skillsRoot)||Be||"-"}),Ce!=null&&Ce.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:Ce.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",Ce!=null&&Ce.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),i.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),i.jsx("span",{className:"af-set-badge"+(Mr?" af-set-badge--ok":" af-set-badge--muted"),children:t(Mr?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void kn(),disabled:Re,children:t(Re?"settings:allowlist.refreshing":"common:common.refresh")})]}),ye?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ye}):null,_e?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:_e})]}):null,i.jsxs("div",{className:"af-allowlist-grid",children:[i.jsxs("div",{className:"af-allowlist-main",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.fileList")}),i.jsx("span",{children:kt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:de.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:de.length>0?de.map(ae=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:ae}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>zs(ae),"aria-label":t("settings:allowlist.remove",{username:ae}),disabled:kt,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ae)):i.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),i.jsxs("div",{className:"af-allowlist-add",children:[i.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:ct,onChange:ae=>yt(ae.target.value),onKeyDown:ae=>{ae.key==="Enter"&&gr()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:gr,disabled:kt||!ct.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),i.jsxs("div",{className:"af-allowlist-side",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.envList")}),i.jsx("span",{children:t("settings:allowlist.readonly")})]}),i.jsx("div",{className:"af-allowlist-env-list",children:Me.length>0?Me.map(ae=>i.jsx("code",{children:ae},ae)):i.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,i.jsxs("section",{className:"af-settings-rail","aria-label":t("settings:title"),children:[e!=null&&e.isAdmin?i.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[i.jsxs("div",{className:"af-set-rail-inner",children:[i.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),i.jsxs("div",{className:"af-set-health-line",children:[i.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),i.jsx("span",{className:"af-set-health-label",children:t(!a&&!k?"settings:system.normal":"settings:system.abnormal")})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.cursorModels")}),i.jsx("span",{children:c.cursor.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.opencodeModels")}),i.jsx("span",{children:c.opencode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.claudeCodeModels")}),i.jsx("span",{children:c.claudeCode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.codexModels")}),i.jsx("span",{children:c.codex.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.length*3:4)}%`}})})]})]}),i.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}):null,i.jsxs("div",{className:"af-set-rail-card",children:[i.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),i.jsxs("div",{className:"af-set-language-selector",children:[i.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Hi,"aria-label":t("settings:language.description"),children:Yie.map(ae=>i.jsxs("option",{value:ae.code,children:[ae.flag," ",ae.name]},ae.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function noe(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t))}function roe(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function soe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function ioe({run:e,onClose:t}){const[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState("timeline"),p=m.useCallback(async({quiet:v=!1}={})=>{if(e!=null&&e.runId){v||o(!0),l("");try{const b=new URLSearchParams({runType:e.runType||"pipeline",userId:e.userId||"",flowId:e.flowId||"",flowSource:e.flowSource||"user",runId:e.runId}),g=await fetch(`/api/admin/run-detail?${b.toString()}`),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||`HTTP ${g.status}`);r(k)}catch(b){l(String((b==null?void 0:b.message)||b))}finally{v||o(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,e==null?void 0:e.runId,e==null?void 0:e.runType,e==null?void 0:e.userId]);m.useEffect(()=>{r(null),u("timeline"),p()},[p]),m.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||p({quiet:!0})},5e3);return()=>window.clearInterval(v)},[p,e==null?void 0:e.status]);const f=Array.isArray(n==null?void 0:n.events)?n.events:[],d=m.useMemo(()=>f.filter(v=>(v==null?void 0:v.kind)==="thinking"),[f]),h=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?d:f;return i.jsx("div",{className:"af-admin-run-detail-overlay",role:"presentation",onMouseDown:t,children:i.jsxs("aside",{className:"af-admin-run-detail",role:"dialog","aria-modal":"true","aria-label":"Run 详情",onMouseDown:v=>v.stopPropagation(),children:[i.jsxs("header",{className:"af-admin-run-detail__head",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"af-admin-run-detail__eyebrow",children:[e.runType==="workspace"?"Workspace Run":"Pipeline Run"," · ",soe(e.status)]}),i.jsx("h2",{children:e.flowId||"Run 详情"}),i.jsxs("p",{children:[e.username||e.userId," · ",i.jsx("code",{children:e.runId})]})]}),i.jsxs("div",{className:"af-admin-run-detail__actions",children:[i.jsx("button",{type:"button",onClick:()=>void p(),disabled:s,title:"刷新详情",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),i.jsx("button",{type:"button",onClick:t,title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),i.jsxs("div",{className:"af-admin-run-detail__tabs",role:"tablist","aria-label":"Run 详情分类",children:[i.jsxs("button",{type:"button",className:c==="timeline"?"is-active":"",onClick:()=>u("timeline"),children:["过程 ",i.jsx("span",{children:f.length})]}),i.jsxs("button",{type:"button",className:c==="thinking"?"is-active":"",onClick:()=>u("thinking"),children:["Thinking ",i.jsx("span",{children:d.length})]}),i.jsxs("button",{type:"button",className:c==="raw"?"is-active":"",onClick:()=>u("raw"),children:["原始日志 ",i.jsx("span",{children:h.length})]})]}),n!=null&&n.truncated?i.jsx("div",{className:"af-admin-run-detail__notice",children:"日志较大,当前展示最新的 512 KB / 2000 条记录。"}):null,a?i.jsx("div",{className:"af-admin-run-detail__error",children:a}):null,s&&!n?i.jsx("div",{className:"af-admin-run-detail__empty",children:"正在读取 Run 详情..."}):null,i.jsx("div",{className:"af-admin-run-detail__body",children:c==="raw"?h.length>0?i.jsx("pre",{className:"af-admin-run-detail__raw",children:h.join(`
316
- `)}):i.jsx("div",{className:"af-admin-run-detail__empty",children:"这个 Run 没有原始日志。"}):y.length>0?i.jsx("div",{className:"af-admin-run-detail__timeline",children:y.map((v,b)=>i.jsxs("article",{className:`af-admin-run-detail__event is-${v.kind||"process"}`,children:[i.jsxs("div",{className:"af-admin-run-detail__event-meta",children:[i.jsx("time",{children:noe(v.ts)}),i.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:roe(v.kind)}),i.jsx("span",{children:v.type||"event"}),v.nodeId?i.jsx("code",{children:v.nodeId}):null]}),i.jsx("pre",{children:v.text||"-"})]},v.id||`${v.ts||0}-${b}`))}):i.jsx("div",{className:"af-admin-run-detail__empty",children:c==="thinking"?"该模型或 CLI 没有为这个 Run 输出可记录的 Thinking。":"这个 Run 暂无过程事件。"})})]})})}function Dr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function th(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Pw(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const s=Math.round(r/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function ooe(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Rw(e){if(!e)return"无运行记录";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(Number(e)))}catch{return String(e)}}function aoe(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function loe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function coe({authUser:e}){const{navigate:t}=rs(),[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(null),[p,f]=m.useState(null),[d,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=m.useCallback(async()=>{if(e!=null&&e.isAdmin){o(!0),l("");try{const E=await fetch("/api/admin/usage-dashboard"),O=await E.json().catch(()=>({}));if(!E.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+E.status);r(O)}catch(E){r(null),l(String((E==null?void 0:E.message)||E))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),x=m.useCallback(async E=>{const O=String((E==null?void 0:E.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!O)){f({userId:O,username:String((E==null?void 0:E.username)||O)}),h([]),g(""),v(!0);try{const D=new URLSearchParams({userId:O}),L=await fetch(`/api/admin/user-workspaces?${D.toString()}`),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(M.error||"读取用户 Workspace 失败");f(M.owner||{userId:O,username:String((E==null?void 0:E.username)||O)}),h(Array.isArray(M.workspaces)?M.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),_=m.useCallback(E=>{const O=String((E==null?void 0:E.ownerUserId)||(p==null?void 0:p.userId)||"").trim(),D=String((E==null?void 0:E.id)||"").trim();if(!O||!D)return;const L=new URLSearchParams({flowId:D,flowSource:"user",adminOwnerId:O});E!=null&&E.archived&&L.set("archived","1"),t(`/workspace?${L.toString()}`)},[t,p==null?void 0:p.userId]);m.useEffect(()=>{k()},[k]);const S=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],N=m.useMemo(()=>{const D={top:20,right:24,bottom:42,left:42},L=980-D.left-D.right,M=250-D.top-D.bottom,V=S.length>0?S:[],B=Math.max(1,...V.map(K=>Number(K.runs||0))),F=Math.max(1,...V.flatMap(K=>[Number(K.users||0),Number(K.pipelines||0)])),$=K=>D.left+(V.length<=1?L/2:K*L/(V.length-1)),H=K=>D.top+M-Math.max(0,Number(K||0))/B*M,A=K=>D.top+M-Math.max(0,Number(K||0))/F*M,Q=K=>V.map((W,te)=>`${te===0?"M":"L"} ${$(te)} ${A(W[K])}`).join(" ");return{width:980,height:250,margin:D,innerHeight:M,rows:V,x:$,yRuns:H,yLine:A,lineUsers:Q("users"),linePipelines:Q("pipelines"),barWidth:Math.min(34,Math.max(12,L/Math.max(1,V.length)*.44))}},[S]),P=(n==null?void 0:n.usage)||{},R=(n==null?void 0:n.totals)||{},z=Array.isArray(n==null?void 0:n.recentRuns)?n.recentRuns:[];return e!=null&&e.isAdmin?i.jsxs("main",{className:"af-admin-usage-page",children:[i.jsxs("section",{className:"af-admin-usage-hero",children:[i.jsxs("div",{children:[i.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),i.jsx("h1",{children:"管理看板"}),i.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),i.jsxs("button",{type:"button",onClick:()=>void k(),disabled:s,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),s?"刷新中":"刷新"]})]}),a?i.jsx("div",{className:"af-project-admin-usage__error",children:a}):null,i.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[i.jsxs("div",{children:[i.jsx("span",{children:"7日活跃用户率"}),i.jsx("strong",{children:th(P.activeUserRate)}),i.jsxs("em",{children:[Dr(P.activeUsers)," / ",Dr(R.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:th(P.activePipelineRate)}),i.jsxs("em",{children:[Dr(P.activePipelines)," / ",Dr(R.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Dr(P.runs)}),i.jsxs("em",{children:[Dr(P.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:th(P.successRate)}),i.jsxs("em",{children:["失败率 ",th(P.failureRate)," · avg ",Pw(P.avgDurationMs)]})]})]}),i.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"每日趋势"}),i.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),i.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[i.jsxs("div",{className:"af-admin-usage-chart__legend",children:[i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),i.jsx("div",{className:"af-admin-usage-chart__canvas",children:i.jsxs("svg",{viewBox:`0 0 ${N.width} ${N.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:N.margin.left,y1:N.margin.top+N.innerHeight,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight}),[.25,.5,.75,1].map(E=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:N.margin.left,y1:N.margin.top+N.innerHeight-N.innerHeight*E,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight-N.innerHeight*E},E)),N.rows.map((E,O)=>{const D=N.x(O),L=N.yRuns(E.runs),M=N.margin.top+N.innerHeight,V=Math.max(2,M-L);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:D-N.barWidth/2,y:M-V,width:N.barWidth,height:V,rx:"5",children:i.jsx("title",{children:`${E.date}: ${E.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:D,y:M+22,children:Dr(E.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:D,y:M+42,children:ooe(E.date)})]},E.date)}),N.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:N.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:N.linePipelines}),N.rows.map((E,O)=>{const D=N.x(O);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:D,cy:N.yLine(E.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:D,cy:N.yLine(E.pipelines),r:"3.5"})]},`${E.date}-points`)})]}):null]})})]}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"用户"}),i.jsx("th",{children:"流水线"}),i.jsx("th",{children:"运行时间"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"耗时"}),i.jsx("th",{children:"Run ID"})]})}),i.jsx("tbody",{children:z.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):z.map(E=>i.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(E),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),u(E))},children:[i.jsxs("td",{children:[i.jsx("strong",{children:E.username||E.userId||"-"}),i.jsx("span",{children:E.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:E.flowId||"-"}),i.jsxs("span",{children:[E.runType==="workspace"?"Workspace Run":"Pipeline"," · ",E.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Rw(E.at)}),E.endedAt?i.jsxs("span",{children:["结束 ",Rw(E.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:loe(E.status)})})}),i.jsx("td",{children:Pw(E.durationMs)}),i.jsx("td",{children:i.jsxs("span",{className:"af-admin-usage-run-link",children:[i.jsx("code",{className:"af-admin-usage-run-id",title:E.runId,children:aoe(E.runId)}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${E.userId}:${E.flowSource}:${E.flowId}:${E.runId}:${E.at}`))})]})})]}),i.jsxs("section",{className:"af-project-admin-usage",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"用户使用明细"}),i.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"User"}),i.jsx("th",{children:"Pipeline"}),i.jsx("th",{children:"Runs"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"最近运行"}),i.jsx("th",{children:"Workspace"})]})}),i.jsx("tbody",{children:s&&!n?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"正在加载..."})}):((n==null?void 0:n.users)||[]).length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无用户数据"})}):((n==null?void 0:n.users)||[]).map(E=>{var O,D,L,M,V,B,F,$,H,A,Q,K,W;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:E.username||E.userId}),i.jsxs("span",{children:[E.userId,E.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Dr((O=E.pipelines)==null?void 0:O.total)}),i.jsxs("span",{children:[Dr((D=E.pipelines)==null?void 0:D.active)," active / ",Dr((L=E.pipelines)==null?void 0:L.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Dr((M=E.runs)==null?void 0:M.total)}),i.jsxs("span",{children:["avg ",Pw((V=E.runs)==null?void 0:V.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Dr((B=E.runs)==null?void 0:B.success)]}),i.jsxs("em",{children:["失败 ",Dr((F=E.runs)==null?void 0:F.failed)]}),i.jsxs("em",{children:["运行中 ",Dr(($=E.runs)==null?void 0:$.running)]})]})}),i.jsx("td",{children:(H=E.runs)!=null&&H.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((A=E.runs)==null?void 0:A.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((Q=E.runs)==null?void 0:Q.lastRunStatus)||"unknown"," · ",Rw(E.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})}),i.jsx("td",{children:i.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((K=E.pipelines)!=null&&K.total)||y&&(p==null?void 0:p.userId)===E.userId,onClick:()=>void x(E),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(p==null?void 0:p.userId)===E.userId?"读取中":`查看 ${Dr((W=E.pipelines)==null?void 0:W.total)}`]})})]},E.userId)})})]})})]}),p?i.jsxs("section",{className:"af-project-admin-usage af-admin-user-workspaces",children:[i.jsxs("div",{className:"af-project-admin-usage__head",children:[i.jsxs("div",{children:[i.jsxs("strong",{children:[p.username||p.userId," 的 Workspace"]}),i.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),i.jsx("button",{type:"button",onClick:()=>{f(null),h([]),g("")},children:"关闭"})]}),b?i.jsx("div",{className:"af-project-admin-usage__error",children:b}):null,i.jsx("div",{className:"af-admin-user-workspaces__grid",children:y?i.jsx("p",{children:"正在读取 Workspace..."}):d.length===0?i.jsx("p",{children:"该用户暂无 Workspace。"}):d.map(E=>i.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>_(E),children:[i.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:E.archived?"inventory_2":"account_tree"}),i.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[i.jsx("strong",{children:E.id}),i.jsx("small",{children:E.description||(E.archived?"已归档 Workspace":"用户 Workspace")})]}),i.jsx("span",{className:"af-admin-user-workspace-card__status",children:E.archived?"已归档":"只读打开"})]},`${E.id}:${E.archived?"archived":"active"}`))})]}):null,c?i.jsx(ioe,{run:c,onClose:()=>u(null)}):null]}):i.jsx("main",{className:"af-admin-usage-page",children:i.jsx("section",{className:"af-project-admin-usage",children:i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"管理看板"}),i.jsx("span",{children:"需要管理员权限。"})]})})})})}function uoe({authUser:e}){const[t,n]=m.useState([]),[r,s]=m.useState([]),[o,a]=m.useState(""),[l,c]=m.useState({name:"",description:"",status:"active",members:[]}),[u,p]=m.useState(""),[f,d]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState(""),g=m.useCallback(async()=>{b("");try{const S=await fetch("/api/admin/teams"),N=await S.json().catch(()=>({}));if(!S.ok)throw new Error(N.error||"读取团队失败");const P=Array.isArray(N.teams)?N.teams:[];n(P),s(Array.isArray(N.users)?N.users:[]),a(R=>{var z;return R&&P.some(E=>E.id===R)?R:((z=P[0])==null?void 0:z.id)||""})}catch(S){b(String(S.message||S))}},[]);m.useEffect(()=>{g()},[g]);const k=m.useMemo(()=>t.find(S=>S.id===o)||null,[o,t]);m.useEffect(()=>{if(!k){c({name:"",description:"",status:"active",members:[]});return}c({name:k.name||"",description:k.description||"",status:k.status||"active",members:(k.members||[]).map(S=>S.userId||S)})},[k]);const x=async(S,N)=>{y(!0),b("");try{const P=await fetch("/api/admin/teams",{method:S,headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),R=await P.json().catch(()=>({}));if(!P.ok)throw new Error(R.error||"更新团队失败");return await g(),R}catch(P){return b(String(P.message||P)),null}finally{y(!1)}};if(!(e!=null&&e.isAdmin))return i.jsx("main",{className:"af-team-admin-page",children:i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:"仅超级管理员可以管理团队。"})});const _=r.filter(S=>{const N=f.trim().toLowerCase();return!N||`${S.username} ${S.userId}`.toLowerCase().includes(N)});return i.jsxs("main",{className:"af-team-admin-page",children:[i.jsxs("header",{className:"af-team-admin-hero",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Admin / Organization"}),i.jsx("h1",{children:"团队管理"}),i.jsx("p",{children:"划分团队成员,并为团队迭代汇总与 Project 分享提供权限边界。"})]}),i.jsxs("button",{type:"button",onClick:()=>void g(),disabled:h,children:[i.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),v?i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,i.jsxs("div",{className:"af-team-admin-layout",children:[i.jsxs("aside",{className:"af-team-admin-list",children:[i.jsxs("form",{onSubmit:S=>{S.preventDefault(),u.trim()&&x("POST",{name:u.trim()}).then(N=>{var P;(P=N==null?void 0:N.team)!=null&&P.id&&a(N.team.id),N&&p("")})},children:[i.jsx("input",{value:u,onChange:S=>p(S.target.value),placeholder:"新团队名称"}),i.jsx("button",{type:"submit",disabled:h||!u.trim(),children:i.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),t.map(S=>i.jsxs("button",{type:"button",className:S.id===o?"is-active":"",onClick:()=>a(S.id),children:[i.jsxs("span",{children:[i.jsx("strong",{children:S.name}),i.jsxs("small",{children:[S.memberCount||0," 位成员"]})]}),S.status==="inactive"?i.jsx("em",{children:"已停用"}):null]},S.id)),t.length?null:i.jsx("p",{children:"还没有团队。"})]}),i.jsx("section",{className:"af-team-admin-detail",children:k?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-team-admin-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"团队名称"}),i.jsx("input",{value:l.name,onChange:S=>c(N=>({...N,name:S.target.value}))})]}),i.jsxs("label",{children:[i.jsx("span",{children:"状态"}),i.jsxs("select",{value:l.status,onChange:S=>c(N=>({...N,status:S.target.value})),children:[i.jsx("option",{value:"active",children:"启用"}),i.jsx("option",{value:"inactive",children:"停用"})]})]}),i.jsxs("label",{className:"is-wide",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:l.description,onChange:S=>c(N=>({...N,description:S.target.value})),placeholder:"团队职责或范围"})]})]}),i.jsxs("div",{className:"af-team-admin-members-head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"团队成员"}),i.jsx("span",{children:"一个用户只能属于一个团队,保存后会自动从原团队移出。"})]}),i.jsx("input",{type:"search",value:f,onChange:S=>d(S.target.value),placeholder:"搜索用户"})]}),i.jsx("div",{className:"af-team-admin-members",children:_.map(S=>{var P;const N=l.members.includes(S.userId);return i.jsxs("label",{className:N?"is-selected":"",children:[i.jsx("input",{type:"checkbox",checked:N,onChange:R=>c(z=>({...z,members:R.target.checked?[...z.members,S.userId]:z.members.filter(E=>E!==S.userId)}))}),i.jsx("span",{className:"material-symbols-outlined",children:"person"}),i.jsxs("span",{children:[i.jsx("strong",{children:S.username}),i.jsxs("small",{children:[S.userId,S.isAdmin?" · Admin":""]})]}),S.teamId&&S.teamId!==k.id?i.jsx("em",{children:((P=t.find(R=>R.id===S.teamId))==null?void 0:P.name)||"其他团队"}):null]},S.userId)})}),i.jsxs("footer",{className:"af-team-admin-actions",children:[i.jsx("button",{type:"button",className:"is-danger",disabled:h||l.members.length>0,onClick:()=>{window.confirm(`删除团队「${k.name}」?`)&&x("DELETE",{teamId:k.id})},children:"删除团队"}),i.jsxs("div",{children:[i.jsx("button",{type:"button",disabled:h,onClick:()=>c({name:k.name,description:k.description||"",status:k.status,members:(k.members||[]).map(S=>S.userId||S)}),children:"重置"}),i.jsx("button",{type:"button",className:"is-primary",disabled:h||!l.name.trim(),onClick:async()=>{await x("PATCH",{teamId:k.id,name:l.name,description:l.description,status:l.status})&&await x("PUT",{teamId:k.id,members:l.members})},children:h?"保存中...":"保存团队"})]})]})]}):i.jsx("div",{className:"af-workflows-message",children:"创建或选择一个团队。"})})]})]})}function doe(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);try{return new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}).format(new Date(t))}catch{return String(e)}}function foe({authUser:e}){const{navigate:t}=rs(),[n,r]=m.useState(""),[s,o]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(k){v(!0),g("");try{const S=await fetch("/api/feedback"),N=await S.json().catch(()=>({}));if(!S.ok)throw new Error(N.error||"加载失败");h(Array.isArray(N.feedback)?N.feedback:[])}catch(S){g(String(S.message||S)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{x()},[x]);const _=async S=>{if(S.preventDefault(),!a){l(!0),u("");try{const N=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),P=await N.json().catch(()=>({}));if(!N.ok)throw new Error(P.error||"提交失败");f(!0),r(""),o("")}catch(N){u(String(N.message||N))}finally{l(!1)}}};return k?i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"查看用户提交的问题、建议和功能需求。"})]}),i.jsxs("div",{className:"af-feedback-admin-actions",children:[i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:y,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":"refresh"}),y?"刷新中...":"刷新"]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),b?i.jsx("p",{className:"af-err af-feedback-error",children:b}):null,i.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:d.length>0?d.map(S=>i.jsxs("article",{className:"af-feedback-item",children:[i.jsxs("header",{className:"af-feedback-item__head",children:[i.jsxs("div",{children:[i.jsx("h3",{children:S.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:S.username||S.userId||"unknown"}),i.jsx("span",{children:doe(S.createdAt)})]})]}),S.contact?i.jsx("span",{className:"af-feedback-item__contact",children:S.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:S.content}),S.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:S.pageUrl}):null]},S.id)):i.jsx("div",{className:"af-feedback-empty",children:y?"正在加载反馈...":"暂无反馈"})})]})}):i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在这里统一查看。"})]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),p?i.jsxs("div",{className:"af-feedback-success",role:"status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("div",{children:[i.jsx("strong",{children:"已提交"}),i.jsx("span",{children:"感谢反馈,管理员可以在意见反馈页查看这条记录。"})]})]}):null,i.jsxs("form",{className:"af-feedback-form",onSubmit:_,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:n,onChange:S=>r(S.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"反馈内容"}),i.jsx("textarea",{value:s,onChange:S=>o(S.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),c?i.jsx("p",{className:"af-err af-feedback-error",children:c}):null,i.jsx("div",{className:"af-feedback-actions",children:i.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:a||!n.trim()||!s.trim(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"send"}),a?"提交中...":"提交反馈"]})})]})]})})}function s$(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function OC(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:s$(),key:r,value:String(s??""),private:n.has(r)}))}function DC(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.key)||"").trim();r&&(t[r]=String((n==null?void 0:n.value)??""))}return t}function Ih(e=null){const t=e!=null&&e.raw&&typeof e.raw=="object"?e.raw:{},n=Array.isArray(t.args)?t.args:Array.isArray(e==null?void 0:e.args)?e.args:[];return{originalName:String((e==null?void 0:e.name)||""),name:String((e==null?void 0:e.name)||""),type:e!=null&&e.url||t.url?"url":"command",url:String((e==null?void 0:e.url)||t.url||""),command:String((e==null?void 0:e.command)||t.command||""),argsText:n.map(String).join(`
317
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:OC(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:OC(t.headers||(e==null?void 0:e.headers),e==null?void 0:e.privateHeaderKeys),extraJson:JSON.stringify(Object.fromEntries(Object.entries(t).filter(([r])=>!["url","command","args","env","headers","description","__agentflowPrivateKeys"].includes(r))),null,2)}}function Tw(){return Ih({name:"",raw:{command:""}})}function poe(e){const n={...e.extraJson.trim()?JSON.parse(e.extraJson):{}};if(e.type==="url")n.url=e.url.trim();else{n.command=e.command.trim();const o=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);o.length&&(n.args=o)}const r=DC(e.envRows),s=DC(e.headerRows);return Object.keys(r).length&&(n.env=r),Object.keys(s).length&&(n.headers=s),e.description.trim()&&(n.description=e.description.trim()),{name:e.originalName,nextName:e.name.trim(),server:n,privateEnvKeys:e.envRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean)}}function FC(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function zC(e){return e?e.ok?"ok":"error":"unknown"}function Fb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function hoe(e,t){return e&&e.label||t}async function Mw(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText&&window.isSecureContext)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return r.remove(),s}catch{return!1}}function Dv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function i$({baseUrl:e="",token:t=""}){return JSON.stringify({mcpServers:{agentflow:{command:"agentflow",args:["mcp"],env:{AGENTFLOW_BASE_URL:String(e||"http://127.0.0.1:8875"),AGENTFLOW_TOKEN:Dv(t)}}}},null,2)}function o$({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(Dv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
318
- `)}function moe({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=i$({baseUrl:n,token:t}),s=o$({baseUrl:n,token:t});return["你是一个 AI Coding Agent。请帮我把 AgentFlow 配置成当前开发环境可用的 MCP server。","","这是一项配置任务,不是调用任务:请修改 Cursor 或 Codex 的 MCP 配置文件,让它们能连接本机 AgentFlow。","","AgentFlow MCP server 信息:","- server name: agentflow","- command: agentflow",'- args: ["mcp"]',`- env.AGENTFLOW_BASE_URL: ${n}`,`- env.AGENTFLOW_TOKEN: ${Dv(t)}`,"","Cursor 配置片段(合并到 .cursor/mcp.json 或 ~/.cursor/mcp.json):","```json",r,"```","","Codex 配置片段(合并到 ~/.codex/config.toml 的 mcp_servers 配置):","```toml",s,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 的 MCP 页面点击“使用当前登录 Token”后重新复制。","7. 如果外部 Agent 启动 MCP 时找不到 `agentflow` 命令,请把 command 改成本机 agentflow 可执行文件的绝对路径,或先把 agentflow 安装/软链到 PATH。","","配置后验证:","- 如果配置使用 `command: agentflow`,确认外部 Agent 所在环境可以执行这个命令;如果使用绝对路径,则确认路径存在且可执行。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
319
- `)}function goe({server:e}){const t=(e==null?void 0:e.backends)||{},n=[["Cursor",t.cursor],["Codex",t.codex]];return i.jsx("div",{className:"af-mcp-backends",children:n.map(([r,s])=>i.jsxs("div",{className:`af-mcp-backend af-mcp-backend--${Fb(s==null?void 0:s.status)}`,children:[i.jsxs("div",{className:"af-mcp-backend-head",children:[i.jsx("strong",{children:r}),i.jsx("span",{children:hoe(s,"Unknown")})]}),Array.isArray(s==null?void 0:s.reasons)&&s.reasons.length?i.jsx("ul",{children:s.reasons.map(o=>i.jsx("li",{children:o},o))}):i.jsx("p",{children:"当前配置可直接使用。"})]},r))})}function BC({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const o=(a,l,c)=>n(t.map(u=>u.id===a?{...u,[l]:c}:u));return i.jsxs("div",{className:"af-mcp-field",children:[i.jsxs("div",{className:"af-mcp-field-head",children:[i.jsx("span",{children:e}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:s$(),key:"",value:"",private:!0}]),children:"添加"})]}),i.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?i.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>i.jsxs("div",{className:"af-mcp-kv-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>o(a.id,"key",l.target.value)}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>o(a.id,"value",l.target.value)}),i.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[i.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>o(a.id,"private",l.target.checked)}),i.jsx("span",{children:"个人"})]}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function yoe(){var Z;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState(Tw),[a,l]=m.useState(""),[c,u]=m.useState(!1),[p,f]=m.useState(!1),[d,h]=m.useState(!1),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[N,P]=m.useState(""),[R,z]=m.useState(""),E=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),O=E&&y[E.name]||null,D=m.useMemo(()=>i$({baseUrl:_,token:N}),[_,N]),L=m.useMemo(()=>o$({baseUrl:_,token:N}),[_,N]),M=m.useMemo(()=>moe({baseUrl:_,token:N}),[_,N]),V=m.useCallback(async()=>{u(!0),g("");try{const G=await fetch("/api/mcps"),ne=await G.json().catch(()=>({}));if(!G.ok)throw new Error(ne.error||"MCP HTTP "+G.status);const re=Array.isArray(ne.servers)?ne.servers:[];t(String(ne.path||"")),r(re),a&&re.some(se=>se.name===a)&&o(Ih(re.find(se=>se.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{V()},[V]);const B=()=>{l(""),o(Tw()),x(""),g("")},F=G=>{l(G.name),o(Ih(G)),x(""),g("")},$=m.useCallback(async()=>{if(!M)return;const G=await Mw(M);z(G?"prompt":"copy-failed"),window.setTimeout(()=>z(""),1200)},[M]),H=m.useCallback(async()=>{const G=await Mw(D);z(G?"cursor":"copy-failed"),window.setTimeout(()=>z(""),1200)},[D]),A=m.useCallback(async()=>{const G=await Mw(L);z(G?"codex":"copy-failed"),window.setTimeout(()=>z(""),1200)},[L]),Q=m.useCallback(async()=>{try{const G=await fetch("/api/auth/session-token"),ne=await G.json().catch(()=>({}));if(!G.ok)throw new Error(typeof ne.error=="string"?ne.error:"HTTP "+G.status);P(String(ne.token||"")),z("token"),window.setTimeout(()=>z(""),1200)}catch(G){z(""),g(String(G.message||G))}},[]),K=async(G="")=>{h(!0),g(""),x("");try{const ne=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G?{name:G}:{})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"检测 MCP 失败");const se=Array.isArray(re.results)?re.results:[];v(ee=>{const ue={...ee};for(const de of se)de!=null&&de.name&&(ue[de.name]=de);return ue}),x(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(ne){g(String(ne.message||ne))}finally{h(!1)}},W=async()=>{f(!0),g(""),x("");try{const G=poe(s);if(!G.nextName)throw new Error("请填写 MCP 名称");const ne=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"保存 MCP 失败");const se=Array.isArray(re.servers)?re.servers:[];r(se),t(String(re.path||e)),l(G.nextName),o(Ih(se.find(ee=>ee.name===G.nextName)||null)),v(ee=>{const ue={...ee};return s.originalName&&s.originalName!==G.nextName&&delete ue[s.originalName],delete ue[G.nextName],ue}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(G){g(String(G.message||G))}finally{f(!1)}},te=async G=>{if(G!=null&&G.name&&window.confirm(`删除 MCP "${G.name}"?`)){f(!0),g(""),x("");try{const ne=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"删除 MCP 失败");r(Array.isArray(re.servers)?re.servers:[]),l(""),o(Tw()),v(se=>{const ee={...se};return delete ee[G.name],ee}),x("已删除。")}catch(ne){g(String(ne.message||ne))}finally{f(!1)}}};return i.jsxs("main",{className:"af-settings-page",children:[i.jsxs("header",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),i.jsxs("div",{className:"af-settings-top-right",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:V,disabled:c||p,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(),disabled:d||c||p||n.length===0,children:d?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:p,children:"新增 MCP"})]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),i.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"lan"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),i.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),i.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),i.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),i.jsxs("div",{className:"af-set-mcp-connect-grid",children:[i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Base URL"}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:_,onChange:G=>S(G.target.value),placeholder:"http://127.0.0.1:8875"})]}),i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Token"}),i.jsxs("div",{className:"af-set-mcp-token-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:N,onChange:G=>P(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:R==="token"?"已填入":"使用当前登录 Token"})]})]})]}),i.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Cursor mcp.json"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:H,children:R==="cursor"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:D})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Codex config.toml"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:A,children:R==="codex"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:L})]})]}),i.jsx("div",{className:"af-set-mcp-copy-row",children:i.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:$,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),R==="prompt"?"已复制 Prompt":R==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),R==="copy-failed"?i.jsx("p",{className:"af-mcp-error",children:"浏览器禁止访问剪贴板,请手动选中下面的 Prompt 复制。"}):null,i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),i.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:M})]}),i.jsxs("section",{className:"af-settings-hero af-settings-hero--compact",children:[i.jsx("h2",{className:"af-settings-h2",children:"外部 MCP Servers"}),i.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 AgentFlow 可调用的外部 MCP server。当前配置文件:",i.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),i.jsxs("div",{className:"af-mcp-layout",children:[i.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2",children:"Servers"}),i.jsxs("div",{className:"af-mcp-list-head-actions",children:[i.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),i.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:p,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?i.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?i.jsxs("div",{className:"af-mcp-empty",children:[i.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:B,disabled:p,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var ne,re,se,ee;return i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===G.name?" af-mcp-server-item--active":""),onClick:()=>F(G),children:[i.jsx("span",{className:"material-symbols-outlined",children:G.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:G.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${zC(y[G.name])}`,children:FC(y[G.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Fb((re=(ne=G.backends)==null?void 0:ne.cursor)==null?void 0:re.status)}`,children:"Cursor"}),i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Fb((ee=(se=G.backends)==null?void 0:se.codex)==null?void 0:ee.status)}`,children:"Codex"})]}),i.jsx("em",{children:G.url||[G.command,...G.args||[]].filter(Boolean).join(" ")})]})]},G.name)})})]}),i.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:E?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),E?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(E.name),disabled:d||p,children:d?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>te(E),disabled:p,children:"删除"})]}):null]}),b?i.jsx("p",{className:"af-mcp-error",children:b}):null,k?i.jsx("p",{className:"af-mcp-status",children:k}):null,E?i.jsx(goe,{server:E}):null,O?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${zC(O)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:FC(O)}),i.jsxs("span",{children:[O.elapsedMs||0,"ms"]})]}),O.error?i.jsx("p",{children:O.error}):null,(Z=O.tools)!=null&&Z.length?i.jsx("div",{className:"af-mcp-tools-list",children:O.tools.map(G=>i.jsxs("div",{className:"af-mcp-tool-row",children:[i.jsx("strong",{children:G.name}),G.description?i.jsx("span",{children:G.description}):null]},G.name))}):null]}):null,i.jsxs("div",{className:"af-mcp-form",children:[i.jsxs("label",{className:"af-set-label",children:["MCP 名称",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:G=>o(ne=>({...ne,name:G.target.value})),placeholder:"github"})]}),i.jsxs("label",{className:"af-set-label",children:["类型",i.jsxs("select",{className:"af-set-input",value:s.type,onChange:G=>o(ne=>({...ne,type:G.target.value})),children:[i.jsx("option",{value:"url",children:"URL / HTTP"}),i.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:G=>o(ne=>({...ne,url:G.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-set-label",children:["Command",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:G=>o(ne=>({...ne,command:G.target.value})),placeholder:"uvx"})]}),i.jsxs("label",{className:"af-set-label",children:["Args,每行一个",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:G=>o(ne=>({...ne,argsText:G.target.value})),placeholder:`mcp-server-example
320
- --flag`})]})]}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",i.jsx("input",{className:"af-set-input",value:s.description,onChange:G=>o(ne=>({...ne,description:G.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(BC,{title:"Headers",rows:s.headerRows,onChange:G=>o(ne=>({...ne,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(BC,{title:"Env",rows:s.envRows,onChange:G=>o(ne=>({...ne,envRows:G})),placeholderKey:"TOKEN",placeholderValue:"..."}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:G=>o(ne=>({...ne,extraJson:G.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:B,disabled:p,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:W,disabled:p,children:p?"保存中...":"保存 MCP"})]})]})]})]})})]})}function woe(e={}){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=new URLSearchParams({flowId:t,flowSource:String((e==null?void 0:e.flowSource)||"user").trim()||"user"}),r=String((e==null?void 0:e.workspaceId)||"").trim();if(r&&n.set("workspaceId",r),(e==null?void 0:e.kind)==="workspace"){const s=String((e==null?void 0:e.scheduleNodeId)||"").trim();s&&n.set("focusNodeId",s)}return`/workspace?${n.toString()}`}function WC(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function HC(e){if(!e)return"-";const t=typeof e=="number"?e:Date.parse(String(e));return Number.isFinite(t)?new Date(t).toLocaleString():String(e)}function xoe(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function boe(e){if(e!=null&&e.running)return"运行中";if(!(e!=null&&e.enabled))return"已停用";const t=String((e==null?void 0:e.lastStatus)||"").trim();return!t||t==="armed"||t==="enabled"?"已启用":t==="success"?"上次成功":t==="failed"?"上次失败":t==="invalid"?"配置异常":t.startsWith("skipped")?"已跳过":t}function koe(){const{navigate:e}=rs(),[t,n]=m.useState([]),[r,s]=m.useState(!1),[o,a]=m.useState(""),[l,c]=m.useState(""),u=m.useCallback(async()=>{s(!0),a("");try{const d=await fetch("/api/schedules"),h=await d.json().catch(()=>({}));if(!d.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(d){a(String(d.message||d)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{u()},[u]);const p=m.useCallback(async d=>{const h=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`;c(h),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:d.kind,flowId:d.flowId,flowSource:d.flowSource||"user",scheduleNodeId:d.scheduleNodeId||"",enabled:!d.enabled})}),v=await y.json().catch(()=>({}));if(!y.ok||v.success===!1)throw new Error(v.error||"更新定时任务失败");await u()}catch(y){a(String(y.message||y))}finally{c("")}},[u]),f=m.useMemo(()=>{const d=t.filter(y=>y.enabled).length,h=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:d,workspace:h,pipeline:t.length-h}},[t]);return i.jsxs("div",{className:"af-settings-page af-schedules-page",children:[i.jsxs("div",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"定时任务"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"定时任务"}),i.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),i.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[i.jsxs("div",{children:[i.jsx("span",{children:"全部"}),i.jsx("strong",{children:f.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"启用中"}),i.jsx("strong",{children:f.enabled})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Workspace"}),i.jsx("strong",{children:f.workspace})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Pipeline"}),i.jsx("strong",{children:f.pipeline})]})]}),o?i.jsx("div",{className:"af-schedules-error",children:o}):null,r?i.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?i.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,i.jsx("div",{className:"af-schedules-list",children:t.map(d=>{const h=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`,y=l===h,v=woe(d);return i.jsxs("article",{className:"af-schedule-card",children:[i.jsxs("div",{className:"af-schedule-card__main",children:[i.jsxs("div",{className:"af-schedule-card__title-row",children:[i.jsx("strong",{children:d.label||d.flowId||"-"}),i.jsx("span",{className:`af-schedule-badge af-schedule-badge--${d.kind||"pipeline"}`,children:xoe(d)}),i.jsx("span",{className:`af-schedule-state ${d.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:boe(d)})]}),i.jsxs("div",{className:"af-schedule-card__meta",children:[i.jsx("span",{children:d.flowId||"-"}),i.jsx("span",{children:d.flowSource||"user"}),d.scheduleNodeId?i.jsx("span",{children:d.scheduleNodeId}):null]}),i.jsxs("div",{className:"af-schedule-card__grid",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Cron"}),i.jsx("strong",{children:d.cron||"-"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"时区"}),i.jsx("strong",{children:d.timezone||"Asia/Shanghai"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"下次执行"}),i.jsx("strong",{children:HC(d.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:HC(d.lastTriggeredAt)})]})]}),d.lastError?i.jsx("p",{className:"af-schedule-card__error",children:d.lastError}):null]}),i.jsxs("div",{className:"af-schedule-card__actions",children:[v?i.jsxs("button",{type:"button",className:"af-schedule-open",title:WC(d),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),WC(d)]}):null,i.jsxs("button",{type:"button",className:d.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":d.enabled,title:d.enabled?"点击停用":"点击启用",onClick:()=>void p(d),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":d.enabled?"toggle_on":"toggle_off"}),d.enabled?"已启用":"已停用"]})]})]},h)})})]})})]})}const VC={id:"",title:"Untitled Node",definitionId:"",agentMessages:[],promptDraft:"",manifest:{id:"",version:"1.0.0",name:"",runtime:{type:"agent_subAgent"},inputs:[],outputs:[],configSchema:{fields:[]},ui:{card:{icon:"extension",variant:"default",actions:[]}}},config:{},files:{},test:{inputs:{},log:[],status:"not run"}};function KC(e){const t=(e==null?void 0:e.manifest)||{};return(e==null?void 0:e.definitionId)||`marketplace:${t.id||(e==null?void 0:e.id)||"node"}@${t.version||"1.0.0"}`}function voe(e){var c,u,p,f,d,h,y,v,b,g,k,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((p=(u=t.ui)==null?void 0:u.card)==null?void 0:p.actions)?t.ui.card.actions:[],l=(f=e==null?void 0:e.test)!=null&&f.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(_=>[`input.${_.name||"-"}`,`${_.type||"text"}${_.required?" · required":""}${_.default?` · default: ${_.default}`:""}`]),...s.map(_=>[`output.${_.name||"-"}`,_.type||"text"]),...o.map(_=>[`config.${_.key||"-"}`,_.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((d=t.runtime)==null?void 0:d.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(b=t.ui)==null?void 0:b.card)==null?void 0:g.icon)||"extension"],...a.map(_=>[`action.${_.id||_.label||"-"}`,_.variant||_.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([_,S])=>[`sample.${_}`,String(S)]),["last run",`${((k=e==null?void 0:e.test)==null?void 0:k.status)||"not run"}${(x=e==null?void 0:e.test)!=null&&x.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function Soe(){var L,M,V,B,F,$,H;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,o]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState(""),y=e||VC,v=m.useMemo(()=>voe(y),[y]),b=m.useMemo(()=>v.find(A=>A.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((L=y==null?void 0:y.test)==null?void 0:L.inputs)||{},_=Array.isArray((M=y==null?void 0:y.test)==null?void 0:M.log)?y.test.log:[],S=((B=(V=g.ui)==null?void 0:V.card)==null?void 0:B.icon)||"event_repeat",N=(($=(F=g.ui)==null?void 0:F.card)==null?void 0:$.variant)||"default",P=k.enabled===!0,R=m.useCallback(async()=>{var A;l(!0),u("");try{const Q=await fetch("/api/node-studio/drafts"),K=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(K.error||"读取节点草稿失败");const W=Array.isArray(K.drafts)?K.drafts[0]:null;if(!(W!=null&&W.id)){t(null),h("");return}const te=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(W.id)}`),Z=await te.json().catch(()=>({}));if(!te.ok)throw new Error(Z.error||"读取节点草稿失败");t(Z.draft||null),h(String(((A=Z.draft)==null?void 0:A.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);m.useEffect(()=>{R()},[R]);const z=m.useCallback(async(A={})=>{var Q;f(!0),u("");try{const K=await fetch("/api/node-studio/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:(e==null?void 0:e.id)||"untitled_node",...A})}),W=await K.json().catch(()=>({}));if(!K.ok||W.ok===!1)throw new Error(W.error||"保存节点草稿失败");t(W.draft||e),h(String(((Q=W.draft||e)==null?void 0:Q.promptDraft)||""))}catch(K){u(String(K.message||K))}finally{f(!1)}},[e]),E=()=>{o(!0),window.setTimeout(()=>o(!1),900)},O=A=>{const Q={...k,enabled:A};t(K=>({...K||VC,config:Q})),z({config:{enabled:A}})},D=()=>{z({promptDraft:d,appendUserMessage:!0})};return i.jsxs("div",{className:"af-node-studio-page",children:[i.jsxs("header",{className:"af-node-studio-top",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"Node Studio"})]}),i.jsx("h1",{children:"节点编辑器"})]}),i.jsxs("div",{className:"af-node-studio-actions",children:[i.jsxs("button",{type:"button",onClick:()=>void R(),disabled:a,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),i.jsxs("button",{type:"button",onClick:E,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"science"}),"Test"]}),i.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),i.jsxs("main",{className:"af-node-studio-shell",children:[i.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),i.jsx("strong",{children:"AI Agent"})]}),c?i.jsx("div",{className:"af-node-studio-error",children:c}):null,i.jsxs("div",{className:"af-node-studio-thread",children:[e?null:i.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(y==null?void 0:y.agentMessages)?y.agentMessages:[]).map((A,Q)=>i.jsx("div",{className:A.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:A.text||""},`${A.role||"message"}-${Q}`)),i.jsxs("div",{className:"af-node-studio-agent-tools",children:[i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),i.jsxs("label",{className:"af-node-studio-prompt",children:[i.jsx("span",{children:"需求"}),i.jsx("textarea",{value:d,onChange:A=>h(A.target.value)})]}),i.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:p,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:p?"sync":"send"}),p?"Saving":"Send"]})]}),i.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),i.jsx("strong",{children:"Preview / Test"})]}),i.jsxs("div",{className:"af-node-studio-preview-grid",children:[i.jsx("div",{className:"af-node-studio-preview-stage",children:e?N==="schedule"?i.jsxs("div",{className:"af-node-preview-card",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:KC(y)})]}),i.jsxs("label",{className:"af-node-preview-toggle",children:[i.jsx("input",{type:"checkbox",checked:P,onChange:A=>O(A.target.checked)}),i.jsx("span",{children:P?"定时开启":"定时关闭"})]}),i.jsxs("div",{className:"af-node-preview-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:k.scheduleType||"daily",onChange:A=>z({config:{scheduleType:A.target.value}}),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{children:[i.jsxs("select",{value:k.hour||"09",onChange:A=>z({config:{hour:A.target.value}}),children:[i.jsx("option",{children:"09"}),i.jsx("option",{children:"10"})]}),i.jsxs("select",{value:k.minute||"00",onChange:A=>z({config:{minute:A.target.value}}),children:[i.jsx("option",{children:"00"}),i.jsx("option",{children:"30"})]})]})]})]}),i.jsxs("div",{className:"af-node-preview-meta",children:[i.jsxs("span",{children:[k.scheduleType==="weekly"?"每周":"每天"," ",k.hour||"09",":",k.minute||"00"]}),i.jsx("span",{children:"Next -"}),i.jsx("span",{children:P?"enabled":"disabled"})]}),i.jsxs("div",{className:"af-node-preview-actions",children:[i.jsxs("button",{type:"button",className:"af-node-preview-run",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):i.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:KC(y)})]}),i.jsxs("div",{className:"af-node-preview-default-body",children:[i.jsx("p",{children:g.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),i.jsxs("div",{children:[i.jsxs("span",{children:[Array.isArray(g.inputs)?g.inputs.length:0," inputs"]}),i.jsxs("span",{children:[Array.isArray(g.outputs)?g.outputs.length:0," outputs"]}),i.jsx("span",{children:((H=g.runtime)==null?void 0:H.type)||g.baseDefinitionId||"agent_subAgent"})]})]})]}):i.jsxs("div",{className:"af-node-preview-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),i.jsx("strong",{children:"暂无预览"}),i.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),i.jsxs("div",{className:"af-node-studio-test",children:[i.jsxs("div",{className:"af-node-studio-subhead",children:[i.jsx("strong",{children:"Test Inputs"}),i.jsxs("button",{type:"button",onClick:E,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"play_arrow"}),"Run"]})]}),i.jsxs("div",{className:"af-node-studio-inputs",children:[i.jsxs("label",{children:[i.jsx("span",{children:"project"}),i.jsx("input",{value:x.project||"",readOnly:!0,placeholder:"-"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"date"}),i.jsx("input",{value:x.date||"",readOnly:!0,placeholder:"-"})]})]}),i.jsx("div",{className:"af-node-studio-log",children:(s?["running..."]:_.length?_:["No test run yet."]).map((A,Q)=>i.jsx("span",{children:A},`${A}-${Q}`))})]})]})]}),i.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),i.jsx("strong",{children:"Internals"})]}),i.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:v.map(A=>i.jsxs("button",{type:"button",className:A.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(A.id),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:A.icon}),A.label]},A.id))}),i.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([A,Q])=>i.jsxs("div",{className:"af-node-studio-internal-row",children:[i.jsx("span",{children:A}),i.jsx("strong",{children:Q})]},A))}),i.jsx("pre",{className:"af-node-studio-code",children:b.id==="ui"?JSON.stringify(g.ui||{},null,2):b.id==="contract"?JSON.stringify({inputs:g.inputs||[],outputs:g.outputs||[],configSchema:g.configSchema||{}},null,2):b.id==="tests"?JSON.stringify((y==null?void 0:y.test)||{},null,2):JSON.stringify({runtime:g.runtime||{},files:(y==null?void 0:y.files)||{}},null,2)})]})]})]})}function joe(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Noe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ph(e){const t=String(e||"").trim();if(!t)return"";let n=t;try{n=new URL(t).pathname}catch{n=t.split("?")[0].split("#")[0]}return(n.replace(/\/+$/,"").split("/").filter(Boolean).pop()||"").replace(/\.git$/i,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/^_+|_+$/g,"")}function _oe(e={},t={}){return`${String(e.mountPath||t.mountPath||e.label||t.label||e.id||t.id||"workspace").trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"WORKSPACE"}_GIT_TOKEN`}function $w(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function nh(e={}){return{id:String((e==null?void 0:e.id)||""),label:String((e==null?void 0:e.label)||(e==null?void 0:e.name)||""),kind:(e==null?void 0:e.kind)==="local"?"local":"git",path:String((e==null?void 0:e.path)||""),repoUrl:String((e==null?void 0:e.repoUrl)||""),branch:String((e==null?void 0:e.branch)||"master"),mountPath:String((e==null?void 0:e.mountPath)||""),credentialRef:String((e==null?void 0:e.credentialRef)||""),type:String((e==null?void 0:e.type)||((e==null?void 0:e.kind)==="local"?"local":"code")),description:String((e==null?void 0:e.description)||""),enabled:(e==null?void 0:e.enabled)!==!1}}function Coe(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||Ph(n)||"").trim():"";return{id:String(e.id||"").trim(),label:String(e.label||"").trim(),kind:t,path:String(e.path||"").trim(),repoUrl:n,branch:t==="git"?String(e.branch||"master").trim()||"master":"",mountPath:r,credentialRef:t==="git"?String(e.credentialRef||"").trim():"",type:String(e.type||(t==="local"?"local":"code")).trim(),description:String(e.description||"").trim(),enabled:e.enabled!==!1}}function Qi(e,t=0){return(e==null?void 0:e.id)||(e==null?void 0:e.path)||(e==null?void 0:e.repoUrl)||`workspace-${t}`}function Aoe({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function qC({item:e,selected:t,onClick:n,readOnly:r}){return i.jsxs("button",{type:"button",className:"af-workspaces-card"+(t?" af-workspaces-card--selected":""),onClick:n,children:[i.jsxs("div",{className:"af-workspaces-card__head",children:[i.jsx("strong",{children:e.label||"知识库"}),i.jsx("span",{children:e.kind==="git"?"Git":"Local"})]}),i.jsx("p",{children:e.description||e.repoUrl||e.path||"-"}),i.jsxs("div",{className:"af-workspaces-card__meta",children:[i.jsx(Aoe,{ok:e.exists!==!1}),i.jsx("span",{children:e.exists===!1?"路径未就绪":"路径可用"}),r?i.jsx("em",{children:"内置"}):e.enabled===!1?i.jsx("em",{children:"disabled"}):null]})]})}function Eoe(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState($w),[k,x]=m.useState(""),[_,S]=m.useState([]),[N,P]=m.useState(""),R=m.useMemo(()=>y.findIndex((K,W)=>Qi(K,W)===N),[y,N]),E=!!m.useMemo(()=>d.find((K,W)=>Qi(K,W)===N)||null,[d,N]),O=m.useMemo(()=>{const K=String(b.credentialRef||"").trim();return K?_.some(W=>String((W==null?void 0:W.key)||"").trim()===K&&String((W==null?void 0:W.value)??"")!==""):!1},[b.credentialRef,_]),D=m.useCallback(async()=>{t(!0),l("");try{const[K,W]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),te=await K.json().catch(()=>({})),Z=await W.json().catch(()=>({}));if(!W.ok)throw new Error(typeof Z.error=="string"?Z.error:"ENV HTTP "+W.status);if(!K.ok)throw new Error(typeof te.error=="string"?te.error:"HTTP "+K.status);const G=Array.isArray(te.workspaces)?te.workspaces:[],ne=Array.isArray(te.customWorkspaces)?te.customWorkspaces:[];f(String(te.path||"")),h(G.filter(re=>re==null?void 0:re.builtin)),v(ne),S(Array.isArray(Z.env)?Z.env.map(re=>({key:String((re==null?void 0:re.key)||""),value:String((re==null?void 0:re.value)??"")})):[])}catch(K){l(String(K.message||K))}finally{t(!1)}},[]);m.useEffect(()=>{D()},[D]);const L=m.useCallback(async(K,W="")=>{r(!0),l(""),u("");try{const te=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:K})}),Z=await te.json().catch(()=>({}));if(!te.ok)throw new Error(typeof Z.error=="string"?Z.error:"HTTP "+te.status);const G=Array.isArray(Z.customWorkspaces)?Z.customWorkspaces:K;v(G),h((Array.isArray(Z.workspaces)?Z.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin)),f(String(Z.path||p)),W&&P(W),u("已保存")}catch(te){l(String(te.message||te))}finally{r(!1)}},[p]),M=m.useCallback(()=>{P(""),g($w()),x(""),u(""),l("")},[]),V=m.useCallback((K,W)=>{P(Qi(K,W)),g(nh(K)),x(""),u("")},[]),B=m.useCallback((K,W)=>{P(Qi(K,W)),g(nh(K)),x(""),u("")},[]),F=m.useCallback(async(K,W)=>{const te=String(K||"").trim(),Z=String(W??"");if(!te||!Z)return;const G=_.filter(se=>String((se==null?void 0:se.key)||"").trim()!==te);G.push({key:te,value:Z});const ne=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(typeof re.error=="string"?re.error:"ENV HTTP "+ne.status);S(Array.isArray(re.env)?re.env.map(se=>({key:String((se==null?void 0:se.key)||""),value:String((se==null?void 0:se.value)??"")})):G)},[_]),$=m.useCallback(()=>{const K=Coe({...b,id:b.id||joe()}),W=k.trim();if(K.kind==="git"&&W&&!K.credentialRef&&(K.credentialRef=_oe(b,K)),K.kind==="local"&&!K.path){l("本地知识库需要填写路径");return}if(K.kind==="git"&&!K.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!K.label){l("请填写名称");return}if(K.kind==="git"&&K.credentialRef&&!Noe(K.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const te=R>=0?y.map((Z,G)=>G===R?K:Z):[K,...y];g(nh(K)),(async()=>{r(!0);try{W&&await F(K.credentialRef,W),x(""),await L(te,Qi(K))}catch(Z){l(String(Z.message||Z)),r(!1)}})()},[y,b,L,F,R,k]),H=m.useCallback(()=>{if(R<0)return;const K=y.filter((W,te)=>te!==R);g($w()),P(""),L(K)},[y,L,R]),A=m.useCallback(async()=>{if(!E){if(R<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}o(!0),l(""),u("");try{const K=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),W=await K.json().catch(()=>({}));if(!K.ok)throw new Error(typeof W.error=="string"?W.error:"HTTP "+K.status);const te=Array.isArray(W.customWorkspaces)?W.customWorkspaces:y;v(te),h((Array.isArray(W.workspaces)?W.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin));const Z=te.find(ne=>String((ne==null?void 0:ne.id)||"")===String(b.id||""));Z&&g(nh(Z));const G=String(W.commit||"").trim();u(W.changed?`已拉取更新${G?`:${G.slice(0,8)}`:""}`:`已是最新${G?`:${G.slice(0,8)}`:""}`)}catch(K){l(String(K.message||K))}finally{o(!1)}}},[y,b,E,R]),Q=m.useCallback(K=>{g(W=>({...W,...K}))},[]);return i.jsxs("div",{className:"af-workspaces-page",children:[i.jsxs("header",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb","aria-label":"知识库",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"知识库"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:D,disabled:e,children:[i.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),i.jsx("main",{className:"af-settings-body",children:i.jsxs("div",{className:"af-workspaces-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"知识库"}),i.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),p?i.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",p]}):null,a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?i.jsx("p",{className:"af-workspaces-status",children:c}):null]}),i.jsxs("section",{className:"af-workspaces-summary",children:[i.jsxs("div",{children:[i.jsx("span",{children:"内置"}),i.jsx("strong",{children:d.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"自定义"}),i.jsx("strong",{children:y.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Git"}),i.jsx("strong",{children:y.filter(K=>K.kind==="git").length})]})]}),i.jsxs("div",{className:"af-workspaces-layout",children:[i.jsxs("section",{className:"af-workspaces-list",children:[i.jsxs("div",{className:"af-workspaces-section-head",children:[i.jsx("h2",{children:"自定义知识库"}),i.jsxs("button",{type:"button",onClick:M,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]}),y.length?y.map((K,W)=>i.jsx(qC,{item:K,selected:Qi(K,W)===N,onClick:()=>V(K,W)},Qi(K,W))):i.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义知识库。新增 Git 或本地目录后,画布里的加载知识库和一键任务就可以选择它。"}),i.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:i.jsx("h2",{children:"内置知识库"})}),d.map((K,W)=>i.jsx(qC,{item:K,selected:Qi(K,W)===N,onClick:()=>B(K,W),readOnly:!0},Qi(K,W)))]}),i.jsxs("section",{className:"af-workspaces-editor",children:[i.jsxs("div",{className:"af-workspaces-editor__head",children:[i.jsxs("div",{children:[i.jsx("h2",{children:E?"查看内置知识库":R>=0?"编辑知识库":"新增知识库"}),i.jsx("p",{children:E?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),i.jsxs("label",{className:"af-workspaces-switch",children:[i.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:E,onChange:K=>Q({enabled:K.target.checked})}),i.jsx("span",{children:"启用"})]})]}),i.jsxs("div",{className:"af-workspaces-kind",children:[i.jsxs("button",{type:"button",className:b.kind==="git"?"active":"",disabled:E,onClick:()=>Q({kind:"git",type:b.type==="local"?"code":b.type}),children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),i.jsxs("button",{type:"button",className:b.kind==="local"?"active":"",disabled:E,onClick:()=>Q({kind:"local",type:"local"}),children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),i.jsxs("div",{className:"af-workspaces-form",children:[i.jsxs("label",{children:[i.jsx("span",{children:"名称"}),i.jsx("input",{value:b.label,disabled:E,onChange:K=>Q({label:K.target.value}),placeholder:"Likee Android"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"类型"}),i.jsxs("select",{value:b.type,disabled:E,onChange:K=>Q({type:K.target.value}),children:[i.jsx("option",{value:"code",children:"code"}),i.jsx("option",{value:"docs",children:"docs"}),i.jsx("option",{value:"analytics",children:"analytics"}),i.jsx("option",{value:"config",children:"config"}),i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"other",children:"other"})]})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"本地路径"}),i.jsx("input",{value:b.path,disabled:E,onChange:K=>Q({path:K.target.value}),placeholder:b.kind==="git"?"可空,默认保存到全局资源目录/repos/<仓库名>":"/Users/.../project"})]}),b.kind==="git"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"Git URL"}),i.jsx("input",{value:b.repoUrl,disabled:E,onChange:K=>{const W=K.target.value,te=Ph(b.repoUrl),Z=String(b.mountPath||"").trim();Q({repoUrl:W,...!Z||Z===te?{mountPath:Ph(W)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"分支"}),i.jsx("input",{value:b.branch,disabled:E,onChange:K=>Q({branch:K.target.value}),placeholder:"master"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"挂载目录"}),i.jsx("input",{value:b.mountPath,disabled:E,onChange:K=>Q({mountPath:K.target.value}),placeholder:Ph(b.repoUrl)||"repo_name"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"凭证环境变量"}),i.jsx("input",{value:b.credentialRef,disabled:E,onChange:K=>Q({credentialRef:K.target.value}),placeholder:"LIKEE_GIT_READONLY_TOKEN"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"Token"}),i.jsx("input",{type:"password",value:k,disabled:E,onChange:K=>x(K.target.value),placeholder:O?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 workspace 配置"}),i.jsx("small",{children:"保存后只在知识库配置中保留 credentialRef,token 会写入当前用户的个人环境变量。"})]})]}):null,i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:b.description,disabled:E,onChange:K=>Q({description:K.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),i.jsxs("div",{className:"af-workspaces-actions",children:[!E&&R>=0?i.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:H,disabled:n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):i.jsx("span",{}),i.jsxs("div",{children:[b.kind==="git"&&R>=0?i.jsxs("button",{type:"button",onClick:A,disabled:E||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:s?"sync":"download"}),s?"拉取中":"拉取更新"]}):null,i.jsx("button",{type:"button",onClick:M,disabled:n||s,children:"重置"}),i.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:$,disabled:E||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const a$="agentflow.workflows.scopeView",qa=8,UC=24;function Ioe(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(a$)==="team"?"team":"personal"}catch{return"personal"}}function Poe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}function Roe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleDateString([],{year:"numeric",month:"2-digit",day:"2-digit"}):"日期待定"}function Toe(e){return Object.values((e==null?void 0:e.dimensions)||{}).flatMap(t=>Array.isArray(t)?t:[t]).map(t=>String(t||"").trim()).filter(Boolean).join(" · ")}function Moe(e){const t=Number((e==null?void 0:e.workflowCount)||0),n=Number((e==null?void 0:e.completedCount)||0);if(t>0&&n>=t)return{key:"completed",label:"已完成"};const r=Date.parse(String((e==null?void 0:e.date)||""));return Number.isFinite(r)&&r<Date.now()?{key:"overdue",label:"已到期"}:{key:"planned",label:"计划中"}}function Ra(e){const t=new Date;return t.setHours(12,0,0,0),t.setDate(t.getDate()+e),t.toISOString().slice(0,10)}function $oe(e){const t=Array.isArray(e)?e.length:0;if(t<=qa)return{start:0,end:t};const n=Date.now();let r=e.findIndex(o=>{const a=Date.parse(String((o==null?void 0:o.date)||""));return Number.isFinite(a)&&a>=n});r<0&&(r=t-1);const s=Math.max(0,Math.min(r-3,t-qa));return{start:s,end:Math.min(t,s+qa)}}function Loe(){const e=[{key:"prd-flow:version:android-5.62.0",kind:"version",id:"android-5.62.0",title:"Likee Android 5.62.0",date:Ra(-12),source:"prd-flow",dimensions:{platform:"Android"}},{key:"prd-flow:version:android-5.63.0",kind:"version",id:"android-5.63.0",title:"Likee Android 5.63.0",date:Ra(6),source:"prd-flow",dimensions:{platform:"Android"}},{key:"prd-flow:version:ios-5.63.0",kind:"version",id:"ios-5.63.0",title:"Likee iOS 5.63.0",date:Ra(10),source:"prd-flow",dimensions:{platform:"iOS"}},{key:"prd-flow:milestone:august-gray",kind:"milestone",id:"august-gray",title:"8 月灰度窗口",date:Ra(18),source:"prd-flow",dimensions:{channel:"灰度"}},...Array.from({length:12},(s,o)=>({key:`prd-flow:version:android-5.${50+o}.0`,kind:"version",id:`android-5.${50+o}.0`,title:`Likee Android 5.${50+o}.0`,date:Ra(-180+o*14),source:"prd-flow",dimensions:{platform:"Android"}})),...Array.from({length:8},(s,o)=>({key:`prd-flow:version:android-5.${64+o}.0`,kind:"version",id:`android-5.${64+o}.0`,title:`Likee Android 5.${64+o}.0`,date:Ra(32+o*14),source:"prd-flow",dimensions:{platform:"Android"}}))],t=Object.fromEntries(e.map(s=>[s.key,s])),n=[{id:"demo-1",tapdId:"1020124",title:"Likee Android AI Runtime Hook Skill 搭建",pointer:"继续实现 Android Action 与通用 Hook 多层注入平台",phase:"IMPLEMENTATION_IN_PROGRESS",state:"active",role:"owner",ownerUsername:"wangfang",issueCount:2,platforms:["android"],actionCount:5,completedActionCount:4,latestAction:{title:"Android 实现协议已确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:android-5.63.0"]],demo:!0},{id:"demo-2",tapdId:"1013667",title:"激励视频增收方案",pointer:"检查并选择 TAPD 未解决 Bug",phase:"BUG_SELECTION_READY",state:"blocked",role:"viewer",ownerUsername:"surujija",issueCount:18,platforms:["android","ios"],actionCount:33,completedActionCount:32,latestAction:{title:"等待版本风险确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:android-5.63.0"],t["prd-flow:version:ios-5.63.0"]],demo:!0},{id:"demo-3",tapdId:"1133202860001018940",title:"Likee Android 5.62.0",pointer:"发版上下文已同步",phase:"RELEASED",state:"completed",role:"editor",ownerUsername:"chenjunlun",issueCount:1,platforms:["ios"],actionCount:1,completedActionCount:1,latestAction:{title:"版本发布完成",at:Ra(-12)},timeline:[t["prd-flow:version:android-5.62.0"]],demo:!0},{id:"demo-4",tapdId:"1015046",title:"Remote Config 拉取频控",pointer:"双端方案进入提测准备",phase:"SUBMIT_TEST",state:"active",role:"owner",ownerUsername:"alice",issueCount:4,platforms:["android","ios"],actionCount:8,completedActionCount:6,latestAction:{title:"测试用例已归档",at:new Date().toISOString()},timeline:[t["prd-flow:version:ios-5.63.0"],t["prd-flow:milestone:august-gray"]],demo:!0},{id:"demo-5",tapdId:"1027788",title:"直播间礼物动效治理",pointer:"等待确认目标版本",phase:"PLANNING",state:"active",role:"editor",ownerUsername:"bob",issueCount:3,platforms:["all"],actionCount:4,completedActionCount:1,latestAction:{title:"技术方案评审中",at:new Date().toISOString()},timeline:[],demo:!0},...e.slice(4).map((s,o)=>({id:`demo-timeline-${o+1}`,tapdId:`DEMO-${String(o+1).padStart(3,"0")}`,title:`${s.title} 版本事项`,pointer:o<12?"历史版本事项已归档":"等待进入版本排期",phase:o<12?"RELEASED":"PLANNING",state:o<12?"completed":"active",role:o%3===0?"owner":"editor",ownerUsername:o%3===0?"wangfang":"demo-user",issueCount:o%4+1,platforms:["android"],actionCount:4,completedActionCount:o<12?4:1,latestAction:{title:o<12?"版本归档完成":"版本排期已同步",at:s.date},timeline:[s],demo:!0}))],r=e.map(s=>{const o=n.filter(a=>a.timeline.some(l=>l.key===s.key));return{...s,workflowCount:o.length,completedCount:o.filter(a=>a.state==="completed").length,blockedCount:o.filter(a=>a.state==="blocked").length,workflowIds:o.map(a=>a.id)}}).sort((s,o)=>Date.parse(s.date)-Date.parse(o.date));return{workflows:n,timeline:r,unassignedCount:1}}function Ooe(e){return e==="owner"?"我创建的":e==="editor"?"协作编辑":e==="viewer"?"只读协作":"可访问"}function l$(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function c$(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function Doe(e){const t=new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||""),returnTo:"/workflows"});return e!=null&&e.demo&&t.set("workflowDemo","1"),`/workspace?${t.toString()}`}function Foe(e){var u,p,f;const t=String((e==null?void 0:e.tapdId)||"DEMO"),n=c$(((u=e==null?void 0:e.platforms)==null?void 0:u[0])||"all")||"双端",r=((p=e==null?void 0:e.timeline)==null?void 0:p[0])||{},s=[["方案已确认","需求范围和实现方案已完成确认。"],["研发任务已创建","Issue 与研发分支信息已经同步。"],["实现进度已更新","实现状态和当前风险已归档。"],["测试状态已更新","自测、提测状态已经同步。"],["版本归属已确认","版本排期和发布上下文已经确认。"]],o=Math.min(5,Math.max(1,Number((e==null?void 0:e.actionCount)||1))),a=Number((e==null?void 0:e.actionCount)||0)>0?Number((e==null?void 0:e.completedActionCount)||0)/Number(e.actionCount):0,l=Math.round(o*a),c=s.slice(0,o).map(([d,h],y)=>({id:`demo-action-${y+1}`,actionId:`demo-action-${y+1}`,stageKey:["plan","issue","implementation","test","release"][y],title:d,detail:h,status:y<l?"done":y===l?"current":"pending",issueKey:`demo-${t.toLowerCase()}`,platform:n,updatedAt:new Date(Date.now()-(o-y)*45*60*1e3).toISOString()}));return{revision:`demo-${t}`,phase:(e==null?void 0:e.phase)||"PLANNING",pointer:(e==null?void 0:e.pointer)||((f=e==null?void 0:e.latestAction)==null?void 0:f.title)||"本地 Workflow 示例",actions:c,issues:Array.from({length:Math.min(4,Math.max(1,Number((e==null?void 0:e.issueCount)||1)))},(d,h)=>({key:`demo-${t.toLowerCase()}-${h+1}`,title:h===0?(e==null?void 0:e.title)||"示例研发事项":`子任务 ${h+1}`,platform:n,status:(e==null?void 0:e.state)==="completed"?"done":h===0?"in_progress":"pending",epicKey:"示例需求"})),globalState:{title:(e==null?void 0:e.title)||`TAPD ${t}`,status:{label:l$(e==null?void 0:e.state)},workflow:{namespace:"tapd",id:t},sections:{version:{title:"版本归属",fields:{version:{label:"版本",type:"text",value:r.title||"待归属"},date:{label:"版本日期",type:"text",value:r.date||"待确认"},platform:{label:"平台",type:"chips",value:[n]}}},progress:{title:"研发进度",fields:{actions:{label:"Action",type:"text",value:`${(e==null?void 0:e.completedActionCount)||0}/${(e==null?void 0:e.actionCount)||0}`},issues:{label:"Issues",type:"text",value:String((e==null?void 0:e.issueCount)||0)},owner:{label:"Owner",type:"user",value:(e==null?void 0:e.ownerUsername)||"demo-user"}}}}},runtimeEvents:c.map(d=>({...d,type:"demo-runtime-event"})),demo:!0}}function zoe(e,t){if(t!=null&&t.demo)try{window.sessionStorage.setItem(`agentflow.workflow.demo:${t.tapdId}`,JSON.stringify(Foe(t)))}catch{}e(Doe(t))}function Boe(){const{navigate:e}=rs(),[t,n]=m.useState([]),[r,s]=m.useState([]),[o,a]=m.useState(0),[l,c]=m.useState("all"),[u,p]=m.useState(Ioe),[f,d]=m.useState(null),[h,y]=m.useState(!1),[v,b]=m.useState(""),[g,k]=m.useState(""),[x,_]=m.useState("all"),[S,N]=m.useState("all"),[P,R]=m.useState(!1),[z,E]=m.useState({start:0,end:0}),O=m.useRef(null),D=m.useRef(null),L=m.useRef(!1),M=m.useRef(0),V=m.useRef(0),B=m.useCallback(async()=>{R(!1),y(!0),b("");try{const Z=await fetch(`/api/prd-workflows?view=${encodeURIComponent(u)}`),G=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(G.error||"读取迭代列表失败");const ne=Array.isArray(G.workflows)?G.workflows:[],re=Array.isArray(G.timeline)?G.timeline:[];n(ne),s(re),a(Number(G.unassignedCount||0)),c(se=>se==="all"||se==="unassigned"&&Number(G.unassignedCount||0)>0||re.some(ee=>ee.key===se)?se:"all"),d(G.team||null)}catch(Z){b(String(Z.message||Z)),n([]),s([]),a(0),c("all"),d(null)}finally{y(!1)}},[u]),F=m.useCallback(()=>{const Z=Loe();n(Z.workflows),s(Z.timeline),a(Z.unassignedCount),c("all"),k(""),_("all"),N("all"),b(""),R(!0)},[]);m.useEffect(()=>{B()},[B]),m.useEffect(()=>{try{localStorage.setItem(a$,u)}catch{}},[u]),m.useEffect(()=>{E($oe(r))},[r]),m.useLayoutEffect(()=>{const Z=D.current,G=O.current;if(G){if(Z){D.current=null;const ne=Array.from(G.children).find(re=>re.dataset.timelineKey===Z.key);ne&&(G.scrollLeft=Z.scrollLeft+ne.offsetLeft-Z.offsetLeft)}window.clearTimeout(M.current),M.current=window.setTimeout(()=>{L.current=!1},80)}},[z]),m.useEffect(()=>()=>{window.clearTimeout(M.current),window.cancelAnimationFrame(V.current)},[]);const $=m.useMemo(()=>r.slice(z.start,z.end),[r,z]),H=z.start>0,A=z.end<r.length,Q=m.useCallback(()=>{if(!H||L.current)return;L.current=!0;const Z=O.current,G=Z==null?void 0:Z.querySelector("[data-timeline-key]");D.current=G?{key:G.dataset.timelineKey,offsetLeft:G.offsetLeft,scrollLeft:Z.scrollLeft}:null,E(ne=>({start:Math.max(0,ne.start-qa),end:Math.min(ne.end,Math.max(0,ne.start-qa)+UC)}))},[H]),K=m.useCallback(()=>{if(!A||L.current)return;L.current=!0;const Z=O.current,G=Z==null?void 0:Z.querySelectorAll("[data-timeline-key]"),ne=G==null?void 0:G[G.length-1];D.current=ne?{key:ne.dataset.timelineKey,offsetLeft:ne.offsetLeft,scrollLeft:Z.scrollLeft}:null,E(re=>({start:Math.max(re.start,Math.min(r.length,re.end+qa)-UC),end:Math.min(r.length,re.end+qa)}))},[A,r.length]),W=m.useCallback(Z=>{const G=Z.currentTarget;V.current||(V.current=window.requestAnimationFrame(()=>{V.current=0,!L.current&&(G.scrollLeft<=32?Q():G.scrollLeft+G.clientWidth>=G.scrollWidth-32&&K())}))},[Q,K]),te=m.useMemo(()=>{const Z=g.trim().toLowerCase();return t.filter(G=>{var ne;return l==="unassigned"&&(G.timeline||[]).length>0||l!=="all"&&l!=="unassigned"&&!(G.timeline||[]).some(re=>re.key===l)||x==="owned"&&G.role!=="owner"||x==="collaborating"&&G.role==="owner"||S!=="all"&&G.state!==S?!1:Z?[G.tapdId,G.title,G.pointer,G.phase,G.ownerUsername,(ne=G.latestAction)==null?void 0:ne.title,...(G.timeline||[]).flatMap(re=>[re.title,re.kind,re.date,...Object.values(re.dimensions||{})])].some(re=>String(re||"").toLowerCase().includes(Z)):!0})},[g,x,S,l,t]);return i.jsx("div",{className:"af-settings-page af-workflows-page",children:i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner af-workflows-inner",children:[i.jsxs("section",{className:"af-settings-hero af-workflows-hero",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-workflows-eyebrow",children:"Workflow Dashboard"}),i.jsx("h1",{className:"af-settings-h1",children:"迭代"}),i.jsx("p",{className:"af-settings-lead",children:u==="team"?`汇总${f!=null&&f.name?`「${f.name}」`:"当前团队"}的需求 Workflow,按负责人追踪进度与风险。`:"集中查看我创建和参与的需求 Workflow,追踪阶段、Action 进度与最新动态。"})]}),i.jsxs("div",{className:"af-workflows-hero-actions",children:[i.jsxs("button",{type:"button",className:"af-workflows-guide-link",onClick:()=>e("/workflow-report"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"integration_instructions"}),"接入说明"]}),i.jsxs("div",{className:"af-scope-switch","aria-label":"迭代视图",children:[i.jsx("button",{type:"button",className:u==="personal"?"is-active":"",onClick:()=>p("personal"),children:"个人迭代"}),i.jsx("button",{type:"button",className:u==="team"?"is-active":"",onClick:()=>p("team"),children:"团队迭代"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void B(),disabled:h,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:h?"hourglass_empty":"refresh"}),"刷新"]})]})]}),r.length>0||o>0?i.jsxs("section",{className:"af-workflows-timeline","aria-label":"迭代时间线",children:[i.jsxs("div",{className:"af-workflows-timeline__heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"迭代时间线"}),i.jsx("strong",{children:"按排期归属汇总"}),P?i.jsx("em",{children:"本地示例"}):null]}),i.jsxs("div",{className:"af-workflows-timeline__actions",children:[l!=="all"?i.jsx("button",{type:"button",onClick:()=>c("all"),children:"查看全部"}):null,P?i.jsx("button",{type:"button",onClick:()=>void B(),children:"退出示例"}):null]})]}),i.jsxs("div",{className:"af-workflows-timeline__rail",ref:O,onScroll:W,children:[$.map(Z=>{const G=Toe(Z),ne=Moe(Z);return i.jsxs("button",{type:"button","data-timeline-key":Z.key,className:`is-${ne.key}${l===Z.key?" is-active":""}`,"aria-pressed":l===Z.key,onClick:()=>c(re=>re===Z.key?"all":Z.key),children:[i.jsxs("span",{className:"af-workflows-timeline__date",children:[Roe(Z.date),i.jsx("em",{children:ne.label})]}),i.jsx("strong",{children:Z.title||Z.id}),i.jsx("small",{children:[G,`${Z.workflowCount||0} 项`,Z.completedCount?`${Z.completedCount} 项已完成`:"",Z.blockedCount?`${Z.blockedCount} 项需关注`:""].filter(Boolean).join(" · ")})]},Z.key)}),o>0&&!A?i.jsxs("button",{type:"button",className:`af-workflows-timeline__unassigned${l==="unassigned"?" is-active":""}`,"aria-pressed":l==="unassigned",onClick:()=>c(Z=>Z==="unassigned"?"all":"unassigned"),children:[i.jsx("span",{className:"af-workflows-timeline__date",children:"未排期"}),i.jsx("strong",{children:"未归属"}),i.jsxs("small",{children:[o," 项 Workflow"]})]}):null]})]}):null,i.jsxs("section",{className:"af-workflows-toolbar","aria-label":"迭代筛选",children:[i.jsxs("label",{className:"af-workflows-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:g,onChange:Z=>k(Z.target.value),placeholder:"搜索 TAPD、需求、阶段或成员","aria-label":"搜索迭代"})]}),i.jsx("div",{className:"af-workflows-segments","aria-label":"协作范围",children:[["all","全部"],["owned","我创建的"],["collaborating","与我协作"]].map(([Z,G])=>i.jsx("button",{type:"button",className:x===Z?"is-active":"","aria-pressed":x===Z,onClick:()=>_(Z),children:G},Z))}),i.jsxs("select",{value:S,onChange:Z=>N(Z.target.value),"aria-label":"迭代状态",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"active",children:"进行中"}),i.jsx("option",{value:"completed",children:"已完成"}),i.jsx("option",{value:"blocked",children:"需关注"})]})]}),v?i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,h?i.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!h&&!v&&t.length===0?i.jsxs("div",{className:"af-workflows-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timeline"}),i.jsx("strong",{children:u==="team"&&!f?"尚未加入团队":"暂无迭代"}),i.jsx("p",{children:u==="team"&&!f?"请联系超级管理员完成团队划分。":"当 prd-flow 上报 Workflow 后,它会出现在这里。"}),i.jsxs("button",{type:"button",className:"af-workflows-demo-button",onClick:F,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"science"}),"载入本地示例时间线"]})]}):null,!h&&t.length>0&&te.length===0?i.jsx("div",{className:"af-workflows-message",children:"没有符合当前筛选条件的迭代。"}):null,i.jsx("div",{className:"af-workflows-list",children:te.map(Z=>{var ne,re;const G=Z.actionCount>0?Math.round(Z.completedActionCount/Z.actionCount*100):0;return i.jsxs("article",{className:"af-workflow-card",children:[i.jsxs("div",{className:"af-workflow-card__identity",children:[i.jsxs("div",{className:"af-workflow-card__title-row",children:[i.jsxs("span",{className:"af-workflow-tapd",children:["TAPD ",Z.tapdId]}),i.jsx("span",{className:`af-workflow-state af-workflow-state--${Z.state||"active"}`,children:l$(Z.state)}),i.jsx("span",{className:"af-workflow-role",children:Ooe(Z.role)}),Z.shareActive?i.jsxs("span",{className:"af-workflow-shared",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"已分享"]}):null]}),i.jsx("h2",{children:Z.title||Z.pointer||`需求 ${Z.tapdId}`}),i.jsxs("div",{className:"af-workflow-card__meta",children:[i.jsx("span",{children:Z.phase||"未识别阶段"}),i.jsxs("span",{children:[Z.issueCount||0," Issues"]}),(Z.platforms||[]).map(se=>i.jsx("span",{children:c$(se)},se)),(Z.timeline||[]).map(se=>i.jsx("span",{children:se.title||se.id},se.key)),i.jsxs("span",{children:["Owner · ",Z.ownerUsername||Z.ownerId||"-"]}),u==="team"&&Z.teamName?i.jsxs("span",{children:["团队 · ",Z.teamName]}):null]})]}),i.jsxs("div",{className:"af-workflow-card__progress",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Action 进度"}),i.jsxs("strong",{children:[Z.completedActionCount||0,"/",Z.actionCount||0]})]}),i.jsx("div",{className:"af-workflow-progress","aria-label":`Action 完成度 ${G}%`,children:i.jsx("span",{style:{width:`${G}%`}})}),i.jsxs("small",{children:[G,"%"]})]}),i.jsxs("div",{className:"af-workflow-card__latest",children:[i.jsx("span",{children:"最新动态"}),i.jsx("strong",{children:((ne=Z.latestAction)==null?void 0:ne.title)||"暂无 Action 记录"}),i.jsx("small",{children:Poe(((re=Z.latestAction)==null?void 0:re.at)||Z.updatedAt)})]}),i.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>zoe(e,Z),children:[Z.demo?"查看示例":"打开 Workflow",i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Z.demo?"science":"arrow_forward"})]})]},Z.id||Z.tapdId)})})]})})})}const Woe=`skillhub install agentflow-cli --global --agent codex
321
- skillhub install agentflow-workflow-report --global --agent codex
322
-
323
- export AGENTFLOW_BASE_URL=http://ai.mengma.bigo.inner
324
- export AGENTFLOW_TOKEN=<your-token>
325
-
326
- # 本地联调
327
- # export AGENTFLOW_BASE_URL=http://127.0.0.1:8765`,Hoe=`{
328
- "schemaVersion": 1,
329
- "workflow": { "namespace": "tapd", "id": "1020124" },
330
- "source": "my-adapter",
331
- "action": {
332
- "key": "requirement-imported",
333
- "title": "需求已同步",
334
- "status": "done",
335
- "occurredAt": "2026-08-05T08:00:00.000Z"
336
- },
337
- "idempotencyKey": "requirement-imported:1020124:v1"
338
- }`,Voe=`# 1. 读取;记录返回的 snapshot.runtimeRevision
339
- node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
340
- --workflow tapd:1020124 --runtime-only
341
-
342
- # 2. 将右侧 JSON 保存为 workflow-report.json 后上报
343
- node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-report \\
344
- --workflow tapd:1020124 \\
345
- --file workflow-report.json \\
346
- --expected-revision 'runtime:<current-revision>'
347
-
348
- # 3. 再读一次,确认 action 和 runtimeRevision 已更新
349
- node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
350
- --workflow tapd:1020124 --runtime-only`,Koe=`GET /api/workflows/state?workflow=tapd%3A1020124&runtimeOnly=1
351
- Authorization: Bearer <AGENTFLOW_TOKEN>`,qoe=`{
352
- "ok": true,
353
- "workflow": {
354
- "namespace": "tapd",
355
- "id": "1020124",
356
- "key": "tapd:1020124"
357
- },
358
- "snapshot": {
359
- "runtimeRevision": "runtime:<current-revision>",
360
- "globalState": {},
361
- "actions": [],
362
- "artifacts": [],
363
- "projections": { "timeline": [] },
364
- "extensions": {}
365
- }
366
- }`,Uoe=`{
367
- "schemaVersion": 1,
368
- "workflow": { "namespace": "tapd", "id": "1020124" },
369
- "source": "prd-flow",
370
- "globalState": {
371
- "mode": "merge",
372
- "patch": {
373
- "tapdCurrentVersion": {
374
- "id": "1133202860001000338",
375
- "name": "Likee Android 5.63.0",
376
- "date": "2026-08-31",
377
- "platform": "android"
378
- }
379
- }
380
- },
381
- "projections": {
382
- "timeline": [
383
- {
384
- "kind": "sprint",
385
- "id": "2026-w32",
386
- "key": "another-producer:sprint:2026-w32"
387
- },
388
- {
389
- "kind": "version",
390
- "id": "android:1133202860001000338",
391
- "key": "prd-flow:version:android:1133202860001000338",
392
- "title": "Likee Android 5.63.0",
393
- "date": "2026-08-31",
394
- "source": "prd-flow",
395
- "dimensions": { "platform": "android" }
396
- }
397
- ]
398
- },
399
- "expectedRevision": "runtime:<current-revision>",
400
- "idempotencyKey": "timeline:1020124:android-version-1133202860001000338:v1"
401
- }`,Goe=`{
402
- "schemaVersion": 1,
403
- "workflow": { "namespace": "tapd", "id": "1020124" },
404
- "source": "prd-flow",
405
- "action": {
406
- "key": "implementation:runtime-hook:android",
407
- "title": "Android 实现完成",
408
- "detail": "MR !957 已合并",
409
- "status": "done",
410
- "group": "implementation",
411
- "platform": "android",
412
- "issueKey": "runtime-hook",
413
- "occurredAt": "2026-08-05T08:25:00.000Z"
414
- },
415
- "artifacts": [{
416
- "key": "implementation-mr:runtime-hook:android",
417
- "type": "gitlab-mr",
418
- "title": "实现 MR !957",
419
- "url": "https://git.example.test/merge_requests/957",
420
- "scope": "action",
421
- "status": "ready"
422
- }],
423
- "expectedRevision": "runtime:<current-revision>",
424
- "idempotencyKey": "implementation-finished:android:runtime-hook:v1"
425
- }`,Yoe=`{
426
- "schemaVersion": 1,
427
- "workflow": { "namespace": "tapd", "id": "1020124" },
428
- "source": "prd-flow",
429
- "extensions": {
430
- "prd-flow": {
431
- "aiDocs": [{
432
- "key": "tech-design",
433
- "title": "技术方案",
434
- "url": "https://ai-doc.example.test/docs/123"
435
- }],
436
- "issues": [{
437
- "key": "runtime-hook",
438
- "title": "Runtime Hook",
439
- "platform": "android",
440
- "status": "implementing"
441
- }]
442
- }
443
- },
444
- "expectedRevision": "runtime:<current-revision>",
445
- "idempotencyKey": "prd-panels:1020124:<semantic-digest>"
446
- }`,Joe=`{
447
- "workflow": { "namespace": "tapd", "id": "1020124" },
448
- "source": "my-adapter",
449
- "globalState": {
450
- "mode": "merge",
451
- "patch": {
452
- "title": "Remote Config 拉取频控",
453
- "url": "https://tapd.example.test/1020124",
454
- "status": "实现中",
455
- "sections": {
456
- "ownership": {
457
- "title": "归属信息",
458
- "fields": {
459
- "owner": {
460
- "label": "负责人",
461
- "type": "user",
462
- "value": { "username": "alice" }
463
- },
464
- "platforms": {
465
- "label": "平台",
466
- "type": "chips",
467
- "value": ["Android", "iOS"]
468
- },
469
- "branch": {
470
- "label": "需求分支",
471
- "type": "text",
472
- "value": "story/1020124"
473
- },
474
- "risks": {
475
- "label": "当前风险",
476
- "type": "list",
477
- "value": ["等待服务端字段确认", "灰度策略待补充"]
478
- },
479
- "design": {
480
- "label": "技术方案",
481
- "type": "link",
482
- "value": "打开方案文档",
483
- "url": "https://docs.example.test/1020124"
484
- }
485
- }
486
- }
487
- }
488
- }
489
- }
490
- }`,Xoe=`POST /api/workflow-artifacts/publish
491
- Authorization: Bearer <AGENTFLOW_TOKEN>
492
- Content-Type: application/json
493
-
494
- {
495
- "workflow": { "namespace": "tapd", "id": "1020124" },
496
- "source": "prd-flow",
497
- "title": "Issue1 · Android 方案草稿",
498
- "markdown": "# 方案内容\\n...",
499
- "stage": "issue-plan:runtime-hook",
500
- "issueKey": "runtime-hook",
501
- "platform": "android",
502
- "artifactKey": "plan:runtime-hook:android",
503
- "artifactLabel": "方案预览",
504
- "durability": "temporary",
505
- "ttlDays": 7,
506
- "expectedRevision": "runtime:<current-revision>",
507
- "idempotencyKey": "review:plan:runtime-hook:android:<content-digest>"
508
- }`,GC=`请使用 $agentflow-workflow-report 接入一个生产方,并完整阅读 references/protocol.md。
509
-
510
- 目标只有三个正式接口:
511
- 1. GET /api/workflows/state:读取 snapshot.runtimeRevision 和当前状态。
512
- 2. POST /api/workflows/report:写全局信息、Action、普通产物、迭代投影或自定义区域。
513
- 3. POST /api/workflow-artifacts/publish:把本地 Markdown 内容发布成预览 URL。
514
-
515
- 先输出接入映射表:
516
- - 稳定 Workflow 身份是什么;当前服务支持 tapd:<short-id>。
517
- - 哪些事实进入 observation.state / globalState。
518
- - 哪些关键业务节点进入 action;每个稳定 action.key 是什么。
519
- - 哪些外部链接进入 artifacts;哪些本地 Markdown 需要先 publish。
520
- - 哪些版本/Sprint/里程碑进入 projections.timeline。
521
- - 普通自定义信息是否可用 globalState.sections 的 text/user/chips/list/link 渲染器表达。
522
- - 只有通用渲染器不够时,才设计 extensions namespace/schema/前端渲染器。
523
-
524
- 实现 read → merge → report → verify:
525
- - owner/editor 才能写;viewer、团队成员、分享链接、管理员代看只读。
526
- - globalState 只 patch 自己拥有的路径;对象递归合并,数组/标量替换。
527
- - source 使用真实业务 Adapter 的稳定小写名称;agentflow-cli 只是传输工具。
528
- - 同一 source + action.key 更新同一阶段,不为刷新或重试创建新 key。
529
- - timeline 是完整数组替换;先读取并保留其他生产方条目。
530
- - globalState.sections 是当前通用自定义卡片能力;优先使用现有 field type。
531
- - extensions 只写自己的 namespace;当前仅 prd-flow 注册了 AI Docs / Issues 专用 renderer,保存其他 namespace 不会自动出现 UI。
532
- - 携带 expectedRevision 与稳定 idempotencyKey;409 后重新读取、重新合并,只重试一次。
533
- - 不输出 Token,不新增生产方专用写接口,不使用 /api/prd-workflow/* 兼容接口。
534
-
535
- 最后验证 Workflow 全局区域、Action 时间轴、产物链接、个人/团队迭代和自定义区域。`,Qoe=[{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",detail:"取得服务端物化快照与 runtimeRevision;安全写入的第一步。",permission:"可访问该 Workflow 的用户可读",effect:"只读,不修改任何状态"},{method:"POST",path:"/api/workflows/report",title:"统一上报",detail:"写入全局信息、Action、普通产物、迭代归属和自定义区域。",permission:"owner / editor",effect:"按区域执行替换、合并或更新"},{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",detail:"上传 Markdown 内容,生成可供浏览器查看的规范 URL 与短链。",permission:"owner / editor",effect:"保存预览副本与辅助 Artifact,不推进阶段"}],Zoe=[["workflow","string","二选一","规范 Workflow key,例如 tapd:1020124"],["namespace + id","string","二选一","拆分传入身份;当前 namespace 仅支持 tapd"],["runtimeOnly","0 | 1","否","1 只读已保存运行态,不主动刷新上游"],["flowId / flowSource","string","否","关联 AgentFlow 项目上下文;flowSource 默认 user"],["workspaceId","string","否","关联项目的工作区上下文"],["workflowShare","string","否","只读分享 token,不能用于写接口"]],eae=[["workflow","object","规范身份 {namespace,id,key}"],["snapshot.runtimeRevision","string","下一次安全写入使用的并发版本"],["snapshot.globalState","object","服务端合并后的全局区域"],["snapshot.actions","array","已物化的 Action 时间轴"],["snapshot.artifacts","array","已物化的全局产物"],["snapshot.projections.timeline","array","当前完整迭代归属"],["snapshot.extensions","object","所有已保存的 namespace 数据"]],tae=[["schemaVersion","number","否","当前固定为 1"],["workflow","object | string","是","{namespace,id} 或规范 key"],["source","string","建议","真实业务 Adapter 的稳定小写名称;默认 agentflow-cli 仅用于兼容"],["expectedRevision","string","建议","最近一次 GET 返回的 runtimeRevision"],["idempotencyKey","string","建议","业务操作稳定身份,不使用时间戳或随机 UUID"],["observation","object","条件","同一 clientId 的完整生产方观察"],["globalState","object","条件","全局事实的 merge patch 与 remove"],["action","object","条件","一个关键业务阶段;key 必填"],["artifacts","array","条件","Action 证据或全局证据"],["projections","object","条件","完整 timeline 迭代归属数组"],["extensions","object","条件","按生产方 namespace 组织的自定义区域"]],nae=[["key","string","是","稳定阶段身份;同 key 更新同一阶段"],["title / detail","string","否","时间轴卡片标题与摘要"],["status","enum","否","pending/running/done/error/conflict/skipped/cancelled/observed"],["group / scope","string","否","阶段分组与业务范围"],["platform / issueKey","string","否","平台和自定义 Issue 维度"],["tags","string[]","否","额外筛选标签"],["occurredAt","ISO date","否","业务发生时间,不是 HTTP 重试时间"]],rae=[["schema","string","否","生产方观察 schema,建议带版本,例如 my-adapter/v1"],["clientId","string","建议","稳定客户端身份;决定哪份完整观察被替换"],["observedAt","ISO date","建议","本次事实采集时间"],["scope","string","否","观察范围,默认 client"],["state","object","是","该 clientId 的完整当前观察,不是 patch"]],sae=[["mode","merge","是","当前只支持 merge"],["patch","object","条件","对象递归合并;数组、标量整体替换;null 删除字段"],["remove","string[]","条件","显式删除点路径,例如 sections.progress.fields.owner"]],iae=[["sections.<key>.title","string","建议","分区标题;key=progress 使用紧凑网格"],["fields.<key>.label","string","建议","字段显示名"],["fields.<key>.type","enum","否","text / user / chips / list / link;未知值回退 text"],["fields.<key>.value","any","是","展示值;空值不渲染"],["fields.<key>.url","string","link 条件","link 类型的跳转地址"]],oae=[["timeline","array","是","完整数组替换;省略 projections 才表示不修改"],["timeline[].kind","string","是","version / sprint / milestone 或生产方自定义类型"],["timeline[].id","string","是","业务对象稳定 ID;改名或改期不改变"],["timeline[].key","string","建议","建议 source:kind:id,避免不同生产方碰撞"],["timeline[].title / date","string","否","卡片标题和 YYYY-MM-DD 排期"],["timeline[].source","string","建议","条目所有者,用于 read-merge 时识别自有条目"],["timeline[].dimensions","object","否","平台、发布列车等不透明筛选维度"]],aae=[["extensions.<namespace>","object","是","生产方自有、带版本约定的结构化 JSON"],["namespace","string","是","小写稳定标识;建议与 report.source 相同"],["对象字段","object","否","递归合并;null 删除"],["数组 / 标量","any","否","整体替换,不做元素级 merge"],["renderer","前端注册","展示条件","未知 namespace 只保存,不自动出现面板"]],lae=[["key","string","建议","稳定证据身份;不要依赖标题去重"],["type","string","否","gitlab-mr/build/test-report/document 等"],["title","string","否","页面展示标题"],["url / path","string","至少一个","外部地址或可识别路径"],["scope","action | global","否","有 Action 时默认 action"],["status","string","否","生产方定义的证据状态"]],cae=[["workflow","object | string","是","目标 Workflow"],["source","string","建议","真实生产方身份;agentflow-cli 只是传输工具"],["title","string","是","Review 页面标题"],["markdown","string","是","Markdown 实际内容,不是本地文件路径"],["stage / stageKey","string","建议","关联的稳定 Action 阶段"],["issueKey / platform","string","否","Issue 与平台维度"],["artifactKey","string","是","预览 Artifact 的稳定槽位"],["artifactLabel","string","否","页面按钮文案"],["durability","enum","否","temporary 或 durable"],["ttlDays","number","临时建议","临时预览有效期,通常 7 天"],["expectedRevision","string","建议","发布前读取的 runtimeRevision;过期返回 409"],["idempotencyKey","string","建议","包含内容摘要;同 source + key 重放返回同一预览"]],YC=[["api","快速开始"],["model","区域模型"],["renderers","渲染效果"],["reference","参数参考"],["scenarios","关键场景"],["safety","权限与覆盖"],["design","设计思想"],["ai","AI 引导"]],uae=[{icon:"dashboard",name:"全局区域",question:"这个需求现在是什么?",fields:"observation.state · globalState · projections.timeline",detail:"标题、状态、负责人、平台、版本事实和迭代归属。事实留在 globalState,迭代列表只读取可重建的 projection。"},{icon:"timeline",name:"Action 时间轴",question:"关键阶段发生了什么?",fields:"action · artifacts",detail:"方案确认、实现、提测、发布等业务节点及其 MR、构建、测试或文档证据。Action 不是刷新日志。"},{icon:"extension",name:"自定义展示",question:"生产方还需要展示什么?",fields:"globalState.sections · extensions[namespace]",detail:"普通键值、标签、列表和链接优先使用通用 sections;只有需要树形结构或专用交互时才使用 extensions 并开发 renderer。"}],dae=[["observation.state","同一 clientId 完整替换","省略不改","只替换自己的完整观察"],["globalState","对象递归合并;数组/标量替换","null 或 remove 删除","只 patch 自己拥有的路径"],["action","同 source + action.key 更新同一阶段","无通用物理删除","取消/跳过使用业务状态表达"],["artifacts","同 source + 稳定 key 更新/归并","无通用物理删除","不要改 key 来伪造删除"],["projections.timeline","整数组替换","[] 清空全部归属","先 GET,并保留其他生产方条目"],["extensions","namespace 内对象递归合并;数组/标量替换","null 删除自有字段","不要写别人的 namespace"]],fae=[["Workflow owner","可读","可写","可管理成员和分享"],["显式 editor","可读","可写","不能管理成员"],["显式 viewer","可读","只读","不能管理成员"],["同团队成员","可读","只读","自动获得 team viewer"],["分享链接","可读","只读","不能用于上报"],["超级管理员代看","可读","只读","不会以管理员身份覆盖数据"]];async function pae(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText&&window.isSecureContext)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",document.body.appendChild(r),r.select();const s=document.execCommand("copy");return r.remove(),s}catch{return!1}}function Do({number:e,title:t,detail:n}){return i.jsxs("div",{className:"af-wr-section__head",children:[i.jsx("span",{children:e}),i.jsxs("div",{children:[i.jsx("h2",{children:t}),i.jsx("p",{children:n})]})]})}function Zs({title:e,value:t,copyKey:n,copied:r,onCopy:s,wrap:o=!1}){const a=r===`failed:${n}`;return i.jsxs("div",{className:`af-wr-code-panel${o?" is-wrap":""}`,children:[i.jsxs("div",{className:"af-wr-code-panel__head",children:[i.jsx("span",{children:e}),i.jsxs("button",{type:"button",onClick:()=>void s(n,t),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r===n?"check":"content_copy"}),r===n?"已复制":"复制"]})]}),i.jsx("pre",{children:t}),a?i.jsx("p",{className:"af-wr-copy-error",children:"浏览器禁止访问剪贴板,请手动选择代码块内容。"}):null]})}function ls({columns:e=["参数","类型","必填","含义"],rows:t,label:n}){return i.jsxs("div",{className:`af-wr-table is-${e.length}-columns`,role:"table","aria-label":n,children:[i.jsx("div",{className:"af-wr-table__row is-head",role:"row",children:e.map(r=>i.jsx("span",{role:"columnheader",children:r},r))}),t.map(r=>i.jsx("div",{className:"af-wr-table__row",role:"row",children:r.map((s,o)=>i.jsx("span",{role:"cell","data-label":e[o],children:s},`${r[0]}-${o}`))},r[0]))]})}function Lw({method:e,path:t,title:n,permission:r,effect:s}){return i.jsxs("div",{className:"af-wr-endpoint__head",children:[i.jsxs("div",{className:"af-wr-endpoint__identity",children:[i.jsx("span",{className:`is-${e.toLowerCase()}`,children:e}),i.jsx("code",{children:t}),i.jsx("h3",{children:n})]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"权限"}),i.jsx("dd",{children:r})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"副作用"}),i.jsx("dd",{children:s})]})]})]})}function hae(){return i.jsxs("article",{className:"af-prd-workflow-card af-prd-overall af-wr-render-preview",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"需求概览"}),i.jsx("span",{className:"af-prd-overall__status",children:"实现中"})]}),i.jsx("div",{className:"af-prd-overall__requirement",children:i.jsx("strong",{children:"Remote Config 拉取频控"})}),i.jsx("div",{className:"af-prd-overall__platforms",children:i.jsxs("section",{className:"af-prd-overall-platform",children:[i.jsx("div",{className:"af-prd-overall-platform__head",children:i.jsx("strong",{children:"归属信息"})}),i.jsxs("div",{className:"af-prd-overall-platform__fields",children:[i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--user",children:[i.jsx("small",{children:"负责人 · user"}),i.jsx("div",{children:i.jsx("span",{children:"alice"})})]}),i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--chips",children:[i.jsx("small",{children:"平台 · chips"}),i.jsxs("div",{children:[i.jsx("span",{children:"Android"}),i.jsx("span",{children:"iOS"})]})]}),i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--text",children:[i.jsx("small",{children:"需求分支 · text"}),i.jsx("div",{children:i.jsx("span",{children:"story/1020124"})})]}),i.jsxs("div",{className:"af-prd-overall-platform__rules",children:[i.jsx("small",{children:"当前风险 · list"}),i.jsxs("ul",{children:[i.jsx("li",{children:"等待服务端字段确认"}),i.jsx("li",{children:"灰度策略待补充"})]})]}),i.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[i.jsx("small",{children:"技术方案 · link"}),i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"打开方案文档"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]})]})]})})]})}function mae(){return i.jsxs("div",{className:"af-prd-workflow-action af-prd-workflow-action--done af-wr-render-preview",children:[i.jsx("div",{className:"af-prd-workflow-action__rail",children:i.jsx("span",{className:"af-prd-workflow-action__dot"})}),i.jsxs("div",{className:"af-prd-workflow-action__body",children:[i.jsxs("div",{className:"af-prd-workflow-action__top",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-prd-workflow-action__title",children:[i.jsx("time",{children:"16:25:40"}),i.jsx("strong",{children:"Android 实现完成"})]}),i.jsx("p",{children:"MR !957 已合并"}),i.jsxs("div",{className:"af-prd-workflow-action__meta",children:[i.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--issue",children:[i.jsx("b",{children:"Issue"}),i.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"runtime-hook"})]}),i.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--platform",children:[i.jsx("b",{children:"平台"}),i.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"Android"})]})]})]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:"完成"})]}),i.jsx("div",{className:"af-prd-workflow-action__links",children:i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"实现 MR !957"}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]})]})}function gae(){return i.jsxs("article",{className:"af-prd-workflow-card af-wr-render-preview",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"关联产物"}),i.jsx("span",{children:"2"})]}),i.jsxs("div",{className:"af-prd-workflow-list",children:[i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"测试报告 #128"}),i.jsx("small",{children:"test-report"})]}),i.jsxs("span",{className:"af-wr-preview-link",children:[i.jsx("span",{children:"Jenkins Build #8451"}),i.jsx("small",{children:"build"})]})]})]})}function yae(){return i.jsxs("section",{className:"af-workflows-timeline af-wr-render-preview",children:[i.jsx("div",{className:"af-workflows-timeline__heading",children:i.jsxs("div",{children:[i.jsx("span",{children:"迭代时间线"}),i.jsx("strong",{children:"按排期归属汇总"})]})}),i.jsx("div",{className:"af-workflows-timeline__rail",children:i.jsxs("button",{type:"button",className:"is-active",children:[i.jsxs("span",{className:"af-workflows-timeline__date",children:["2026/08/31",i.jsx("em",{children:"计划中"})]}),i.jsx("strong",{children:"Likee Android 5.63.0"}),i.jsx("small",{children:"Android · 3 项 · 1 项需关注"})]})})]})}function wae(){return i.jsxs("div",{className:"af-wr-extension-preview",children:[i.jsxs("section",{children:[i.jsxs("div",{children:[i.jsx("span",{children:"AI DOCS"}),i.jsx("strong",{children:"2"})]}),i.jsx("p",{children:"技术方案"}),i.jsx("p",{children:"测试与灰度说明"})]}),i.jsxs("section",{children:[i.jsxs("div",{children:[i.jsx("span",{children:"ISSUES"}),i.jsx("strong",{children:"2 / 3"})]}),i.jsxs("p",{children:[i.jsx("i",{className:"is-done"})," Runtime Hook · Android"]}),i.jsxs("p",{children:[i.jsx("i",{})," iOS 容器适配"]})]})]})}function xae(){const{navigate:e}=rs(),[t,n]=m.useState(""),[r,s]=m.useState("api"),o=m.useCallback(async(a,l)=>{n(await pae(l)?a:`failed:${a}`)},[]);return m.useEffect(()=>{const a=YC.map(([c])=>document.getElementById(c)).filter(Boolean);if(!a.length||typeof IntersectionObserver>"u")return;const l=new IntersectionObserver(c=>{var p,f;const u=c.filter(d=>d.isIntersecting).sort((d,h)=>d.boundingClientRect.top-h.boundingClientRect.top);(f=(p=u[0])==null?void 0:p.target)!=null&&f.id&&s(u[0].target.id)},{rootMargin:"-18% 0px -68% 0px",threshold:[0,.1]});return a.forEach(c=>l.observe(c)),()=>l.disconnect()},[]),i.jsx("div",{className:"af-wr-page",children:i.jsxs("div",{className:"af-wr-inner",children:[i.jsxs("section",{className:"af-wr-hero",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-wr-kicker",children:"WORKFLOW REPORT · API REFERENCE"}),i.jsx("h1",{children:"Workflow 接入文档"}),i.jsx("p",{children:"用 3 个正式接口,把生产流程的全局信息、Action 时间轴、产物链接、迭代归属和自定义面板接入 AgentFlow。数据协议面向任意 Adapter;当前服务端的 Workflow 身份适配器只支持 TAPD,prd-flow 仅作为 TAPD 研发场景的参考实现。"}),i.jsxs("div",{className:"af-wr-hero__boundary",children:[i.jsx("strong",{children:"当前边界"}),i.jsx("span",{children:"可接入任意事实来源"}),i.jsx("i",{children:"·"}),i.jsx("span",{children:"Workflow key 目前必须是 tapd:<short-id>"})]})]}),i.jsxs("div",{className:"af-wr-hero__actions",children:[i.jsxs("button",{type:"button",className:"is-primary",onClick:()=>void o("ai",GC),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:t==="ai"?"check":"smart_toy"}),t==="ai"?"已复制 AI 引导":"复制 AI 接入引导"]}),i.jsx("button",{type:"button",onClick:()=>e("/workflows"),children:"打开 Workflow Dashboard"})]})]}),i.jsx("nav",{className:"af-wr-toc","aria-label":"接入文档目录",children:YC.map(([a,l])=>i.jsx("a",{className:r===a?"is-active":"",href:`#${a}`,children:l},a))}),i.jsxs("section",{className:"af-wr-section",id:"api",children:[i.jsx(Do,{number:"01",title:"5 分钟跑通一次上报",detail:"正式接口只有三个。先准备登录 Token 和稳定 source,再执行 read → merge → report → verify;旧 /api/prd-workflow/* 仅为兼容入口。"}),i.jsx("div",{className:"af-wr-endpoint-grid",children:Qoe.map(a=>i.jsxs("article",{children:[i.jsxs("div",{children:[i.jsx("span",{className:`is-${a.method.toLowerCase()}`,children:a.method}),i.jsx("code",{children:a.path})]}),i.jsx("h3",{children:a.title}),i.jsx("p",{children:a.detail}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"权限"}),i.jsx("dd",{children:a.permission})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"副作用"}),i.jsx("dd",{children:a.effect})]})]})]},a.path))}),i.jsxs("div",{className:"af-wr-quickstart",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"开始前准备"}),i.jsxs("p",{children:["在 AgentFlow 的 MCP 页面点击“使用当前登录 Token”,仅在本机设置 ",i.jsx("code",{children:"AGENTFLOW_TOKEN"}),"。当前 Workflow 身份必须使用 ",i.jsx("code",{children:"tapd:<short-id>"}),";",i.jsx("code",{children:"source"})," 填业务 Adapter 名,不能填传输工具名。"]})]}),i.jsx(Zs,{title:"安装与认证",value:Woe,copyKey:"install",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-code-grid af-wr-quickstart-run",children:[i.jsx(Zs,{title:"可直接执行的三步命令",value:Voe,copyKey:"quickstart",copied:t,onCopy:o}),i.jsx(Zs,{title:"workflow-report.json 最小请求",value:Hoe,copyKey:"quickstart-report",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-success-check",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("p",{children:[i.jsx("strong",{children:"成功标准:"}),"POST 返回 ",i.jsx("code",{children:"ok: true"}),",再次 GET 能看到 ",i.jsx("code",{children:"requirement-imported"}),",且 ",i.jsx("code",{children:"snapshot.runtimeRevision"})," 已变化。"]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"model",children:[i.jsx(Do,{number:"02",title:"先决定数据进入哪个区域",detail:"页面区域和协议字段一一对应。不要把所有内容都塞进一个 snapshot,也不要从 Action 标题反推结构化数据。"}),i.jsx("div",{className:"af-wr-region-grid",children:uae.map(a=>i.jsxs("article",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a.icon}),i.jsxs("div",{children:[i.jsx("small",{children:a.question}),i.jsx("h3",{children:a.name}),i.jsx("code",{children:a.fields}),i.jsx("p",{children:a.detail})]})]},a.name))}),i.jsxs("div",{className:"af-wr-model-note",children:[i.jsx("strong",{children:"核心原则"}),i.jsx("span",{children:"globalState.sections 解决通用自定义展示"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"Action 表达关键业务节点"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"projection 只做聚合索引"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"extension 承载专用结构"})]})]}),i.jsxs("section",{className:"af-wr-section",id:"renderers",children:[i.jsx(Do,{number:"03",title:"当前可直接使用的通用渲染器",detail:"这些 schema 已经由 AgentFlow 页面识别,接入方只需上报数据,不需要开发前端。下面的预览使用与 Workflow 详情页相同的样式类。"}),i.jsxs("div",{className:"af-wr-renderer-notice",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"info"}),i.jsxs("p",{children:[i.jsx("strong",{children:"普通自定义信息不要放进 extensions。"}),"负责人、平台、分支、风险列表、文档链接等,直接使用 ",i.jsx("code",{children:"globalState.sections"}),"。只有通用组件无法表达的树形结构、复杂交互或专用业务面板,才需要 ",i.jsx("code",{children:"extensions"})," 和前端 renderer。"]})]}),i.jsxs("div",{className:"af-wr-renderer-feature",children:[i.jsxs("div",{className:"af-wr-renderer-feature__copy",children:[i.jsx("span",{children:"GENERIC · GLOBAL STATE"}),i.jsx("h3",{children:"概览分区 / 字段渲染器"}),i.jsxs("p",{children:["每个 section 生成一张分区卡片;字段按 ",i.jsx("code",{children:"type"})," 选择固定样式。section key 为 ",i.jsx("code",{children:"progress"})," 时使用紧凑响应式网格,其余分区纵向排列。"]}),i.jsxs("dl",{children:[i.jsxs("div",{children:[i.jsx("dt",{children:"text"}),i.jsx("dd",{children:"普通文本,无胶囊背景"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"user"}),i.jsx("dd",{children:"负责人文本,使用强调色"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"chips"}),i.jsx("dd",{children:"一个或多个标签胶囊"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"list"}),i.jsx("dd",{children:"纵向项目符号列表"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:"link"}),i.jsx("dd",{children:"可点击文本与外链图标"})]})]})]}),i.jsx(hae,{})]}),i.jsx(Zs,{title:"globalState.sections 上报示例",value:Joe,copyKey:"generic-section",copied:t,onCopy:o}),i.jsxs("div",{className:"af-wr-renderer-grid",children:[i.jsxs("article",{children:[i.jsxs("div",{className:"af-wr-renderer-grid__head",children:[i.jsx("span",{children:"GENERIC"}),i.jsx("h3",{children:"Action 时间轴"}),i.jsx("code",{children:"action + artifacts[scope=action]"}),i.jsx("p",{children:"按日期分组,展示状态点、时间、标题、详情、Issue/平台标签和阶段产物按钮。"})]}),i.jsx(mae,{})]}),i.jsxs("article",{children:[i.jsxs("div",{className:"af-wr-renderer-grid__head",children:[i.jsx("span",{children:"GENERIC"}),i.jsx("h3",{children:"关联产物列表"}),i.jsx("code",{children:"artifacts[scope=global]"}),i.jsx("p",{children:"用于构建、测试报告、外部文档等全局链接;显示标题、类型与跳转状态。"})]}),i.jsx(gae,{})]}),i.jsxs("article",{children:[i.jsxs("div",{className:"af-wr-renderer-grid__head",children:[i.jsx("span",{children:"GENERIC"}),i.jsx("h3",{children:"迭代时间线"}),i.jsx("code",{children:"projections.timeline"}),i.jsx("p",{children:"根据 kind/id/title/date/dimensions 聚合个人与团队迭代,支持横向时间线和筛选。"})]}),i.jsx(yae,{})]})]}),i.jsxs("div",{className:"af-wr-extension-registry",children:[i.jsxs("div",{children:[i.jsx("span",{children:"REGISTERED EXTENSION"}),i.jsx("h3",{children:i.jsx("code",{children:'extensions["prd-flow"]'})}),i.jsx("p",{children:"当前唯一已注册的专用 extension renderer。支持 AI Docs 链接列表和带父子层级、平台、MR 状态及关联链接的 Issues 树。"}),i.jsx(wae,{})]}),i.jsxs("div",{children:[i.jsx("strong",{children:"其他 namespace 当前如何显示?"}),i.jsx("p",{children:"数据会被保存并参与 revision,但不会自动出现面板。若现有 sections / Action / Artifact / timeline 足够,应优先使用通用组件;确实需要新布局时,再提交扩展 schema、空态/错误态、响应式样式和 renderer 实现。"})]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"reference",children:[i.jsx(Do,{number:"04",title:"接口与参数参考",detail:"以下字段来自当前服务端真实校验与合并逻辑;可以按区域只提交本次需要更新的部分。"}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(Lw,{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",permission:"owner / editor / viewer / team viewer / share viewer",effect:"无"}),i.jsxs("p",{className:"af-wr-endpoint__intro",children:["写入前读取当前快照,保存 ",i.jsx("code",{children:"snapshot.runtimeRevision"}),"。客户端提交的完整状态叫 ",i.jsx("code",{children:"observation.state"}),";只有服务端返回的数据才叫 ",i.jsx("code",{children:"snapshot"}),"。"]}),i.jsx(ls,{rows:Zoe,label:"Workflow state query 参数"}),i.jsx("h4",{children:"成功响应"}),i.jsx(ls,{columns:["字段","类型","含义"],rows:eae,label:"Workflow state 成功响应"}),i.jsxs("div",{className:"af-wr-code-grid",children:[i.jsx(Zs,{title:"请求",value:Koe,copyKey:"read-request",copied:t,onCopy:o}),i.jsx(Zs,{title:"关键响应字段",value:qoe,copyKey:"read-response",copied:t,onCopy:o})]})]}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(Lw,{method:"POST",path:"/api/workflows/report",title:"统一上报 Workflow",permission:"owner / editor",effect:"修改运行态并返回新 snapshot"}),i.jsx("p",{className:"af-wr-endpoint__intro",children:"至少提交 observation、globalState、action、artifacts、projections、extensions 之一。一次请求可以组合多个区域,并用一个 revision 和幂等键保护整次语义更新。"}),i.jsx("h4",{children:"Envelope"}),i.jsx(ls,{rows:tae,label:"Workflow Report 顶层参数"}),i.jsxs("div",{className:"af-wr-subreference",children:[i.jsxs("div",{children:[i.jsx("h4",{children:"action"}),i.jsx("p",{children:"业务阶段,不是运行日志。"}),i.jsx(ls,{rows:nae,label:"Action 参数"})]}),i.jsxs("div",{children:[i.jsx("h4",{children:"artifacts"}),i.jsx("p",{children:"已有 HTTP URL 的证据直接上报。"}),i.jsx(ls,{rows:lae,label:"Artifact 参数"})]})]}),i.jsxs("div",{className:"af-wr-schema-reference",children:[i.jsxs("article",{children:[i.jsx("h4",{children:"observation"}),i.jsx("p",{children:"同一 clientId 的完整生产方观察。"}),i.jsx(ls,{rows:rae,label:"Observation 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"globalState"}),i.jsx("p",{children:"可独立更新的全局事实和通用分区。"}),i.jsx(ls,{rows:sae,label:"Global State 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"globalState.sections"}),i.jsx("p",{children:"无需前端开发的通用字段渲染器。"}),i.jsx(ls,{rows:iae,label:"Global State Section 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"projections.timeline"}),i.jsx("p",{children:"个人/团队 Dashboard 使用的可重建索引。"}),i.jsx(ls,{rows:oae,label:"Timeline Projection 参数"})]}),i.jsxs("article",{children:[i.jsx("h4",{children:"extensions"}),i.jsx("p",{children:"只有专用 renderer 才能显示的 namespace 数据。"}),i.jsx(ls,{rows:aae,label:"Workflow Extensions 参数"})]})]}),i.jsxs("p",{className:"af-wr-table-note",children:[i.jsx("strong",{children:"生产方隔离:"}),"Action、幂等键和 Artifact 的服务端身份按 ",i.jsx("code",{children:"source + key"})," 组合;不同 source 可以复用相同业务 key。",i.jsx("code",{children:"globalState"})," 与完整 timeline 仍是共享区域,必须先读后合并,只修改自己拥有的路径或条目。"]})]}),i.jsxs("article",{className:"af-wr-endpoint",children:[i.jsx(Lw,{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",permission:"owner / editor",effect:"保存预览副本和辅助 Artifact;不推进 Action"}),i.jsx("p",{className:"af-wr-endpoint__intro",children:"客户端读取本地 Markdown,再发送实际内容。服务端不能访问调用方本地路径;外部系统已有 URL 时直接使用 Report artifacts,无需发布副本。"}),i.jsx(ls,{rows:cae,label:"Artifact Publish 参数"}),i.jsxs("div",{className:"af-wr-publish-layout",children:[i.jsxs("div",{className:"af-wr-result-list",children:[i.jsx("h4",{children:"返回什么"}),i.jsxs("p",{children:[i.jsx("code",{children:"artifact"}),":页面可识别的标准产物"]}),i.jsxs("p",{children:[i.jsx("code",{children:"review.url"}),":规范预览地址"]}),i.jsxs("p",{children:[i.jsx("code",{children:"review.shortUrl"}),":通常为 ",i.jsx("code",{children:"/r/<code>"})," 的分享短链"]}),i.jsxs("p",{children:[i.jsx("code",{children:"snapshot"}),":发布后的最新 Workflow 状态"]}),i.jsx("strong",{children:"不会确认方案、修改原文件、提交 ai-doc、创建 Issue 或推进阶段。"})]}),i.jsx(Zs,{title:"发布请求",value:Xoe,copyKey:"publish",copied:t,onCopy:o})]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"scenarios",children:[i.jsx(Do,{number:"05",title:"三个关键接入场景",detail:"以 prd-flow 为例说明接口组合;它是 TAPD 研发流程的一种实现,不是协议依赖。"}),i.jsxs("div",{className:"af-wr-scenario",children:[i.jsxs("div",{className:"af-wr-scenario__copy",children:[i.jsx("span",{children:"场景 A"}),i.jsx("h3",{children:"更新迭代:绑定或切换版本"}),i.jsxs("ol",{children:[i.jsx("li",{children:"Adapter 从业务系统得到稳定 version ID、标题、日期、平台;prd-flow 的来源恰好是 TAPD。"}),i.jsx("li",{children:"GET 当前 snapshot 与完整 timeline。"}),i.jsx("li",{children:"版本事实写入 globalState;归属索引写入 kind=version projection。"}),i.jsx("li",{children:"保留其他 source 的 Sprint/版本,只替换自己的条目。"})]}),i.jsxs("p",{children:[i.jsx("strong",{children:"改名/改期:"}),"保持 ID 和 key 不变。",i.jsx("strong",{children:"取消归属:"}),"移除自有条目后上报剩余完整数组;只有确实要清空全部归属时才发送空数组。"]})]}),i.jsx(Zs,{title:"版本事实 + 完整迭代投影",value:Uoe,copyKey:"version",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-scenario",children:[i.jsxs("div",{className:"af-wr-scenario__copy",children:[i.jsx("span",{children:"场景 B"}),i.jsx("h3",{children:"上报 Action 和产物链接"}),i.jsxs("ol",{children:[i.jsx("li",{children:"先完成真实业务动作,例如创建并合并 MR。"}),i.jsx("li",{children:"用稳定 action.key 报告阶段,用 artifact.key 报告证据。"}),i.jsx("li",{children:"同一阶段刷新继续使用相同 key;occurredAt 使用业务时间。"}),i.jsx("li",{children:"本地 Markdown 先 publish,已有 HTTP URL 直接作为 Artifact。"})]}),i.jsx("p",{children:"AgentFlow 只记录和展示结果,不替接入方操作 TAPD、GitLab 或 Jenkins。"})]}),i.jsx(Zs,{title:"实现完成 + MR",value:Goe,copyKey:"action",copied:t,onCopy:o})]}),i.jsxs("div",{className:"af-wr-scenario",children:[i.jsxs("div",{className:"af-wr-scenario__copy",children:[i.jsx("span",{children:"场景 C"}),i.jsx("h3",{children:"上报自定义文档区 / Issue 区"}),i.jsxs("ol",{children:[i.jsx("li",{children:"定义生产方 namespace 和版本化 schema。"}),i.jsx("li",{children:"把结构化数组写入 extensions[namespace]。"}),i.jsx("li",{children:"数组上报完整新值,对象字段可以递归合并。"}),i.jsx("li",{children:"实现并注册专用渲染器,页面才会出现对应区域。"})]}),i.jsx("p",{children:"prd-flow 已有 AI Docs / Issues 渲染;其他生产方不能仅通过改字段名复用它。"})]}),i.jsx(Zs,{title:"prd-flow 专用扩展示例",value:Yoe,copyKey:"extension",copied:t,onCopy:o})]})]}),i.jsxs("section",{className:"af-wr-section",id:"safety",children:[i.jsx(Do,{number:"06",title:"权限、覆盖和冲突",detail:"接入前必须明确谁能写、每个区域怎么更新,以及冲突发生时是否可能误删其他生产方的数据。"}),i.jsxs("div",{className:"af-wr-safety-grid",children:[i.jsxs("div",{children:[i.jsx("h3",{children:"权限矩阵"}),i.jsx(ls,{columns:["身份","读取","上报","说明"],rows:fae,label:"Workflow 权限矩阵"}),i.jsx("p",{className:"af-wr-table-note",children:"首次由已认证用户上报未登记的 TAPD ID 时,该用户成为 owner。团队成员自动获得 viewer,不会自动获得写权限。"})]}),i.jsxs("div",{children:[i.jsx("h3",{children:"覆盖矩阵"}),i.jsx(ls,{columns:["区域","重复上报","删除/清空","接入方责任"],rows:dae,label:"Workflow 覆盖矩阵"})]})]}),i.jsxs("div",{className:"af-wr-conflict-flow",children:[i.jsx("span",{children:"GET snapshot.runtimeRevision"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"计算语义 patch"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"POST + source + expectedRevision + idempotencyKey"}),i.jsx("i",{children:"→"}),i.jsx("span",{children:"409 时重新 GET / 合并 / 只重试一次"})]}),i.jsxs("div",{className:"af-wr-errors",children:[i.jsxs("div",{children:[i.jsx("code",{children:"400"}),i.jsx("p",{children:"字段或 schema 错误;按协议修正"})]}),i.jsxs("div",{children:[i.jsx("code",{children:"401"}),i.jsx("p",{children:"缺少认证;停止并配置 Token"})]}),i.jsxs("div",{children:[i.jsx("code",{children:"403"}),i.jsx("p",{children:"只读或无权限;由 owner 授权 editor"})]}),i.jsxs("div",{children:[i.jsx("code",{children:"409"}),i.jsx("p",{children:"revision 冲突;不得原样重放旧数组"})]})]})]}),i.jsxs("section",{className:"af-wr-section",id:"design",children:[i.jsx(Do,{number:"07",title:"设计思想与运行关系",detail:"业务解释留在 Adapter,传输和存储保持通用;这样新生产方不需要复制 prd-flow 的 TAPD 私有模型。"}),i.jsxs("div",{className:"af-wr-runtime",children:[i.jsxs("article",{children:[i.jsx("small",{children:"事实来源"}),i.jsx("strong",{children:"TAPD / GitLab / Jenkins / 其他系统"}),i.jsx("p",{children:"提供原始业务事实。"})]}),i.jsx("i",{children:"→"}),i.jsxs("article",{className:"is-focus",children:[i.jsx("small",{children:"你需要实现"}),i.jsx("strong",{children:"业务 Adapter"}),i.jsx("p",{children:"解释阶段、定义稳定 key、生成 Report。prd-flow 是一个现有 Adapter。"})]}),i.jsx("i",{children:"→"}),i.jsxs("article",{children:[i.jsx("small",{children:"通用传输"}),i.jsx("strong",{children:"Workflow Report Client / agentflow-cli"}),i.jsx("p",{children:"负责地址、Token、JSON 和 HTTP,不理解业务。"})]}),i.jsx("i",{children:"→"}),i.jsxs("article",{children:[i.jsx("small",{children:"接收与展示"}),i.jsx("strong",{children:"AgentFlow 服务与页面"}),i.jsx("p",{children:"鉴权、合并、存储并渲染三类区域。"})]})]}),i.jsxs("div",{className:"af-wr-design-rules",children:[i.jsxs("article",{children:[i.jsx("strong",{children:"事实与投影分离"}),i.jsx("p",{children:"版本完整信息属于 globalState;个人/团队迭代只读取 projection。投影可以重建,不成为第二份真相。"})]}),i.jsxs("article",{children:[i.jsx("strong",{children:"业务节点与技术日志分离"}),i.jsx("p",{children:"Action 只表达可理解的阶段。轮询、重试、刷新留在接入方日志,不污染时间轴。"})]}),i.jsxs("article",{children:[i.jsx("strong",{children:"通用存储与专用渲染分离"}),i.jsx("p",{children:"extensions 可以保存任意生产方结构,但专用面板必须显式注册 schema 和 renderer。"})]})]})]}),i.jsxs("section",{className:"af-wr-section af-wr-ai",id:"ai",children:[i.jsx(Do,{number:"08",title:"给 AI 的接入引导",detail:"复制后交给 AI,它会先输出事实到页面区域的映射,再按真实协议实现。"}),i.jsx(Zs,{title:"$agentflow-workflow-report",value:GC,copyKey:"ai-bottom",copied:t,onCopy:o,wrap:!0})]})]})})}const bae=[{icon:"campaign",title:"首页 Feed 想加一个广告引导",question:"先判断入口、展示位、用户影响面,再决定弹框、浮层还是页面内引导。",context:["查客户端展示位逻辑","查历史需求与配置","查 m09 / Feed PV"],result:"原型 + PRD + TAPD 更新",tone:"pink"},{icon:"manage_search",title:"接到需求但不知道现有逻辑",question:"不用先找研发问一圈,直接从 Likee 代码、知识库、历史文档里拿上下文。",context:["客户端 / 后台 / 前端知识库","接口与配置链路","相关 Git 文档"],result:"背景结论 + 影响范围",tone:"cyan"},{icon:"query_stats",title:"运营要评估活动或入口价值",question:"先查人群规模、页面访问、历史转化,避免凭经验拍优先级。",context:["CK / Hive 查数","自动生成 SQL","指标口径解释"],result:"数据表 + 图表 + 结论",tone:"green"},{icon:"draw",title:"想快速把方案画给团队看",question:"把一句需求变成客户端或 H5 原型,让评审时先讨论体验,不只讨论文字。",context:["Likee 客户端样式","前端页面结构","交互状态与文案"],result:"HTML 原型 + Display 面板",tone:"amber"},{icon:"sync_alt",title:"需求写完后需要同步多个地方",question:"PRD、TAPD、Git 仓库和评审展示保持一致,减少重复复制和漏改。",context:["需求正文","变更记录","MR / 仓库路径"],result:"TAPD 更新 + Git 提交",tone:"violet"},{icon:"monitoring",title:"上线后要看效果和复盘",question:"沿用需求阶段的口径继续查数,把结果沉淀回下一轮需求线索。",context:["上线后 CK / Hive","分页面 / 分人群指标","实验和版本信息"],result:"复盘结论 + 后续建议",tone:"blue"}],kae=[{label:"Use Case 01",title:"Likee 客户端知识库查询(如广告占位)",images:["/likee-context/usecase-ad-query.png"],trigger:"产品或运营想确认客户端已有逻辑,例如 Likee Android 里有哪些广告占位,以及相关常量和代码位置。",steps:["在「我的流程」加载 Likee Android 流程片段","在子 Agent 节点输入客户端逻辑问题","点击 Run Line,只执行当前链路","在右侧 Markdown Display 查看知识库查询结果"],outputs:["SETTING_ID / PAGE_ID 表格","客户端代码路径与口径说明","可继续用于 PRD 的背景材料"]},{label:"Use Case 02",title:"客户端原型设计",images:["/likee-context/usecase-prototype.png"],trigger:"业务已经明确要在 Likee 首页加入广告引导,需要先把弹框体验画出来给产品、设计、研发评审。",steps:["在 Workspace 打开原型生成流程","加载客户端原型 Skill","在子 Agent 中说明生成一个首页 dialog 弹框","查看 HTML Display 中的手机预览稿"],outputs:["Likee 风格手机原型","弹框文案与按钮状态","可直接用于评审的 Display 面板"]},{label:"Use Case 03",title:"前端 H5 原型设计",images:["/likee-context/usecase-h5-prototype.png"],trigger:"运营活动需要快速产出 Likee 风格 H5 页面,例如幸运转盘、积分排行榜、活动首页或结果页。",steps:["在 Workspace 打开 H5 原型生成流程","加载前端 H5 原型相关 Skill","在子 Agent 中说明活动结构、页面模块和运营规则","查看 HTML Display 中的可交互 H5 原型"],outputs:["Likee 风格 H5 页面","抽奖转盘与排行榜布局","活动规则和状态页","可用于评审的 HTML Display"]},{label:"Use Case 04",title:"CK / Hive 查数与 SQL 生成",images:["/likee-context/usecase-data-query.png"],trigger:"运营或产品需要快速验证一个数据问题,例如找出典型 UID、对比不同日期的视频上传分辨率占比,并保留可复用 SQL。",steps:["在 Workspace 打开查数流程","加载查数相关 Skill","在子 Agent 中说明数据口径、日期和筛选条件","查看 Markdown Display 中的数据结果和查询 SQL"],outputs:["查询结果表格","SQL 语句","口径说明","可继续接入 PRD 或复盘面板的数据结论"]},{label:"Use Case 05",title:"需求文档生成、数据补齐与同步",images:["/likee-context/usecase-prd.png","/likee-context/usecase-sync.png"],trigger:"需求进入评审和落库阶段,需要把 TAPD 信息、Hive 数据、原型内容组织成 PRD,并同步到 TAPD 和 Git 仓库。",steps:["先运行 TAPD / 数据查询节点,拿到迭代、页面 PV 和业务背景","把查询结果和原型 Display 内容接入 PRD 生成子 Agent","在 Markdown Display 查看完整需求文档","把 PRD content 接入 TAPD 更新节点和 Git 仓库提交节点"],outputs:["完整 PRD 文档","项目背景与 Top 页面数据","TAPD 需求更新成功","Git MR 链接"]},{label:"Use Case 06",title:"Display 模式做需求评审面板",images:["/likee-context/usecase-display.png"],trigger:"流程跑完后,需要把 PRD、原型、数据图表、展示位表格放在一个页面里给产品、运营、研发一起看。",steps:["在 Workspace 中完成查数、原型、PRD、同步节点执行","确认 Markdown / HTML / 图表 / 表格展示节点都有结果","切换顶部 DISPLAY 模式","使用生成链接把评审面板发给相关同学"],outputs:["PRD 长文档","客户端原型预览","图表与表格","统一展示链接"]}],vae=[{name:"likee-client-ui",namespace:"智能助手 / 客户端原型",icon:"phone_iphone",mode:"客户端原型设计",usage:"生成 Likee 客户端风格页面、弹框、Feed 引导、个人页、活动入口等原型,适合产品评审前快速对齐体验。",examples:["首页 dialog 弹框","Feed 内引导","客户端红色主品牌视觉","移动端交互态"],tone:"pink"},{name:"tapd-likee",namespace:"智能助手 / TAPD",icon:"sync",mode:"需求系统交互",usage:"和 TAPD 交互,支持创建、同步、更新需求,把工作区生成的 PRD 或 Markdown 内容回写到需求系统。",examples:["创建 TAPD 需求","更新需求正文","同步处理人和链接","把结果回显到 Display"],tone:"green"},{name:"plain-language-response",namespace:"智能助手 / 回答风格",icon:"record_voice_over",mode:"业务化回答",usage:"用于把回答收敛成产品、运营更容易阅读的解释,避免直接把客户端代码库细节、函数调用链和实现细节暴露太多。",examples:["需求背景解释","代码结论转业务语言","评审材料摘要","减少实现细节噪音"],tone:"cyan"},{name:"create-likee-h5-style-html",namespace:"智能助手 / 前端 H5",icon:"language",mode:"H5 原型设计",usage:"创建 Likee H5 风格原型,适合运营活动、抽奖、排行榜、报告页、反馈表单、创作者认证页、订单列表等页面。",examples:["幸运转盘活动","积分排行榜","活动规则页","结果页和空状态"],tone:"amber"},{name:"analytics",namespace:"数据 / CK & Hive",icon:"query_stats",mode:"查数和 SQL 生成",usage:"面向 CK、Hive 的指标查询和 SQL 生成,适合 PV、UV、转化、分国家、分实验组、典型 UID 等数据问题。",examples:["自动生成 SQL","输出查询结果表","解释指标口径","沉淀复盘数据"],tone:"green"}],Sae=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function rh({icon:e,title:t,label:n,tone:r="violet"}){return i.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[i.jsx("span",{className:"material-symbols-outlined",children:e}),i.jsxs("div",{children:[i.jsx("strong",{children:t}),i.jsx("small",{children:n})]})]})}function jae(){return i.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[i.jsx("div",{className:"likee-scene-grid"}),i.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[i.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),i.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),i.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),i.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),i.jsx("div",{className:"likee-node-pos likee-node-a",children:i.jsx(rh,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(rh,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(rh,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(rh,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),i.jsxs("div",{className:"likee-phone-preview",children:[i.jsxs("div",{className:"likee-phone-top",children:[i.jsx("span",{children:"关注"}),i.jsx("strong",{children:"推荐"}),i.jsx("span",{children:"直播"})]}),i.jsxs("div",{className:"likee-phone-card",children:[i.jsx("div",{className:"likee-gift",children:"AD"}),i.jsx("h4",{children:"广告个性化引导弹框"}),i.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),i.jsx("button",{children:"继续"}),i.jsx("button",{className:"secondary",children:"稍后"})]})]}),i.jsxs("div",{className:"likee-display-panel",children:[i.jsxs("div",{className:"likee-panel-header",children:[i.jsx("span",{children:"DISPLAY"}),i.jsx("strong",{children:"需求资产面板"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"需求"}),i.jsx("strong",{children:"首页广告个性化引导"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"数据"}),i.jsx("strong",{children:"m09 PV Top 1"})]}),i.jsxs("div",{className:"likee-table-row",children:[i.jsx("span",{children:"同步"}),i.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function Rh({kicker:e,title:t,children:n}){return i.jsxs("div",{className:"likee-section-copy",children:[i.jsx("p",{className:"likee-section-kicker",children:e}),i.jsx("h2",{children:t}),i.jsx("p",{children:n})]})}function Nae(){return i.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[i.jsx(Rh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:vae.map(e=>i.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[i.jsxs("div",{className:"likee-skill-head",children:[i.jsx("div",{className:"likee-skill-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.name}),i.jsx("span",{children:e.namespace})]})]}),i.jsx("div",{className:"likee-skill-mode",children:e.mode}),i.jsx("p",{children:e.usage}),i.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>i.jsx("strong",{children:t},t))})]},e.name))})]})})}function u$(){return i.jsxs("div",{className:"likee-page",children:[i.jsx("div",{className:"likee-top-actions",children:i.jsxs("a",{href:"/projects",className:"likee-home-link",children:[i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),i.jsxs("section",{className:"likee-hero",children:[i.jsx(jae,{}),i.jsxs("div",{className:"likee-hero-content",children:[i.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),i.jsx("h1",{children:"Likee Agent 工作台"}),i.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),i.jsxs("div",{className:"likee-signal-row",children:[i.jsx("span",{children:"查业务逻辑"}),i.jsx("span",{children:"查 CK / Hive"}),i.jsx("span",{children:"生成原型"}),i.jsx("span",{children:"生成 PRD"}),i.jsx("span",{children:"同步 TAPD / Git"})]}),i.jsxs("div",{className:"likee-hero-actions",children:[i.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),i.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),i.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),i.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),i.jsx("section",{id:"likee-scenarios",className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner",children:[i.jsx(Rh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:bae.map(e=>i.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[i.jsx("div",{className:"likee-scenario-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.title}),i.jsx("p",{children:e.question})]}),i.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>i.jsx("span",{children:t},t))}),i.jsxs("div",{className:"likee-scenario-result",children:[i.jsx("span",{children:"产出"}),i.jsx("strong",{children:e.result})]})]},e.title))})]})}),i.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[i.jsx(Rh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:kae.map(e=>i.jsxs("article",{className:"likee-usecase-card",children:[i.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>i.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),i.jsxs("div",{className:"likee-usecase-body",children:[i.jsx("div",{className:"likee-usecase-label",children:e.label}),i.jsx("h3",{children:e.title}),i.jsx("p",{children:e.trigger}),i.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>i.jsx("li",{children:t},t))}),i.jsxs("div",{className:"likee-usecase-output",children:[i.jsx("span",{children:"实际产物"}),i.jsx("div",{children:e.outputs.map(t=>i.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),i.jsx(Nae,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(Rh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:Sae.map(([e,t,n])=>i.jsxs("div",{className:"likee-capability-row",children:[i.jsx("span",{children:e}),i.jsx("strong",{children:t}),i.jsx("p",{children:n})]},e))})]})})]})}function d$(e){return t=>typeof t===e}var _ae=d$("function"),Cae=e=>e===null,JC=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",XC=e=>!Aae(e)&&!Cae(e)&&(_ae(e)||typeof e=="object"),Aae=d$("undefined");function Eae(e,t,n){return Lae(n,e,t)?!0:(Oae(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Iae(e,t,n):e instanceof Map&&t instanceof Map?Tae(e,t,n):e instanceof Set&&t instanceof Set?$ae(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Pae(e,t):JC(e)&&JC(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Rae(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Mae(e,t,n))}function Mf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!XC(e)||!t||!XC(t)?!1:Eae(e,t,n)}function Iae(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!Mf(e[s],t[s],n))return!1;return!0}function Pae(e,t){if(e.byteLength!==t.byteLength)return!1;const n=new DataView(e.buffer),r=new DataView(t.buffer);let s=e.byteLength;for(;s--;)if(n.getUint8(s)!==r.getUint8(s))return!1;return!0}function Rae(e,t,n){return e.message===t.message&&e.name===t.name&&Mf(e.cause,t.cause,n)}function Tae(e,t,n){if(e.size!==t.size)return!1;for(const r of e.entries())if(!t.has(r[0]))return!1;for(const r of e.entries())if(!Mf(r[1],t.get(r[0]),n))return!1;return!0}function Mae(e,t,n){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let s=r.length;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[s]))return!1;for(let s=r.length;s--!==0;){const o=r[s];if(!(o==="_owner"&&e.$$typeof)&&!Mf(e[o],t[o],n))return!1}return!0}function $ae(e,t){if(e.size!==t.size)return!1;for(const n of e.entries())if(!t.has(n[0]))return!1;return!0}function Lae(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Oae(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function Fv(e,t){return Mf(e,t,new WeakMap)}function Ow(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Dae(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Fae(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function zae(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Bae(e,t){const n=zae();m.useEffect(()=>{if(!n)return e()},t)}function f$(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function Wae(e,t){const n=m.useRef(t);return Fv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Hae(e){m.useEffect(()=>{e()},[])}function Vae(e=0){const[t,n]=m.useState({height:Ow()?window.innerHeight:0,width:Ow()?window.innerWidth:0}),r=m.useRef(0),s=m.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return m.useEffect(()=>{if(!Ow())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Fae(window,"resize",o),()=>{Dae(window,"resize",o)}},[]),t}var Kae=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],qae=["bigint","boolean","null","number","string","symbol","undefined"];function $f(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Uae(t))return t}function mi(e){return t=>$f(t)===e}function Uae(e){return Kae.includes(e)}function iu(e){return t=>typeof t===e}function Gae(e){return qae.includes(e)}var Yae=["innerHTML","ownerDocument","style","attributes","nodeValue"],Lf=e=>Array.isArray(e),Jae=e=>$f(e)==="AsyncGeneratorFunction",Xae=mi("AsyncFunction"),Qae=iu("bigint"),Zae=e=>e===!0||e===!1,ele=mi("Date"),tle=mi("Error"),pa=iu("function"),nle=mi("GeneratorFunction"),rle=e=>typeof e=="number"&&Number.isInteger(e),zb=mi("Map"),p$=e=>Number.isNaN(e),zv=e=>e===null,h$=mi("Function"),sle=mi("Promise"),ile=mi("RegExp"),Bb=mi("Set"),Of=iu("string"),ole=iu("symbol"),Bv=iu("undefined"),ale=mi("WeakMap"),lle=mi("WeakSet"),Wv=e=>zv(e)||Bv(e),m$=e=>!Bv(e),cle=e=>iu("number")(e)&&!p$(e),ule=e=>Of(e)&&e.trim().length>0,dle=e=>{if(!Of(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},_g=e=>!Wv(e)&&(pa(e)||typeof e=="object"),g$=e=>{if($f(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},fle=e=>zv(e)||Gae(typeof e),ple=e=>$f(e)==="URL",y$=e=>!Wv(e)&&pa(e[Symbol.iterator]),hle=e=>y$(e)&&pa(e.next)&&pa(e.throw),mle=e=>pa(e)&&/^class\s/.test(e.toString()),gle=(e,t)=>!Lf(e)||!pa(t)?!1:e.every(n=>t(n)),yle=e=>_g(e)&&!g$(e)&&e.nodeType===1&&Of(e.nodeName)&&Yae.every(t=>t in e),wle=e=>Of(e)&&e.length===0||Lf(e)&&e.length===0||_g(e)&&!zb(e)&&!Bb(e)&&Object.keys(e).length===0||Bb(e)&&e.size===0||zb(e)&&e.size===0,xle=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,ble=(e,t)=>Lf(e)?e.indexOf(t)>-1:!1,kle=(e,t,n)=>{if(!_g(e)||!t)return!1;const r=e[t];return pa(n)?n(r):m$(r)};function Nt(e){if(e===null)return"null";switch(typeof e){case"bigint":return"bigint";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";case"undefined":return"undefined"}if(Lf(e))return"Array";if(h$(e))return"Function";const t=$f(e);return t||"Object"}Nt.array=Lf;Nt.arrayOf=gle;Nt.asyncGeneratorFunction=Jae;Nt.asyncFunction=Xae;Nt.bigint=Qae;Nt.boolean=Zae;Nt.class=mle;Nt.date=ele;Nt.defined=m$;Nt.domElement=yle;Nt.empty=wle;Nt.error=tle;Nt.function=pa;Nt.generator=hle;Nt.generatorFunction=nle;Nt.instanceOf=xle;Nt.integer=rle;Nt.iterable=y$;Nt.map=zb;Nt.nan=p$;Nt.null=zv;Nt.nullOrUndefined=Wv;Nt.nonEmptyString=ule;Nt.number=cle;Nt.numericString=dle;Nt.object=_g;Nt.oneOf=ble;Nt.plainFunction=h$;Nt.plainObject=g$;Nt.primitive=fle;Nt.promise=sle;Nt.propertyOf=kle;Nt.regexp=ile;Nt.set=Bb;Nt.string=Of;Nt.symbol=ole;Nt.undefined=Bv;Nt.url=ple;Nt.weakMap=ale;Nt.weakSet=lle;var Ir=Nt;/* v8 ignore next -- @preserve */var vle=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Sle=function(e,t){return e+gf(t)},gf=function(e){return e===null||typeof e=="boolean"||typeof e>"u"?"":typeof e=="number"?e.toString():typeof e=="string"?e:Array.isArray(e)?e.reduce(Sle,""):vle(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?gf(e.props.children):""};gf.default=gf;var jle=gf;const Dw=ma(jle);var w$={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(o){return typeof o=="object"&&o!==null&&!(o instanceof RegExp)&&!(o instanceof Date)}}function r(s){function o(S){return S!=="constructor"&&S!=="prototype"&&S!=="__proto__"}function a(S){let N=0;const P=S.length,R=new Array(P);for(N;N<P;++N)R[N]=g(S[N]);return R}function l(S){const N={};if(d&&Object.getPrototypeOf(S)!==t)return d(S);const P=f(S);let R,z,E;for(R=0,z=P.length;R<z;++R)o(E=P[R])&&(N[E]=g(S[E]));return N}function c(S,N){const P=S.length,R=N.length;let z=0;const E=new Array(P+R);for(z;z<P;++z)E[z]=g(S[z]);for(z=0;z<R;++z)E[z+P]=g(N[z]);return E}const u=Object.prototype.propertyIsEnumerable;function p(S){const N=Object.keys(S),P=Object.getOwnPropertySymbols(S);for(let R=0,z=P.length;R<z;++R)u.call(S,P[R])&&N.push(P[R]);return N}const f=s!=null&&s.symbols?p:Object.keys,d=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),y=(s==null?void 0:s.onlyDefinedProperties)===!0;function v(S){return typeof S!="object"||S===null}const b=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:g,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function g(S){return h(S)?Array.isArray(S)?a(S):l(S):S}function k(S,N){const P={},R=f(S),z=f(N);let E,O,D;for(E=0,O=R.length;E<O;++E)o(D=R[E])&&z.indexOf(D)===-1&&(P[D]=g(S[D]));for(E=0,O=z.length;E<O;++E)if(o(D=z[E]))if(D in S)R.indexOf(D)!==-1&&(d&&h(N[D])&&Object.getPrototypeOf(N[D])!==t?P[D]=d(N[D]):P[D]=x(S[D],N[D]));else{if(y&&typeof N[D]>"u")continue;P[D]=g(N[D])}return P}function x(S,N){if(y&&typeof N>"u")return g(S);const P=Array.isArray(N),R=Array.isArray(S);return v(N)?N:h(S)?P&&R?b(S,N):P!==R?g(N):k(S,N):g(N)}function _(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let S;for(let N=0,P=arguments.length;N<P;++N)S=x(S,arguments[N]);return S}return s!=null&&s.all?_:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(w$);var Nle=w$.exports;const _le=ma(Nle);var Cle=new Error("Element already at target scroll position"),Ale=new Error("Scroll cancelled"),Ele=Math.min,QC=Date.now,Ile={left:ZC("scrollLeft"),top:ZC("scrollTop")};function ZC(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=Rle);var a=QC(),l=n[e],c=s.ease||Ple,u=isNaN(s.duration)?350:+s.duration,p=!1;return l===r?o(Cle,n[e]):requestAnimationFrame(d),f;function f(){p=!0}function d(h){if(p)return o(Ale,n[e]);var y=QC(),v=Ele(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(d):requestAnimationFrame(function(){o(null,n[e])})}}}function Ple(e){return .5*(1-Math.cos(Math.PI*e))}function Rle(){}const Tle=ma(Ile);var x$={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(Rd,function(){function t(r){var s=getComputedStyle(r,null).getPropertyValue("overflow");return s.indexOf("scroll")>-1||s.indexOf("auto")>-1}function n(r){if(r instanceof HTMLElement||r instanceof SVGElement){for(var s=r.parentNode;s.parentNode;){if(t(s))return s;s=s.parentNode}return document.scrollingElement||document.documentElement}}return n})})(x$);var Mle=x$.exports;const b$=ma(Mle),$le=["top","right","bottom","left"],eA=["start","end"],tA=$le.reduce((e,t)=>e.concat(t,t+"-"+eA[0],t+"-"+eA[1]),[]),Yc=Math.min,Za=Math.max,Lm=Math.round,sh=Math.floor,Oi=e=>({x:e,y:e}),Lle={left:"right",right:"left",bottom:"top",top:"bottom"};function Wb(e,t,n){return Za(e,Yc(t,n))}function ou(e,t){return typeof e=="function"?e(t):e}function xo(e){return e.split("-")[0]}function Di(e){return e.split("-")[1]}function k$(e){return e==="x"?"y":"x"}function Hv(e){return e==="y"?"height":"width"}function Jo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Vv(e){return k$(Jo(e))}function v$(e,t,n){n===void 0&&(n=!1);const r=Di(e),s=Vv(e),o=Hv(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Dm(a)),[a,Dm(a)]}function Ole(e){const t=Dm(e);return[Om(e),t,Om(t)]}function Om(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const nA=["left","right"],rA=["right","left"],Dle=["top","bottom"],Fle=["bottom","top"];function zle(e,t,n){switch(e){case"top":case"bottom":return n?t?rA:nA:t?nA:rA;case"left":case"right":return t?Dle:Fle;default:return[]}}function Ble(e,t,n,r){const s=Di(e);let o=zle(xo(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(Om)))),o}function Dm(e){const t=xo(e);return Lle[t]+e.slice(t.length)}function Wle(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?Wle(e):{top:e,right:e,bottom:e,left:e}}function Fm(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function sA(e,t,n){let{reference:r,floating:s}=e;const o=Jo(t),a=Vv(t),l=Hv(a),c=xo(t),u=o==="y",p=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:p,y:r.y-s.height};break;case"bottom":h={x:p,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Di(t)){case"start":h[a]-=d*(n&&u?-1:1);break;case"end":h[a]+=d*(n&&u?-1:1);break}return h}async function Hle(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=ou(t,e),y=S$(h),b=l[d?f==="floating"?"reference":"floating":f],g=Fm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:p,strategy:c})),k=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),_=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},S=Fm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-S.top+y.top)/_.y,bottom:(S.bottom-g.bottom+y.bottom)/_.y,left:(g.left-S.left+y.left)/_.x,right:(S.right-g.right+y.right)/_.x}}const Vle=50,Kle=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Hle},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:p,y:f}=sA(u,r,c),d=r,h=0;const y={};for(let v=0;v<o.length;v++){const b=o[v];if(!b)continue;const{name:g,fn:k}=b,{x,y:_,data:S,reset:N}=await k({x:p,y:f,initialPlacement:r,placement:d,strategy:s,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});p=x??p,f=_??f,y[g]={...y[g],...S},N&&h<Vle&&(h++,typeof N=="object"&&(N.placement&&(d=N.placement),N.rects&&(u=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):N.rects),{x:p,y:f}=sA(u,d,c)),v=-1)}return{x:p,y:f,placement:d,strategy:s,middlewareData:y}},qle=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:p=0}=ou(e,t)||{};if(u==null)return{};const f=S$(p),d={x:n,y:r},h=Vv(s),y=Hv(h),v=await a.getDimensions(u),b=h==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",_=o.reference[y]+o.reference[h]-d[h]-o.floating[y],S=d[h]-o.reference[h],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let P=N?N[x]:0;(!P||!await(a.isElement==null?void 0:a.isElement(N)))&&(P=l.floating[x]||o.floating[y]);const R=_/2-S/2,z=P/2-v[y]/2-1,E=Yc(f[g],z),O=Yc(f[k],z),D=E,L=P-v[y]-O,M=P/2-v[y]/2+R,V=Wb(D,M,L),B=!c.arrow&&Di(s)!=null&&M!==V&&o.reference[y]/2-(M<D?E:O)-v[y]/2<0,F=B?M<D?M-D:M-L:0;return{[h]:d[h]+F,data:{[h]:V,centerOffset:M-V-F,...B&&{alignmentOffset:F}},reset:B}}});function Ule(e,t,n){return(e?[...n.filter(s=>Di(s)===e),...n.filter(s=>Di(s)!==e)]:n.filter(s=>xo(s)===s)).filter(s=>e?Di(s)===e||(t?Om(s)!==s:!1):!0)}const Gle=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:o,middlewareData:a,placement:l,platform:c,elements:u}=t,{crossAxis:p=!1,alignment:f,allowedPlacements:d=tA,autoAlignment:h=!0,...y}=ou(e,t),v=f!==void 0||d===tA?Ule(f||null,h,d):d,b=await c.detectOverflow(t,y),g=((n=a.autoPlacement)==null?void 0:n.index)||0,k=v[g];if(k==null)return{};const x=v$(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const _=[b[xo(k)],b[x[0]],b[x[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:_}],N=v[g+1];if(N)return{data:{index:g+1,overflows:S},reset:{placement:N}};const P=S.map(E=>{const O=Di(E.placement);return[E.placement,O&&p?E.overflows.slice(0,2).reduce((D,L)=>D+L,0):E.overflows[0],E.overflows]}).sort((E,O)=>E[1]-O[1]),z=((s=P.filter(E=>E[2].slice(0,Di(E[0])?2:3).every(O=>O<=0))[0])==null?void 0:s[0])||P[0][0];return z!==l?{data:{index:g+1,overflows:S},reset:{placement:z}}:{}}}},Yle=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=ou(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=xo(s),k=Jo(l),x=xo(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=d||(x||!v?[Dm(l)]:Ole(l)),N=y!=="none";!d&&N&&S.push(...Ble(l,v,y,_));const P=[l,...S],R=await c.detectOverflow(t,b),z=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&z.push(R[g]),f){const M=v$(s,a,_);z.push(R[M[0]],R[M[1]])}if(E=[...E,{placement:s,overflows:z}],!z.every(M=>M<=0)){var O,D;const M=(((O=o.flip)==null?void 0:O.index)||0)+1,V=P[M];if(V&&(!(f==="alignment"?k!==Jo(V):!1)||E.every($=>Jo($.placement)===k?$.overflows[0]>0:!0)))return{data:{index:M,overflows:E},reset:{placement:V}};let B=(D=E.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:D.placement;if(!B)switch(h){case"bestFit":{var L;const F=(L=E.filter($=>{if(N){const H=Jo($.placement);return H===k||H==="y"}return!0}).map($=>[$.placement,$.overflows.filter(H=>H>0).reduce((H,A)=>H+A,0)]).sort(($,H)=>$[1]-H[1])[0])==null?void 0:L[0];F&&(B=F);break}case"initialPlacement":B=l;break}if(s!==B)return{reset:{placement:B}}}return{}}}},Jle=new Set(["left","top"]);async function Xle(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=xo(n),l=Di(n),c=Jo(n)==="y",u=Jle.has(a)?-1:1,p=o&&c?-1:1,f=ou(t,e);let{mainAxis:d,crossAxis:h,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*p,y:d*u}:{x:d*u,y:h*p}}const Qle=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:o,placement:a,middlewareData:l}=t,c=await Xle(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:a}}}}},Zle=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:o}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:g=>{let{x:k,y:x}=g;return{x:k,y:x}}},...u}=ou(e,t),p={x:n,y:r},f=await o.detectOverflow(t,u),d=Jo(xo(s)),h=k$(d);let y=p[h],v=p[d];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",x=y+f[g],_=y-f[k];y=Wb(x,y,_)}if(l){const g=d==="y"?"top":"left",k=d==="y"?"bottom":"right",x=v+f[g],_=v-f[k];v=Wb(x,v,_)}const b=c.fn({...t,[h]:y,[d]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[d]:l}}}}}};function Cg(){return typeof window<"u"}function au(e){return j$(e)?(e.nodeName||"").toLowerCase():"#document"}function gs(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Wi(e){var t;return(t=(j$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function j$(e){return Cg()?e instanceof Node||e instanceof gs(e).Node:!1}function fi(e){return Cg()?e instanceof Element||e instanceof gs(e).Element:!1}function So(e){return Cg()?e instanceof HTMLElement||e instanceof gs(e).HTMLElement:!1}function iA(e){return!Cg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gs(e).ShadowRoot}function Df(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=pi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function ece(e){return/^(table|td|th)$/.test(au(e))}function Ag(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tce=/transform|translate|scale|rotate|perspective|filter/,nce=/paint|layout|strict|content/,Ta=e=>!!e&&e!=="none";let Fw;function Kv(e){const t=fi(e)?pi(e):e;return Ta(t.transform)||Ta(t.translate)||Ta(t.scale)||Ta(t.rotate)||Ta(t.perspective)||!qv()&&(Ta(t.backdropFilter)||Ta(t.filter))||tce.test(t.willChange||"")||nce.test(t.contain||"")}function rce(e){let t=ha(e);for(;So(t)&&!Jc(t);){if(Kv(t))return t;if(Ag(t))return null;t=ha(t)}return null}function qv(){return Fw==null&&(Fw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Fw}function Jc(e){return/^(html|body|#document)$/.test(au(e))}function pi(e){return gs(e).getComputedStyle(e)}function Eg(e){return fi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ha(e){if(au(e)==="html")return e;const t=e.assignedSlot||e.parentNode||iA(e)&&e.host||Wi(e);return iA(t)?t.host:t}function N$(e){const t=ha(e);return Jc(t)?e.ownerDocument?e.ownerDocument.body:e.body:So(t)&&Df(t)?t:N$(t)}function yf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=N$(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=gs(s);if(o){const l=Hb(a);return t.concat(a,a.visualViewport||[],Df(s)?s:[],l&&n?yf(l):[])}else return t.concat(s,yf(s,[],n))}function Hb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _$(e){const t=pi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=So(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=Lm(n)!==o||Lm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Uv(e){return fi(e)?e:e.contextElement}function Rc(e){const t=Uv(e);if(!So(t))return Oi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=_$(t);let a=(o?Lm(n.width):n.width)/r,l=(o?Lm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const sce=Oi(0);function C$(e){const t=gs(e);return!qv()||!t.visualViewport?sce:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ice(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==gs(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Uv(e);let a=Oi(1);t&&(r?fi(r)&&(a=Rc(r)):a=Rc(e));const l=ice(o,n,r)?C$(o):Oi(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,p=s.width/a.x,f=s.height/a.y;if(o){const d=gs(o),h=r&&fi(r)?gs(r):r;let y=d,v=Hb(y);for(;v&&r&&h!==y;){const b=Rc(v),g=v.getBoundingClientRect(),k=pi(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,_=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,p*=b.x,f*=b.y,c+=x,u+=_,y=gs(v),v=Hb(y)}}return Fm({width:p,height:f,x:c,y:u})}function Ig(e,t){const n=Eg(e).scrollLeft;return t?t.left+n:ml(Wi(e)).left+n}function A$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ig(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function oce(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Wi(r),l=t?Ag(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Oi(1);const p=Oi(0),f=So(r);if((f||!f&&!o)&&((au(r)!=="body"||Df(a))&&(c=Eg(r)),f)){const h=ml(r);u=Rc(r),p.x=h.x+r.clientLeft,p.y=h.y+r.clientTop}const d=a&&!f&&!o?A$(a,c):Oi(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+d.x,y:n.y*u.y-c.scrollTop*u.y+p.y+d.y}}function ace(e){return Array.from(e.getClientRects())}function lce(e){const t=Wi(e),n=Eg(e),r=e.ownerDocument.body,s=Za(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Za(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Ig(e);const l=-n.scrollTop;return pi(r).direction==="rtl"&&(a+=Za(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const oA=25;function cce(e,t){const n=gs(e),r=Wi(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;const p=qv();(!p||p&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=Ig(r);if(u<=0){const p=r.ownerDocument,f=p.body,d=getComputedStyle(f),h=p.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-h);y<=oA&&(o-=y)}else u<=oA&&(o+=u);return{width:o,height:a,x:l,y:c}}function uce(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=So(e)?Rc(e):Oi(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=s*o.x,u=r*o.y;return{width:a,height:l,x:c,y:u}}function aA(e,t,n){let r;if(t==="viewport")r=cce(e,n);else if(t==="document")r=lce(Wi(e));else if(fi(t))r=uce(t,n);else{const s=C$(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Fm(r)}function E$(e,t){const n=ha(e);return n===t||!fi(n)||Jc(n)?!1:pi(n).position==="fixed"||E$(n,t)}function dce(e,t){const n=t.get(e);if(n)return n;let r=yf(e,[],!1).filter(l=>fi(l)&&au(l)!=="body"),s=null;const o=pi(e).position==="fixed";let a=o?ha(e):e;for(;fi(a)&&!Jc(a);){const l=pi(a),c=Kv(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Df(a)&&!c&&E$(e,a))?r=r.filter(p=>p!==a):s=l,a=ha(a)}return t.set(e,r),r}function fce(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Ag(t)?[]:dce(t,this._c):[].concat(n),r],l=aA(t,a[0],s);let c=l.top,u=l.right,p=l.bottom,f=l.left;for(let d=1;d<a.length;d++){const h=aA(t,a[d],s);c=Za(h.top,c),u=Yc(h.right,u),p=Yc(h.bottom,p),f=Za(h.left,f)}return{width:u-f,height:p-c,x:f,y:c}}function pce(e){const{width:t,height:n}=_$(e);return{width:t,height:n}}function hce(e,t,n){const r=So(t),s=Wi(t),o=n==="fixed",a=ml(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Oi(0);function u(){c.x=Ig(s)}if(r||!r&&!o)if((au(t)!=="body"||Df(s))&&(l=Eg(t)),r){const h=ml(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();o&&!r&&s&&u();const p=s&&!r&&!o?A$(s,l):Oi(0),f=a.left+l.scrollLeft-c.x-p.x,d=a.top+l.scrollTop-c.y-p.y;return{x:f,y:d,width:a.width,height:a.height}}function zw(e){return pi(e).position==="static"}function lA(e,t){if(!So(e)||pi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Wi(e)===n&&(n=n.ownerDocument.body),n}function I$(e,t){const n=gs(e);if(Ag(e))return n;if(!So(e)){let s=ha(e);for(;s&&!Jc(s);){if(fi(s)&&!zw(s))return s;s=ha(s)}return n}let r=lA(e,t);for(;r&&ece(r)&&zw(r);)r=lA(r,t);return r&&Jc(r)&&zw(r)&&!Kv(r)?n:r||rce(e)||n}const mce=async function(e){const t=this.getOffsetParent||I$,n=this.getDimensions,r=await n(e.floating);return{reference:hce(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gce(e){return pi(e).direction==="rtl"}const yce={convertOffsetParentRelativeRectToViewportRelativeRect:oce,getDocumentElement:Wi,getClippingRect:fce,getOffsetParent:I$,getElementRects:mce,getClientRects:ace,getDimensions:pce,getScale:Rc,isElement:fi,isRTL:gce};function P$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wce(e,t){let n=null,r;const s=Wi(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const u=e.getBoundingClientRect(),{left:p,top:f,width:d,height:h}=u;if(l||t(),!d||!h)return;const y=sh(f),v=sh(s.clientWidth-(p+d)),b=sh(s.clientHeight-(f+h)),g=sh(p),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Za(0,Yc(1,c))||1};let _=!0;function S(N){const P=N[0].intersectionRatio;if(P!==c){if(!_)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!P$(u,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver(S,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return a(!0),o}function cA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Uv(e),p=s||o?[...u?yf(u):[],...t?yf(t):[]]:[];p.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?wce(u,n):null;let d=-1,h=null;a&&(h=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?ml(e):null;c&&b();function b(){const g=ml(e);v&&!P$(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;p.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const xce=Qle,bce=Gle,kce=Zle,vce=Yle,uA=qle,Sce=(e,t,n)=>{const r=new Map,s={platform:yce,...n},o={...s.platform,_c:r};return Kle(e,t,{...s,platform:o})};var jce=typeof document<"u",Nce=function(){},Th=jce?m.useLayoutEffect:Nce;function zm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zm(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!zm(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function R$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dA(e,t){const n=R$(e);return Math.round(t*n)/n}function Bw(e){const t=m.useRef(e);return Th(()=>{t.current=e}),t}function fA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[p,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);zm(d,r)||h(r);const[y,v]=m.useState(null),[b,g]=m.useState(null),k=m.useCallback($=>{$!==N.current&&(N.current=$,v($))},[]),x=m.useCallback($=>{$!==P.current&&(P.current=$,g($))},[]),_=o||y,S=a||b,N=m.useRef(null),P=m.useRef(null),R=m.useRef(p),z=c!=null,E=Bw(c),O=Bw(s),D=Bw(u),L=m.useCallback(()=>{if(!N.current||!P.current)return;const $={placement:t,strategy:n,middleware:d};O.current&&($.platform=O.current),Sce(N.current,P.current,$).then(H=>{const A={...H,isPositioned:D.current!==!1};M.current&&!zm(R.current,A)&&(R.current=A,lr.flushSync(()=>{f(A)}))})},[d,t,n,O,D]);Th(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const M=m.useRef(!1);Th(()=>(M.current=!0,()=>{M.current=!1}),[]),Th(()=>{if(_&&(N.current=_),S&&(P.current=S),_&&S){if(E.current)return E.current(_,S,L);L()}},[_,S,L,E,z]);const V=m.useMemo(()=>({reference:N,floating:P,setReference:k,setFloating:x}),[k,x]),B=m.useMemo(()=>({reference:_,floating:S}),[_,S]),F=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!B.floating)return $;const H=dA(B.floating,p.x),A=dA(B.floating,p.y);return l?{...$,transform:"translate("+H+"px, "+A+"px)",...R$(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:A}},[n,l,B.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:L,refs:V,elements:B,floatingStyles:F}),[p,L,V,B,F])}const _ce=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?uA({element:r.current,padding:s}).fn(n):{}:r?uA({element:r,padding:s}).fn(n):{}}}},pA=(e,t)=>{const n=xce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cce=(e,t)=>{const n=kce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ace=(e,t)=>{const n=vce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ece=(e,t)=>{const n=bce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ice=(e,t)=>{const n=_ce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pce={arrowBase:32,arrowColor:"#ffffff",arrowSize:16,arrowSpacing:12,backgroundColor:"#ffffff",beaconSize:36,beaconTrigger:"click",beforeTimeout:5e3,blockTargetInteraction:!1,buttons:["back","close","primary"],closeButtonAction:"close",disableFocusTrap:!1,dismissKeyAction:"close",hideOverlay:!1,loaderDelay:300,offset:10,overlayClickAction:"close",overlayColor:"#00000080",primaryColor:"#000000",scrollDuration:300,scrollOffset:20,showProgress:!1,skipBeacon:!1,skipScroll:!1,spotlightPadding:10,spotlightRadius:4,targetWaitTimeout:1e3,textColor:"#000000",width:380,zIndex:100},Rce={beaconOptions:{offset:-18}},T$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Tce={isFixed:!1,locale:T$,placement:"bottom"},Mce={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Dt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},ar={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Je={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Ni={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Et={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},$ce="react-joyride-portal";function Lce(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function wc(...e){return _le({all:!0,isMergeableObject:t=>!(!Ir.plainObject(t)||m.isValidElement(t))})(...e)}function M$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function to(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=Dw(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&s&&(o=o.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&M$(e.type)==="function")try{o=to(e.type({}),t)}catch{o=Dw(n)}else o=Dw(n);return o}function dr(e,t,n,...r){if(!e)return;const s=new Date,o=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}:${String(s.getSeconds()).padStart(2,"0")}.${String(s.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${o}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Oce(e,t){const n=Lce(t);return{...e,...n}}function wf(){}function Dce(e){return Object.keys(e)}function Bm(e,...t){if(!Ir.plainObject(e))throw new TypeError("Expected an object");const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&(t.includes(r)||(n[r]=e[r]));return n}function hA(e,...t){if(!Ir.plainObject(e))throw new TypeError("Expected an object");if(!t.length)return e;const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&t.includes(r)&&(n[r]=e[r]);return n}function Vb(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(M$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Ir.string(s)&&s.includes("{current}"))return m.cloneElement(e,{children:r(s)});if(Array.isArray(s))return m.cloneElement(e,{children:s.map(o=>typeof o=="string"?r(o):Vb(o,t,n))});if(Ir.function(e.type)&&!Object.values(e.props).length)try{return Vb(e.type({}),t,n)}catch{return e}return e}function mA(e){return Dce(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Gv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function gA(e){let t=0,n=0,r=e;for(;r;)t+=r.offsetTop,n+=r.offsetLeft,r=r.offsetParent;return{left:n,top:t}}function Yv(e){return e?e.getBoundingClientRect():null}function Fce(e=!1){const{body:t,documentElement:n}=document;if(!t||!n)return 0;if(e){const r=[t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight].sort((o,a)=>o-a),s=Math.floor(r.length/2);return r.length%2===0?(r[s-1]+r[s])/2:r[s]}return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}function Ms(e){if(!e)return null;if(typeof e=="function")try{return e()}catch{return null}if(typeof e=="object"&&"current"in e)return e.current;if(typeof e=="string")try{return document.querySelector(e)}catch{return null}return e}function zce(e,t,n){const r=Yv(e),s=lu(e),o=s?!s.isSameNode(Qr()):!1,a=n??cu(e);let l=0,c=(r==null?void 0:r.top)??0;return o&&a?c=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!o&&!a&&(c+=l),s.isSameNode(Qr())||(c+=Qr().scrollTop)),Math.floor(c-t)}function lu(e,t){if(!e)return Qr();const n=b$(e);if(n){if(n.isSameNode(Qr()))return t?document:Qr();if(!(n.scrollHeight>n.offsetHeight))return Qr()}return n}function Bce(e){const t=e.getBoundingClientRect(),n=Qr(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Wce(e,t){if(!e)return 0;const n=b$(e)??Qr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Yv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&($$(e)||Hce(e))){const p=e.getBoundingClientRect(),f=p.top-((s==null?void 0:s.top)??0),d=f+p.height,h=n.clientHeight,y=h*.2;f>=y&&d<=h-y?c=o:c=f+o}const u=Math.floor(c-t-r);return u<0?0:u}function Hce(e){return e.offsetParent!==document.body}function $$(e){if(!e)return!1;const t=lu(e);return t?!t.isSameNode(Qr()):!1}function cu(e,t="fixed"){if(!e||!(e instanceof Element))return!1;const{nodeName:n}=e;return n==="BODY"||n==="HTML"?!1:getComputedStyle(e).position===t?!0:e.parentNode?cu(e.parentNode,t):!1}function ih(e){if(!e)return!1;let t=e;for(;t&&t!==document.body;){if(t instanceof HTMLElement){const{display:n,visibility:r}=getComputedStyle(t);if(n==="none"||r==="hidden")return!1}t=t.parentElement??null}return!0}function yA(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Je.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?lu(s):Qr(),l=a?!a.isSameNode(Qr()):!1;return(r.isFixed||cu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Qr(){return document.scrollingElement??document.documentElement}function wA(e,t){const{duration:n,element:r}=t;let s=()=>{};const o=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;s=Tle.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function Vce(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,o,a)=>s+s+o+o+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const L$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},oh={...L$,borderRadius:4,padding:8};function Kce(e,t){const{styles:n}=e,r=wc(n??{},t.styles??{});let{width:s}=t;Gv()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const o={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return wc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...L$,display:"inline-flex",borderRadius:"50%",position:"relative"},beacon:{height:t.beaconSize,width:t.beaconSize},beaconInner:{animation:"joyride-beacon-inner 1.2s infinite ease-in-out",backgroundColor:t.primaryColor,borderRadius:"50%",display:"block",height:"50%",left:"50%",opacity:.7,position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:"50%"},beaconOuter:{animation:"joyride-beacon-outer 1.2s infinite ease-in-out",backgroundColor:`rgba(${Vce(t.primaryColor).join(",")}, 0.2)`,border:`2px solid ${t.primaryColor}`,borderRadius:"50%",boxSizing:"border-box",display:"block",height:"100%",left:0,opacity:.9,position:"absolute",top:0,transformOrigin:"center",width:"100%"},buttonBack:{...oh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...oh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...oh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...oh,color:t.textColor,fontSize:14},floater:{display:"inline-block",filter:"drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))",maxWidth:"100%",transition:"opacity 0.3s"},loader:{alignItems:"center",display:"flex",height:48,inset:0,justifyContent:"center",pointerEvents:"none",position:"fixed",width:48,zIndex:t.zIndex+1},overlay:{...o,backgroundColor:t.overlayColor},spotlight:{},tooltip:{backgroundColor:t.backgroundColor,borderRadius:5,boxSizing:"border-box",color:t.textColor,fontSize:16,maxWidth:"100%",padding:12,position:"relative",width:s},tooltipContainer:{lineHeight:1.4,textAlign:"center"},tooltipTitle:{fontSize:18,margin:0},tooltipContent:{paddingBottom:12,paddingTop:12},tooltipFooter:{alignItems:"center",display:"flex",justifyContent:"flex-end"},tooltipFooterSpacer:{flex:1}},r)}const qce=["after","arrowBase","arrowColor","arrowSize","arrowSpacing","backgroundColor","beaconSize","beaconTrigger","before","beforeTimeout","buttons","closeButtonAction","skipBeacon","dismissKeyAction","disableFocusTrap","hideOverlay","skipScroll","blockTargetInteraction","loaderDelay","offset","overlayClickAction","overlayColor","primaryColor","scrollDuration","scrollOffset","showProgress","spotlightPadding","spotlightRadius","targetWaitTimeout","textColor","width","zIndex"];function Jv(e,t){if(!t)return null;const n=wc(Tce,hA(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=wc(Pce,e.options??{},hA(t,...qce)),s=Kce(e,{...n,...r}),o=wc(Rce,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:wc(T$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:Uce(r.spotlightPadding),styles:s}}function Uce(e){return typeof e=="number"?{top:e,right:e,bottom:e,left:e}:{top:(e==null?void 0:e.top)??0,right:(e==null?void 0:e.right)??0,bottom:(e==null?void 0:e.bottom)??0,left:(e==null?void 0:e.left)??0}}function Gce(e,t,n){const{action:r}=t,s=n&&[Dt.PREV,Dt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function O$(e,t=!1){return Ir.plainObject(e)?e.target?!0:(dr(t,"tour","target is missing from the step"),!1):(dr(t,"tour","step must be an object"),!1)}function D$(e,t=!1){return Ir.array(e)?e.every(n=>O$(n,t)):(dr(t,"tour","steps must be an array"),!1)}var Yce=class{constructor(e){Tn(this,"beaconPosition",null);Tn(this,"debug");Tn(this,"eventListeners",new Map);Tn(this,"listeners",new Set);Tn(this,"props");Tn(this,"snapshot");Tn(this,"state");Tn(this,"steps");Tn(this,"tooltipPosition",null);Tn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Tn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Tn(this,"getServerSnapshot",()=>this.snapshot);Tn(this,"getSnapshot",()=>this.snapshot);Tn(this,"getEventState",()=>Bm(this.snapshot,"positioned"));Tn(this,"getState",()=>Bm(this.snapshot,"positioned"));Tn(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&dr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Je.BEACON_BEFORE||this.state.lifecycle===Je.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(o=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:o.onPosition;n&&n(t)});Tn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Tn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Tn(this,"on",(e,t)=>{let n=this.eventListeners.get(e);return n||(n=new Set,this.eventListeners.set(e,n)),n.add(t),()=>{n.delete(t)}});Tn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Tn(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,o=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:o,lifecycle:e.lifecycle??this.state.lifecycle,origin:e.origin??null,positioned:e.positioned??this.state.positioned,scrolling:e.scrolling??this.state.scrolling,size:e.size??this.state.size,status:e.status??this.state.status,waiting:e.waiting??this.state.waiting},l=this.applyTransitions(a);if(this.state=l,!Fv(s,l)){this.snapshot=Object.freeze({...l});for(const c of this.listeners)c(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},s=Ir.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,Ir.number(t)&&dr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Ir.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&dr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Dt.INIT,controlled:s,index:o,lifecycle:Je.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Et.READY:Et.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Et.WAITING&&e.size>0?{...e,status:Et.RUNNING}:e}getStep(e){return Jv(this.props,this.steps[e??this.state.index])}};function Jce(e){return new Yce(e)}function xA(e,t){return Math.min(Math.max(e,0),t)}function Xce(e,t,n){const r=m.useRef(t),s=m.useRef(n);return r.current=t,s.current=n,m.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(b=null)=>{const{index:g,status:k}=o();k===Et.RUNNING&&e.current.updateState({action:Dt.CLOSE,index:g+1,origin:b,lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:g,size:k,status:x}=o();if(g){dr(r.current,"tour","go() is not supported in controlled mode");return}x===Et.RUNNING&&e.current.updateState({action:Dt.GO,index:b,lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:Et.FINISHED,waiting:!1})},info:()=>Bm(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===Et.RUNNING&&e.current.updateState({action:Dt.NEXT,index:xA(g+1,k),lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===Et.RUNNING&&e.current.updateState({action:Dt.UPDATE,lifecycle:Je.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===Et.RUNNING&&e.current.updateState({action:Dt.PREV,index:xA(g-1,k),lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){dr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Dt.RESET,index:0,lifecycle:Je.INIT,positioned:!1,scrolling:!1,status:b?Et.RUNNING:Et.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===Et.RUNNING&&e.current.updateState({action:Dt.SKIP,lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:Et.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();s.current(),e.current.updateState({action:Dt.START,index:Ir.number(b)?b:g,lifecycle:Je.INIT,positioned:!1,scrolling:!1,status:k?Et.RUNNING:Et.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[Et.FINISHED,Et.SKIPPED].includes(k)||e.current.updateState({action:Dt.STOP,index:g+(b?1:0),lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,status:Et.PAUSED,waiting:!1})}}},[e])}const Qce=new Set(["origin","positioned"]);function Zce(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return dr(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const o=n.current;if(n.current=s,!o)return;const a={};let l=!1;for(const c of Object.keys(s))s[c]!==o[c]&&!Qce.has(c)&&(a[c]={from:o[c],to:s[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||dr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function eue(e,t,n){const r=m.useRef(e),s=m.useRef(t);return r.current=e,s.current=t,m.useCallback((o,a,l)=>{var u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(u=r.current)==null||u.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Bo(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],o=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(o):s===r&&o!==r},previous:t}}function tue(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:c}=e,{action:u,index:p,lifecycle:f,positioned:d,scrolling:h,size:y,status:v}=a,b=f$(l)??null,g=m.useRef(null),k=m.useRef(o),x=m.useRef(a),_=m.useRef(s),S=m.useRef(l),N=m.useRef(b),P=m.useRef(n),R=m.useRef(null),z=m.useRef(null),E=m.useRef(null);k.current=o,x.current=a,_.current=s,S.current=l,N.current=b,P.current=n;const O=()=>{R.current&&(clearInterval(R.current),R.current=null),z.current=null,E.current&&(E.current.cancel(),E.current=null)};m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D}=Bo(x.current,_.current);(D("action",[Dt.NEXT,Dt.PREV,Dt.SKIP,Dt.CLOSE])||g.current===Dt.CLOSE&&u===Dt.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!_.current)return()=>{O()};const{hasChanged:D}=Bo(x.current,_.current),L=S.current;if(D("index")&&O(),v!==Et.RUNNING||!L||f!==Je.INIT)return()=>{O()};const{hasChangedTo:M}=Bo(x.current,_.current);M("status",Et.RUNNING)&&[Et.IDLE,Et.READY,Et.PAUSED].includes(_.current.status)&&r(ar.TOUR_START,L),c.current.cleanupPositionData();const{debug:V}=k.current;if(L.before&&!E.current){dr(V,`step:${p}`,"before()",L),E.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(ar.STEP_BEFORE_HOOK,L,{action:g.current??x.current.action});const B=()=>{E.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:Je.READY})},F=new AbortController,$=L.beforeTimeout;E.current={cancel:()=>F.abort()};const H=$?setTimeout(()=>{F.signal.aborted||(dr(V,`step:${p}`,"before()","timed out",`${$}ms`),F.abort(),t(L,"before_hook"),r(ar.ERROR,L,{error:new Error("Step before hook timed out")}),B())},$):null;L.before({...c.current.getState(),action:g.current??c.current.getState().action,step:L}).then(()=>{F.signal.aborted||(H&&clearTimeout(H),B())}).catch(A=>{F.signal.aborted||(H&&clearTimeout(H),t(L,"before_hook"),r(ar.ERROR,L,{error:A instanceof Error?A:new Error(String(A))}),B())})}else if(!E.current){R.current&&z.current!==L.target&&O();const B=Ms(L.target);if(B&&ih(B))O(),c.current.updateState({action:g.current??Dt.UPDATE,lifecycle:Je.READY,waiting:!1});else if(L.targetWaitTimeout===0)c.current.updateState({action:g.current??Dt.UPDATE,lifecycle:Je.READY,waiting:!1});else if(!R.current){const{targetWaitTimeout:F}=L,$=Date.now();z.current=L.target,dr(V,`step:${p}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),R.current=setInterval(()=>{const H=Ms(L.target),A=Date.now()-$,Q=A>=F;(H&&ih(H)||Q)&&(dr(V,`step:${p}`,"polling",H&&ih(H)?"found":"timed out",`${A}ms`),O(),c.current.updateState({action:g.current??Dt.UPDATE,lifecycle:Je.READY,waiting:!1}))},100)}}return()=>{O()}},[t,r,p,f,v,c]),m.useEffect(()=>{if(!_.current)return;const{hasChanged:D,hasChangedTo:L,previous:M}=Bo(x.current,_.current),V=S.current;if(!V)return;const B=Ms(V.target),F=!!B;if(F&&ih(B)){if(L("lifecycle",Je.READY)&&M.lifecycle===Je.INIT&&r(ar.STEP_BEFORE,V,{action:g.current??x.current.action}),L("lifecycle",Je.READY)){const $=x.current,H=Gce(V,$,k.current.continuous)?Je.TOOLTIP:Je.BEACON,A=Ms(V.scrollTarget??V.spotlightTarget??V.target),Q=yA({isFirstStep:$.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:V,target:A,targetLifecycle:H}),K=H===Je.TOOLTIP?Je.TOOLTIP_BEFORE:Je.BEACON_BEFORE;dr(k.current.debug,`step:${p}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:Dt.UPDATE,lifecycle:K,scrolling:Q})}}else if(x.current.status===Et.RUNNING&&f!==Je.INIT&&f!==Je.COMPLETE&&D("lifecycle")){dr(k.current.debug,`step:${p}`,F?"Target not visible":"Target not mounted",V),t(V,"target_not_found"),r(ar.TARGET_NOT_FOUND,V);const $=x.current;$.controlled||c.current.updateState({action:Dt.UPDATE,index:$.index+($.action===Dt.PREV?-1:1),lifecycle:Je.INIT})}},[t,r,p,f,c]),m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D,previous:L}=Bo(x.current,_.current),M=S.current,V=N.current;if(M&&D("lifecycle",Je.TOOLTIP_BEFORE)&&L.lifecycle===Je.BEACON){const $=Ms(M.scrollTarget??M.spotlightTarget??M.target);if(yA({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:$,targetLifecycle:Je.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const B=f===Je.BEACON_BEFORE||f===Je.TOOLTIP_BEFORE;if(M&&B&&!h){const $=f===Je.TOOLTIP_BEFORE?Je.TOOLTIP:Je.BEACON;c.current.updateState({action:Dt.UPDATE,lifecycle:$})}M&&D("lifecycle",Je.BEACON)&&r(ar.BEACON,M),M&&D("lifecycle",Je.TOOLTIP)&&r(ar.TOOLTIP,M);const F=x.current;if((F.status===Et.RUNNING||F.controlled&&F.status===Et.PAUSED&&M)&&V&&D("lifecycle",Je.COMPLETE)&&L.lifecycle===Je.TOOLTIP&&(r(ar.STEP_AFTER,V,{action:g.current??Dt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle}),V.after)){r(ar.STEP_AFTER_HOOK,V,{action:g.current??Dt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle});try{V.after({...c.current.getState(),action:g.current??Dt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle,step:V})}catch{}}},[r,f,d,h,c]),m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D,previous:L}=Bo(x.current,_.current),M=S.current,V=N.current;y&&!M&&f===Je.INIT&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.COMPLETE,status:Et.FINISHED}),!x.current.controlled&&v===Et.RUNNING&&D("lifecycle",Je.COMPLETE)&&p<y&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.INIT}),D("lifecycle",Je.COMPLETE)&&p>=y&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.COMPLETE,status:Et.FINISHED});const B=M??V??Jv(k.current,k.current.steps[p-1]);if(B&&D("status",[Et.FINISHED,Et.SKIPPED])){let F;M?F=p:V?F=L.index??p:F=p-1,r(ar.TOUR_END,B,{index:F}),x.current.controlled||P.current.reset(),g.current=null}M&&D("action",Dt.STOP)&&(g.current=null,r(ar.TOUR_STATUS,M)),M&&D("action",Dt.RESET)&&(r(ar.TOUR_STATUS,M),g.current=null)},[u,r,p,f,y,v,c])}function nue({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,p=m.useRef(void 0),f=m.useRef(r),d=m.useRef(e);f.current=r,d.current=e,m.useEffect(()=>{const h=p.current;if(p.current=n,!h||n===h)return;const{hasChanged:y}=Bo(n,h);if(Fv(h.steps,u)||(D$(u,o)?s.current.setSteps(u):(dr(o,"tour","Steps are not valid",u),t(ar.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),y("run"))l?s.current.getState().size&&d.current.start(c??a):d.current.stop();else if(Ir.number(c)&&y("stepIndex")){const v=Ir.number(h.stepIndex)&&h.stepIndex<c?Dt.NEXT:Dt.PREV;[Et.FINISHED,Et.SKIPPED].includes(f.current.status)||s.current.updateState({action:v,index:c,lifecycle:Je.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,s])}function rue(e,t){var l,c,u,p;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===Je.BEACON_BEFORE&&(n!=null&&n.placement)){const f=sue(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Je.TOOLTIP_BEFORE){const{placement:f}=o;if(f==="top"){const d=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+h;a-=d+y}else if(f==="left"||f==="right"){const d=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((p=Ms(o.target))==null?void 0:p.getBoundingClientRect().height)??0,y=s+o.spotlightPadding.top+h/2-d/2;y<s&&(a-=s-y)}}return Math.max(0,a)}function sue(e){var n;const t=(n=e.middlewareData)==null?void 0:n.offset;return t?["left","right"].some(r=>e.placement.startsWith(r))?t.x:t.y:0}function iue({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:p}=r,f=m.useRef(null),d=m.useRef(r),h=m.useRef(t),y=m.useRef(n),v=m.useRef(s);d.current=r,h.current=t,y.current=n,v.current=s,m.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),m.useEffect(()=>{var S;if(!h.current||!v.current)return;const{hasChangedTo:b}=Bo(d.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,_=l===Je.BEACON_BEFORE||l===Je.TOOLTIP_BEFORE;if(p===Et.RUNNING&&_&&u&&b("positioned",!0)){const N=Ms(g.scrollTarget??g.spotlightTarget??g.target),P=o.current.getPositionData("beacon"),R=lu(N),z=R?!R.isSameNode(Qr()):!1;(S=f.current)==null||S.call(f),(async()=>{if(z&&!cu(R)){const F=Qr(),$=Bce(R),H={initial:F.scrollTop,target:$,element:F,duration:x};e(ar.SCROLL_START,g,{scroll:H});const{cancel:A,promise:Q}=wA($,{element:F,duration:x});f.current=A,await Q,e(ar.SCROLL_END,g,{scroll:H})}const O=Math.floor(Wce(N,g.scrollOffset))||0,D=z?O:rue(O,{beaconPosition:P,lifecycle:l,scrollOffset:g.scrollOffset,step:g});dr(k,`step:${a}`,"scroll",z?"custom":"document",`${O} → ${D}`);const L=R,M={initial:L.scrollTop,target:D,element:L,duration:x};e(ar.SCROLL_START,g,{scroll:M});const{cancel:V,promise:B}=wA(D,{element:L,duration:x});f.current=V,await B,e(ar.SCROLL_END,g,{scroll:M}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,p,o])}function oue(e){const t=Wae(()=>Oce(Mce,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=m.useRef(Jce(t)),u=fR.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[p,f]=m.useState([]),d=m.useCallback((S,N)=>{f(P=>[...P,{reason:N,step:S}])},[]),h=m.useCallback(()=>{f([])},[]);Zce(c,n);const y=Xce(c,n,h),v=eue(s,y,c),{index:b,size:g,status:k}=u,x=f$(u),_=m.useMemo(()=>Jv(t,l[b]),[b,t,l]);return Hae(()=>{o&&g&&D$(l,n)&&y.start(a??r)}),Bae(()=>{o&&g&&k===Et.IDLE&&c.current.updateState({status:Et.READY})},[o,g,k]),nue({controls:y,emitEvent:v,props:t,state:u,store:c}),tue({addFailure:d,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),iue({emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),{controls:y,failures:p,mergedProps:t,state:u,step:_,store:c}}function aue(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Ir.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=$ce,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const lue={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function cue({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return wf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
536
- @keyframes joyride-loader-spin {
537
- to { transform: rotate(360deg); }
538
- }
539
- `)),document.head.appendChild(c),()=>{const u=document.getElementById("joyride-loader-animation");u!=null&&u.parentNode&&u.parentNode.removeChild(u)}},[r,e]),n===null)return null;const{height:s,width:o,...a}=t.styles.loader;let l;if(n){const c=n;l=pt.createElement(c,{step:t})}else l=pt.createElement("div",{style:{...lue,height:s,width:o,borderTopColor:t.primaryColor}});return pt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const uue={height:0,isFixed:!1,left:0,top:0,width:0};function ed(e,t){const n=Ms(e);if(!n)return uue;const r=Yv(n),s=cu(n),o=zce(n,t.top,s);return{height:Math.round(((r==null?void 0:r.height)??0)+t.top+t.bottom),isFixed:s,left:Math.round(((r==null?void 0:r.left)??0)-t.left),top:o,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function due(e,t,n){const[r,s]=m.useState(()=>ed(e,t)),o=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),u=m.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(f=>{const d=ed(e,t);return f.top===d.top&&f.left===d.left&&f.width===d.width&&f.height===d.height&&f.isFixed===d.isFixed?f:d})},100)},[e,t]);m.useEffect(()=>{let f=null;const d=y=>{a.current=lu(y,!0),a.current&&a.current.addEventListener("scroll",u,{passive:!0}),window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(u),c.current.observe(y)),s(ed(e,t))},h=Ms(e);return h?d(h):(f=new MutationObserver(()=>{const y=Ms(e);y&&(f==null||f.disconnect(),f=null,d(y))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var y;f==null||f.disconnect(),a.current&&a.current.removeEventListener("scroll",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(y=c.current)==null||y.disconnect(),clearTimeout(o.current)}},[e,t,u]),m.useEffect(()=>{l.current&&!n&&s(ed(e,t)),l.current=n},[n,e,t]);let p=r;return l.current&&!n&&(p=ed(e,t)),p}function fue(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function bA(e,t,n,r,s){if(n<=0||r<=0)return"";const o=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+o} ${t}`;return a+=`H${e+n-o}`,a+=`A${o} ${o} 0 0 1 ${e+n} ${t+o}`,a+=`V${t+r-o}`,a+=`A${o} ${o} 0 0 1 ${e+n-o} ${t+r}`,a+=`H${e+o}`,a+=`A${o} ${o} 0 0 1 ${e} ${t+r-o}`,a+=`V${t+o}`,a+=`A${o} ${o} 0 0 1 ${e+o} ${t}Z`,a}const pue=[Je.BEACON_BEFORE,Je.BEACON];function hue(e){var B,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:p,spotlightRadius:f,spotlightTarget:d,styles:h,target:y,waiting:v}=e,b=Vae(),g=due(d??y,p,u||v),k=m.useRef(null),x=(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE)&&l!=="center",[_,S]=m.useState(!1),N=c?(B=k.current)==null?void 0:B.offsetParent:null,P=(N==null?void 0:N.clientWidth)??b.width,R=(N==null?void 0:N.clientHeight)??Fce()??b.height,z=((F=h.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",E=m.useMemo(()=>{const{backgroundColor:$,mixBlendMode:H,...A}=h.overlay;return{height:R,pointerEvents:"none",...A}},[R,h.overlay]),O=x&&!u&&!v;m.useEffect(()=>{O?requestAnimationFrame(()=>S(!0)):S(!1)},[O]);const D=n&&pue.includes(s),L=!n&&s!==Je.TOOLTIP;if(r||!v&&(D||L))return null;let M="";if(O)if(c&&N){const $=Ms(d??y);if($){const H=gA($),A=gA(N);M=bA(H.left-A.left-p.left,H.top-A.top-p.top,$.offsetWidth+p.left+p.right,$.offsetHeight+p.top+p.bottom,f)}}else M=bA(g.left,g.top,g.width,g.height,f);const V=fue(P,R,M);return pt.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:E},pt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:R,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:P}},pt.createElement("path",{d:V,fill:z,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&pt.createElement("path",{d:M,fill:z,style:{opacity:_?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&pt.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function F$(e){const{children:t,element:n}=e;return n?lr.createPortal(t,n):null}const mue='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function gue(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return wf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(mue)],{shiftKey:l}=o;if(!a.length)return;o.preventDefault();let c=document.activeElement?a.indexOf(document.activeElement):0;c===-1||!l&&c+1===a.length?c=0:l&&c===0?c=a.length-1:c+=l?-1:1,a[c].focus()};e.addEventListener("keydown",r,!1);let s;{const o=e.querySelector(t);o&&(s=setTimeout(()=>{o.focus({preventScroll:!0})},100))}return()=>{var o;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(o=n.current)==null||o.focus({preventScroll:!0})}},[e,t])}function oo(e,t,n){const[r]=e.split("-");switch(r){case"top":case"bottom":return{width:t,height:n};case"left":case"right":return{width:n,height:t};default:return null}}function yue(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...oo(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...oo(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...oo(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...oo(e,t,n)};default:return null}}function wue(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...oo(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...oo(e,r,n)};case"left":return{right:-n,top:t.y??0,...oo(e,r,n)};case"right":return{left:-n,top:t.y??0,...oo(e,r,n)};default:return{}}}function xue({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!oo(r,n,o))return null;c=pt.createElement("span",{style:{flexShrink:0}},pt.createElement(l,{base:n,placement:r,size:o}))}else{const u=yue(r,n,o);if(!u)return null;c=pt.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},pt.createElement("polygon",{fill:"currentColor",points:u.points}))}return pt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...wue(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function bue(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:p,styles:f}=e,d=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return wf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
540
- @keyframes joyride-beacon-inner {
541
- 20% {
542
- opacity: 0.9;
543
- }
544
-
545
- 90% {
546
- opacity: 0.7;
547
- }
548
- }
549
-
550
- @keyframes joyride-beacon-outer {
551
- 0% {
552
- transform: scale(1);
553
- }
554
-
555
- 45% {
556
- opacity: 0.7;
557
- transform: scale(0.75);
558
- }
559
-
560
- 100% {
561
- opacity: 0.9;
562
- transform: scale(1);
563
- }
564
- }
565
- `)),document.head.appendChild(b);const g=setTimeout(()=>{Ir.domElement(d.current)&&c&&d.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[h,a,c]);const y=to(o.open);let v;if(t){const b=t;v=pt.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:p})}else v=pt.createElement("span",{style:f.beacon},pt.createElement("span",{style:f.beaconOuter}),pt.createElement("span",{style:f.beaconInner}));return pt.createElement("button",{ref:d,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function kue({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return pt.createElement("button",{style:o,type:"button",...t},pt.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof s=="number"?`${s}px`:s,xmlns:"http://www.w3.org/2000/svg"},pt.createElement("g",null,pt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function vue(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:p,styles:f,title:d}=l,h={};u.includes("primary")&&(h.primary=pt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=pt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=pt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&pt.createElement(kue,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":to(p),"aria-describedby":"joyride-tooltip-content"};return pt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},pt.createElement("div",{style:f.tooltipContainer},d&&pt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},d),pt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},p)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&pt.createElement("div",{style:f.tooltipFooter},pt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Sue(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Ni.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Ni.BUTTON_CLOSE):n.close(Ni.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Ni.BUTTON_PRIMARY);return}n.next(Ni.BUTTON_PRIMARY)},p=g=>{g.preventDefault(),n.skip(Ni.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:_,nextWithProgress:S,skip:N}=a.locale,P=to(g),R=to(k),z=to(x),E=to(_),O=to(N);let D=k,L=R;if(t){if(D=_,L=E,a.showProgress&&!s){const M=to(S,{step:r+1,steps:o});D=Vb(S,r+1,o),L=M}s&&(D=x,L=z)}return{backProps:{"aria-label":P,children:g,"data-action":"back",onClick:l,role:"button",title:P},closeProps:{"aria-label":R,children:k,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":L,children:D,"data-action":"primary",onClick:u,role:"button",title:L},skipProps:{"aria-label":O,children:N,"data-action":"skip",onClick:p,role:"button",title:O},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=pt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=pt.createElement(vue,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function jue(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Nue(e,t,n){var r,s;return e?[Ece()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Ace({crossAxis:!1,fallbackPlacements:jue(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function _ue(e){var H,A,Q,K,W;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:p,size:f,step:d,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=d.placement==="center",x=d.placement==="auto",_=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),S=m.useMemo(()=>$$(h)?lu(h):void 0,[h]),N=m.useMemo(()=>cu(h),[h]),P=m.useMemo(()=>S?{boundary:S,rootBoundary:"viewport"}:{},[S]),R=k||x?"bottom":d.placement,z=k?"fixed":((H=d.floatingOptions)==null?void 0:H.strategy)??(d.isFixed||N?"fixed":"absolute"),E=m.useMemo(()=>{var te,Z,G,ne;return k?[{name:"center",fn:({rects:re})=>({x:(window.innerWidth-re.floating.width)/2,y:(window.innerHeight-re.floating.height)/2})}]:[pA(({placement:re})=>{var ue;let se="right";re.startsWith("top")?se="top":re.startsWith("bottom")?se="bottom":re.startsWith("left")&&(se="left");const ee=d.spotlightTarget?0:d.spotlightPadding[se];return d.offset+ee+((ue=d.floatingOptions)!=null&&ue.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(te=d.floatingOptions)==null?void 0:te.hideArrow]),...Nue(x,d,R),Cce({padding:10,...P,...(Z=d.floatingOptions)==null?void 0:Z.shiftOptions}),...(G=d.floatingOptions)!=null&&G.hideArrow?[]:[Ice({element:v,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((ne=d.floatingOptions)==null?void 0:ne.middleware)??[]]},[k,d,x,R,P]),O=fA({...k?{elements:{reference:_}}:{},placement:R,strategy:z,middleware:E}),D=fA({strategy:z,placement:d.beaconPlacement??(x||k?"bottom":d.placement),middleware:m.useMemo(()=>{var te,Z;return[pA(((Z=(te=d.floatingOptions)==null?void 0:te.beaconOptions)==null?void 0:Z.offset)??-18)]},[(Q=(A=d.floatingOptions)==null?void 0:A.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:cA});g.current=O.middlewareData,b.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:te,reference:Z}=O.elements;if(!(!Z||!te||s!==Je.TOOLTIP))return cA(Z,te,O.update,(G=d.floatingOptions)==null?void 0:G.autoUpdate)},[s,O.update,(K=d.floatingOptions)==null?void 0:K.autoUpdate,d.target,O.elements]),m.useEffect(()=>{!k&&h&&O.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,O.refs]),m.useEffect(()=>{O.isPositioned&&c("tooltip",{placement:O.placement,x:O.x??0,y:O.y??0,middlewareData:g.current})},[c,O.isPositioned,O.placement,O.x,O.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const L=d.zIndex+100,M=m.useCallback(te=>{te.type==="mouseenter"&&d.beaconTrigger!=="hover"||y({lifecycle:Je.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,y]),V=m.useCallback(te=>{te&&(O.refs.setFloating(te),u(te))},[O.refs,u]),{arrow:B,floater:F}=d.styles;let $=null;if(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE){const te=mA({...F,...O.floatingStyles,zIndex:L,opacity:a&&O.isPositioned?1:0,...!a&&{transition:"none"}});$=pt.createElement("div",{ref:V,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:te},pt.createElement(Sue,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:d}),!k&&!((W=d.floatingOptions)!=null&&W.hideArrow)&&pt.createElement(xue,{arrowComponent:d.arrowComponent,arrowRef:v,base:d.arrowBase,placement:O.placement,position:O.middlewareData.arrow,size:d.arrowSize,styles:B}))}else(s===Je.BEACON||s===Je.BEACON_BEFORE)&&($=pt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:mA({...D.floatingStyles,zIndex:L})},pt.createElement(bue,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:d.locale,nonce:o,onInteract:M,shouldFocus:p,size:f,step:d,styles:d.styles})));return pt.createElement(F$,{element:l},$)}function Cue(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:p,updateState:f}=e,[d,h]=m.useState(null);gue(p.disableFocusTrap?null:d,"[data-action=primary]");const y=Ms(p.target),v=s===Je.TOOLTIP;return!O$(p)||!Ir.domElement(y)?null:pt.createElement(_ue,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:p,target:y,updateState:f})}function Aue({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,p=aue(c),{index:f,lifecycle:d,status:h}=n,y=h===Et.RUNNING,[v,b]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const S=N=>{!r||d!==Je.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Ni.KEYBOARD):e.close(Ni.KEYBOARD))};return document.body.addEventListener("keydown",S,{passive:!0}),()=>{document.body.removeEventListener("keydown",S)}},[e,y,d,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Ni.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Ni.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const _=n.action===Dt.START&&!r.skipBeacon&&r.placement!=="center";return pt.createElement(pt.Fragment,null,d!==Je.INIT&&pt.createElement(Cue,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),pt.createElement(F$,{element:p},pt.createElement(pt.Fragment,null,v&&pt.createElement(cue,{nonce:l,step:r}),!_&&pt.createElement(hue,{...r,continuous:o,lifecycle:d,onClickOverlay:x,portalElement:c?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Eue(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=oue(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Bm(s,"positioned"),[s]),step:o,Tour:Gv()?pt.createElement(Aue,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function Iue(e){const{Tour:t}=Eue(e);return t}function Pue(e){return Gv()?pt.createElement(Iue,e):null}function Rue(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function Tue(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Mue(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const ah="af:onboarding";function $ue({page:e,hasNodes:t=!1}){const{t:n}=Vr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?Rue(n):t?Tue(n):Mue(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(ah),p=u?JSON.parse(u):{};if(p.completed||p[e]){s(!1),a([]);return}localStorage.setItem(ah,JSON.stringify({...p,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=p=>{var y;const f=p.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(ah)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(ah,JSON.stringify(b)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:i.jsx(Pue,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const Lue="agentflow:recent-runs:v1",Oue="agentflow:recent-runs:poller",Due=3e3,Fue=8e3,zue=2e3,kA=5e3,Bue=16e3,vA=[1e4,3e4,6e4];function Wue(e){return vA[Math.min(Math.max(e-1,0),vA.length-1)]}function Hue(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Vue(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function Kue(){const{navigate:e,path:t}=rs(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),p=m.useRef(()=>{});m.useEffect(()=>{let _=!1,S=!1,N=!1,P=null,R=0,z=0,E=0,O=0,D=null,L=0,M=0;const V=Hue(),B=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(Lue):null,$=Ne=>{try{F==null||F.postMessage({...Ne,tabId:V,sentAt:Date.now()})}catch{}},H=()=>{const Ne=Date.now()-Bue;for(const[_e,He]of B)He<Ne&&B.delete(_e);l(1+B.size)},A=(Ne="presence")=>{$({type:Ne,visible:!document.hidden})},Q=Ne=>{if(!_&&(Array.isArray(Ne.runs)&&r(Ne.runs),Ne.syncHealth&&typeof Ne.syncHealth=="object")){const _e=Ne.syncHealth;L=Number(_e.failureCount)||0,M=Number(_e.lastSuccessAt)||0,u(_e)}},K=Ne=>{Q(Ne),$({type:"state",...Ne})},W=()=>{R&&(window.clearTimeout(R),R=0)},te=Ne=>{W(),!(_||!S||document.hidden)&&(R=window.setTimeout(()=>{R=0,Z()},Math.max(0,Ne)))},Z=async()=>{if(_||!S||document.hidden||D)return;const Ne=new AbortController;D=Ne;let _e=!1;const He=window.setTimeout(()=>{_e=!0,Ne.abort()},Fue);try{const ct=await fetch("/api/pipeline-recent-runs",{signal:Ne.signal});if(!ct.ok)throw new Error(`HTTP ${ct.status}`);const yt=await ct.json();if(_||!S||document.hidden)return;L=0,M=Date.now();const Re=Array.isArray(yt.runs)?yt.runs:[];K({runs:Re.filter(at=>at&&at.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),te(Due)}catch(ct){const yt=Ne.signal.aborted&&!_e;if(_||!S||document.hidden||yt)return;L+=1,K({syncHealth:{status:"delayed",failureCount:L,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ct==null?void 0:ct.message)||ct)}`}}),te(Wue(L))}finally{window.clearTimeout(He),D===Ne&&(D=null)}},G=()=>{W(),D&&(D.abort(),D=null)},ne=()=>{if(G(),P){const Ne=P;P=null,Ne()}S=!1},re=(Ne=zue)=>{z&&window.clearTimeout(z),!(_||document.hidden||S||N)&&(z=window.setTimeout(()=>{z=0,ee()},Ne))},se=()=>{_||document.hidden||S||(S=!0,te(0))},ee=async()=>{var Ne;if(!(_||document.hidden||S||N)){if(!((Ne=navigator.locks)!=null&&Ne.request)){se();return}N=!0;try{await navigator.locks.request(Oue,{mode:"exclusive",ifAvailable:!0},async _e=>{if(N=!1,!_e||_||document.hidden){re();return}S=!0,te(0),await new Promise(He=>{P=He}),P=null,S=!1})}catch{N=!1}finally{re()}}},ue=()=>{if(!_){if(S){L=0,te(0);return}$({type:"retry"}),re(0)}};p.current=ue,F&&(F.onmessage=Ne=>{const _e=Ne.data;if(!(!_e||_e.tabId===V)){if(_e.type==="hello"||_e.type==="presence"){B.set(_e.tabId,Date.now()),H(),_e.type==="hello"&&A();return}if(_e.type==="bye"){B.delete(_e.tabId),H(),re(0);return}if(_e.type==="state"){B.set(_e.tabId,Date.now()),H(),Q(_e);return}_e.type==="retry"&&S&&(L=0,te(0))}});const de=()=>{A(),document.hidden?ne():re(0)},pe=()=>{A("bye"),ne()},Me=()=>{A("hello"),re(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",pe),window.addEventListener("pageshow",Me),A("hello"),E=window.setInterval(A,kA),O=window.setInterval(H,kA),re(0),()=>{_=!0,p.current=()=>{},A("bye"),ne(),z&&window.clearTimeout(z),E&&window.clearInterval(E),O&&window.clearInterval(O),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",pe),window.removeEventListener("pageshow",Me),F==null||F.close()}},[]);const f=_=>{const S=new URLSearchParams({flowId:_.flowId,flowSource:_.flowSource||"workspace"});e(`/flow?${S.toString()}`),o(!1)},d=t==="/flow"?new URLSearchParams(window.location.search):null,h=(d==null?void 0:d.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(_=>!_)};return i.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[s&&i.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&i.jsxs("div",{className:"af-run-indicator__sync",children:[i.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),i.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&i.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",Vue(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:_=>{_.stopPropagation(),p.current()},children:"立即重试"})]}),n.map(_=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(_.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(_),title:`${_.flowId} · ${_.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:_.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:_.runId.slice(0,12)})]},`${_.flowId}:${_.runId}`))]}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const Ww="0.1.136",que=6e4,Uue=30*6e4;function Xc(e){return String(e||"").trim().replace(/^v/i,"")}function Gue(e,t){const n=Xc(e),r=Xc(t);return!!(n&&r&&n!==r)}function Yue(e,t){return`agentflow.app-version.snooze:${Xc(e)}:${Xc(t)}`}function Jue(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Xue(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const o=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const p=Xc(u.version);if(!Gue(Ww,p)){t(null);return}const f=Yue(Ww,p);if(Jue(f)>Date.now())return;t({clientVersion:Xc(Ww),serverVersion:p,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),que);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+Uue))}catch{}t(null)};return i.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),i.jsxs("div",{className:"af-app-version-notice__copy",children:[i.jsx("strong",{children:"AgentFlow 已更新"}),i.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),i.jsxs("div",{className:"af-app-version-notice__actions",children:[i.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),i.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function z$(e){return e==="/likee-context"||e==="/likee_context"}function Que(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function Zue(){const{navigate:e}=rs();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class ede extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function tde({authUser:e}){const{path:t}=rs();return t==="/projects"||t==="/"?i.jsx(Kl,{authUser:e}):t==="/nodes"?i.jsx(Kl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Kl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Kl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Kl,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(Eoe,{authUser:e}):t==="/workflows"?i.jsx(Boe,{}):t==="/workflow-report"?i.jsx(xae,{}):t==="/mcps"?i.jsx(yoe,{}):t==="/schedules"?i.jsx(koe,{}):t==="/node-studio"?i.jsx(Soe,{}):t==="/flow"?i.jsx(Zue,{}):t==="/workspace"?i.jsx(KM,{}):t.startsWith("/display")?i.jsx(GM,{}):t==="/settings"?i.jsx(toe,{authUser:e}):t==="/admin/usage"?i.jsx(coe,{authUser:e}):t==="/admin/teams"?i.jsx(uoe,{authUser:e}):t==="/feedback"?i.jsx(foe,{authUser:e}):z$(t)?i.jsx(u$,{}):i.jsx(Kl,{})}function nde({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,p]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),p(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),p(String(h.message||h))}};m.useEffect(()=>{f()},[]);const d=async h=>{h.preventDefault(),c(!0),p("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");s(""),a(""),window.location.replace(window.location.href);return}catch(y){p(String(y.message||y))}finally{c(!1)}};return t.loading?i.jsx("div",{className:"af-auth-screen",children:i.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):i.jsx("div",{className:"af-auth-screen",children:i.jsxs("form",{className:"af-auth-panel",onSubmit:d,autoComplete:"on",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow"}),i.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"用户名"}),i.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?i.jsx("p",{className:"af-auth-error",children:u}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function rde({authUser:e,onLogout:t}){const{path:n}=rs(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx($ue,{page:r?"flow":"projects"}):null,r?null:i.jsx(hF,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(tde,{authUser:e})}),i.jsx(Kue,{})]})}function sde(){return i.jsx(ede,{children:i.jsxs(YD,{children:[i.jsx(ide,{}),i.jsx(Xue,{})]})})}function ide(){const{path:e}=rs();return e.startsWith("/display")?i.jsx(GM,{}):z$(e)?i.jsx(u$,{}):Que(e)?i.jsx(KM,{}):i.jsx(nde,{children:({user:t,onLogout:n})=>i.jsx(rde,{authUser:t,onLogout:n})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const SA=document.querySelector('link[rel="icon"]');SA&&(SA.href=FI);Hw.createRoot(document.getElementById("root")).render(i.jsx(pt.StrictMode,{children:i.jsx(sde,{})}));