@fieldwangai/agentflow 0.1.133 → 0.1.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,420 @@
1
+ var m2=Object.defineProperty;var g2=(e,t,n)=>t in e?m2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Tn=(e,t,n)=>g2(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 _d=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function da(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bA={exports:{}},zm={},kA={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 hf=Symbol.for("react.element"),y2=Symbol.for("react.portal"),w2=Symbol.for("react.fragment"),x2=Symbol.for("react.strict_mode"),b2=Symbol.for("react.profiler"),k2=Symbol.for("react.provider"),v2=Symbol.for("react.context"),S2=Symbol.for("react.forward_ref"),j2=Symbol.for("react.suspense"),N2=Symbol.for("react.memo"),C2=Symbol.for("react.lazy"),tj=Symbol.iterator;function _2(e){return e===null||typeof e!="object"?null:(e=tj&&e[tj]||e["@@iterator"],typeof e=="function"?e:null)}var vA={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},SA=Object.assign,jA={};function Yc(e,t,n){this.props=e,this.context=t,this.refs=jA,this.updater=n||vA}Yc.prototype.isReactComponent={};Yc.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")};Yc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function NA(){}NA.prototype=Yc.prototype;function Wb(e,t,n){this.props=e,this.context=t,this.refs=jA,this.updater=n||vA}var Hb=Wb.prototype=new NA;Hb.constructor=Wb;SA(Hb,Yc.prototype);Hb.isPureReactComponent=!0;var nj=Array.isArray,CA=Object.prototype.hasOwnProperty,Vb={current:null},_A={key:!0,ref:!0,__self:!0,__source:!0};function AA(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)CA.call(t,r)&&!_A.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:hf,type:e,key:o,ref:a,props:s,_owner:Vb.current}}function A2(e,t){return{$$typeof:hf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Kb(e){return typeof e=="object"&&e!==null&&e.$$typeof===hf}function E2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var rj=/\/+/g;function gy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?E2(""+e.key):t.toString(36)}function oh(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 hf:case y2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+gy(a,0):r,nj(s)?(n="",e!=null&&(n=e.replace(rj,"$&/")+"/"),oh(s,t,n,"",function(u){return u})):s!=null&&(Kb(s)&&(s=A2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(rj,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",nj(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+gy(o,l);a+=oh(o,t,n,c,s)}else if(c=_2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+gy(o,l++),a+=oh(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 fp(e,t,n){if(e==null)return e;var r=[],s=0;return oh(e,r,"","",function(o){return t.call(n,o,s++)}),r}function I2(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},ah={transition:null},P2={ReactCurrentDispatcher:Wr,ReactCurrentBatchConfig:ah,ReactCurrentOwner:Vb};function EA(){throw Error("act(...) is not supported in production builds of React.")}Mt.Children={map:fp,forEach:function(e,t,n){fp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return fp(e,function(){t++}),t},toArray:function(e){return fp(e,function(t){return t})||[]},only:function(e){if(!Kb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Mt.Component=Yc;Mt.Fragment=w2;Mt.Profiler=b2;Mt.PureComponent=Wb;Mt.StrictMode=x2;Mt.Suspense=j2;Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=P2;Mt.act=EA;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=SA({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Vb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)CA.call(t,c)&&!_A.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:hf,type:e.type,key:s,ref:o,props:r,_owner:a}};Mt.createContext=function(e){return e={$$typeof:v2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:k2,_context:e},e.Consumer=e};Mt.createElement=AA;Mt.createFactory=function(e){var t=AA.bind(null,e);return t.type=e,t};Mt.createRef=function(){return{current:null}};Mt.forwardRef=function(e){return{$$typeof:S2,render:e}};Mt.isValidElement=Kb;Mt.lazy=function(e){return{$$typeof:C2,_payload:{_status:-1,_result:e},_init:I2}};Mt.memo=function(e,t){return{$$typeof:N2,type:e,compare:t===void 0?null:t}};Mt.startTransition=function(e){var t=ah.transition;ah.transition={};try{e()}finally{ah.transition=t}};Mt.unstable_act=EA;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";kA.exports=Mt;var h=kA.exports;const pt=da(h);/**
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 R2=h,T2=Symbol.for("react.element"),M2=Symbol.for("react.fragment"),$2=Object.prototype.hasOwnProperty,L2=R2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,O2={key:!0,ref:!0,__self:!0,__source:!0};function IA(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)$2.call(t,r)&&!O2.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:T2,type:e,key:o,ref:a,props:s,_owner:L2.current}}zm.Fragment=M2;zm.jsx=IA;zm.jsxs=IA;bA.exports=zm;var i=bA.exports,zw={},PA={exports:{}},ws={},RA={exports:{}},TA={};/**
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],Y=te+1,ne=$[Y];if(0>s(Z,A))Y<K&&0>s(ne,Z)?($[Q]=ne,$[Y]=A,Q=Y):($[Q]=Z,$[te]=A,Q=te);else if(Y<K&&0>s(ne,A))$[Q]=ne,$[Y]=A,Q=Y;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=[],d=1,f=null,p=3,m=!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 C($){if(v=!1,x($),!y)if(n(c)!==null)y=!0,B(S);else{var H=n(u);H!==null&&F(C,H.startTime-$)}}function S($,H){y=!1,v&&(v=!1,g(R),R=-1),m=!0;var A=p;try{for(x(H),f=n(c);f!==null&&(!(f.expirationTime>H)||$&&!O());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,p=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(C,te.startTime-H),W=!1}return W}finally{f=null,p=A,m=!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||m||(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 p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(p){case 1:case 2:case 3:var H=3;break;default:H=p}var A=p;p=H;try{return $()}finally{p=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=p;p=$;try{return H()}finally{p=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:d++,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(C,A-Q))):($.sortIndex=K,t(c,$),y||m||(y=!0,B(S))),$},e.unstable_shouldYield=O,e.unstable_wrapCallback=function($){var H=p;return function(){var A=p;p=H;try{return $.apply(this,arguments)}finally{p=A}}}})(TA);RA.exports=TA;var D2=RA.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 F2=h,gs=D2;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 MA=new Set,Ad={};function pl(e,t){Ec(e,t),Ec(e+"Capture",t)}function Ec(e,t){for(Ad[e]=t,e=0;e<t.length;e++)MA.add(t[e])}var co=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Bw=Object.prototype.hasOwnProperty,z2=/^[: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]*$/,sj={},ij={};function B2(e){return Bw.call(ij,e)?!0:Bw.call(sj,e)?!1:z2.test(e)?ij[e]=!0:(sj[e]=!0,!1)}function W2(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 H2(e,t,n,r){if(t===null||typeof t>"u"||W2(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 qb=/[\-:]([a-z])/g;function Ub(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(qb,Ub);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(qb,Ub);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(qb,Ub);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 Yb(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")&&(H2(t,n,s,r)&&(n=null),r||s===null?B2(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 wo=F2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,pp=Symbol.for("react.element"),Xl=Symbol.for("react.portal"),Ql=Symbol.for("react.fragment"),Gb=Symbol.for("react.strict_mode"),Ww=Symbol.for("react.profiler"),$A=Symbol.for("react.provider"),LA=Symbol.for("react.context"),Jb=Symbol.for("react.forward_ref"),Hw=Symbol.for("react.suspense"),Vw=Symbol.for("react.suspense_list"),Xb=Symbol.for("react.memo"),Lo=Symbol.for("react.lazy"),OA=Symbol.for("react.offscreen"),oj=Symbol.iterator;function Iu(e){return e===null||typeof e!="object"?null:(e=oj&&e[oj]||e["@@iterator"],typeof e=="function"?e:null)}var Pn=Object.assign,yy;function Ju(e){if(yy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);yy=t&&t[1]||""}return`
34
+ `+yy+e}var wy=!1;function xy(e,t){if(!e||wy)return"";wy=!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{wy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ju(e):""}function V2(e){switch(e.tag){case 5:return Ju(e.type);case 16:return Ju("Lazy");case 13:return Ju("Suspense");case 19:return Ju("SuspenseList");case 0:case 2:case 15:return e=xy(e.type,!1),e;case 11:return e=xy(e.type.render,!1),e;case 1:return e=xy(e.type,!0),e;default:return""}}function Kw(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 Ql:return"Fragment";case Xl:return"Portal";case Ww:return"Profiler";case Gb:return"StrictMode";case Hw:return"Suspense";case Vw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case LA:return(e.displayName||"Context")+".Consumer";case $A:return(e._context.displayName||"Context")+".Provider";case Jb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Xb:return t=e.displayName||null,t!==null?t:Kw(e.type)||"Memo";case Lo:t=e._payload,e=e._init;try{return Kw(e(t))}catch{}}return null}function K2(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 Kw(t);case 8:return t===Gb?"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 ra(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function DA(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function q2(e){var t=DA(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 hp(e){e._valueTracker||(e._valueTracker=q2(e))}function FA(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=DA(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Rh(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 qw(e,t){var n=t.checked;return Pn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function aj(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ra(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 zA(e,t){t=t.checked,t!=null&&Yb(e,"checked",t,!1)}function Uw(e,t){zA(e,t);var n=ra(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")?Yw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Yw(e,t.type,ra(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lj(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 Yw(e,t,n){(t!=="number"||Rh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Xu=Array.isArray;function mc(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=""+ra(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 Gw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ee(91));return Pn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function cj(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(Xu(n)){if(1<n.length)throw Error(Ee(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ra(n)}}function BA(e,t){var n=ra(t.value),r=ra(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 uj(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function WA(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 Jw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?WA(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var mp,HA=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(mp=mp||document.createElement("div"),mp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=mp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ed(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ld={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},U2=["Webkit","ms","Moz","O"];Object.keys(ld).forEach(function(e){U2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ld[t]=ld[e]})});function VA(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ld.hasOwnProperty(e)&&ld[e]?(""+t).trim():t+"px"}function KA(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=VA(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Y2=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 Xw(e,t){if(t){if(Y2[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 Qw(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 Zw=null;function Qb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ex=null,gc=null,yc=null;function dj(e){if(e=yf(e)){if(typeof ex!="function")throw Error(Ee(280));var t=e.stateNode;t&&(t=Km(t),ex(e.stateNode,e.type,t))}}function qA(e){gc?yc?yc.push(e):yc=[e]:gc=e}function UA(){if(gc){var e=gc,t=yc;if(yc=gc=null,dj(e),t)for(e=0;e<t.length;e++)dj(t[e])}}function YA(e,t){return e(t)}function GA(){}var by=!1;function JA(e,t,n){if(by)return e(t,n);by=!0;try{return YA(e,t,n)}finally{by=!1,(gc!==null||yc!==null)&&(GA(),UA())}}function Id(e,t){var n=e.stateNode;if(n===null)return null;var r=Km(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 tx=!1;if(co)try{var Pu={};Object.defineProperty(Pu,"passive",{get:function(){tx=!0}}),window.addEventListener("test",Pu,Pu),window.removeEventListener("test",Pu,Pu)}catch{tx=!1}function G2(e,t,n,r,s,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var cd=!1,Th=null,Mh=!1,nx=null,J2={onError:function(e){cd=!0,Th=e}};function X2(e,t,n,r,s,o,a,l,c){cd=!1,Th=null,G2.apply(J2,arguments)}function Q2(e,t,n,r,s,o,a,l,c){if(X2.apply(this,arguments),cd){if(cd){var u=Th;cd=!1,Th=null}else throw Error(Ee(198));Mh||(Mh=!0,nx=u)}}function hl(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 XA(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 fj(e){if(hl(e)!==e)throw Error(Ee(188))}function Z2(e){var t=e.alternate;if(!t){if(t=hl(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 fj(s),e;if(o===r)return fj(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 QA(e){return e=Z2(e),e!==null?ZA(e):null}function ZA(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=ZA(e);if(t!==null)return t;e=e.sibling}return null}var eE=gs.unstable_scheduleCallback,pj=gs.unstable_cancelCallback,eO=gs.unstable_shouldYield,tO=gs.unstable_requestPaint,Dn=gs.unstable_now,nO=gs.unstable_getCurrentPriorityLevel,Zb=gs.unstable_ImmediatePriority,tE=gs.unstable_UserBlockingPriority,$h=gs.unstable_NormalPriority,rO=gs.unstable_LowPriority,nE=gs.unstable_IdlePriority,Bm=null,Ii=null;function sO(e){if(Ii&&typeof Ii.onCommitFiberRoot=="function")try{Ii.onCommitFiberRoot(Bm,e,void 0,(e.current.flags&128)===128)}catch{}}var oi=Math.clz32?Math.clz32:aO,iO=Math.log,oO=Math.LN2;function aO(e){return e>>>=0,e===0?32:31-(iO(e)/oO|0)|0}var gp=64,yp=4194304;function Qu(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 Lh(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=Qu(l):(o&=a,o!==0&&(r=Qu(o)))}else a=n&~s,a!==0?r=Qu(a):o!==0&&(r=Qu(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-oi(t),s=1<<n,r|=e[n],t&=~s;return r}function lO(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 cO(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-oi(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=lO(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function rx(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function rE(){var e=gp;return gp<<=1,!(gp&4194240)&&(gp=64),e}function ky(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-oi(t),e[t]=n}function uO(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-oi(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function ek(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-oi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var rn=0;function sE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var iE,tk,oE,aE,lE,sx=!1,wp=[],Uo=null,Yo=null,Go=null,Pd=new Map,Rd=new Map,Fo=[],dO="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 hj(e,t){switch(e){case"focusin":case"focusout":Uo=null;break;case"dragenter":case"dragleave":Yo=null;break;case"mouseover":case"mouseout":Go=null;break;case"pointerover":case"pointerout":Pd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Rd.delete(t.pointerId)}}function Ru(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=yf(t),t!==null&&tk(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function fO(e,t,n,r,s){switch(t){case"focusin":return Uo=Ru(Uo,e,t,n,r,s),!0;case"dragenter":return Yo=Ru(Yo,e,t,n,r,s),!0;case"mouseover":return Go=Ru(Go,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return Pd.set(o,Ru(Pd.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,Rd.set(o,Ru(Rd.get(o)||null,e,t,n,r,s)),!0}return!1}function cE(e){var t=Oa(e.target);if(t!==null){var n=hl(t);if(n!==null){if(t=n.tag,t===13){if(t=XA(n),t!==null){e.blockedOn=t,lE(e.priority,function(){oE(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 lh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=ix(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Zw=r,n.target.dispatchEvent(r),Zw=null}else return t=yf(n),t!==null&&tk(t),e.blockedOn=n,!1;t.shift()}return!0}function mj(e,t,n){lh(e)&&n.delete(t)}function pO(){sx=!1,Uo!==null&&lh(Uo)&&(Uo=null),Yo!==null&&lh(Yo)&&(Yo=null),Go!==null&&lh(Go)&&(Go=null),Pd.forEach(mj),Rd.forEach(mj)}function Tu(e,t){e.blockedOn===t&&(e.blockedOn=null,sx||(sx=!0,gs.unstable_scheduleCallback(gs.unstable_NormalPriority,pO)))}function Td(e){function t(s){return Tu(s,e)}if(0<wp.length){Tu(wp[0],e);for(var n=1;n<wp.length;n++){var r=wp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Uo!==null&&Tu(Uo,e),Yo!==null&&Tu(Yo,e),Go!==null&&Tu(Go,e),Pd.forEach(t),Rd.forEach(t),n=0;n<Fo.length;n++)r=Fo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Fo.length&&(n=Fo[0],n.blockedOn===null);)cE(n),n.blockedOn===null&&Fo.shift()}var wc=wo.ReactCurrentBatchConfig,Oh=!0;function hO(e,t,n,r){var s=rn,o=wc.transition;wc.transition=null;try{rn=1,nk(e,t,n,r)}finally{rn=s,wc.transition=o}}function mO(e,t,n,r){var s=rn,o=wc.transition;wc.transition=null;try{rn=4,nk(e,t,n,r)}finally{rn=s,wc.transition=o}}function nk(e,t,n,r){if(Oh){var s=ix(e,t,n,r);if(s===null)Py(e,t,r,Dh,n),hj(e,r);else if(fO(s,e,t,n,r))r.stopPropagation();else if(hj(e,r),t&4&&-1<dO.indexOf(e)){for(;s!==null;){var o=yf(s);if(o!==null&&iE(o),o=ix(e,t,n,r),o===null&&Py(e,t,r,Dh,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else Py(e,t,r,null,n)}}var Dh=null;function ix(e,t,n,r){if(Dh=null,e=Qb(r),e=Oa(e),e!==null)if(t=hl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=XA(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 Dh=e,null}function uE(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(nO()){case Zb:return 1;case tE:return 4;case $h:case rO:return 16;case nE:return 536870912;default:return 16}default:return 16}}var Ho=null,rk=null,ch=null;function dE(){if(ch)return ch;var e,t=rk,n=t.length,r,s="value"in Ho?Ho.value:Ho.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 ch=s.slice(e,1<r?1-r:void 0)}function uh(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 xp(){return!0}function gj(){return!1}function xs(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)?xp:gj,this.isPropagationStopped=gj,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=xp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=xp)},persist:function(){},isPersistent:xp}),t}var Gc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sk=xs(Gc),gf=Pn({},Gc,{view:0,detail:0}),gO=xs(gf),vy,Sy,Mu,Wm=Pn({},gf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ik,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!==Mu&&(Mu&&e.type==="mousemove"?(vy=e.screenX-Mu.screenX,Sy=e.screenY-Mu.screenY):Sy=vy=0,Mu=e),vy)},movementY:function(e){return"movementY"in e?e.movementY:Sy}}),yj=xs(Wm),yO=Pn({},Wm,{dataTransfer:0}),wO=xs(yO),xO=Pn({},gf,{relatedTarget:0}),jy=xs(xO),bO=Pn({},Gc,{animationName:0,elapsedTime:0,pseudoElement:0}),kO=xs(bO),vO=Pn({},Gc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),SO=xs(vO),jO=Pn({},Gc,{data:0}),wj=xs(jO),NO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},CO={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"},_O={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function AO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=_O[e])?!!t[e]:!1}function ik(){return AO}var EO=Pn({},gf,{key:function(e){if(e.key){var t=NO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=uh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?CO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ik,charCode:function(e){return e.type==="keypress"?uh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?uh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),IO=xs(EO),PO=Pn({},Wm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xj=xs(PO),RO=Pn({},gf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ik}),TO=xs(RO),MO=Pn({},Gc,{propertyName:0,elapsedTime:0,pseudoElement:0}),$O=xs(MO),LO=Pn({},Wm,{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}),OO=xs(LO),DO=[9,13,27,32],ok=co&&"CompositionEvent"in window,ud=null;co&&"documentMode"in document&&(ud=document.documentMode);var FO=co&&"TextEvent"in window&&!ud,fE=co&&(!ok||ud&&8<ud&&11>=ud),bj=" ",kj=!1;function pE(e,t){switch(e){case"keyup":return DO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Zl=!1;function zO(e,t){switch(e){case"compositionend":return hE(t);case"keypress":return t.which!==32?null:(kj=!0,bj);case"textInput":return e=t.data,e===bj&&kj?null:e;default:return null}}function BO(e,t){if(Zl)return e==="compositionend"||!ok&&pE(e,t)?(e=dE(),ch=rk=Ho=null,Zl=!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 fE&&t.locale!=="ko"?null:t.data;default:return null}}var WO={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 vj(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!WO[e.type]:t==="textarea"}function mE(e,t,n,r){qA(r),t=Fh(t,"onChange"),0<t.length&&(n=new sk("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var dd=null,Md=null;function HO(e){CE(e,0)}function Hm(e){var t=nc(e);if(FA(t))return e}function VO(e,t){if(e==="change")return t}var gE=!1;if(co){var Ny;if(co){var Cy="oninput"in document;if(!Cy){var Sj=document.createElement("div");Sj.setAttribute("oninput","return;"),Cy=typeof Sj.oninput=="function"}Ny=Cy}else Ny=!1;gE=Ny&&(!document.documentMode||9<document.documentMode)}function jj(){dd&&(dd.detachEvent("onpropertychange",yE),Md=dd=null)}function yE(e){if(e.propertyName==="value"&&Hm(Md)){var t=[];mE(t,Md,e,Qb(e)),JA(HO,t)}}function KO(e,t,n){e==="focusin"?(jj(),dd=t,Md=n,dd.attachEvent("onpropertychange",yE)):e==="focusout"&&jj()}function qO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Hm(Md)}function UO(e,t){if(e==="click")return Hm(t)}function YO(e,t){if(e==="input"||e==="change")return Hm(t)}function GO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ci=typeof Object.is=="function"?Object.is:GO;function $d(e,t){if(ci(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(!Bw.call(t,s)||!ci(e[s],t[s]))return!1}return!0}function Nj(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Cj(e,t){var n=Nj(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=Nj(n)}}function wE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xE(){for(var e=window,t=Rh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Rh(e.document)}return t}function ak(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 JO(e){var t=xE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&wE(n.ownerDocument.documentElement,n)){if(r!==null&&ak(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=Cj(n,o);var a=Cj(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 XO=co&&"documentMode"in document&&11>=document.documentMode,ec=null,ox=null,fd=null,ax=!1;function _j(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ax||ec==null||ec!==Rh(r)||(r=ec,"selectionStart"in r&&ak(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}),fd&&$d(fd,r)||(fd=r,r=Fh(ox,"onSelect"),0<r.length&&(t=new sk("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ec)))}function bp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var tc={animationend:bp("Animation","AnimationEnd"),animationiteration:bp("Animation","AnimationIteration"),animationstart:bp("Animation","AnimationStart"),transitionend:bp("Transition","TransitionEnd")},_y={},bE={};co&&(bE=document.createElement("div").style,"AnimationEvent"in window||(delete tc.animationend.animation,delete tc.animationiteration.animation,delete tc.animationstart.animation),"TransitionEvent"in window||delete tc.transitionend.transition);function Vm(e){if(_y[e])return _y[e];if(!tc[e])return e;var t=tc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in bE)return _y[e]=t[n];return e}var kE=Vm("animationend"),vE=Vm("animationiteration"),SE=Vm("animationstart"),jE=Vm("transitionend"),NE=new Map,Aj="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 fa(e,t){NE.set(e,t),pl(t,[e])}for(var Ay=0;Ay<Aj.length;Ay++){var Ey=Aj[Ay],QO=Ey.toLowerCase(),ZO=Ey[0].toUpperCase()+Ey.slice(1);fa(QO,"on"+ZO)}fa(kE,"onAnimationEnd");fa(vE,"onAnimationIteration");fa(SE,"onAnimationStart");fa("dblclick","onDoubleClick");fa("focusin","onFocus");fa("focusout","onBlur");fa(jE,"onTransitionEnd");Ec("onMouseEnter",["mouseout","mouseover"]);Ec("onMouseLeave",["mouseout","mouseover"]);Ec("onPointerEnter",["pointerout","pointerover"]);Ec("onPointerLeave",["pointerout","pointerover"]);pl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));pl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));pl("onBeforeInput",["compositionend","keypress","textInput","paste"]);pl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));pl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));pl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Zu="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(" "),eD=new Set("cancel close invalid load scroll toggle".split(" ").concat(Zu));function Ej(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Q2(r,t,void 0,e),e.currentTarget=null}function CE(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;Ej(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;Ej(s,l,u),o=c}}}if(Mh)throw e=nx,Mh=!1,nx=null,e}function mn(e,t){var n=t[fx];n===void 0&&(n=t[fx]=new Set);var r=e+"__bubble";n.has(r)||(_E(t,e,2,!1),n.add(r))}function Iy(e,t,n){var r=0;t&&(r|=4),_E(n,e,r,t)}var kp="_reactListening"+Math.random().toString(36).slice(2);function Ld(e){if(!e[kp]){e[kp]=!0,MA.forEach(function(n){n!=="selectionchange"&&(eD.has(n)||Iy(n,!1,e),Iy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[kp]||(t[kp]=!0,Iy("selectionchange",!1,t))}}function _E(e,t,n,r){switch(uE(t)){case 1:var s=hO;break;case 4:s=mO;break;default:s=nk}n=s.bind(null,t,n,e),s=void 0,!tx||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 Py(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=Oa(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}JA(function(){var u=o,d=Qb(n),f=[];e:{var p=NE.get(e);if(p!==void 0){var m=sk,y=e;switch(e){case"keypress":if(uh(n)===0)break e;case"keydown":case"keyup":m=IO;break;case"focusin":y="focus",m=jy;break;case"focusout":y="blur",m=jy;break;case"beforeblur":case"afterblur":m=jy;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":m=yj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=wO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=TO;break;case kE:case vE:case SE:m=kO;break;case jE:m=$O;break;case"scroll":m=gO;break;case"wheel":m=OO;break;case"copy":case"cut":case"paste":m=SO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=xj}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?p!==null?p+"Capture":null:p;v=[];for(var k=u,x;k!==null;){x=k;var C=x.stateNode;if(x.tag===5&&C!==null&&(x=C,g!==null&&(C=Id(k,g),C!=null&&v.push(Od(k,C,x)))),b)break;k=k.return}0<v.length&&(p=new m(p,y,null,n,d),f.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==Zw&&(y=n.relatedTarget||n.fromElement)&&(Oa(y)||y[uo]))break e;if((m||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,m?(y=n.relatedTarget||n.toElement,m=u,y=y?Oa(y):null,y!==null&&(b=hl(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(m=null,y=u),m!==y)){if(v=yj,C="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=xj,C="onPointerLeave",g="onPointerEnter",k="pointer"),b=m==null?p:nc(m),x=y==null?p:nc(y),p=new v(C,k+"leave",m,n,d),p.target=b,p.relatedTarget=x,C=null,Oa(d)===u&&(v=new v(g,k+"enter",y,n,d),v.target=x,v.relatedTarget=b,C=v),b=C,m&&y)t:{for(v=m,g=y,k=0,x=v;x;x=Fl(x))k++;for(x=0,C=g;C;C=Fl(C))x++;for(;0<k-x;)v=Fl(v),k--;for(;0<x-k;)g=Fl(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Fl(v),g=Fl(g)}v=null}else v=null;m!==null&&Ij(f,p,m,v,!1),y!==null&&b!==null&&Ij(f,b,y,v,!0)}}e:{if(p=u?nc(u):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var S=VO;else if(vj(p))if(gE)S=YO;else{S=qO;var N=KO}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(S=UO);if(S&&(S=S(e,u))){mE(f,S,n,d);break e}N&&N(e,p,u),e==="focusout"&&(N=p._wrapperState)&&N.controlled&&p.type==="number"&&Yw(p,"number",p.value)}switch(N=u?nc(u):window,e){case"focusin":(vj(N)||N.contentEditable==="true")&&(ec=N,ox=u,fd=null);break;case"focusout":fd=ox=ec=null;break;case"mousedown":ax=!0;break;case"contextmenu":case"mouseup":case"dragend":ax=!1,_j(f,n,d);break;case"selectionchange":if(XO)break;case"keydown":case"keyup":_j(f,n,d)}var P;if(ok)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 Zl?pE(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(fE&&n.locale!=="ko"&&(Zl||R!=="onCompositionStart"?R==="onCompositionEnd"&&Zl&&(P=dE()):(Ho=d,rk="value"in Ho?Ho.value:Ho.textContent,Zl=!0)),N=Fh(u,R),0<N.length&&(R=new wj(R,e,null,n,d),f.push({event:R,listeners:N}),P?R.data=P:(P=hE(n),P!==null&&(R.data=P)))),(P=FO?zO(e,n):BO(e,n))&&(u=Fh(u,"onBeforeInput"),0<u.length&&(d=new wj("onBeforeInput","beforeinput",null,n,d),f.push({event:d,listeners:u}),d.data=P))}CE(f,t)})}function Od(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Fh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=Id(e,n),o!=null&&r.unshift(Od(e,o,s)),o=Id(e,t),o!=null&&r.push(Od(e,o,s))),e=e.return}return r}function Fl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Ij(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=Id(n,o),c!=null&&a.unshift(Od(n,c,l))):s||(c=Id(n,o),c!=null&&a.push(Od(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var tD=/\r\n?/g,nD=/\u0000|\uFFFD/g;function Pj(e){return(typeof e=="string"?e:""+e).replace(tD,`
38
+ `).replace(nD,"")}function vp(e,t,n){if(t=Pj(t),Pj(e)!==t&&n)throw Error(Ee(425))}function zh(){}var lx=null,cx=null;function ux(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 dx=typeof setTimeout=="function"?setTimeout:void 0,rD=typeof clearTimeout=="function"?clearTimeout:void 0,Rj=typeof Promise=="function"?Promise:void 0,sD=typeof queueMicrotask=="function"?queueMicrotask:typeof Rj<"u"?function(e){return Rj.resolve(null).then(e).catch(iD)}:dx;function iD(e){setTimeout(function(){throw e})}function Ry(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),Td(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Td(t)}function Jo(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 Tj(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 Jc=Math.random().toString(36).slice(2),ji="__reactFiber$"+Jc,Dd="__reactProps$"+Jc,uo="__reactContainer$"+Jc,fx="__reactEvents$"+Jc,oD="__reactListeners$"+Jc,aD="__reactHandles$"+Jc;function Oa(e){var t=e[ji];if(t)return t;for(var n=e.parentNode;n;){if(t=n[uo]||n[ji]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Tj(e);e!==null;){if(n=e[ji])return n;e=Tj(e)}return t}e=n,n=e.parentNode}return null}function yf(e){return e=e[ji]||e[uo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function nc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ee(33))}function Km(e){return e[Dd]||null}var px=[],rc=-1;function pa(e){return{current:e}}function yn(e){0>rc||(e.current=px[rc],px[rc]=null,rc--)}function cn(e,t){rc++,px[rc]=e.current,e.current=t}var sa={},Pr=pa(sa),Zr=pa(!1),Xa=sa;function Ic(e,t){var n=e.type.contextTypes;if(!n)return sa;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 Bh(){yn(Zr),yn(Pr)}function Mj(e,t,n){if(Pr.current!==sa)throw Error(Ee(168));cn(Pr,t),cn(Zr,n)}function AE(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,K2(e)||"Unknown",s));return Pn({},n,r)}function Wh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||sa,Xa=Pr.current,cn(Pr,e),cn(Zr,Zr.current),!0}function $j(e,t,n){var r=e.stateNode;if(!r)throw Error(Ee(169));n?(e=AE(e,t,Xa),r.__reactInternalMemoizedMergedChildContext=e,yn(Zr),yn(Pr),cn(Pr,e)):yn(Zr),cn(Zr,n)}var Qi=null,qm=!1,Ty=!1;function EE(e){Qi===null?Qi=[e]:Qi.push(e)}function lD(e){qm=!0,EE(e)}function ha(){if(!Ty&&Qi!==null){Ty=!0;var e=0,t=rn;try{var n=Qi;for(rn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Qi=null,qm=!1}catch(s){throw Qi!==null&&(Qi=Qi.slice(e+1)),eE(Zb,ha),s}finally{rn=t,Ty=!1}}return null}var sc=[],ic=0,Hh=null,Vh=0,Is=[],Ps=0,Qa=null,eo=1,to="";function Ia(e,t){sc[ic++]=Vh,sc[ic++]=Hh,Hh=e,Vh=t}function IE(e,t,n){Is[Ps++]=eo,Is[Ps++]=to,Is[Ps++]=Qa,Qa=e;var r=eo;e=to;var s=32-oi(r)-1;r&=~(1<<s),n+=1;var o=32-oi(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,eo=1<<32-oi(t)+s|n<<s|r,to=o+e}else eo=1<<o|n<<s|r,to=e}function lk(e){e.return!==null&&(Ia(e,1),IE(e,1,0))}function ck(e){for(;e===Hh;)Hh=sc[--ic],sc[ic]=null,Vh=sc[--ic],sc[ic]=null;for(;e===Qa;)Qa=Is[--Ps],Is[Ps]=null,to=Is[--Ps],Is[Ps]=null,eo=Is[--Ps],Is[Ps]=null}var hs=null,fs=null,xn=!1,ti=null;function PE(e,t){var n=Ms(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 Lj(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,hs=e,fs=Jo(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,hs=e,fs=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Qa!==null?{id:eo,overflow:to}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ms(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,hs=e,fs=null,!0):!1;default:return!1}}function hx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function mx(e){if(xn){var t=fs;if(t){var n=t;if(!Lj(e,t)){if(hx(e))throw Error(Ee(418));t=Jo(n.nextSibling);var r=hs;t&&Lj(e,t)?PE(r,n):(e.flags=e.flags&-4097|2,xn=!1,hs=e)}}else{if(hx(e))throw Error(Ee(418));e.flags=e.flags&-4097|2,xn=!1,hs=e}}}function Oj(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;hs=e}function Sp(e){if(e!==hs)return!1;if(!xn)return Oj(e),xn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ux(e.type,e.memoizedProps)),t&&(t=fs)){if(hx(e))throw RE(),Error(Ee(418));for(;t;)PE(e,t),t=Jo(t.nextSibling)}if(Oj(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){fs=Jo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}fs=null}}else fs=hs?Jo(e.stateNode.nextSibling):null;return!0}function RE(){for(var e=fs;e;)e=Jo(e.nextSibling)}function Pc(){fs=hs=null,xn=!1}function uk(e){ti===null?ti=[e]:ti.push(e)}var cD=wo.ReactCurrentBatchConfig;function $u(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 jp(e,t){throw e=Object.prototype.toString.call(t),Error(Ee(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Dj(e){var t=e._init;return t(e._payload)}function TE(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=ea(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,C){return k===null||k.tag!==6?(k=zy(x,g.mode,C),k.return=g,k):(k=s(k,x),k.return=g,k)}function c(g,k,x,C){var S=x.type;return S===Ql?d(g,k,x.props.children,C,x.key):k!==null&&(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Lo&&Dj(S)===k.type)?(C=s(k,x.props),C.ref=$u(g,k,x),C.return=g,C):(C=yh(x.type,x.key,x.props,null,g.mode,C),C.ref=$u(g,k,x),C.return=g,C)}function u(g,k,x,C){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=By(x,g.mode,C),k.return=g,k):(k=s(k,x.children||[]),k.return=g,k)}function d(g,k,x,C,S){return k===null||k.tag!==7?(k=Ka(x,g.mode,C,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=zy(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case pp:return x=yh(k.type,k.key,k.props,null,g.mode,x),x.ref=$u(g,null,k),x.return=g,x;case Xl:return k=By(k,g.mode,x),k.return=g,k;case Lo:var C=k._init;return f(g,C(k._payload),x)}if(Xu(k)||Iu(k))return k=Ka(k,g.mode,x,null),k.return=g,k;jp(g,k)}return null}function p(g,k,x,C){var S=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return S!==null?null:l(g,k,""+x,C);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case pp:return x.key===S?c(g,k,x,C):null;case Xl:return x.key===S?u(g,k,x,C):null;case Lo:return S=x._init,p(g,k,S(x._payload),C)}if(Xu(x)||Iu(x))return S!==null?null:d(g,k,x,C,null);jp(g,x)}return null}function m(g,k,x,C,S){if(typeof C=="string"&&C!==""||typeof C=="number")return g=g.get(x)||null,l(k,g,""+C,S);if(typeof C=="object"&&C!==null){switch(C.$$typeof){case pp:return g=g.get(C.key===null?x:C.key)||null,c(k,g,C,S);case Xl:return g=g.get(C.key===null?x:C.key)||null,u(k,g,C,S);case Lo:var N=C._init;return m(g,k,x,N(C._payload),S)}if(Xu(C)||Iu(C))return g=g.get(x)||null,d(k,g,C,S,null);jp(k,C)}return null}function y(g,k,x,C){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=p(g,P,x[R],C);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&&Ia(g,R),S;if(P===null){for(;R<x.length;R++)P=f(g,x[R],C),P!==null&&(k=o(P,k,R),N===null?S=P:N.sibling=P,N=P);return xn&&Ia(g,R),S}for(P=r(g,P);R<x.length;R++)z=m(P,g,R,x[R],C),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&&Ia(g,R),S}function v(g,k,x,C){var S=Iu(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=p(g,P,E.value,C);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&&Ia(g,R),S;if(P===null){for(;!E.done;R++,E=x.next())E=f(g,E.value,C),E!==null&&(k=o(E,k,R),N===null?S=E:N.sibling=E,N=E);return xn&&Ia(g,R),S}for(P=r(g,P);!E.done;R++,E=x.next())E=m(P,g,R,E.value,C),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&&Ia(g,R),S}function b(g,k,x,C){if(typeof x=="object"&&x!==null&&x.type===Ql&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case pp:e:{for(var S=x.key,N=k;N!==null;){if(N.key===S){if(S=x.type,S===Ql){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===Lo&&Dj(S)===N.type){n(g,N.sibling),k=s(N,x.props),k.ref=$u(g,N,x),k.return=g,g=k;break e}n(g,N);break}else t(g,N);N=N.sibling}x.type===Ql?(k=Ka(x.props.children,g.mode,C,x.key),k.return=g,g=k):(C=yh(x.type,x.key,x.props,null,g.mode,C),C.ref=$u(g,k,x),C.return=g,g=C)}return a(g);case Xl: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=By(x,g.mode,C),k.return=g,g=k}return a(g);case Lo:return N=x._init,b(g,k,N(x._payload),C)}if(Xu(x))return y(g,k,x,C);if(Iu(x))return v(g,k,x,C);jp(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=zy(x,g.mode,C),k.return=g,g=k),a(g)):n(g,k)}return b}var Rc=TE(!0),ME=TE(!1),Kh=pa(null),qh=null,oc=null,dk=null;function fk(){dk=oc=qh=null}function pk(e){var t=Kh.current;yn(Kh),e._currentValue=t}function gx(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 xc(e,t){qh=e,dk=oc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Jr=!0),e.firstContext=null)}function Ls(e){var t=e._currentValue;if(dk!==e)if(e={context:e,memoizedValue:t,next:null},oc===null){if(qh===null)throw Error(Ee(308));oc=e,qh.dependencies={lanes:0,firstContext:e}}else oc=oc.next=e;return t}var Da=null;function hk(e){Da===null?Da=[e]:Da.push(e)}function $E(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hk(t)):(n.next=s.next,s.next=n),t.interleaved=n,fo(e,r)}function fo(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 Oo=!1;function mk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function LE(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 io(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xo(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,fo(e,n)}return s=r.interleaved,s===null?(t.next=t,hk(r)):(t.next=s.next,s.next=t),r.interleaved=t,fo(e,n)}function dh(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,ek(e,n)}}function Fj(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 Uh(e,t,n,r){var s=e.updateQueue;Oo=!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 d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==a&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(o!==null){var f=s.baseState;a=0,d=u=c=null,l=o;do{var p=l.lane,m=l.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(p=t,m=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){f=y.call(m,f,p);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,p=typeof y=="function"?y.call(m,f,p):y,p==null)break e;f=Pn({},f,p);break e;case 2:Oo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else m={eventTime:m,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=m,c=f):d=d.next=m,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,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);el|=a,e.lanes=a,e.memoizedState=f}}function zj(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 wf={},Pi=pa(wf),Fd=pa(wf),zd=pa(wf);function Fa(e){if(e===wf)throw Error(Ee(174));return e}function gk(e,t){switch(cn(zd,t),cn(Fd,e),cn(Pi,wf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Jw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Jw(t,e)}yn(Pi),cn(Pi,t)}function Tc(){yn(Pi),yn(Fd),yn(zd)}function OE(e){Fa(zd.current);var t=Fa(Pi.current),n=Jw(t,e.type);t!==n&&(cn(Fd,e),cn(Pi,n))}function yk(e){Fd.current===e&&(yn(Pi),yn(Fd))}var An=pa(0);function Yh(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 My=[];function wk(){for(var e=0;e<My.length;e++)My[e]._workInProgressVersionPrimary=null;My.length=0}var fh=wo.ReactCurrentDispatcher,$y=wo.ReactCurrentBatchConfig,Za=0,In=null,Zn=null,cr=null,Gh=!1,pd=!1,Bd=0,uD=0;function Cr(){throw Error(Ee(321))}function xk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ci(e[n],t[n]))return!1;return!0}function bk(e,t,n,r,s,o){if(Za=o,In=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,fh.current=e===null||e.memoizedState===null?hD:mD,e=n(r,s),pd){o=0;do{if(pd=!1,Bd=0,25<=o)throw Error(Ee(301));o+=1,cr=Zn=null,t.updateQueue=null,fh.current=gD,e=n(r,s)}while(pd)}if(fh.current=Jh,t=Zn!==null&&Zn.next!==null,Za=0,cr=Zn=In=null,Gh=!1,t)throw Error(Ee(300));return e}function kk(){var e=Bd!==0;return Bd=0,e}function bi(){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 Os(){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 Wd(e,t){return typeof t=="function"?t(e):t}function Ly(e){var t=Os(),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 d=u.lane;if((Za&d)===d)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:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,In.lanes|=d,el|=d}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,ci(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,el|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Oy(e){var t=Os(),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);ci(o,t.memoizedState)||(Jr=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function DE(){}function FE(e,t){var n=In,r=Os(),s=t(),o=!ci(r.memoizedState,s);if(o&&(r.memoizedState=s,Jr=!0),r=r.queue,vk(WE.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||cr!==null&&cr.memoizedState.tag&1){if(n.flags|=2048,Hd(9,BE.bind(null,n,r,s,t),void 0,null),fr===null)throw Error(Ee(349));Za&30||zE(n,t,s)}return s}function zE(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 BE(e,t,n,r){t.value=n,t.getSnapshot=r,HE(t)&&VE(e)}function WE(e,t,n){return n(function(){HE(t)&&VE(e)})}function HE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ci(e,n)}catch{return!0}}function VE(e){var t=fo(e,1);t!==null&&ai(t,e,1,-1)}function Bj(e){var t=bi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Wd,lastRenderedState:e},t.queue=e,e=e.dispatch=pD.bind(null,In,e),[t.memoizedState,e]}function Hd(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 KE(){return Os().memoizedState}function ph(e,t,n,r){var s=bi();In.flags|=e,s.memoizedState=Hd(1|t,n,void 0,r===void 0?null:r)}function Um(e,t,n,r){var s=Os();r=r===void 0?null:r;var o=void 0;if(Zn!==null){var a=Zn.memoizedState;if(o=a.destroy,r!==null&&xk(r,a.deps)){s.memoizedState=Hd(t,n,o,r);return}}In.flags|=e,s.memoizedState=Hd(1|t,n,o,r)}function Wj(e,t){return ph(8390656,8,e,t)}function vk(e,t){return Um(2048,8,e,t)}function qE(e,t){return Um(4,2,e,t)}function UE(e,t){return Um(4,4,e,t)}function YE(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 GE(e,t,n){return n=n!=null?n.concat([e]):null,Um(4,4,YE.bind(null,t,e),n)}function Sk(){}function JE(e,t){var n=Os();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function XE(e,t){var n=Os();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&xk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function QE(e,t,n){return Za&21?(ci(n,t)||(n=rE(),In.lanes|=n,el|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Jr=!0),e.memoizedState=n)}function dD(e,t){var n=rn;rn=n!==0&&4>n?n:4,e(!0);var r=$y.transition;$y.transition={};try{e(!1),t()}finally{rn=n,$y.transition=r}}function ZE(){return Os().memoizedState}function fD(e,t,n){var r=Zo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},eI(e))tI(t,n);else if(n=$E(e,t,n,r),n!==null){var s=Br();ai(n,e,r,s),nI(n,t,r)}}function pD(e,t,n){var r=Zo(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(eI(e))tI(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,ci(l,a)){var c=t.interleaved;c===null?(s.next=s,hk(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=$E(e,t,s,r),n!==null&&(s=Br(),ai(n,e,r,s),nI(n,t,r))}}function eI(e){var t=e.alternate;return e===In||t!==null&&t===In}function tI(e,t){pd=Gh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function nI(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ek(e,n)}}var Jh={readContext:Ls,useCallback:Cr,useContext:Cr,useEffect:Cr,useImperativeHandle:Cr,useInsertionEffect:Cr,useLayoutEffect:Cr,useMemo:Cr,useReducer:Cr,useRef:Cr,useState:Cr,useDebugValue:Cr,useDeferredValue:Cr,useTransition:Cr,useMutableSource:Cr,useSyncExternalStore:Cr,useId:Cr,unstable_isNewReconciler:!1},hD={readContext:Ls,useCallback:function(e,t){return bi().memoizedState=[e,t===void 0?null:t],e},useContext:Ls,useEffect:Wj,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ph(4194308,4,YE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ph(4194308,4,e,t)},useInsertionEffect:function(e,t){return ph(4,2,e,t)},useMemo:function(e,t){var n=bi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bi();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=fD.bind(null,In,e),[r.memoizedState,e]},useRef:function(e){var t=bi();return e={current:e},t.memoizedState=e},useState:Bj,useDebugValue:Sk,useDeferredValue:function(e){return bi().memoizedState=e},useTransition:function(){var e=Bj(!1),t=e[0];return e=dD.bind(null,e[1]),bi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=In,s=bi();if(xn){if(n===void 0)throw Error(Ee(407));n=n()}else{if(n=t(),fr===null)throw Error(Ee(349));Za&30||zE(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Wj(WE.bind(null,r,o,e),[e]),r.flags|=2048,Hd(9,BE.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=bi(),t=fr.identifierPrefix;if(xn){var n=to,r=eo;n=(r&~(1<<32-oi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Bd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=uD++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},mD={readContext:Ls,useCallback:JE,useContext:Ls,useEffect:vk,useImperativeHandle:GE,useInsertionEffect:qE,useLayoutEffect:UE,useMemo:XE,useReducer:Ly,useRef:KE,useState:function(){return Ly(Wd)},useDebugValue:Sk,useDeferredValue:function(e){var t=Os();return QE(t,Zn.memoizedState,e)},useTransition:function(){var e=Ly(Wd)[0],t=Os().memoizedState;return[e,t]},useMutableSource:DE,useSyncExternalStore:FE,useId:ZE,unstable_isNewReconciler:!1},gD={readContext:Ls,useCallback:JE,useContext:Ls,useEffect:vk,useImperativeHandle:GE,useInsertionEffect:qE,useLayoutEffect:UE,useMemo:XE,useReducer:Oy,useRef:KE,useState:function(){return Oy(Wd)},useDebugValue:Sk,useDeferredValue:function(e){var t=Os();return Zn===null?t.memoizedState=e:QE(t,Zn.memoizedState,e)},useTransition:function(){var e=Oy(Wd)[0],t=Os().memoizedState;return[e,t]},useMutableSource:DE,useSyncExternalStore:FE,useId:ZE,unstable_isNewReconciler:!1};function Qs(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 yx(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 Ym={isMounted:function(e){return(e=e._reactInternals)?hl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Br(),s=Zo(e),o=io(r,s);o.payload=t,n!=null&&(o.callback=n),t=Xo(e,o,s),t!==null&&(ai(t,e,s,r),dh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Br(),s=Zo(e),o=io(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Xo(e,o,s),t!==null&&(ai(t,e,s,r),dh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Br(),r=Zo(e),s=io(n,r);s.tag=2,t!=null&&(s.callback=t),t=Xo(e,s,r),t!==null&&(ai(t,e,r,n),dh(t,e,r))}};function Hj(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?!$d(n,r)||!$d(s,o):!0}function rI(e,t,n){var r=!1,s=sa,o=t.contextType;return typeof o=="object"&&o!==null?o=Ls(o):(s=es(t)?Xa:Pr.current,r=t.contextTypes,o=(r=r!=null)?Ic(e,s):sa),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ym,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function Vj(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&&Ym.enqueueReplaceState(t,t.state,null)}function wx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},mk(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Ls(o):(o=es(t)?Xa:Pr.current,s.context=Ic(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(yx(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&&Ym.enqueueReplaceState(s,s.state,null),Uh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Mc(e,t){try{var n="",r=t;do n+=V2(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 Dy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function xx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var yD=typeof WeakMap=="function"?WeakMap:Map;function sI(e,t,n){n=io(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Qh||(Qh=!0,Ex=r),xx(e,t)},n}function iI(e,t,n){n=io(-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(){xx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){xx(e,t),typeof r!="function"&&(Qo===null?Qo=new Set([this]):Qo.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Kj(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new yD;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=PD.bind(null,e,t,n),t.then(e,e))}function qj(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 Uj(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=io(-1,1),t.tag=2,Xo(n,t,1))),n.lanes|=1),e)}var wD=wo.ReactCurrentOwner,Jr=!1;function zr(e,t,n,r){t.child=e===null?ME(t,null,n,r):Rc(t,e.child,n,r)}function Yj(e,t,n,r,s){n=n.render;var o=t.ref;return xc(t,s),r=bk(e,t,n,r,o,s),n=kk(),e!==null&&!Jr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,po(e,t,s)):(xn&&n&&lk(t),t.flags|=1,zr(e,t,r,s),t.child)}function Gj(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!Pk(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,oI(e,t,o,r,s)):(e=yh(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:$d,n(a,r)&&e.ref===t.ref)return po(e,t,s)}return t.flags|=1,e=ea(o,r),e.ref=t.ref,e.return=t,t.child=e}function oI(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if($d(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,po(e,t,s)}return bx(e,t,n,r,s)}function aI(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(lc,cs),cs|=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(lc,cs),cs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,cn(lc,cs),cs|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,cn(lc,cs),cs|=r;return zr(e,t,s,n),t.child}function lI(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function bx(e,t,n,r,s){var o=es(n)?Xa:Pr.current;return o=Ic(t,o),xc(t,s),n=bk(e,t,n,r,o,s),r=kk(),e!==null&&!Jr?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,po(e,t,s)):(xn&&r&&lk(t),t.flags|=1,zr(e,t,n,s),t.child)}function Jj(e,t,n,r,s){if(es(n)){var o=!0;Wh(t)}else o=!1;if(xc(t,s),t.stateNode===null)hh(e,t),rI(t,n,r),wx(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=Ls(u):(u=es(n)?Xa:Pr.current,u=Ic(t,u));var d=n.getDerivedStateFromProps,f=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&Vj(t,a,r,u),Oo=!1;var p=t.memoizedState;a.state=p,Uh(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Zr.current||Oo?(typeof d=="function"&&(yx(t,n,d,r),c=t.memoizedState),(l=Oo||Hj(t,n,l,r,p,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,LE(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Qs(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ls(c):(c=es(n)?Xa:Pr.current,c=Ic(t,c));var m=n.getDerivedStateFromProps;(d=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&Vj(t,a,r,c),Oo=!1,p=t.memoizedState,a.state=p,Uh(t,r,a,s);var y=t.memoizedState;l!==f||p!==y||Zr.current||Oo?(typeof m=="function"&&(yx(t,n,m,r),y=t.memoizedState),(u=Oo||Hj(t,n,u,r,p,y,c)||!1)?(d||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&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===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&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return kx(e,t,n,r,o,s)}function kx(e,t,n,r,s,o){lI(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&$j(t,n,!1),po(e,t,o);r=t.stateNode,wD.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Rc(t,e.child,null,o),t.child=Rc(t,null,l,o)):zr(e,t,l,o),t.memoizedState=r.state,s&&$j(t,n,!0),t.child}function cI(e){var t=e.stateNode;t.pendingContext?Mj(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Mj(e,t.context,!1),gk(e,t.containerInfo)}function Xj(e,t,n,r,s){return Pc(),uk(s),t.flags|=256,zr(e,t,n,r),t.child}var vx={dehydrated:null,treeContext:null,retryLane:0};function Sx(e){return{baseLanes:e,cachePool:null,transitions:null}}function uI(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 mx(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=Xm(a,r,0,null),e=Ka(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Sx(n),t.memoizedState=vx,e):jk(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return xD(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=ea(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=ea(l,o):(o=Ka(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?Sx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=vx,r}return o=e.child,e=o.sibling,r=ea(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 jk(e,t){return t=Xm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Np(e,t,n,r){return r!==null&&uk(r),Rc(t,e.child,null,n),e=jk(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function xD(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=Dy(Error(Ee(422))),Np(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Xm({mode:"visible",children:r.children},s,0,null),o=Ka(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Rc(t,e.child,null,a),t.child.memoizedState=Sx(a),t.memoizedState=vx,o);if(!(t.mode&1))return Np(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=Dy(o,r,void 0),Np(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,fo(e,s),ai(r,e,s,-1))}return Ik(),r=Dy(Error(Ee(421))),Np(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=RD.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,fs=Jo(s.nextSibling),hs=t,xn=!0,ti=null,e!==null&&(Is[Ps++]=eo,Is[Ps++]=to,Is[Ps++]=Qa,eo=e.id,to=e.overflow,Qa=t),t=jk(t,r.children),t.flags|=4096,t)}function Qj(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),gx(e.return,t,n)}function Fy(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 dI(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&&Qj(e,n,t);else if(e.tag===19)Qj(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&&Yh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Fy(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&&Yh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Fy(t,!0,n,null,o);break;case"together":Fy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function hh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function po(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),el|=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=ea(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ea(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function bD(e,t,n){switch(t.tag){case 3:cI(t),Pc();break;case 5:OE(t);break;case 1:es(t.type)&&Wh(t);break;case 4:gk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;cn(Kh,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?uI(e,t,n):(cn(An,An.current&1),e=po(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 dI(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,aI(e,t,n)}return po(e,t,n)}var fI,jx,pI,hI;fI=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}};jx=function(){};pI=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Fa(Pi.current);var o=null;switch(n){case"input":s=qw(e,s),r=qw(e,r),o=[];break;case"select":s=Pn({},s,{value:void 0}),r=Pn({},r,{value:void 0}),o=[];break;case"textarea":s=Gw(e,s),r=Gw(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=zh)}Xw(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"&&(Ad.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"&&(Ad.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)}};hI=function(e,t,n,r){n!==r&&(t.flags|=4)};function Lu(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 _r(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 kD(e,t,n){var r=t.pendingProps;switch(ck(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _r(t),null;case 1:return es(t.type)&&Bh(),_r(t),null;case 3:return r=t.stateNode,Tc(),yn(Zr),yn(Pr),wk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Sp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ti!==null&&(Rx(ti),ti=null))),jx(e,t),_r(t),null;case 5:yk(t);var s=Fa(zd.current);if(n=t.type,e!==null&&t.stateNode!=null)pI(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 _r(t),null}if(e=Fa(Pi.current),Sp(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[ji]=t,r[Dd]=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<Zu.length;s++)mn(Zu[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":aj(r,o),mn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},mn("invalid",r);break;case"textarea":cj(r,o),mn("invalid",r)}Xw(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&&vp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&vp(r.textContent,l,e),s=["children",""+l]):Ad.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&mn("scroll",r)}switch(n){case"input":hp(r),lj(r,o,!0);break;case"textarea":hp(r),uj(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=zh)}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=WA(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[ji]=t,e[Dd]=r,fI(e,t,!1,!1),t.stateNode=e;e:{switch(a=Qw(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<Zu.length;s++)mn(Zu[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":aj(e,r),s=qw(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":cj(e,r),s=Gw(e,r),mn("invalid",e);break;default:s=r}Xw(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?KA(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&HA(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Ed(e,c):typeof c=="number"&&Ed(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Ad.hasOwnProperty(o)?c!=null&&o==="onScroll"&&mn("scroll",e):c!=null&&Yb(e,o,c,a))}switch(n){case"input":hp(e),lj(e,r,!1);break;case"textarea":hp(e),uj(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ra(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?mc(e,!!r.multiple,o,!1):r.defaultValue!=null&&mc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=zh)}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 _r(t),null;case 6:if(e&&t.stateNode!=null)hI(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ee(166));if(n=Fa(zd.current),Fa(Pi.current),Sp(t)){if(r=t.stateNode,n=t.memoizedProps,r[ji]=t,(o=r.nodeValue!==n)&&(e=hs,e!==null))switch(e.tag){case 3:vp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&vp(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[ji]=t,t.stateNode=r}return _r(t),null;case 13:if(yn(An),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(xn&&fs!==null&&t.mode&1&&!(t.flags&128))RE(),Pc(),t.flags|=98560,o=!1;else if(o=Sp(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[ji]=t}else Pc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;_r(t),o=!1}else ti!==null&&(Rx(ti),ti=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):Ik())),t.updateQueue!==null&&(t.flags|=4),_r(t),null);case 4:return Tc(),jx(e,t),e===null&&Ld(t.stateNode.containerInfo),_r(t),null;case 10:return pk(t.type._context),_r(t),null;case 17:return es(t.type)&&Bh(),_r(t),null;case 19:if(yn(An),o=t.memoizedState,o===null)return _r(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Lu(o,!1);else{if(er!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Yh(e),a!==null){for(t.flags|=128,Lu(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()>$c&&(t.flags|=128,r=!0,Lu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Yh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Lu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!xn)return _r(t),null}else 2*Dn()-o.renderingStartTime>$c&&n!==1073741824&&(t.flags|=128,r=!0,Lu(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):(_r(t),null);case 22:case 23:return Ek(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?cs&1073741824&&(_r(t),t.subtreeFlags&6&&(t.flags|=8192)):_r(t),null;case 24:return null;case 25:return null}throw Error(Ee(156,t.tag))}function vD(e,t){switch(ck(t),t.tag){case 1:return es(t.type)&&Bh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Tc(),yn(Zr),yn(Pr),wk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return yk(t),null;case 13:if(yn(An),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ee(340));Pc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return yn(An),null;case 4:return Tc(),null;case 10:return pk(t.type._context),null;case 22:case 23:return Ek(),null;case 24:return null;default:return null}}var Cp=!1,Ar=!1,SD=typeof WeakSet=="function"?WeakSet:Set,Xe=null;function ac(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 Nx(e,t,n){try{n()}catch(r){Mn(e,t,r)}}var Zj=!1;function jD(e,t){if(lx=Oh,e=xE(),ak(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,d=0,f=e,p=null;t:for(;;){for(var m;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),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break t;if(p===n&&++u===s&&(l=a),p===o&&++d===r&&(c=a),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(cx={focusedElem:e,selectionRange:n},Oh=!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:Qs(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(C){Mn(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,Xe=e;break}Xe=t.return}return y=Zj,Zj=!1,y}function hd(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&&Nx(t,n,o)}s=s.next}while(s!==r)}}function Gm(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 Cx(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 mI(e){var t=e.alternate;t!==null&&(e.alternate=null,mI(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ji],delete t[Dd],delete t[fx],delete t[oD],delete t[aD])),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 gI(e){return e.tag===5||e.tag===3||e.tag===4}function eN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gI(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 _x(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=zh));else if(r!==4&&(e=e.child,e!==null))for(_x(e,t,n),e=e.sibling;e!==null;)_x(e,t,n),e=e.sibling}function Ax(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(Ax(e,t,n),e=e.sibling;e!==null;)Ax(e,t,n),e=e.sibling}var wr=null,Zs=!1;function Io(e,t,n){for(n=n.child;n!==null;)yI(e,t,n),n=n.sibling}function yI(e,t,n){if(Ii&&typeof Ii.onCommitFiberUnmount=="function")try{Ii.onCommitFiberUnmount(Bm,n)}catch{}switch(n.tag){case 5:Ar||ac(n,t);case 6:var r=wr,s=Zs;wr=null,Io(e,t,n),wr=r,Zs=s,wr!==null&&(Zs?(e=wr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):wr.removeChild(n.stateNode));break;case 18:wr!==null&&(Zs?(e=wr,n=n.stateNode,e.nodeType===8?Ry(e.parentNode,n):e.nodeType===1&&Ry(e,n),Td(e)):Ry(wr,n.stateNode));break;case 4:r=wr,s=Zs,wr=n.stateNode.containerInfo,Zs=!0,Io(e,t,n),wr=r,Zs=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)&&Nx(n,t,a),s=s.next}while(s!==r)}Io(e,t,n);break;case 1:if(!Ar&&(ac(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)}Io(e,t,n);break;case 21:Io(e,t,n);break;case 22:n.mode&1?(Ar=(r=Ar)||n.memoizedState!==null,Io(e,t,n),Ar=r):Io(e,t,n);break;default:Io(e,t,n)}}function tN(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new SD),t.forEach(function(r){var s=TD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Gs(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,Zs=!1;break e;case 3:wr=l.stateNode.containerInfo,Zs=!0;break e;case 4:wr=l.stateNode.containerInfo,Zs=!0;break e}l=l.return}if(wr===null)throw Error(Ee(160));yI(o,a,s),wr=null,Zs=!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;)wI(t,e),t=t.sibling}function wI(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Gs(t,e),yi(e),r&4){try{hd(3,e,e.return),Gm(3,e)}catch(v){Mn(e,e.return,v)}try{hd(5,e,e.return)}catch(v){Mn(e,e.return,v)}}break;case 1:Gs(t,e),yi(e),r&512&&n!==null&&ac(n,n.return);break;case 5:if(Gs(t,e),yi(e),r&512&&n!==null&&ac(n,n.return),e.flags&32){var s=e.stateNode;try{Ed(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&&zA(s,o),Qw(l,a);var u=Qw(l,o);for(a=0;a<c.length;a+=2){var d=c[a],f=c[a+1];d==="style"?KA(s,f):d==="dangerouslySetInnerHTML"?HA(s,f):d==="children"?Ed(s,f):Yb(s,d,f,u)}switch(l){case"input":Uw(s,o);break;case"textarea":BA(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m!=null?mc(s,!!o.multiple,m,!1):p!==!!o.multiple&&(o.defaultValue!=null?mc(s,!!o.multiple,o.defaultValue,!0):mc(s,!!o.multiple,o.multiple?[]:"",!1))}s[Dd]=o}catch(v){Mn(e,e.return,v)}}break;case 6:if(Gs(t,e),yi(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(Gs(t,e),yi(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Td(t.containerInfo)}catch(v){Mn(e,e.return,v)}break;case 4:Gs(t,e),yi(e);break;case 13:Gs(t,e),yi(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(_k=Dn())),r&4&&tN(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Ar=(u=Ar)||d,Gs(t,e),Ar=u):Gs(t,e),yi(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(Xe=e,d=e.child;d!==null;){for(f=Xe=d;Xe!==null;){switch(p=Xe,m=p.child,p.tag){case 0:case 11:case 14:case 15:hd(4,p,p.return);break;case 1:ac(p,p.return);var y=p.stateNode;if(typeof y.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Mn(r,n,v)}}break;case 5:ac(p,p.return);break;case 22:if(p.memoizedState!==null){rN(f);continue}}m!==null?(m.return=p,Xe=m):rN(f)}d=d.sibling}e:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=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=VA("display",a))}catch(v){Mn(e,e.return,v)}}}else if(f.tag===6){if(d===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;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Gs(t,e),yi(e),r&4&&tN(e);break;case 21:break;default:Gs(t,e),yi(e)}}function yi(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(gI(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&&(Ed(s,""),r.flags&=-33);var o=eN(e);Ax(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=eN(e);_x(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 ND(e,t,n){Xe=e,xI(e)}function xI(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||Cp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Ar;l=Cp;var u=Ar;if(Cp=a,(Ar=c)&&!u)for(Xe=s;Xe!==null;)a=Xe,c=a.child,a.tag===22&&a.memoizedState!==null?sN(s):c!==null?(c.return=a,Xe=c):sN(s);for(;o!==null;)Xe=o,xI(o),o=o.sibling;Xe=s,Cp=l,Ar=u}nN(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Xe=o):nN(e)}}function nN(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||Gm(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:Qs(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&zj(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}zj(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 d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&Td(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ee(163))}Ar||t.flags&512&&Cx(t)}catch(p){Mn(t,t.return,p)}}if(t===e){Xe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function rN(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 sN(e){for(;Xe!==null;){var t=Xe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Gm(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{Cx(t)}catch(c){Mn(t,o,c)}break;case 5:var a=t.return;try{Cx(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 CD=Math.ceil,Xh=wo.ReactCurrentDispatcher,Nk=wo.ReactCurrentOwner,$s=wo.ReactCurrentBatchConfig,qt=0,fr=null,Kn=null,xr=0,cs=0,lc=pa(0),er=0,Vd=null,el=0,Jm=0,Ck=0,md=null,Yr=null,_k=0,$c=1/0,Xi=null,Qh=!1,Ex=null,Qo=null,_p=!1,Vo=null,Zh=0,gd=0,Ix=null,mh=-1,gh=0;function Br(){return qt&6?Dn():mh!==-1?mh:mh=Dn()}function Zo(e){return e.mode&1?qt&2&&xr!==0?xr&-xr:cD.transition!==null?(gh===0&&(gh=rE()),gh):(e=rn,e!==0||(e=window.event,e=e===void 0?16:uE(e.type)),e):1}function ai(e,t,n,r){if(50<gd)throw gd=0,Ix=null,Error(Ee(185));mf(e,n,r),(!(qt&2)||e!==fr)&&(e===fr&&(!(qt&2)&&(Jm|=n),er===4&&zo(e,xr)),ts(e,r),n===1&&qt===0&&!(t.mode&1)&&($c=Dn()+500,qm&&ha()))}function ts(e,t){var n=e.callbackNode;cO(e,t);var r=Lh(e,e===fr?xr:0);if(r===0)n!==null&&pj(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&pj(n),t===1)e.tag===0?lD(iN.bind(null,e)):EE(iN.bind(null,e)),sD(function(){!(qt&6)&&ha()}),n=null;else{switch(sE(r)){case 1:n=Zb;break;case 4:n=tE;break;case 16:n=$h;break;case 536870912:n=nE;break;default:n=$h}n=_I(n,bI.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function bI(e,t){if(mh=-1,gh=0,qt&6)throw Error(Ee(327));var n=e.callbackNode;if(bc()&&e.callbackNode!==n)return null;var r=Lh(e,e===fr?xr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=em(e,r);else{t=r;var s=qt;qt|=2;var o=vI();(fr!==e||xr!==t)&&(Xi=null,$c=Dn()+500,Va(e,t));do try{ED();break}catch(l){kI(e,l)}while(!0);fk(),Xh.current=o,qt=s,Kn!==null?t=0:(fr=null,xr=0,t=er)}if(t!==0){if(t===2&&(s=rx(e),s!==0&&(r=s,t=Px(e,s))),t===1)throw n=Vd,Va(e,0),zo(e,r),ts(e,Dn()),n;if(t===6)zo(e,r);else{if(s=e.current.alternate,!(r&30)&&!_D(s)&&(t=em(e,r),t===2&&(o=rx(e),o!==0&&(r=o,t=Px(e,o))),t===1))throw n=Vd,Va(e,0),zo(e,r),ts(e,Dn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ee(345));case 2:Pa(e,Yr,Xi);break;case 3:if(zo(e,r),(r&130023424)===r&&(t=_k+500-Dn(),10<t)){if(Lh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Br(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=dx(Pa.bind(null,e,Yr,Xi),t);break}Pa(e,Yr,Xi);break;case 4:if(zo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-oi(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*CD(r/1960))-r,10<r){e.timeoutHandle=dx(Pa.bind(null,e,Yr,Xi),r);break}Pa(e,Yr,Xi);break;case 5:Pa(e,Yr,Xi);break;default:throw Error(Ee(329))}}}return ts(e,Dn()),e.callbackNode===n?bI.bind(null,e):null}function Px(e,t){var n=md;return e.current.memoizedState.isDehydrated&&(Va(e,t).flags|=256),e=em(e,t),e!==2&&(t=Yr,Yr=n,t!==null&&Rx(t)),e}function Rx(e){Yr===null?Yr=e:Yr.push.apply(Yr,e)}function _D(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(!ci(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 zo(e,t){for(t&=~Ck,t&=~Jm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-oi(t),r=1<<n;e[n]=-1,t&=~r}}function iN(e){if(qt&6)throw Error(Ee(327));bc();var t=Lh(e,0);if(!(t&1))return ts(e,Dn()),null;var n=em(e,t);if(e.tag!==0&&n===2){var r=rx(e);r!==0&&(t=r,n=Px(e,r))}if(n===1)throw n=Vd,Va(e,0),zo(e,t),ts(e,Dn()),n;if(n===6)throw Error(Ee(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Pa(e,Yr,Xi),ts(e,Dn()),null}function Ak(e,t){var n=qt;qt|=1;try{return e(t)}finally{qt=n,qt===0&&($c=Dn()+500,qm&&ha())}}function tl(e){Vo!==null&&Vo.tag===0&&!(qt&6)&&bc();var t=qt;qt|=1;var n=$s.transition,r=rn;try{if($s.transition=null,rn=1,e)return e()}finally{rn=r,$s.transition=n,qt=t,!(qt&6)&&ha()}}function Ek(){cs=lc.current,yn(lc)}function Va(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,rD(n)),Kn!==null)for(n=Kn.return;n!==null;){var r=n;switch(ck(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Bh();break;case 3:Tc(),yn(Zr),yn(Pr),wk();break;case 5:yk(r);break;case 4:Tc();break;case 13:yn(An);break;case 19:yn(An);break;case 10:pk(r.type._context);break;case 22:case 23:Ek()}n=n.return}if(fr=e,Kn=e=ea(e.current,null),xr=cs=t,er=0,Vd=null,Ck=Jm=el=0,Yr=md=null,Da!==null){for(t=0;t<Da.length;t++)if(n=Da[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}Da=null}return e}function kI(e,t){do{var n=Kn;try{if(fk(),fh.current=Jh,Gh){for(var r=In.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Gh=!1}if(Za=0,cr=Zn=In=null,pd=!1,Bd=0,Nk.current=null,n===null||n.return===null){er=1,Vd=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,d=l,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=qj(a);if(m!==null){m.flags&=-257,Uj(m,a,l,o,t),m.mode&1&&Kj(o,u,t),t=m,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)){Kj(o,u,t),Ik();break e}c=Error(Ee(426))}}else if(xn&&l.mode&1){var b=qj(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Uj(b,a,l,o,t),uk(Mc(c,l));break e}}o=c=Mc(c,l),er!==4&&(er=2),md===null?md=[o]:md.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=sI(o,c,t);Fj(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"&&(Qo===null||!Qo.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var C=iI(o,l,t);Fj(o,C);break e}}o=o.return}while(o!==null)}jI(n)}catch(S){t=S,Kn===n&&n!==null&&(Kn=n=n.return);continue}break}while(!0)}function vI(){var e=Xh.current;return Xh.current=Jh,e===null?Jh:e}function Ik(){(er===0||er===3||er===2)&&(er=4),fr===null||!(el&268435455)&&!(Jm&268435455)||zo(fr,xr)}function em(e,t){var n=qt;qt|=2;var r=vI();(fr!==e||xr!==t)&&(Xi=null,Va(e,t));do try{AD();break}catch(s){kI(e,s)}while(!0);if(fk(),qt=n,Xh.current=r,Kn!==null)throw Error(Ee(261));return fr=null,xr=0,er}function AD(){for(;Kn!==null;)SI(Kn)}function ED(){for(;Kn!==null&&!eO();)SI(Kn)}function SI(e){var t=CI(e.alternate,e,cs);e.memoizedProps=e.pendingProps,t===null?jI(e):Kn=t,Nk.current=null}function jI(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=vD(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=kD(n,t,cs),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 Pa(e,t,n){var r=rn,s=$s.transition;try{$s.transition=null,rn=1,ID(e,t,n,r)}finally{$s.transition=s,rn=r}return null}function ID(e,t,n,r){do bc();while(Vo!==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(uO(e,o),e===fr&&(Kn=fr=null,xr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||_p||(_p=!0,_I($h,function(){return bc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=$s.transition,$s.transition=null;var a=rn;rn=1;var l=qt;qt|=4,Nk.current=null,jD(e,n),wI(n,e),JO(cx),Oh=!!lx,cx=lx=null,e.current=n,ND(n),tO(),qt=l,rn=a,$s.transition=o}else e.current=n;if(_p&&(_p=!1,Vo=e,Zh=s),o=e.pendingLanes,o===0&&(Qo=null),sO(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(Qh)throw Qh=!1,e=Ex,Ex=null,e;return Zh&1&&e.tag!==0&&bc(),o=e.pendingLanes,o&1?e===Ix?gd++:(gd=0,Ix=e):gd=0,ha(),null}function bc(){if(Vo!==null){var e=sE(Zh),t=$s.transition,n=rn;try{if($s.transition=null,rn=16>e?16:e,Vo===null)var r=!1;else{if(e=Vo,Vo=null,Zh=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 d=Xe;switch(d.tag){case 0:case 11:case 15:hd(8,d,o)}var f=d.child;if(f!==null)f.return=d,Xe=f;else for(;Xe!==null;){d=Xe;var p=d.sibling,m=d.return;if(mI(d),d===u){Xe=null;break}if(p!==null){p.return=m,Xe=p;break}Xe=m}}}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:hd(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:Gm(9,l)}}catch(S){Mn(l,l.return,S)}if(l===a){Xe=null;break e}var C=l.sibling;if(C!==null){C.return=l.return,Xe=C;break e}Xe=l.return}}if(qt=s,ha(),Ii&&typeof Ii.onPostCommitFiberRoot=="function")try{Ii.onPostCommitFiberRoot(Bm,e)}catch{}r=!0}return r}finally{rn=n,$s.transition=t}}return!1}function oN(e,t,n){t=Mc(n,t),t=sI(e,t,1),e=Xo(e,t,1),t=Br(),e!==null&&(mf(e,1,t),ts(e,t))}function Mn(e,t,n){if(e.tag===3)oN(e,e,n);else for(;t!==null;){if(t.tag===3){oN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Qo===null||!Qo.has(r))){e=Mc(n,e),e=iI(t,e,1),t=Xo(t,e,1),e=Br(),t!==null&&(mf(t,1,e),ts(t,e));break}}t=t.return}}function PD(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()-_k?Va(e,0):Ck|=n),ts(e,t)}function NI(e,t){t===0&&(e.mode&1?(t=yp,yp<<=1,!(yp&130023424)&&(yp=4194304)):t=1);var n=Br();e=fo(e,t),e!==null&&(mf(e,t,n),ts(e,n))}function RD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),NI(e,n)}function TD(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),NI(e,n)}var CI;CI=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,bD(e,t,n);Jr=!!(e.flags&131072)}else Jr=!1,xn&&t.flags&1048576&&IE(t,Vh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;hh(e,t),e=t.pendingProps;var s=Ic(t,Pr.current);xc(t,n),s=bk(null,t,r,e,s,n);var o=kk();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,Wh(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mk(t),s.updater=Ym,t.stateNode=s,s._reactInternals=t,wx(t,r,e,n),t=kx(null,t,r,!0,o,n)):(t.tag=0,xn&&o&&lk(t),zr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(hh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=$D(r),e=Qs(r,e),s){case 0:t=bx(null,t,r,e,n);break e;case 1:t=Jj(null,t,r,e,n);break e;case 11:t=Yj(null,t,r,e,n);break e;case 14:t=Gj(null,t,r,Qs(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:Qs(r,s),bx(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Qs(r,s),Jj(e,t,r,s,n);case 3:e:{if(cI(t),e===null)throw Error(Ee(387));r=t.pendingProps,o=t.memoizedState,s=o.element,LE(e,t),Uh(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=Mc(Error(Ee(423)),t),t=Xj(e,t,r,n,s);break e}else if(r!==s){s=Mc(Error(Ee(424)),t),t=Xj(e,t,r,n,s);break e}else for(fs=Jo(t.stateNode.containerInfo.firstChild),hs=t,xn=!0,ti=null,n=ME(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pc(),r===s){t=po(e,t,n);break e}zr(e,t,r,n)}t=t.child}return t;case 5:return OE(t),e===null&&mx(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,ux(r,s)?a=null:o!==null&&ux(r,o)&&(t.flags|=32),lI(e,t),zr(e,t,a,n),t.child;case 6:return e===null&&mx(t),null;case 13:return uI(e,t,n);case 4:return gk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Rc(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:Qs(r,s),Yj(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(Kh,r._currentValue),r._currentValue=a,o!==null)if(ci(o.value,a)){if(o.children===s.children&&!Zr.current){t=po(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=io(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),gx(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),gx(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,xc(t,n),s=Ls(s),r=r(s),t.flags|=1,zr(e,t,r,n),t.child;case 14:return r=t.type,s=Qs(r,t.pendingProps),s=Qs(r.type,s),Gj(e,t,r,s,n);case 15:return oI(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Qs(r,s),hh(e,t),t.tag=1,es(r)?(e=!0,Wh(t)):e=!1,xc(t,n),rI(t,r,s),wx(t,r,s,n),kx(null,t,r,!0,e,n);case 19:return dI(e,t,n);case 22:return aI(e,t,n)}throw Error(Ee(156,t.tag))};function _I(e,t){return eE(e,t)}function MD(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 Ms(e,t,n,r){return new MD(e,t,n,r)}function Pk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $D(e){if(typeof e=="function")return Pk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Jb)return 11;if(e===Xb)return 14}return 2}function ea(e,t){var n=e.alternate;return n===null?(n=Ms(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 yh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")Pk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Ql:return Ka(n.children,s,o,t);case Gb:a=8,s|=8;break;case Ww:return e=Ms(12,n,t,s|2),e.elementType=Ww,e.lanes=o,e;case Hw:return e=Ms(13,n,t,s),e.elementType=Hw,e.lanes=o,e;case Vw:return e=Ms(19,n,t,s),e.elementType=Vw,e.lanes=o,e;case OA:return Xm(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case $A:a=10;break e;case LA:a=9;break e;case Jb:a=11;break e;case Xb:a=14;break e;case Lo:a=16,r=null;break e}throw Error(Ee(130,e==null?e:typeof e,""))}return t=Ms(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Ka(e,t,n,r){return e=Ms(7,e,r,t),e.lanes=n,e}function Xm(e,t,n,r){return e=Ms(22,e,r,t),e.elementType=OA,e.lanes=n,e.stateNode={isHidden:!1},e}function zy(e,t,n){return e=Ms(6,e,null,t),e.lanes=n,e}function By(e,t,n){return t=Ms(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function LD(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=ky(0),this.expirationTimes=ky(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ky(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Rk(e,t,n,r,s,o,a,l,c){return e=new LD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ms(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mk(o),e}function OD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Xl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function AI(e){if(!e)return sa;e=e._reactInternals;e:{if(hl(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 AE(e,n,t)}return t}function EI(e,t,n,r,s,o,a,l,c){return e=Rk(n,r,!0,e,s,o,a,l,c),e.context=AI(null),n=e.current,r=Br(),s=Zo(n),o=io(r,s),o.callback=t??null,Xo(n,o,s),e.current.lanes=s,mf(e,s,r),ts(e,r),e}function Qm(e,t,n,r){var s=t.current,o=Br(),a=Zo(s);return n=AI(n),t.context===null?t.context=n:t.pendingContext=n,t=io(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Xo(s,t,a),e!==null&&(ai(e,s,a,o),dh(e,s,a)),a}function tm(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 aN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Tk(e,t){aN(e,t),(e=e.alternate)&&aN(e,t)}function DD(){return null}var II=typeof reportError=="function"?reportError:function(e){console.error(e)};function Mk(e){this._internalRoot=e}Zm.prototype.render=Mk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ee(409));Qm(e,t,null,null)};Zm.prototype.unmount=Mk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;tl(function(){Qm(null,e,null,null)}),t[uo]=null}};function Zm(e){this._internalRoot=e}Zm.prototype.unstable_scheduleHydration=function(e){if(e){var t=aE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Fo.length&&t!==0&&t<Fo[n].priority;n++);Fo.splice(n,0,e),n===0&&cE(e)}};function $k(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function eg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function lN(){}function FD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=tm(a);o.call(u)}}var a=EI(t,r,e,0,null,!1,!1,"",lN);return e._reactRootContainer=a,e[uo]=a.current,Ld(e.nodeType===8?e.parentNode:e),tl(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=tm(c);l.call(u)}}var c=Rk(e,0,!1,null,null,!1,!1,"",lN);return e._reactRootContainer=c,e[uo]=c.current,Ld(e.nodeType===8?e.parentNode:e),tl(function(){Qm(t,c,n,r)}),c}function tg(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=tm(a);l.call(c)}}Qm(t,a,e,s)}else a=FD(n,t,e,s,r);return tm(a)}iE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Qu(t.pendingLanes);n!==0&&(ek(t,n|1),ts(t,Dn()),!(qt&6)&&($c=Dn()+500,ha()))}break;case 13:tl(function(){var r=fo(e,1);if(r!==null){var s=Br();ai(r,e,1,s)}}),Tk(e,1)}};tk=function(e){if(e.tag===13){var t=fo(e,134217728);if(t!==null){var n=Br();ai(t,e,134217728,n)}Tk(e,134217728)}};oE=function(e){if(e.tag===13){var t=Zo(e),n=fo(e,t);if(n!==null){var r=Br();ai(n,e,t,r)}Tk(e,t)}};aE=function(){return rn};lE=function(e,t){var n=rn;try{return rn=e,t()}finally{rn=n}};ex=function(e,t,n){switch(t){case"input":if(Uw(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=Km(r);if(!s)throw Error(Ee(90));FA(r),Uw(r,s)}}}break;case"textarea":BA(e,n);break;case"select":t=n.value,t!=null&&mc(e,!!n.multiple,t,!1)}};YA=Ak;GA=tl;var zD={usingClientEntryPoint:!1,Events:[yf,nc,Km,qA,UA,Ak]},Ou={findFiberByHostInstance:Oa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},BD={bundleType:Ou.bundleType,version:Ou.version,rendererPackageName:Ou.rendererPackageName,rendererConfig:Ou.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:wo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=QA(e),e===null?null:e.stateNode},findFiberByHostInstance:Ou.findFiberByHostInstance||DD,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 Ap=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ap.isDisabled&&Ap.supportsFiber)try{Bm=Ap.inject(BD),Ii=Ap}catch{}}ws.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zD;ws.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!$k(t))throw Error(Ee(200));return OD(e,t,null,n)};ws.createRoot=function(e,t){if(!$k(e))throw Error(Ee(299));var n=!1,r="",s=II;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Rk(e,1,!1,null,null,n,!1,r,s),e[uo]=t.current,Ld(e.nodeType===8?e.parentNode:e),new Mk(t)};ws.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=QA(t),e=e===null?null:e.stateNode,e};ws.flushSync=function(e){return tl(e)};ws.hydrate=function(e,t,n){if(!eg(t))throw Error(Ee(200));return tg(null,e,t,!0,n)};ws.hydrateRoot=function(e,t,n){if(!$k(e))throw Error(Ee(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=II;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=EI(t,null,e,1,n??null,s,!1,o,a),e[uo]=t.current,Ld(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 Zm(t)};ws.render=function(e,t,n){if(!eg(t))throw Error(Ee(200));return tg(null,e,t,!1,n)};ws.unmountComponentAtNode=function(e){if(!eg(e))throw Error(Ee(40));return e._reactRootContainer?(tl(function(){tg(null,null,e,!1,function(){e._reactRootContainer=null,e[uo]=null})}),!0):!1};ws.unstable_batchedUpdates=Ak;ws.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!eg(n))throw Error(Ee(200));if(e==null||e._reactInternals===void 0)throw Error(Ee(38));return tg(e,t,n,!1,r)};ws.version="18.3.1-next-f1338f8080-20240426";function PI(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(PI)}catch(e){console.error(e)}}PI(),PA.exports=ws;var lr=PA.exports,cN=lr;zw.createRoot=cN.createRoot,zw.hydrateRoot=cN.hydrateRoot;const RI=h.createContext(null);function Tx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function WD(){const e=Tx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function HD({children:e}){const[t,n]=h.useState(WD);h.useEffect(()=>{const o=()=>n(Tx(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=h.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=Tx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(RI.Provider,{value:s,children:e})}function rs(){const e=h.useContext(RI);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function VD(){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 uN={};function Mx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&uN[t[0]]||(typeof t[0]=="string"&&(uN[t[0]]=new Date),VD(...t))}const TI=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function dN(e,t,n){e.loadNamespaces(t,TI(e,n))}function fN(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,TI(e,r))}function KD(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?(Mx("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}}):KD(e,t,n)}const UD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,YD={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},GD=e=>YD[e],JD=e=>e.replace(UD,GD);let $x={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:JD};function XD(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};$x={...$x,...e}}function QD(){return $x}let MI;function ZD(e){MI=e}function eF(){return MI}const tF={type:"3rdParty",init(e){XD(e.options.react),ZD(e)}},nF=h.createContext();class rF{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const sF=(e,t)=>{const n=h.useRef();return h.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}=h.useContext(nF)||{},o=n||r||eF();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new rF),!o){Mx("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,C=[x,{},!1];return C.t=x,C.i18n={},C.ready=!1,C}o.options.react&&o.options.react.wait!==void 0&&Mx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...QD(),...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 d=(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[p,m]=h.useState(f);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=sF(y),b=h.useRef(!0);h.useEffect(()=>{const{bindI18n:x,bindI18nStore:C}=a;b.current=!0,!d&&!l&&(t.lng?fN(o,t.lng,u,()=>{b.current&&m(f)}):dN(o,u,()=>{b.current&&m(f)})),d&&v&&v!==y&&b.current&&m(f);function S(){b.current&&m(f)}return x&&o&&o.on(x,S),C&&o&&o.store.on(C,S),()=>{b.current=!1,x&&o&&x.split(" ").forEach(N=>o.off(N,S)),C&&o&&C.split(" ").forEach(N=>o.store.off(N,S))}},[o,y]);const g=h.useRef(!0);h.useEffect(()=>{b.current&&!g.current&&m(f),g.current=!1},[o,c]);const k=[p,o,d];if(k.t=p,k.i18n=o,k.ready=d,d||!d&&!l)return k;throw new Promise(x=>{t.lng?fN(o,t.lng,u,()=>x()):dN(o,u,()=>x())})}const $I="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",iF=[{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"}],oF=[{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 aF(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function lF({authUser:e,onLogout:t}){const{path:n,navigate:r}=rs(),{t:s}=Vr(),[o,a]=h.useState(!1);return h.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:$I,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:iF.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+(aF(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&&oF.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 cF="agentflow.pipelineRecent",uF=15;function dF(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function fF(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(cF);return e?dF(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 pF(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 pN(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 d=Math.floor(a/24);return d<7?t("flow:time.daysAgo",{n:d}):`${l.getMonth()+1}/${l.getDate()}`}function hF(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:pF(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,uF)}var us=Uint8Array,cc=Uint16Array,mF=Int32Array,LI=new us([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]),OI=new us([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]),gF=new us([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),DI=function(e,t){for(var n=new cc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new mF(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}},FI=DI(LI,2),zI=FI.b,yF=FI.r;zI[28]=258,yF[258]=28;var wF=DI(OI,0),xF=wF.b,Lx=new cc(32768);for(var gn=0;gn<32768;++gn){var Po=(gn&43690)>>1|(gn&21845)<<1;Po=(Po&52428)>>2|(Po&13107)<<2,Po=(Po&61680)>>4|(Po&3855)<<4,Lx[gn]=((Po&65280)>>8|(Po&255)<<8)>>1}var yd=function(e,t,n){for(var r=e.length,s=0,o=new cc(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new cc(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new cc(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],d=t-e[s],f=a[e[s]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)l[Lx[f]>>c]=u}else for(l=new cc(r),s=0;s<r;++s)e[s]&&(l[s]=Lx[a[e[s]-1]++]>>15-e[s]);return l},xf=new us(288);for(var gn=0;gn<144;++gn)xf[gn]=8;for(var gn=144;gn<256;++gn)xf[gn]=9;for(var gn=256;gn<280;++gn)xf[gn]=7;for(var gn=280;gn<288;++gn)xf[gn]=8;var BI=new us(32);for(var gn=0;gn<32;++gn)BI[gn]=5;var bF=yd(xf,9,1),kF=yd(BI,5,1),Wy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Js=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Hy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},vF=function(e){return(e+7)/8|0},Lk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new us(e.subarray(t,n))},SF=["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"],Es=function(e,t,n){var r=new Error(t||SF[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Es),!n)throw r;return r},jF=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new us(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new us(s*3));var u=function(ue){var de=n.length;if(ue>de){var pe=new us(Math.max(de*2,ue));pe.set(n),n=pe}},d=t.f||0,f=t.p||0,p=t.b||0,m=t.l,y=t.d,v=t.m,b=t.n,g=s*8;do{if(!m){d=Js(e,f,1);var k=Js(e,f+1,3);if(f+=3,k)if(k==1)m=bF,y=kF,v=9,b=5;else if(k==2){var N=Js(e,f,31)+257,P=Js(e,f+10,15)+4,R=N+Js(e,f+5,31)+1;f+=14;for(var z=new us(R),E=new us(19),O=0;O<P;++O)E[gF[O]]=Js(e,f+O*3,7);f+=P*3;for(var D=Wy(E),L=(1<<D)-1,M=yd(E,D,1),O=0;O<R;){var V=M[Js(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+Js(e,f,3),f+=2,B=z[O-1]):x==17?(F=3+Js(e,f,7),f+=3):x==18&&(F=11+Js(e,f,127),f+=7);F--;)z[O++]=B}}var $=z.subarray(0,N),H=z.subarray(N);v=Wy($),b=Wy(H),m=yd($,v,1),y=yd(H,b,1)}else Es(1);else{var x=vF(f)+4,C=e[x-4]|e[x-3]<<8,S=x+C;if(S>s){c&&Es(0);break}l&&u(p+C),n.set(e.subarray(x,S),p),t.b=p+=C,t.p=f=S*8,t.f=d;continue}if(f>g){c&&Es(0);break}}l&&u(p+131072);for(var A=(1<<v)-1,Q=(1<<b)-1,K=f;;K=f){var B=m[Hy(e,f)&A],W=B>>4;if(f+=B&15,f>g){c&&Es(0);break}if(B||Es(2),W<256)n[p++]=W;else if(W==256){K=f,m=null;break}else{var te=W-254;if(W>264){var O=W-257,Z=LI[O];te=Js(e,f,(1<<Z)-1)+zI[O],f+=Z}var Y=y[Hy(e,f)&Q],ne=Y>>4;Y||Es(3),f+=Y&15;var H=xF[ne];if(ne>3){var Z=OI[ne];H+=Hy(e,f)&(1<<Z)-1,f+=Z}if(f>g){c&&Es(0);break}l&&u(p+131072);var re=p+te;if(p<H){var se=o-H,ee=Math.min(H,re);for(se+p<0&&Es(3);p<ee;++p)n[p]=r[se+p]}for(;p<re;++p)n[p]=n[p-H]}}t.l=m,t.p=K,t.b=p,t.f=d,m&&(d=1,t.m=v,t.d=y,t.n=b)}while(!d);return p!=n.length&&a?Lk(n,0,p):n.subarray(0,p)},NF=new us(0),Ni=function(e,t){return e[t]|e[t+1]<<8},ni=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Vy=function(e,t){return ni(e,t)+ni(e,t+4)*4294967296};function CF(e,t){return jF(e,{i:2},t&&t.out,t&&t.dictionary)}var Ox=typeof TextDecoder<"u"&&new TextDecoder,_F=0;try{Ox.decode(NF,{stream:!0}),_F=1}catch{}var AF=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:Lk(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 EF(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(Ox)return Ox.decode(e);var s=AF(e),o=s.s,n=s.r;return n.length&&Es(8),o}}var IF=function(e,t){return t+30+Ni(e,t+26)+Ni(e,t+28)},PF=function(e,t,n){var r=Ni(e,t+28),s=EF(e.subarray(t+46,t+46+r),!(Ni(e,t+8)&2048)),o=t+46+r,a=ni(e,t+20),l=n&&a==4294967295?RF(e,o):[a,ni(e,t+24),ni(e,t+42)],c=l[0],u=l[1],d=l[2];return[Ni(e,t+10),c,u,s,o+Ni(e,t+30)+Ni(e,t+32),d]},RF=function(e,t){for(;Ni(e,t)!=1;t+=4+Ni(e,t+2));return[Vy(e,t+12),Vy(e,t+4),Vy(e,t+20)]};function TF(e,t){for(var n={},r=e.length-22;ni(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Es(13);var s=Ni(e,r+8);if(!s)return{};var o=ni(e,r+16),a=o==4294967295||s==65535;if(a){var l=ni(e,r-12);a=ni(e,l)==101075792,a&&(s=ni(e,l+32),o=ni(e,l+48))}for(var c=0;c<s;++c){var u=PF(e,o,a),d=u[0],f=u[1],p=u[2],m=u[3],y=u[4],v=u[5],b=IF(e,v);o=y,d?d==8?n[m]=CF(e.subarray(b,b+f),{out:new us(p)}):Es(14,"unknown compression type "+d):n[m]=Lk(e,b,b+f)}return n}const MF=8*1024*1024,$F=500;function LF(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 OF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function DF(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 FF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function zF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=TF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const d=LF(c);if(!d||OF(d))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>MF||(o+=1,o>$F))return null;r.set(d,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=DF(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 FF.test(l)?l:null}catch{return null}}const Ky=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function BF({file:e,onClose:t,onImported:n}){const{t:r}=Vr(),s=h.useId(),o=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(""),[u,d]=h.useState("user"),[f,p]=h.useState(!1),[m,y]=h.useState(""),[v,b]=h.useState(null),g=v??e;h.useEffect(()=>{const S=requestAnimationFrame(()=>{var N;return(N=o.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(S)},[]),h.useEffect(()=>{let S=!1;return(async()=>{const N=g.name||"",P=N.toLowerCase();let R="";if(P.endsWith(".zip")){if(R=await zF(g)||"",!R){const z=N.replace(/\.zip$/i,"");Ky.test(z)&&(R=z)}}else if(P.endsWith(".yaml")||P.endsWith(".yml")){const z=N.replace(/\.ya?ml$/i,"");Ky.test(z)&&(R=z)}S||c(R)})(),()=>{S=!0}},[g]);const k=l.trim(),x=k.length>0&&Ky.test(k);async function C(S){if(S.preventDefault(),!(!x||f)){p(!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{p(!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:C,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")})}),m?i.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):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 WF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,hN="af:newPipelineGuide";function HF({open:e,onClose:t,onCreated:n}){const{t:r}=Vr(),s=h.useId(),o=h.useRef(null),[a,l]=h.useState(""),[c,u]=h.useState(""),[d,f]=h.useState("user"),[p,m]=h.useState(!1),[y,v]=h.useState(""),[b,g]=h.useState(!1);h.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),m(!1),localStorage.getItem(hN)==="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(hN),g(!1)};if(!e)return null;const x=a.trim(),C=x.length>0&&WF.test(x);async function S(N){if(N.preventDefault(),!(!C||p)){m(!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:d})}),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{m(!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&&!C}),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:p,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!C||p,children:r(p?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const WI="agentflow.pipelineViewPreference";function HI(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function VI(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(WI)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function VF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(WI,JSON.stringify(e))}catch{}}function Ok(e){return e==="display"?"display":"workspace"}function KF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function KI(e,t){const n=Ok(t);return n==="pipeline"&&KF(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 UF(e,t,n,r=!1){if(!e)return;const s=VI();s[HI(e,t,r)]={view:Ok(n),at:Date.now()},VF(s)}function YF(e,t="workspace"){if(!(e!=null&&e.id))return Ok(t);const r=VI()[HI(e.id,e.source??"user",!!e.archived)],s=KI(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!qF(e)?"workspace":s}function GF(e,t="workspace"){var s;const n=KI(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 Ep(e,t="workspace"){return GF(e,YF(e,t))}function JF(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 Dx(e){return String((e==null?void 0:e.version)||"").trim()}function XF(e){const t=Dx(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 QF({onChanged:e,canManage:t=!1}){const[n,r]=h.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,o]=h.useState([]),[a,l]=h.useState(""),[c,u]=h.useState(""),[d,f]=h.useState("keyword"),[p,m]=h.useState([]),[y,v]=h.useState({}),[b,g]=h.useState(""),[k,x]=h.useState(""),[C,S]=h.useState(""),N=h.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))}},[]);h.useEffect(()=>{N()},[N]);const P=h.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(d)}`),M=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+L.status);m(Array.isArray(M.items)?M.items:[])}catch(L){x(String(L.message||L))}finally{g("")}}},[c,d]),R=h.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=h.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=Dx(V),K=String((A==null?void 0:A.version)||"").trim();let W="unknown";return A?Q&&K?W=JF(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:Dx(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=h.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=h.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:d,onChange:D=>{f(D.target.value),m([])},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:d==="collectionId"?"输入 collection id,例如 1":d==="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,C?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:C}):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:XF(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:p.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:p.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):p.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 qa(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 ZF(e){return{version:1,collections:qa({collections:e})}}function ez(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function qI(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(ez(s)))||""}}function ia(e,t){const n=qI(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function tz(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 nz(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function rz(e,t,n){const r=ia(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 sz(e,t,n){const r=String(e).trim().toLowerCase(),s=qa({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return ia(s,t)}function iz(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=qa({collections:r}),l=sz(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const d=JSON.parse(u);if(Array.isArray(d)){const f=qI(n),p=Array.from(new Set(d.map(f).filter(Boolean)));if(s.length>0&&p.length===s.length)return c;const m=new Set(p),y=new Set(l),v=l.length>0&&l.every(g=>m.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=ia(g,n);return k.length>0&&k.every(x=>m.has(x))});return l.length>0&&b&&!v?c:p}}}catch{}return c}function zl(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 oz(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function az(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 Fx(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 UI(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 lz="project:defaultCardDesc";function YI(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(lz)}function cz(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(`(${cz(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 uz(e,t,n){const r=[String(e.id),YI(e,n),UI(e),Fx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
+ `).toLowerCase()}function dz(e,t,n){return t?uz(e,t,n).includes(t):!0}function fz(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 qy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
+ `).toLowerCase().includes(n):!0}function mN(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 gN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const pz=["all","agent","control","provide","marketplace"],hz=["all","agent","control","provide"],GI="agentflow.projects.activityPanelOpen",zx="agentflow.projects.activitySelected",JI="agentflow.projects.scopeView";function mz(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(JI)==="team"?"team":"personal"}catch{return"personal"}}function gz(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(GI);return e!=="0"}function yN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function yz(){return typeof localStorage>"u"?"":localStorage.getItem(zx)||""}function Ip(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 wz(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 Ro(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function XI(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 QI(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 Bx(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 wN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Bx(e,t))}function xz(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function xN(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 bz(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 Uy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function kz(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 vz(e,t){const n=e.map(d=>d.id),r=new Set(n),s=new Map(n.map(d=>[d,0])),o=new Map(n.map(d=>[d,[]]));t.forEach(d=>{var f;!r.has(d.sourceId)||!r.has(d.targetId)||(s.set(d.targetId,(s.get(d.targetId)||0)+1),(f=o.get(d.sourceId))==null||f.push(d.targetId))});const a=new Map,l=n.filter(d=>(s.get(d)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(d=>a.set(d,0));for(let d=0;d<l.length;d+=1){const f=l[d],p=(a.get(f)||0)+1;for(const m of o.get(f)||[])(!a.has(m)||p>a.get(m))&&(a.set(m,p),l.push(m))}n.forEach((d,f)=>{a.has(d)||a.set(d,f%3)});const c=new Map,u=new Map;return n.forEach(d=>{const f=a.get(d)||0,p=c.get(f)||0;c.set(f,p+1),u.set(d,{x:f*190,y:p*86})}),u}function Sz(e){var v,b,g,k;const t=XI(e),n=QI(e),r=new Map(t.map((x,C)=>[Bx(x,C),wN(x,C)])),s=t.map((x,C)=>({id:Bx(x,C),title:wN(x,C),meta:xz(x)})),o=n.map((x,C)=>{const S=xN(x,"source"),N=xN(x,"target");return{key:(x==null?void 0:x.id)||`${S}-${N}-${C}`,sourceId:S,targetId:N,source:r.get(S)||S||"?",target:r.get(N)||N||"?",label:bz(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=vz(s,o),u=s.map(x=>{const C=kz(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:C.x,y:C.y,width:R,height:z}}),d=new Map(u.map(x=>[x.id,x])),f=o.map(x=>{const C=d.get(x.sourceId),S=d.get(x.targetId);if(!C||!S)return null;const N=C.x+C.width,P=C.y+C.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),p=u.reduce((x,C)=>({minX:Math.min(x.minX,C.x),minY:Math.min(x.minY,C.y),maxX:Math.max(x.maxX,C.x+C.width),maxY:Math.max(x.maxY,C.y+C.height)}),{minX:0,minY:0,maxX:420,maxY:220}),m=36,y=`${p.minX-m} ${p.minY-m} ${Math.max(360,p.maxX-p.minX+m*2)} ${Math.max(180,p.maxY-p.minY+m*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Bl({resourceKind:e="",authUser:t=null}){var Rt,Qt,pn,$n,ks,vs;const{t:n}=Vr(),{navigate:r,path:s}=rs(),o=!!(t!=null&&t.isAdmin),[a,l]=h.useState(e||"all"),[c,u]=h.useState([]),[d,f]=h.useState(mz),[p,m]=h.useState([]),[y,v]=h.useState([]),[b,g]=h.useState([]),[k,x]=h.useState([]),[C,S]=h.useState(""),[N,P]=h.useState(!1),[R,z]=h.useState([]),[E,O]=h.useState(""),[D,L]=h.useState(""),[M,V]=h.useState(!1),[B,F]=h.useState(!1),[$,H]=h.useState(!1),[A,Q]=h.useState(null),[K,W]=h.useState(!1),[te,Z]=h.useState(""),[Y,ne]=h.useState(gz),[re,se]=h.useState(yz),[ee,ue]=h.useState("all"),[de,pe]=h.useState(""),[Me,Ne]=h.useState("overview"),[Ce,He]=h.useState({}),[ct,yt]=h.useState(""),[Re,ot]=h.useState({}),[kt,$t]=h.useState(""),[ye,ze]=h.useState(""),[oe,ke]=h.useState({}),[Be,Qe]=h.useState(""),[_e,_t]=h.useState(""),[Xt,Ft]=h.useState(""),[at,Fn]=h.useState(""),[ie,Ie]=h.useState(""),[et,qe]=h.useState(!1),[Pt,vt]=h.useState(""),[tr,Yn]=h.useState({hiddenBuiltins:[],promoted:[]}),Tr=h.useRef(0),kn=h.useRef(0),nr=h.useRef(0),pr=h.useCallback(async()=>{var we,$e;const q=++kn.current;O("");try{const Ae=await fetch(`/api/flows?view=${encodeURIComponent(d)}`);if(q!==kn.current)return;if(!Ae.ok)throw new Error("HTTP "+Ae.status);const Ze=await Ae.json();if(q!==kn.current)return;u(Array.isArray(Ze)?Ze:[])}catch(Ae){if(q!==kn.current)return;u([]),O(String(Ae.message||Ae))}try{const Ae=await fetch("/api/pipeline-recent-runs");if(q!==kn.current)return;if(Ae.ok){const Ze=await Ae.json();if(q!==kn.current)return;z(Array.isArray(Ze.runs)?Ze.runs:[])}else z([])}catch{if(q!==kn.current)return;z([])}if(t!=null&&t.isAdmin)try{const Ae=await fetch("/api/admin/builtin-flows");if(q!==kn.current)return;const Ze=await Ae.json().catch(()=>({}));Ae.ok&&Yn({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(q!==kn.current)return;Yn({hiddenBuiltins:[],promoted:[]})}else Yn({hiddenBuiltins:[],promoted:[]});V(!0)},[t==null?void 0:t.isAdmin,d]),hr=h.useCallback(async(q,we)=>{if(!(t!=null&&t.isAdmin)||!(q!=null&&q.id))return;const $e=`${we}:${q.source}:${q.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:q.id,ownerUserId:q.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=h.useCallback(async()=>{const q=++nr.current;L(""),F(!1);const we="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";m([]),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(q!==nr.current)return;m(Array.isArray(Sn.nodes)?Sn.nodes:Array.isArray(Sn)?Sn:[]),v(Array.isArray(rr.skills)?rr.skills:[]),x(qa(yr)),g(Array.isArray(Zt.snippets)?Zt.snippets:[])}catch(Ae){if(q!==nr.current)return;m([]),v([]),g([]),x([]),L(String(Ae.message||Ae))}finally{if(q!==nr.current)return;F(!0)}},[e]);h.useEffect(()=>{V(!1),pr(),fn()},[pr,fn]),h.useEffect(()=>{try{localStorage.setItem(GI,Y?"1":"0")}catch{}},[Y]),h.useEffect(()=>{try{localStorage.setItem(JI,d)}catch{}},[d]),h.useEffect(()=>{try{re?localStorage.setItem(zx,re):localStorage.removeItem(zx)}catch{}},[re]),h.useEffect(()=>{let q=!1;return fetch("/api/ui-context").then(we=>we.json()).then(we=>{q||qe(!!we.hideCommunityLinks)}).catch(()=>{}),()=>{q=!0}},[]);const zn=h.useCallback(async q=>{if(!o)return;const we=qa({collections:q});P(!0),L("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ZF(we))}),Ae=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ae.error||"Collections HTTP "+$e.status);x(qa(Ae))}catch($e){L(String($e.message||$e))}finally{P(!1)}},[o]),is=h.useCallback(()=>{if(!o)return;const q=C.trim();if(!q)return;const we=q.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:q,skillKeys:[],createdAt:wn,updatedAt:wn}]),S(""),ue(`collection:${Ae}`)},[o,C,zn,k]),Ds=h.useCallback(q=>{if(!o)return;const we=k.find(Ae=>Ae.id===q);if(we!=null&&we.builtin)return;const $e=k.filter(Ae=>Ae.id!==q);ee===`collection:${q}`&&ue("all"),zn($e)},[o,ee,zn,k]),vn=h.useCallback((q,we,$e)=>{if(!o)return;const Ae=String(we||"").trim();if(!Ae)return;const Ze=Date.now(),wn=k.map(Lt=>{if(Lt.id!==q)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]),Gn=h.useCallback(async q=>{const we=q==null?void 0:q.packageId,$e=q==null?void 0:q.version;if(!we||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:we,version:$e})))return;const Ae=On(q);_t(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})),ot(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{_t("")}},[fn,n]),bs=h.useCallback(async q=>{const we=q==null?void 0:q.id,$e=(q==null?void 0:q.version)||"1.0.0";if(!we||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:we,version:$e})))return;const Ae=Ro(q);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]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ue("all"),pe(""),Ne("overview");return}l(q=>q==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const q=new URLSearchParams(window.location.search),we=q.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"),q.delete("tab"),$e=!0):we&&(l("all"),q.delete("tab"),$e=!0),q.get("new")==="1"&&(H(!0),q.delete("new"),$e=!0),$e){const Ae=q.toString();window.history.replaceState({},"",Ae?`/projects?${Ae}`:"/projects")}},[s,r]);const Jn=h.useMemo(()=>hF(R,fF(),c),[R,c,s]),Bn=h.useMemo(()=>Jn.filter(q=>fz(te,q)),[Jn,te]),vr=te.trim().toLowerCase(),Sr=h.useMemo(()=>a==="archived"?c.filter(q=>q.archived):c.filter(q=>!q.archived),[c,a]),Wn=h.useMemo(()=>Sr.filter(q=>dz(q,vr,n)),[Sr,vr,n]),Mr=h.useMemo(()=>new Set((tr.promoted||[]).map(q=>String((q==null?void 0:q.id)||"").trim()).filter(Boolean)),[tr.promoted]),$r=h.useMemo(()=>(tr.hiddenBuiltins||[]).map(q=>String(q||"").trim()).filter(Boolean),[tr.hiddenBuiltins]),ce=a==="nodes"||a==="my-nodes",me=a==="my-nodes",tt=a==="my-flows",rt=h.useMemo(()=>p.filter(q=>me&&!wz(q,t)?!1:(ee==="all"||(ee==="marketplace"?q.source==="marketplace":q.type===ee))&&qy(te,[q.id,q.label,q.displayName,q.description,q.type,q.source,q.packageId,q.version])),[t,p,me,te,ee]),zt=h.useMemo(()=>{const q=new Map;for(const we of k)q.set(we.id,new Set(ia(we,y)));return q},[y,k]),Rn=h.useMemo(()=>[{id:"all",label:"全部"},...k.map(q=>{var we;return{id:`collection:${q.id}`,label:q.name,count:((we=zt.get(q.id))==null?void 0:we.size)||0,collection:q}}),{id:"ungrouped",label:"未分组"}],[zt,k]),jr=h.useMemo(()=>y.filter(q=>{var Ae;const we=On(q);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&&qy(te,[q.name,q.id,q.description,q.sourceLabel,q.source,q.path])}),[y,te,ee,zt]),Nr=h.useMemo(()=>b.filter(q=>qy(te,[q.id,q.name,q.displayName,q.description,q.version,q.packageDir,Array.isArray(q.tags)?q.tags.join(" "):""])),[b,te]),mr=ce||tt||a==="skills",ut=h.useMemo(()=>rt.find(q=>On(q)===de)||rt[0]||null,[rt,de]),Ut=h.useMemo(()=>jr.find(q=>On(q)===de)||jr[0]||null,[jr,de]),Yt=h.useMemo(()=>Nr.find(q=>Ro(q)===de)||Nr[0]||null,[Nr,de]),Xn=Ut?Ce[On(Ut)]:null,it=ut?Re[On(ut)]:null,gr=ut&&ye?oe[`${On(ut)}:${ye}`]:null,Fs=n(ce?"project:searchNodes":tt?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(a!=="skills"||!Ut)return;const q=On(Ut);if(Ce[q])return;let we=!1;return yt(q),fetch(`/api/skills/detail?key=${encodeURIComponent(q)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&Ae.skill&&He(Ze=>({...Ze,[q]:Ae.skill}))}).catch(()=>{}).finally(()=>{we||yt("")}),()=>{we=!0}},[a,Ut,Ce]),h.useEffect(()=>{if(!ce||!ut)return;const q=On(ut);if(Re[q])return;let we=!1;return $t(q),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&&ot(Ze=>({...Ze,[q]:Ae}))}).catch(()=>{}).finally(()=>{we||$t("")}),()=>{we=!0}},[ce,ut,Re]),h.useEffect(()=>{if(!ce)return;const q=Array.isArray(it==null?void 0:it.files)?it.files:[];ze(we=>{var $e;return we&&q.some(Ae=>Ae.path===we)?we:(($e=q[0])==null?void 0:$e.path)||""})},[ce,it]),h.useEffect(()=>{if(!ce||!ut||!ye)return;const q=`${On(ut)}:${ye}`;if(oe[q])return;let we=!1;return Qe(q),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,[q]:Ae}))}).catch(()=>{}).finally(()=>{we||Qe("")}),()=>{we=!0}},[ce,ut,ye,oe]),h.useEffect(()=>{Ft("")},[de,a]);const Bi=q=>{r(Ep(q,"workspace"))},zs=q=>{se(yN(q)),r(Ep({id:q.flowId,source:q.flowSource,archived:!!q.archived},"workspace"))},ae=h.useCallback(q=>{var we,$e;q.preventDefault(),q.stopPropagation(),($e=(we=q.dataTransfer)==null?void 0:we.types)!=null&&$e.includes("Files")&&(Tr.current+=1,W(!0))},[]),ve=h.useCallback(q=>{q.preventDefault(),q.stopPropagation(),Tr.current-=1,Tr.current<=0&&(Tr.current=0,W(!1))},[]),Te=h.useCallback(q=>{q.preventDefault(),q.stopPropagation()},[]),bt=h.useCallback(q=>{var Ae,Ze;q.preventDefault(),q.stopPropagation(),Tr.current=0,W(!1);const we=(Ze=(Ae=q.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:d==="personal"?"is-active":"",onClick:()=>f("personal"),children:"个人"}),i.jsx("button",{type:"button",className:d==="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:Fs,"aria-label":Fs,autoComplete:"off",value:te,onChange:q=>Z(q.target.value),onKeyDown:q=>{q.key==="Escape"&&(Z(""),q.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"+(Y?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":Y,"aria-controls":"af-recent-activity-panel",onClick:()=>ne(q=>!q),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"?rt.length:a==="my-flows"?Nr.length:a==="skills"?jr.length:Wn.length}):a==="my-nodes"?n("project:myNodesHint",{count:rt.length}):a==="my-flows"?n("project:myFlowsHint",{count:Nr.length}):a==="nodes"?n("project:nodesHint",{count:p.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(QF,{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?hz:pz).map(q=>({id:q,label:n(`project:resourceFilter.${q}`)})):Rn).map(q=>q.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(ee===q.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ue(q.id),pe("")},children:[q.label,i.jsx("em",{children:q.count}),q.collection.builtin?i.jsx("strong",{children:"built-in"}):null]}),o&&!q.collection.builtin?i.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${q.collection.name}`,onClick:()=>Ds(q.collection.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},q.id):i.jsx("button",{type:"button",className:"af-resource-filter"+(ee===q.id?" af-resource-filter--active":""),onClick:()=>{ue(q.id),pe("")},children:q.label},q.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:C,onChange:q=>S(q.target.value),onKeyDown:q=>{q.key==="Enter"&&is()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!C.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:rt.length>0?rt.map(q=>i.jsxs("button",{type:"button",className:"af-resource-card"+(ut&&On(q)===On(ut)?" af-resource-card--active":""),onClick:()=>pe(On(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:zl(q.type==="control"?"secondary":q.type==="provide"?"primary":"muted"),children:i.jsx(Ln,{query:te,children:q.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Ln,{query:te,children:mN(q.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Ln,{query:te,children:q.label||q.displayName||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Ln,{query:te,children:q.id})}),i.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(q.inputs||{}).length,outputs:Object.keys(q.outputs||{}).length})})]}),q.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:`${q.packageId}${q.version?` / ${q.version}`:""}`})})]}):null]},`${q.id}:${q.source||""}:${q.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(q=>{const we=XI(q),$e=QI(q),Ae=Number.isFinite(Number(q.nodeCount))?Number(q.nodeCount):we.length,Ze=Number.isFinite(Number(q.edgeCount))?Number(q.edgeCount):$e.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Yt&&Ro(q)===Ro(Yt)?" af-resource-card--active":""),onClick:()=>pe(Ro(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:zl("primary"),children:i.jsx(Ln,{query:te,children:q.version?`v${q.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:q.displayName||q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:q.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:q.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:gN(q)})})]})]},Ro(q))}):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(q=>{const we=On(q),$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:zl(q.source==="builtin"?"muted":"primary"),children:i.jsx(Ln,{query:te,children:q.sourceLabel||q.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:q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:q.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:q.path||q.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]})]},q.key||`${q.source}:${q.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(q=>{const we=Pt===`show-builtin:builtin:${q}`;return i.jsxs("button",{type:"button",disabled:we,onClick:()=>hr({id:q,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:q}),i.jsx("em",{children:we?"恢复中":"恢复"})]},q)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[Wn.length>0?Wn.map(q=>{var wn,Lt,Sn,rr,yr;const we=(t==null?void 0:t.isAdmin)&&q.source==="user"&&!q.archived&&!Mr.has(q.id),$e=(t==null?void 0:t.isAdmin)&&q.source==="admin",Ae=(t==null?void 0:t.isAdmin)&&q.source==="builtin",Ze=Pt.endsWith(`:${q.source}:${q.id}`);return i.jsx("div",{className:oz(q.source),role:"button",tabIndex:0,onClick:()=>Bi(q),onKeyDown:Zt=>{(Zt.key==="Enter"||Zt.key===" ")&&(Zt.preventDefault(),Bi(q))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:zl(Fx(q.source,n).tone),children:i.jsx(Ln,{query:te,children:Fx(q.source,n).label})}),(wn=q.collaboration)!=null&&wn.role?i.jsx("span",{className:zl(q.collaboration.role==="owner"?"primary":"muted"),children:q.collaboration.role==="owner"?(Lt=q.collaboration.teamShares)!=null&&Lt.length?"已分享团队":"我创建的":q.collaboration.accessSource==="team"?`${((rr=(Sn=q.collaboration.teamShares)==null?void 0:Sn.find(Zt=>Zt.teamId===q.collaboration.teamId))==null?void 0:rr.teamName)||"团队"}共享`:`${q.collaboration.ownerUsername||q.collaboration.ownerId} 分享`}):null,q.archived?i.jsx("span",{className:zl("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:q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Ln,{query:te,children:YI(q,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:UI(q)})})]}),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(q,"promote"),children:"设为内置"}):null,$e?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(q,"unpromote"),children:"取消内置"}):null,Ae?i.jsx("button",{type:"button",disabled:Ze,onClick:()=>hr(q,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${q.id}:${q.source??"user"}:${q.archived?"a":""}:${((yr=q.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(q=>i.jsx("button",{type:"button",className:"af-resource-detail-tab"+(Me===q?" af-resource-detail-tab--active":""),onClick:()=>Ne(q),children:n(`project:nodeDetailTabs.${q}`)},q))}),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=it==null?void 0:it.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=it==null?void 0:it.node)==null?void 0:Qt.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:mN(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||it!=null&&it.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:ut.packageDir||(it==null?void 0:it.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(it==null?void 0:it.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:_e===On(ut),onClick:()=>Gn(ut),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),_e===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")}),Ip(((pn=it==null?void 0:it.node)==null?void 0:pn.inputs)||ut.inputs).length>0?Ip((($n=it==null?void 0:it.node)==null?void 0:$n.inputs)||ut.inputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):i.jsx("em",{children:n("project:noSlots")})]}),i.jsxs("div",{className:"af-resource-slot-group",children:[i.jsx("span",{children:n("project:nodeOutputs")}),Ip(((ks=it==null?void 0:it.node)==null?void 0:ks.outputs)||ut.outputs).length>0?Ip(((vs=it==null?void 0:it.node)==null?void 0:vs.outputs)||ut.outputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.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")}),it!=null&&it.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(it.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),it!=null&&it.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:it.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(it==null?void 0:it.files)&&it.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:it.files.map(q=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(ye===q.path?" af-node-file-item--active":""),onClick:()=>ze(q.path),children:[i.jsx("span",{className:"material-symbols-outlined",children:"description"}),i.jsx("span",{children:q.path})]},q.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(it==null?void 0:it.usage)&&it.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:it.usage.map(q=>i.jsxs("div",{className:"af-node-usage-item",children:[i.jsx("strong",{children:q.flowId}),i.jsxs("span",{children:[q.flowSource,q.archived?` · ${n("project:archived")}`:""]}),i.jsx("em",{children:q.instances.map(we=>we.label||we.instanceId).join(", ")})]},`${q.flowSource}:${q.flowId}:${q.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):tt&&Yt?(()=>{const q=Sz(Yt);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:Yt.displayName||Yt.name||Yt.id}),i.jsx("p",{children:Yt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Yt.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:Yt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:gN(Yt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Yt.nodeCount))?Number(Yt.nodeCount):q.nodes.length,edges:Number.isFinite(Number(Yt.edgeCount))?Number(Yt.edgeCount):q.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:at===Ro(Yt),onClick:()=>bs(Yt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),at===Ro(Yt)?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")}),q.diagram.nodes.length>0?i.jsx("div",{className:"af-flow-snippet-map",children:i.jsxs("svg",{viewBox:q.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:q.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:Uy(we.label,18)}):null]},we.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:q.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:Uy(we.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:we.height/2+16,children:Uy(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(Yt.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(q=>{const we=On(Ut),$e=zt.get(q.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(q.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:q.name}),i.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},q.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"+(Y?"":" af-activity--hidden"),"aria-hidden":!Y,"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(q=>{const we=re===yN(q);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:()=>zs(q),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Ln,{query:te,children:q.flowId})}),i.jsx("span",{className:"af-activity-time",children:pN(q.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:az(q.kind),children:q.kind==="executed"?"play_arrow":"visibility"}),i.jsxs("p",{className:"af-activity-text",children:[q.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",pN(q.at,n)]})]})]},`${q.kind}-${q.flowId}-${q.flowSource}-${q.at}`)})})]})]}),i.jsx(HF,{open:$,onClose:()=>H(!1),onCreated:async q=>{H(!1),await pr();const we=q.source??"user";r(Ep({id:q.id,source:we},"workspace"))}}),A?i.jsx(BF,{file:A,onClose:()=>Q(null),onImported:async q=>{Q(null),await pr();const we=q.source??"user";r(Ep({id:q.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 jz={value:()=>{}};function ng(){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 wh(n)}function wh(e){this._=e}function Nz(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}})}wh.prototype=ng.prototype={constructor:wh,on:function(e,t){var n=this._,r=Nz(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=Cz(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]=bN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=bN(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 wh(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 Cz(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function bN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=jz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Wx="http://www.w3.org/1999/xhtml";const kN={svg:"http://www.w3.org/2000/svg",xhtml:Wx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function rg(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),kN.hasOwnProperty(t)?{space:kN[t],local:e}:e}function _z(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Wx&&t.documentElement.namespaceURI===Wx?t.createElement(e):t.createElementNS(n,e)}}function Az(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ZI(e){var t=rg(e);return(t.local?Az:_z)(t)}function Ez(){}function Dk(e){return e==null?Ez:function(){return this.querySelector(e)}}function Iz(e){typeof e!="function"&&(e=Dk(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,d=0;d<a;++d)(c=o[d])&&(u=e.call(c,c.__data__,d,o))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new ys(r,this._parents)}function Pz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Rz(){return[]}function eP(e){return e==null?Rz:function(){return this.querySelectorAll(e)}}function Tz(e){return function(){return Pz(e.apply(this,arguments))}}function Mz(e){typeof e=="function"?e=Tz(e):e=eP(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 ys(r,s)}function tP(e){return function(){return this.matches(e)}}function nP(e){return function(t){return t.matches(e)}}var $z=Array.prototype.find;function Lz(e){return function(){return $z.call(this.children,e)}}function Oz(){return this.firstElementChild}function Dz(e){return this.select(e==null?Oz:Lz(typeof e=="function"?e:nP(e)))}var Fz=Array.prototype.filter;function zz(){return Array.from(this.children)}function Bz(e){return function(){return Fz.call(this.children,e)}}function Wz(e){return this.selectAll(e==null?zz:Bz(typeof e=="function"?e:nP(e)))}function Hz(e){typeof e!="function"&&(e=tP(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 ys(r,this._parents)}function rP(e){return new Array(e.length)}function Vz(){return new ys(this._enter||this._groups.map(rP),this._parents)}function nm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}nm.prototype={constructor:nm,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 Kz(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 nm(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function Uz(e,t,n,r,s,o,a){var l,c,u=new Map,d=t.length,f=o.length,p=new Array(d),m;for(l=0;l<d;++l)(c=t[l])&&(p[l]=m=a.call(c,c.__data__,l,t)+"",u.has(m)?s[l]=c:u.set(m,c));for(l=0;l<f;++l)m=a.call(e,o[l],l,o)+"",(c=u.get(m))?(r[l]=c,c.__data__=o[l],u.delete(m)):n[l]=new nm(e,o[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function Yz(e){return e.__data__}function Gz(e,t){if(!arguments.length)return Array.from(this,Yz);var n=t?Uz:qz,r=this._parents,s=this._groups;typeof e!="function"&&(e=Kz(e));for(var o=s.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var d=r[u],f=s[u],p=f.length,m=Jz(e.call(d,d&&d.__data__,u,r)),y=m.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(p);n(d,f,v,b,g,m,t);for(var k=0,x=0,C,S;k<y;++k)if(C=v[k]){for(k>=x&&(x=k+1);!(S=b[x])&&++x<y;);C._next=S||null}}return a=new ys(a,r),a._enter=l,a._exit=c,a}function Jz(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xz(){return new ys(this._exit||this._groups.map(rP),this._parents)}function Qz(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 Zz(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],d=r[c],f=u.length,p=l[c]=new Array(f),m,y=0;y<f;++y)(m=u[y]||d[y])&&(p[y]=m);for(;c<s;++c)l[c]=n[c];return new ys(l,this._parents)}function e3(){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 t3(e){e||(e=n3);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}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,d=0;d<l;++d)(u=a[d])&&(c[d]=u);c.sort(t)}return new ys(s,this._parents).order()}function n3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function r3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function s3(){return Array.from(this)}function i3(){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 o3(){let e=0;for(const t of this)++e;return e}function a3(){return!this.node()}function l3(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 c3(e){return function(){this.removeAttribute(e)}}function u3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function d3(e,t){return function(){this.setAttribute(e,t)}}function f3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function p3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function h3(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 m3(e,t){var n=rg(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?u3:c3:typeof t=="function"?n.local?h3:p3:n.local?f3:d3)(n,t))}function sP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function g3(e){return function(){this.style.removeProperty(e)}}function y3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function w3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function x3(e,t,n){return arguments.length>1?this.each((t==null?g3:typeof t=="function"?w3:y3)(e,t,n??"")):Lc(this.node(),e)}function Lc(e,t){return e.style.getPropertyValue(t)||sP(e).getComputedStyle(e,null).getPropertyValue(t)}function b3(e){return function(){delete this[e]}}function k3(e,t){return function(){this[e]=t}}function v3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function S3(e,t){return arguments.length>1?this.each((t==null?b3:typeof t=="function"?v3:k3)(e,t)):this.node()[e]}function iP(e){return e.trim().split(/^|\s+/)}function Fk(e){return e.classList||new oP(e)}function oP(e){this._node=e,this._names=iP(e.getAttribute("class")||"")}oP.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 aP(e,t){for(var n=Fk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function lP(e,t){for(var n=Fk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function j3(e){return function(){aP(this,e)}}function N3(e){return function(){lP(this,e)}}function C3(e,t){return function(){(t.apply(this,arguments)?aP:lP)(this,e)}}function _3(e,t){var n=iP(e+"");if(arguments.length<2){for(var r=Fk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?C3:t?j3:N3)(n,t))}function A3(){this.textContent=""}function E3(e){return function(){this.textContent=e}}function I3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function P3(e){return arguments.length?this.each(e==null?A3:(typeof e=="function"?I3:E3)(e)):this.node().textContent}function R3(){this.innerHTML=""}function T3(e){return function(){this.innerHTML=e}}function M3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function $3(e){return arguments.length?this.each(e==null?R3:(typeof e=="function"?M3:T3)(e)):this.node().innerHTML}function L3(){this.nextSibling&&this.parentNode.appendChild(this)}function O3(){return this.each(L3)}function D3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function F3(){return this.each(D3)}function z3(e){var t=typeof e=="function"?e:ZI(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function B3(){return null}function W3(e,t){var n=typeof e=="function"?e:ZI(e),r=t==null?B3:typeof t=="function"?t:Dk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function H3(){var e=this.parentNode;e&&e.removeChild(this)}function V3(){return this.each(H3)}function K3(){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 U3(e){return this.select(e?q3:K3)}function Y3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function G3(e){return function(t){e.call(this,t,this.__data__)}}function J3(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 X3(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 Q3(e,t,n){return function(){var r=this.__on,s,o=G3(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 Z3(e,t,n){var r=J3(e+""),s,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<o;++s)if((a=r[s]).type===d.type&&a.name===d.name)return d.value}return}for(l=t?Q3:X3,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function cP(e,t,n){var r=sP(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 eB(e,t){return function(){return cP(this,e,t)}}function tB(e,t){return function(){return cP(this,e,t.apply(this,arguments))}}function nB(e,t){return this.each((typeof t=="function"?tB:eB)(e,t))}function*rB(){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 uP=[null];function ys(e,t){this._groups=e,this._parents=t}function bf(){return new ys([[document.documentElement]],uP)}function sB(){return this}ys.prototype=bf.prototype={constructor:ys,select:Iz,selectAll:Mz,selectChild:Dz,selectChildren:Wz,filter:Hz,data:Gz,enter:Vz,exit:Xz,join:Qz,merge:Zz,selection:sB,order:e3,sort:t3,call:r3,nodes:s3,node:i3,size:o3,empty:a3,each:l3,attr:m3,style:x3,property:S3,classed:_3,text:P3,html:$3,raise:O3,lower:F3,append:z3,insert:W3,remove:V3,clone:U3,datum:Y3,on:Z3,dispatch:nB,[Symbol.iterator]:rB};function ds(e){return typeof e=="string"?new ys([[document.querySelector(e)]],[document.documentElement]):new ys([[e]],uP)}function iB(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ei(e,t){if(e=iB(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 oB={passive:!1},Kd={capture:!0,passive:!1};function Yy(e){e.stopImmediatePropagation()}function kc(e){e.preventDefault(),e.stopImmediatePropagation()}function dP(e){var t=e.document.documentElement,n=ds(e).on("dragstart.drag",kc,Kd);"onselectstart"in t?n.on("selectstart.drag",kc,Kd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function fP(e,t){var n=e.document.documentElement,r=ds(e).on("dragstart.drag",null);t&&(r.on("click.drag",kc,Kd),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 Pp=e=>()=>e;function Hx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:a,y:l,dx:c,dy:u,dispatch:d}){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:d}})}Hx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function aB(e){return!e.ctrlKey&&!e.button}function lB(){return this.parentNode}function cB(e,t){return t??{x:e.x,y:e.y}}function uB(){return navigator.maxTouchPoints||"ontouchstart"in this}function pP(){var e=aB,t=lB,n=cB,r=uB,s={},o=ng("start","drag","end"),a=0,l,c,u,d,f=0;function p(C){C.on("mousedown.drag",m).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,oB).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(C,S){if(!(d||!e.call(this,C,S))){var N=x(this,t.call(this,C,S),C,S,"mouse");N&&(ds(C.view).on("mousemove.drag",y,Kd).on("mouseup.drag",v,Kd),dP(C.view),Yy(C),u=!1,l=C.clientX,c=C.clientY,N("start",C))}}function y(C){if(kc(C),!u){var S=C.clientX-l,N=C.clientY-c;u=S*S+N*N>f}s.mouse("drag",C)}function v(C){ds(C.view).on("mousemove.drag mouseup.drag",null),fP(C.view,u),kc(C),s.mouse("end",C)}function b(C,S){if(e.call(this,C,S)){var N=C.changedTouches,P=t.call(this,C,S),R=N.length,z,E;for(z=0;z<R;++z)(E=x(this,P,C,S,N[z].identifier,N[z]))&&(Yy(C),E("start",C,N[z]))}}function g(C){var S=C.changedTouches,N=S.length,P,R;for(P=0;P<N;++P)(R=s[S[P].identifier])&&(kc(C),R("drag",C,S[P]))}function k(C){var S=C.changedTouches,N=S.length,P,R;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),P=0;P<N;++P)(R=s[S[P].identifier])&&(Yy(C),R("end",C,S[P]))}function x(C,S,N,P,R,z){var E=o.copy(),O=ei(z||N,S),D,L,M;if((M=n.call(C,new Hx("beforestart",{sourceEvent:N,target:p,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=ei($||F,S),A=a;break}E.call(B,C,new Hx(B,{sourceEvent:F,subject:M,target:p,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 p.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Pp(!!C),p):e},p.container=function(C){return arguments.length?(t=typeof C=="function"?C:Pp(C),p):t},p.subject=function(C){return arguments.length?(n=typeof C=="function"?C:Pp(C),p):n},p.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:Pp(!!C),p):r},p.on=function(){var C=o.on.apply(o,arguments);return C===o?p:C},p.clickDistance=function(C){return arguments.length?(f=(C=+C)*C,p):Math.sqrt(f)},p}function zk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function hP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function kf(){}var qd=.7,rm=1/qd,vc="\\s*([+-]?\\d+)\\s*",Ud="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ri="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",dB=/^#([0-9a-f]{3,8})$/,fB=new RegExp(`^rgb\\(${vc},${vc},${vc}\\)$`),pB=new RegExp(`^rgb\\(${Ri},${Ri},${Ri}\\)$`),hB=new RegExp(`^rgba\\(${vc},${vc},${vc},${Ud}\\)$`),mB=new RegExp(`^rgba\\(${Ri},${Ri},${Ri},${Ud}\\)$`),gB=new RegExp(`^hsl\\(${Ud},${Ri},${Ri}\\)$`),yB=new RegExp(`^hsla\\(${Ud},${Ri},${Ri},${Ud}\\)$`),vN={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};zk(kf,nl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:SN,formatHex:SN,formatHex8:wB,formatHsl:xB,formatRgb:jN,toString:jN});function SN(){return this.rgb().formatHex()}function wB(){return this.rgb().formatHex8()}function xB(){return mP(this).formatHsl()}function jN(){return this.rgb().formatRgb()}function nl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=dB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?NN(t):n===3?new Xr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Rp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Rp(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=fB.exec(e))?new Xr(t[1],t[2],t[3],1):(t=pB.exec(e))?new Xr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=hB.exec(e))?Rp(t[1],t[2],t[3],t[4]):(t=mB.exec(e))?Rp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gB.exec(e))?AN(t[1],t[2]/100,t[3]/100,1):(t=yB.exec(e))?AN(t[1],t[2]/100,t[3]/100,t[4]):vN.hasOwnProperty(e)?NN(vN[e]):e==="transparent"?new Xr(NaN,NaN,NaN,0):null}function NN(e){return new Xr(e>>16&255,e>>8&255,e&255,1)}function Rp(e,t,n,r){return r<=0&&(e=t=n=NaN),new Xr(e,t,n,r)}function bB(e){return e instanceof kf||(e=nl(e)),e?(e=e.rgb(),new Xr(e.r,e.g,e.b,e.opacity)):new Xr}function Vx(e,t,n,r){return arguments.length===1?bB(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}zk(Xr,Vx,hP(kf,{brighter(e){return e=e==null?rm:Math.pow(rm,e),new Xr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?qd:Math.pow(qd,e),new Xr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Xr(Ua(this.r),Ua(this.g),Ua(this.b),sm(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:CN,formatHex:CN,formatHex8:kB,formatRgb:_N,toString:_N}));function CN(){return`#${za(this.r)}${za(this.g)}${za(this.b)}`}function kB(){return`#${za(this.r)}${za(this.g)}${za(this.b)}${za((isNaN(this.opacity)?1:this.opacity)*255)}`}function _N(){const e=sm(this.opacity);return`${e===1?"rgb(":"rgba("}${Ua(this.r)}, ${Ua(this.g)}, ${Ua(this.b)}${e===1?")":`, ${e})`}`}function sm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ua(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function za(e){return e=Ua(e),(e<16?"0":"")+e.toString(16)}function AN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ri(e,t,n,r)}function mP(e){if(e instanceof ri)return new ri(e.h,e.s,e.l,e.opacity);if(e instanceof kf||(e=nl(e)),!e)return new ri;if(e instanceof ri)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 ri(a,l,c,e.opacity)}function vB(e,t,n,r){return arguments.length===1?mP(e):new ri(e,t,n,r??1)}function ri(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}zk(ri,vB,hP(kf,{brighter(e){return e=e==null?rm:Math.pow(rm,e),new ri(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?qd:Math.pow(qd,e),new ri(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(Gy(e>=240?e-240:e+120,s,r),Gy(e,s,r),Gy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ri(EN(this.h),Tp(this.s),Tp(this.l),sm(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=sm(this.opacity);return`${e===1?"hsl(":"hsla("}${EN(this.h)}, ${Tp(this.s)*100}%, ${Tp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function EN(e){return e=(e||0)%360,e<0?e+360:e}function Tp(e){return Math.max(0,Math.min(1,e||0))}function Gy(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 Bk=e=>()=>e;function SB(e,t){return function(n){return e+n*t}}function jB(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 NB(e){return(e=+e)==1?gP:function(t,n){return n-t?jB(t,n,e):Bk(isNaN(t)?n:t)}}function gP(e,t){var n=t-e;return n?SB(e,n):Bk(isNaN(e)?t:e)}const im=function e(t){var n=NB(t);function r(s,o){var a=n((s=Vx(s)).r,(o=Vx(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=gP(s.opacity,o.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function CB(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 _B(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function AB(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]=wd(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 EB(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function vi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function IB(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]=wd(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Kx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Jy=new RegExp(Kx.source,"g");function PB(e){return function(){return e}}function RB(e){return function(t){return e(t)+""}}function yP(e,t){var n=Kx.lastIndex=Jy.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Kx.exec(e))&&(s=Jy.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:vi(r,s)})),n=Jy.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?RB(c[0].x):PB(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function wd(e,t){var n=typeof t,r;return t==null||n==="boolean"?Bk(t):(n==="number"?vi:n==="string"?(r=nl(t))?(t=r,im):yP:t instanceof nl?im:t instanceof Date?EB:_B(t)?CB:Array.isArray(t)?AB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?IB:vi)(e,t)}var IN=180/Math.PI,qx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function wP(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)*IN,skewX:Math.atan(c)*IN,scaleX:a,scaleY:l}}var Mp;function TB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?qx:wP(t.a,t.b,t.c,t.d,t.e,t.f)}function MB(e){return e==null||(Mp||(Mp=document.createElementNS("http://www.w3.org/2000/svg","g")),Mp.setAttribute("transform",e),!(e=Mp.transform.baseVal.consolidate()))?qx:(e=e.matrix,wP(e.a,e.b,e.c,e.d,e.e,e.f))}function xP(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function o(u,d,f,p,m,y){if(u!==f||d!==p){var v=m.push("translate(",null,t,null,n);y.push({i:v-4,x:vi(u,f)},{i:v-2,x:vi(d,p)})}else(f||p)&&m.push("translate("+f+t+p+n)}function a(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:vi(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:vi(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,m,y){if(u!==f||d!==p){var v=m.push(s(m)+"scale(",null,",",null,")");y.push({i:v-4,x:vi(u,f)},{i:v-2,x:vi(d,p)})}else(f!==1||p!==1)&&m.push(s(m)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),o(u.translateX,u.translateY,d.translateX,d.translateY,f,p),a(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(m){for(var y=-1,v=p.length,b;++y<v;)f[(b=p[y]).i]=b.x(m);return f.join("")}}}var $B=xP(TB,"px, ","px)","deg)"),LB=xP(MB,", ",")",")"),OB=1e-12;function PN(e){return((e=Math.exp(e))+1/e)/2}function DB(e){return((e=Math.exp(e))-1/e)/2}function FB(e){return((e=Math.exp(2*e))-1)/(e+1)}const xh=function e(t,n,r){function s(o,a){var l=o[0],c=o[1],u=o[2],d=a[0],f=a[1],p=a[2],m=d-l,y=f-c,v=m*m+y*y,b,g;if(v<OB)g=Math.log(p/u)/t,b=function(P){return[l+P*m,c+P*y,u*Math.exp(t*P*g)]};else{var k=Math.sqrt(v),x=(p*p-u*u+r*v)/(2*u*n*k),C=(p*p-u*u-r*v)/(2*p*n*k),S=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(C*C+1)-C);g=(N-S)/t,b=function(P){var R=P*g,z=PN(S),E=u/(n*k)*(z*FB(t*R+S)-DB(S));return[l+E*m,c+E*y,u*z/PN(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 Oc=0,ed=0,Du=0,bP=1e3,om,td,am=0,rl=0,sg=0,Yd=typeof performance=="object"&&performance.now?performance:Date,kP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wk(){return rl||(kP(zB),rl=Yd.now()+sg)}function zB(){rl=0}function lm(){this._call=this._time=this._next=null}lm.prototype=vP.prototype={constructor:lm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Wk():+n)+(t==null?0:+t),!this._next&&td!==this&&(td?td._next=this:om=this,td=this),this._call=e,this._time=n,Ux()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ux())}};function vP(e,t,n){var r=new lm;return r.restart(e,t,n),r}function BB(){Wk(),++Oc;for(var e=om,t;e;)(t=rl-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Oc}function RN(){rl=(am=Yd.now())+sg,Oc=ed=0;try{BB()}finally{Oc=0,HB(),rl=0}}function WB(){var e=Yd.now(),t=e-am;t>bP&&(sg-=t,am=e)}function HB(){for(var e,t=om,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:om=n);td=e,Ux(r)}function Ux(e){if(!Oc){ed&&(ed=clearTimeout(ed));var t=e-rl;t>24?(e<1/0&&(ed=setTimeout(RN,e-Yd.now()-sg)),Du&&(Du=clearInterval(Du))):(Du||(am=Yd.now(),Du=setInterval(WB,bP)),Oc=1,kP(RN))}}function TN(e,t,n){var r=new lm;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var VB=ng("start","end","cancel","interrupt"),KB=[],SP=0,MN=1,Yx=2,bh=3,$N=4,Gx=5,kh=6;function ig(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:VB,tween:KB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:SP})}function Hk(e,t){var n=fi(e,t);if(n.state>SP)throw new Error("too late; already scheduled");return n}function Fi(e,t){var n=fi(e,t);if(n.state>bh)throw new Error("too late; already running");return n}function fi(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=vP(o,0,n.time);function o(u){n.state=MN,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,m;if(n.state!==MN)return c();for(d in r)if(m=r[d],m.name===n.name){if(m.state===bh)return TN(a);m.state===$N?(m.state=kh,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[d]):+d<t&&(m.state=kh,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[d])}if(TN(function(){n.state===bh&&(n.state=$N,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Yx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Yx){for(n.state=bh,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(m=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=m);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Gx,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Gx&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=kh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function vh(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>Yx&&r.state<Gx,r.state=kh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function UB(e){return this.each(function(){vh(this,e)})}function YB(e,t){var n,r;return function(){var s=Fi(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 GB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Fi(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 JB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=fi(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?YB:GB)(n,e,t))}function Vk(e,t,n){var r=e._id;return e.each(function(){var s=Fi(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return fi(s,r).value[t]}}function jP(e,t){var n;return(typeof t=="number"?vi:t instanceof nl?im:(n=nl(t))?(t=n,im):yP)(e,t)}function XB(e){return function(){this.removeAttribute(e)}}function QB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ZB(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 e4(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 t4(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 n4(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 r4(e,t){var n=rg(e),r=n==="transform"?LB:jP;return this.attrTween(e,typeof t=="function"?(n.local?n4:t4)(n,r,Vk(this,"attr."+e,t)):t==null?(n.local?QB:XB)(n):(n.local?e4:ZB)(n,r,t))}function s4(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function i4(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function o4(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&i4(e,o)),n}return s._value=t,s}function a4(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&s4(e,o)),n}return s._value=t,s}function l4(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=rg(e);return this.tween(n,(r.local?o4:a4)(r,t))}function c4(e,t){return function(){Hk(this,e).delay=+t.apply(this,arguments)}}function u4(e,t){return t=+t,function(){Hk(this,e).delay=t}}function d4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?c4:u4)(t,e)):fi(this.node(),t).delay}function f4(e,t){return function(){Fi(this,e).duration=+t.apply(this,arguments)}}function p4(e,t){return t=+t,function(){Fi(this,e).duration=t}}function h4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?f4:p4)(t,e)):fi(this.node(),t).duration}function m4(e,t){if(typeof t!="function")throw new Error;return function(){Fi(this,e).ease=t}}function g4(e){var t=this._id;return arguments.length?this.each(m4(t,e)):fi(this.node(),t).ease}function y4(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Fi(this,e).ease=n}}function w4(e){if(typeof e!="function")throw new Error;return this.each(y4(this._id,e))}function x4(e){typeof e!="function"&&(e=tP(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 ho(r,this._parents,this._name,this._id)}function b4(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],d=c.length,f=a[l]=new Array(d),p,m=0;m<d;++m)(p=c[m]||u[m])&&(f[m]=p);for(;l<r;++l)a[l]=t[l];return new ho(a,this._parents,this._name,this._id)}function k4(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 v4(e,t,n){var r,s,o=k4(t)?Hk:Fi;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function S4(e,t){var n=this._id;return arguments.length<2?fi(this.node(),n).on.on(e):this.each(v4(n,e,t))}function j4(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function N4(){return this.on("end.remove",j4(this._id))}function C4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Dk(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),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,ig(u[p],t,n,p,u,fi(d,n)));return new ho(o,this._parents,t,n)}function _4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=eP(e));for(var r=this._groups,s=r.length,o=[],a=[],l=0;l<s;++l)for(var c=r[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),m,y=fi(d,n),v=0,b=p.length;v<b;++v)(m=p[v])&&ig(m,t,n,v,p,y);o.push(p),a.push(d)}return new ho(o,a,t,n)}var A4=bf.prototype.constructor;function E4(){return new A4(this._groups,this._parents)}function I4(e,t){var n,r,s;return function(){var o=Lc(this,e),a=(this.style.removeProperty(e),Lc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function NP(e){return function(){this.style.removeProperty(e)}}function P4(e,t,n){var r,s=n+"",o;return function(){var a=Lc(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function R4(e,t,n){var r,s,o;return function(){var a=Lc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Lc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function T4(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Fi(this,e),u=c.on,d=c.value[o]==null?l||(l=NP(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(a,s=d),c.on=r}}function M4(e,t,n){var r=(e+="")=="transform"?$B:jP;return t==null?this.styleTween(e,I4(e,r)).on("end.style."+e,NP(e)):typeof t=="function"?this.styleTween(e,R4(e,r,Vk(this,"style."+e,t))).each(T4(this._id,e)):this.styleTween(e,P4(e,r,t),n).on("end.style."+e,null)}function $4(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function L4(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&$4(e,a,n)),r}return o._value=t,o}function O4(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,L4(e,t,n??""))}function D4(e){return function(){this.textContent=e}}function F4(e){return function(){var t=e(this);this.textContent=t??""}}function z4(e){return this.tween("text",typeof e=="function"?F4(Vk(this,"text",e)):D4(e==null?"":e+""))}function B4(e){return function(t){this.textContent=e.call(this,t)}}function W4(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&B4(s)),t}return r._value=e,r}function H4(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,W4(e))}function V4(){for(var e=this._name,t=this._id,n=CP(),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 d=fi(c,t);ig(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ho(r,this._parents,e,n)}function K4(){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=Fi(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&o()})}var q4=0;function ho(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function CP(){return++q4}var Yi=bf.prototype;ho.prototype={constructor:ho,select:C4,selectAll:_4,selectChild:Yi.selectChild,selectChildren:Yi.selectChildren,filter:x4,merge:b4,selection:E4,transition:V4,call:Yi.call,nodes:Yi.nodes,node:Yi.node,size:Yi.size,empty:Yi.empty,each:Yi.each,on:S4,attr:r4,attrTween:l4,style:M4,styleTween:O4,text:z4,textTween:H4,remove:N4,tween:JB,delay:d4,duration:h4,ease:g4,easeVarying:w4,end:K4,[Symbol.iterator]:Yi[Symbol.iterator]};function U4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Y4={time:null,delay:0,duration:250,ease:U4};function G4(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 J4(e){var t,n;e instanceof ho?(t=e._id,e=e._name):(t=CP(),(n=Y4).time=Wk(),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])&&ig(c,e,t,u,a,n||G4(c,t));return new ho(r,this._parents,e,t)}bf.prototype.interrupt=UB;bf.prototype.transition=J4;const $p=e=>()=>e;function X4(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 no(e,t,n){this.k=e,this.x=t,this.y=n}no.prototype={constructor:no,scale:function(e){return e===1?this:new no(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new no(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 og=new no(1,0,0);_P.prototype=no.prototype;function _P(e){for(;!e.__zoom;)if(!(e=e.parentNode))return og;return e.__zoom}function Xy(e){e.stopImmediatePropagation()}function Fu(e){e.preventDefault(),e.stopImmediatePropagation()}function Q4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Z4(){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 LN(){return this.__zoom||og}function eW(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function tW(){return navigator.maxTouchPoints||"ontouchstart"in this}function nW(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 AP(){var e=Q4,t=Z4,n=nW,r=eW,s=tW,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=xh,u=ng("start","zoom","end"),d,f,p,m=500,y=150,v=0,b=10;function g(M){M.property("__zoom",LN).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",LN),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?C($):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?C(H):typeof F=="function"?F.apply(this,arguments):F;return n(og.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 no(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 no(M.k,F,$)}function C(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?C(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,Y=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=Y(ne),se=W/re[2];ne=new no(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=ds(this.that).datum();u.call(M,this.that,new X4(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=ei(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)],vh(this),B.start()}Fu(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(p||!e.apply(this,arguments))return;var B=M.currentTarget,F=N(this,V,!0).event(M),$=ds(M.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",W,!0),H=ei(M,B),A=M.clientX,Q=M.clientY;dP(M.view),Xy(M),F.mouse=[H,this.__zoom.invert(H)],vh(this),F.start();function K(te){if(Fu(te),!F.moved){var Z=te.clientX-A,Y=te.clientY-Q;F.moved=Z*Z+Y*Y>v}F.event(te).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=ei(te,B),F.mouse[1]),F.extent,a))}function W(te){$.on("mousemove.zoom mouseup.zoom",null),fP(te.view,F.moved),Fu(te),F.event(te).end()}}function E(M,...V){if(e.apply(this,arguments)){var B=this.__zoom,F=ei(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);Fu(M),l>0?ds(this).transition().duration(l).call(S,A,F,M):ds(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(Xy(M),A=0;A<F;++A)Q=B[A],K=ei(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+!!d);d&&(d=clearTimeout(d)),H&&($.taps<2&&(f=K[0],d=setTimeout(function(){d=null},m)),vh(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(Fu(M),H=0;H<$;++H)A=F[H],Q=ei(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],Y=B.touch1[1],ne=(ne=Z[0]-W[0])*ne+(ne=Z[1]-W[1])*ne,re=(re=Y[0]-te[0])*re+(re=Y[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]+Y[0])/2,(te[1]+Y[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(Xy(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),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=ei(A,this),Math.hypot(f[0]-A[0],f[1]-A[1])<b)){var Q=ds(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return g.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:$p(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:$p(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:$p(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:$p([[+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 Oi={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."},Gd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],EP=["Enter"," ","Escape"],IP={"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 Dc;(function(e){e.Strict="strict",e.Loose="loose"})(Dc||(Dc={}));var Ya;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ya||(Ya={}));var Jd;(function(e){e.Partial="partial",e.Full="full"})(Jd||(Jd={}));const PP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Bo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Bo||(Bo={}));var Ci;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ci||(Ci={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));const ON={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top};function RP(e){return e===null?null:e?"valid":"invalid"}const TP=e=>"id"in e&&"source"in e&&"target"in e,rW=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Kk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vf=(e,t=[0,0])=>{const{width:n,height:r}=xo(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},sW=(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):Kk(s)?s:t.nodeLookup.get(s.id));const l=a?cm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ag(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return lg(n)},Sf=(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=ag(n,cm(s)),r=!0)}),r?lg(n):{x:0,y:0,width:0,height:0}},qk=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...Nf(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(a&&!f||p)continue;const m=d.width??u.width??u.initialWidth??null,y=d.height??u.height??u.initialHeight??null,v=Xd(l,zc(u)),b=(m??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},iW=(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 oW(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 aW({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=oW(e,a),c=Sf(l),u=Uk(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 MP({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},d=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Oi.error005());else{const m=l.measured.width,y=l.measured.height;m&&y&&(f=[[c,u],[c+m,u+y]])}else l&&Bc(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Bc(f)?sl(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Oi.error015())),{position:{x:p.x-c+(a.measured.width??0)*d[0],y:p.y-u+(a.measured.height??0)*d[1]},positionAbsolute:p}}async function lW({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const m=o.has(p.id),y=!m&&p.parentId&&a.find(v=>v.id===p.parentId);(m||y)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=iW(a,c);for(const p of c)l.has(p.id)&&!d.find(y=>y.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const Fc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),sl=(e={x:0,y:0},t,n)=>({x:Fc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Fc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function $P(e,t,n){const{width:r,height:s}=xo(n),{x:o,y:a}=n.internals.positionAbsolute;return sl(e,[[o,a],[o+r,a+s]],t)}const DN=(e,t,n)=>e<t?Fc(Math.abs(e-t),1,t)/t:e>n?-Fc(Math.abs(e-n),1,t)/t:0,LP=(e,t,n=15,r=40)=>{const s=DN(e.x,r,t.width-r)*n,o=DN(e.y,r,t.height-r)*n;return[s,o]},ag=(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)}),Jx=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),lg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),zc=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Kk(e)?e.internals.positionAbsolute:vf(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}},cm=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Kk(e)?e.internals.positionAbsolute:vf(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)}},OP=(e,t)=>lg(ag(Jx(e),Jx(t))),Xd=(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)},FN=e=>si(e.width)&&si(e.height)&&si(e.x)&&si(e.y),si=e=>!isNaN(e)&&isFinite(e),cW=(e,t)=>{},jf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Nf=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?jf(l,a):l},um=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Wl(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 uW(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Wl(e,n),s=Wl(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Wl(e.top??e.y??0,n),s=Wl(e.bottom??e.y??0,n),o=Wl(e.left??e.x??0,t),a=Wl(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 dW(e,t,n,r,s,o){const{x:a,y:l}=um(e,[t,n,r]),{x:c,y:u}=um({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const Uk=(e,t,n,r,s,o)=>{const a=uW(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Fc(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,m=t/2-f*d,y=n/2-p*d,v=dW(e,m,y,d,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:m-b.left+b.right,y:y-b.top+b.bottom,zoom:d}},Qd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Bc(e){return e!=null&&e!=="parent"}function xo(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 DP(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 FP(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 zN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function fW(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function pW(e){return{...IP,...e||{}}}function xd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=ii(e),l=Nf({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?jf(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Yk=e=>({width:e.offsetWidth,height:e.offsetHeight}),zP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},hW=["INPUT","SELECT","TEXTAREA"];function BP(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:hW.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const WP=e=>"clientX"in e,ii=(e,t)=>{var o,a;const n=WP(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)}},BN=(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,...Yk(a)}})};function HP({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,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function Lp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function WN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ue.Left:return[t-Lp(t-r,o),n];case Ue.Right:return[t+Lp(r-t,o),n];case Ue.Top:return[t,n-Lp(n-s,o)];case Ue.Bottom:return[t,n+Lp(s-n,o)]}}function VP({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top,curvature:a=.25}){const[l,c]=WN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=WN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,m,y]=HP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${s}`,f,p,m,y]}function KP({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 mW({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 gW({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=ag(cm(e),cm(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 Xd(a,lg(o))>0}const yW=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,wW=(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)),Sh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||yW;let s;return TP(e)?s={...e}:s={...e,id:r(e)},wW(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function qP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=KP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const HN={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},xW=({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},VN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bW({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:r=Ue.Top,center:s,offset:o,stepPosition:a}){const l=HN[t],c=HN[r],u={x:e.x+l.x*o,y:e.y+l.y*o},d={x:n.x+c.x*o,y:n.y+c.y*o},f=xW({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",m=f[p];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,C]=KP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(v=s.x??u.x+(d.x-u.x)*a,b=s.y??(u.y+d.y)/2):(v=s.x??(u.x+d.x)/2,b=s.y??u.y+(d.y-u.y)*a);const R=[{x:v,y:u.y},{x:v,y:d.y}],z=[{x:u.x,y:b},{x:d.x,y:b}];l[p]===m?y=p==="x"?R:z:y=p==="x"?z:R}else{const R=[{x:u.x,y:d.y}],z=[{x:d.x,y:u.y}];if(p==="x"?y=l.x===m?z:R:y=l.y===m?R:z,t===r){const M=Math.abs(e[p]-n[p]);if(M<=o){const V=Math.min(o-1,o-M);l[p]===m?g[p]=(u[p]>e[p]?-1:1)*V:k[p]=(d[p]>n[p]?-1:1)*V}}if(t!==r){const M=p==="x"?"y":"x",V=l[p]===c[M],B=u[M]>d[M],F=u[M]<d[M];(l[p]===1&&(!V&&B||V&&F)||l[p]!==1&&(!V&&F||V&&B))&&(y=p==="x"?R:z)}const E={x:u.x+g.x,y:u.y+g.y},O={x:d.x+k.x,y:d.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:d.x+k.x,y:d.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,C]}function kW(e,t,n,r){const s=Math.min(VN(e,t)/2,VN(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,d=e.y<n.y?1:-1;return`L ${o+s*u},${a}Q ${o},${a} ${o},${a+s*d}`}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 Xx({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:d=.5}){const[f,p,m,y,v]=bW({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:d});let b=`M${f[0].x} ${f[0].y}`;for(let g=1;g<f.length-1;g++)b+=kW(f[g-1],f[g],f[g+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,p,m,y,v]}function KN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function vW(e){var f;const{sourceNode:t,targetNode:n}=e;if(!KN(t)||!KN(n))return null;const r=t.internals.handleBounds||qN(t.handles),s=n.internals.handleBounds||qN(n.handles),o=UN((r==null?void 0:r.source)??[],e.sourceHandle),a=UN(e.connectionMode===Dc.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",Oi.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=il(t,o,l),d=il(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function qN(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 il(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??xo(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 UN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Qx(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function SW(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=Qx(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 UP=1e3,jW=10,Gk={nodeOrigin:[0,0],nodeExtent:Gd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},NW={...Gk,checkEquality:!0};function Jk(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function CW(e,t,n){const r=Jk(Gk,n);for(const s of e.values())if(s.parentId)Qk(s,e,t,r);else{const o=vf(s,r.nodeOrigin),a=Bc(s.extent)?s.extent:r.nodeExtent,l=sl(o,a,xo(s));s.internals.positionAbsolute=l}}function _W(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 Xk(e){return e==="manual"}function Zx(e,t,n,r={}){var d,f;const s=Jk(NW,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Xk(s.zIndexMode)?UP:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const p of e){let m=a.get(p.id);if(s.checkEquality&&p===(m==null?void 0:m.internals.userNode))t.set(p.id,m);else{const y=vf(p,s.nodeOrigin),v=Bc(p.extent)?p.extent:s.nodeExtent,b=sl(y,v,xo(p));m={...s.defaults,...p,measured:{width:(d=p.measured)==null?void 0:d.width,height:(f=p.measured)==null?void 0:f.height},internals:{positionAbsolute:b,handleBounds:_W(p,m),z:YP(p,l,s.zIndexMode),userNode:p}},t.set(p.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),p.parentId&&Qk(m,t,n,r,o),u||(u=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function AW(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 Qk(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Jk(Gk,r),u=e.parentId,d=t.get(u);if(!d){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}AW(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*jW),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=o&&!Xk(c)?UP:0,{x:p,y:m,z:y}=EW(e,d,a,l,f,c),{positionAbsolute:v}=e.internals,b=p!==v.x||m!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:p,y:m}:v,z:y}})}function YP(e,t,n){const r=si(e.zIndex)?e.zIndex:0;return Xk(n)?r:r+(e.selected?t:0)}function EW(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=xo(e),u=vf(e,n),d=Bc(e.extent)?sl(u,e.extent,c):u;let f=sl({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=$P(f,c,t));const p=YP(e,s,o),m=t.internals.z??0;return{x:f.x,y:f.y,z:m>=p?m+1:p}}function Zk(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)??zc(c),d=OP(u,l.rect);o.set(l.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=xo(c),p=c.origin??r,m=l.x<d.x?Math.round(Math.abs(d.x-l.x)):0,y=l.y<d.y?Math.round(Math.abs(d.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)*p[0],k=(b-f.height)*p[1];(m>0||y>0||g||k)&&(s.push({id:u,type:"position",position:{x:c.position.x-m+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(C=>{e.some(S=>S.id===C.id)||s.push({id:C.id,type:"position",position:{x:C.position.x+m,y:C.position.y+y}})})),(f.width<l.width||f.height<l.height||m||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(m?p[0]*m-g:0),height:b+(y?p[1]*y-k:0)}})}),s}function IW(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=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.transform),p=[];for(const m of e.values()){const y=t.get(m.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=Yk(m.nodeElement),b=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!y.internals.handleBounds||m.force))){const k=m.nodeElement.getBoundingClientRect(),x=Bc(y.extent)?y.extent:o;let{positionAbsolute:C}=y.internals;y.parentId&&y.extent==="parent"?C=$P(C,v,t.get(y.parentId)):x&&(C=sl(C,x,v));const S={...y,measured:v,internals:{...y.internals,positionAbsolute:C,handleBounds:{source:BN("source",m.nodeElement,k,f,y.id),target:BN("target",m.nodeElement,k,f,y.id)}}};t.set(y.id,S),y.parentId&&Qk(S,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:zc(S,s)}))}}if(p.length>0){const m=Zk(p,t,n,s);u.push(...m)}return{changes:u,updatedInternals:c}}async function PW({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 YN(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 GP(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}`,d=`${o}-${l}--${s}-${a}`;YN("source",c,d,e,s,a),YN("target",c,u,e,o,l),t.set(r.id,r)}}function JP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:JP(n,t):!1}function GN(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 RW(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!JP(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 Qy({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:d.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 TW({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=jf(o,t);return{x:a.x-o.x,y:a.y-o.y}}function MW({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},d=null,f=!1,p=null,m=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:C,isSelectable:S,nodeId:N,nodeClickDistance:P=0}){p=ds(C);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?Jx(Sf(l)):null,Y=te&&F?TW({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=Y?{x:Math.round(se.x+Y.x),y:Math.round(se.y+Y.y)}:jf(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],Ce=pe.y-Z.y+V[0][1],He=pe.y+re.measured.height-Z.y2+V[1][1];ee=[[Me,Ce],[Ne,He]]}const{position:ue,positionAbsolute:de}=MP({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]=Qy({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(!d)return;const{transform:D,panBy:L,autoPanSpeed:M,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(a);return}const[B,F]=LP(u,d,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=xd(D.sourceEvent,{transform:B,snapGrid:F,snapToGrid:$,containerBounds:d});if(o=W,l=RW(L,V,W,N),l.size>0&&(n||A||!N&&Q)){const[Z,Y]=Qy({nodeId:N,dragItems:l,nodeLookup:L});n==null||n(D.sourceEvent,l,Z,Y),A==null||A(D.sourceEvent,Z,Y),N||Q==null||Q(D.sourceEvent,Y)}}const O=pP().clickDistance(P).on("start",D=>{const{domNode:L,nodeDragThreshold:M,transform:V,snapGrid:B,snapToGrid:F}=t();d=(L==null?void 0:L.getBoundingClientRect())||null,m=!1,y=!1,v=D.sourceEvent,M===0&&E(D),o=xd(D.sourceEvent,{transform:V,snapGrid:B,snapToGrid:F,containerBounds:d}),u=ii(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:L,transform:M,snapGrid:V,snapToGrid:B,nodeDragThreshold:F,nodeLookup:$}=t(),H=xd(D.sourceEvent,{transform:M,snapGrid:V,snapToGrid:B,containerBounds:d});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||N&&!$.has(N))&&(m=!0),!m){if(!c&&L&&f&&(c=!0,z()),!f){const A=ii(D.sourceEvent,d),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=ii(D.sourceEvent,d),R(H))}}).on("end",D=>{if(!(!f||m)&&(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,$]=Qy({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||!GN(L,`.${k}`,C))&&(!x||GN(L,x,C))});p.call(O)}function g(){p==null||p.on(".drag",null)}return{update:b,destroy:g}}function $W(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())Xd(s,zc(o))>0&&r.push(o);return r}const LW=250;function OW(e,t,n,r){var l,c;let s=[],o=1/0;const a=$W(e,n,t+LW);for(const u of a){const d=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:m}=il(u,f,f.position,!0),y=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(m-e.y,2));y>t||(y<o?(s=[{...f,x:p,y:m}],o=y):y===o&&s.push({...f,x:p,y:m}))}}if(!s.length)return null;if(s.length>1){const u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function XP(e,t,n,r,s,o=!1){var u,d,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...il(a,c,c.position,!0)}:c}function QP(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function DW(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ZP=()=>!0;function FW(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:m,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=ZP,onReconnectEnd:k,updateConnection:x,getTransform:C,getFromHandle:S,autoPanSpeed:N,dragThreshold:P=1,handleDomNode:R}){const z=zP(e.target);let E=0,O;const{x:D,y:L}=ii(e),M=QP(o,R),V=l==null?void 0:l.getBoundingClientRect();let B=!1;if(!V||!M)return;const F=XP(s,M,r,c,t);if(!F)return;let $=ii(e,V),H=!1,A=null,Q=!1,K=null;function W(){if(!d||!V)return;const[ue,de]=LP($,V,N);p({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:il(Z,te,Ue.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:Z,to:$,toHandle:null,toPosition:ON[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}=ii(ue),yt=He-D,Re=ct-L;if(!(yt*yt+Re*Re>P*P))return;re()}if(!S()||!te){ee(ue);return}const de=C();$=ii(ue,V),O=OW(Nf($,de,!1,[1,1]),n,c,te),H||(W(),H=!0);const pe=eR(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=DW(!!O,pe.isValid);const Me=c.get(s),Ne=Me?il(Me,te,Ue.Left,!0):ne.from,Ce={...ne,from:Ne,isValid:Q,to:pe.toHandle&&Q?um({x:pe.toHandle.x,y:pe.toHandle.y},de):$,toHandle:pe.toHandle,toPosition:Q&&pe.toHandle?pe.toHandle.position:ON[te.position],toNode:pe.toHandle?c.get(pe.toHandle.nodeId):null,pointer:$};x(Ce),ne=Ce}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))}m(),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 eR(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=ZP,nodeLookup:d}){const f=o==="target",p=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:m,y}=ii(e),v=a.elementFromPoint(m,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:p,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=QP(void 0,b),x=b.getAttribute("data-nodeid"),C=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?C:s,target:f?r:x,targetHandle:f?s:C};g.connection=P;const z=S&&N&&(n===Dc.Strict?f&&k==="source"||!f&&k==="target":x!==r||C!==s);g.isValid=z&&u(P),g.toHandle=XP(x,k,C,d,n,!0)}return g}const eb={onPointerDown:FW,isValid:eR};function zW({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ds(e);function o({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:m=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const C=n(),S=x.sourceEvent.ctrlKey&&Qd()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,P=C[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 C=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(C[2],Math.log(C[2]))*(m?-1:1),R={x:C[0]-N[0]*P,y:C[1]-N[1]*P},z=[[0,0],[c,u]];t.setViewportConstrained({x:R.x,y:R.y,zoom:C[2]},z,l)},k=AP().on("start",b).on("zoom",f?g:null).on("zoom.wheel",p?y:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:o,destroy:a,pointer:ei}}const cg=e=>({x:e.x,y:e.y,zoom:e.k}),Zy=({x:e,y:t,zoom:n})=>og.translate(e,t).scale(n),uc=(e,t)=>e.target.closest(`.${t}`),tR=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),BW=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ew=(e,t=0,n=BW,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},nR=e=>{const t=e.ctrlKey&&Qd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function WW({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(uc(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const b=ei(d),g=nR(d),k=f*Math.pow(2,g);r.scaleTo(n,k,b,d);return}const p=d.deltaMode===1?20:1;let m=s===Ya.Vertical?0:d.deltaX*p,y=s===Ya.Horizontal?0:d.deltaY*p;!Qd()&&d.shiftKey&&s!==Ya.Vertical&&(m=d.deltaY*p,y=0),r.translateBy(n,-(m/f)*o,-(y/f)*o,{internal:!0});const v=cg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,v))}}function HW({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=uc(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function VW({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=cg(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 KW({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&tR(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,cg(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&&tR(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=cg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function UW({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var b;const p=e||t,m=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(uc(f,`${u}-flow__node`)||uc(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!o&&!n||a||d&&!y||uc(f,l)&&y||uc(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(!p&&!s&&!m&&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 YW({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},d=e.getBoundingClientRect(),f=AP().scaleExtent([t,n]).translateExtent(r),p=ds(e).call(f);k({x:s.x,y:s.y,zoom:Fc(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const m=p.on("wheel.zoom"),y=p.on("dblclick.zoom");f.wheelDelta(nR);function v(O,D){return p?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?wd:xh).transform(ew(p,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:Y,paneClickDistance:ne,selectionOnDrag:re}){M&&!u.isZoomingOrPanning&&g();const se=V&&!W&&!M;f.clickDistance(re?1/0:!si(ne)||ne<0?0:ne);const ee=se?WW({zoomPanValues:u,noWheelClassName:O,d3Selection:p,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:$,zoomOnPinch:A,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):HW({noWheelClassName:O,preventScrolling:H,d3ZoomHandler:m});if(p.on("wheel.zoom",ee,{passive:!1}),!M){const de=VW({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const pe=KW({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=UW({zoomActivationKeyPressed:W,panOnDrag:B,zoomOnScroll:Q,panOnScroll:V,zoomOnDoubleClick:K,zoomOnPinch:A,userSelectionActive:M,noPanClassName:D,noWheelClassName:O,lib:te,connectionInProgress:Y});f.filter(ue),K?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)}function g(){f.on("zoom",null)}async function k(O,D,L){const M=Zy(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=Zy(O);return await v(L,D),new Promise(M=>M(L))}function C(O){if(p){const D=Zy(O),L=p.property("__zoom");(L.k!==O.zoom||L.x!==O.x||L.y!==O.y)&&(f==null||f.transform(p,D,null,{sync:!0}))}}function S(){const O=p?_P(p.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function N(O,D){return p?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?wd:xh).scaleTo(ew(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function P(O,D){return p?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?wd:xh).scaleBy(ew(p,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=!si(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:C,setClickDistance:E}}var Wc;(function(e){e.Line="line",e.Handle="handle"})(Wc||(Wc={}));function GW({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 JN(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 To(e,t){return Math.max(0,t-e)}function Mo(e,t){return Math.max(0,e-t)}function Op(e,t,n){return Math.max(0,t-e,e-n)}function XN(e,t){return e?!t:t}function JW(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:m,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:C,width:S,height:N,aspectRatio:P}=e;let R=Math.floor(d?m-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=Op(E,v,b),V=Op(O,g,k);if(a){let $=0,H=0;c&&R<0?$=To(x+R+D,a[0][0]):!c&&R>0&&($=Mo(x+E+D,a[1][0])),u&&z<0?H=To(C+z+L,a[0][1]):!u&&z>0&&(H=Mo(C+O+L,a[1][1])),M=Math.max(M,$),V=Math.max(V,H)}if(l){let $=0,H=0;c&&R>0?$=Mo(x+R,l[0][0]):!c&&R<0&&($=To(x+E,l[1][0])),u&&z>0?H=Mo(C+z,l[0][1]):!u&&z<0&&(H=To(C+O,l[1][1])),M=Math.max(M,$),V=Math.max(V,H)}if(s){if(d){const $=Op(E/P,g,k)*P;if(M=Math.max(M,$),a){let H=0;!c&&!u||c&&!u&&p?H=Mo(C+L+E/P,a[1][1])*P:H=To(C+L+(c?R:-R)/P,a[0][1])*P,M=Math.max(M,H)}if(l){let H=0;!c&&!u||c&&!u&&p?H=To(C+E/P,l[1][1])*P:H=Mo(C+(c?R:-R)/P,l[0][1])*P,M=Math.max(M,H)}}if(f){const $=Op(O*P,v,b)/P;if(V=Math.max(V,$),a){let H=0;!c&&!u||u&&!c&&p?H=Mo(x+O*P+D,a[1][0])/P:H=To(x+(u?z:-z)*P+D,a[0][0])/P,V=Math.max(V,H)}if(l){let H=0;!c&&!u||u&&!c&&p?H=To(x+O*P,l[1][0])/P:H=Mo(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&&(p?E>O*P?z=(XN(c,u)?-R:R)/P:R=(XN(c,u)?-z:z)*P:d?(z=R/P,u=c):(R=z*P,c=u));const B=c?x+R:x,F=u?C+z:C;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 rR={width:0,height:0,x:0,y:0},XW={...rR,pointerX:0,pointerY:0,aspectRatio:1};function QW(e){return[[0,0],[e.measured.width,e.measured.height]]}function ZW(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 e5({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=ds(e);let a={controlDirection:JN("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:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...rR},k={...XW};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:JN(u)};let x,C=null,S=[],N,P,R,z=!1;const E=pP().on("start",O=>{const{nodeLookup:D,transform:L,snapGrid:M,snapToGrid:V,nodeOrigin:B,paneDomNode:F}=n();if(x=D.get(t),!x)return;C=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:H}=xd(O.sourceEvent,{transform:L,snapGrid:M,snapToGrid:V,containerBounds:C});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"?QW(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=ZW(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}m==null||m(O,{...g})}).on("drag",O=>{const{transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V}=n(),B=xd(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:M,containerBounds:C}),F=[];if(!x)return;const{x:$,y:H,width:A,height:Q}=g,K={},W=x.origin??V,{width:te,height:Z,x:Y,y:ne}=JW(k,a.controlDirection,B,a.boundaries,a.keepAspectRatio,W,P,R),re=te!==A,se=Z!==Q,ee=Y!==$&&re,ue=ne!==H&&se;if(!ee&&!ue&&!re&&!se)return;if((ee||ue||W[0]===1||W[1]===1)&&(K.x=ee?Y:g.x,K.y=ue?ne:g.y,g.x=K.x,g.y=K.y,S.length>0)){const Ne=Y-$,Ce=ne-H;for(const He of S)He.position={x:He.position.x-Ne+W[0]*(te-A),y:He.position.y-Ce+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 Ce=W[1]*(K.height??0);K.y&&K.y<Ce&&(g.y=Ce,k.y=k.y-(K.y-Ce))}const de=GW({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 sR={exports:{}},iR={},oR={exports:{}},aR={};/**
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 Hc=h;function t5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n5=typeof Object.is=="function"?Object.is:t5,r5=Hc.useState,s5=Hc.useEffect,i5=Hc.useLayoutEffect,o5=Hc.useDebugValue;function a5(e,t){var n=t(),r=r5({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return i5(function(){s.value=n,s.getSnapshot=t,tw(s)&&o({inst:s})},[e,n,t]),s5(function(){return tw(s)&&o({inst:s}),e(function(){tw(s)&&o({inst:s})})},[e]),o5(n),n}function tw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n5(e,n)}catch{return!0}}function l5(e,t){return t()}var c5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l5:a5;aR.useSyncExternalStore=Hc.useSyncExternalStore!==void 0?Hc.useSyncExternalStore:c5;oR.exports=aR;var lR=oR.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 ug=h,u5=lR;function d5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var f5=typeof Object.is=="function"?Object.is:d5,p5=u5.useSyncExternalStore,h5=ug.useRef,m5=ug.useEffect,g5=ug.useMemo,y5=ug.useDebugValue;iR.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=h5(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=g5(function(){function c(m){if(!u){if(u=!0,d=m,m=r(m),s!==void 0&&a.hasValue){var y=a.value;if(s(y,m))return f=y}return f=m}if(y=f,f5(d,m))return y;var v=r(m);return s!==void 0&&s(y,v)?(d=m,y):(d=m,f=v)}var u=!1,d,f,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=p5(e,o[0],o[1]);return m5(function(){a.hasValue=!0,a.value=l},[l]),y5(l),l};sR.exports=iR;var w5=sR.exports;const x5=da(w5),b5={},QN=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const m=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(y=>y(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(b5?"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},k5=e=>e?QN(e):QN,{useDebugValue:v5}=pt,{useSyncExternalStoreWithSelector:S5}=x5,j5=e=>e;function cR(e,t=j5,n){const r=S5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return v5(r),r}const ZN=(e,t)=>{const n=k5(e),r=(s,o=t)=>cR(n,s,o);return Object.assign(r,n),r},N5=(e,t)=>e?ZN(e,t):ZN;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 dg=h.createContext(null),C5=dg.Provider,uR=Oi.error001();function Vt(e,t){const n=h.useContext(dg);if(n===null)throw new Error(uR);return cR(n,e,t)}function dn(){const e=h.useContext(dg);if(e===null)throw new Error(uR);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const e1={display:"none"},_5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},dR="react-flow__node-desc",fR="react-flow__edge-desc",A5="react-flow__aria-live",E5=e=>e.ariaLiveMessage,I5=e=>e.ariaLabelConfig;function P5({rfId:e}){const t=Vt(E5);return i.jsx("div",{id:`${A5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:_5,children:t})}function R5({rfId:e,disableKeyboardA11y:t}){const n=Vt(I5);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${dR}-${e}`,style:e1,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${fR}-${e}`,style:e1,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(P5,{rfId:e})]})}const fg=h.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})});fg.displayName="Panel";function T5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(fg,{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 M5=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}},Dp=e=>e.id;function $5(e,t){return bn(e.selectedNodes.map(Dp),t.selectedNodes.map(Dp))&&bn(e.selectedEdges.map(Dp),t.selectedEdges.map(Dp))}function L5({onSelectionChange:e}){const t=dn(),{selectedNodes:n,selectedEdges:r}=Vt(M5,$5);return h.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const O5=e=>!!e.onSelectionChangeHandlers;function D5({onSelectionChange:e}){const t=Vt(O5);return e||t?i.jsx(L5,{onSelectionChange:e}):null}const tb=typeof window<"u"?h.useLayoutEffect:h.useEffect,pR=[0,0],F5={x:0,y:0,zoom:1},z5=["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"],t1=[...z5,"rfId"],B5=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}),n1={translateExtent:Gd,nodeOrigin:pR,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function W5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Vt(B5,bn),u=dn();tb(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=n1,l()}),[]);const d=h.useRef(n1);return tb(()=>{for(const f of t1){const p=e[f],m=d.current[f];p!==m&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?o(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:pW(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},t1.map(f=>e[f])),null}function r1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function H5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const s=r1(),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=r1())!=null&&r.matches?"dark":"light"}const s1=typeof document<"u"?document:null;function Zd(e=null,t={target:s1,actInsideInputWithModifier:!0}){const[n,r]=h.useState(!1),s=h.useRef(!1),o=h.useRef(new Set([])),[a,l]=h.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
+ `)),d=u.reduce((f,p)=>f.concat(...p),[]);return[u,d]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??s1,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=m=>{var b,g;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!u)&&BP(m))return!1;const v=o1(m.code,l);if(o.current.add(m[v]),i1(a,o.current,!1)){const k=((g=(b=m.composedPath)==null?void 0:b.call(m))==null?void 0:g[0])||m.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&m.preventDefault(),r(!0)}},f=m=>{const y=o1(m.code,l);i1(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(m[y]),m.key==="Meta"&&o.current.clear(),s.current=!1},p=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function i1(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function o1(e,t){return t.includes(e)?"code":"key"}const V5=()=>{const e=dn();return h.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=Uk(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},d=n.snapGrid??s,f=n.snapToGrid??o;return Nf(u,r,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),a=um(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function hR(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)K5(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 K5(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 bd(e,t){return hR(e,t)}function dm(e,t){return hR(e,t)}function Ra(e,t){return{id:e,type:"select",selected:t}}function dc(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(Ra(o.id,a)))}return r}function a1({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 l1(e){return{id:e.id,type:"remove"}}const c1=e=>rW(e),q5=e=>TP(e);function mR(e){return h.forwardRef(e)}function u1(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>U5(()=>n(s=>s+BigInt(1))));return tb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function U5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const gR=h.createContext(null);function Y5({children:e}){const t=dn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:p,fitViewQueued:m,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=a1({items:v,lookup:p});for(const g of y.values())b=g(b);d&&u(v),b.length>0?f==null||f(b):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=u1(n),s=h.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:p}=t.getState();let m=c;for(const y of l)m=typeof y=="function"?y(m):y;d?u(m):f&&f(a1({items:m,lookup:p}))},[]),o=u1(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(gR.Provider,{value:a,children:e})}function G5(){const e=h.useContext(gR);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const J5=e=>!!e.panZoom;function Xc(){const e=V5(),t=dn(),n=G5(),r=Vt(J5),s=h.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:p,nodeOrigin:m}=t.getState(),y=c1(f)?f:p.get(f.id),v=y.parentId?FP(y.position,y.measured,y.parentId,p,m):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 zc(b)},u=(f,p,m={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return m.replace&&c1(b)?b:{...v,...b}}return v}))},d=(f,p,m={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return m.replace&&q5(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var p;return(p=o(f))==null?void 0:p.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(p=>({...p}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const p=Array.isArray(f)?f:[f];n.nodeQueue.push(m=>[...m,...p])},addEdges:f=>{const p=Array.isArray(f)?f:[f];n.edgeQueue.push(m=>[...m,...p])},toObject:()=>{const{nodes:f=[],edges:p=[],transform:m}=t.getState(),[y,v,b]=m;return{nodes:f.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:m,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:C}=t.getState(),{nodes:S,edges:N}=await lW({nodesToRemove:f,edgesToRemove:p,nodes:m,edges:y,onBeforeDelete:C}),P=N.length>0,R=S.length>0;if(P){const z=N.map(l1);b==null||b(N),k(z)}if(R){const z=S.map(l1);v==null||v(S),g(z)}return(R||P)&&(x==null||x({nodes:S,edges:N})),{deletedNodes:S,deletedEdges:N}},getIntersectingNodes:(f,p=!0,m)=>{const y=FN(f),v=y?f:c(f),b=m!==void 0;return v?(m||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=zc(b?g:k),C=Xd(x,v);return p&&C>0||C>=x.width*x.height||C>=v.width*v.height}):[]},isNodeIntersecting:(f,p,m=!0)=>{const v=FN(f)?f:c(f);if(!v)return!1;const b=Xd(v,p);return m&&b>0||b>=p.width*p.height||b>=v.width*v.height},updateNode:u,updateNodeData:(f,p,m={replace:!1})=>{u(f,y=>{const v=typeof p=="function"?p(y):p;return m.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},m)},updateEdge:d,updateEdgeData:(f,p,m={replace:!1})=>{d(f,y=>{const v=typeof p=="function"?p(y):p;return m.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},m)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:m}=t.getState();return sW(f,{nodeLookup:p,nodeOrigin:m})},getHandleConnections:({type:f,id:p,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${f}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:p,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${f?p?`-${f}-${p}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const p=t.getState().fitViewResolver??fW();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:p}),n.nodeQueue.push(m=>[...m]),p.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const d1=e=>e.selected,X5=typeof window<"u"?window:void 0;function Q5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=dn(),{deleteElements:r}=Xc(),s=Zd(e,{actInsideInputWithModifier:!1}),o=Zd(t,{target:X5});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(d1),edges:a.filter(d1)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function Z5(e){const t=dn();h.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=Yk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Oi.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 pg={position:"absolute",width:"100%",height:"100%",top:0,left:0},eH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function tH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=Ya.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:C}){const S=dn(),N=h.useRef(null),{userSelectionActive:P,lib:R,connectionInProgress:z}=Vt(eH,bn),E=Zd(p),O=h.useRef();Z5(N);const D=h.useCallback(L=>{g==null||g({x:L[0],y:L[1],zoom:L[2]}),k||S.setState({transform:L})},[g,k]);return h.useEffect(()=>{if(N.current){O.current=YW({domNode:N.current,minZoom:d,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()}}},[]),h.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:m,noPanClassName:b,userSelectionActive:P,noWheelClassName:v,lib:R,onTransformChange:D,connectionInProgress:z,selectionOnDrag:C,paneClickDistance:x})},[e,t,n,r,s,o,a,l,E,m,b,P,v,R,D,z,C,x]),i.jsx("div",{className:"react-flow__renderer",ref:N,style:pg,children:y})}const nH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function rH(){const{userSelectionActive:e,userSelectionRect:t}=Vt(nH,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 nw=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},sH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function iH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Jd.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:y}){const v=dn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Vt(sH,bn),C=g&&(e||b),S=h.useRef(null),N=h.useRef(),P=h.useRef(new Set),R=h.useRef(new Set),z=h.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=d?$=>d($):void 0,L=$=>{z.current&&($.stopPropagation(),z.current=!1)},M=$=>{var Z,Y;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;(Y=(Z=$.target)==null?void 0:Z.setPointerCapture)==null||Y.call(Z,$.pointerId),z.current=!1;const{x:W,y:te}=ii($.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:Y,resetSelectedElements:ne}=v.getState();if(!N.current||!H)return;const{x:re,y:se}=ii($.nativeEvent,N.current),{startX:ee,startY:ue}=H;if(!z.current){const Ce=t?0:s;if(Math.hypot(re-ee,se-ue)<=Ce)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(qk(Q,de,A,n===Jd.Partial,!0).map(Ce=>Ce.id)),R.current=new Set;const Ne=(Y==null?void 0:Y.selectable)??!0;for(const Ce of P.current){const He=W.get(Ce);if(He)for(const{edgeId:ct}of He.values()){const yt=K.get(ct);yt&&(yt.selectable??Ne)&&R.current.add(ct)}}if(!zN(pe,P.current)){const Ce=dc(Q,P.current,!0);te(Ce)}if(!zN(Me,R.current)){const Ce=dc(K,R.current);Z(Ce)}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:C?void 0:nw(E,S),onContextMenu:nw(O,S),onWheel:nw(D,S),onPointerEnter:C?void 0:f,onPointerMove:C?V:p,onPointerUp:C?B:void 0,onPointerDownCapture:C?M:void 0,onClickCapture:C?L:void 0,onPointerLeave:m,ref:S,style:pg,children:[y,i.jsx(rH,{})]})}function nb({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",Oi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function yR({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=dn(),[c,u]=h.useState(!1),d=h.useRef();return h.useEffect(()=>{d.current=MW({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{nb({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,r,t,o,e,s,a]),c}const oH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function wR(){const e=dn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,p=oH(a),m=s?o[0]:5,y=s?o[1]:5,v=n.direction.x*m*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!p(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};s&&(k=jf(k,o));const{position:x,positionAbsolute:C}=MP({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:l});g.position=x,g.internals.positionAbsolute=C,f.set(g.id,g)}c(f)},[])}const ev=h.createContext(null),aH=ev.Provider;ev.Consumer;const xR=()=>h.useContext(ev),lH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),cH=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,d=(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:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===Dc.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:d&&u}};function uH({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:d,onTouchStart:f,...p},m){var V,B;const y=a||null,v=e==="target",b=dn(),g=xR(),{connectOnClick:k,noPanClassName:x,rfId:C}=Vt(lH,bn),{connectingFrom:S,connectingTo:N,clickConnecting:P,isPossibleEndHandle:R,connectionInProcess:z,clickConnectionInProcess:E,valid:O}=Vt(cH(g,y,e),bn);g||(B=(V=b.getState()).onError)==null||B.call(V,"010",Oi.error010());const D=F=>{const{defaultEdgeOptions:$,onConnect:H,hasDefaultEdges:A}=b.getState(),Q={...$,...F};if(A){const{edges:K,setEdges:W}=b.getState();W(Sh(Q,K))}H==null||H(Q),l==null||l(Q)},L=F=>{if(!g)return;const $=WP(F.nativeEvent);if(s&&($&&F.button===0||!$)){const H=b.getState();eb.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})}$?d==null||d(F):f==null||f(F)},M=F=>{const{onClickConnectStart:$,onClickConnectEnd:H,connectionClickStartHandle:A,connectionMode:Q,isValidConnection:K,lib:W,rfId:te,nodeLookup:Z,connection:Y}=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=zP(F.target),re=n||K,{connection:se,isValid:ee}=eb.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(Y);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":`${C}-${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:m,...p,children:c})}const qn=h.memo(mR(uH));function dH({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 fH({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 pH(){return null}function hH({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 fm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},f1={input:dH,default:fH,output:hH,group:pH};function mH(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 gH=e=>{const{width:t,height:n,x:r,y:s}=Sf(e.nodeLookup,{filter:o=>!!o.selected});return{width:si(t)?t:null,height:si(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 yH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=dn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Vt(gH,bn),c=wR(),u=h.useRef(null);h.useEffect(()=>{var m;n||(m=u.current)==null||m.focus({preventScroll:!0})},[n]);const d=!l&&s!==null&&o!==null;if(yR({nodeRef:u,disabled:!d}),!d)return null;const f=e?m=>{const y=r.getState().nodes.filter(v=>v.selected);e(m,y)}:void 0,p=m=>{Object.prototype.hasOwnProperty.call(fm,m.key)&&(m.preventDefault(),c({direction:fm[m.key],factor:m.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:p,style:{width:s,height:o}})})}const p1=typeof window<"u"?window:void 0,wH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function bR({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:C,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(wH,bn),K=Zd(u,{target:p1}),W=Zd(v,{target:p1}),te=W||R,Z=W||C,Y=d&&te!==!0,ne=K||Q||Y;return Q5({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(tH,{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:Y,children:i.jsxs(iH,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:te,isSelecting:!!ne,selectionMode:f,selectionKeyPressed:K,paneClickDistance:l,selectionOnDrag:Y,children:[e,A&&i.jsx(yH,{onSelectionContextMenu:M,noPanClassName:B,disableKeyboardA11y:F})]})})}bR.displayName="FlowRenderer";const xH=h.memo(bR),bH=e=>t=>e?qk(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 kH(e){return Vt(h.useCallback(bH(e),[e]),bn)}const vH=e=>e.updateNodeInternals;function SH(){const e=Vt(vH),[t]=h.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 h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function jH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=dn(),o=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),u=h.useRef(t),d=n&&!!e.internals.handleBounds;return h.useEffect(()=>{o.current&&!e.hidden&&(!d||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[d,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(o.current){const f=u.current!==t,p=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(f||p||m)&&(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 NH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:C,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])||f1[N];P===void 0&&(k==null||k("003",Oi.error003(N)),N="default",P=(b==null?void 0:b.default)||f1.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||d&&typeof x.focusable>"u"),D=dn(),L=DP(x),M=jH({node:x,nodeType:N,hasDimensions:L,resizeObserver:f}),V=yR({nodeRef:M,disabled:x.hidden||!R,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:g}),B=wR();if(x.hidden)return null;const F=xo(x),$=mH(x),H=z||R||t||n||r||s,A=n?re=>n(re,{...C.userNode}):void 0,Q=r?re=>r(re,{...C.userNode}):void 0,K=s?re=>s(re,{...C.userNode}):void 0,W=o?re=>o(re,{...C.userNode}):void 0,te=a?re=>a(re,{...C.userNode}):void 0,Z=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:ee}=D.getState();z&&(!se||!R||ee>0)&&nb({id:e,store:D,nodeRef:M}),t&&t(re,{...C.userNode})},Y=re=>{if(!(BP(re.nativeEvent)||y)){if(EP.includes(re.key)&&z){const se=re.key==="Escape";nb({id:e,store:D,unselect:se,nodeRef:M})}else if(R&&x.selected&&Object.prototype.hasOwnProperty.call(fm,re.key)){re.preventDefault();const{ariaLabelConfig:se}=D.getState();D.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),B({direction:fm[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;qk(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}`,{[m]:R},x.className,{selected:x.selected,selectable:z,parent:S,draggable:R,dragging:V}]),ref:M,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.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?Y: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:`${dR}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(aH,{value:e,children:i.jsx(P,{id:e,data:x.data,type:N,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.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:C.z,parentId:x.parentId,...F})})})}var CH=h.memo(NH);const _H=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function kR(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Vt(_H,bn),a=kH(e.onlyRenderVisibleElements),l=SH();return i.jsx("div",{className:"react-flow__nodes",style:pg,children:a.map(c=>i.jsx(CH,{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))})}kR.displayName="NodeRenderer";const AH=h.memo(kR);function EH(e){return Vt(h.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&&gW({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),bn)}const IH=({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"})},PH=({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"})},h1={[Ci.Arrow]:IH,[Ci.ArrowClosed]:PH};function RH(e){const t=dn();return h.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(h1,e)?h1[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Oi.error009(e)),null)},[e])}const TH=({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=RH(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},vR=({defaultColor:e,rfId:t})=>{const n=Vt(o=>o.edges),r=Vt(o=>o.defaultEdgeOptions),s=h.useMemo(()=>SW(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(TH,{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};vR.displayName="MarkerDefinitions";var MH=h.memo(vR);function SR({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...d}){const[f,p]=h.useState({x:1,y:0,width:0,height:0}),m=Un(["react-flow__edge-textwrapper",u]),y=h.useRef(null);return h.useEffect(()=>{if(y.current){const v=y.current.getBBox();p({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:m,visibility:f.width?"visible":"hidden",...d,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}SR.displayName="EdgeText";const $H=h.memo(SR);function hg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return i.jsxs(i.Fragment,{children:[i.jsx("path",{...d,d:e,fill:"none",className:Un(["react-flow__edge-path",d.className])}),u?i.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&si(t)&&si(n)?i.jsx($H,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function m1({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 jR({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:s,targetPosition:o=Ue.Top}){const[a,l]=m1({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=m1({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,f,p,m]=HP({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}`,d,f,p,m]}function NR(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,C]=jR({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),S=e.isInternal?void 0:t;return i.jsx(hg,{id:S,path:k,labelX:x,labelY:C,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const LH=NR({isInternal:!1}),CR=NR({isInternal:!0});LH.displayName="SimpleBezierEdge";CR.displayName="SimpleBezierEdgeInternal";function _R(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,sourcePosition:m=Ue.Bottom,targetPosition:y=Ue.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,C,S]=Xx({sourceX:n,sourceY:r,sourcePosition:m,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(hg,{id:N,path:x,labelX:C,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:v,markerStart:b,interactionWidth:k})})}const AR=_R({isInternal:!1}),ER=_R({isInternal:!0});AR.displayName="SmoothStepEdge";ER.displayName="SmoothStepEdgeInternal";function IR(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(AR,{...n,id:r,pathOptions:h.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const OH=IR({isInternal:!1}),PR=IR({isInternal:!0});OH.displayName="StepEdge";PR.displayName="StepEdgeInternal";function RR(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:m,markerStart:y,interactionWidth:v})=>{const[b,g,k]=qP({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(hg,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:m,markerStart:y,interactionWidth:v})})}const DH=RR({isInternal:!1}),TR=RR({isInternal:!0});DH.displayName="StraightEdge";TR.displayName="StraightEdgeInternal";function MR(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=Ue.Bottom,targetPosition:l=Ue.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,C,S]=VP({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(hg,{id:N,path:x,labelX:C,labelY:S,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const FH=MR({isInternal:!1}),$R=MR({isInternal:!0});FH.displayName="BezierEdge";$R.displayName="BezierEdgeInternal";const g1={default:$R,straight:TR,step:PR,smoothstep:ER,simplebezier:CR},y1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},zH=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,BH=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,w1="react-flow__edgeupdater";function x1({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([w1,`${w1}-${l}`]),cx:zH(t,r,e),cy:BH(n,r,e),r,stroke:"transparent",fill:"transparent"})}function WH({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:p,setUpdateHover:m}){const y=dn(),v=(C,S)=>{if(C.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)=>{p(!1),f==null||f(Q,n,S.type,K)},H=Q=>u==null?void 0:u(n,Q),A=(Q,K)=>{p(!0),d==null||d(C,n,S.type),O==null||O(Q,K)};eb.onPointerDown(C.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:C.currentTarget})},b=C=>v(C,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=C=>v(C,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>m(!0),x=()=>m(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(x1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(x1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function HH({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Vt(de=>de.edgeLookup.get(e));const C=Vt(de=>de.defaultEdgeOptions);x=C?{...C,...x}:x;let S=x.type||"default",N=(v==null?void 0:v[S])||g1[S];N===void 0&&(g==null||g("011",Oi.error011(S)),S="default",N=(v==null?void 0:v.default)||g1.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=h.useRef(null),[O,D]=h.useState(!1),[L,M]=h.useState(!1),V=dn(),{zIndex:B,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K}=Vt(h.useCallback(de=>{const pe=de.nodeLookup.get(x.source),Me=de.nodeLookup.get(x.target);if(!pe||!Me)return{zIndex:x.zIndex,...y1};const Ne=vW({id:e,sourceNode:pe,targetNode:Me,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:mW({selected:x.selected,zIndex:x.zIndex,sourceNode:pe,targetNode:Me,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Ne||y1}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),bn),W=h.useMemo(()=>x.markerStart?`url('#${Qx(x.markerStart,y)}')`:void 0,[x.markerStart,y]),te=h.useMemo(()=>x.markerEnd?`url('#${Qx(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||$===null||H===null||A===null)return null;const Z=de=>{var Ce;const{addSelectedEdges:pe,unselectNodesAndEdges:Me,multiSelectionActive:Ne}=V.getState();z&&(V.setState({nodesSelectionActive:!1}),x.selected&&Ne?(Me({nodes:[],edges:[x]}),(Ce=E.current)==null||Ce.blur()):pe([e])),s&&s(de,x)},Y=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&&EP.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:Y,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?`${fR}-${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(WH,{edge:x,isReconnectable:R,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,sourceX:F,sourceY:$,targetX:H,targetY:A,sourcePosition:Q,targetPosition:K,setUpdateHover:D,setReconnecting:M})]})})}var VH=h.memo(HH);const KH=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function LR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:p,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Vt(KH,bn),C=EH(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(MH,{defaultColor:e,rfId:n}),C.map(S=>i.jsx(VH,{id:S,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:s,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:p,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},S))]})}LR.displayName="EdgeRenderer";const qH=h.memo(LR),UH=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function YH({children:e}){const t=Vt(UH);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function GH(e){const t=Xc(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const JH=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function XH(e){const t=Vt(JH),n=dn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function QH(e){return e.connection.inProgress?{...e.connection,to:Nf(e.connection.to,e.transform)}:{...e.connection}}function ZH(e){return QH}function e6(e){const t=ZH();return Vt(t,bn)}const t6=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function n6({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Vt(t6,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",RP(l)]),children:i.jsx(OR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const OR=({style:e,type:t=Bo.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:p,pointer:m}=e6();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:p,connectionStatus:RP(r),toNode:d,toHandle:f,pointer:m});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:p};switch(t){case Bo.Bezier:[y]=VP(v);break;case Bo.SimpleBezier:[y]=jR(v);break;case Bo.Step:[y]=Xx({...v,borderRadius:0});break;case Bo.SmoothStep:[y]=Xx(v);break;default:[y]=qP(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};OR.displayName="ConnectionLine";const r6={};function b1(e=r6){h.useRef(e),dn(),h.useEffect(()=>{},[e])}function s6(){dn(),h.useRef(!1),h.useEffect(()=>{},[])}function DR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:C,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:Y,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:ee,nodeClickDistance:ue,onEdgeContextMenu:de,onEdgeMouseEnter:pe,onEdgeMouseMove:Me,onEdgeMouseLeave:Ne,reconnectRadius:Ce,onReconnect:He,onReconnectStart:ct,onReconnectEnd:yt,noDragClassName:Re,noWheelClassName:ot,noPanClassName:kt,disableKeyboardA11y:$t,nodeExtent:ye,rfId:ze,viewport:oe,onViewportChange:ke}){return b1(e),b1(t),s6(),GH(n),XH(oe),i.jsx(xH,{onPaneClick:te,onPaneMouseEnter:Z,onPaneMouseMove:Y,onPaneMouseLeave:ne,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:ee,deleteKeyCode:R,selectionKeyCode:k,selectionOnDrag:x,selectionMode:C,onSelectionStart:p,onSelectionEnd:m,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:ot,noPanClassName:kt,disableKeyboardA11y:$t,onViewportChange:ke,isControlledViewport:!!oe,children:i.jsxs(YH,{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:Ce,defaultMarkerColor:B,noPanClassName:kt,disableKeyboardA11y:$t,rfId:ze}),i.jsx(n6,{style:v,type:y,component:b,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(AH,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:ue,onlyRenderVisibleElements:z,noPanClassName:kt,noDragClassName:Re,disableKeyboardA11y:$t,nodeExtent:ye,rfId:ze}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}DR.displayName="GraphView";const i6=h.memo(DR),k1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:p="basic"}={})=>{const m=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=d??[0,0],C=f??Gd;GP(v,b,g);const{nodesInitialized:S}=Zx(k,m,y,{nodeOrigin:x,nodeExtent:C,zIndexMode:p});let N=[0,0,1];if(a&&s&&o){const P=Sf(m,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:R,y:z,zoom:E}=Uk(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:m,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:Gd,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Dc.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:{...PP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:cW,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:IP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},o6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p})=>N5((m,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:C,height:S,minZoom:N,maxZoom:P}=y();g&&(await aW({nodes:b,width:C,height:S,panZoom:g,minZoom:N,maxZoom:P},k),x==null||x.resolve(!0),m({fitViewResolver:null}))}return{...k1({nodes:e,edges:t,width:s,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:C,fitViewQueued:S,zIndexMode:N,nodesSelectionActive:P}=y(),{nodesInitialized:R,hasSelectedNodes:z}=Zx(b,g,k,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:N}),E=P&&z;S&&R?(v(),m({nodes:b,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:E})):m({nodes:b,nodesInitialized:R,nodesSelectionActive:E})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();GP(g,k,b),m({edges:b})},setDefaultNodesAndEdges:(b,g)=>{if(b){const{setNodes:k}=y();k(b),m({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),m({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:x,domNode:C,nodeOrigin:S,nodeExtent:N,debug:P,fitViewQueued:R,zIndexMode:z}=y(),{changes:E,updatedInternals:O}=IW(b,k,x,C,S,N,z);O&&(CW(k,x,{nodeOrigin:S,nodeExtent:N,zIndexMode:z}),R?(v(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(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:C,triggerNodeChanges:S,connection:N,updateConnection:P,onNodesChangeMiddlewareMap:R}=y();for(const[z,E]of b){const O=C.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=il(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=Zk(k,C,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:C,debug:S}=y();if(b!=null&&b.length){if(C){const N=bd(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:C,debug:S}=y();if(b!=null&&b.length){if(C){const N=dm(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:C,triggerEdgeChanges:S}=y();if(g){const N=b.map(P=>Ra(P,!0));C(N);return}C(dc(x,new Set([...b]),!0)),S(dc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:C,triggerEdgeChanges:S}=y();if(g){const N=b.map(P=>Ra(P,!0));S(N);return}S(dc(k,new Set([...b]))),C(dc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:C,triggerNodeChanges:S,triggerEdgeChanges:N}=y(),P=b||x,R=g||k,z=[];for(const O of P){if(!O.selected)continue;const D=C.get(O.id);D&&(D.selected=!1),z.push(Ra(O.id,!1))}const E=[];for(const O of R)O.selected&&E.push(Ra(O.id,!1));S(z),N(E)},setMinZoom:b=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([b,k]),m({minZoom:b})},setMaxZoom:b=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,b]),m({maxZoom:b})},setTranslateExtent:b=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(b),m({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:x,elementsSelectable:C}=y();if(!C)return;const S=g.reduce((P,R)=>R.selected?[...P,Ra(R.id,!1)]:P,[]),N=b.reduce((P,R)=>R.selected?[...P,Ra(R.id,!1)]:P,[]);k(S),x(N)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:C,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]||(Zx(g,k,x,{nodeOrigin:C,nodeExtent:b,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:P}),m({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:C,translateExtent:S}=y();return PW({delta:b,panZoom:C,transform:g,translateExtent:S,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:C,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:C/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:()=>{m({connection:{...PP}})},updateConnection:b=>{m({connection:b})},reset:()=>m({...k1()})}},Object.is);function tv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:m}){const[y]=h.useState(()=>o6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:p}));return i.jsx(C5,{value:y,children:i.jsx(Y5,{children:m})})}function a6({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m}){return h.useContext(dg)?i.jsx(i.Fragment,{children:e}):i.jsx(tv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:m,children:e})}const l6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function c6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:m,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:C,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=Bo.Bezier,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:Z,deleteKeyCode:Y="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:se=Jd.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ue=Qd()?"Meta":"Control",zoomActivationKeyCode:de=Qd()?"Meta":"Control",snapToGrid:pe,snapGrid:Me,onlyRenderVisibleElements:Ne=!1,selectNodesOnDrag:Ce,nodesDraggable:He,autoPanOnNodeFocus:ct,nodesConnectable:yt,nodesFocusable:Re,nodeOrigin:ot=pR,edgesFocusable:kt,edgesReconnectable:$t,elementsSelectable:ye=!0,defaultViewport:ze=F5,minZoom:oe=.5,maxZoom:ke=2,translateExtent:Be=Gd,preventScrolling:Qe=!0,nodeExtent:_e,defaultMarkerColor:_t="#b1b1b7",zoomOnScroll:Xt=!0,zoomOnPinch:Ft=!0,panOnScroll:at=!1,panOnScrollSpeed:Fn=.5,panOnScrollMode:ie=Ya.Free,zoomOnDoubleClick:Ie=!0,panOnDrag:et=!0,onPaneClick:qe,onPaneMouseEnter:Pt,onPaneMouseMove:vt,onPaneMouseLeave:tr,onPaneScroll:Yn,onPaneContextMenu:Tr,paneClickDistance:kn=1,nodeClickDistance:nr=0,children:pr,onReconnect:hr,onReconnectStart:fn,onReconnectEnd:zn,onEdgeContextMenu:is,onEdgeDoubleClick:Ds,onEdgeMouseEnter:vn,onEdgeMouseMove:Gn,onEdgeMouseLeave:bs,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:rt,defaultEdgeOptions:zt,elevateNodesOnSelect:Rn=!0,elevateEdgesOnSelect:jr=!1,disableKeyboardA11y:Nr=!1,autoPanOnConnect:mr,autoPanOnNodeDrag:ut,autoPanSpeed:Ut,connectionRadius:Yt,isValidConnection:Xn,onError:it,style:gr,id:Fs,nodeDragThreshold:Bi,connectionDragThreshold:zs,viewport:ae,onViewportChange:ve,width:Te,height:bt,colorMode:Rt="light",debug:Qt,onScroll:pn,ariaLabelConfig:$n,zIndexMode:ks="basic",...vs},q){const we=Fs||"1",$e=H5(Rt),Ae=h.useCallback(Ze=>{Ze.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),pn==null||pn(Ze)},[pn]);return i.jsx("div",{"data-testid":"rf__wrapper",...vs,onScroll:Ae,style:{...gr,...l6},ref:q,className:Un(["react-flow",s,$e]),id:Fs,role:"application",children:i.jsxs(a6,{nodes:e,edges:t,width:Te,height:bt,fitView:$r,fitViewOptions:ce,minZoom:oe,maxZoom:ke,nodeOrigin:ot,nodeExtent:_e,zIndexMode:ks,children:[i.jsx(W5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,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:_e,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:d,onMoveStart:f,onMoveEnd:p,noPanClassName:Mr,nodeOrigin:ot,rfId:we,autoPanOnConnect:mr,autoPanOnNodeDrag:ut,autoPanSpeed:Ut,onError:it,connectionRadius:Yt,isValidConnection:Xn,selectNodesOnDrag:Ce,nodeDragThreshold:Bi,connectionDragThreshold:zs,onBeforeDelete:A,debug:Qt,ariaLabelConfig:$n,zIndexMode:ks}),i.jsx(i6,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:C,onNodeContextMenu:S,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:K,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:Z,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:se,deleteKeyCode:Y,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:at,panOnScrollSpeed:Fn,panOnScrollMode:ie,panOnDrag:et,onPaneClick:qe,onPaneMouseEnter:Pt,onPaneMouseMove:vt,onPaneMouseLeave:tr,onPaneScroll:Yn,onPaneContextMenu:Tr,paneClickDistance:kn,nodeClickDistance:nr,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:H,onReconnect:hr,onReconnectStart:fn,onReconnectEnd:zn,onEdgeContextMenu:is,onEdgeDoubleClick:Ds,onEdgeMouseEnter:vn,onEdgeMouseMove:Gn,onEdgeMouseLeave:bs,reconnectRadius:Jn,defaultMarkerColor:_t,noDragClassName:Sr,noWheelClassName:Wn,noPanClassName:Mr,rfId:we,disableKeyboardA11y:Nr,nodeExtent:_e,viewport:ae,onViewportChange:ve}),i.jsx(D5,{onSelectionChange:L}),pr,i.jsx(T5,{proOptions:rt,position:tt}),i.jsx(R5,{rfId:we,disableKeyboardA11y:Nr})]})})}var FR=mR(c6);function u6(){const e=dn();return h.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 d6(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(o=>bd(s,o)),[]);return[t,n,r]}function f6(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(o=>dm(s,o)),[]);return[t,n,r]}function p6({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 h6({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Un(["react-flow__background-pattern","dots",t])})}var ta;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ta||(ta={}));const m6={[ta.Dots]:1,[ta.Lines]:1,[ta.Cross]:6},g6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function zR({id:e,variant:t=ta.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:d}){const f=h.useRef(null),{transform:p,patternId:m}=Vt(g6,bn),y=r||m6[t],v=t===ta.Dots,b=t===ta.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*p[2]||1,g[1]*p[2]||1],x=y*p[2],C=Array.isArray(o)?o:[o,o],S=b?[x,x]:k,N=[C[0]*p[2]||1+S[0]/2,C[1]*p[2]||1+S[1]/2],P=`${m}${e||""}`;return i.jsxs("svg",{className:Un(["react-flow__background",u]),style:{...c,...pg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i.jsx("pattern",{id:P,x:p[0]%k[0],y:p[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?i.jsx(h6,{radius:x/2,className:d}):i.jsx(p6,{dimensions:S,lineWidth:s,variant:t,className:d})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}zR.displayName="Background";const BR=h.memo(zR);function y6(){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 w6(){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 x6(){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 b6(){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 k6(){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 Fp({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Un(["react-flow__controls-button",t]),...n,children:e})}const v6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function WR({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:p="vertical","aria-label":m}){const y=dn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Vt(v6,bn),{zoomIn:x,zoomOut:C,fitView:S}=Xc(),N=()=>{x(),o==null||o()},P=()=>{C(),a==null||a()},R=()=>{S(s),l==null||l()},z=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},E=p==="horizontal"?"horizontal":"vertical";return i.jsxs(fg,{className:Un(["react-flow__controls",E,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":m??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Fp,{onClick:N,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(y6,{})}),i.jsx(Fp,{onClick:P,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:i.jsx(w6,{})})]}),n&&i.jsx(Fp,{className:"react-flow__controls-fitview",onClick:R,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(x6,{})}),r&&i.jsx(Fp,{className:"react-flow__controls-interactive",onClick:z,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(k6,{}):i.jsx(b6,{})}),d]})}WR.displayName="Controls";h.memo(WR);function S6({id:e,x:t,y:n,width:r,height:s,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:p,onClick:m}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return i.jsx("rect",{className:Un(["react-flow__minimap-node",{selected:p},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:m?g=>m(g,e):void 0})}const j6=h.memo(S6),N6=e=>e.nodes.map(t=>t.id),rw=e=>e instanceof Function?e:()=>e;function C6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=j6,onClick:a}){const l=Vt(N6,bn),c=rw(t),u=rw(e),d=rw(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(p=>i.jsx(A6,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:f},p))})}function _6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:d,y:f,width:p,height:m}=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:C}=xo(b);return{node:b,x:g,y:k,width:x,height:C}},bn);return!u||u.hidden||!DP(u)?null:i.jsx(l,{x:d,y:f,width:p,height:m,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 A6=h.memo(_6);var E6=h.memo(C6);const I6=200,P6=150,R6=e=>!e.hidden,T6=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?OP(Sf(e.nodeLookup,{filter:R6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},M6="react-flow__minimap-desc";function HR({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:p="bottom-right",onClick:m,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:C=5}){const S=dn(),N=h.useRef(null),{boundingRect:P,viewBB:R,rfId:z,panZoom:E,translateExtent:O,flowWidth:D,flowHeight:L,ariaLabelConfig:M}=Vt(T6,bn),V=(e==null?void 0:e.width)??I6,B=(e==null?void 0:e.height)??P6,F=P.width/V,$=P.height/B,H=Math.max(F,$),A=H*V,Q=H*B,K=C*H,W=P.x-(A-P.width)/2-K,te=P.y-(Q-P.height)/2-K,Z=A+K*2,Y=Q+K*2,ne=`${M6}-${z}`,re=h.useRef(0),se=h.useRef();re.current=H,h.useEffect(()=>{if(N.current&&E)return se.current=zW({domNode:N.current,panZoom:E,getTransform:()=>S.getState().transform,getViewScale:()=>re.current}),()=>{var pe;(pe=se.current)==null||pe.destroy()}},[E]),h.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=m?pe=>{var Ce;const[Me,Ne]=((Ce=se.current)==null?void 0:Ce.pointer(pe))||[0,0];m(pe,{x:Me,y:Ne})}:void 0,ue=y?h.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(fg,{position:p,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 d=="string"?d: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} ${Y}`,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(E6,{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${Y+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"})]})})}HR.displayName="MiniMap";h.memo(HR);const $6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,L6={[Wc.Line]:"right",[Wc.Handle]:"bottom-right"};function O6({nodeId:e,position:t,variant:n=Wc.Handle,className:r,style:s=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:m=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=xR(),x=typeof e=="string"?e:k,C=dn(),S=h.useRef(null),N=n===Wc.Handle,P=Vt(h.useCallback($6(N&&m),[N,m]),bn),R=h.useRef(null),z=t??L6[n];h.useEffect(()=>{if(!(!S.current||!x))return R.current||(R.current=e5({domNode:S.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:M,nodeOrigin:V,domNode:B}=C.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}=C.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,...FP({x:O.x??H.position.x,y:O.y??H.position.y},{width:Q,height:K},H.parentId,M,A)}},te=Zk([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:p?p==="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}};C.getState().triggerNodeChanges([L])}})),R.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var O;(O=R.current)==null||O.destroy()}},[z,l,c,u,d,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 nv=h.memo(O6),D6="modulepreload",F6=function(e){return"/"+e},v1={},z6=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=F6(c),c in v1)return;v1[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":D6,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,m)=>{f.addEventListener("load",p),f.addEventListener("error",()=>m(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 B6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const W6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,H6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,V6={};function S1(e,t){return(V6.jsx?H6:W6).test(e)}const K6=/[ \t\n\f\r]/g;function q6(e){return typeof e=="object"?e.type==="text"?j1(e.value):!1:j1(e)}function j1(e){return e.replace(K6,"")===""}class Cf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Cf.prototype.normal={};Cf.prototype.property={};Cf.prototype.space=void 0;function VR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new Cf(n,r,t)}function rb(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 U6=0;const jt=ml(),Vn=ml(),sb=ml(),Pe=ml(),ln=ml(),Sc=ml(),ls=ml();function ml(){return 2**++U6}const ib=Object.freeze(Object.defineProperty({__proto__:null,boolean:jt,booleanish:Vn,commaOrSpaceSeparated:ls,commaSeparated:Sc,number:Pe,overloadedBoolean:sb,spaceSeparated:ln},Symbol.toStringTag,{value:"Module"})),sw=Object.keys(ib);class rv extends ss{constructor(t,n,r,s){let o=-1;if(super(t,n),N1(this,"space",s),typeof r=="number")for(;++o<sw.length;){const a=sw[o];N1(this,sw[o],(r&ib[a])===ib[a])}}}rv.prototype.defined=!0;function N1(e,t,n){n&&(e[t]=n)}function Qc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new rv(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[rb(r)]=r,n[rb(o.attribute)]=r}return new Cf(t,n,e.space)}const KR=Qc({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 qR(e,t){return t in e?e[t]:t}function UR(e,t){return qR(e,t.toLowerCase())}const Y6=Qc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Sc,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|Sc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:jt,defer:jt,dir:null,dirName:null,disabled:jt,download:sb,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:sb,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:UR}),G6=Qc({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:ls,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:Sc,g2:Sc,glyphName:Sc,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:ls,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:ls,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ls,rev:ls,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ls,requiredFeatures:ls,requiredFonts:ls,requiredFormats:ls,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:ls,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:ls,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:ls,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:qR}),YR=Qc({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()}}),GR=Qc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:UR}),JR=Qc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),J6={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"},X6=/[A-Z]/g,C1=/-[a-z]/g,Q6=/^data[-\w.:]+$/i;function Z6(e,t){const n=rb(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"&&Q6.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(C1,t8);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!C1.test(o)){let a=o.replace(X6,e8);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=rv}return new s(r,t)}function e8(e){return"-"+e.toLowerCase()}function t8(e){return e.charAt(1).toUpperCase()}const n8=VR([KR,Y6,YR,GR,JR],"html"),sv=VR([KR,G6,YR,GR,JR],"svg");function r8(e){return e.join(" ").trim()}var iv={},_1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,s8=/\n/g,i8=/^\s*/,o8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a8=/^:\s*/,l8=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c8=/^[;\s]*/,u8=/^\s+|\s+$/g,d8=`
67
+ `,A1="/",E1="*",Ma="",f8="comment",p8="declaration";function h8(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(s8);v&&(n+=v.length);var b=y.lastIndexOf(d8);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(i8)}function d(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(A1!=e.charAt(0)||E1!=e.charAt(1))){for(var v=2;Ma!=e.charAt(v)&&(E1!=e.charAt(v)||A1!=e.charAt(v+1));)++v;if(v+=2,Ma===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:f8,comment:b})}}function p(){var y=o(),v=c(o8);if(v){if(f(),!c(a8))return l("property missing ':'");var b=c(l8),g=y({type:p8,property:I1(v[0].replace(_1,Ma)),value:b?I1(b[0].replace(_1,Ma)):Ma});return c(c8),g}}function m(){var y=[];d(y);for(var v;v=p();)v!==!1&&(y.push(v),d(y));return y}return u(),m()}function I1(e){return e?e.replace(u8,Ma):Ma}var m8=h8,g8=_d&&_d.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(iv,"__esModule",{value:!0});iv.default=w8;const y8=g8(m8);function w8(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,y8.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 mg={};Object.defineProperty(mg,"__esModule",{value:!0});mg.camelCase=void 0;var x8=/^--[a-zA-Z0-9_-]+$/,b8=/-([a-z])/g,k8=/^[^-]+$/,v8=/^-(webkit|moz|ms|o|khtml)-/,S8=/^-(ms)-/,j8=function(e){return!e||k8.test(e)||x8.test(e)},N8=function(e,t){return t.toUpperCase()},P1=function(e,t){return"".concat(t,"-")},C8=function(e,t){return t===void 0&&(t={}),j8(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(S8,P1):e=e.replace(v8,P1),e.replace(b8,N8))};mg.camelCase=C8;var _8=_d&&_d.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},A8=_8(iv),E8=mg;function ob(e,t){var n={};return!e||typeof e!="string"||(0,A8.default)(e,function(r,s){r&&s&&(n[(0,E8.camelCase)(r,t)]=s)}),n}ob.default=ob;var I8=ob;const P8=da(I8),XR=QR("end"),ov=QR("start");function QR(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 R8(e){const t=ov(e),n=XR(e);if(t&&n)return{start:t,end:n}}function kd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?R1(e.position):"start"in e||"end"in e?R1(e):"line"in e||"column"in e?ab(e):""}function ab(e){return T1(e&&e.line)+":"+T1(e&&e.column)}function R1(e){return ab(e&&e.start)+"-"+ab(e&&e.end)}function T1(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=kd(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 av={}.hasOwnProperty,T8=new Map,M8=/[A-Z]/g,$8=new Set(["table","tbody","thead","tfoot","tr"]),L8=new Set(["td","th"]),ZR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function O8(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=K8(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=V8(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"?sv:n8,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=eT(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function eT(e,t,n){if(t.type==="element")return D8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return F8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return B8(e,t,n);if(t.type==="mdxjsEsm")return z8(e,t);if(t.type==="root")return W8(e,t,n);if(t.type==="text")return H8(e,t)}function D8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=sv,e.schema=s),e.ancestors.push(t);const o=nT(e,t.tagName,!1),a=q8(e,t);let l=cv(e,t);return $8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!q6(c):!0})),tT(e,a,o,t),lv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function F8(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)}ef(e,t.position)}function z8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ef(e,t.position)}function B8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=sv,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:nT(e,t.name,!0),a=U8(e,t),l=cv(e,t);return tT(e,a,o,t),lv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function W8(e,t,n){const r={};return lv(r,cv(e,t)),e.create(t,e.Fragment,r,n)}function H8(e,t){return t.value}function tT(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function lv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function V8(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 K8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=ov(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"&&av.call(t.properties,s)){const o=Y8(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&L8.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 U8(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 ef(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 ef(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function cv(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:T8;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=eT(e,o,a);l!==void 0&&n.push(l)}return n}function Y8(e,t,n){const r=Z6(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?B6(n):r8(n)),r.property==="style"){let s=typeof n=="object"?n:G8(e,String(n));return e.stylePropertyNameCase==="css"&&(s=J8(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?J6[r.property]||r.property:r.attribute,n]}}function G8(e,t){try{return P8(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=ZR+"#cannot-parse-style-attribute",s}}function nT(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=S1(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=S1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return av.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);ef(e)}function ef(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=ZR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function J8(e){const t={};let n;for(n in e)av.call(e,n)&&(t[X8(n)]=e[n]);return t}function X8(e){let t=e.replace(M8,Q8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Q8(e){return"-"+e.toLowerCase()}const iw={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"]},Z8={};function e9(e,t){const n=Z8,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return rT(e,r,s)}function rT(e,t,n){if(t9(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 M1(e.children,t,n)}return Array.isArray(e)?M1(e,t,n):""}function M1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=rT(e[s],t,n);return r.join("")}function t9(e){return!!(e&&typeof e=="object")}const $1=document.createElement("i");function uv(e){const t="&"+e+";";$1.innerHTML=t;const n=$1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Di(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 Rs(e,t){return e.length>0?(Di(e,e.length,0,t),e):t}const L1={}.hasOwnProperty;function n9(e){const t={};let n=-1;for(;++n<e.length;)r9(t,e[n]);return t}function r9(e,t){let n;for(n in t){const s=(L1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){L1.call(s,a)||(s[a]=[]);const l=o[a];s9(s[a],Array.isArray(l)?l:l?[l]:[])}}}function s9(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Di(e,0,0,r)}function sT(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 jc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const _i=ma(/[A-Za-z]/),ps=ma(/[\dA-Za-z]/),i9=ma(/[#-'*+\--9=?A-Z^-~]/);function lb(e){return e!==null&&(e<32||e===127)}const cb=ma(/\d/),o9=ma(/[\dA-Fa-f]/),a9=ma(/[!-/:-@[-`{-~]/);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 l9=ma(new RegExp("\\p{P}|\\p{S}","u")),c9=ma(/\s/);function ma(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Zc(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&ps(e.charCodeAt(n+1))&&ps(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 u9={tokenize:d9};function d9(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 f9={tokenize:p9},O1={tokenize:h9};function p9(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const C=t.events.length;let S=C,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=C;for(;P<t.events.length;)t.events[P][1].end={...N},P++;return Di(t.events,S+1,0,t.events.slice(C)),t.events.length=P,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return p(x);if(s.currentConstruct&&s.currentConstruct.concrete)return y(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(O1,d,f)(x)}function d(x){return s&&k(),g(r),p(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function p(x){return t.containerState={},e.attempt(O1,m,y)(x)}function m(x){return r++,n.push([t.currentConstruct,t.containerState]),p(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,C){const S=t.sliceStream(x);if(C&&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++;Di(t.events,R+1,0,t.events.slice(P)),t.events.length=N}}function g(x){let C=n.length;for(;C-- >x;){const S=n[C];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 h9(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 D1(e){if(e===null||ns(e)||c9(e))return 1;if(l9(e))return 2}function dv(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 ub={name:"attention",resolveAll:m9,tokenize:g9};function m9(e,t){let n=-1,r,s,o,a,l,c,u,d;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},p={...e[n][1].start};F1(f,-c),F1(p,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:p},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=Rs(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Rs(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Rs(u,dv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Rs(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Rs(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Di(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function g9(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=D1(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"),d=D1(c),f=!d||d===2&&s||n.includes(c),p=!s||s===2&&d||n.includes(r);return u._open=!!(o===42?f:f&&(s||!p)),u._close=!!(o===42?p:p&&(d||!f)),t(c)}}function F1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const y9={name:"autolink",tokenize:w9};function w9(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(m){return _i(m)?(e.consume(m),a):m===64?n(m):u(m)}function a(m){return m===43||m===45||m===46||ps(m)?(r=1,l(m)):u(m)}function l(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||ps(m))&&r++<32?(e.consume(m),l):(r=0,u(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||lb(m)?n(m):(e.consume(m),c)}function u(m){return m===64?(e.consume(m),d):i9(m)?(e.consume(m),u):n(m)}function d(m){return ps(m)?f(m):n(m)}function f(m){return m===46?(e.consume(m),r=0,d):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||ps(m))&&r++<63){const y=m===45?p:f;return e.consume(m),y}return n(m)}}const gg={partial:!0,tokenize:x9};function x9(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 iT={continuation:{tokenize:k9},exit:v9,name:"blockQuote",tokenize:b9};function b9(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 k9(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(iT,t,n)(a)}}function v9(e){e.exit("blockQuote")}const oT={name:"characterEscape",tokenize:S9};function S9(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 a9(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const aT={name:"characterReference",tokenize:j9};function j9(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=ps,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=o9,d):(e.enter("characterReferenceValue"),o=7,a=cb,d(f))}function d(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===ps&&!uv(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<o?(e.consume(f),d):n(f)}}const z1={partial:!0,tokenize:C9},B1={concrete:!0,name:"codeFenced",tokenize:N9};function N9(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"),d(N)}function d(N){return N===l?(a++,e.consume(N),d):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(z1,v,C)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(N))}function p(N){return N===null||wt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):Jt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),un(e,m,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),p)}function m(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,C,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(z1,v,C)(N):(e.enter("codeFlowValue"),x(N))}function x(N){return N===null||wt(N)?(e.exit("codeFlowValue"),k(N)):(e.consume(N),x)}function C(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 C9(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 ow={name:"codeIndented",tokenize:A9},_9={partial:!0,tokenize:E9};function A9(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 d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):wt(u)?e.attempt(_9,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 E9(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 I9={name:"codeText",previous:R9,resolve:P9,tokenize:T9};function P9(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 R9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function T9(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,d(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 d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class M9{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&&zu(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),zu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),zu(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);zu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);zu(this.left,n.reverse())}}}function zu(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 lT(e){const t={};let n=-1,r,s,o,a,l,c,u;const d=new M9(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.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,$9(d,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(a=d.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(d.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={...d.get(s)[1].start},l=d.slice(s,n),l.unshift(r),d.splice(s,n-s+1,l))}}return Di(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function $9(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 d,f,p=-1,m=n,y=0,v=0;const b=[v];for(;m;){for(;e.get(++s)[1]!==m;);o.push(s),m._tokenizer||(d=r.sliceStream(m),m.next||d.push(null),f&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=m,m=m.next}for(m=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(v=p+1,b.push(v),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):b.pop(),p=b.length;p--;){const g=l.slice(b[p],b[p+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),p=-1;++p<c.length;)u[y+c[p][0]]=y+c[p][1],y+=c[p][1]-c[p][0]-1;return u}const L9={resolve:D9,tokenize:F9},O9={partial:!0,tokenize:z9};function D9(e){return lT(e),e}function F9(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(O9,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 z9(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 cT(e,t,n,r,s,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(g){return g===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(g),e.exit(o),p):g===null||g===32||g===41||lb(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function p(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"}),m(g))}function m(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||wt(g)?n(g):(e.consume(g),g===92?y:m)}function y(g){return g===60||g===62||g===92?(e.consume(g),m):m(g)}function v(g){return!d&&(g===null||g===41||ns(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):d<u&&g===40?(e.consume(g),d++,v):g===41?(e.consume(g),d--,v):g===null||g===32||g===40||lb(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 uT(e,t,n,r,s,o){const a=this;let l=0,c;return u;function u(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(o),d}function d(m){return l>999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(o),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):wt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(m))}function f(m){return m===null||m===91||m===93||wt(m)||l++>999?(e.exit("chunkString"),d(m)):(e.consume(m),c||(c=!Jt(m)),m===92?p:f)}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,f):f(m)}}function dT(e,t,n,r,s,o){let a;return l;function l(p){return p===34||p===39||p===40?(e.enter(r),e.enter(s),e.consume(p),e.exit(s),a=p===40?41:p,c):n(p)}function c(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(o),u(p))}function u(p){return p===a?(e.exit(o),c(a)):p===null?n(p):wt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),un(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||wt(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?f:d)}function f(p){return p===a||p===92?(e.consume(p),d):d(p)}}function vd(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 B9={name:"definition",tokenize:H9},W9={partial:!0,tokenize:V9};function H9(e,t,n){const r=this;let s;return o;function o(m){return e.enter("definition"),a(m)}function a(m){return uT.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=jc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return ns(m)?vd(e,u)(m):u(m)}function u(m){return cT(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function d(m){return e.attempt(W9,f,f)(m)}function f(m){return Jt(m)?un(e,p,"whitespace")(m):p(m)}function p(m){return m===null||wt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function V9(e,t,n){return r;function r(l){return ns(l)?vd(e,s)(l):n(l)}function s(l){return dT(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 K9={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 U9={name:"headingAtx",resolve:Y9,tokenize:G9};function Y9(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"},Di(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function G9(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||ns(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||wt(d)?(e.exit("atxHeading"),t(d)):Jt(d)?un(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||ns(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const J9=["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"],W1=["pre","script","style","textarea"],X9={concrete:!0,name:"htmlFlow",resolveTo:eV,tokenize:tV},Q9={partial:!0,tokenize:rV},Z9={partial:!0,tokenize:nV};function eV(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 tV(e,t,n){const r=this;let s,o,a,l,c;return u;function u(W){return d(W)}function d(W){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(W),f}function f(W){return W===33?(e.consume(W),p):W===47?(e.consume(W),o=!0,v):W===63?(e.consume(W),s=3,r.interrupt?t:A):_i(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function p(W){return W===45?(e.consume(W),s=2,m):W===91?(e.consume(W),s=5,l=0,y):_i(W)?(e.consume(W),s=4,r.interrupt?t:A):n(W)}function m(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 _i(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&&W1.includes(Z)?(s=1,r.interrupt?t(W):D(W)):J9.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||ps(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||_i(W)?(e.consume(W),C):Jt(W)?(e.consume(W),x):E(W)}function C(W){return W===45||W===46||W===58||W===95||ps(W)?(e.consume(W),C):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(Q9,K,L)(W)):W===null||wt(W)?(e.exit("htmlFlowData"),L(W)):(e.consume(W),D)}function L(W){return e.check(Z9,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 W1.includes(te)?(e.consume(W),Q):D(W)}return _i(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 nV(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 rV(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(gg,t,n)}}const sV={name:"htmlText",tokenize:iV};function iV(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):_i(A)?(e.consume(A),R):n(A)}function u(A){return A===45?(e.consume(A),d):A===91?(e.consume(A),o=0,y):_i(A)?(e.consume(A),k):n(A)}function d(A){return A===45?(e.consume(A),m):n(A)}function f(A){return A===null?n(A):A===45?(e.consume(A),p):wt(A)?(a=f,F(A)):(e.consume(A),f)}function p(A){return A===45?(e.consume(A),m):f(A)}function m(A){return A===62?B(A):A===45?p(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),C):wt(A)?(a=x,F(A)):(e.consume(A),x)}function C(A){return A===62?B(A):x(A)}function S(A){return _i(A)?(e.consume(A),N):n(A)}function N(A){return A===45||ps(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||ps(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||_i(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||ps(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 fv={name:"labelEnd",resolveAll:cV,resolveTo:uV,tokenize:dV},oV={tokenize:fV},aV={tokenize:pV},lV={tokenize:hV};function cV(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&&Di(e,0,e.length,n),e}function uV(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}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Rs(l,e.slice(o+1,o+r+3)),l=Rs(l,[["enter",d,t]]),l=Rs(l,dv(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Rs(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=Rs(l,e.slice(a+1)),l=Rs(l,[["exit",c,t]]),Di(e,o,e.length,l),e}function dV(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(p){return o?o._inactive?f(p):(a=r.parser.defined.includes(jc(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),c):n(p)}function c(p){return p===40?e.attempt(oV,d,a?d:f)(p):p===91?e.attempt(aV,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt(lV,d,f)(p)}function d(p){return t(p)}function f(p){return o._balanced=!0,n(p)}}function fV(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)?vd(e,o)(f):o(f)}function o(f){return f===41?d(f):cT(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return ns(f)?vd(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?dT(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return ns(f)?vd(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function pV(e,t,n){const r=this;return s;function s(l){return uT.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(jc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function hV(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 mV={name:"labelStartImage",resolveAll:fv.resolveAll,tokenize:gV};function gV(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 yV={name:"labelStartLink",resolveAll:fv.resolveAll,tokenize:wV};function wV(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 aw={name:"lineEnding",tokenize:xV};function xV(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),un(e,t,"linePrefix")}}const jh={name:"thematicBreak",tokenize:bV};function bV(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:jV},exit:CV,name:"list",tokenize:SV},kV={partial:!0,tokenize:_V},vV={partial:!0,tokenize:NV};function SV(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(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:cb(m)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(jh,n,u)(m):u(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return cb(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),u(m)):n(m)}function u(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(gg,r.interrupt?n:d,e.attempt(kV,p,f))}function d(m){return r.containerState.initialBlankLine=!0,o++,p(m)}function f(m){return Jt(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function jV(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(gg,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(vV,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 NV(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 CV(e){e.exit(this.containerState.type)}function _V(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 H1={name:"setextUnderline",resolveTo:AV,tokenize:EV};function AV(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 EV(e,t,n){const r=this;let s;return o;function o(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][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 IV={tokenize:PV};function PV(e){const t=this,n=e.attempt(gg,r,e.attempt(this.parser.constructs.flowInitial,s,un(e,e.attempt(this.parser.constructs.flow,s,e.attempt(L9,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 RV={resolveAll:pT()},TV=fT("string"),MV=fT("text");function fT(e){return{resolveAll:pT(e==="text"?$V: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(d){return u(d)?o(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let p=-1;if(f)for(;++p<f.length;){const m=f[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function pT(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 $V(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 LV={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:iT},OV={91:B9},DV={[-2]:ow,[-1]:ow,32:ow},FV={35:U9,42:jh,45:[H1,jh],60:X9,61:H1,95:jh,96:B1,126:B1},zV={38:aT,92:oT},BV={[-5]:aw,[-4]:aw,[-3]:aw,33:mV,38:aT,42:ub,60:[y9,sV],91:yV,92:[K9,oT],93:fv,95:ub,96:I9},WV={null:[ub,RV]},HV={null:[42,95]},VV={null:[]},KV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:HV,contentInitial:OV,disable:VV,document:LV,flow:FV,flowInitial:DV,insideSpan:WV,string:zV,text:BV},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:C,interrupt:P(N,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(O){return a=Rs(a,O),b(),a[a.length-1]!==null?[]:(R(t,0),u.events=dv(o,u.events,u),u.events)}function p(O,D){return YV(m(O),D)}function m(O){return UV(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){d=d(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 C(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(Y){return ne;function ne(re){const se=re!==null&&Y[re],ee=re!==null&&Y.null,ue=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(ee)?ee:ee?[ee]:[]];return K(ue)(re)}}function K(Y){return F=Y,$=0,Y.length===0?B:W(Y[$])}function W(Y){return ne;function ne(re){return A=z(),H=Y,Y.partial||(u.currentConstruct=Y),Y.name&&u.parser.constructs.disable.null.includes(Y.name)?Z():Y.tokenize.call(D?Object.assign(Object.create(u),D):u,c,te,Z)(re)}}function te(Y){return O(H,A),V}function Z(Y){return A.restore(),++$<F.length?W(F[$]):B}}}function R(O,D){O.resolveAll&&!o.includes(O)&&o.push(O),O.resolve&&Di(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 UV(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 YV(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 GV(e){const r={constructs:n9([KV,...(e||{}).extensions||[]]),content:s(u9),defined:[],document:s(f9),flow:s(IV),lazy:{},string:s(TV),text:s(MV)};return r;function s(o){return a;function a(l){return qV(r,o,l)}}}function JV(e){for(;!lT(e););return e}const V1=/[\0\t\n\r]/g;function XV(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,d,f,p,m;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(V1.lastIndex=f,u=V1.exec(o),p=u&&u.index!==void 0?u.index:o.length,m=o.charCodeAt(p),!u){t=o.slice(f);break}if(m===10&&f===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<p&&(c.push(o.slice(f,p)),e+=p-f),m){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const QV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ZV(e){return e.replace(QV,eK)}function eK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return sT(n.slice(o?2:1),o?16:10)}return uv(n)||e}const hT={}.hasOwnProperty;function tK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),nK(n)(JV(GV(n).document().write(XV()(e,t,!0))))}function nK(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(Ce),hardBreakTrailing:o(Ce),htmlFlow:o(He,a),htmlFlowData:z,htmlText:o(He,a),htmlTextData:z,image:o(ct),label:a,link:o(yt),listItem:o(ot),listItemValue:p,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:Y,characterReference:ne,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:c(g),codeText:c(V),codeTextData:E,data:E,definition:c(),definitionDestinationString:C,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()}};mT(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:d,data:n},Qe=[];let _e=-1;for(;++_e<oe.length;)if(oe[_e][1].type==="listOrdered"||oe[_e][1].type==="listUnordered")if(oe[_e][0]==="enter")Qe.push(_e);else{const _t=Qe.pop();_e=s(oe,_t,_e)}for(_e=-1;++_e<oe.length;){const _t=t[oe[_e][0]];hT.call(_t,oe[_e][1].type)&&_t[oe[_e][1].type].call(Object.assign({sliceSerialize:oe[_e][2].sliceSerialize},Be),oe[_e][1])}if(Be.tokenStack.length>0){const _t=Be.tokenStack[Be.tokenStack.length-1];(_t[1]||K1).call(Be,void 0,_t[0])}for(ke.position={start:$o(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:$o(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},_e=-1;++_e<t.transforms.length;)ke=t.transforms[_e](ke)||ke;return ke}function s(oe,ke,Be){let Qe=ke-1,_e=-1,_t=!1,Xt,Ft,at,Fn;for(;++Qe<=Be;){const ie=oe[Qe];switch(ie[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ie[0]==="enter"?_e++:_e--,Fn=void 0;break}case"lineEndingBlank":{ie[0]==="enter"&&(Xt&&!Fn&&!_e&&!at&&(at=Qe),Fn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Fn=void 0}if(!_e&&ie[0]==="enter"&&ie[1].type==="listItemPrefix"||_e===-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",_t=!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}at&&(!Ft||at<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++,at=void 0,Fn=!0}}}return oe[ke][1]._spread=_t,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:$o(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]||K1).call(this,oe,Qe[0]));else throw new Error("Cannot close `"+oe.type+"` ("+kd({start:oe.start,end:oe.end})+"): it’s not open");Be.position.end=$o(oe.end)}function d(){return e9(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(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 m(){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=jc(this.sliceSerialize(oe)).toLowerCase()}function x(){const oe=this.resume(),ke=this.stack[this.stack.length-1];ke.title=oe}function C(){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:$o(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=$o(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=$o(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=ZV(ke),Be.identifier=jc(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=jc(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function Z(oe){this.data.characterReferenceType=oe.type}function Y(oe){const ke=this.sliceSerialize(oe),Be=this.data.characterReferenceType;let Qe;Be?(Qe=sT(ke,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Qe=uv(ke);const _e=this.stack[this.stack.length-1];_e.value+=Qe}function ne(oe){const ke=this.stack.pop();ke.position.end=$o(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 Ce(){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 ot(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 $o(e){return{line:e.line,column:e.column,offset:e.offset}}function mT(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?mT(e,r):rK(e,r)}}function rK(e,t){let n;for(n in t)if(hT.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 K1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+kd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+kd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+kd({start:t.start,end:t.end})+") is still open")}function sK(e){const t=this;t.parser=n;function n(r){return tK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function iK(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 oK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `}]}function aK(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 lK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Zc(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 dK(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 fK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function gT(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 pK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return gT(e,t);const s={src:Zc(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 hK(e,t){const n={src:Zc(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 mK(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 gK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return gT(e,t);const s={href:Zc(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 yK(e,t){const n={href:Zc(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 wK(e,t,n){const r=e.all(t),s=n?xK(n):yT(t),o={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(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 d=r[l];(s||l!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
72
+ `}),d.type==="element"&&d.tagName==="p"&&!s?a.push(...d.children):a.push(d)}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 xK(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=yT(n[r])}return t}function yT(e){const t=e.spread;return t??e.children.length>1}function bK(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 kK(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vK(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function SK(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jK(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=ov(t.children[1]),c=XR(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 NK(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],p={},m=a?a[c]:void 0;m&&(p.align=m);let y={type:"element",tagName:o,properties:p,children:[]};f&&(y.children=e.all(f),e.patch(f,y),y=e.applyData(f,y)),u.push(y)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function CK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const q1=9,U1=32;function _K(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(Y1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(Y1(t.slice(s),s>0,!1)),o.join("")}function Y1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===q1||o===U1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===q1||o===U1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function AK(e,t){const n={type:"text",value:_K(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function EK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const IK={blockquote:iK,break:oK,code:aK,delete:lK,emphasis:cK,footnoteReference:uK,heading:dK,html:fK,imageReference:pK,image:hK,inlineCode:mK,linkReference:gK,link:yK,listItem:wK,list:bK,paragraph:kK,root:vK,strong:SK,table:jK,tableCell:CK,tableRow:NK,text:AK,thematicBreak:EK,toml:zp,yaml:zp,definition:zp,footnoteDefinition:zp};function zp(){}const wT=-1,yg=0,Sd=1,pm=2,pv=3,hv=4,mv=5,gv=6,xT=7,bT=8,G1=typeof self=="object"?self:globalThis,PK=(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 yg:case wT:return n(a,s);case Sd:{const l=n([],s);for(const c of a)l.push(r(c));return l}case pm:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case pv:return n(new Date(a),s);case hv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case mv:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case gv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case xT:{const{name:l,message:c}=a;return n(new G1[l](c),s)}case bT: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 G1[o](a),s)};return r},J1=e=>PK(new Map,e)(0),Hl="",{toString:RK}={},{keys:TK}=Object,Bu=e=>{const t=typeof e;if(t!=="object"||!e)return[yg,t];const n=RK.call(e).slice(8,-1);switch(n){case"Array":return[Sd,Hl];case"Object":return[pm,Hl];case"Date":return[pv,Hl];case"RegExp":return[hv,Hl];case"Map":return[mv,Hl];case"Set":return[gv,Hl];case"DataView":return[Sd,n]}return n.includes("Array")?[Sd,n]:n.includes("Error")?[xT,n]:[pm,n]},Bp=([e,t])=>e===yg&&(t==="function"||t==="symbol"),MK=(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]=Bu(a);switch(l){case yg:{let d=a;switch(c){case"bigint":l=bT,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([wT],a)}return s([l,d],a)}case Sd:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const d=[],f=s([l,d],a);for(const p of a)d.push(o(p));return f}case pm:{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 d=[],f=s([l,d],a);for(const p of TK(a))(e||!Bp(Bu(a[p])))&&d.push([o(p),o(a[p])]);return f}case pv:return s([l,a.toISOString()],a);case hv:{const{source:d,flags:f}=a;return s([l,{source:d,flags:f}],a)}case mv:{const d=[],f=s([l,d],a);for(const[p,m]of a)(e||!(Bp(Bu(p))||Bp(Bu(m))))&&d.push([o(p),o(m)]);return f}case gv:{const d=[],f=s([l,d],a);for(const p of a)(e||!Bp(Bu(p)))&&d.push(o(p));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},X1=(e,{json:t,lossy:n}={})=>{const r=[];return MK(!(t||n),!!t,new Map,r)(e),r},hm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?J1(X1(e,t)):structuredClone(e):(e,t)=>J1(X1(e,t));function $K(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 LK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function OK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||$K,r=e.options.footnoteBackLabel||LK,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 d=e.all(u),f=String(u.identifier).toUpperCase(),p=Zc(f.toLowerCase());let m=0;const y=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++m<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,m);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,m),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=d[d.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 d.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!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:{...hm(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 kT=function(e){if(e==null)return BK;if(typeof e=="function")return wg(e);if(typeof e=="object")return Array.isArray(e)?DK(e):FK(e);if(typeof e=="string")return zK(e);throw new Error("Expected function, string, or object as test")};function DK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=kT(e[n]);return wg(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function FK(e){const t=e;return wg(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function zK(e){return wg(t);function t(n){return n&&n.type===e}}function wg(e){return t;function t(n,r,s){return!!(WK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function BK(){return!0}function WK(e){return e!==null&&typeof e=="object"&&"type"in e}const vT=[],HK=!0,Q1=!1,VK="skip";function KK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=kT(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,d){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const m=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=vT,y,v,b;if((!t||o(c,u,d[d.length-1]||void 0))&&(m=qK(n(c,d)),m[0]===Q1))return m;if("children"in c&&c.children){const g=c;if(g.children&&m[0]!==VK)for(v=(r?g.children.length:-1)+a,b=d.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===Q1)return y;v=typeof y[1]=="number"?y[1]:v+a}}return m}}}function qK(e){return Array.isArray(e)?e:typeof e=="number"?[HK,e]:e==null?vT:[e]}function ST(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),KK(e,o,l,s);function l(c,u){const d=u[u.length-1],f=d?d.children.indexOf(c):void 0;return a(c,f,d)}}const db={}.hasOwnProperty,UK={};function YK(e,t){const n=t||UK,r=new Map,s=new Map,o=new Map,a={...IK,...n.handlers},l={all:u,applyData:JK,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:GK,wrap:QK};return ST(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:s,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),l;function c(d,f){const p=d.type,m=l.handlers[p];if(db.call(l.handlers,p)&&m)return m(l,d,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in d){const{children:v,...b}=d,g=hm(b);return g.children=l.all(d),g}return hm(d)}return(l.options.unknownHandler||XK)(l,d,f)}function u(d){const f=[];if("children"in d){const p=d.children;let m=-1;for(;++m<p.length;){const y=l.one(p[m],d);if(y){if(m&&p[m-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=Z1(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=Z1(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function GK(e,t){e.position&&(t.position=R8(e))}function JK(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,hm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function XK(e,t){const n=t.data||{},r="value"in t&&!(db.call(n,"hProperties")||db.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 QK(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 Z1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function eC(e,t){const n=YK(e,t),r=n.one(e,void 0),s=OK(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 ZK(e,t){return e&&"run"in e?async function(n,r){const s=eC(n,{file:r,...t});await e.run(s,r)}:function(n,r){return eC(n,{file:r,...e||t})}}function tC(e){if(e)throw e}var Nh=Object.prototype.hasOwnProperty,jT=Object.prototype.toString,nC=Object.defineProperty,rC=Object.getOwnPropertyDescriptor,sC=function(t){return typeof Array.isArray=="function"?Array.isArray(t):jT.call(t)==="[object Array]"},iC=function(t){if(!t||jT.call(t)!=="[object Object]")return!1;var n=Nh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Nh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Nh.call(t,s)},oC=function(t,n){nC&&n.name==="__proto__"?nC(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},aC=function(t,n){if(n==="__proto__")if(Nh.call(t,n)){if(rC)return rC(t,n).value}else return;return t[n]},e7=function e(){var t,n,r,s,o,a,l=arguments[0],c=1,u=arguments.length,d=!1;for(typeof l=="boolean"&&(d=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=aC(l,n),s=aC(t,n),l!==s&&(d&&s&&(iC(s)||(o=sC(s)))?(o?(o=!1,a=r&&sC(r)?r:[]):a=r&&iC(r)?r:{},oC(l,{name:n,newValue:e(d,a,s)})):typeof s<"u"&&oC(l,{name:n,newValue:s}));return l};const lw=da(e7);function fb(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 t7(){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 d=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,d?n7(d,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 n7(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 d=u;if(l&&n)throw d;return s(d)}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 ki={basename:r7,dirname:s7,extname:i7,join:o7,sep:"/"};function r7(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');_f(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 s7(e){if(_f(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 i7(e){_f(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 o7(...e){let t=-1,n;for(;++t<e.length;)_f(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":a7(n)}function a7(e){_f(e);const t=e.codePointAt(0)===47;let n=l7(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function l7(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 _f(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const c7={cwd:u7};function u7(){return"/"}function pb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function d7(e){if(typeof e=="string")e=new URL(e);else if(!pb(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 f7(e)}function f7(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 cw=["history","path","basename","stem","extname","dirname"];class NT{constructor(t){let n;t?pb(t)?n={path:t}:typeof t=="string"||p7(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":c7.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<cw.length;){const o=cw[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)cw.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?ki.basename(this.path):void 0}set basename(t){dw(t,"basename"),uw(t,"basename"),this.path=ki.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ki.dirname(this.path):void 0}set dirname(t){lC(this.basename,"dirname"),this.path=ki.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ki.extname(this.path):void 0}set extname(t){if(uw(t,"extname"),lC(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=ki.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){pb(t)&&(t=d7(t)),dw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ki.basename(this.path,this.extname):void 0}set stem(t){dw(t,"stem"),uw(t,"stem"),this.path=ki.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 uw(e,t){if(e&&e.includes(ki.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ki.sep+"`")}function dw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function lC(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function p7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const h7=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},m7={}.hasOwnProperty;class yv extends h7{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=t7()}copy(){const t=new yv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(lw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(hw("data",this.frozen),this.namespace[t]=n,this):m7.call(this.namespace,t)&&this.namespace[t]||void 0:t?(hw("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=Wp(t),r=this.parser||this.Parser;return fw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),fw("process",this.parser||this.Parser),pw("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Wp(t),c=r.parse(l);r.run(c,l,function(d,f,p){if(d||!f||!p)return u(d);const m=f,y=r.stringify(m,p);w7(y)?p.value=y:p.result=y,u(d,p)});function u(d,f){d||!f?a(d):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),fw("processSync",this.parser||this.Parser),pw("processSync",this.compiler||this.Compiler),this.process(t,s),uC("processSync","process",n),r;function s(o,a){n=!0,tC(o),r=a}}run(t,n,r){cC(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=Wp(n);s.run(t,c,u);function u(d,f,p){const m=f||t;d?l(d):a?a(m):r(void 0,m,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),uC("runSync","run",r),s;function o(a,l){tC(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Wp(n),s=this.compiler||this.Compiler;return pw("stringify",s),cC(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(hw("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[d,...f]=u;c(d,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=lw(!0,s.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];o(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===u){p=f;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[m,...y]=d;const v=r[p][1];fb(v)&&fb(m)&&(m=lw(!0,v,m)),r[p]=[u,m,...y]}}}}const g7=new yv().freeze();function fw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function pw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function hw(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 cC(e){if(!fb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function uC(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Wp(e){return y7(e)?e:new NT(e)}function y7(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function w7(e){return typeof e=="string"||x7(e)}function x7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const b7="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",dC=[],fC={allowDangerousHtml:!0},k7=/^(https?|ircs?|mailto|xmpp)$/i,v7=[{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 CT(e){const t=S7(e),n=j7(e);return N7(t.runSync(t.parse(n),n),e)}function S7(e){const t=e.rehypePlugins||dC,n=e.remarkPlugins||dC,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...fC}:fC;return g7().use(sK).use(n).use(ZK,r).use(t)}function j7(e){const t=e.children||"",n=new NT;return typeof t=="string"&&(n.value=t),n}function N7(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||C7;for(const d of v7)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+b7+d.id,void 0);return ST(e,u),O8(e,{Fragment:i.Fragment,components:s,ignoreInvalidStyle:!0,jsx:i.jsx,jsxs:i.jsxs,passKeys:!0,passNode:!0});function u(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let m;for(m in iw)if(Object.hasOwn(iw,m)&&Object.hasOwn(d.properties,m)){const y=d.properties[m],v=iw[m];(v===null||v.includes(d.tagName))&&(d.properties[m]=c(String(y||""),m,d))}}if(d.type==="element"){let m=n?!n.includes(d.tagName):o?o.includes(d.tagName):!1;if(!m&&r&&typeof f=="number"&&(m=!r(d,f,p)),m&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function C7(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||k7.test(e.slice(0,t))?e:""}const _7=new Set(["echarts"]),A7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),E7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),I7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function na(e){return e&&typeof e=="object"&&!Array.isArray(e)}function ol(e,t){if(!na(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:na(n[r])&&na(s)&&(n[r]=ol(n[r],s));return n}function xg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>na(n)?ol(n,t):n):na(e)?ol(e,t):e}function P7(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 hb(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)=>hb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||E7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);hb(r,`${t}.${n}`)}}}function R7(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(!A7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function T7(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:ol(e,t)}function M7(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(!na(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return ol(o,n)}):na(e)?ol(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function $7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:xg(e,n)}function pC(e,t="rgba(255, 255, 255, 0.62)"){return xg(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 L7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:xg(e,n)}function O7(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:xg(e,t)}function D7(e,t,n){const r=M7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>na(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??I7,textStyle:ol(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:T7(e.tooltip),legend:$7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?L7(e.grid,s||o):e.grid,xAxis:pC(e.xAxis),yAxis:pC(e.yAxis),radar:O7(e.radar),series:t}}function F7(e){const t=P7(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(!_7.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");hb(n);const r=R7(n.option.series),s=n.title==null?"":String(n.title),o=D7(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 Hp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function z7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function ro(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!Hp(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==="`"&&!Hp(t,o)){const l=z7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!Hp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&Hp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function _T(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 AT(e){const t=ro(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function ET(e){return ro(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function B7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function W7(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 H7({code:e}){const t=h.useMemo(()=>W7(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((d,f)=>{l.set(d.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(d=>d.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(d=>d.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((d,f)=>{const p=l.get(d.from),m=l.get(d.to);if(!p||!m)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+m.x+r)/2} ${p.y+s/2}, ${(p.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.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:d.label.slice(0,24)})]},d.id)})]})}function V7(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 K7({code:e}){const t=h.useMemo(()=>V7(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),d=f=>{const p=Math.max(0,n.findIndex(m=>m.id===f));return s+p*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,p)=>{const m=s+p*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:m-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:m,y:o+22,textAnchor:"middle",children:f.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:m,y1:o+a,x2:m,y2:u-18})]},f.id)}),t.rows.map((f,p)=>{const m=o+a+p*l+24;if(f.type!=="message")return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-sequence-note",x:s,y:m-17,width:c-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:m+4,children:f.text.slice(0,120)})]},`note-${p}`);const y=d(f.from),v=d(f.to),b=(y+v)/2;return i.jsxs("g",{children:[i.jsx("line",{className:"af-md-mermaid-edge",x1:y,y1:m,x2:v,y2:m,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:b,y:m-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${p}`)})]})}function IT({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(K7,{code:t}):i.jsx(H7,{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&&B7(l)){o();const u=[];for(;a<t.length;){const d=t[a]||"";if(u.length>0&&(!d.trim()||/^-{3,}\s*$/.test(d)||/^#{1,6}\s+/.test(d)))break;u.push(d),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&&ro(l).length>1&&AT(t[a+1])){o();const u=ro(l),d=ET(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&ro(t[a]).length>1;)f.push(_T(ro(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return o(),n}function hC(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 PT(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 d=o;for(;d<r.length&&!/\s|<|>/.test(r[d]);)d+=1;let f=r.slice(o,d),p="";for(;/[.,;:!?)}\]]$/.test(f);)p=f.slice(-1)+p,f=f.slice(0,-1);f?s+=`[${f}](${f})${p}`:s+=r.slice(o,d),o=d}return s}).join(`
87
+ `)}function RT(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=hC(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 d;const c=((d=String(a||"").match(/language-(\w+)/i))==null?void 0:d[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?i.jsx(IT,{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(hC(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 mC({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(CT,{components:RT(t,!0,n),children:PT(e)})}function wv({content:e,resolveSrc:t,basePath:n=""}){const r=h.useMemo(()=>q7(e),[e]),s=h.useMemo(()=>RT(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(IT,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(CT,{components:s,children:PT(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(mC,{resolveSrc:t,basePath:n,children:l})},c))})}),i.jsx("tbody",{children:o.rows.map((l,c)=>i.jsx("tr",{children:o.headers.map((u,d)=>i.jsx("td",{style:{textAlign:o.align[d]||"left"},children:i.jsx(mC,{resolveSrc:t,basePath:n,children:l[d]||""})},d))},c))})]})},`table-${a}`))})}function U7(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 xi(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 Y7(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=>xi(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>xi(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)=>xi(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:xi(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:xi(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>xi(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>xi(s[a])):s&&typeof s=="object"?r.map(o=>xi(s[o.key])):r.map((o,a)=>a===0?xi(s):""))}}function G7(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=Y7(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&&ro(s[0]).length>1&&AT(s[1])){const l=ro(s[0]),c=ET(s[1]);return{columns:l.map((u,d)=>({key:String(d),label:u,align:c[d]||"left"})),rows:s.slice(2).map(u=>_T(ro(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=U7(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 xv({content:e}){const t=h.useMemo(()=>G7(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:xi(n[o])},`${s.key}-${o}`))},r))})]})})}function bv({content:e}){const t=h.useRef(null),n=h.useMemo(()=>F7(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.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:""}),z6(()=>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,d;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(d=a==null?void 0:a.dispose)==null||d.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 TT(e){return typeof e>"u"||e===null}function J7(e){return typeof e=="object"&&e!==null}function X7(e){return Array.isArray(e)?e:TT(e)?[]:[e]}function Q7(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 Z7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function eq(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var tq=TT,nq=J7,rq=X7,sq=Z7,iq=eq,oq=Q7,kv={isNothing:tq,isObject:nq,toArray:rq,repeat:sq,isNegativeZero:iq,extend:oq};function MT(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 tf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=MT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}tf.prototype=Object.create(Error.prototype);tf.prototype.constructor=tf;tf.prototype.toString=function(t){return this.name+": "+MT(this,t)};var $a=tf,aq=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],lq=["scalar","sequence","mapping"];function cq(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function uq(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(aq.indexOf(n)===-1)throw new $a('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=cq(t.styleAliases||null),lq.indexOf(this.kind)===-1)throw new $a('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Er=uq;function gC(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 dq(){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 mb(e){return this.extend(e)}mb.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 $a("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Er))throw new $a("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new $a("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 $a("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 $a("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(mb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=gC(s,"implicit"),s.compiledExplicit=gC(s,"explicit"),s.compiledTypeMap=dq(s.compiledImplicit,s.compiledExplicit),s};var fq=mb,pq=new Er("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),hq=new Er("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),mq=new Er("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),gq=new fq({explicit:[pq,hq,mq]});function yq(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function wq(){return null}function xq(e){return e===null}var bq=new Er("tag:yaml.org,2002:null",{kind:"scalar",resolve:yq,construct:wq,predicate:xq,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function kq(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 vq(e){return e==="true"||e==="True"||e==="TRUE"}function Sq(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var jq=new Er("tag:yaml.org,2002:bool",{kind:"scalar",resolve:kq,construct:vq,predicate:Sq,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 Nq(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Cq(e){return 48<=e&&e<=55}function _q(e){return 48<=e&&e<=57}function Aq(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(!Nq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!Cq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!_q(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function Eq(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 Iq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!kv.isNegativeZero(e)}var Pq=new Er("tag:yaml.org,2002:int",{kind:"scalar",resolve:Aq,construct:Eq,predicate:Iq,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"]}}),Rq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Tq(e){return!(e===null||!Rq.test(e)||e[e.length-1]==="_")}function Mq(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 $q=/^[-+]?[0-9]+e/;function Lq(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(kv.isNegativeZero(e))return"-0.0";return n=e.toString(10),$q.test(n)?n.replace("e",".e"):n}function Oq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||kv.isNegativeZero(e))}var Dq=new Er("tag:yaml.org,2002:float",{kind:"scalar",resolve:Tq,construct:Mq,predicate:Oq,represent:Lq,defaultStyle:"lowercase"}),Fq=gq.extend({implicit:[bq,jq,Pq,Dq]}),zq=Fq,$T=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),LT=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 Bq(e){return e===null?!1:$T.exec(e)!==null||LT.exec(e)!==null}function Wq(e){var t,n,r,s,o,a,l,c=0,u=null,d,f,p;if(t=$T.exec(e),t===null&&(t=LT.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]&&(d=+t[10],f=+(t[11]||0),u=(d*60+f)*6e4,t[9]==="-"&&(u=-u)),p=new Date(Date.UTC(n,r,s,o,a,l,c)),u&&p.setTime(p.getTime()-u),p}function Hq(e){return e.toISOString()}var Vq=new Er("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Bq,construct:Wq,instanceOf:Date,represent:Hq});function Kq(e){return e==="<<"||e===null}var qq=new Er("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Kq}),vv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
+ \r`;function Uq(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=vv;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 Yq(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=vv,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 Gq(e){var t="",n=0,r,s,o=e.length,a=vv;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 Jq(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Xq=new Er("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Uq,construct:Yq,predicate:Jq,represent:Gq}),Qq=Object.prototype.hasOwnProperty,Zq=Object.prototype.toString;function eU(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,Zq.call(s)!=="[object Object]")return!1;for(o in s)if(Qq.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 tU(e){return e!==null?e:[]}var nU=new Er("tag:yaml.org,2002:omap",{kind:"sequence",resolve:eU,construct:tU}),rU=Object.prototype.toString;function sU(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],rU.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function iU(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 oU=new Er("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:sU,construct:iU}),aU=Object.prototype.hasOwnProperty;function lU(e){if(e===null)return!0;var t,n=e;for(t in n)if(aU.call(n,t)&&n[t]!==null)return!1;return!0}function cU(e){return e!==null?e:{}}var uU=new Er("tag:yaml.org,2002:set",{kind:"mapping",resolve:lU,construct:cU});zq.extend({implicit:[Vq,qq],explicit:[Xq,nU,oU,uU]});function yC(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 dU=new Array(256),fU=new Array(256);for(var Vl=0;Vl<256;Vl++)dU[Vl]=yC(Vl)?1:0,fU[Vl]=yC(Vl);const nf=["requirement","planning","code","test","normal"],wC={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function Sv(e,t){var s,o,a,l,c,u,d,f,p,m,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]}:{},C=((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=wC[P]||P,E=wC[R]||R,O=nf.includes(z)?z:nf.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=(d=k.data)==null?void 0:d.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:C,label:M,role:O,model:F,input:D,output:L},H=((p=k.data)==null?void 0:p.marketplaceRef)||x.marketplaceRef;H?$.marketplaceRef=String(H):delete $.marketplaceRef;const A=((m=k.data)==null?void 0:m.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,C.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 Y=(g=k.data)==null?void 0:g[Z],ne=Y!=null?String(Y):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 jd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function pU(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 hU(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=>jd(a)),edges:o.map(a=>jd(a)),instances:Sv(r,n||{})}}function mU(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(p=>p.id)),l=new Map;for(const p of e.nodes)l.set(p.id,pU(p.id,a));const c=e.nodes.map(p=>{var y,v;const m=l.get(p.id);return{...jd(p),id:m,selected:!0,dragging:!1,position:{x:Number(((y=p.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=p.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,m)=>{const y=l.get(p.source),v=l.get(p.target);return{...jd(p),id:`e-${y}-${v}-${Date.now()}-${m}`,source:y,target:v,selected:!1}}),d={...r||{}};for(const[p,m]of l.entries()){const y=(f=e.instances)==null?void 0:f[p];y&&(d[m]={...jd(y),label:y.label!=null?String(y.label):m})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...u],instances:d,pastedNodeIds:c.map(p=>p.id)}}function En(e){switch(mm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function mm(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 gU(e,t){const n=mm(e),r=mm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const yU=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function gb(e){const t=mm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&yU.has(n)?`${t}+${n}`:t}function wU(e){return gb(e)}function rf(e,t){if(!e||!t||!gU(e.type,t.type))return!1;const n=gb(e),r=gb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function xU(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 yb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=xU(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 gm=/\[image\s+(\d+)\]/gi;function bo(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 bU(e){return`image ${bo(e).length+1}`}function kU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function vU(e,t){const n=bo(e),r=String(t||""),s=new Set;gm.lastIndex=0;let o;for(;o=gm.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function SU(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 OT(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 Nd(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 DT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=bo(n);for(const a of r){const l=await SU(a),c=bU(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=kU(s,c)}return{body:s,images:o}}function _s(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function jU(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 NU(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 CU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _U(e,t){const n=`\\[${CU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
+ `).replace(/\n{3,}/g,`
97
+
98
+ `).trimEnd()}function mw(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function AU(e){const t=String(e||"");let n="",r=0;gm.lastIndex=0;let s;for(;s=gm.exec(t);)n+=mw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${mw(s[0])}</span>`,r=s.index+s[0].length;return n+=mw(t.slice(r)),n||" "}function EU(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 IU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:d=!1}){var Mr,$r;const{t:f}=Vr(),p=(e==null?void 0:e.inputs)??[],m=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=jU(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,C=(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?NU(m[0]):!1,B=P?String(((Mr=m[0])==null?void 0:Mr.value)??(($r=m[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=bo(e==null?void 0:e.images),Q=R||z||E||O||M||!!H,K=h.useRef(!1),W=h.useRef(!1),te=h.useRef(null),Z=h.useRef(null),Y=h.useRef(null),ne=h.useRef(null),re=h.useRef(null),[se,ee]=h.useState(B),[ue,de]=h.useState(!1),[pe,Me]=h.useState(F),[Ne,Ce]=h.useState(!1),[He,ct]=h.useState({visible:!1,top:0,height:100}),[yt,Re]=h.useState(!1),ot=h.useCallback(()=>{const ce=Z.current;if(!ce)return;const me=Math.max(1,ce.scrollHeight),tt=Math.max(1,ce.clientHeight),rt=me>tt+1,zt=rt?Math.max(12,tt/me*100):100,Rn=Math.max(0,100-zt),jr=rt?Math.min(Rn,ce.scrollTop/Math.max(1,me-tt)*Rn):0;ct({visible:rt,top:jr,height:zt})},[]);h.useEffect(()=>{K.current||ee(B)},[n,B]),h.useEffect(()=>{W.current||Me(F)},[n,F]),h.useEffect(()=>{const ce=Z.current;if(!ce)return;if(M){ce.style.minHeight="",ce.style.height="",Y.current&&(Y.current.style.minHeight="",Y.current.style.height="");return}const me=EU(ce,pe);ce.style.minHeight=`${me}px`,ce.style.height="",Y.current&&(Y.current.style.minHeight=`${me}px`,Y.current.style.height="")},[pe,M]),h.useEffect(()=>{if(!M)return;const ce=window.requestAnimationFrame(ot),me=Z.current;if(!me||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(ce);const tt=new ResizeObserver(ot);return tt.observe(me),()=>{window.cancelAnimationFrame(ce),tt.disconnect()}},[pe,M,ot]),h.useEffect(()=>{const ce=te.current,me=e==null?void 0:e.onNodeContentResize;if(!M||!ce||!me||typeof ResizeObserver>"u")return;let tt=0;const rt=()=>{window.cancelAnimationFrame(tt),tt=window.requestAnimationFrame(()=>me(n))},zt=new ResizeObserver(rt);return zt.observe(ce),rt(),()=>{window.cancelAnimationFrame(tt),zt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),h.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(_s)),Qe=new Set($t.map(_s)),_e=new Set(ye.map(_s)),_t=new Set(ze.map(_s)),Xt=oe?oe.startsWith("cursor:")||oe.startsWith("opencode:")||oe.startsWith("codex:")||oe.startsWith("claude-code:")?oe:_e.has(oe)?`claude-code:${oe}`:_t.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)&&!_e.has(oe)&&!_t.has(oe),at=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),!d&&!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),d||o==null||o(n,me)},tr=()=>{g||d&&se===B||o==null||o(n,se)},Yn=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=vU(A,ce);(me.length!==A.length||me.some((tt,rt)=>{var zt;return tt.id!==((zt=A[rt])==null?void 0:zt.id)}))&&l(n,me)}},nr=ce=>{if(ce.stopPropagation(),g)return;const me=ce.target.value;d||W.current?Me(me):kn(me)},pr=ce=>{ce.stopPropagation(),!g&&(W.current=!0,Ce(!0))},hr=ce=>{if(ce.stopPropagation(),g)return;W.current=!1,Ce(!1);const me=ce.currentTarget.value;d?Me(me):kn(me)},fn=()=>{g||(W.current=!1,Ce(!1),!(d&&pe===F)&&kn(pe))},zn=ce=>{ce.stopPropagation(),ce.preventDefault(),!g&&Re(!0)},is=()=>{Re(!1),fn()},Ds=ce=>{ce.stopPropagation(),ce.key==="Escape"&&(ce.preventDefault(),is())},vn=h.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,ot()},[ot]),Gn=h.useCallback((ce,me=0)=>{const tt=ne.current;if(!tt)return 0;const rt=tt.getBoundingClientRect(),zt=He.height/100*rt.height,Rn=Math.max(1,rt.height-zt);return(ce-rt.top-me)/Rn},[He.height]),bs=h.useCallback(ce=>{var Ut,Yt;if(!He.visible)return;ce.preventDefault(),ce.stopPropagation();const me=ne.current;if(!me)return;const tt=me.getBoundingClientRect(),rt=He.top/100*tt.height,zt=He.height/100*tt.height,jr=ce.clientY>=tt.top+rt&&ce.clientY<=tt.top+rt+zt?ce.clientY-tt.top-rt:zt/2;vn(Gn(ce.clientY,jr));const Nr=ce.pointerId;(Yt=(Ut=ce.currentTarget).setPointerCapture)==null||Yt.call(Ut,Nr);const mr=Xn=>{Xn.preventDefault(),vn(Gn(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)},[Gn,He.height,He.top,He.visible,vn]),Jn=async ce=>{if(g)return;const me=await DT({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),rt=_U(pe,me.label);Me(rt),a==null||a(n,rt),l==null||l(n,tt)},vr=ce=>{if(g)return;const me=OT(ce);me.length!==0&&(ce.preventDefault(),ce.stopPropagation(),Jn(me).catch(()=>{}))},Sr=ce=>{if(g)return;const me=Nd(ce);me.length!==0&&(ce.preventDefault(),ce.stopPropagation(),Jn(me).catch(()=>{}))},Wn=()=>{const ce=Z.current,me=Y.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":"")+(C==="success"?" af-flow-node--done":"")+(C==="failed"?" af-flow-node--failed":"")+(C==="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:at||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:${_s(ce)}`,children:_s(ce)},`c-${ce}`))}),$t.length>0&&i.jsx("optgroup",{label:"OpenCode",children:$t.map(ce=>i.jsx("option",{value:`opencode:${_s(ce)}`,children:_s(ce)},`o-${ce}`))}),ze.length>0&&i.jsx("optgroup",{label:"Codex",children:ze.map(ce=>i.jsx("option",{value:`codex:${_s(ce)}`,children:_s(ce)},`codex-${ce}`))}),ye.length>0&&i.jsx("optgroup",{label:"Claude Code",children:ye.map(ce=>i.jsx("option",{value:`claude-code:${_s(ce)}`,children:_s(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"}),C==="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"}),C==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),C==="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:p.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}):""),rt=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:[rt,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:Yn,"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:Y,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:AU(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(),ot()},onPointerDown:tn,onMouseDown:tn,onClick:tn,onKeyDown:tn,onDragOver:ce=>{Nd(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:bs,"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:m.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}):""),rt=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:[rt,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:Ds,onDragOver:ce=>{Nd(ce).length>0&&ce.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const Nc="flowNode";function wb(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 PU={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 RU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(PU[e]||[]).includes(s)?r:s}const TU={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"])},MU={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"])},$U={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},LU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function OU(e,t){if(!LU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function DU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function FU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function FT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function zU(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 BU(e){const t=String(e??"").trim();return t?t.includes("${")?t:FT(t):""}function WU(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(BU).filter(Boolean):[];return[zU(t,n),FT(s),...o].join(" ")}return String(t.command||"").trim()}function xC(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,d,f;const o=n[s],l=n.find(p=>(p==null?void 0:p.name)&&p.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=TU[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&&OU(e,r)?{showOnNode:!0}:{},...(d=$U[e])!=null&&d.has(r.name)?{showOnNode:!0}:{},...(f=MU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function HU(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=wb(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 xb(e,t,n,r,s){var $,H,A,Q,K,W,te,Z,Y,ne,re,se,ee,ue,de,pe,Me,Ne,Ce,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=[],d=((H=e.data)==null?void 0:H.label)??e.id,f,p,m,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(wb)),Array.isArray(l.output)&&(u=l.output.map(wb)),l.label&&(d=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(m=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=p??((Q=e.data)==null?void 0:Q.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",C=x!==""?x:void 0,S=m??((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=WU(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=(Y=E==null?void 0:E.label)==null?void 0:Y.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=FU(a,(a==null?void 0:a.id)??o),V=(l==null?void 0:l.marketplaceRef)||((se=e.data)==null?void 0:se.marketplaceRef)||DU(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(ot=>(ot==null?void 0:ot.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(ot=>(ot==null?void 0:ot.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(ot=>(ot==null?void 0:ot.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(ot=>(ot==null?void 0:ot.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(ot=>(ot==null?void 0:ot.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}}c=xC(M,c,a==null?void 0:a.inputs),u=xC(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,ot)=>ot===0?{...Re,default:S,value:S}:Re));const B=RU(M,d,a),F=M==="tool_nodejs"||String(R).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:O||d,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)||((Ce=e.data)==null?void 0:Ce.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||C,originalLabel:d,originalBody:S,...F?{script:R}:{}}}}function VU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var d,f,p,m;const s=n.get(r.source),o=n.get(r.target),a=((f=(d=s==null?void 0:s.data)==null?void 0:d.outputs)==null?void 0:f.length)??0,l=((m=(p=o==null?void 0:o.data)==null?void 0:p.inputs)==null?void 0:m.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 bC(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 kC(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function gw(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=bC(t==null?void 0:t.sourceHandle,"output"),o=bC(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,d,f,p;if(c.id===n){const m=kC((u=c.data)==null?void 0:u.outputs,s);if(m!==((d=c.data)==null?void 0:d.outputs))return a=!0,{...c,data:{...c.data,outputs:m}}}if(c.id===r){const m=kC((f=c.data)==null?void 0:f.inputs,o);if(m!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:m}}}return c});return a?l:e}function KU(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 vC(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 UU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Xs({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(UU,{children:t})]},n))})}function YU({open:e,onClose:t}){const{t:n}=Vr(),r=h.useRef(null);if(h.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(Xs,{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(Xs,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{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(Xs,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function GU(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 JU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Vr(),[o,a]=h.useState(""),[l,c]=h.useState(0),u=h.useRef(null),d=h.useRef(null);h.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=h.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,C;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((C=g.data)==null?void 0:C.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:GU(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(h.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),h.useEffect(()=>{var v;const y=(v=d.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=y=>{const v=f[y];v&&(n(v.id),t())},m=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(),p(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:m,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:d,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(),p(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 SC(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 XU(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 jC(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 yw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function NC(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 QU({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:o}){const[a,l]=h.useState([]),[c,u]=h.useState(""),[d,f]=h.useState(null),[p,m]=h.useState(!1),[y,v]=h.useState(!1),[b,g]=h.useState(""),[k,x]=h.useState(""),C=h.useCallback(async()=>{if(e!=null&&e.flowId){m(!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{m(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),S=h.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]);h.useEffect(()=>{C()},[C]),h.useEffect(()=>{S(c)},[S,c]),h.useEffect(()=>{const R=a.find(E=>E.runId===c),z=window.setInterval(()=>{C(),(!R||R.status==="running")&&c&&S(c)},2e3);return()=>window.clearInterval(z)},[S,C,a,c]);const N=h.useMemo(()=>{const R=Array.isArray(d==null?void 0:d.events)?d.events:[],z=k.trim().toLowerCase();return z?R.filter(E=>String(E.type||"").toLowerCase().includes(z)||yw(E).toLowerCase().includes(z)||jC(E).toLowerCase().includes(z)):R},[d==null?void 0:d.events,k]),P=(d==null?void 0:d.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 C(),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:"最近执行"}),p?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!p&&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--${NC(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:SC(R.startedAt)}),i.jsx("span",{children:XU(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--${NC(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,d!=null&&d.error?i.jsx("div",{className:"af-work-run-logs__error",children:d.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:SC(R.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:R.type||"event"}),yw(R)?i.jsx("span",{className:"af-work-run-logs__event-node",children:yw(R)}):null,i.jsx("pre",{children:jC(R)})]},`${R.ts||z}-${z}`))})]})]})]})}function ZU(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 zT(e){const t=ZU(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 eY(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 tY(e){return String(e).replace(/<\/script/gi,"<\\/script")}function bg(e){const t=zT(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 jv(e,t=""){const n=zT(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(p=>/(?:^|\/)App\.[jt]sx$/i.test(p))||Object.keys(r).find(p=>/\.[jt]sx?$/i.test(p))||n.entry,o=eY(r[s]||""),a=Object.entries(r).filter(([p])=>/\.css$/i.test(p)).map(([,p])=>String(p||"")).join(`
101
+
102
+ `),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),d=tY(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,p=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[p])}</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
+ ${d}
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 BT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),nY=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function rY(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 sY(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 CC(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 WT(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(BT.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 HT(e){return{inputNames:CC(e==null?void 0:e.inputs),outputNames:CC(e==null?void 0:e.outputs)}}function iY(e,t,n){const r=HT(t),s=sY(e),o=[];for(const a of s)if(!WT(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 oY(e,t){const n=HT(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=WT(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 aY(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function lY(e){return e.map(t=>{const n=aY(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 cY(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 nY)BT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function uY(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 dY(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 Vp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:d}=Vr(),f=h.useId(),p=h.useRef(null),m=h.useRef(null),[y,v]=h.useState(0),[b,g]=h.useState(0),[k,x]=h.useState(null),C=h.useMemo(()=>bo(c),[c]),S=h.useMemo(()=>iY(e,a,d),[e,a,d]),N=S.length>0,P=h.useMemo(()=>oY(e,a),[e,a]),R=h.useMemo(()=>lY(P),[P]),z=h.useMemo(()=>n?null:rY(e,y),[e,y,n]),E=h.useMemo(()=>{if(!z)return[];const B=cY(a,d);return uY(B,z.query)},[z,a,d]);h.useEffect(()=>{g(B=>{const F=Math.max(0,E.length-1);return Math.min(Math.max(0,B),F)})},[E.length]);const O=h.useCallback(()=>{const B=p.current;if(!B||!z||E.length===0){x(null);return}const F=dY(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]);h.useLayoutEffect(()=>{if(!z||E.length===0){x(null);return}const B=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(B)},[z,E.length,y,e,O]),h.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=h.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=p.current;A&&(A.focus(),A.setSelectionRange(H,H)),v(H)})},[z,e,y,t]),L=h.useCallback(()=>{const B=p.current,F=m.current;!B||!F||(F.scrollTop=B.scrollTop,F.scrollLeft=B.scrollLeft,z&&E.length>0&&queueMicrotask(()=>O()))},[z,E.length,O]),M=h.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=h.useCallback(async B=>{if(n||typeof u!="function")return!1;const F=await DT({files:B,body:e,images:C});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=p.current;if(!$)return;$.focus();const H=F.body.length;$.setSelectionRange(H,H),v(H)}),!0):!1},[n,C,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[C.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:C.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:m,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
182
+ `}}),i.jsx("textarea",{ref:p,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=OT(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onDragOver:B=>{Nd(B).length>0&&B.preventDefault()},onDrop:B=>{const F=Nd(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":d("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 fY=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Wu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function _C({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((p,m)=>m!==f)),u=(f,p,m)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[p]:m};return p==="required"&&m===!0&&(g.showOnNode=!0),g});r(y)},d=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:d})}),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,p)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${d}-${p}`,children:[d,"-",p]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:m=>u(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>i.jsx("option",{value:m,children:m},m))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:m=>u(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:m=>u(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:m=>u(p,"description",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:p})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!f.required,onChange:m=>{o||u(p,"required",m.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),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:m=>u(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${d}-${p}`))]}):null]})}function pY({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:d,ioSlots:f}){const{t:p}=Vr(),[m,y]=h.useState(!1),[v,b]=h.useState(!1),[g,k]=h.useState({status:"idle",message:""}),x=h.useCallback(L=>{t(M=>M&&{...M,...L})},[t]),{cursorList:C,opencodeList:S,claudeCodeList:N,codexList:P,currentNotInLists:R}=h.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(Wu)),$=((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:p("flow:nodeProps.publishRunning")});try{const L=await c(e,n);k({status:"success",message:L!=null&&L.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):p("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:p("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:p("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[d?i.jsx("p",{className:"af-err af-node-props-err",children:d}):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:p("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:[p("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:p("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":p("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:[p("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:[p("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:nf.includes(e.role)?e.role:p("flow:roles.normal"),onChange:L=>x({role:L.target.value}),disabled:o,children:nf.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:[p("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:p("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":p("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),R?i.jsxs("option",{value:R,children:[R,p("flow:nodeProps.yamlValueNotInList")]}):null,C.length>0?i.jsx("optgroup",{label:"Cursor",children:C.map(L=>i.jsx("option",{value:Wu(L),children:L},`c-${L}`))}):null,S.length>0?i.jsx("optgroup",{label:"OpenCode",children:S.map(L=>i.jsx("option",{value:`opencode:${Wu(L)}`,children:L},`o-${L}`))}):null,P.length>0?i.jsx("optgroup",{label:"Codex",children:P.map(L=>i.jsx("option",{value:`codex:${Wu(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:${Wu(L)}`,children:L},`cc-${L}`))}):null]})]}),i.jsx(_C,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>x({inputs:L}),disabled:o,requiredReadonly:!u}),i.jsx(_C,{kind:"output",label:p("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:[p("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Vp,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:p("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:p("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Vp,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:p("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:p("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("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:p("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Vp,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,m?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("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:p("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Vp,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function hY({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=Vr(),a=h.useId(),l=h.useRef(null),[c,u]=h.useState(""),[d,f]=h.useState(!1),[p,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;u(""),m(""),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||d)){f(!0),m("");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){m(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(k){m(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})]}),p?i.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:d,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||d,children:o(d?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function mY({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Vr(),u=h.useId(),d=h.useRef(null),[f,p]=h.useState(""),[m,y]=h.useState(!1),[v,b]=h.useState("");if(h.useEffect(()=>{if(!e)return;p(""),b(""),y(!1);const C=requestAnimationFrame(()=>{var S;return(S=d.current)==null?void 0:S.focus()});return()=>cancelAnimationFrame(C)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(C){if(C.preventDefault(),!k||m)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:C=>{C.target===C.currentTarget&&t()},children:i.jsxs("div",{ref:d,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:C=>C.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:C=>p(C.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:m,children:c("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||m,children:m?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const AC=80,gY=220;function yY(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 wY(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Kp(e,t,n){const r={nodes:Array.isArray(e)?e.map(yY):[],edges:Array.isArray(t)?t.map(wY):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function ww(e,t){const n=[...e,t];return n.length>AC?n.slice(n.length-AC):n}function xY({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=h.useState(0),l=h.useRef([]),c=h.useRef([]),u=h.useRef(null),d=h.useRef(null),f=h.useRef(null),p=h.useRef(null),m=h.useRef(!1),y=h.useCallback(()=>a(S=>S+1),[]),v=h.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),b=h.useCallback(()=>{v();const S=d.current,N=f.current;return d.current=null,f.current=null,!S||!N||S.signature===N.signature?(N&&(u.current=N),!1):(l.current=ww(l.current,S),c.current=[],u.current=N,y(),!0)},[y,v]),g=h.useCallback((S=[],N=[],P={})=>{v(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Kp(S,N,P),m.current=!1,y()},[y,v]),k=h.useCallback(S=>{m.current=!0,u.current=S,d.current=null,f.current=null,v(),s==null||s(S.value),y()},[y,v,s]),x=h.useCallback(()=>{b();const S=u.current||Kp(e,t,n),N=l.current.pop();return N?(c.current=ww(c.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]),C=h.useCallback(()=>{b();const S=u.current||Kp(e,t,n),N=c.current.pop();return N?(l.current=ww(l.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]);return h.useEffect(()=>()=>v(),[v]),h.useEffect(()=>{if(!r)return;const S=Kp(e,t,n);if(!u.current){u.current=S;return}if(m.current){m.current=!1,u.current=S;return}S.signature!==u.current.signature&&(d.current||(d.current=u.current),f.current=S,v(),p.current=window.setTimeout(()=>{b()},gY))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:C,version:o}}function mo(e){return String(e??"").trim()}function EC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(mo(e).toLowerCase())}function bY(e){return e===!1?!0:["false","no","not_required","waived"].includes(mo(e).toLowerCase())}function kY(e,t=""){return mo((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 VT(e){return mo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function KT(e){return VT(e)==="all"}function vY(e,t=[]){const n=mo((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=VT(e),s=kY(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=>mo(l))).has(a)?a:""}function ym(e){const t=mo(e==null?void 0:e.label).toLowerCase(),n=mo((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 SY(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[ym(n)]-t[ym(r)])}function jY(e){const t=mo((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 NY(e,t=[]){if(KT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(ym);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 EC(e==null?void 0:e.implementationNotRequired)||EC(e==null?void 0:e.implementation_not_required)||bY(r)?{kind:"not-required",label:jY(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function bb(e=[]){return e.reduce((t,n)=>t+1+bb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function ur(e){return String(e||"").trim()}function Wo(e){return ur(e).toLowerCase()}function wm(e){return typeof e=="string"?Wo(e):!e||typeof e!="object"||Array.isArray(e)?"":Wo(e.kind||e.type||e.persistence||e.durability)}function qT(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 UT(e={}){const t=ur(e.href||e.url);if(!t)return!1;const n=Wo(e.kind||e.type),r=Wo(e.durability),s=Wo(e.persistence),o=Wo(e.truth||e.stateTruth||e.state_truth),a=Wo(e.authority),l=wm(e.source)||wm(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 p=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),m=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&p,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return m&&(r==="durable"||m||y)}function YT(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 CY(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):YT(e)==="tech-design"&&ur(n)?ur(n):ur(e.title||e.label))}function _Y(e={},t="http://localhost"){const n=ur(e.issueKey||e.issue_key||e.issue),r=YT(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:${qT(e.href||e.url,t)}`}function IC(e={}){const t=ur(e.href||e.url),n=Wo(e.kind||e.type),r=wm(e.source)||wm(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 AY(e,t){const n=IC(t)>IC(e)?t:e,r=n===t?e:t;return{...r,...n,title:PC(e.title)>=PC(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 PC(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 xw(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]=AY(r[a],s)}return r}function EY(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>UT(o)),r=xw(n,o=>qT(o.href||o.url,t)),s=xw(r,o=>ur(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return xw(s,o=>_Y(o,t))}function It(e){return String(e||"").trim()}function go(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 fc(e){return It((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function GT(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 JT(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 IY(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 PY(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 RY(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 Vc(e){const t=fc(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(GT(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=go(e==null?void 0:e.source)||go((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 RC(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,go(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 TC(e){const t=[],n=fc(e);if(n&&t.push(`key:${n}`),Vc(e)){const s=JT(GT(e));s&&t.push(`review:${s}`)}const r=IY((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 TY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=TC(r),o=s.map(m=>n.get(m)).find(m=>m!=null);if(o==null){s.forEach(m=>n.set(m,t.length)),t.push(r);continue}const a=t[o],l=RC(r)>=RC(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=!!fc(a),u=!!fc(r),d=c&&!u?a:r,f=d===a?r:a,p=fc(d)&&!fc(f)&&It(d==null?void 0:d.label)||l;t[o]={...f,...d,...p?{label:p}:{}},TC(t[o]).forEach(m=>n.set(m,o))}return t}function XT(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=go(e==null?void 0:e.source)||go((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 MY(e){if(!Vc(e)||XT(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=go(e==null?void 0:e.source)||go((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 $Y(e){if(Vc(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=go(e==null?void 0:e.source)||go((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 LY(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 OY(e=[],t={}){const n=TY(Array.isArray(e)?e:[]);if(!LY(t))return n;const r=n.filter(Vc);if(r.length===0)return n;const s=r.filter(MY),a=s.length>0||n.some($Y)?s.at(-1):r.filter(XT).at(-1);return n.filter(l=>!Vc(l)||l===a)}function Ai(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=JT(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const d=It(a.path);return d&&l.push(`path:${d}`),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(d=>r.set(d,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 Gr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function xm(e){return Array.isArray(e)?e.map(xm):Gr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,xm(e[t])])):e}function oo(e,t){return JSON.stringify(xm(e))===JSON.stringify(xm(t))}function QT(e){return Gr(e==null?void 0:e.instances)?e.instances:{}}function sf(e){return Gr(e==null?void 0:e.ui)?e.ui:{}}function qp(e,t){if(!Gr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function DY(e,t){if(!Gr(e)||!Gr(t)||!Gr(e.instances)||!Gr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!Gr(e.ui)||!Gr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=qp(e,["version","instances","edges","ui"]),r=qp(t,["version","instances","edges","ui"]);if(!oo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return oo(qp(e.ui,s),qp(t.ui,s))}function ZT(e){const t=Array.isArray(sf(e).groups)?sf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function MC(e){const t=new Set(Object.keys(QT(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 ZT(e).keys())t.add(n);return t}function $C(e,t){const n=QT(e),r=sf(e),s=ZT(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:Gr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:Gr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function LC(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 FY(e,t){if(!DY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...MC(e),...MC(t)]),r=Array.from(n).filter(s=>!oo($C(e,s),$C(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!oo(LC(e),LC(t)),displayPageChanged:!oo(sf(e).displayPage||null,sf(t).displayPage||null)}}function zY(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 OC(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 DC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function BY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[OC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(OC(r));return s?oo(DC(s),DC(r))?s:{...r,selected:s.selected===!0}:r})}function WY(e,t,n){const r=Gr(e)?e:{},s=Gr(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 HY({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 VY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function eM(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 KY({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function qY(e=[]){const t=eM(e);return t.mutated&&!t.active}function UY(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 YY(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 GY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(UY(s)){t.push(s);continue}n.push(s),YY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function kb(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 JY(e=[]){return kb(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 FC(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 XY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function QY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const ZY="af:workspace-graph:v2",zC="agentflow.workspace.sidebarCollapsed",Yl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],eG=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),tG={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:""}]},nG={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:""}]},rG={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}]},sG={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}]},iG={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}]},oG={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}]},aG=new Set(["png","jpg","jpeg","gif","webp","svg"]),tM=320,nM=180,rM=960,bm=96,sM=900,vb=520,Sb=320,Up=52,al=240,ll=160,jb="display-ref:",of="0 9 * * *",lG="Asia/Shanghai",cG="0.1.135";function uG(){const e=new URLSearchParams(window.location.search);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"}}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"),t}function Nv(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 dG(e){const t=Nv(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 Cv(e,t=80){return(Array.isArray(e)?e:[]).map(dG).filter(Boolean).slice(-t)}function fG(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=Cv(s.messages,40),l=Nv(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 pG(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Cv(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:Nv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function BC(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:Cv(n.messages,100),runSessions:pG(n.runSessions)},nodeChats:fG(t.nodeChats)}}function km(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 aG.has(n)}function af(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 hG(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 mG(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${zC}:${t}`:zC}function gG(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function WC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function yG(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 wG(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!yG(e)}function xG(e){const t=String(e||"").trim();if(!t||bG(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 bG(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 kG(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function bw(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 kw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function La(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 HC(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 vG(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 SG(e){const t=vG(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 iM(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 Cc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return iM(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ga(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 oa(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 _v(e){return ga(e==null?void 0:e.status)==="done"&&oa(e)!=="observation"}function ao(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 Ch(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function Av(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 jG(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 NG(e,t){const n=ao(e,t),r=ga(e==null?void 0:e.status),s=_v(e),a=`${cl(e)} ${Av(e)}`,l=jG(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"||oa(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"||oa(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function CG(e){if(!e||typeof e!="object")return"";const t=ga(e.status),n=oa(e),r=_v(e),o=`${cl(e)} ${Av(e)}`,a=Ev(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 d=Ch(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function vm(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 oM="Asia/Shanghai",_G=new Intl.DateTimeFormat("zh-CN",{timeZone:oM,year:"numeric",month:"2-digit",day:"2-digit"}),AG=new Intl.DateTimeFormat("zh-CN",{timeZone:oM,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function aM(e){const t=vm(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function EG(e){const t=aM(e);return t?_G.format(t).replace(/\//g,"-"):"无时间"}function IG(e){const t=aM(e);return t?AG.format(t):""}function PG(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=EG(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 lM(e){const t=ga(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Ba(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 RG(e){const t=ga(e==null?void 0:e.status);return oa(e)==="observation"&&t==="done"?"已观察":lM(t)}function cM(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=ga(e.status),s=oa(e)==="observation"&&r==="done"?"observed":r;return n("status",lM(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Ba(e.platform),e.platform),t}function TG(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{cM(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 MG(e,t){const n=String(t||"all");return!n||n==="all"?!0:cM(e).some(r=>r.key===n)}function $G(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("平台",Ba(e.platform)),t}function Ev(e){const t=[],n=(c,u,d={})=>{const f=iM(u);f&&t.push({...d,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",d=0)=>{if(d>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((p,m)=>r(p,`${u} ${m+1}`,d+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 p of["links","urls","artifacts","outputs","output","results","result","files"])c[p]!=null&&r(c[p],p,d+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",Cc(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 d=new URL(u,window.location.origin);return`${d.origin}${d.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=Vc(c),d=String(c.key||c.artifactKey||c.artifact_key||"").trim(),f=d?`key:${d}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
185
+ ${c.href}`,p=l.get(f);if(!p){l.set(f,c);continue}if(u){const m=a(p.label),y=a(c.label);(y>m||y===m&&String(c.label||"").length>String(p.label||"").length)&&l.set(f,c)}}return OY(Array.from(l.values()),e)}function LG(e,t=[]){var a,l,c,u;const n=[],r=new Map,s=String(((l=(a=e==null?void 0:e.overall)==null?void 0:a.requirement)==null?void 0:l.title)||((u=(c=e==null?void 0:e.overall)==null?void 0:c.requirement)==null?void 0:u.name)||"").trim();for(const d of Nb(e)){const f=Ti(d),p=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();f&&p&&r.set(f,p)}const o=(d,f={})=>{if(!d||typeof d!="object")return;const p=(y,v={})=>{if(!y||typeof y!="object")return;const b=String(f.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),g=y.source||y.sourceArtifact||y.source_artifact||d.sourceArtifact||d.source_artifact||d.source||f.source||null,k=CY({...y,title:y.title||f.documentTitle||(d==null?void 0:d.title)||"",documentTitle:y.documentTitle||y.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(b)||"",requirementTitle:s}),x={label:String(y.label||"ai-doc").trim()||"ai-doc",href:String(y.href||y.url||"").trim(),kind:String(y.kind||y.type||d.kind||d.type||"").trim(),title:k,issueKey:b,platform:f.platform||Ba(d.platform),durability:y.durability||d.durability||f.durability||"",persistence:y.persistence||d.persistence||f.persistence||"",truth:y.truth||y.stateTruth||y.state_truth||oa(d)||f.truth||"",authority:y.authority||d.authority||f.authority||"",confirmed:y.confirmed??d.confirmed??f.confirmed,source:g,documentPath:y.documentPath||y.document_path||y.path||v.documentPath||(g==null?void 0:g.path)||(g==null?void 0:g.documentPath)||(g==null?void 0:g.document_path)||""};x.href&&n.push(x)};for(const y of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:Cc(y)},{documentPath:y.path});for(const y of Array.isArray(d==null?void 0:d.links)?d.links:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:Cc(y)},{documentPath:y.path});const m=Cc(d);m&&p({...d,label:d.label||d.title||d.kind||"ai-doc",href:m},{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:Ba(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 f of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(f,{issueKey:String((f==null?void 0:f.issueKey)||(f==null?void 0:f.issue_key)||(f==null?void 0:f.issue)||"").trim(),platform:Ba(f==null?void 0:f.platform),documentTitle:String((f==null?void 0:f.documentTitle)||(f==null?void 0:f.document_title)||(f==null?void 0:f.title)||"").trim()});for(const d of Nb(e))o(d,{issueKey:Ti(d),platform:Ba(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()});return EY(n,window.location.origin)}function OG(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 Ti(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 DG(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)||Ti(e,t)||`Issue ${t+1}`).trim()}function FG(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 zG(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 BG(e){const t=Ev(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 WG(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 d of u)d&&typeof d=="object"&&c.issues.push({...d,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(FG(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((d,f)=>Ti(d,f));return a.forEach((d,f)=>{const p=Ti(d,f);l.set(p,{issue:d,children:[]})}),a.forEach((d,f)=>{const p=Ti(d,f),m=zG(d)||vY(d,u),y=l.get(p);m&&l.has(m)?l.get(m).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function Sm(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 cl(e){return PY(e)}function jm(e){const t=vm(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 Nb(e){var s,o,a,l,c,u,d,f,p,m,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=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:f.epics,(m=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:m.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 HG(e,t){const n=String(t||"").trim();return n&&Nb(e).find((r,s)=>Ti(r,s)===n)||null}function VG(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 KG(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=HG(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=VG(e);if(!a&&!l)return o;const c=cl(o),u=`${c} ${Av(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 p=ga(o.status),m=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...m?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:Ai(o.artifacts,f)}}function VC(e,t){const n=jm(t),r=jm(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:ao(s,0)||ao(t,0)||ao(e,0),detail:Ch(s)||Ch(t)||Ch(e),status:o,links:Ai(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Ai(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Ai(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Ai(e==null?void 0:e.results,t==null?void 0:t.results),events:Ai(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 qG(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=f=>{var p,m;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||RY(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(((p=f.conflict)==null?void 0:p.previousArtifact)||((m=f.conflict)==null?void 0:m.incomingArtifact)||"")))},l=(f,p)=>({...f,links:Ai(f==null?void 0:f.links,p==null?void 0:p.links),artifacts:Ai(f==null?void 0:f.artifacts,p==null?void 0:p.artifacts),outputs:Ai(f==null?void 0:f.outputs,p==null?void 0:p.outputs),results:Ai(f==null?void 0:f.results,p==null?void 0:p.results)}),c=(f,p)=>{if(!f)return;const m=r.get(f);if(m!=null){n[m]=l(n[m],p);return}o.set(f,l(o.get(f)||{},p))},u=(f,p)=>f&&o.has(f)?l(p,o.get(f)):p,d=f=>{if(Array.isArray(f))for(const p of f){const m=cl(p);if(a(p)){c(m,p);continue}const y=String(p.id||p.eventId||p.event_id||p.actionId||p.action_id||"").trim(),v=m||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(m,VC(n[b],p)),m&&r.set(m,b),y&&s.set(y,b)):(v&&r.set(v,n.length),y&&s.set(y,n.length),n.push(u(m,p)))}};if(d(e==null?void 0:e.actions),d(e==null?void 0:e.workflowActions),d(e==null?void 0:e.workflow_actions),d(e==null?void 0:e.timeline),d(e==null?void 0:e.history),d(e==null?void 0:e.events),d(e==null?void 0:e.runtimeEvents),d(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=Sm(t),p=cl(t),m=p?r.get(p):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};m!=null&&(n[m]=VC(n[m],y))}return n.map((f,p)=>({item:f,index:p,ts:jm(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>KG(e,f.item))}function UG(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:jm(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 YG(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 GG(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)?`(+${La(r)} / 总 ${La(s)})`:"";return`${t+1}. ${n}${o}`}function uM(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 Gl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function JG(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 XG(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 QG(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 ZG(e){var o,a,l;const t=uM(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Gl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=XG(t),u=JG(t),d=Gl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Gl(t.completedAtMs,c==null?void 0:c.completedAtMs),p=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},m=Number.isFinite(d)&&Number.isFinite(f)?Math.max(0,f-d):Gl(p.executionTime,p.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||p.command||"").trim(),v=y?y.split(`
187
+ `).find(Boolean)||y:"";return{kind:"tool",label:QG(u,c),durationMs:Number.isFinite(m)?m:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Gl(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 KC(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=Gl(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),d=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"),p=f.reduce((b,g)=>b+(Number(g.durationMs)||0),0),m=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(`- 当前总耗时:${La(u)}`),d>0&&v.push(`- 模型相关间隔:约 ${La(d)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${La(p)}(${f.length} 次完成事件)`),m>0&&v.push(`- 网络/会话恢复事件:${m} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${La(b.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((b,g)=>{v.push(GG(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${La(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
188
+ `)}function qC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=uM(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 dM(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 fM(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Iv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function pM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function eJ(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 tJ(e){const t=String(e??"").trim();return t?t.includes("${")?t:pM(t):""}function hM(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(tJ).filter(Boolean):[];return[eJ(t,n),pM(o),...a].join(" ")}return String(t.command||"").trim()}function nd(e){const t=String(Iv(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 UC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Nm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function rd(e){return Nm(e)}function Cb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Yp(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 YC(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 GC(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 vw(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=yb(s.get(n),e.sourceHandle||"output-0","source"),a=yb(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&rf(o,a))}function nJ(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=yb(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:wU(a)}:null}function rJ(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"?rf(t.slot,a):rf(a,t.slot)))continue;const c=nd(n);return{def:n,order:r,category:c,categoryRank:Yl.indexOf(c),slot:a,slotIndex:o,displayLabel:rd(n),description:Cb(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 sJ(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 d=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<d.length;f+=1){const p=d[f];if((p==null?void 0:p.showOnNode)===!1||!(s?rf(n.slot,p):rf(p,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:p,slotIndex:f,handleId:s?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,d)=>{var v,b,g,k,x,C,S,N;const f=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),p=Number(((k=(g=d.node)==null?void 0:g.position)==null?void 0:k.y)||0),m=Number(((C=(x=u.node)==null?void 0:x.position)==null?void 0:C.x)||0),y=Number(((N=(S=d.node)==null?void 0:S.position)==null?void 0:N.x)||0);return f-p||m-y||u.slotIndex-d.slotIndex||String(u.nodeId).localeCompare(String(d.nodeId))})}function pc(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 iJ(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 oJ(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function aJ(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return of;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} * * *`:of}function Ko(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 Pv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Ko(t[1],9,0,23)}:${Ko(t[2],0,0,59)}`:"09:00"}function sd(e,t,n,r,s){const o=Pv(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()||of:`${l} ${a} * * *`}function lJ(e){const n=String(e||of).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),d=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),f=d?`${Ko(u,9,0,23)}:${Ko(c,0,0,59)}`:"09:00";return d&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:d&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:d&&/^\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 Rv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=aJ(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=lJ(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=Pv(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),d=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=sd(l,c,u,d,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:d,cron:f,timezone:lG,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function cJ(e){const t=Rv(JSON.stringify(e||{}));return JSON.stringify(t)}function uJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dJ(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function JC(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 Gp(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:JC(n.nextRunAt),lastAt:JC(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 Cm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function _m(e){return e>0?`Group ${e+1}`:"Group"}function fJ(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)||_m(r)).trim()||_m(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(al,Math.round(l)),height:Math.max(ll,Math.round(c))}}).filter(Boolean)}function pJ(e){var n;return fJ((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Nc,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 _b(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(al,Math.round(t)),height:Math.max(ll,Math.round(n))}}function id(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:oJ(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 mM(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 hJ(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=kg(t);return[mM(e),_n(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 XC(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 mJ=new Map,gJ=[];function Hu(e,t){var m,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=wM(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(m=e==null?void 0:e.ui)!=null&&m.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=Iv(k)||g,C=t.find(D=>D.id===x)||k,S=b.marketplaceRef||fM(k),N=hM(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=!!_n({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=Ga(z,{display:R}),O=E&&!li(x);return{id:v,type:Nc,position:P,...O?{width:E.width,height:E.height}:{},data:{label:b.label||Nm(k)||Nm(C)||v,definitionId:x,...S?{marketplaceRef:S}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:dM(x,C||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=>xb(v,r,t)),d=pJ(e),f=s.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!d.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:Ci.ArrowClosed}})),p=[...d,...u];return{nodes:p,edges:VU(f,p),instances:r}}function QC(e){return`${jb}${e}`}function Jp(e){const t=String(e||"");return t.startsWith(jb)?t.slice(jb.length):t}function Ab(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 _h(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var p;return ul((p=f==null?void 0:f.data)==null?void 0:p.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 p=String(f||"").trim();!p||o.has(p)||!n.has(p)||(o.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((f,p)=>{const m=l[f];a[f]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(f=>{const p=Ga(u[f],{display:!0});p&&(c[f]=p)});const d=Ab(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...d?{viewport:d}:{}}}function ZC(e,t=[]){return _h(e,t)}const Sw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function jw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function e_(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function t_(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 yJ(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function n_(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const gM="af:workspace:canvas-clipboard",yM="agentflow.workspace.canvas-clipboard";function wJ(e){return JSON.stringify({type:yM,version:1,clipboard:e})}function xJ(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==yM)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function bJ(e){try{localStorage.setItem(gM,wJ(e))}catch{}}function kJ(){try{return xJ(localStorage.getItem(gM))}catch{return null}}function vJ(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Eb(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 r_(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Ga(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:r_(n,nM,rM)||tM,height:r_(r,bm,sM)||bm}}function Am(e){const t=Ga(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function SJ(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:vb,height:Sb}}function jJ(e,t=""){const n=Am(e==null?void 0:e.displaySize);if(n)return n;const r=Am(e==null?void 0:e.nodeSize);if(r)return r;const s=ul(t)||Af(la((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return SJ(s)}function Jl(e){var s,o,a,l,c,u,d,f,p,m,y;if(li((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!_n(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=(d=e==null?void 0:e.data)==null?void 0:d.displaySize)==null?void 0:f.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return Ga({width:n,height:r},{display:t})}function Kl(e,t,n){var d,f,p,m,y,v,b,g,k,x,C,S,N;const r=(e||[]).filter(P=>!Cm(P)),s=(e||[]).filter(Cm),o=wM(Sv(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:((d=P.position)==null?void 0:d.x)||0,y:((f=P.position)==null?void 0:f.y)||0};const R=Jl(P);R&&(c[P.id]=R)}for(const P of s){const R=Number(((m=(p=P.data)==null?void 0:p.nodeSize)==null?void 0:m.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(((C=P.data)==null?void 0:C.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(al,Math.round(R||al)),height:Math.max(ll,Math.round(z||ll))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function wM(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!ul(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 ul(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 _n(e){const t=ul(e==null?void 0:e.definitionId);return t||(li(e==null?void 0:e.definitionId)&&kg(e)?Af(la((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function lo(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=_n(e),r=li(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 aa(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 NJ(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 Mi(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=NJ(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 d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
193
+ `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
194
+ `).replace(/\s+$/g,""):d.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 dl(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 Ib(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 CJ(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 eu(e){let t=Mi(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 _J(e){const t=eu(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Wa(e,t){return e==="html"?_J(t):""}function xM(e,t=""){const n=eu(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 AJ(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 EJ(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function IJ(e,t){const n=URL.createObjectURL(e);try{EJ(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function bM(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 PJ(e){const t=bM(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 Nw(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 RJ(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=bM(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,d=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,p={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:Nw(c),displayBody:Nw(u),scroller:Nw(d)},m=[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((d==null?void 0:d.clientWidth)||0),Number((d==null?void 0:d.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,...m.length?m:[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:p}}async function TJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=RJ(r,s,o,{...l||{},displaySize:c}),d=PJ(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:d||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!f.ok){const m=await f.json().catch(()=>({}));throw new Error(m.error||"截图失败")}const p=await f.blob();IJ(p,a)}function MJ(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 kM(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 $J(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 vM({code:e}){const t=h.useMemo(()=>$J(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((d,f)=>{l.set(d.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(d=>d.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(d=>d.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((d,f)=>{const p=l.get(d.from),m=l.get(d.to);if(!p||!m)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+m.x+r)/2} ${p.y+s/2}, ${(p.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.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:d.label.slice(0,22)})]},d.id)})]})})}function wi({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),m=f>p+1,y=m?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=m?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:m,top:b,height:y})},[]);h.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const m of Array.from(f.children))p.observe(m);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=h.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=h.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),y=s.height/100*m.height,v=Math.max(1,m.height-y);return(d-m.top-f)/v},[s.height]),u=h.useCallback(d=>{var C,S;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),m=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+m&&d.clientY<=p.top+m+y?d.clientY-p.top-m:y/2;l(c(d.clientY,b));const g=d.pointerId;(S=(C=d.currentTarget).setPointerCapture)==null||S.call(C,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 SM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=_n(e),o=lo(e),a=s==="image"?o:Mi(o),l=s==="image"?"":aa(a,s),[c,u]=h.useState(""),[d,f]=h.useState(""),[p,m]=h.useState(!1);h.useEffect(()=>{let k=!1;return l?(m(!0),f(""),u(""),dl(t,l).then(x=>{k||u(x)}).catch(x=>{k||f(String(x.message||x))}).finally(()=>{k||m(!1)}),()=>{k=!0}):(u(""),f(""),m(!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"?eu(y):s==="react"?bg(y):Mi(y),b=h.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=Wa(s,v);if(p)return i.jsxs(wi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(d)return i.jsx(wi,{className:"af-work-display-empty",children:d});if(g)return i.jsx(wi,{className:"af-work-display-empty",children:g});if(!v.trim())return i.jsx(wi,{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"?jv(v,b.current):xM(v,b.current)},r)});if(s==="image"){const k=af(v,t);return i.jsx(wi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:k,alt:MJ(e),loading:"lazy"})})}return s==="markdown"?i.jsx(wi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(wv,{content:v,basePath:l,resolveSrc:(k,x)=>af(k,t,x)})}):s==="chart"?i.jsx(wi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(bv,{content:v})}):s==="table"?i.jsx(wi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(xv,{content:v})}):s==="mermaid"?i.jsxs(wi,{className:"af-work-display-body",children:[i.jsx(vM,{code:v}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):i.jsx(wi,{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 LJ({node:e,onClose:t}){var k,x,C,S,N,P,R,z,E,O,D;const n=h.useRef(null),r=_n(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]=h.useState(!1),[c,u]=h.useState(""),[d,f]=h.useState(""),[p,m]=h.useState(!1),y=lo(e==null?void 0:e.data),v=r==="markdown"?Mi(y):"",b=r==="markdown"?aa(v,"markdown"):"",g=r==="markdown"?b?d:v:"";return h.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]),h.useEffect(()=>{var M;let L=!1;return r!=="markdown"||!b?(f(""),m(!1),()=>{L=!0}):(m(!0),dl(((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||m(!1)}),()=>{L=!0})},[r,b,(S=(C=e==null?void 0:e.data)==null?void 0:C.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]),h.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:kM(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||p,onClick:async()=>{var L,M;try{await NM({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||p,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(jM,{value:c,onChange:u,onUploadImage:(O=e.data)==null?void 0:O.onUploadWorkspaceImage,readOnly:o}):i.jsx(SM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function OJ({node:e}){var p,m,y,v,b,g,k,x,C,S;const t=_n(e==null?void 0:e.data),n=lo(e==null?void 0:e.data),r=t==="image"?n:Mi(n),s=t==="image"?"":aa(r,t),[o,a]=h.useState(""),[l,c]=h.useState(!1);h.useEffect(()=>{var P;let N=!1;return s?(c(!0),a(""),dl(((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,(m=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:m.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,d=t==="html"?eu(u):t==="react"?bg(u):Mi(u),f=Wa(t,d);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}):d.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"?jv(d):xM(d)}):t==="image"?i.jsx("img",{src:af(d,(C=e==null?void 0:e.data)==null?void 0:C.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(wv,{content:d,basePath:s,resolveSrc:(N,P)=>{var R;return af(N,(R=e==null?void 0:e.data)==null?void 0:R.flowParams,P)}})}):t==="chart"?i.jsx(bv,{content:d}):t==="table"?i.jsx(xv,{content:d}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(vM,{code:d}),i.jsx("pre",{children:d})]}):i.jsx("pre",{className:"af-display-picker-preview__pre",children:d}):i.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function jM({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=h.useRef(null),o=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(!1),[u,d]=h.useState({visible:!1,top:0,height:100}),f=h.useCallback(()=>{const g=s.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),C=k>x+1,S=C?Math.max(12,x/k*100):100,N=Math.max(0,100-S),P=C?Math.min(N,g.scrollTop/Math.max(1,k-x)*N):0;d({visible:C,top:P,height:S})},[]);h.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 p=h.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]),m=h.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const C=x.getBoundingClientRect(),S=u.height/100*C.height,N=Math.max(1,C.height-S);return(g-C.top-k)/N},[u.height]),y=h.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),C=u.top/100*x.height,S=u.height/100*x.height,P=g.clientY>=x.top+C&&g.clientY<=x.top+C+S?g.clientY-x.top-C:S/2;p(m(g.clientY,P));const R=E=>{E.preventDefault(),p(m(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)},[m,p,u.height,u.top,u.visible]),v=h.useCallback(g=>{const k=String(e||""),x=s.current,C=Number((x==null?void 0:x.selectionStart)??k.length),S=Number((x==null?void 0:x.selectionEnd)??C),N=k.slice(0,C),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=h.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 C=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(`![${C}](${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(C=>String((C==null?void 0:C.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(km);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 DJ({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]=h.useState(a),u=h.useRef(!1),d=String(s.candidateContent||""),f=!!s.running,p=!!(t!=null&&t.readOnly),m=String(s.error||""),y=o.slice(-2);return h.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||m?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,m?i.jsx("div",{className:"af-work-node-chat__error",children:m}):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||p,"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||p,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||p||!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"})})]}),d.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:d})]})}):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 FJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function zJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function BJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function s_(e,t=""){const n=aa(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function WJ(e,t){const n=BJ(e),r=new Set,s=_n(t)||"";li(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=s_(lo(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(/^\/+/,""),d=s_(u,s);return d&&r.add(d),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function i_(e,t){const n=_n(t)||"markdown";return`outputs/${zJ((t==null?void 0:t.label)||e||n)}.${FJ(n)}`}async function NM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await Ib((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 CM({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 Ce,He,ct,yt;const de=String(((Ce=ee.slot)==null?void 0:Ce.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=_n(t),c=h.useRef(null),u=h.useRef(null),[d,f]=h.useState(0),[p,m]=h.useState(!1),[y,v]=h.useState(!1),[b,g]=h.useState(!1),[k,x]=h.useState(""),[C,S]=h.useState(""),[N,P]=h.useState(!1),[R,z]=h.useState(!1),E=h.useRef(null),O=lo(t),D=l==="markdown"?Mi(O):"",L=l==="markdown"?aa(D,"markdown"):"",M=l==="markdown"?L?C:D:"",V=!!(t!=null&&t.readOnly),B=!!(t!=null&&t.displayPageMode);h.useEffect(()=>{let ee=!1;return l!=="markdown"||!L?(S(""),P(!1),()=>{ee=!0}):(P(!0),dl((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]),h.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]),h.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=h.useCallback(async()=>{var Re,ot,kt,$t,ye,ze,oe,ke,Be,Qe;if(l!=="html"||p)return;const ee=lo(t),ue=aa(ee,l);let de=ee;if(ue)try{de=await dl((t==null?void 0:t.flowParams)||{},ue)}catch(_e){m(!1),console.warn("Failed to read HTML display file before saving image.",_e);return}const pe=eu(de);if(!pe.trim())return;const Me=Wa(l,pe);if(Me){console.warn(Me);return}const Ne=(ot=(Re=u.current)==null?void 0:Re.getBoundingClientRect)==null?void 0:ot.call(Re),Ce=($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((Ce==null?void 0:Ce.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((Ce==null?void 0:Ce.clientHeight)||0),Number((He==null?void 0:He.clientHeight)||0),Math.max(180,Number((A==null?void 0:A.height)||640)-46)));m(!0);try{await TJ({flowParams:(t==null?void 0:t.flowParams)||{},content:pe,sourceFilePath:ue,iframe:u.current,width:ct,height:yt,filename:AJ((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:Ce,scroller:He},displaySize:A}),(Be=t==null?void 0:t.onStatus)==null||Be.call(t,"已导出 HTML 展示截图")}catch(_e){const _t=String((_e==null?void 0:_e.message)||_e||"截图失败");(Qe=t==null?void 0:t.onStatus)==null||Qe.call(t,`HTML 截图失败:${_t}`),console.warn("Failed to save HTML display as PNG.",_e)}finally{m(!1)}},[t,A==null?void 0:A.height,A==null?void 0:A.width,e,l,p]),K=h.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=h.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=h.useCallback(ee=>{var pe,Me;V||l!=="image"||!(Array.from(((pe=ee.dataTransfer)==null?void 0:pe.files)||[]).some(km)||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=h.useCallback(ee=>{l==="image"&&(ee.currentTarget.contains(ee.relatedTarget)||z(!1))},[l]),Y=h.useCallback(ee=>{var de;if(l!=="image")return;const ue=Array.from(((de=ee.dataTransfer)==null?void 0:de.files)||[]).find(km);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:Y,children:[i.jsx(nv,{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(h.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(h.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:kM(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:p,onClick:Q,"aria-label":"截图另存为图片",title:"截图另存为图片",children:i.jsx("span",{className:"material-symbols-outlined",children:p?"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 NM({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(jM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:V}):i.jsx(SM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),i.jsx(DJ,{nodeId:e,data:t})]})}function HJ({id:e,data:t,selected:n,deleteNode:r}){var d,f,p;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=(d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d.has)==null?void 0:f.call(d,e))||((p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p[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((m,y)=>{if(m.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=m.name||`#${y+1}`;return i.jsxs(h.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(m.type)},title:`${b} · ${m.type}`})]},`in-${y}`)}),o.map((m,y)=>{if(m.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=m.name||`#${y+1}`;return i.jsxs(h.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(m.type)},title:`${b} · ${m.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:m=>{var y,v;m.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:m=>{var y;m.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:m=>{var y;m.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 VJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var Qe,_e,_t,Xt,Ft,at,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=oX(t),[d,f]=h.useState(u.task),p=h.useRef(!1),m=h.useRef(u.task),y=((_e=(Qe=t==null?void 0:t.runningRunNodeIds)==null?void 0:Qe.has)==null?void 0:_e.call(Qe,e))||((_t=t==null?void 0:t.runningRunNodeIds)==null?void 0:_t[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=h.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]),[C,S]=h.useState(!1),[N,P]=h.useState(""),[R,z]=h.useState(()=>new Set),[E,O]=h.useState(!1),[D,L]=h.useState(""),[M,V]=h.useState("config"),B=kg(t),F=!!B,$=TM(u.displayType),H=h.useMemo(()=>jJ(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=h.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((at=t==null?void 0:t.modelLists)==null?void 0:at.claudeCode)?t.modelLists.claudeCode:[],te=Array.isArray((Fn=t==null?void 0:t.modelLists)==null?void 0:Fn.codex)?t.modelLists.codex:[],Z=h.useMemo(()=>new Set(Q.map(As)),[Q]),Y=h.useMemo(()=>new Set(K.map(As)),[K]),ne=h.useMemo(()=>new Set(W.map(As)),[W]),re=h.useMemo(()=>new Set(te.map(As)),[te]),se=u.model,ee=h.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}`:Y.has(se)?`opencode:${se}`:Z.has(se)?`cursor:${se}`:se:"",[ne,re,Z,Y,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)&&!Y.has(de)&&!ne.has(de)&&!re.has(de),Me=h.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ne=h.useMemo(()=>new Map(g.map(ie=>[ie.key,ie])),[g]),Ce=h.useMemo(()=>{const ie=new Set,Ie=k.map(qe=>{const Pt=ia(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]);h.useEffect(()=>{z(ie=>{let Ie=!1;const et=new Set(ie);for(const qe of Ce.collectionGroups)et.has(qe.id)||(et.add(qe.id),Ie=!0);return Ie?et:ie})},[Ce.collectionGroups]);const He=h.useMemo(()=>{const ie=N.trim().toLowerCase();if(!ie)return Ce;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:Ce.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:Ce.ungrouped.filter(Ie)}},[Ce,N]),ct=Pb(C,[He.collectionGroups.length,He.ungrouped.length,R.size,u.skillKeys.length,N]),yt=h.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=h.useMemo(()=>OM(u.knowledgeContext),[u.knowledgeContext]),ot=h.useMemo(()=>new Set(Re.map(ie=>ie.id||ie.path||ie.repoPath).filter(Boolean)),[Re]),kt=Pb(E,[yt.length,Re.length,D]);h.useEffect(()=>{u.task!==m.current&&(m.current=u.task,p.current||f(u.task))},[u.task]),h.useEffect(()=>{if(!F){V("config");return}y||V("result")},[F,B,y]),h.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:d,...ie})},ye=(ie=d)=>{var et;const Ie=String(ie??"");Ie!==u.task&&(m.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:ot.has(vt)});$t({knowledgeContext:vg(qe)})},Be=()=>{$t({knowledgeContext:null})};return M==="result"&&F?i.jsx(CM,{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(h.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(h.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:${As(ie)}`,children:As(ie)},`context-cursor-${ie}`))}):null,K.length?i.jsx("optgroup",{label:"OpenCode",children:K.map(ie=>i.jsx("option",{value:`opencode:${As(ie)}`,children:As(ie)},`context-opencode-${ie}`))}):null,te.length?i.jsx("optgroup",{label:"Codex",children:te.map(ie=>i.jsx("option",{value:`codex:${As(ie)}`,children:As(ie)},`context-codex-${ie}`))}):null,W.length?i.jsx("optgroup",{label:"Claude Code",children:W.map(ie=>i.jsx("option",{value:`claude-code:${As(ie)}`,children:As(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:li(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:d,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{p.current=!0},onCompositionEnd:ie=>{p.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(),C||(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"})]}),C?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:ot.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 KJ({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=Rv((t==null?void 0:t.body)||""),[l,c]=h.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},d=((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,p=(t==null?void 0:t.nodeStatus)==="stopped",m=!!(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:sd(E,a.time,a.weekday,a.monthDay,a.cron)})},b=E=>{y({time:E,cron:sd(a.scheduleType,E,a.weekday,a.monthDay,a.cron)})},[g,k]=Pv(a.time).split(":"),x=(E,O)=>{b(`${Ko(E,9,0,23)}:${Ko(O,0,0,59)}`)},C=E=>{y({weekday:E,cron:sd(a.scheduleType,a.time,E,a.monthDay,a.cron)})},S=E=>{y({monthDay:E,cron:sd(a.scheduleType,a.time,a.weekday,E,a.cron)})};h.useEffect(()=>{c(a.cron)},[a.cron,e]);const N=()=>{m||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":"")+(d?" 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":"")+(p?" 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(h.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(h.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:m,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:m,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:m,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:m,"aria-label":"小时",onChange:E=>x(E.target.value,k),children:Array.from({length:24},(E,O)=>Ko(O,0,0,23)).map(E=>i.jsxs("option",{value:E,children:[E," 时"]},E))}),i.jsx("select",{value:k,disabled:m,"aria-label":"分钟",onChange:E=>x(g,E.target.value),children:Array.from({length:12},(E,O)=>Ko(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:m,onChange:E=>C(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:m,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:m,spellCheck:!1,placeholder:of,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:[dJ(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",uJ(u.nextAt)]}),i.jsx("span",{children:d?"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"+(d?" af-work-run-card__button--stop":""),disabled:m||f,onClick:E=>{var O,D;E.stopPropagation(),d?(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:d?"stop_circle":"play_arrow"}),i.jsx("span",{children:d?"停止":"立即运行"})]}),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:m||d||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 qJ({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Xc(),o=!!(t!=null&&t.readOnly),a=_b(t==null?void 0:t.nodeSize)||{width:al,height:ll},l=h.useCallback(c=>{var u,d;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(d=(u=c.target)==null?void 0:u.closest)!=null&&d.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(f=>EM(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(nv,{className:"af-work-group-node__resize nodrag",minWidth:al,minHeight:ll,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 UJ(e){var y,v,b,g,k,x,C,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}=Xc(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,s=!!((v=e.data)!=null&&v.readOnly),[o,a]=h.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=h.useCallback(Y=>{var se,ee,ue;if(s)return;(ee=(se=e.data)==null?void 0:se.onCleanupWorkspaceNodeOutputs)==null||ee.call(se,Y,e.data);const ne=li((ue=e.data)==null?void 0:ue.definitionId)?MM(Y):"",re=new Set([Y,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=h.useCallback(Y=>{var ne,re;Y.button!==0||Y.metaKey||Y.ctrlKey||Y.shiftKey||(re=(ne=Y.target)==null?void 0:ne.closest)!=null&&re.call(ne,".react-flow__handle, .af-work-display-resize")||(n(se=>EM(se,e.id)),t(se=>XJ(se)))},[e.id,t,n]),d=h.useCallback((Y,ne)=>{s||(n(re=>re.map(se=>se.id===Y?{...se,data:{...se.data,model:ne}}:se)),r==null||r(Y,{model:ne}))},[s,n,r]),f=h.useCallback((Y,ne)=>{s||(n(re=>re.map(se=>{var ue;if(se.id!==Y)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(Y,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]),p=h.useCallback((Y,ne)=>{s||(n(re=>re.map(se=>se.id===Y?{...se,data:{...se.data,body:ne}}:se)),r==null||r(Y,{body:ne}))},[s,n,r]),m=h.useCallback((Y,ne)=>{if(s)return;const re=bo(ne);n(se=>se.map(ee=>ee.id===Y?{...ee,data:{...ee.data,images:re}}:ee)),r==null||r(Y,{images:re})},[s,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?i.jsx(qJ,{...e,deleteNode:c}):ul((k=e.data)==null?void 0:k.definitionId)?i.jsx(CM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(HJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((C=e.data)==null?void 0:C.definitionId)==="workspace_scheduled_run"?i.jsx(KJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):li((S=e.data)==null?void 0:S.definitionId)?i.jsx(VJ,{...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(pX,{...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(hX,{...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(mX,{...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(nv,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:nM,minHeight:bm,maxWidth:rM,maxHeight:sM,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(IU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(Z=e.data)==null?void 0:Z.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:p,onNodeImagesChange:m})]})}const YJ={[Nc]:h.memo(UJ)};function Tv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Tv(n.children,t);return t}function _M(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)?_M(r.children,n):null;if(s)return s}return null}function GJ(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function AM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&AM(n.children,t));return t}function Xp(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 JJ(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 EM(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:JJ(e,n)}function XJ(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function QJ(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function ZJ(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,d=a===r.length-1;let f=!1;const p=(Array.isArray(o)?o:[]).map(m=>m.name!==c?m:(f=!0,d?{...m,type:"file",name:c,path:u,icon:pc(c),size:n}:{...m,type:"directory",name:c,path:u,icon:pc(c,!0),children:s(m.children||[],a+1,u)}));return f||p.push(d?{type:"file",name:c,path:u,icon:pc(c),size:n}:{type:"directory",name:c,path:u,icon:pc(c,!0),children:s([],a+1,u)}),QJ(p)};return s(e||[],0,"")}function eX(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 IM({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 m;const d=u.type==="directory",f=d&&(r==null?void 0:r.has(u.path)),p=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+(p?" af-work-file--selected":""),draggable:!d,onDragStart:y=>{d||a==null||a(y,u)},onClick:()=>{o==null||o(u),d&&(s==null||s(u.path))},onDoubleClick:()=>{d||t(u)},title:u.path,children:[d?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||pc(u.name,d)}),i.jsx("span",{children:u.name})]}),p?i.jsxs("div",{className:"af-work-file-actions",children:[d?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]}),d&&!f&&((m=u.children)!=null&&m.length)?i.jsx(IM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function tX({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=h.useMemo(()=>Tv(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||pc(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:eX(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function o_({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 PM(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function nX(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!PM(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 rX(e){return(Array.isArray(e)?e:[]).filter(PM)}function lf(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 sX(e){const t=lf((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 lf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function iX(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 lf((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function RM(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 a_(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function la(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 Em(e,t){const n=la(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 Af(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function As(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function TM(e){const t=Af(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 MM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function $M(e){return e==="display_image"?"src":"content"}function l_(e,t,n){const r=$M(t),s=id(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 c_(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 u_(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 kg(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 oX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=la(t,"includeWorkspaceContext","true").toLowerCase(),r=Em(t,"knowledgeContext"),s=Em(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:iX(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?vg([s]):null),workspaceContext:s,displayType:Af(la(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function li(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function aX(e){const t=lf((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 lf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function lX(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function LM(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 vg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>LM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function OM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>LM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function cX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=Em(t,"knowledgeContext"),r=Em(t,"workspaceContext");return{sources:OM(n||(r?vg([r]):null)),path:la(t,"path",""),label:la(t,"label","")}}function d_(e){var r,s,o,a,l,c,u,d,f;if(!e)return null;const{inputs:t,outputs:n}=HU(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:bo((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(((d=e.data)==null?void 0:d.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function f_(e,t,n,r=""){var c,u;const s=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(d=>String((d==null?void 0:d.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 p_(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 uX(e,t,n){var d,f;const r=String(((d=e==null?void 0:e.data)==null?void 0:d.definitionId)??n),s=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=nf.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?[]:bo(t==null?void 0:t.images),inputs:p_(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:p_(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 p of["scriptRef","implementationRef","implementationMode"]){const m=String((t==null?void 0:t[p])??"").trim();m?c[p]=m:delete c[p]}return c}function h_({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(!fY.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=uX(r,s,c),d=r.data||{};if(!(c!==a||d.label!==u.label||d.role!==u.role||d.model!==u.model||d.body!==u.body||JSON.stringify(bo(d.images))!==JSON.stringify(u.images)||(d.script??void 0)!==(u.script??void 0)||(d.scriptRef??void 0)!==(u.scriptRef??void 0)||(d.implementationRef??void 0)!==(u.implementationRef??void 0)||(d.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(d.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(d.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const p=e.map(v=>v.id===a?{...v,id:c,selected:!0,data:u}:v);let m=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,m=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:p,edges:m,instances:y}}function dX(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function fX(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"])dX(e[s],t[s])&&(r[s]=n[s]);return r}function Pb(e,t=[]){const n=h.useRef(null),r=h.useRef(null),[s,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),m=f>p+1,y=m?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=m?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:m,top:b,height:y})},[]);h.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)},[e,a,...t]);const l=h.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=h.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),y=s.height/100*m.height,v=Math.max(1,m.height-y);return(d-m.top-f)/v},[s.height]),u=h.useCallback(d=>{var C,S;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),m=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+m&&d.clientY<=p.top+m+y?d.clientY-p.top-m:y/2;l(c(d.clientY,b));const g=d.pointerId;(S=(C=d.currentTarget).setPointerCapture)==null||S.call(C,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 pX({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:[],d=Array.isArray(o)?o:[],[f,p]=h.useState(!1),[m,y]=h.useState(""),[v,b]=h.useState(()=>new Set),g=h.useRef(null),k=h.useRef(null),[x,C]=h.useState({visible:!1,top:0,height:100}),S=h.useMemo(()=>new Set(sX(t)),[t]),N=h.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),P=h.useMemo(()=>Array.from(S).map(F=>{var $;return(($=N.get(F))==null?void 0:$.name)||F}),[N,S]),R=h.useMemo(()=>RM(P,"选择 Skills"),[P]),z=h.useMemo(()=>{const F=new Set,$=d.map(A=>{const Q=ia(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,d,u]);h.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=h.useMemo(()=>{const F=m.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,m]),O=h.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=h.useCallback(F=>{b($=>{const H=new Set($);return H.has(F)?H.delete(F):H.add(F),H})},[]),L=h.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;C({visible:A,top:W,height:Q})},[]);h.useEffect(()=>{if(!f)return;const F=requestAnimationFrame(L);return()=>cancelAnimationFrame(F)},[v,E,S.size,f,L]);const M=h.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=h.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=h.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))},Y=()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",Y),window.removeEventListener("pointercancel",Y)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",Y),window.addEventListener("pointercancel",Y)},[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(h.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(h.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),p(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:m,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),m?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 hX({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]=h.useState(!1),[d,f]=h.useState(""),p=h.useMemo(()=>new Set(aX(t)),[t]),m=h.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=h.useMemo(()=>{const b=d.trim().toLowerCase();return b?m.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):m},[d,m]),v=h.useCallback((b,g)=>{const k=new Set(p);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,p,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(h.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(h.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:p.size>0?`${p.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:d,onChange:b=>f(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),d?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:p.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 mX({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,d]=h.useState(!1),[f,p]=h.useState(""),m=cX(t),y=h.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=h.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=h.useMemo(()=>new Set((m.sources||[]).map(S=>S.id||S.path||S.repoPath).filter(Boolean)),[m.sources]),g=h.useMemo(()=>(m.sources||[]).map(S=>S.label||S.id||S.mountPath||S.path),[m.sources]),k=h.useMemo(()=>RM(g,"选择知识库"),[g]),x=Pb(u,[v.length,g.length,f]),C=(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(h.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(h.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(),d(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=>p(S.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),f?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: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=>C(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 DM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=KT(r),o=SY(BG(r)),a=s?o.filter(p=>!["issue","mr"].includes(ym(p))):o,l=NY(r,o),c=Ti(r,t),u=s?"":Ba(r.platform),d=Array.isArray(e==null?void 0:e.children)?e.children.length:0,f=[c,s&&d?`${d} 个端侧 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:DG(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(p=>i.jsx("a",{href:p.href,target:"_blank",rel:"noreferrer",children:p.label},`${p.label}-${p.href}`))}):null,d?i.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((p,m)=>i.jsx(DM,{row:p,index:m,child:!0},Ti((p==null?void 0:p.issue)||{},m)))}):null]})}function FM(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 zM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>FM(n)).filter(Boolean)}function gX({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=zM(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 yX({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"&&zM(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(gX,{fieldKey:o,field:a},o))})]})}function wX({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=FM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(s).filter(([f,p])=>f&&p&&typeof p=="object"&&!Array.isArray(p)),d=!!(o||a||l||u.length);return!c&&!d?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,d?i.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([f,p])=>i.jsx(yX,{sectionKey:f,section:p},f))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function xX({flowParams:e={},tapdId:t,setTapdId:n,snapshot:r,loading:s,error:o,actionRunning:a,actionOutput:l,pendingConfirm:c,conflict:u,reviewPublishing:d,onRefresh:f,onRunDryRun:p,onConfirmAction:m,onRetryConflict:y,onPublishReview:v}){const[b,g]=h.useState("all"),[k,x]=h.useState("all"),[C,S]=h.useState(!1),[N,P]=h.useState(!1),[R,z]=h.useState(!1),[E,O]=h.useState(""),[D,L]=h.useState(!1),[M,V]=h.useState(""),[B,F]=h.useState(null),$=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),H=Array.isArray(r==null?void 0:r.issues)?r.issues:[],A=WG(r),Q=A.reduce((ye,ze)=>ye+bb(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=qG(r,W),Z=LG(r,te),Y=K.filter(ye=>!UT({...ye,href:Cc(ye)})),ne=h.useMemo(()=>TG(te),[te]);h.useEffect(()=>{k!=="all"&&(ne.some(ye=>ye.key===k)||x("all"))},[k,ne]);const re=te.filter(ye=>MG(ye,k)),se=PG(re),ee=UG(r),ue=ee.filter(ye=>YG(ye,b)),de=re.filter(ye=>_v(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)||""),Ce=r!=null&&r.globalState&&typeof r.globalState=="object"?r.globalState:null,He=SG($),ct=h.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 _e=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:ye})}),_t=await _e.json().catch(()=>({}));if(!_e.ok)throw new Error(_t.error||"生成 Workflow 分享链接失败");Be=_t.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)}}},ot=async()=>{const ye=await Eb((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:HC($)}),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})," · 独立需求 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),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,onClick:yt,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:[HC(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&&Sm(W)?i.jsxs("div",{className:"af-prd-workflow-local-command",children:[i.jsx("span",{children:"本地 agent 执行"}),i.jsx("code",{children:W.command||ao(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=ga(ze.status),Be=oa(ze)==="observation"&&ke==="done"?"observed":ke,Qe=Ev(ze),_e=IG(ze),_t=$G(ze),Xt=NG(ze,oe),Ft=CG(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:[_e?i.jsx("time",{dateTime:vm(ze),children:_e}):null,i.jsx("strong",{children:Xt})]}),Ft?i.jsx("p",{children:Ft}):null,_t.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:_t.map(at=>i.jsxs("span",{children:[i.jsx("b",{children:at.label}),at.value]},`${at.label}-${at.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:RG(ze)})]}),Qe.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Qe.map(at=>i.jsxs("a",{href:at.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:at.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${at.label}-${at.href}`))}):null]})]},ze.id||ze.actionId||`${ao(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(wX,{globalState:Ce,tapdId:t}),Y.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:Y.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:Y.map((ye,ze)=>{const oe=Cc(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:bb(ye.issues)})]}),ye.issues.map((ze,oe)=>i.jsx(DM,{row:ze,index:oe},Ti((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:ao(ye,ze)}),i.jsx("small",{children:[ye.status,ye.type,vm(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]})]}),C?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 ot(),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 m_(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 Vu(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function bX(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],d=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(d)?[]:{}),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 kX(){var O0,D0,F0,z0;const{t:e,i18n:t}=Vr(),{navigate:n}=rs(),r=Xc(),s=dn(),o=u6(),a=h.useMemo(uG,[]),l=!!a.workflowShare,c=h.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=h.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[d,f]=h.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[p,m]=h.useState(!1),[y,v]=h.useState(!1),[b,g]=d6([]),[k,x]=f6([]),C=h.useRef([]),S=h.useRef([]),N=h.useRef(null),[P,R]=h.useState(()=>_h(null,[])),z=h.useRef(P),[E,O]=h.useState(null),D=h.useRef(null),L=h.useRef(!1),[M,V]=h.useState([]),B=h.useRef(new Map),F=h.useRef(new Map),$=h.useRef(new Set),H=h.useRef(new Set),A=h.useRef(null),Q=h.useRef(null),K=h.useRef([]),W=h.useRef(null),te=h.useRef(null),Z=h.useRef(null),[Y,ne]=h.useState(null),[re,se]=h.useState({}),ee=h.useRef({}),ue=h.useRef(!1),de=h.useRef(null),pe=h.useRef(""),Me=h.useRef(null),Ne=h.useRef(Promise.resolve()),Ce=h.useRef({running:!1,pending:null}),He=h.useRef(0),ct=h.useRef(!1),yt=h.useRef(0),Re=h.useRef(null),ot=h.useRef(!1),kt=h.useRef(!1),$t=h.useRef(""),ye=h.useRef(!1),ze=h.useRef(null),oe=h.useRef(!1),ke=h.useRef(new Set),Be=h.useRef(!1),Qe=h.useRef(!1),_e=h.useCallback(()=>KY({nodeInteraction:oe.current,pointerCount:ke.current.size,viewportInteraction:Be.current}),[]),_t=h.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),Xt=h.useRef(!1),Ft=h.useRef(null),[at,Fn]=h.useState([]),ie=h.useRef([]),[Ie,et]=h.useState(""),[qe,Pt]=h.useState("nodes"),[vt,tr]=h.useState([]),[Yn,Tr]=h.useState(!1),[kn,nr]=h.useState(""),[pr,hr]=h.useState(!1),[fn,zn]=h.useState({name:"",id:"",description:""}),[is,Ds]=h.useState(!1),[vn,Gn]=h.useState(""),[bs,Jn]=h.useState(""),Bn=h.useRef(null),[vr,Sr]=h.useState(!1),[Wn,Mr]=h.useState(!1),[$r,ce]=h.useState(""),[me,tt]=h.useState(null),[rt,zt]=h.useState(()=>jw()),[Rn,jr]=h.useState(""),[Nr,mr]=h.useState(!1),[ut,Ut]=h.useState(""),[Yt,Xn]=h.useState(!1),[it,gr]=h.useState([]),[Fs,Bi]=h.useState(!1),[zs,ae]=h.useState(""),[ve,Te]=h.useState(""),[bt,Rt]=h.useState(""),[Qt,pn]=h.useState(!1),[$n,ks]=h.useState(""),[vs,q]=h.useState(""),[we,$e]=h.useState(!1),[Ae,Ze]=h.useState("nodes"),[wn,Lt]=h.useState(""),[Sn,rr]=h.useState(0),[yr,Zt]=h.useState(""),Yv=h.useRef(""),[gt,Ss]=h.useState(null),Gv=h.useRef(null),[$$,gl]=h.useState(""),[yl,Jv]=h.useState([]),[Xv,L$]=h.useState(""),[Se,O$]=h.useState(!a.adminOwnerId),[Mf,D$]=h.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[Tt,$f]=h.useState(null),[F$,Eg]=h.useState(!1),[Ig,Qv]=h.useState(!1),[Zv,vo]=h.useState(""),[ou,eS]=h.useState(""),[tS,nS]=h.useState(""),[Bs,z$]=h.useState(null),[Pg,rS]=h.useState("viewer"),[au,sS]=h.useState(!1),[jn,wl]=h.useState(null),[B$,ya]=h.useState(!1),[Rg,xl]=h.useState({}),[Lf,iS]=h.useState(!1),[oS,lu]=h.useState(""),[Tg,W$]=h.useState(""),[H$,bl]=h.useState(()=>new Set),[Mg,$g]=h.useState(""),[cu,Lg]=h.useState({nodeId:"",query:""}),[aS,lS]=h.useState(!1),Og=h.useRef(null),cS=h.useRef(null),uS=h.useRef(""),[Dg,dS]=h.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[V$,fS]=h.useState(!1),[wa,K$]=h.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Wi,q$]=h.useState(""),[Ws,U$]=h.useState([]),[pS,hS]=h.useState(!1),[Hs,uu]=h.useState([]),[kl,Y$]=h.useState([]),[mS,G$]=h.useState(!1),[gS,yS]=h.useState([]),[wS,xS]=h.useState([]),[sr,J$]=h.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,Of]=h.useState(null),[X$,bS]=h.useState(!1),[Q$,vl]=h.useState(""),[Fg,kS]=h.useState(!1),[zg,Df]=h.useState(""),[js,Ff]=h.useState(null),[Bg,vS]=h.useState(!1),[du,fu]=h.useState(null),SS=h.useCallback(w=>{Bn.current&&window.clearTimeout(Bn.current),Jn(w),Bn.current=window.setTimeout(()=>{Jn(""),Bn.current=null},3800)},[]),Kr=h.useCallback(w=>{const j=Array.isArray(w)||w instanceof Set?w:[w];for(const _ of j){const I=String(_||"").trim();I&&($.current.add(I),H.current.add(I))}$.current.size!==0&&(A.current==null&&(A.current=window.requestAnimationFrame(()=>{A.current=null;const _=Array.from($.current);$.current.clear(),_.forEach(I=>o(I))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const _=Array.from(H.current);H.current.clear(),_.forEach(I=>o(I))},80))},[o]);h.useEffect(()=>()=>{A.current!=null&&window.cancelAnimationFrame(A.current),Q.current!=null&&window.clearTimeout(Q.current),$.current.clear(),H.current.clear()},[]);const jS=h.useCallback((w,j)=>{const _=String(w||"").trim(),I=Am(j);!_||!I||(g(T=>T.map(U=>{var le;if(U.id!==_)return U;const X=Am((le=U.data)==null?void 0:le.displaySize),J=X&&X.width===I.width&&X.height===I.height,G=Math.round(Number(U.width||0))===I.width&&Math.round(Number(U.height||0))===I.height;return J&&G?U:{...U,width:I.width,height:I.height,data:{...U.data,nodeSize:I,displaySize:I}}})),Kr(_))},[Kr,g]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Dg)))}catch{}},[Dg]);const Wg=h.useCallback(w=>{const j=Og.current;if(!j)return null;const _=j.getBoundingClientRect(),I=16,T=150,U=230,X=_.top+I,J=_.bottom-I,G=Math.max(T,J-X-U);return Math.min(Math.max(w-X,T),G)},[]),Z$=h.useCallback(w=>{w.preventDefault(),w.stopPropagation();const j=Og.current;if(!j)return;let _=Wg(w.clientY);if(!Number.isFinite(_))return;fS(!0),dS(_);const I=U=>{U.preventDefault();const X=Wg(U.clientY);Number.isFinite(X)&&(_=X,j.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},T=()=>{dS(_),fS(!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)},[Wg]);h.useEffect(()=>()=>{Bn.current&&window.clearTimeout(Bn.current),Ft.current&&window.clearTimeout(Ft.current)},[]);const[eL,NS]=h.useState(()=>new Set),[zf,Hg]=h.useState(!1),Vg=h.useRef(null),CS=h.useRef(null),_S=h.useRef(null),[tL,nL]=h.useState({}),[xa,Kg]=h.useState(""),[os,AS]=h.useState(!1),[ba,Sl]=h.useState([]),[Vs,Hn]=h.useState([]),[qr,Ns]=h.useState("workspace"),[pu,jl]=h.useState(!1),ES=h.useRef(null),qg=h.useRef(null),[hu,Nl]=h.useState(null),[rL,Ug]=h.useState(!0),[IS,PS]=h.useState(""),[ka,So]=h.useState({}),[Lr,Yg]=h.useState(null),[RS,Gg]=h.useState(!1),Cl=h.useMemo(()=>RS?mG(Lr):"",[RS,Lr]),[mu,Bf]=h.useState(!0);h.useEffect(()=>{Cl&&Bf(gG(Cl))},[Cl]),h.useEffect(()=>{if(Cl)try{window.localStorage.setItem(Cl,mu?"true":"false")}catch{}},[mu,Cl]);const[Jg,Wf]=h.useState(!1),[Xg,TS]=h.useState(!1),[Qg,MS]=h.useState("pan"),[$S,sL]=h.useState({}),gu=h.useRef({}),[LS,va]=h.useState({}),yu=h.useRef(new Map),wu=h.useRef(new Set),[OS,_l]=h.useState(()=>new Set),[Zg,Al]=h.useState({}),[DS,FS]=h.useState(""),[Aue,ge]=h.useState(""),[zS,Ks]=h.useState("loading"),[BS,qs]=h.useState("正在载入 Project"),Hi=h.useMemo(()=>hG(a),[a]),[WS,HS]=h.useState(""),xu=a.flowSource||"user",VS=h.useMemo(()=>new Set(Object.values($S||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[$S]),Vi=h.useCallback(w=>{const j=gu.current||{},_=typeof w=="function"?w(j):w,I=_&&typeof _=="object"&&!Array.isArray(_)?_:{};return gu.current=I,sL(I),I},[]),KS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(Tt!=null&&Tt.role?Tt.role==="owner":xu==="user"||xu==="workspace")),bu=!!(!a.adminOwnerId&&xu==="workspace"&&(Tt!=null&&Tt.role)&&Tt.role!=="owner"),qS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[zS]||"同步状态",hi=h.useCallback(()=>{!ue.current||!Se||(ye.current=!1,He.current+=1,ct.current=!0,Ks("dirty"),qs("本地修改等待同步"))},[Se]);h.useEffect(()=>{a.flowId&&UF(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),h.useEffect(()=>{const w=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),h.useEffect(()=>{Sl([]),Hn([]),Ns("workspace"),Ug(!0)},[a]);const Nn=h.useCallback(async()=>{const w=Fr(a),j=await fetch(`/api/workspace/files?${w.toString()}`),_=await j.json();if(!j.ok)throw new Error(_.error||"读取 workspace 失败");const I=_.files||[];Jv(I),bl(new Set(AM(I))),L$(_.root||"")},[a]),Hf=h.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)}},[]),US=h.useCallback(async(w,j,_)=>{var G,le,he;if(!ue.current)return;if(!Se)throw ge("Readonly workspace"),Ks("readonly"),qs("只读 Project"),new Error("Readonly workspace");Ks("saving"),qs("正在同步修改");const I=Kl(w,j,ee.current);I.ui={...I.ui||{},displayPage:ZC(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:_t.current})}),U=await T.json().catch(()=>({}));if(!T.ok){if(T.status===409||T.status===428){const je=Array.isArray(U.conflictItems)?U.conflictItems:[];wl({currentRevision:String(U.currentRevision||""),message:U.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(U.conflictPaths)?U.conflictPaths:[],conflictItems:je,mergeGraph:U.mergeGraph||null,currentGraph:U.currentGraph||null}),xl(Object.fromEntries(je.map((We,Le)=>[String(Le),{mode:"local",manual:Vu(We)}]))),lu(""),ya(je.length>0),Ks("conflict"),qs(U.error||"存在需要处理的字段冲突");const Ve=Array.isArray(U.conflictPaths)?U.conflictPaths:[],Fe=Ve.length?`${U.error||"Workspace 已被其他成员更新"}:${Ve.join("、")}`:U.error||"Workspace 已被其他成员更新",Ke=new Error(Fe);throw Ke.code="WORKSPACE_REVISION_CONFLICT",Ke.currentRevision=U.currentRevision||"",Ke}const fe=new Error(U.error||"保存 workspace graph 失败");throw Ks("error"),qs(fe.message),fe}const X=He.current!==_,J=VY({savedGraph:U.graph,sentGraph:I,savedRevision:U.revision,currentRevision:pe.current});if(pe.current=J.revision,Me.current=J.graph,!X){if(ee.current=((G=U.graph)==null?void 0:G.instances)||I.instances,se(ee.current),U.merged&&U.graph){const fe=Hu(U.graph,at),je=_h((he=(le=U.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 va(Gp(U.workspaceSchedules||[])),wl(null),ya(!1),Ks(X?"dirty":"synced"),qs(X?"本地仍有修改等待同步":"所有修改已同步"),ge(X?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[a,at,x,g,Se]),en=h.useCallback((w=b,j=k)=>{const _=Ce.current,I={nextNodes:w,nextEdges:j,saveEditVersion:He.current,waiters:[]},T=new Promise((J,G)=>{I.waiters.push({resolve:J,reject:G})});if(_.running)return _.pending=FC(_.pending,I),T;_.running=!0;const U=async()=>{let J=I;for(;J;){_.pending&&(J=FC(J,_.pending),_.pending=null);try{const G=await US(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:le})=>le(G))}catch(G){(G==null?void 0:G.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Ks("error"),qs(String(G.message||G))),J.waiters.forEach(({reject:le})=>le(G)),(G==null?void 0:G.code)==="WORKSPACE_REVISION_CONFLICT"&&_.pending&&(_.pending.waiters.forEach(({reject:le})=>le(G)),_.pending=null)}J=_.pending,_.pending=null}_.running=!1},X=Ne.current.catch(()=>{}).then(U);return Ne.current=X,T},[k,b,US]),iL=h.useCallback(w=>{var _;const j=(_=w==null?void 0:w.extra)!=null&&_.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]),oL=h.useMemo(()=>({instances:re}),[re]),aL=xY({nodes:b,edges:k,extra:oL,enabled:ue.current,onRestore:iL}),{resetHistory:ku,undo:YS,redo:GS}=aL,Cs=h.useCallback(async(w={})=>{var Oe,Ot;const j=(w==null?void 0:w.background)===!0,_=yt.current+1;yt.current=_;const I=He.current,T=pe.current;j||(ue.current=!1);const U=XY({background:j}),X=Fr(a);let J=null,G;if(!U.nodes&&!U.files)G=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||"读取节点定义失败");G=At}const le=await G.json();if(!G.ok)throw new Error(le.error||"读取 workspace graph 失败");const he=HY({background:j,requestId:_,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=>!eG.has(De.id)),oG,iG,rG,sG,tG,nG];j||(ie.current=fe,Fn(fe));const je=le.graph||JSON.parse(localStorage.getItem(ZY)||"null")||{},Ve=Hu(je,fe),Fe=_h((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=Ab(De)||Ab((Ot=je==null?void 0:je.ui)==null?void 0:Ot.viewport)}const Le=j?FY(Me.current,je):null;if(j&&(Le!=null&&Le.safe)){const De=Le.nodesChanged?zY(C.current,Ve.nodes,Le.changedNodeIds):C.current,ft=Le.edgesChanged?BY(S.current,Ve.edges):S.current,At=Le.displayPageChanged||!oo(z.current,Fe),Dl=Le.nodesChanged||Le.edgesChanged||At;if(Dl&&(ye.current=!0),Le.nodesChanged){const mi=WY(ee.current,Ve.instances,Le.changedNodeIds);ee.current=mi,C.current=De,se(mi),g(De)}if(Le.edgesChanged&&(S.current=ft,x(ft)),At&&(z.current=Fe,R(Fe)),Dl&&ku(De,ft,{instances:Le.nodesChanged?ee.current:Ve.instances}),Le.nodesChanged||At){const mi=new Set(Fe.nodeIds);V(Na=>{const Ca=Na.filter(op=>mi.has(op));return Ca.length===Na.length?Na:Ca})}}else ee.current=Ve.instances,C.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([]),ku(Ve.nodes,Ve.edges,{instances:Ve.instances});const Wt=Gp(le.workspaceSchedules||[]);va(De=>oo(De,Wt)?De:Wt),pe.current=String(le.revision||""),Me.current=je,ct.current=!1;const st=le.collaboration||null;$f(De=>oo(De,st)?De:st),D$(le.adminReview||null),wl(null),Ke&&(O(We),D.current=We,L.current=!0);const Ye=le.writable!==!1;return O$(Ye),ge(Ye?"Workspace ready":"Readonly workspace"),Ks(Ye?"synced":"readonly"),qs(Ye?"所有修改已同步":le.adminReview?`管理员只读查看:${le.adminReview.ownerUsername||le.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),ue.current=!0,{skipped:!1}},[a,t.language,Nn,ku,x,g,u]),El=h.useCallback((w={})=>{if(!ue.current)return;const j=String(w.revision||""),_=w.type==="graph.committed",I=!!(Re.current||ot.current||kt.current);if(QY({eventType:w.type,revision:j,currentRevision:pe.current,targetRevision:$t.current,refreshPending:I}))return;if(_&&j&&($t.current=j),ct.current){kt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(kt.current=!0,Re.current||ot.current)return;const T=async()=>{if(Re.current=null,_e()){kt.current=!0;return}if(ct.current){kt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}kt.current=!1,ot.current=!0;try{await Cs({background:!0}),$t.current=pe.current}catch(U){$t.current="",ge(String(U.message||U))}finally{ot.current=!1,kt.current&&!ct.current&&(Re.current=window.setTimeout(T,40))}};Re.current=window.setTimeout(T,40)},[Cs,_e]),vu=h.useCallback(async(w=sr)=>{const j=String(w||"").trim();bS(!0),vl("");try{const _=Fr(a);_.set("tapdId",j),_.set("runtimeOnly","1");const I=await fetch(`/api/prd-workflow/snapshot?${_.toString()}`),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"读取 PRD Workflow 失败");Of(T.snapshot||null),Df(""),Ff(null),fu(null);try{const U=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;j?window.localStorage.setItem(U,j):window.localStorage.removeItem(U)}catch{}}catch(_){vl(String(_.message||_))}finally{bS(!1)}},[a,sr]),Il=h.useCallback(async(w=null,j={})=>{const _=w&&typeof w=="object"?w:sn==null?void 0:sn.nextAction,I=Sm(_);if(!I||Fg)return;const T=(j==null?void 0:j.confirm)===!0,U=String((j==null?void 0:j.expectedRevision)||(sn==null?void 0:sn.revision)||"");kS(!0),vl(""),T||(Df(""),Ff(null),fu(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:cl(_),title:ao(_,0),...OG(_),dryRun:!T,confirm:T,issueKey:_.issueKey||_.issue_key||"",expectedRevision:U,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw J.snapshot&&Of(J.snapshot),J.conflict&&fu({...J.conflict,action:_}),new Error(J.error||"执行 PRD Workflow action 失败");Df(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),Of(J.snapshot||sn),fu(null),Ff(T?null:{action:_,output:J.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(X){vl(String(X.message||X))}finally{kS(!1)}},[a,Fg,sn,sr]),lL=h.useCallback((w=null)=>Il(w,{confirm:!1}),[Il]),cL=h.useCallback(()=>{const w=(js==null?void 0:js.action)||(sn==null?void 0:sn.nextAction);return Il(w,{confirm:!0,expectedRevision:(js==null?void 0:js.expectedRevision)||""})},[Il,js,sn]),uL=h.useCallback(()=>{const w=(du==null?void 0:du.action)||(sn==null?void 0:sn.nextAction);return fu(null),Il(w,{confirm:!1})},[Il,du,sn]),dL=h.useCallback(async()=>{var U,X;const w=String(zg||(sn==null?void 0:sn.rawOutput)||"").trim();if(!w||Bg)return;const j=(js==null?void 0:js.action)||(sn==null?void 0:sn.nextAction)||{},_=`Review: ${ao(j,0)||(sn==null?void 0:sn.pointer)||sr||"PRD Workflow"}`,I=/^[\[{]/.test(w),T=w.startsWith("#")?w:`# ${_}
247
+
248
+ ${I?`\`\`\`json
249
+ ${w}
250
+ \`\`\``:w}`;vS(!0),vl("");try{const J=await fetch("/api/prd-workflow/review-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:sr,title:_,markdown:T,action:Sm(j),stage:cl(j),issueKey:j.issueKey||j.issue_key||"",artifactLabel:"临时 Review"})}),G=await J.json().catch(()=>({}));if(!J.ok||G.ok===!1)throw new Error(G.error||"生成 Review 链接失败");Of(G.snapshot||sn);const le=((U=G.review)==null?void 0:U.shortUrl)||((X=G.review)==null?void 0:X.url)||"";le&&Df(he=>`${he||w}
251
+
252
+ Review link: ${le}`)}catch(J){vl(String(J.message||J))}finally{vS(!1)}},[a,zg,js,Bg,sn,sr]),fL=h.useCallback(async(w,j)=>{const _={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(_)}),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||_.packageId}`),T},[a,Cs]),Sa=h.useCallback((w=Vs)=>{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")},[Vs]),pL=h.useCallback(w=>{const j=String(w||"").trim();!j||j==="workspace"||Hn(_=>{const I=(Array.isArray(_)?_:[]).filter(T=>T.id!==j);return Ns(T=>T===j?Sa(I):T),I})},[Sa]);h.useCallback((w="")=>{jl(!0),Nl(null),Ss(null),Ns(w||Sa())},[Sa]);const JS=h.useCallback((w={})=>{Nl({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),jl(!1),Ss(null),Zt("")},[]),ey=h.useCallback(async(w="")=>{const j=String(w||"").trim();if(!(!j||!Se)){FS(j),ge(`Optimizing run: ${j}`);try{await en(C.current,S.current);const _=Kl(C.current,S.current,ee.current),I=f_(C.current,ee.current,j,Wi),T=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:j,graph:_,model:I})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"优化失败");const X=U.graph||_,J=Hu(X,at);ee.current=J.instances,se(J.instances),g(J.nodes),x(J.edges),va(Gp(U.workspaceSchedules||[])),ku(J.nodes,J.edges,{instances:J.instances});const G=Array.isArray(U.optimized)?U.optimized.length:0;ge(G>0?`已生成 ${G} 个 implementation`:"没有需要优化的节点")}catch(_){ge(String(_.message||_))}finally{FS("")}}},[Wi,S,a,C,at,ku,en,x,g,Se]),XS=h.useCallback(async(w="")=>{const j=String(w||"").trim(),_=gu.current||{},I=Object.entries(_).find(([G,le])=>G===j||String((le==null?void 0:le.runNodeId)||"")===j)||Object.entries(_)[0]||null,T=(I==null?void 0:I[0])||"",U=(I==null?void 0:I[1])||null,X=String((U==null?void 0:U.runNodeId)||j||"").trim();if((U==null?void 0:U.status)==="stopping")return;const J=new Set([X,...Array.isArray(U==null?void 0:U.plannedNodeIds)?U.plannedNodeIds:[]].map(G=>String(G||"").trim()).filter(Boolean));T&&Vi(G=>{const le={...G};return le[T]&&(le[T]={...le[T],status:"stopping"}),le}),ge(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Hn(G=>G.map(le=>(T?le.id===T:!X||le.runNodeId===X)&&le.status==="running"?{...le,status:"stopping"}:le));try{const G=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:T,runNodeId:X})}),le=await G.json().catch(()=>({}));if(!G.ok||(le==null?void 0:le.stopped)!==!0)throw new Error(le.error||"Workspace run stop failed");const he=T?yu.current.get(T):null;he&&(he.abort(),yu.current.delete(T)),T&&Vi(fe=>{const je={...fe};return delete je[T],je}),_l(fe=>{const je=new Set(fe);for(const Ve of J)je.delete(Ve);return je}),Al(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(G){T&&Vi(he=>{const fe={...he};return fe[T]&&(fe[T]={...fe[T],status:"running"}),fe});const le=String((G==null?void 0:G.message)||G||"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,Vi]),Vf=h.useCallback(async()=>{if(a.flowId)try{const w=Fr(a),j=await fetch(`/api/workspace/run/status?${w.toString()}`),_=await j.json().catch(()=>({}));if(!j.ok||!_.running)return;const I=Array.isArray(_.runs)&&_.runs.length?_.runs:[{runId:`run-restored-${_.startedAt||Date.now()}`,runNodeId:_.runNodeId||"",startedAt:_.startedAt||Date.now(),plannedNodeIds:[]}],T={},U=[];for(const X of I){const J=String((X==null?void 0:X.runNodeId)||"").trim(),G=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${J}`).trim();if(!G)continue;const le=String((X==null?void 0:X.label)||"").trim()||bw(C.current,ee.current,J,"Workspace Run");T[G]={id:G,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&&U.push(J)}if(!Object.keys(T).length)return;Vi(X=>({...X,...T})),_l(X=>{const J=new Set(X);for(const G of U)J.add(G);return J}),Al(X=>{const J={...X};for(const G of U)J[G]={status:"running"};return J}),ge(U.length?`Workspace run still running: ${U.join(", ")}`:"Workspace run still running"),Hn(X=>{const J=[...X];for(const[G,le]of Object.entries(T)){if(J.some(je=>je.id===G||["running","stopping"].includes(je.status)&&je.runNodeId===le.runNodeId))continue;const he=String(le.runNodeId||""),fe=String(le.label||"").trim()||bw(C.current,ee.current,he,"Workspace Run");J.push({id:G,label:kw(fe,he,"Workspace Run"),alias:fe,runNodeId:he,status:le.status,startedAt:le.startedAt||Date.now(),steps:he?[{id:he,label:kw(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,C,Vi]),QS=h.useCallback(async w=>{if(!Se){ge("Readonly workspace");return}if(!w)return;if(Object.values(gu.current||{}).find(st=>String((st==null?void 0:st.runNodeId)||"")===String(w||""))){ge(`Workspace run already running: ${w}`);return}let _=C.current,I=S.current,T=ee.current;const U=Gv.current;if(U!=null&&U.id){const st=_.find(Oe=>Oe.id===U.id),Ye=h_({nodes:_,edges:I,instances:T,selectedNode:st,draft:U,allowRename:!1});if(Ye!=null&&Ye.error){gl(Ye.error),ge(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(_=Ye.nodes,I=Ye.edges,T=Ye.instances,ee.current=T,C.current=_,S.current=I,se(T),g(_),x(I),Kr(Ye.nextId||U.id))}const X=Kl(_,I,T),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,G=bw(_,T,w,"Workspace Run"),le=kw(G,w,"Workspace Run");let he=[w];try{const st=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:X,runNodeId:w})}),Ye=await st.json().catch(()=>({}));if(!st.ok||(Ye==null?void 0:Ye.ok)===!1)throw new Error(Ye.error||"Workspace run plan failed");he=Array.isArray(Ye.plannedNodeIds)&&Ye.plannedNodeIds.length?Ye.plannedNodeIds.map(Ot=>String(Ot||"").trim()).filter(Boolean):[w],he=Array.from(new Set([w,...he].filter(Boolean)));const Oe=Ye.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(st){ge(String(st.message||st));return}const fe=new Set(he),je=Object.values(gu.current||{}).find(st=>(Array.isArray(st==null?void 0:st.plannedNodeIds)?st.plannedNodeIds:[]).some(Ye=>fe.has(String(Ye||"").trim())));if(je){const st=(Array.isArray(je.plannedNodeIds)?je.plannedNodeIds:[]).map(Ye=>String(Ye||"").trim()).filter(Ye=>Ye&&fe.has(Ye));ge(`Run ${w} conflicts with running ${je.runNodeId||"workspace run"}${st.length?`: ${st.join(", ")}`:""}`);return}const Ve=new AbortController;yu.current.set(J,Ve),wu.current.delete(J),Vi(st=>({...st,[J]:{id:J,runNodeId:w,label:G,plannedNodeIds:he,startedAt:Date.now()}})),_l(st=>new Set([...st,w])),Al(st=>({...st,[w]:{status:"running"}})),ge(`Running ${le}...`),Ns(J),Hn(st=>[...st.slice(-7),{id:J,label:le,alias:G,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=()=>wu.current.has(J),Le=st=>{const Ye=new Set((st||[]).map(Oe=>String(Oe||"").trim()).filter(Boolean));Ye.size||Ye.add(String(w||"")),_l(Oe=>{const Ot=new Set(Oe);for(const De of Ye)Ot.delete(De);return Ot})},Wt=(st,Ye)=>{const Oe=new Set((st||[]).map(Ot=>String(Ot||"").trim()).filter(Boolean));Oe.size||Oe.add(String(w||"")),Al(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:Ye});return De})};try{await en(_,I);const st=f_(_,T,w,Wi),Ye=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:G,runSessionId:J,expectedRevision:pe.current,clientId:_t.current,model:st,selectedSkills:Hs,stream:!0})});if(!Ye.ok){const xe=await Ye.json().catch(()=>({}));throw new Error(xe.error||"Workspace run failed")}if(!Ye.body)throw new Error("Workspace run stream unavailable");const Oe=Ye.body.getReader(),Ot=new TextDecoder;let De="",ft=[],At=[];const Dl=(xe,nt)=>{var lt,Ct;const Ge=b.find(Bt=>Bt.id===xe),ht=String(((lt=Ge==null?void 0:Ge.data)==null?void 0:lt.label)||xe||"").trim(),be=String(nt||((Ct=Ge==null?void 0:Ge.data)==null?void 0:Ct.definitionId)||"").trim();return be&&be!==ht?`${ht} (${be})`:ht},mi=(xe,nt,Ge)=>{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:Dl(ht,nt),status:Ge};mt>=0?Bt[mt]={...Bt[mt],...St}:Bt.push(St);const on=Bt.map((an,_o)=>{const Ui=an.status==="done"?"[done]":an.status==="failed"?"[failed]":"[running]";return`${_o+1}. ${Ui} ${an.label}`}).join(`
253
+ `),Gt=Array.isArray(lt.messages)?lt.messages:[],nn=Gt.findIndex(an=>an.kind==="run-summary"),hn={role:"assistant",kind:"run-summary",text:on||"准备运行...",at:Date.now()},Ht=[...Gt];return nn>=0?Ht[nn]=hn:Ht.unshift(hn),{...lt,steps:Bt,messages:Ht.slice(-160)}}))},Na=(xe,nt)=>{var K0,q0,U0,Y0,G0,J0,X0,Q0,Z0,ej;const Ge=String(xe||"").trim(),ht=String(nt||"").trim();if(!Ge||!ht)return;const be=(K0=ee.current)==null?void 0:K0[Ge];if(!li(be==null?void 0:be.definitionId))return;const lt=la(be==null?void 0:be.input,"displayType","markdown"),Ct=TM(lt),Bt=MM(Ge),mt=at.find(Or=>Or.id===Ct),St=l_(mt==null?void 0:mt.inputs,Ct,ht),on=l_(mt==null?void 0:mt.outputs,Ct,ht),Gt=String((be==null?void 0:be.label)||Ge||"一键任务").trim(),nn={...ee.current||{},[Ge]:{...be||{},output:u_(be==null?void 0:be.output)},[Bt]:{...((q0=ee.current)==null?void 0:q0[Bt])||{},definitionId:Ct,label:Gt,role:"normal",body:ht,input:St,output:on,sourceContextRunNodeId:Ge,displayReloadKey:String(Date.now())}};ee.current=nn,se(nn);const hn=C.current||[],Ht=hn.find(Or=>Or.id===Ge),an=hn.find(Or=>Or.id===Bt),_o=Number(((U0=Ht==null?void 0:Ht.measured)==null?void 0:U0.width)||(Ht==null?void 0:Ht.width)||((G0=(Y0=Ht==null?void 0:Ht.data)==null?void 0:Y0.nodeSize)==null?void 0:G0.width)||520),Ui=(an==null?void 0:an.position)||{x:Number(((J0=Ht==null?void 0:Ht.position)==null?void 0:J0.x)||0)+_o+120,y:Number(((X0=Ht==null?void 0:Ht.position)==null?void 0:X0.y)||0)},or=((Q0=an==null?void 0:an.data)==null?void 0:Q0.displaySize)||((Z0=an==null?void 0:an.data)==null?void 0:Z0.nodeSize)||{width:vb,height:Sb},gi=xb({id:Bt,type:Nc,position:Ui,width:Number(or.width)||vb,height:Number(or.height)||Sb,data:{label:Gt,definitionId:Ct,role:"normal",body:ht,inputs:St,outputs:on,sourceContextRunNodeId:Ge,displayReloadKey:nn[Bt].displayReloadKey,nodeSize:or,displaySize:or}},nn,at),Ao=hn.map(Or=>{if(Or.id===Ge){const{width:Eue,height:Iue,measured:Pue,...h2}=Or,{nodeSize:Rue,displaySize:Tue,...dp}=Or.data||{};return{...h2,data:{...dp,outputs:u_(dp==null?void 0:dp.outputs),contextRunResultNonce:Date.now()}}}return Or.id===Bt?{...gi,selected:Or.selected}:Or});an||Ao.push(gi),C.current=Ao,g(Ao);const Eo=S.current||[],up=$M(Ct),my=c_((be==null?void 0:be.output)||((ej=Ht==null?void 0:Ht.data)==null?void 0:ej.outputs),"output",["content","result"],["text"]),f2=c_(St,"input",[up,"content"],["text"]),p2={id:`we-${Ge}-${Bt}`,source:Ge,target:Bt,sourceHandle:my,targetHandle:f2,markerEnd:{type:Ci.ArrowClosed}},V0=[...Eo.filter(Or=>!(Or.source===Ge&&Or.target===Bt)),p2];S.current=V0,x(V0),window.requestAnimationFrame(()=>{o(Ge),o(Bt)})},Ca=(xe,nt=null)=>{const Ge=xe!=null&&xe.instances&&typeof xe.instances=="object"?xe.instances:{},ht=nt instanceof Set?nt:null;for(const[be,lt]of Object.entries(Ge)){if(ht&&!ht.has(be)||!li(lt==null?void 0:lt.definitionId))continue;const Ct=kg({outputs:lt.output});Ct&&Na(be,Ct)}},op=xe=>{const nt=String(xe||"").trim();if(!nt)return;const Ge=Fe;Fe=nt,_l(ht=>{const be=new Set(ht);return Ge&&Ge!==nt&&Ge!==w&&be.delete(Ge),w&&be.add(w),be.add(nt),be}),Al(ht=>{var be;return{...ht,...Ge&&Ge!==nt&&Ge!==w&&((be=ht[Ge])==null?void 0:be.status)==="running"?{[Ge]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},B0=xe=>{const nt=String(xe||"").trim();nt&&(_l(Ge=>{const ht=new Set(Ge);return ht.delete(nt),ht}),Al(Ge=>({...Ge,[nt]:{status:"success"}})))},W0=(xe,nt)=>{const Ge=String(nt||"");if(!Ge.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 Ct=Array.isArray(lt.messages)?lt.messages:[];if(ht==="result"){const St=[...Ct].reverse().find(on=>on.kind==="assistant");if(String((St==null?void 0:St.text)||"").trim()===Ge.trim())return lt}if(ht==="assistant"){const St=Ct.findIndex(on=>on.kind==="result"&&String(on.text||"").trim()===Ge.trim());St>=0&&(Ct=Ct.filter((on,Gt)=>Gt!==St))}const Bt=[...Ct],mt=Bt[Bt.length-1];return mt&&mt.kind===ht&&!mt.error?Bt[Bt.length-1]={...mt,text:`${mt.text||""}${mt.text?`
254
+ `:""}${Ge}`}:Bt.push({role:"assistant",kind:ht,text:Ge,...ht==="error"?{error:!0}:{},at:Date.now()}),{...lt,messages:Bt.slice(-160)}}))},ap=xe=>{const nt=String(xe||"");nt.trim()&&Hn(Ge=>Ge.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"),Ct=[...be];if(lt>=0){const mt=String(((Bt=Ct[lt])==null?void 0:Bt.text)||"");Ct[lt]={...Ct[lt],text:`${mt}${mt&&!mt.endsWith(`
255
+ `),""}${nt}`,at:Date.now()}}else{const mt=Ct.findIndex(St=>St.kind==="activity");Ct.splice(mt>=0?mt+1:Ct.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...ht,messages:Ct.slice(-160)}}))},Co=(xe,nt=null)=>{const Ge=xG(xe);Ge&&Hn(ht=>ht.map(be=>{if(be.id!==J)return be;const lt=Number(nt==null?void 0:nt.ts)||Date.now(),Ct=Number(be.startedAt)||lt,Bt=Number(be.lastActivityAt)||Ct,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-Ct),on=Array.isArray(be.activities)?be.activities:[],Gt=on[on.length-1],hn=(typeof Gt=="string"?Gt:String((Gt==null?void 0:Gt.text)||""))===Ge?on:[...on,{text:Ge,kind:kG(Ge),stepMs:mt,totalMs:St,at:lt}].slice(-30),Ht=Array.isArray(be.timingEntries)?be.timingEntries:[],an=Array.isArray(be.messages)?be.messages:[],_o=an.findIndex(gi=>gi.kind==="activity"),Ui={role:"assistant",kind:"activity",text:KC(hn,Ht,Ct,lt),at:Date.now()},or=[...an];if(_o>=0)or[_o]=Ui;else{const gi=or.findIndex(Ao=>Ao.kind==="run-summary");or.splice(gi>=0?gi+1:0,0,Ui)}return{...be,activities:hn,lastActivityAt:lt,messages:or.slice(-160)}}))},H0=xe=>{const nt=String((xe==null?void 0:xe.source)||"runner"),Ge=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}${Ge?`:${Ge}`:""}] ${ht}
256
+ ${be}`,Ct=ZG(xe);Hn(Bt=>Bt.map(mt=>{if(mt.id!==J)return mt;const on=[...Array.isArray(mt.rawTrace)?mt.rawTrace:[],lt].slice(-80),Gt=Array.isArray(mt.timingEntries)?mt.timingEntries:[],nn=Ct?[...Gt,Ct].slice(-80):Gt,hn=Array.isArray(mt.activities)?mt.activities:[],Ht=Number(mt.startedAt)||Number(xe==null?void 0:xe.ts)||Date.now(),an=Number(Ct==null?void 0:Ct.at)||Number(xe==null?void 0:xe.ts)||Date.now(),_o=Array.isArray(mt.messages)?mt.messages:[],Ui={role:"assistant",kind:"raw",text:on.join(`
257
+
258
+ ---
259
+
260
+ `),at:Date.now()},or=[..._o],gi=or.findIndex(Eo=>Eo.kind==="activity");if(Ct){const Eo={role:"assistant",kind:"activity",text:KC(hn,nn,Ht,an),at:Date.now()};if(gi>=0)or[gi]=Eo;else{const up=or.findIndex(my=>my.kind==="run-summary");or.splice(up>=0?up+1:0,0,Eo)}}const Ao=or.findIndex(Eo=>Eo.kind==="raw");return Ao>=0?or[Ao]=Ui:or.push(Ui),{...mt,rawTrace:on,timingEntries:nn,messages:or.slice(-160)}}))},d2=xe=>{Hn(nt=>nt.map(Ge=>Ge.id===J?{...Ge,status:xe,endedAt:Date.now()}:Ge))},lp=xe=>{const nt=new Set,Ge=String((xe==null?void 0:xe.nodeId)||"").trim();Ge&&nt.add(Ge);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},cp=(xe,nt=null)=>{const Ge=Hu(xe||X,at),ht=new Map(Ge.nodes.map(mt=>[mt.id,mt])),be=Ge.instances||{},lt=nt instanceof Set?nt:null,Ct=(mt,St)=>{const on={...mt||St};Array.isArray(St==null?void 0:St.output)&&(on.output=St.output);for(const Gt of["scriptRef","implementationRef","implementationMode"])(St==null?void 0:St[Gt])!=null&&String(St[Gt]).trim()!==""&&(on[Gt]=St[Gt]);return on},Bt=(mt,St)=>{const on={...mt||{}};Array.isArray(St==null?void 0:St.outputs)&&(on.outputs=St.outputs);for(const Gt of["scriptRef","implementationRef","implementationMode"])(St==null?void 0:St[Gt])!=null&&String(St[Gt]).trim()!==""&&(on[Gt]=St[Gt]);return on};g(mt=>{const St=new Set(mt.map(nn=>nn.id)),Gt={...Kl(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=Gt[nn];ul((hn==null?void 0:hn.definitionId)||(Ht==null?void 0:Ht.definitionId))?Gt[nn]=hn:Array.isArray(hn==null?void 0:hn.output)&&(Gt[nn]=Ct(Ht,hn))}return ee.current=Gt,se(Gt),mt.map(nn=>{var Ht,an;if(lt&&!lt.has(nn.id))return nn;const hn=ht.get(nn.id);return hn?ul(((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 Ge=De.split(`
261
+ `);De=Ge.pop()||"";for(const ht of Ge){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"){wu.current.add(J),ft=Array.isArray(be.order)?be.order:ft,Co("运行停止",be);continue}if(be.type==="node-start"&&(ge(`Running ${be.nodeId}...`),op(be.nodeId),mi(be.nodeId,be.definitionId,"running")),be.type==="node-done"){const lt=Ke.get(String(be.nodeId||"").trim());lt&&Na(be.nodeId,lt),B0(be.nodeId),mi(be.nodeId,be.definitionId,"done")}if(be.type==="status"&&Co(be.line||be.message||"",be),be.type==="paused"&&(At=Array.isArray(be.nodeIds)?be.nodeIds:[],Co("运行暂停",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"?ap(be.text||""):W0(be.kind,be.text||"")),be.type==="raw"){const lt=qC(be);lt&&ap(lt),H0(be)}if(be.type==="graph"&&be.graph){const lt=lp(be);cp(be.graph,lt),Ca(be.graph,lt)}if(be.type==="done"){if(be.revision&&(pe.current=String(be.revision)),be.graph){Me.current=be.graph;const lt=lp(be);cp(be.graph,lt),Ca(be.graph,lt)}ft=Array.isArray(be.order)?be.order:[],At=Array.isArray(be.pauseNodeIds)?be.pauseNodeIds:At,Co(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"&&(wu.current.add(J),Co("运行停止",xe)),xe.type==="node-start"&&(ge(`Running ${xe.nodeId}...`),op(xe.nodeId),mi(xe.nodeId,xe.definitionId,"running")),xe.type==="node-done"){const nt=Ke.get(String(xe.nodeId||"").trim());nt&&Na(xe.nodeId,nt),B0(xe.nodeId),mi(xe.nodeId,xe.definitionId,"done")}if(xe.type==="status"&&Co(xe.line||xe.message||"",xe),xe.type==="paused"&&(At=Array.isArray(xe.nodeIds)?xe.nodeIds:[],Co("运行暂停",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"?ap(xe.text||""):W0(xe.kind,xe.text||"")),xe.type==="raw"){const nt=qC(xe);nt&&ap(nt),H0(xe)}if(xe.type==="graph"&&xe.graph){const nt=lp(xe);cp(xe.graph,nt),Ca(xe.graph,nt)}if(xe.type==="done"){if(xe.revision&&(pe.current=String(xe.revision)),xe.graph){Me.current=xe.graph;const nt=lp(xe);cp(xe.graph,nt),Ca(xe.graph,nt)}ft=Array.isArray(xe.order)?xe.order:[],At=Array.isArray(xe.pauseNodeIds)?xe.pauseNodeIds:At,Co(At.length?"运行暂停":"运行完成",xe)}}We()&&(Le(he),Wt(he,"stopped"));const hy=We()?`Workspace run stopped: ${w}`:At.length?`Workspace run paused at ${At.join(", ")}`:`Workspace run done: ${ft.length?ft.join(" -> "):w}`;if(ge(hy),We()||Wt(he,At.length?"paused":"success"),d2(We()?"stopped":At.length?"paused":"done"),!We()){try{await en(C.current,S.current),ge(hy)}catch(xe){ge(`${hy},但保存结果失败:${String(xe.message||xe)}`)}await Nn()}}catch(st){if(We()||(st==null?void 0:st.name)==="AbortError"){Le(he),Wt(he,"stopped"),ge(`Workspace run stopped: ${w}`),Hn(Ye=>Ye.map(Oe=>Oe.id===J?{...Oe,status:"stopped",endedAt:Date.now()}:Oe));return}Le(he),Wt([w,Fe].filter(Boolean),"failed"),ge(String(st.message||st)),Hn(Ye=>Ye.map(Oe=>Oe.id===J?{...Oe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Oe.messages)?Oe.messages:[],{role:"assistant",error:!0,text:String(st.message||st),at:Date.now()}].slice(-160)}:Oe))}finally{yu.current.get(J)===Ve&&yu.current.delete(J),Vi(st=>{const Ye={...st};return delete Ye[J],Ye}),wu.current.delete(J),Le(he)}},[Wi,k,a,Nn,b,at,Kr,en,Hs,x,g,Vi,o,Se]),Kf=h.useCallback(async()=>{try{const j=await(await fetch("/api/skills")).json().catch(()=>({})),_=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):""})):[];U$(_),hS(!0)}catch{hS(!0)}},[]),qf=h.useCallback(async()=>{try{const j=await(await fetch("/api/mcps")).json().catch(()=>({})),_=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):[];yS(_)}catch{yS([])}},[]),Uf=h.useCallback(async()=>{try{const w=Fr(a),_=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),I=Array.isArray(_.workspaces)?_.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):[];xS(I)}catch{xS([])}},[a]),ZS=h.useCallback(async()=>{Xt.current=!1;try{const w=Fr(a),j=await fetch(`/api/workspace/conversations?${w.toString()}`),_=await j.json().catch(()=>({}));if(!j.ok)throw new Error(_.error||`HTTP ${j.status}`);const I=BC(_.conversations||{});Sl(I.composer.messages),Hn(I.composer.runSessions),Ns(I.composer.activeSessionId||"workspace"),So(I.nodeChats)}catch{Sl([]),Hn([]),Ns("workspace"),So({})}finally{Xt.current=!0}},[a]),e0=h.useCallback(async()=>{if(!Se||a.archived)return;const w=BC({composer:{activeSessionId:qr,messages:ba,runSessions:Vs},nodeChats:ka});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 _=await j.json().catch(()=>({}));throw new Error(_.error||`HTTP ${j.status}`)}})},[qr,ba,Vs,a,ka,Se]);h.useEffect(()=>{let w=!1;return l?(Yg(null),Gg(!0),()=>{w=!0}):((async()=>{const _=new URL(window.location.href),I=String(_.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})}),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"加入共享 Workspace 失败");_.searchParams.delete("invite"),window.history.replaceState({},"",`${_.pathname}${_.search}${_.hash}`)}w||(await Cs(),w||await ZS())})().catch(_=>{const I=String(_.message||_);ge(I),Ks("error"),qs(I)}),Hf(),fetch("/api/model-lists").then(_=>_.json()).then(_=>K$({cursor:Array.isArray(_.cursor)?_.cursor.map(String):[],opencode:Array.isArray(_.opencode)?_.opencode.map(String):[],claudeCode:Array.isArray(_.claudeCode)?_.claudeCode.map(String):[],codex:Array.isArray(_.codex)?_.codex.map(String):[]})).catch(()=>{}),Kf(),qf(),Uf(),Vf(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{Y$(qa(_)),G$(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>{Yg(_.user||null),Gg(!0)}).catch(()=>{Yg(null),Gg(!0)}),()=>{w=!0})},[l,Cs,ZS,Hf,qf,Kf,Vf,Uf,Hi]),h.useEffect(()=>{if(HS(""),!(!pS||!mS)){if(!Hi){uu([]);return}uu(iz(Hi,"workspace",Ws,kl)),HS(Hi)}},[kl,mS,Ws,pS,Hi]),h.useEffect(()=>{if(!(WS!==Hi||!Hi))try{localStorage.setItem(Hi,JSON.stringify(Hs))}catch{}},[Hs,Hi,WS]),h.useEffect(()=>{ee.current=re},[re]),h.useEffect(()=>{C.current=b},[b]),h.useEffect(()=>{if(oe.current)return;const w=B.current,j=new Map,_=[];for(const I of b){const T=mM(I);j.set(I.id,T),w.get(I.id)!==T&&_.push(I.id)}B.current=j,_.length!==0&&Kr(_)},[b,Kr]),h.useEffect(()=>{S.current=k},[k]),h.useEffect(()=>{z.current=P},[P]),h.useEffect(()=>{D.current=E},[E]),h.useEffect(()=>{Gv.current=gt},[gt]),h.useEffect(()=>{Yv.current=yr},[yr]),h.useEffect(()=>{Z.current=Y},[Y]),h.useEffect(()=>{if(!Y)return;const w=_=>{_.key==="Escape"&&ne(null)},j=_=>{var I,T;(T=(I=_.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)}},[Y]),h.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}hi(),de.current&&window.clearTimeout(de.current);const j=Qe.current?0:650;return Qe.current=!1,de.current=window.setTimeout(()=>{en().catch(_=>ge(String(_.message||_)))},j),()=>{de.current&&window.clearTimeout(de.current)}},[b,k,P,hi,en,Se]),h.useEffect(()=>{if(Xt.current&&!(!Se||a.archived))return Ft.current&&window.clearTimeout(Ft.current),Ft.current=window.setTimeout(()=>{e0().catch(w=>ge(String(w.message||w)))},900),()=>{Ft.current&&window.clearTimeout(Ft.current)}},[qr,ba,Vs,a.archived,ka,e0,Se]);const Su=h.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:Rv(((j=w.data)==null?void 0:j.body)||"")}}),[b]),hL=h.useMemo(()=>Su.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[Su]);h.useEffect(()=>{if(!ue.current||d!=="workspace"||!a.flowId){va({});return}if(!Su.length){va({});return}let w=!1;const j=async()=>{try{const I=Fr(a),T=await fetch(`/api/workspace/schedules?${I.toString()}`),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");w||va(Gp(U.schedules||[]))}catch{w||va(I=>{var U;const T={};for(const X of Su)T[X.id]={...I[X.id]||{},lastStatus:((U=I[X.id])==null?void 0:U.lastStatus)||"unknown"};return T})}};j();const _=window.setInterval(j,5e3);return()=>{w=!0,window.clearInterval(_)}},[a,Su,hL,d]);const t0=h.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const _=a_(j),I=G=>Array.isArray(G)?G.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:_,value:_}):[],T=b.map(G=>{var le;return G.id!==w?G:{...G,data:{...G.data,body:_,inputs:I((le=G.data)==null?void 0:le.inputs)}}}),U=ee.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:I(X.input)}};ee.current=J,g(T),se(J),Ss(G=>!G||G.id!==w?G:{...G,body:_,inputs:I(G.inputs)}),en(T,k).catch(G=>ge(String(G.message||G)))},[k,b,en,g,Se]),n0=h.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const _=lX(j),I=G=>Array.isArray(G)?G.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:_,value:_}):[],T=b.map(G=>{var le;return G.id!==w?G:{...G,data:{...G.data,body:_,inputs:I((le=G.data)==null?void 0:le.inputs)}}}),U=ee.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:I(X.input)}};ee.current=J,g(T),se(J),Ss(G=>!G||G.id!==w?G:{...G,body:_,inputs:I(G.inputs)}),en(T,k).catch(G=>ge(String(G.message||G)))},[k,b,en,g,Se]),r0=h.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const _=(Array.isArray(j)?j:j?[j]:[]).filter(Fe=>String((Fe==null?void 0:Fe.path)||"").trim()),I=_[0]||null,T=String((I==null?void 0:I.path)||"").trim(),U=_.length===1?String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim():_.length?`${_.length} 个知识库`:"",X=_.length?JSON.stringify(vg(_)):"",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)||""}):"",G=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:U,value:U}:(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:G((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:G(je.input),output:le(je.output)}};ee.current=Ve,g(he),se(Ve),Ss(Fe=>(Fe==null?void 0:Fe.id)===w?{...Fe,inputs:G(Fe.inputs),outputs:le(Fe.outputs)}:Fe),en(he,k).catch(Fe=>ge(String(Fe.message||Fe)))},[k,b,en,g,Se]),s0=h.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const _=String(w||"");if(!_)return;const I=a_((j==null?void 0:j.skillKeys)||[]),T=Af((j==null?void 0:j.displayType)||"markdown"),U=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):"",G=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:G,value:G}:(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===_?{...We,data:{...We.data,body:fe,model:U,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[_]&&typeof Ve[_]=="object"?Ve[_]:{},Ke={...Ve,[_]:{...Fe,body:fe,model:U,input:le(Fe.input),output:he(Fe.output)}};ee.current=Ke,g(je),se(Ke),Ss(We=>(We==null?void 0:We.id)===_?{...We,body:fe,model:U,inputs:le(We.inputs),outputs:he(We.outputs)}:We),en(je,k).catch(We=>ge(String(We.message||We)))},[k,b,en,g,Se]),i0=h.useCallback((w,j)=>{if(!Se){ge("Readonly workspace");return}const _=cJ(j),I=b.map(J=>J.id===w?{...J,data:{...J.data,body:_}}:J),T=ee.current||{},U=T[w]&&typeof T[w]=="object"?T[w]:{},X={...T,[w]:{...U,body:_}};ee.current=X,ye.current=!0,g(I),se(X),Ss(J=>(J==null?void 0:J.id)===w?{...J,body:_}:J),en(I,k).catch(J=>ge(String(J.message||J)))},[k,b,en,g,Se]),o0=h.useCallback(w=>{const j=String(w||"").trim();j&&(PS(_=>_===j?"":j),So(_=>({..._,[j]:_[j]||{sessionId:`nodechat_${Date.now()}_${j.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),a0=h.useCallback(()=>PS(""),[]),l0=h.useCallback((w,j)=>{const _=String(w||"").trim();_&&So(I=>({...I,[_]:{...I[_]||{sessionId:`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(j||""),error:""}}))},[]),Us=h.useCallback((w,j,_="replace",I={})=>{var st,Ye;if(!Se){ge("Readonly workspace");return}const T=String(w||"").trim();if(!T)return;const U=C.current.find(Oe=>Oe.id===T),X=_n(U==null?void 0:U.data),J=li((st=U==null?void 0:U.data)==null?void 0:st.definitionId),G=Mi(j),le=X==="html"?eu(G):X==="react"?bg(G):String(G||""),he=U?lo(U.data):"",fe=_==="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():(Ye=U==null?void 0:U.data)==null?void 0:Ye.displayReloadKey,Fe=Oe=>{let Ot=!1;return(Array.isArray(Oe)?Oe:[]).map(ft=>{const At=String((ft==null?void 0:ft.name)||""),Dl=String((ft==null?void 0:ft.type)||"");return(J?At===je||At==="result"||At==="filePath":At===je||At==="filePath"||Dl==="text")?Ot?{...ft,default:"",value:""}:(Ot=!0,{...ft,default:fe,value:fe}):ft})},Ke=C.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),Ss(Oe=>(Oe==null?void 0:Oe.id)===T?{...Oe,...J?{}:{body:fe}}:Oe),(I==null?void 0:I.logChat)!==!1&&So(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:_==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),en(Ke,S.current).catch(Oe=>ge(String(Oe.message||Oe))),ge(String((I==null?void 0:I.statusMessage)||"")||(_==="append"?"已追加节点内容":"已替换节点内容"))},[en,g,Se]),Yf=h.useCallback(async(w,j="")=>{if(!Se)return ge("Readonly workspace"),"";if(!w)return"";try{const _=new FormData;_.set("file",w),_.set("dir",String(j||"")),a.flowId&&_.set("flowId",a.flowId),a.flowSource&&_.set("flowSource",a.flowSource),a.adminOwnerId&&_.set("adminOwnerId",a.adminOwnerId),a.archived&&_.set("archived","1");const I=await fetch("/api/workspace/upload",{method:"POST",body:_}),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"上传文件失败");const U=String(T.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await Nn(),bl(X=>{const J=new Set(X);for(const G of Xp(U))J.delete(G);return J}),ge(`已上传 ${U}`),U}catch(_){return ge(String(_.message||_)),""}},[a,Nn,Se]),Gf=h.useCallback(async w=>km(w)?Yf(w,"img"):(ge("请选择图片文件"),""),[Yf]),c0=h.useCallback((w="")=>{var j;if(!Se){ge("Readonly workspace");return}uS.current=String(w||""),(j=cS.current)==null||j.click()},[Se]),mL=h.useCallback(async w=>{const j=Array.from(w.target.files||[]);if(w.target.value="",!j.length)return;const _=uS.current||"";lS(!0);try{let I="";for(const T of j){const U=await Yf(T,_);U&&(I=U)}j.length>1&&ge(`已上传 ${j.length} 个文件${I?`,最后一个:${I}`:""}`)}catch(I){ge(String(I.message||I))}finally{lS(!1)}},[Yf]),u0=h.useCallback(async(w,j)=>{const _=String(w||"").trim();if(!_)return;const I=await Gf(j);I&&Us(_,I,"replace",{logChat:!1,statusMessage:`已上传图片 ${I}`})},[Us,Gf]),d0=h.useCallback(async(w,j=void 0)=>{var Fe,Ke;if(!Se){ge("Readonly workspace");return}const _=String(w||"").trim();if(!_)return;const I=ka[_]||{},T=String(j!==void 0?j:I.draft||"").trim();if(!T||I.running)return;const U=C.current.find(We=>We.id===_);if(!U)return;const X=_n(U.data)||"markdown",J=lo(U.data);let G=aa(J,X),le=Mi(J);if(G)try{le=await dl(a,G)}catch(We){ge(String(We.message||We))}else if(X!=="image"&&String(le||"").trim()){const We=Wa(X,le);if(We){ge(`${We} 未进入微调。`);return}try{const Le=await Ib(a,i_(_,U.data),le);await Nn(),Us(_,Le,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Le}`}),G=Le,le=""}catch(Le){ge(String(Le.message||Le));return}}const he=CJ(_,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()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`;So(We=>({...We,[_]:{...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:_,label:((Fe=U.data)==null?void 0:Fe.label)||_,definitionId:((Ke=U.data)==null?void 0:Ke.definitionId)||""},nodeKind:X,currentContent:G?"":le,sourceContext:he,targetFilePath:G,messages:je,message:T,model:Wi})}),Le=await We.json().catch(()=>({}));if(!We.ok)throw new Error(Le.error||"节点微调失败");const Wt=String(Le.candidateContent||Le.reply||"").trim(),st=!!Le.directFileEdit,Ye=String(Le.artifactPath||G||"").trim();if(st&&Ye){const Oe=Wa(X,Wt);if(Oe)throw new Error(`${Oe} 文件已由 agent 修改,请检查 ${Ye}。`);await Nn(),Us(_,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(Wt){const Oe=Wa(X,Wt);if(Oe)throw new Error(`${Oe} 已取消写入,避免覆盖当前展示文件。`);if(G){const Ot=await Ib(a,G,Wt);await Nn(),Us(_,Ot,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ot}`})}else Us(_,Wt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}So(Oe=>{var Ot;return{...Oe,[_]:{...Oe[_]||{},sessionId:String(Le.sessionId||Ve),running:!1,candidateContent:"",messages:[...(Ot=Oe[_])!=null&&Ot.messages&&Array.isArray(Oe[_].messages)?Oe[_].messages:[...je,fe],{role:"assistant",text:Wt||st?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(We){const Le=String(We.message||We);So(Wt=>({...Wt,[_]:{...Wt[_]||{},running:!1,error:Le}})),ge(Le)}},[Wi,a,Nn,ka,Us,Se]),f0=h.useCallback(async(w,j)=>{if(!Se){ge("Readonly workspace");return}const _=_n(j)||"markdown",I=lo(j),T=aa(I,_);let U=Mi(I);if(T)try{U=await dl(a,T)}catch(le){ge(String(le.message||le));return}if(!String(U||"").trim()){ge("展示节点没有可保存内容");return}const X=Wa(_,U);if(X){ge(`${X} 未保存文件。`);return}const J=i_(w,j),G=window.prompt("保存到 workspace 相对路径",J);if(G)try{const le=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:G,content:U})}),he=await le.json().catch(()=>({}));if(!le.ok)throw new Error(he.error||"保存文件失败");const fe=he.path||G,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(),Jv(Fe=>ZJ(Fe,fe,String(U||"").length)),bl(Fe=>{const Ke=new Set(Fe);for(const We of Xp(fe))Ke.delete(We);return Ke}),Us(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ge(`已保存 ${fe}`)}catch(le){ge(String(le.message||le))}},[a,Nn,Us,Se]),p0=h.useCallback(w=>{var T,U;const j=String(w||"").trim();if(!j||Rn)return;const _=C.current.find(X=>X.id===j);if(!_||!_n(_==null?void 0:_.data)){ge("展示节点不可用");return}const I=String(((T=_.data)==null?void 0:T.label)||((U=_.data)==null?void 0:U.displayName)||j).trim()||"AgentFlow Display";zt(jw({title:I,layout:"single",nodeIds:[j],mode:"single-node",sourceNodeId:j})),ce(""),tt(null),Sr(!0)},[Rn]),Jf=h.useCallback((w,j)=>{const _=String(w||"");_&&Ss(I=>{if(!I||I.id!==_)return I;const T=typeof j=="function"?j(I):j;return!T||typeof T!="object"?I:{...I,...T}})},[]),h0=h.useCallback((w,j)=>{const _=String(w||"");!_||!Se||(g(I=>I.map(T=>{var X;if(T.id!==_)return T;const U=Array.isArray((X=T.data)==null?void 0:X.outputs)&&T.data.outputs.length?T.data.outputs.map((J,G)=>G===0?{...J,default:j,value:j}:J):[{type:"file",name:"value",default:j,value:j}];return{...T,data:{...T.data,body:"",outputs:U}}})),Jf(_,I=>({body:"",outputs:Array.isArray(I==null?void 0:I.outputs)&&I.outputs.length?I.outputs.map((U,X)=>X===0?{...U,default:j,value:j}:U):[{type:"file",name:"value",default:j,value:j}]})),ge(`已选择文件 ${j}`))},[g,Jf,Se]),m0=h.useCallback(w=>{Lg({nodeId:String(w||""),query:""})},[]),ty=h.useCallback(()=>{Lg({nodeId:"",query:""})},[]),gL=h.useCallback(w=>{const j=String((w==null?void 0:w.path)||"").trim();!j||!cu.nodeId||(h0(cu.nodeId,j),ty())},[ty,cu.nodeId,h0]),g0=h.useCallback(async(w,j)=>{if(!Se)return;const _=WJ(w,j);if(_.length===0)return;const I=[];try{for(const T of _){const U=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:T})});if(U.status===404)continue;const X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"清理节点输出失败");I.push(X.path||T)}if(I.length===0)return;ge(`已清理 ${I.join(", ")}`),await Nn(),$g(T=>_.some(U=>T===U||T.startsWith(`${U}/`))?"":T)}catch(T){ge(String(T.message||T))}},[a,Nn,Se]),ju=h.useMemo(()=>({modelLists:wa,showBodyPreview:!0,flowParams:a,readOnly:!Se,onRunWorkspaceNode:QS,onStopWorkspaceNode:XS,onOpenWorkspaceRunLogs:JS,onOptimizeWorkspaceRun:ey,onOptimizeWorkspaceSchedule:ey,runningRunNodeIds:VS,onChangeScheduledRunConfig:i0,onChangeContextRunConfig:s0,skills:Ws,skillCollections:kl,onChangeLoadSkillKeys:t0,onRefreshSkills:Kf,mcpServers:gS,onChangeLoadMcpNames:n0,onRefreshMcps:qf,workspaceTargets:wS,onChangeLoadWorkspace:r0,onRefreshWorkspaces:Uf,onSaveDisplayNodeToFile:f0,onShareDisplayNode:p0,onOpenDisplayPreview:q,onRefreshNodeInternals:Kr,onEnsureWorkspaceNodeDisplaySize:jS,sharingDisplayNodeId:Rn,onUploadWorkspaceImage:Gf,onUploadImageToDisplayNode:u0,onOpenProvideFilePicker:m0,onStatus:ge,onSetDisplayNodeContent:Us,onToggleNodeChat:o0,onCloseNodeChat:a0,onUpdateNodeChatDraft:l0,onSendNodeChat:d0,onSyncNodePropDraft:Jf,onCleanupWorkspaceNodeOutputs:g0}),[s0,n0,t0,r0,i0,g0,a0,jS,a,gS,wa,m0,JS,ey,qf,Kr,Kf,Uf,QS,VS,f0,d0,Us,p0,Rn,kl,Ws,XS,Jf,o0,l0,u0,Gf,wS,Se]),yL=h.useRef(new Map),as=h.useMemo(()=>{const w=yL.current,j=new Set,_=b.map(I=>{var G,le,he;const T={selected:I.selected===!0,isExecuting:OS.has(I.id),nodeStatus:((G=Zg[I.id])==null?void 0:G.status)??null,nodeElapsed:((le=Zg[I.id])==null?void 0:le.elapsed)??null,optimizingRun:DS===I.id,scheduledRunState:LS[I.id]||null,nodeChatActive:IS===I.id,nodeChat:ka[I.id]||null},U=w.get(I.id);if(U&&U.source===I&&U.commonData===ju&&XC(U.runtime,T))return j.add(I.id),U.node;const X=!!(U&&((he=U.source)==null?void 0:he.data)===I.data&&U.commonData===ju&&XC(U.runtime,T)),J={...I,data:X?U.node.data:{...I.data,...ju,...T}};return w.set(I.id,{source:I,commonData:ju,runtime:T,node:J}),j.add(I.id),J});for(const I of w.keys())j.has(I)||w.delete(I);return _},[IS,ju,ka,b,DS,LS,OS,Zg]),dt=d==="display",Cn=d==="workflow",y0=h.useMemo(()=>dt?new Map(as.map(w=>[w.id,w])):mJ,[as,dt]),w0=h.useMemo(()=>vs&&as.find(w=>w.id===vs)||null,[vs,as]),x0=h.useRef(new Map),Nu=h.useMemo(()=>{if(!dt)return x0.current.clear(),gJ;const w=new Set(M),j=x0.current,_=new Set,I=P.nodeIds.map((T,U)=>{var Ve,Fe,Ke,We;const X=y0.get(T);if(!X||!_n(X.data))return null;const J=Jl(X)||{width:520,height:320},G=Ga(P.nodeSizes[T]||J,{display:!0})||J,le=P.nodePositions[T]||{x:180+U*36,y:120+U*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)===G.width&&((We=fe.size)==null?void 0:We.height)===G.height&&fe.selected===he)return _.add(T),fe.node;const je={...X,id:QC(T),position:le,selected:he,width:G.width,height:G.height,data:{...X.data,sourceNodeId:T,displayPageMode:!0,readOnly:!0,selected:he,displaySize:G,nodeSize:G}};return j.set(T,{source:X,position:le,size:G,selected:he,node:je}),_.add(T),je}).filter(Boolean);for(const T of j.keys())_.has(T)||j.delete(T);return I},[P,y0,dt,M]),Pl=h.useMemo(()=>as.filter(w=>_n(w==null?void 0:w.data)),[as]);h.useEffect(()=>{if(!dt||!P.viewport)return;const w=P.viewport,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(_)},[P.viewport,dt,r]),h.useEffect(()=>{if(dt||Cn||!E)return;const w=E,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(_)},[dt,Cn,r,E]),h.useEffect(()=>{Cn&&vu(sr)},[Cn]),h.useEffect(()=>{if(!Cn||!sr)return;const w=Fr(a);w.set("tapdId",sr);let j=null,_=null,I=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},U=()=>{I||document.hidden||j||(j=new EventSource(`/api/prd-workflow/events?${w.toString()}`),j.onmessage=()=>{vu(sr)},j.onerror=()=>{T(),!I&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}vu(sr),U()};return U(),document.addEventListener("visibilitychange",X),()=>{I=!0,document.removeEventListener("visibilitychange",X),T()}},[a,Cn,vu,sr]),h.useEffect(()=>{if(!a.flowId||Cn)return;const w=Fr(a);w.set("clientId",_t.current);let j=null,_=null,I=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},U=()=>{I||document.hidden||j||(j=new EventSource(`/api/workspace/events?${w.toString()}`),j.onmessage=J=>{let G=null;try{G=JSON.parse(J.data||"{}")}catch{G=null}if(!(!G||G.clientId===_t.current)){if(G.type==="graph.committed"){El(G);return}if(G.type==="runtime.committed"){El(G);return}if(String(G.type||"").startsWith("file.")){Nn();return}String(G.type||"").startsWith("run.")&&Vf()}},j.onerror=()=>{T(),!I&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}El({type:"visibility.resume"}),U()};return U(),document.addEventListener("visibilitychange",X),()=>{I=!0,document.removeEventListener("visibilitychange",X),T(),Re.current&&(window.clearTimeout(Re.current),Re.current=null),kt.current=!1}},[a,Cn,Nn,Vf,El]),h.useEffect(()=>{if(oe.current)return;const w=F.current,j=new Map,_=[];for(const I of[...as,...Nu]){const T=hJ(I);j.set(I.id,T),w.get(I.id)!==T&&_.push(I.id)}F.current=j,_.length!==0&&Kr(_)},[Nu,as,Kr]);const Kt=h.useMemo(()=>b.find(w=>w.id===yr)||null,[b,yr]),ny=h.useRef({id:"",draft:null}),wL=h.useMemo(()=>{const w=d_(Kt);return w?JSON.stringify(w):""},[Kt==null?void 0:Kt.data,Kt==null?void 0:Kt.id]);h.useEffect(()=>{if(!Kt){ny.current={id:"",draft:null},Ss(null),gl("");return}const w=d_(Kt),j=ny.current;ny.current={id:Kt.id,draft:w},Ss(_=>!_||_.id!==Kt.id||j.id!==Kt.id||!j.draft?w:fX(_,j.draft,w)),gl("")},[Kt==null?void 0:Kt.id,wL]);const ry=h.useCallback((w=!1)=>{if(!gt||!Kt)return!1;if(!Se)return gl("Readonly workspace"),ge("Readonly workspace"),!1;gl("");const j=h_({nodes:b,edges:k,instances:ee.current,selectedNode:Kt,draft:gt,allowRename:w});return j!=null&&j.error?(gl(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]);h.useEffect(()=>{if(!Se||!gt||!Kt)return;const w=window.setTimeout(()=>{ry(!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)||[]),ry,Kt==null?void 0:Kt.id,Se]);const b0=h.useRef({refs:new Map,nodeDataById:new Map}),sy=h.useMemo(()=>{const w=b0.current;let j=w.refs.size!==b.length;const _=new Map;for(const T of b)_.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 b0.current={refs:_,nodeDataById:I},I},[b]),xL=h.useMemo(()=>k.map(w=>{var G,le;const j=sy.get(w.source),_=sy.get(w.target),I=/^output-(\d+)$/.exec(w.sourceHandle||""),T=/^input-(\d+)$/.exec(w.targetHandle||""),U=j&&I?(G=j.outputs)==null?void 0:G[parseInt(I[1],10)]:null,X=_&&T?(le=_.inputs)==null?void 0:le[parseInt(T[1],10)]:null,J=U!=null&&U.type?En(U.type):X!=null&&X.type?En(X.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:Ci.ArrowClosed,color:J}}:w}),[sy,k]),Xf=dt?Nu:as,bL=dt?[]:xL,k0=h.useRef(Xf),Rl=h.useRef([]);oe.current||(k0.current=Xf);const kL=h.useMemo(()=>dt?Nu.map(w=>({...w,id:Jp(w.id)})):as,[Nu,as,dt]),iy=h.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const _=dt?QC(j):j;dt?V([j]):(g(T=>T.map(U=>({...U,selected:U.id===_}))),x(T=>T.map(U=>({...U,selected:!1}))),Zt(_));const I=()=>{var le,he,fe;const T=r.getNode(_);if(!T)return;const U=(le=r.getInternalNode)==null?void 0:le.call(r,_),X=((he=U==null?void 0:U.measured)==null?void 0:he.width)??(U==null?void 0:U.width)??T.width??260,J=((fe=U==null?void 0:U.measured)==null?void 0:fe.height)??(U==null?void 0:U.height)??T.height??120,{zoom:G}=r.getViewport();r.setCenter(T.position.x+X/2,T.position.y+J/2,{zoom:vJ(G),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(I))},[dt,r,x,g]);h.useEffect(()=>{const w=String(c.current||"").trim();!w||!ue.current||d!=="workspace"||as.some(j=>j.id===w)&&(c.current="",ye.current=!0,iy(w))},[as,iy,d]);const v0=h.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 _={...z.current,viewport:j};z.current=_,R(_),ge("已固定 Display 进入视角")}else{D.current=j,O(j);try{window.localStorage.setItem(u,JSON.stringify(j))}catch{}ge("已固定 Workspace 进入视角");return}en(C.current,S.current).catch(_=>ge(String(_.message||_)))},[dt,r,en,u]),oy=h.useMemo(()=>{const w=Ie.trim().toLowerCase(),j={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const _ of at)w&&![_.id,_.label,_.displayName,_.description].some(I=>String(I||"").toLowerCase().includes(w))||j[nd(_)].push(_);for(const _ of Yl)j[_].sort((I,T)=>I.id.localeCompare(T.id));return j},[at,Ie]),Cu=h.useMemo(()=>{const w=wn.trim().toLowerCase();return at.filter(j=>!w||[j.id,j.label,j.displayName,j.description].some(_=>String(_||"").toLowerCase().includes(w))).sort((j,_)=>{const I=Yl.indexOf(nd(j)),T=Yl.indexOf(nd(_));return I!==T?I-T:rd(j).localeCompare(rd(_))}).slice(0,30)},[at,wn]),_u=h.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(_=>String(_||"").toLowerCase().includes(w))).sort((j,_)=>String(j.displayName||j.name||j.id).localeCompare(String(_.displayName||_.name||_.id))).slice(0,30)},[vt,wn]);h.useEffect(()=>{rr(0)},[wn,we,Ae]),h.useEffect(()=>{if(!we)return;const w=window.setTimeout(()=>{var j;return(j=_S.current)==null?void 0:j.focus()},0);return()=>window.clearTimeout(w)},[we]);const vL=h.useMemo(()=>{const w=Tg.trim().toLowerCase();return w?Tv(yl).filter(j=>j.path.toLowerCase().includes(w)):yl},[Tg,yl]),ja=h.useMemo(()=>_M(yl,Mg),[yl,Mg]),Ki=(ja==null?void 0:ja.type)==="directory"?ja.path:GJ((ja==null?void 0:ja.path)||""),SL=h.useCallback(w=>{var j,_;(_=(j=w.target)==null?void 0:j.closest)!=null&&_.call(j,".af-work-file")||$g("")},[]),jL=[...(wa.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(wa.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(wa.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(wa.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],ay=h.useMemo(()=>new Set(Hs),[Hs]),Tl=h.useMemo(()=>{const w=new Map(Ws.map(U=>[U.key,U])),j=new Set,_=new Set,I=kl.map(U=>{const X=ia(U,Ws).map(J=>w.get(J)).filter(Boolean);for(const J of X)j.add(J.key),_.add(String(J.name||J.id||J.key||"").trim());return{...U,skills:X}}).filter(U=>U.skills.length>0),T=Ws.filter(U=>{const X=String(U.name||U.id||U.key||"").trim();return!j.has(U.key)&&!_.has(X)});return{groups:I,ungrouped:T}},[kl,Ws]);h.useEffect(()=>{NS(w=>{let j=!1;const _=new Set(w);for(const I of Tl.groups)_.has(I.id)||(_.add(I.id),j=!0);return j?_:w})},[Tl.groups]);const Qn=h.useMemo(()=>{const w=b.filter(j=>j.selected);return w.length>0?w:yr?b.filter(j=>j.id===yr):[]},[b,yr]),Qf=h.useMemo(()=>Qn.map(w=>w.id),[Qn]),S0=h.useCallback(()=>{if(dt)return;if(!Se){ge("Readonly workspace");return}const w=(C.current||[]).filter(J=>(J==null?void 0:J.selected)&&!Cm(J));if(w.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const j=w.reduce((J,G)=>{var Ve,Fe,Ke,We,Le,Wt,st,Ye,Oe,Ot,De,ft;const le=Number(((Ve=G.position)==null?void 0:Ve.x)||0),he=Number(((Fe=G.position)==null?void 0:Fe.y)||0),fe=Number(((Ke=G.measured)==null?void 0:Ke.width)||G.width||((Le=(We=G.data)==null?void 0:We.nodeSize)==null?void 0:Le.width)||((st=(Wt=G.data)==null?void 0:Wt.displaySize)==null?void 0:st.width)||tM),je=Number(((Ye=G.measured)==null?void 0:Ye.height)||G.height||((Ot=(Oe=G.data)==null?void 0:Oe.nodeSize)==null?void 0:Ot.height)||((ft=(De=G.data)==null?void 0:De.displaySize)==null?void 0:ft.height)||bm);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 _=new Set((C.current||[]).map(J=>J.id));let I=1,T=`group_${I}`;for(;_.has(T);)I+=1,T=`group_${I}`;const U=_b({width:j.maxX-j.minX+Up*2,height:j.maxY-j.minY+Up*2})||{width:al,height:ll},X={id:T,type:Nc,position:{x:j.minX-Up,y:j.minY-Up},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:_m(I-1),title:_m(I-1),color:"purple",nodeSize:U}};g(J=>[X,...J.map(G=>({...G,selected:!1}))]),x(J=>J.map(G=>({...G,selected:!1}))),Zt(""),ge(`Created group for ${w.length} nodes`)},[dt,x,g,Se]),Au=h.useMemo(()=>b.filter(w=>_n(w==null?void 0:w.data)),[b]),ly=h.useMemo(()=>Qn.filter(w=>_n(w==null?void 0:w.data)).map(w=>w.id),[Qn]),NL=h.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]),cy=h.useMemo(()=>new Set(Qf),[Qf]),Zf=h.useMemo(()=>k.filter(w=>cy.has(w.source)&&cy.has(w.target)),[k,cy]),uy=h.useCallback(w=>{const j=w==="display"?"display":w==="workflow"?"workflow":"workspace";f(j),Zt(""),V([]),ne(null),$e(!1),pn(!1);const _=Fr(a);j==="display"&&_.set("view","display"),j==="workflow"&&(_.set("view","workflow"),sr.trim()&&_.set("tapdId",sr.trim()));const I=`/workspace${_.toString()?`?${_.toString()}`:""}`;window.history.pushState({},"",I)},[a,sr]),j0=h.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const _=C.current.find(I=>I.id===j);if(!_||!_n(_.data)){ge("展示节点不可用");return}R(I=>{if(I.nodeIds.includes(j))return I;const T=I.nodeIds.length,U=Jl(_);return{nodeIds:[...I.nodeIds,j],nodePositions:{...I.nodePositions,[j]:{x:180+T*36,y:120+T*28}},nodeSizes:{...I.nodeSizes,...U?{[j]:U}:{}}}}),V([j])},[]),N0=h.useCallback(w=>{const j=String(w||"").trim();j&&(R(_=>{const I=_.nodeIds.filter(X=>X!==j),T={..._.nodePositions},U={..._.nodeSizes};return delete T[j],delete U[j],{nodeIds:I,nodePositions:T,nodeSizes:U}}),V(_=>_.filter(I=>I!==j)))},[]),C0=h.useCallback(w=>{const j=String(w||"").trim();j&&(z.current.nodeIds.includes(j)?N0(j):j0(j))},[j0,N0]),ep=h.useMemo(()=>{const w=$n.trim().toLowerCase();return w?Pl.filter(j=>{var _,I;return[j.id,(_=j.data)==null?void 0:_.label,(I=j.data)==null?void 0:I.definitionId].filter(Boolean).some(T=>String(T).toLowerCase().includes(w))}):Pl},[Pl,$n]),_0=h.useMemo(()=>{const w=ep.length,j=w<=1?1:w<=4?2:3,_=Array.from({length:j},()=>({height:0,nodes:[]}));for(const I of ep){const T=Jl(I)||{width:420,height:260},U=Math.max(1,Number(T.width)||420),X=Math.max(1,Number(T.height)||260),J=Math.min(26,Math.max(5.5,X/U*16))+3.2;let G=_[0];for(const le of _)le.height<G.height&&(G=le);G.nodes.push(I),G.height+=J}return _.map(I=>I.nodes)},[ep]),CL=h.useCallback(w=>{var U;const j=P.nodeIds.includes(w.id),_=Jl(w)||{width:420,height:260},I=Math.max(1,Math.round(Number(_.width)||420)),T=Math.max(1,Math.round(Number(_.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:()=>C0(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(OJ,{node:w})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((U=w.data)==null?void 0:U.label)||w.id}),i.jsxs("small",{children:[_n(w.data)," · ",w.id]})]})]},w.id)},[P.nodeIds,C0]),A0=h.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(_=>String(_).toLowerCase().includes(w))):vt},[vt,Ie]),E0=h.useCallback((w,j)=>{const _=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let I=`${_}_${Date.now().toString(36)}`,T=2;for(;j.has(I);)I=`${_}_${Date.now().toString(36)}_${T}`,T+=1;return j.add(I),I},[]),Eu=h.useCallback((w,j)=>{var Oe,Ot;if(!Se){ge("Readonly workspace");return}const _=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},I=_.instances&&typeof _.instances=="object"?_.instances:{},T=Object.keys(I);if(T.length===0)return;const U=new Set(C.current.map(De=>De.id)),X={};for(const De of T)X[De]=E0(De,U);const J=(Oe=_.ui)!=null&&Oe.nodePositions&&typeof _.ui.nodePositions=="object"?_.ui.nodePositions:{},G=(Ot=_.ui)!=null&&Ot.nodeSizes&&typeof _.ui.nodeSizes=="object"?_.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+C.current.length*24,y:180+C.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=G[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(_.edges)?_.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=Hu({instances:Ve,edges:Le,ui:{nodePositions:Fe,nodeSizes:Ke}},at),st=Wt.nodes.map(De=>De.id),Ye=Wt.nodes.map(De=>({...De,selected:!0}));ee.current={...ee.current,...Wt.instances},se(ee.current),g(De=>[...De.map(ft=>({...ft,selected:!1})),...Ye]),x(De=>[...De.map(ft=>({...ft,selected:!1})),...Wt.edges.map(ft=>({...ft,selected:!1}))]),Zt(""),V([]),ge(`已添加流程片段:${w.displayName||w.id}(已选中 ${st.length} 个节点)`)},[E0,at,r,x,g,Se]),_L=h.useCallback(()=>{var _,I;if(Qn.length<2){nr("请先在 workspace 画布上选择至少两个节点。"),Pt("flows");return}const w=Qn[0],j=Qn.length===2?`${((_=w.data)==null?void 0:_.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:""}),Gn(""),hr(!0),Pt("flows")},[Qn]),AL=h.useCallback(async()=>{var T,U;if(Qn.length<2)return;const w=fn.name.trim();if(!w){Gn("请填写片段名称。");return}const j={},_={};for(const X of Qn){j[X.id]={x:((T=X.position)==null?void 0:T.x)||0,y:((U=X.position)==null?void 0:U.y)||0};const J=Jl(X);J&&(_[X.id]=J)}const I=Zf.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));Ds(!0),Gn("");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:Sv(Qn,ee.current),edges:I,ui:{nodePositions:j,nodeSizes:_}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");hr(!1),ge(`流程片段已发布:${J.id||w}`),SS(`流程片段已发布:${J.id||w}`),await Hf(),Pt("flows")}catch(X){Gn(String(X.message||X))}finally{Ds(!1)}},[Hf,fn,Zf,Qn,SS]),I0=h.useCallback(async()=>{var j;const w=ou.trim();if(w){Qv(!0),vo("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),I=await _.json().catch(()=>({}));if(!_.ok)throw new Error(I.error||"添加协作成员失败");$f(I.workspace||null),eS(""),ge(`已将 Workspace 分享给 ${((j=I.member)==null?void 0:j.username)||w}`)}catch(_){vo(String(_.message||_))}finally{Qv(!1)}}},[a,ou]),EL=h.useCallback(()=>{vo(""),Eg(!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 _=j.team||null;z$(_);const I=(T=Tt==null?void 0:Tt.teamShares)==null?void 0:T.find(U=>U.teamId===(_==null?void 0:_.id));rS((I==null?void 0:I.role)==="editor"?"editor":"viewer")}).catch(w=>vo(String(w.message||w)))},[Tt==null?void 0:Tt.teamShares]),dy=h.useCallback(async(w=!1)=>{if(Bs!=null&&Bs.id){sS(!0),vo("");try{const j=await fetch("/api/workspace/collaboration/team-share",{method:w?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,teamId:Bs.id,role:Pg})}),_=await j.json().catch(()=>({}));if(!j.ok)throw new Error(_.error||(w?"取消团队分享失败":"分享到团队失败"));$f(_.workspace||null),ge(w?`已取消对「${Bs.name}」的分享`:`已分享到「${Bs.name}」`)}catch(j){vo(String(j.message||j))}finally{sS(!1)}}},[a,Bs,Pg]),IL=h.useCallback(async w=>{const j=String((w==null?void 0:w.userId)||"").trim();if(!(!j||j===(Tt==null?void 0:Tt.ownerId))){nS(j),vo("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:j})}),I=await _.json().catch(()=>({}));if(!_.ok)throw new Error(I.error||"取消成员分享失败");$f(I.workspace||null),ge(`已取消对 ${(w==null?void 0:w.username)||j} 的分享`)}catch(_){vo(String(_.message||_))}finally{nS("")}}},[a,Tt==null?void 0:Tt.ownerId]),P0=h.useCallback(async()=>{const w=Kl(C.current,S.current,ee.current);w.ui={...w.ui||{},...D.current?{viewport:D.current}:{},displayPage:ZC(z.current,C.current)};const j=new Blob([`${JSON.stringify(w,null,2)}
264
+ `],{type:"application/json"}),_=URL.createObjectURL(j),I=document.createElement("a");I.href=_,I.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(I),I.click(),I.remove(),URL.revokeObjectURL(_),await Cs(),wl(null),ya(!1),ge("已备份本地草稿并载入远端最新版本")},[S,a.flowId,Cs,C]),PL=h.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)){lu("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let j=jn.mergeGraph;try{w.forEach((I,T)=>{const U=Rg[String(T)]||{mode:"local"};let X,J=!0;U.mode==="remote"?(X=I.current,J=I.hasCurrent!==!1):U.mode==="manual"?X=JSON.parse(String(U.manual||"")):(X=I.incoming,J=I.hasIncoming!==!1),j=bX(j,I.pathParts,X,J)})}catch(I){lu(`手动值不是有效 JSON:${String(I.message||I)}`);return}iS(!0),lu(""),Ks("saving"),qs("正在提交冲突解决结果");const _=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:_t.current})}),T=await I.json().catch(()=>({}));if(!I.ok){if(I.status===409&&Array.isArray(T.conflictItems)){const U=T.conflictItems;wl({currentRevision:String(T.currentRevision||""),message:T.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(T.conflictPaths)?T.conflictPaths:[],conflictItems:U,mergeGraph:T.mergeGraph||null,currentGraph:T.currentGraph||null}),xl(Object.fromEntries(U.map((X,J)=>[String(J),{mode:"local",manual:Vu(X)}])))}throw new Error(T.error||"提交冲突解决结果失败")}await Cs(),wl(null),ya(!1),ge("冲突已解决并保存")});Ne.current=_;try{await _}catch(I){lu(String(I.message||I)),Ks("error"),qs(String(I.message||I))}finally{iS(!1)}},[a,Cs,jn,Rg]);h.useCallback(()=>{if(Au.length===0){ge("当前 workspace 没有 display 节点");return}const w=ly.length>0?ly:Au.map(_=>_.id),j=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";zt(jw({title:j,layout:"gallery",nodeIds:w,mode:"multi-node"})),ce(""),tt(null),Sr(!0)},[a.flowId,ly,Au]);const RL=h.useCallback(w=>{zt(j=>{const _=Array.isArray(j.nodeIds)?j.nodeIds:[];return _.includes(w)?{...j,nodeIds:_.filter(I=>I!==w)}:{...j,nodeIds:[..._,w]}})},[]),Ys=h.useCallback(async()=>{Bi(!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{Bi(!1)}},[]),TL=h.useCallback(()=>{Xn(!0),Rt(""),Ys()},[Ys]),ML=h.useCallback(async()=>{var _,I;const w=rt.title.trim(),j=Array.isArray(rt.nodeIds)?rt.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:rt.layout,nodeIds:j,...t_(rt)})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"发布展示页失败");const X=new URL(U.url||`/display/${((_=U.share)==null?void 0:_.id)||""}`,window.location.origin).href;tt({...U,absoluteUrl:X}),ge((I=U.share)!=null&&I.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Yt&&Ys()}catch(T){ce(String(T.message||T))}finally{Mr(!1)}},[rt,Yt,k,a,Ys,b,en]),$L=h.useCallback(async()=>{var j,_;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,...t_(rt)})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"生成展示链接失败");const X=new URL(U.url||`/display/${((j=U.share)==null?void 0:j.id)||""}`,window.location.origin).href;tt({...U,absoluteUrl:X}),mr(!0),ge((_=U.share)!=null&&_.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Yt&&Ys()}catch(I){const T=String(I.message||I);ce(T),ge(T)}finally{Mr(!1)}},[P.nodeIds,rt,Yt,k,a,Ys,b,en]),R0=h.useCallback(async()=>{const w=me==null?void 0:me.absoluteUrl;if(!w)return;const j=await Eb(w);Ut(j?"copied":"failed"),window.setTimeout(()=>Ut(""),1600)},[me==null?void 0:me.absoluteUrl]),LL=h.useCallback(async w=>{const j=n_(w),_=await Eb(j);Rt(_?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>Rt(""),1600)},[]),OL=h.useCallback(async(w,j)=>{const _=String((w==null?void 0:w.id)||"");if(_){Te(_),ae("");try{const I=j==="permanent"?{id:_,expiresMode:"permanent",permanent:!0}:{id:_,expiresMode:"days",expiresInDays:Number(j||30)},T=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await Ys(),ge("分享有效期已更新")}catch(I){ae(String(I.message||I))}finally{Te("")}}},[Ys]),DL=h.useCallback(async w=>{const j=String((w==null?void 0:w.id)||"");if(j){Te(j),ae("");try{const _=await fetch(`/api/display/share?id=${encodeURIComponent(j)}`,{method:"DELETE"}),I=await _.json().catch(()=>({}));if(!_.ok||I.ok===!1)throw new Error(I.error||"撤销分享失败");await Ys(),ge("分享已撤销")}catch(_){ae(String(_.message||_))}finally{Te("")}}},[Ys]),FL=h.useCallback(w=>{g(j=>j.map(_=>_.id===w?{..._,selected:!1}:_)),Zt(j=>j===w?"":j)},[g]),Ml=h.useCallback(()=>{const w=Vg.current;if(!w)return;const j=w.getBoundingClientRect(),_=Math.min(420,Math.max(320,j.width+160)),I=12,T=Math.max(180,j.top-I*2),U=Math.min(560,T);nL({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-_-12,j.left)),top:Math.max(I,j.top-U-I),width:_,maxHeight:U,zIndex:1e4})},[]);h.useEffect(()=>{if(!zf)return;Ml();const w=_=>{var T,U;const I=_.target;(T=Vg.current)!=null&&T.contains(I)||(U=CS.current)!=null&&U.contains(I)||Hg(!1)},j=_=>{_.key==="Escape"&&Hg(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",j),window.addEventListener("resize",Ml),window.addEventListener("scroll",Ml,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",j),window.removeEventListener("resize",Ml),window.removeEventListener("scroll",Ml,!0)}},[zf,Ml]);const tp=h.useCallback(w=>{const j=eM(w);if(j.active&&(oe.current=!0),j.finished&&(oe.current=!1,Qe.current=!0),qY(w)&&hi(),d==="display"){R(T=>{var G,le;let U=T.nodePositions,X=T.nodeSizes;for(const he of w||[]){const fe=Jp(he==null?void 0:he.id);if(!(!fe||!T.nodeIds.includes(fe))&&he.type!=="select"){if(he.type==="position"&&he.position){const je=U[fe];if((je==null?void 0:je.x)===he.position.x&&(je==null?void 0:je.y)===he.position.y)continue;U===T.nodePositions&&(U={...T.nodePositions}),U[fe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((G=he.dimensions)!=null&&G.width)&&((le=he.dimensions)!=null&&le.height)){const je=Ga({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(U===T.nodePositions&&X===T.nodeSizes)return T;const J={...T,nodePositions:U,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 U=new Set(T);for(const J of I){const G=Jp(J==null?void 0:J.id);G&&(J.selected?U.add(G):U.delete(G))}const X=Array.from(U);return X.length===T.length&&X.every((J,G)=>J===T[G])?T:X});return}if(!Se){const I=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");I.length>0&&g(T=>bd(I,T));return}const _=(w||[]).filter(I=>{var T,U;return(I==null?void 0:I.type)==="dimensions"&&((T=I.dimensions)==null?void 0:T.width)&&((U=I.dimensions)==null?void 0:U.height)});g(I=>{const T=new Map;if(_.length>0){const J=new Map(I.map(G=>[G.id,G]));for(const G of _){const le=J.get(G.id),he={width:Math.round(Number(G.dimensions.width)),height:Math.round(Number(G.dimensions.height))},fe=Cm(le)?_b(he):Ga(he,{display:!!_n(le==null?void 0:le.data)});fe&&T.set(G.id,fe)}}const U=bd(w,I),X=T.size===0?U:U.map(J=>{const G=T.get(J.id);if(!G)return J;const le={...J.data,nodeSize:G};return _n(J.data)&&(le.displaySize=G),{...J,width:G.width,height:G.height,data:le}});return j.mutated||(ze.current={nodes:X,edges:S.current,displayPage:z.current}),C.current=X,X}),_.length>0&&Kr(_.map(I=>I.id))},[hi,Kr,g,d,Se]),np=h.useCallback((w=[],{finish:j=!1}={})=>{const _=j?JY([...K.current,...w]):kb(w);j&&(K.current=[]),_.length>0&&tp(_)},[tp]),zL=h.useCallback(w=>{const{transient:j,committed:_,finishesInteraction:I}=GY(w);if(j.length>0){de.current&&(window.clearTimeout(de.current),de.current=null),oe.current||(oe.current=!0,Rl.current=k0.current),K.current=kb([...K.current,...j]);const T=bd(j,Rl.current);Rl.current=T,s.getState().setNodes(T)}if(I){Rl.current=[],np(_,{finish:!0});return}_.length>0&&tp(_)},[tp,np,s]),$l=h.useCallback(()=>{ke.current.size>0||Be.current||((oe.current||K.current.length>0)&&(np([],{finish:!0}),Rl.current=[]),kt.current&&El({type:"interaction.finished"}))},[np,El]),BL=h.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.add(w.pointerId)},[]),jo=h.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.delete(w.pointerId),window.queueMicrotask($l)},[$l]),WL=h.useCallback(()=>{Be.current=!0},[]),HL=h.useCallback(()=>{Be.current=!1,window.queueMicrotask($l)},[$l]);h.useEffect(()=>{const w=()=>{ke.current.clear(),Be.current=!1,$l()},j=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",jo,!0),window.addEventListener("pointercancel",jo,!0),window.addEventListener("lostpointercapture",jo,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("pointerup",jo,!0),window.removeEventListener("pointercancel",jo,!0),window.removeEventListener("lostpointercapture",jo,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",j),ke.current.clear(),Be.current=!1,K.current=[],Rl.current=[]}},[jo,$l]);const VL=h.useCallback(w=>{if(d!=="display"){if(!Se){const j=(w||[]).filter(_=>(_==null?void 0:_.type)==="select");j.length>0&&x(_=>{const I=dm(j,_);return S.current=I,I});return}(w||[]).some(j=>(j==null?void 0:j.type)!=="select")&&hi(),x(j=>{const _=dm(w,j);return S.current=_,_})}},[hi,x,d,Se]),Ll=h.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]),rp=h.useCallback(()=>{var w,j,_;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(((_=Kt.position)==null?void 0:_.y)||0)}}return Ll()},[Ll,Kt]),qi=h.useCallback((w,j={})=>{if(!Se)return ge("Readonly workspace"),null;if(!w)return null;const _=Iv(w)||w.id,I=fM(w),T=hM(w),U=j.id||iJ(_,b),X=id(w.inputs),J=id(w.outputs),G={definitionId:_,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:j.label||Nm(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:U,type:Nc,position:j.position||Ll(),data:{label:G.label,definitionId:_,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:dM(_,w),role:"normal",body:G.body,...G.script?{script:G.script}:{},...G.scriptRef?{scriptRef:G.scriptRef}:{},...G.implementationRef?{implementationRef:G.implementationRef}:{},...G.implementationMode?{implementationMode:G.implementationMode}:{},inputs:G.input,outputs:G.output}},he={...xb(le,{...ee.current,[U]:G},at),selected:!0};return hi(),g(fe=>[...fe.map(je=>({...je,selected:!1})),he]),j.openProperties&&Zt(U),U},[Ll,hi,b,at,g,Se]),KL=h.useCallback(w=>vw(w,C.current),[]),qL=h.useCallback(w=>{if(!Se){ge("Readonly workspace");return}if(!vw(w,C.current)){ge("端口类型不匹配,已取消连线");return}ne(null),hi(),g(j=>gw(j,w)),x(j=>{const _=j.filter(T=>!(T.target===w.target&&T.targetHandle===w.targetHandle)),I=Sh({...w,markerEnd:{type:Ci.ArrowClosed}},_);return S.current=I,I})},[hi,x,g,Se]),UL=h.useCallback((w,j)=>{if(!Se)return;const _=nJ(j,C.current);te.current=_?{..._,preferExisting:!!(w!=null&&w.shiftKey)}:null,ne(null)},[Se]),YL=h.useCallback((w,j)=>{var We,Le,Wt,st;if(!Se)return;const _=te.current;if(te.current=null,!_||j!=null&&j.toNode)return;const I=rJ(at,_),T=sJ(C.current,S.current,_);if(I.length===0&&T.length===0){ge(`没有匹配 ${_.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||_.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),G=((st=(Wt=w==null?void 0:w.changedTouches)==null?void 0:Wt[0])==null?void 0:st.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(G))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(G-he.top,he.height-Ve-12));ne({left:Fe,top:Ke,flowPosition:r.screenToFlowPosition({x:J,y:G}),draft:_,candidates:I,existingCandidates:T,mode:X,query:""})},[at,r,Se]),GL=h.useCallback(w=>{if(!Se){ge("Readonly workspace"),ne(null);return}const j=Z.current;if(!j||!(w!=null&&w.def))return;const _=qi(w.def,{position:j.flowPosition});if(!_)return;const I=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:_,targetHandle:`input-${w.slotIndex}`}:{source:_,sourceHandle:`output-${w.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};g(T=>gw(T,I)),x(T=>{const U=T.filter(J=>!(J.target===I.target&&J.targetHandle===I.targetHandle)),X=Sh({...I,markerEnd:{type:Ci.ArrowClosed}},U);return S.current=X,X}),ne(null)},[qi,x,Se]),JL=h.useCallback(w=>{if(!Se){ge("Readonly workspace"),ne(null);return}const j=w==null?void 0:w.connection;if(!j||!vw(j,C.current)){ge("端口类型不匹配,已取消连线"),ne(null);return}g(_=>gw(_,j)),x(_=>{const I=_.filter(U=>!(U.target===j.target&&U.targetHandle===j.targetHandle)),T=Sh({...j,markerEnd:{type:Ci.ArrowClosed}},I);return S.current=T,T}),ne(null)},[x,g,Se]),T0=h.useCallback(w=>{w&&(qi(w,{position:rp()}),$e(!1),Lt(""))},[qi,rp]),M0=h.useCallback(w=>{w&&(Eu(w,rp()),$e(!1),Lt(""))},[Eu,rp]),XL=h.useCallback(w=>{var _,I,T;if(dt||Cn)return;const j=w==null?void 0:w.target;WC(j)||(_=j==null?void 0:j.closest)!=null&&_.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,Cn]);h.useEffect(()=>{const w=j=>{var le;if(j.defaultPrevented)return;const _=KU(j.target)||WC(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(),TS(he=>!he);return}if(Xg)return;if(Jg){(j.key==="Escape"||vC(j))&&(j.preventDefault(),Wf(!1));return}const I=j.key.toLowerCase(),T=(j.metaKey||j.ctrlKey)&&I==="c",U=(j.metaKey||j.ctrlKey)&&I==="v",X=_&&T&&wG(j.target);if(_&&!X)return;const J=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&I==="z",G=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&I==="z"||I==="y");if(J||G){if(dt){j.preventDefault(),j.stopPropagation(),ge("展示页布局会自动保存");return}if(!Se){j.preventDefault(),ge("Readonly workspace");return}j.preventDefault(),j.stopPropagation();const he=J?YS():GS();ge(he?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(T){if(dt)return;const he=Yv.current,fe=(C.current||[]).some(Ve=>Ve==null?void 0:Ve.selected)?C.current:(C.current||[]).map(Ve=>he&&Ve.id===he?{...Ve,selected:!0}:Ve),je=hU(fe,S.current,ee.current);je&&(j.preventDefault(),j.stopPropagation(),W.current=je,bJ(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(U){if(dt){j.preventDefault(),j.stopPropagation();return}if(!Se){j.preventDefault(),ge("Readonly workspace");return}const he=W.current||kJ();he&&!W.current&&(W.current=he);const fe=mU(he,C.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(vC(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Wf(!0);return}if(I==="g"&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),S0();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(),MS("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),MS("pan");return}(j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&(j.preventDefault(),v0())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[S0,dt,Xg,v0,GS,en,Jg,x,g,YS,Se]);const QL=h.useCallback(w=>{bl(j=>{const _=new Set(j);return _.has(w)?_.delete(w):_.add(w),_})},[]),ZL=h.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)},[]),e2=h.useCallback((w,j)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",j.id),w.dataTransfer.setData("text/plain",j.id)},[]),sp=h.useCallback(async(w,j)=>{const _=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),I=_.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(_)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(I)?"display_image":"display_markdown",U=at.find(fe=>fe.id===T);if(!U){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 G=T==="display_image"?"src":"content",le=id(U.inputs).map(fe=>fe.name===G?{...fe,default:J,value:J}:fe),he=id(U.outputs).map(fe=>fe.name===G?{...fe,default:J,value:J}:fe);qi(U,{label:w.name||"Display",body:J,inputs:le,outputs:he,position:j}),ge(`已创建展示:${w.path}`)},[qi,a,at]),t2=h.useCallback(w=>{if(!Se){ge("Readonly workspace");return}sp(w,Ll()).catch(j=>ge(String(j.message||j)))},[sp,Ll,Se]),n2=h.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});sp(X,J).catch(G=>ge(String(G.message||G)));return}const _=w.dataTransfer.getData("application/agentflow-snippet");if(_){const X=vt.find(G=>`${G.id}@${G.version}`===_);if(!X)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Eu(X,J);return}const I=w.dataTransfer.getData("application/agentflow-node");if(!I)return;const T=at.find(X=>X.id===I);if(!T)return;w.preventDefault();const U=r.screenToFlowPosition({x:w.clientX,y:w.clientY});qi(T,{position:U})},[sp,qi,vt,Eu,at,r,Se]),r2=h.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]),s2=h.useCallback(async(w="")=>{if(!Se){ge("Readonly workspace");return}const j=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!j)return;const _=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:_,content:""})}),T=await I.json();if(!I.ok)throw new Error(T.error||"创建文件失败");await Nn(),bl(U=>{const X=new Set(U);for(const J of Xp(T.path||_))X.delete(J);return X}),ge(`已创建 ${T.path}`)}catch(I){ge(String(I.message||I))}},[a,Nn,Se]),i2=h.useCallback(async(w="")=>{if(!Se){ge("Readonly workspace");return}const j=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!j)return;const _=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:_})}),T=await I.json();if(!I.ok)throw new Error(T.error||"创建文件夹失败");await Nn(),bl(U=>{const X=new Set(U);for(const J of Xp(T.path||_))X.delete(J);return T.path&&X.delete(T.path),X}),ge(`已创建 ${T.path}`)}catch(I){ge(String(I.message||I))}},[a,Nn,Se]),o2=h.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})}),_=await j.json();if(!j.ok)throw new Error(_.error||"删除失败");ge(`已删除 ${_.path}`),await Nn()}catch(j){ge(String(j.message||j))}},[a,Nn,Se]),a2=h.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const j=af(w.path,a,{download:!0});if(!j)return;const _=document.createElement("a");_.href=j,_.download=w.name||w.path.split("/").pop()||"download",_.rel="noopener",document.body.appendChild(_),_.click(),_.remove()},[a]),ip=h.useCallback(async()=>{if(!Se){ge("Readonly workspace");return}const w=xa.trim(),j=qr,_=Vs.find(X=>X.id===j)||null;if(!w||os||(_==null?void 0:_.status)==="running"||(_==null?void 0:_.status)==="stopping")return;const I=_?Array.isArray(_.messages)?_.messages:[]:ba,T=Kl(b,k,ee.current);Kg(""),AS(!0),jl(!0),Nl(null);const U={role:"user",text:w,at:Date.now()};_?Hn(X=>X.map(J=>J.id===j?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],U].slice(-180)}:J)):(Ns("workspace"),Sl(X=>[...X,U]));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:Wi,selectedSkills:Hs,selectedNodeIds:Qf,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()};_?Hn(he=>he.map(fe=>fe.id===j?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],le].slice(-180)}:fe)):Sl(he=>[...he,le]),await Cs(),ge("AI 生成完成")}catch(X){const J=String(X.message||X),G={role:"assistant",text:J,error:!0,at:Date.now()};_?Hn(le=>le.map(he=>he.id===j?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],G].slice(-180)}:he)):Sl(le=>[...le,G]),ge(J)}finally{AS(!1)}},[qr,ba,Wi,Vs,os,xa,k,a,Cs,b,en,Qf,Hs,Se]),ir=Vs.find(w=>w.id===qr)||null,fy=ir?Array.isArray(ir.messages)?ir.messages:[]:ba,Ol=ir&&(ir.status==="running"||ir.status==="stopping")||os,l2=nX(fy,Ol),py=rX(fy),$0=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":ba.length>0?"Workspace conversation":"Ready";h.useEffect(()=>{qr!=="workspace"&&(Vs.some(w=>w.id===qr)||Ns(Sa()))},[qr,Vs,Sa]),h.useEffect(()=>{if(!pu)return;const w=window.requestAnimationFrame(()=>{var _,I;const j=ES.current;j&&(j.scrollTop=j.scrollHeight),(I=(_=qg.current)==null?void 0:_.scrollIntoView)==null||I.call(_,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[fy.length,qr,$0,py.length,pu]);const c2=String(a.flowId||"").trim()||"Workspace",No=(rt==null?void 0:rt.mode)==="single-node",L0=No&&Au.find(w=>{var j;return w.id===rt.sourceNodeId||((j=rt.nodeIds)==null?void 0:j.includes(w.id))})||null,u2=No&&L0?[L0]:Au;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":"/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} · ${Xv}`:Xv||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:c2}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",cG,"-STABLE"]})]}),Mf?i.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",Mf.ownerUsername||Mf.ownerUserId]}):null,i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:d==="workspace"?"af-view-switch__active":"",onClick:()=>uy("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:d==="display"?"af-view-switch__active":"",onClick:()=>uy("display"),children:"Display"}),i.jsx("button",{type:"button",className:d==="workflow"?"af-view-switch__active":"",onClick:()=>uy("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${zS}`,title:`${qS} · ${BS}`,role:"status","aria-label":`${qS}:${BS}`,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?ya(!0):P0()},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||Pl.length===0,onClick:()=>pn(!0),title:Pl.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:EL,title:Tt!=null&&Tt.role&&Tt.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),Mf?null:i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:TL,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:!KS,onClick:()=>m(!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:!KS&&!bu,onClick:()=>v(!0),"aria-label":bu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:bu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:bu?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Wf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(pu?" af-composer-topbar-btn--active":"")+(os?" af-composer-topbar-btn--running":""),disabled:!Se||dt||Cn,onClick:()=>{Nl(null),jl(w=>(w||Ns(Sa()),!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"})]})]}),bs?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:bs}),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&&!Cn&&(pu||gt)?" af-workspace-body--drawer":"")+(!dt&&!Cn&&mu?" af-workspace-body--sidebar-collapsed":"")+(dt?" af-workspace-body--display-mode":"")+(Cn?" af-workspace-body--workflow-mode":""),children:[!dt&&!Cn&&mu?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:()=>Bf(!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:()=>Bf(!1),"aria-label":"展开侧边栏",title:(Lr==null?void 0:Lr.username)||(Lr==null?void 0:Lr.userId)||"展开侧边栏",children:NL})]})}):null,!dt&&!Cn?i.jsxs("aside",{ref:Og,className:"af-workspace-sidebar"+(V$?" af-workspace-sidebar--resizing":""),"aria-hidden":mu,style:{"--af-work-files-pane-height":`${Math.round(Dg)}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:()=>Bf(!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:()=>s2(Ki),"aria-label":"新增文件",title:Ki?`在 ${Ki} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>i2(Ki),"aria-label":"新增文件夹",title:Ki?`在 ${Ki} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se||aS,onClick:()=>c0(Ki),"aria-label":"上传文件",title:Ki?`上传到 ${Ki}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:aS?"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:cS,type:"file",multiple:!0,className:"af-visually-hidden",onChange:mL})]})]}),i.jsx("input",{className:"af-workspace-search",value:Tg,onChange:w=>W$(w.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:SL,children:i.jsx(IM,{items:vL,onOpen:t2,selectedPath:Mg,collapsedDirs:H$,onToggleDir:QL,onSelect:w=>$g(w.path||""),onFileDragStart:ZL,onDelete:o2,onDownload:a2})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:Z$,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:_L,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," 节点 / ",Zf.length," 连线"]})]})}),kn?i.jsx("p",{className:"af-err af-palette-list-err",children:kn}):null,Yn?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):A0.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:A0.map(w=>{const j=`${w.id}@${w.version}`,_=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:()=>Eu(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:_}),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:[Yl.map(w=>{var j;return(j=oy[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:oy[w].map(_=>{const I=GC(_.inputs,"input"),T=GC(_.outputs,"output"),U=Cb(_),X=rd(_);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>e2(J,_),onClick:()=>qi(_),title:U||_.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:UC(w)})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:X}),X!==_.id?i.jsx("span",{className:"af-palette-card-id",children:_.id}):null]})]}),U?i.jsx("span",{className:"af-palette-card-desc",children:U}):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,G)=>i.jsxs("span",{className:"af-palette-card-port",title:YC("input",J,G),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:Yp(J,G)})]},`in-${G}`)),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,G)=>i.jsxs("span",{className:"af-palette-card-port",title:YC("output",J,G),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Yp(J,G)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:En(J==null?void 0:J.type)}})]},`out-${G}`)),T.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",T.hidden]}):null]})]})]})]},_.id)})})]},w):null}),at.length>0&&Ie.trim()&&Yl.every(w=>{var j;return!((j=oy[w])!=null&&j.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,Cn?i.jsx(xX,{flowParams:a,tapdId:sr,setTapdId:J$,snapshot:sn,loading:X$,error:Q$,actionRunning:Fg,actionOutput:zg,pendingConfirm:js,conflict:du,reviewPublishing:Bg,onRefresh:()=>vu(sr),onRunDryRun:lL,onConfirmAction:cL,onRetryConflict:uL,onPublishReview:dL}):i.jsxs("main",{ref:N,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:w=>{XL(w),BL(w)},onLostPointerCaptureCapture:jo,children:[i.jsx(FR,{className:"af-flow-canvas af-workspace-flow"+(Qg==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(dt?" af-workspace-flow--display-mode":""),nodes:Xf,edges:bL,nodeTypes:YJ,onNodesChange:zL,onEdgesChange:VL,onMoveStart:WL,onMoveEnd:HL,onConnect:dt?void 0:qL,onConnectStart:dt?void 0:UL,onConnectEnd:dt?void 0:YL,isValidConnection:dt?void 0:KL,onNodeClick:(w,j)=>{var _;if(dt){V([Jp(j.id)]);return}if((_=j==null?void 0:j.data)!=null&&_.isWorkspaceGroup){Zt("");return}if(w.detail>=3){jl(!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:n2,onDragOver:dt?void 0:r2,nodesDraggable:Se,nodesConnectable:dt?!1:Se,edgesReconnectable:dt?!1:Se,onlyRenderVisibleElements:Xf.length>=80,deleteKeyCode:dt?null:Se?["Backspace","Delete"]:null,selectionOnDrag:Qg==="select",panOnDrag:Qg==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(BR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!dt&&Y?(()=>{var J;const w=String(Y.query||"").trim().toLowerCase(),j=Y.mode==="create"?"create":"existing",_=Array.isArray(Y.candidates)?Y.candidates:[],I=Array.isArray(Y.existingCandidates)?Y.existingCandidates:[],T=w?_.filter(G=>{var le,he,fe;return[(le=G.def)==null?void 0:le.id,G.displayLabel,G.description,(he=G.slot)==null?void 0:he.name,(fe=G.slot)==null?void 0:fe.type].filter(Boolean).some(je=>String(je).toLowerCase().includes(w))}):_,U=w?I.filter(G=>{var le,he;return[G.nodeId,G.nodeLabel,G.definitionId,(le=G.slot)==null?void 0:le.name,(he=G.slot)==null?void 0:he.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):I,X=Y.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:Y.left,top:Y.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=Y.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",Y.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(G=>G&&{...G,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:_.length===0,onClick:()=>ne(G=>G&&{...G,mode:"create",query:""}),children:["新建节点 ",i.jsx("span",{children:_.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:Y.query,onChange:G=>ne(le=>le&&{...le,query:G.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[j==="create"?T.map(G=>{var fe,je;const le=G.displayLabel||((fe=G.def)==null?void 0:fe.id),he=Yp(G.slot,G.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>GL(G),title:G.description||G.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!==G.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:G.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=G.slot)==null?void 0:je.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he})]})]},`${G.def.id}-${G.slotIndex}`)}):U.map(G=>{var fe;const le=G.nodeLabel||G.nodeId,he=Yp(G.slot,G.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>JL(G),title:`${G.definitionId||G.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:[G.definitionId?`${G.definitionId} · `:"",G.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=G.slot)==null?void 0:fe.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:he}),G.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${G.nodeId}-${G.handleId}`)}),(j==="create"?T.length:U.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!dt&&!Cn&&!rL?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:()=>Ug(!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,U;const j=String(((T=w.data)==null?void 0:T.label)??w.id),_=(U=w.data)!=null&&U.definitionId?String(w.data.definitionId):"",I=_&&_!==j?`${j} · ${w.id} · ${_}`:`${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:_||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:j}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>FL(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:xa,rows:2,onChange:w=>Kg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),ip())},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:Vg,type:"button",className:"af-composer-skills-button"+(Hs.length>0?" af-composer-skills-button--active":""),disabled:os||!Se,"aria-haspopup":"listbox","aria-expanded":zf,onClick:()=>Hg(w=>!w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Hs.length>0?`Skills ${Hs.length}`:"Skills"})]}),zf&&!os?lr.createPortal(i.jsx("div",{ref:CS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:tL,children:Ws.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[Tl.groups.map(w=>{const j=ia(w,Ws),_=rz(w,ay,Ws),I=eL.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:_==="all",disabled:j.length===0,onChange:T=>{const U=T.target.checked;uu(X=>U?tz(X,j):nz(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,_==="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:()=>{NS(T=>{const U=new Set(T);return U.has(w.id)?U.delete(w.id):U.add(w.id),U})},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:ay.has(T.key),onChange:U=>{const X=U.target.checked;uu(J=>X?J.includes(T.key)?J:[...J,T.key]:J.filter(G=>G!==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)}),Tl.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:Tl.ungrouped.length})]}),Tl.ungrouped.map(w=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:ay.has(w.key),onChange:j=>{const _=j.target.checked;uu(I=>_?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:Wi,onChange:w=>q$(w.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),jL.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(xa.trim()&&!os?" af-composer-send--active":"")+(os?" af-composer-send--stop":""),disabled:os||!xa.trim()||!Se,"aria-label":os?"Running":"Send",onClick:()=>void ip(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:os?"sync":"arrow_upward"})})]})]})]})}):!dt&&!Cn?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Ug(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!dt&&!Cn&&pu?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:()=>jl(!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"?qg:null,onClick:()=>Ns("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Vs.map(w=>i.jsxs("div",{role:"tab",tabIndex:0,ref:qr===w.id?qg: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:()=>Ns(w.id),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),Ns(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(),pL(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"+(Ol?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:$0}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:ES,children:[i.jsx(o_,{messages:l2,running:Ol,showRunningIndicator:!ir}),py.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",...Ol?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(o_,{messages:py,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:xa,rows:3,onChange:w=>Kg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),ip())},placeholder:ir?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!Se||Ol}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!Se||Ol||!xa.trim(),onClick:()=>void ip(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!dt&&!Cn&&gt&&Kt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(pY,{draft:gt,setDraft:Ss,definitionId:String(((O0=Kt.data)==null?void 0:O0.definitionId)||Kt.id),systemPromptReadonly:String(((D0=Kt.data)==null?void 0:D0.description)||""),modelLists:wa,disabled:!Se,onIdBlur:()=>ry(!0),onClose:()=>Zt(""),onPublishToMarketplace:fL,error:$$,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&&!Cn&&hu?lr.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>Nl(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:i.jsx(QU,{flowParams:a,scheduleNodeId:hu.scheduleNodeId,runNodeId:hu.runNodeId,lastRunId:hu.lastRunId,label:hu.label,onClose:()=>Nl(null)})})}),document.body):null,i.jsx(YU,{open:Jg,onClose:()=>Wf(!1)}),i.jsx(JU,{open:Xg,onClose:()=>TS(!1),onJump:iy,nodes:kL}),i.jsx(hY,{open:p,onClose:()=>m(!1),flowId:a.flowId||"",flowSource:xu,onArchived:()=>{m(!1),n("/projects?tab=archived")}}),i.jsx(mY,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:xu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:bu,onDeleted:async()=>{v(!1),n("/projects")}}),B$&&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"}),"解决 ",((F0=jn.conflictItems)==null?void 0:F0.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ya(!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:()=>xl(Object.fromEntries((jn.conflictItems||[]).map((w,j)=>[String(j),{mode:"local",manual:Vu(w)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>xl(Object.fromEntries((jn.conflictItems||[]).map((w,j)=>[String(j),{mode:"remote",manual:Vu(w)}]))),children:"全部使用远端"})]})]}),(jn.conflictItems||[]).map((w,j)=>{const _=Rg[String(j)]||{mode:"local",manual:Vu(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:_.mode===I?"is-active":"",onClick:()=>xl(U=>({...U,[String(j)]:{..._,mode:I}})),children:T},I))}),i.jsxs("div",{className:"af-workspace-conflict-values",children:[i.jsxs("div",{className:_.mode==="local"?"is-selected":"",children:[i.jsx("span",{children:"我的修改"}),i.jsx("pre",{children:m_(w,"incoming")})]}),i.jsxs("div",{className:_.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:m_(w,"current")})]})]}),_.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:_.manual,onChange:I=>xl(T=>({...T,[String(j)]:{..._,manual:I.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${j}`)}),oS?i.jsx("div",{className:"af-flow-snippet-error",children:oS}):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:Lf,onClick:()=>void P0(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Lf,onClick:()=>ya(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Lf||!(jn.conflictItems||[]).length,onClick:()=>void PL(),children:Lf?"保存中...":"应用选择并保存"})]})]})}),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(_=>({..._,name:j,id:_.id?_.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," 个节点和 ",Zf.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 AL(),children:is?"发布中...":"发布"})]})]})}),document.body):null,w0?i.jsx(LJ,{node:w0,onClose:()=>q("")}):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":No?"新建分享":"发布展示页",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"}),No?"新建分享":"发布展示页"]}),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:rt.title,onChange:w=>zt(j=>({...j,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),No?null:i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:rt.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:e_(rt),onChange:w=>{const j=w.target.value;zt(_=>({..._,permanent:j==="permanent",expiresInDays:j==="permanent"?_.expiresInDays||30:Number(j)}))},children:Sw.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":No?"分享内容":"选择展示节点",children:[No?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,u2.map(w=>{var _;const j=Array.isArray(rt.nodeIds)&&rt.nodeIds.includes(w.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:j,disabled:No,onChange:()=>RL(w.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((_=w.data)==null?void 0:_.label)||w.id}),i.jsxs("small",{children:[_n(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 R0(),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(rt.nodeIds)||rt.nodeIds.length===0,onClick:()=>void ML(),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 R0(),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:e_(rt),onChange:w=>{const j=w.target.value;zt(_=>({..._,permanent:j==="permanent",expiresInDays:j==="permanent"?_.expiresInDays||30:Number(j)}))},children:Sw.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 $L(),children:Wn?"生成中...":me!=null&&me.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,F$?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:()=>Eg(!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:Bs?Bs.name:"尚未加入团队"})]}),Bs?i.jsxs("div",{className:"af-workspace-team-share__actions",children:[i.jsxs("select",{value:Pg,onChange:w=>rS(w.target.value),"aria-label":"团队权限",children:[i.jsx("option",{value:"viewer",children:"只读"}),i.jsx("option",{value:"editor",children:"可编辑和运行"})]}),(z0=Tt==null?void 0:Tt.teamShares)!=null&&z0.some(w=>w.teamId===Bs.id)?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",disabled:au,onClick:()=>void dy(!1),children:au?"处理中...":"更新权限"}),i.jsx("button",{type:"button",disabled:au,onClick:()=>void dy(!0),children:"取消分享"})]}):i.jsx("button",{type:"button",disabled:au,onClick:()=>void dy(!1),children:au?"分享中...":"分享到团队"})]}):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:ou,onChange:w=>eS(w.target.value),onKeyDown:w=>{w.key==="Enter"&&ou.trim()&&!Ig&&(w.preventDefault(),I0())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:Ig||!ou.trim(),onClick:()=>void I0(),children:Ig?"添加中...":"添加成员"})]}),Zv?i.jsx("div",{className:"af-flow-snippet-error",children:Zv}):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:tS===w.userId,onClick:()=>void IL(w),children:tS===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:()=>Eg(!1),children:"完成"})})]})}),document.body):null,Yt?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:it.length?`${it.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void Ys(),disabled:Fs,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),zs?i.jsx("div",{className:"af-flow-snippet-error",children:zs}):null,Fs?i.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!Fs&&it.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:it.map(w=>{const j=n_(w),_=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:yJ(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:_,onChange:T=>void OL(w,T.target.value),"aria-label":"修改分享有效期",children:Sw.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 LL(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:_,onClick:()=>void DL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_?"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=>ks(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":_0.length||1},children:ep.length>0?_0.map((w,j)=>i.jsx("div",{className:"af-display-picker-column",children:w.map(CL)},`display-picker-column-${j}`)):i.jsx("div",{className:"af-display-picker-empty",children:Pl.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,cu.nodeId?lr.createPortal(i.jsx(tX,{files:yl,query:cu.query,onQueryChange:w=>Lg(j=>({...j,query:w})),onSelect:gL,onUpload:c0,onClose:ty}),document.body):null,!dt&&!Cn&&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:_S,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"?_u.length:Cu.length;rr(_=>Math.min(Math.max(0,j-1),_+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"?M0(_u[Sn]||_u[0]):T0(Cu[Sn]||Cu[0]))},placeholder:Ae==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ae==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:Ae==="flows"?_u.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:Yn?"正在加载流程片段...":kn||"没有匹配的流程片段"}):_u.map((w,j)=>{const _=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,U=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:()=>M0(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:_}),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||`${U} 节点 / ${X} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):Cu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Cu.map((w,j)=>{const _=nd(w),I=rd(w),T=Cb(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:()=>T0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:UC(_)}),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:_})]},w.id)})})]})}),document.body):null]})]})}function BM(){return i.jsx(tv,{children:i.jsx(kX,{})})}function vX(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 SX(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 jX(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 WM(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=jX(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 d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
270
+ `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
271
+ `).replace(/\s+$/g,""):d.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 Mv(e){let t=WM(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 NX(e){const t=Mv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function CX(e){const t=Mv(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 HM(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 _X(e,t,n={}){const r=String(e||"").trim();return r?HM(r,t,n):""}function AX({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),m=f>p+1,y=m?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=m?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:m,top:b,height:y})},[]);h.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const m of Array.from(f.children))p.observe(m);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=h.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=h.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),y=s.height/100*m.height,v=Math.max(1,m.height-y);return(d-m.top-f)/v},[s.height]),u=h.useCallback(d=>{if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),m=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+m&&d.clientY<=p.top+m+y?d.clientY-p.top-m:y/2;l(c(d.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 Rb({node:e,shareId:t,style:n,bare:r=!1}){const s=vX(e),o=e.kind==="html"?Mv(s):e.kind==="react"?bg(s):WM(s),a=e.kind==="html"?NX(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:SX(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(AX,{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:CX(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:jv(o)}):null,e.kind==="image"?i.jsx("img",{src:HM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(wv,{content:o,resolveSrc:(c,u)=>_X(c,t,u)})}):null,e.kind==="chart"?i.jsx(bv,{content:o}):null,e.kind==="table"?i.jsx(xv,{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 EX({data:e}){return i.jsx(Rb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const IX={publicDisplay:EX};function PX(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 VM(){var l,c,u,d;const{path:e}=rs(),t=h.useMemo(()=>PX(e),[e]),[n,r]=h.useState({loading:!0,error:"",share:null,nodes:[]});h.useEffect(()=>{let f=!1;async function p(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(m=>({...m,loading:!0,error:""}));try{const m=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await m.json().catch(()=>({}));if(!m.ok)throw new Error(y.error||"展示页不存在");f||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(m){f||r({loading:!1,error:String((m==null?void 0:m.message)||m),share:null,nodes:[]})}}return p(),()=>{f=!0}},[t]);const s=h.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((p,m)=>{const y=p.position&&typeof p.position.x=="number"&&typeof p.position.y=="number"?p.position:{x:120+m*40,y:100+m*32},v=p.size&&typeof p.size.width=="number"&&typeof p.size.height=="number"?p.size:{width:520,height:320};return{id:p.id,type:"publicDisplay",position:y,data:{node:p,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=h.useMemo(()=>{var v;const f=(v=n.share)==null?void 0:v.viewport;if(!f||typeof f!="object")return null;const p=Number(f.x),m=Number(f.y),y=Number(f.zoom);return!Number.isFinite(p)||!Number.isFinite(m)||!Number.isFinite(y)?null:{x:p,y:m,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(p=>i.jsx(Rb,{node:p,shareId:t,bare:!0},p.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:(d=n.share)!=null&&d.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>i.jsx(Rb,{node:p,shareId:t},p.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(tv,{children:i.jsx(FR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:IX,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(BR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const xt=e=>typeof e=="string",Ku=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},g_=e=>e==null?"":""+e,RX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},TX=/###/g,y_=e=>e&&e.indexOf("###")>-1?e.replace(TX,"."):e,w_=e=>!e||xt(e),Cd=(e,t,n)=>{const r=xt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(w_(e))return{};const o=y_(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return w_(e)?{}:{obj:e,k:y_(r[s])}},x_=(e,t,n)=>{const{obj:r,k:s}=Cd(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=Cd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Cd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},MX=(e,t,n,r)=>{const{obj:s,k:o}=Cd(e,t,Object);s[o]=s[o]||[],s[o].push(n)},Im=(e,t)=>{const{obj:n,k:r}=Cd(e,t);if(n)return n[r]},$X=(e,t,n)=>{const r=Im(e,n);return r!==void 0?r:Im(t,n)},KM=(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]):KM(e[r],t[r],n):e[r]=t[r]);return e},ql=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var LX={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const OX=e=>xt(e)?e.replace(/[&<>"'\/]/g,t=>LX[t]):e;class DX{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 FX=[" ",",","?","!",";"],zX=new DX(20),BX=(e,t,n)=>{t=t||"",n=n||"";const r=FX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=zX.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},Tb=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},Pm=e=>e&&e.replace("_","-"),WX={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 Rm{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||WX,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 Rm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Rm(this.logger,t)}}var Ei=new Rm;class Sg{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 b_ extends Sg{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=Im(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:Tb(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),x_(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=Im(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?KM(c,r,o):c={...c,...r},x_(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 qM={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 k_={};class Tm extends Sg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),RX(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ei.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&&!BX(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,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(d){const C=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${C}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${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 p=f&&f.res;const m=f&&f.usedKey||a,y=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(p),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(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&x&&b.indexOf(v)<0&&!(xt(g)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const C=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=C,f.usedParams=this.getUsedParamsDetails(n),f):C}if(o){const C=Array.isArray(p),S=C?[]:{},N=C?y:m;for(const P in p)if(Object.prototype.hasOwnProperty.call(p,P)){const R=`${N}${o}${P}`;S[P]=this.translate(R,{...n,joinArrays:!1,ns:l}),S[P]===R&&(S[P]=p[P])}p=S}}else if(k&&xt(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let C=!1,S=!1;const N=n.count!==void 0&&!xt(n.count),P=Tm.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(p)&&P&&(C=!0,p=O),this.isValidLookup(p)||(S=!0,p=a);const L=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&S?void 0:p,M=P&&O!==p&&this.options.updateMissing;if(S||C||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?O:p),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!==p?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,p)};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))}p=this.extendTranslation(p,t,n,f,r),S&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(S||C)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,C?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}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 d;if(u){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.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 p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;d<m&&(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 p=arguments.length,m=new Array(p),y=0;y<p;y++)m[y]=arguments[y];return o&&o[0]===m[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${n[0]}`),null):a.translate(...m,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=qM.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),d=u.key;s=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!xt(n.count),m=p&&!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,!k_[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(k_[`${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=[d];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,d,g,b,n);else{let C;p&&(C=this.pluralResolver.getSuffix(g,n.count,n));const S=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(d+C),n.ordinal&&C.indexOf(N)===0&&k.push(d+C.replace(N,this.options.pluralSeparator)),m&&k.push(d+S)),y){const P=`${d}${this.options.contextSeparator}${n.context}`;k.push(P),p&&(k.push(P+C),n.ordinal&&C.indexOf(N)===0&&k.push(P+C.replace(N,this.options.pluralSeparator)),m&&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 Cw=e=>e.charAt(0).toUpperCase()+e.slice(1);class v_{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ei.create("languageUtils")}getScriptPartFromCode(t){if(t=Pm(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=Pm(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]=Cw(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]=Cw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Cw(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 HX=[{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}],VX={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 KX=["v1","v2","v3"],qX=["v4"],S_={zero:0,one:1,two:2,few:3,many:4,other:5},UX=()=>{const e={};return HX.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:VX[t.fc]}})}),e};class YX{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Ei.create("pluralResolver"),(!this.options.compatibilityJSON||qX.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=UX(),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=Pm(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)=>S_[s]-S_[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!KX.includes(this.options.compatibilityJSON)}}const j_=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=$X(e,t,n);return!o&&s&&xt(n)&&(o=Tb(e,n,r),o===void 0&&(o=Tb(t,n,r))),o},_w=e=>e.replace(/\$/g,"$$$$");class GX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ei.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:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:OX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?ql(o):a||"{{",this.suffix=l?ql(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?ql(p):m||ql("$t("),this.nestingSuffix=y?ql(y):v||ql(")"),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=m=>{if(m.indexOf(this.formatSeparator)<0){const g=j_(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...s,...n,interpolationkey:m}):g}const y=m.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(j_(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...s,...n,interpolationkey:v})};this.resetRegExp();const d=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:m=>_w(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?_w(this.escape(m)):_w(m)}].forEach(m=>{for(l=0;o=m.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof d=="function"){const b=d(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=g_(a));const v=m.safeValue(a);if(t=t.replace(o[0],v),f?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=o[0].length):m.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 d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const m=p.match(/'/g),y=p.match(/"/g);(m&&m.length%2===0&&!y||y.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${p}`}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 d=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=d.shift(),c=d,u=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!xt(o))return o;xt(o)||(o=g_(o)),o||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:s[1].trim()}),o.trim())),t=t.replace(s[0],o),this.regexp.lastIndex=0}return t}}const JX=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,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Ul=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(Pm(r),s),t[a]=l),l(n)}};class XX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ei.create("formatter"),this.options=t,this.formats={number:Ul((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Ul((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Ul((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Ul((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Ul((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()]=Ul(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:d}=JX(c);if(this.formats[u]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[u](l,m,{...d,...s,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const QX=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class ZX extends Sg{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=Ei.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 d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,d=!1,a[p]===void 0&&(a[p]=!0),o[p]===void 0&&(o[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(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=>{MX(c.loaded,[o],a),QX(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.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,d)=>{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&&d&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).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 d;u.length===5?d=u(t,n,r,s,c):d=u(t,n,r,s),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const N_=()=>({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}}),C_=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),Qp=()=>{},eQ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class cf extends Sg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=C_(t),this.services={},this.logger=Ei,this.modules={external:[]},eQ(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=N_();this.options={...s,...this.options,...C_(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=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Ei.init(o(this.modules.logger),this.options):Ei.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:typeof Intl<"u"&&(d=XX);const f=new v_(this.options);this.store=new b_(this.options.resources,this.options);const p=this.services;p.logger=Ei,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new YX(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=o(d),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new GX(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new ZX(o(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(m){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(m,...v)}),this.modules.languageDetector&&(p.languageDetector=o(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=o(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Tm(this.services,this.options),this.translator.on("*",function(m){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(m,...v)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Qp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[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(d=>{this[d]=function(){return t.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return t.store[d](...arguments),t}});const c=Ku(),u=()=>{const d=(f,p)=>{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(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};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]:Qp;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=Ku();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=Qp),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"&&qM.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=Ku();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,d=>{a(d,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,d=new Array(u>2?u-2:0),f=2;f<u;f++)d[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(d))}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 p=s.options.keySeparator||".";let m;return c.keyPrefix&&Array.isArray(a)?m=a.map(y=>`${c.keyPrefix}${p}${y}`):m=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(m,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=Ku();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=Ku();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 v_(N_());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 cf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new cf(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 b_(this.store.data,s),o.services.resourceStore=o.store),o.translator=new Tm(o.services,s),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];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=cf.createInstance();kr.createInstance=cf.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 tQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function uf(e){"@babel/helpers - typeof";return uf=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},uf(e)}function nQ(e,t){if(uf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(uf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function rQ(e){var t=nQ(e,"string");return uf(t)=="symbol"?t:t+""}function sQ(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,rQ(r.key),r)}}function iQ(e,t,n){return t&&sQ(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var UM=[],oQ=UM.forEach,aQ=UM.slice;function lQ(e){return oQ.call(aQ.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var __=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,cQ=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(!__.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!__.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},A_={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=cQ(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)}},uQ={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=A_.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&A_.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},dQ={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,E_=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},fQ={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&E_()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&E_()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Uu=null,I_=function(){if(Uu!==null)return Uu;try{Uu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Uu=!1}return Uu},pQ={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&I_()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&I_()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},hQ={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}},mQ={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}},gQ={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}},yQ={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]}},YM=!1;try{document.cookie,YM=!0}catch{}var GM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];YM||GM.splice(1,1);function wQ(){return{order:GM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var JM=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};tQ(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return iQ(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=lQ(r,this.options||{},wQ()),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(uQ),this.addDetector(dQ),this.addDetector(fQ),this.addDetector(pQ),this.addDetector(hQ),this.addDetector(mQ),this.addDetector(gQ),this.addDetector(yQ)}},{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)}))}}])}();JM.type="languageDetector";const xQ={name:"AgentFlow",tagline:"AI Workflow Orchestration"},bQ={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},kQ={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"},vQ={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},SQ={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},jQ={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},NQ={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},CQ={app:xQ,nav:bQ,common:kQ,status:vQ,nodeTypes:SQ,engine:jQ,links:NQ},_Q="Flow Editor",AQ="Nodes",EQ="Edges",IQ="Properties",PQ={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"},RQ={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}}"},TQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},MQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},$Q={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"},LQ={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)"},OQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},DQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},FQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},zQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},BQ={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"},WQ={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"},HQ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},VQ={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."},KQ={mainNav:"Main Navigation"},qQ={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'},UQ={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}}"},YQ={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"},GQ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},JQ={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}}"},XQ={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"},QQ={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"},ZQ={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"},eZ={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"},tZ={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"},nZ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},rZ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},sZ={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"},iZ={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."},oZ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},aZ={save:"Save",cancel:"Cancel"},lZ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},cZ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},uZ={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"},dZ={title:_Q,nodes:AQ,edges:EQ,properties:IQ,node:PQ,nodeProps:RQ,actions:TQ,panel:MQ,palette:$Q,pipeline:LQ,status:OQ,roles:DQ,phases:FQ,types:zQ,runContext:BQ,shortcuts:WQ,jumpPalette:HQ,emptyCanvas:VQ,sidebar:KQ,validation:qQ,composer:UQ,topbar:YQ,palette2:GQ,run:JQ,fileEdit:XQ,settings:QQ,schedule:ZQ,history:eZ,nodePropsError:tZ,placeholder:nZ,time:rZ,userCheck:sZ,userAsk:iZ,toolPrint:oZ,provideEdit:aZ,runParams:lZ,runPreset:cZ,runConfig:uZ},fZ="Settings",pZ={engine:"Engine Settings",preferences:"Global Preferences"},hZ={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)."},mZ={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..."}},gZ={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."},yZ={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."},wZ={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."},xZ={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)"},bZ={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"},kZ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},vZ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},SZ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},jZ={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."},NZ={title:fZ,crumb:pZ,workspace:hZ,cursor:mZ,opencode:gZ,claudeCode:yZ,codex:wZ,env:xZ,allowlist:bZ,system:kZ,shortcuts:vZ,language:SZ,onboarding:jZ},CZ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},_Z={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)"},AZ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},EZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},IZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},PZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},RZ={aiLabels:CZ,placeholders:_Z,actions:AZ,labels:EZ,tooltips:IZ,rightPanel:PZ},TZ="Projects",MZ="All",$Z="Archived",LZ="Nodes",OZ="My Nodes",DZ="My Flows",FZ="Skills",zZ="Active Projects",BZ="Archived Pipelines",WZ="Global Nodes",HZ="All Nodes",VZ="My Nodes",KZ="Manage node versions published to the current workspace marketplace, {{count}} total.",qZ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",UZ="Global Skills",YZ="Create New Project",GZ="New Pipeline",JZ="SEARCH PIPELINES...",XZ="SEARCH NODES...",QZ="SEARCH FLOW SNIPPETS...",ZZ="SEARCH SKILLS...",eee="Refresh Resources",tee="Loading pipelines...",nee="Loading global resources...",ree="Filter result: {{count}} items (matching title, description, path and tags)",see="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",iee="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",oee="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",aee="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",lee="Executable building blocks for pipeline runtime",cee="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.",uee="Published local node packages",dee="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",fee="Published flow snippets",pee="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",hee="Operating guides for Composer and agents",mee="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",gee="No archived projects.",yee="No active pipelines; archived items are in the Archived tab.",wee="No global nodes available.",xee="No marketplace nodes have been published.",bee="No flow snippets have been published. Select multiple canvas nodes and publish them first.",kee="No skills available.",vee="No description.",See='No node matches "{{query}}".',jee='No flow snippet matches "{{query}}".',Nee='No skill matches "{{query}}".',Cee="{{inputs}} in / {{outputs}} out",_ee="Flow Snippet",Aee="{{nodes}} nodes / {{edges}} edges",Eee="Skill",Iee="Node detail",Pee="Flow snippet detail",Ree="Skill detail",Tee="Type",Mee="Source",$ee="Package",Lee="Version",Oee="Path",Dee="Editable",Fee="Read only",zee="Editable",Bee="Schema",Wee="Inputs",Hee="Outputs",Vee="Runtime",Kee="Node Body",qee="Files",Uee="Usage",Yee="No runtime manifest.",Gee="No node body or README.",Jee="No previewable files.",Xee="Select a file to preview.",Qee="Binary file preview is not supported.",Zee="Large file; showing the first 256KB only.",ete="No pipelines using this node were found.",tte="Node Management",nte="Delete Node Version",rte="Deleting...",ste="AgentFlow checks all flow references before deleting; installed or used versions are kept.",ite="Delete {{id}}@{{version}}? This cannot be undone.",ote="Deleted {{id}}@{{version}}.",ate="{{count}} flow(s) still use it.",lte="Flow Snippet Management",cte="Delete Flow Snippet",ute="Deleting...",dte="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",fte="Delete {{id}}@{{version}}? This cannot be undone.",pte="Deleted {{id}}@{{version}}.",hte="No slots",mte="Purpose",gte="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",yte="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.",wte="Scale",xte="Flow Preview",bte="Edges",kte="Snippet JSON",vte="{{count}} more edge(s)",Ste="No previewable nodes.",jte="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Nte="SKILL.md Preview",Cte="No preview content available.",_te="Select a resource to inspect details.",Ate="Failed to load pipeline list.",Ete="No pipelines in current workspace.",Ite="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.",Pte='No pipelines found matching "{{query}}". Try different keywords or clear the search.',Rte="Recent Activity",Tte="No recent activity",Mte="No recent activity matching the keyword",$te="Recent Run",Lte="Recent Open",Ote={builtin:"Built-in",workspace:"Workspace",user:"User"},Dte={flow:"Flow",global:"Global",marketplace:"Marketplace"},Fte={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},zte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Bte="Open to edit this pipeline in the node canvas.",Wte={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>"},Hte={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"},Vte={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"},Kte={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"},qte={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"},Ute={title:TZ,all:MZ,archived:$Z,nodes:LZ,myNodes:OZ,myFlows:DZ,skills:FZ,activeProjects:zZ,archivedPipelines:BZ,globalNodes:WZ,nodeScopeAll:HZ,nodeScopeMine:VZ,myNodesHint:KZ,myFlowsHint:qZ,globalSkills:UZ,createNew:YZ,newPipeline:GZ,searchPipelines:JZ,searchNodes:XZ,searchFlows:QZ,searchSkills:ZZ,refreshResources:eee,loadingPipelines:tee,loadingResources:nee,filterResult:ree,archivedHint:see,activeHint:iee,nodesHint:oee,skillsHint:aee,nodesPurposeTitle:lee,nodesPurposeDesc:cee,myNodesPurposeTitle:uee,myNodesPurposeDesc:dee,myFlowsPurposeTitle:fee,myFlowsPurposeDesc:pee,skillsPurposeTitle:hee,skillsPurposeDesc:mee,noArchived:gee,noActive:yee,noNodes:wee,noMyNodes:xee,noMyFlows:bee,noSkills:kee,noDescription:vee,noNodeMatch:See,noFlowSnippetMatch:jee,noSkillMatch:Nee,nodeSlots:Cee,flowSnippet:_ee,flowSnippetNodes:Aee,skill:Eee,nodeDetail:Iee,flowDetail:Pee,skillDetail:Ree,detailType:Tee,detailSource:Mee,detailPackage:$ee,detailVersion:Lee,detailPath:Oee,detailEditable:Dee,readOnly:Fee,editable:zee,nodeSchema:Bee,nodeInputs:Wee,nodeOutputs:Hee,nodeRuntime:Vee,nodeBody:Kee,nodeFiles:qee,nodeUsage:Uee,noRuntimeManifest:Yee,noNodeBody:Gee,noNodeFiles:Jee,selectNodeFile:Xee,binaryFile:Qee,fileTruncated:Zee,noNodeUsage:ete,myNodeManagement:tte,deleteMyNode:nte,deletingMyNode:rte,deleteMyNodeHint:ste,deleteMyNodeConfirm:ite,deleteMyNodeSuccess:ote,deleteMyNodeUsedBy:ate,myFlowManagement:lte,deleteMyFlow:cte,deletingMyFlow:ute,deleteMyFlowHint:dte,deleteMyFlowConfirm:fte,deleteMyFlowSuccess:pte,noSlots:hte,resourceMeaning:mte,nodesMeaning:gte,myFlowsMeaning:yte,flowSnippetScale:wte,flowSnippetPreview:xte,flowSnippetEdges:bte,flowSnippetJson:kte,flowSnippetMoreEdges:vte,noFlowSnippetPreview:Ste,skillsMeaning:jte,skillPreview:Nte,skillPreviewEmpty:Cte,selectResource:_te,loadFailed:Ate,noPipelines:Ete,emptyHint:Ite,noMatch:Pte,recentActivity:Rte,noRecentActivity:Tte,noMatchRecent:Mte,recentRun:$te,recentOpen:Lte,sourceBadge:Ote,resourceSource:Dte,resourceFilter:Fte,nodeDetailTabs:zte,defaultCardDesc:Bte,hubCard:Wte,newPipelineModal:Hte,importModal:Vte,deleteModal:Kte,archiveModal:qte},Yte="Back",Gte="Next",Jte="Skip",Xte="Done",Qte="Start Creating",Zte={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.`},ene={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.`},tne={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"},nne={back:Yte,next:Gte,skip:Jte,done:Xte,startCreate:Qte,projects:Zte,flow:ene,newPipeline:tne},rne={name:"AgentFlow",tagline:"AI 工作流编排"},sne={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},ine={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},one={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},ane={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},lne={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},cne={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},une={app:rne,nav:sne,common:ine,status:one,nodeTypes:ane,engine:lne,links:cne},dne="流程编辑器",fne="节点",pne="连线",hne="属性",mne={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:"编辑内容"},gne={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}}"},yne={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},wne={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},xne={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},bne={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},kne={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},vne={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},Sne={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},jne={node:"节点",text:"文本",file:"文件",bool:"布尔"},Nne={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:"等待"},Cne={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},_ne={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},Ane={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},Ene={mainNav:"主导航"},Ine={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Pne={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}}"},Rne={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},Tne={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Mne={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}} 的分支"},$ne={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Lne={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:"已复制"},One={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:"定时配置已保存"},Dne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},Fne={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},zne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Bne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},Wne={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},Hne={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},Vne={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},Kne={save:"保存",cancel:"取消"},qne={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},Une={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},Yne={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},Gne={title:dne,nodes:fne,edges:pne,properties:hne,node:mne,nodeProps:gne,actions:yne,panel:wne,palette:xne,pipeline:bne,status:kne,roles:vne,phases:Sne,types:jne,runContext:Nne,shortcuts:Cne,jumpPalette:_ne,emptyCanvas:Ane,sidebar:Ene,validation:Ine,composer:Pne,topbar:Rne,palette2:Tne,run:Mne,fileEdit:$ne,settings:Lne,schedule:One,history:Dne,nodePropsError:Fne,placeholder:zne,time:Bne,userCheck:Wne,userAsk:Hne,toolPrint:Vne,provideEdit:Kne,runParams:qne,runPreset:Une,runConfig:Yne},Jne="设置",Xne={engine:"引擎设置",preferences:"全局首选项"},Qne={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},Zne={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},ere={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},tre={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},nre={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},rre={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},sre={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:"添加"},ire={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},ore={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},are={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},lre={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},cre={title:Jne,crumb:Xne,workspace:Qne,cursor:Zne,opencode:ere,claudeCode:tre,codex:nre,env:rre,allowlist:sre,system:ire,shortcuts:ore,language:are,onboarding:lre},ure={thinking:"思考",result:"结果",reply:"回复",error:"错误"},dre={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},fre={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},pre={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},hre={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},mre={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},gre={aiLabels:ure,placeholders:dre,actions:fre,labels:pre,tooltips:hre,rightPanel:mre},yre="项目",wre="全部",xre="已归档",bre="Nodes",kre="我的 Nodes",vre="我的流程",Sre="Skills",jre="活跃项目",Nre="已归档流水线",Cre="全局 Nodes",_re="全部 Nodes",Are="我的 Nodes",Ere="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Ire="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Pre="全局 Skills",Rre="创建新项目",Tre="新建流水线",Mre="搜索流水线…",$re="搜索 nodes…",Lre="搜索流程片段…",Ore="搜索 skills…",Dre="刷新资源",Fre="加载流水线列表…",zre="加载全局资源…",Bre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",Wre="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",Hre="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",Vre="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",Kre="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",qre="流程运行时的可执行积木",Ure="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",Yre="已发布的本地节点包",Gre="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",Jre="已发布的流程片段",Xre="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",Qre="Composer/Agent 的操作指南",Zre="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",ese="暂无归档项目。",tse="暂无未归档流水线;已归档项在 Archived 标签中查看。",nse="暂无可用全局 nodes。",rse="暂无已发布的 marketplace nodes。",sse="暂无已发布的流程片段。可在画布中选中多个节点后发布。",ise="暂无可用 skills。",ose="暂无描述。",ase="未找到与「{{query}}」匹配的 node。",lse="未找到与「{{query}}」匹配的流程片段。",cse="未找到与「{{query}}」匹配的 skill。",use="{{inputs}} in / {{outputs}} out",dse="流程片段",fse="{{nodes}} 节点 / {{edges}} 连线",pse="Skill",hse="Node 详情",mse="流程片段详情",gse="Skill 详情",yse="类型",wse="来源",xse="包",bse="版本",kse="路径",vse="可编辑",Sse="只读",jse="可编辑",Nse="Schema",Cse="输入",_se="输出",Ase="Runtime",Ese="节点内容",Ise="Files",Pse="Usage",Rse="暂无 runtime manifest。",Tse="暂无节点正文或 README。",Mse="暂无可预览文件。",$se="请选择文件查看内容。",Lse="二进制文件暂不支持预览。",Ose="文件较大,仅显示前 256KB。",Dse="暂未发现使用此 node 的流水线。",Fse="节点管理",zse="删除节点版本",Bse="删除中…",Wse="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",Hse="确定删除 {{id}}@{{version}}?此操作不可撤销。",Vse="已删除 {{id}}@{{version}}。",Kse="仍有 {{count}} 个 Flow 使用它。",qse="流程片段管理",Use="删除流程片段",Yse="删除中…",Gse="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",Jse="确定删除 {{id}}@{{version}}?此操作不可撤销。",Xse="已删除 {{id}}@{{version}}。",Qse="无槽位",Zse="作用",eie="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",tie="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",nie="规模",rie="流程预览",sie="连线",iie="片段 JSON",oie="还有 {{count}} 条连线",aie="暂无可预览节点。",lie="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",cie="SKILL.md 预览",uie="暂无可预览内容。",die="请选择一个资源查看详情。",fie="未能加载流水线列表。",pie="当前工作区暂无流水线。",hie="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",mie="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",gie="最近打开或最近运行",yie="暂无打开或运行记录",wie="暂无与关键词匹配的最近记录",xie="最近运行",bie="最近打开",kie={builtin:"内置",workspace:"工作区",user:"用户"},vie={flow:"Flow",global:"Global",marketplace:"Marketplace"},Sie={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},jie={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Nie="打开以在节点画布中编辑此流水线。",Cie={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},_ie={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:"关闭"},Aie={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Eie={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Iie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Pie={title:yre,all:wre,archived:xre,nodes:bre,myNodes:kre,myFlows:vre,skills:Sre,activeProjects:jre,archivedPipelines:Nre,globalNodes:Cre,nodeScopeAll:_re,nodeScopeMine:Are,myNodesHint:Ere,myFlowsHint:Ire,globalSkills:Pre,createNew:Rre,newPipeline:Tre,searchPipelines:Mre,searchNodes:$re,searchFlows:Lre,searchSkills:Ore,refreshResources:Dre,loadingPipelines:Fre,loadingResources:zre,filterResult:Bre,archivedHint:Wre,activeHint:Hre,nodesHint:Vre,skillsHint:Kre,nodesPurposeTitle:qre,nodesPurposeDesc:Ure,myNodesPurposeTitle:Yre,myNodesPurposeDesc:Gre,myFlowsPurposeTitle:Jre,myFlowsPurposeDesc:Xre,skillsPurposeTitle:Qre,skillsPurposeDesc:Zre,noArchived:ese,noActive:tse,noNodes:nse,noMyNodes:rse,noMyFlows:sse,noSkills:ise,noDescription:ose,noNodeMatch:ase,noFlowSnippetMatch:lse,noSkillMatch:cse,nodeSlots:use,flowSnippet:dse,flowSnippetNodes:fse,skill:pse,nodeDetail:hse,flowDetail:mse,skillDetail:gse,detailType:yse,detailSource:wse,detailPackage:xse,detailVersion:bse,detailPath:kse,detailEditable:vse,readOnly:Sse,editable:jse,nodeSchema:Nse,nodeInputs:Cse,nodeOutputs:_se,nodeRuntime:Ase,nodeBody:Ese,nodeFiles:Ise,nodeUsage:Pse,noRuntimeManifest:Rse,noNodeBody:Tse,noNodeFiles:Mse,selectNodeFile:$se,binaryFile:Lse,fileTruncated:Ose,noNodeUsage:Dse,myNodeManagement:Fse,deleteMyNode:zse,deletingMyNode:Bse,deleteMyNodeHint:Wse,deleteMyNodeConfirm:Hse,deleteMyNodeSuccess:Vse,deleteMyNodeUsedBy:Kse,myFlowManagement:qse,deleteMyFlow:Use,deletingMyFlow:Yse,deleteMyFlowHint:Gse,deleteMyFlowConfirm:Jse,deleteMyFlowSuccess:Xse,noSlots:Qse,resourceMeaning:Zse,nodesMeaning:eie,myFlowsMeaning:tie,flowSnippetScale:nie,flowSnippetPreview:rie,flowSnippetEdges:sie,flowSnippetJson:iie,flowSnippetMoreEdges:oie,noFlowSnippetPreview:aie,skillsMeaning:lie,skillPreview:cie,skillPreviewEmpty:uie,selectResource:die,loadFailed:fie,noPipelines:pie,emptyHint:hie,noMatch:mie,recentActivity:gie,noRecentActivity:yie,noMatchRecent:wie,recentRun:xie,recentOpen:bie,sourceBadge:kie,resourceSource:vie,resourceFilter:Sie,nodeDetailTabs:jie,defaultCardDesc:Nie,hubCard:Cie,newPipelineModal:_ie,importModal:Aie,deleteModal:Eie,archiveModal:Iie},Rie="返回",Tie="下一步",Mie="跳过",$ie="完成",Lie="开始创建",Oie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
303
+
304
+ 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
305
+
306
+ 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Die={intro:`现在进入流程编辑器。
307
+
308
+ 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
309
+
310
+ 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
311
+
312
+ 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
313
+
314
+ 左侧节点面板可以自由拖拽、删除和调整连接。`},Fie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},zie={back:Rie,next:Tie,skip:Mie,done:$ie,startCreate:Lie,projects:Oie,flow:Die,newPipeline:Fie},Bie={en:{common:CQ,flow:dZ,settings:NZ,composer:RZ,project:Ute,onboarding:nne},zh:{common:une,flow:Gne,settings:cre,composer:gre,project:Pie,onboarding:zie}};kr.use(JM).use(tF).init({resources:Bie,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 Wie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Hie(e){return kr.changeLanguage(e)}const Mb="agentflow-settings-opencode-plan-v1",od="CURSOR_API_KEYS",ad="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",Aw=new Set([od,ad,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),XM=["cursor","opencode","claudeCode","codex"];function QM(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function $b(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function _a(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of XM)n[r]=Array.isArray(t[r])?[...new Set(t[r].map($b).filter(Boolean))]:[];return n}function Gi(e){if(!e||typeof e!="object")return QM();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 _c(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Vie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ta(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()||_c(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function P_(e){return Ta(e).map(({key:t,value:n})=>({key:t,value:n}))}function R_(){try{return localStorage.getItem(Mb)??""}catch{return""}}function ZM(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function Kie(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()||_c(),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 T_(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||_c(),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 qie(e){const t=String(e||"").trim();return t?t.length<=10?ZM(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function Uie(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 Yie({authUser:e}){const{t,i18n:n}=Vr(["common","settings"]),r=n.language||"zh",[s,o]=h.useState(""),[a,l]=h.useState(""),[c,u]=h.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[d,f]=h.useState(QM()),[p,m]=h.useState(()=>_a({})),[y,v]=h.useState(!1),[b,g]=h.useState(""),[k,x]=h.useState(""),[C,S]=h.useState(!1),[N,P]=h.useState(!1),[R,z]=h.useState(""),[E,O]=h.useState([]),[D,L]=h.useState(""),[M,V]=h.useState(!1),[B,F]=h.useState(""),[$,H]=h.useState(""),[A,Q]=h.useState(!1),[K,W]=h.useState(()=>new Set),[te,Z]=h.useState(""),[Y,ne]=h.useState(""),[re,se]=h.useState(!!(e!=null&&e.isAdmin)),[ee,ue]=h.useState(""),[de,pe]=h.useState([]),[Me,Ne]=h.useState([]),[Ce,He]=h.useState(""),[ct,yt]=h.useState(""),[Re,ot]=h.useState(!1),[kt,$t]=h.useState(!1),[ye,ze]=h.useState(""),[oe,ke]=h.useState(""),[Be,Qe]=h.useState(""),[_e,_t]=h.useState(null),[Xt,Ft]=h.useState(!1),[at,Fn]=h.useState(!1),[ie,Ie]=h.useState(""),et=h.useRef(null),qe=h.useRef(!1),Pt=h.useRef(!1),vt=h.useRef(""),tr=h.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("")}},[]),Yn=h.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(Gi(ve.modelLists)),f(Gi(ve.allModelLists)),m(_a(ve.hiddenModels));else{const Te=Gi(ve);u(Te),f(Te),m(_a({}))}}catch(ae){x(String(ae.message||ae))}finally{S(!1)}},[e==null?void 0:e.isAdmin]),Tr=h.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=Ta(Array.isArray(ve.env)?ve.env:[],"user").map(Qt=>({...Qt,scope:"user"})),Rt=[...e!=null&&e.isAdmin?Ta(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=h.useCallback(async()=>{if(e!=null&&e.isAdmin){ot(!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{ot(!1)}}},[e==null?void 0:e.isAdmin]),nr=h.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=h.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:{};_t(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=h.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:{};_t(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=h.useCallback(async ae=>{const ve=Ta(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:P_(Te),...e!=null&&e.isAdmin?{globalEnv:P_(bt)}:{}})}),Qt=await Rt.json().catch(()=>({}));if(!Rt.ok)throw new Error(typeof Qt.error=="string"?Qt.error:"HTTP "+Rt.status);const pn=Ta(Array.isArray(Qt.env)?Qt.env:[],"user").map(vs=>({...vs,scope:"user"})),ks=[...e!=null&&e.isAdmin?Ta(Array.isArray(Qt.globalEnv)?Qt.globalEnv:[],"global").map(vs=>({...vs,scope:"global"})):[],...pn];vt.current=JSON.stringify(ks),O(ks)}catch(Rt){L(String(Rt.message||Rt))}finally{V(!1)}},[e==null?void 0:e.isAdmin]),zn=h.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(Gi(ve.modelLists)),e!=null&&e.isAdmin?await Yn():f(Gi(ve.modelLists))}catch(ae){x(String(ae.message||ae))}finally{S(!1)}},[e==null?void 0:e.isAdmin,Yn,ee]),is=h.useCallback(async ae=>{if(!(e!=null&&e.isAdmin))return;const ve=_a(ae);m(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(Gi(bt.modelLists)),f(Gi(bt.allModelLists)),m(_a(bt.hiddenModels))}catch(Te){g(String(Te.message||Te)),Yn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,Yn]),Ds=h.useCallback((ae,ve,Te)=>{const bt=XM.includes(ae)?ae:"cursor",Rt=$b(ve);if(!Rt)return;const Qt=_a(p),pn=new Set(Qt[bt]);Te?pn.delete(Rt):pn.add(Rt),is({...Qt,[bt]:Array.from(pn)})},[p,is]);h.useEffect(()=>{Tr(),e!=null&&e.isAdmin?(tr(),Yn(),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(Mb,Te)}catch{}}else{const ve=R_();ue(ve),et.current=ve}}catch{const ae=R_();ue(ae),et.current=ae}finally{qe.current=!0}})()):(o(""),qe.current=!1)},[e==null?void 0:e.isAdmin,tr,Yn,pr,kn,Tr]),h.useEffect(()=>{if(!Pt.current||JSON.stringify(Ta(E))===vt.current)return;const ve=setTimeout(()=>{fn(E)},350);return()=>clearTimeout(ve)},[E,fn]),h.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(Mb,ae)}catch{}bt.modelLists&&(u(Gi(bt.modelLists)),e!=null&&e.isAdmin?Yn():f(Gi(bt.modelLists)))}catch(Te){z(String(Te.message||Te))}finally{P(!1)}})()},450);return()=>clearTimeout(ve)},[e==null?void 0:e.isAdmin,Yn,ee]);const vn=e!=null&&e.isAdmin?d:c,Gn=vn.cursor.length>0,bs=vn.opencode.length>0,Jn=vn.claudeCode.length>0,Bn=vn.codex.length>0,vr=_a(p),Sr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},Wn=h.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=$b(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:ks=>Ds(ae,Qt,ks.target.checked)}),i.jsx("span",{children:Qt})]},`${ae}-${Qt}`)})})]})},[e==null?void 0:e.isAdmin,vr,y,Sr,Ds]),Mr=de.length>0||Me.length>0,$r=e!=null&&e.isAdmin?E:E.filter(ae=>!Aw.has(String((ae==null?void 0:ae.key)||"").trim())),ce=e!=null&&e.isAdmin&&re?"global":"user",me=h.useMemo(()=>E.find(ae=>ae.key===od&&(ae.scope||"user")===ce)||null,[ce,E]),tt=h.useMemo(()=>Kie((me==null?void 0:me.value)||""),[me==null?void 0:me.value]),rt=h.useMemo(()=>E.find(ae=>ae.key===ad&&(ae.scope||"user")===ce)||null,[ce,E]),zt=rt!=null&&rt.value?String(rt.value):"30",Rn=h.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:_c(),key:bt,value:Rt,scope:Te},...Qt]:Qt.filter($n=>!($n.key===bt&&($n.scope||"user")===Te))})},[]),jr=h.useCallback(()=>{const ae=Y.trim();if(!ae)return;const ve=[...tt,{id:_c(),name:te.trim()||`Key ${tt.length+1}`,key:ae,createdAt:new Date().toISOString()}];Rn(od,T_(ve),ce),Z(""),ne("")},[te,tt,ce,Y,Rn]),Nr=h.useCallback(ae=>{const ve=tt.filter(Te=>Te.id!==ae);Rn(od,ve.length?T_(ve):"",ce)},[tt,ce,Rn]),mr=h.useCallback(ae=>{const ve=String(ae||"").replace(/[^\d]/g,"");if(!ve){Rn(ad,"",ce);return}const Te=Math.min(1440,Math.max(1,Number(ve)||30));Rn(ad,String(Te),ce)},[ce,Rn]),ut=h.useCallback(()=>{var ae;s&&((ae=navigator.clipboard)==null||ae.writeText(s))},[s]),Ut=h.useCallback(()=>{const ae=B.trim(),ve=$;if(ae){if(!Vie(ae)){L(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&Aw.has(ae)){L("该运行基础设施变量仅管理员可配置。");return}O(Te=>[{id:_c(),key:ae,value:ve,scope:e!=null&&e.isAdmin&&A?"global":"user"},...Te]),F(""),H("")}},[e==null?void 0:e.isAdmin,A,B,$,t]),Yt=h.useCallback(ae=>{O(ve=>ve.filter(Te=>Te.id!==ae))},[]),Xn=h.useCallback((ae,ve)=>{const Te=String((ve==null?void 0:ve.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Te&&Aw.has(Te)){L("该运行基础设施变量仅管理员可配置。");return}O(bt=>bt.map(Rt=>Rt.id===ae?{...Rt,...ve}:Rt))},[e==null?void 0:e.isAdmin]),it=h.useCallback(ae=>{W(ve=>{const Te=new Set(ve);return Te.has(ae)?Te.delete(ae):Te.add(ae),Te})},[]),gr=h.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]),Fs=h.useCallback(ae=>{const ve=String(ae||"").trim().toLowerCase();ve&&nr(de.filter(Te=>String(Te||"").trim().toLowerCase()!==ve))},[de,nr]),Bi=h.useCallback(ae=>{const ve=ae.target.value;Hie(ve)},[]),zs=ae=>{const ve=Uie(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"+(Gn?" af-set-badge--ok":" af-set-badge--muted"),children:t(Gn?"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:Gn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Gn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Gn?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${vn.cursor.length}`:"")+" · "+zs(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Gn?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:C,children:t(C?"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:qie(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:Y,onChange:ae=>ne(ae.target.value),placeholder:"Cursor API Key"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:jr,disabled:!Y.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",od,";冷却时间保存到 ",ad,"。个人配置会覆盖全局配置。"]})]}),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"+(bs?" af-set-badge--ok":" af-set-badge--err"),children:t(bs?"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]}),bs?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}`:"")+" · "+zs(c.opencodeFetchedAt)}),Wn("opencode",vn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>zn(),disabled:C,children:t(C?"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}`:"")+" · "+zs(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:C,children:t(C?"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}`:"")+" · "+zs(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:C,children:t(C?"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:ZM(ae.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>it(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:()=>Yt(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"+(_e!=null&&_e.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:_e!=null&&_e.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void pr(),disabled:Xt||at,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:!!(_e!=null&&_e.envLocked)||at}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Data Root",disabled:at||!!(_e!=null&&_e.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:at?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(_e==null?void 0:_e.dataRoot)||oe||"-"}),_e!=null&&_e.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:_e.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 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",_e!=null&&_e.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:!!(_e!=null&&_e.skillsEnvLocked)||at}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void hr(),"aria-label":"保存 AgentFlow Skills Root",disabled:at||!!(_e!=null&&_e.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:at?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(_e==null?void 0:_e.skillsRoot)||Be||"-"}),_e!=null&&_e.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:_e.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",_e!=null&&_e.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,Ce?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:Ce})]}):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:()=>Fs(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:Bi,"aria-label":t("settings:language.description"),children:Wie.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 Gie(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 Jie(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function Xie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function Qie({run:e,onClose:t}){const[n,r]=h.useState(null),[s,o]=h.useState(!1),[a,l]=h.useState(""),[c,u]=h.useState("timeline"),d=h.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]);h.useEffect(()=>{r(null),u("timeline"),d()},[d]),h.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||d({quiet:!0})},5e3);return()=>window.clearInterval(v)},[d,e==null?void 0:e.status]);const f=Array.isArray(n==null?void 0:n.events)?n.events:[],p=h.useMemo(()=>f.filter(v=>(v==null?void 0:v.kind)==="thinking"),[f]),m=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?p: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"," · ",Xie(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 d(),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:p.length})]}),i.jsxs("button",{type:"button",className:c==="raw"?"is-active":"",onClick:()=>u("raw"),children:["原始日志 ",i.jsx("span",{children:m.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"?m.length>0?i.jsx("pre",{className:"af-admin-run-detail__raw",children:m.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:Gie(v.ts)}),i.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:Jie(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 Zp(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Ew(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 Zie(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Iw(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 eoe(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function toe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function noe({authUser:e}){const{navigate:t}=rs(),[n,r]=h.useState(null),[s,o]=h.useState(!1),[a,l]=h.useState(""),[c,u]=h.useState(null),[d,f]=h.useState(null),[p,m]=h.useState([]),[y,v]=h.useState(!1),[b,g]=h.useState(""),k=h.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=h.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)}),m([]),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)}),m(Array.isArray(M.workspaces)?M.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),C=h.useCallback(E=>{const O=String((E==null?void 0:E.ownerUserId)||(d==null?void 0:d.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,d==null?void 0:d.userId]);h.useEffect(()=>{k()},[k]);const S=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],N=h.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:Zp(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:Zp(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:Zp(P.successRate)}),i.jsxs("em",{children:["失败率 ",Zp(P.failureRate)," · avg ",Ew(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:Zie(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:Iw(E.at)}),E.endedAt?i.jsxs("span",{children:["结束 ",Iw(E.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:toe(E.status)})})}),i.jsx("td",{children:Ew(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:eoe(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 ",Ew((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"," · ",Iw(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&&(d==null?void 0:d.userId)===E.userId,onClick:()=>void x(E),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(d==null?void 0:d.userId)===E.userId?"读取中":`查看 ${Dr((W=E.pipelines)==null?void 0:W.total)}`]})})]},E.userId)})})]})})]}),d?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:[d.username||d.userId," 的 Workspace"]}),i.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),i.jsx("button",{type:"button",onClick:()=>{f(null),m([]),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..."}):p.length===0?i.jsx("p",{children:"该用户暂无 Workspace。"}):p.map(E=>i.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>C(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(Qie,{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 roe({authUser:e}){const[t,n]=h.useState([]),[r,s]=h.useState([]),[o,a]=h.useState(""),[l,c]=h.useState({name:"",description:"",status:"active",members:[]}),[u,d]=h.useState(""),[f,p]=h.useState(""),[m,y]=h.useState(!1),[v,b]=h.useState(""),g=h.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))}},[]);h.useEffect(()=>{g()},[g]);const k=h.useMemo(()=>t.find(S=>S.id===o)||null,[o,t]);h.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 C=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:m,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&&d("")})},children:[i.jsx("input",{value:u,onChange:S=>d(S.target.value),placeholder:"新团队名称"}),i.jsx("button",{type:"submit",disabled:m||!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=>p(S.target.value),placeholder:"搜索用户"})]}),i.jsx("div",{className:"af-team-admin-members",children:C.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:m||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:m,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:m||!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:m?"保存中...":"保存团队"})]})]})]}):i.jsx("div",{className:"af-workflows-message",children:"创建或选择一个团队。"})})]})]})}function soe(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 ioe({authUser:e}){const{navigate:t}=rs(),[n,r]=h.useState(""),[s,o]=h.useState(""),[a,l]=h.useState(!1),[c,u]=h.useState(""),[d,f]=h.useState(!1),[p,m]=h.useState([]),[y,v]=h.useState(!1),[b,g]=h.useState(""),k=!!(e!=null&&e.isAdmin),x=h.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||"加载失败");m(Array.isArray(N.feedback)?N.feedback:[])}catch(S){g(String(S.message||S)),m([])}finally{v(!1)}}},[k]);h.useEffect(()=>{x()},[x]);const C=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:p.length>0?p.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:soe(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"}),"返回"]})]}),d?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:C,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 e$(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function M_(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:e$(),key:r,value:String(s??""),private:n.has(r)}))}function $_(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 Ah(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:M_(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:M_(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 Pw(){return Ah({name:"",raw:{command:""}})}function ooe(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=$_(e.envRows),s=$_(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 L_(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function O_(e){return e?e.ok?"ok":"error":"unknown"}function Lb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function aoe(e,t){return e&&e.label||t}async function Rw(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 $v(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function t$({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:$v(t)}}}},null,2)}function n$({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify($v(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
318
+ `)}function loe({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=t$({baseUrl:n,token:t}),s=n$({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: ${$v(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 coe({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--${Lb(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:aoe(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 D_({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:e$(),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 uoe(){var Z;const[e,t]=h.useState(""),[n,r]=h.useState([]),[s,o]=h.useState(Pw),[a,l]=h.useState(""),[c,u]=h.useState(!1),[d,f]=h.useState(!1),[p,m]=h.useState(!1),[y,v]=h.useState({}),[b,g]=h.useState(""),[k,x]=h.useState(""),[C,S]=h.useState(()=>{var Y;return typeof window<"u"&&((Y=window.location)!=null&&Y.origin)?window.location.origin:"http://127.0.0.1:8875"}),[N,P]=h.useState(""),[R,z]=h.useState(""),E=h.useMemo(()=>n.find(Y=>Y.name===a)||null,[a,n]),O=E&&y[E.name]||null,D=h.useMemo(()=>t$({baseUrl:C,token:N}),[C,N]),L=h.useMemo(()=>n$({baseUrl:C,token:N}),[C,N]),M=h.useMemo(()=>loe({baseUrl:C,token:N}),[C,N]),V=h.useCallback(async()=>{u(!0),g("");try{const Y=await fetch("/api/mcps"),ne=await Y.json().catch(()=>({}));if(!Y.ok)throw new Error(ne.error||"MCP HTTP "+Y.status);const re=Array.isArray(ne.servers)?ne.servers:[];t(String(ne.path||"")),r(re),a&&re.some(se=>se.name===a)&&o(Ah(re.find(se=>se.name===a)))}catch(Y){g(String(Y.message||Y))}finally{u(!1)}},[a]);h.useEffect(()=>{V()},[V]);const B=()=>{l(""),o(Pw()),x(""),g("")},F=Y=>{l(Y.name),o(Ah(Y)),x(""),g("")},$=h.useCallback(async()=>{if(!M)return;const Y=await Rw(M);z(Y?"prompt":"copy-failed"),window.setTimeout(()=>z(""),1200)},[M]),H=h.useCallback(async()=>{const Y=await Rw(D);z(Y?"cursor":"copy-failed"),window.setTimeout(()=>z(""),1200)},[D]),A=h.useCallback(async()=>{const Y=await Rw(L);z(Y?"codex":"copy-failed"),window.setTimeout(()=>z(""),1200)},[L]),Q=h.useCallback(async()=>{try{const Y=await fetch("/api/auth/session-token"),ne=await Y.json().catch(()=>({}));if(!Y.ok)throw new Error(typeof ne.error=="string"?ne.error:"HTTP "+Y.status);P(String(ne.token||"")),z("token"),window.setTimeout(()=>z(""),1200)}catch(Y){z(""),g(String(Y.message||Y))}},[]),K=async(Y="")=>{m(!0),g(""),x("");try{const ne=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y?{name:Y}:{})}),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(Y?`已检测 ${Y}。`:"已检测所有 MCP。")}catch(ne){g(String(ne.message||ne))}finally{m(!1)}},W=async()=>{f(!0),g(""),x("");try{const Y=ooe(s);if(!Y.nextName)throw new Error("请填写 MCP 名称");const ne=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}),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(Y.nextName),o(Ah(se.find(ee=>ee.name===Y.nextName)||null)),v(ee=>{const ue={...ee};return s.originalName&&s.originalName!==Y.nextName&&delete ue[s.originalName],delete ue[Y.nextName],ue}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(Y){g(String(Y.message||Y))}finally{f(!1)}},te=async Y=>{if(Y!=null&&Y.name&&window.confirm(`删除 MCP "${Y.name}"?`)){f(!0),g(""),x("");try{const ne=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Y.name})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"删除 MCP 失败");r(Array.isArray(re.servers)?re.servers:[]),l(""),o(Pw()),v(se=>{const ee={...se};return delete ee[Y.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||d,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(),disabled:p||c||d||n.length===0,children:p?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:d,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:C,onChange:Y=>S(Y.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:Y=>P(Y.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:d,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:d,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(Y=>{var ne,re,se,ee;return i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===Y.name?" af-mcp-server-item--active":""),onClick:()=>F(Y),children:[i.jsx("span",{className:"material-symbols-outlined",children:Y.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:Y.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${O_(y[Y.name])}`,children:L_(y[Y.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${Lb((re=(ne=Y.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--${Lb((ee=(se=Y.backends)==null?void 0:se.codex)==null?void 0:ee.status)}`,children:"Codex"})]}),i.jsx("em",{children:Y.url||[Y.command,...Y.args||[]].filter(Boolean).join(" ")})]})]},Y.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:p||d,children:p?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>te(E),disabled:d,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(coe,{server:E}):null,O?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${O_(O)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:L_(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(Y=>i.jsxs("div",{className:"af-mcp-tool-row",children:[i.jsx("strong",{children:Y.name}),Y.description?i.jsx("span",{children:Y.description}):null]},Y.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:Y=>o(ne=>({...ne,name:Y.target.value})),placeholder:"github"})]}),i.jsxs("label",{className:"af-set-label",children:["类型",i.jsxs("select",{className:"af-set-input",value:s.type,onChange:Y=>o(ne=>({...ne,type:Y.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:Y=>o(ne=>({...ne,url:Y.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:Y=>o(ne=>({...ne,command:Y.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:Y=>o(ne=>({...ne,argsText:Y.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:Y=>o(ne=>({...ne,description:Y.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(D_,{title:"Headers",rows:s.headerRows,onChange:Y=>o(ne=>({...ne,headerRows:Y})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(D_,{title:"Env",rows:s.envRows,onChange:Y=>o(ne=>({...ne,envRows:Y})),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:Y=>o(ne=>({...ne,extraJson:Y.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:B,disabled:d,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:W,disabled:d,children:d?"保存中...":"保存 MCP"})]})]})]})]})})]})}function doe(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 F_(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function z_(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 foe(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function poe(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 hoe(){const{navigate:e}=rs(),[t,n]=h.useState([]),[r,s]=h.useState(!1),[o,a]=h.useState(""),[l,c]=h.useState(""),u=h.useCallback(async()=>{s(!0),a("");try{const p=await fetch("/api/schedules"),m=await p.json().catch(()=>({}));if(!p.ok)throw new Error(m.error||"读取定时任务失败");n(Array.isArray(m.schedules)?m.schedules:[])}catch(p){a(String(p.message||p)),n([])}finally{s(!1)}},[]);h.useEffect(()=>{u()},[u]);const d=h.useCallback(async p=>{const m=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`;c(m),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:p.kind,flowId:p.flowId,flowSource:p.flowSource||"user",scheduleNodeId:p.scheduleNodeId||"",enabled:!p.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=h.useMemo(()=>{const p=t.filter(y=>y.enabled).length,m=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:p,workspace:m,pipeline:t.length-m}},[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(p=>{const m=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`,y=l===m,v=doe(p);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:p.label||p.flowId||"-"}),i.jsx("span",{className:`af-schedule-badge af-schedule-badge--${p.kind||"pipeline"}`,children:foe(p)}),i.jsx("span",{className:`af-schedule-state ${p.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:poe(p)})]}),i.jsxs("div",{className:"af-schedule-card__meta",children:[i.jsx("span",{children:p.flowId||"-"}),i.jsx("span",{children:p.flowSource||"user"}),p.scheduleNodeId?i.jsx("span",{children:p.scheduleNodeId}):null]}),i.jsxs("div",{className:"af-schedule-card__grid",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Cron"}),i.jsx("strong",{children:p.cron||"-"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"时区"}),i.jsx("strong",{children:p.timezone||"Asia/Shanghai"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"下次执行"}),i.jsx("strong",{children:z_(p.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:z_(p.lastTriggeredAt)})]})]}),p.lastError?i.jsx("p",{className:"af-schedule-card__error",children:p.lastError}):null]}),i.jsxs("div",{className:"af-schedule-card__actions",children:[v?i.jsxs("button",{type:"button",className:"af-schedule-open",title:F_(p),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),F_(p)]}):null,i.jsxs("button",{type:"button",className:p.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":p.enabled,title:p.enabled?"点击停用":"点击启用",onClick:()=>void d(p),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":p.enabled?"toggle_on":"toggle_off"}),p.enabled?"已启用":"已停用"]})]})]},m)})})]})})]})}const B_={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 W_(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 moe(e){var c,u,d,f,p,m,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((d=(u=t.ui)==null?void 0:u.card)==null?void 0:d.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(C=>[`input.${C.name||"-"}`,`${C.type||"text"}${C.required?" · required":""}${C.default?` · default: ${C.default}`:""}`]),...s.map(C=>[`output.${C.name||"-"}`,C.type||"text"]),...o.map(C=>[`config.${C.key||"-"}`,C.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((p=t.runtime)==null?void 0:p.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((m=t.runtime)==null?void 0:m.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(C=>[`action.${C.id||C.label||"-"}`,C.variant||C.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([C,S])=>[`sample.${C}`,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 goe(){var L,M,V,B,F,$,H;const[e,t]=h.useState(null),[n,r]=h.useState("runtime"),[s,o]=h.useState(!1),[a,l]=h.useState(!0),[c,u]=h.useState(""),[d,f]=h.useState(!1),[p,m]=h.useState(""),y=e||B_,v=h.useMemo(()=>moe(y),[y]),b=h.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)||{},C=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=h.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),m("");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),m(String(((A=Z.draft)==null?void 0:A.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);h.useEffect(()=>{R()},[R]);const z=h.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),m(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||B_,config:Q})),z({config:{enabled:A}})},D=()=>{z({promptDraft:p,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:p,onChange:A=>m(A.target.value)})]}),i.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:d,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:d?"sync":"send"}),d?"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:W_(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:W_(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..."]:C.length?C:["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 yoe(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function woe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Eh(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 xoe(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 Tw(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function eh(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 boe(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||Eh(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 Ji(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 koe({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function H_({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(koe,{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 voe(){const[e,t]=h.useState(!1),[n,r]=h.useState(!1),[s,o]=h.useState(!1),[a,l]=h.useState(""),[c,u]=h.useState(""),[d,f]=h.useState(""),[p,m]=h.useState([]),[y,v]=h.useState([]),[b,g]=h.useState(Tw),[k,x]=h.useState(""),[C,S]=h.useState([]),[N,P]=h.useState(""),R=h.useMemo(()=>y.findIndex((K,W)=>Ji(K,W)===N),[y,N]),E=!!h.useMemo(()=>p.find((K,W)=>Ji(K,W)===N)||null,[p,N]),O=h.useMemo(()=>{const K=String(b.credentialRef||"").trim();return K?C.some(W=>String((W==null?void 0:W.key)||"").trim()===K&&String((W==null?void 0:W.value)??"")!==""):!1},[b.credentialRef,C]),D=h.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 Y=Array.isArray(te.workspaces)?te.workspaces:[],ne=Array.isArray(te.customWorkspaces)?te.customWorkspaces:[];f(String(te.path||"")),m(Y.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)}},[]);h.useEffect(()=>{D()},[D]);const L=h.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 Y=Array.isArray(Z.customWorkspaces)?Z.customWorkspaces:K;v(Y),m((Array.isArray(Z.workspaces)?Z.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin)),f(String(Z.path||d)),W&&P(W),u("已保存")}catch(te){l(String(te.message||te))}finally{r(!1)}},[d]),M=h.useCallback(()=>{P(""),g(Tw()),x(""),u(""),l("")},[]),V=h.useCallback((K,W)=>{P(Ji(K,W)),g(eh(K)),x(""),u("")},[]),B=h.useCallback((K,W)=>{P(Ji(K,W)),g(eh(K)),x(""),u("")},[]),F=h.useCallback(async(K,W)=>{const te=String(K||"").trim(),Z=String(W??"");if(!te||!Z)return;const Y=C.filter(se=>String((se==null?void 0:se.key)||"").trim()!==te);Y.push({key:te,value:Z});const ne=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:Y})}),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)??"")})):Y)},[C]),$=h.useCallback(()=>{const K=boe({...b,id:b.id||yoe()}),W=k.trim();if(K.kind==="git"&&W&&!K.credentialRef&&(K.credentialRef=xoe(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&&!woe(K.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const te=R>=0?y.map((Z,Y)=>Y===R?K:Z):[K,...y];g(eh(K)),(async()=>{r(!0);try{W&&await F(K.credentialRef,W),x(""),await L(te,Ji(K))}catch(Z){l(String(Z.message||Z)),r(!1)}})()},[y,b,L,F,R,k]),H=h.useCallback(()=>{if(R<0)return;const K=y.filter((W,te)=>te!==R);g(Tw()),P(""),L(K)},[y,L,R]),A=h.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),m((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(eh(Z));const Y=String(W.commit||"").trim();u(W.changed?`已拉取更新${Y?`:${Y.slice(0,8)}`:""}`:`已是最新${Y?`:${Y.slice(0,8)}`:""}`)}catch(K){l(String(K.message||K))}finally{o(!1)}}},[y,b,E,R]),Q=h.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 的资源配置保持一致。"}),d?i.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",d]}):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:p.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(H_,{item:K,selected:Ji(K,W)===N,onClick:()=>V(K,W)},Ji(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:"内置知识库"})}),p.map((K,W)=>i.jsx(H_,{item:K,selected:Ji(K,W)===N,onClick:()=>B(K,W),readOnly:!0},Ji(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=Eh(b.repoUrl),Z=String(b.mountPath||"").trim();Q({repoUrl:W,...!Z||Z===te?{mountPath:Eh(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:Eh(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 r$="agentflow.workflows.scopeView",Ha=8,V_=24;function Soe(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(r$)==="team"?"team":"personal"}catch{return"personal"}}function joe(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 Noe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleDateString([],{year:"numeric",month:"2-digit",day:"2-digit"}):"日期待定"}function Coe(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 _oe(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 Aa(e){const t=new Date;return t.setHours(12,0,0,0),t.setDate(t.getDate()+e),t.toISOString().slice(0,10)}function Aoe(e){const t=Array.isArray(e)?e.length:0;if(t<=Ha)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-Ha));return{start:s,end:Math.min(t,s+Ha)}}function Eoe(){const e=[{key:"prd-flow:version:android-5.62.0",kind:"version",id:"android-5.62.0",title:"Likee Android 5.62.0",date:Aa(-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:Aa(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:Aa(10),source:"prd-flow",dimensions:{platform:"iOS"}},{key:"prd-flow:milestone:august-gray",kind:"milestone",id:"august-gray",title:"8 月灰度窗口",date:Aa(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:Aa(-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:Aa(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:Aa(-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 Ioe(e){return e==="owner"?"我创建的":e==="editor"?"协作编辑":e==="viewer"?"只读协作":"可访问"}function Poe(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function Roe(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function Toe(e){return`/workspace?${new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||"")}).toString()}`}function Moe(){const{navigate:e}=rs(),[t,n]=h.useState([]),[r,s]=h.useState([]),[o,a]=h.useState(0),[l,c]=h.useState("all"),[u,d]=h.useState(Soe),[f,p]=h.useState(null),[m,y]=h.useState(!1),[v,b]=h.useState(""),[g,k]=h.useState(""),[x,C]=h.useState("all"),[S,N]=h.useState("all"),[P,R]=h.useState(!1),[z,E]=h.useState({start:0,end:0}),O=h.useRef(null),D=h.useRef(null),L=h.useRef(!1),M=h.useRef(0),V=h.useRef(0),B=h.useCallback(async()=>{R(!1),y(!0),b("");try{const Z=await fetch(`/api/prd-workflows?view=${encodeURIComponent(u)}`),Y=await Z.json().catch(()=>({}));if(!Z.ok)throw new Error(Y.error||"读取迭代列表失败");const ne=Array.isArray(Y.workflows)?Y.workflows:[],re=Array.isArray(Y.timeline)?Y.timeline:[];n(ne),s(re),a(Number(Y.unassignedCount||0)),c(se=>se==="all"||se==="unassigned"&&Number(Y.unassignedCount||0)>0||re.some(ee=>ee.key===se)?se:"all"),p(Y.team||null)}catch(Z){b(String(Z.message||Z)),n([]),s([]),a(0),c("all"),p(null)}finally{y(!1)}},[u]),F=h.useCallback(()=>{const Z=Eoe();n(Z.workflows),s(Z.timeline),a(Z.unassignedCount),c("all"),k(""),C("all"),N("all"),b(""),R(!0)},[]);h.useEffect(()=>{B()},[B]),h.useEffect(()=>{try{localStorage.setItem(r$,u)}catch{}},[u]),h.useEffect(()=>{E(Aoe(r))},[r]),h.useLayoutEffect(()=>{const Z=D.current,Y=O.current;if(Y){if(Z){D.current=null;const ne=Array.from(Y.children).find(re=>re.dataset.timelineKey===Z.key);ne&&(Y.scrollLeft=Z.scrollLeft+ne.offsetLeft-Z.offsetLeft)}window.clearTimeout(M.current),M.current=window.setTimeout(()=>{L.current=!1},80)}},[z]),h.useEffect(()=>()=>{window.clearTimeout(M.current),window.cancelAnimationFrame(V.current)},[]);const $=h.useMemo(()=>r.slice(z.start,z.end),[r,z]),H=z.start>0,A=z.end<r.length,Q=h.useCallback(()=>{if(!H||L.current)return;L.current=!0;const Z=O.current,Y=Z==null?void 0:Z.querySelector("[data-timeline-key]");D.current=Y?{key:Y.dataset.timelineKey,offsetLeft:Y.offsetLeft,scrollLeft:Z.scrollLeft}:null,E(ne=>({start:Math.max(0,ne.start-Ha),end:Math.min(ne.end,Math.max(0,ne.start-Ha)+V_)}))},[H]),K=h.useCallback(()=>{if(!A||L.current)return;L.current=!0;const Z=O.current,Y=Z==null?void 0:Z.querySelectorAll("[data-timeline-key]"),ne=Y==null?void 0:Y[Y.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+Ha)-V_),end:Math.min(r.length,re.end+Ha)}))},[A,r.length]),W=h.useCallback(Z=>{const Y=Z.currentTarget;V.current||(V.current=window.requestAnimationFrame(()=>{V.current=0,!L.current&&(Y.scrollLeft<=32?Q():Y.scrollLeft+Y.clientWidth>=Y.scrollWidth-32&&K())}))},[Q,K]),te=h.useMemo(()=>{const Z=g.trim().toLowerCase();return t.filter(Y=>{var ne;return l==="unassigned"&&(Y.timeline||[]).length>0||l!=="all"&&l!=="unassigned"&&!(Y.timeline||[]).some(re=>re.key===l)||x==="owned"&&Y.role!=="owner"||x==="collaborating"&&Y.role==="owner"||S!=="all"&&Y.state!==S?!1:Z?[Y.tapdId,Y.title,Y.pointer,Y.phase,Y.ownerUsername,(ne=Y.latestAction)==null?void 0:ne.title,...(Y.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:()=>d("personal"),children:"个人迭代"}),i.jsx("button",{type:"button",className:u==="team"?"is-active":"",onClick:()=>d("team"),children:"团队迭代"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void B(),disabled:m,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:m?"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 Y=Coe(Z),ne=_oe(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:[Noe(Z.date),i.jsx("em",{children:ne.label})]}),i.jsx("strong",{children:Z.title||Z.id}),i.jsx("small",{children:[Y,`${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,Y])=>i.jsx("button",{type:"button",className:x===Z?"is-active":"","aria-pressed":x===Z,onClick:()=>C(Z),children:Y},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,m?i.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!m&&!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,!m&&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 Y=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:Poe(Z.state)}),i.jsx("span",{className:"af-workflow-role",children:Ioe(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:Roe(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 完成度 ${Y}%`,children:i.jsx("span",{style:{width:`${Y}%`}})}),i.jsxs("small",{children:[Y,"%"]})]}),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:joe(((re=Z.latestAction)==null?void 0:re.at)||Z.updatedAt)})]}),i.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>{Z.demo||e(Toe(Z))},disabled:Z.demo,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 $oe=`# 安装通用 CLI
321
+ skillhub install agentflow-cli --global --agent codex
322
+
323
+ # 安装 Workflow 上报规格 Skill
324
+ skillhub install agentflow-workflow-report --global --agent codex
325
+
326
+ # 配置鉴权;不要把 Token 写进上报内容
327
+ export AGENTFLOW_TOKEN=<your-token>
328
+ # 本地联调时再覆盖:
329
+ # export AGENTFLOW_BASE_URL=http://127.0.0.1:8875`,Loe=`node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
330
+ --workflow tapd:1015046 \\
331
+ --runtime-only`,Ooe=`node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-report \\
332
+ --workflow tapd:1015046 \\
333
+ --file workflow-report.json \\
334
+ --expected-revision 'runtime:current-revision' \\
335
+ --idempotency-key 'implementation-finished:android:issue-2:v1'`,Doe=`{
336
+ "schemaVersion": 1,
337
+ "workflow": { "namespace": "tapd", "id": "1015046" },
338
+ "source": "prd-flow",
339
+ "action": {
340
+ "key": "implementation:android:issue-2",
341
+ "title": "Android 实现完成",
342
+ "status": "done",
343
+ "group": "implementation",
344
+ "platform": "android",
345
+ "issueKey": "issue-2"
346
+ },
347
+ "artifacts": [{
348
+ "key": "implementation-mr:issue-2:android",
349
+ "type": "gitlab-mr",
350
+ "title": "Android 实现 MR",
351
+ "url": "https://git.example.test/merge_requests/123",
352
+ "scope": "action",
353
+ "status": "ready"
354
+ }],
355
+ "globalState": {
356
+ "mode": "merge",
357
+ "patch": {
358
+ "producerOwnedState": { "status": "implementing" }
359
+ },
360
+ "remove": []
361
+ },
362
+ "projections": {
363
+ "timeline": [{
364
+ "kind": "version",
365
+ "id": "android-5.63.0",
366
+ "title": "Likee Android 5.63.0",
367
+ "date": "2026-08-20",
368
+ "source": "prd-flow",
369
+ "dimensions": { "platform": "android" }
370
+ }]
371
+ }
372
+ }`,K_=`请使用 $agentflow-workflow-report 为当前生产方接入 AgentFlow Workflow 上报。
373
+
374
+ 目标:
375
+ 1. 生产方自行定义并维护 globalState 的业务格式,AgentFlow 不解析其私有字段。
376
+ 2. 从生产方当前状态确定性生成完整的 projections.timeline,用于个人和团队迭代汇总。
377
+ 3. 支持 action、artifacts、globalState 和 projections 的组合或独立上报。
378
+
379
+ 执行要求:
380
+ 1. 完整阅读 Skill 中 references/protocol.md 的协议规格。
381
+ 2. 先用 workflow-get 读取当前 snapshot,并保留 runtimeRevision。
382
+ 3. 只合并本次语义变化,不覆盖不属于生产方的 globalState 字段。
383
+ 4. timeline 每项必须有稳定的 kind 和 id;title/date 变化不能改变身份;dimensions 保持通用,不在 AgentFlow 中硬编码平台或版本结构。
384
+ 5. projections.timeline 出现时必须发送当前完整数组;用空数组显式清空;省略 projections 表示不修改。
385
+ 6. workflow-report 必须携带 expectedRevision 和稳定 idempotencyKey。
386
+ 7. 遇到 409 时重新读取、重放语义修改,只重试一次;禁止用旧快照覆盖。
387
+ 8. 不得在命令、日志、产物或最终回复中打印 Token。
388
+ 9. 完成后验证返回 snapshot,并确认个人/团队迭代页面的时间线聚合正确。
389
+
390
+ 请先检查现有生产方的数据模型和上报链路,再给出最小兼容改造并执行测试。`,Foe=[["action","进度事实","用稳定 key 上报阶段、状态和发生时间。"],["artifacts","证据产物","关联 MR、文档、看板或其他可审查证据。"],["globalState","生产方状态","只定义 merge/remove 操作,不限定业务数据结构。"],["projections","通用投影","以完整替换语义提供版本、Sprint、里程碑等时间线归属。"]];async function zoe(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 Yu({title:e,value:t,copyKey:n,copied:r,onCopy:s}){return i.jsxs("div",{className:"af-wr-code-panel",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?"已复制":r==="failed"?"复制失败":"复制"]})]}),i.jsx("pre",{children:t})]})}function Boe(){const{navigate:e}=rs(),[t,n]=h.useState(""),r=h.useCallback(async(s,o)=>{n(await zoe(o)?s:"failed")},[]);return 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",{className:"af-wr-hero__copy",children:[i.jsx("span",{className:"af-wr-kicker",children:"WORKFLOW REPORTING PROTOCOL · V1"}),i.jsx("h1",{children:"Workflow 上报接入"}),i.jsx("p",{children:"为 prd-flow 和其他生产方提供稳定的 Action、产物、全局状态与时间线投影上报协议。业务格式由生产方维护,AgentFlow 只负责安全物化与通用汇总。"}),i.jsxs("div",{className:"af-wr-hero__actions",children:[i.jsxs("button",{type:"button",className:"is-primary",onClick:()=>void r("ai",K_),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:"查看迭代汇总"})]})]}),i.jsxs("div",{className:"af-wr-boundary","aria-label":"协议边界",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schema"}),i.jsx("strong",{children:"一个明确边界"}),i.jsx("p",{children:"globalState 是生产方事实;projections 是 AgentFlow 通用索引。"}),i.jsxs("ul",{children:[i.jsx("li",{children:"不解析业务私有字段"}),i.jsx("li",{children:"不复制第二份业务真相"}),i.jsx("li",{children:"用 revision 和幂等键保护写入"})]})]})]}),i.jsxs("section",{className:"af-wr-section",children:[i.jsxs("div",{className:"af-wr-section__head",children:[i.jsx("span",{children:"01"}),i.jsxs("div",{children:[i.jsx("h2",{children:"上报能力"}),i.jsx("p",{children:"同一个报告可以组合这些能力,也可以只同步其中一种。"})]})]}),i.jsx("div",{className:"af-wr-capabilities",children:Foe.map(([s,o,a])=>i.jsxs("article",{children:[i.jsx("code",{children:s}),i.jsx("h3",{children:o}),i.jsx("p",{children:a})]},s))})]}),i.jsxs("section",{className:"af-wr-section",children:[i.jsxs("div",{className:"af-wr-section__head",children:[i.jsx("span",{children:"02"}),i.jsxs("div",{children:[i.jsx("h2",{children:"接入流程"}),i.jsx("p",{children:"必须使用 read → merge → report 顺序,不允许直接覆盖远端状态。"})]})]}),i.jsx("div",{className:"af-wr-flow","aria-label":"接入流程",children:[["1","读取","workflow-get 获取当前 snapshot 和 runtimeRevision"],["2","计算","合并本次语义变化,并从生产方状态派生完整投影"],["3","上报","携带 expectedRevision 和稳定 idempotencyKey"],["4","验证","检查返回快照以及个人/团队时间线聚合"]].map(([s,o,a])=>i.jsxs("div",{children:[i.jsx("span",{children:s}),i.jsx("strong",{children:o}),i.jsx("p",{children:a})]},s))}),i.jsxs("div",{className:"af-wr-code-grid",children:[i.jsx(Yu,{title:"安装与配置",value:$oe,copyKey:"install",copied:t,onCopy:r}),i.jsxs("div",{className:"af-wr-code-stack",children:[i.jsx(Yu,{title:"读取当前状态",value:Loe,copyKey:"read",copied:t,onCopy:r}),i.jsx(Yu,{title:"提交报告",value:Ooe,copyKey:"report",copied:t,onCopy:r})]})]})]}),i.jsxs("section",{className:"af-wr-section",children:[i.jsxs("div",{className:"af-wr-section__head",children:[i.jsx("span",{children:"03"}),i.jsxs("div",{children:[i.jsx("h2",{children:"协议示例"}),i.jsx("p",{children:"这里的 globalState 仅为占位,真实结构由 prd-flow 或其他生产方决定。"})]})]}),i.jsxs("div",{className:"af-wr-contract",children:[i.jsx(Yu,{title:"workflow-report.json",value:Doe,copyKey:"payload",copied:t,onCopy:r}),i.jsxs("div",{className:"af-wr-rules",children:[i.jsx("h3",{children:"写入约束"}),i.jsxs("ul",{children:[i.jsxs("li",{children:[i.jsx("strong",{children:"Action:"}),"必须有稳定 key。"]}),i.jsxs("li",{children:[i.jsx("strong",{children:"Artifact:"}),"使用稳定 key,不依赖标题去重。"]}),i.jsxs("li",{children:[i.jsx("strong",{children:"Global State:"}),"只 patch 自己拥有的字段;数组为替换语义。"]}),i.jsxs("li",{children:[i.jsx("strong",{children:"Timeline:"}),"每项必须有 kind 和 id;出现时发送完整数组。"]}),i.jsxs("li",{children:[i.jsx("strong",{children:"清空归属:"}),"发送 ",i.jsx("code",{children:'{"projections":{"timeline":[]}}'}),"。"]}),i.jsxs("li",{children:[i.jsx("strong",{children:"冲突:"}),"409 后重新读取并重放语义修改,只重试一次。"]})]}),i.jsxs("div",{className:"af-wr-endpoints",children:[i.jsxs("div",{children:[i.jsx("span",{children:"READ"}),i.jsx("code",{children:"GET /api/workflows/state"})]}),i.jsxs("div",{children:[i.jsx("span",{children:"WRITE"}),i.jsx("code",{children:"POST /api/workflows/report"})]})]})]})]})]}),i.jsxs("section",{className:"af-wr-section af-wr-ai",children:[i.jsxs("div",{className:"af-wr-section__head",children:[i.jsx("span",{children:"04"}),i.jsxs("div",{children:[i.jsx("h2",{children:"给 AI 的接入引导"}),i.jsx("p",{children:"复制后交给 Codex、Claude Code 或其他支持 Skill 的编码 Agent。"})]})]}),i.jsx(Yu,{title:"$agentflow-workflow-report",value:K_,copyKey:"ai",copied:t,onCopy:r}),t==="failed"?i.jsx("p",{className:"af-wr-copy-error",children:"浏览器禁止访问剪贴板,请手动选择代码块内容。"}):null]})]})})}const Woe=[{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"}],Hoe=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Voe=[{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"}],Koe=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function th({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 qoe(){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(th,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(th,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(th,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(th,{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 Ih({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 Uoe(){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(Ih,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:Voe.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 s$(){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(qoe,{}),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(Ih,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:Woe.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(Ih,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:Hoe.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(Uoe,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(Ih,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:Koe.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 i$(e){return t=>typeof t===e}var Yoe=i$("function"),Goe=e=>e===null,q_=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",U_=e=>!Joe(e)&&!Goe(e)&&(Yoe(e)||typeof e=="object"),Joe=i$("undefined");function Xoe(e,t,n){return sae(n,e,t)?!0:(iae(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Qoe(e,t,n):e instanceof Map&&t instanceof Map?tae(e,t,n):e instanceof Set&&t instanceof Set?rae(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Zoe(e,t):q_(e)&&q_(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?eae(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():nae(e,t,n))}function Ef(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!U_(e)||!t||!U_(t)?!1:Xoe(e,t,n)}function Qoe(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!Ef(e[s],t[s],n))return!1;return!0}function Zoe(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 eae(e,t,n){return e.message===t.message&&e.name===t.name&&Ef(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(!Ef(r[1],t.get(r[0]),n))return!1;return!0}function nae(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)&&!Ef(e[o],t[o],n))return!1}return!0}function rae(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 sae(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function iae(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function Lv(e,t){return Ef(e,t,new WeakMap)}function Mw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function oae(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function aae(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function lae(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function cae(e,t){const n=lae();h.useEffect(()=>{if(!n)return e()},t)}function o$(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function uae(e,t){const n=h.useRef(t);return Lv(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function dae(e){h.useEffect(()=>{e()},[])}function fae(e=0){const[t,n]=h.useState({height:Mw()?window.innerHeight:0,width:Mw()?window.innerWidth:0}),r=h.useRef(0),s=h.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return h.useEffect(()=>{if(!Mw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),aae(window,"resize",o),()=>{oae(window,"resize",o)}},[]),t}var pae=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],hae=["bigint","boolean","null","number","string","symbol","undefined"];function If(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(mae(t))return t}function pi(e){return t=>If(t)===e}function mae(e){return pae.includes(e)}function tu(e){return t=>typeof t===e}function gae(e){return hae.includes(e)}var yae=["innerHTML","ownerDocument","style","attributes","nodeValue"],Pf=e=>Array.isArray(e),wae=e=>If(e)==="AsyncGeneratorFunction",xae=pi("AsyncFunction"),bae=tu("bigint"),kae=e=>e===!0||e===!1,vae=pi("Date"),Sae=pi("Error"),ca=tu("function"),jae=pi("GeneratorFunction"),Nae=e=>typeof e=="number"&&Number.isInteger(e),Ob=pi("Map"),a$=e=>Number.isNaN(e),Ov=e=>e===null,l$=pi("Function"),Cae=pi("Promise"),_ae=pi("RegExp"),Db=pi("Set"),Rf=tu("string"),Aae=tu("symbol"),Dv=tu("undefined"),Eae=pi("WeakMap"),Iae=pi("WeakSet"),Fv=e=>Ov(e)||Dv(e),c$=e=>!Dv(e),Pae=e=>tu("number")(e)&&!a$(e),Rae=e=>Rf(e)&&e.trim().length>0,Tae=e=>{if(!Rf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},jg=e=>!Fv(e)&&(ca(e)||typeof e=="object"),u$=e=>{if(If(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Mae=e=>Ov(e)||gae(typeof e),$ae=e=>If(e)==="URL",d$=e=>!Fv(e)&&ca(e[Symbol.iterator]),Lae=e=>d$(e)&&ca(e.next)&&ca(e.throw),Oae=e=>ca(e)&&/^class\s/.test(e.toString()),Dae=(e,t)=>!Pf(e)||!ca(t)?!1:e.every(n=>t(n)),Fae=e=>jg(e)&&!u$(e)&&e.nodeType===1&&Rf(e.nodeName)&&yae.every(t=>t in e),zae=e=>Rf(e)&&e.length===0||Pf(e)&&e.length===0||jg(e)&&!Ob(e)&&!Db(e)&&Object.keys(e).length===0||Db(e)&&e.size===0||Ob(e)&&e.size===0,Bae=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Wae=(e,t)=>Pf(e)?e.indexOf(t)>-1:!1,Hae=(e,t,n)=>{if(!jg(e)||!t)return!1;const r=e[t];return ca(n)?n(r):c$(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(Pf(e))return"Array";if(l$(e))return"Function";const t=If(e);return t||"Object"}Nt.array=Pf;Nt.arrayOf=Dae;Nt.asyncGeneratorFunction=wae;Nt.asyncFunction=xae;Nt.bigint=bae;Nt.boolean=kae;Nt.class=Oae;Nt.date=vae;Nt.defined=c$;Nt.domElement=Fae;Nt.empty=zae;Nt.error=Sae;Nt.function=ca;Nt.generator=Lae;Nt.generatorFunction=jae;Nt.instanceOf=Bae;Nt.integer=Nae;Nt.iterable=d$;Nt.map=Ob;Nt.nan=a$;Nt.null=Ov;Nt.nullOrUndefined=Fv;Nt.nonEmptyString=Rae;Nt.number=Pae;Nt.numericString=Tae;Nt.object=jg;Nt.oneOf=Wae;Nt.plainFunction=l$;Nt.plainObject=u$;Nt.primitive=Mae;Nt.promise=Cae;Nt.propertyOf=Hae;Nt.regexp=_ae;Nt.set=Db;Nt.string=Rf;Nt.symbol=Aae;Nt.undefined=Dv;Nt.url=$ae;Nt.weakMap=Eae;Nt.weakSet=Iae;var Ir=Nt;/* v8 ignore next -- @preserve */var Vae=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Kae=function(e,t){return e+df(t)},df=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(Kae,""):Vae(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?df(e.props.children):""};df.default=df;var qae=df;const $w=da(qae);var f$={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(p&&Object.getPrototypeOf(S)!==t)return p(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 d(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?d:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,m=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:m}):c;function g(S){return m(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&&(p&&m(N[D])&&Object.getPrototypeOf(N[D])!==t?P[D]=p(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:m(S)?P&&R?b(S,N):P!==R?g(N):k(S,N):g(N)}function C(){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?C:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(f$);var Uae=f$.exports;const Yae=da(Uae);var Gae=new Error("Element already at target scroll position"),Jae=new Error("Scroll cancelled"),Xae=Math.min,Y_=Date.now,Qae={left:G_("scrollLeft"),top:G_("scrollTop")};function G_(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=ele);var a=Y_(),l=n[e],c=s.ease||Zae,u=isNaN(s.duration)?350:+s.duration,d=!1;return l===r?o(Gae,n[e]):requestAnimationFrame(p),f;function f(){d=!0}function p(m){if(d)return o(Jae,n[e]);var y=Y_(),v=Xae(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(p):requestAnimationFrame(function(){o(null,n[e])})}}}function Zae(e){return .5*(1-Math.cos(Math.PI*e))}function ele(){}const tle=da(Qae);var p$={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(_d,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})})(p$);var nle=p$.exports;const h$=da(nle),rle=["top","right","bottom","left"],J_=["start","end"],X_=rle.reduce((e,t)=>e.concat(t,t+"-"+J_[0],t+"-"+J_[1]),[]),Kc=Math.min,Ja=Math.max,Mm=Math.round,nh=Math.floor,$i=e=>({x:e,y:e}),sle={left:"right",right:"left",bottom:"top",top:"bottom"};function Fb(e,t,n){return Ja(e,Kc(t,n))}function nu(e,t){return typeof e=="function"?e(t):e}function yo(e){return e.split("-")[0]}function Li(e){return e.split("-")[1]}function m$(e){return e==="x"?"y":"x"}function zv(e){return e==="y"?"height":"width"}function qo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Bv(e){return m$(qo(e))}function g$(e,t,n){n===void 0&&(n=!1);const r=Li(e),s=Bv(e),o=zv(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Lm(a)),[a,Lm(a)]}function ile(e){const t=Lm(e);return[$m(e),t,$m(t)]}function $m(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Q_=["left","right"],Z_=["right","left"],ole=["top","bottom"],ale=["bottom","top"];function lle(e,t,n){switch(e){case"top":case"bottom":return n?t?Z_:Q_:t?Q_:Z_;case"left":case"right":return t?ole:ale;default:return[]}}function cle(e,t,n,r){const s=Li(e);let o=lle(yo(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map($m)))),o}function Lm(e){const t=yo(e);return sle[t]+e.slice(t.length)}function ule(e){return{top:0,right:0,bottom:0,left:0,...e}}function y$(e){return typeof e!="number"?ule(e):{top:e,right:e,bottom:e,left:e}}function Om(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 eA(e,t,n){let{reference:r,floating:s}=e;const o=qo(t),a=Bv(t),l=zv(a),c=yo(t),u=o==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let m;switch(c){case"top":m={x:d,y:r.y-s.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:f};break;case"left":m={x:r.x-s.width,y:f};break;default:m={x:r.x,y:r.y}}switch(Li(t)){case"start":m[a]-=p*(n&&u?-1:1);break;case"end":m[a]+=p*(n&&u?-1:1);break}return m}async function dle(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:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:m=0}=nu(t,e),y=y$(m),b=l[p?f==="floating"?"reference":"floating":f],g=Om(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:d,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)),C=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=Om(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-S.top+y.top)/C.y,bottom:(S.bottom-g.bottom+y.bottom)/C.y,left:(g.left-S.left+y.left)/C.x,right:(S.right-g.right+y.right)/C.x}}const fle=50,ple=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:dle},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=eA(u,r,c),p=r,m=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:C,data:S,reset:N}=await k({x:d,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});d=x??d,f=C??f,y[g]={...y[g],...S},N&&m<fle&&(m++,typeof N=="object"&&(N.placement&&(p=N.placement),N.rects&&(u=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):N.rects),{x:d,y:f}=eA(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:y}},hle=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:d=0}=nu(e,t)||{};if(u==null)return{};const f=y$(d),p={x:n,y:r},m=Bv(s),y=zv(m),v=await a.getDimensions(u),b=m==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=o.reference[y]+o.reference[m]-p[m]-o.floating[y],S=p[m]-o.reference[m],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=C/2-S/2,z=P/2-v[y]/2-1,E=Kc(f[g],z),O=Kc(f[k],z),D=E,L=P-v[y]-O,M=P/2-v[y]/2+R,V=Fb(D,M,L),B=!c.arrow&&Li(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{[m]:p[m]+F,data:{[m]:V,centerOffset:M-V-F,...B&&{alignmentOffset:F}},reset:B}}});function mle(e,t,n){return(e?[...n.filter(s=>Li(s)===e),...n.filter(s=>Li(s)!==e)]:n.filter(s=>yo(s)===s)).filter(s=>e?Li(s)===e||(t?$m(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:d=!1,alignment:f,allowedPlacements:p=X_,autoAlignment:m=!0,...y}=nu(e,t),v=f!==void 0||p===X_?mle(f||null,m,p):p,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=g$(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const C=[b[yo(k)],b[x[0]],b[x[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:C}],N=v[g+1];if(N)return{data:{index:g+1,overflows:S},reset:{placement:N}};const P=S.map(E=>{const O=Li(E.placement);return[E.placement,O&&d?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,Li(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:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=nu(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=yo(s),k=qo(l),x=yo(l)===l,C=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=p||(x||!v?[Lm(l)]:ile(l)),N=y!=="none";!p&&N&&S.push(...cle(l,v,y,C));const P=[l,...S],R=await c.detectOverflow(t,b),z=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&z.push(R[g]),f){const M=g$(s,a,C);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!==qo(V):!1)||E.every($=>qo($.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(m){case"bestFit":{var L;const F=(L=E.filter($=>{if(N){const H=qo($.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{}}}},wle=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=yo(n),l=Li(n),c=qo(n)==="y",u=wle.has(a)?-1:1,d=o&&c?-1:1,f=nu(t,e);let{mainAxis:p,crossAxis:m,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"&&(m=l==="end"?y*-1:y),c?{x:m*d,y:p*u}:{x:p*u,y:m*d}}const ble=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}}}}},kle=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}=nu(e,t),d={x:n,y:r},f=await o.detectOverflow(t,u),p=qo(yo(s)),m=m$(p);let y=d[m],v=d[p];if(a){const g=m==="y"?"top":"left",k=m==="y"?"bottom":"right",x=y+f[g],C=y-f[k];y=Fb(x,y,C)}if(l){const g=p==="y"?"top":"left",k=p==="y"?"bottom":"right",x=v+f[g],C=v-f[k];v=Fb(x,v,C)}const b=c.fn({...t,[m]:y,[p]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[m]:a,[p]:l}}}}}};function Ng(){return typeof window<"u"}function ru(e){return w$(e)?(e.nodeName||"").toLowerCase():"#document"}function ms(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function zi(e){var t;return(t=(w$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function w$(e){return Ng()?e instanceof Node||e instanceof ms(e).Node:!1}function ui(e){return Ng()?e instanceof Element||e instanceof ms(e).Element:!1}function ko(e){return Ng()?e instanceof HTMLElement||e instanceof ms(e).HTMLElement:!1}function tA(e){return!Ng()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ms(e).ShadowRoot}function Tf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=di(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function vle(e){return/^(table|td|th)$/.test(ru(e))}function Cg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Sle=/transform|translate|scale|rotate|perspective|filter/,jle=/paint|layout|strict|content/,Ea=e=>!!e&&e!=="none";let Lw;function Wv(e){const t=ui(e)?di(e):e;return Ea(t.transform)||Ea(t.translate)||Ea(t.scale)||Ea(t.rotate)||Ea(t.perspective)||!Hv()&&(Ea(t.backdropFilter)||Ea(t.filter))||Sle.test(t.willChange||"")||jle.test(t.contain||"")}function Nle(e){let t=ua(e);for(;ko(t)&&!qc(t);){if(Wv(t))return t;if(Cg(t))return null;t=ua(t)}return null}function Hv(){return Lw==null&&(Lw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lw}function qc(e){return/^(html|body|#document)$/.test(ru(e))}function di(e){return ms(e).getComputedStyle(e)}function _g(e){return ui(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ua(e){if(ru(e)==="html")return e;const t=e.assignedSlot||e.parentNode||tA(e)&&e.host||zi(e);return tA(t)?t.host:t}function x$(e){const t=ua(e);return qc(t)?e.ownerDocument?e.ownerDocument.body:e.body:ko(t)&&Tf(t)?t:x$(t)}function ff(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=x$(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ms(s);if(o){const l=zb(a);return t.concat(a,a.visualViewport||[],Tf(s)?s:[],l&&n?ff(l):[])}else return t.concat(s,ff(s,[],n))}function zb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function b$(e){const t=di(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ko(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=Mm(n)!==o||Mm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Vv(e){return ui(e)?e:e.contextElement}function Ac(e){const t=Vv(e);if(!ko(t))return $i(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=b$(t);let a=(o?Mm(n.width):n.width)/r,l=(o?Mm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Cle=$i(0);function k$(e){const t=ms(e);return!Hv()||!t.visualViewport?Cle:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _le(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ms(e)?!1:t}function fl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Vv(e);let a=$i(1);t&&(r?ui(r)&&(a=Ac(r)):a=Ac(e));const l=_le(o,n,r)?k$(o):$i(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,d=s.width/a.x,f=s.height/a.y;if(o){const p=ms(o),m=r&&ui(r)?ms(r):r;let y=p,v=zb(y);for(;v&&r&&m!==y;){const b=Ac(v),g=v.getBoundingClientRect(),k=di(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,C=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,d*=b.x,f*=b.y,c+=x,u+=C,y=ms(v),v=zb(y)}}return Om({width:d,height:f,x:c,y:u})}function Ag(e,t){const n=_g(e).scrollLeft;return t?t.left+n:fl(zi(e)).left+n}function v$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Ag(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Ale(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=zi(r),l=t?Cg(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=$i(1);const d=$i(0),f=ko(r);if((f||!f&&!o)&&((ru(r)!=="body"||Tf(a))&&(c=_g(r)),f)){const m=fl(r);u=Ac(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const p=a&&!f&&!o?v$(a,c):$i(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Ele(e){return Array.from(e.getClientRects())}function Ile(e){const t=zi(e),n=_g(e),r=e.ownerDocument.body,s=Ja(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ja(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Ag(e);const l=-n.scrollTop;return di(r).direction==="rtl"&&(a+=Ja(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const nA=25;function Ple(e,t){const n=ms(e),r=zi(e),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){o=s.width,a=s.height;const d=Hv();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=Ag(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),m=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-m);y<=nA&&(o-=y)}else u<=nA&&(o+=u);return{width:o,height:a,x:l,y:c}}function Rle(e,t){const n=fl(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=ko(e)?Ac(e):$i(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 rA(e,t,n){let r;if(t==="viewport")r=Ple(e,n);else if(t==="document")r=Ile(zi(e));else if(ui(t))r=Rle(t,n);else{const s=k$(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Om(r)}function S$(e,t){const n=ua(e);return n===t||!ui(n)||qc(n)?!1:di(n).position==="fixed"||S$(n,t)}function Tle(e,t){const n=t.get(e);if(n)return n;let r=ff(e,[],!1).filter(l=>ui(l)&&ru(l)!=="body"),s=null;const o=di(e).position==="fixed";let a=o?ua(e):e;for(;ui(a)&&!qc(a);){const l=di(a),c=Wv(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Tf(a)&&!c&&S$(e,a))?r=r.filter(d=>d!==a):s=l,a=ua(a)}return t.set(e,r),r}function Mle(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Cg(t)?[]:Tle(t,this._c):[].concat(n),r],l=rA(t,a[0],s);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const m=rA(t,a[p],s);c=Ja(m.top,c),u=Kc(m.right,u),d=Kc(m.bottom,d),f=Ja(m.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function $le(e){const{width:t,height:n}=b$(e);return{width:t,height:n}}function Lle(e,t,n){const r=ko(t),s=zi(t),o=n==="fixed",a=fl(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=$i(0);function u(){c.x=Ag(s)}if(r||!r&&!o)if((ru(t)!=="body"||Tf(s))&&(l=_g(t)),r){const m=fl(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&u();o&&!r&&s&&u();const d=s&&!r&&!o?v$(s,l):$i(0),f=a.left+l.scrollLeft-c.x-d.x,p=a.top+l.scrollTop-c.y-d.y;return{x:f,y:p,width:a.width,height:a.height}}function Ow(e){return di(e).position==="static"}function sA(e,t){if(!ko(e)||di(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return zi(e)===n&&(n=n.ownerDocument.body),n}function j$(e,t){const n=ms(e);if(Cg(e))return n;if(!ko(e)){let s=ua(e);for(;s&&!qc(s);){if(ui(s)&&!Ow(s))return s;s=ua(s)}return n}let r=sA(e,t);for(;r&&vle(r)&&Ow(r);)r=sA(r,t);return r&&qc(r)&&Ow(r)&&!Wv(r)?n:r||Nle(e)||n}const Ole=async function(e){const t=this.getOffsetParent||j$,n=this.getDimensions,r=await n(e.floating);return{reference:Lle(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Dle(e){return di(e).direction==="rtl"}const Fle={convertOffsetParentRelativeRectToViewportRelativeRect:Ale,getDocumentElement:zi,getClippingRect:Mle,getOffsetParent:j$,getElementRects:Ole,getClientRects:Ele,getDimensions:$le,getScale:Ac,isElement:ui,isRTL:Dle};function N$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function zle(e,t){let n=null,r;const s=zi(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:d,top:f,width:p,height:m}=u;if(l||t(),!p||!m)return;const y=nh(f),v=nh(s.clientWidth-(d+p)),b=nh(s.clientHeight-(f+m)),g=nh(d),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Ja(0,Kc(1,c))||1};let C=!0;function S(N){const P=N[0].intersectionRatio;if(P!==c){if(!C)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!N$(u,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(S,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return a(!0),o}function iA(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=Vv(e),d=s||o?[...u?ff(u):[],...t?ff(t):[]]:[];d.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?zle(u,n):null;let p=-1,m=null;a&&(m=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),u&&!c&&m.observe(u),t&&m.observe(t));let y,v=c?fl(e):null;c&&b();function b(){const g=fl(e);v&&!N$(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;d.forEach(k=>{s&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),f==null||f(),(g=m)==null||g.disconnect(),m=null,c&&cancelAnimationFrame(y)}}const Ble=ble,Wle=gle,Hle=kle,Vle=yle,oA=hle,Kle=(e,t,n)=>{const r=new Map,s={platform:Fle,...n},o={...s.platform,_c:r};return ple(e,t,{...s,platform:o})};var qle=typeof document<"u",Ule=function(){},Ph=qle?h.useLayoutEffect:Ule;function Dm(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(!Dm(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)&&!Dm(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function C$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function aA(e,t){const n=C$(e);return Math.round(t*n)/n}function Dw(e){const t=h.useRef(e);return Ph(()=>{t.current=e}),t}function lA(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,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);Dm(p,r)||m(r);const[y,v]=h.useState(null),[b,g]=h.useState(null),k=h.useCallback($=>{$!==N.current&&(N.current=$,v($))},[]),x=h.useCallback($=>{$!==P.current&&(P.current=$,g($))},[]),C=o||y,S=a||b,N=h.useRef(null),P=h.useRef(null),R=h.useRef(d),z=c!=null,E=Dw(c),O=Dw(s),D=Dw(u),L=h.useCallback(()=>{if(!N.current||!P.current)return;const $={placement:t,strategy:n,middleware:p};O.current&&($.platform=O.current),Kle(N.current,P.current,$).then(H=>{const A={...H,isPositioned:D.current!==!1};M.current&&!Dm(R.current,A)&&(R.current=A,lr.flushSync(()=>{f(A)}))})},[p,t,n,O,D]);Ph(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const M=h.useRef(!1);Ph(()=>(M.current=!0,()=>{M.current=!1}),[]),Ph(()=>{if(C&&(N.current=C),S&&(P.current=S),C&&S){if(E.current)return E.current(C,S,L);L()}},[C,S,L,E,z]);const V=h.useMemo(()=>({reference:N,floating:P,setReference:k,setFloating:x}),[k,x]),B=h.useMemo(()=>({reference:C,floating:S}),[C,S]),F=h.useMemo(()=>{const $={position:n,left:0,top:0};if(!B.floating)return $;const H=aA(B.floating,d.x),A=aA(B.floating,d.y);return l?{...$,transform:"translate("+H+"px, "+A+"px)",...C$(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:A}},[n,l,B.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:L,refs:V,elements:B,floatingStyles:F}),[d,L,V,B,F])}const Yle=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?oA({element:r.current,padding:s}).fn(n):{}:r?oA({element:r,padding:s}).fn(n):{}}}},cA=(e,t)=>{const n=Ble(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gle=(e,t)=>{const n=Hle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jle=(e,t)=>{const n=Vle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xle=(e,t)=>{const n=Wle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qle=(e,t)=>{const n=Yle(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zle={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},ece={beaconOptions:{offset:-18}},_$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},tce={isFixed:!1,locale:_$,placement:"bottom"},nce={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"},Si={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"},rce="react-joyride-portal";function sce(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function hc(...e){return Yae({all:!0,isMergeableObject:t=>!(!Ir.plainObject(t)||h.isValidElement(t))})(...e)}function A$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Zi(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=$w(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&s&&(o=o.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(h.isValidElement(e)&&!Object.values(e.props).length&&A$(e.type)==="function")try{o=Zi(e.type({}),t)}catch{o=$w(n)}else o=$w(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 ice(e,t){const n=sce(t);return{...e,...n}}function pf(){}function oce(e){return Object.keys(e)}function Fm(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 uA(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 Bb(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(A$(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:s}=e.props;if(Ir.string(s)&&s.includes("{current}"))return h.cloneElement(e,{children:r(s)});if(Array.isArray(s))return h.cloneElement(e,{children:s.map(o=>typeof o=="string"?r(o):Bb(o,t,n))});if(Ir.function(e.type)&&!Object.values(e.props).length)try{return Bb(e.type({}),t,n)}catch{return e}return e}function dA(e){return oce(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Kv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function fA(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 qv(e){return e?e.getBoundingClientRect():null}function ace(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 Ts(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 lce(e,t,n){const r=qv(e),s=su(e),o=s?!s.isSameNode(Qr()):!1,a=n??iu(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 su(e,t){if(!e)return Qr();const n=h$(e);if(n){if(n.isSameNode(Qr()))return t?document:Qr();if(!(n.scrollHeight>n.offsetHeight))return Qr()}return n}function cce(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 uce(e,t){if(!e)return 0;const n=h$(e)??Qr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=qv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(E$(e)||dce(e))){const d=e.getBoundingClientRect(),f=d.top-((s==null?void 0:s.top)??0),p=f+d.height,m=n.clientHeight,y=m*.2;f>=y&&p<=m-y?c=o:c=f+o}const u=Math.floor(c-t-r);return u<0?0:u}function dce(e){return e.offsetParent!==document.body}function E$(e){if(!e)return!1;const t=su(e);return t?!t.isSameNode(Qr()):!1}function iu(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?iu(e.parentNode,t):!1}function rh(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 pA(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?su(s):Qr(),l=a?!a.isSameNode(Qr()):!1;return(r.isFixed||iu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Qr(){return document.scrollingElement??document.documentElement}function hA(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 fce(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 I$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},sh={...I$,borderRadius:4,padding:8};function pce(e,t){const{styles:n}=e,r=hc(n??{},t.styles??{});let{width:s}=t;Kv()&&(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 hc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...I$,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(${fce(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:{...sh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...sh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...sh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...sh,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 hce=["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 Uv(e,t){if(!t)return null;const n=hc(tce,uA(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=hc(Zle,e.options??{},uA(t,...hce)),s=pce(e,{...n,...r}),o=hc(ece,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:hc(_$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:mce(r.spotlightPadding),styles:s}}function mce(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 P$(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 R$(e,t=!1){return Ir.array(e)?e.every(n=>P$(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",()=>Fm(this.snapshot,"positioned"));Tn(this,"getState",()=>Fm(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,!Lv(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 Uv(this.props,this.steps[e??this.state.index])}};function wce(e){return new yce(e)}function mA(e,t){return Math.min(Math.max(e,0),t)}function xce(e,t,n){const r=h.useRef(t),s=h.useRef(n);return r.current=t,s.current=n,h.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:()=>Fm(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===Et.RUNNING&&e.current.updateState({action:Dt.NEXT,index:mA(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:mA(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 bce=new Set(["origin","positioned"]);function kce(e,t){const n=h.useRef(null);h.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]&&!bce.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 vce(e,t,n){const r=h.useRef(e),s=h.useRef(t);return r.current=e,s.current=t,h.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 Do(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 Sce(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:o,state:a,step:l,store:c}=e,{action:u,index:d,lifecycle:f,positioned:p,scrolling:m,size:y,status:v}=a,b=o$(l)??null,g=h.useRef(null),k=h.useRef(o),x=h.useRef(a),C=h.useRef(s),S=h.useRef(l),N=h.useRef(b),P=h.useRef(n),R=h.useRef(null),z=h.useRef(null),E=h.useRef(null);k.current=o,x.current=a,C.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)};h.useEffect(()=>{if(!C.current)return;const{hasChangedTo:D}=Do(x.current,C.current);(D("action",[Dt.NEXT,Dt.PREV,Dt.SKIP,Dt.CLOSE])||g.current===Dt.CLOSE&&u===Dt.START)&&(g.current=u)},[u]),h.useEffect(()=>{if(!C.current)return()=>{O()};const{hasChanged:D}=Do(x.current,C.current),L=S.current;if(D("index")&&O(),v!==Et.RUNNING||!L||f!==Je.INIT)return()=>{O()};const{hasChangedTo:M}=Do(x.current,C.current);M("status",Et.RUNNING)&&[Et.IDLE,Et.READY,Et.PAUSED].includes(C.current.status)&&r(ar.TOUR_START,L),c.current.cleanupPositionData();const{debug:V}=k.current;if(L.before&&!E.current){dr(V,`step:${d}`,"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:${d}`,"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=Ts(L.target);if(B&&rh(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:${d}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),R.current=setInterval(()=>{const H=Ts(L.target),A=Date.now()-$,Q=A>=F;(H&&rh(H)||Q)&&(dr(V,`step:${d}`,"polling",H&&rh(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,d,f,v,c]),h.useEffect(()=>{if(!C.current)return;const{hasChanged:D,hasChangedTo:L,previous:M}=Do(x.current,C.current),V=S.current;if(!V)return;const B=Ts(V.target),F=!!B;if(F&&rh(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=Ts(V.scrollTarget??V.spotlightTarget??V.target),Q=pA({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:${d}`,"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:${d}`,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,d,f,c]),h.useEffect(()=>{if(!C.current)return;const{hasChangedTo:D,previous:L}=Do(x.current,C.current),M=S.current,V=N.current;if(M&&D("lifecycle",Je.TOOLTIP_BEFORE)&&L.lifecycle===Je.BEACON){const $=Ts(M.scrollTarget??M.spotlightTarget??M.target);if(pA({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&&!m){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,p,m,c]),h.useEffect(()=>{if(!C.current)return;const{hasChangedTo:D,previous:L}=Do(x.current,C.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)&&d<y&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.INIT}),D("lifecycle",Je.COMPLETE)&&d>=y&&c.current.updateState({action:Dt.UPDATE,lifecycle:Je.COMPLETE,status:Et.FINISHED});const B=M??V??Uv(k.current,k.current.steps[d-1]);if(B&&D("status",[Et.FINISHED,Et.SKIPPED])){let F;M?F=d:V?F=L.index??d:F=d-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,d,f,y,v,c])}function jce({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,d=h.useRef(void 0),f=h.useRef(r),p=h.useRef(e);f.current=r,p.current=e,h.useEffect(()=>{const m=d.current;if(d.current=n,!m||n===m)return;const{hasChanged:y}=Do(n,m);if(Lv(m.steps,u)||(R$(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&&p.current.start(c??a):p.current.stop();else if(Ir.number(c)&&y("stepIndex")){const v=Ir.number(m.stepIndex)&&m.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 Nce(e,t){var l,c,u,d;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=Cce(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Je.TOOLTIP_BEFORE){const{placement:f}=o;if(f==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,m=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+m;a-=p+y}else if(f==="left"||f==="right"){const p=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,m=((d=Ts(o.target))==null?void 0:d.getBoundingClientRect().height)??0,y=s+o.spotlightPadding.top+m/2-p/2;y<s&&(a-=s-y)}}return Math.max(0,a)}function Cce(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 _ce({emitEvent:e,previousState:t,props:n,state:r,step:s,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:d}=r,f=h.useRef(null),p=h.useRef(r),m=h.useRef(t),y=h.useRef(n),v=h.useRef(s);p.current=r,m.current=t,y.current=n,v.current=s,h.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),h.useEffect(()=>{var S;if(!m.current||!v.current)return;const{hasChangedTo:b}=Do(p.current,m.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,C=l===Je.BEACON_BEFORE||l===Je.TOOLTIP_BEFORE;if(d===Et.RUNNING&&C&&u&&b("positioned",!0)){const N=Ts(g.scrollTarget??g.spotlightTarget??g.target),P=o.current.getPositionData("beacon"),R=su(N),z=R?!R.isSameNode(Qr()):!1;(S=f.current)==null||S.call(f),(async()=>{if(z&&!iu(R)){const F=Qr(),$=cce(R),H={initial:F.scrollTop,target:$,element:F,duration:x};e(ar.SCROLL_START,g,{scroll:H});const{cancel:A,promise:Q}=hA($,{element:F,duration:x});f.current=A,await Q,e(ar.SCROLL_END,g,{scroll:H})}const O=Math.floor(uce(N,g.scrollOffset))||0,D=z?O:Nce(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}=hA(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,d,o])}function Ace(e){const t=uae(()=>ice(nce,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=h.useRef(wce(t)),u=lR.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[d,f]=h.useState([]),p=h.useCallback((S,N)=>{f(P=>[...P,{reason:N,step:S}])},[]),m=h.useCallback(()=>{f([])},[]);kce(c,n);const y=xce(c,n,m),v=vce(s,y,c),{index:b,size:g,status:k}=u,x=o$(u),C=h.useMemo(()=>Uv(t,l[b]),[b,t,l]);return dae(()=>{o&&g&&R$(l,n)&&y.start(a??r)}),cae(()=>{o&&g&&k===Et.IDLE&&c.current.updateState({status:Et.READY})},[o,g,k]),jce({controls:y,emitEvent:v,props:t,state:u,store:c}),Sce({addFailure:p,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:C,store:c}),_ce({emitEvent:v,previousState:x,props:t,state:u,step:C,store:c}),{controls:y,failures:d,mergedProps:t,state:u,step:C,store:c}}function Ece(e){const[t,n]=h.useState(null);return h.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=rce,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Ice={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Pce({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return pf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
391
+ @keyframes joyride-loader-spin {
392
+ to { transform: rotate(360deg); }
393
+ }
394
+ `)),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:{...Ice,height:s,width:o,borderTopColor:t.primaryColor}});return pt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Rce={height:0,isFixed:!1,left:0,top:0,width:0};function Gu(e,t){const n=Ts(e);if(!n)return Rce;const r=qv(n),s=iu(n),o=lce(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 Tce(e,t,n){const[r,s]=h.useState(()=>Gu(e,t)),o=h.useRef(void 0),a=h.useRef(null),l=h.useRef(n),c=h.useRef(null),u=h.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(f=>{const p=Gu(e,t);return f.top===p.top&&f.left===p.left&&f.width===p.width&&f.height===p.height&&f.isFixed===p.isFixed?f:p})},100)},[e,t]);h.useEffect(()=>{let f=null;const p=y=>{a.current=su(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(Gu(e,t))},m=Ts(e);return m?p(m):(f=new MutationObserver(()=>{const y=Ts(e);y&&(f==null||f.disconnect(),f=null,p(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]),h.useEffect(()=>{l.current&&!n&&s(Gu(e,t)),l.current=n},[n,e,t]);let d=r;return l.current&&!n&&(d=Gu(e,t)),d}function Mce(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function gA(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 $ce=[Je.BEACON_BEFORE,Je.BEACON];function Lce(e){var B,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:d,spotlightRadius:f,spotlightTarget:p,styles:m,target:y,waiting:v}=e,b=fae(),g=Tce(p??y,d,u||v),k=h.useRef(null),x=(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE)&&l!=="center",[C,S]=h.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)??ace()??b.height,z=((F=m.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",E=h.useMemo(()=>{const{backgroundColor:$,mixBlendMode:H,...A}=m.overlay;return{height:R,pointerEvents:"none",...A}},[R,m.overlay]),O=x&&!u&&!v;h.useEffect(()=>{O?requestAnimationFrame(()=>S(!0)):S(!1)},[O]);const D=n&&$ce.includes(s),L=!n&&s!==Je.TOOLTIP;if(r||!v&&(D||L))return null;let M="";if(O)if(c&&N){const $=Ts(p??y);if($){const H=fA($),A=fA(N);M=gA(H.left-A.left-d.left,H.top-A.top-d.top,$.offsetWidth+d.left+d.right,$.offsetHeight+d.top+d.bottom,f)}}else M=gA(g.left,g.top,g.width,g.height,f);const V=Mce(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:C?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(m.spotlight).length>0&&pt.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...m.spotlight})))}function T$(e){const{children:t,element:n}=e;return n?lr.createPortal(t,n):null}const Oce='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Dce(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return pf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Oce)],{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 so(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 Fce(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...so(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...so(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...so(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...so(e,t,n)};default:return null}}function zce(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...so(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...so(e,r,n)};case"left":return{right:-n,top:t.y??0,...so(e,r,n)};case"right":return{left:-n,top:t.y??0,...so(e,r,n)};default:return{}}}function Bce({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!so(r,n,o))return null;c=pt.createElement("span",{style:{flexShrink:0}},pt.createElement(l,{base:n,placement:r,size:o}))}else{const u=Fce(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,...zce(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function Wce(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:d,styles:f}=e,p=h.useRef(null),m=!!t;h.useEffect(()=>{if(m||document.getElementById("joyride-beacon-animation"))return pf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
395
+ @keyframes joyride-beacon-inner {
396
+ 20% {
397
+ opacity: 0.9;
398
+ }
399
+
400
+ 90% {
401
+ opacity: 0.7;
402
+ }
403
+ }
404
+
405
+ @keyframes joyride-beacon-outer {
406
+ 0% {
407
+ transform: scale(1);
408
+ }
409
+
410
+ 45% {
411
+ opacity: 0.7;
412
+ transform: scale(0.75);
413
+ }
414
+
415
+ 100% {
416
+ opacity: 0.9;
417
+ transform: scale(1);
418
+ }
419
+ }
420
+ `)),document.head.appendChild(b);const g=setTimeout(()=>{Ir.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[m,a,c]);const y=Zi(o.open);let v;if(t){const b=t;v=pt.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}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:p,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function Hce({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 Vce(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,m={};u.includes("primary")&&(m.primary=pt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(m.skip=pt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(m.back=pt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),m.close=u.includes("close")&&pt.createElement(Hce,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Zi(d),"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},p&&pt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),pt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&pt.createElement("div",{style:f.tooltipFooter},pt.createElement("div",{style:f.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function Kce(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Si.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Si.BUTTON_CLOSE):n.close(Si.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Si.BUTTON_PRIMARY);return}n.next(Si.BUTTON_PRIMARY)},d=g=>{g.preventDefault(),n.skip(Si.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:C,nextWithProgress:S,skip:N}=a.locale,P=Zi(g),R=Zi(k),z=Zi(x),E=Zi(C),O=Zi(N);let D=k,L=R;if(t){if(D=C,L=E,a.showProgress&&!s){const M=Zi(S,{step:r+1,steps:o});D=Bb(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:d,role:"button",title:O},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:m,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(Vce,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function qce(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Uce(e,t,n){var r,s;return e?[Xle()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Jle({crossAxis:!1,fallbackPlacements:qce(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Yce(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:d,size:f,step:p,target:m,updateState:y}=e,v=h.useRef(null),b=h.useRef({}),g=h.useRef({}),k=p.placement==="center",x=p.placement==="auto",C=h.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=h.useMemo(()=>E$(m)?su(m):void 0,[m]),N=h.useMemo(()=>iu(m),[m]),P=h.useMemo(()=>S?{boundary:S,rootBoundary:"viewport"}:{},[S]),R=k||x?"bottom":p.placement,z=k?"fixed":((H=p.floatingOptions)==null?void 0:H.strategy)??(p.isFixed||N?"fixed":"absolute"),E=h.useMemo(()=>{var te,Z,Y,ne;return k?[{name:"center",fn:({rects:re})=>({x:(window.innerWidth-re.floating.width)/2,y:(window.innerHeight-re.floating.height)/2})}]:[cA(({placement:re})=>{var ue;let se="right";re.startsWith("top")?se="top":re.startsWith("bottom")?se="bottom":re.startsWith("left")&&(se="left");const ee=p.spotlightTarget?0:p.spotlightPadding[se];return p.offset+ee+((ue=p.floatingOptions)!=null&&ue.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(te=p.floatingOptions)==null?void 0:te.hideArrow]),...Uce(x,p,R),Gle({padding:10,...P,...(Z=p.floatingOptions)==null?void 0:Z.shiftOptions}),...(Y=p.floatingOptions)!=null&&Y.hideArrow?[]:[Qle({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ne=p.floatingOptions)==null?void 0:ne.middleware)??[]]},[k,p,x,R,P]),O=lA({...k?{elements:{reference:C}}:{},placement:R,strategy:z,middleware:E}),D=lA({strategy:z,placement:p.beaconPlacement??(x||k?"bottom":p.placement),middleware:h.useMemo(()=>{var te,Z;return[cA(((Z=(te=p.floatingOptions)==null?void 0:te.beaconOptions)==null?void 0:Z.offset)??-18)]},[(Q=(A=p.floatingOptions)==null?void 0:A.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:iA});g.current=O.middlewareData,b.current=D.middlewareData,h.useEffect(()=>{var Y;const{floating:te,reference:Z}=O.elements;if(!(!Z||!te||s!==Je.TOOLTIP))return iA(Z,te,O.update,(Y=p.floatingOptions)==null?void 0:Y.autoUpdate)},[s,O.update,(K=p.floatingOptions)==null?void 0:K.autoUpdate,p.target,O.elements]),h.useEffect(()=>{!k&&m&&O.refs.setReference(m),m&&D.refs.setReference(m)},[D.refs,k,m,O.refs]),h.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]),h.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=p.zIndex+100,M=h.useCallback(te=>{te.type==="mouseenter"&&p.beaconTrigger!=="hover"||y({lifecycle:Je.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,y]),V=h.useCallback(te=>{te&&(O.refs.setFloating(te),u(te))},[O.refs,u]),{arrow:B,floater:F}=p.styles;let $=null;if(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE){const te=dA({...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(Kce,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((W=p.floatingOptions)!=null&&W.hideArrow)&&pt.createElement(Bce,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:O.placement,position:O.middlewareData.arrow,size:p.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:dA({...D.floatingStyles,zIndex:L})},pt.createElement(Wce,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:o,onInteract:M,shouldFocus:d,size:f,step:p,styles:p.styles})));return pt.createElement(T$,{element:l},$)}function Gce(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:d,updateState:f}=e,[p,m]=h.useState(null);Dce(d.disableFocusTrap?null:p,"[data-action=primary]");const y=Ts(d.target),v=s===Je.TOOLTIP;return!P$(d)||!Ir.domElement(y)?null:pt.createElement(Yce,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:u,step:d,target:y,updateState:f})}function Jce({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=Ece(c),{index:f,lifecycle:p,status:m}=n,y=m===Et.RUNNING,[v,b]=h.useState(!1),g=h.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;h.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]),h.useEffect(()=>{if(!y)return;const S=N=>{!r||p!==Je.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Si.KEYBOARD):e.close(Si.KEYBOARD))};return document.body.addEventListener("keydown",S,{passive:!0}),()=>{document.body.removeEventListener("keydown",S)}},[e,y,p,r]);const x=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Si.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Si.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const C=n.action===Dt.START&&!r.skipBeacon&&r.placement!=="center";return pt.createElement(pt.Fragment,null,p!==Je.INIT&&pt.createElement(Gce,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:d,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),pt.createElement(T$,{element:d},pt.createElement(pt.Fragment,null,v&&pt.createElement(Pce,{nonce:l,step:r}),!C&&pt.createElement(Lce,{...r,continuous:o,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Xce(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=Ace(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>Fm(s,"positioned"),[s]),step:o,Tour:Kv()?pt.createElement(Jce,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function Qce(e){const{Tour:t}=Xce(e);return t}function Zce(e){return Kv()?pt.createElement(Qce,e):null}function eue(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 nue(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const ih="af:onboarding";function rue({page:e,hasNodes:t=!1}){const{t:n}=Vr(),[r,s]=h.useState(!1),[o,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?eue(n):t?tue(n):nue(n),[e,t,n]);return h.useEffect(()=>{const u=localStorage.getItem(ih),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(ih,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const u=d=>{var y;const f=d.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const m=(y=f.textContent)==null?void 0:y.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const v=localStorage.getItem(ih)||"{}",b=JSON.parse(v);m===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(ih,JSON.stringify(b)),a([]),s(!1),e==="projects"&&(m===n("onboarding:done")||m===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(Zce,{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 sue="agentflow:recent-runs:v1",iue="agentflow:recent-runs:poller",oue=3e3,aue=8e3,lue=2e3,yA=5e3,cue=16e3,wA=[1e4,3e4,6e4];function uue(e){return wA[Math.min(Math.max(e-1,0),wA.length-1)]}function due(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function fue(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function pue(){const{navigate:e,path:t}=rs(),[n,r]=h.useState([]),[s,o]=h.useState(!1),[a,l]=h.useState(1),[c,u]=h.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=h.useRef(()=>{});h.useEffect(()=>{let C=!1,S=!1,N=!1,P=null,R=0,z=0,E=0,O=0,D=null,L=0,M=0;const V=due(),B=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(sue):null,$=Ne=>{try{F==null||F.postMessage({...Ne,tabId:V,sentAt:Date.now()})}catch{}},H=()=>{const Ne=Date.now()-cue;for(const[Ce,He]of B)He<Ne&&B.delete(Ce);l(1+B.size)},A=(Ne="presence")=>{$({type:Ne,visible:!document.hidden})},Q=Ne=>{if(!C&&(Array.isArray(Ne.runs)&&r(Ne.runs),Ne.syncHealth&&typeof Ne.syncHealth=="object")){const Ce=Ne.syncHealth;L=Number(Ce.failureCount)||0,M=Number(Ce.lastSuccessAt)||0,u(Ce)}},K=Ne=>{Q(Ne),$({type:"state",...Ne})},W=()=>{R&&(window.clearTimeout(R),R=0)},te=Ne=>{W(),!(C||!S||document.hidden)&&(R=window.setTimeout(()=>{R=0,Z()},Math.max(0,Ne)))},Z=async()=>{if(C||!S||document.hidden||D)return;const Ne=new AbortController;D=Ne;let Ce=!1;const He=window.setTimeout(()=>{Ce=!0,Ne.abort()},aue);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(C||!S||document.hidden)return;L=0,M=Date.now();const Re=Array.isArray(yt.runs)?yt.runs:[];K({runs:Re.filter(ot=>ot&&ot.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),te(oue)}catch(ct){const yt=Ne.signal.aborted&&!Ce;if(C||!S||document.hidden||yt)return;L+=1,K({syncHealth:{status:"delayed",failureCount:L,lastSuccessAt:M,message:Ce?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ct==null?void 0:ct.message)||ct)}`}}),te(uue(L))}finally{window.clearTimeout(He),D===Ne&&(D=null)}},Y=()=>{W(),D&&(D.abort(),D=null)},ne=()=>{if(Y(),P){const Ne=P;P=null,Ne()}S=!1},re=(Ne=lue)=>{z&&window.clearTimeout(z),!(C||document.hidden||S||N)&&(z=window.setTimeout(()=>{z=0,ee()},Ne))},se=()=>{C||document.hidden||S||(S=!0,te(0))},ee=async()=>{var Ne;if(!(C||document.hidden||S||N)){if(!((Ne=navigator.locks)!=null&&Ne.request)){se();return}N=!0;try{await navigator.locks.request(iue,{mode:"exclusive",ifAvailable:!0},async Ce=>{if(N=!1,!Ce||C||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(!C){if(S){L=0,te(0);return}$({type:"retry"}),re(0)}};d.current=ue,F&&(F.onmessage=Ne=>{const Ce=Ne.data;if(!(!Ce||Ce.tabId===V)){if(Ce.type==="hello"||Ce.type==="presence"){B.set(Ce.tabId,Date.now()),H(),Ce.type==="hello"&&A();return}if(Ce.type==="bye"){B.delete(Ce.tabId),H(),re(0);return}if(Ce.type==="state"){B.set(Ce.tabId,Date.now()),H(),Q(Ce);return}Ce.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,yA),O=window.setInterval(H,yA),re(0),()=>{C=!0,d.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=C=>{const S=new URLSearchParams({flowId:C.flowId,flowSource:C.flowSource||"workspace"});e(`/flow?${S.toString()}`),o(!1)},p=t==="/flow"?new URLSearchParams(window.location.search):null,m=(p==null?void 0:p.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(C=>!C)};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:["最近成功:",fue(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:C=>{C.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(C=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(C.flowId===m?" af-run-indicator__item--current":""),onClick:()=>f(C),title:`${C.flowId} · ${C.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:C.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:C.runId.slice(0,12)})]},`${C.flowId}:${C.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 Fw="0.1.135",hue=6e4,mue=30*6e4;function Uc(e){return String(e||"").trim().replace(/^v/i,"")}function gue(e,t){const n=Uc(e),r=Uc(t);return!!(n&&r&&n!==r)}function yue(e,t){return`agentflow.app-version.snooze:${Uc(e)}:${Uc(t)}`}function wue(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]=h.useState(null);if(h.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 d=Uc(u.version);if(!gue(Fw,d)){t(null);return}const f=yue(Fw,d);if(wue(f)>Date.now())return;t({clientVersion:Uc(Fw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),hue);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()+mue))}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 M$(e){return e==="/likee-context"||e==="/likee_context"}function bue(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function kue(){const{navigate:e}=rs();return h.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 vue extends h.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 Sue({authUser:e}){const{path:t}=rs();return t==="/projects"||t==="/"?i.jsx(Bl,{authUser:e}):t==="/nodes"?i.jsx(Bl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Bl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Bl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Bl,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(voe,{authUser:e}):t==="/workflows"?i.jsx(Moe,{}):t==="/workflow-report"?i.jsx(Boe,{}):t==="/mcps"?i.jsx(uoe,{}):t==="/schedules"?i.jsx(hoe,{}):t==="/node-studio"?i.jsx(goe,{}):t==="/flow"?i.jsx(kue,{}):t==="/workspace"?i.jsx(BM,{}):t.startsWith("/display")?i.jsx(VM,{}):t==="/settings"?i.jsx(Yie,{authUser:e}):t==="/admin/usage"?i.jsx(noe,{authUser:e}):t==="/admin/teams"?i.jsx(roe,{authUser:e}):t==="/feedback"?i.jsx(ioe,{authUser:e}):M$(t)?i.jsx(s$,{}):i.jsx(Bl,{})}function jue({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=h.useState(""),[o,a]=h.useState(""),[l,c]=h.useState(!1),[u,d]=h.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}),d(y.error?String(y.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(m.message||m))}};h.useEffect(()=>{f()},[]);const p=async m=>{m.preventDefault(),c(!0),d("");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){d(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:p,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:m=>s(m.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:m=>a(m.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 Nue({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(rue,{page:r?"flow":"projects"}):null,r?null:i.jsx(lF,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(Sue,{authUser:e})}),i.jsx(pue,{})]})}function Cue(){return i.jsx(vue,{children:i.jsxs(HD,{children:[i.jsx(_ue,{}),i.jsx(xue,{})]})})}function _ue(){const{path:e}=rs();return e.startsWith("/display")?i.jsx(VM,{}):M$(e)?i.jsx(s$,{}):bue(e)?i.jsx(BM,{}):i.jsx(jue,{children:({user:t,onLogout:n})=>i.jsx(Nue,{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 xA=document.querySelector('link[rel="icon"]');xA&&(xA.href=$I);zw.createRoot(document.getElementById("root")).render(i.jsx(pt.StrictMode,{children:i.jsx(Cue,{})}));