@fieldwangai/agentflow 0.1.115 → 0.1.118

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,350 @@
1
+ var WL=Object.defineProperty;var VL=(e,t,n)=>t in e?WL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fn=(e,t,n)=>VL(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 md=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ia(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tE={exports:{}},Em={},nE={exports:{}},It={};/**
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 nf=Symbol.for("react.element"),KL=Symbol.for("react.portal"),qL=Symbol.for("react.fragment"),UL=Symbol.for("react.strict_mode"),YL=Symbol.for("react.profiler"),GL=Symbol.for("react.provider"),JL=Symbol.for("react.context"),XL=Symbol.for("react.forward_ref"),QL=Symbol.for("react.suspense"),ZL=Symbol.for("react.memo"),e2=Symbol.for("react.lazy"),D0=Symbol.iterator;function t2(e){return e===null||typeof e!="object"?null:(e=D0&&e[D0]||e["@@iterator"],typeof e=="function"?e:null)}var rE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},sE=Object.assign,iE={};function Oc(e,t,n){this.props=e,this.context=t,this.refs=iE,this.updater=n||rE}Oc.prototype.isReactComponent={};Oc.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")};Oc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function oE(){}oE.prototype=Oc.prototype;function _b(e,t,n){this.props=e,this.context=t,this.refs=iE,this.updater=n||rE}var Eb=_b.prototype=new oE;Eb.constructor=_b;sE(Eb,Oc.prototype);Eb.isPureReactComponent=!0;var F0=Array.isArray,aE=Object.prototype.hasOwnProperty,Ab={current:null},lE={key:!0,ref:!0,__self:!0,__source:!0};function cE(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)aE.call(t,r)&&!lE.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:nf,type:e,key:o,ref:a,props:s,_owner:Ab.current}}function n2(e,t){return{$$typeof:nf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Pb(e){return typeof e=="object"&&e!==null&&e.$$typeof===nf}function r2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var z0=/\/+/g;function ty(e,t){return typeof e=="object"&&e!==null&&e.key!=null?r2(""+e.key):t.toString(36)}function Gp(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 nf:case KL:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+ty(a,0):r,F0(s)?(n="",e!=null&&(n=e.replace(z0,"$&/")+"/"),Gp(s,t,n,"",function(u){return u})):s!=null&&(Pb(s)&&(s=n2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(z0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",F0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+ty(o,l);a+=Gp(o,t,n,c,s)}else if(c=t2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+ty(o,l++),a+=Gp(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 tp(e,t,n){if(e==null)return e;var r=[],s=0;return Gp(e,r,"","",function(o){return t.call(n,o,s++)}),r}function s2(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 Dr={current:null},Jp={transition:null},i2={ReactCurrentDispatcher:Dr,ReactCurrentBatchConfig:Jp,ReactCurrentOwner:Ab};function uE(){throw Error("act(...) is not supported in production builds of React.")}It.Children={map:tp,forEach:function(e,t,n){tp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return tp(e,function(){t++}),t},toArray:function(e){return tp(e,function(t){return t})||[]},only:function(e){if(!Pb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};It.Component=Oc;It.Fragment=qL;It.Profiler=YL;It.PureComponent=_b;It.StrictMode=UL;It.Suspense=QL;It.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=i2;It.act=uE;It.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=sE({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Ab.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)aE.call(t,c)&&!lE.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:nf,type:e.type,key:s,ref:o,props:r,_owner:a}};It.createContext=function(e){return e={$$typeof:JL,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:GL,_context:e},e.Consumer=e};It.createElement=cE;It.createFactory=function(e){var t=cE.bind(null,e);return t.type=e,t};It.createRef=function(){return{current:null}};It.forwardRef=function(e){return{$$typeof:XL,render:e}};It.isValidElement=Pb;It.lazy=function(e){return{$$typeof:e2,_payload:{_status:-1,_result:e},_init:s2}};It.memo=function(e,t){return{$$typeof:ZL,type:e,compare:t===void 0?null:t}};It.startTransition=function(e){var t=Jp.transition;Jp.transition={};try{e()}finally{Jp.transition=t}};It.unstable_act=uE;It.useCallback=function(e,t){return Dr.current.useCallback(e,t)};It.useContext=function(e){return Dr.current.useContext(e)};It.useDebugValue=function(){};It.useDeferredValue=function(e){return Dr.current.useDeferredValue(e)};It.useEffect=function(e,t){return Dr.current.useEffect(e,t)};It.useId=function(){return Dr.current.useId()};It.useImperativeHandle=function(e,t,n){return Dr.current.useImperativeHandle(e,t,n)};It.useInsertionEffect=function(e,t){return Dr.current.useInsertionEffect(e,t)};It.useLayoutEffect=function(e,t){return Dr.current.useLayoutEffect(e,t)};It.useMemo=function(e,t){return Dr.current.useMemo(e,t)};It.useReducer=function(e,t,n){return Dr.current.useReducer(e,t,n)};It.useRef=function(e){return Dr.current.useRef(e)};It.useState=function(e){return Dr.current.useState(e)};It.useSyncExternalStore=function(e,t,n){return Dr.current.useSyncExternalStore(e,t,n)};It.useTransition=function(){return Dr.current.useTransition()};It.version="18.3.1";nE.exports=It;var m=nE.exports;const dt=ia(m);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var o2=m,a2=Symbol.for("react.element"),l2=Symbol.for("react.fragment"),c2=Object.prototype.hasOwnProperty,u2=o2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d2={key:!0,ref:!0,__self:!0,__source:!0};function dE(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)c2.call(t,r)&&!d2.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:a2,type:e,key:o,ref:a,props:s,_owner:u2.current}}Em.Fragment=l2;Em.jsx=dE;Em.jsxs=dE;tE.exports=Em;var i=tE.exports,Nw={},fE={exports:{}},hs={},pE={exports:{}},hE={};/**
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($,W){var E=$.length;$.push(W);e:for(;0<E;){var Q=E-1>>>1,V=$[Q];if(0<s(V,W))$[Q]=W,$[E]=V,E=Q;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var W=$[0],E=$.pop();if(E!==W){$[0]=E;e:for(var Q=0,V=$.length,B=V>>>1;Q<B;){var se=2*(Q+1)-1,ue=$[se],G=se+1,ee=$[G];if(0>s(ue,E))G<V&&0>s(ee,ue)?($[Q]=ee,$[G]=E,Q=G):($[Q]=ue,$[se]=E,Q=se);else if(G<V&&0>s(ee,E))$[Q]=ee,$[G]=E,Q=G;else break e}}return W}function s($,W){var E=$.sortIndex-W.sortIndex;return E!==0?E:$.id-W.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,h=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x($){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=$)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(u)}}function j($){if(v=!1,x($),!y)if(n(c)!==null)y=!0,z(N);else{var W=n(u);W!==null&&F(j,W.startTime-$)}}function N($,W){y=!1,v&&(v=!1,g(R),R=-1),h=!0;var E=p;try{for(x(W),f=n(c);f!==null&&(!(f.expirationTime>W)||$&&!L());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,p=f.priorityLevel;var V=Q(f.expirationTime<=W);W=e.unstable_now(),typeof V=="function"?f.callback=V:f===n(c)&&r(c),x(W)}else r(c);f=n(c)}if(f!==null)var B=!0;else{var se=n(u);se!==null&&F(j,se.startTime-W),B=!1}return B}finally{f=null,p=E,h=!1}}var C=!1,I=null,R=-1,H=5,A=-1;function L(){return!(e.unstable_now()-A<H)}function D(){if(I!==null){var $=e.unstable_now();A=$;var W=!0;try{W=I(!0,$)}finally{W?O():(C=!1,I=null)}}else C=!1}var O;if(typeof k=="function")O=function(){k(D)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,K=M.port2;M.port1.onmessage=D,O=function(){K.postMessage(null)}}else O=function(){b(D,0)};function z($){I=$,C||(C=!0,O())}function F($,W){R=b(function(){$(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_continueExecution=function(){y||h||(y=!0,z(N))},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"):H=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 W=3;break;default:W=p}var E=p;p=W;try{return $()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,W){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var E=p;p=$;try{return W()}finally{p=E}},e.unstable_scheduleCallback=function($,W,E){var Q=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?Q+E:Q):E=Q,$){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=E+V,$={id:d++,callback:W,priorityLevel:$,startTime:E,expirationTime:V,sortIndex:-1},E>Q?($.sortIndex=E,t(u,$),n(c)===null&&$===n(u)&&(v?(g(R),R=-1):v=!0,F(j,E-Q))):($.sortIndex=V,t(c,$),y||h||(y=!0,z(N))),$},e.unstable_shouldYield=L,e.unstable_wrapCallback=function($){var W=p;return function(){var E=p;p=W;try{return $.apply(this,arguments)}finally{p=E}}}})(hE);pE.exports=hE;var f2=pE.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 p2=m,fs=f2;function Ae(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 mE=new Set,gd={};function il(e,t){wc(e,t),wc(e+"Capture",t)}function wc(e,t){for(gd[e]=t,e=0;e<t.length;e++)mE.add(t[e])}var ro=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cw=Object.prototype.hasOwnProperty,h2=/^[: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]*$/,B0={},H0={};function m2(e){return Cw.call(H0,e)?!0:Cw.call(B0,e)?!1:h2.test(e)?H0[e]=!0:(B0[e]=!0,!1)}function g2(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function y2(e,t,n,r){if(t===null||typeof t>"u"||g2(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Fr(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 wr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){wr[e]=new Fr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];wr[t]=new Fr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){wr[e]=new Fr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){wr[e]=new Fr(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){wr[e]=new Fr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){wr[e]=new Fr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){wr[e]=new Fr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){wr[e]=new Fr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){wr[e]=new Fr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ib=/[\-:]([a-z])/g;function Rb(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(Ib,Rb);wr[t]=new Fr(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(Ib,Rb);wr[t]=new Fr(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(Ib,Rb);wr[t]=new Fr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){wr[e]=new Fr(e,1,!1,e.toLowerCase(),null,!1,!1)});wr.xlinkHref=new Fr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){wr[e]=new Fr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Tb(e,t,n,r){var s=wr.hasOwnProperty(t)?wr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(y2(t,n,s,r)&&(n=null),r||s===null?m2(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 fo=p2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,np=Symbol.for("react.element"),Bl=Symbol.for("react.portal"),Hl=Symbol.for("react.fragment"),Mb=Symbol.for("react.strict_mode"),_w=Symbol.for("react.profiler"),gE=Symbol.for("react.provider"),yE=Symbol.for("react.context"),$b=Symbol.for("react.forward_ref"),Ew=Symbol.for("react.suspense"),Aw=Symbol.for("react.suspense_list"),Lb=Symbol.for("react.memo"),Po=Symbol.for("react.lazy"),wE=Symbol.for("react.offscreen"),W0=Symbol.iterator;function xu(e){return e===null||typeof e!="object"?null:(e=W0&&e[W0]||e["@@iterator"],typeof e=="function"?e:null)}var Ln=Object.assign,ny;function Du(e){if(ny===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);ny=t&&t[1]||""}return`
34
+ `+ny+e}var ry=!1;function sy(e,t){if(!e||ry)return"";ry=!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{ry=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Du(e):""}function w2(e){switch(e.tag){case 5:return Du(e.type);case 16:return Du("Lazy");case 13:return Du("Suspense");case 19:return Du("SuspenseList");case 0:case 2:case 15:return e=sy(e.type,!1),e;case 11:return e=sy(e.type.render,!1),e;case 1:return e=sy(e.type,!0),e;default:return""}}function Pw(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 Hl:return"Fragment";case Bl:return"Portal";case _w:return"Profiler";case Mb:return"StrictMode";case Ew:return"Suspense";case Aw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case yE:return(e.displayName||"Context")+".Consumer";case gE:return(e._context.displayName||"Context")+".Provider";case $b:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Lb:return t=e.displayName||null,t!==null?t:Pw(e.type)||"Memo";case Po:t=e._payload,e=e._init;try{return Pw(e(t))}catch{}}return null}function x2(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pw(t);case 8:return t===Mb?"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 Xo(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function xE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function b2(e){var t=xE(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 rp(e){e._valueTracker||(e._valueTracker=b2(e))}function bE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=xE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function kh(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 Iw(e,t){var n=t.checked;return Ln({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function V0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Xo(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 kE(e,t){t=t.checked,t!=null&&Tb(e,"checked",t,!1)}function Rw(e,t){kE(e,t);var n=Xo(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")?Tw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Tw(e,t.type,Xo(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function K0(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 Tw(e,t,n){(t!=="number"||kh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Fu=Array.isArray;function sc(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=""+Xo(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 Mw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ae(91));return Ln({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function q0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ae(92));if(Fu(n)){if(1<n.length)throw Error(Ae(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Xo(n)}}function vE(e,t){var n=Xo(t.value),r=Xo(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 U0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function SE(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 $w(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?SE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var sp,jE=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(sp=sp||document.createElement("div"),sp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=sp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function yd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ju={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},k2=["Webkit","ms","Moz","O"];Object.keys(Ju).forEach(function(e){k2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ju[t]=Ju[e]})});function NE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ju.hasOwnProperty(e)&&Ju[e]?(""+t).trim():t+"px"}function CE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=NE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var v2=Ln({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 Lw(e,t){if(t){if(v2[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ae(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ae(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ae(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ae(62))}}function Ow(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 Dw=null;function Ob(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Fw=null,ic=null,oc=null;function Y0(e){if(e=of(e)){if(typeof Fw!="function")throw Error(Ae(280));var t=e.stateNode;t&&(t=Tm(t),Fw(e.stateNode,e.type,t))}}function _E(e){ic?oc?oc.push(e):oc=[e]:ic=e}function EE(){if(ic){var e=ic,t=oc;if(oc=ic=null,Y0(e),t)for(e=0;e<t.length;e++)Y0(t[e])}}function AE(e,t){return e(t)}function PE(){}var iy=!1;function IE(e,t,n){if(iy)return e(t,n);iy=!0;try{return AE(e,t,n)}finally{iy=!1,(ic!==null||oc!==null)&&(PE(),EE())}}function wd(e,t){var n=e.stateNode;if(n===null)return null;var r=Tm(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(Ae(231,t,typeof n));return n}var zw=!1;if(ro)try{var bu={};Object.defineProperty(bu,"passive",{get:function(){zw=!0}}),window.addEventListener("test",bu,bu),window.removeEventListener("test",bu,bu)}catch{zw=!1}function S2(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 Xu=!1,vh=null,Sh=!1,Bw=null,j2={onError:function(e){Xu=!0,vh=e}};function N2(e,t,n,r,s,o,a,l,c){Xu=!1,vh=null,S2.apply(j2,arguments)}function C2(e,t,n,r,s,o,a,l,c){if(N2.apply(this,arguments),Xu){if(Xu){var u=vh;Xu=!1,vh=null}else throw Error(Ae(198));Sh||(Sh=!0,Bw=u)}}function ol(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 RE(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 G0(e){if(ol(e)!==e)throw Error(Ae(188))}function _2(e){var t=e.alternate;if(!t){if(t=ol(e),t===null)throw Error(Ae(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 G0(s),e;if(o===r)return G0(s),t;o=o.sibling}throw Error(Ae(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(Ae(189))}}if(n.alternate!==r)throw Error(Ae(190))}if(n.tag!==3)throw Error(Ae(188));return n.stateNode.current===n?e:t}function TE(e){return e=_2(e),e!==null?ME(e):null}function ME(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=ME(e);if(t!==null)return t;e=e.sibling}return null}var $E=fs.unstable_scheduleCallback,J0=fs.unstable_cancelCallback,E2=fs.unstable_shouldYield,A2=fs.unstable_requestPaint,Vn=fs.unstable_now,P2=fs.unstable_getCurrentPriorityLevel,Db=fs.unstable_ImmediatePriority,LE=fs.unstable_UserBlockingPriority,jh=fs.unstable_NormalPriority,I2=fs.unstable_LowPriority,OE=fs.unstable_IdlePriority,Am=null,ji=null;function R2(e){if(ji&&typeof ji.onCommitFiberRoot=="function")try{ji.onCommitFiberRoot(Am,e,void 0,(e.current.flags&128)===128)}catch{}}var Zs=Math.clz32?Math.clz32:$2,T2=Math.log,M2=Math.LN2;function $2(e){return e>>>=0,e===0?32:31-(T2(e)/M2|0)|0}var ip=64,op=4194304;function zu(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 Nh(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=zu(l):(o&=a,o!==0&&(r=zu(o)))}else a=n&~s,a!==0?r=zu(a):o!==0&&(r=zu(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-Zs(t),s=1<<n,r|=e[n],t&=~s;return r}function L2(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 O2(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-Zs(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=L2(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Hw(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function DE(){var e=ip;return ip<<=1,!(ip&4194240)&&(ip=64),e}function oy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function rf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Zs(t),e[t]=n}function D2(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-Zs(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Fb(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Zs(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var on=0;function FE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var zE,zb,BE,HE,WE,Ww=!1,ap=[],Bo=null,Ho=null,Wo=null,xd=new Map,bd=new Map,To=[],F2="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 X0(e,t){switch(e){case"focusin":case"focusout":Bo=null;break;case"dragenter":case"dragleave":Ho=null;break;case"mouseover":case"mouseout":Wo=null;break;case"pointerover":case"pointerout":xd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":bd.delete(t.pointerId)}}function ku(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=of(t),t!==null&&zb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function z2(e,t,n,r,s){switch(t){case"focusin":return Bo=ku(Bo,e,t,n,r,s),!0;case"dragenter":return Ho=ku(Ho,e,t,n,r,s),!0;case"mouseover":return Wo=ku(Wo,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return xd.set(o,ku(xd.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,bd.set(o,ku(bd.get(o)||null,e,t,n,r,s)),!0}return!1}function VE(e){var t=Pa(e.target);if(t!==null){var n=ol(t);if(n!==null){if(t=n.tag,t===13){if(t=RE(n),t!==null){e.blockedOn=t,WE(e.priority,function(){BE(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 Xp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Vw(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Dw=r,n.target.dispatchEvent(r),Dw=null}else return t=of(n),t!==null&&zb(t),e.blockedOn=n,!1;t.shift()}return!0}function Q0(e,t,n){Xp(e)&&n.delete(t)}function B2(){Ww=!1,Bo!==null&&Xp(Bo)&&(Bo=null),Ho!==null&&Xp(Ho)&&(Ho=null),Wo!==null&&Xp(Wo)&&(Wo=null),xd.forEach(Q0),bd.forEach(Q0)}function vu(e,t){e.blockedOn===t&&(e.blockedOn=null,Ww||(Ww=!0,fs.unstable_scheduleCallback(fs.unstable_NormalPriority,B2)))}function kd(e){function t(s){return vu(s,e)}if(0<ap.length){vu(ap[0],e);for(var n=1;n<ap.length;n++){var r=ap[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Bo!==null&&vu(Bo,e),Ho!==null&&vu(Ho,e),Wo!==null&&vu(Wo,e),xd.forEach(t),bd.forEach(t),n=0;n<To.length;n++)r=To[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<To.length&&(n=To[0],n.blockedOn===null);)VE(n),n.blockedOn===null&&To.shift()}var ac=fo.ReactCurrentBatchConfig,Ch=!0;function H2(e,t,n,r){var s=on,o=ac.transition;ac.transition=null;try{on=1,Bb(e,t,n,r)}finally{on=s,ac.transition=o}}function W2(e,t,n,r){var s=on,o=ac.transition;ac.transition=null;try{on=4,Bb(e,t,n,r)}finally{on=s,ac.transition=o}}function Bb(e,t,n,r){if(Ch){var s=Vw(e,t,n,r);if(s===null)gy(e,t,r,_h,n),X0(e,r);else if(z2(s,e,t,n,r))r.stopPropagation();else if(X0(e,r),t&4&&-1<F2.indexOf(e)){for(;s!==null;){var o=of(s);if(o!==null&&zE(o),o=Vw(e,t,n,r),o===null&&gy(e,t,r,_h,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else gy(e,t,r,null,n)}}var _h=null;function Vw(e,t,n,r){if(_h=null,e=Ob(r),e=Pa(e),e!==null)if(t=ol(e),t===null)e=null;else if(n=t.tag,n===13){if(e=RE(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 _h=e,null}function KE(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(P2()){case Db:return 1;case LE:return 4;case jh:case I2:return 16;case OE:return 536870912;default:return 16}default:return 16}}var Oo=null,Hb=null,Qp=null;function qE(){if(Qp)return Qp;var e,t=Hb,n=t.length,r,s="value"in Oo?Oo.value:Oo.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 Qp=s.slice(e,1<r?1-r:void 0)}function Zp(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 lp(){return!0}function Z0(){return!1}function ms(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)?lp:Z0,this.isPropagationStopped=Z0,this}return Ln(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=lp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=lp)},persist:function(){},isPersistent:lp}),t}var Dc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Wb=ms(Dc),sf=Ln({},Dc,{view:0,detail:0}),V2=ms(sf),ay,ly,Su,Pm=Ln({},sf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vb,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!==Su&&(Su&&e.type==="mousemove"?(ay=e.screenX-Su.screenX,ly=e.screenY-Su.screenY):ly=ay=0,Su=e),ay)},movementY:function(e){return"movementY"in e?e.movementY:ly}}),ej=ms(Pm),K2=Ln({},Pm,{dataTransfer:0}),q2=ms(K2),U2=Ln({},sf,{relatedTarget:0}),cy=ms(U2),Y2=Ln({},Dc,{animationName:0,elapsedTime:0,pseudoElement:0}),G2=ms(Y2),J2=Ln({},Dc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),X2=ms(J2),Q2=Ln({},Dc,{data:0}),tj=ms(Q2),Z2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},eO={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},tO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function nO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=tO[e])?!!t[e]:!1}function Vb(){return nO}var rO=Ln({},sf,{key:function(e){if(e.key){var t=Z2[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Zp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?eO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vb,charCode:function(e){return e.type==="keypress"?Zp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Zp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),sO=ms(rO),iO=Ln({},Pm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),nj=ms(iO),oO=Ln({},sf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vb}),aO=ms(oO),lO=Ln({},Dc,{propertyName:0,elapsedTime:0,pseudoElement:0}),cO=ms(lO),uO=Ln({},Pm,{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}),dO=ms(uO),fO=[9,13,27,32],Kb=ro&&"CompositionEvent"in window,Qu=null;ro&&"documentMode"in document&&(Qu=document.documentMode);var pO=ro&&"TextEvent"in window&&!Qu,UE=ro&&(!Kb||Qu&&8<Qu&&11>=Qu),rj=" ",sj=!1;function YE(e,t){switch(e){case"keyup":return fO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function GE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wl=!1;function hO(e,t){switch(e){case"compositionend":return GE(t);case"keypress":return t.which!==32?null:(sj=!0,rj);case"textInput":return e=t.data,e===rj&&sj?null:e;default:return null}}function mO(e,t){if(Wl)return e==="compositionend"||!Kb&&YE(e,t)?(e=qE(),Qp=Hb=Oo=null,Wl=!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 UE&&t.locale!=="ko"?null:t.data;default:return null}}var gO={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ij(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!gO[e.type]:t==="textarea"}function JE(e,t,n,r){_E(r),t=Eh(t,"onChange"),0<t.length&&(n=new Wb("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Zu=null,vd=null;function yO(e){aA(e,0)}function Im(e){var t=ql(e);if(bE(t))return e}function wO(e,t){if(e==="change")return t}var XE=!1;if(ro){var uy;if(ro){var dy="oninput"in document;if(!dy){var oj=document.createElement("div");oj.setAttribute("oninput","return;"),dy=typeof oj.oninput=="function"}uy=dy}else uy=!1;XE=uy&&(!document.documentMode||9<document.documentMode)}function aj(){Zu&&(Zu.detachEvent("onpropertychange",QE),vd=Zu=null)}function QE(e){if(e.propertyName==="value"&&Im(vd)){var t=[];JE(t,vd,e,Ob(e)),IE(yO,t)}}function xO(e,t,n){e==="focusin"?(aj(),Zu=t,vd=n,Zu.attachEvent("onpropertychange",QE)):e==="focusout"&&aj()}function bO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Im(vd)}function kO(e,t){if(e==="click")return Im(t)}function vO(e,t){if(e==="input"||e==="change")return Im(t)}function SO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ni=typeof Object.is=="function"?Object.is:SO;function Sd(e,t){if(ni(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(!Cw.call(t,s)||!ni(e[s],t[s]))return!1}return!0}function lj(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function cj(e,t){var n=lj(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=lj(n)}}function ZE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ZE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function eA(){for(var e=window,t=kh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=kh(e.document)}return t}function qb(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=eA(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ZE(n.ownerDocument.documentElement,n)){if(r!==null&&qb(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 NO=ro&&"documentMode"in document&&11>=document.documentMode,Vl=null,Kw=null,ed=null,qw=!1;function uj(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qw||Vl==null||Vl!==kh(r)||(r=Vl,"selectionStart"in r&&qb(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}),ed&&Sd(ed,r)||(ed=r,r=Eh(Kw,"onSelect"),0<r.length&&(t=new Wb("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Vl)))}function cp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Kl={animationend:cp("Animation","AnimationEnd"),animationiteration:cp("Animation","AnimationIteration"),animationstart:cp("Animation","AnimationStart"),transitionend:cp("Transition","TransitionEnd")},fy={},tA={};ro&&(tA=document.createElement("div").style,"AnimationEvent"in window||(delete Kl.animationend.animation,delete Kl.animationiteration.animation,delete Kl.animationstart.animation),"TransitionEvent"in window||delete Kl.transitionend.transition);function Rm(e){if(fy[e])return fy[e];if(!Kl[e])return e;var t=Kl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in tA)return fy[e]=t[n];return e}var nA=Rm("animationend"),rA=Rm("animationiteration"),sA=Rm("animationstart"),iA=Rm("transitionend"),oA=new Map,dj="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 oa(e,t){oA.set(e,t),il(t,[e])}for(var py=0;py<dj.length;py++){var hy=dj[py],CO=hy.toLowerCase(),_O=hy[0].toUpperCase()+hy.slice(1);oa(CO,"on"+_O)}oa(nA,"onAnimationEnd");oa(rA,"onAnimationIteration");oa(sA,"onAnimationStart");oa("dblclick","onDoubleClick");oa("focusin","onFocus");oa("focusout","onBlur");oa(iA,"onTransitionEnd");wc("onMouseEnter",["mouseout","mouseover"]);wc("onMouseLeave",["mouseout","mouseover"]);wc("onPointerEnter",["pointerout","pointerover"]);wc("onPointerLeave",["pointerout","pointerover"]);il("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));il("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));il("onBeforeInput",["compositionend","keypress","textInput","paste"]);il("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));il("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));il("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bu="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(" "),EO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bu));function fj(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,C2(r,t,void 0,e),e.currentTarget=null}function aA(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;fj(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;fj(s,l,u),o=c}}}if(Sh)throw e=Bw,Sh=!1,Bw=null,e}function kn(e,t){var n=t[Xw];n===void 0&&(n=t[Xw]=new Set);var r=e+"__bubble";n.has(r)||(lA(t,e,2,!1),n.add(r))}function my(e,t,n){var r=0;t&&(r|=4),lA(n,e,r,t)}var up="_reactListening"+Math.random().toString(36).slice(2);function jd(e){if(!e[up]){e[up]=!0,mE.forEach(function(n){n!=="selectionchange"&&(EO.has(n)||my(n,!1,e),my(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[up]||(t[up]=!0,my("selectionchange",!1,t))}}function lA(e,t,n,r){switch(KE(t)){case 1:var s=H2;break;case 4:s=W2;break;default:s=Bb}n=s.bind(null,t,n,e),s=void 0,!zw||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 gy(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=Pa(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}IE(function(){var u=o,d=Ob(n),f=[];e:{var p=oA.get(e);if(p!==void 0){var h=Wb,y=e;switch(e){case"keypress":if(Zp(n)===0)break e;case"keydown":case"keyup":h=sO;break;case"focusin":y="focus",h=cy;break;case"focusout":y="blur",h=cy;break;case"beforeblur":case"afterblur":h=cy;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=ej;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=q2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=aO;break;case nA:case rA:case sA:h=G2;break;case iA:h=cO;break;case"scroll":h=V2;break;case"wheel":h=dO;break;case"copy":case"cut":case"paste":h=X2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=nj}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 j=x.stateNode;if(x.tag===5&&j!==null&&(x=j,g!==null&&(j=wd(k,g),j!=null&&v.push(Nd(k,j,x)))),b)break;k=k.return}0<v.length&&(p=new h(p,y,null,n,d),f.push({event:p,listeners:v}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&n!==Dw&&(y=n.relatedTarget||n.fromElement)&&(Pa(y)||y[so]))break e;if((h||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?Pa(y):null,y!==null&&(b=ol(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=ej,j="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=nj,j="onPointerLeave",g="onPointerEnter",k="pointer"),b=h==null?p:ql(h),x=y==null?p:ql(y),p=new v(j,k+"leave",h,n,d),p.target=b,p.relatedTarget=x,j=null,Pa(d)===u&&(v=new v(g,k+"enter",y,n,d),v.target=x,v.relatedTarget=b,j=v),b=j,h&&y)t:{for(v=h,g=y,k=0,x=v;x;x=Al(x))k++;for(x=0,j=g;j;j=Al(j))x++;for(;0<k-x;)v=Al(v),k--;for(;0<x-k;)g=Al(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Al(v),g=Al(g)}v=null}else v=null;h!==null&&pj(f,p,h,v,!1),y!==null&&b!==null&&pj(f,b,y,v,!0)}}e:{if(p=u?ql(u):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var N=wO;else if(ij(p))if(XE)N=vO;else{N=bO;var C=xO}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(N=kO);if(N&&(N=N(e,u))){JE(f,N,n,d);break e}C&&C(e,p,u),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Tw(p,"number",p.value)}switch(C=u?ql(u):window,e){case"focusin":(ij(C)||C.contentEditable==="true")&&(Vl=C,Kw=u,ed=null);break;case"focusout":ed=Kw=Vl=null;break;case"mousedown":qw=!0;break;case"contextmenu":case"mouseup":case"dragend":qw=!1,uj(f,n,d);break;case"selectionchange":if(NO)break;case"keydown":case"keyup":uj(f,n,d)}var I;if(Kb)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 Wl?YE(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(UE&&n.locale!=="ko"&&(Wl||R!=="onCompositionStart"?R==="onCompositionEnd"&&Wl&&(I=qE()):(Oo=d,Hb="value"in Oo?Oo.value:Oo.textContent,Wl=!0)),C=Eh(u,R),0<C.length&&(R=new tj(R,e,null,n,d),f.push({event:R,listeners:C}),I?R.data=I:(I=GE(n),I!==null&&(R.data=I)))),(I=pO?hO(e,n):mO(e,n))&&(u=Eh(u,"onBeforeInput"),0<u.length&&(d=new tj("onBeforeInput","beforeinput",null,n,d),f.push({event:d,listeners:u}),d.data=I))}aA(f,t)})}function Nd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Eh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=wd(e,n),o!=null&&r.unshift(Nd(e,o,s)),o=wd(e,t),o!=null&&r.push(Nd(e,o,s))),e=e.return}return r}function Al(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function pj(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=wd(n,o),c!=null&&a.unshift(Nd(n,c,l))):s||(c=wd(n,o),c!=null&&a.push(Nd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var AO=/\r\n?/g,PO=/\u0000|\uFFFD/g;function hj(e){return(typeof e=="string"?e:""+e).replace(AO,`
38
+ `).replace(PO,"")}function dp(e,t,n){if(t=hj(t),hj(e)!==t&&n)throw Error(Ae(425))}function Ah(){}var Uw=null,Yw=null;function Gw(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 Jw=typeof setTimeout=="function"?setTimeout:void 0,IO=typeof clearTimeout=="function"?clearTimeout:void 0,mj=typeof Promise=="function"?Promise:void 0,RO=typeof queueMicrotask=="function"?queueMicrotask:typeof mj<"u"?function(e){return mj.resolve(null).then(e).catch(TO)}:Jw;function TO(e){setTimeout(function(){throw e})}function yy(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),kd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);kd(t)}function Vo(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 gj(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 Fc=Math.random().toString(36).slice(2),wi="__reactFiber$"+Fc,Cd="__reactProps$"+Fc,so="__reactContainer$"+Fc,Xw="__reactEvents$"+Fc,MO="__reactListeners$"+Fc,$O="__reactHandles$"+Fc;function Pa(e){var t=e[wi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[so]||n[wi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=gj(e);e!==null;){if(n=e[wi])return n;e=gj(e)}return t}e=n,n=e.parentNode}return null}function of(e){return e=e[wi]||e[so],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ql(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ae(33))}function Tm(e){return e[Cd]||null}var Qw=[],Ul=-1;function aa(e){return{current:e}}function Sn(e){0>Ul||(e.current=Qw[Ul],Qw[Ul]=null,Ul--)}function gn(e,t){Ul++,Qw[Ul]=e.current,e.current=t}var Qo={},Er=aa(Qo),Jr=aa(!1),Wa=Qo;function xc(e,t){var n=e.type.contextTypes;if(!n)return Qo;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 Xr(e){return e=e.childContextTypes,e!=null}function Ph(){Sn(Jr),Sn(Er)}function yj(e,t,n){if(Er.current!==Qo)throw Error(Ae(168));gn(Er,t),gn(Jr,n)}function cA(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(Ae(108,x2(e)||"Unknown",s));return Ln({},n,r)}function Ih(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Qo,Wa=Er.current,gn(Er,e),gn(Jr,Jr.current),!0}function wj(e,t,n){var r=e.stateNode;if(!r)throw Error(Ae(169));n?(e=cA(e,t,Wa),r.__reactInternalMemoizedMergedChildContext=e,Sn(Jr),Sn(Er),gn(Er,e)):Sn(Jr),gn(Jr,n)}var qi=null,Mm=!1,wy=!1;function uA(e){qi===null?qi=[e]:qi.push(e)}function LO(e){Mm=!0,uA(e)}function la(){if(!wy&&qi!==null){wy=!0;var e=0,t=on;try{var n=qi;for(on=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}qi=null,Mm=!1}catch(s){throw qi!==null&&(qi=qi.slice(e+1)),$E(Db,la),s}finally{on=t,wy=!1}}return null}var Yl=[],Gl=0,Rh=null,Th=0,Ns=[],Cs=0,Va=null,Yi=1,Gi="";function Sa(e,t){Yl[Gl++]=Th,Yl[Gl++]=Rh,Rh=e,Th=t}function dA(e,t,n){Ns[Cs++]=Yi,Ns[Cs++]=Gi,Ns[Cs++]=Va,Va=e;var r=Yi;e=Gi;var s=32-Zs(r)-1;r&=~(1<<s),n+=1;var o=32-Zs(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Yi=1<<32-Zs(t)+s|n<<s|r,Gi=o+e}else Yi=1<<o|n<<s|r,Gi=e}function Ub(e){e.return!==null&&(Sa(e,1),dA(e,1,0))}function Yb(e){for(;e===Rh;)Rh=Yl[--Gl],Yl[Gl]=null,Th=Yl[--Gl],Yl[Gl]=null;for(;e===Va;)Va=Ns[--Cs],Ns[Cs]=null,Gi=Ns[--Cs],Ns[Cs]=null,Yi=Ns[--Cs],Ns[Cs]=null}var us=null,ls=null,_n=!1,Ys=null;function fA(e,t){var n=As(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 xj(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,us=e,ls=Vo(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,us=e,ls=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Va!==null?{id:Yi,overflow:Gi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=As(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,us=e,ls=null,!0):!1;default:return!1}}function Zw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ex(e){if(_n){var t=ls;if(t){var n=t;if(!xj(e,t)){if(Zw(e))throw Error(Ae(418));t=Vo(n.nextSibling);var r=us;t&&xj(e,t)?fA(r,n):(e.flags=e.flags&-4097|2,_n=!1,us=e)}}else{if(Zw(e))throw Error(Ae(418));e.flags=e.flags&-4097|2,_n=!1,us=e}}}function bj(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;us=e}function fp(e){if(e!==us)return!1;if(!_n)return bj(e),_n=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Gw(e.type,e.memoizedProps)),t&&(t=ls)){if(Zw(e))throw pA(),Error(Ae(418));for(;t;)fA(e,t),t=Vo(t.nextSibling)}if(bj(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ae(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ls=Vo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ls=null}}else ls=us?Vo(e.stateNode.nextSibling):null;return!0}function pA(){for(var e=ls;e;)e=Vo(e.nextSibling)}function bc(){ls=us=null,_n=!1}function Gb(e){Ys===null?Ys=[e]:Ys.push(e)}var OO=fo.ReactCurrentBatchConfig;function ju(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(Ae(309));var r=n.stateNode}if(!r)throw Error(Ae(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(Ae(284));if(!n._owner)throw Error(Ae(290,e))}return e}function pp(e,t){throw e=Object.prototype.toString.call(t),Error(Ae(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function kj(e){var t=e._init;return t(e._payload)}function hA(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=Yo(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,j){return k===null||k.tag!==6?(k=Ny(x,g.mode,j),k.return=g,k):(k=s(k,x),k.return=g,k)}function c(g,k,x,j){var N=x.type;return N===Hl?d(g,k,x.props.children,j,x.key):k!==null&&(k.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Po&&kj(N)===k.type)?(j=s(k,x.props),j.ref=ju(g,k,x),j.return=g,j):(j=oh(x.type,x.key,x.props,null,g.mode,j),j.ref=ju(g,k,x),j.return=g,j)}function u(g,k,x,j){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=Cy(x,g.mode,j),k.return=g,k):(k=s(k,x.children||[]),k.return=g,k)}function d(g,k,x,j,N){return k===null||k.tag!==7?(k=Oa(x,g.mode,j,N),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=Ny(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case np:return x=oh(k.type,k.key,k.props,null,g.mode,x),x.ref=ju(g,null,k),x.return=g,x;case Bl:return k=Cy(k,g.mode,x),k.return=g,k;case Po:var j=k._init;return f(g,j(k._payload),x)}if(Fu(k)||xu(k))return k=Oa(k,g.mode,x,null),k.return=g,k;pp(g,k)}return null}function p(g,k,x,j){var N=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return N!==null?null:l(g,k,""+x,j);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case np:return x.key===N?c(g,k,x,j):null;case Bl:return x.key===N?u(g,k,x,j):null;case Po:return N=x._init,p(g,k,N(x._payload),j)}if(Fu(x)||xu(x))return N!==null?null:d(g,k,x,j,null);pp(g,x)}return null}function h(g,k,x,j,N){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(x)||null,l(k,g,""+j,N);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case np:return g=g.get(j.key===null?x:j.key)||null,c(k,g,j,N);case Bl:return g=g.get(j.key===null?x:j.key)||null,u(k,g,j,N);case Po:var C=j._init;return h(g,k,x,C(j._payload),N)}if(Fu(j)||xu(j))return g=g.get(x)||null,d(k,g,j,N,null);pp(k,j)}return null}function y(g,k,x,j){for(var N=null,C=null,I=k,R=k=0,H=null;I!==null&&R<x.length;R++){I.index>R?(H=I,I=null):H=I.sibling;var A=p(g,I,x[R],j);if(A===null){I===null&&(I=H);break}e&&I&&A.alternate===null&&t(g,I),k=o(A,k,R),C===null?N=A:C.sibling=A,C=A,I=H}if(R===x.length)return n(g,I),_n&&Sa(g,R),N;if(I===null){for(;R<x.length;R++)I=f(g,x[R],j),I!==null&&(k=o(I,k,R),C===null?N=I:C.sibling=I,C=I);return _n&&Sa(g,R),N}for(I=r(g,I);R<x.length;R++)H=h(I,g,R,x[R],j),H!==null&&(e&&H.alternate!==null&&I.delete(H.key===null?R:H.key),k=o(H,k,R),C===null?N=H:C.sibling=H,C=H);return e&&I.forEach(function(L){return t(g,L)}),_n&&Sa(g,R),N}function v(g,k,x,j){var N=xu(x);if(typeof N!="function")throw Error(Ae(150));if(x=N.call(x),x==null)throw Error(Ae(151));for(var C=N=null,I=k,R=k=0,H=null,A=x.next();I!==null&&!A.done;R++,A=x.next()){I.index>R?(H=I,I=null):H=I.sibling;var L=p(g,I,A.value,j);if(L===null){I===null&&(I=H);break}e&&I&&L.alternate===null&&t(g,I),k=o(L,k,R),C===null?N=L:C.sibling=L,C=L,I=H}if(A.done)return n(g,I),_n&&Sa(g,R),N;if(I===null){for(;!A.done;R++,A=x.next())A=f(g,A.value,j),A!==null&&(k=o(A,k,R),C===null?N=A:C.sibling=A,C=A);return _n&&Sa(g,R),N}for(I=r(g,I);!A.done;R++,A=x.next())A=h(I,g,R,A.value,j),A!==null&&(e&&A.alternate!==null&&I.delete(A.key===null?R:A.key),k=o(A,k,R),C===null?N=A:C.sibling=A,C=A);return e&&I.forEach(function(D){return t(g,D)}),_n&&Sa(g,R),N}function b(g,k,x,j){if(typeof x=="object"&&x!==null&&x.type===Hl&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case np:e:{for(var N=x.key,C=k;C!==null;){if(C.key===N){if(N=x.type,N===Hl){if(C.tag===7){n(g,C.sibling),k=s(C,x.props.children),k.return=g,g=k;break e}}else if(C.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Po&&kj(N)===C.type){n(g,C.sibling),k=s(C,x.props),k.ref=ju(g,C,x),k.return=g,g=k;break e}n(g,C);break}else t(g,C);C=C.sibling}x.type===Hl?(k=Oa(x.props.children,g.mode,j,x.key),k.return=g,g=k):(j=oh(x.type,x.key,x.props,null,g.mode,j),j.ref=ju(g,k,x),j.return=g,g=j)}return a(g);case Bl:e:{for(C=x.key;k!==null;){if(k.key===C)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=Cy(x,g.mode,j),k.return=g,g=k}return a(g);case Po:return C=x._init,b(g,k,C(x._payload),j)}if(Fu(x))return y(g,k,x,j);if(xu(x))return v(g,k,x,j);pp(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=Ny(x,g.mode,j),k.return=g,g=k),a(g)):n(g,k)}return b}var kc=hA(!0),mA=hA(!1),Mh=aa(null),$h=null,Jl=null,Jb=null;function Xb(){Jb=Jl=$h=null}function Qb(e){var t=Mh.current;Sn(Mh),e._currentValue=t}function tx(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 lc(e,t){$h=e,Jb=Jl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ur=!0),e.firstContext=null)}function Is(e){var t=e._currentValue;if(Jb!==e)if(e={context:e,memoizedValue:t,next:null},Jl===null){if($h===null)throw Error(Ae(308));Jl=e,$h.dependencies={lanes:0,firstContext:e}}else Jl=Jl.next=e;return t}var Ia=null;function Zb(e){Ia===null?Ia=[e]:Ia.push(e)}function gA(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Zb(t)):(n.next=s.next,s.next=n),t.interleaved=n,io(e,r)}function io(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 Io=!1;function ek(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function yA(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 Zi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ko(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,io(e,n)}return s=r.interleaved,s===null?(t.next=t,Zb(r)):(t.next=s.next,s.next=t),r.interleaved=t,io(e,n)}function eh(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,Fb(e,n)}}function vj(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 Lh(e,t,n,r){var s=e.updateQueue;Io=!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,h=l.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(p=t,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){f=y.call(h,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(h,f,p):y,p==null)break e;f=Ln({},f,p);break e;case 2:Io=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=h,c=f):d=d.next=h,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);qa|=a,e.lanes=a,e.memoizedState=f}}function Sj(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(Ae(191,s));s.call(r)}}}var af={},Ni=aa(af),_d=aa(af),Ed=aa(af);function Ra(e){if(e===af)throw Error(Ae(174));return e}function tk(e,t){switch(gn(Ed,t),gn(_d,e),gn(Ni,af),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:$w(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=$w(t,e)}Sn(Ni),gn(Ni,t)}function vc(){Sn(Ni),Sn(_d),Sn(Ed)}function wA(e){Ra(Ed.current);var t=Ra(Ni.current),n=$w(t,e.type);t!==n&&(gn(_d,e),gn(Ni,n))}function nk(e){_d.current===e&&(Sn(Ni),Sn(_d))}var Tn=aa(0);function Oh(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 xy=[];function rk(){for(var e=0;e<xy.length;e++)xy[e]._workInProgressVersionPrimary=null;xy.length=0}var th=fo.ReactCurrentDispatcher,by=fo.ReactCurrentBatchConfig,Ka=0,$n=null,nr=null,dr=null,Dh=!1,td=!1,Ad=0,DO=0;function Sr(){throw Error(Ae(321))}function sk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ni(e[n],t[n]))return!1;return!0}function ik(e,t,n,r,s,o){if(Ka=o,$n=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,th.current=e===null||e.memoizedState===null?HO:WO,e=n(r,s),td){o=0;do{if(td=!1,Ad=0,25<=o)throw Error(Ae(301));o+=1,dr=nr=null,t.updateQueue=null,th.current=VO,e=n(r,s)}while(td)}if(th.current=Fh,t=nr!==null&&nr.next!==null,Ka=0,dr=nr=$n=null,Dh=!1,t)throw Error(Ae(300));return e}function ok(){var e=Ad!==0;return Ad=0,e}function hi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dr===null?$n.memoizedState=dr=e:dr=dr.next=e,dr}function Rs(){if(nr===null){var e=$n.alternate;e=e!==null?e.memoizedState:null}else e=nr.next;var t=dr===null?$n.memoizedState:dr.next;if(t!==null)dr=t,nr=e;else{if(e===null)throw Error(Ae(310));nr=e,e={memoizedState:nr.memoizedState,baseState:nr.baseState,baseQueue:nr.baseQueue,queue:nr.queue,next:null},dr===null?$n.memoizedState=dr=e:dr=dr.next=e}return dr}function Pd(e,t){return typeof t=="function"?t(e):t}function ky(e){var t=Rs(),n=t.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=e;var r=nr,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((Ka&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,$n.lanes|=d,qa|=d}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,ni(r,t.memoizedState)||(Ur=!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,$n.lanes|=o,qa|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function vy(e){var t=Rs(),n=t.queue;if(n===null)throw Error(Ae(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);ni(o,t.memoizedState)||(Ur=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function xA(){}function bA(e,t){var n=$n,r=Rs(),s=t(),o=!ni(r.memoizedState,s);if(o&&(r.memoizedState=s,Ur=!0),r=r.queue,ak(SA.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||dr!==null&&dr.memoizedState.tag&1){if(n.flags|=2048,Id(9,vA.bind(null,n,r,s,t),void 0,null),hr===null)throw Error(Ae(349));Ka&30||kA(n,t,s)}return s}function kA(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=$n.updateQueue,t===null?(t={lastEffect:null,stores:null},$n.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function vA(e,t,n,r){t.value=n,t.getSnapshot=r,jA(t)&&NA(e)}function SA(e,t,n){return n(function(){jA(t)&&NA(e)})}function jA(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ni(e,n)}catch{return!0}}function NA(e){var t=io(e,1);t!==null&&ei(t,e,1,-1)}function jj(e){var t=hi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pd,lastRenderedState:e},t.queue=e,e=e.dispatch=BO.bind(null,$n,e),[t.memoizedState,e]}function Id(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=$n.updateQueue,t===null?(t={lastEffect:null,stores:null},$n.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 CA(){return Rs().memoizedState}function nh(e,t,n,r){var s=hi();$n.flags|=e,s.memoizedState=Id(1|t,n,void 0,r===void 0?null:r)}function $m(e,t,n,r){var s=Rs();r=r===void 0?null:r;var o=void 0;if(nr!==null){var a=nr.memoizedState;if(o=a.destroy,r!==null&&sk(r,a.deps)){s.memoizedState=Id(t,n,o,r);return}}$n.flags|=e,s.memoizedState=Id(1|t,n,o,r)}function Nj(e,t){return nh(8390656,8,e,t)}function ak(e,t){return $m(2048,8,e,t)}function _A(e,t){return $m(4,2,e,t)}function EA(e,t){return $m(4,4,e,t)}function AA(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 PA(e,t,n){return n=n!=null?n.concat([e]):null,$m(4,4,AA.bind(null,t,e),n)}function lk(){}function IA(e,t){var n=Rs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&sk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function RA(e,t){var n=Rs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&sk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function TA(e,t,n){return Ka&21?(ni(n,t)||(n=DE(),$n.lanes|=n,qa|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ur=!0),e.memoizedState=n)}function FO(e,t){var n=on;on=n!==0&&4>n?n:4,e(!0);var r=by.transition;by.transition={};try{e(!1),t()}finally{on=n,by.transition=r}}function MA(){return Rs().memoizedState}function zO(e,t,n){var r=Uo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},$A(e))LA(t,n);else if(n=gA(e,t,n,r),n!==null){var s=Or();ei(n,e,r,s),OA(n,t,r)}}function BO(e,t,n){var r=Uo(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if($A(e))LA(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,ni(l,a)){var c=t.interleaved;c===null?(s.next=s,Zb(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=gA(e,t,s,r),n!==null&&(s=Or(),ei(n,e,r,s),OA(n,t,r))}}function $A(e){var t=e.alternate;return e===$n||t!==null&&t===$n}function LA(e,t){td=Dh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function OA(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Fb(e,n)}}var Fh={readContext:Is,useCallback:Sr,useContext:Sr,useEffect:Sr,useImperativeHandle:Sr,useInsertionEffect:Sr,useLayoutEffect:Sr,useMemo:Sr,useReducer:Sr,useRef:Sr,useState:Sr,useDebugValue:Sr,useDeferredValue:Sr,useTransition:Sr,useMutableSource:Sr,useSyncExternalStore:Sr,useId:Sr,unstable_isNewReconciler:!1},HO={readContext:Is,useCallback:function(e,t){return hi().memoizedState=[e,t===void 0?null:t],e},useContext:Is,useEffect:Nj,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,nh(4194308,4,AA.bind(null,t,e),n)},useLayoutEffect:function(e,t){return nh(4194308,4,e,t)},useInsertionEffect:function(e,t){return nh(4,2,e,t)},useMemo:function(e,t){var n=hi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=hi();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=zO.bind(null,$n,e),[r.memoizedState,e]},useRef:function(e){var t=hi();return e={current:e},t.memoizedState=e},useState:jj,useDebugValue:lk,useDeferredValue:function(e){return hi().memoizedState=e},useTransition:function(){var e=jj(!1),t=e[0];return e=FO.bind(null,e[1]),hi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=$n,s=hi();if(_n){if(n===void 0)throw Error(Ae(407));n=n()}else{if(n=t(),hr===null)throw Error(Ae(349));Ka&30||kA(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Nj(SA.bind(null,r,o,e),[e]),r.flags|=2048,Id(9,vA.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=hi(),t=hr.identifierPrefix;if(_n){var n=Gi,r=Yi;n=(r&~(1<<32-Zs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ad++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=DO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},WO={readContext:Is,useCallback:IA,useContext:Is,useEffect:ak,useImperativeHandle:PA,useInsertionEffect:_A,useLayoutEffect:EA,useMemo:RA,useReducer:ky,useRef:CA,useState:function(){return ky(Pd)},useDebugValue:lk,useDeferredValue:function(e){var t=Rs();return TA(t,nr.memoizedState,e)},useTransition:function(){var e=ky(Pd)[0],t=Rs().memoizedState;return[e,t]},useMutableSource:xA,useSyncExternalStore:bA,useId:MA,unstable_isNewReconciler:!1},VO={readContext:Is,useCallback:IA,useContext:Is,useEffect:ak,useImperativeHandle:PA,useInsertionEffect:_A,useLayoutEffect:EA,useMemo:RA,useReducer:vy,useRef:CA,useState:function(){return vy(Pd)},useDebugValue:lk,useDeferredValue:function(e){var t=Rs();return nr===null?t.memoizedState=e:TA(t,nr.memoizedState,e)},useTransition:function(){var e=vy(Pd)[0],t=Rs().memoizedState;return[e,t]},useMutableSource:xA,useSyncExternalStore:bA,useId:MA,unstable_isNewReconciler:!1};function Ks(e,t){if(e&&e.defaultProps){t=Ln({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function nx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ln({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Lm={isMounted:function(e){return(e=e._reactInternals)?ol(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Or(),s=Uo(e),o=Zi(r,s);o.payload=t,n!=null&&(o.callback=n),t=Ko(e,o,s),t!==null&&(ei(t,e,s,r),eh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Or(),s=Uo(e),o=Zi(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Ko(e,o,s),t!==null&&(ei(t,e,s,r),eh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Or(),r=Uo(e),s=Zi(n,r);s.tag=2,t!=null&&(s.callback=t),t=Ko(e,s,r),t!==null&&(ei(t,e,r,n),eh(t,e,r))}};function Cj(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?!Sd(n,r)||!Sd(s,o):!0}function DA(e,t,n){var r=!1,s=Qo,o=t.contextType;return typeof o=="object"&&o!==null?o=Is(o):(s=Xr(t)?Wa:Er.current,r=t.contextTypes,o=(r=r!=null)?xc(e,s):Qo),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Lm,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function _j(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&&Lm.enqueueReplaceState(t,t.state,null)}function rx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},ek(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Is(o):(o=Xr(t)?Wa:Er.current,s.context=xc(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(nx(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&&Lm.enqueueReplaceState(s,s.state,null),Lh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function Sc(e,t){try{var n="",r=t;do n+=w2(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 Sy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function sx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var KO=typeof WeakMap=="function"?WeakMap:Map;function FA(e,t,n){n=Zi(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Bh||(Bh=!0,hx=r),sx(e,t)},n}function zA(e,t,n){n=Zi(-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(){sx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){sx(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 Ej(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new KO;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=iD.bind(null,e,t,n),t.then(e,e))}function Aj(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 Pj(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=Zi(-1,1),t.tag=2,Ko(n,t,1))),n.lanes|=1),e)}var qO=fo.ReactCurrentOwner,Ur=!1;function Lr(e,t,n,r){t.child=e===null?mA(t,null,n,r):kc(t,e.child,n,r)}function Ij(e,t,n,r,s){n=n.render;var o=t.ref;return lc(t,s),r=ik(e,t,n,r,o,s),n=ok(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,oo(e,t,s)):(_n&&n&&Ub(t),t.flags|=1,Lr(e,t,r,s),t.child)}function Rj(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!gk(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,BA(e,t,o,r,s)):(e=oh(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:Sd,n(a,r)&&e.ref===t.ref)return oo(e,t,s)}return t.flags|=1,e=Yo(o,r),e.ref=t.ref,e.return=t,t.child=e}function BA(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(Sd(o,r)&&e.ref===t.ref)if(Ur=!1,t.pendingProps=r=o,(e.lanes&s)!==0)e.flags&131072&&(Ur=!0);else return t.lanes=e.lanes,oo(e,t,s)}return ix(e,t,n,r,s)}function HA(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},gn(Ql,is),is|=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,gn(Ql,is),is|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,gn(Ql,is),is|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,gn(Ql,is),is|=r;return Lr(e,t,s,n),t.child}function WA(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ix(e,t,n,r,s){var o=Xr(n)?Wa:Er.current;return o=xc(t,o),lc(t,s),n=ik(e,t,n,r,o,s),r=ok(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,oo(e,t,s)):(_n&&r&&Ub(t),t.flags|=1,Lr(e,t,n,s),t.child)}function Tj(e,t,n,r,s){if(Xr(n)){var o=!0;Ih(t)}else o=!1;if(lc(t,s),t.stateNode===null)rh(e,t),DA(t,n,r),rx(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=Is(u):(u=Xr(n)?Wa:Er.current,u=xc(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)&&_j(t,a,r,u),Io=!1;var p=t.memoizedState;a.state=p,Lh(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Jr.current||Io?(typeof d=="function"&&(nx(t,n,d,r),c=t.memoizedState),(l=Io||Cj(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,yA(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Ks(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Is(c):(c=Xr(n)?Wa:Er.current,c=xc(t,c));var h=n.getDerivedStateFromProps;(d=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&_j(t,a,r,c),Io=!1,p=t.memoizedState,a.state=p,Lh(t,r,a,s);var y=t.memoizedState;l!==f||p!==y||Jr.current||Io?(typeof h=="function"&&(nx(t,n,h,r),y=t.memoizedState),(u=Io||Cj(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 ox(e,t,n,r,o,s)}function ox(e,t,n,r,s,o){WA(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&wj(t,n,!1),oo(e,t,o);r=t.stateNode,qO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=kc(t,e.child,null,o),t.child=kc(t,null,l,o)):Lr(e,t,l,o),t.memoizedState=r.state,s&&wj(t,n,!0),t.child}function VA(e){var t=e.stateNode;t.pendingContext?yj(e,t.pendingContext,t.pendingContext!==t.context):t.context&&yj(e,t.context,!1),tk(e,t.containerInfo)}function Mj(e,t,n,r,s){return bc(),Gb(s),t.flags|=256,Lr(e,t,n,r),t.child}var ax={dehydrated:null,treeContext:null,retryLane:0};function lx(e){return{baseLanes:e,cachePool:null,transitions:null}}function KA(e,t,n){var r=t.pendingProps,s=Tn.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),gn(Tn,s&1),e===null)return ex(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=Fm(a,r,0,null),e=Oa(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=lx(n),t.memoizedState=ax,e):ck(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return UO(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=Yo(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=Yo(l,o):(o=Oa(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?lx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=ax,r}return o=e.child,e=o.sibling,r=Yo(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function ck(e,t){return t=Fm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function hp(e,t,n,r){return r!==null&&Gb(r),kc(t,e.child,null,n),e=ck(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function UO(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=Sy(Error(Ae(422))),hp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=Fm({mode:"visible",children:r.children},s,0,null),o=Oa(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&kc(t,e.child,null,a),t.child.memoizedState=lx(a),t.memoizedState=ax,o);if(!(t.mode&1))return hp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Ae(419)),r=Sy(o,r,void 0),hp(e,t,a,r)}if(l=(a&e.childLanes)!==0,Ur||l){if(r=hr,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,io(e,s),ei(r,e,s,-1))}return mk(),r=Sy(Error(Ae(421))),hp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=oD.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ls=Vo(s.nextSibling),us=t,_n=!0,Ys=null,e!==null&&(Ns[Cs++]=Yi,Ns[Cs++]=Gi,Ns[Cs++]=Va,Yi=e.id,Gi=e.overflow,Va=t),t=ck(t,r.children),t.flags|=4096,t)}function $j(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),tx(e.return,t,n)}function jy(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 qA(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Lr(e,t,r.children,n),r=Tn.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&&$j(e,n,t);else if(e.tag===19)$j(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(gn(Tn,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&&Oh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),jy(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&&Oh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}jy(t,!0,n,null,o);break;case"together":jy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function rh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function oo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),qa|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ae(153));if(t.child!==null){for(e=t.child,n=Yo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function YO(e,t,n){switch(t.tag){case 3:VA(t),bc();break;case 5:wA(t);break;case 1:Xr(t.type)&&Ih(t);break;case 4:tk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;gn(Mh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(gn(Tn,Tn.current&1),t.flags|=128,null):n&t.child.childLanes?KA(e,t,n):(gn(Tn,Tn.current&1),e=oo(e,t,n),e!==null?e.sibling:null);gn(Tn,Tn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return qA(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),gn(Tn,Tn.current),r)break;return null;case 22:case 23:return t.lanes=0,HA(e,t,n)}return oo(e,t,n)}var UA,cx,YA,GA;UA=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};cx=function(){};YA=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Ra(Ni.current);var o=null;switch(n){case"input":s=Iw(e,s),r=Iw(e,r),o=[];break;case"select":s=Ln({},s,{value:void 0}),r=Ln({},r,{value:void 0}),o=[];break;case"textarea":s=Mw(e,s),r=Mw(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Ah)}Lw(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"&&(gd.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"&&(gd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&kn("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)}};GA=function(e,t,n,r){n!==r&&(t.flags|=4)};function Nu(e,t){if(!_n)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 jr(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 GO(e,t,n){var r=t.pendingProps;switch(Yb(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(t),null;case 1:return Xr(t.type)&&Ph(),jr(t),null;case 3:return r=t.stateNode,vc(),Sn(Jr),Sn(Er),rk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(fp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ys!==null&&(yx(Ys),Ys=null))),cx(e,t),jr(t),null;case 5:nk(t);var s=Ra(Ed.current);if(n=t.type,e!==null&&t.stateNode!=null)YA(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ae(166));return jr(t),null}if(e=Ra(Ni.current),fp(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[wi]=t,r[Cd]=o,e=(t.mode&1)!==0,n){case"dialog":kn("cancel",r),kn("close",r);break;case"iframe":case"object":case"embed":kn("load",r);break;case"video":case"audio":for(s=0;s<Bu.length;s++)kn(Bu[s],r);break;case"source":kn("error",r);break;case"img":case"image":case"link":kn("error",r),kn("load",r);break;case"details":kn("toggle",r);break;case"input":V0(r,o),kn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},kn("invalid",r);break;case"textarea":q0(r,o),kn("invalid",r)}Lw(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&&dp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&dp(r.textContent,l,e),s=["children",""+l]):gd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&kn("scroll",r)}switch(n){case"input":rp(r),K0(r,o,!0);break;case"textarea":rp(r),U0(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Ah)}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=SE(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[wi]=t,e[Cd]=r,UA(e,t,!1,!1),t.stateNode=e;e:{switch(a=Ow(n,r),n){case"dialog":kn("cancel",e),kn("close",e),s=r;break;case"iframe":case"object":case"embed":kn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Bu.length;s++)kn(Bu[s],e);s=r;break;case"source":kn("error",e),s=r;break;case"img":case"image":case"link":kn("error",e),kn("load",e),s=r;break;case"details":kn("toggle",e),s=r;break;case"input":V0(e,r),s=Iw(e,r),kn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Ln({},r,{value:void 0}),kn("invalid",e);break;case"textarea":q0(e,r),s=Mw(e,r),kn("invalid",e);break;default:s=r}Lw(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?CE(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&jE(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&yd(e,c):typeof c=="number"&&yd(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(gd.hasOwnProperty(o)?c!=null&&o==="onScroll"&&kn("scroll",e):c!=null&&Tb(e,o,c,a))}switch(n){case"input":rp(e),K0(e,r,!1);break;case"textarea":rp(e),U0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Xo(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?sc(e,!!r.multiple,o,!1):r.defaultValue!=null&&sc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Ah)}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 jr(t),null;case 6:if(e&&t.stateNode!=null)GA(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ae(166));if(n=Ra(Ed.current),Ra(Ni.current),fp(t)){if(r=t.stateNode,n=t.memoizedProps,r[wi]=t,(o=r.nodeValue!==n)&&(e=us,e!==null))switch(e.tag){case 3:dp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&dp(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[wi]=t,t.stateNode=r}return jr(t),null;case 13:if(Sn(Tn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(_n&&ls!==null&&t.mode&1&&!(t.flags&128))pA(),bc(),t.flags|=98560,o=!1;else if(o=fp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Ae(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Ae(317));o[wi]=t}else bc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jr(t),o=!1}else Ys!==null&&(yx(Ys),Ys=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||Tn.current&1?rr===0&&(rr=3):mk())),t.updateQueue!==null&&(t.flags|=4),jr(t),null);case 4:return vc(),cx(e,t),e===null&&jd(t.stateNode.containerInfo),jr(t),null;case 10:return Qb(t.type._context),jr(t),null;case 17:return Xr(t.type)&&Ph(),jr(t),null;case 19:if(Sn(Tn),o=t.memoizedState,o===null)return jr(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Nu(o,!1);else{if(rr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Oh(e),a!==null){for(t.flags|=128,Nu(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 gn(Tn,Tn.current&1|2),t.child}e=e.sibling}o.tail!==null&&Vn()>jc&&(t.flags|=128,r=!0,Nu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Oh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!_n)return jr(t),null}else 2*Vn()-o.renderingStartTime>jc&&n!==1073741824&&(t.flags|=128,r=!0,Nu(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=Vn(),t.sibling=null,n=Tn.current,gn(Tn,r?n&1|2:n&1),t):(jr(t),null);case 22:case 23:return hk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?is&1073741824&&(jr(t),t.subtreeFlags&6&&(t.flags|=8192)):jr(t),null;case 24:return null;case 25:return null}throw Error(Ae(156,t.tag))}function JO(e,t){switch(Yb(t),t.tag){case 1:return Xr(t.type)&&Ph(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vc(),Sn(Jr),Sn(Er),rk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return nk(t),null;case 13:if(Sn(Tn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ae(340));bc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Sn(Tn),null;case 4:return vc(),null;case 10:return Qb(t.type._context),null;case 22:case 23:return hk(),null;case 24:return null;default:return null}}var mp=!1,Nr=!1,XO=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Xl(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){zn(e,t,r)}else n.current=null}function ux(e,t,n){try{n()}catch(r){zn(e,t,r)}}var Lj=!1;function QO(e,t){if(Uw=Ch,e=eA(),qb(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 h;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==o||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)p=f,f=h;for(;;){if(f===e)break t;if(p===n&&++u===s&&(l=a),p===o&&++d===r&&(c=a),(h=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Yw={focusedElem:e,selectionRange:n},Ch=!1,Qe=t;Qe!==null;)if(t=Qe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Qe=e;else for(;Qe!==null;){t=Qe;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:Ks(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(Ae(163))}}catch(j){zn(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Qe=e;break}Qe=t.return}return y=Lj,Lj=!1,y}function nd(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&&ux(t,n,o)}s=s.next}while(s!==r)}}function Om(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 dx(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 JA(e){var t=e.alternate;t!==null&&(e.alternate=null,JA(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[Cd],delete t[Xw],delete t[MO],delete t[$O])),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 XA(e){return e.tag===5||e.tag===3||e.tag===4}function Oj(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||XA(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 fx(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=Ah));else if(r!==4&&(e=e.child,e!==null))for(fx(e,t,n),e=e.sibling;e!==null;)fx(e,t,n),e=e.sibling}function px(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(px(e,t,n),e=e.sibling;e!==null;)px(e,t,n),e=e.sibling}var gr=null,qs=!1;function jo(e,t,n){for(n=n.child;n!==null;)QA(e,t,n),n=n.sibling}function QA(e,t,n){if(ji&&typeof ji.onCommitFiberUnmount=="function")try{ji.onCommitFiberUnmount(Am,n)}catch{}switch(n.tag){case 5:Nr||Xl(n,t);case 6:var r=gr,s=qs;gr=null,jo(e,t,n),gr=r,qs=s,gr!==null&&(qs?(e=gr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):gr.removeChild(n.stateNode));break;case 18:gr!==null&&(qs?(e=gr,n=n.stateNode,e.nodeType===8?yy(e.parentNode,n):e.nodeType===1&&yy(e,n),kd(e)):yy(gr,n.stateNode));break;case 4:r=gr,s=qs,gr=n.stateNode.containerInfo,qs=!0,jo(e,t,n),gr=r,qs=s;break;case 0:case 11:case 14:case 15:if(!Nr&&(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)&&ux(n,t,a),s=s.next}while(s!==r)}jo(e,t,n);break;case 1:if(!Nr&&(Xl(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){zn(n,t,l)}jo(e,t,n);break;case 21:jo(e,t,n);break;case 22:n.mode&1?(Nr=(r=Nr)||n.memoizedState!==null,jo(e,t,n),Nr=r):jo(e,t,n);break;default:jo(e,t,n)}}function Dj(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new XO),t.forEach(function(r){var s=aD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Hs(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:gr=l.stateNode,qs=!1;break e;case 3:gr=l.stateNode.containerInfo,qs=!0;break e;case 4:gr=l.stateNode.containerInfo,qs=!0;break e}l=l.return}if(gr===null)throw Error(Ae(160));QA(o,a,s),gr=null,qs=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){zn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)ZA(t,e),t=t.sibling}function ZA(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Hs(t,e),di(e),r&4){try{nd(3,e,e.return),Om(3,e)}catch(v){zn(e,e.return,v)}try{nd(5,e,e.return)}catch(v){zn(e,e.return,v)}}break;case 1:Hs(t,e),di(e),r&512&&n!==null&&Xl(n,n.return);break;case 5:if(Hs(t,e),di(e),r&512&&n!==null&&Xl(n,n.return),e.flags&32){var s=e.stateNode;try{yd(s,"")}catch(v){zn(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&&kE(s,o),Ow(l,a);var u=Ow(l,o);for(a=0;a<c.length;a+=2){var d=c[a],f=c[a+1];d==="style"?CE(s,f):d==="dangerouslySetInnerHTML"?jE(s,f):d==="children"?yd(s,f):Tb(s,d,f,u)}switch(l){case"input":Rw(s,o);break;case"textarea":vE(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?sc(s,!!o.multiple,h,!1):p!==!!o.multiple&&(o.defaultValue!=null?sc(s,!!o.multiple,o.defaultValue,!0):sc(s,!!o.multiple,o.multiple?[]:"",!1))}s[Cd]=o}catch(v){zn(e,e.return,v)}}break;case 6:if(Hs(t,e),di(e),r&4){if(e.stateNode===null)throw Error(Ae(162));s=e.stateNode,o=e.memoizedProps;try{s.nodeValue=o}catch(v){zn(e,e.return,v)}}break;case 3:if(Hs(t,e),di(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{kd(t.containerInfo)}catch(v){zn(e,e.return,v)}break;case 4:Hs(t,e),di(e);break;case 13:Hs(t,e),di(e),s=e.child,s.flags&8192&&(o=s.memoizedState!==null,s.stateNode.isHidden=o,!o||s.alternate!==null&&s.alternate.memoizedState!==null||(fk=Vn())),r&4&&Dj(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Nr=(u=Nr)||d,Hs(t,e),Nr=u):Hs(t,e),di(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(Qe=e,d=e.child;d!==null;){for(f=Qe=d;Qe!==null;){switch(p=Qe,h=p.child,p.tag){case 0:case 11:case 14:case 15:nd(4,p,p.return);break;case 1:Xl(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){zn(r,n,v)}}break;case 5:Xl(p,p.return);break;case 22:if(p.memoizedState!==null){zj(f);continue}}h!==null?(h.return=p,Qe=h):zj(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=NE("display",a))}catch(v){zn(e,e.return,v)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(v){zn(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:Hs(t,e),di(e),r&4&&Dj(e);break;case 21:break;default:Hs(t,e),di(e)}}function di(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(XA(n)){var r=n;break e}n=n.return}throw Error(Ae(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(yd(s,""),r.flags&=-33);var o=Oj(e);px(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Oj(e);fx(e,l,a);break;default:throw Error(Ae(161))}}catch(c){zn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ZO(e,t,n){Qe=e,eP(e)}function eP(e,t,n){for(var r=(e.mode&1)!==0;Qe!==null;){var s=Qe,o=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||mp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Nr;l=mp;var u=Nr;if(mp=a,(Nr=c)&&!u)for(Qe=s;Qe!==null;)a=Qe,c=a.child,a.tag===22&&a.memoizedState!==null?Bj(s):c!==null?(c.return=a,Qe=c):Bj(s);for(;o!==null;)Qe=o,eP(o),o=o.sibling;Qe=s,mp=l,Nr=u}Fj(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Qe=o):Fj(e)}}function Fj(e){for(;Qe!==null;){var t=Qe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Nr||Om(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Nr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Ks(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&Sj(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}Sj(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&&kd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ae(163))}Nr||t.flags&512&&dx(t)}catch(p){zn(t,t.return,p)}}if(t===e){Qe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Qe=n;break}Qe=t.return}}function zj(e){for(;Qe!==null;){var t=Qe;if(t===e){Qe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Qe=n;break}Qe=t.return}}function Bj(e){for(;Qe!==null;){var t=Qe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Om(4,t)}catch(c){zn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){zn(t,s,c)}}var o=t.return;try{dx(t)}catch(c){zn(t,o,c)}break;case 5:var a=t.return;try{dx(t)}catch(c){zn(t,a,c)}}}catch(c){zn(t,t.return,c)}if(t===e){Qe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Qe=l;break}Qe=t.return}}var eD=Math.ceil,zh=fo.ReactCurrentDispatcher,uk=fo.ReactCurrentOwner,Ps=fo.ReactCurrentBatchConfig,qt=0,hr=null,Gn=null,yr=0,is=0,Ql=aa(0),rr=0,Rd=null,qa=0,Dm=0,dk=0,rd=null,Kr=null,fk=0,jc=1/0,Ki=null,Bh=!1,hx=null,qo=null,gp=!1,Do=null,Hh=0,sd=0,mx=null,sh=-1,ih=0;function Or(){return qt&6?Vn():sh!==-1?sh:sh=Vn()}function Uo(e){return e.mode&1?qt&2&&yr!==0?yr&-yr:OO.transition!==null?(ih===0&&(ih=DE()),ih):(e=on,e!==0||(e=window.event,e=e===void 0?16:KE(e.type)),e):1}function ei(e,t,n,r){if(50<sd)throw sd=0,mx=null,Error(Ae(185));rf(e,n,r),(!(qt&2)||e!==hr)&&(e===hr&&(!(qt&2)&&(Dm|=n),rr===4&&Mo(e,yr)),Qr(e,r),n===1&&qt===0&&!(t.mode&1)&&(jc=Vn()+500,Mm&&la()))}function Qr(e,t){var n=e.callbackNode;O2(e,t);var r=Nh(e,e===hr?yr:0);if(r===0)n!==null&&J0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&J0(n),t===1)e.tag===0?LO(Hj.bind(null,e)):uA(Hj.bind(null,e)),RO(function(){!(qt&6)&&la()}),n=null;else{switch(FE(r)){case 1:n=Db;break;case 4:n=LE;break;case 16:n=jh;break;case 536870912:n=OE;break;default:n=jh}n=lP(n,tP.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function tP(e,t){if(sh=-1,ih=0,qt&6)throw Error(Ae(327));var n=e.callbackNode;if(cc()&&e.callbackNode!==n)return null;var r=Nh(e,e===hr?yr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Wh(e,r);else{t=r;var s=qt;qt|=2;var o=rP();(hr!==e||yr!==t)&&(Ki=null,jc=Vn()+500,La(e,t));do try{rD();break}catch(l){nP(e,l)}while(!0);Xb(),zh.current=o,qt=s,Gn!==null?t=0:(hr=null,yr=0,t=rr)}if(t!==0){if(t===2&&(s=Hw(e),s!==0&&(r=s,t=gx(e,s))),t===1)throw n=Rd,La(e,0),Mo(e,r),Qr(e,Vn()),n;if(t===6)Mo(e,r);else{if(s=e.current.alternate,!(r&30)&&!tD(s)&&(t=Wh(e,r),t===2&&(o=Hw(e),o!==0&&(r=o,t=gx(e,o))),t===1))throw n=Rd,La(e,0),Mo(e,r),Qr(e,Vn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ae(345));case 2:ja(e,Kr,Ki);break;case 3:if(Mo(e,r),(r&130023424)===r&&(t=fk+500-Vn(),10<t)){if(Nh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Or(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Jw(ja.bind(null,e,Kr,Ki),t);break}ja(e,Kr,Ki);break;case 4:if(Mo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Zs(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=Vn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*eD(r/1960))-r,10<r){e.timeoutHandle=Jw(ja.bind(null,e,Kr,Ki),r);break}ja(e,Kr,Ki);break;case 5:ja(e,Kr,Ki);break;default:throw Error(Ae(329))}}}return Qr(e,Vn()),e.callbackNode===n?tP.bind(null,e):null}function gx(e,t){var n=rd;return e.current.memoizedState.isDehydrated&&(La(e,t).flags|=256),e=Wh(e,t),e!==2&&(t=Kr,Kr=n,t!==null&&yx(t)),e}function yx(e){Kr===null?Kr=e:Kr.push.apply(Kr,e)}function tD(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],o=s.getSnapshot;s=s.value;try{if(!ni(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 Mo(e,t){for(t&=~dk,t&=~Dm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Zs(t),r=1<<n;e[n]=-1,t&=~r}}function Hj(e){if(qt&6)throw Error(Ae(327));cc();var t=Nh(e,0);if(!(t&1))return Qr(e,Vn()),null;var n=Wh(e,t);if(e.tag!==0&&n===2){var r=Hw(e);r!==0&&(t=r,n=gx(e,r))}if(n===1)throw n=Rd,La(e,0),Mo(e,t),Qr(e,Vn()),n;if(n===6)throw Error(Ae(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ja(e,Kr,Ki),Qr(e,Vn()),null}function pk(e,t){var n=qt;qt|=1;try{return e(t)}finally{qt=n,qt===0&&(jc=Vn()+500,Mm&&la())}}function Ua(e){Do!==null&&Do.tag===0&&!(qt&6)&&cc();var t=qt;qt|=1;var n=Ps.transition,r=on;try{if(Ps.transition=null,on=1,e)return e()}finally{on=r,Ps.transition=n,qt=t,!(qt&6)&&la()}}function hk(){is=Ql.current,Sn(Ql)}function La(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,IO(n)),Gn!==null)for(n=Gn.return;n!==null;){var r=n;switch(Yb(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ph();break;case 3:vc(),Sn(Jr),Sn(Er),rk();break;case 5:nk(r);break;case 4:vc();break;case 13:Sn(Tn);break;case 19:Sn(Tn);break;case 10:Qb(r.type._context);break;case 22:case 23:hk()}n=n.return}if(hr=e,Gn=e=Yo(e.current,null),yr=is=t,rr=0,Rd=null,dk=Dm=qa=0,Kr=rd=null,Ia!==null){for(t=0;t<Ia.length;t++)if(n=Ia[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}Ia=null}return e}function nP(e,t){do{var n=Gn;try{if(Xb(),th.current=Fh,Dh){for(var r=$n.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Dh=!1}if(Ka=0,dr=nr=$n=null,td=!1,Ad=0,uk.current=null,n===null||n.return===null){rr=1,Rd=t,Gn=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=yr,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 h=Aj(a);if(h!==null){h.flags&=-257,Pj(h,a,l,o,t),h.mode&1&&Ej(o,u,t),t=h,c=u;var y=t.updateQueue;if(y===null){var v=new Set;v.add(c),t.updateQueue=v}else y.add(c);break e}else{if(!(t&1)){Ej(o,u,t),mk();break e}c=Error(Ae(426))}}else if(_n&&l.mode&1){var b=Aj(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),Pj(b,a,l,o,t),Gb(Sc(c,l));break e}}o=c=Sc(c,l),rr!==4&&(rr=2),rd===null?rd=[o]:rd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=FA(o,c,t);vj(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 j=zA(o,l,t);vj(o,j);break e}}o=o.return}while(o!==null)}iP(n)}catch(N){t=N,Gn===n&&n!==null&&(Gn=n=n.return);continue}break}while(!0)}function rP(){var e=zh.current;return zh.current=Fh,e===null?Fh:e}function mk(){(rr===0||rr===3||rr===2)&&(rr=4),hr===null||!(qa&268435455)&&!(Dm&268435455)||Mo(hr,yr)}function Wh(e,t){var n=qt;qt|=2;var r=rP();(hr!==e||yr!==t)&&(Ki=null,La(e,t));do try{nD();break}catch(s){nP(e,s)}while(!0);if(Xb(),qt=n,zh.current=r,Gn!==null)throw Error(Ae(261));return hr=null,yr=0,rr}function nD(){for(;Gn!==null;)sP(Gn)}function rD(){for(;Gn!==null&&!E2();)sP(Gn)}function sP(e){var t=aP(e.alternate,e,is);e.memoizedProps=e.pendingProps,t===null?iP(e):Gn=t,uk.current=null}function iP(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=JO(n,t),n!==null){n.flags&=32767,Gn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{rr=6,Gn=null;return}}else if(n=GO(n,t,is),n!==null){Gn=n;return}if(t=t.sibling,t!==null){Gn=t;return}Gn=t=e}while(t!==null);rr===0&&(rr=5)}function ja(e,t,n){var r=on,s=Ps.transition;try{Ps.transition=null,on=1,sD(e,t,n,r)}finally{Ps.transition=s,on=r}return null}function sD(e,t,n,r){do cc();while(Do!==null);if(qt&6)throw Error(Ae(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(Ae(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(D2(e,o),e===hr&&(Gn=hr=null,yr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||gp||(gp=!0,lP(jh,function(){return cc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Ps.transition,Ps.transition=null;var a=on;on=1;var l=qt;qt|=4,uk.current=null,QO(e,n),ZA(n,e),jO(Yw),Ch=!!Uw,Yw=Uw=null,e.current=n,ZO(n),A2(),qt=l,on=a,Ps.transition=o}else e.current=n;if(gp&&(gp=!1,Do=e,Hh=s),o=e.pendingLanes,o===0&&(qo=null),R2(n.stateNode),Qr(e,Vn()),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(Bh)throw Bh=!1,e=hx,hx=null,e;return Hh&1&&e.tag!==0&&cc(),o=e.pendingLanes,o&1?e===mx?sd++:(sd=0,mx=e):sd=0,la(),null}function cc(){if(Do!==null){var e=FE(Hh),t=Ps.transition,n=on;try{if(Ps.transition=null,on=16>e?16:e,Do===null)var r=!1;else{if(e=Do,Do=null,Hh=0,qt&6)throw Error(Ae(331));var s=qt;for(qt|=4,Qe=e.current;Qe!==null;){var o=Qe,a=o.child;if(Qe.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(Qe=u;Qe!==null;){var d=Qe;switch(d.tag){case 0:case 11:case 15:nd(8,d,o)}var f=d.child;if(f!==null)f.return=d,Qe=f;else for(;Qe!==null;){d=Qe;var p=d.sibling,h=d.return;if(JA(d),d===u){Qe=null;break}if(p!==null){p.return=h,Qe=p;break}Qe=h}}}var y=o.alternate;if(y!==null){var v=y.child;if(v!==null){y.child=null;do{var b=v.sibling;v.sibling=null,v=b}while(v!==null)}}Qe=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Qe=a;else e:for(;Qe!==null;){if(o=Qe,o.flags&2048)switch(o.tag){case 0:case 11:case 15:nd(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,Qe=g;break e}Qe=o.return}}var k=e.current;for(Qe=k;Qe!==null;){a=Qe;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Qe=x;else e:for(a=k;Qe!==null;){if(l=Qe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Om(9,l)}}catch(N){zn(l,l.return,N)}if(l===a){Qe=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Qe=j;break e}Qe=l.return}}if(qt=s,la(),ji&&typeof ji.onPostCommitFiberRoot=="function")try{ji.onPostCommitFiberRoot(Am,e)}catch{}r=!0}return r}finally{on=n,Ps.transition=t}}return!1}function Wj(e,t,n){t=Sc(n,t),t=FA(e,t,1),e=Ko(e,t,1),t=Or(),e!==null&&(rf(e,1,t),Qr(e,t))}function zn(e,t,n){if(e.tag===3)Wj(e,e,n);else for(;t!==null;){if(t.tag===3){Wj(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=Sc(n,e),e=zA(t,e,1),t=Ko(t,e,1),e=Or(),t!==null&&(rf(t,1,e),Qr(t,e));break}}t=t.return}}function iD(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Or(),e.pingedLanes|=e.suspendedLanes&n,hr===e&&(yr&n)===n&&(rr===4||rr===3&&(yr&130023424)===yr&&500>Vn()-fk?La(e,0):dk|=n),Qr(e,t)}function oP(e,t){t===0&&(e.mode&1?(t=op,op<<=1,!(op&130023424)&&(op=4194304)):t=1);var n=Or();e=io(e,t),e!==null&&(rf(e,t,n),Qr(e,n))}function oD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),oP(e,n)}function aD(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(Ae(314))}r!==null&&r.delete(t),oP(e,n)}var aP;aP=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Jr.current)Ur=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ur=!1,YO(e,t,n);Ur=!!(e.flags&131072)}else Ur=!1,_n&&t.flags&1048576&&dA(t,Th,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;rh(e,t),e=t.pendingProps;var s=xc(t,Er.current);lc(t,n),s=ik(null,t,r,e,s,n);var o=ok();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,Xr(r)?(o=!0,Ih(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,ek(t),s.updater=Lm,t.stateNode=s,s._reactInternals=t,rx(t,r,e,n),t=ox(null,t,r,!0,o,n)):(t.tag=0,_n&&o&&Ub(t),Lr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(rh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=cD(r),e=Ks(r,e),s){case 0:t=ix(null,t,r,e,n);break e;case 1:t=Tj(null,t,r,e,n);break e;case 11:t=Ij(null,t,r,e,n);break e;case 14:t=Rj(null,t,r,Ks(r.type,e),n);break e}throw Error(Ae(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),ix(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),Tj(e,t,r,s,n);case 3:e:{if(VA(t),e===null)throw Error(Ae(387));r=t.pendingProps,o=t.memoizedState,s=o.element,yA(e,t),Lh(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=Sc(Error(Ae(423)),t),t=Mj(e,t,r,n,s);break e}else if(r!==s){s=Sc(Error(Ae(424)),t),t=Mj(e,t,r,n,s);break e}else for(ls=Vo(t.stateNode.containerInfo.firstChild),us=t,_n=!0,Ys=null,n=mA(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(bc(),r===s){t=oo(e,t,n);break e}Lr(e,t,r,n)}t=t.child}return t;case 5:return wA(t),e===null&&ex(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,Gw(r,s)?a=null:o!==null&&Gw(r,o)&&(t.flags|=32),WA(e,t),Lr(e,t,a,n),t.child;case 6:return e===null&&ex(t),null;case 13:return KA(e,t,n);case 4:return tk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=kc(t,null,r,n):Lr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),Ij(e,t,r,s,n);case 7:return Lr(e,t,t.pendingProps,n),t.child;case 8:return Lr(e,t,t.pendingProps.children,n),t.child;case 12:return Lr(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,gn(Mh,r._currentValue),r._currentValue=a,o!==null)if(ni(o.value,a)){if(o.children===s.children&&!Jr.current){t=oo(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=Zi(-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),tx(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(Ae(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),tx(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}Lr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,lc(t,n),s=Is(s),r=r(s),t.flags|=1,Lr(e,t,r,n),t.child;case 14:return r=t.type,s=Ks(r,t.pendingProps),s=Ks(r.type,s),Rj(e,t,r,s,n);case 15:return BA(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),rh(e,t),t.tag=1,Xr(r)?(e=!0,Ih(t)):e=!1,lc(t,n),DA(t,r,s),rx(t,r,s,n),ox(null,t,r,!0,e,n);case 19:return qA(e,t,n);case 22:return HA(e,t,n)}throw Error(Ae(156,t.tag))};function lP(e,t){return $E(e,t)}function lD(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 As(e,t,n,r){return new lD(e,t,n,r)}function gk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function cD(e){if(typeof e=="function")return gk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===$b)return 11;if(e===Lb)return 14}return 2}function Yo(e,t){var n=e.alternate;return n===null?(n=As(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 oh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")gk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Hl:return Oa(n.children,s,o,t);case Mb:a=8,s|=8;break;case _w:return e=As(12,n,t,s|2),e.elementType=_w,e.lanes=o,e;case Ew:return e=As(13,n,t,s),e.elementType=Ew,e.lanes=o,e;case Aw:return e=As(19,n,t,s),e.elementType=Aw,e.lanes=o,e;case wE:return Fm(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case gE:a=10;break e;case yE:a=9;break e;case $b:a=11;break e;case Lb:a=14;break e;case Po:a=16,r=null;break e}throw Error(Ae(130,e==null?e:typeof e,""))}return t=As(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Oa(e,t,n,r){return e=As(7,e,r,t),e.lanes=n,e}function Fm(e,t,n,r){return e=As(22,e,r,t),e.elementType=wE,e.lanes=n,e.stateNode={isHidden:!1},e}function Ny(e,t,n){return e=As(6,e,null,t),e.lanes=n,e}function Cy(e,t,n){return t=As(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function uD(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=oy(0),this.expirationTimes=oy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function yk(e,t,n,r,s,o,a,l,c){return e=new uD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=As(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ek(o),e}function dD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Bl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function cP(e){if(!e)return Qo;e=e._reactInternals;e:{if(ol(e)!==e||e.tag!==1)throw Error(Ae(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Xr(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ae(171))}if(e.tag===1){var n=e.type;if(Xr(n))return cA(e,n,t)}return t}function uP(e,t,n,r,s,o,a,l,c){return e=yk(n,r,!0,e,s,o,a,l,c),e.context=cP(null),n=e.current,r=Or(),s=Uo(n),o=Zi(r,s),o.callback=t??null,Ko(n,o,s),e.current.lanes=s,rf(e,s,r),Qr(e,r),e}function zm(e,t,n,r){var s=t.current,o=Or(),a=Uo(s);return n=cP(n),t.context===null?t.context=n:t.pendingContext=n,t=Zi(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Ko(s,t,a),e!==null&&(ei(e,s,a,o),eh(e,s,a)),a}function Vh(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 Vj(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function wk(e,t){Vj(e,t),(e=e.alternate)&&Vj(e,t)}function fD(){return null}var dP=typeof reportError=="function"?reportError:function(e){console.error(e)};function xk(e){this._internalRoot=e}Bm.prototype.render=xk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ae(409));zm(e,t,null,null)};Bm.prototype.unmount=xk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ua(function(){zm(null,e,null,null)}),t[so]=null}};function Bm(e){this._internalRoot=e}Bm.prototype.unstable_scheduleHydration=function(e){if(e){var t=HE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<To.length&&t!==0&&t<To[n].priority;n++);To.splice(n,0,e),n===0&&VE(e)}};function bk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Hm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Kj(){}function pD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=Vh(a);o.call(u)}}var a=uP(t,r,e,0,null,!1,!1,"",Kj);return e._reactRootContainer=a,e[so]=a.current,jd(e.nodeType===8?e.parentNode:e),Ua(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=Vh(c);l.call(u)}}var c=yk(e,0,!1,null,null,!1,!1,"",Kj);return e._reactRootContainer=c,e[so]=c.current,jd(e.nodeType===8?e.parentNode:e),Ua(function(){zm(t,c,n,r)}),c}function Wm(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=Vh(a);l.call(c)}}zm(t,a,e,s)}else a=pD(n,t,e,s,r);return Vh(a)}zE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=zu(t.pendingLanes);n!==0&&(Fb(t,n|1),Qr(t,Vn()),!(qt&6)&&(jc=Vn()+500,la()))}break;case 13:Ua(function(){var r=io(e,1);if(r!==null){var s=Or();ei(r,e,1,s)}}),wk(e,1)}};zb=function(e){if(e.tag===13){var t=io(e,134217728);if(t!==null){var n=Or();ei(t,e,134217728,n)}wk(e,134217728)}};BE=function(e){if(e.tag===13){var t=Uo(e),n=io(e,t);if(n!==null){var r=Or();ei(n,e,t,r)}wk(e,t)}};HE=function(){return on};WE=function(e,t){var n=on;try{return on=e,t()}finally{on=n}};Fw=function(e,t,n){switch(t){case"input":if(Rw(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=Tm(r);if(!s)throw Error(Ae(90));bE(r),Rw(r,s)}}}break;case"textarea":vE(e,n);break;case"select":t=n.value,t!=null&&sc(e,!!n.multiple,t,!1)}};AE=pk;PE=Ua;var hD={usingClientEntryPoint:!1,Events:[of,ql,Tm,_E,EE,pk]},Cu={findFiberByHostInstance:Pa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},mD={bundleType:Cu.bundleType,version:Cu.version,rendererPackageName:Cu.rendererPackageName,rendererConfig:Cu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:fo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=TE(e),e===null?null:e.stateNode},findFiberByHostInstance:Cu.findFiberByHostInstance||fD,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 yp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yp.isDisabled&&yp.supportsFiber)try{Am=yp.inject(mD),ji=yp}catch{}}hs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=hD;hs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bk(t))throw Error(Ae(200));return dD(e,t,null,n)};hs.createRoot=function(e,t){if(!bk(e))throw Error(Ae(299));var n=!1,r="",s=dP;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=yk(e,1,!1,null,null,n,!1,r,s),e[so]=t.current,jd(e.nodeType===8?e.parentNode:e),new xk(t)};hs.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(Ae(188)):(e=Object.keys(e).join(","),Error(Ae(268,e)));return e=TE(t),e=e===null?null:e.stateNode,e};hs.flushSync=function(e){return Ua(e)};hs.hydrate=function(e,t,n){if(!Hm(t))throw Error(Ae(200));return Wm(null,e,t,!0,n)};hs.hydrateRoot=function(e,t,n){if(!bk(e))throw Error(Ae(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=dP;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=uP(t,null,e,1,n??null,s,!1,o,a),e[so]=t.current,jd(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 Bm(t)};hs.render=function(e,t,n){if(!Hm(t))throw Error(Ae(200));return Wm(null,e,t,!1,n)};hs.unmountComponentAtNode=function(e){if(!Hm(e))throw Error(Ae(40));return e._reactRootContainer?(Ua(function(){Wm(null,null,e,!1,function(){e._reactRootContainer=null,e[so]=null})}),!0):!1};hs.unstable_batchedUpdates=pk;hs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Hm(n))throw Error(Ae(200));if(e==null||e._reactInternals===void 0)throw Error(Ae(38));return Wm(e,t,n,!1,r)};hs.version="18.3.1-next-f1338f8080-20240426";function fP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(fP)}catch(e){console.error(e)}}fP(),fE.exports=hs;var ur=fE.exports,qj=ur;Nw.createRoot=qj.createRoot,Nw.hydrateRoot=qj.hydrateRoot;const pP=m.createContext(null);function wx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function gD(){const e=wx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function yD({children:e}){const[t,n]=m.useState(gD);m.useEffect(()=>{const o=()=>n(wx(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=m.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=wx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(pP.Provider,{value:s,children:e})}function Ts(){const e=m.useContext(pP);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function wD(){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 Uj={};function xx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&Uj[t[0]]||(typeof t[0]=="string"&&(Uj[t[0]]=new Date),wD(...t))}const hP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function Yj(e,t,n){e.loadNamespaces(t,hP(e,n))}function Gj(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,hP(e,r))}function xD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],s=t.options?t.options.fallbackLng:!1,o=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(o,e)))}function bD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(xx("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,o)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,e))return!1}}):xD(e,t,n)}const kD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,vD={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},SD=e=>vD[e],jD=e=>e.replace(kD,SD);let bx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:jD};function ND(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};bx={...bx,...e}}function CD(){return bx}let mP;function _D(e){mP=e}function ED(){return mP}const AD={type:"3rdParty",init(e){ND(e.options.react),_D(e)}},PD=m.createContext();class ID{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const RD=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function zr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(PD)||{},o=n||r||ED();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new ID),!o){xx("You will need to pass in an i18next instance by using initReactI18next");const x=(N,C)=>typeof C=="string"?C:C&&typeof C=="object"&&typeof C.defaultValue=="string"?C.defaultValue:Array.isArray(N)?N[N.length-1]:N,j=[x,{},!1];return j.t=x,j.i18n={},j.ready=!1,j}o.options.react&&o.options.react.wait!==void 0&&xx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...CD(),...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=>bD(x,o,a));function f(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[p,h]=m.useState(f);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=RD(y),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:j}=a;b.current=!0,!d&&!l&&(t.lng?Gj(o,t.lng,u,()=>{b.current&&h(f)}):Yj(o,u,()=>{b.current&&h(f)})),d&&v&&v!==y&&b.current&&h(f);function N(){b.current&&h(f)}return x&&o&&o.on(x,N),j&&o&&o.store.on(j,N),()=>{b.current=!1,x&&o&&x.split(" ").forEach(C=>o.off(C,N)),j&&o&&j.split(" ").forEach(C=>o.store.off(C,N))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{b.current&&!g.current&&h(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?Gj(o,t.lng,u,()=>x()):Yj(o,u,()=>x())})}const gP="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",TD=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{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:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],MD=[{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 $D(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function LD({authUser:e,onLogout:t}){const{path:n,navigate:r}=Ts(),{t:s}=zr(),[o,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),i.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[i.jsxs("div",{className:"af-brand",children:[i.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:i.jsx("img",{src:gP,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:TD.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>i.jsxs("button",{type:"button",className:"af-nav-link"+($D(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&&MD.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 OD="agentflow.pipelineRecent",DD=15;function FD(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function zD(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(OD);return e?FD(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 BD(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 Jj(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 HD(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:BD(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,DD)}var os=Uint8Array,Zl=Uint16Array,WD=Int32Array,yP=new os([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]),wP=new os([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]),VD=new os([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),xP=function(e,t){for(var n=new Zl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new WD(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}},bP=xP(yP,2),kP=bP.b,KD=bP.r;kP[28]=258,KD[258]=28;var qD=xP(wP,0),UD=qD.b,kx=new Zl(32768);for(var vn=0;vn<32768;++vn){var No=(vn&43690)>>1|(vn&21845)<<1;No=(No&52428)>>2|(No&13107)<<2,No=(No&61680)>>4|(No&3855)<<4,kx[vn]=((No&65280)>>8|(No&255)<<8)>>1}var id=function(e,t,n){for(var r=e.length,s=0,o=new Zl(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new Zl(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new Zl(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[kx[f]>>c]=u}else for(l=new Zl(r),s=0;s<r;++s)e[s]&&(l[s]=kx[a[e[s]-1]++]>>15-e[s]);return l},lf=new os(288);for(var vn=0;vn<144;++vn)lf[vn]=8;for(var vn=144;vn<256;++vn)lf[vn]=9;for(var vn=256;vn<280;++vn)lf[vn]=7;for(var vn=280;vn<288;++vn)lf[vn]=8;var vP=new os(32);for(var vn=0;vn<32;++vn)vP[vn]=5;var YD=id(lf,9,1),GD=id(vP,5,1),_y=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ws=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Ey=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},JD=function(e){return(e+7)/8|0},kk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new os(e.subarray(t,n))},XD=["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"],js=function(e,t,n){var r=new Error(t||XD[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,js),!n)throw r;return r},QD=function(e,t,n,r){var s=e.length,o=r?r.length:0;if(!s||t.f&&!t.l)return n||new os(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new os(s*3));var u=function(ce){var de=n.length;if(ce>de){var me=new os(Math.max(de*2,ce));me.set(n),n=me}},d=t.f||0,f=t.p||0,p=t.b||0,h=t.l,y=t.d,v=t.m,b=t.n,g=s*8;do{if(!h){d=Ws(e,f,1);var k=Ws(e,f+1,3);if(f+=3,k)if(k==1)h=YD,y=GD,v=9,b=5;else if(k==2){var C=Ws(e,f,31)+257,I=Ws(e,f+10,15)+4,R=C+Ws(e,f+5,31)+1;f+=14;for(var H=new os(R),A=new os(19),L=0;L<I;++L)A[VD[L]]=Ws(e,f+L*3,7);f+=I*3;for(var D=_y(A),O=(1<<D)-1,M=id(A,D,1),L=0;L<R;){var K=M[Ws(e,f,O)];f+=K&15;var x=K>>4;if(x<16)H[L++]=x;else{var z=0,F=0;for(x==16?(F=3+Ws(e,f,3),f+=2,z=H[L-1]):x==17?(F=3+Ws(e,f,7),f+=3):x==18&&(F=11+Ws(e,f,127),f+=7);F--;)H[L++]=z}}var $=H.subarray(0,C),W=H.subarray(C);v=_y($),b=_y(W),h=id($,v,1),y=id(W,b,1)}else js(1);else{var x=JD(f)+4,j=e[x-4]|e[x-3]<<8,N=x+j;if(N>s){c&&js(0);break}l&&u(p+j),n.set(e.subarray(x,N),p),t.b=p+=j,t.p=f=N*8,t.f=d;continue}if(f>g){c&&js(0);break}}l&&u(p+131072);for(var E=(1<<v)-1,Q=(1<<b)-1,V=f;;V=f){var z=h[Ey(e,f)&E],B=z>>4;if(f+=z&15,f>g){c&&js(0);break}if(z||js(2),B<256)n[p++]=B;else if(B==256){V=f,h=null;break}else{var se=B-254;if(B>264){var L=B-257,ue=yP[L];se=Ws(e,f,(1<<ue)-1)+kP[L],f+=ue}var G=y[Ey(e,f)&Q],ee=G>>4;G||js(3),f+=G&15;var W=UD[ee];if(ee>3){var ue=wP[ee];W+=Ey(e,f)&(1<<ue)-1,f+=ue}if(f>g){c&&js(0);break}l&&u(p+131072);var te=p+se;if(p<W){var ne=o-W,Z=Math.min(W,te);for(ne+p<0&&js(3);p<Z;++p)n[p]=r[ne+p]}for(;p<te;++p)n[p]=n[p-W]}}t.l=h,t.p=V,t.b=p,t.f=d,h&&(d=1,t.m=v,t.d=y,t.n=b)}while(!d);return p!=n.length&&a?kk(n,0,p):n.subarray(0,p)},ZD=new os(0),xi=function(e,t){return e[t]|e[t+1]<<8},Gs=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Ay=function(e,t){return Gs(e,t)+Gs(e,t+4)*4294967296};function eF(e,t){return QD(e,{i:2},t&&t.out,t&&t.dictionary)}var vx=typeof TextDecoder<"u"&&new TextDecoder,tF=0;try{vx.decode(ZD,{stream:!0}),tF=1}catch{}var nF=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:kk(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 rF(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(vx)return vx.decode(e);var s=nF(e),o=s.s,n=s.r;return n.length&&js(8),o}}var sF=function(e,t){return t+30+xi(e,t+26)+xi(e,t+28)},iF=function(e,t,n){var r=xi(e,t+28),s=rF(e.subarray(t+46,t+46+r),!(xi(e,t+8)&2048)),o=t+46+r,a=Gs(e,t+20),l=n&&a==4294967295?oF(e,o):[a,Gs(e,t+24),Gs(e,t+42)],c=l[0],u=l[1],d=l[2];return[xi(e,t+10),c,u,s,o+xi(e,t+30)+xi(e,t+32),d]},oF=function(e,t){for(;xi(e,t)!=1;t+=4+xi(e,t+2));return[Ay(e,t+12),Ay(e,t+4),Ay(e,t+20)]};function aF(e,t){for(var n={},r=e.length-22;Gs(e,r)!=101010256;--r)(!r||e.length-r>65558)&&js(13);var s=xi(e,r+8);if(!s)return{};var o=Gs(e,r+16),a=o==4294967295||s==65535;if(a){var l=Gs(e,r-12);a=Gs(e,l)==101075792,a&&(s=Gs(e,l+32),o=Gs(e,l+48))}for(var c=0;c<s;++c){var u=iF(e,o,a),d=u[0],f=u[1],p=u[2],h=u[3],y=u[4],v=u[5],b=sF(e,v);o=y,d?d==8?n[h]=eF(e.subarray(b,b+f),{out:new os(p)}):js(14,"unknown compression type "+d):n[h]=kk(e,b,b+f)}return n}const lF=8*1024*1024,cF=500;function uF(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 dF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function fF(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 pF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function hF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=aF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const d=uF(c);if(!d||dF(d))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>lF||(o+=1,o>cF))return null;r.set(d,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=fF(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 pF.test(l)?l:null}catch{return null}}const Py=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function mF({file:e,onClose:t,onImported:n}){const{t:r}=zr(),s=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,d]=m.useState("user"),[f,p]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),g=v??e;m.useEffect(()=>{const N=requestAnimationFrame(()=>{var C;return(C=o.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(N)},[]),m.useEffect(()=>{let N=!1;return(async()=>{const C=g.name||"",I=C.toLowerCase();let R="";if(I.endsWith(".zip")){if(R=await hF(g)||"",!R){const H=C.replace(/\.zip$/i,"");Py.test(H)&&(R=H)}}else if(I.endsWith(".yaml")||I.endsWith(".yml")){const H=C.replace(/\.ya?ml$/i,"");Py.test(H)&&(R=H)}N||c(R)})(),()=>{N=!0}},[g]);const k=l.trim(),x=k.length>0&&Py.test(k);async function j(N){if(N.preventDefault(),!(!x||f)){p(!0),y("");try{const C=new FormData;C.set("flowId",k),C.set("targetSpace",u),C.set("file",g,g.name);const I=await fetch("/api/flows/import",{method:"POST",body:C}),R=await I.json().catch(()=>({}));if(!I.ok){y(typeof R.error=="string"?R.error:r("project:importModal.importFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(C){y(String((C==null?void 0:C.message)||C))}finally{p(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.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: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: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:j,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:N=>{var I;const C=(I=N.target.files)==null?void 0:I[0];C&&b(C),N.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:N=>c(N.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 N;return(N=a.current)==null?void 0:N.click()},children:r("project:importModal.changeFile")})}),h?i.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const gF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,Xj="af:newPipelineGuide";function yF({open:e,onClose:t,onCreated:n}){const{t:r}=zr(),s=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("user"),[p,h]=m.useState(!1),[y,v]=m.useState(""),[b,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),h(!1),localStorage.getItem(Xj)==="true"&&g(!0);const I=requestAnimationFrame(()=>{var R;return(R=o.current)==null?void 0:R.focus()});return()=>cancelAnimationFrame(I)},[e]);const k=()=>{localStorage.removeItem(Xj),g(!1)};if(!e)return null;const x=a.trim(),j=x.length>0&&gF.test(x);async function N(C){if(C.preventDefault(),!(!j||p)){h(!0),v(""),k();try{const I=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:d})}),R=await I.json().catch(()=>({}));if(!I.ok){v(typeof R.error=="string"?R.error:r("project:newPipelineModal.createFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(I){v(String((I==null?void 0:I.message)||I))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.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:C=>C.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:N,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:C=>l(C.target.value),"aria-invalid":x.length>0&&!j}),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:C=>u(C.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:!j||p,children:r(p?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const SP="agentflow.pipelineViewPreference";function jP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function NP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(SP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function wF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(SP,JSON.stringify(e))}catch{}}function vk(e){return e==="display"?"display":"workspace"}function xF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function CP(e,t){const n=vk(t);return n==="pipeline"&&xF(e==null?void 0:e.source)?"workspace":n}function bF(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function kF(e,t,n,r=!1){if(!e)return;const s=NP();s[jP(e,t,r)]={view:vk(n),at:Date.now()},wF(s)}function vF(e,t="workspace"){if(!(e!=null&&e.id))return vk(t);const r=NP()[jP(e.id,e.source??"user",!!e.archived)],s=CP(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!bF(e)?"workspace":s}function SF(e,t="workspace"){var s;const n=CP(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 wp(e,t="workspace"){return SF(e,vF(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 Sx(e){return String((e==null?void 0:e.version)||"").trim()}function NF(e){const t=Sx(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 CF({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,o]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("keyword"),[p,h]=m.useState([]),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[j,N]=m.useState(""),C=m.useCallback(async()=>{x("");try{const[D,O]=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 K=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof K.error=="string"?K.error:"HTTP "+O.status);o(Array.isArray(K.skills)?K.skills:[]),l(typeof K.skillsRoot=="string"?K.skillsRoot:""),v({})}catch(D){x(String(D.message||D))}},[]);m.useEffect(()=>{C()},[C]);const I=m.useCallback(async()=>{const D=c.trim();if(D){g("search"),x(""),N("");try{const O=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(d)}`),M=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+O.status);h(Array.isArray(M.items)?M.items:[])}catch(O){x(String(O.message||O))}finally{g("")}}},[c,d]),R=m.useCallback(async(D,O=!1)=>{if(!t)return;const M=D&&typeof D=="object"?D:null,K=String(M?M.slug||M.name||M.collection||M.skillId||M.id:D||"").trim();if(K){g(`install:${K}`),x(""),N("");try{const z=M?{slug:M.slug||"",skillId:M.skillId||"",collection:M.collection||"",collectionName:M.collection&&M.name||"",target:"agentflow",agent:"codex",force:O}:{slug:K,target:"agentflow",agent:"codex",force:O},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)}),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);N(O?`已更新 ${K}`:`已安装 ${K}`),await C(),typeof e=="function"&&await e()}catch(z){x(String(z.message||z))}finally{g("")}}},[t,C,e]),H=m.useCallback(async()=>{if(t&&s.length!==0){g("check-updates"),x(""),N("");try{const D=await Promise.all(s.map(async K=>{const z=String(K.name||"").trim();if(!z)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(z)}&mode=keyword`),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);const W=Array.isArray($.items)?$.items:[],E=W.find(se=>se.slug===z||se.name===z||se.id===z)||W[0],Q=Sx(K),V=String((E==null?void 0:E.version)||"").trim();let B="unknown";return E?Q&&V?B=jF(Q,V)<0?"update":"current":V&&(B="remote-only"):B="missing",[z,{state:B,latestVersion:V,installedVersion:Q,summary:(E==null?void 0:E.summary)||""}]}catch(F){return[z,{state:"error",error:String(F.message||F),installedVersion:Sx(K)}]}})),O={};for(const K of D)K&&(O[K[0]]=K[1]);v(O);const M=Object.values(O).filter(K=>K.state==="update").length;N(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,s]),A=m.useCallback(async D=>{if(!t)return;const O=String(D||"").trim();if(O){g(`uninstall:${O}`),x(""),N("");try{const M=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:O,target:"agentflow",agent:"codex"})}),K=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof K.error=="string"?K.error:"HTTP "+M.status);N(`已卸载 ${O}`),await C(),typeof e=="function"&&await e()}catch(M){x(String(M.message||M))}finally{g("")}}},[t,C,e]),L=m.useCallback(async()=>{if(t){g("update-cli"),x(""),N("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),O=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+D.status);N("SkillHub CLI 已更新"),await C()}catch(D){x(String(D.message||D))}finally{g("")}}},[t,C]);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:C,disabled:!!b,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:H,disabled:!t||!!b||s.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:L,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),h([])},children:[i.jsx("option",{value:"keyword",children:"关键词"}),i.jsx("option",{value:"skillId",children:"Skill ID"}),i.jsx("option",{value:"collectionId",children:"Collection ID"})]}),i.jsx("input",{className:"af-set-input af-set-input--sm",value:c,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&I()},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:()=>I(),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,j?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:j}):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 O=y[D.name],M=!O||O.state==="update"||O.state==="remote-only"||O.state==="unknown"||O.state==="error",K=b===`install:${D.name}`?"更新中…":(O==null?void 0:O.state)==="current"?"已最新":(O==null?void 0:O.state)==="update"&&O.latestVersion?`更新到 v${O.latestVersion}`:(O==null?void 0:O.state)==="remote-only"&&O.latestVersion?`安装 v${O.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:NF(D)}),i.jsx("div",{className:"af-set-skillhub-version-row",children:O?O.state==="update"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",O.installedVersion?`v${O.installedVersion} -> `:"","v",O.latestVersion]}):O.state==="current"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",O.latestVersion||O.installedVersion]}):O.state==="remote-only"?i.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",O.latestVersion,",本地版本未知"]}):O.state==="missing"?i.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):O.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:K}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>A(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 O=D.slug||D.name,M=D.kind==="collection"||D.collection,K=!M&&s.some(z=>z.name===O||z.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||O}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${D.collection}`:O,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:K?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>R(D,K),disabled:!t||!!b,children:K?"更新":M?"安装合集":"安装"})]},D.id||O)})})]})]})]})}function Da(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 _F(e){return{version:1,collections:Da({collections:e})}}function EF(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function _P(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(EF(s)))||""}}function Zo(e,t){const n=_P(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function AF(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 PF(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function IF(e,t,n){const r=Zo(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 RF(e,t,n){const r=String(e).trim().toLowerCase(),s=Da({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return Zo(s,t)}function TF(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Da({collections:r}),l=RF(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=_P(n),p=Array.from(new Set(d.map(f).filter(Boolean)));if(s.length>0&&p.length===s.length)return c;const h=new Set(p),y=new Set(l),v=l.length>0&&l.every(g=>h.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=Zo(g,n);return k.length>0&&k.every(x=>h.has(x))});return l.length>0&&b&&!v?c:p}}}catch{}return c}function Pl(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 MF(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function $F(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 jx(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 EP(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 LF="project:defaultCardDesc";function AP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(LF)}function OF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hn({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(`(${OF(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 DF(e,t,n){const r=[String(e.id),AP(e,n),EP(e),jx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
+ `).toLowerCase()}function FF(e,t,n){return t?DF(e,t,n).includes(t):!0}function zF(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 Iy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
+ `).toLowerCase().includes(n):!0}function Qj(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 Zj(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const BF=["all","agent","control","provide","marketplace"],HF=["all","agent","control","provide"],PP="agentflow.projects.activityPanelOpen",Nx="agentflow.projects.activitySelected";function WF(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(PP);return e!=="0"}function eN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function VF(){return typeof localStorage>"u"?"":localStorage.getItem(Nx)||""}function xp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Wn(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 KF(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 Co(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function IP(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 RP(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 Cx(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 tN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Cx(e,t))}function qF(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function nN(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 UF(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 Ry(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function YF(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 GF(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 h of o.get(f)||[])(!a.has(h)||p>a.get(h))&&(a.set(h,p),l.push(h))}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 JF(e){var v,b,g,k;const t=IP(e),n=RP(e),r=new Map(t.map((x,j)=>[Cx(x,j),tN(x,j)])),s=t.map((x,j)=>({id:Cx(x,j),title:tN(x,j),meta:qF(x)})),o=n.map((x,j)=>{const N=nN(x,"source"),C=nN(x,"target");return{key:(x==null?void 0:x.id)||`${N}-${C}-${j}`,sourceId:N,targetId:C,source:r.get(N)||N||"?",target:r.get(C)||C||"?",label:UF(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=GF(s,o),u=s.map(x=>{const j=YF(a[x.id])||c.get(x.id)||{x:0,y:0},N=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},C=Number(N.width),I=Number(N.height),R=Math.max(132,Math.min(210,Number.isFinite(C)?C*.62:150)),H=Math.max(48,Math.min(76,Number.isFinite(I)?I*.46:54));return{...x,x:j.x,y:j.y,width:R,height:H}}),d=new Map(u.map(x=>[x.id,x])),f=o.map(x=>{const j=d.get(x.sourceId),N=d.get(x.targetId);if(!j||!N)return null;const C=j.x+j.width,I=j.y+j.height/2,R=N.x,H=N.y+N.height/2,A=Math.max(48,Math.abs(R-C)*.45);return{...x,path:`M ${C} ${I} C ${C+A} ${I}, ${R-A} ${H}, ${R} ${H}`,labelX:(C+R)/2,labelY:(I+H)/2}}).filter(Boolean),p=u.reduce((x,j)=>({minX:Math.min(x.minX,j.x),minY:Math.min(x.minY,j.y),maxX:Math.max(x.maxX,j.x+j.width),maxY:Math.max(x.maxY,j.y+j.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,y=`${p.minX-h} ${p.minY-h} ${Math.max(360,p.maxX-p.minX+h*2)} ${Math.max(180,p.maxY-p.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Il({resourceKind:e="",authUser:t=null}){var Pe,wt,Ot,Ut,Bn,Dn;const{t:n}=zr(),{navigate:r,path:s}=Ts(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[d,f]=m.useState([]),[p,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState([]),[k,x]=m.useState(""),[j,N]=m.useState(!1),[C,I]=m.useState([]),[R,H]=m.useState(""),[A,L]=m.useState(""),[D,O]=m.useState(!1),[M,K]=m.useState(!1),[z,F]=m.useState(!1),[$,W]=m.useState(null),[E,Q]=m.useState(!1),[V,B]=m.useState(""),[se,ue]=m.useState(WF),[G,ee]=m.useState(VF),[te,ne]=m.useState("all"),[Z,ce]=m.useState(""),[de,me]=m.useState("overview"),[$e,Ce]=m.useState({}),[_e,Be]=m.useState(""),[ot,gt]=m.useState({}),[Te,st]=m.useState(""),[mt,Rt]=m.useState(""),[xe,Oe]=m.useState({}),[ie,ke]=m.useState(""),[Ke,Ue]=m.useState(""),[be,Pt]=m.useState(""),[tn,Wt]=m.useState(""),[Lt,an]=m.useState(""),[re,Re]=m.useState(!1),[Je,Ze]=m.useState(""),[Tt,_t]=m.useState({hiddenBuiltins:[],promoted:[]}),Kn=m.useRef(0),jn=m.useRef(0),br=m.useRef(0),xn=m.useCallback(async()=>{var he,De;const q=++jn.current;H("");try{const Ee=await fetch("/api/flows");if(q!==jn.current)return;if(!Ee.ok)throw new Error("HTTP "+Ee.status);const et=await Ee.json();if(q!==jn.current)return;u(Array.isArray(et)?et:[])}catch(Ee){if(q!==jn.current)return;u([]),H(String(Ee.message||Ee))}try{const Ee=await fetch("/api/pipeline-recent-runs");if(q!==jn.current)return;if(Ee.ok){const et=await Ee.json();if(q!==jn.current)return;I(Array.isArray(et.runs)?et.runs:[])}else I([])}catch{if(q!==jn.current)return;I([])}if(t!=null&&t.isAdmin)try{const Ee=await fetch("/api/admin/builtin-flows");if(q!==jn.current)return;const et=await Ee.json().catch(()=>({}));Ee.ok&&_t({hiddenBuiltins:Array.isArray((he=et==null?void 0:et.config)==null?void 0:he.hiddenBuiltins)?et.config.hiddenBuiltins:[],promoted:Array.isArray((De=et==null?void 0:et.config)==null?void 0:De.promoted)?et.config.promoted:[]})}catch{if(q!==jn.current)return;_t({hiddenBuiltins:[],promoted:[]})}else _t({hiddenBuiltins:[],promoted:[]});O(!0)},[t==null?void 0:t.isAdmin]),Qn=m.useCallback(async(q,he)=>{if(!(t!=null&&t.isAdmin)||!(q!=null&&q.id))return;const De=`${he}:${q.source}:${q.id}`;Ze(De),H("");try{const Ee=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:he,flowId:q.id,ownerUserId:q.ownerUserId||t.userId})}),et=await Ee.json().catch(()=>({}));if(!Ee.ok)throw new Error(et.error||"更新内置配置失败");await xn()}catch(Ee){H(String(Ee.message||Ee))}finally{Ze("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,xn]),qn=m.useCallback(async()=>{const q=++br.current;L(""),K(!1);const he="/api/nodes",De=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),v([]),ce("");try{const[Ee,et,Nn,bt]=await Promise.all([fetch(he),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(De)]),Yt=await Ee.json().catch(()=>({})),Cn=await et.json().catch(()=>({})),yo=await Nn.json().catch(()=>({})),at=await bt.json().catch(()=>({}));if(!Ee.ok)throw new Error(Yt.error||"Nodes HTTP "+Ee.status);if(!et.ok)throw new Error(Cn.error||"Skills HTTP "+et.status);if(!Nn.ok)throw new Error(yo.error||"Collections HTTP "+Nn.status);if(!bt.ok)throw new Error(at.error||"Flow snippets HTTP "+bt.status);if(q!==br.current)return;f(Array.isArray(Yt.nodes)?Yt.nodes:Array.isArray(Yt)?Yt:[]),h(Array.isArray(Cn.skills)?Cn.skills:[]),g(Da(yo)),v(Array.isArray(at.snippets)?at.snippets:[])}catch(Ee){if(q!==br.current)return;f([]),h([]),v([]),g([]),L(String(Ee.message||Ee))}finally{if(q!==br.current)return;K(!0)}},[e]);m.useEffect(()=>{O(!1),xn(),qn()},[xn,qn]),m.useEffect(()=>{try{localStorage.setItem(PP,se?"1":"0")}catch{}},[se]),m.useEffect(()=>{try{G?localStorage.setItem(Nx,G):localStorage.removeItem(Nx)}catch{}},[G]),m.useEffect(()=>{let q=!1;return fetch("/api/ui-context").then(he=>he.json()).then(he=>{q||Re(!!he.hideCommunityLinks)}).catch(()=>{}),()=>{q=!0}},[]);const mr=m.useCallback(async q=>{if(!o)return;const he=Da({collections:q});N(!0),L("");try{const De=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_F(he))}),Ee=await De.json().catch(()=>({}));if(!De.ok)throw new Error(Ee.error||"Collections HTTP "+De.status);g(Da(Ee))}catch(De){L(String(De.message||De))}finally{N(!1)}},[o]),ts=m.useCallback(()=>{if(!o)return;const q=k.trim();if(!q)return;const he=q.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",De=new Set(b.map(bt=>bt.id));let Ee=he,et=2;for(;De.has(Ee);)Ee=`${he}-${et++}`;const Nn=Date.now();mr([...b,{id:Ee,name:q,skillKeys:[],createdAt:Nn,updatedAt:Nn}]),x(""),ne(`collection:${Ee}`)},[o,k,mr,b]),Pr=m.useCallback(q=>{if(!o)return;const he=b.find(Ee=>Ee.id===q);if(he!=null&&he.builtin)return;const De=b.filter(Ee=>Ee.id!==q);te===`collection:${q}`&&ne("all"),mr(De)},[o,te,mr,b]),gs=m.useCallback((q,he,De)=>{if(!o)return;const Ee=String(he||"").trim();if(!Ee)return;const et=Date.now(),Nn=b.map(bt=>{if(bt.id!==q)return bt;const Yt=new Set(bt.skillKeys||[]);return De?Yt.add(Ee):Yt.delete(Ee),{...bt,skillKeys:Array.from(Yt),updatedAt:et}});mr(Nn)},[o,mr,b]),ys=m.useCallback(async q=>{const he=q==null?void 0:q.packageId,De=q==null?void 0:q.version;if(!he||!De||!window.confirm(n("project:deleteMyNodeConfirm",{id:he,version:De})))return;const Ee=Wn(q);Ue(Ee),Pt(""),L("");try{const et=new URLSearchParams({id:he,version:De}),Nn=await fetch(`/api/marketplace/node?${et.toString()}`,{method:"DELETE"}),bt=await Nn.json().catch(()=>({}));if(!Nn.ok||(bt==null?void 0:bt.ok)===!1){const Yt=Array.isArray(bt==null?void 0:bt.usage)&&bt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:bt.usage.length})}`:"";throw new Error(((bt==null?void 0:bt.error)||"Delete failed")+Yt)}Pt(n("project:deleteMyNodeSuccess",{id:he,version:De})),gt(Yt=>{const Cn={...Yt};return delete Cn[Ee],Cn}),Oe(Yt=>{const Cn={};for(const[yo,at]of Object.entries(Yt))yo.startsWith(`${Ee}:`)||(Cn[yo]=at);return Cn}),ce(""),await qn()}catch(et){Pt(String(et.message||et))}finally{Ue("")}},[qn,n]),dn=m.useCallback(async q=>{const he=q==null?void 0:q.id,De=(q==null?void 0:q.version)||"1.0.0";if(!he||!De||!window.confirm(n("project:deleteMyFlowConfirm",{id:he,version:De})))return;const Ee=Co(q);Wt(Ee),an(""),L("");try{const et=new URLSearchParams({id:he,version:De}),Nn=await fetch(`/api/marketplace/flow-snippet?${et.toString()}`,{method:"DELETE"}),bt=await Nn.json().catch(()=>({}));if(!Nn.ok||(bt==null?void 0:bt.ok)===!1)throw new Error((bt==null?void 0:bt.error)||"Delete failed");an(n("project:deleteMyFlowSuccess",{id:he,version:De})),ce(""),await qn()}catch(et){an(String(et.message||et))}finally{Wt("")}},[qn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),ne("all"),ce(""),me("overview");return}l(q=>q==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const q=new URLSearchParams(window.location.search),he=q.get("tab");let De=!1;if(he==="nodes"){r("/nodes");return}if(he==="my-nodes"){r("/my-nodes");return}if(he==="my-flows"){r("/my-flows");return}if(he==="skills"){r("/skills");return}if(he==="archived"?(l("archived"),q.delete("tab"),De=!0):he&&(l("all"),q.delete("tab"),De=!0),q.get("new")==="1"&&(F(!0),q.delete("new"),De=!0),De){const Ee=q.toString();window.history.replaceState({},"",Ee?`/projects?${Ee}`:"/projects")}},[s,r]);const sr=m.useMemo(()=>HD(C,zD(),c),[C,c,s]),Ir=m.useMemo(()=>sr.filter(q=>zF(V,q)),[sr,V]),pn=V.trim().toLowerCase(),Zn=m.useMemo(()=>a==="archived"?c.filter(q=>q.archived):c.filter(q=>!q.archived),[c,a]),kr=m.useMemo(()=>Zn.filter(q=>FF(q,pn,n)),[Zn,pn,n]),ir=m.useMemo(()=>new Set((Tt.promoted||[]).map(q=>String((q==null?void 0:q.id)||"").trim()).filter(Boolean)),[Tt.promoted]),jt=m.useMemo(()=>(Tt.hiddenBuiltins||[]).map(q=>String(q||"").trim()).filter(Boolean),[Tt.hiddenBuiltins]),Jt=a==="nodes"||a==="my-nodes",Nt=a==="my-nodes",le=a==="my-flows",ve=m.useMemo(()=>d.filter(q=>Nt&&!KF(q,t)?!1:(te==="all"||(te==="marketplace"?q.source==="marketplace":q.type===te))&&Iy(V,[q.id,q.label,q.displayName,q.description,q.type,q.source,q.packageId,q.version])),[t,d,Nt,V,te]),it=m.useMemo(()=>{const q=new Map;for(const he of b)q.set(he.id,new Set(Zo(he,p)));return q},[p,b]),Ft=m.useMemo(()=>[{id:"all",label:"全部"},...b.map(q=>{var he;return{id:`collection:${q.id}`,label:q.name,count:((he=it.get(q.id))==null?void 0:he.size)||0,collection:q}}),{id:"ungrouped",label:"未分组"}],[it,b]),Xt=m.useMemo(()=>p.filter(q=>{var Ee;const he=Wn(q);let De=te==="all";if(te.startsWith("collection:")){const et=te.slice(11);De=!!((Ee=it.get(et))!=null&&Ee.has(he))}else te==="ungrouped"&&(De=!Array.from(it.values()).some(et=>et.has(he)));return De&&Iy(V,[q.name,q.id,q.description,q.sourceLabel,q.source,q.path])}),[p,V,te,it]),nn=m.useMemo(()=>y.filter(q=>Iy(V,[q.id,q.name,q.displayName,q.description,q.version,q.packageDir,Array.isArray(q.tags)?q.tags.join(" "):""])),[y,V]),er=Jt||le||a==="skills",ht=m.useMemo(()=>ve.find(q=>Wn(q)===Z)||ve[0]||null,[ve,Z]),rn=m.useMemo(()=>Xt.find(q=>Wn(q)===Z)||Xt[0]||null,[Xt,Z]),Vt=m.useMemo(()=>nn.find(q=>Co(q)===Z)||nn[0]||null,[nn,Z]),vr=rn?$e[Wn(rn)]:null,tt=ht?ot[Wn(ht)]:null,On=ht&&mt?xe[`${Wn(ht)}:${mt}`]:null,$i=n(Jt?"project:searchNodes":le?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!rn)return;const q=Wn(rn);if($e[q])return;let he=!1;return Be(q),fetch(`/api/skills/detail?key=${encodeURIComponent(q)}`).then(De=>De.json().then(Ee=>({ok:De.ok,json:Ee}))).then(({ok:De,json:Ee})=>{he||De&&Ee.skill&&Ce(et=>({...et,[q]:Ee.skill}))}).catch(()=>{}).finally(()=>{he||Be("")}),()=>{he=!0}},[a,rn,$e]),m.useEffect(()=>{if(!Jt||!ht)return;const q=Wn(ht);if(ot[q])return;let he=!1;return st(q),fetch(`/api/nodes/detail?id=${encodeURIComponent(ht.id)}`).then(De=>De.json().then(Ee=>({ok:De.ok,json:Ee}))).then(({ok:De,json:Ee})=>{he||De&&gt(et=>({...et,[q]:Ee}))}).catch(()=>{}).finally(()=>{he||st("")}),()=>{he=!0}},[Jt,ht,ot]),m.useEffect(()=>{if(!Jt)return;const q=Array.isArray(tt==null?void 0:tt.files)?tt.files:[];Rt(he=>{var De;return he&&q.some(Ee=>Ee.path===he)?he:((De=q[0])==null?void 0:De.path)||""})},[Jt,tt]),m.useEffect(()=>{if(!Jt||!ht||!mt)return;const q=`${Wn(ht)}:${mt}`;if(xe[q])return;let he=!1;return ke(q),fetch(`/api/nodes/file?id=${encodeURIComponent(ht.id)}&path=${encodeURIComponent(mt)}`).then(De=>De.json().then(Ee=>({ok:De.ok,json:Ee}))).then(({ok:De,json:Ee})=>{he||De&&Oe(et=>({...et,[q]:Ee}))}).catch(()=>{}).finally(()=>{he||ke("")}),()=>{he=!0}},[Jt,ht,mt,xe]),m.useEffect(()=>{Pt("")},[Z,a]);const Br=q=>{r(wp(q,"workspace"))},go=q=>{ee(eN(q)),r(wp({id:q.flowId,source:q.flowSource,archived:!!q.archived},"workspace"))},ai=m.useCallback(q=>{var he,De;q.preventDefault(),q.stopPropagation(),(De=(he=q.dataTransfer)==null?void 0:he.types)!=null&&De.includes("Files")&&(Kn.current+=1,Q(!0))},[]),Ms=m.useCallback(q=>{q.preventDefault(),q.stopPropagation(),Kn.current-=1,Kn.current<=0&&(Kn.current=0,Q(!1))},[]),oe=m.useCallback(q=>{q.preventDefault(),q.stopPropagation()},[]),Se=m.useCallback(q=>{var Ee,et;q.preventDefault(),q.stopPropagation(),Kn.current=0,Q(!1);const he=(et=(Ee=q.dataTransfer)==null?void 0:Ee.files)==null?void 0:et[0];if(!he)return;const De=he.name.toLowerCase();!De.endsWith(".yaml")&&!De.endsWith(".yml")&&!De.endsWith(".zip")||W(he)},[]);return i.jsxs("div",{className:"af-projects"+(E?" af-projects--drop-target":""),onDragEnter:ai,onDragLeave:Ms,onDragOver:oe,onDrop:Se,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:[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"+(V.trim()?" af-search--has-clear":""),type:"search",placeholder:$i,"aria-label":$i,autoComplete:"off",value:V,onChange:q=>B(q.target.value),onKeyDown:q=>{q.key==="Escape"&&(B(""),q.currentTarget.blur())}}),V.trim()?i.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>B(""),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),er?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>qn(),children:n("project:refreshResources")}):i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-icon-btn"+(se?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":se,"aria-controls":"af-recent-activity-panel",onClick:()=>ue(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:()=>F(!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:pn?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?ve.length:a==="my-flows"?nn.length:a==="skills"?Xt.length:kr.length}):a==="my-nodes"?n("project:myNodesHint",{count:ve.length}):a==="my-flows"?n("project:myFlowsHint",{count:nn.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:p.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),R?i.jsx("p",{className:"af-err af-projects-api-hint",children:R}):null,A&&er?i.jsx("p",{className:"af-err af-projects-api-hint",children:A}):null]}),er?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(CF,{onChanged:qn,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:le?"schema":Jt?Nt?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(le?"project:myFlowsPurposeTitle":Nt?"project:myNodesPurposeTitle":Jt?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(le?"project:myFlowsPurposeDesc":Nt?"project:myNodesPurposeDesc":Jt?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),le?null:i.jsxs(i.Fragment,{children:[Jt?i.jsxs("div",{className:"af-resource-filter-row",children:[i.jsx("button",{type:"button",className:"af-resource-filter"+(Nt?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ne("all"),ce("")},children:n("project:nodeScopeAll")}),i.jsx("button",{type:"button",className:"af-resource-filter"+(Nt?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),ne("all"),ce("")},children:n("project:nodeScopeMine")})]}):null,i.jsx("div",{className:"af-resource-filter-row",children:(Jt?(Nt?HF:BF).map(q=>({id:q,label:n(`project:resourceFilter.${q}`)})):Ft).map(q=>q.collection?i.jsxs("span",{className:"af-resource-filter-chip"+(te===q.id?" af-resource-filter-chip--active":""),children:[i.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ne(q.id),ce("")},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:j,"aria-label":`删除 ${q.collection.name}`,onClick:()=>Pr(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"+(te===q.id?" af-resource-filter--active":""),onClick:()=>{ne(q.id),ce("")},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:k,onChange:q=>x(q.target.value),onKeyDown:q=>{q.key==="Enter"&&ts()},placeholder:"新建 skill collection"}),i.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!k.trim()||j,onClick:()=>ts(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Jt?i.jsx("div",{className:"af-resource-grid",children:ve.length>0?ve.map(q=>i.jsxs("button",{type:"button",className:"af-resource-card"+(ht&&Wn(q)===Wn(ht)?" af-resource-card--active":""),onClick:()=>ce(Wn(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Pl(q.type==="control"?"secondary":q.type==="provide"?"primary":"muted"),children:i.jsx(Hn,{query:V,children:q.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Hn,{query:V,children:Qj(q.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Hn,{query:V,children:q.label||q.displayName||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{query:V,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Hn,{query:V,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(Hn,{query:V,children:`${q.packageId}${q.version?` / ${q.version}`:""}`})})]}):null]},`${q.id}:${q.source||""}:${q.packageId||""}`)):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:pn?n("project:noNodeMatch",{query:V.trim()}):n(Nt?"project:noMyNodes":"project:noNodes")})}):i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):le?i.jsx("div",{className:"af-resource-grid",children:nn.length>0?nn.map(q=>{const he=IP(q),De=RP(q),Ee=Number.isFinite(Number(q.nodeCount))?Number(q.nodeCount):he.length,et=Number.isFinite(Number(q.edgeCount))?Number(q.edgeCount):De.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Vt&&Co(q)===Co(Vt)?" af-resource-card--active":""),onClick:()=>ce(Co(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Pl("primary"),children:i.jsx(Hn,{query:V,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(Hn,{query:V,children:q.displayName||q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{query:V,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ee,edges:et})}),i.jsx("span",{children:i.jsx(Hn,{query:V,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(Hn,{query:V,children:Zj(q)})})]})]},Co(q))}):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:pn?n("project:noFlowSnippetMatch",{query:V.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:Xt.length>0?Xt.map(q=>{const he=Wn(q),De=b.filter(Ee=>{var et;return(et=it.get(Ee.id))==null?void 0:et.has(he)});return i.jsxs("button",{type:"button",className:"af-resource-card"+(rn&&he===Wn(rn)?" af-resource-card--active":""),onClick:()=>ce(he),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Pl(q.source==="builtin"?"muted":"primary"),children:i.jsx(Hn,{query:V,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(Hn,{query:V,children:q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{query:V,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(Hn,{query:V,children:q.path||q.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[De.slice(0,3).map(Ee=>i.jsx("span",{children:Ee.name},Ee.id)),De.length===0?i.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},q.key||`${q.source}:${q.name}`)}):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:pn?n("project:noSkillMatch",{query:V.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"&&jt.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:jt.map(q=>{const he=Je===`show-builtin:builtin:${q}`;return i.jsxs("button",{type:"button",disabled:he,onClick:()=>Qn({id:q,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:q}),i.jsx("em",{children:he?"恢复中":"恢复"})]},q)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[kr.length>0?kr.map(q=>{var Nn,bt;const he=(t==null?void 0:t.isAdmin)&&q.source==="user"&&!q.archived&&!ir.has(q.id),De=(t==null?void 0:t.isAdmin)&&q.source==="admin",Ee=(t==null?void 0:t.isAdmin)&&q.source==="builtin",et=Je.endsWith(`:${q.source}:${q.id}`);return i.jsx("div",{className:MF(q.source),role:"button",tabIndex:0,onClick:()=>Br(q),onKeyDown:Yt=>{(Yt.key==="Enter"||Yt.key===" ")&&(Yt.preventDefault(),Br(q))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:Pl(jx(q.source,n).tone),children:i.jsx(Hn,{query:V,children:jx(q.source,n).label})}),q.source==="workspace"&&((Nn=q.collaboration)!=null&&Nn.role)?i.jsx("span",{className:Pl(q.collaboration.role==="owner"?"primary":"muted"),children:q.collaboration.role==="owner"?"我创建的":`${q.collaboration.ownerUsername||q.collaboration.ownerId} 分享`}):null,q.archived?i.jsx("span",{className:Pl("muted"),children:i.jsx(Hn,{query:V,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Hn,{query:V,children:q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{query:V,children:AP(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(Hn,{query:V,children:EP(q)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:Yt=>Yt.stopPropagation(),onKeyDown:Yt=>Yt.stopPropagation(),children:[he?i.jsx("button",{type:"button",disabled:et,onClick:()=>Qn(q,"promote"),children:"设为内置"}):null,De?i.jsx("button",{type:"button",disabled:et,onClick:()=>Qn(q,"unpromote"),children:"取消内置"}):null,Ee?i.jsx("button",{type:"button",disabled:et,onClick:()=>Qn(q,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${q.id}:${q.source??"user"}:${q.archived?"a":""}:${((bt=q.collaboration)==null?void 0:bt.id)||"own"}`)}):D?Zn.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(R?"project:loadFailed":"project:noPipelines")}),!R&&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:V.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:()=>F(!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")})]}),re?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")})]})]})]})]}),er?i.jsx("aside",{className:"af-resource-detail","aria-label":n(Jt?"project:nodeDetail":le?"project:flowDetail":"project:skillDetail"),children:Jt&&ht?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:ht.label||ht.displayName||ht.id}),i.jsx("p",{children:ht.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"+(de===q?" af-resource-detail-tab--active":""),onClick:()=>me(q),children:n(`project:nodeDetailTabs.${q}`)},q))}),Te===Wn(ht)?i.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):de==="overview"?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"af-resource-detail-desc",children:ht.description||((Pe=tt==null?void 0:tt.node)==null?void 0:Pe.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:ht.type||((wt=tt==null?void 0:tt.node)==null?void 0:wt.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:Qj(ht.source,n)})]}),ht.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:ht.packageId})]}):null,ht.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:ht.version})]}):null,ht.packageDir||tt!=null&&tt.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:ht.packageDir||(tt==null?void 0:tt.baseDir)})]}):null,i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailEditable")}),i.jsx("dd",{children:(tt==null?void 0:tt.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),Nt&&ht.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:Ke===Wn(ht),onClick:()=>ys(ht),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ke===Wn(ht)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),be?i.jsx("p",{className:"af-resource-action-message",children:be}):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")})]})]}):de==="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")}),xp(((Ot=tt==null?void 0:tt.node)==null?void 0:Ot.inputs)||ht.inputs).length>0?xp(((Ut=tt==null?void 0:tt.node)==null?void 0:Ut.inputs)||ht.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")}),xp(((Bn=tt==null?void 0:tt.node)==null?void 0:Bn.outputs)||ht.outputs).length>0?xp(((Dn=tt==null?void 0:tt.node)==null?void 0:Dn.outputs)||ht.outputs).map(q=>i.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):i.jsx("em",{children:n("project:noSlots")})]})]}):de==="runtime"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeRuntime")}),tt!=null&&tt.runtime?i.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(tt.runtime,null,2)}):i.jsx("p",{children:n("project:noRuntimeManifest")}),tt!=null&&tt.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:tt.body})]}):i.jsx("p",{children:n("project:noNodeBody")})]}):de==="files"?i.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[i.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(tt==null?void 0:tt.files)&&tt.files.length>0?i.jsxs("div",{className:"af-node-file-browser",children:[i.jsx("div",{className:"af-node-file-list",children:tt.files.map(q=>i.jsxs("button",{type:"button",className:"af-node-file-item"+(mt===q.path?" af-node-file-item--active":""),onClick:()=>Rt(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:[ie===`${Wn(ht)}:${mt}`?n("project:loadingResources"):On!=null&&On.binary?n("project:binaryFile"):(On==null?void 0:On.content)||n("project:selectNodeFile"),On!=null&&On.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(tt==null?void 0:tt.usage)&&tt.usage.length>0?i.jsx("div",{className:"af-node-usage-list",children:tt.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(he=>he.label||he.instanceId).join(", ")})]},`${q.flowSource}:${q.flowId}:${q.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):le&&Vt?(()=>{const q=JF(Vt);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:Vt.displayName||Vt.name||Vt.id}),i.jsx("p",{children:Vt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Vt.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:Vt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:Zj(Vt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Vt.nodeCount))?Number(Vt.nodeCount):q.nodes.length,edges:Number.isFinite(Number(Vt.edgeCount))?Number(Vt.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:tn===Co(Vt),onClick:()=>dn(Vt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),tn===Co(Vt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),Lt?i.jsx("p",{className:"af-resource-action-message",children:Lt}):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(he=>i.jsxs("g",{children:[i.jsx("path",{d:he.path}),he.label?i.jsx("text",{x:he.labelX,y:he.labelY-5,textAnchor:"middle",children:Ry(he.label,18)}):null]},he.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:q.diagram.nodes.map((he,De)=>i.jsxs("g",{transform:`translate(${he.x} ${he.y})`,children:[i.jsx("rect",{width:he.width,height:he.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:he.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:he.height/2+4,textAnchor:"middle",children:De+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:he.height/2-3,children:Ry(he.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:he.height/2+16,children:Ry(he.meta||he.id,20)})]},he.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(Vt.snippet||{},null,2)})]})]})]})})():a==="skills"&&rn?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:rn.name||rn.id}),i.jsx("p",{children:rn.sourceLabel||rn.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:rn.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:rn.sourceLabel||rn.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:rn.path||rn.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),b.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:b.map(q=>{const he=Wn(rn),De=it.get(q.id)||new Set,Ee=De.has(he);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:Ee,disabled:j||!o,onChange:et=>gs(q.id,he,et.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:[De.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:_e===Wn(rn)?n("project:loadingResources"):(vr==null?void 0:vr.body)||(vr==null?void 0:vr.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"+(se?"":" af-activity--hidden"),"aria-hidden":!se,"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:Ir.length===0?i.jsx("p",{className:"af-activity-empty",children:sr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Ir.map(q=>{const he=G===eN(q);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(he?" af-activity-row--active":""),"aria-current":he?"page":void 0,onClick:()=>go(q),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Hn,{query:V,children:q.flowId})}),i.jsx("span",{className:"af-activity-time",children:Jj(q.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:$F(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")," · ",Jj(q.at,n)]})]})]},`${q.kind}-${q.flowId}-${q.flowSource}-${q.at}`)})})]})]}),i.jsx(yF,{open:z,onClose:()=>F(!1),onCreated:async q=>{F(!1),await xn();const he=q.source??"user";r(wp({id:q.id,source:he},"workspace"))}}),$?i.jsx(mF,{file:$,onClose:()=>W(null),onImported:async q=>{W(null),await xn();const he=q.source??"user";r(wp({id:q.id,source:he},"workspace"))}},`${$.name}-${$.size}-${$.lastModified}`):null]})}function Xn(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=Xn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var XF={value:()=>{}};function Vm(){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 ah(n)}function ah(e){this._=e}function QF(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}})}ah.prototype=Vm.prototype={constructor:ah,on:function(e,t){var n=this._,r=QF(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=ZF(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]=rN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=rN(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 ah(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 ZF(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function rN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=XF,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var _x="http://www.w3.org/1999/xhtml";const sN={svg:"http://www.w3.org/2000/svg",xhtml:_x,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Km(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),sN.hasOwnProperty(t)?{space:sN[t],local:e}:e}function ez(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===_x&&t.documentElement.namespaceURI===_x?t.createElement(e):t.createElementNS(n,e)}}function tz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function TP(e){var t=Km(e);return(t.local?tz:ez)(t)}function nz(){}function Sk(e){return e==null?nz:function(){return this.querySelector(e)}}function rz(e){typeof e!="function"&&(e=Sk(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 ps(r,this._parents)}function sz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function iz(){return[]}function MP(e){return e==null?iz:function(){return this.querySelectorAll(e)}}function oz(e){return function(){return sz(e.apply(this,arguments))}}function az(e){typeof e=="function"?e=oz(e):e=MP(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 ps(r,s)}function $P(e){return function(){return this.matches(e)}}function LP(e){return function(t){return t.matches(e)}}var lz=Array.prototype.find;function cz(e){return function(){return lz.call(this.children,e)}}function uz(){return this.firstElementChild}function dz(e){return this.select(e==null?uz:cz(typeof e=="function"?e:LP(e)))}var fz=Array.prototype.filter;function pz(){return Array.from(this.children)}function hz(e){return function(){return fz.call(this.children,e)}}function mz(e){return this.selectAll(e==null?pz:hz(typeof e=="function"?e:LP(e)))}function gz(e){typeof e!="function"&&(e=$P(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 ps(r,this._parents)}function OP(e){return new Array(e.length)}function yz(){return new ps(this._enter||this._groups.map(OP),this._parents)}function Kh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kh.prototype={constructor:Kh,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 wz(e){return function(){return e}}function xz(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 Kh(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function bz(e,t,n,r,s,o,a){var l,c,u=new Map,d=t.length,f=o.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,o[l],l,o)+"",(c=u.get(h))?(r[l]=c,c.__data__=o[l],u.delete(h)):n[l]=new Kh(e,o[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function kz(e){return e.__data__}function vz(e,t){if(!arguments.length)return Array.from(this,kz);var n=t?bz:xz,r=this._parents,s=this._groups;typeof e!="function"&&(e=wz(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,h=Sz(e.call(d,d&&d.__data__,u,r)),y=h.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,h,t);for(var k=0,x=0,j,N;k<y;++k)if(j=v[k]){for(k>=x&&(x=k+1);!(N=b[x])&&++x<y;);j._next=N||null}}return a=new ps(a,r),a._enter=l,a._exit=c,a}function Sz(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function jz(){return new ps(this._exit||this._groups.map(OP),this._parents)}function Nz(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 Cz(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),h,y=0;y<f;++y)(h=u[y]||d[y])&&(p[y]=h);for(;c<s;++c)l[c]=n[c];return new ps(l,this._parents)}function _z(){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 Ez(e){e||(e=Az);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 ps(s,this._parents).order()}function Az(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pz(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Iz(){return Array.from(this)}function Rz(){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 Tz(){let e=0;for(const t of this)++e;return e}function Mz(){return!this.node()}function $z(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 Lz(e){return function(){this.removeAttribute(e)}}function Oz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Dz(e,t){return function(){this.setAttribute(e,t)}}function Fz(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function zz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Bz(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 Hz(e,t){var n=Km(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?Oz:Lz:typeof t=="function"?n.local?Bz:zz:n.local?Fz:Dz)(n,t))}function DP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Wz(e){return function(){this.style.removeProperty(e)}}function Vz(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Kz(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function qz(e,t,n){return arguments.length>1?this.each((t==null?Wz:typeof t=="function"?Kz:Vz)(e,t,n??"")):Nc(this.node(),e)}function Nc(e,t){return e.style.getPropertyValue(t)||DP(e).getComputedStyle(e,null).getPropertyValue(t)}function Uz(e){return function(){delete this[e]}}function Yz(e,t){return function(){this[e]=t}}function Gz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Jz(e,t){return arguments.length>1?this.each((t==null?Uz:typeof t=="function"?Gz:Yz)(e,t)):this.node()[e]}function FP(e){return e.trim().split(/^|\s+/)}function jk(e){return e.classList||new zP(e)}function zP(e){this._node=e,this._names=FP(e.getAttribute("class")||"")}zP.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 BP(e,t){for(var n=jk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function HP(e,t){for(var n=jk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Xz(e){return function(){BP(this,e)}}function Qz(e){return function(){HP(this,e)}}function Zz(e,t){return function(){(t.apply(this,arguments)?BP:HP)(this,e)}}function e3(e,t){var n=FP(e+"");if(arguments.length<2){for(var r=jk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?Zz:t?Xz:Qz)(n,t))}function t3(){this.textContent=""}function n3(e){return function(){this.textContent=e}}function r3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function s3(e){return arguments.length?this.each(e==null?t3:(typeof e=="function"?r3:n3)(e)):this.node().textContent}function i3(){this.innerHTML=""}function o3(e){return function(){this.innerHTML=e}}function a3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function l3(e){return arguments.length?this.each(e==null?i3:(typeof e=="function"?a3:o3)(e)):this.node().innerHTML}function c3(){this.nextSibling&&this.parentNode.appendChild(this)}function u3(){return this.each(c3)}function d3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function f3(){return this.each(d3)}function p3(e){var t=typeof e=="function"?e:TP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function h3(){return null}function m3(e,t){var n=typeof e=="function"?e:TP(e),r=t==null?h3:typeof t=="function"?t:Sk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function g3(){var e=this.parentNode;e&&e.removeChild(this)}function y3(){return this.each(g3)}function w3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function x3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function b3(e){return this.select(e?x3:w3)}function k3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function v3(e){return function(t){e.call(this,t,this.__data__)}}function S3(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 j3(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 N3(e,t,n){return function(){var r=this.__on,s,o=v3(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 C3(e,t,n){var r=S3(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?N3:j3,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function WP(e,t,n){var r=DP(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 _3(e,t){return function(){return WP(this,e,t)}}function E3(e,t){return function(){return WP(this,e,t.apply(this,arguments))}}function A3(e,t){return this.each((typeof t=="function"?E3:_3)(e,t))}function*P3(){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 VP=[null];function ps(e,t){this._groups=e,this._parents=t}function cf(){return new ps([[document.documentElement]],VP)}function I3(){return this}ps.prototype=cf.prototype={constructor:ps,select:rz,selectAll:az,selectChild:dz,selectChildren:mz,filter:gz,data:vz,enter:yz,exit:jz,join:Nz,merge:Cz,selection:I3,order:_z,sort:Ez,call:Pz,nodes:Iz,node:Rz,size:Tz,empty:Mz,each:$z,attr:Hz,style:qz,property:Jz,classed:e3,text:s3,html:l3,raise:u3,lower:f3,append:p3,insert:m3,remove:y3,clone:b3,datum:k3,on:C3,dispatch:A3,[Symbol.iterator]:P3};function as(e){return typeof e=="string"?new ps([[document.querySelector(e)]],[document.documentElement]):new ps([[e]],VP)}function R3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Us(e,t){if(e=R3(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 T3={passive:!1},Td={capture:!0,passive:!1};function Ty(e){e.stopImmediatePropagation()}function uc(e){e.preventDefault(),e.stopImmediatePropagation()}function KP(e){var t=e.document.documentElement,n=as(e).on("dragstart.drag",uc,Td);"onselectstart"in t?n.on("selectstart.drag",uc,Td):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function qP(e,t){var n=e.document.documentElement,r=as(e).on("dragstart.drag",null);t&&(r.on("click.drag",uc,Td),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 bp=e=>()=>e;function Ex(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}})}Ex.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function M3(e){return!e.ctrlKey&&!e.button}function $3(){return this.parentNode}function L3(e,t){return t??{x:e.x,y:e.y}}function O3(){return navigator.maxTouchPoints||"ontouchstart"in this}function UP(){var e=M3,t=$3,n=L3,r=O3,s={},o=Vm("start","drag","end"),a=0,l,c,u,d,f=0;function p(j){j.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,T3).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(j,N){if(!(d||!e.call(this,j,N))){var C=x(this,t.call(this,j,N),j,N,"mouse");C&&(as(j.view).on("mousemove.drag",y,Td).on("mouseup.drag",v,Td),KP(j.view),Ty(j),u=!1,l=j.clientX,c=j.clientY,C("start",j))}}function y(j){if(uc(j),!u){var N=j.clientX-l,C=j.clientY-c;u=N*N+C*C>f}s.mouse("drag",j)}function v(j){as(j.view).on("mousemove.drag mouseup.drag",null),qP(j.view,u),uc(j),s.mouse("end",j)}function b(j,N){if(e.call(this,j,N)){var C=j.changedTouches,I=t.call(this,j,N),R=C.length,H,A;for(H=0;H<R;++H)(A=x(this,I,j,N,C[H].identifier,C[H]))&&(Ty(j),A("start",j,C[H]))}}function g(j){var N=j.changedTouches,C=N.length,I,R;for(I=0;I<C;++I)(R=s[N[I].identifier])&&(uc(j),R("drag",j,N[I]))}function k(j){var N=j.changedTouches,C=N.length,I,R;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),I=0;I<C;++I)(R=s[N[I].identifier])&&(Ty(j),R("end",j,N[I]))}function x(j,N,C,I,R,H){var A=o.copy(),L=Us(H||C,N),D,O,M;if((M=n.call(j,new Ex("beforestart",{sourceEvent:C,target:p,identifier:R,active:a,x:L[0],y:L[1],dx:0,dy:0,dispatch:A}),I))!=null)return D=M.x-L[0]||0,O=M.y-L[1]||0,function K(z,F,$){var W=L,E;switch(z){case"start":s[R]=K,E=a++;break;case"end":delete s[R],--a;case"drag":L=Us($||F,N),E=a;break}A.call(z,j,new Ex(z,{sourceEvent:F,subject:M,target:p,identifier:R,active:E,x:L[0]+D,y:L[1]+O,dx:L[0]-W[0],dy:L[1]-W[1],dispatch:A}),I)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:bp(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:bp(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:bp(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:bp(!!j),p):r},p.on=function(){var j=o.on.apply(o,arguments);return j===o?p:j},p.clickDistance=function(j){return arguments.length?(f=(j=+j)*j,p):Math.sqrt(f)},p}function Nk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function YP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function uf(){}var Md=.7,qh=1/Md,dc="\\s*([+-]?\\d+)\\s*",$d="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ci="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",D3=/^#([0-9a-f]{3,8})$/,F3=new RegExp(`^rgb\\(${dc},${dc},${dc}\\)$`),z3=new RegExp(`^rgb\\(${Ci},${Ci},${Ci}\\)$`),B3=new RegExp(`^rgba\\(${dc},${dc},${dc},${$d}\\)$`),H3=new RegExp(`^rgba\\(${Ci},${Ci},${Ci},${$d}\\)$`),W3=new RegExp(`^hsl\\(${$d},${Ci},${Ci}\\)$`),V3=new RegExp(`^hsla\\(${$d},${Ci},${Ci},${$d}\\)$`),iN={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};Nk(uf,Ya,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:oN,formatHex:oN,formatHex8:K3,formatHsl:q3,formatRgb:aN,toString:aN});function oN(){return this.rgb().formatHex()}function K3(){return this.rgb().formatHex8()}function q3(){return GP(this).formatHsl()}function aN(){return this.rgb().formatRgb()}function Ya(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=D3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?lN(t):n===3?new Yr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kp(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=F3.exec(e))?new Yr(t[1],t[2],t[3],1):(t=z3.exec(e))?new Yr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=B3.exec(e))?kp(t[1],t[2],t[3],t[4]):(t=H3.exec(e))?kp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=W3.exec(e))?dN(t[1],t[2]/100,t[3]/100,1):(t=V3.exec(e))?dN(t[1],t[2]/100,t[3]/100,t[4]):iN.hasOwnProperty(e)?lN(iN[e]):e==="transparent"?new Yr(NaN,NaN,NaN,0):null}function lN(e){return new Yr(e>>16&255,e>>8&255,e&255,1)}function kp(e,t,n,r){return r<=0&&(e=t=n=NaN),new Yr(e,t,n,r)}function U3(e){return e instanceof uf||(e=Ya(e)),e?(e=e.rgb(),new Yr(e.r,e.g,e.b,e.opacity)):new Yr}function Ax(e,t,n,r){return arguments.length===1?U3(e):new Yr(e,t,n,r??1)}function Yr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Nk(Yr,Ax,YP(uf,{brighter(e){return e=e==null?qh:Math.pow(qh,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Md:Math.pow(Md,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Yr(Fa(this.r),Fa(this.g),Fa(this.b),Uh(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:Y3,formatRgb:uN,toString:uN}));function cN(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}`}function Y3(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}${Ta((isNaN(this.opacity)?1:this.opacity)*255)}`}function uN(){const e=Uh(this.opacity);return`${e===1?"rgb(":"rgba("}${Fa(this.r)}, ${Fa(this.g)}, ${Fa(this.b)}${e===1?")":`, ${e})`}`}function Uh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ta(e){return e=Fa(e),(e<16?"0":"")+e.toString(16)}function dN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Js(e,t,n,r)}function GP(e){if(e instanceof Js)return new Js(e.h,e.s,e.l,e.opacity);if(e instanceof uf||(e=Ya(e)),!e)return new Js;if(e instanceof Js)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 Js(a,l,c,e.opacity)}function G3(e,t,n,r){return arguments.length===1?GP(e):new Js(e,t,n,r??1)}function Js(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Nk(Js,G3,YP(uf,{brighter(e){return e=e==null?qh:Math.pow(qh,e),new Js(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Md:Math.pow(Md,e),new Js(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 Yr(My(e>=240?e-240:e+120,s,r),My(e,s,r),My(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Js(fN(this.h),vp(this.s),vp(this.l),Uh(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=Uh(this.opacity);return`${e===1?"hsl(":"hsla("}${fN(this.h)}, ${vp(this.s)*100}%, ${vp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fN(e){return e=(e||0)%360,e<0?e+360:e}function vp(e){return Math.max(0,Math.min(1,e||0))}function My(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 Ck=e=>()=>e;function J3(e,t){return function(n){return e+n*t}}function X3(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 Q3(e){return(e=+e)==1?JP:function(t,n){return n-t?X3(t,n,e):Ck(isNaN(t)?n:t)}}function JP(e,t){var n=t-e;return n?J3(e,n):Ck(isNaN(e)?t:e)}const Yh=function e(t){var n=Q3(t);function r(s,o){var a=n((s=Ax(s)).r,(o=Ax(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=JP(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 Z3(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 eB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function tB(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]=od(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 nB(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function gi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function rB(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]=od(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Px=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$y=new RegExp(Px.source,"g");function sB(e){return function(){return e}}function iB(e){return function(t){return e(t)+""}}function XP(e,t){var n=Px.lastIndex=$y.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Px.exec(e))&&(s=$y.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:gi(r,s)})),n=$y.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?iB(c[0].x):sB(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 od(e,t){var n=typeof t,r;return t==null||n==="boolean"?Ck(t):(n==="number"?gi:n==="string"?(r=Ya(t))?(t=r,Yh):XP:t instanceof Ya?Yh:t instanceof Date?nB:eB(t)?Z3:Array.isArray(t)?tB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?rB:gi)(e,t)}var pN=180/Math.PI,Ix={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function QP(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)*pN,skewX:Math.atan(c)*pN,scaleX:a,scaleY:l}}var Sp;function oB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ix:QP(t.a,t.b,t.c,t.d,t.e,t.f)}function aB(e){return e==null||(Sp||(Sp=document.createElementNS("http://www.w3.org/2000/svg","g")),Sp.setAttribute("transform",e),!(e=Sp.transform.baseVal.consolidate()))?Ix:(e=e.matrix,QP(e.a,e.b,e.c,e.d,e.e,e.f))}function ZP(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function o(u,d,f,p,h,y){if(u!==f||d!==p){var v=h.push("translate(",null,t,null,n);y.push({i:v-4,x:gi(u,f)},{i:v-2,x:gi(d,p)})}else(f||p)&&h.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:gi(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:gi(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,y){if(u!==f||d!==p){var v=h.push(s(h)+"scale(",null,",",null,")");y.push({i:v-4,x:gi(u,f)},{i:v-2,x:gi(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"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(h){for(var y=-1,v=p.length,b;++y<v;)f[(b=p[y]).i]=b.x(h);return f.join("")}}}var lB=ZP(oB,"px, ","px)","deg)"),cB=ZP(aB,", ",")",")"),uB=1e-12;function hN(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 lh=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],h=d-l,y=f-c,v=h*h+y*y,b,g;if(v<uB)g=Math.log(p/u)/t,b=function(I){return[l+I*h,c+I*y,u*Math.exp(t*I*g)]};else{var k=Math.sqrt(v),x=(p*p-u*u+r*v)/(2*u*n*k),j=(p*p-u*u-r*v)/(2*p*n*k),N=Math.log(Math.sqrt(x*x+1)-x),C=Math.log(Math.sqrt(j*j+1)-j);g=(C-N)/t,b=function(I){var R=I*g,H=hN(N),A=u/(n*k)*(H*fB(t*R+N)-dB(N));return[l+A*h,c+A*y,u*H/hN(t*R+N)]}}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 Cc=0,Hu=0,_u=0,eI=1e3,Gh,Wu,Jh=0,Ga=0,qm=0,Ld=typeof performance=="object"&&performance.now?performance:Date,tI=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _k(){return Ga||(tI(pB),Ga=Ld.now()+qm)}function pB(){Ga=0}function Xh(){this._call=this._time=this._next=null}Xh.prototype=nI.prototype={constructor:Xh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_k():+n)+(t==null?0:+t),!this._next&&Wu!==this&&(Wu?Wu._next=this:Gh=this,Wu=this),this._call=e,this._time=n,Rx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rx())}};function nI(e,t,n){var r=new Xh;return r.restart(e,t,n),r}function hB(){_k(),++Cc;for(var e=Gh,t;e;)(t=Ga-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Cc}function mN(){Ga=(Jh=Ld.now())+qm,Cc=Hu=0;try{hB()}finally{Cc=0,gB(),Ga=0}}function mB(){var e=Ld.now(),t=e-Jh;t>eI&&(qm-=t,Jh=e)}function gB(){for(var e,t=Gh,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:Gh=n);Wu=e,Rx(r)}function Rx(e){if(!Cc){Hu&&(Hu=clearTimeout(Hu));var t=e-Ga;t>24?(e<1/0&&(Hu=setTimeout(mN,e-Ld.now()-qm)),_u&&(_u=clearInterval(_u))):(_u||(Jh=Ld.now(),_u=setInterval(mB,eI)),Cc=1,tI(mN))}}function gN(e,t,n){var r=new Xh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var yB=Vm("start","end","cancel","interrupt"),wB=[],rI=0,yN=1,Tx=2,ch=3,wN=4,Mx=5,uh=6;function Um(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;xB(e,n,{name:t,index:r,group:s,on:yB,tween:wB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:rI})}function Ek(e,t){var n=ii(e,t);if(n.state>rI)throw new Error("too late; already scheduled");return n}function Ti(e,t){var n=ii(e,t);if(n.state>ch)throw new Error("too late; already running");return n}function ii(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function xB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=nI(o,0,n.time);function o(u){n.state=yN,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,h;if(n.state!==yN)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===ch)return gN(a);h.state===wN?(h.state=uh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=uh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(gN(function(){n.state===ch&&(n.state=wN,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Tx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tx){for(n.state=ch,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);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=Mx,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Mx&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=uh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function dh(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>Tx&&r.state<Mx,r.state=uh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function bB(e){return this.each(function(){dh(this,e)})}function kB(e,t){var n,r;return function(){var s=Ti(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 vB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Ti(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 SB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ii(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?kB:vB)(n,e,t))}function Ak(e,t,n){var r=e._id;return e.each(function(){var s=Ti(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ii(s,r).value[t]}}function sI(e,t){var n;return(typeof t=="number"?gi:t instanceof Ya?Yh:(n=Ya(t))?(t=n,Yh):XP)(e,t)}function jB(e){return function(){this.removeAttribute(e)}}function NB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function CB(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 _B(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 EB(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 AB(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 PB(e,t){var n=Km(e),r=n==="transform"?cB:sI;return this.attrTween(e,typeof t=="function"?(n.local?AB:EB)(n,r,Ak(this,"attr."+e,t)):t==null?(n.local?NB:jB)(n):(n.local?_B:CB)(n,r,t))}function IB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function RB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function TB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&RB(e,o)),n}return s._value=t,s}function MB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&IB(e,o)),n}return s._value=t,s}function $B(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=Km(e);return this.tween(n,(r.local?TB:MB)(r,t))}function LB(e,t){return function(){Ek(this,e).delay=+t.apply(this,arguments)}}function OB(e,t){return t=+t,function(){Ek(this,e).delay=t}}function DB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?LB:OB)(t,e)):ii(this.node(),t).delay}function FB(e,t){return function(){Ti(this,e).duration=+t.apply(this,arguments)}}function zB(e,t){return t=+t,function(){Ti(this,e).duration=t}}function BB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?FB:zB)(t,e)):ii(this.node(),t).duration}function HB(e,t){if(typeof t!="function")throw new Error;return function(){Ti(this,e).ease=t}}function WB(e){var t=this._id;return arguments.length?this.each(HB(t,e)):ii(this.node(),t).ease}function VB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ti(this,e).ease=n}}function KB(e){if(typeof e!="function")throw new Error;return this.each(VB(this._id,e))}function qB(e){typeof e!="function"&&(e=$P(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 ao(r,this._parents,this._name,this._id)}function UB(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,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<r;++l)a[l]=t[l];return new ao(a,this._parents,this._name,this._id)}function YB(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 GB(e,t,n){var r,s,o=YB(t)?Ek:Ti;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function JB(e,t){var n=this._id;return arguments.length<2?ii(this.node(),n).on.on(e):this.each(GB(n,e,t))}function XB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function QB(){return this.on("end.remove",XB(this._id))}function ZB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Sk(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,Um(u[p],t,n,p,u,ii(d,n)));return new ao(o,this._parents,t,n)}function eH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=MP(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),h,y=ii(d,n),v=0,b=p.length;v<b;++v)(h=p[v])&&Um(h,t,n,v,p,y);o.push(p),a.push(d)}return new ao(o,a,t,n)}var tH=cf.prototype.constructor;function nH(){return new tH(this._groups,this._parents)}function rH(e,t){var n,r,s;return function(){var o=Nc(this,e),a=(this.style.removeProperty(e),Nc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function iI(e){return function(){this.style.removeProperty(e)}}function sH(e,t,n){var r,s=n+"",o;return function(){var a=Nc(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function iH(e,t,n){var r,s,o;return function(){var a=Nc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Nc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function oH(e,t){var n,r,s,o="style."+t,a="end."+o,l;return function(){var c=Ti(this,e),u=c.on,d=c.value[o]==null?l||(l=iI(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(a,s=d),c.on=r}}function aH(e,t,n){var r=(e+="")=="transform"?lB:sI;return t==null?this.styleTween(e,rH(e,r)).on("end.style."+e,iI(e)):typeof t=="function"?this.styleTween(e,iH(e,r,Ak(this,"style."+e,t))).each(oH(this._id,e)):this.styleTween(e,sH(e,r,t),n).on("end.style."+e,null)}function lH(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function cH(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&lH(e,a,n)),r}return o._value=t,o}function uH(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,cH(e,t,n??""))}function dH(e){return function(){this.textContent=e}}function fH(e){return function(){var t=e(this);this.textContent=t??""}}function pH(e){return this.tween("text",typeof e=="function"?fH(Ak(this,"text",e)):dH(e==null?"":e+""))}function hH(e){return function(t){this.textContent=e.call(this,t)}}function mH(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&hH(s)),t}return r._value=e,r}function gH(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,mH(e))}function yH(){for(var e=this._name,t=this._id,n=oI(),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=ii(c,t);Um(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ao(r,this._parents,e,n)}function wH(){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=Ti(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 xH=0;function ao(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function oI(){return++xH}var Hi=cf.prototype;ao.prototype={constructor:ao,select:ZB,selectAll:eH,selectChild:Hi.selectChild,selectChildren:Hi.selectChildren,filter:qB,merge:UB,selection:nH,transition:yH,call:Hi.call,nodes:Hi.nodes,node:Hi.node,size:Hi.size,empty:Hi.empty,each:Hi.each,on:JB,attr:PB,attrTween:$B,style:aH,styleTween:uH,text:pH,textTween:gH,remove:QB,tween:SB,delay:DB,duration:BB,ease:WB,easeVarying:KB,end:wH,[Symbol.iterator]:Hi[Symbol.iterator]};function bH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var kH={time:null,delay:0,duration:250,ease:bH};function vH(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 SH(e){var t,n;e instanceof ao?(t=e._id,e=e._name):(t=oI(),(n=kH).time=_k(),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])&&Um(c,e,t,u,a,n||vH(c,t));return new ao(r,this._parents,e,t)}cf.prototype.interrupt=bB;cf.prototype.transition=SH;const jp=e=>()=>e;function jH(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 Ji(e,t,n){this.k=e,this.x=t,this.y=n}Ji.prototype={constructor:Ji,scale:function(e){return e===1?this:new Ji(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ji(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 Ym=new Ji(1,0,0);aI.prototype=Ji.prototype;function aI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ym;return e.__zoom}function Ly(e){e.stopImmediatePropagation()}function Eu(e){e.preventDefault(),e.stopImmediatePropagation()}function NH(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function CH(){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 xN(){return this.__zoom||Ym}function _H(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function EH(){return navigator.maxTouchPoints||"ontouchstart"in this}function AH(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 lI(){var e=NH,t=CH,n=AH,r=_H,s=EH,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=lh,u=Vm("start","zoom","end"),d,f,p,h=500,y=150,v=0,b=10;function g(M){M.property("__zoom",xN).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",H).on("dblclick.zoom",A).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(M,K,z,F){var $=M.selection?M.selection():M;$.property("__zoom",xN),M!==$?N(M,K,z,F):$.interrupt().each(function(){C(this,arguments).event(F).start().zoom(null,typeof K=="function"?K.apply(this,arguments):K).end()})},g.scaleBy=function(M,K,z,F){g.scaleTo(M,function(){var $=this.__zoom.k,W=typeof K=="function"?K.apply(this,arguments):K;return $*W},z,F)},g.scaleTo=function(M,K,z,F){g.transform(M,function(){var $=t.apply(this,arguments),W=this.__zoom,E=z==null?j($):typeof z=="function"?z.apply(this,arguments):z,Q=W.invert(E),V=typeof K=="function"?K.apply(this,arguments):K;return n(x(k(W,V),E,Q),$,a)},z,F)},g.translateBy=function(M,K,z,F){g.transform(M,function(){return n(this.__zoom.translate(typeof K=="function"?K.apply(this,arguments):K,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),a)},null,F)},g.translateTo=function(M,K,z,F,$){g.transform(M,function(){var W=t.apply(this,arguments),E=this.__zoom,Q=F==null?j(W):typeof F=="function"?F.apply(this,arguments):F;return n(Ym.translate(Q[0],Q[1]).scale(E.k).translate(typeof K=="function"?-K.apply(this,arguments):-K,typeof z=="function"?-z.apply(this,arguments):-z),W,a)},F,$)};function k(M,K){return K=Math.max(o[0],Math.min(o[1],K)),K===M.k?M:new Ji(K,M.x,M.y)}function x(M,K,z){var F=K[0]-z[0]*M.k,$=K[1]-z[1]*M.k;return F===M.x&&$===M.y?M:new Ji(M.k,F,$)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function N(M,K,z,F){M.on("start.zoom",function(){C(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(F).end()}).tween("zoom",function(){var $=this,W=arguments,E=C($,W).event(F),Q=t.apply($,W),V=z==null?j(Q):typeof z=="function"?z.apply($,W):z,B=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),se=$.__zoom,ue=typeof K=="function"?K.apply($,W):K,G=c(se.invert(V).concat(B/se.k),ue.invert(V).concat(B/ue.k));return function(ee){if(ee===1)ee=ue;else{var te=G(ee),ne=B/te[2];ee=new Ji(ne,V[0]-te[0]*ne,V[1]-te[1]*ne)}E.zoom(null,ee)}})}function C(M,K,z){return!z&&M.__zooming||new I(M,K)}function I(M,K){this.that=M,this.args=K,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,K),this.taps=0}I.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,K){return this.mouse&&M!=="mouse"&&(this.mouse[1]=K.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=K.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=K.invert(this.touch1[0])),this.that.__zoom=K,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var K=as(this.that).datum();u.call(M,this.that,new jH(M,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),K)}};function R(M,...K){if(!e.apply(this,arguments))return;var z=C(this,K).event(M),F=this.__zoom,$=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),W=Us(M);if(z.wheel)(z.mouse[0][0]!==W[0]||z.mouse[0][1]!==W[1])&&(z.mouse[1]=F.invert(z.mouse[0]=W)),clearTimeout(z.wheel);else{if(F.k===$)return;z.mouse=[W,F.invert(W)],dh(this),z.start()}Eu(M),z.wheel=setTimeout(E,y),z.zoom("mouse",n(x(k(F,$),z.mouse[0],z.mouse[1]),z.extent,a));function E(){z.wheel=null,z.end()}}function H(M,...K){if(p||!e.apply(this,arguments))return;var z=M.currentTarget,F=C(this,K,!0).event(M),$=as(M.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",B,!0),W=Us(M,z),E=M.clientX,Q=M.clientY;KP(M.view),Ly(M),F.mouse=[W,this.__zoom.invert(W)],dh(this),F.start();function V(se){if(Eu(se),!F.moved){var ue=se.clientX-E,G=se.clientY-Q;F.moved=ue*ue+G*G>v}F.event(se).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=Us(se,z),F.mouse[1]),F.extent,a))}function B(se){$.on("mousemove.zoom mouseup.zoom",null),qP(se.view,F.moved),Eu(se),F.event(se).end()}}function A(M,...K){if(e.apply(this,arguments)){var z=this.__zoom,F=Us(M.changedTouches?M.changedTouches[0]:M,this),$=z.invert(F),W=z.k*(M.shiftKey?.5:2),E=n(x(k(z,W),F,$),t.apply(this,K),a);Eu(M),l>0?as(this).transition().duration(l).call(N,E,F,M):as(this).call(g.transform,E,F,M)}}function L(M,...K){if(e.apply(this,arguments)){var z=M.touches,F=z.length,$=C(this,K,M.changedTouches.length===F).event(M),W,E,Q,V;for(Ly(M),E=0;E<F;++E)Q=z[E],V=Us(Q,this),V=[V,this.__zoom.invert(V),Q.identifier],$.touch0?!$.touch1&&$.touch0[2]!==V[2]&&($.touch1=V,$.taps=0):($.touch0=V,W=!0,$.taps=1+!!d);d&&(d=clearTimeout(d)),W&&($.taps<2&&(f=V[0],d=setTimeout(function(){d=null},h)),dh(this),$.start())}}function D(M,...K){if(this.__zooming){var z=C(this,K).event(M),F=M.changedTouches,$=F.length,W,E,Q,V;for(Eu(M),W=0;W<$;++W)E=F[W],Q=Us(E,this),z.touch0&&z.touch0[2]===E.identifier?z.touch0[0]=Q:z.touch1&&z.touch1[2]===E.identifier&&(z.touch1[0]=Q);if(E=z.that.__zoom,z.touch1){var B=z.touch0[0],se=z.touch0[1],ue=z.touch1[0],G=z.touch1[1],ee=(ee=ue[0]-B[0])*ee+(ee=ue[1]-B[1])*ee,te=(te=G[0]-se[0])*te+(te=G[1]-se[1])*te;E=k(E,Math.sqrt(ee/te)),Q=[(B[0]+ue[0])/2,(B[1]+ue[1])/2],V=[(se[0]+G[0])/2,(se[1]+G[1])/2]}else if(z.touch0)Q=z.touch0[0],V=z.touch0[1];else return;z.zoom("touch",n(x(E,Q,V),z.extent,a))}}function O(M,...K){if(this.__zooming){var z=C(this,K).event(M),F=M.changedTouches,$=F.length,W,E;for(Ly(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),W=0;W<$;++W)E=F[W],z.touch0&&z.touch0[2]===E.identifier?delete z.touch0:z.touch1&&z.touch1[2]===E.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(E=Us(E,this),Math.hypot(f[0]-E[0],f[1]-E[1])<b)){var Q=as(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return g.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:jp(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:jp(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:jp(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:jp([[+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 Ii={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."},Od=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],cI=["Enter"," ","Escape"],uI={"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 _c;(function(e){e.Strict="strict",e.Loose="loose"})(_c||(_c={}));var za;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(za||(za={}));var Dd;(function(e){e.Partial="partial",e.Full="full"})(Dd||(Dd={}));const dI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var $o;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})($o||($o={}));var bi;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(bi||(bi={}));var qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(qe||(qe={}));const bN={[qe.Left]:qe.Right,[qe.Right]:qe.Left,[qe.Top]:qe.Bottom,[qe.Bottom]:qe.Top};function fI(e){return e===null?null:e?"valid":"invalid"}const pI=e=>"id"in e&&"source"in e&&"target"in e,PH=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Pk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),df=(e,t=[0,0])=>{const{width:n,height:r}=po(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},IH=(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):Pk(s)?s:t.nodeLookup.get(s.id));const l=a?Qh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Gm(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Jm(n)},ff=(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=Gm(n,Qh(s)),r=!0)}),r?Jm(n):{x:0,y:0,width:0,height:0}},Ik=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...hf(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 h=d.width??u.width??u.initialWidth??null,y=d.height??u.height??u.initialHeight??null,v=Fd(l,Ac(u)),b=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},RH=(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 TH(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 MH({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=TH(e,a),c=ff(l),u=Rk(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 hI({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",Ii.error005());else{const h=l.measured.width,y=l.measured.height;h&&y&&(f=[[c,u],[c+h,u+y]])}else l&&Pc(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=Pc(f)?Ja(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Ii.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 $H({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 h=o.has(p.id),y=!h&&p.parentId&&a.find(v=>v.id===p.parentId);(h||y)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=RH(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 Ec=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ja=(e={x:0,y:0},t,n)=>({x:Ec(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Ec(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function mI(e,t,n){const{width:r,height:s}=po(n),{x:o,y:a}=n.internals.positionAbsolute;return Ja(e,[[o,a],[o+r,a+s]],t)}const kN=(e,t,n)=>e<t?Ec(Math.abs(e-t),1,t)/t:e>n?-Ec(Math.abs(e-n),1,t)/t:0,gI=(e,t,n=15,r=40)=>{const s=kN(e.x,r,t.width-r)*n,o=kN(e.y,r,t.height-r)*n;return[s,o]},Gm=(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)}),$x=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Jm=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ac=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Pk(e)?e.internals.positionAbsolute:df(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}},Qh=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Pk(e)?e.internals.positionAbsolute:df(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)}},yI=(e,t)=>Jm(Gm($x(e),$x(t))),Fd=(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)},vN=e=>Xs(e.width)&&Xs(e.height)&&Xs(e.x)&&Xs(e.y),Xs=e=>!isNaN(e)&&isFinite(e),LH=(e,t)=>{},pf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),hf=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?pf(l,a):l},Zh=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Rl(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 OH(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Rl(e,n),s=Rl(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Rl(e.top??e.y??0,n),s=Rl(e.bottom??e.y??0,n),o=Rl(e.left??e.x??0,t),a=Rl(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 DH(e,t,n,r,s,o){const{x:a,y:l}=Zh(e,[t,n,r]),{x:c,y:u}=Zh({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 Rk=(e,t,n,r,s,o)=>{const a=OH(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Ec(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,y=n/2-p*d,v=DH(e,h,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:h-b.left+b.right,y:y-b.top+b.bottom,zoom:d}},zd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Pc(e){return e!=null&&e!=="parent"}function po(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 wI(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 xI(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 SN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function FH(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function zH(e){return{...uI,...e||{}}}function ad(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=Qs(e),l=hf({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?pf(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Tk=e=>({width:e.offsetWidth,height:e.offsetHeight}),bI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},BH=["INPUT","SELECT","TEXTAREA"];function kI(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:BH.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const vI=e=>"clientX"in e,Qs=(e,t)=>{var o,a;const n=vI(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)}},jN=(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,...Tk(a)}})};function SI({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 Np(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function NN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case qe.Left:return[t-Np(t-r,o),n];case qe.Right:return[t+Np(r-t,o),n];case qe.Top:return[t,n-Np(n-s,o)];case qe.Bottom:return[t,n+Np(s-n,o)]}}function jI({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top,curvature:a=.25}){const[l,c]=NN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=NN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,y]=SI({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,h,y]}function NI({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 HH({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 WH({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=Gm(Qh(e),Qh(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 Fd(a,Jm(o))>0}const VH=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,KH=(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)),fh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||VH;let s;return pI(e)?s={...e}:s={...e,id:r(e)},KH(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function CI({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=NI({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const CN={[qe.Left]:{x:-1,y:0},[qe.Right]:{x:1,y:0},[qe.Top]:{x:0,y:-1},[qe.Bottom]:{x:0,y:1}},qH=({source:e,sourcePosition:t=qe.Bottom,target:n})=>t===qe.Left||t===qe.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},_N=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function UH({source:e,sourcePosition:t=qe.Bottom,target:n,targetPosition:r=qe.Top,center:s,offset:o,stepPosition:a}){const l=CN[t],c=CN[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=qH({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,j]=NI({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}],H=[{x:u.x,y:b},{x:d.x,y:b}];l[p]===h?y=p==="x"?R:H:y=p==="x"?H:R}else{const R=[{x:u.x,y:d.y}],H=[{x:d.x,y:u.y}];if(p==="x"?y=l.x===h?H:R:y=l.y===h?R:H,t===r){const M=Math.abs(e[p]-n[p]);if(M<=o){const K=Math.min(o-1,o-M);l[p]===h?g[p]=(u[p]>e[p]?-1:1)*K:k[p]=(d[p]>n[p]?-1:1)*K}}if(t!==r){const M=p==="x"?"y":"x",K=l[p]===c[M],z=u[M]>d[M],F=u[M]<d[M];(l[p]===1&&(!K&&z||K&&F)||l[p]!==1&&(!K&&F||K&&z))&&(y=p==="x"?R:H)}const A={x:u.x+g.x,y:u.y+g.y},L={x:d.x+k.x,y:d.y+k.y},D=Math.max(Math.abs(A.x-y[0].x),Math.abs(L.x-y[0].x)),O=Math.max(Math.abs(A.y-y[0].y),Math.abs(L.y-y[0].y));D>=O?(v=(A.x+L.x)/2,b=y[0].y):(v=y[0].x,b=(A.y+L.y)/2)}const N={x:u.x+g.x,y:u.y+g.y},C={x:d.x+k.x,y:d.y+k.y};return[[e,...N.x!==y[0].x||N.y!==y[0].y?[N]:[],...y,...C.x!==y[y.length-1].x||C.y!==y[y.length-1].y?[C]:[],n],v,b,x,j]}function YH(e,t,n,r){const s=Math.min(_N(e,t)/2,_N(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 Lx({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,y,v]=UH({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+=YH(f[g-1],f[g],f[g+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,p,h,y,v]}function EN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function GH(e){var f;const{sourceNode:t,targetNode:n}=e;if(!EN(t)||!EN(n))return null;const r=t.internals.handleBounds||AN(t.handles),s=n.internals.handleBounds||AN(n.handles),o=PN((r==null?void 0:r.source)??[],e.sourceHandle),a=PN(e.connectionMode===_c.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",Ii.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||qe.Bottom,c=(a==null?void 0:a.position)||qe.Top,u=Xa(t,o,l),d=Xa(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function AN(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 Xa(e,t,n=qe.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??po(e);if(r)return{x:s+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case qe.Top:return{x:s+a/2,y:o};case qe.Right:return{x:s+a,y:o+l/2};case qe.Bottom:return{x:s+a/2,y:o+l};case qe.Left:return{x:s,y:o+l/2}}}function PN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ox(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function JH(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=Ox(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 _I=1e3,XH=10,Mk={nodeOrigin:[0,0],nodeExtent:Od,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},QH={...Mk,checkEquality:!0};function $k(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function ZH(e,t,n){const r=$k(Mk,n);for(const s of e.values())if(s.parentId)Ok(s,e,t,r);else{const o=df(s,r.nodeOrigin),a=Pc(s.extent)?s.extent:r.nodeExtent,l=Ja(o,a,po(s));s.internals.positionAbsolute=l}}function e4(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 Lk(e){return e==="manual"}function Dx(e,t,n,r={}){var d,f;const s=$k(QH,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Lk(s.zIndexMode)?_I:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const p of e){let h=a.get(p.id);if(s.checkEquality&&p===(h==null?void 0:h.internals.userNode))t.set(p.id,h);else{const y=df(p,s.nodeOrigin),v=Pc(p.extent)?p.extent:s.nodeExtent,b=Ja(y,v,po(p));h={...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:e4(p,h),z:EI(p,l,s.zIndexMode),userNode:p}},t.set(p.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),p.parentId&&Ok(h,t,n,r,o),u||(u=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function t4(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 Ok(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=$k(Mk,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}t4(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*XH),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=o&&!Lk(c)?_I:0,{x:p,y:h,z:y}=n4(e,d,a,l,f,c),{positionAbsolute:v}=e.internals,b=p!==v.x||h!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:p,y:h}:v,z:y}})}function EI(e,t,n){const r=Xs(e.zIndex)?e.zIndex:0;return Lk(n)?r:r+(e.selected?t:0)}function n4(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=po(e),u=df(e,n),d=Pc(e.extent)?Ja(u,e.extent,c):u;let f=Ja({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=mI(f,c,t));const p=EI(e,s,o),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Dk(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)??Ac(c),d=yI(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=po(c),p=c.origin??r,h=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];(h>0||y>0||g||k)&&(s.push({id:u,type:"position",position:{x:c.position.x-h+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(j=>{e.some(N=>N.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+h,y:j.position.y+y}})})),(f.width<l.width||f.height<l.height||h||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?p[0]*h-g:0),height:b+(y?p[1]*y-k:0)}})}),s}function r4(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 h of e.values()){const y=t.get(h.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=Tk(h.nodeElement),b=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!y.internals.handleBounds||h.force))){const k=h.nodeElement.getBoundingClientRect(),x=Pc(y.extent)?y.extent:o;let{positionAbsolute:j}=y.internals;y.parentId&&y.extent==="parent"?j=mI(j,v,t.get(y.parentId)):x&&(j=Ja(j,x,v));const N={...y,measured:v,internals:{...y.internals,positionAbsolute:j,handleBounds:{source:jN("source",h.nodeElement,k,f,y.id),target:jN("target",h.nodeElement,k,f,y.id)}}};t.set(y.id,N),y.parentId&&Ok(N,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:Ac(N,s)}))}}if(p.length>0){const h=Dk(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function s4({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 IN(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 AI(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}`;IN("source",c,d,e,s,a),IN("target",c,u,e,o,l),t.set(r.id,r)}}function PI(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:PI(n,t):!1}function RN(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 i4(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!PI(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 Oy({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 o4({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=pf(o,t);return{x:a.x-o.x,y:a.y-o.y}}function a4({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,h=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:j,isSelectable:N,nodeId:C,nodeClickDistance:I=0}){p=as(j);function R({x:D,y:O}){const{nodeLookup:M,nodeExtent:K,snapGrid:z,snapToGrid:F,nodeOrigin:$,onNodeDrag:W,onSelectionDrag:E,onError:Q,updateNodePositions:V}=t();o={x:D,y:O};let B=!1;const se=l.size>1,ue=se&&K?$x(ff(l)):null,G=se&&F?o4({dragItems:l,snapGrid:z,x:D,y:O}):null;for(const[ee,te]of l){if(!M.has(ee))continue;let ne={x:D-te.distance.x,y:O-te.distance.y};F&&(ne=G?{x:Math.round(ne.x+G.x),y:Math.round(ne.y+G.y)}:pf(ne,z));let Z=null;if(se&&K&&!te.extent&&ue){const{positionAbsolute:me}=te.internals,$e=me.x-ue.x+K[0][0],Ce=me.x+te.measured.width-ue.x2+K[1][0],_e=me.y-ue.y+K[0][1],Be=me.y+te.measured.height-ue.y2+K[1][1];Z=[[$e,_e],[Ce,Be]]}const{position:ce,positionAbsolute:de}=hI({nodeId:ee,nextPosition:ne,nodeLookup:M,nodeExtent:Z||K,nodeOrigin:$,onError:Q});B=B||te.position.x!==ce.x||te.position.y!==ce.y,te.position=ce,te.internals.positionAbsolute=de}if(y=y||B,!!B&&(V(l,!0),v&&(r||W||!C&&E))){const[ee,te]=Oy({nodeId:C,dragItems:l,nodeLookup:M});r==null||r(v,l,ee,te),W==null||W(v,ee,te),C||E==null||E(v,te)}}async function H(){if(!d)return;const{transform:D,panBy:O,autoPanSpeed:M,autoPanOnNodeDrag:K}=t();if(!K){c=!1,cancelAnimationFrame(a);return}const[z,F]=gI(u,d,M);(z!==0||F!==0)&&(o.x=(o.x??0)-z/D[2],o.y=(o.y??0)-F/D[2],await O({x:z,y:F})&&R(o)),a=requestAnimationFrame(H)}function A(D){var se;const{nodeLookup:O,multiSelectionActive:M,nodesDraggable:K,transform:z,snapGrid:F,snapToGrid:$,selectNodesOnDrag:W,onNodeDragStart:E,onSelectionDragStart:Q,unselectNodesAndEdges:V}=t();f=!0,(!W||!N)&&!M&&C&&((se=O.get(C))!=null&&se.selected||V()),N&&W&&C&&(e==null||e(C));const B=ad(D.sourceEvent,{transform:z,snapGrid:F,snapToGrid:$,containerBounds:d});if(o=B,l=i4(O,K,B,C),l.size>0&&(n||E||!C&&Q)){const[ue,G]=Oy({nodeId:C,dragItems:l,nodeLookup:O});n==null||n(D.sourceEvent,l,ue,G),E==null||E(D.sourceEvent,ue,G),C||Q==null||Q(D.sourceEvent,G)}}const L=UP().clickDistance(I).on("start",D=>{const{domNode:O,nodeDragThreshold:M,transform:K,snapGrid:z,snapToGrid:F}=t();d=(O==null?void 0:O.getBoundingClientRect())||null,h=!1,y=!1,v=D.sourceEvent,M===0&&A(D),o=ad(D.sourceEvent,{transform:K,snapGrid:z,snapToGrid:F,containerBounds:d}),u=Qs(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:O,transform:M,snapGrid:K,snapToGrid:z,nodeDragThreshold:F,nodeLookup:$}=t(),W=ad(D.sourceEvent,{transform:M,snapGrid:K,snapToGrid:z,containerBounds:d});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||C&&!$.has(C))&&(h=!0),!h){if(!c&&O&&f&&(c=!0,H()),!f){const E=Qs(D.sourceEvent,d),Q=E.x-u.x,V=E.y-u.y;Math.sqrt(Q*Q+V*V)>F&&A(D)}(o.x!==W.xSnapped||o.y!==W.ySnapped)&&l&&f&&(u=Qs(D.sourceEvent,d),R(W))}}).on("end",D=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:O,updateNodePositions:M,onNodeDragStop:K,onSelectionDragStop:z}=t();if(y&&(M(l,!1),y=!1),s||K||!C&&z){const[F,$]=Oy({nodeId:C,dragItems:l,nodeLookup:O,dragging:!1});s==null||s(D.sourceEvent,l,F,$),K==null||K(D.sourceEvent,F,$),C||z==null||z(D.sourceEvent,$)}}}).filter(D=>{const O=D.target;return!D.button&&(!k||!RN(O,`.${k}`,j))&&(!x||RN(O,x,j))});p.call(L)}function g(){p==null||p.on(".drag",null)}return{update:b,destroy:g}}function l4(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())Fd(s,Ac(o))>0&&r.push(o);return r}const c4=250;function u4(e,t,n,r){var l,c;let s=[],o=1/0;const a=l4(e,n,t+c4);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:h}=Xa(u,f,f.position,!0),y=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(h-e.y,2));y>t||(y<o?(s=[{...f,x:p,y:h}],o=y):y===o&&s.push({...f,x:p,y:h}))}}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 II(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,...Xa(a,c,c.position,!0)}:c}function RI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function d4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const TI=()=>!0;function f4(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:h,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=TI,onReconnectEnd:k,updateConnection:x,getTransform:j,getFromHandle:N,autoPanSpeed:C,dragThreshold:I=1,handleDomNode:R}){const H=bI(e.target);let A=0,L;const{x:D,y:O}=Qs(e),M=RI(o,R),K=l==null?void 0:l.getBoundingClientRect();let z=!1;if(!K||!M)return;const F=II(s,M,r,c,t);if(!F)return;let $=Qs(e,K),W=!1,E=null,Q=!1,V=null;function B(){if(!d||!K)return;const[ce,de]=gI($,K,C);p({x:ce,y:de}),A=requestAnimationFrame(B)}const se={...F,nodeId:s,type:M,position:F.position},ue=c.get(s);let ee={inProgress:!0,isValid:null,from:Xa(ue,se,qe.Left,!0),fromHandle:se,fromPosition:se.position,fromNode:ue,to:$,toHandle:null,toPosition:bN[se.position],toNode:null,pointer:$};function te(){z=!0,x(ee),y==null||y(e,{nodeId:s,handleId:r,handleType:M})}I===0&&te();function ne(ce){if(!z){const{x:Be,y:ot}=Qs(ce),gt=Be-D,Te=ot-O;if(!(gt*gt+Te*Te>I*I))return;te()}if(!N()||!se){Z(ce);return}const de=j();$=Qs(ce,K),L=u4(hf($,de,!1,[1,1]),n,c,se),W||(B(),W=!0);const me=MI(ce,{handle:L,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:H,lib:u,flowId:f,nodeLookup:c});V=me.handleDomNode,E=me.connection,Q=d4(!!L,me.isValid);const $e=c.get(s),Ce=$e?Xa($e,se,qe.Left,!0):ee.from,_e={...ee,from:Ce,isValid:Q,to:me.toHandle&&Q?Zh({x:me.toHandle.x,y:me.toHandle.y},de):$,toHandle:me.toHandle,toPosition:Q&&me.toHandle?me.toHandle.position:bN[se.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null,pointer:$};x(_e),ee=_e}function Z(ce){if(!("touches"in ce&&ce.touches.length>0)){if(z){(L||V)&&E&&Q&&(v==null||v(E));const{inProgress:de,...me}=ee,$e={...me,toPosition:ee.toHandle?ee.toPosition:null};b==null||b(ce,$e),o&&(k==null||k(ce,$e))}h(),cancelAnimationFrame(A),W=!1,Q=!1,E=null,V=null,H.removeEventListener("mousemove",ne),H.removeEventListener("mouseup",Z),H.removeEventListener("touchmove",ne),H.removeEventListener("touchend",Z)}}H.addEventListener("mousemove",ne),H.addEventListener("mouseup",Z),H.addEventListener("touchmove",ne),H.addEventListener("touchend",Z)}function MI(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=TI,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:h,y}=Qs(e),v=a.elementFromPoint(h,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=RI(void 0,b),x=b.getAttribute("data-nodeid"),j=b.getAttribute("data-handleid"),N=b.classList.contains("connectable"),C=b.classList.contains("connectableend");if(!x||!k)return g;const I={source:f?x:r,sourceHandle:f?j:s,target:f?r:x,targetHandle:f?s:j};g.connection=I;const H=N&&C&&(n===_c.Strict?f&&k==="source"||!f&&k==="target":x!==r||j!==s);g.isValid=H&&u(I),g.toHandle=II(x,k,j,d,n,!0)}return g}const Fx={onPointerDown:f4,isValid:MI};function p4({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=as(e);function o({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const j=n(),N=x.sourceEvent.ctrlKey&&zd()?10:1,C=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,I=j[2]*Math.pow(2,C*N);t.scaleTo(I)};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 j=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const N=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],C=[N[0]-v[0],N[1]-v[1]];v=N;const I=r()*Math.max(j[2],Math.log(j[2]))*(h?-1:1),R={x:j[0]-C[0]*I,y:j[1]-C[1]*I},H=[[0,0],[c,u]];t.setViewportConstrained({x:R.x,y:R.y,zoom:j[2]},H,l)},k=lI().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:Us}}const Xm=e=>({x:e.x,y:e.y,zoom:e.k}),Dy=({x:e,y:t,zoom:n})=>Ym.translate(e,t).scale(n),ec=(e,t)=>e.target.closest(`.${t}`),$I=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),h4=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Fy=(e,t=0,n=h4,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},LI=e=>{const t=e.ctrlKey&&zd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function m4({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(ec(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=Us(d),g=LI(d),k=f*Math.pow(2,g);r.scaleTo(n,k,b,d);return}const p=d.deltaMode===1?20:1;let h=s===za.Vertical?0:d.deltaX*p,y=s===za.Horizontal?0:d.deltaY*p;!zd()&&d.shiftKey&&s!==za.Vertical&&(h=d.deltaY*p,y=0),r.translateBy(n,-(h/f)*o,-(y/f)*o,{internal:!0});const v=Xm(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 g4({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=ec(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function y4({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=Xm(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 w4({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&$I(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,Xm(o.transform)))}}function x4({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&&$I(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Xm(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function b4({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,h=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(ec(f,`${u}-flow__node`)||ec(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!o&&!n||a||d&&!y||ec(f,l)&&y||ec(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&&!h&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function k4({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=lI().scaleExtent([t,n]).translateExtent(r),p=as(e).call(f);k({x:s.x,y:s.y,zoom:Ec(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),y=p.on("dblclick.zoom");f.wheelDelta(LI);function v(L,D){return p?new Promise(O=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?od:lh).transform(Fy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>O(!0)),L)}):Promise.resolve(!1)}function b({noWheelClassName:L,noPanClassName:D,onPaneContextMenu:O,userSelectionActive:M,panOnScroll:K,panOnDrag:z,panOnScrollMode:F,panOnScrollSpeed:$,preventScrolling:W,zoomOnPinch:E,zoomOnScroll:Q,zoomOnDoubleClick:V,zoomActivationKeyPressed:B,lib:se,onTransformChange:ue,connectionInProgress:G,paneClickDistance:ee,selectionOnDrag:te}){M&&!u.isZoomingOrPanning&&g();const ne=K&&!B&&!M;f.clickDistance(te?1/0:!Xs(ee)||ee<0?0:ee);const Z=ne?m4({zoomPanValues:u,noWheelClassName:L,d3Selection:p,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:$,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):g4({noWheelClassName:L,preventScrolling:W,d3ZoomHandler:h});if(p.on("wheel.zoom",Z,{passive:!1}),!M){const de=y4({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const me=w4({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!O,onPanZoom:o,onTransformChange:ue});f.on("zoom",me);const $e=x4({zoomPanValues:u,panOnDrag:z,panOnScroll:K,onPaneContextMenu:O,onPanZoomEnd:l,onDraggingChange:c});f.on("end",$e)}const ce=b4({zoomActivationKeyPressed:B,panOnDrag:z,zoomOnScroll:Q,panOnScroll:K,zoomOnDoubleClick:V,zoomOnPinch:E,userSelectionActive:M,noPanClassName:D,noWheelClassName:L,lib:se,connectionInProgress:G});f.filter(ce),V?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)}function g(){f.on("zoom",null)}async function k(L,D,O){const M=Dy(L),K=f==null?void 0:f.constrain()(M,D,O);return K&&await v(K),new Promise(z=>z(K))}async function x(L,D){const O=Dy(L);return await v(O,D),new Promise(M=>M(O))}function j(L){if(p){const D=Dy(L),O=p.property("__zoom");(O.k!==L.zoom||O.x!==L.x||O.y!==L.y)&&(f==null||f.transform(p,D,null,{sync:!0}))}}function N(){const L=p?aI(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function C(L,D){return p?new Promise(O=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?od:lh).scaleTo(Fy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>O(!0)),L)}):Promise.resolve(!1)}function I(L,D){return p?new Promise(O=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?od:lh).scaleBy(Fy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>O(!0)),L)}):Promise.resolve(!1)}function R(L){f==null||f.scaleExtent(L)}function H(L){f==null||f.translateExtent(L)}function A(L){const D=!Xs(L)||L<0?0:L;f==null||f.clickDistance(D)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:N,scaleTo:C,scaleBy:I,setScaleExtent:R,setTranslateExtent:H,syncViewport:j,setClickDistance:A}}var Ic;(function(e){e.Line="line",e.Handle="handle"})(Ic||(Ic={}));function v4({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 TN(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function _o(e,t){return Math.max(0,t-e)}function Eo(e,t){return Math.max(0,e-t)}function Cp(e,t,n){return Math.max(0,t-e,e-n)}function MN(e,t){return e?!t:t}function S4(e,t,n,r,s,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:j,width:N,height:C,aspectRatio:I}=e;let R=Math.floor(d?h-e.pointerX:0),H=Math.floor(f?y-e.pointerY:0);const A=N+(c?-R:R),L=C+(u?-H:H),D=-o[0]*N,O=-o[1]*C;let M=Cp(A,v,b),K=Cp(L,g,k);if(a){let $=0,W=0;c&&R<0?$=_o(x+R+D,a[0][0]):!c&&R>0&&($=Eo(x+A+D,a[1][0])),u&&H<0?W=_o(j+H+O,a[0][1]):!u&&H>0&&(W=Eo(j+L+O,a[1][1])),M=Math.max(M,$),K=Math.max(K,W)}if(l){let $=0,W=0;c&&R>0?$=Eo(x+R,l[0][0]):!c&&R<0&&($=_o(x+A,l[1][0])),u&&H>0?W=Eo(j+H,l[0][1]):!u&&H<0&&(W=_o(j+L,l[1][1])),M=Math.max(M,$),K=Math.max(K,W)}if(s){if(d){const $=Cp(A/I,g,k)*I;if(M=Math.max(M,$),a){let W=0;!c&&!u||c&&!u&&p?W=Eo(j+O+A/I,a[1][1])*I:W=_o(j+O+(c?R:-R)/I,a[0][1])*I,M=Math.max(M,W)}if(l){let W=0;!c&&!u||c&&!u&&p?W=_o(j+A/I,l[1][1])*I:W=Eo(j+(c?R:-R)/I,l[0][1])*I,M=Math.max(M,W)}}if(f){const $=Cp(L*I,v,b)/I;if(K=Math.max(K,$),a){let W=0;!c&&!u||u&&!c&&p?W=Eo(x+L*I+D,a[1][0])/I:W=_o(x+(u?H:-H)*I+D,a[0][0])/I,K=Math.max(K,W)}if(l){let W=0;!c&&!u||u&&!c&&p?W=_o(x+L*I,l[1][0])/I:W=Eo(x+(u?H:-H)*I,l[0][0])/I,K=Math.max(K,W)}}}H=H+(H<0?K:-K),R=R+(R<0?M:-M),s&&(p?A>L*I?H=(MN(c,u)?-R:R)/I:R=(MN(c,u)?-H:H)*I:d?(H=R/I,u=c):(R=H*I,c=u));const z=c?x+R:x,F=u?j+H:j;return{width:N+(c?-R:R),height:C+(u?-H:H),x:o[0]*R*(c?-1:1)+z,y:o[1]*H*(u?-1:1)+F}}const OI={width:0,height:0,x:0,y:0},j4={...OI,pointerX:0,pointerY:0,aspectRatio:1};function N4(e){return[[0,0],[e.measured.width,e.measured.height]]}function C4(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 _4({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=as(e);let a={controlDirection:TN("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:h,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...OI},k={...j4};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:TN(u)};let x,j=null,N=[],C,I,R,H=!1;const A=UP().on("start",L=>{const{nodeLookup:D,transform:O,snapGrid:M,snapToGrid:K,nodeOrigin:z,paneDomNode:F}=n();if(x=D.get(t),!x)return;j=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:W}=ad(L.sourceEvent,{transform:O,snapGrid:M,snapToGrid:K,containerBounds:j});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:W,aspectRatio:g.width/g.height},C=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(C=D.get(x.parentId),I=C&&x.extent==="parent"?N4(C):void 0),N=[],R=void 0;for(const[E,Q]of D)if(Q.parentId===t&&(N.push({id:E,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const V=C4(Q,x,Q.origin??z);R?R=[[Math.min(V[0][0],R[0][0]),Math.min(V[0][1],R[0][1])],[Math.max(V[1][0],R[1][0]),Math.max(V[1][1],R[1][1])]]:R=V}h==null||h(L,{...g})}).on("drag",L=>{const{transform:D,snapGrid:O,snapToGrid:M,nodeOrigin:K}=n(),z=ad(L.sourceEvent,{transform:D,snapGrid:O,snapToGrid:M,containerBounds:j}),F=[];if(!x)return;const{x:$,y:W,width:E,height:Q}=g,V={},B=x.origin??K,{width:se,height:ue,x:G,y:ee}=S4(k,a.controlDirection,z,a.boundaries,a.keepAspectRatio,B,I,R),te=se!==E,ne=ue!==Q,Z=G!==$&&te,ce=ee!==W&&ne;if(!Z&&!ce&&!te&&!ne)return;if((Z||ce||B[0]===1||B[1]===1)&&(V.x=Z?G:g.x,V.y=ce?ee:g.y,g.x=V.x,g.y=V.y,N.length>0)){const Ce=G-$,_e=ee-W;for(const Be of N)Be.position={x:Be.position.x-Ce+B[0]*(se-E),y:Be.position.y-_e+B[1]*(ue-Q)},F.push(Be)}if((te||ne)&&(V.width=te&&(!a.resizeDirection||a.resizeDirection==="horizontal")?se:g.width,V.height=ne&&(!a.resizeDirection||a.resizeDirection==="vertical")?ue:g.height,g.width=V.width,g.height=V.height),C&&x.expandParent){const Ce=B[0]*(V.width??0);V.x&&V.x<Ce&&(g.x=Ce,k.x=k.x-(V.x-Ce));const _e=B[1]*(V.height??0);V.y&&V.y<_e&&(g.y=_e,k.y=k.y-(V.y-_e))}const de=v4({width:g.width,prevWidth:E,height:g.height,prevHeight:Q,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),me={...g,direction:de};(b==null?void 0:b(L,me))!==!1&&(H=!0,y==null||y(L,me),r(V,F))}).on("end",L=>{H&&(v==null||v(L,{...g}),s==null||s({...g}),H=!1)});o.call(A)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var DI={exports:{}},FI={},zI={exports:{}},BI={};/**
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 Rc=m;function E4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var A4=typeof Object.is=="function"?Object.is:E4,P4=Rc.useState,I4=Rc.useEffect,R4=Rc.useLayoutEffect,T4=Rc.useDebugValue;function M4(e,t){var n=t(),r=P4({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return R4(function(){s.value=n,s.getSnapshot=t,zy(s)&&o({inst:s})},[e,n,t]),I4(function(){return zy(s)&&o({inst:s}),e(function(){zy(s)&&o({inst:s})})},[e]),T4(n),n}function zy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!A4(e,n)}catch{return!0}}function $4(e,t){return t()}var L4=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?$4:M4;BI.useSyncExternalStore=Rc.useSyncExternalStore!==void 0?Rc.useSyncExternalStore:L4;zI.exports=BI;var HI=zI.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 Qm=m,O4=HI;function D4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var F4=typeof Object.is=="function"?Object.is:D4,z4=O4.useSyncExternalStore,B4=Qm.useRef,H4=Qm.useEffect,W4=Qm.useMemo,V4=Qm.useDebugValue;FI.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=B4(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=W4(function(){function c(h){if(!u){if(u=!0,d=h,h=r(h),s!==void 0&&a.hasValue){var y=a.value;if(s(y,h))return f=y}return f=h}if(y=f,F4(d,h))return y;var v=r(h);return s!==void 0&&s(y,v)?(d=h,y):(d=h,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=z4(e,o[0],o[1]);return H4(function(){a.hasValue=!0,a.value=l},[l]),V4(l),l};DI.exports=FI;var K4=DI.exports;const q4=ia(K4),U4={},$N=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(y=>y(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(U4?"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},Y4=e=>e?$N(e):$N,{useDebugValue:G4}=dt,{useSyncExternalStoreWithSelector:J4}=q4,X4=e=>e;function WI(e,t=X4,n){const r=J4(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return G4(r),r}const LN=(e,t)=>{const n=Y4(e),r=(s,o=t)=>WI(n,s,o);return Object.assign(r,n),r},Q4=(e,t)=>e?LN(e,t):LN;function En(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 Zm=m.createContext(null),Z4=Zm.Provider,VI=Ii.error001();function Ht(e,t){const n=m.useContext(Zm);if(n===null)throw new Error(VI);return WI(n,e,t)}function wn(){const e=m.useContext(Zm);if(e===null)throw new Error(VI);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const ON={display:"none"},e5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},KI="react-flow__node-desc",qI="react-flow__edge-desc",t5="react-flow__aria-live",n5=e=>e.ariaLiveMessage,r5=e=>e.ariaLabelConfig;function s5({rfId:e}){const t=Ht(n5);return i.jsx("div",{id:`${t5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:e5,children:t})}function i5({rfId:e,disableKeyboardA11y:t}){const n=Ht(r5);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${KI}-${e}`,style:ON,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${qI}-${e}`,style:ON,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(s5,{rfId:e})]})}const eg=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Xn(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});eg.displayName="Panel";function o5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(eg,{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 a5=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}},_p=e=>e.id;function l5(e,t){return En(e.selectedNodes.map(_p),t.selectedNodes.map(_p))&&En(e.selectedEdges.map(_p),t.selectedEdges.map(_p))}function c5({onSelectionChange:e}){const t=wn(),{selectedNodes:n,selectedEdges:r}=Ht(a5,l5);return m.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const u5=e=>!!e.onSelectionChangeHandlers;function d5({onSelectionChange:e}){const t=Ht(u5);return e||t?i.jsx(c5,{onSelectionChange:e}):null}const zx=typeof window<"u"?m.useLayoutEffect:m.useEffect,UI=[0,0],f5={x:0,y:0,zoom:1},p5=["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"],DN=[...p5,"rfId"],h5=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}),FN={translateExtent:Od,nodeOrigin:UI,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function m5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Ht(h5,En),u=wn();zx(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=FN,l()}),[]);const d=m.useRef(FN);return zx(()=>{for(const f of DN){const p=e[f],h=d.current[f];p!==h&&(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:zH(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},DN.map(f=>e[f])),null}function zN(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function g5(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=zN(),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=zN())!=null&&r.matches?"dark":"light"}const BN=typeof document<"u"?document:null;function Bd(e=null,t={target:BN,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),o=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
+ `).replace(`
62
+
63
+ `,`
64
+ +`).split(`
65
+ `)),d=u.reduce((f,p)=>f.concat(...p),[]);return[u,d]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??BN,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var b,g;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&kI(h))return!1;const v=WN(h.code,l);if(o.current.add(h[v]),HN(a,o.current,!1)){const k=((g=(b=h.composedPath)==null?void 0:b.call(h))==null?void 0:g[0])||h.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const y=WN(h.code,l);HN(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[y]),h.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 HN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function WN(e,t){return t.includes(e)?"code":"key"}const y5=()=>{const e=wn();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=Rk(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 hf(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=Zh(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function YI(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)w5(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 w5(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 ld(e,t){return YI(e,t)}function em(e,t){return YI(e,t)}function Na(e,t){return{id:e,type:"select",selected:t}}function tc(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(Na(o.id,a)))}return r}function VN({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 KN(e){return{id:e.id,type:"remove"}}const qN=e=>PH(e),x5=e=>pI(e);function GI(e){return m.forwardRef(e)}function UN(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>b5(()=>n(s=>s+BigInt(1))));return zx(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function b5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const JI=m.createContext(null);function k5({children:e}){const t=wn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:p,fitViewQueued:h,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=VN({items:v,lookup:p});for(const g of y.values())b=g(b);d&&u(v),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=UN(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:p}=t.getState();let h=c;for(const y of l)h=typeof y=="function"?y(h):y;d?u(h):f&&f(VN({items:h,lookup:p}))},[]),o=UN(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(JI.Provider,{value:a,children:e})}function v5(){const e=m.useContext(JI);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const S5=e=>!!e.panZoom;function zc(){const e=y5(),t=wn(),n=v5(),r=Ht(S5),s=m.useMemo(()=>{const o=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var g,k;const{nodeLookup:p,nodeOrigin:h}=t.getState(),y=qN(f)?f:p.get(f.id),v=y.parentId?xI(y.position,y.measured,y.parentId,p,h):y.position,b={...y,position:v,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((k=y.measured)==null?void 0:k.height)??y.height};return Ac(b)},u=(f,p,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return h.replace&&qN(b)?b:{...v,...b}}return v}))},d=(f,p,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const b=typeof p=="function"?p(v):p;return h.replace&&x5(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(h=>[...h,...p])},addEdges:f=>{const p=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...p])},toObject:()=>{const{nodes:f=[],edges:p=[],transform:h}=t.getState(),[y,v,b]=h;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:h,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:j}=t.getState(),{nodes:N,edges:C}=await $H({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:y,onBeforeDelete:j}),I=C.length>0,R=N.length>0;if(I){const H=C.map(KN);b==null||b(C),k(H)}if(R){const H=N.map(KN);v==null||v(N),g(H)}return(R||I)&&(x==null||x({nodes:N,edges:C})),{deletedNodes:N,deletedEdges:C}},getIntersectingNodes:(f,p=!0,h)=>{const y=vN(f),v=y?f:c(f),b=h!==void 0;return v?(h||t.getState().nodes).filter(g=>{const k=t.getState().nodeLookup.get(g.id);if(k&&!y&&(g.id===f.id||!k.internals.positionAbsolute))return!1;const x=Ac(b?g:k),j=Fd(x,v);return p&&j>0||j>=x.width*x.height||j>=v.width*v.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const v=vN(f)?f:c(f);if(!v)return!1;const b=Fd(v,p);return h&&b>0||b>=p.width*p.height||b>=v.width*v.height},updateNode:u,updateNodeData:(f,p,h={replace:!1})=>{u(f,y=>{const v=typeof p=="function"?p(y):p;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},updateEdge:d,updateEdgeData:(f,p,h={replace:!1})=>{d(f,y=>{const v=typeof p=="function"?p(y):p;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:h}=t.getState();return IH(f,{nodeLookup:p,nodeOrigin:h})},getHandleConnections:({type:f,id:p,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}-${f}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:p,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}${f?p?`-${f}-${p}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const p=t.getState().fitViewResolver??FH();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:p}),n.nodeQueue.push(h=>[...h]),p.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const YN=e=>e.selected,j5=typeof window<"u"?window:void 0;function N5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=wn(),{deleteElements:r}=zc(),s=Bd(e,{actInsideInputWithModifier:!1}),o=Bd(t,{target:j5});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(YN),edges:a.filter(YN)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function C5(e){const t=wn();m.useEffect(()=>{const n=()=>{var s,o,a,l;if(!e.current||!(((o=(s=e.current).checkVisibility)==null?void 0:o.call(s))??!0))return!1;const r=Tk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Ii.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 tg={position:"absolute",width:"100%",height:"100%",top:0,left:0},_5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function E5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=za.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:h=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:j}){const N=wn(),C=m.useRef(null),{userSelectionActive:I,lib:R,connectionInProgress:H}=Ht(_5,En),A=Bd(p),L=m.useRef();C5(C);const D=m.useCallback(O=>{g==null||g({x:O[0],y:O[1],zoom:O[2]}),k||N.setState({transform:O})},[g,k]);return m.useEffect(()=>{if(C.current){L.current=k4({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:z=>N.setState(F=>F.paneDragging===z?F:{paneDragging:z}),onPanZoomStart:(z,F)=>{const{onViewportChangeStart:$,onMoveStart:W}=N.getState();W==null||W(z,F),$==null||$(F)},onPanZoom:(z,F)=>{const{onViewportChange:$,onMove:W}=N.getState();W==null||W(z,F),$==null||$(F)},onPanZoomEnd:(z,F)=>{const{onViewportChangeEnd:$,onMoveEnd:W}=N.getState();W==null||W(z,F),$==null||$(F)}});const{x:O,y:M,zoom:K}=L.current.getViewport();return N.setState({panZoom:L.current,transform:[O,M,K],domNode:C.current.closest(".react-flow")}),()=>{var z;(z=L.current)==null||z.destroy()}}},[]),m.useEffect(()=>{var O;(O=L.current)==null||O.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:A,preventScrolling:h,noPanClassName:b,userSelectionActive:I,noWheelClassName:v,lib:R,onTransformChange:D,connectionInProgress:H,selectionOnDrag:j,paneClickDistance:x})},[e,t,n,r,s,o,a,l,A,h,b,I,v,R,D,H,j,x]),i.jsx("div",{className:"react-flow__renderer",ref:C,style:tg,children:y})}const A5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function P5(){const{userSelectionActive:e,userSelectionRect:t}=Ht(A5,En);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 By=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},I5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function R5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Dd.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:y}){const v=wn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Ht(I5,En),j=g&&(e||b),N=m.useRef(null),C=m.useRef(),I=m.useRef(new Set),R=m.useRef(new Set),H=m.useRef(!1),A=$=>{if(H.current||x){H.current=!1;return}c==null||c($),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},L=$=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){$.preventDefault();return}u==null||u($)},D=d?$=>d($):void 0,O=$=>{H.current&&($.stopPropagation(),H.current=!1)},M=$=>{var ue,G;const{domNode:W}=v.getState();if(C.current=W==null?void 0:W.getBoundingClientRect(),!C.current)return;const E=$.target===N.current;if(!E&&!!$.target.closest(".nokey")||!e||!(o&&E||t)||$.button!==0||!$.isPrimary)return;(G=(ue=$.target)==null?void 0:ue.setPointerCapture)==null||G.call(ue,$.pointerId),H.current=!1;const{x:B,y:se}=Qs($.nativeEvent,C.current);v.setState({userSelectionRect:{width:0,height:0,startX:B,startY:se,x:B,y:se}}),E||($.stopPropagation(),$.preventDefault())},K=$=>{const{userSelectionRect:W,transform:E,nodeLookup:Q,edgeLookup:V,connectionLookup:B,triggerNodeChanges:se,triggerEdgeChanges:ue,defaultEdgeOptions:G,resetSelectedElements:ee}=v.getState();if(!C.current||!W)return;const{x:te,y:ne}=Qs($.nativeEvent,C.current),{startX:Z,startY:ce}=W;if(!H.current){const _e=t?0:s;if(Math.hypot(te-Z,ne-ce)<=_e)return;ee(),a==null||a($)}H.current=!0;const de={startX:Z,startY:ce,x:te<Z?te:Z,y:ne<ce?ne:ce,width:Math.abs(te-Z),height:Math.abs(ne-ce)},me=I.current,$e=R.current;I.current=new Set(Ik(Q,de,E,n===Dd.Partial,!0).map(_e=>_e.id)),R.current=new Set;const Ce=(G==null?void 0:G.selectable)??!0;for(const _e of I.current){const Be=B.get(_e);if(Be)for(const{edgeId:ot}of Be.values()){const gt=V.get(ot);gt&&(gt.selectable??Ce)&&R.current.add(ot)}}if(!SN(me,I.current)){const _e=tc(Q,I.current,!0);se(_e)}if(!SN($e,R.current)){const _e=tc(V,R.current);ue(_e)}v.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},z=$=>{var W,E;$.button===0&&((E=(W=$.target)==null?void 0:W.releasePointerCapture)==null||E.call(W,$.pointerId),!b&&$.target===N.current&&v.getState().userSelectionRect&&(A==null||A($)),v.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(l==null||l($),v.setState({nodesSelectionActive:I.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:Xn(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:j?void 0:By(A,N),onContextMenu:By(L,N),onWheel:By(D,N),onPointerEnter:j?void 0:f,onPointerMove:j?K:p,onPointerUp:j?z:void 0,onPointerDownCapture:j?M:void 0,onClickCapture:j?O:void 0,onPointerLeave:h,ref:N,style:tg,children:[y,i.jsx(P5,{})]})}function Bx({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",Ii.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 XI({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=wn(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=a4({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Bx({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.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 T5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function QI(){const e=wn();return m.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=T5(a),h=s?o[0]:5,y=s?o[1]:5,v=n.direction.x*h*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!p(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};s&&(k=pf(k,o));const{position:x,positionAbsolute:j}=hI({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:l});g.position=x,g.internals.positionAbsolute=j,f.set(g.id,g)}c(f)},[])}const Fk=m.createContext(null),M5=Fk.Provider;Fk.Consumer;const ZI=()=>m.useContext(Fk),$5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),L5=(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===_c.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 O5({type:e="source",position:t=qe.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},h){var K,z;const y=a||null,v=e==="target",b=wn(),g=ZI(),{connectOnClick:k,noPanClassName:x,rfId:j}=Ht($5,En),{connectingFrom:N,connectingTo:C,clickConnecting:I,isPossibleEndHandle:R,connectionInProcess:H,clickConnectionInProcess:A,valid:L}=Ht(L5(g,y,e),En);g||(z=(K=b.getState()).onError)==null||z.call(K,"010",Ii.error010());const D=F=>{const{defaultEdgeOptions:$,onConnect:W,hasDefaultEdges:E}=b.getState(),Q={...$,...F};if(E){const{edges:V,setEdges:B}=b.getState();B(fh(Q,V))}W==null||W(Q),l==null||l(Q)},O=F=>{if(!g)return;const $=vI(F.nativeEvent);if(s&&($&&F.button===0||!$)){const W=b.getState();Fx.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:v,handleId:y,nodeId:g,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...E)=>{var Q,V;return(V=(Q=b.getState()).onConnectEnd)==null?void 0:V.call(Q,...E)},updateConnection:W.updateConnection,onConnect:D,isValidConnection:n||((...E)=>{var Q,V;return((V=(Q=b.getState()).isValidConnection)==null?void 0:V.call(Q,...E))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}$?d==null||d(F):f==null||f(F)},M=F=>{const{onClickConnectStart:$,onClickConnectEnd:W,connectionClickStartHandle:E,connectionMode:Q,isValidConnection:V,lib:B,rfId:se,nodeLookup:ue,connection:G}=b.getState();if(!g||!E&&!s)return;if(!E){$==null||$(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ee=bI(F.target),te=n||V,{connection:ne,isValid:Z}=Fx.isValid(F.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:Q,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:te,flowId:se,doc:ee,lib:B,nodeLookup:ue});Z&&ne&&D(ne);const ce=structuredClone(G);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,W==null||W(F,ce),b.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${j}-${g}-${y}-${e}`,className:Xn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:I,connectingfrom:N,connectingto:C,valid:L,connectionindicator:r&&(!H||R)&&(H||A?o:s)}]),onMouseDown:O,onTouchStart:O,onClick:k?M:void 0,ref:h,...p,children:c})}const Jn=m.memo(GI(O5));function D5({data:e,isConnectable:t,sourcePosition:n=qe.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(Jn,{type:"source",position:n,isConnectable:t})]})}function F5({data:e,isConnectable:t,targetPosition:n=qe.Top,sourcePosition:r=qe.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(Jn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(Jn,{type:"source",position:r,isConnectable:t})]})}function z5(){return null}function B5({data:e,isConnectable:t,targetPosition:n=qe.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(Jn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const tm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},GN={input:D5,default:F5,output:B5,group:z5};function H5(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 W5=e=>{const{width:t,height:n,x:r,y:s}=ff(e.nodeLookup,{filter:o=>!!o.selected});return{width:Xs(t)?t:null,height:Xs(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 V5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=wn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Ht(W5,En),c=QI(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const d=!l&&s!==null&&o!==null;if(XI({nodeRef:u,disabled:!d}),!d)return null;const f=e?h=>{const y=r.getState().nodes.filter(v=>v.selected);e(h,y)}:void 0,p=h=>{Object.prototype.hasOwnProperty.call(tm,h.key)&&(h.preventDefault(),c({direction:tm[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:Xn(["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 JN=typeof window<"u"?window:void 0,K5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function eR({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:h,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:j,panOnScrollSpeed:N,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:R,defaultViewport:H,translateExtent:A,minZoom:L,maxZoom:D,preventScrolling:O,onSelectionContextMenu:M,noWheelClassName:K,noPanClassName:z,disableKeyboardA11y:F,onViewportChange:$,isControlledViewport:W}){const{nodesSelectionActive:E,userSelectionActive:Q}=Ht(K5,En),V=Bd(u,{target:JN}),B=Bd(v,{target:JN}),se=B||R,ue=B||j,G=d&&se!==!0,ee=V||Q||G;return N5({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(E5,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:ue,panOnScrollSpeed:N,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:!V&&se,defaultViewport:H,translateExtent:A,minZoom:L,maxZoom:D,zoomActivationKeyCode:b,preventScrolling:O,noWheelClassName:K,noPanClassName:z,onViewportChange:$,isControlledViewport:W,paneClickDistance:l,selectionOnDrag:G,children:i.jsxs(R5,{onSelectionStart:p,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:se,isSelecting:!!ee,selectionMode:f,selectionKeyPressed:V,paneClickDistance:l,selectionOnDrag:G,children:[e,E&&i.jsx(V5,{onSelectionContextMenu:M,noPanClassName:z,disableKeyboardA11y:F})]})})}eR.displayName="FlowRenderer";const q5=m.memo(eR),U5=e=>t=>e?Ik(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 Y5(e){return Ht(m.useCallback(U5(e),[e]),En)}const G5=e=>e.updateNodeInternals;function J5(){const e=Ht(G5),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const o=s.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:s.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function X5({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=wn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),d=n&&!!e.internals.handleBounds;return m.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]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const f=u.current!==t,p=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||p||h)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function Q5({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:h,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:j,isParent:N}=Ht(te=>{const ne=te.nodeLookup.get(e),Z=te.parentLookup.has(e);return{node:ne,internals:ne.internals,isParent:Z}},En);let C=x.type||"default",I=(b==null?void 0:b[C])||GN[C];I===void 0&&(k==null||k("003",Ii.error003(C)),C="default",I=(b==null?void 0:b.default)||GN.default);const R=!!(x.draggable||l&&typeof x.draggable>"u"),H=!!(x.selectable||c&&typeof x.selectable>"u"),A=!!(x.connectable||u&&typeof x.connectable>"u"),L=!!(x.focusable||d&&typeof x.focusable>"u"),D=wn(),O=wI(x),M=X5({node:x,nodeType:C,hasDimensions:O,resizeObserver:f}),K=XI({nodeRef:M,disabled:x.hidden||!R,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:H,nodeClickDistance:g}),z=QI();if(x.hidden)return null;const F=po(x),$=H5(x),W=H||R||t||n||r||s,E=n?te=>n(te,{...j.userNode}):void 0,Q=r?te=>r(te,{...j.userNode}):void 0,V=s?te=>s(te,{...j.userNode}):void 0,B=o?te=>o(te,{...j.userNode}):void 0,se=a?te=>a(te,{...j.userNode}):void 0,ue=te=>{const{selectNodesOnDrag:ne,nodeDragThreshold:Z}=D.getState();H&&(!ne||!R||Z>0)&&Bx({id:e,store:D,nodeRef:M}),t&&t(te,{...j.userNode})},G=te=>{if(!(kI(te.nativeEvent)||y)){if(cI.includes(te.key)&&H){const ne=te.key==="Escape";Bx({id:e,store:D,unselect:ne,nodeRef:M})}else if(R&&x.selected&&Object.prototype.hasOwnProperty.call(tm,te.key)){te.preventDefault();const{ariaLabelConfig:ne}=D.getState();D.setState({ariaLiveMessage:ne["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),z({direction:tm[te.key],factor:te.shiftKey?4:1})}}},ee=()=>{var $e;if(y||!(($e=M.current)!=null&&$e.matches(":focus-visible")))return;const{transform:te,width:ne,height:Z,autoPanOnNodeFocus:ce,setCenter:de}=D.getState();if(!ce)return;Ik(new Map([[e,x]]),{x:0,y:0,width:ne,height:Z},te,!0).length>0||de(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:te[2]})};return i.jsx("div",{className:Xn(["react-flow__node",`react-flow__node-${C}`,{[h]:R},x.className,{selected:x.selected,selectable:H,parent:N,draggable:R,dragging:K}]),ref:M,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:O?"visible":"hidden",...x.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:Q,onMouseLeave:V,onContextMenu:B,onClick:ue,onDoubleClick:se,onKeyDown:L?G:void 0,tabIndex:L?0:void 0,onFocus:L?ee:void 0,role:x.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${KI}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:i.jsx(M5,{value:e,children:i.jsx(I,{id:e,data:x.data,type:C,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:x.selected??!1,selectable:H,draggable:R,deletable:x.deletable??!0,isConnectable:A,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:K,dragHandle:x.dragHandle,zIndex:j.z,parentId:x.parentId,...F})})})}var Z5=m.memo(Q5);const eW=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function tR(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Ht(eW,En),a=Y5(e.onlyRenderVisibleElements),l=J5();return i.jsx("div",{className:"react-flow__nodes",style:tg,children:a.map(c=>i.jsx(Z5,{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))})}tR.displayName="NodeRenderer";const tW=m.memo(tR);function nW(e){return Ht(m.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const o=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);o&&a&&WH({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),En)}const rW=({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"})},sW=({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"})},XN={[bi.Arrow]:rW,[bi.ArrowClosed]:sW};function iW(e){const t=wn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(XN,e)?XN[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Ii.error009(e)),null)},[e])}const oW=({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=iW(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},nR=({defaultColor:e,rfId:t})=>{const n=Ht(o=>o.edges),r=Ht(o=>o.defaultEdgeOptions),s=m.useMemo(()=>JH(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(oW,{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};nR.displayName="MarkerDefinitions";var aW=m.memo(nR);function rR({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]=m.useState({x:1,y:0,width:0,height:0}),h=Xn(["react-flow__edge-textwrapper",u]),y=m.useRef(null);return m.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:h,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}rR.displayName="EdgeText";const lW=m.memo(rR);function ng({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:Xn(["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&&Xs(t)&&Xs(n)?i.jsx(lW,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function QN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===qe.Left||e===qe.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function sR({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top}){const[a,l]=QN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=QN({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,f,p,h]=SI({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,h]}function iR(e){return m.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:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,j]=sR({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),N=e.isInternal?void 0:t;return i.jsx(ng,{id:N,path:k,labelX:x,labelY:j,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const cW=iR({isInternal:!1}),oR=iR({isInternal:!0});cW.displayName="SimpleBezierEdge";oR.displayName="SimpleBezierEdgeInternal";function aR(e){return m.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:h=qe.Bottom,targetPosition:y=qe.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,j,N]=Lx({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:o,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),C=e.isInternal?void 0:t;return i.jsx(ng,{id:C,path:x,labelX:j,labelY:N,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:v,markerStart:b,interactionWidth:k})})}const lR=aR({isInternal:!1}),cR=aR({isInternal:!0});lR.displayName="SmoothStepEdge";cR.displayName="SmoothStepEdgeInternal";function uR(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(lR,{...n,id:r,pathOptions:m.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const uW=uR({isInternal:!1}),dR=uR({isInternal:!0});uW.displayName="StepEdge";dR.displayName="StepEdgeInternal";function fR(e){return m.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:h,markerStart:y,interactionWidth:v})=>{const[b,g,k]=CI({sourceX:n,sourceY:r,targetX:s,targetY:o}),x=e.isInternal?void 0:t;return i.jsx(ng,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:y,interactionWidth:v})})}const dW=fR({isInternal:!1}),pR=fR({isInternal:!0});dW.displayName="StraightEdge";pR.displayName="StraightEdgeInternal";function hR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:a=qe.Bottom,targetPosition:l=qe.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,j,N]=jI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),C=e.isInternal?void 0:t;return i.jsx(ng,{id:C,path:x,labelX:j,labelY:N,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const fW=hR({isInternal:!1}),mR=hR({isInternal:!0});fW.displayName="BezierEdge";mR.displayName="BezierEdgeInternal";const ZN={default:mR,straight:pR,step:dR,smoothstep:cR,simplebezier:oR},e1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},pW=(e,t,n)=>n===qe.Left?e-t:n===qe.Right?e+t:e,hW=(e,t,n)=>n===qe.Top?e-t:n===qe.Bottom?e+t:e,t1="react-flow__edgeupdater";function n1({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:Xn([t1,`${t1}-${l}`]),cx:pW(t,r,e),cy:hW(n,r,e),r,stroke:"transparent",fill:"transparent"})}function mW({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:h}){const y=wn(),v=(j,N)=>{if(j.button!==0)return;const{autoPanOnConnect:C,domNode:I,connectionMode:R,connectionRadius:H,lib:A,onConnectStart:L,cancelConnection:D,nodeLookup:O,rfId:M,panBy:K,updateConnection:z}=y.getState(),F=N.type==="target",$=(Q,V)=>{p(!1),f==null||f(Q,n,N.type,V)},W=Q=>u==null?void 0:u(n,Q),E=(Q,V)=>{p(!0),d==null||d(j,n,N.type),L==null||L(Q,V)};Fx.onPointerDown(j.nativeEvent,{autoPanOnConnect:C,connectionMode:R,connectionRadius:H,domNode:I,handleId:N.id,nodeId:N.nodeId,nodeLookup:O,isTarget:F,edgeUpdaterType:N.type,lib:A,flowId:M,cancelConnection:D,panBy:K,isValidConnection:(...Q)=>{var V,B;return((B=(V=y.getState()).isValidConnection)==null?void 0:B.call(V,...Q))??!0},onConnect:W,onConnectStart:E,onConnectEnd:(...Q)=>{var V,B;return(B=(V=y.getState()).onConnectEnd)==null?void 0:B.call(V,...Q)},onReconnectEnd:$,updateConnection:z,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},b=j=>v(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=j=>v(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>h(!0),x=()=>h(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(n1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&i.jsx(n1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function gW({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:h,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Ht(de=>de.edgeLookup.get(e));const j=Ht(de=>de.defaultEdgeOptions);x=j?{...j,...x}:x;let N=x.type||"default",C=(v==null?void 0:v[N])||ZN[N];C===void 0&&(g==null||g("011",Ii.error011(N)),N="default",C=(v==null?void 0:v.default)||ZN.default);const I=!!(x.focusable||t&&typeof x.focusable>"u"),R=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),H=!!(x.selectable||r&&typeof x.selectable>"u"),A=m.useRef(null),[L,D]=m.useState(!1),[O,M]=m.useState(!1),K=wn(),{zIndex:z,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V}=Ht(m.useCallback(de=>{const me=de.nodeLookup.get(x.source),$e=de.nodeLookup.get(x.target);if(!me||!$e)return{zIndex:x.zIndex,...e1};const Ce=GH({id:e,sourceNode:me,targetNode:$e,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:HH({selected:x.selected,zIndex:x.zIndex,sourceNode:me,targetNode:$e,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Ce||e1}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),En),B=m.useMemo(()=>x.markerStart?`url('#${Ox(x.markerStart,y)}')`:void 0,[x.markerStart,y]),se=m.useMemo(()=>x.markerEnd?`url('#${Ox(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||$===null||W===null||E===null)return null;const ue=de=>{var _e;const{addSelectedEdges:me,unselectNodesAndEdges:$e,multiSelectionActive:Ce}=K.getState();H&&(K.setState({nodesSelectionActive:!1}),x.selected&&Ce?($e({nodes:[],edges:[x]}),(_e=A.current)==null||_e.blur()):me([e])),s&&s(de,x)},G=o?de=>{o(de,{...x})}:void 0,ee=a?de=>{a(de,{...x})}:void 0,te=l?de=>{l(de,{...x})}:void 0,ne=c?de=>{c(de,{...x})}:void 0,Z=u?de=>{u(de,{...x})}:void 0,ce=de=>{var me;if(!k&&cI.includes(de.key)&&H){const{unselectNodesAndEdges:$e,addSelectedEdges:Ce}=K.getState();de.key==="Escape"?((me=A.current)==null||me.blur(),$e({edges:[x]})):Ce([e])}};return i.jsx("svg",{style:{zIndex:z},children:i.jsxs("g",{className:Xn(["react-flow__edge",`react-flow__edge-${N}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!H&&!s,updating:L,selectable:H}]),onClick:ue,onDoubleClick:G,onContextMenu:ee,onMouseEnter:te,onMouseMove:ne,onMouseLeave:Z,onKeyDown:I?ce:void 0,tabIndex:I?0:void 0,role:x.ariaRole??(I?"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":I?`${qI}-${y}`:void 0,ref:A,...x.domAttributes,children:[!O&&i.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:H,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:W,targetY:E,sourcePosition:Q,targetPosition:V,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:B,markerEnd:se,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),R&&i.jsx(mW,{edge:x,isReconnectable:R,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,setUpdateHover:D,setReconnecting:M})]})})}var yW=m.memo(gW);const wW=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function gR({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:h,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Ht(wW,En),j=nW(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(aW,{defaultColor:e,rfId:n}),j.map(N=>i.jsx(yW,{id:N,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:h,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},N))]})}gR.displayName="EdgeRenderer";const xW=m.memo(gR),bW=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function kW({children:e}){const t=Ht(bW);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function vW(e){const t=zc(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const SW=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function jW(e){const t=Ht(SW),n=wn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function NW(e){return e.connection.inProgress?{...e.connection,to:hf(e.connection.to,e.transform)}:{...e.connection}}function CW(e){return NW}function _W(e){const t=CW();return Ht(t,En)}const EW=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function AW({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Ht(EW,En);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:Xn(["react-flow__connection",fI(l)]),children:i.jsx(yR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const yR=({style:e,type:t=$o.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:h}=_W();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:fI(r),toNode:d,toHandle:f,pointer:h});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:p};switch(t){case $o.Bezier:[y]=jI(v);break;case $o.SimpleBezier:[y]=sR(v);break;case $o.Step:[y]=Lx({...v,borderRadius:0});break;case $o.SmoothStep:[y]=Lx(v);break;default:[y]=CI(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};yR.displayName="ConnectionLine";const PW={};function r1(e=PW){m.useRef(e),wn(),m.useEffect(()=>{},[e])}function IW(){wn(),m.useRef(!1),m.useEffect(()=>{},[])}function wR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:h,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:j,multiSelectionKeyCode:N,panActivationKeyCode:C,zoomActivationKeyCode:I,deleteKeyCode:R,onlyRenderVisibleElements:H,elementsSelectable:A,defaultViewport:L,translateExtent:D,minZoom:O,maxZoom:M,preventScrolling:K,defaultMarkerColor:z,zoomOnScroll:F,zoomOnPinch:$,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,zoomOnDoubleClick:V,panOnDrag:B,onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:ee,onPaneScroll:te,onPaneContextMenu:ne,paneClickDistance:Z,nodeClickDistance:ce,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:$e,onEdgeMouseLeave:Ce,reconnectRadius:_e,onReconnect:Be,onReconnectStart:ot,onReconnectEnd:gt,noDragClassName:Te,noWheelClassName:st,noPanClassName:mt,disableKeyboardA11y:Rt,nodeExtent:xe,rfId:Oe,viewport:ie,onViewportChange:ke}){return r1(e),r1(t),IW(),vW(n),jW(ie),i.jsx(q5,{onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:ee,onPaneContextMenu:ne,onPaneScroll:te,paneClickDistance:Z,deleteKeyCode:R,selectionKeyCode:k,selectionOnDrag:x,selectionMode:j,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:C,zoomActivationKeyCode:I,elementsSelectable:A,zoomOnScroll:F,zoomOnPinch:$,zoomOnDoubleClick:V,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,panOnDrag:B,defaultViewport:L,translateExtent:D,minZoom:O,maxZoom:M,onSelectionContextMenu:f,preventScrolling:K,noDragClassName:Te,noWheelClassName:st,noPanClassName:mt,disableKeyboardA11y:Rt,onViewportChange:ke,isControlledViewport:!!ie,children:i.jsxs(kW,{children:[i.jsx(xW,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:Be,onReconnectStart:ot,onReconnectEnd:gt,onlyRenderVisibleElements:H,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:$e,onEdgeMouseLeave:Ce,reconnectRadius:_e,defaultMarkerColor:z,noPanClassName:mt,disableKeyboardA11y:Rt,rfId:Oe}),i.jsx(AW,{style:v,type:y,component:b,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(tW,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:ce,onlyRenderVisibleElements:H,noPanClassName:mt,noDragClassName:Te,disableKeyboardA11y:Rt,nodeExtent:xe,rfId:Oe}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}wR.displayName="GraphView";const RW=m.memo(wR),s1=({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 h=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=d??[0,0],j=f??Od;AI(v,b,g);const{nodesInitialized:N}=Dx(k,h,y,{nodeOrigin:x,nodeExtent:j,zIndexMode:p});let C=[0,0,1];if(a&&s&&o){const I=ff(h,{filter:L=>!!((L.width||L.initialWidth)&&(L.height||L.initialHeight))}),{x:R,y:H,zoom:A}=Rk(I,s,o,c,u,(l==null?void 0:l.padding)??.1);C=[R,H,A]}return{rfId:"1",width:s??0,height:o??0,transform:C,nodes:k,nodesInitialized:N,nodeLookup:h,parentLookup:y,edges:g,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:Od,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:_c.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:{...dI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:LH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:uI,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},TW=({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})=>Q4((h,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:j,height:N,minZoom:C,maxZoom:I}=y();g&&(await MH({nodes:b,width:j,height:N,panZoom:g,minZoom:C,maxZoom:I},k),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...s1({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:j,fitViewQueued:N,zIndexMode:C,nodesSelectionActive:I}=y(),{nodesInitialized:R,hasSelectedNodes:H}=Dx(b,g,k,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:C}),A=I&&H;N&&R?(v(),h({nodes:b,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:A})):h({nodes:b,nodesInitialized:R,nodesSelectionActive:A})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();AI(g,k,b),h({edges:b})},setDefaultNodesAndEdges:(b,g)=>{if(b){const{setNodes:k}=y();k(b),h({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),h({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:x,domNode:j,nodeOrigin:N,nodeExtent:C,debug:I,fitViewQueued:R,zIndexMode:H}=y(),{changes:A,updatedInternals:L}=r4(b,k,x,j,N,C,H);L&&(ZH(k,x,{nodeOrigin:N,nodeExtent:C,zIndexMode:H}),R?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(A==null?void 0:A.length)>0&&(I&&console.log("React Flow: trigger node changes",A),g==null||g(A)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:j,triggerNodeChanges:N,connection:C,updateConnection:I,onNodesChangeMiddlewareMap:R}=y();for(const[H,A]of b){const L=j.get(H),D=!!(L!=null&&L.expandParent&&(L!=null&&L.parentId)&&(A!=null&&A.position)),O={id:H,type:"position",position:D?{x:Math.max(0,A.position.x),y:Math.max(0,A.position.y)}:A.position,dragging:g};if(L&&C.inProgress&&C.fromNode.id===L.id){const M=Xa(L,C.fromHandle,qe.Left,!0);I({...C,from:M})}D&&L.parentId&&k.push({id:H,parentId:L.parentId,rect:{...A.internals.positionAbsolute,width:A.measured.width??0,height:A.measured.height??0}}),x.push(O)}if(k.length>0){const{parentLookup:H,nodeOrigin:A}=y(),L=Dk(k,j,H,A);x.push(...L)}for(const H of R.values())x=H(x);N(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:j,debug:N}=y();if(b!=null&&b.length){if(j){const C=ld(b,x);k(C)}N&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:j,debug:N}=y();if(b!=null&&b.length){if(j){const C=em(b,x);k(C)}N&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:j,triggerEdgeChanges:N}=y();if(g){const C=b.map(I=>Na(I,!0));j(C);return}j(tc(x,new Set([...b]),!0)),N(tc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:j,triggerEdgeChanges:N}=y();if(g){const C=b.map(I=>Na(I,!0));N(C);return}N(tc(k,new Set([...b]))),j(tc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:j,triggerNodeChanges:N,triggerEdgeChanges:C}=y(),I=b||x,R=g||k,H=[];for(const L of I){if(!L.selected)continue;const D=j.get(L.id);D&&(D.selected=!1),H.push(Na(L.id,!1))}const A=[];for(const L of R)L.selected&&A.push(Na(L.id,!1));N(H),C(A)},setMinZoom:b=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([b,k]),h({minZoom:b})},setMaxZoom:b=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,b]),h({maxZoom:b})},setTranslateExtent:b=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(b),h({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:x,elementsSelectable:j}=y();if(!j)return;const N=g.reduce((I,R)=>R.selected?[...I,Na(R.id,!1)]:I,[]),C=b.reduce((I,R)=>R.selected?[...I,Na(R.id,!1)]:I,[]);k(N),x(C)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:j,elevateNodesOnSelect:N,nodeExtent:C,zIndexMode:I}=y();b[0][0]===C[0][0]&&b[0][1]===C[0][1]&&b[1][0]===C[1][0]&&b[1][1]===C[1][1]||(Dx(g,k,x,{nodeOrigin:j,nodeExtent:b,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:I}),h({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:j,translateExtent:N}=y();return s4({delta:b,panZoom:j,transform:g,translateExtent:N,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:j,maxZoom:N,panZoom:C}=y();if(!C)return Promise.resolve(!1);const I=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:N;return await C.setViewport({x:x/2-b*I,y:j/2-g*I,zoom:I},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...dI}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...s1()})}},Object.is);function zk({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:h}){const[y]=m.useState(()=>TW({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(Z4,{value:y,children:i.jsx(k5,{children:h})})}function MW({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:h}){return m.useContext(Zm)?i.jsx(i.Fragment,{children:e}):i.jsx(zk,{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:h,children:e})}const $W={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function LW({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:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:j,onNodeContextMenu:N,onNodeDoubleClick:C,onNodeDragStart:I,onNodeDrag:R,onNodeDragStop:H,onNodesDelete:A,onEdgesDelete:L,onDelete:D,onSelectionChange:O,onSelectionDragStart:M,onSelectionDrag:K,onSelectionDragStop:z,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:W,onBeforeDelete:E,connectionMode:Q,connectionLineType:V=$o.Bezier,connectionLineStyle:B,connectionLineComponent:se,connectionLineContainerStyle:ue,deleteKeyCode:G="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:te=!1,selectionMode:ne=Dd.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:ce=zd()?"Meta":"Control",zoomActivationKeyCode:de=zd()?"Meta":"Control",snapToGrid:me,snapGrid:$e,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:_e,nodesDraggable:Be,autoPanOnNodeFocus:ot,nodesConnectable:gt,nodesFocusable:Te,nodeOrigin:st=UI,edgesFocusable:mt,edgesReconnectable:Rt,elementsSelectable:xe=!0,defaultViewport:Oe=f5,minZoom:ie=.5,maxZoom:ke=2,translateExtent:Ke=Od,preventScrolling:Ue=!0,nodeExtent:be,defaultMarkerColor:Pt="#b1b1b7",zoomOnScroll:tn=!0,zoomOnPinch:Wt=!0,panOnScroll:Lt=!1,panOnScrollSpeed:an=.5,panOnScrollMode:re=za.Free,zoomOnDoubleClick:Re=!0,panOnDrag:Je=!0,onPaneClick:Ze,onPaneMouseEnter:Tt,onPaneMouseMove:_t,onPaneMouseLeave:Kn,onPaneScroll:jn,onPaneContextMenu:br,paneClickDistance:xn=1,nodeClickDistance:Qn=0,children:qn,onReconnect:mr,onReconnectStart:ts,onReconnectEnd:Pr,onEdgeContextMenu:gs,onEdgeDoubleClick:ys,onEdgeMouseEnter:dn,onEdgeMouseMove:sr,onEdgeMouseLeave:Ir,reconnectRadius:pn=10,onNodesChange:Zn,onEdgesChange:kr,noDragClassName:ir="nodrag",noWheelClassName:jt="nowheel",noPanClassName:Jt="nopan",fitView:Nt,fitViewOptions:le,connectOnClick:ve,attributionPosition:it,proOptions:Ft,defaultEdgeOptions:Xt,elevateNodesOnSelect:nn=!0,elevateEdgesOnSelect:er=!1,disableKeyboardA11y:ht=!1,autoPanOnConnect:rn,autoPanOnNodeDrag:Vt,autoPanSpeed:vr,connectionRadius:tt,isValidConnection:On,onError:$i,style:Br,id:go,nodeDragThreshold:ai,connectionDragThreshold:Ms,viewport:oe,onViewportChange:Se,width:Pe,height:wt,colorMode:Ot="light",debug:Ut,onScroll:Bn,ariaLabelConfig:Dn,zIndexMode:q="basic",...he},De){const Ee=go||"1",et=g5(Ot),Nn=m.useCallback(bt=>{bt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bn==null||Bn(bt)},[Bn]);return i.jsx("div",{"data-testid":"rf__wrapper",...he,onScroll:Nn,style:{...Br,...$W},ref:De,className:Xn(["react-flow",s,et]),id:go,role:"application",children:i.jsxs(MW,{nodes:e,edges:t,width:Pe,height:wt,fitView:Nt,fitViewOptions:le,minZoom:ie,maxZoom:ke,nodeOrigin:st,nodeExtent:be,zIndexMode:q,children:[i.jsx(m5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:Be,autoPanOnNodeFocus:ot,nodesConnectable:gt,nodesFocusable:Te,edgesFocusable:mt,edgesReconnectable:Rt,elementsSelectable:xe,elevateNodesOnSelect:nn,elevateEdgesOnSelect:er,minZoom:ie,maxZoom:ke,nodeExtent:be,onNodesChange:Zn,onEdgesChange:kr,snapToGrid:me,snapGrid:$e,connectionMode:Q,translateExtent:Ke,connectOnClick:ve,defaultEdgeOptions:Xt,fitView:Nt,fitViewOptions:le,onNodesDelete:A,onEdgesDelete:L,onDelete:D,onNodeDragStart:I,onNodeDrag:R,onNodeDragStop:H,onSelectionDrag:K,onSelectionDragStart:M,onSelectionDragStop:z,onMove:d,onMoveStart:f,onMoveEnd:p,noPanClassName:Jt,nodeOrigin:st,rfId:Ee,autoPanOnConnect:rn,autoPanOnNodeDrag:Vt,autoPanSpeed:vr,onError:$i,connectionRadius:tt,isValidConnection:On,selectNodesOnDrag:_e,nodeDragThreshold:ai,connectionDragThreshold:Ms,onBeforeDelete:E,debug:Ut,ariaLabelConfig:Dn,zIndexMode:q}),i.jsx(RW,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:j,onNodeContextMenu:N,onNodeDoubleClick:C,nodeTypes:o,edgeTypes:a,connectionLineType:V,connectionLineStyle:B,connectionLineComponent:se,connectionLineContainerStyle:ue,selectionKeyCode:ee,selectionOnDrag:te,selectionMode:ne,deleteKeyCode:G,multiSelectionKeyCode:ce,panActivationKeyCode:Z,zoomActivationKeyCode:de,onlyRenderVisibleElements:Ce,defaultViewport:Oe,translateExtent:Ke,minZoom:ie,maxZoom:ke,preventScrolling:Ue,zoomOnScroll:tn,zoomOnPinch:Wt,zoomOnDoubleClick:Re,panOnScroll:Lt,panOnScrollSpeed:an,panOnScrollMode:re,panOnDrag:Je,onPaneClick:Ze,onPaneMouseEnter:Tt,onPaneMouseMove:_t,onPaneMouseLeave:Kn,onPaneScroll:jn,onPaneContextMenu:br,paneClickDistance:xn,nodeClickDistance:Qn,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:W,onReconnect:mr,onReconnectStart:ts,onReconnectEnd:Pr,onEdgeContextMenu:gs,onEdgeDoubleClick:ys,onEdgeMouseEnter:dn,onEdgeMouseMove:sr,onEdgeMouseLeave:Ir,reconnectRadius:pn,defaultMarkerColor:Pt,noDragClassName:ir,noWheelClassName:jt,noPanClassName:Jt,rfId:Ee,disableKeyboardA11y:ht,nodeExtent:be,viewport:oe,onViewportChange:Se}),i.jsx(d5,{onSelectionChange:O}),qn,i.jsx(o5,{proOptions:Ft,position:it}),i.jsx(i5,{rfId:Ee,disableKeyboardA11y:ht})]})})}var xR=GI(LW);function OW(){const e=wn();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],o=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function DW(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>ld(s,o)),[]);return[t,n,r]}function FW(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>em(s,o)),[]);return[t,n,r]}function zW({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:Xn(["react-flow__background-pattern",n,r])})}function BW({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Xn(["react-flow__background-pattern","dots",t])})}var Go;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Go||(Go={}));const HW={[Go.Dots]:1,[Go.Lines]:1,[Go.Cross]:6},WW=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function bR({id:e,variant:t=Go.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:d}){const f=m.useRef(null),{transform:p,patternId:h}=Ht(WW,En),y=r||HW[t],v=t===Go.Dots,b=t===Go.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*p[2]||1,g[1]*p[2]||1],x=y*p[2],j=Array.isArray(o)?o:[o,o],N=b?[x,x]:k,C=[j[0]*p[2]||1+N[0]/2,j[1]*p[2]||1+N[1]/2],I=`${h}${e||""}`;return i.jsxs("svg",{className:Xn(["react-flow__background",u]),style:{...c,...tg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i.jsx("pattern",{id:I,x:p[0]%k[0],y:p[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:v?i.jsx(BW,{radius:x/2,className:d}):i.jsx(zW,{dimensions:N,lineWidth:s,variant:t,className:d})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}bR.displayName="Background";const kR=m.memo(bR);function VW(){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 KW(){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 qW(){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 UW(){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 YW(){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 Ep({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Xn(["react-flow__controls-button",t]),...n,children:e})}const GW=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function vR({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":h}){const y=wn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Ht(GW,En),{zoomIn:x,zoomOut:j,fitView:N}=zc(),C=()=>{x(),o==null||o()},I=()=>{j(),a==null||a()},R=()=>{N(s),l==null||l()},H=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},A=p==="horizontal"?"horizontal":"vertical";return i.jsxs(eg,{className:Xn(["react-flow__controls",A,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Ep,{onClick:C,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(VW,{})}),i.jsx(Ep,{onClick:I,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:i.jsx(KW,{})})]}),n&&i.jsx(Ep,{className:"react-flow__controls-fitview",onClick:R,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(qW,{})}),r&&i.jsx(Ep,{className:"react-flow__controls-interactive",onClick:H,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(YW,{}):i.jsx(UW,{})}),d]})}vR.displayName="Controls";m.memo(vR);function JW({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:h}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return i.jsx("rect",{className:Xn(["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:h?g=>h(g,e):void 0})}const XW=m.memo(JW),QW=e=>e.nodes.map(t=>t.id),Hy=e=>e instanceof Function?e:()=>e;function ZW({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=XW,onClick:a}){const l=Ht(QW,En),c=Hy(t),u=Hy(e),d=Hy(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(p=>i.jsx(t6,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:f},p))})}function e6({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:h}=Ht(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:j}=po(b);return{node:b,x:g,y:k,width:x,height:j}},En);return!u||u.hidden||!wI(u)?null:i.jsx(l,{x:d,y:f,width:p,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:o,shapeRendering:a,onClick:c,id:u.id})}const t6=m.memo(e6);var n6=m.memo(ZW);const r6=200,s6=150,i6=e=>!e.hidden,o6=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?yI(ff(e.nodeLookup,{filter:i6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},a6="react-flow__minimap-desc";function SR({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:h,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:j=5}){const N=wn(),C=m.useRef(null),{boundingRect:I,viewBB:R,rfId:H,panZoom:A,translateExtent:L,flowWidth:D,flowHeight:O,ariaLabelConfig:M}=Ht(o6,En),K=(e==null?void 0:e.width)??r6,z=(e==null?void 0:e.height)??s6,F=I.width/K,$=I.height/z,W=Math.max(F,$),E=W*K,Q=W*z,V=j*W,B=I.x-(E-I.width)/2-V,se=I.y-(Q-I.height)/2-V,ue=E+V*2,G=Q+V*2,ee=`${a6}-${H}`,te=m.useRef(0),ne=m.useRef();te.current=W,m.useEffect(()=>{if(C.current&&A)return ne.current=p4({domNode:C.current,panZoom:A,getTransform:()=>N.getState().transform,getViewScale:()=>te.current}),()=>{var me;(me=ne.current)==null||me.destroy()}},[A]),m.useEffect(()=>{var me;(me=ne.current)==null||me.update({translateExtent:L,width:D,height:O,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,L,D,O]);const Z=h?me=>{var _e;const[$e,Ce]=((_e=ne.current)==null?void 0:_e.pointer(me))||[0,0];h(me,{x:$e,y:Ce})}:void 0,ce=y?m.useCallback((me,$e)=>{const Ce=N.getState().nodeLookup.get($e).internals.userNode;y(me,Ce)},[]):void 0,de=g??M["minimap.ariaLabel"];return i.jsx(eg,{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*W: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:Xn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:K,height:z,viewBox:`${B} ${se} ${ue} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:C,onClick:Z,children:[de&&i.jsx("title",{id:ee,children:de}),i.jsx(n6,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),i.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-V},${se-V}h${ue+V*2}v${G+V*2}h${-ue-V*2}z
66
+ M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}SR.displayName="MiniMap";m.memo(SR);const l6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,c6={[Ic.Line]:"right",[Ic.Handle]:"bottom-right"};function u6({nodeId:e,position:t,variant:n=Ic.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:h=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=ZI(),x=typeof e=="string"?e:k,j=wn(),N=m.useRef(null),C=n===Ic.Handle,I=Ht(m.useCallback(l6(C&&h),[C,h]),En),R=m.useRef(null),H=t??c6[n];m.useEffect(()=>{if(!(!N.current||!x))return R.current||(R.current=_4({domNode:N.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:L,transform:D,snapGrid:O,snapToGrid:M,nodeOrigin:K,domNode:z}=j.getState();return{nodeLookup:L,transform:D,snapGrid:O,snapToGrid:M,nodeOrigin:K,paneDomNode:z}},onChange:(L,D)=>{const{triggerNodeChanges:O,nodeLookup:M,parentLookup:K,nodeOrigin:z}=j.getState(),F=[],$={x:L.x,y:L.y},W=M.get(x);if(W&&W.expandParent&&W.parentId){const E=W.origin??z,Q=L.width??W.measured.width??0,V=L.height??W.measured.height??0,B={id:W.id,parentId:W.parentId,rect:{width:Q,height:V,...xI({x:L.x??W.position.x,y:L.y??W.position.y},{width:Q,height:V},W.parentId,M,E)}},se=Dk([B],M,K,z);F.push(...se),$.x=L.x?Math.max(E[0]*Q,L.x):void 0,$.y=L.y?Math.max(E[1]*V,L.y):void 0}if($.x!==void 0&&$.y!==void 0){const E={id:x,type:"position",position:{...$}};F.push(E)}if(L.width!==void 0&&L.height!==void 0){const Q={id:x,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:L.width,height:L.height}};F.push(Q)}for(const E of D){const Q={...E,type:"position"};F.push(Q)}O(F)},onEnd:({width:L,height:D})=>{const O={id:x,type:"dimensions",resizing:!1,dimensions:{width:L,height:D}};j.getState().triggerNodeChanges([O])}})),R.current.update({controlPosition:H,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var L;(L=R.current)==null||L.destroy()}},[H,l,c,u,d,f,v,b,g,y]);const A=H.split("-");return i.jsx("div",{className:Xn(["react-flow__resize-control","nodrag",...A,n,r]),ref:N,style:{...s,scale:I,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:o})}const Bk=m.memo(u6),d6="modulepreload",f6=function(e){return"/"+e},i1={},p6=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 i1)return;i1[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,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function h6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const m6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,g6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,y6={};function o1(e,t){return(y6.jsx?g6:m6).test(e)}const w6=/[ \t\n\f\r]/g;function x6(e){return typeof e=="object"?e.type==="text"?a1(e.value):!1:a1(e)}function a1(e){return e.replace(w6,"")===""}class mf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}mf.prototype.normal={};mf.prototype.property={};mf.prototype.space=void 0;function jR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new mf(n,r,t)}function Hx(e){return e.toLowerCase()}class es{constructor(t,n){this.attribute=n,this.property=t}}es.prototype.attribute="";es.prototype.booleanish=!1;es.prototype.boolean=!1;es.prototype.commaOrSpaceSeparated=!1;es.prototype.commaSeparated=!1;es.prototype.defined=!1;es.prototype.mustUseProperty=!1;es.prototype.number=!1;es.prototype.overloadedBoolean=!1;es.prototype.property="";es.prototype.spaceSeparated=!1;es.prototype.space=void 0;let b6=0;const vt=al(),Yn=al(),Wx=al(),Ie=al(),mn=al(),fc=al(),ss=al();function al(){return 2**++b6}const Vx=Object.freeze(Object.defineProperty({__proto__:null,boolean:vt,booleanish:Yn,commaOrSpaceSeparated:ss,commaSeparated:fc,number:Ie,overloadedBoolean:Wx,spaceSeparated:mn},Symbol.toStringTag,{value:"Module"})),Wy=Object.keys(Vx);class Hk extends es{constructor(t,n,r,s){let o=-1;if(super(t,n),l1(this,"space",s),typeof r=="number")for(;++o<Wy.length;){const a=Wy[o];l1(this,Wy[o],(r&Vx[a])===Vx[a])}}}Hk.prototype.defined=!0;function l1(e,t,n){n&&(e[t]=n)}function Bc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new Hk(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Hx(r)]=r,n[Hx(o.attribute)]=r}return new mf(t,n,e.space)}const NR=Bc({properties:{ariaActiveDescendant:null,ariaAtomic:Yn,ariaAutoComplete:null,ariaBusy:Yn,ariaChecked:Yn,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:mn,ariaCurrent:null,ariaDescribedBy:mn,ariaDetails:null,ariaDisabled:Yn,ariaDropEffect:mn,ariaErrorMessage:null,ariaExpanded:Yn,ariaFlowTo:mn,ariaGrabbed:Yn,ariaHasPopup:null,ariaHidden:Yn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:mn,ariaLevel:Ie,ariaLive:null,ariaModal:Yn,ariaMultiLine:Yn,ariaMultiSelectable:Yn,ariaOrientation:null,ariaOwns:mn,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Yn,ariaReadOnly:Yn,ariaRelevant:null,ariaRequired:Yn,ariaRoleDescription:mn,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Yn,ariaSetSize:Ie,ariaSort:null,ariaValueMax:Ie,ariaValueMin:Ie,ariaValueNow:Ie,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function CR(e,t){return t in e?e[t]:t}function _R(e,t){return CR(e,t.toLowerCase())}const k6=Bc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:fc,acceptCharset:mn,accessKey:mn,action:null,allow:null,allowFullScreen:vt,allowPaymentRequest:vt,allowUserMedia:vt,alt:null,as:null,async:vt,autoCapitalize:null,autoComplete:mn,autoFocus:vt,autoPlay:vt,blocking:mn,capture:null,charSet:null,checked:vt,cite:null,className:mn,cols:Ie,colSpan:null,content:null,contentEditable:Yn,controls:vt,controlsList:mn,coords:Ie|fc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:vt,defer:vt,dir:null,dirName:null,disabled:vt,download:Wx,draggable:Yn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:vt,formTarget:null,headers:mn,height:Ie,hidden:Wx,high:Ie,href:null,hrefLang:null,htmlFor:mn,httpEquiv:mn,id:null,imageSizes:null,imageSrcSet:null,inert:vt,inputMode:null,integrity:null,is:null,isMap:vt,itemId:null,itemProp:mn,itemRef:mn,itemScope:vt,itemType:mn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:vt,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:vt,muted:vt,name:null,nonce:null,noModule:vt,noValidate:vt,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:vt,optimum:Ie,pattern:null,ping:mn,placeholder:null,playsInline:vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:vt,referrerPolicy:null,rel:mn,required:vt,reversed:vt,rows:Ie,rowSpan:Ie,sandbox:mn,scope:null,scoped:vt,seamless:vt,selected:vt,shadowRootClonable:vt,shadowRootDelegatesFocus:vt,shadowRootMode:null,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Yn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ie,step:null,style:null,tabIndex:Ie,target:null,title:null,translate:null,type:null,typeMustMatch:vt,useMap:null,value:Yn,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:mn,axis:null,background:null,bgColor:null,border:Ie,borderColor:null,bottomMargin:Ie,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:vt,declare:vt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:vt,noHref:vt,noShade:vt,noWrap:vt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Yn,standby:null,summary:null,text:null,topMargin:Ie,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ie,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:vt,disableRemotePlayback:vt,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:_R}),v6=Bc({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:ss,accentHeight:Ie,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ie,amplitude:Ie,arabicForm:null,ascent:Ie,attributeName:null,attributeType:null,azimuth:Ie,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ie,by:null,calcMode:null,capHeight:Ie,className:mn,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:Ie,diffuseConstant:Ie,direction:null,display:null,dur:null,divisor:Ie,dominantBaseline:null,download:vt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ie,enableBackground:null,end:null,event:null,exponent:Ie,externalResourcesRequired:null,fill:null,fillOpacity:Ie,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:fc,g2:fc,glyphName:fc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ie,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ie,horizOriginX:Ie,horizOriginY:Ie,id:null,ideographic:Ie,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ie,k:Ie,k1:Ie,k2:Ie,k3:Ie,k4:Ie,kernelMatrix:ss,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ie,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:Ie,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:Ie,overlineThickness:Ie,paintOrder:null,panose1:null,path:null,pathLength:Ie,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:mn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ie,pointsAtY:Ie,pointsAtZ:Ie,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ss,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ss,rev:ss,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ss,requiredFeatures:ss,requiredFonts:ss,requiredFormats:ss,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:Ie,specularExponent:Ie,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ie,strikethroughThickness:Ie,string:null,stroke:null,strokeDashArray:ss,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ie,strokeOpacity:Ie,strokeWidth:null,style:null,surfaceScale:Ie,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ss,tabIndex:Ie,tableValues:null,target:null,targetX:Ie,targetY:Ie,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ss,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ie,underlineThickness:Ie,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ie,values:null,vAlphabetic:Ie,vMathematical:Ie,vectorEffect:null,vHanging:Ie,vIdeographic:Ie,version:null,vertAdvY:Ie,vertOriginX:Ie,vertOriginY:Ie,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ie,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:CR}),ER=Bc({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()}}),AR=Bc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:_R}),PR=Bc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),S6={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"},j6=/[A-Z]/g,c1=/-[a-z]/g,N6=/^data[-\w.:]+$/i;function C6(e,t){const n=Hx(t);let r=t,s=es;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&N6.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(c1,E6);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!c1.test(o)){let a=o.replace(j6,_6);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Hk}return new s(r,t)}function _6(e){return"-"+e.toLowerCase()}function E6(e){return e.charAt(1).toUpperCase()}const A6=jR([NR,k6,ER,AR,PR],"html"),Wk=jR([NR,v6,ER,AR,PR],"svg");function P6(e){return e.join(" ").trim()}var Vk={},u1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,I6=/\n/g,R6=/^\s*/,T6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,M6=/^:\s*/,$6=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,L6=/^[;\s]*/,O6=/^\s+|\s+$/g,D6=`
67
+ `,d1="/",f1="*",_a="",F6="comment",z6="declaration";function B6(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(I6);v&&(n+=v.length);var b=y.lastIndexOf(D6);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(R6)}function d(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(d1!=e.charAt(0)||f1!=e.charAt(1))){for(var v=2;_a!=e.charAt(v)&&(f1!=e.charAt(v)||d1!=e.charAt(v+1));)++v;if(v+=2,_a===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:F6,comment:b})}}function p(){var y=o(),v=c(T6);if(v){if(f(),!c(M6))return l("property missing ':'");var b=c($6),g=y({type:z6,property:p1(v[0].replace(u1,_a)),value:b?p1(b[0].replace(u1,_a)):_a});return c(L6),g}}function h(){var y=[];d(y);for(var v;v=p();)v!==!1&&(y.push(v),d(y));return y}return u(),h()}function p1(e){return e?e.replace(O6,_a):_a}var H6=B6,W6=md&&md.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vk,"__esModule",{value:!0});Vk.default=K6;const V6=W6(H6);function K6(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,V6.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 rg={};Object.defineProperty(rg,"__esModule",{value:!0});rg.camelCase=void 0;var q6=/^--[a-zA-Z0-9_-]+$/,U6=/-([a-z])/g,Y6=/^[^-]+$/,G6=/^-(webkit|moz|ms|o|khtml)-/,J6=/^-(ms)-/,X6=function(e){return!e||Y6.test(e)||q6.test(e)},Q6=function(e,t){return t.toUpperCase()},h1=function(e,t){return"".concat(t,"-")},Z6=function(e,t){return t===void 0&&(t={}),X6(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(J6,h1):e=e.replace(G6,h1),e.replace(U6,Q6))};rg.camelCase=Z6;var e8=md&&md.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},t8=e8(Vk),n8=rg;function Kx(e,t){var n={};return!e||typeof e!="string"||(0,t8.default)(e,function(r,s){r&&s&&(n[(0,n8.camelCase)(r,t)]=s)}),n}Kx.default=Kx;var r8=Kx;const s8=ia(r8),IR=RR("end"),Kk=RR("start");function RR(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 i8(e){const t=Kk(e),n=IR(e);if(t&&n)return{start:t,end:n}}function cd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?m1(e.position):"start"in e||"end"in e?m1(e):"line"in e||"column"in e?qx(e):""}function qx(e){return g1(e&&e.line)+":"+g1(e&&e.column)}function m1(e){return qx(e&&e.start)+"-"+qx(e&&e.end)}function g1(e){return e&&typeof e=="number"?e:1}class Ar 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=cd(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}}Ar.prototype.file="";Ar.prototype.name="";Ar.prototype.reason="";Ar.prototype.message="";Ar.prototype.stack="";Ar.prototype.column=void 0;Ar.prototype.line=void 0;Ar.prototype.ancestors=void 0;Ar.prototype.cause=void 0;Ar.prototype.fatal=void 0;Ar.prototype.place=void 0;Ar.prototype.ruleId=void 0;Ar.prototype.source=void 0;const qk={}.hasOwnProperty,o8=new Map,a8=/[A-Z]/g,l8=new Set(["table","tbody","thead","tfoot","tr"]),c8=new Set(["td","th"]),TR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function u8(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=w8(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=y8(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"?Wk:A6,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=MR(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function MR(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 h8(e,t,n);if(t.type==="mdxjsEsm")return p8(e,t);if(t.type==="root")return m8(e,t,n);if(t.type==="text")return g8(e,t)}function d8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Wk,e.schema=s),e.ancestors.push(t);const o=LR(e,t.tagName,!1),a=x8(e,t);let l=Yk(e,t);return l8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!x6(c):!0})),$R(e,a,o,t),Uk(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)}Hd(e,t.position)}function p8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Hd(e,t.position)}function h8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Wk,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:LR(e,t.name,!0),a=b8(e,t),l=Yk(e,t);return $R(e,a,o,t),Uk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function m8(e,t,n){const r={};return Uk(r,Yk(e,t)),e.create(t,e.Fragment,r,n)}function g8(e,t){return t.value}function $R(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Uk(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function y8(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 w8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=Kk(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 x8(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&qk.call(t.properties,s)){const o=k8(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&c8.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 b8(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 Hd(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 Hd(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function Yk(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:o8;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=MR(e,o,a);l!==void 0&&n.push(l)}return n}function k8(e,t,n){const r=C6(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?h6(n):P6(n)),r.property==="style"){let s=typeof n=="object"?n:v8(e,String(n));return e.stylePropertyNameCase==="css"&&(s=S8(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?S6[r.property]||r.property:r.attribute,n]}}function v8(e,t){try{return s8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Ar("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=TR+"#cannot-parse-style-attribute",s}}function LR(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=o1(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=o1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return qk.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Hd(e)}function Hd(e,t){const n=new Ar("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=TR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function S8(e){const t={};let n;for(n in e)qk.call(e,n)&&(t[j8(n)]=e[n]);return t}function j8(e){let t=e.replace(a8,N8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function N8(e){return"-"+e.toLowerCase()}const Vy={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"]},C8={};function _8(e,t){const n=C8,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return OR(e,r,s)}function OR(e,t,n){if(E8(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 y1(e.children,t,n)}return Array.isArray(e)?y1(e,t,n):""}function y1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=OR(e[s],t,n);return r.join("")}function E8(e){return!!(e&&typeof e=="object")}const w1=document.createElement("i");function Gk(e){const t="&"+e+";";w1.innerHTML=t;const n=w1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ri(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 _s(e,t){return e.length>0?(Ri(e,e.length,0,t),e):t}const x1={}.hasOwnProperty;function A8(e){const t={};let n=-1;for(;++n<e.length;)P8(t,e[n]);return t}function P8(e,t){let n;for(n in t){const s=(x1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){x1.call(s,a)||(s[a]=[]);const l=o[a];I8(s[a],Array.isArray(l)?l:l?[l]:[])}}}function I8(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ri(e,0,0,r)}function DR(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 pc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ki=ca(/[A-Za-z]/),cs=ca(/[\dA-Za-z]/),R8=ca(/[#-'*+\--9=?A-Z^-~]/);function Ux(e){return e!==null&&(e<32||e===127)}const Yx=ca(/\d/),T8=ca(/[\dA-Fa-f]/),M8=ca(/[!-/:-@[-`{-~]/);function yt(e){return e!==null&&e<-2}function Zr(e){return e!==null&&(e<0||e===32)}function Qt(e){return e===-2||e===-1||e===32}const $8=ca(new RegExp("\\p{P}|\\p{S}","u")),L8=ca(/\s/);function ca(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Hc(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&cs(e.charCodeAt(n+1))&&cs(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 yn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return Qt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Qt(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const O8={tokenize:D8};function D8(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"),yn(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 yt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const F8={tokenize:z8},b1={tokenize:B8};function z8(e){const t=this,n=[];let r=0,s,o,a;return l;function l(x){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const j=t.events.length;let N=j,C;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){C=t.events[N][1].end;break}g(r);let I=j;for(;I<t.events.length;)t.events[I][1].end={...C},I++;return Ri(t.events,N+1,0,t.events.slice(j)),t.events.length=I,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(b1,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(b1,h,y)(x)}function h(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 yt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,j){const N=t.sliceStream(x);if(j&&N.push(null),x.previous=o,o&&(o.next=x),o=x,s.defineSkip(x.start),s.write(N),t.parser.lazy[x.start.line]){let C=s.events.length;for(;C--;)if(s.events[C][1].start.offset<a&&(!s.events[C][1].end||s.events[C][1].end.offset>a))return;const I=t.events.length;let R=I,H,A;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(H){A=t.events[R][1].end;break}H=!0}for(g(r),C=I;C<t.events.length;)t.events[C][1].end={...A},C++;Ri(t.events,R+1,0,t.events.slice(I)),t.events.length=C}}function g(x){let j=n.length;for(;j-- >x;){const N=n[j];t.containerState=N[1],N[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 B8(e,t,n){return yn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function k1(e){if(e===null||Zr(e)||L8(e))return 1;if($8(e))return 2}function Jk(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 Gx={name:"attention",resolveAll:H8,tokenize:W8};function H8(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};v1(f,-c),v1(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=_s(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=_s(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=_s(u,Jk(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=_s(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=_s(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Ri(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 W8(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=k1(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=k1(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 v1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const V8={name:"autolink",tokenize:K8};function K8(e,t,n){let r=0;return s;function s(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return ki(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||cs(h)?(r=1,l(h)):u(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||cs(h))&&r++<32?(e.consume(h),l):(r=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||Ux(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):R8(h)?(e.consume(h),u):n(h)}function d(h){return cs(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||cs(h))&&r++<63){const y=h===45?p:f;return e.consume(h),y}return n(h)}}const sg={partial:!0,tokenize:q8};function q8(e,t,n){return r;function r(o){return Qt(o)?yn(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||yt(o)?t(o):n(o)}}const FR={continuation:{tokenize:Y8},exit:G8,name:"blockQuote",tokenize:U8};function U8(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 Qt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Y8(e,t,n){const r=this;return s;function s(a){return Qt(a)?yn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(FR,t,n)(a)}}function G8(e){e.exit("blockQuote")}const zR={name:"characterEscape",tokenize:J8};function J8(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 M8(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const BR={name:"characterReference",tokenize:X8};function X8(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=cs,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=T8,d):(e.enter("characterReferenceValue"),o=7,a=Yx,d(f))}function d(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===cs&&!Gk(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 S1={partial:!0,tokenize:Z8},j1={concrete:!0,name:"codeFenced",tokenize:Q8};function Q8(e,t,n){const r=this,s={partial:!0,tokenize:N};let o=0,a=0,l;return c;function c(C){return u(C)}function u(C){const I=r.events[r.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(C)}function d(C){return C===l?(a++,e.consume(C),d):a<3?n(C):(e.exit("codeFencedFenceSequence"),Qt(C)?yn(e,f,"whitespace")(C):f(C))}function f(C){return C===null||yt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(S1,v,j)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||yt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(C)):Qt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),yn(e,h,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function h(C){return C===null||yt(C)?f(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===null||yt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(C)):C===96&&C===l?n(C):(e.consume(C),y)}function v(C){return e.attempt(s,j,b)(C)}function b(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return o>0&&Qt(C)?yn(e,k,"linePrefix",o+1)(C):k(C)}function k(C){return C===null||yt(C)?e.check(S1,v,j)(C):(e.enter("codeFlowValue"),x(C))}function x(C){return C===null||yt(C)?(e.exit("codeFlowValue"),k(C)):(e.consume(C),x)}function j(C){return e.exit("codeFenced"),t(C)}function N(C,I,R){let H=0;return A;function A(K){return C.enter("lineEnding"),C.consume(K),C.exit("lineEnding"),L}function L(K){return C.enter("codeFencedFence"),Qt(K)?yn(C,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):D(K)}function D(K){return K===l?(C.enter("codeFencedFenceSequence"),O(K)):R(K)}function O(K){return K===l?(H++,C.consume(K),O):H>=a?(C.exit("codeFencedFenceSequence"),Qt(K)?yn(C,M,"whitespace")(K):M(K)):R(K)}function M(K){return K===null||yt(K)?(C.exit("codeFencedFence"),I(K)):R(K)}}}function Z8(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 Ky={name:"codeIndented",tokenize:t9},e9={partial:!0,tokenize:n9};function t9(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),yn(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):yt(u)?e.attempt(e9,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||yt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function n9(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):yt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):yn(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):yt(a)?s(a):n(a)}}const r9={name:"codeText",previous:i9,resolve:s9,tokenize:o9};function s9(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 i9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function o9(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)):yt(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||yt(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 a9{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&&Au(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),Au(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Au(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);Au(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Au(this.left,n.reverse())}}}function Au(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 HR(e){const t={};let n=-1,r,s,o,a,l,c,u;const d=new a9(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,l9(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 Ri(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function l9(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,h=n,y=0,v=0;const b=[v];for(;h;){for(;e.get(++s)[1]!==h;);o.push(s),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=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),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),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 c9={resolve:d9,tokenize:f9},u9={partial:!0,tokenize:p9};function d9(e){return HR(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):yt(l)?e.check(u9,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 p9(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),yn(e,o,"linePrefix")}function o(a){if(a===null||yt(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 WR(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||Ux(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"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(l),p(g)):g===null||g===60||yt(g)?n(g):(e.consume(g),g===92?y:h)}function y(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function v(g){return!d&&(g===null||g===41||Zr(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||Ux(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 VR(e,t,n,r,s,o){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(o),d}function d(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):yt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||yt(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!Qt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function KR(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):yt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),yn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||yt(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 ud(e,t){let n;return r;function r(s){return yt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Qt(s)?yn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const h9={name:"definition",tokenize:g9},m9={partial:!0,tokenize:y9};function g9(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return VR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=pc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return Zr(h)?ud(e,u)(h):u(h)}function u(h){return WR(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(m9,f,f)(h)}function f(h){return Qt(h)?yn(e,p,"whitespace")(h):p(h)}function p(h){return h===null||yt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function y9(e,t,n){return r;function r(l){return Zr(l)?ud(e,s)(l):n(l)}function s(l){return KR(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return Qt(l)?yn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||yt(l)?t(l):n(l)}}const w9={name:"hardBreakEscape",tokenize:x9};function x9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return yt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const b9={name:"headingAtx",resolve:k9,tokenize:v9};function k9(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"},Ri(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function v9(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||Zr(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||yt(d)?(e.exit("atxHeading"),t(d)):Qt(d)?yn(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||Zr(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const S9=["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"],N1=["pre","script","style","textarea"],j9={concrete:!0,name:"htmlFlow",resolveTo:_9,tokenize:E9},N9={partial:!0,tokenize:P9},C9={partial:!0,tokenize:A9};function _9(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 E9(e,t,n){const r=this;let s,o,a,l,c;return u;function u(B){return d(B)}function d(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),f}function f(B){return B===33?(e.consume(B),p):B===47?(e.consume(B),o=!0,v):B===63?(e.consume(B),s=3,r.interrupt?t:E):ki(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function p(B){return B===45?(e.consume(B),s=2,h):B===91?(e.consume(B),s=5,l=0,y):ki(B)?(e.consume(B),s=4,r.interrupt?t:E):n(B)}function h(B){return B===45?(e.consume(B),r.interrupt?t:E):n(B)}function y(B){const se="CDATA[";return B===se.charCodeAt(l++)?(e.consume(B),l===se.length?r.interrupt?t:D:y):n(B)}function v(B){return ki(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function b(B){if(B===null||B===47||B===62||Zr(B)){const se=B===47,ue=a.toLowerCase();return!se&&!o&&N1.includes(ue)?(s=1,r.interrupt?t(B):D(B)):S9.includes(a.toLowerCase())?(s=6,se?(e.consume(B),g):r.interrupt?t(B):D(B)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):o?k(B):x(B))}return B===45||cs(B)?(e.consume(B),a+=String.fromCharCode(B),b):n(B)}function g(B){return B===62?(e.consume(B),r.interrupt?t:D):n(B)}function k(B){return Qt(B)?(e.consume(B),k):A(B)}function x(B){return B===47?(e.consume(B),A):B===58||B===95||ki(B)?(e.consume(B),j):Qt(B)?(e.consume(B),x):A(B)}function j(B){return B===45||B===46||B===58||B===95||cs(B)?(e.consume(B),j):N(B)}function N(B){return B===61?(e.consume(B),C):Qt(B)?(e.consume(B),N):x(B)}function C(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),c=B,I):Qt(B)?(e.consume(B),C):R(B)}function I(B){return B===c?(e.consume(B),c=null,H):B===null||yt(B)?n(B):(e.consume(B),I)}function R(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Zr(B)?N(B):(e.consume(B),R)}function H(B){return B===47||B===62||Qt(B)?x(B):n(B)}function A(B){return B===62?(e.consume(B),L):n(B)}function L(B){return B===null||yt(B)?D(B):Qt(B)?(e.consume(B),L):n(B)}function D(B){return B===45&&s===2?(e.consume(B),z):B===60&&s===1?(e.consume(B),F):B===62&&s===4?(e.consume(B),Q):B===63&&s===3?(e.consume(B),E):B===93&&s===5?(e.consume(B),W):yt(B)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(N9,V,O)(B)):B===null||yt(B)?(e.exit("htmlFlowData"),O(B)):(e.consume(B),D)}function O(B){return e.check(C9,M,V)(B)}function M(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),K}function K(B){return B===null||yt(B)?O(B):(e.enter("htmlFlowData"),D(B))}function z(B){return B===45?(e.consume(B),E):D(B)}function F(B){return B===47?(e.consume(B),a="",$):D(B)}function $(B){if(B===62){const se=a.toLowerCase();return N1.includes(se)?(e.consume(B),Q):D(B)}return ki(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),$):D(B)}function W(B){return B===93?(e.consume(B),E):D(B)}function E(B){return B===62?(e.consume(B),Q):B===45&&s===2?(e.consume(B),E):D(B)}function Q(B){return B===null||yt(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),Q)}function V(B){return e.exit("htmlFlow"),t(B)}}function A9(e,t,n){const r=this;return s;function s(a){return yt(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 P9(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(sg,t,n)}}const I9={name:"htmlText",tokenize:R9};function R9(e,t,n){const r=this;let s,o,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),u):E===47?(e.consume(E),N):E===63?(e.consume(E),x):ki(E)?(e.consume(E),R):n(E)}function u(E){return E===45?(e.consume(E),d):E===91?(e.consume(E),o=0,y):ki(E)?(e.consume(E),k):n(E)}function d(E){return E===45?(e.consume(E),h):n(E)}function f(E){return E===null?n(E):E===45?(e.consume(E),p):yt(E)?(a=f,F(E)):(e.consume(E),f)}function p(E){return E===45?(e.consume(E),h):f(E)}function h(E){return E===62?z(E):E===45?p(E):f(E)}function y(E){const Q="CDATA[";return E===Q.charCodeAt(o++)?(e.consume(E),o===Q.length?v:y):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),b):yt(E)?(a=v,F(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),g):v(E)}function g(E){return E===62?z(E):E===93?(e.consume(E),g):v(E)}function k(E){return E===null||E===62?z(E):yt(E)?(a=k,F(E)):(e.consume(E),k)}function x(E){return E===null?n(E):E===63?(e.consume(E),j):yt(E)?(a=x,F(E)):(e.consume(E),x)}function j(E){return E===62?z(E):x(E)}function N(E){return ki(E)?(e.consume(E),C):n(E)}function C(E){return E===45||cs(E)?(e.consume(E),C):I(E)}function I(E){return yt(E)?(a=I,F(E)):Qt(E)?(e.consume(E),I):z(E)}function R(E){return E===45||cs(E)?(e.consume(E),R):E===47||E===62||Zr(E)?H(E):n(E)}function H(E){return E===47?(e.consume(E),z):E===58||E===95||ki(E)?(e.consume(E),A):yt(E)?(a=H,F(E)):Qt(E)?(e.consume(E),H):z(E)}function A(E){return E===45||E===46||E===58||E===95||cs(E)?(e.consume(E),A):L(E)}function L(E){return E===61?(e.consume(E),D):yt(E)?(a=L,F(E)):Qt(E)?(e.consume(E),L):H(E)}function D(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,O):yt(E)?(a=D,F(E)):Qt(E)?(e.consume(E),D):(e.consume(E),M)}function O(E){return E===s?(e.consume(E),s=void 0,K):E===null?n(E):yt(E)?(a=O,F(E)):(e.consume(E),O)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Zr(E)?H(E):(e.consume(E),M)}function K(E){return E===47||E===62||Zr(E)?H(E):n(E)}function z(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),$}function $(E){return Qt(E)?yn(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):W(E)}function W(E){return e.enter("htmlTextData"),a(E)}}const Xk={name:"labelEnd",resolveAll:L9,resolveTo:O9,tokenize:D9},T9={tokenize:F9},M9={tokenize:z9},$9={tokenize:B9};function L9(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&&Ri(e,0,e.length,n),e}function O9(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=_s(l,e.slice(o+1,o+r+3)),l=_s(l,[["enter",d,t]]),l=_s(l,Jk(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=_s(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=_s(l,e.slice(a+1)),l=_s(l,[["exit",c,t]]),Ri(e,o,e.length,l),e}function D9(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(pc(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(T9,d,a?d:f)(p):p===91?e.attempt(M9,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt($9,d,f)(p)}function d(p){return t(p)}function f(p){return o._balanced=!0,n(p)}}function F9(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 Zr(f)?ud(e,o)(f):o(f)}function o(f){return f===41?d(f):WR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Zr(f)?ud(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?KR(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Zr(f)?ud(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 z9(e,t,n){const r=this;return s;function s(l){return VR.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(pc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function B9(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 H9={name:"labelStartImage",resolveAll:Xk.resolveAll,tokenize:W9};function W9(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 V9={name:"labelStartLink",resolveAll:Xk.resolveAll,tokenize:K9};function K9(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 qy={name:"lineEnding",tokenize:q9};function q9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),yn(e,t,"linePrefix")}}const ph={name:"thematicBreak",tokenize:U9};function U9(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||yt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Qt(u)?yn(e,l,"whitespace")(u):l(u))}}const Vr={continuation:{tokenize:X9},exit:Z9,name:"list",tokenize:J9},Y9={partial:!0,tokenize:eV},G9={partial:!0,tokenize:Q9};function J9(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(h){const y=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Yx(h)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(ph,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return Yx(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(sg,r.interrupt?n:d,e.attempt(Y9,p,f))}function d(h){return r.containerState.initialBlankLine=!0,o++,p(h)}function f(h){return Qt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function X9(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(sg,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,yn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!Qt(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(G9,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,yn(e,e.attempt(Vr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Q9(e,t,n){const r=this;return yn(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 Z9(e){e.exit(this.containerState.type)}function eV(e,t,n){const r=this;return yn(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!Qt(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const C1={name:"setextUnderline",resolveTo:tV,tokenize:nV};function tV(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 nV(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"),Qt(u)?yn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||yt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const rV={tokenize:sV};function sV(e){const t=this,n=e.attempt(sg,r,e.attempt(this.parser.constructs.flowInitial,s,yn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(c9,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 iV={resolveAll:UR()},oV=qR("string"),aV=qR("text");function qR(e){return{resolveAll:UR(e==="text"?lV: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 h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function UR(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 lV(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 cV={42:Vr,43:Vr,45:Vr,48:Vr,49:Vr,50:Vr,51:Vr,52:Vr,53:Vr,54:Vr,55:Vr,56:Vr,57:Vr,62:FR},uV={91:h9},dV={[-2]:Ky,[-1]:Ky,32:Ky},fV={35:b9,42:ph,45:[C1,ph],60:j9,61:C1,95:ph,96:j1,126:j1},pV={38:BR,92:zR},hV={[-5]:qy,[-4]:qy,[-3]:qy,33:H9,38:BR,42:Gx,60:[V8,I9],91:V9,92:[w9,zR],93:Xk,95:Gx,96:r9},mV={null:[Gx,iV]},gV={null:[42,95]},yV={null:[]},wV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:gV,contentInitial:uV,disable:yV,document:cV,flow:fV,flowInitial:dV,insideSpan:mV,string:pV,text:hV},Symbol.toStringTag,{value:"Module"}));function xV(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:I(N),check:I(C),consume:k,enter:x,exit:j,interrupt:I(C,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(L){return a=_s(a,L),b(),a[a.length-1]!==null?[]:(R(t,0),u.events=Jk(o,u.events,u),u.events)}function p(L,D){return kV(h(L),D)}function h(L){return bV(a,L)}function y(){const{_bufferIndex:L,_index:D,line:O,column:M,offset:K}=r;return{_bufferIndex:L,_index:D,line:O,column:M,offset:K}}function v(L){s[L.line]=L.column,A()}function b(){let L;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(L=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===L&&r._bufferIndex<D.length;)g(D.charCodeAt(r._bufferIndex));else g(D)}}function g(L){d=d(L)}function k(L){yt(L)?(r.line++,r.column=1,r.offset+=L===-3?2:1,A()):L!==-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=L}function x(L,D){const O=D||{};return O.type=L,O.start=y(),u.events.push(["enter",O,u]),l.push(O),O}function j(L){const D=l.pop();return D.end=y(),u.events.push(["exit",D,u]),D}function N(L,D){R(L,D.from)}function C(L,D){D.restore()}function I(L,D){return O;function O(M,K,z){let F,$,W,E;return Array.isArray(M)?V(M):"tokenize"in M?V([M]):Q(M);function Q(G){return ee;function ee(te){const ne=te!==null&&G[te],Z=te!==null&&G.null,ce=[...Array.isArray(ne)?ne:ne?[ne]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return V(ce)(te)}}function V(G){return F=G,$=0,G.length===0?z:B(G[$])}function B(G){return ee;function ee(te){return E=H(),W=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?ue():G.tokenize.call(D?Object.assign(Object.create(u),D):u,c,se,ue)(te)}}function se(G){return L(W,E),K}function ue(G){return E.restore(),++$<F.length?B(F[$]):z}}}function R(L,D){L.resolveAll&&!o.includes(L)&&o.push(L),L.resolve&&Ri(u.events,D,u.events.length-D,L.resolve(u.events.slice(D),u)),L.resolveTo&&(u.events=L.resolveTo(u.events,u))}function H(){const L=y(),D=u.previous,O=u.currentConstruct,M=u.events.length,K=Array.from(l);return{from:M,restore:z};function z(){r=L,u.previous=D,u.currentConstruct=O,u.events.length=M,l=K,A()}}function A(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function bV(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 kV(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 vV(e){const r={constructs:A8([wV,...(e||{}).extensions||[]]),content:s(O8),defined:[],document:s(F8),flow:s(rV),lazy:{},string:s(oV),text:s(aV)};return r;function s(o){return a;function a(l){return xV(r,o,l)}}}function SV(e){for(;!HR(e););return e}const _1=/[\0\t\n\r]/g;function jV(){let e=1,t="",n=!0,r;return s;function s(o,a,l){const c=[];let u,d,f,p,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(_1.lastIndex=f,u=_1.exec(o),p=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(p),!u){t=o.slice(f);break}if(h===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),h){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 NV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function CV(e){return e.replace(NV,_V)}function _V(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return DR(n.slice(o?2:1),o?16:10)}return Gk(n)||e}const YR={}.hasOwnProperty;function EV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),AV(n)(SV(vV(n).document().write(jV()(e,t,!0))))}function AV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(gt),autolinkProtocol:H,autolinkEmail:H,atxHeading:o(Ce),blockQuote:o(Z),characterEscape:H,characterReference:H,codeFenced:o(ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ce,a),codeText:o(de,a),codeTextData:H,data:H,codeFlowValue:H,definition:o(me),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o($e),hardBreakEscape:o(_e),hardBreakTrailing:o(_e),htmlFlow:o(Be,a),htmlFlowData:H,htmlText:o(Be,a),htmlTextData:H,image:o(ot),label:a,link:o(gt),listItem:o(st),listItemValue:p,listOrdered:o(Te,f),listUnordered:o(Te),paragraph:o(mt),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ce),strong:o(Rt),thematicBreak:o(Oe)},exit:{atxHeading:c(),atxHeadingSequence:N,autolink:c(),autolinkEmail:ne,autolinkProtocol:te,blockQuote:c(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:G,characterReference:ee,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:A,codeIndented:c(g),codeText:c(K),codeTextData:A,data:A,definition:c(),definitionDestinationString:j,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(O),htmlFlowData:A,htmlText:c(M),htmlTextData:A,image:c(F),label:W,labelText:$,lineEnding:L,link:c(z),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:E,resourceTitleString:Q,resource:V,setextHeading:c(R),setextHeadingLineSequence:I,setextHeadingText:C,strong:c(),thematicBreak:c()}};GR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){let ke={type:"root",children:[]};const Ke={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:d,data:n},Ue=[];let be=-1;for(;++be<ie.length;)if(ie[be][1].type==="listOrdered"||ie[be][1].type==="listUnordered")if(ie[be][0]==="enter")Ue.push(be);else{const Pt=Ue.pop();be=s(ie,Pt,be)}for(be=-1;++be<ie.length;){const Pt=t[ie[be][0]];YR.call(Pt,ie[be][1].type)&&Pt[ie[be][1].type].call(Object.assign({sliceSerialize:ie[be][2].sliceSerialize},Ke),ie[be][1])}if(Ke.tokenStack.length>0){const Pt=Ke.tokenStack[Ke.tokenStack.length-1];(Pt[1]||E1).call(Ke,void 0,Pt[0])}for(ke.position={start:Ao(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:Ao(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},be=-1;++be<t.transforms.length;)ke=t.transforms[be](ke)||ke;return ke}function s(ie,ke,Ke){let Ue=ke-1,be=-1,Pt=!1,tn,Wt,Lt,an;for(;++Ue<=Ke;){const re=ie[Ue];switch(re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{re[0]==="enter"?be++:be--,an=void 0;break}case"lineEndingBlank":{re[0]==="enter"&&(tn&&!an&&!be&&!Lt&&(Lt=Ue),an=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:an=void 0}if(!be&&re[0]==="enter"&&re[1].type==="listItemPrefix"||be===-1&&re[0]==="exit"&&(re[1].type==="listUnordered"||re[1].type==="listOrdered")){if(tn){let Re=Ue;for(Wt=void 0;Re--;){const Je=ie[Re];if(Je[1].type==="lineEnding"||Je[1].type==="lineEndingBlank"){if(Je[0]==="exit")continue;Wt&&(ie[Wt][1].type="lineEndingBlank",Pt=!0),Je[1].type="lineEnding",Wt=Re}else if(!(Je[1].type==="linePrefix"||Je[1].type==="blockQuotePrefix"||Je[1].type==="blockQuotePrefixWhitespace"||Je[1].type==="blockQuoteMarker"||Je[1].type==="listItemIndent"))break}Lt&&(!Wt||Lt<Wt)&&(tn._spread=!0),tn.end=Object.assign({},Wt?ie[Wt][1].start:re[1].end),ie.splice(Wt||Ue,0,["exit",tn,re[2]]),Ue++,Ke++}if(re[1].type==="listItemPrefix"){const Re={type:"listItem",_spread:!1,start:Object.assign({},re[1].start),end:void 0};tn=Re,ie.splice(Ue,0,["enter",Re,re[2]]),Ue++,Ke++,Lt=void 0,an=!0}}}return ie[ke][1]._spread=Pt,Ke}function o(ie,ke){return Ke;function Ke(Ue){l.call(this,ie(Ue),Ue),ke&&ke.call(this,Ue)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ie,ke,Ke){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([ke,Ke||void 0]),ie.position={start:Ao(ke.start),end:void 0}}function c(ie){return ke;function ke(Ke){ie&&ie.call(this,Ke),u.call(this,Ke)}}function u(ie,ke){const Ke=this.stack.pop(),Ue=this.tokenStack.pop();if(Ue)Ue[0].type!==ie.type&&(ke?ke.call(this,ie,Ue[0]):(Ue[1]||E1).call(this,ie,Ue[0]));else throw new Error("Cannot close `"+ie.type+"` ("+cd({start:ie.start,end:ie.end})+"): it’s not open");Ke.position.end=Ao(ie.end)}function d(){return _8(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(ie){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=ie}function y(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=ie}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie.replace(/(\r?\n|\r)$/g,"")}function k(ie){const ke=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=ke,Ke.identifier=pc(this.sliceSerialize(ie)).toLowerCase()}function x(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ie}function j(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ie}function N(ie){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Ke=this.sliceSerialize(ie).length;ke.depth=Ke}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function I(ie){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function H(ie){const Ke=this.stack[this.stack.length-1].children;let Ue=Ke[Ke.length-1];(!Ue||Ue.type!=="text")&&(Ue=xe(),Ue.position={start:Ao(ie.start),end:void 0},Ke.push(Ue)),this.stack.push(Ue)}function A(ie){const ke=this.stack.pop();ke.value+=this.sliceSerialize(ie),ke.position.end=Ao(ie.end)}function L(ie){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ke=ke.children[ke.children.length-1];Ke.position.end=Ao(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(H.call(this,ie),A.call(this,ie))}function D(){this.data.atHardBreak=!0}function O(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function M(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function K(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function z(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ke,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function F(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ke,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function $(ie){const ke=this.sliceSerialize(ie),Ke=this.stack[this.stack.length-2];Ke.label=CV(ke),Ke.identifier=pc(ke).toLowerCase()}function W(){const ie=this.stack[this.stack.length-1],ke=this.resume(),Ke=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ke.type==="link"){const Ue=ie.children;Ke.children=Ue}else Ke.alt=ke}function E(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ie}function Q(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ie}function V(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function se(ie){const ke=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=ke,Ke.identifier=pc(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function ue(ie){this.data.characterReferenceType=ie.type}function G(ie){const ke=this.sliceSerialize(ie),Ke=this.data.characterReferenceType;let Ue;Ke?(Ue=DR(ke,Ke==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ue=Gk(ke);const be=this.stack[this.stack.length-1];be.value+=Ue}function ee(ie){const ke=this.stack.pop();ke.position.end=Ao(ie.end)}function te(ie){A.call(this,ie);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(ie)}function ne(ie){A.call(this,ie);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(ie)}function Z(){return{type:"blockquote",children:[]}}function ce(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function me(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function $e(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function _e(){return{type:"break"}}function Be(){return{type:"html",value:""}}function ot(){return{type:"image",title:null,url:"",alt:null}}function gt(){return{type:"link",title:null,url:"",children:[]}}function Te(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function st(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function mt(){return{type:"paragraph",children:[]}}function Rt(){return{type:"strong",children:[]}}function xe(){return{type:"text",value:""}}function Oe(){return{type:"thematicBreak"}}}function Ao(e){return{line:e.line,column:e.column,offset:e.offset}}function GR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?GR(e,r):PV(e,r)}}function PV(e,t){let n;for(n in t)if(YR.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 E1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+cd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+cd({start:t.start,end:t.end})+") is still open")}function IV(e){const t=this;t.parser=n;function n(r){return EV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function RV(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 TV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `}]}function MV(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 $V(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function LV(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function OV(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Hc(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 DV(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 FV(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function JR(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 zV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return JR(e,t);const s={src:Hc(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 BV(e,t){const n={src:Hc(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 HV(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 WV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return JR(e,t);const s={href:Hc(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 VV(e,t){const n={href:Hc(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 KV(e,t,n){const r=e.all(t),s=n?qV(n):XR(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 qV(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=XR(n[r])}return t}function XR(e){const t=e.spread;return t??e.children.length>1}function UV(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 YV(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GV(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function JV(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XV(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=Kk(t.children[1]),c=IR(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 QV(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={},h=a?a[c]:void 0;h&&(p.align=h);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 ZV(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const A1=9,P1=32;function eK(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(I1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(I1(t.slice(s),s>0,!1)),o.join("")}function I1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===A1||o===P1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===A1||o===P1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function tK(e,t){const n={type:"text",value:eK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function nK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const rK={blockquote:RV,break:TV,code:MV,delete:$V,emphasis:LV,footnoteReference:OV,heading:DV,html:FV,imageReference:zV,image:BV,inlineCode:HV,linkReference:WV,link:VV,listItem:KV,list:UV,paragraph:YV,root:GV,strong:JV,table:XV,tableCell:ZV,tableRow:QV,text:tK,thematicBreak:nK,toml:Ap,yaml:Ap,definition:Ap,footnoteDefinition:Ap};function Ap(){}const QR=-1,ig=0,dd=1,nm=2,Qk=3,Zk=4,ev=5,tv=6,ZR=7,eT=8,R1=typeof self=="object"?self:globalThis,sK=(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 ig:case QR:return n(a,s);case dd:{const l=n([],s);for(const c of a)l.push(r(c));return l}case nm:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case Qk:return n(new Date(a),s);case Zk:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case ev:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case tv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case ZR:{const{name:l,message:c}=a;return n(new R1[l](c),s)}case eT: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 R1[o](a),s)};return r},T1=e=>sK(new Map,e)(0),Tl="",{toString:iK}={},{keys:oK}=Object,Pu=e=>{const t=typeof e;if(t!=="object"||!e)return[ig,t];const n=iK.call(e).slice(8,-1);switch(n){case"Array":return[dd,Tl];case"Object":return[nm,Tl];case"Date":return[Qk,Tl];case"RegExp":return[Zk,Tl];case"Map":return[ev,Tl];case"Set":return[tv,Tl];case"DataView":return[dd,n]}return n.includes("Array")?[dd,n]:n.includes("Error")?[ZR,n]:[nm,n]},Pp=([e,t])=>e===ig&&(t==="function"||t==="symbol"),aK=(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]=Pu(a);switch(l){case ig:{let d=a;switch(c){case"bigint":l=eT,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([QR],a)}return s([l,d],a)}case dd:{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 nm:{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 oK(a))(e||!Pp(Pu(a[p])))&&d.push([o(p),o(a[p])]);return f}case Qk:return s([l,a.toISOString()],a);case Zk:{const{source:d,flags:f}=a;return s([l,{source:d,flags:f}],a)}case ev:{const d=[],f=s([l,d],a);for(const[p,h]of a)(e||!(Pp(Pu(p))||Pp(Pu(h))))&&d.push([o(p),o(h)]);return f}case tv:{const d=[],f=s([l,d],a);for(const p of a)(e||!Pp(Pu(p)))&&d.push(o(p));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},M1=(e,{json:t,lossy:n}={})=>{const r=[];return aK(!(t||n),!!t,new Map,r)(e),r},rm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?T1(M1(e,t)):structuredClone(e):(e,t)=>T1(M1(e,t));function lK(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 cK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function uK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||lK,r=e.options.footnoteBackLabel||cK,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=Hc(f.toLowerCase());let h=0;const y=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,h);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),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:{...rm(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 tT=function(e){if(e==null)return hK;if(typeof e=="function")return og(e);if(typeof e=="object")return Array.isArray(e)?dK(e):fK(e);if(typeof e=="string")return pK(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]=tT(e[n]);return og(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 og(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function pK(e){return og(t);function t(n){return n&&n.type===e}}function og(e){return t;function t(n,r,s){return!!(mK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function hK(){return!0}function mK(e){return e!==null&&typeof e=="object"&&"type"in e}const nT=[],gK=!0,$1=!1,yK="skip";function wK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=tT(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 h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=nT,y,v,b;if((!t||o(c,u,d[d.length-1]||void 0))&&(h=xK(n(c,d)),h[0]===$1))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==yK)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]===$1)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function xK(e){return Array.isArray(e)?e:typeof e=="number"?[gK,e]:e==null?nT:[e]}function rT(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),wK(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 Jx={}.hasOwnProperty,bK={};function kK(e,t){const n=t||bK,r=new Map,s=new Map,o=new Map,a={...rK,...n.handlers},l={all:u,applyData:SK,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:vK,wrap:NK};return rT(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,h=l.handlers[p];if(Jx.call(l.handlers,p)&&h)return h(l,d,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in d){const{children:v,...b}=d,g=rm(b);return g.children=l.all(d),g}return rm(d)}return(l.options.unknownHandler||jK)(l,d,f)}function u(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const y=l.one(p[h],d);if(y){if(h&&p[h-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=L1(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=L1(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function vK(e,t){e.position&&(t.position=i8(e))}function SK(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,rm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function jK(e,t){const n=t.data||{},r="value"in t&&!(Jx.call(n,"hProperties")||Jx.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 NK(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 L1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function O1(e,t){const n=kK(e,t),r=n.one(e,void 0),s=uK(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 CK(e,t){return e&&"run"in e?async function(n,r){const s=O1(n,{file:r,...t});await e.run(s,r)}:function(n,r){return O1(n,{file:r,...e||t})}}function D1(e){if(e)throw e}var hh=Object.prototype.hasOwnProperty,sT=Object.prototype.toString,F1=Object.defineProperty,z1=Object.getOwnPropertyDescriptor,B1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):sT.call(t)==="[object Array]"},H1=function(t){if(!t||sT.call(t)!=="[object Object]")return!1;var n=hh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&hh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||hh.call(t,s)},W1=function(t,n){F1&&n.name==="__proto__"?F1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},V1=function(t,n){if(n==="__proto__")if(hh.call(t,n)){if(z1)return z1(t,n).value}else return;return t[n]},_K=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=V1(l,n),s=V1(t,n),l!==s&&(d&&s&&(H1(s)||(o=B1(s)))?(o?(o=!1,a=r&&B1(r)?r:[]):a=r&&H1(r)?r:{},W1(l,{name:n,newValue:e(d,a,s)})):typeof s<"u"&&W1(l,{name:n,newValue:s}));return l};const Uy=ia(_K);function Xx(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 EK(){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?AK(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 AK(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 mi={basename:PK,dirname:IK,extname:RK,join:TK,sep:"/"};function PK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');gf(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 IK(e){if(gf(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 RK(e){gf(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 TK(...e){let t=-1,n;for(;++t<e.length;)gf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":MK(n)}function MK(e){gf(e);const t=e.codePointAt(0)===47;let n=$K(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function $K(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 gf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const LK={cwd:OK};function OK(){return"/"}function Qx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function DK(e){if(typeof e=="string")e=new URL(e);else if(!Qx(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 FK(e)}function FK(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 Yy=["history","path","basename","stem","extname","dirname"];class iT{constructor(t){let n;t?Qx(t)?n={path:t}:typeof t=="string"||zK(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":LK.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Yy.length;){const o=Yy[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)Yy.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?mi.basename(this.path):void 0}set basename(t){Jy(t,"basename"),Gy(t,"basename"),this.path=mi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?mi.dirname(this.path):void 0}set dirname(t){K1(this.basename,"dirname"),this.path=mi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?mi.extname(this.path):void 0}set extname(t){if(Gy(t,"extname"),K1(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=mi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Qx(t)&&(t=DK(t)),Jy(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?mi.basename(this.path,this.extname):void 0}set stem(t){Jy(t,"stem"),Gy(t,"stem"),this.path=mi.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 Ar(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 Gy(e,t){if(e&&e.includes(mi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mi.sep+"`")}function Jy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function K1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function zK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const BK=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},HK={}.hasOwnProperty;class nv extends BK{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=EK()}copy(){const t=new nv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Uy(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Zy("data",this.frozen),this.namespace[t]=n,this):HK.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Zy("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=Ip(t),r=this.parser||this.Parser;return Xy("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Xy("process",this.parser||this.Parser),Qy("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Ip(t),c=r.parse(l);r.run(c,l,function(d,f,p){if(d||!f||!p)return u(d);const h=f,y=r.stringify(h,p);KK(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(),Xy("processSync",this.parser||this.Parser),Qy("processSync",this.compiler||this.Compiler),this.process(t,s),U1("processSync","process",n),r;function s(o,a){n=!0,D1(o),r=a}}run(t,n,r){q1(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=Ip(n);s.run(t,c,u);function u(d,f,p){const h=f||t;d?l(d):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,o),U1("runSync","run",r),s;function o(a,l){D1(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Ip(n),s=this.compiler||this.Compiler;return Qy("stringify",s),q1(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Zy("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=Uy(!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[h,...y]=d;const v=r[p][1];Xx(v)&&Xx(h)&&(h=Uy(!0,v,h)),r[p]=[u,h,...y]}}}}const WK=new nv().freeze();function Xy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Qy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Zy(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 q1(e){if(!Xx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function U1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ip(e){return VK(e)?e:new iT(e)}function VK(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function KK(e){return typeof e=="string"||qK(e)}function qK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const UK="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Y1=[],G1={allowDangerousHtml:!0},YK=/^(https?|ircs?|mailto|xmpp)$/i,GK=[{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 oT(e){const t=JK(e),n=XK(e);return QK(t.runSync(t.parse(n),n),e)}function JK(e){const t=e.rehypePlugins||Y1,n=e.remarkPlugins||Y1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...G1}:G1;return WK().use(IV).use(n).use(CK,r).use(t)}function XK(e){const t=e.children||"",n=new iT;return typeof t=="string"&&(n.value=t),n}function QK(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||ZK;for(const d of GK)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+UK+d.id,void 0);return rT(e,u),u8(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 h;for(h in Vy)if(Object.hasOwn(Vy,h)&&Object.hasOwn(d.properties,h)){const y=d.properties[h],v=Vy[h];(v===null||v.includes(d.tagName))&&(d.properties[h]=c(String(y||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):o?o.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function ZK(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||YK.test(e.slice(0,t))?e:""}const e7=new Set(["echarts"]),t7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),n7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),r7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Jo(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Qa(e,t){if(!Jo(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Jo(n[r])&&Jo(s)&&(n[r]=Qa(n[r],s));return n}function ag(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Jo(n)?Qa(n,t):n):Jo(e)?Qa(e,t):e}function s7(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 Zx(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)=>Zx(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||n7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Zx(r,`${t}.${n}`)}}}function i7(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(!t7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function o7(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:Qa(e,t)}function a7(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(!Jo(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return Qa(o,n)}):Jo(e)?Qa(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function l7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:ag(e,n)}function J1(e,t="rgba(255, 255, 255, 0.62)"){return ag(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 c7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:ag(e,n)}function u7(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:ag(e,t)}function d7(e,t,n){const r=a7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Jo(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??r7,textStyle:Qa(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:o7(e.tooltip),legend:l7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?c7(e.grid,s||o):e.grid,xAxis:J1(e.xAxis),yAxis:J1(e.yAxis),radar:u7(e.radar),series:t}}function f7(e){const t=s7(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(!e7.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");Zx(n);const r=i7(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 Rp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function p7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function Xi(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!Rp(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==="`"&&!Rp(t,o)){const l=p7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!Rp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&Rp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function aT(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 lT(e){const t=Xi(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function cT(e){return Xi(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function h7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function m7(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 g7({code:e}){const t=m.useMemo(()=>m7(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),h=l.get(d.to);if(!p||!h)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${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 y7(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 w7({code:e}){const t=m.useMemo(()=>y7(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(h=>h.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 h=s+p*r+r/2;return i.jsxs("g",{children:[i.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:o,width:"136",height:"34",rx:"8"}),i.jsx("text",{className:"af-md-mermaid-text",x:h,y:o+22,textAnchor:"middle",children:f.label.slice(0,18)}),i.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,p)=>{const h=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:h-17,width:c-s*2,height:"30",rx:"7"}),i.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:f.text.slice(0,120)})]},`note-${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:h,x2:v,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),i.jsx("text",{className:"af-md-sequence-label",x:b,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${p}`)})]})}function uT({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(w7,{code:t}):i.jsx(g7,{code:t})})}function x7(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&&h7(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&&Xi(l).length>1&&lT(t[a+1])){o();const u=Xi(l),d=cT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Xi(t[a]).length>1;)f.push(aT(Xi(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return o(),n}function X1(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 dT(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 fT(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=X1(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(uT,{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(X1(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 Q1({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(oT,{components:fT(t,!0,n),children:dT(e)})}function rv({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>x7(e),[e]),s=m.useMemo(()=>fT(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(uT,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(oT,{components:s,children:dT(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(Q1,{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(Q1,{resolveSrc:t,basePath:n,children:l[d]||""})},d))},c))})]})},`table-${a}`))})}function b7(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 pi(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 k7(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=>pi(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>pi(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)=>pi(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:pi(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:pi(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>pi(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>pi(s[a])):s&&typeof s=="object"?r.map(o=>pi(s[o.key])):r.map((o,a)=>a===0?pi(s):""))}}function v7(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=k7(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&&Xi(s[0]).length>1&&lT(s[1])){const l=Xi(s[0]),c=cT(s[1]);return{columns:l.map((u,d)=>({key:String(d),label:u,align:c[d]||"left"})),rows:s.slice(2).map(u=>aT(Xi(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=b7(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 sv({content:e}){const t=m.useMemo(()=>v7(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:pi(n[o])},`${s.key}-${o}`))},r))})]})})}function iv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>f7(e),[e]),[r,s]=m.useState({loading:!1,error:""});return m.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),p6(()=>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 pT(e){return typeof e>"u"||e===null}function S7(e){return typeof e=="object"&&e!==null}function j7(e){return Array.isArray(e)?e:pT(e)?[]:[e]}function N7(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 C7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function _7(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var E7=pT,A7=S7,P7=j7,I7=C7,R7=_7,T7=N7,ov={isNothing:E7,isObject:A7,toArray:P7,repeat:I7,isNegativeZero:R7,extend:T7};function hT(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 Wd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=hT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Wd.prototype=Object.create(Error.prototype);Wd.prototype.constructor=Wd;Wd.prototype.toString=function(t){return this.name+": "+hT(this,t)};var Ea=Wd,M7=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],$7=["scalar","sequence","mapping"];function L7(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function O7(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(M7.indexOf(n)===-1)throw new Ea('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=L7(t.styleAliases||null),$7.indexOf(this.kind)===-1)throw new Ea('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Cr=O7;function Z1(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 D7(){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 eb(e){return this.extend(e)}eb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Cr)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 Ea("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Cr))throw new Ea("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Ea("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 Ea("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 Cr))throw new Ea("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(eb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=Z1(s,"implicit"),s.compiledExplicit=Z1(s,"explicit"),s.compiledTypeMap=D7(s.compiledImplicit,s.compiledExplicit),s};var F7=eb,z7=new Cr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),B7=new Cr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),H7=new Cr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),W7=new F7({explicit:[z7,B7,H7]});function V7(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function K7(){return null}function q7(e){return e===null}var U7=new Cr("tag:yaml.org,2002:null",{kind:"scalar",resolve:V7,construct:K7,predicate:q7,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Y7(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 G7(e){return e==="true"||e==="True"||e==="TRUE"}function J7(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var X7=new Cr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Y7,construct:G7,predicate:J7,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 Q7(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Z7(e){return 48<=e&&e<=55}function eq(e){return 48<=e&&e<=57}function tq(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(!Q7(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!Z7(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!eq(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function nq(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 rq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!ov.isNegativeZero(e)}var sq=new Cr("tag:yaml.org,2002:int",{kind:"scalar",resolve:tq,construct:nq,predicate:rq,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"]}}),iq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function oq(e){return!(e===null||!iq.test(e)||e[e.length-1]==="_")}function aq(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 lq=/^[-+]?[0-9]+e/;function cq(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(ov.isNegativeZero(e))return"-0.0";return n=e.toString(10),lq.test(n)?n.replace("e",".e"):n}function uq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||ov.isNegativeZero(e))}var dq=new Cr("tag:yaml.org,2002:float",{kind:"scalar",resolve:oq,construct:aq,predicate:uq,represent:cq,defaultStyle:"lowercase"}),fq=W7.extend({implicit:[U7,X7,sq,dq]}),pq=fq,mT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),gT=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 hq(e){return e===null?!1:mT.exec(e)!==null||gT.exec(e)!==null}function mq(e){var t,n,r,s,o,a,l,c=0,u=null,d,f,p;if(t=mT.exec(e),t===null&&(t=gT.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 gq(e){return e.toISOString()}var yq=new Cr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:hq,construct:mq,instanceOf:Date,represent:gq});function wq(e){return e==="<<"||e===null}var xq=new Cr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:wq}),av=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
+ \r`;function bq(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=av;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 kq(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=av,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 vq(e){var t="",n=0,r,s,o=e.length,a=av;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 Sq(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var jq=new Cr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:bq,construct:kq,predicate:Sq,represent:vq}),Nq=Object.prototype.hasOwnProperty,Cq=Object.prototype.toString;function _q(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,Cq.call(s)!=="[object Object]")return!1;for(o in s)if(Nq.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 Eq(e){return e!==null?e:[]}var Aq=new Cr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:_q,construct:Eq}),Pq=Object.prototype.toString;function Iq(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],Pq.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function Rq(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 Tq=new Cr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Iq,construct:Rq}),Mq=Object.prototype.hasOwnProperty;function $q(e){if(e===null)return!0;var t,n=e;for(t in n)if(Mq.call(n,t)&&n[t]!==null)return!1;return!0}function Lq(e){return e!==null?e:{}}var Oq=new Cr("tag:yaml.org,2002:set",{kind:"mapping",resolve:$q,construct:Lq});pq.extend({implicit:[yq,xq],explicit:[jq,Aq,Tq,Oq]});function eC(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 Dq=new Array(256),Fq=new Array(256);for(var Ml=0;Ml<256;Ml++)Dq[Ml]=eC(Ml)?1:0,Fq[Ml]=eC(Ml);const Vd=["requirement","planning","code","test","normal"],tC={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function lv(e,t){var s,o,a,l,c,u,d,f,p,h,y,v,b,g;const n=k=>{const x={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(x.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(x.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(x.showOnNode=!!k.showOnNode),x},r={};for(const k of e){if((s=k==null?void 0:k.data)!=null&&s.isWorkspaceGroup)continue;const x=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},j=((o=k.data)==null?void 0:o.definitionId)||k.id,N=((a=k.data)==null?void 0:a.inputs)??[],C=((l=k.data)==null?void 0:l.outputs)??[],I=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",R=x.role!=null?String(x.role).trim():"",H=tC[I]||I,A=tC[R]||R,L=Vd.includes(H)?H:Vd.includes(A)?A:"normal",D=Array.isArray(N)?N.map(n):Array.isArray(x.input)?x.input.map(ue=>n(ue)):[],O=Array.isArray(C)?C.map(n):Array.isArray(x.output)?x.output.map(ue=>n(ue)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,K=(d=k.data)==null?void 0:d.body,z=K!=null?String(K):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:j,label:M,role:L,model:F,input:D,output:O},W=((p=k.data)==null?void 0:p.marketplaceRef)||x.marketplaceRef;W?$.marketplaceRef=String(W):delete $.marketplaceRef;const E=((h=k.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;E?$.marketplacePackageId=String(E):delete $.marketplacePackageId;const Q=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;Q?$.marketplaceVersion=String(Q):delete $.marketplaceVersion,j.startsWith("provide_")||z.trim()===""?delete $.body:$.body=z;const V=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(x.images)?x.images:[];V.length>0?$.images=V:delete $.images;const B=(b=k.data)==null?void 0:b.script,se=B!=null?String(B):x.script!=null?String(x.script):"";se.trim()===""?delete $.script:$.script=se;for(const ue of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[ue],ee=G!=null?String(G):x[ue]!=null?String(x[ue]):"";ee.trim()===""?delete $[ue]:$[ue]=ee.trim()}delete $.temperature,delete $.maxTokens,delete $.description,r[k.id]=$}return r}function fd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function zq(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 Bq(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=>fd(a)),edges:o.map(a=>fd(a)),instances:lv(r,n||{})}}function Hq(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,zq(p.id,a));const c=e.nodes.map(p=>{var y,v;const h=l.get(p.id);return{...fd(p),id:h,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,h)=>{const y=l.get(p.source),v=l.get(p.target);return{...fd(p),id:`e-${y}-${v}-${Date.now()}-${h}`,source:y,target:v,selected:!1}}),d={...r||{}};for(const[p,h]of l.entries()){const y=(f=e.instances)==null?void 0:f[p];y&&(d[h]={...fd(y),label:y.label!=null?String(y.label):h})}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 Mn(e){switch(sm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function sm(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 Wq(e,t){const n=sm(e),r=sm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const Vq=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function tb(e){const t=sm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&Vq.has(n)?`${t}+${n}`:t}function Kq(e){return tb(e)}function Kd(e,t){if(!e||!t||!Wq(e.type,t.type))return!1;const n=tb(e),r=tb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function qq(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 nb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=qq(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 im=/\[image\s+(\d+)\]/gi;function ho(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 Uq(e){return`image ${ho(e).length+1}`}function Yq(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function Gq(e,t){const n=ho(e),r=String(t||""),s=new Set;im.lastIndex=0;let o;for(;o=im.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function Jq(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 yT(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 pd(e){var t;return Array.from(((t=e==null?void 0:e.dataTransfer)==null?void 0:t.files)||[]).filter(n=>String(n.type||"").startsWith("image/"))}async function wT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=ho(n);for(const a of r){const l=await Jq(a),c=Uq(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=Yq(s,c)}return{body:s,images:o}}function vs(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Xq(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 Qq(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function en(e){e.stopPropagation()}function Zq(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eU(e,t){const n=`\\[${Zq(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
+ `).replace(/\n{3,}/g,`
97
+
98
+ `).trimEnd()}function ew(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tU(e){const t=String(e||"");let n="",r=0;im.lastIndex=0;let s;for(;s=im.exec(t);)n+=ew(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${ew(s[0])}</span>`,r=s.index+s[0].length;return n+=ew(t.slice(r)),n||" "}function nU(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 rU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:d=!1}){var Jt,Nt;const{t:f}=zr(),p=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=Xq(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,j=(e==null?void 0:e.nodeStatus)??null,N=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",I=C.startsWith("provide_"),R=C==="provide_bool",H=C==="provide_str",A=C==="provide_file",L=C==="provide_password",D=C==="agent_subAgent",O=C==="control_agent_toBool",M=(D||O)&&!b,K=R?Qq(h[0]):!1,z=I?String(((Jt=h[0])==null?void 0:Jt.value)??((Nt=h[0])==null?void 0:Nt.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"),W=!I&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",E=ho(e==null?void 0:e.images),Q=R||H||A||L||M||!!W,V=m.useRef(!1),B=m.useRef(!1),se=m.useRef(null),ue=m.useRef(null),G=m.useRef(null),ee=m.useRef(null),te=m.useRef(null),[ne,Z]=m.useState(z),[ce,de]=m.useState(!1),[me,$e]=m.useState(F),[Ce,_e]=m.useState(!1),[Be,ot]=m.useState({visible:!1,top:0,height:100}),[gt,Te]=m.useState(!1),st=m.useCallback(()=>{const le=ue.current;if(!le)return;const ve=Math.max(1,le.scrollHeight),it=Math.max(1,le.clientHeight),Ft=ve>it+1,Xt=Ft?Math.max(12,it/ve*100):100,nn=Math.max(0,100-Xt),er=Ft?Math.min(nn,le.scrollTop/Math.max(1,ve-it)*nn):0;ot({visible:Ft,top:er,height:Xt})},[]);m.useEffect(()=>{V.current||Z(z)},[n,z]),m.useEffect(()=>{B.current||$e(F)},[n,F]),m.useEffect(()=>{const le=ue.current;if(!le)return;if(M){le.style.minHeight="",le.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const ve=nU(le,me);le.style.minHeight=`${ve}px`,le.style.height="",G.current&&(G.current.style.minHeight=`${ve}px`,G.current.style.height="")},[me,M]),m.useEffect(()=>{if(!M)return;const le=window.requestAnimationFrame(st),ve=ue.current;if(!ve||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(le);const it=new ResizeObserver(st);return it.observe(ve),()=>{window.cancelAnimationFrame(le),it.disconnect()}},[me,M,st]),m.useEffect(()=>{const le=se.current,ve=e==null?void 0:e.onNodeContentResize;if(!M||!le||!ve||typeof ResizeObserver>"u")return;let it=0;const Ft=()=>{window.cancelAnimationFrame(it),it=window.requestAnimationFrame(()=>ve(n))},Xt=new ResizeObserver(Ft);return Xt.observe(le),Ft(),()=>{window.cancelAnimationFrame(it),Xt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),m.useEffect(()=>{if(!gt)return;const le=window.setTimeout(()=>{const ve=te.current;if(!ve)return;ve.focus();const it=ve.value.length;ve.setSelectionRange(it,it)},0);return()=>window.clearTimeout(le)},[gt]);const mt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],Rt=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],xe=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Oe=Array.isArray(c==null?void 0:c.codex)?c.codex:[],ie=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!C.startsWith("tool_nodejs"),Ke=new Set(mt.map(vs)),Ue=new Set(Rt.map(vs)),be=new Set(xe.map(vs)),Pt=new Set(Oe.map(vs)),tn=ie?ie.startsWith("cursor:")||ie.startsWith("opencode:")||ie.startsWith("codex:")||ie.startsWith("claude-code:")?ie:be.has(ie)?`claude-code:${ie}`:Pt.has(ie)?`codex:${ie}`:Ue.has(ie)?`opencode:${ie}`:Ke.has(ie)?`cursor:${ie}`:ie:"",Wt=ie&&!tn.startsWith("cursor:")&&!tn.startsWith("opencode:")&&!tn.startsWith("codex:")&&!tn.startsWith("claude-code:")&&!Ke.has(ie)&&!Ue.has(ie)&&!be.has(ie)&&!Pt.has(ie),Lt=ie.startsWith("cursor:")?ie.slice(7):ie.startsWith("opencode:")?ie.slice(9):ie.startsWith("codex:")?ie.slice(6):ie.startsWith("claude-code:")?ie.slice(12):ie,an=le=>{if(g)return;const ve=le.target.value;u&&u(n,ve)},re=le=>{le.stopPropagation(),!g&&r&&r(n)},Re=le=>{le.stopPropagation(),s&&s()},Je=le=>{le.stopPropagation(),!g&&(o==null||o(n,le.target.value==="true"?"true":"false"))},Ze=le=>{if(le.stopPropagation(),g)return;const ve=le.target.value;Z(ve),!d&&!V.current&&(o==null||o(n,ve))},Tt=le=>{le.stopPropagation(),V.current=!0},_t=le=>{if(le.stopPropagation(),g)return;V.current=!1;const ve=le.currentTarget.value;Z(ve),d||o==null||o(n,ve)},Kn=()=>{g||d&&ne===z||o==null||o(n,ne)},jn=le=>{if(le.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ne);return}const ve=window.prompt("文件路径",ne);ve!=null&&(Z(ve),o==null||o(n,ve))},br=le=>{le.stopPropagation(),de(ve=>!ve)},xn=le=>{if($e(le),a==null||a(n,le),l){const ve=Gq(E,le);(ve.length!==E.length||ve.some((it,Ft)=>{var Xt;return it.id!==((Xt=E[Ft])==null?void 0:Xt.id)}))&&l(n,ve)}},Qn=le=>{if(le.stopPropagation(),g)return;const ve=le.target.value;d||B.current?$e(ve):xn(ve)},qn=le=>{le.stopPropagation(),!g&&(B.current=!0,_e(!0))},mr=le=>{if(le.stopPropagation(),g)return;B.current=!1,_e(!1);const ve=le.currentTarget.value;d?$e(ve):xn(ve)},ts=()=>{g||(B.current=!1,_e(!1),!(d&&me===F)&&xn(me))},Pr=le=>{le.stopPropagation(),le.preventDefault(),!g&&Te(!0)},gs=()=>{Te(!1),ts()},ys=le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),gs())},dn=m.useCallback(le=>{const ve=ue.current;if(!ve)return;const it=Math.max(0,ve.scrollHeight-ve.clientHeight);ve.scrollTop=Math.min(1,Math.max(0,le))*it,st()},[st]),sr=m.useCallback((le,ve=0)=>{const it=ee.current;if(!it)return 0;const Ft=it.getBoundingClientRect(),Xt=Be.height/100*Ft.height,nn=Math.max(1,Ft.height-Xt);return(le-Ft.top-ve)/nn},[Be.height]),Ir=m.useCallback(le=>{var vr,tt;if(!Be.visible)return;le.preventDefault(),le.stopPropagation();const ve=ee.current;if(!ve)return;const it=ve.getBoundingClientRect(),Ft=Be.top/100*it.height,Xt=Be.height/100*it.height,er=le.clientY>=it.top+Ft&&le.clientY<=it.top+Ft+Xt?le.clientY-it.top-Ft:Xt/2;dn(sr(le.clientY,er));const ht=le.pointerId;(tt=(vr=le.currentTarget).setPointerCapture)==null||tt.call(vr,ht);const rn=On=>{On.preventDefault(),dn(sr(On.clientY,er))},Vt=()=>{window.removeEventListener("pointermove",rn),window.removeEventListener("pointerup",Vt),window.removeEventListener("pointercancel",Vt)};window.addEventListener("pointermove",rn),window.addEventListener("pointerup",Vt),window.addEventListener("pointercancel",Vt)},[sr,Be.height,Be.top,Be.visible,dn]),pn=async le=>{if(g)return;const ve=await wT({files:le,body:me,images:E});ve&&($e(ve.body),a==null||a(n,ve.body),l==null||l(n,ve.images))},Zn=(le,ve)=>{if(le.stopPropagation(),g)return;const it=E.filter(Xt=>Xt.id!==ve.id),Ft=eU(me,ve.label);$e(Ft),a==null||a(n,Ft),l==null||l(n,it)},kr=le=>{if(g)return;const ve=yT(le);ve.length!==0&&(le.preventDefault(),le.stopPropagation(),pn(ve).catch(()=>{}))},ir=le=>{if(g)return;const ve=pd(le);ve.length!==0&&(le.preventDefault(),le.stopPropagation(),pn(ve).catch(()=>{}))},jt=()=>{const le=ue.current,ve=G.current;!le||!ve||(ve.scrollTop=le.scrollTop,ve.scrollLeft=le.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(j==="success"?" af-flow-node--done":"")+(j==="failed"?" af-flow-node--failed":"")+(j==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+(H?" af-flow-node--provide-text":"")+(L?" 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:en,onMouseDown:en,onClick:en,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:tn,onChange:an,onPointerDown:en,onMouseDown:en,onClick:en,"aria-label":f("flow:node.model"),title:Lt||f("flow:node.defaultModel"),disabled:g,children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),Wt&&i.jsx("option",{value:ie,children:ie}),mt.length>0&&i.jsx("optgroup",{label:"Cursor",children:mt.map(le=>i.jsx("option",{value:`cursor:${vs(le)}`,children:vs(le)},`c-${le}`))}),Rt.length>0&&i.jsx("optgroup",{label:"OpenCode",children:Rt.map(le=>i.jsx("option",{value:`opencode:${vs(le)}`,children:vs(le)},`o-${le}`))}),Oe.length>0&&i.jsx("optgroup",{label:"Codex",children:Oe.map(le=>i.jsx("option",{value:`codex:${vs(le)}`,children:vs(le)},`codex-${le}`))}),xe.length>0&&i.jsx("optgroup",{label:"Claude Code",children:xe.map(le=>i.jsx("option",{value:`claude-code:${vs(le)}`,children:vs(le)},`cc-${le}`))})]}),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"}),j==="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"}),j==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:N!=null&&String(N).trim()!==""?N:"--"}),j==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&I&&!R&&!H&&!A&&!L&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Re,"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:re,"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((le,ve)=>{if(le.showOnNode===!1)return null;const it=f("flow:node.inputTooltip",{name:le.name||`#${ve}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),Ft=le.name||`#${ve+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Ft,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${ve}`,className:"af-flow-node__handle",style:{background:Mn(le.type)},title:it})]},`in-${ve}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[R?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(K?" af-flow-node__bool-select--true":""),value:K?"true":"false",onChange:Je,onPointerDown:en,onMouseDown:en,onClick:en,"aria-label":"Boolean value",title:K?"true":"false",disabled:g,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):H?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ne,onChange:Ze,onCompositionStart:Tt,onCompositionEnd:_t,onBlur:Kn,onPointerDown:en,onMouseDown:en,onClick:en,placeholder:"输入文本",rows:2,readOnly:g}):A?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:en,onMouseDown:en,onClick:en,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:ne,onChange:Ze,onCompositionStart:Tt,onCompositionEnd:_t,onBlur:Kn,placeholder:"选择或输入文件路径",title:ne||"选择或输入文件路径",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:jn,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):L?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:en,onMouseDown:en,onClick:en,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ce?"text":"password",value:ne,onChange:Ze,onCompositionStart:Tt,onCompositionEnd:_t,onBlur:Kn,placeholder:"输入密码或密钥",title:ce?ne:"密码已隐藏",autoComplete:"off",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:br,"aria-label":ce?"隐藏密码":"预览密码",title:ce?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:ce?"visibility_off":"visibility"})})]}):M?i.jsxs("div",{ref:se,className:"af-flow-node__prompt-stack nodrag"+(Ce?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:tU(me)+`
99
+ `}}),i.jsx("textarea",{ref:ue,className:"af-flow-node__prompt-editor nodrag",value:me,onChange:Qn,onCompositionStart:qn,onCompositionEnd:mr,onBlur:ts,onPaste:kr,onDrop:ir,onScroll:le=>{jt(),st()},onPointerDown:en,onMouseDown:en,onClick:en,onKeyDown:en,onDragOver:le=>{pd(le).length>0&&le.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&i.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:en,onMouseDown:en,onClick:Pr,"aria-label":"放大编辑",title:"放大编辑",children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),i.jsx("div",{ref:ee,className:"af-flow-node__prompt-scrollbar"+(Be.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:Ir,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${Be.height}%`,top:`${Be.top}%`}})})]}):null,M&&E.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:E.map((le,ve)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:le.name,children:[i.jsx("img",{src:le.dataUrl,alt:""}),i.jsxs("span",{children:["[",le.label||`image ${ve+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:it=>Zn(it,le),onPointerDown:en,onMouseDown:en,"aria-label":`删除 ${le.label||`image ${ve+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},le.id||ve))}):null,W?i.jsx("span",{className:"af-flow-node__prompt-preview",title:W,children:W}):null,Q?null:i.jsx("span",{className:"af-flow-node__body-title",title:$,children:$})]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:h.map((le,ve)=>{if(le.showOnNode===!1)return null;const it=f("flow:node.outputTooltip",{name:le.name||`#${ve}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),Ft=le.name||`#${ve+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Ft,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${ve}`,className:"af-flow-node__handle",style:{background:Mn(le.type)},title:it})]},`out-${ve}`)})})]}),gt?ur.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:en,onMouseDown:en,onClick:en,onWheel:en,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:gs,"aria-label":"关闭",title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("textarea",{ref:te,className:"af-flow-node-full-editor__textarea",value:me,onChange:Qn,onCompositionStart:qn,onCompositionEnd:mr,onPaste:kr,onDrop:ir,onKeyDown:ys,onDragOver:le=>{pd(le).length>0&&le.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const hc="flowNode";function rb(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 sU={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 iU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(sU[e]||[]).includes(s)?r:s}const oU={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"])},aU={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"])},lU={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},cU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function uU(e,t){if(!cU.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 xT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function pU(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 hU(e){const t=String(e??"").trim();return t?t.includes("${")?t:xT(t):""}function mU(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(hU).filter(Boolean):[];return[pU(t,n),xT(s),...o].join(" ")}return String(t.command||"").trim()}function nC(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=oU[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&&uU(e,r)?{showOnNode:!0}:{},...(d=lU[e])!=null&&d.has(r.name)?{showOnNode:!0}:{},...(f=aU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function gU(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=rb(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 sb(e,t,n,r,s){var $,W,E,Q,V,B,se,ue,G,ee,te,ne,Z,ce,de,me,$e,Ce,_e,Be,ot,gt;const o=(($=e.data)==null?void 0:$.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Te=>Te.id===o),l=t[e.id];let c=[],u=[],d=((W=e.data)==null?void 0:W.label)??e.id,f,p,h,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(rb)),Array.isArray(l.output)&&(u=l.output.map(rb)),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&&(h=String(l.body)),Array.isArray(l.images)&&(y=l.images),l.script!=null&&(v=String(l.script)));const g=f??(typeof((E=e.data)==null?void 0:E.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():"",j=x!==""?x:void 0,N=h??((V=e.data)==null?void 0:V.body)??"",C=Array.isArray(y)?y:Array.isArray((B=e.data)==null?void 0:B.images)?e.data.images:[],I=mU(a),R=v!==void 0?v:((se=e.data)==null?void 0:se.script)!=null?String(e.data.script):I,H=String(e.id),A=(ue=r==null?void 0:r[s])==null?void 0:ue[H],L=(G=A==null?void 0:A.label)==null?void 0:G.label,D=A==null?void 0:A.body,O=A==null?void 0:A.description;b||(c.length===0&&((ee=a==null?void 0:a.inputs)!=null&&ee.length)&&(c=a.inputs.map(Te=>({...Te}))),u.length===0&&((te=a==null?void 0:a.outputs)!=null&&te.length)&&(u=a.outputs.map(Te=>({...Te}))));const M=fU(a,(a==null?void 0:a.id)??o),K=(l==null?void 0:l.marketplaceRef)||((ne=e.data)==null?void 0:ne.marketplaceRef)||dU(a);if(M==="agent_subAgent"&&!u.some(Te=>(Te==null?void 0:Te.name)==="result")){const Te=(Z=a==null?void 0:a.outputs)==null?void 0:Z.find(st=>(st==null?void 0:st.name)==="result");u=[...u,Te?{...Te}:{type:"text",name:"result",default:""}]}if(M==="agent_subAgent"&&!c.some(Te=>(Te==null?void 0:Te.name)==="knowledgeContext")){const Te=(ce=a==null?void 0:a.inputs)==null?void 0:ce.find(st=>(st==null?void 0:st.name)==="knowledgeContext");c=[...c,Te?{...Te}:{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(Te=>(Te==null?void 0:Te.name)==="next")){const Te=(de=a==null?void 0:a.outputs)==null?void 0:de.find(st=>(st==null?void 0:st.name)==="next");u=[...u,Te?{...Te}:{type:"node",name:"next",default:""}]}if(M==="workspace_run"){if(!c.some(Te=>(Te==null?void 0:Te.name)==="prev")){const Te=(me=a==null?void 0:a.inputs)==null?void 0:me.find(st=>(st==null?void 0:st.name)==="prev");c=[Te?{...Te}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Te=>(Te==null?void 0:Te.name)==="next")){const Te=($e=a==null?void 0:a.outputs)==null?void 0:$e.find(st=>(st==null?void 0:st.name)==="next");u=[...u,Te?{...Te}:{type:"node",name:"next",default:""}]}}c=nC(M,c,a==null?void 0:a.inputs),u=nC(M,u,a==null?void 0:a.outputs),M.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(N).trim()!==""&&(u=u.map((Te,st)=>st===0?{...Te,default:N,value:N}:Te));const z=iU(M,d,a),F=M==="tool_nodejs"||String(R).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:L||d,displayLabel:z,definitionDisplayName:a==null?void 0:a.displayName,definitionId:M,...K?{marketplaceRef:K}:{},...l!=null&&l.marketplacePackageId||(Ce=e.data)!=null&&Ce.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((_e=e.data)==null?void 0:_e.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(Be=e.data)!=null&&Be.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((ot=e.data)==null?void 0:ot.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((gt=e.data)==null?void 0:gt.schemaType)??e.type??"agent",role:g,model:k,body:D||N,images:C,script:R,inputs:c,outputs:u,description:O||j,originalLabel:d,originalBody:N,...F?{script:R}:{}}}}function yU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var d,f,p,h;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=((h=(p=o==null?void 0:o.data)==null?void 0:p.inputs)==null?void 0:h.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&o&&c>=0&&c<a&&u>=0&&u<l})}function rC(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 sC(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function tw(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=rC(t==null?void 0:t.sourceHandle,"output"),o=rC(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 h=sC((u=c.data)==null?void 0:u.outputs,s);if(h!==((d=c.data)==null?void 0:d.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=sC((f=c.data)==null?void 0:f.inputs,o);if(h!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function wU(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 iC(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function xU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function bU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Vs({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(bU,{children:t})]},n))})}function kU({open:e,onClose:t}){const{t:n}=zr(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const o=xU()?"⌘":"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(Vs,{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(Vs,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function vU(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 SU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=zr(),[o,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var v;return(v=u.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e]);const f=m.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,j;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((j=g.data)==null?void 0:j.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:vU(g,v)})).filter(g=>g.s>0);return b.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),b.slice(0,50).map(g=>g.e)},[r,o]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var v;const y=(v=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())},h=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(v=>Math.min(f.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),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:h,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref: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 oC(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 jU(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 aC(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 nw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function lC(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 NU({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:o}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[d,f]=m.useState(null),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),j=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const R=new URLSearchParams;R.set("flowId",e.flowId),R.set("flowSource",e.flowSource||"user"),t?R.set("scheduleNodeId",t):n&&R.set("runNodeId",n),R.set("limit","80");const H=await fetch(`/api/workspace/run-logs?${R.toString()}`),A=await H.json().catch(()=>({}));if(!H.ok)throw new Error(A.error||"读取日志失败");const L=Array.isArray(A.runs)?A.runs:[];l(L),u(D=>{const O=L[0]||null;return O&&String(O.status||"")==="running"&&O.runId!==D?O.runId:D&&L.some(M=>M.runId===D)?D:r&&L.some(M=>M.runId===r)?r:(O==null?void 0:O.runId)||""})}catch(R){g(String(R.message||R)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),N=m.useCallback(async R=>{if(!R){f(null);return}v(!0);try{const H=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&H.set("archived","1");const A=await fetch(`/api/workspace/run-logs/${encodeURIComponent(R)}?${H.toString()}`),L=await A.json().catch(()=>({}));if(!A.ok)throw new Error(L.error||"读取日志详情失败");f(L)}catch(H){f({error:String(H.message||H),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{j()},[j]),m.useEffect(()=>{N(c)},[N,c]),m.useEffect(()=>{const R=a.find(A=>A.runId===c),H=window.setInterval(()=>{j(),(!R||R.status==="running")&&c&&N(c)},2e3);return()=>window.clearInterval(H)},[N,j,a,c]);const C=m.useMemo(()=>{const R=Array.isArray(d==null?void 0:d.events)?d.events:[],H=k.trim().toLowerCase();return H?R.filter(A=>String(A.type||"").toLowerCase().includes(H)||nw(A).toLowerCase().includes(H)||aC(A).toLowerCase().includes(H)):R},[d==null?void 0:d.events,k]),I=(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 j(),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--${lC(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:oC(R.startedAt)}),i.jsx("span",{children:jU(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:"详情"}),I!=null&&I.label?i.jsx("div",{className:"af-work-run-logs__detail-label",children:I.label}):null,i.jsx("div",{className:"af-work-run-logs__run-id",children:(I==null?void 0:I.runId)||"-"})]}),I?i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${lC(I.status)}`,children:I.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&&!C.length?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,i.jsx("div",{className:"af-work-run-logs__events",children:C.map((R,H)=>i.jsxs("div",{className:"af-work-run-logs__event",children:[i.jsx("span",{className:"af-work-run-logs__event-time",children:oC(R.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:R.type||"event"}),nw(R)?i.jsx("span",{className:"af-work-run-logs__event-node",children:nw(R)}):null,i.jsx("pre",{children:aC(R)})]},`${R.ts||H}-${H}`))})]})]})]})}function CU(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 bT(e){const t=CU(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 _U(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 EU(e){return String(e).replace(/<\/script/gi,"<\\/script")}function lg(e){const t=bT(e);return JSON.stringify({title:t.title,entry:t.entry,packageJson:t.packageJson||{scripts:{dev:"vite --host 0.0.0.0",build:"vite build"},dependencies:{"@vitejs/plugin-react":"latest",vite:"latest",react:"latest","react-dom":"latest"},devDependencies:{}},files:t.files,inputs:t.inputs},null,2)}function cv(e,t=""){const n=bT(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=_U(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=EU(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 kT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),AU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function PU(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 IU(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 vT(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(kT.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function ST(e){return{inputNames:cC(e==null?void 0:e.inputs),outputNames:cC(e==null?void 0:e.outputs)}}function RU(e,t,n){const r=ST(t),s=IU(e),o=[];for(const a of s)if(!vT(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 TU(e,t){const n=ST(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=vT(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 MU(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function $U(e){return e.map(t=>{const n=MU(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 LU(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 AU)kT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function OU(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 DU(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 Tp({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}=zr(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),j=m.useMemo(()=>ho(c),[c]),N=m.useMemo(()=>RU(e,a,d),[e,a,d]),C=N.length>0,I=m.useMemo(()=>TU(e,a),[e,a]),R=m.useMemo(()=>$U(I),[I]),H=m.useMemo(()=>n?null:PU(e,y),[e,y,n]),A=m.useMemo(()=>{if(!H)return[];const z=LU(a,d);return OU(z,H.query)},[H,a,d]);m.useEffect(()=>{g(z=>{const F=Math.max(0,A.length-1);return Math.min(Math.max(0,z),F)})},[A.length]);const L=m.useCallback(()=>{const z=p.current;if(!z||!H||A.length===0){x(null);return}const F=DU(z,y);if(!F){x(null);return}const $=4,W=44,E=13.5*16,Q=Math.min(A.length*W+8,E);let V=F.bottom+$;V+Q>window.innerHeight-8&&(V=Math.max(8,F.top-Q-$));const B=288;let se=F.left;se=Math.max(8,Math.min(se,window.innerWidth-B-8)),x({top:V,left:se})},[H,A.length,y]);m.useLayoutEffect(()=>{if(!H||A.length===0){x(null);return}const z=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(z)},[H,A.length,y,e,L]),m.useEffect(()=>{if(!H||A.length===0)return;const z=()=>L();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[H,A.length,L]);const D=m.useCallback(z=>{if(!H)return;const{atIndex:F}=H,$=e.slice(0,F)+"${"+z+"}"+e.slice(y);t($);const W=F+z.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(W,W)),v(W)})},[H,e,y,t]),O=m.useCallback(()=>{const z=p.current,F=h.current;!z||!F||(F.scrollTop=z.scrollTop,F.scrollLeft=z.scrollLeft,H&&A.length>0&&queueMicrotask(()=>L()))},[H,A.length,L]),M=m.useCallback(z=>{if(!n&&H&&A.length>0&&(z.key==="ArrowDown"||z.key==="ArrowUp"||z.key==="Enter")){if(z.key==="ArrowDown")z.preventDefault(),g(F=>(F+1)%A.length);else if(z.key==="ArrowUp")z.preventDefault(),g(F=>(F-1+A.length)%A.length);else if(z.key==="Enter"&&!z.shiftKey){z.preventDefault();const F=A[b];F&&D(F.insert)}}},[n,H,A,b,D]),K=m.useCallback(async z=>{if(n||typeof u!="function")return!1;const F=await wT({files:z,body:e,images:j});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=p.current;if(!$)return;$.focus();const W=F.body.length;$.setSelectionRange(W,W),v(W)}),!0):!1},[n,j,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((z,F)=>i.jsxs("span",{className:"af-body-image-chip",title:z.name,children:[i.jsx("img",{src:z.dataUrl,alt:""}),i.jsxs("span",{children:["[",z.label||`image ${F+1}`,"]"]})]},z.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
182
+ `}}),i.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?f:void 0,onChange:z=>{t(z.target.value),v(z.target.selectionStart??z.target.value.length)},onSelect:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:M,onPaste:z=>{const F=yT(z);F.length!==0&&(z.preventDefault(),K(F).catch(()=>{}))},onDragOver:z=>{pd(z).length>0&&z.preventDefault()},onDrop:z=>{const F=pd(z);F.length!==0&&(z.preventDefault(),K(F).catch(()=>{}))},onScroll:O})]}),H&&A.length>0&&k?ur.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:A.map((z,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(z.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${z.insert}}`}),z.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:z.subtitle}):null]})},`${z.section}-${z.insert}`))}),document.body):null,C?i.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:N.map(z=>z.message).join(" · ")}):null]})}const FU=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Iu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function uC({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=zr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),u=(f,p,h)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[p]:h};return p==="required"&&h===!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:h=>u(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>u(p,"name",h.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:h=>u(p,"default",h.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:h=>u(p,"description",h.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:h=>{o||u(p,"required",h.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:h=>u(p,"showOnNode",h.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 zU({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}=zr(),[h,y]=m.useState(!1),[v,b]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),x=m.useCallback(O=>{t(M=>M&&{...M,...O})},[t]),{cursorList:j,opencodeList:N,claudeCodeList:C,codexList:I,currentNotInLists:R}=m.useMemo(()=>{const O=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],M=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],K=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],z=Array.isArray(s==null?void 0:s.codex)?s.codex:[],F=new Set([...O,...M,...K,...z].map(Iu)),$=((e==null?void 0:e.model)??"").trim(),W=$.startsWith("cursor:")?$.slice(7):$.startsWith("opencode:")?$.slice(9):$.startsWith("codex:")?$.slice(6):$.startsWith("claude-code:")?$.slice(12):$,E=$&&!F.has(W)?$:"";return{cursorList:O,opencodeList:M,claudeCodeList:K,codexList:z,currentNotInLists:E}},[s,e==null?void 0:e.model]);if(!e)return null;const H=String(e.script??""),A=n==="tool_nodejs"||H.trim()!=="",L=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(L){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const O=await c(e,n);k({status:"success",message:O!=null&&O.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:O.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(O){k({status:"error",message:String((O==null?void 0:O.message)||O)})}}};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:!L||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:O=>x({newId:O.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:O=>x({label:O.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:Vd.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>x({role:O.target.value}),disabled:o,children:Vd.map(O=>i.jsx("option",{value:O,children:O},O))})]}),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 O=(e.model||"").trim();return O?R||O:""})(),onChange:O=>x({model:O.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,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map(O=>i.jsx("option",{value:Iu(O),children:O},`c-${O}`))}):null,N.length>0?i.jsx("optgroup",{label:"OpenCode",children:N.map(O=>i.jsx("option",{value:`opencode:${Iu(O)}`,children:O},`o-${O}`))}):null,I.length>0?i.jsx("optgroup",{label:"Codex",children:I.map(O=>i.jsx("option",{value:`codex:${Iu(O)}`,children:O},`codex-${O}`))}):null,C.length>0?i.jsx("optgroup",{label:"Claude Code",children:C.map(O=>i.jsx("option",{value:`claude-code:${Iu(O)}`,children:O},`cc-${O}`))}):null]})]}),i.jsx(uC,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>x({inputs:O}),disabled:o,requiredReadonly:!u}),i.jsx(uC,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>x({outputs:O}),disabled:o,requiredReadonly:!u}),A?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(Tp,{value:H,onChange:O=>x({script:O}),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:O=>x({scriptRef:O.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:O=>x({implementationRef:O.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:O=>x({implementationMode:O.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(Tp,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),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:O=>{O.target===O.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(Tp,{value:H,onChange:O=>x({script:O}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:O=>{O.target===O.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(Tp,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function BU({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=zr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||d)){f(!0),h("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){h(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(k){h(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),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 HU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=zr(),u=m.useId(),d=m.useRef(null),[f,p]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),b(""),y(!1);const j=requestAnimationFrame(()=>{var N;return(N=d.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(j)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(j){if(j.preventDefault(),!k||h)return;y(!0),b("");let N=null;try{const C=new AbortController;N=setTimeout(()=>C.abort(),15e3);const I=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:C.signal}),R=await I.json().catch(()=>({}));if(!I.ok){b(typeof R.error=="string"?R.error:c("project:deleteModal.deleteFailed"));return}try{for(let H=localStorage.length-1;H>=0;H--){const A=localStorage.key(H);A&&(A.startsWith(`af:composer-sessions:${n}:${r}`)||A.startsWith(`af:composer-active-session:${n}:${r}`)||A.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(A)}}catch{}await l()}catch(C){if((C==null?void 0:C.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((C==null?void 0:C.message)||C))}finally{N&&clearTimeout(N),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.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:j=>j.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:j=>p(j.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?i.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const dC=80,WU=220;function VU(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 KU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Mp(e,t,n){const r={nodes:Array.isArray(e)?e.map(VU):[],edges:Array.isArray(t)?t.map(KU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function rw(e,t){const n=[...e,t];return n.length>dC?n.slice(n.length-dC):n}function qU({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null),p=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(N=>N+1),[]),v=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),b=m.useCallback(()=>{v();const N=d.current,C=f.current;return d.current=null,f.current=null,!N||!C||N.signature===C.signature?(C&&(u.current=C),!1):(l.current=rw(l.current,N),c.current=[],u.current=C,y(),!0)},[y,v]),g=m.useCallback((N=[],C=[],I={})=>{v(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Mp(N,C,I),h.current=!1,y()},[y,v]),k=m.useCallback(N=>{h.current=!0,u.current=N,d.current=null,f.current=null,v(),s==null||s(N.value),y()},[y,v,s]),x=m.useCallback(()=>{b();const N=u.current||Mp(e,t,n),C=l.current.pop();return C?(c.current=rw(c.current,N),k(C),!0):(y(),!1)},[y,t,n,b,e,k]),j=m.useCallback(()=>{b();const N=u.current||Mp(e,t,n),C=c.current.pop();return C?(l.current=rw(l.current,N),k(C),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const N=Mp(e,t,n);if(!u.current){u.current=N;return}if(h.current){h.current=!1,u.current=N;return}N.signature!==u.current.signature&&(d.current||(d.current=u.current),f.current=N,v(),p.current=window.setTimeout(()=>{b()},WU))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:j,version:o}}function lo(e){return String(e??"").trim()}function fC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(lo(e).toLowerCase())}function UU(e){return e===!1?!0:["false","no","not_required","waived"].includes(lo(e).toLowerCase())}function YU(e,t=""){return lo((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 jT(e){return lo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function NT(e){return jT(e)==="all"}function GU(e,t=[]){const n=lo((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=jT(e),s=YU(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=>lo(l))).has(a)?a:""}function om(e){const t=lo(e==null?void 0:e.label).toLowerCase(),n=lo((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 JU(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[om(n)]-t[om(r)])}function XU(e){const t=lo((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 QU(e,t=[]){if(NT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(om);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 fC(e==null?void 0:e.implementationNotRequired)||fC(e==null?void 0:e.implementation_not_required)||UU(r)?{kind:"not-required",label:XU(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function ib(e=[]){return e.reduce((t,n)=>t+1+ib(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function fr(e){return String(e||"").trim()}function Lo(e){return fr(e).toLowerCase()}function am(e){return typeof e=="string"?Lo(e):!e||typeof e!="object"||Array.isArray(e)?"":Lo(e.kind||e.type||e.persistence||e.durability)}function CT(e,t="http://localhost"){const n=fr(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 _T(e={}){const t=fr(e.href||e.url);if(!t)return!1;const n=Lo(e.kind||e.type),r=Lo(e.durability),s=Lo(e.persistence),o=Lo(e.truth||e.stateTruth||e.state_truth),a=Lo(e.authority),l=am(e.source)||am(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(fr).join(" "),u=[e.label,e.title,n,s,a,l,t].map(fr).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),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&p,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function ET(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(fr).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 ZU(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=fr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(fr(t)?fr(t):ET(e)==="tech-design"&&fr(n)?fr(n):fr(e.title||e.label))}function eY(e={},t="http://localhost"){const n=fr(e.issueKey||e.issue_key||e.issue),r=ET(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=fr(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${CT(e.href||e.url,t)}`}function pC(e={}){const t=fr(e.href||e.url),n=Lo(e.kind||e.type),r=am(e.source)||am(e.sourceArtifact||e.source_artifact),s=fr(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 tY(e,t){const n=pC(t)>pC(e)?t:e,r=n===t?e:t;return{...r,...n,title:hC(e.title)>=hC(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 hC(e){const t=fr(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 sw(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]=tY(r[a],s)}return r}function nY(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>_T(o)),r=sw(n,o=>CT(o.href||o.url,t)),s=sw(r,o=>fr(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return sw(s,o=>eY(o,t))}function un(e){return String(e||"").trim()}function co(e){return typeof e=="string"?un(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":un(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function AT(e){return un((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function PT(e){return un((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 mC(e){const t=un(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function Tc(e){const t=AT(e);if(/^prd-review:/i.test(t)||un((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(PT(e)))return!0;const n=un((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=un((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),s=un(e==null?void 0:e.durability).toLowerCase(),o=co(e==null?void 0:e.source)||co((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 gC(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,co(e==null?void 0:e.source)].map(un).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function rY(e){const t=AT(e);if(t)return`key:${t}`;if(Tc(e)){const n=mC(PT(e));if(n)return`review:${n}`}return`link:${un(e==null?void 0:e.label)}
183
+ ${mC((e==null?void 0:e.href)||(e==null?void 0:e.url))}`}function sY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=rY(r),o=n.get(s);if(o==null){n.set(s,t.length),t.push(r);continue}const a=t[o],l=gC(r)>=gC(a)?un(r==null?void 0:r.label)||un(a==null?void 0:a.label):un(a==null?void 0:a.label)||un(r==null?void 0:r.label);t[o]={...a,...r,...l?{label:l}:{}}}return t}function IT(e){const t=un((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=un(e==null?void 0:e.durability).toLowerCase(),r=un(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((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(un).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function iY(e){if(!Tc(e)||IT(e))return!1;const t=un((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=un(e==null?void 0:e.durability).toLowerCase(),r=un(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((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(un).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function oY(e){if(Tc(e))return!1;const t=un((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=un(e==null?void 0:e.persistence).toLowerCase(),r=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(un).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function aY(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(un).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function lY(e=[],t={}){const n=sY(Array.isArray(e)?e:[]);if(!aY(t))return n;const r=n.filter(Tc);if(r.length===0)return n;const s=r.filter(iY),a=s.length>0||n.some(oY)?s.at(-1):r.filter(IT).at(-1);return n.filter(l=>!Tc(l)||l===a)}function vi(e,t){const n=[],r=new Map,s=a=>{if(typeof a=="string")return`value:${a}`;if(!a||typeof a!="object")return"";const l=un(a.key||a.artifactKey||a.artifact_key);return l?`key:${l}`:`value:${JSON.stringify(a)}`},o=a=>{if(!a)return;const l=s(a);if(!l)return;const c=r.get(l);if(c==null){r.set(l,n.length),n.push(a);return}n[c]=a};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function lm(e){return Array.isArray(e)?e.map(lm):qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,lm(e[t])])):e}function eo(e,t){return JSON.stringify(lm(e))===JSON.stringify(lm(t))}function RT(e){return qr(e==null?void 0:e.instances)?e.instances:{}}function qd(e){return qr(e==null?void 0:e.ui)?e.ui:{}}function $p(e,t){if(!qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function cY(e,t){if(!qr(e)||!qr(t)||!qr(e.instances)||!qr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!qr(e.ui)||!qr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=$p(e,["version","instances","edges","ui"]),r=$p(t,["version","instances","edges","ui"]);if(!eo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return eo($p(e.ui,s),$p(t.ui,s))}function TT(e){const t=Array.isArray(qd(e).groups)?qd(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function yC(e){const t=new Set(Object.keys(RT(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 TT(e).keys())t.add(n);return t}function wC(e,t){const n=RT(e),r=qd(e),s=TT(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:qr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:qr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function xC(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 uY(e,t){if(!cY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...yC(e),...yC(t)]),r=Array.from(n).filter(s=>!eo(wC(e,s),wC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!eo(xC(e),xC(t)),displayPageChanged:!eo(qd(e).displayPage||null,qd(t).displayPage||null)}}function dY(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 bC(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 kC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function fY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[bC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(bC(r));return s?eo(kC(s),kC(r))?s:{...r,selected:s.selected===!0}:r})}function pY(e,t,n){const r=qr(e)?e:{},s=qr(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 mY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function MT(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 gY(e=[]){const t=MT(e);return t.mutated&&!t.active}function yY(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 wY(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 xY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(yY(s)){t.push(s);continue}n.push(s),wY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function ob(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 bY(e=[]){return ob(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 vC(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 kY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function vY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const SY="af:workspace-graph:v2",SC="agentflow.workspace.sidebarCollapsed",Dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],jY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),NY={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:""}]},CY={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:""}]},_Y={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}]},EY={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}]},AY={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}]},PY={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}]},IY=new Set(["png","jpg","jpeg","gif","webp","svg"]),$T=320,LT=180,OT=960,cm=96,DT=900,ab=520,lb=320,Lp=52,Za=240,el=160,cb="display-ref:",Ud="0 9 * * *",RY="Asia/Shanghai",TY="0.1.118";function MY(){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 $r(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 uv(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 $Y(e){const t=uv(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 dv(e,t=80){return(Array.isArray(e)?e:[]).map($Y).filter(Boolean).slice(-t)}function LY(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=dv(s.messages,40),l=uv(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 OY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=dv(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:uv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function jC(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:dv(n.messages,100),runSessions:OY(n.runSessions)},nodeChats:LY(t.nodeChats)}}function um(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 IY.has(n)}function Yd(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=$r(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function DY(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 FY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${SC}:${t}`:SC}function zY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function NC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function BY(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 HY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!BY(e)}function WY(e){const t=String(e||"").trim();if(!t||VY(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 VY(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 KY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function iw(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 ow(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function Aa(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 CC(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 qY(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 UY(e){const t=qY(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 FT(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 mc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return FT(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ua(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 ea(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 fv(e){return ua(e==null?void 0:e.status)==="done"&&ea(e)!=="observation"}function to(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 mh(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function pv(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function YY(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 GY(e,t){const n=to(e,t),r=ua(e==null?void 0:e.status),s=fv(e),a=`${tl(e)} ${pv(e)}`,l=YY(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"||ea(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"||ea(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function JY(e){if(!e||typeof e!="object")return"";const t=ua(e.status),n=ea(e),r=fv(e),o=`${tl(e)} ${pv(e)}`,a=hv(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=mh(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function dm(e){return!e||typeof e!="object"?"":String(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 zT="Asia/Shanghai",XY=new Intl.DateTimeFormat("zh-CN",{timeZone:zT,year:"numeric",month:"2-digit",day:"2-digit"}),QY=new Intl.DateTimeFormat("zh-CN",{timeZone:zT,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function BT(e){const t=dm(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function ZY(e){const t=BT(e);return t?XY.format(t).replace(/\//g,"-"):"无时间"}function eG(e){const t=BT(e);return t?QY.format(t):""}function tG(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=ZY(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 HT(e){const t=ua(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Ma(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 nG(e){const t=ua(e==null?void 0:e.status);return ea(e)==="observation"&&t==="done"?"已观察":HT(t)}function WT(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=ua(e.status),s=ea(e)==="observation"&&r==="done"?"observed":r;return n("status",HT(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Ma(e.platform),e.platform),t}function rG(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{WT(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 sG(e,t){const n=String(t||"all");return!n||n==="all"?!0:WT(e).some(r=>r.key===n)}function iG(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("平台",Ma(e.platform)),t}function hv(e){const t=[],n=(c,u,d={})=>{const f=FT(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,h)=>r(p,`${u} ${h+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",mc(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=Tc(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 h=a(p.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(p.label||"").length)&&l.set(f,c)}}return lY(Array.from(l.values()),e)}function oG(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 ub(e)){const f=_i(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=ZU({...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||Ma(d.platform),durability:y.durability||d.durability||f.durability||"",persistence:y.persistence||d.persistence||f.persistence||"",truth:y.truth||y.stateTruth||y.state_truth||ea(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:mc(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:mc(y)},{documentPath:y.path});const h=mc(d);h&&p({...d,label:d.label||d.title||d.kind||"ai-doc",href:h},{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:Ma(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:Ma(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 ub(e))o(d,{issueKey:_i(d),platform:Ma(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 nY(n,window.location.origin)}function aG(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function _i(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function lG(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||_i(e,t)||`Issue ${t+1}`).trim()}function cG(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 uG(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 dG(e){const t=hv(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 fG(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(cG(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((d,f)=>_i(d,f));return a.forEach((d,f)=>{const p=_i(d,f);l.set(p,{issue:d,children:[]})}),a.forEach((d,f)=>{const p=_i(d,f),h=uG(d)||GU(d,u),y=l.get(p);h&&l.has(h)?l.get(h).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function Gd(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 tl(e){if(!e||typeof e!="object")return"";const t=String(e.issueKey||e.issue_key||e.issue||"").trim(),n=String(e.action||e.actionId||e.action_id||Gd(e)||"").trim(),r=String(e.stageKey||e.stage_key||e.stage||e.phase||e.code||e.pointer||n).trim(),s=[r,n,e.code,e.type,e.title].map(o=>String(o||"")).join(" ").toLowerCase();if(t){if(/plan_draft_local|submit-plan|plan-doc/.test(s))return`issue-plan:${t}`;if(/gitlab_issue_missing|ensure-gitlab-issue/.test(s))return`issue-gitlab:${t}`}return r}function fm(e){const t=dm(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 ub(e){var s,o,a,l,c,u,d,f,p,h,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:f.epics,(h=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:h.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function pG(e,t){const n=String(t||"").trim();return n&&ub(e).find((r,s)=>_i(r,s)===n)||null}function hG(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 mG(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=pG(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=hG(e);if(!a&&!l)return o;const c=tl(o),u=`${c} ${pv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const p=ua(o.status),h=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...a?{gitlabIssue:a,gitlab_issue:a}:{},...l?{gitlabEpic:l,gitlab_epic:l}:{},...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:vi(o.artifacts,f)}}function _C(e,t){const n=fm(t),r=fm(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:to(s,0)||to(t,0)||to(e,0),detail:mh(s)||mh(t)||mh(e),status:o,links:vi(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:vi(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:vi(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:vi(e==null?void 0:e.results,t==null?void 0:t.results),events:vi(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 gG(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=f=>{var p,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||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)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,p)=>({...f,links:vi(f==null?void 0:f.links,p==null?void 0:p.links),artifacts:vi(f==null?void 0:f.artifacts,p==null?void 0:p.artifacts),outputs:vi(f==null?void 0:f.outputs,p==null?void 0:p.outputs),results:vi(f==null?void 0:f.results,p==null?void 0:p.results)}),c=(f,p)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],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 h=tl(p);if(a(p)){c(h,p);continue}const y=String(p.id||p.eventId||p.event_id||p.actionId||p.action_id||"").trim(),v=h||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(h,_C(n[b],p)),h&&r.set(h,b),y&&s.set(y,b)):(v&&r.set(v,n.length),y&&s.set(y,n.length),n.push(u(h,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=Gd(t),p=tl(t),h=p?r.get(p):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=_C(n[h],y))}return n.map((f,p)=>({item:f,index:p,ts:fm(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>mG(e,f.item))}function yG(e){return(Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[]).filter(n=>n&&typeof n=="object").map((n,r)=>({item:n,index:r,ts:fm(n)})).sort((n,r)=>{const s=Number.isFinite(n.ts),o=Number.isFinite(r.ts);return s&&o?r.ts-n.ts||r.index-n.index:s?-1:o?1:r.index-n.index}).slice(0,8).map(n=>n.item)}function wG(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 xG(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)?`(+${Aa(r)} / 总 ${Aa(s)})`:"";return`${t+1}. ${n}${o}`}function VT(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 Fl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function bG(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 kG(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 vG(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 SG(e){var o,a,l;const t=VT(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Fl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=kG(t),u=bG(t),d=Fl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Fl(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)||{},h=Number.isFinite(d)&&Number.isFinite(f)?Math.max(0,f-d):Fl(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:vG(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Fl(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 EC(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=Fl(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),h=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...s.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${Aa(u)}`),d>0&&v.push(`- 模型相关间隔:约 ${Aa(d)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${Aa(p)}(${f.length} 次完成事件)`),h>0&&v.push(`- 网络/会话恢复事件:${h} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${Aa(b.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((b,g)=>{v.push(xG(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${Aa(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
188
+ `)}function AC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=VT(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 KT(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 qT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function mv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function UT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function jG(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 NG(e){const t=String(e??"").trim();return t?t.includes("${")?t:UT(t):""}function YT(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(NG).filter(Boolean):[];return[jG(t,n),UT(o),...a].join(" ")}return String(t.command||"").trim()}function Vu(e){const t=String(mv(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 PC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function pm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Ku(e){return pm(e)}function db(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Op(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 IC(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 RC(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 aw(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=nb(s.get(n),e.sourceHandle||"output-0","source"),a=nb(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&Kd(o,a))}function CG(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=nb(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:Kq(a)}:null}function _G(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"?Kd(t.slot,a):Kd(a,t.slot)))continue;const c=Vu(n);return{def:n,order:r,category:c,categoryRank:Dl.indexOf(c),slot:a,slotIndex:o,displayLabel:Ku(n),description:db(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 EG(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?Kd(n.slot,p):Kd(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,j,N,C;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),h=Number(((j=(x=u.node)==null?void 0:x.position)==null?void 0:j.x)||0),y=Number(((C=(N=d.node)==null?void 0:N.position)==null?void 0:C.x)||0);return f-p||h-y||u.slotIndex-d.slotIndex||String(u.nodeId).localeCompare(String(d.nodeId))})}function nc(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 AG(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 PG(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function IG(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return Ud;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} * * *`:Ud}function Fo(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 gv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Fo(t[1],9,0,23)}:${Fo(t[2],0,0,59)}`:"09:00"}function qu(e,t,n,r,s){const o=gv(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()||Ud:`${l} ${a} * * *`}function RG(e){const n=String(e||Ud).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?`${Fo(u,9,0,23)}:${Fo(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 yv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=IG(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=RG(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=gv(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=qu(l,c,u,d,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:d,cron:f,timezone:RY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function TG(e){const t=yv(JSON.stringify(e||{}));return JSON.stringify(t)}function MG(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function $G(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function TC(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 Dp(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:TC(n.nextRunAt),lastAt:TC(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 hm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function mm(e){return e>0?`Group ${e+1}`:"Group"}function LG(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)||mm(r)).trim()||mm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(Za,Math.round(l)),height:Math.max(el,Math.round(c))}}).filter(Boolean)}function OG(e){var n;return LG((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:hc,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 fb(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(Za,Math.round(t)),height:Math.max(el,Math.round(n))}}function Uu(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:PG(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 GT(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 DG(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=cg(t);return[GT(e),Rn(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 MC(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 FG=new Map,zG=[];function Ru(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=QT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(h=e==null?void 0:e.ui)!=null&&h.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(y=e==null?void 0:e.ui)!=null&&y.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const v of s)v!=null&&v.source&&l.add(String(v.source)),v!=null&&v.target&&l.add(String(v.target));const u=Array.from(l).map(v=>{const b=r[v]||{},g=b.definitionId||v,k=t.find(D=>D.id===g),x=mv(k)||g,j=t.find(D=>D.id===x)||k,N=b.marketplaceRef||qT(k),C=YT(k),I=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=!!Rn({definitionId:x,inputs:b.input,outputs:b.output}),H=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,A=Ba(H,{display:R}),L=A&&!ti(x);return{id:v,type:hc,position:I,...L?{width:A.width,height:A.height}:{},data:{label:b.label||pm(k)||pm(j)||v,definitionId:x,...N?{marketplaceRef:N}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:KT(x,j||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||C||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...L?{nodeSize:A}:{},...R&&L?{displaySize:A}:{}}}}).map(v=>sb(v,r,t)),d=OG(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:bi.ArrowClosed}})),p=[...d,...u];return{nodes:p,edges:yU(f,p),instances:r}}function $C(e){return`${cb}${e}`}function Fp(e){const t=String(e||"");return t.startsWith(cb)?t.slice(cb.length):t}function pb(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function gh(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var p;return nl((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 h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.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=Ba(u[f],{display:!0});p&&(c[f]=p)});const d=pb(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...d?{viewport:d}:{}}}function LC(e,t=[]){return gh(e,t)}const lw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function cw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function OC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function DC(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 BG(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function FC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const JT="af:workspace:canvas-clipboard",XT="agentflow.workspace.canvas-clipboard";function HG(e){return JSON.stringify({type:XT,version:1,clipboard:e})}function WG(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==XT)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function VG(e){try{localStorage.setItem(JT,HG(e))}catch{}}function KG(){try{return WG(localStorage.getItem(JT))}catch{return null}}function qG(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function hb(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 zC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Ba(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:zC(n,LT,OT)||$T,height:zC(r,cm,DT)||cm}}function gm(e){const t=Ba(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function UG(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:ab,height:lb}}function YG(e,t=""){const n=gm(e==null?void 0:e.displaySize);if(n)return n;const r=gm(e==null?void 0:e.nodeSize);if(r)return r;const s=nl(t)||yf(na((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return UG(s)}function zl(e){var s,o,a,l,c,u,d,f,p,h,y;if(ti((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!Rn(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)||((h=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return Ba({width:n,height:r},{display:t})}function $l(e,t,n){var d,f,p,h,y,v,b,g,k,x,j,N,C;const r=(e||[]).filter(I=>!hm(I)),s=(e||[]).filter(hm),o=QT(lv(r,n||{})),a=t.map(I=>({source:I.source,target:I.target,sourceHandle:I.sourceHandle??null,targetHandle:I.targetHandle??null})).filter(I=>!s.some(R=>R.id===I.source||R.id===I.target)),l={},c={},u=[];for(const I of r){l[I.id]={x:((d=I.position)==null?void 0:d.x)||0,y:((f=I.position)==null?void 0:f.y)||0};const R=zl(I);R&&(c[I.id]=R)}for(const I of s){const R=Number(((h=(p=I.data)==null?void 0:p.nodeSize)==null?void 0:h.width)||I.width||((y=I.measured)==null?void 0:y.width)||0),H=Number(((b=(v=I.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||I.height||((g=I.measured)==null?void 0:g.height)||0);u.push({id:I.id,title:String(((k=I.data)==null?void 0:k.title)||((x=I.data)==null?void 0:x.label)||"Group"),color:String(((j=I.data)==null?void 0:j.color)||"purple"),x:Number(((N=I.position)==null?void 0:N.x)||0),y:Number(((C=I.position)==null?void 0:C.y)||0),width:Math.max(Za,Math.round(R||Za)),height:Math.max(el,Math.round(H||el))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function QT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!nl(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 nl(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 Rn(e){const t=nl(e==null?void 0:e.definitionId);return t||(ti(e==null?void 0:e.definitionId)&&cg(e)?yf(na((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function no(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=Rn(e),r=ti(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 ta(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 GG(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 Ei(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=GG(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 rl(e,t){const n=$r(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 mb(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 JG(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 Wc(e){let t=Ei(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 XG(e){const t=Wc(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function $a(e,t){return e==="html"?XG(t):""}function ZT(e,t=""){const n=Wc(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 QG(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 ZG(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function eJ(e,t){const n=URL.createObjectURL(e);try{ZG(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function eM(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 tJ(e){const t=eM(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 uw(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 nJ(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=eM(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:uw(c),displayBody:uw(u),scroller:uw(d)},h=[Number(t)||0,Number((f==null?void 0:f.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((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,...h.length?h:[960]),v=Math.max(1,Math.round(Number(n)||(s==null?void 0:s.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:y,height:v,debug:p}}async function rJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=nJ(r,s,o,{...l||{},displaySize:c}),d=tJ(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 h=await f.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const p=await f.blob();eJ(p,a)}function sJ(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 tM(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 iJ(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 nM({code:e}){const t=m.useMemo(()=>iJ(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),h=l.get(d.to);if(!p||!h)return null;const y=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return i.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${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 fi({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.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 h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.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=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var j,N;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=d.pointerId;(N=(j=d.currentTarget).setPointerCapture)==null||N.call(j,g);const k=C=>{C.preventDefault(),l(c(C.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 rM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Rn(e),o=no(e),a=s==="image"?o:Ei(o),l=s==="image"?"":ta(a,s),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1);m.useEffect(()=>{let k=!1;return l?(h(!0),f(""),u(""),rl(t,l).then(x=>{k||u(x)}).catch(x=>{k||f(String(x.message||x))}).finally(()=>{k||h(!1)}),()=>{k=!0}):(u(""),f(""),h(!1),()=>{k=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const y=l?c:a,v=s==="html"?Wc(y):s==="react"?lg(y):Ei(y),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=$a(s,v);if(p)return i.jsxs(fi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(d)return i.jsx(fi,{className:"af-work-display-empty",children:d});if(g)return i.jsx(fi,{className:"af-work-display-empty",children:g});if(!v.trim())return i.jsx(fi,{className:"af-work-display-empty",children:"No display content"});if(s==="html"||s==="react")return i.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:i.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(s==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:s==="react"?cv(v,b.current):ZT(v,b.current)},r)});if(s==="image"){const k=Yd(v,t);return i.jsx(fi,{className:"af-work-display-body af-work-display-body--image",children:i.jsx("img",{className:"af-work-display-image",src:k,alt:sJ(e),loading:"lazy"})})}return s==="markdown"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(rv,{content:v,basePath:l,resolveSrc:(k,x)=>Yd(k,t,x)})}):s==="chart"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(iv,{content:v})}):s==="table"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(sv,{content:v})}):s==="mermaid"?i.jsxs(fi,{className:"af-work-display-body",children:[i.jsx(nM,{code:v}),i.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):i.jsx(fi,{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 oJ({node:e,onClose:t}){var k,x,j,N,C,I,R,H,A,L,D;const n=m.useRef(null),r=Rn(e==null?void 0:e.data),s=((k=e==null?void 0:e.data)==null?void 0:k.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),o=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1),y=no(e==null?void 0:e.data),v=r==="markdown"?Ei(y):"",b=r==="markdown"?ta(v,"markdown"):"",g=r==="markdown"?b?d:v:"";return m.useEffect(()=>{const O=M=>{if(M.key==="Escape"){if(a){u(String(g||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[g,a,t]),m.useEffect(()=>{var M;let O=!1;return r!=="markdown"||!b?(f(""),h(!1),()=>{O=!0}):(h(!0),rl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},b).then(K=>{O||f(K)}).catch(K=>{var z,F;O||(f(""),(F=(z=e==null?void 0:e.data)==null?void 0:z.onStatus)==null||F.call(z,String(K.message||K)))}).finally(()=>{O||h(!1)}),()=>{O=!0})},[r,b,(N=(j=e==null?void 0:e.data)==null?void 0:j.flowParams)==null?void 0:N.flowId,(I=(C=e==null?void 0:e.data)==null?void 0:C.flowParams)==null?void 0:I.flowSource,(H=(R=e==null?void 0:e.data)==null?void 0:R.flowParams)==null?void 0:H.archived,(A=e==null?void 0:e.data)==null?void 0:A.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?ur.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:tM(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 O,M;try{await iM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:f}),l(!1)}catch(K){(M=(O=e==null?void 0:e.data)==null?void 0:O.onStatus)==null||M.call(O,String(K.message||K))}},"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(sM,{value:c,onChange:u,onUploadImage:(L=e.data)==null?void 0:L.onUploadWorkspaceImage,readOnly:o}):i.jsx(rM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function aJ({node:e}){var p,h,y,v,b,g,k,x,j,N;const t=Rn(e==null?void 0:e.data),n=no(e==null?void 0:e.data),r=t==="image"?n:Ei(n),s=t==="image"?"":ta(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var I;let C=!1;return s?(c(!0),a(""),rl(((I=e==null?void 0:e.data)==null?void 0:I.flowParams)||{},s).then(R=>{C||a(R)}).catch(()=>{C||a("")}).finally(()=>{C||c(!1)}),()=>{C=!0}):(a(""),c(!1),()=>{C=!0})},[s,(h=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:h.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:g.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const u=s?o:r,d=t==="html"?Wc(u):t==="react"?lg(u):Ei(u),f=$a(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"?cv(d):ZT(d)}):t==="image"?i.jsx("img",{src:Yd(d,(j=e==null?void 0:e.data)==null?void 0:j.flowParams),alt:((N=e==null?void 0:e.data)==null?void 0:N.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(rv,{content:d,basePath:s,resolveSrc:(C,I)=>{var R;return Yd(C,(R=e==null?void 0:e.data)==null?void 0:R.flowParams,I)}})}):t==="chart"?i.jsx(iv,{content:d}):t==="table"?i.jsx(sv,{content:d}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(nM,{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 sM({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,d]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const g=s.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),j=k>x+1,N=j?Math.max(12,x/k*100):100,C=Math.max(0,100-N),I=j?Math.min(C,g.scrollTop/Math.max(1,k-x)*C):0;d({visible:j,top:I,height:N})},[]);m.useEffect(()=>{const g=requestAnimationFrame(f),k=s.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(f);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[f,e]);const p=m.useCallback(g=>{const k=s.current;if(!k)return;const x=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*x,f()},[f]),h=m.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const j=x.getBoundingClientRect(),N=u.height/100*j.height,C=Math.max(1,j.height-N);return(g-j.top-k)/C},[u.height]),y=m.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),j=u.top/100*x.height,N=u.height/100*x.height,I=g.clientY>=x.top+j&&g.clientY<=x.top+j+N?g.clientY-x.top-j:N/2;p(h(g.clientY,I));const R=A=>{A.preventDefault(),p(h(A.clientY,I))},H=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",H),window.removeEventListener("pointercancel",H)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",H),window.addEventListener("pointercancel",H)},[h,p,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),x=s.current,j=Number((x==null?void 0:x.selectionStart)??k.length),N=Number((x==null?void 0:x.selectionEnd)??j),C=k.slice(0,j),I=k.slice(N),R=C&&!C.endsWith(`
243
+ `)?`
244
+ `:"",H=I&&!I.startsWith(`
245
+ `)?`
246
+ `:"",A=`${C}${R}${g}${H}${I}`;t==null||t(A),window.requestAnimationFrame(()=>{var D,O;const L=C.length+R.length+g.length;(D=s.current)==null||D.focus(),(O=s.current)==null||O.setSelectionRange(L,L)})},[t,e]),b=m.useCallback(async g=>{if(!r&&!(!g||l)){c(!0);try{const k=await(n==null?void 0:n(g)),x=String(k||"").trim();if(x){const j=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(`![${j}](${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(j=>String((j==null?void 0:j.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(um);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 lJ({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=m.useState(a),u=m.useRef(!1),d=String(s.candidateContent||""),f=!!s.running,p=!!(t!=null&&t.readOnly),h=String(s.error||""),y=o.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?i.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:v=>v.stopPropagation(),children:[i.jsxs("div",{className:"af-work-node-chat__head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"继续微调"}),i.jsx("span",{children:(t==null?void 0:t.label)||e})]}),i.jsx("button",{type:"button",onClick:()=>{var v;return(v=t==null?void 0:t.onCloseNodeChat)==null?void 0:v.call(t)},"aria-label":"关闭节点微调",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||f||h?i.jsxs("div",{className:"af-work-node-chat__messages",children:[y.map((v,b)=>i.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${v.role==="assistant"?"assistant":"user"}`,children:[i.jsx("span",{children:v.role==="assistant"?"AI":"你"}),i.jsx("p",{children:v.text})]},`${v.at||b}-${b}`)),f?i.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?i.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,i.jsxs("div",{className:"af-work-node-chat__composer",children:[i.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f||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 cJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function uJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function dJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function BC(e,t=""){const n=ta(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function fJ(e,t){const n=dJ(e),r=new Set,s=Rn(t)||"";ti(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=BC(no(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=BC(u,s);return d&&r.add(d),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function HC(e,t){const n=Rn(t)||"markdown";return`outputs/${uJ((t==null?void 0:t.label)||e||n)}.${cJ(n)}`}async function iM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await mb((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 oM({id:e,data:t,selected:n,deleteNode:r}){var ee,te,ne;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((Z,ce)=>({slot:Z,idx:ce})).sort((Z,ce)=>{var _e,Be,ot,gt;const de=String(((_e=Z.slot)==null?void 0:_e.name)||"").trim(),me=String(((Be=ce.slot)==null?void 0:Be.name)||"").trim();if(de==="next"&&me!=="next")return-1;if(me==="next"&&de!=="next")return 1;const $e=String(((ot=Z.slot)==null?void 0:ot.type)||"").trim(),Ce=String(((gt=ce.slot)==null?void 0:gt.type)||"").trim();return $e==="node"&&Ce!=="node"?-1:Ce==="node"&&$e!=="node"?1:Z.idx-ce.idx}),l=Rn(t),c=m.useRef(null),u=m.useRef(null),[d,f]=m.useState(0),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(!1),[k,x]=m.useState(""),[j,N]=m.useState(""),[C,I]=m.useState(!1),[R,H]=m.useState(!1),A=m.useRef(null),L=no(t),D=l==="markdown"?Ei(L):"",O=l==="markdown"?ta(D,"markdown"):"",M=l==="markdown"?O?j:D:"",K=!!(t!=null&&t.readOnly),z=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let Z=!1;return l!=="markdown"||!O?(N(""),I(!1),()=>{Z=!0}):(I(!0),rl((t==null?void 0:t.flowParams)||{},O).then(ce=>{Z||N(ce)}).catch(ce=>{var de;Z||(N(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(ce.message||ce)))}).finally(()=>{Z||I(!1)}),()=>{Z=!0})},[l,O,(ee=t==null?void 0:t.flowParams)==null?void 0:ee.flowId,(te=t==null?void 0:t.flowParams)==null?void 0:te.flowSource,(ne=t==null?void 0:t.flowParams)==null?void 0:ne.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!y)return;const Z=()=>v(!1);return window.addEventListener("pointerup",Z,!0),window.addEventListener("pointercancel",Z,!0),window.addEventListener("mouseup",Z,!0),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointerup",Z,!0),window.removeEventListener("pointercancel",Z,!0),window.removeEventListener("mouseup",Z,!0),window.removeEventListener("blur",Z)}},[y]),m.useEffect(()=>{b||x(String(M||""))},[M,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),$=String((t==null?void 0:t.sourceNodeId)||e),W=(t==null?void 0:t.sharingDisplayNodeId)===$,E=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Te,st,mt,Rt,xe,Oe,ie,ke,Ke,Ue;if(l!=="html"||p)return;const Z=no(t),ce=ta(Z,l);let de=Z;if(ce)try{de=await rl((t==null?void 0:t.flowParams)||{},ce)}catch(be){h(!1),console.warn("Failed to read HTML display file before saving image.",be);return}const me=Wc(de);if(!me.trim())return;const $e=$a(l,me);if($e){console.warn($e);return}const Ce=(st=(Te=u.current)==null?void 0:Te.getBoundingClientRect)==null?void 0:st.call(Te),_e=(Rt=(mt=c.current)==null?void 0:mt.querySelector)==null?void 0:Rt.call(mt,".af-work-display-body"),Be=(Oe=(xe=c.current)==null?void 0:xe.querySelector)==null?void 0:Oe.call(xe,".af-visible-scroll-frame__scroller"),ot=Math.round(Math.max(Number((Ce==null?void 0:Ce.width)||0),Number((E==null?void 0:E.width)||0),Number(((ie=c.current)==null?void 0:ie.clientWidth)||0),Number((_e==null?void 0:_e.clientWidth)||0),Number((Be==null?void 0:Be.clientWidth)||0),Math.max(320,Number((E==null?void 0:E.width)||960)-2))),gt=Math.round(Math.max(Number((Ce==null?void 0:Ce.height)||0),Number((E==null?void 0:E.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((_e==null?void 0:_e.clientHeight)||0),Number((Be==null?void 0:Be.clientHeight)||0),Math.max(180,Number((E==null?void 0:E.height)||640)-46)));h(!0);try{await rJ({flowParams:(t==null?void 0:t.flowParams)||{},content:me,sourceFilePath:ce,iframe:u.current,width:ot,height:gt,filename:QG((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:_e,scroller:Be},displaySize:E}),(Ke=t==null?void 0:t.onStatus)==null||Ke.call(t,"已导出 HTML 展示截图")}catch(be){const Pt=String((be==null?void 0:be.message)||be||"截图失败");(Ue=t==null?void 0:t.onStatus)==null||Ue.call(t,`HTML 截图失败:${Pt}`),console.warn("Failed to save HTML display as PNG.",be)}finally{h(!1)}},[t,E==null?void 0:E.height,E==null?void 0:E.width,e,l,p]),V=m.useCallback(Z=>{var ce;K||!Z||l!=="image"||(ce=t==null?void 0:t.onUploadImageToDisplayNode)==null||ce.call(t,e,Z)},[t,e,l,K]),B=m.useCallback(Z=>{var ce,de;(ce=Z==null?void 0:Z.stopPropagation)==null||ce.call(Z),!K&&((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,K]),se=m.useCallback(Z=>{var me,$e;K||l!=="image"||!(Array.from(((me=Z.dataTransfer)==null?void 0:me.files)||[]).some(um)||Array.from((($e=Z.dataTransfer)==null?void 0:$e.items)||[]).some(Ce=>String((Ce==null?void 0:Ce.type)||"").startsWith("image/")))||(Z.preventDefault(),Z.stopPropagation(),Z.dataTransfer.dropEffect="copy",H(!0))},[l,K]),ue=m.useCallback(Z=>{l==="image"&&(Z.currentTarget.contains(Z.relatedTarget)||H(!1))},[l]),G=m.useCallback(Z=>{var de;if(l!=="image")return;const ce=Array.from(((de=Z.dataTransfer)==null?void 0:de.files)||[]).find(um);ce&&(Z.preventDefault(),Z.stopPropagation(),H(!1),V(ce))},[l,V]);return i.jsxs("div",{className:"af-work-display-card"+(E?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(R?" af-work-display-card--image-drop":"")+(z?" 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:E?{width:E.width,height:E.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:se,onDragLeave:ue,onDrop:G,children:[i.jsx(Bk,{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((Z,ce)=>{if(Z.showOnNode===!1)return null;const de=`${4.15+ce*1.75}rem`,me=Z.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:de},children:me}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:Mn(Z.type)},title:`${me} · ${Z.type}`})]},`in-${ce}`)}),a.map(({slot:Z,idx:ce},de)=>{if(Z.showOnNode===!1)return null;const me=`${4.15+de*1.75}rem`,$e=Z.name||`#${ce+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:me},children:$e}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:me,background:Mn(Z.type)},title:`${$e} · ${Z.type}`})]},`out-${ce}`)}),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:tM(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:Z=>Z.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Z,ce,de,me;try{(me=(de=(ce=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:ce.history)==null?void 0:de.back)==null||me.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 Z,ce,de,me;try{(me=(de=(ce=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:ce.history)==null?void 0:de.forward)==null||me.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(Z=>Z+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:Z=>Z.stopPropagation(),children:[i.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:K||C,onClick:async()=>{var Z;try{await iM({nodeId:e,data:t,filePath:O,content:k,setFileContent:N}),g(!1)}catch(ce){(Z=t==null?void 0:t.onStatus)==null||Z.call(t,String(ce.message||ce))}},"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:K||C,onClick:Z=>{Z.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:A,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Z=>{var de;const ce=(de=Z.target.files)==null?void 0:de[0];Z.target.value="",ce&&V(ce)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:K,onClick:Z=>{var ce;Z.stopPropagation(),(ce=A.current)==null||ce.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:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onOpenDisplayPreview)==null||ce.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:W,onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onShareDisplayNode)==null||ce.call(t,$)},"aria-label":"分享展示",title:"分享展示",children:i.jsx("span",{className:"material-symbols-outlined",children:W?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:K,onClick:B,"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:K,onClick:()=>{var Z;return(Z=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:Z.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:K,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?i.jsx(sM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:K}):i.jsx(rM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),i.jsx(lJ,{nodeId:e,data:t})]})}function pJ({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((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:b}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:Mn(h.type)},title:`${b} · ${h.type}`})]},`in-${y}`)}),o.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:b}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:Mn(h.type)},title:`${b} · ${h.type}`})]},`out-${y}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-run-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:h=>{var y,v;h.stopPropagation(),a?(y=t==null?void 0:t.onStopWorkspaceNode)==null||y.call(t,e):(v=t==null?void 0:t.onRunWorkspaceNode)==null||v.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),i.jsx("span",{children:a?"Stop":"Run line"})]}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOptimizeWorkspaceRun)==null||y.call(t,e)},children:i.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),i.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||y.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:i.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function hJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var Ue,be,Pt,tn,Wt,Lt,an;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=PJ(t),[d,f]=m.useState(u.task),p=m.useRef(!1),h=m.useRef(u.task),y=((be=(Ue=t==null?void 0:t.runningRunNodeIds)==null?void 0:Ue.has)==null?void 0:be.call(Ue,e))||((Pt=t==null?void 0:t.runningRunNodeIds)==null?void 0:Pt[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",v=(t==null?void 0:t.nodeStatus)==="stopped",b=!!(t!=null&&t.readOnly),g=Array.isArray(s)?s:[],k=Array.isArray(o)?o:[],x=m.useMemo(()=>(Array.isArray(a)?a:[]).map(re=>({id:String((re==null?void 0:re.id)||""),label:String((re==null?void 0:re.label)||(re==null?void 0:re.name)||"知识库"),kind:(re==null?void 0:re.kind)==="git"?"git":"local",path:String((re==null?void 0:re.path)||""),repoUrl:String((re==null?void 0:re.repoUrl)||""),branch:String((re==null?void 0:re.branch)||""),mountPath:String((re==null?void 0:re.mountPath)||""),builtin:(re==null?void 0:re.builtin)===!0,exists:(re==null?void 0:re.exists)!==!1,type:String((re==null?void 0:re.type)||"")})).filter(re=>re.path),[a]),[j,N]=m.useState(!1),[C,I]=m.useState(""),[R,H]=m.useState(()=>new Set),[A,L]=m.useState(!1),[D,O]=m.useState(""),[M,K]=m.useState("config"),z=cg(t),F=!!z,$=pM(u.displayType),W=m.useMemo(()=>YG(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,$]),E=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:$,displaySize:W,nodeSize:W,body:z,inputs:[{type:"text",name:$==="display_image"?"src":"content",value:z,default:z}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,$,e,z,c,W]),Q=Array.isArray((tn=t==null?void 0:t.modelLists)==null?void 0:tn.cursor)?t.modelLists.cursor:[],V=Array.isArray((Wt=t==null?void 0:t.modelLists)==null?void 0:Wt.opencode)?t.modelLists.opencode:[],B=Array.isArray((Lt=t==null?void 0:t.modelLists)==null?void 0:Lt.claudeCode)?t.modelLists.claudeCode:[],se=Array.isArray((an=t==null?void 0:t.modelLists)==null?void 0:an.codex)?t.modelLists.codex:[],ue=m.useMemo(()=>new Set(Q.map(Ss)),[Q]),G=m.useMemo(()=>new Set(V.map(Ss)),[V]),ee=m.useMemo(()=>new Set(B.map(Ss)),[B]),te=m.useMemo(()=>new Set(se.map(Ss)),[se]),ne=u.model,Z=m.useMemo(()=>ne?ne.startsWith("cursor:")||ne.startsWith("opencode:")||ne.startsWith("codex:")||ne.startsWith("claude-code:")?ne:ee.has(ne)?`claude-code:${ne}`:te.has(ne)?`codex:${ne}`:G.has(ne)?`opencode:${ne}`:ue.has(ne)?`cursor:${ne}`:ne:"",[ee,te,ue,G,ne]),ce=ne.startsWith("cursor:")?ne.slice(7):ne.startsWith("opencode:")?ne.slice(9):ne.startsWith("codex:")?ne.slice(6):ne.startsWith("claude-code:")?ne.slice(12):ne,de=ce,me=!!ne&&!ue.has(de)&&!G.has(de)&&!ee.has(de)&&!te.has(de),$e=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ce=m.useMemo(()=>new Map(g.map(re=>[re.key,re])),[g]),_e=m.useMemo(()=>{const re=new Set,Re=k.map(Ze=>{const Tt=Zo(Ze,g).map(_t=>Ce.get(_t)).filter(Boolean);for(const _t of Tt)re.add(_t.key);return{...Ze,skills:Tt}}).filter(Ze=>Ze.skills.length>0),Je=g.filter(Ze=>!re.has(Ze.key));return{collectionGroups:Re,ungrouped:Je}},[k,Ce,g]);m.useEffect(()=>{H(re=>{let Re=!1;const Je=new Set(re);for(const Ze of _e.collectionGroups)Je.has(Ze.id)||(Je.add(Ze.id),Re=!0);return Re?Je:re})},[_e.collectionGroups]);const Be=m.useMemo(()=>{const re=C.trim().toLowerCase();if(!re)return _e;const Re=Ze=>[Ze==null?void 0:Ze.key,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(Tt=>String(Tt||"").toLowerCase()).join(" ").includes(re);return{collectionGroups:_e.collectionGroups.map(Ze=>{const Tt=[Ze==null?void 0:Ze.id,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(_t=>String(_t||"").toLowerCase()).join(" ").includes(re);return{...Ze,skills:Tt?Ze.skills:Ze.skills.filter(Re)}}).filter(Ze=>Ze.skills.length>0),ungrouped:_e.ungrouped.filter(Re)}},[_e,C]),ot=gb(j,[Be.collectionGroups.length,Be.ungrouped.length,R.size,u.skillKeys.length,C]),gt=m.useMemo(()=>{const re=D.trim().toLowerCase();return re?x.filter(Re=>[Re.id,Re.label,Re.path,Re.repoUrl,Re.branch,Re.mountPath,Re.type].join(" ").toLowerCase().includes(re)):x},[x,D]),Te=m.useMemo(()=>yM(u.knowledgeContext),[u.knowledgeContext]),st=m.useMemo(()=>new Set(Te.map(re=>re.id||re.path||re.repoPath).filter(Boolean)),[Te]),mt=gb(A,[gt.length,Te.length,D]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,p.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!F){K("config");return}y||K("result")},[F,z,y]),m.useEffect(()=>{var Re,Je;if(!(M==="result"&&F))return;(Re=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Re.call(t,e,W),(Je=t==null?void 0:t.onRefreshNodeInternals)==null||Je.call(t,e);const re=window.setTimeout(()=>{var Ze;return(Ze=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:Ze.call(t,e)},120);return()=>window.clearTimeout(re)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,$,F,e,z,W,M]);const Rt=re=>{var Re;(Re=t==null?void 0:t.onChangeContextRunConfig)==null||Re.call(t,e,{...u,task:d,...re})},xe=(re=d)=>{var Je;const Re=String(re??"");Re!==u.task&&(h.current=Re,(Je=t==null?void 0:t.onChangeContextRunConfig)==null||Je.call(t,e,{...u,task:Re}))},Oe=(re,Re)=>{const Je=new Set(u.skillKeys);for(const Ze of re){const Tt=String(Ze||"").trim();Tt&&(Re?Je.add(Tt):Je.delete(Tt))}Rt({skillKeys:Array.from(Je)})},ie=re=>{H(Re=>{const Je=new Set(Re);return Je.has(re)?Je.delete(re):Je.add(re),Je})},ke=(re,Re)=>{const Je=(re==null?void 0:re.id)||(re==null?void 0:re.path)||"";if(!Je)return;const Ze=x.filter(Tt=>{const _t=Tt.id||Tt.path||"";return _t===Je?Re:st.has(_t)});Rt({knowledgeContext:ug(Ze)})},Ke=()=>{Rt({knowledgeContext:null})};return M==="result"&&F?i.jsx(oM,{id:e,data:{...E,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((re,Re)=>{if(re.showOnNode===!1)return null;const Je=`${2.25+Re*1.75}rem`,Ze=re.name||`#${Re+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Je},children:Ze}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${Re}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Je,background:Mn(re.type)},title:`${Ze} · ${re.type}`})]},`in-${Re}`)}),c.map((re,Re)=>{if(re.showOnNode===!1)return null;const Je=`${2.25+Re*1.75}rem`,Ze=re.name||`#${Re+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Je},children:Ze}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${Re}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Je,background:Mn(re.type)},title:`${Ze} · ${re.type}`})]},`out-${Re}`)}),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:re=>re.stopPropagation(),onMouseDown:re=>re.stopPropagation(),onClick:re=>re.stopPropagation(),children:[i.jsxs("select",{className:"af-work-context-run-card__model",value:Z,disabled:b,"aria-label":"模型",title:ce||"默认模型",onChange:re=>Rt({model:re.target.value}),children:[i.jsx("option",{value:"",children:"默认"}),me?i.jsx("option",{value:ne,children:ne}):null,Q.length?i.jsx("optgroup",{label:"Cursor",children:Q.map(re=>i.jsx("option",{value:`cursor:${Ss(re)}`,children:Ss(re)},`context-cursor-${re}`))}):null,V.length?i.jsx("optgroup",{label:"OpenCode",children:V.map(re=>i.jsx("option",{value:`opencode:${Ss(re)}`,children:Ss(re)},`context-opencode-${re}`))}):null,se.length?i.jsx("optgroup",{label:"Codex",children:se.map(re=>i.jsx("option",{value:`codex:${Ss(re)}`,children:Ss(re)},`context-codex-${re}`))}):null,B.length?i.jsx("optgroup",{label:"Claude Code",children:B.map(re=>i.jsx("option",{value:`claude-code:${Ss(re)}`,children:Ss(re)},`context-claude-${re}`))}):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:ti(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:re=>re.stopPropagation(),children:[i.jsx("button",{type:"button",className:M==="config"?"is-active":"",onClick:()=>K("config"),"aria-label":"切换到任务配置",children:i.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),i.jsx("button",{type:"button",className:M==="result"?"is-active":"",onClick:()=>K("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:re=>{p.current=!1,f(re.currentTarget.value),xe(re.currentTarget.value)},onChange:re=>{f(re.target.value)},onBlur:re=>xe(re.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:re=>{var Re;re.stopPropagation(),j||(Re=t==null?void 0:t.onRefreshSkills)==null||Re.call(t),N(Je=>!Je)},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"})]}),j?i.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:re=>re.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:C,onChange:re=>I(re.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),C?i.jsx("button",{type:"button",onClick:()=>I(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:ot.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:ot.updateMenuScrollbar,children:[Be.collectionGroups.map(re=>{const Re=re.skills.map(_t=>_t.key),Je=Re.filter(_t=>$e.has(_t)).length,Ze=Re.length>0&&Je===Re.length,Tt=R.has(re.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Tt?" 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:Ze,disabled:b,onChange:_t=>Oe(Re,_t.target.checked),"aria-label":`选择 ${re.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>ie(re.id),"aria-expanded":!Tt,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:re.name}),re.description?i.jsx("em",{children:re.description}):null]})}),i.jsxs("small",{children:[Je,"/",Re.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>ie(re.id),"aria-label":Tt?`展开 ${re.name}`:`收起 ${re.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Tt?"chevron_right":"expand_more"})})]}),Tt?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:re.skills.map(_t=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:$e.has(_t.key),disabled:b,onChange:Kn=>Oe([_t.key],Kn.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:_t.name}),_t.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:_t.description}):null]})]},`${re.id}:${_t.key}`))})]},re.id)}),Be.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:Be.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:Be.ungrouped.map(re=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:$e.has(re.key),disabled:b,onChange:Re=>Oe([re.key],Re.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:re.name}),re.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:re.description}):null]})]},`ungrouped:${re.key}`))})]}):null,Be.collectionGroups.length===0&&Be.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:()=>Rt({skillKeys:[]}),children:"清空"})]}),i.jsx("div",{ref:ot.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(ot.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:ot.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${ot.scrollbar.height}%`,top:`${ot.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:re=>{var Re;re.stopPropagation(),A||(Re=t==null?void 0:t.onRefreshWorkspaces)==null||Re.call(t),L(Je=>!Je)},children:[i.jsx("span",{className:"material-symbols-outlined",children:Te.length?"folder_open":"folder_off"}),i.jsx("span",{children:Te.length?`${Te.length} 知识库`:"知识库"}),i.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),A?i.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:re=>re.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:re=>O(re.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),D?i.jsx("button",{type:"button",onClick:()=>O(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:mt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:mt.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:gt.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:gt.map(re=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:st.has(re.id||re.path),disabled:b,onChange:Re=>ke(re,Re.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:re.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[re.kind==="git"&&re.repoUrl?`${re.repoUrl}${re.branch?` · ${re.branch}`:""}${re.mountPath?` · ${re.mountPath}`:""}`:re.path,re.exists?"":" · 路径未就绪"]})]})]},`${re.id}:${re.path}`))})]}),gt.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:Ke,children:"清空知识库"})]}),i.jsx("div",{ref:mt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(mt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:mt.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${mt.scrollbar.height}%`,top:`${mt.scrollbar.top}%`}})})]}):null]}),i.jsxs("select",{value:u.displayType,disabled:b,onChange:re=>Rt({displayType:re.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"})]})]}),z?i.jsx("pre",{className:"af-work-context-run-card__preview",children:z.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:re=>{var Re,Je;re.stopPropagation(),xe(),y?(Re=t==null?void 0:t.onStopWorkspaceNode)==null||Re.call(t,e):(Je=t==null?void 0:t.onRunWorkspaceNode)==null||Je.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:re=>{var Re;re.stopPropagation(),(Re=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Re.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 mJ({id:e,data:t,selected:n,deleteNode:r}){var I,R,H;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=yv((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},d=((R=(I=t==null?void 0:t.runningRunNodeIds)==null?void 0:I.has)==null?void 0:R.call(I,e))||((H=t==null?void 0:t.runningRunNodeIds)==null?void 0:H[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",h=!!(t!=null&&t.readOnly),y=A=>{var L;(L=t==null?void 0:t.onChangeScheduledRunConfig)==null||L.call(t,e,{...a,...A})},v=A=>{y({scheduleType:A,cron:qu(A,a.time,a.weekday,a.monthDay,a.cron)})},b=A=>{y({time:A,cron:qu(a.scheduleType,A,a.weekday,a.monthDay,a.cron)})},[g,k]=gv(a.time).split(":"),x=(A,L)=>{b(`${Fo(A,9,0,23)}:${Fo(L,0,0,59)}`)},j=A=>{y({weekday:A,cron:qu(a.scheduleType,a.time,A,a.monthDay,a.cron)})},N=A=>{y({monthDay:A,cron:qu(a.scheduleType,a.time,a.weekday,A,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const C=()=>{h||l===a.cron||y({cron:l})};return i.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(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((A,L)=>{if(A.showOnNode===!1)return null;const D=`${2.25+L*1.75}rem`,O=A.name||`#${L+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:O}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${L}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:Mn(A.type)},title:`${O} · ${A.type}`})]},`in-${L}`)}),o.map((A,L)=>{if(A.showOnNode===!1)return null;const D=`${2.25+L*1.75}rem`,O=A.name||`#${L+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:O}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${L}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:Mn(A.type)},title:`${O} · ${A.type}`})]},`out-${L}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:h,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[i.jsxs("label",{className:"af-work-schedule-card__toggle",children:[i.jsx("input",{type:"checkbox",checked:a.enabled,disabled:h,onChange:A=>y({enabled:A.target.checked})}),i.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:a.scheduleType,disabled:h,onChange:A=>v(A.target.value),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"}),i.jsx("option",{value:"monthly",children:"每月"}),i.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{className:"af-work-schedule-time-selects",children:[i.jsx("select",{value:g,disabled:h,"aria-label":"小时",onChange:A=>x(A.target.value,k),children:Array.from({length:24},(A,L)=>Fo(L,0,0,23)).map(A=>i.jsxs("option",{value:A,children:[A," 时"]},A))}),i.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:A=>x(g,A.target.value),children:Array.from({length:12},(A,L)=>Fo(L*5,0,0,59)).map(A=>i.jsxs("option",{value:A,children:[A," 分"]},A))})]})]}):null,a.scheduleType==="weekly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"星期"}),i.jsxs("select",{value:a.weekday,disabled:h,onChange:A=>j(A.target.value),children:[i.jsx("option",{value:1,children:"周一"}),i.jsx("option",{value:2,children:"周二"}),i.jsx("option",{value:3,children:"周三"}),i.jsx("option",{value:4,children:"周四"}),i.jsx("option",{value:5,children:"周五"}),i.jsx("option",{value:6,children:"周六"}),i.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"日期"}),i.jsx("select",{value:a.monthDay,disabled:h,onChange:A=>N(A.target.value),children:Array.from({length:31},(A,L)=>L+1).map(A=>i.jsxs("option",{value:A,children:[A," 日"]},A))})]}):null,a.scheduleType==="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"Cron"}),i.jsx("input",{type:"text",value:l,disabled:h,spellCheck:!1,placeholder:Ud,onChange:A=>c(A.target.value),onBlur:C,onKeyDown:A=>{A.key==="Enter"&&A.currentTarget.blur()}})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[$G(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",MG(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:h||f,onClick:A=>{var L,D;A.stopPropagation(),d?(L=t==null?void 0:t.onStopWorkspaceNode)==null||L.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:h||d||f,title:"为下游节点提前生成 implementation",onClick:A=>{var L;A.stopPropagation(),(L=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||L.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:A=>{var L;A.stopPropagation(),(L=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||L.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 gJ({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=zc(),o=!!(t!=null&&t.readOnly),a=fb(t==null?void 0:t.nodeSize)||{width:Za,height:el},l=m.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=>cM(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(Bk,{className:"af-work-group-node__resize nodrag",minWidth:Za,minHeight:el,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 yJ(e){var y,v,b,g,k,x,j,N,C,I,R,H,A,L,D,O,M,K,z,F,$,W,E,Q,V,B,se,ue;const{setEdges:t,setNodes:n}=zc(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,s=!!((v=e.data)!=null&&v.readOnly),[o,a]=m.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=m.useCallback(G=>{var ne,Z,ce;if(s)return;(Z=(ne=e.data)==null?void 0:ne.onCleanupWorkspaceNodeOutputs)==null||Z.call(ne,G,e.data);const ee=ti((ce=e.data)==null?void 0:ce.definitionId)?hM(G):"",te=new Set([G,ee].filter(Boolean));n(de=>de.filter(me=>!te.has(me.id))),t(de=>de.filter(me=>!te.has(me.source)&&!te.has(me.target)))},[e.data,s,t,n]),u=m.useCallback(G=>{var ee,te;G.button!==0||G.metaKey||G.ctrlKey||G.shiftKey||(te=(ee=G.target)==null?void 0:ee.closest)!=null&&te.call(ee,".react-flow__handle, .af-work-display-resize")||(n(ne=>cM(ne,e.id)),t(ne=>kJ(ne)))},[e.id,t,n]),d=m.useCallback((G,ee)=>{s||(n(te=>te.map(ne=>ne.id===G?{...ne,data:{...ne.data,model:ee}}:ne)),r==null||r(G,{model:ee}))},[s,n,r]),f=m.useCallback((G,ee)=>{s||(n(te=>te.map(ne=>{var ce;if(ne.id!==G)return ne;const Z=Array.isArray((ce=ne.data)==null?void 0:ce.outputs)&&ne.data.outputs.length?ne.data.outputs.map((de,me)=>me===0?{...de,default:ee,value:ee}:de):[{type:"bool",name:"value",default:ee,value:ee}];return{...ne,data:{...ne.data,body:"",outputs:Z}}})),r==null||r(G,te=>({body:"",outputs:Array.isArray(te==null?void 0:te.outputs)&&te.outputs.length?te.outputs.map((Z,ce)=>ce===0?{...Z,default:ee,value:ee}:Z):[{type:"bool",name:"value",default:ee,value:ee}]})))},[s,n,r]),p=m.useCallback((G,ee)=>{s||(n(te=>te.map(ne=>ne.id===G?{...ne,data:{...ne.data,body:ee}}:ne)),r==null||r(G,{body:ee}))},[s,n,r]),h=m.useCallback((G,ee)=>{if(s)return;const te=ho(ee);n(ne=>ne.map(Z=>Z.id===G?{...Z,data:{...Z.data,images:te}}:Z)),r==null||r(G,{images:te})},[s,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?i.jsx(gJ,{...e,deleteNode:c}):nl((k=e.data)==null?void 0:k.definitionId)?i.jsx(oM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?i.jsx(pJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((j=e.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"?i.jsx(mJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):ti((N=e.data)==null?void 0:N.definitionId)?i.jsx(hJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(C=e.data)==null?void 0:C.skills,skillCollections:(I=e.data)==null?void 0:I.skillCollections,workspaces:(R=e.data)==null?void 0:R.workspaceTargets}):((H=e.data)==null?void 0:H.definitionId)==="control_load_skills"?i.jsx(OJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(A=e.data)==null?void 0:A.skills,skillCollections:(L=e.data)==null?void 0:L.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((O=e.data)==null?void 0:O.definitionId)==="control_load_mcp"?i.jsx(DJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:(M=e.data)==null?void 0:M.mcpServers,onChangeMcpNames:(K=e.data)==null?void 0:K.onChangeLoadMcpNames}):((z=e.data)==null?void 0:z.definitionId)==="control_cd_workspace"?i.jsx(FJ,{...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:(W=e.data)==null?void 0:W.onRefreshWorkspaces}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((E=e.data)!=null&&E.isExecuting||((Q=e.data)==null?void 0:Q.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((V=e.data)==null?void 0:V.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((B=e.data)==null?void 0:B.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((se=e.data)==null?void 0:se.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:i.jsx(Bk,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:LT,minHeight:cm,maxWidth:OT,maxHeight:DT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(rU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(ue=e.data)==null?void 0:ue.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:p,onNodeImagesChange:h})]})}const wJ={[hc]:m.memo(yJ)};function wv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&wv(n.children,t);return t}function aM(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)?aM(r.children,n):null;if(s)return s}return null}function xJ(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function lM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&lM(n.children,t));return t}function zp(e){const t=String(e||"").replace(/\\/g,"/").split("/").filter(Boolean),n=[];for(let r=1;r<t.length;r++)n.push(t.slice(0,r).join("/"));return n}function bJ(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 cM(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:bJ(e,n)}function kJ(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function vJ(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function SJ(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(h=>h.name!==c?h:(f=!0,d?{...h,type:"file",name:c,path:u,icon:nc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:nc(c,!0),children:s(h.children||[],a+1,u)}));return f||p.push(d?{type:"file",name:c,path:u,icon:nc(c),size:n}:{type:"directory",name:c,path:u,icon:nc(c,!0),children:s([],a+1,u)}),vJ(p)};return s(e||[],0,"")}function jJ(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 uM({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}){return i.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const 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||nc(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&&((h=u.children)!=null&&h.length)?i.jsx(uM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function NJ({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=m.useMemo(()=>wv(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||nc(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:jJ(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function WC({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 dM(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function CJ(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!dM(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 _J(e){return(Array.isArray(e)?e:[]).filter(dM)}function Jd(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 EJ(e){const t=Jd((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 Jd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function AJ(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 Jd((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function fM(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 VC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function na(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 ym(e,t){const n=na(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 yf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Ss(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function pM(e){const t=yf(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 hM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function mM(e){return e==="display_image"?"src":"content"}function KC(e,t,n){const r=mM(t),s=Uu(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 qC(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 UC(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 cg(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 PJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=na(t,"includeWorkspaceContext","true").toLowerCase(),r=ym(t,"knowledgeContext"),s=ym(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:AJ(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?ug([s]):null),workspaceContext:s,displayType:yf(na(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function ti(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function IJ(e){const t=Jd((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 Jd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function RJ(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function gM(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 ug(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>gM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function yM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>gM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function TJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=ym(t,"knowledgeContext"),r=ym(t,"workspaceContext");return{sources:yM(n||(r?ug([r]):null)),path:na(t,"path",""),label:na(t,"label","")}}function YC(e){var r,s,o,a,l,c,u,d,f;if(!e)return null;const{inputs:t,outputs:n}=gU(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:ho((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 GC(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 JC(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 MJ(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=Vd.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?[]:ho(t==null?void 0:t.images),inputs:JC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:JC(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 h=String((t==null?void 0:t[p])??"").trim();h?c[p]=h:delete c[p]}return c}function XC({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(!FU.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=MJ(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(ho(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 h=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,h=t.map((b,g)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:h,instances:y}}function $J(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function LJ(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"])$J(e[s],t[s])&&(r[s]=n[s]);return r}function gb(e,t=[]){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)},[e,a,...t]);const l=m.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=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var j,N;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,b));const g=d.pointerId;(N=(j=d.currentTarget).setPointerCapture)==null||N.call(j,g);const k=C=>{C.preventDefault(),l(c(C.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 OJ({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]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[x,j]=m.useState({visible:!1,top:0,height:100}),N=m.useMemo(()=>new Set(EJ(t)),[t]),C=m.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),I=m.useMemo(()=>Array.from(N).map(F=>{var $;return(($=C.get(F))==null?void 0:$.name)||F}),[C,N]),R=m.useMemo(()=>fM(I,"选择 Skills"),[I]),H=m.useMemo(()=>{const F=new Set,$=d.map(E=>{const Q=Zo(E,u).map(V=>C.get(V)).filter(Boolean);for(const V of Q)F.add(V.key);return{...E,skills:Q}}).filter(E=>E.skills.length>0),W=u.filter(E=>!F.has(E.key));return{collectionGroups:$,ungrouped:W}},[C,d,u]);m.useEffect(()=>{b(F=>{let $=!1;const W=new Set(F);for(const E of H.collectionGroups)W.has(E.id)||(W.add(E.id),$=!0);return $?W:F})},[H.collectionGroups]);const A=m.useMemo(()=>{const F=h.trim().toLowerCase();if(!F)return H;const $=E=>[E==null?void 0:E.key,E==null?void 0:E.name,E==null?void 0:E.description].map(V=>String(V||"").toLowerCase()).join(" ").includes(F);return{collectionGroups:H.collectionGroups.map(E=>{const V=[E==null?void 0:E.id,E==null?void 0:E.name,E==null?void 0:E.description].map(B=>String(B||"").toLowerCase()).join(" ").includes(F)?E.skills:E.skills.filter($);return{...E,skills:V}}).filter(E=>E.skills.length>0),ungrouped:H.ungrouped.filter($)}},[H,h]),L=m.useCallback((F,$)=>{const W=new Set(N);for(const E of F)$?W.add(E):W.delete(E);a==null||a(e,Array.from(W))},[e,N,a]),D=m.useCallback(F=>{b($=>{const W=new Set($);return W.has(F)?W.delete(F):W.add(F),W})},[]),O=m.useCallback(()=>{const F=g.current;if(!F)return;const $=Math.max(1,F.scrollHeight),W=Math.max(1,F.clientHeight),E=$>W+1,Q=E?Math.max(12,W/$*100):100,V=Math.max(0,100-Q),B=E?Math.min(V,F.scrollTop/Math.max(1,$-W)*V):0;j({visible:E,top:B,height:Q})},[]);m.useEffect(()=>{if(!f)return;const F=requestAnimationFrame(O);return()=>cancelAnimationFrame(F)},[v,A,N.size,f,O]);const M=m.useCallback(F=>{const $=g.current;if(!$)return;const W=Math.max(0,$.scrollHeight-$.clientHeight);$.scrollTop=Math.min(1,Math.max(0,F))*W,O()},[O]),K=m.useCallback((F,$=0)=>{const W=k.current;if(!W)return 0;const E=W.getBoundingClientRect(),Q=x.height/100*E.height,V=Math.max(1,E.height-Q);return(F-E.top-$)/V},[x.height]),z=m.useCallback(F=>{var ee,te;if(!x.visible)return;F.preventDefault(),F.stopPropagation();const $=k.current;if(!$)return;const W=$.getBoundingClientRect(),E=x.top/100*W.height,Q=x.height/100*W.height,B=F.clientY>=W.top+E&&F.clientY<=W.top+E+Q?F.clientY-W.top-E:Q/2;M(K(F.clientY,B));const se=F.pointerId;(te=(ee=F.currentTarget).setPointerCapture)==null||te.call(ee,se);const ue=ne=>{ne.preventDefault(),M(K(ne.clientY,B))},G=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G)},[K,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 W=`${2.6+$*1.7}rem`,E=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:W},children:E}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${$}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:W,background:Mn(F.type)},title:`${E} · ${F.type}`})]},`in-${$}`)}),c.map((F,$)=>{if(F.showOnNode===!1)return null;const W=`${2.6+$*1.7}rem`,E=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:W},children:E}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${$}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:W,background:Mn(F.type)},title:`${E} · ${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(W=>!W)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:R.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:R.head}),R.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:R.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:F=>F.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:h,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?i.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:g,className:"af-work-load-skills-menu",onScroll:O,children:[A.collectionGroups.map(F=>{const $=F.skills.map(V=>V.key),W=$.filter(V=>N.has(V)).length,E=$.length>0&&W===$.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:E,onChange:V=>L($,V.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:[W,"/",$.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(V=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:N.has(V.key),onChange:B=>L([V.key],B.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:V.name}),V.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:V.description}):null]})]},`${F.id}:${V.key}`))})]},F.id)}),A.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:A.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:A.ungrouped.map(F=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:N.has(F.key),onChange:$=>L([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,A.collectionGroups.length===0&&A.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:z,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function DJ({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,u]=m.useState(!1),[d,f]=m.useState(""),p=m.useMemo(()=>new Set(IJ(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>({name:String((b==null?void 0:b.name)||""),description:String((b==null?void 0:b.description)||""),detail:String((b==null?void 0:b.url)||[b==null?void 0:b.command,...Array.isArray(b==null?void 0:b.args)?b.args:[]].filter(Boolean).join(" ")||""),type:String((b==null?void 0:b.type)||"")})).filter(b=>b.name),[s]),y=m.useMemo(()=>{const b=d.trim().toLowerCase();return b?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):h},[d,h]),v=m.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(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:x}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:Mn(b.type)},title:`${x} · ${b.type}`})]},`in-${g}`)}),l.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:x}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:Mn(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 FJ({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]=m.useState(!1),[f,p]=m.useState(""),h=TJ(t),y=m.useMemo(()=>(Array.isArray(s)?s:[]).map(N=>({id:String((N==null?void 0:N.id)||""),label:String((N==null?void 0:N.label)||(N==null?void 0:N.name)||"知识库"),kind:(N==null?void 0:N.kind)==="git"?"git":"local",path:String((N==null?void 0:N.path)||""),repoUrl:String((N==null?void 0:N.repoUrl)||""),branch:String((N==null?void 0:N.branch)||""),mountPath:String((N==null?void 0:N.mountPath)||""),builtin:(N==null?void 0:N.builtin)===!0,exists:(N==null?void 0:N.exists)!==!1})).filter(N=>N.path),[s]),v=m.useMemo(()=>{const N=f.trim().toLowerCase();return N?y.filter(C=>[C.id,C.label,C.path,C.repoUrl,C.branch,C.mountPath].join(" ").toLowerCase().includes(N)):y},[f,y]),b=m.useMemo(()=>new Set((h.sources||[]).map(N=>N.id||N.path||N.repoPath).filter(Boolean)),[h.sources]),g=m.useMemo(()=>(h.sources||[]).map(N=>N.label||N.id||N.mountPath||N.path),[h.sources]),k=m.useMemo(()=>fM(g,"选择知识库"),[g]),x=gb(u,[v.length,g.length,f]),j=(N,C)=>{const I=(N==null?void 0:N.id)||(N==null?void 0:N.path)||"",R=y.filter(H=>{const A=H.id||H.path||"";return A===I?C:b.has(A)});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((N,C)=>{if(N.showOnNode===!1)return null;const I=`${2.6+C*1.7}rem`,R=N.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:I},children:R}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${C}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:I,background:Mn(N.type)},title:`${R} · ${N.type}`})]},`in-${C}`)}),c.map((N,C)=>{if(N.showOnNode===!1)return null;const I=`${2.6+C*1.7}rem`,R=N.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:I},children:R}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${C}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:I,background:Mn(N.type)},title:`${R} · ${N.type}`})]},`out-${C}`)}),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:N=>{N.stopPropagation(),u||a==null||a(),d(C=>!C)},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:N=>N.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:N=>p(N.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(N=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:b.has(N.id||N.path),onChange:C=>j(N,C.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:N.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[N.kind==="git"&&N.repoUrl?`${N.repoUrl}${N.branch?` · ${N.branch}`:""}${N.mountPath?` · ${N.mountPath}`:""}`:N.path,N.exists?"":" · 路径未就绪"]})]})]},`${N.id}:${N.path}`))})]}),v.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空知识库"})]}),i.jsx("div",{ref:x.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(x.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:x.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${x.scrollbar.height}%`,top:`${x.scrollbar.top}%`}})})]}):null]})]})}function wM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=NT(r),o=JU(dG(r)),a=s?o.filter(p=>!["issue","mr"].includes(om(p))):o,l=QU(r,o),c=_i(r,t),u=s?"":Ma(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:lG(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,h)=>i.jsx(wM,{row:p,index:h,child:!0},_i((p==null?void 0:p.issue)||{},h)))}):null]})}function xM(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 bM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>xM(n)).filter(Boolean)}function zJ({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=bM(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 BJ({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"&&bM(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(zJ,{fieldKey:o,field:a},o))})]})}function HJ({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=xM(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(BJ,{sectionKey:f,section:p},f))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function WJ({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:h,onRetryConflict:y,onPublishReview:v}){const[b,g]=m.useState("all"),[k,x]=m.useState("all"),[j,N]=m.useState(!1),[C,I]=m.useState(!1),[R,H]=m.useState(!1),[A,L]=m.useState(""),[D,O]=m.useState(!1),[M,K]=m.useState(""),[z,F]=m.useState(null),$=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),W=Array.isArray(r==null?void 0:r.issues)?r.issues:[],E=fG(r),Q=E.reduce((xe,Oe)=>xe+ib(Oe.issues),0),V=Array.isArray(r==null?void 0:r.artifacts)?r.artifacts:[];Array.isArray(r==null?void 0:r.optionalGaps)&&r.optionalGaps;const B=r!=null&&r.nextAction&&typeof r.nextAction=="object"?r.nextAction:null,se=gG(r,B),ue=oG(r,se),G=V.filter(xe=>!_T({...xe,href:mc(xe)})),ee=m.useMemo(()=>rG(se),[se]);m.useEffect(()=>{k!=="all"&&(ee.some(xe=>xe.key===k)||x("all"))},[k,ee]);const te=se.filter(xe=>sG(xe,k)),ne=tG(te),Z=yG(r),ce=Z.filter(xe=>wG(xe,b)),de=te.filter(xe=>fv(xe)).length,me=r!=null&&r.collaboration&&typeof r.collaboration=="object"?r.collaboration:{},$e=me.activeAction&&typeof me.activeAction=="object"?me.activeAction:null;Array.isArray(r==null?void 0:r.clientObservations)&&r.clientObservations;const Ce=String((r==null?void 0:r.rawOutput)||""),_e=r!=null&&r.globalState&&typeof r.globalState=="object"?r.globalState:null,Be=UY($),ot=m.useCallback(async()=>{const xe=String(t||"").trim();if(!xe){F(null);return}I(!0),L(""),K("");try{const Oe=new URLSearchParams({tapdId:xe});e.workflowShare&&Oe.set("workflowShare",e.workflowShare);const ie=await fetch(`/api/prd-workflow/share?${Oe.toString()}`),ke=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(ke.error||"读取 Workflow 分享状态失败");let Ke=ke.share||null;const Ue=ke.canCreate===!0&&!e.workflowShare;if(O(Ue),!Ke&&Ue){const be=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:xe})}),Pt=await be.json().catch(()=>({}));if(!be.ok)throw new Error(Pt.error||"生成 Workflow 分享链接失败");Ke=Pt.share||null}F(Ke)}catch(Oe){L(String(Oe.message||Oe))}finally{I(!1)}},[e,t]),gt=()=>{N(!0),ot()},Te=async()=>{if(!(!t||R||e.workflowShare)){H(!0),L(""),K("");try{const xe=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),Oe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Oe.error||"生成 Workflow 分享链接失败");F(Oe.share||null),O(!0)}catch(xe){L(String(xe.message||xe))}finally{H(!1)}}},st=async()=>{const xe=await hb((z==null?void 0:z.shortUrl)||(z==null?void 0:z.url)||"");K(xe?"已复制":"复制失败")},mt=async()=>{if(!(!t||R||!(z!=null&&z.canManage))){H(!0),L(""),K("");try{const xe=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),Oe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Oe.error||"取消 Workflow 分享链接失败");F(null),O(!0)}catch(xe){L(String(xe.message||xe))}finally{H(!1)}}},Rt=(z==null?void 0:z.shortUrl)||(z==null?void 0:z.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:CC($)}),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,$e||me.subscribers?i.jsxs("div",{className:"af-prd-workflow-collab",children:[$e?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),$e.title||$e.action||"Workflow action"," 执行中",$e.userId?i.jsx("small",{children:$e.userId}):null]}):null,me.subscribers?i.jsxs("span",{children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),me.subscribers," 个连接"]}):null]}):null]}),i.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:xe=>{xe.preventDefault(),f==null||f()},children:[i.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:Be.map(xe=>i.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${xe.status}`,children:[i.jsx("span",{"aria-hidden":"true"}),i.jsx("small",{children:xe.label})]},xe.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:xe=>n(xe.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:gt,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:[CC(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:se.length?`${de}/${te.length} 已完成${k!=="all"?` · 共 ${se.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),B&&Gd(B)?i.jsxs("div",{className:"af-prd-workflow-local-command",children:[i.jsx("span",{children:"本地 agent 执行"}),i.jsx("code",{children:B.command||to(B,0)})]}):null]}),ee.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:se.length})]}),ee.map(xe=>i.jsxs("button",{type:"button",className:k===xe.key?"is-active":"","aria-pressed":k===xe.key,onClick:()=>x(xe.key),children:[xe.label," ",i.jsx("span",{children:xe.count})]},xe.key))]}):null,i.jsx("div",{className:"af-prd-workflow-action-list",children:te.length?ne.map(xe=>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:xe.day}),i.jsx("small",{children:"北京时间"})]}),i.jsx("div",{className:"af-prd-workflow-action-day__items",children:xe.items.map(({item:Oe,index:ie})=>{const ke=ua(Oe.status),Ke=ea(Oe)==="observation"&&ke==="done"?"observed":ke,Ue=hv(Oe),be=eG(Oe),Pt=iG(Oe),tn=GY(Oe,ie),Wt=JY(Oe);return i.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${Ke}`,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:[be?i.jsx("time",{dateTime:dm(Oe),children:be}):null,i.jsx("strong",{children:tn})]}),Wt?i.jsx("p",{children:Wt}):null,Pt.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:Pt.map(Lt=>i.jsxs("span",{children:[i.jsx("b",{children:Lt.label}),Lt.value]},`${Lt.label}-${Lt.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:nG(Oe)})]}),Ue.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Ue.map(Lt=>i.jsxs("a",{href:Lt.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:Lt.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${Lt.label}-${Lt.href}`))}):null]})]},Oe.id||Oe.actionId||`${to(Oe,ie)}-${ie}`)})})]},xe.day)):i.jsxs("div",{className:"af-prd-workflow-action-empty",children:[i.jsx("strong",{children:t?se.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),i.jsx("p",{children:t?se.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(HJ,{globalState:_e,tapdId:t}),G.length?i.jsxs("article",{className:"af-prd-workflow-card",children:[i.jsxs("div",{className:"af-prd-workflow-card__head",children:[i.jsx("h2",{children:"关联产物"}),i.jsx("span",{children:G.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:G.map((xe,Oe)=>{const ie=mc(xe),ke=String(xe.label||xe.title||xe.kind||ie||`Artifact ${Oe+1}`);return ie?i.jsxs("a",{href:ie,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:ke}),i.jsx("small",{children:xe.kind||ie})]},`${ie}-${Oe}`):i.jsxs("div",{children:[i.jsx("span",{children:ke}),i.jsx("small",{children:xe.kind||""})]},`${ke}-${Oe}`)})})]}):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:ue.length})]}),i.jsx("div",{className:"af-prd-workflow-list",children:ue.length?ue.map(xe=>{const Oe=String(xe.title||xe.label||"ai-doc").trim(),ie=[xe.label&&xe.label!==Oe?xe.label:"",xe.platform,xe.issueKey].filter(Boolean);return i.jsxs("a",{className:"af-prd-ai-doc",href:xe.href,target:"_blank",rel:"noreferrer",title:Oe,children:[i.jsx("span",{className:"af-prd-ai-doc__title",children:Oe}),i.jsx("small",{className:"af-prd-ai-doc__meta",children:ie.join(" · ")||xe.kind||"ai-doc"})]},xe.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||W.length})]}),i.jsx("div",{className:"af-prd-workflow-issues",children:E.length?E.map(xe=>i.jsxs("div",{className:"af-prd-workflow-epic",children:[i.jsxs("div",{className:"af-prd-workflow-epic__head",children:[i.jsx("strong",{children:xe.title||xe.key}),i.jsx("small",{children:ib(xe.issues)})]}),xe.issues.map((Oe,ie)=>i.jsx(wM,{row:Oe,index:ie},_i((Oe==null?void 0:Oe.issue)||{},ie)))]},xe.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:[ce.length,"/",Z.length]})]}),i.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([xe,Oe])=>i.jsx("button",{type:"button",className:b===xe?"is-active":"",onClick:()=>g(xe),children:Oe},xe))}),i.jsx("div",{className:"af-prd-workflow-audit",children:ce.length?ce.map((xe,Oe)=>i.jsxs("div",{children:[i.jsx("strong",{children:to(xe,Oe)}),i.jsx("small",{children:[xe.status,xe.type,dm(xe)].filter(Boolean).join(" · ")})]},xe.id||`${xe.type}-${Oe}`)):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),Ce||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||Ce})]}):null]})]}),j?ur.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:()=>N(!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、画布或项目文件。"]}),C?i.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!C&&Rt?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",value:Rt,readOnly:!0,onFocus:xe=>xe.currentTarget.select(),"aria-label":"Workflow 分享链接"}),i.jsxs("button",{type:"button",disabled:R,onClick:()=>void st(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),M||"复制链接"]}),z.canManage?i.jsx("button",{type:"button",disabled:R,onClick:()=>void mt(),children:R?"处理中...":"取消分享"}):null]}),i.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的 AgentFlow 用户可以只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!C&&!Rt&&D?i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:R,onClick:()=>void Te(),children:R?"生成中...":"生成分享链接"}):null,A?i.jsx("div",{className:"af-flow-snippet-error",children:A}):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:()=>N(!1),children:"完成"})})]})}),document.body):null]})}function QC(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 Tu(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function VJ(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 KJ(){var k0,v0,S0;const{t:e,i18n:t}=zr(),{navigate:n}=Ts(),r=zc(),s=wn(),o=OW(),a=m.useMemo(MY,[]),l=!!a.workflowShare,c=m.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=m.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[d,f]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=DW([]),[k,x]=FW([]),j=m.useRef([]),N=m.useRef([]),C=m.useRef(null),[I,R]=m.useState(()=>gh(null,[])),H=m.useRef(I),[A,L]=m.useState(null),D=m.useRef(null),O=m.useRef(!1),[M,K]=m.useState([]),z=m.useRef(new Map),F=m.useRef(new Map),$=m.useRef(new Set),W=m.useRef(new Set),E=m.useRef(null),Q=m.useRef(null),V=m.useRef([]),B=m.useRef(null),se=m.useRef(null),ue=m.useRef(null),[G,ee]=m.useState(null),[te,ne]=m.useState({}),Z=m.useRef({}),ce=m.useRef(!1),de=m.useRef(null),me=m.useRef(""),$e=m.useRef(null),Ce=m.useRef(Promise.resolve()),_e=m.useRef({running:!1,pending:null}),Be=m.useRef(0),ot=m.useRef(!1),gt=m.useRef(0),Te=m.useRef(null),st=m.useRef(!1),mt=m.useRef(!1),Rt=m.useRef(""),xe=m.useRef(!1),Oe=m.useRef(!1),ie=m.useRef(!1),ke=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),Ke=m.useRef(!1),Ue=m.useRef(null),[be,Pt]=m.useState([]),tn=m.useRef([]),[Wt,Lt]=m.useState(""),[an,re]=m.useState("nodes"),[Re,Je]=m.useState([]),[Ze,Tt]=m.useState(!1),[_t,Kn]=m.useState(""),[jn,br]=m.useState(!1),[xn,Qn]=m.useState({name:"",id:"",description:""}),[qn,mr]=m.useState(!1),[ts,Pr]=m.useState(""),[gs,ys]=m.useState(""),dn=m.useRef(null),[sr,Ir]=m.useState(!1),[pn,Zn]=m.useState(!1),[kr,ir]=m.useState(""),[jt,Jt]=m.useState(null),[Nt,le]=m.useState(()=>cw()),[ve,it]=m.useState(""),[Ft,Xt]=m.useState(!1),[nn,er]=m.useState(""),[ht,rn]=m.useState(!1),[Vt,vr]=m.useState([]),[tt,On]=m.useState(!1),[$i,Br]=m.useState(""),[go,ai]=m.useState(""),[Ms,oe]=m.useState(""),[Se,Pe]=m.useState(!1),[wt,Ot]=m.useState(""),[Ut,Bn]=m.useState(""),[Dn,q]=m.useState(!1),[he,De]=m.useState("nodes"),[Ee,et]=m.useState(""),[Nn,bt]=m.useState(0),[Yt,Cn]=m.useState(""),yo=m.useRef(""),[at,ws]=m.useState(null),Tv=m.useRef(null),[p$,ll]=m.useState(""),[cl,Mv]=m.useState([]),[$v,h$]=m.useState(""),[je,m$]=m.useState(!a.adminOwnerId),[Sf,g$]=m.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[ln,yg]=m.useState(null),[y$,wg]=m.useState(!1),[xg,Lv]=m.useState(!1),[Ov,Gc]=m.useState(""),[Jc,Dv]=m.useState(""),[Fv,zv]=m.useState(""),[An,ul]=m.useState(null),[w$,da]=m.useState(!1),[bg,dl]=m.useState({}),[jf,Bv]=m.useState(!1),[Hv,Xc]=m.useState(""),[kg,x$]=m.useState(""),[b$,fl]=m.useState(()=>new Set),[vg,Sg]=m.useState(""),[Qc,jg]=m.useState({nodeId:"",query:""}),[Wv,Vv]=m.useState(!1),Ng=m.useRef(null),Kv=m.useRef(null),qv=m.useRef(""),[Cg,Uv]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[k$,Yv]=m.useState(!1),[fa,v$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Li,S$]=m.useState(""),[$s,j$]=m.useState([]),[Gv,Jv]=m.useState(!1),[Ls,Zc]=m.useState([]),[pl,N$]=m.useState([]),[Xv,C$]=m.useState(!1),[Qv,Zv]=m.useState([]),[eS,tS]=m.useState([]),[or,_$]=m.useState(()=>{try{const w=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return w||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`)||"").trim()}catch{return""}}),[cn,Nf]=m.useState(null),[E$,nS]=m.useState(!1),[A$,hl]=m.useState(""),[_g,rS]=m.useState(!1),[Eg,Cf]=m.useState(""),[xs,_f]=m.useState(null),[Ag,sS]=m.useState(!1),[eu,tu]=m.useState(null),iS=m.useCallback(w=>{dn.current&&window.clearTimeout(dn.current),ys(w),dn.current=window.setTimeout(()=>{ys(""),dn.current=null},3800)},[]),Hr=m.useCallback(w=>{const S=Array.isArray(w)||w instanceof Set?w:[w];for(const _ of S){const P=String(_||"").trim();P&&($.current.add(P),W.current.add(P))}$.current.size!==0&&(E.current==null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const _=Array.from($.current);$.current.clear(),_.forEach(P=>o(P))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const _=Array.from(W.current);W.current.clear(),_.forEach(P=>o(P))},80))},[o]);m.useEffect(()=>()=>{E.current!=null&&window.cancelAnimationFrame(E.current),Q.current!=null&&window.clearTimeout(Q.current),$.current.clear(),W.current.clear()},[]);const oS=m.useCallback((w,S)=>{const _=String(w||"").trim(),P=gm(S);!_||!P||(g(T=>T.map(U=>{var ae;if(U.id!==_)return U;const X=gm((ae=U.data)==null?void 0:ae.displaySize),J=X&&X.width===P.width&&X.height===P.height,Y=Math.round(Number(U.width||0))===P.width&&Math.round(Number(U.height||0))===P.height;return J&&Y?U:{...U,width:P.width,height:P.height,data:{...U.data,nodeSize:P,displaySize:P}}})),Hr(_))},[Hr,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Cg)))}catch{}},[Cg]);const Pg=m.useCallback(w=>{const S=Ng.current;if(!S)return null;const _=S.getBoundingClientRect(),P=16,T=150,U=230,X=_.top+P,J=_.bottom-P,Y=Math.max(T,J-X-U);return Math.min(Math.max(w-X,T),Y)},[]),P$=m.useCallback(w=>{w.preventDefault(),w.stopPropagation();const S=Ng.current;if(!S)return;let _=Pg(w.clientY);if(!Number.isFinite(_))return;Yv(!0),Uv(_);const P=U=>{U.preventDefault();const X=Pg(U.clientY);Number.isFinite(X)&&(_=X,S.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},T=()=>{Uv(_),Yv(!1),window.removeEventListener("pointermove",P,!0),window.removeEventListener("pointerup",T,!0),window.removeEventListener("pointercancel",T,!0)};window.addEventListener("pointermove",P,!0),window.addEventListener("pointerup",T,!0),window.addEventListener("pointercancel",T,!0)},[Pg]);m.useEffect(()=>()=>{dn.current&&window.clearTimeout(dn.current),Ue.current&&window.clearTimeout(Ue.current)},[]);const[I$,aS]=m.useState(()=>new Set),[Ef,Ig]=m.useState(!1),Rg=m.useRef(null),lS=m.useRef(null),cS=m.useRef(null),[R$,T$]=m.useState({}),[pa,Tg]=m.useState(""),[ns,uS]=m.useState(!1),[ha,ml]=m.useState([]),[Os,Un]=m.useState([]),[Wr,bs]=m.useState("workspace"),[nu,gl]=m.useState(!1),dS=m.useRef(null),Mg=m.useRef(null),[ru,yl]=m.useState(null),[M$,$g]=m.useState(!0),[fS,pS]=m.useState(""),[ma,wo]=m.useState({}),[Rr,hS]=m.useState(null),[mS,gS]=m.useState(!1),wl=m.useMemo(()=>mS?FY(Rr):"",[mS,Rr]),[su,Af]=m.useState(!0);m.useEffect(()=>{wl&&Af(zY(wl))},[wl]),m.useEffect(()=>{if(wl)try{window.localStorage.setItem(wl,su?"true":"false")}catch{}},[su,wl]);const[Lg,Pf]=m.useState(!1),[Og,yS]=m.useState(!1),[Dg,wS]=m.useState("pan"),[xS,$$]=m.useState({}),iu=m.useRef({}),[bS,ga]=m.useState({}),ou=m.useRef(new Map),au=m.useRef(new Set),[kS,xl]=m.useState(()=>new Set),[Fg,bl]=m.useState({}),[vS,SS]=m.useState(""),[Rce,ge]=m.useState(""),[jS,Ds]=m.useState("loading"),[NS,Fs]=m.useState("正在载入 Project"),Oi=m.useMemo(()=>DY(a),[a]),[CS,_S]=m.useState(""),lu=a.flowSource||"user",ES=m.useMemo(()=>new Set(Object.values(xS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[xS]),Di=m.useCallback(w=>{const S=iu.current||{},_=typeof w=="function"?w(S):w,P=_&&typeof _=="object"&&!Array.isArray(_)?_:{};return iu.current=P,$$(P),P},[]),AS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(ln!=null&&ln.role?ln.role==="owner":lu==="user"||lu==="workspace")),cu=!!(!a.adminOwnerId&&lu==="workspace"&&(ln!=null&&ln.role)&&ln.role!=="owner"),PS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[jS]||"同步状态",li=m.useCallback(()=>{!ce.current||!je||(xe.current=!1,Be.current+=1,ot.current=!0,Ds("dirty"),Fs("本地修改等待同步"))},[je]);m.useEffect(()=>{a.flowId&&kF(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const w=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{ml([]),Un([]),bs("workspace"),$g(!0)},[a]);const Pn=m.useCallback(async()=>{const w=$r(a),S=await fetch(`/api/workspace/files?${w.toString()}`),_=await S.json();if(!S.ok)throw new Error(_.error||"读取 workspace 失败");const P=_.files||[];Mv(P),fl(new Set(lM(P))),h$(_.root||"")},[a]),If=m.useCallback(async()=>{Tt(!0),Kn("");try{const w=await fetch("/api/marketplace/flow-snippets"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取流程片段失败");Je(Array.isArray(S.snippets)?S.snippets:[])}catch(w){Kn(String(w.message||w)),Je([])}finally{Tt(!1)}},[]),IS=m.useCallback(async(w,S,_)=>{var Y,ae,pe;if(!ce.current)return;if(!je)throw ge("Readonly workspace"),Ds("readonly"),Fs("只读 Project"),new Error("Readonly workspace");Ds("saving"),Fs("正在同步修改");const P=$l(w,S,Z.current);P.ui={...P.ui||{},displayPage:LC(H.current,w)};const T=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:P,baseRevision:me.current,baseGraph:$e.current,clientId:ke.current})}),U=await T.json().catch(()=>({}));if(!T.ok){if(T.status===409||T.status===428){const Ne=Array.isArray(U.conflictItems)?U.conflictItems:[];ul({currentRevision:String(U.currentRevision||""),message:U.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(U.conflictPaths)?U.conflictPaths:[],conflictItems:Ne,mergeGraph:U.mergeGraph||null,currentGraph:U.currentGraph||null}),dl(Object.fromEntries(Ne.map((He,Me)=>[String(Me),{mode:"local",manual:Tu(He)}]))),Xc(""),da(Ne.length>0),Ds("conflict"),Fs(U.error||"存在需要处理的字段冲突");const We=Array.isArray(U.conflictPaths)?U.conflictPaths:[],ze=We.length?`${U.error||"Workspace 已被其他成员更新"}:${We.join("、")}`:U.error||"Workspace 已被其他成员更新",Ve=new Error(ze);throw Ve.code="WORKSPACE_REVISION_CONFLICT",Ve.currentRevision=U.currentRevision||"",Ve}const fe=new Error(U.error||"保存 workspace graph 失败");throw Ds("error"),Fs(fe.message),fe}const X=Be.current!==_,J=mY({savedGraph:U.graph,sentGraph:P,savedRevision:U.revision,currentRevision:me.current});if(me.current=J.revision,$e.current=J.graph,!X){if(Z.current=((Y=U.graph)==null?void 0:Y.instances)||P.instances,ne(Z.current),U.merged&&U.graph){const fe=Ru(U.graph,be),Ne=gh((pe=(ae=U.graph)==null?void 0:ae.ui)==null?void 0:pe.displayPage,fe.nodes);Z.current=fe.instances,ne(fe.instances),g(fe.nodes),x(fe.edges),H.current=Ne,R(Ne)}ot.current=!1}return ga(Dp(U.workspaceSchedules||[])),ul(null),da(!1),Ds(X?"dirty":"synced"),Fs(X?"本地仍有修改等待同步":"所有修改已同步"),ge(X?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[a,be,x,g,je]),Zt=m.useCallback((w=b,S=k)=>{const _=_e.current,P={nextNodes:w,nextEdges:S,saveEditVersion:Be.current,waiters:[]},T=new Promise((J,Y)=>{P.waiters.push({resolve:J,reject:Y})});if(_.running)return _.pending=vC(_.pending,P),T;_.running=!0;const U=async()=>{let J=P;for(;J;){_.pending&&(J=vC(J,_.pending),_.pending=null);try{const Y=await IS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:ae})=>ae(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Ds("error"),Fs(String(Y.message||Y))),J.waiters.forEach(({reject:ae})=>ae(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&_.pending&&(_.pending.waiters.forEach(({reject:ae})=>ae(Y)),_.pending=null)}J=_.pending,_.pending=null}_.running=!1},X=Ce.current.catch(()=>{}).then(U);return Ce.current=X,T},[k,b,IS]),L$=m.useCallback(w=>{var _;const S=(_=w==null?void 0:w.extra)!=null&&_.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};Z.current=S,ne(S),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),Cn(""),ee(null)},[x,g]),O$=m.useMemo(()=>({instances:te}),[te]),D$=qU({nodes:b,edges:k,extra:O$,enabled:ce.current,onRestore:L$}),{resetHistory:uu,undo:RS,redo:TS}=D$,ks=m.useCallback(async(w={})=>{var Le,Mt;const S=(w==null?void 0:w.background)===!0,_=gt.current+1;gt.current=_;const P=Be.current,T=me.current;S||(ce.current=!1);const U=kY({background:S}),X=$r(a);let J=null,Y;if(!U.nodes&&!U.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const Fe=$r(a);Fe.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[ut,Et]=await Promise.all([fetch(`/api/nodes?${Fe.toString()}`),fetch(`/api/workspace/graph?${X.toString()}`),Pn()]);if(J=await ut.json(),!ut.ok)throw new Error(J.error||"读取节点定义失败");Y=Et}const ae=await Y.json();if(!Y.ok)throw new Error(ae.error||"读取 workspace graph 失败");const pe=hY({background:S,requestId:_,currentRequestId:gt.current,dirty:ot.current,startedEditVersion:P,currentEditVersion:Be.current,startedRevision:T,currentRevision:me.current});if(pe==="superseded")return{skipped:!0,reason:pe};if(pe==="local-edits")return ge("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:pe};const fe=S?tn.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(Fe=>!jY.has(Fe.id)),PY,AY,_Y,EY,NY,CY];S||(tn.current=fe,Pt(fe));const Ne=ae.graph||JSON.parse(localStorage.getItem(SY)||"null")||{},We=Ru(Ne,fe),ze=gh((Le=Ne==null?void 0:Ne.ui)==null?void 0:Le.displayPage,We.nodes),Ve=!O.current;let He=D.current;if(Ve){let Fe=null;try{Fe=JSON.parse(window.localStorage.getItem(u)||"null")}catch{Fe=null}He=pb(Fe)||pb((Mt=Ne==null?void 0:Ne.ui)==null?void 0:Mt.viewport)}const Me=S?uY($e.current,Ne):null;if(S&&(Me!=null&&Me.safe)){const Fe=Me.nodesChanged?dY(j.current,We.nodes,Me.changedNodeIds):j.current,ut=Me.edgesChanged?fY(N.current,We.edges):N.current,Et=Me.displayPageChanged||!eo(H.current,ze),El=Me.nodesChanged||Me.edgesChanged||Et;if(El&&(xe.current=!0),Me.nodesChanged){const ci=pY(Z.current,We.instances,Me.changedNodeIds);Z.current=ci,j.current=Fe,ne(ci),g(Fe)}if(Me.edgesChanged&&(N.current=ut,x(ut)),Et&&(H.current=ze,R(ze)),El&&uu(Fe,ut,{instances:Me.nodesChanged?Z.current:We.instances}),Me.nodesChanged||Et){const ci=new Set(ze.nodeIds);K(xa=>{const ba=xa.filter(Gf=>ci.has(Gf));return ba.length===xa.length?xa:ba})}}else Z.current=We.instances,j.current=We.nodes,N.current=We.edges,H.current=ze,xe.current=!0,ne(We.instances),g(We.nodes),x(We.edges),R(ze),K([]),uu(We.nodes,We.edges,{instances:We.instances});const zt=Dp(ae.workspaceSchedules||[]);ga(Fe=>eo(Fe,zt)?Fe:zt),me.current=String(ae.revision||""),$e.current=Ne,ot.current=!1;const rt=ae.collaboration||null;yg(Fe=>eo(Fe,rt)?Fe:rt),g$(ae.adminReview||null),ul(null),Ve&&(L(He),D.current=He,O.current=!0);const Ye=ae.writable!==!1;return m$(Ye),ge(Ye?"Workspace ready":"Readonly workspace"),Ds(Ye?"synced":"readonly"),Fs(Ye?"所有修改已同步":ae.adminReview?`管理员只读查看:${ae.adminReview.ownerUsername||ae.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),ce.current=!0,{skipped:!1}},[a,t.language,Pn,uu,x,g,u]),Rf=m.useCallback((w={})=>{if(!ce.current)return;const S=String(w.revision||""),_=w.type==="graph.committed",P=!!(Te.current||st.current||mt.current);if(vY({eventType:w.type,revision:S,currentRevision:me.current,targetRevision:Rt.current,refreshPending:P}))return;if(_&&S&&(Rt.current=S),ot.current){mt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(mt.current=!0,Te.current||st.current)return;const T=async()=>{if(Te.current=null,Oe.current){mt.current=!0,Te.current=window.setTimeout(T,80);return}if(ot.current){mt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}mt.current=!1,st.current=!0;try{await ks({background:!0}),Rt.current=me.current}catch(U){Rt.current="",ge(String(U.message||U))}finally{st.current=!1,mt.current&&!ot.current&&(Te.current=window.setTimeout(T,40))}};Te.current=window.setTimeout(T,40)},[ks]),du=m.useCallback(async(w=or)=>{const S=String(w||"").trim();nS(!0),hl("");try{const _=$r(a);_.set("tapdId",S),_.set("runtimeOnly","1");const P=await fetch(`/api/prd-workflow/snapshot?${_.toString()}`),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||"读取 PRD Workflow 失败");Nf(T.snapshot||null),Cf(""),_f(null),tu(null);try{const U=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;S?window.localStorage.setItem(U,S):window.localStorage.removeItem(U)}catch{}}catch(_){hl(String(_.message||_))}finally{nS(!1)}},[a,or]),kl=m.useCallback(async(w=null,S={})=>{const _=w&&typeof w=="object"?w:cn==null?void 0:cn.nextAction,P=Gd(_);if(!P||_g)return;const T=(S==null?void 0:S.confirm)===!0,U=String((S==null?void 0:S.expectedRevision)||(cn==null?void 0:cn.revision)||"");rS(!0),hl(""),T||(Cf(""),_f(null),tu(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:or,action:P,stage:tl(_),title:to(_,0),...aG(_),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&&Nf(J.snapshot),J.conflict&&tu({...J.conflict,action:_}),new Error(J.error||"执行 PRD Workflow action 失败");Cf(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),Nf(J.snapshot||cn),tu(null),_f(T?null:{action:_,output:J.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(X){hl(String(X.message||X))}finally{rS(!1)}},[a,_g,cn,or]),F$=m.useCallback((w=null)=>kl(w,{confirm:!1}),[kl]),z$=m.useCallback(()=>{const w=(xs==null?void 0:xs.action)||(cn==null?void 0:cn.nextAction);return kl(w,{confirm:!0,expectedRevision:(xs==null?void 0:xs.expectedRevision)||""})},[kl,xs,cn]),B$=m.useCallback(()=>{const w=(eu==null?void 0:eu.action)||(cn==null?void 0:cn.nextAction);return tu(null),kl(w,{confirm:!1})},[kl,eu,cn]),H$=m.useCallback(async()=>{var U,X;const w=String(Eg||(cn==null?void 0:cn.rawOutput)||"").trim();if(!w||Ag)return;const S=(xs==null?void 0:xs.action)||(cn==null?void 0:cn.nextAction)||{},_=`Review: ${to(S,0)||(cn==null?void 0:cn.pointer)||or||"PRD Workflow"}`,P=/^[\[{]/.test(w),T=w.startsWith("#")?w:`# ${_}
247
+
248
+ ${P?`\`\`\`json
249
+ ${w}
250
+ \`\`\``:w}`;sS(!0),hl("");try{const J=await fetch("/api/prd-workflow/review-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:or,title:_,markdown:T,action:Gd(S),stage:tl(S),issueKey:S.issueKey||S.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");Nf(Y.snapshot||cn);const ae=((U=Y.review)==null?void 0:U.shortUrl)||((X=Y.review)==null?void 0:X.url)||"";ae&&Cf(pe=>`${pe||w}
251
+
252
+ Review link: ${ae}`)}catch(J){hl(String(J.message||J))}finally{sS(!1)}},[a,Eg,xs,Ag,cn,or]),W$=m.useCallback(async(w,S)=>{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:S,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},P=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),T=await P.json().catch(()=>({}));if(!P.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||"Publish failed");return await ks(),ge(`Published node ${T.definitionId||T.id||_.packageId}`),T},[a,ks]),ya=m.useCallback((w=Os)=>{const S=Array.isArray(w)?w:[],P=[...S].reverse().find(T=>(T==null?void 0:T.status)==="running"||(T==null?void 0:T.status)==="stopping")||[...S].reverse().find(T=>T==null?void 0:T.id);return String((P==null?void 0:P.id)||"workspace")},[Os]),V$=m.useCallback(w=>{const S=String(w||"").trim();!S||S==="workspace"||Un(_=>{const P=(Array.isArray(_)?_:[]).filter(T=>T.id!==S);return bs(T=>T===S?ya(P):T),P})},[ya]);m.useCallback((w="")=>{gl(!0),yl(null),ws(null),bs(w||ya())},[ya]);const MS=m.useCallback((w={})=>{yl({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),gl(!1),ws(null),Cn("")},[]),zg=m.useCallback(async(w="")=>{const S=String(w||"").trim();if(!(!S||!je)){SS(S),ge(`Optimizing run: ${S}`);try{await Zt(j.current,N.current);const _=$l(j.current,N.current,Z.current),P=GC(j.current,Z.current,S,Li),T=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:S,graph:_,model:P})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"优化失败");const X=U.graph||_,J=Ru(X,be);Z.current=J.instances,ne(J.instances),g(J.nodes),x(J.edges),ga(Dp(U.workspaceSchedules||[])),uu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(U.optimized)?U.optimized.length:0;ge(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(_){ge(String(_.message||_))}finally{SS("")}}},[Li,N,a,j,be,uu,Zt,x,g,je]),$S=m.useCallback(async(w="")=>{const S=String(w||"").trim(),_=iu.current||{},P=Object.entries(_).find(([Y,ae])=>Y===S||String((ae==null?void 0:ae.runNodeId)||"")===S)||Object.entries(_)[0]||null,T=(P==null?void 0:P[0])||"",U=(P==null?void 0:P[1])||null,X=String((U==null?void 0:U.runNodeId)||S||"").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(Y=>String(Y||"").trim()).filter(Boolean));T&&Di(Y=>{const ae={...Y};return ae[T]&&(ae[T]={...ae[T],status:"stopping"}),ae}),ge(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Un(Y=>Y.map(ae=>(T?ae.id===T:!X||ae.runNodeId===X)&&ae.status==="running"?{...ae,status:"stopping"}:ae));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:T,runNodeId:X})}),ae=await Y.json().catch(()=>({}));if(!Y.ok||(ae==null?void 0:ae.stopped)!==!0)throw new Error(ae.error||"Workspace run stop failed");const pe=T?ou.current.get(T):null;pe&&(pe.abort(),ou.current.delete(T)),T&&Di(fe=>{const Ne={...fe};return delete Ne[T],Ne}),xl(fe=>{const Ne=new Set(fe);for(const We of J)Ne.delete(We);return Ne}),bl(fe=>{var We;const Ne={...fe};for(const ze of J)ze&&(!Ne[ze]||((We=Ne[ze])==null?void 0:We.status)==="running")&&(Ne[ze]={status:"stopped"});return Ne}),ge(X?`Workspace run stopped: ${X}`:"Workspace run stopped"),Un(fe=>fe.map(Ne=>(T?Ne.id===T:!X||Ne.runNodeId===X)?{...Ne,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(Ne.messages)?Ne.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:Ne))}catch(Y){T&&Di(pe=>{const fe={...pe};return fe[T]&&(fe[T]={...fe[T],status:"running"}),fe});const ae=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ge(`停止失败:${ae}`),Un(pe=>pe.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:`停止失败:${ae}`,at:Date.now()}].slice(-160)}:fe))}},[a,Di]),Tf=m.useCallback(async()=>{if(a.flowId)try{const w=$r(a),S=await fetch(`/api/workspace/run/status?${w.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok||!_.running)return;const P=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 P){const J=String((X==null?void 0:X.runNodeId)||"").trim(),Y=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const ae=String((X==null?void 0:X.label)||"").trim()||iw(j.current,Z.current,J,"Workspace Run");T[Y]={id:Y,runNodeId:J,label:ae,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;Di(X=>({...X,...T})),xl(X=>{const J=new Set(X);for(const Y of U)J.add(Y);return J}),bl(X=>{const J={...X};for(const Y of U)J[Y]={status:"running"};return J}),ge(U.length?`Workspace run still running: ${U.join(", ")}`:"Workspace run still running"),Un(X=>{const J=[...X];for(const[Y,ae]of Object.entries(T)){if(J.some(Ne=>Ne.id===Y||["running","stopping"].includes(Ne.status)&&Ne.runNodeId===ae.runNodeId))continue;const pe=String(ae.runNodeId||""),fe=String(ae.label||"").trim()||iw(j.current,Z.current,pe,"Workspace Run");J.push({id:Y,label:ow(fe,pe,"Workspace Run"),alias:fe,runNodeId:pe,status:ae.status,startedAt:ae.startedAt||Date.now(),steps:pe?[{id:pe,label:ow(fe,pe,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:ae.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,j,Di]),LS=m.useCallback(async w=>{if(!je){ge("Readonly workspace");return}if(!w)return;if(Object.values(iu.current||{}).find(rt=>String((rt==null?void 0:rt.runNodeId)||"")===String(w||""))){ge(`Workspace run already running: ${w}`);return}let _=j.current,P=N.current,T=Z.current;const U=Tv.current;if(U!=null&&U.id){const rt=_.find(Le=>Le.id===U.id),Ye=XC({nodes:_,edges:P,instances:T,selectedNode:rt,draft:U,allowRename:!1});if(Ye!=null&&Ye.error){ll(Ye.error),ge(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(_=Ye.nodes,P=Ye.edges,T=Ye.instances,Z.current=T,j.current=_,N.current=P,ne(T),g(_),x(P),Hr(Ye.nextId||U.id))}const X=$l(_,P,T),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=iw(_,T,w,"Workspace Run"),ae=ow(Y,w,"Workspace Run");let pe=[w];try{const rt=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:X,runNodeId:w})}),Ye=await rt.json().catch(()=>({}));if(!rt.ok||(Ye==null?void 0:Ye.ok)===!1)throw new Error(Ye.error||"Workspace run plan failed");pe=Array.isArray(Ye.plannedNodeIds)&&Ye.plannedNodeIds.length?Ye.plannedNodeIds.map(Mt=>String(Mt||"").trim()).filter(Boolean):[w],pe=Array.from(new Set([w,...pe].filter(Boolean)));const Le=Ye.conflict||null;if(Le!=null&&Le.runNodeId||Le!=null&&Le.runId){const Mt=Array.isArray(Le.conflictNodeIds)&&Le.conflictNodeIds.length?`: ${Le.conflictNodeIds.join(", ")}`:"";ge(`Run ${w} conflicts with running ${Le.runNodeId||Le.runId}${Mt}`);return}}catch(rt){ge(String(rt.message||rt));return}const fe=new Set(pe),Ne=Object.values(iu.current||{}).find(rt=>(Array.isArray(rt==null?void 0:rt.plannedNodeIds)?rt.plannedNodeIds:[]).some(Ye=>fe.has(String(Ye||"").trim())));if(Ne){const rt=(Array.isArray(Ne.plannedNodeIds)?Ne.plannedNodeIds:[]).map(Ye=>String(Ye||"").trim()).filter(Ye=>Ye&&fe.has(Ye));ge(`Run ${w} conflicts with running ${Ne.runNodeId||"workspace run"}${rt.length?`: ${rt.join(", ")}`:""}`);return}const We=new AbortController;ou.current.set(J,We),au.current.delete(J),Di(rt=>({...rt,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:pe,startedAt:Date.now()}})),xl(rt=>new Set([...rt,w])),bl(rt=>({...rt,[w]:{status:"running"}})),ge(`Running ${ae}...`),bs(J),Un(rt=>[...rt.slice(-7),{id:J,label:ae,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let ze=w;const Ve=new Map,He=()=>au.current.has(J),Me=rt=>{const Ye=new Set((rt||[]).map(Le=>String(Le||"").trim()).filter(Boolean));Ye.size||Ye.add(String(w||"")),xl(Le=>{const Mt=new Set(Le);for(const Fe of Ye)Mt.delete(Fe);return Mt})},zt=(rt,Ye)=>{const Le=new Set((rt||[]).map(Mt=>String(Mt||"").trim()).filter(Boolean));Le.size||Le.add(String(w||"")),bl(Mt=>{var ut;const Fe={...Mt};for(const Et of Le)Et&&(!Fe[Et]||((ut=Fe[Et])==null?void 0:ut.status)==="running")&&(Fe[Et]={status:Ye});return Fe})};try{await Zt(_,P);const rt=GC(_,T,w,Li),Ye=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:We.signal,body:JSON.stringify({...a,graph:X,runNodeId:w,runAlias:Y,runSessionId:J,expectedRevision:me.current,clientId:ke.current,model:rt,selectedSkills:Ls,stream:!0})});if(!Ye.ok){const ye=await Ye.json().catch(()=>({}));throw new Error(ye.error||"Workspace run failed")}if(!Ye.body)throw new Error("Workspace run stream unavailable");const Le=Ye.body.getReader(),Mt=new TextDecoder;let Fe="",ut=[],Et=[];const El=(ye,nt)=>{var lt,Ct;const Ge=b.find(Dt=>Dt.id===ye),ft=String(((lt=Ge==null?void 0:Ge.data)==null?void 0:lt.label)||ye||"").trim(),we=String(nt||((Ct=Ge==null?void 0:Ge.data)==null?void 0:Ct.definitionId)||"").trim();return we&&we!==ft?`${ft} (${we})`:ft},ci=(ye,nt,Ge)=>{const ft=String(ye||"").trim();ft&&Un(we=>we.map(lt=>{if(lt.id!==J)return lt;const Dt=[...Array.isArray(lt.steps)?lt.steps:[]],pt=Dt.findIndex(hn=>hn.id===ft),kt={id:ft,label:El(ft,nt),status:Ge};pt>=0?Dt[pt]={...Dt[pt],...kt}:Dt.push(kt);const fn=Dt.map((hn,ko)=>{const Bi=hn.status==="done"?"[done]":hn.status==="failed"?"[failed]":"[running]";return`${ko+1}. ${Bi} ${hn.label}`}).join(`
253
+ `),Gt=Array.isArray(lt.messages)?lt.messages:[],sn=Gt.findIndex(hn=>hn.kind==="run-summary"),bn={role:"assistant",kind:"run-summary",text:fn||"准备运行...",at:Date.now()},Bt=[...Gt];return sn>=0?Bt[sn]=bn:Bt.unshift(bn),{...lt,steps:Dt,messages:Bt.slice(-160)}}))},xa=(ye,nt)=>{var E0,A0,P0,I0,R0,T0,M0,$0,L0,O0;const Ge=String(ye||"").trim(),ft=String(nt||"").trim();if(!Ge||!ft)return;const we=(E0=Z.current)==null?void 0:E0[Ge];if(!ti(we==null?void 0:we.definitionId))return;const lt=na(we==null?void 0:we.input,"displayType","markdown"),Ct=pM(lt),Dt=hM(Ge),pt=be.find(Tr=>Tr.id===Ct),kt=KC(pt==null?void 0:pt.inputs,Ct,ft),fn=KC(pt==null?void 0:pt.outputs,Ct,ft),Gt=String((we==null?void 0:we.label)||Ge||"一键任务").trim(),sn={...Z.current||{},[Ge]:{...we||{},output:UC(we==null?void 0:we.output)},[Dt]:{...((A0=Z.current)==null?void 0:A0[Dt])||{},definitionId:Ct,label:Gt,role:"normal",body:ft,input:kt,output:fn,sourceContextRunNodeId:Ge,displayReloadKey:String(Date.now())}};Z.current=sn,ne(sn);const bn=j.current||[],Bt=bn.find(Tr=>Tr.id===Ge),hn=bn.find(Tr=>Tr.id===Dt),ko=Number(((P0=Bt==null?void 0:Bt.measured)==null?void 0:P0.width)||(Bt==null?void 0:Bt.width)||((R0=(I0=Bt==null?void 0:Bt.data)==null?void 0:I0.nodeSize)==null?void 0:R0.width)||520),Bi=(hn==null?void 0:hn.position)||{x:Number(((T0=Bt==null?void 0:Bt.position)==null?void 0:T0.x)||0)+ko+120,y:Number(((M0=Bt==null?void 0:Bt.position)==null?void 0:M0.y)||0)},lr=(($0=hn==null?void 0:hn.data)==null?void 0:$0.displaySize)||((L0=hn==null?void 0:hn.data)==null?void 0:L0.nodeSize)||{width:ab,height:lb},ui=sb({id:Dt,type:hc,position:Bi,width:Number(lr.width)||ab,height:Number(lr.height)||lb,data:{label:Gt,definitionId:Ct,role:"normal",body:ft,inputs:kt,outputs:fn,sourceContextRunNodeId:Ge,displayReloadKey:sn[Dt].displayReloadKey,nodeSize:lr,displaySize:lr}},sn,be),vo=bn.map(Tr=>{if(Tr.id===Ge){const{width:Tce,height:Mce,measured:$ce,...HL}=Tr,{nodeSize:Lce,displaySize:Oce,...ep}=Tr.data||{};return{...HL,data:{...ep,outputs:UC(ep==null?void 0:ep.outputs),contextRunResultNonce:Date.now()}}}return Tr.id===Dt?{...ui,selected:Tr.selected}:Tr});hn||vo.push(ui),j.current=vo,g(vo);const So=N.current||[],Zf=mM(Ct),ey=qC((we==null?void 0:we.output)||((O0=Bt==null?void 0:Bt.data)==null?void 0:O0.outputs),"output",["content","result"],["text"]),zL=qC(kt,"input",[Zf,"content"],["text"]),BL={id:`we-${Ge}-${Dt}`,source:Ge,target:Dt,sourceHandle:ey,targetHandle:zL,markerEnd:{type:bi.ArrowClosed}},_0=[...So.filter(Tr=>!(Tr.source===Ge&&Tr.target===Dt)),BL];N.current=_0,x(_0),window.requestAnimationFrame(()=>{o(Ge),o(Dt)})},ba=(ye,nt=null)=>{const Ge=ye!=null&&ye.instances&&typeof ye.instances=="object"?ye.instances:{},ft=nt instanceof Set?nt:null;for(const[we,lt]of Object.entries(Ge)){if(ft&&!ft.has(we)||!ti(lt==null?void 0:lt.definitionId))continue;const Ct=cg({outputs:lt.output});Ct&&xa(we,Ct)}},Gf=ye=>{const nt=String(ye||"").trim();if(!nt)return;const Ge=ze;ze=nt,xl(ft=>{const we=new Set(ft);return Ge&&Ge!==nt&&Ge!==w&&we.delete(Ge),w&&we.add(w),we.add(nt),we}),bl(ft=>{var we;return{...ft,...Ge&&Ge!==nt&&Ge!==w&&((we=ft[Ge])==null?void 0:we.status)==="running"?{[Ge]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},j0=ye=>{const nt=String(ye||"").trim();nt&&(xl(Ge=>{const ft=new Set(Ge);return ft.delete(nt),ft}),bl(Ge=>({...Ge,[nt]:{status:"success"}})))},N0=(ye,nt)=>{const Ge=String(nt||"");if(!Ge.trim())return;const ft=["assistant","thinking","result","error","prompt"].includes(ye)?ye:"assistant";Un(we=>we.map(lt=>{if(lt.id!==J)return lt;let Ct=Array.isArray(lt.messages)?lt.messages:[];if(ft==="result"){const kt=[...Ct].reverse().find(fn=>fn.kind==="assistant");if(String((kt==null?void 0:kt.text)||"").trim()===Ge.trim())return lt}if(ft==="assistant"){const kt=Ct.findIndex(fn=>fn.kind==="result"&&String(fn.text||"").trim()===Ge.trim());kt>=0&&(Ct=Ct.filter((fn,Gt)=>Gt!==kt))}const Dt=[...Ct],pt=Dt[Dt.length-1];return pt&&pt.kind===ft&&!pt.error?Dt[Dt.length-1]={...pt,text:`${pt.text||""}${pt.text?`
254
+ `:""}${Ge}`}:Dt.push({role:"assistant",kind:ft,text:Ge,...ft==="error"?{error:!0}:{},at:Date.now()}),{...lt,messages:Dt.slice(-160)}}))},Jf=ye=>{const nt=String(ye||"");nt.trim()&&Un(Ge=>Ge.map(ft=>{var Dt;if(ft.id!==J)return ft;const we=Array.isArray(ft.messages)?ft.messages:[],lt=we.findIndex(pt=>pt.kind==="thinking"),Ct=[...we];if(lt>=0){const pt=String(((Dt=Ct[lt])==null?void 0:Dt.text)||"");Ct[lt]={...Ct[lt],text:`${pt}${pt&&!pt.endsWith(`
255
+ `),""}${nt}`,at:Date.now()}}else{const pt=Ct.findIndex(kt=>kt.kind==="activity");Ct.splice(pt>=0?pt+1:Ct.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...ft,messages:Ct.slice(-160)}}))},bo=(ye,nt=null)=>{const Ge=WY(ye);Ge&&Un(ft=>ft.map(we=>{if(we.id!==J)return we;const lt=Number(nt==null?void 0:nt.ts)||Date.now(),Ct=Number(we.startedAt)||lt,Dt=Number(we.lastActivityAt)||Ct,pt=Math.max(0,lt-Dt),kt=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,lt-Ct),fn=Array.isArray(we.activities)?we.activities:[],Gt=fn[fn.length-1],bn=(typeof Gt=="string"?Gt:String((Gt==null?void 0:Gt.text)||""))===Ge?fn:[...fn,{text:Ge,kind:KY(Ge),stepMs:pt,totalMs:kt,at:lt}].slice(-30),Bt=Array.isArray(we.timingEntries)?we.timingEntries:[],hn=Array.isArray(we.messages)?we.messages:[],ko=hn.findIndex(ui=>ui.kind==="activity"),Bi={role:"assistant",kind:"activity",text:EC(bn,Bt,Ct,lt),at:Date.now()},lr=[...hn];if(ko>=0)lr[ko]=Bi;else{const ui=lr.findIndex(vo=>vo.kind==="run-summary");lr.splice(ui>=0?ui+1:0,0,Bi)}return{...we,activities:bn,lastActivityAt:lt,messages:lr.slice(-160)}}))},C0=ye=>{const nt=String((ye==null?void 0:ye.source)||"runner"),Ge=String((ye==null?void 0:ye.stream)||""),ft=String((ye==null?void 0:ye.eventType)||"event"),we=String((ye==null?void 0:ye.text)||"").trim();if(!we)return;const lt=`[${nt}${Ge?`:${Ge}`:""}] ${ft}
256
+ ${we}`,Ct=SG(ye);Un(Dt=>Dt.map(pt=>{if(pt.id!==J)return pt;const fn=[...Array.isArray(pt.rawTrace)?pt.rawTrace:[],lt].slice(-80),Gt=Array.isArray(pt.timingEntries)?pt.timingEntries:[],sn=Ct?[...Gt,Ct].slice(-80):Gt,bn=Array.isArray(pt.activities)?pt.activities:[],Bt=Number(pt.startedAt)||Number(ye==null?void 0:ye.ts)||Date.now(),hn=Number(Ct==null?void 0:Ct.at)||Number(ye==null?void 0:ye.ts)||Date.now(),ko=Array.isArray(pt.messages)?pt.messages:[],Bi={role:"assistant",kind:"raw",text:fn.join(`
257
+
258
+ ---
259
+
260
+ `),at:Date.now()},lr=[...ko],ui=lr.findIndex(So=>So.kind==="activity");if(Ct){const So={role:"assistant",kind:"activity",text:EC(bn,sn,Bt,hn),at:Date.now()};if(ui>=0)lr[ui]=So;else{const Zf=lr.findIndex(ey=>ey.kind==="run-summary");lr.splice(Zf>=0?Zf+1:0,0,So)}}const vo=lr.findIndex(So=>So.kind==="raw");return vo>=0?lr[vo]=Bi:lr.push(Bi),{...pt,rawTrace:fn,timingEntries:sn,messages:lr.slice(-160)}}))},FL=ye=>{Un(nt=>nt.map(Ge=>Ge.id===J?{...Ge,status:ye,endedAt:Date.now()}:Ge))},Xf=ye=>{const nt=new Set,Ge=String((ye==null?void 0:ye.nodeId)||"").trim();Ge&&nt.add(Ge);for(const ft of Array.isArray(ye==null?void 0:ye.displayNodeIds)?ye.displayNodeIds:[]){const we=String(ft||"").trim();we&&nt.add(we)}for(const ft of Array.isArray(ye==null?void 0:ye.touchedNodeIds)?ye.touchedNodeIds:[]){const we=String(ft||"").trim();we&&nt.add(we)}if(nt.size===0)for(const ft of Array.isArray(ye==null?void 0:ye.order)?ye.order:[]){const we=String(ft||"").trim();we&&nt.add(we)}return nt},Qf=(ye,nt=null)=>{const Ge=Ru(ye||X,be),ft=new Map(Ge.nodes.map(pt=>[pt.id,pt])),we=Ge.instances||{},lt=nt instanceof Set?nt:null,Ct=(pt,kt)=>{const fn={...pt||kt};Array.isArray(kt==null?void 0:kt.output)&&(fn.output=kt.output);for(const Gt of["scriptRef","implementationRef","implementationMode"])(kt==null?void 0:kt[Gt])!=null&&String(kt[Gt]).trim()!==""&&(fn[Gt]=kt[Gt]);return fn},Dt=(pt,kt)=>{const fn={...pt||{}};Array.isArray(kt==null?void 0:kt.outputs)&&(fn.outputs=kt.outputs);for(const Gt of["scriptRef","implementationRef","implementationMode"])(kt==null?void 0:kt[Gt])!=null&&String(kt[Gt]).trim()!==""&&(fn[Gt]=kt[Gt]);return fn};g(pt=>{const kt=new Set(pt.map(sn=>sn.id)),Gt={...$l(pt,N.current,Z.current).instances||{}};for(const[sn,bn]of Object.entries(we)){if(lt&&!lt.has(sn)||!kt.has(sn))continue;const Bt=Gt[sn];nl((bn==null?void 0:bn.definitionId)||(Bt==null?void 0:Bt.definitionId))?Gt[sn]=bn:Array.isArray(bn==null?void 0:bn.output)&&(Gt[sn]=Ct(Bt,bn))}return Z.current=Gt,ne(Gt),pt.map(sn=>{var Bt,hn;if(lt&&!lt.has(sn.id))return sn;const bn=ft.get(sn.id);return bn?nl(((Bt=bn.data)==null?void 0:Bt.definitionId)||((hn=sn.data)==null?void 0:hn.definitionId))?{...sn,data:{...sn.data,...bn.data}}:{...sn,data:Dt(sn.data,bn.data)}:sn})})};for(;;){const{value:ye,done:nt}=await Le.read();if(nt)break;Fe+=Mt.decode(ye,{stream:!0});const Ge=Fe.split(`
261
+ `);Fe=Ge.pop()||"";for(const ft of Ge){if(!ft.trim())continue;const we=JSON.parse(ft);if(we.type==="error")throw new Error(we.error||"Workspace run failed");if(we.type==="stopped"){au.current.add(J),ut=Array.isArray(we.order)?we.order:ut,bo("运行停止",we);continue}if(we.type==="node-start"&&(ge(`Running ${we.nodeId}...`),Gf(we.nodeId),ci(we.nodeId,we.definitionId,"running")),we.type==="node-done"){const lt=Ve.get(String(we.nodeId||"").trim());lt&&xa(we.nodeId,lt),j0(we.nodeId),ci(we.nodeId,we.definitionId,"done")}if(we.type==="status"&&bo(we.line||we.message||"",we),we.type==="paused"&&(Et=Array.isArray(we.nodeIds)?we.nodeIds:[],bo("运行暂停",we)),we.type==="natural"&&((we.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(we.text||"")))&&we.nodeId&&Ve.set(String(we.nodeId||"").trim(),String(we.text||"")),we.kind==="thinking"?Jf(we.text||""):N0(we.kind,we.text||"")),we.type==="raw"){const lt=AC(we);lt&&Jf(lt),C0(we)}if(we.type==="graph"&&we.graph){const lt=Xf(we);Qf(we.graph,lt),ba(we.graph,lt)}if(we.type==="done"){if(we.revision&&(me.current=String(we.revision)),we.graph){$e.current=we.graph;const lt=Xf(we);Qf(we.graph,lt),ba(we.graph,lt)}ut=Array.isArray(we.order)?we.order:[],Et=Array.isArray(we.pauseNodeIds)?we.pauseNodeIds:Et,bo(Et.length?"运行暂停":"运行完成",we)}}}if(Fe.trim()){const ye=JSON.parse(Fe);if(ye.type==="error")throw new Error(ye.error||"Workspace run failed");if(ye.type==="stopped"&&(au.current.add(J),bo("运行停止",ye)),ye.type==="node-start"&&(ge(`Running ${ye.nodeId}...`),Gf(ye.nodeId),ci(ye.nodeId,ye.definitionId,"running")),ye.type==="node-done"){const nt=Ve.get(String(ye.nodeId||"").trim());nt&&xa(ye.nodeId,nt),j0(ye.nodeId),ci(ye.nodeId,ye.definitionId,"done")}if(ye.type==="status"&&bo(ye.line||ye.message||"",ye),ye.type==="paused"&&(Et=Array.isArray(ye.nodeIds)?ye.nodeIds:[],bo("运行暂停",ye)),ye.type==="natural"&&((ye.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(ye.text||"")))&&ye.nodeId&&Ve.set(String(ye.nodeId||"").trim(),String(ye.text||"")),ye.kind==="thinking"?Jf(ye.text||""):N0(ye.kind,ye.text||"")),ye.type==="raw"){const nt=AC(ye);nt&&Jf(nt),C0(ye)}if(ye.type==="graph"&&ye.graph){const nt=Xf(ye);Qf(ye.graph,nt),ba(ye.graph,nt)}if(ye.type==="done"){if(ye.revision&&(me.current=String(ye.revision)),ye.graph){$e.current=ye.graph;const nt=Xf(ye);Qf(ye.graph,nt),ba(ye.graph,nt)}ut=Array.isArray(ye.order)?ye.order:[],Et=Array.isArray(ye.pauseNodeIds)?ye.pauseNodeIds:Et,bo(Et.length?"运行暂停":"运行完成",ye)}}He()&&(Me(pe),zt(pe,"stopped"));const Zg=He()?`Workspace run stopped: ${w}`:Et.length?`Workspace run paused at ${Et.join(", ")}`:`Workspace run done: ${ut.length?ut.join(" -> "):w}`;if(ge(Zg),He()||zt(pe,Et.length?"paused":"success"),FL(He()?"stopped":Et.length?"paused":"done"),!He()){try{await Zt(j.current,N.current),ge(Zg)}catch(ye){ge(`${Zg},但保存结果失败:${String(ye.message||ye)}`)}await Pn()}}catch(rt){if(He()||(rt==null?void 0:rt.name)==="AbortError"){Me(pe),zt(pe,"stopped"),ge(`Workspace run stopped: ${w}`),Un(Ye=>Ye.map(Le=>Le.id===J?{...Le,status:"stopped",endedAt:Date.now()}:Le));return}Me(pe),zt([w,ze].filter(Boolean),"failed"),ge(String(rt.message||rt)),Un(Ye=>Ye.map(Le=>Le.id===J?{...Le,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Le.messages)?Le.messages:[],{role:"assistant",error:!0,text:String(rt.message||rt),at:Date.now()}].slice(-160)}:Le))}finally{ou.current.get(J)===We&&ou.current.delete(J),Di(rt=>{const Ye={...rt};return delete Ye[J],Ye}),au.current.delete(J),Me(pe)}},[Li,k,a,Pn,b,be,Hr,Zt,Ls,x,g,Di,o,je]),Mf=m.useCallback(async()=>{try{const S=await(await fetch("/api/skills")).json().catch(()=>({})),_=Array.isArray(S.skills)?S.skills.map(P=>({key:String(P.key),name:String(P.name||P.id||P.key),description:P.description?String(P.description):"",sourceLabel:P.sourceLabel?String(P.sourceLabel):""})):[];j$(_),Jv(!0)}catch{Jv(!0)}},[]),$f=m.useCallback(async()=>{try{const S=await(await fetch("/api/mcps")).json().catch(()=>({})),_=Array.isArray(S.servers)?S.servers.map(P=>({name:String((P==null?void 0:P.name)||""),type:String((P==null?void 0:P.type)||""),url:String((P==null?void 0:P.url)||""),command:String((P==null?void 0:P.command)||""),args:Array.isArray(P==null?void 0:P.args)?P.args.map(String):[],description:String((P==null?void 0:P.description)||"")})).filter(P=>P.name):[];Zv(_)}catch{Zv([])}},[]),Lf=m.useCallback(async()=>{try{const w=$r(a),_=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),P=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):[];tS(P)}catch{tS([])}},[a]),OS=m.useCallback(async()=>{Ke.current=!1;try{const w=$r(a),S=await fetch(`/api/workspace/conversations?${w.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok)throw new Error(_.error||`HTTP ${S.status}`);const P=jC(_.conversations||{});ml(P.composer.messages),Un(P.composer.runSessions),bs(P.composer.activeSessionId||"workspace"),wo(P.nodeChats)}catch{ml([]),Un([]),bs("workspace"),wo({})}finally{Ke.current=!0}},[a]),DS=m.useCallback(async()=>{if(!je||a.archived)return;const w=jC({composer:{activeSessionId:Wr,messages:ha,runSessions:Os},nodeChats:ma});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async S=>{if(!S.ok){const _=await S.json().catch(()=>({}));throw new Error(_.error||`HTTP ${S.status}`)}})},[Wr,ha,Os,a,ma,je]);m.useEffect(()=>{let w=!1;return(async()=>{const _=new URL(window.location.href),P=String(_.searchParams.get("invite")||"").trim();if(P){ge("正在加入共享 Workspace...");const T=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:P})}),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 ks(),w||await OS())})().catch(_=>{const P=String(_.message||_);ge(P),Ds("error"),Fs(P)}),If(),fetch("/api/model-lists").then(_=>_.json()).then(_=>v$({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(()=>{}),Mf(),$f(),Lf(),Tf(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{N$(Da(_)),C$(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>{hS(_.user||null),gS(!0)}).catch(()=>{hS(null),gS(!0)}),()=>{w=!0}},[ks,OS,If,$f,Mf,Tf,Lf,Oi]),m.useEffect(()=>{if(_S(""),!(!Gv||!Xv)){if(!Oi){Zc([]);return}Zc(TF(Oi,"workspace",$s,pl)),_S(Oi)}},[pl,Xv,$s,Gv,Oi]),m.useEffect(()=>{if(!(CS!==Oi||!Oi))try{localStorage.setItem(Oi,JSON.stringify(Ls))}catch{}},[Ls,Oi,CS]),m.useEffect(()=>{Z.current=te},[te]),m.useEffect(()=>{j.current=b},[b]),m.useEffect(()=>{if(Oe.current)return;const w=z.current,S=new Map,_=[];for(const P of b){const T=GT(P);S.set(P.id,T),w.get(P.id)!==T&&_.push(P.id)}z.current=S,_.length!==0&&Hr(_)},[b,Hr]),m.useEffect(()=>{N.current=k},[k]),m.useEffect(()=>{H.current=I},[I]),m.useEffect(()=>{D.current=A},[A]),m.useEffect(()=>{Tv.current=at},[at]),m.useEffect(()=>{yo.current=Yt},[Yt]),m.useEffect(()=>{ue.current=G},[G]),m.useEffect(()=>{if(!G)return;const w=_=>{_.key==="Escape"&&ee(null)},S=_=>{var P,T;(T=(P=_.target)==null?void 0:P.closest)!=null&&T.call(P,".af-connect-node-menu")||ee(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S)}},[G]),m.useEffect(()=>{if(!ce.current||!je)return;if(Oe.current){de.current&&window.clearTimeout(de.current);return}if(xe.current){xe.current=!1;return}li(),de.current&&window.clearTimeout(de.current);const w=ie.current?0:650;return ie.current=!1,de.current=window.setTimeout(()=>{Zt().catch(S=>ge(String(S.message||S)))},w),()=>{de.current&&window.clearTimeout(de.current)}},[b,k,I,li,Zt,je]),m.useEffect(()=>{if(Ke.current&&!(!je||a.archived))return Ue.current&&window.clearTimeout(Ue.current),Ue.current=window.setTimeout(()=>{DS().catch(w=>ge(String(w.message||w)))},900),()=>{Ue.current&&window.clearTimeout(Ue.current)}},[Wr,ha,Os,a.archived,ma,DS,je]);const fu=m.useMemo(()=>b.filter(w=>{var S;return((S=w==null?void 0:w.data)==null?void 0:S.definitionId)==="workspace_scheduled_run"}).map(w=>{var S;return{id:w.id,config:yv(((S=w.data)==null?void 0:S.body)||"")}}),[b]),K$=m.useMemo(()=>fu.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[fu]);m.useEffect(()=>{if(!ce.current||d!=="workspace"||!a.flowId){ga({});return}if(!fu.length){ga({});return}let w=!1;const S=async()=>{try{const P=$r(a),T=await fetch(`/api/workspace/schedules?${P.toString()}`),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");w||ga(Dp(U.schedules||[]))}catch{w||ga(P=>{var U;const T={};for(const X of fu)T[X.id]={...P[X.id]||{},lastStatus:((U=P[X.id])==null?void 0:U.lastStatus)||"unknown"};return T})}};S();const _=window.setInterval(S,5e3);return()=>{w=!0,window.clearInterval(_)}},[a,fu,K$,d]);const FS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=VC(S),P=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="skillKeys"&&(ae==null?void 0:ae.name)!=="skillsContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],T=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:P((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:P(X.input)}};Z.current=J,g(T),ne(J),ws(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:P(Y.inputs)}),Zt(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,Zt,g,je]),zS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=RJ(S),P=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="serverNames"&&(ae==null?void 0:ae.name)!=="mcpContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],T=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:P((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...X,body:_,input:P(X.input)}};Z.current=J,g(T),ne(J),ws(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:P(Y.inputs)}),Zt(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,Zt,g,je]),BS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=(Array.isArray(S)?S:S?[S]:[]).filter(ze=>String((ze==null?void 0:ze.path)||"").trim()),P=_[0]||null,T=String((P==null?void 0:P.path)||"").trim(),U=_.length===1?String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim():_.length?`${_.length} 个知识库`:"",X=_.length?JSON.stringify(ug(_)):"",J=P?JSON.stringify({version:1,id:(P==null?void 0:P.id)||"",label:String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim(),kind:(P==null?void 0:P.kind)||"local",cwd:T,workspaceRoot:T,repoUrl:(P==null?void 0:P.repoUrl)||"",branch:(P==null?void 0:P.branch)||"",mountPath:(P==null?void 0:P.mountPath)||"",type:(P==null?void 0:P.type)||""}):"",Y=ze=>Array.isArray(ze)?ze.map(Ve=>(Ve==null?void 0:Ve.name)==="path"?{...Ve,default:T,value:T}:(Ve==null?void 0:Ve.name)==="label"?{...Ve,default:U,value:U}:(Ve==null?void 0:Ve.name)==="knowledgeContext"?{...Ve,default:X,value:X}:(Ve==null?void 0:Ve.name)==="workspaceContext"?{...Ve,default:J,value:J}:(Ve==null?void 0:Ve.name)==="mode"?{...Ve,default:"set",value:"set"}:Ve):[],ae=ze=>Array.isArray(ze)?ze.map(Ve=>(Ve==null?void 0:Ve.name)==="knowledgeContext"?{...Ve,default:X,value:X}:(Ve==null?void 0:Ve.name)==="workspaceContext"?{...Ve,default:J,value:J,showOnNode:!1}:(Ve==null?void 0:Ve.name)==="cwd"?{...Ve,default:T,value:T,showOnNode:!1}:Ve):[],pe=b.map(ze=>{var Ve,He,Me;return ze.id===w?{...ze,data:{...ze.data,label:((Ve=ze.data)==null?void 0:Ve.label)||"加载知识库",inputs:Y((He=ze.data)==null?void 0:He.inputs),outputs:ae((Me=ze.data)==null?void 0:Me.outputs)}}:ze}),fe=Z.current||{},Ne=fe[w]&&typeof fe[w]=="object"?fe[w]:{},We={...fe,[w]:{...Ne,label:Ne.label||"加载知识库",input:Y(Ne.input),output:ae(Ne.output)}};Z.current=We,g(pe),ne(We),ws(ze=>(ze==null?void 0:ze.id)===w?{...ze,inputs:Y(ze.inputs),outputs:ae(ze.outputs)}:ze),Zt(pe,k).catch(ze=>ge(String(ze.message||ze)))},[k,b,Zt,g,je]),HS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=String(w||"");if(!_)return;const P=VC((S==null?void 0:S.skillKeys)||[]),T=yf((S==null?void 0:S.displayType)||"markdown"),U=String((S==null?void 0:S.model)||"").trim(),X=(S==null?void 0:S.includeWorkspaceContext)===!1?"false":"true",J=S!=null&&S.workspaceContext&&typeof S.workspaceContext=="object"?JSON.stringify(S.workspaceContext):"",Y=S!=null&&S.knowledgeContext&&typeof S.knowledgeContext=="object"?JSON.stringify(S.knowledgeContext):"",ae=He=>Array.isArray(He)?He.map(Me=>(Me==null?void 0:Me.name)==="skillKeys"?{...Me,default:P,value:P}:(Me==null?void 0:Me.name)==="displayType"?{...Me,default:T,value:T}:(Me==null?void 0:Me.name)==="includeWorkspaceContext"?{...Me,default:X,value:X}:(Me==null?void 0:Me.name)==="knowledgeContext"?{...Me,default:Y,value:Y}:(Me==null?void 0:Me.name)==="workspaceContext"?{...Me,default:J,value:J}:Me):[],pe=He=>Array.isArray(He)?He.map(Me=>(Me==null?void 0:Me.name)==="displayType"?{...Me,default:T,value:T}:Me):[],fe=String((S==null?void 0:S.task)??""),Ne=b.map(He=>{var Me,zt;return He.id===_?{...He,data:{...He.data,body:fe,model:U,inputs:ae((Me=He.data)==null?void 0:Me.inputs),outputs:pe((zt=He.data)==null?void 0:zt.outputs)}}:He}),We=Z.current||{},ze=We[_]&&typeof We[_]=="object"?We[_]:{},Ve={...We,[_]:{...ze,body:fe,model:U,input:ae(ze.input),output:pe(ze.output)}};Z.current=Ve,g(Ne),ne(Ve),ws(He=>(He==null?void 0:He.id)===_?{...He,body:fe,model:U,inputs:ae(He.inputs),outputs:pe(He.outputs)}:He),Zt(Ne,k).catch(He=>ge(String(He.message||He)))},[k,b,Zt,g,je]),WS=m.useCallback((w,S)=>{if(!je){ge("Readonly workspace");return}const _=TG(S),P=b.map(J=>J.id===w?{...J,data:{...J.data,body:_}}:J),T=Z.current||{},U=T[w]&&typeof T[w]=="object"?T[w]:{},X={...T,[w]:{...U,body:_}};Z.current=X,xe.current=!0,g(P),ne(X),ws(J=>(J==null?void 0:J.id)===w?{...J,body:_}:J),Zt(P,k).catch(J=>ge(String(J.message||J)))},[k,b,Zt,g,je]),VS=m.useCallback(w=>{const S=String(w||"").trim();S&&(pS(_=>_===S?"":S),wo(_=>({..._,[S]:_[S]||{sessionId:`nodechat_${Date.now()}_${S.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),KS=m.useCallback(()=>pS(""),[]),qS=m.useCallback((w,S)=>{const _=String(w||"").trim();_&&wo(P=>({...P,[_]:{...P[_]||{sessionId:`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(S||""),error:""}}))},[]),zs=m.useCallback((w,S,_="replace",P={})=>{var rt,Ye;if(!je){ge("Readonly workspace");return}const T=String(w||"").trim();if(!T)return;const U=j.current.find(Le=>Le.id===T),X=Rn(U==null?void 0:U.data),J=ti((rt=U==null?void 0:U.data)==null?void 0:rt.definitionId),Y=Ei(S),ae=X==="html"?Wc(Y):X==="react"?lg(Y):String(Y||""),pe=U?no(U.data):"",fe=_==="append"&&String(pe||"").trim()?`${String(pe).replace(/\s+$/g,"")}
262
+
263
+ ${ae.trim()}`:ae,Ne=X==="image"?"src":"content",We=P!=null&&P.reloadDisplay?Date.now():(Ye=U==null?void 0:U.data)==null?void 0:Ye.displayReloadKey,ze=Le=>{let Mt=!1;return(Array.isArray(Le)?Le:[]).map(ut=>{const Et=String((ut==null?void 0:ut.name)||""),El=String((ut==null?void 0:ut.type)||"");return(J?Et===Ne||Et==="result"||Et==="filePath":Et===Ne||Et==="filePath"||El==="text")?Mt?{...ut,default:"",value:""}:(Mt=!0,{...ut,default:fe,value:fe}):ut})},Ve=j.current.map(Le=>{var Mt,Fe;return Le.id!==T?Le:{...Le,data:{...Le.data,body:J?Le.data.body:fe,...We?{displayReloadKey:We}:{},inputs:ze((Mt=Le.data)==null?void 0:Mt.inputs),outputs:ze((Fe=Le.data)==null?void 0:Fe.outputs)}}}),He=Z.current||{},Me=He[T]&&typeof He[T]=="object"?He[T]:{},zt={...He,[T]:{...Me,body:J?Me.body:fe,input:ze(Me.input),output:ze(Me.output)}};Z.current=zt,g(Ve),ne(zt),ws(Le=>(Le==null?void 0:Le.id)===T?{...Le,...J?{}:{body:fe}}:Le),(P==null?void 0:P.logChat)!==!1&&wo(Le=>{var Mt;return{...Le,[T]:{...Le[T]||{},candidateContent:"",messages:[...(Mt=Le[T])!=null&&Mt.messages&&Array.isArray(Le[T].messages)?Le[T].messages:[],{role:"assistant",text:_==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),Zt(Ve,N.current).catch(Le=>ge(String(Le.message||Le))),ge(String((P==null?void 0:P.statusMessage)||"")||(_==="append"?"已追加节点内容":"已替换节点内容"))},[Zt,g,je]),Of=m.useCallback(async(w,S="")=>{if(!je)return ge("Readonly workspace"),"";if(!w)return"";try{const _=new FormData;_.set("file",w),_.set("dir",String(S||"")),a.flowId&&_.set("flowId",a.flowId),a.flowSource&&_.set("flowSource",a.flowSource),a.adminOwnerId&&_.set("adminOwnerId",a.adminOwnerId),a.archived&&_.set("archived","1");const P=await fetch("/api/workspace/upload",{method:"POST",body:_}),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||"上传文件失败");const U=String(T.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await Pn(),fl(X=>{const J=new Set(X);for(const Y of zp(U))J.delete(Y);return J}),ge(`已上传 ${U}`),U}catch(_){return ge(String(_.message||_)),""}},[a,Pn,je]),Df=m.useCallback(async w=>um(w)?Of(w,"img"):(ge("请选择图片文件"),""),[Of]),US=m.useCallback((w="")=>{var S;if(!je){ge("Readonly workspace");return}qv.current=String(w||""),(S=Kv.current)==null||S.click()},[je]),q$=m.useCallback(async w=>{const S=Array.from(w.target.files||[]);if(w.target.value="",!S.length)return;const _=qv.current||"";Vv(!0);try{let P="";for(const T of S){const U=await Of(T,_);U&&(P=U)}S.length>1&&ge(`已上传 ${S.length} 个文件${P?`,最后一个:${P}`:""}`)}catch(P){ge(String(P.message||P))}finally{Vv(!1)}},[Of]),YS=m.useCallback(async(w,S)=>{const _=String(w||"").trim();if(!_)return;const P=await Df(S);P&&zs(_,P,"replace",{logChat:!1,statusMessage:`已上传图片 ${P}`})},[zs,Df]),GS=m.useCallback(async(w,S=void 0)=>{var ze,Ve;if(!je){ge("Readonly workspace");return}const _=String(w||"").trim();if(!_)return;const P=ma[_]||{},T=String(S!==void 0?S:P.draft||"").trim();if(!T||P.running)return;const U=j.current.find(He=>He.id===_);if(!U)return;const X=Rn(U.data)||"markdown",J=no(U.data);let Y=ta(J,X),ae=Ei(J);if(Y)try{ae=await rl(a,Y)}catch(He){ge(String(He.message||He))}else if(X!=="image"&&String(ae||"").trim()){const He=$a(X,ae);if(He){ge(`${He} 未进入微调。`);return}try{const Me=await mb(a,HC(_,U.data),ae);await Pn(),zs(_,Me,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Me}`}),Y=Me,ae=""}catch(Me){ge(String(Me.message||Me));return}}const pe=JG(_,j.current,N.current),fe={role:"user",text:T,at:Date.now()},Ne=Array.isArray(P.messages)?P.messages:[],We=P.sessionId||`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`;wo(He=>({...He,[_]:{...P,sessionId:We,messages:[...Ne,fe],draft:"",running:!0,error:""}}));try{const He=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:We,node:{id:_,label:((ze=U.data)==null?void 0:ze.label)||_,definitionId:((Ve=U.data)==null?void 0:Ve.definitionId)||""},nodeKind:X,currentContent:Y?"":ae,sourceContext:pe,targetFilePath:Y,messages:Ne,message:T,model:Li})}),Me=await He.json().catch(()=>({}));if(!He.ok)throw new Error(Me.error||"节点微调失败");const zt=String(Me.candidateContent||Me.reply||"").trim(),rt=!!Me.directFileEdit,Ye=String(Me.artifactPath||Y||"").trim();if(rt&&Ye){const Le=$a(X,zt);if(Le)throw new Error(`${Le} 文件已由 agent 修改,请检查 ${Ye}。`);await Pn(),zs(_,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(zt){const Le=$a(X,zt);if(Le)throw new Error(`${Le} 已取消写入,避免覆盖当前展示文件。`);if(Y){const Mt=await mb(a,Y,zt);await Pn(),zs(_,Mt,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Mt}`})}else zs(_,zt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}wo(Le=>{var Mt;return{...Le,[_]:{...Le[_]||{},sessionId:String(Me.sessionId||We),running:!1,candidateContent:"",messages:[...(Mt=Le[_])!=null&&Mt.messages&&Array.isArray(Le[_].messages)?Le[_].messages:[...Ne,fe],{role:"assistant",text:zt||rt?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(He){const Me=String(He.message||He);wo(zt=>({...zt,[_]:{...zt[_]||{},running:!1,error:Me}})),ge(Me)}},[Li,a,Pn,ma,zs,je]),JS=m.useCallback(async(w,S)=>{if(!je){ge("Readonly workspace");return}const _=Rn(S)||"markdown",P=no(S),T=ta(P,_);let U=Ei(P);if(T)try{U=await rl(a,T)}catch(ae){ge(String(ae.message||ae));return}if(!String(U||"").trim()){ge("展示节点没有可保存内容");return}const X=$a(_,U);if(X){ge(`${X} 未保存文件。`);return}const J=HC(w,S),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const ae=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:U})}),pe=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(pe.error||"保存文件失败");const fe=pe.path||Y,Ne=$r(a);Ne.set("path",fe);const We=await fetch(`/api/workspace/file?${Ne.toString()}`);if(!We.ok){const ze=await We.json().catch(()=>({}));throw new Error(ze.error||`保存后读取失败:${fe}`)}await Pn(),Mv(ze=>SJ(ze,fe,String(U||"").length)),fl(ze=>{const Ve=new Set(ze);for(const He of zp(fe))Ve.delete(He);return Ve}),zs(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ge(`已保存 ${fe}`)}catch(ae){ge(String(ae.message||ae))}},[a,Pn,zs,je]),XS=m.useCallback(w=>{var T,U;const S=String(w||"").trim();if(!S||ve)return;const _=j.current.find(X=>X.id===S);if(!_||!Rn(_==null?void 0:_.data)){ge("展示节点不可用");return}const P=String(((T=_.data)==null?void 0:T.label)||((U=_.data)==null?void 0:U.displayName)||S).trim()||"AgentFlow Display";le(cw({title:P,layout:"single",nodeIds:[S],mode:"single-node",sourceNodeId:S})),ir(""),Jt(null),Ir(!0)},[ve]),Ff=m.useCallback((w,S)=>{const _=String(w||"");_&&ws(P=>{if(!P||P.id!==_)return P;const T=typeof S=="function"?S(P):S;return!T||typeof T!="object"?P:{...P,...T}})},[]),QS=m.useCallback((w,S)=>{const _=String(w||"");!_||!je||(g(P=>P.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,Y)=>Y===0?{...J,default:S,value:S}:J):[{type:"file",name:"value",default:S,value:S}];return{...T,data:{...T.data,body:"",outputs:U}}})),Ff(_,P=>({body:"",outputs:Array.isArray(P==null?void 0:P.outputs)&&P.outputs.length?P.outputs.map((U,X)=>X===0?{...U,default:S,value:S}:U):[{type:"file",name:"value",default:S,value:S}]})),ge(`已选择文件 ${S}`))},[g,Ff,je]),ZS=m.useCallback(w=>{jg({nodeId:String(w||""),query:""})},[]),Bg=m.useCallback(()=>{jg({nodeId:"",query:""})},[]),U$=m.useCallback(w=>{const S=String((w==null?void 0:w.path)||"").trim();!S||!Qc.nodeId||(QS(Qc.nodeId,S),Bg())},[Bg,Qc.nodeId,QS]),e0=m.useCallback(async(w,S)=>{if(!je)return;const _=fJ(w,S);if(_.length===0)return;const P=[];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||"清理节点输出失败");P.push(X.path||T)}if(P.length===0)return;ge(`已清理 ${P.join(", ")}`),await Pn(),Sg(T=>_.some(U=>T===U||T.startsWith(`${U}/`))?"":T)}catch(T){ge(String(T.message||T))}},[a,Pn,je]),pu=m.useMemo(()=>({modelLists:fa,showBodyPreview:!0,flowParams:a,readOnly:!je,onRunWorkspaceNode:LS,onStopWorkspaceNode:$S,onOpenWorkspaceRunLogs:MS,onOptimizeWorkspaceRun:zg,onOptimizeWorkspaceSchedule:zg,runningRunNodeIds:ES,onChangeScheduledRunConfig:WS,onChangeContextRunConfig:HS,skills:$s,skillCollections:pl,onChangeLoadSkillKeys:FS,onRefreshSkills:Mf,mcpServers:Qv,onChangeLoadMcpNames:zS,onRefreshMcps:$f,workspaceTargets:eS,onChangeLoadWorkspace:BS,onRefreshWorkspaces:Lf,onSaveDisplayNodeToFile:JS,onShareDisplayNode:XS,onOpenDisplayPreview:Bn,onRefreshNodeInternals:Hr,onEnsureWorkspaceNodeDisplaySize:oS,sharingDisplayNodeId:ve,onUploadWorkspaceImage:Df,onUploadImageToDisplayNode:YS,onOpenProvideFilePicker:ZS,onStatus:ge,onSetDisplayNodeContent:zs,onToggleNodeChat:VS,onCloseNodeChat:KS,onUpdateNodeChatDraft:qS,onSendNodeChat:GS,onSyncNodePropDraft:Ff,onCleanupWorkspaceNodeOutputs:e0}),[HS,zS,FS,BS,WS,e0,KS,oS,a,Qv,fa,ZS,MS,zg,$f,Hr,Mf,Lf,LS,ES,JS,GS,zs,XS,ve,pl,$s,$S,Ff,VS,qS,YS,Df,eS,je]),Y$=m.useRef(new Map),rs=m.useMemo(()=>{const w=Y$.current,S=new Set,_=b.map(P=>{var Y,ae,pe;const T={selected:P.selected===!0,isExecuting:kS.has(P.id),nodeStatus:((Y=Fg[P.id])==null?void 0:Y.status)??null,nodeElapsed:((ae=Fg[P.id])==null?void 0:ae.elapsed)??null,optimizingRun:vS===P.id,scheduledRunState:bS[P.id]||null,nodeChatActive:fS===P.id,nodeChat:ma[P.id]||null},U=w.get(P.id);if(U&&U.source===P&&U.commonData===pu&&MC(U.runtime,T))return S.add(P.id),U.node;const X=!!(U&&((pe=U.source)==null?void 0:pe.data)===P.data&&U.commonData===pu&&MC(U.runtime,T)),J={...P,data:X?U.node.data:{...P.data,...pu,...T}};return w.set(P.id,{source:P,commonData:pu,runtime:T,node:J}),S.add(P.id),J});for(const P of w.keys())S.has(P)||w.delete(P);return _},[fS,pu,ma,b,vS,bS,kS,Fg]),ct=d==="display",In=d==="workflow",t0=m.useMemo(()=>ct?new Map(rs.map(w=>[w.id,w])):FG,[rs,ct]),n0=m.useMemo(()=>Ut&&rs.find(w=>w.id===Ut)||null,[Ut,rs]),r0=m.useRef(new Map),hu=m.useMemo(()=>{if(!ct)return r0.current.clear(),zG;const w=new Set(M),S=r0.current,_=new Set,P=I.nodeIds.map((T,U)=>{var We,ze,Ve,He;const X=t0.get(T);if(!X||!Rn(X.data))return null;const J=zl(X)||{width:520,height:320},Y=Ba(I.nodeSizes[T]||J,{display:!0})||J,ae=I.nodePositions[T]||{x:180+U*36,y:120+U*28},pe=w.has(T),fe=S.get(T);if(fe&&fe.source===X&&((We=fe.position)==null?void 0:We.x)===ae.x&&((ze=fe.position)==null?void 0:ze.y)===ae.y&&((Ve=fe.size)==null?void 0:Ve.width)===Y.width&&((He=fe.size)==null?void 0:He.height)===Y.height&&fe.selected===pe)return _.add(T),fe.node;const Ne={...X,id:$C(T),position:ae,selected:pe,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:T,displayPageMode:!0,readOnly:!0,selected:pe,displaySize:Y,nodeSize:Y}};return S.set(T,{source:X,position:ae,size:Y,selected:pe,node:Ne}),_.add(T),Ne}).filter(Boolean);for(const T of S.keys())_.has(T)||S.delete(T);return P},[I,t0,ct,M]),vl=m.useMemo(()=>rs.filter(w=>Rn(w==null?void 0:w.data)),[rs]);m.useEffect(()=>{if(!ct||!I.viewport)return;const w=I.viewport,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[I.viewport,ct,r]),m.useEffect(()=>{if(ct||In||!A)return;const w=A,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[ct,In,r,A]),m.useEffect(()=>{In&&du(or)},[In]),m.useEffect(()=>{if(!In||!or)return;const w=$r(a);w.set("tapdId",or);let S=null,_=null,P=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{P||document.hidden||S||(S=new EventSource(`/api/prd-workflow/events?${w.toString()}`),S.onmessage=()=>{du(or)},S.onerror=()=>{T(),!P&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}du(or),U()};return U(),document.addEventListener("visibilitychange",X),()=>{P=!0,document.removeEventListener("visibilitychange",X),T()}},[a,In,du,or]),m.useEffect(()=>{if(!a.flowId||In)return;const w=$r(a);w.set("clientId",ke.current);let S=null,_=null,P=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{P||document.hidden||S||(S=new EventSource(`/api/workspace/events?${w.toString()}`),S.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===ke.current)){if(Y.type==="graph.committed"){Rf(Y);return}if(Y.type==="runtime.committed"){Rf(Y);return}if(String(Y.type||"").startsWith("file.")){Pn();return}String(Y.type||"").startsWith("run.")&&Tf()}},S.onerror=()=>{T(),!P&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}Rf({type:"visibility.resume"}),U()};return U(),document.addEventListener("visibilitychange",X),()=>{P=!0,document.removeEventListener("visibilitychange",X),T(),Te.current&&(window.clearTimeout(Te.current),Te.current=null),mt.current=!1}},[a,In,Pn,Tf,Rf]),m.useEffect(()=>{if(Oe.current)return;const w=F.current,S=new Map,_=[];for(const P of[...rs,...hu]){const T=DG(P);S.set(P.id,T),w.get(P.id)!==T&&_.push(P.id)}F.current=S,_.length!==0&&Hr(_)},[hu,rs,Hr]);const Kt=m.useMemo(()=>b.find(w=>w.id===Yt)||null,[b,Yt]),Hg=m.useRef({id:"",draft:null}),G$=m.useMemo(()=>{const w=YC(Kt);return w?JSON.stringify(w):""},[Kt==null?void 0:Kt.data,Kt==null?void 0:Kt.id]);m.useEffect(()=>{if(!Kt){Hg.current={id:"",draft:null},ws(null),ll("");return}const w=YC(Kt),S=Hg.current;Hg.current={id:Kt.id,draft:w},ws(_=>!_||_.id!==Kt.id||S.id!==Kt.id||!S.draft?w:LJ(_,S.draft,w)),ll("")},[Kt==null?void 0:Kt.id,G$]);const Wg=m.useCallback((w=!1)=>{if(!at||!Kt)return!1;if(!je)return ll("Readonly workspace"),ge("Readonly workspace"),!1;ll("");const S=XC({nodes:b,edges:k,instances:Z.current,selectedNode:Kt,draft:at,allowRename:w});return S!=null&&S.error?(ll(S.error),!1):(!(S!=null&&S.ok)||!S.changed||(Z.current=S.instances,ne(S.instances),g(S.nodes),x(S.edges),S.nextId!==Kt.id&&Cn(S.nextId),Hr(S.nextId)),!0)},[k,at,b,Kt,x,g,Hr,je]);m.useEffect(()=>{if(!je||!at||!Kt)return;const w=window.setTimeout(()=>{Wg(!1)},350);return()=>window.clearTimeout(w)},[at==null?void 0:at.label,at==null?void 0:at.role,at==null?void 0:at.model,at==null?void 0:at.body,JSON.stringify((at==null?void 0:at.images)||[]),at==null?void 0:at.script,at==null?void 0:at.scriptRef,at==null?void 0:at.implementationRef,at==null?void 0:at.implementationMode,JSON.stringify((at==null?void 0:at.inputs)||[]),JSON.stringify((at==null?void 0:at.outputs)||[]),Wg,Kt==null?void 0:Kt.id,je]);const s0=m.useRef({refs:new Map,nodeDataById:new Map}),Vg=m.useMemo(()=>{const w=s0.current;let S=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)&&(S=!0);if(!S)return w.nodeDataById;const P=new Map(b.map(T=>[T.id,T.data]));return s0.current={refs:_,nodeDataById:P},P},[b]),J$=m.useMemo(()=>k.map(w=>{var Y,ae;const S=Vg.get(w.source),_=Vg.get(w.target),P=/^output-(\d+)$/.exec(w.sourceHandle||""),T=/^input-(\d+)$/.exec(w.targetHandle||""),U=S&&P?(Y=S.outputs)==null?void 0:Y[parseInt(P[1],10)]:null,X=_&&T?(ae=_.inputs)==null?void 0:ae[parseInt(T[1],10)]:null,J=U!=null&&U.type?Mn(U.type):X!=null&&X.type?Mn(X.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:bi.ArrowClosed,color:J}}:w}),[Vg,k]),zf=ct?hu:rs,X$=ct?[]:J$,i0=m.useRef(zf),Sl=m.useRef([]);Oe.current||(i0.current=zf);const Q$=m.useMemo(()=>ct?hu.map(w=>({...w,id:Fp(w.id)})):rs,[hu,rs,ct]),Kg=m.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const _=ct?$C(S):S;ct?K([S]):(g(T=>T.map(U=>({...U,selected:U.id===_}))),x(T=>T.map(U=>({...U,selected:!1}))),Cn(_));const P=()=>{var ae,pe,fe;const T=r.getNode(_);if(!T)return;const U=(ae=r.getInternalNode)==null?void 0:ae.call(r,_),X=((pe=U==null?void 0:U.measured)==null?void 0:pe.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:Y}=r.getViewport();r.setCenter(T.position.x+X/2,T.position.y+J/2,{zoom:qG(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(P))},[ct,r,x,g]);m.useEffect(()=>{const w=String(c.current||"").trim();!w||!ce.current||d!=="workspace"||rs.some(S=>S.id===w)&&(c.current="",xe.current=!0,Kg(w))},[rs,Kg,d]);const o0=m.useCallback(()=>{const w=r.getViewport(),S={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(ct){const _={...H.current,viewport:S};H.current=_,R(_),ge("已固定 Display 进入视角")}else{D.current=S,L(S);try{window.localStorage.setItem(u,JSON.stringify(S))}catch{}ge("已固定 Workspace 进入视角");return}Zt(j.current,N.current).catch(_=>ge(String(_.message||_)))},[ct,r,Zt,u]),qg=m.useMemo(()=>{const w=Wt.trim().toLowerCase(),S={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const _ of be)w&&![_.id,_.label,_.displayName,_.description].some(P=>String(P||"").toLowerCase().includes(w))||S[Vu(_)].push(_);for(const _ of Dl)S[_].sort((P,T)=>P.id.localeCompare(T.id));return S},[be,Wt]),mu=m.useMemo(()=>{const w=Ee.trim().toLowerCase();return be.filter(S=>!w||[S.id,S.label,S.displayName,S.description].some(_=>String(_||"").toLowerCase().includes(w))).sort((S,_)=>{const P=Dl.indexOf(Vu(S)),T=Dl.indexOf(Vu(_));return P!==T?P-T:Ku(S).localeCompare(Ku(_))}).slice(0,30)},[be,Ee]),gu=m.useMemo(()=>{const w=Ee.trim().toLowerCase();return Re.filter(S=>!w||[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].some(_=>String(_||"").toLowerCase().includes(w))).sort((S,_)=>String(S.displayName||S.name||S.id).localeCompare(String(_.displayName||_.name||_.id))).slice(0,30)},[Re,Ee]);m.useEffect(()=>{bt(0)},[Ee,Dn,he]),m.useEffect(()=>{if(!Dn)return;const w=window.setTimeout(()=>{var S;return(S=cS.current)==null?void 0:S.focus()},0);return()=>window.clearTimeout(w)},[Dn]);const Z$=m.useMemo(()=>{const w=kg.trim().toLowerCase();return w?wv(cl).filter(S=>S.path.toLowerCase().includes(w)):cl},[kg,cl]),wa=m.useMemo(()=>aM(cl,vg),[cl,vg]),Fi=(wa==null?void 0:wa.type)==="directory"?wa.path:xJ((wa==null?void 0:wa.path)||""),eL=m.useCallback(w=>{var S,_;(_=(S=w.target)==null?void 0:S.closest)!=null&&_.call(S,".af-work-file")||Sg("")},[]),tL=[...(fa.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(fa.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(fa.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(fa.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],Ug=m.useMemo(()=>new Set(Ls),[Ls]),jl=m.useMemo(()=>{const w=new Map($s.map(U=>[U.key,U])),S=new Set,_=new Set,P=pl.map(U=>{const X=Zo(U,$s).map(J=>w.get(J)).filter(Boolean);for(const J of X)S.add(J.key),_.add(String(J.name||J.id||J.key||"").trim());return{...U,skills:X}}).filter(U=>U.skills.length>0),T=$s.filter(U=>{const X=String(U.name||U.id||U.key||"").trim();return!S.has(U.key)&&!_.has(X)});return{groups:P,ungrouped:T}},[pl,$s]);m.useEffect(()=>{aS(w=>{let S=!1;const _=new Set(w);for(const P of jl.groups)_.has(P.id)||(_.add(P.id),S=!0);return S?_:w})},[jl.groups]);const tr=m.useMemo(()=>{const w=b.filter(S=>S.selected);return w.length>0?w:Yt?b.filter(S=>S.id===Yt):[]},[b,Yt]),Bf=m.useMemo(()=>tr.map(w=>w.id),[tr]),a0=m.useCallback(()=>{if(ct)return;if(!je){ge("Readonly workspace");return}const w=(j.current||[]).filter(J=>(J==null?void 0:J.selected)&&!hm(J));if(w.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const S=w.reduce((J,Y)=>{var We,ze,Ve,He,Me,zt,rt,Ye,Le,Mt,Fe,ut;const ae=Number(((We=Y.position)==null?void 0:We.x)||0),pe=Number(((ze=Y.position)==null?void 0:ze.y)||0),fe=Number(((Ve=Y.measured)==null?void 0:Ve.width)||Y.width||((Me=(He=Y.data)==null?void 0:He.nodeSize)==null?void 0:Me.width)||((rt=(zt=Y.data)==null?void 0:zt.displaySize)==null?void 0:rt.width)||$T),Ne=Number(((Ye=Y.measured)==null?void 0:Ye.height)||Y.height||((Mt=(Le=Y.data)==null?void 0:Le.nodeSize)==null?void 0:Mt.height)||((ut=(Fe=Y.data)==null?void 0:Fe.displaySize)==null?void 0:ut.height)||cm);return{minX:Math.min(J.minX,ae),minY:Math.min(J.minY,pe),maxX:Math.max(J.maxX,ae+fe),maxY:Math.max(J.maxY,pe+Ne)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(S.minX)||!Number.isFinite(S.minY))return;const _=new Set((j.current||[]).map(J=>J.id));let P=1,T=`group_${P}`;for(;_.has(T);)P+=1,T=`group_${P}`;const U=fb({width:S.maxX-S.minX+Lp*2,height:S.maxY-S.minY+Lp*2})||{width:Za,height:el},X={id:T,type:hc,position:{x:S.minX-Lp,y:S.minY-Lp},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:mm(P-1),title:mm(P-1),color:"purple",nodeSize:U}};g(J=>[X,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),Cn(""),ge(`Created group for ${w.length} nodes`)},[ct,x,g,je]),yu=m.useMemo(()=>b.filter(w=>Rn(w==null?void 0:w.data)),[b]),Yg=m.useMemo(()=>tr.filter(w=>Rn(w==null?void 0:w.data)).map(w=>w.id),[tr]),nL=m.useMemo(()=>{const w=String((Rr==null?void 0:Rr.username)||(Rr==null?void 0:Rr.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Rr]),Gg=m.useMemo(()=>new Set(Bf),[Bf]),Hf=m.useMemo(()=>k.filter(w=>Gg.has(w.source)&&Gg.has(w.target)),[k,Gg]),Jg=m.useCallback(w=>{const S=w==="display"?"display":w==="workflow"?"workflow":"workspace";f(S),Cn(""),K([]),ee(null),q(!1),Pe(!1);const _=$r(a);S==="display"&&_.set("view","display"),S==="workflow"&&(_.set("view","workflow"),or.trim()&&_.set("tapdId",or.trim()));const P=`/workspace${_.toString()?`?${_.toString()}`:""}`;window.history.pushState({},"",P)},[a,or]),l0=m.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const _=j.current.find(P=>P.id===S);if(!_||!Rn(_.data)){ge("展示节点不可用");return}R(P=>{if(P.nodeIds.includes(S))return P;const T=P.nodeIds.length,U=zl(_);return{nodeIds:[...P.nodeIds,S],nodePositions:{...P.nodePositions,[S]:{x:180+T*36,y:120+T*28}},nodeSizes:{...P.nodeSizes,...U?{[S]:U}:{}}}}),K([S])},[]),c0=m.useCallback(w=>{const S=String(w||"").trim();S&&(R(_=>{const P=_.nodeIds.filter(X=>X!==S),T={..._.nodePositions},U={..._.nodeSizes};return delete T[S],delete U[S],{nodeIds:P,nodePositions:T,nodeSizes:U}}),K(_=>_.filter(P=>P!==S)))},[]),u0=m.useCallback(w=>{const S=String(w||"").trim();S&&(H.current.nodeIds.includes(S)?c0(S):l0(S))},[l0,c0]),Wf=m.useMemo(()=>{const w=wt.trim().toLowerCase();return w?vl.filter(S=>{var _,P;return[S.id,(_=S.data)==null?void 0:_.label,(P=S.data)==null?void 0:P.definitionId].filter(Boolean).some(T=>String(T).toLowerCase().includes(w))}):vl},[vl,wt]),d0=m.useMemo(()=>{const w=Wf.length,S=w<=1?1:w<=4?2:3,_=Array.from({length:S},()=>({height:0,nodes:[]}));for(const P of Wf){const T=zl(P)||{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 Y=_[0];for(const ae of _)ae.height<Y.height&&(Y=ae);Y.nodes.push(P),Y.height+=J}return _.map(P=>P.nodes)},[Wf]),rL=m.useCallback(w=>{var U;const S=I.nodeIds.includes(w.id),_=zl(w)||{width:420,height:260},P=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"+(S?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${P} / ${T}`},onClick:()=>u0(w.id),children:[i.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:i.jsx("input",{type:"checkbox",checked:S,readOnly:!0,tabIndex:-1})}),i.jsx("span",{className:"af-display-picker-card__preview",children:i.jsx(aJ,{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:[Rn(w.data)," · ",w.id]})]})]},w.id)},[I.nodeIds,u0]),f0=m.useMemo(()=>{const w=Wt.trim().toLowerCase();return w?Re.filter(S=>[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].filter(Boolean).some(_=>String(_).toLowerCase().includes(w))):Re},[Re,Wt]),p0=m.useCallback((w,S)=>{const _=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let P=`${_}_${Date.now().toString(36)}`,T=2;for(;S.has(P);)P=`${_}_${Date.now().toString(36)}_${T}`,T+=1;return S.add(P),P},[]),wu=m.useCallback((w,S)=>{var Le,Mt;if(!je){ge("Readonly workspace");return}const _=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},P=_.instances&&typeof _.instances=="object"?_.instances:{},T=Object.keys(P);if(T.length===0)return;const U=new Set(j.current.map(Fe=>Fe.id)),X={};for(const Fe of T)X[Fe]=p0(Fe,U);const J=(Le=_.ui)!=null&&Le.nodePositions&&typeof _.ui.nodePositions=="object"?_.ui.nodePositions:{},Y=(Mt=_.ui)!=null&&Mt.nodeSizes&&typeof _.ui.nodeSizes=="object"?_.ui.nodeSizes:{},ae=T.map(Fe=>{const ut=J[Fe];return{id:Fe,x:typeof(ut==null?void 0:ut.x)=="number"?ut.x:0,y:typeof(ut==null?void 0:ut.y)=="number"?ut.y:0}}),pe=Math.min(...ae.map(Fe=>Fe.x)),fe=Math.min(...ae.map(Fe=>Fe.y));let Ne=S||{x:360+j.current.length*24,y:180+j.current.length*18};if(!S){const Fe=document.querySelector(".af-workspace-canvas .react-flow");if(Fe){const ut=Fe.getBoundingClientRect();Ne=r.screenToFlowPosition({x:ut.left+ut.width*.48,y:ut.top+ut.height*.32})}}const We={},ze={},Ve={};for(const Fe of ae){const ut=X[Fe.id];We[ut]={...P[Fe.id]||{}},ze[ut]={x:Ne.x+(Fe.x-pe),y:Ne.y+(Fe.y-fe)};const Et=Y[Fe.id];typeof(Et==null?void 0:Et.width)=="number"&&typeof(Et==null?void 0:Et.height)=="number"&&(Ve[ut]={width:Et.width,height:Et.height})}const He=new Set(T),Me=(Array.isArray(_.edges)?_.edges:[]).filter(Fe=>He.has(Fe==null?void 0:Fe.source)&&He.has(Fe==null?void 0:Fe.target)).map(Fe=>({source:X[Fe.source],target:X[Fe.target],sourceHandle:Fe.sourceHandle??null,targetHandle:Fe.targetHandle??null})),zt=Ru({instances:We,edges:Me,ui:{nodePositions:ze,nodeSizes:Ve}},be),rt=zt.nodes.map(Fe=>Fe.id),Ye=zt.nodes.map(Fe=>({...Fe,selected:!0}));Z.current={...Z.current,...zt.instances},ne(Z.current),g(Fe=>[...Fe.map(ut=>({...ut,selected:!1})),...Ye]),x(Fe=>[...Fe.map(ut=>({...ut,selected:!1})),...zt.edges.map(ut=>({...ut,selected:!1}))]),Cn(""),K([]),ge(`已添加流程片段:${w.displayName||w.id}(已选中 ${rt.length} 个节点)`)},[p0,be,r,x,g,je]),sL=m.useCallback(()=>{var _,P;if(tr.length<2){Kn("请先在 workspace 画布上选择至少两个节点。"),re("flows");return}const w=tr[0],S=tr.length===2?`${((_=w.data)==null?void 0:_.label)||w.id} 片段`:`${((P=w.data)==null?void 0:P.label)||w.id} 等 ${tr.length} 个节点`;Qn({name:S,id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Pr(""),br(!0),re("flows")},[tr]),iL=m.useCallback(async()=>{var T,U;if(tr.length<2)return;const w=xn.name.trim();if(!w){Pr("请填写片段名称。");return}const S={},_={};for(const X of tr){S[X.id]={x:((T=X.position)==null?void 0:T.x)||0,y:((U=X.position)==null?void 0:U.y)||0};const J=zl(X);J&&(_[X.id]=J)}const P=Hf.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));mr(!0),Pr("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:xn.id,name:w,displayName:w,version:"1.0.0",description:xn.description,snippet:{instances:lv(tr,Z.current),edges:P,ui:{nodePositions:S,nodeSizes:_}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");br(!1),ge(`流程片段已发布:${J.id||w}`),iS(`流程片段已发布:${J.id||w}`),await If(),re("flows")}catch(X){Pr(String(X.message||X))}finally{mr(!1)}},[If,xn,Hf,tr,iS]),h0=m.useCallback(async()=>{var S;const w=Jc.trim();if(w){Lv(!0),Gc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),P=await _.json().catch(()=>({}));if(!_.ok)throw new Error(P.error||"添加协作成员失败");yg(P.workspace||null),Dv(""),ge(`已将 Workspace 分享给 ${((S=P.member)==null?void 0:S.username)||w}`)}catch(_){Gc(String(_.message||_))}finally{Lv(!1)}}},[a,Jc]),oL=m.useCallback(()=>{Gc(""),wg(!0)},[]),aL=m.useCallback(async w=>{const S=String((w==null?void 0:w.userId)||"").trim();if(!(!S||S===(ln==null?void 0:ln.ownerId))){zv(S),Gc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:S})}),P=await _.json().catch(()=>({}));if(!_.ok)throw new Error(P.error||"取消成员分享失败");yg(P.workspace||null),ge(`已取消对 ${(w==null?void 0:w.username)||S} 的分享`)}catch(_){Gc(String(_.message||_))}finally{zv("")}}},[a,ln==null?void 0:ln.ownerId]),m0=m.useCallback(async()=>{const w=$l(j.current,N.current,Z.current);w.ui={...w.ui||{},...D.current?{viewport:D.current}:{},displayPage:LC(H.current,j.current)};const S=new Blob([`${JSON.stringify(w,null,2)}
264
+ `],{type:"application/json"}),_=URL.createObjectURL(S),P=document.createElement("a");P.href=_,P.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(_),await ks(),ul(null),da(!1),ge("已备份本地草稿并载入远端最新版本")},[N,a.flowId,ks,j]),lL=m.useCallback(async()=>{const w=Array.isArray(An==null?void 0:An.conflictItems)?An.conflictItems:[];if(!w.length||!(An!=null&&An.mergeGraph)||!(An!=null&&An.currentGraph)){Xc("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let S=An.mergeGraph;try{w.forEach((P,T)=>{const U=bg[String(T)]||{mode:"local"};let X,J=!0;U.mode==="remote"?(X=P.current,J=P.hasCurrent!==!1):U.mode==="manual"?X=JSON.parse(String(U.manual||"")):(X=P.incoming,J=P.hasIncoming!==!1),S=VJ(S,P.pathParts,X,J)})}catch(P){Xc(`手动值不是有效 JSON:${String(P.message||P)}`);return}Bv(!0),Xc(""),Ds("saving"),Fs("正在提交冲突解决结果");const _=Ce.current.catch(()=>{}).then(async()=>{const P=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:S,baseRevision:An.currentRevision,baseGraph:An.currentGraph,clientId:ke.current})}),T=await P.json().catch(()=>({}));if(!P.ok){if(P.status===409&&Array.isArray(T.conflictItems)){const U=T.conflictItems;ul({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}),dl(Object.fromEntries(U.map((X,J)=>[String(J),{mode:"local",manual:Tu(X)}])))}throw new Error(T.error||"提交冲突解决结果失败")}await ks(),ul(null),da(!1),ge("冲突已解决并保存")});Ce.current=_;try{await _}catch(P){Xc(String(P.message||P)),Ds("error"),Fs(String(P.message||P))}finally{Bv(!1)}},[a,ks,An,bg]);m.useCallback(()=>{if(yu.length===0){ge("当前 workspace 没有 display 节点");return}const w=Yg.length>0?Yg:yu.map(_=>_.id),S=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";le(cw({title:S,layout:"gallery",nodeIds:w,mode:"multi-node"})),ir(""),Jt(null),Ir(!0)},[a.flowId,Yg,yu]);const cL=m.useCallback(w=>{le(S=>{const _=Array.isArray(S.nodeIds)?S.nodeIds:[];return _.includes(w)?{...S,nodeIds:_.filter(P=>P!==w)}:{...S,nodeIds:[..._,w]}})},[]),Bs=m.useCallback(async()=>{On(!0),Br("");try{const w=await fetch("/api/display/shares"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取分享列表失败");vr(Array.isArray(S.shares)?S.shares:[])}catch(w){Br(String(w.message||w)),vr([])}finally{On(!1)}},[]),uL=m.useCallback(()=>{rn(!0),oe(""),Bs()},[Bs]),dL=m.useCallback(async()=>{var _,P;const w=Nt.title.trim(),S=Array.isArray(Nt.nodeIds)?Nt.nodeIds:[];if(S.length===0){ir("请选择至少一个 display 节点。");return}Zn(!0),ir(""),Jt(null);try{await Zt(b,k);const T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:Nt.layout,nodeIds:S,...DC(Nt)})}),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;Jt({...U,absoluteUrl:X}),ge((P=U.share)!=null&&P.expiresAt?"展示页已生成":"展示页已生成:永久有效"),ht&&Bs()}catch(T){ir(String(T.message||T))}finally{Zn(!1)}},[Nt,ht,k,a,Bs,b,Zt]),fL=m.useCallback(async()=>{var S,_;const w=Array.isArray(I.nodeIds)?I.nodeIds:[];if(w.length===0){ir("请先添加至少一个展示节点。"),ge("请先添加至少一个展示节点"),Pe(!0);return}Zn(!0),ir("");try{await Zt(b,k);const P=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:P,layout:"canvas",nodeIds:w,...DC(Nt)})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"生成展示链接失败");const X=new URL(U.url||`/display/${((S=U.share)==null?void 0:S.id)||""}`,window.location.origin).href;Jt({...U,absoluteUrl:X}),Xt(!0),ge((_=U.share)!=null&&_.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),ht&&Bs()}catch(P){const T=String(P.message||P);ir(T),ge(T)}finally{Zn(!1)}},[I.nodeIds,Nt,ht,k,a,Bs,b,Zt]),g0=m.useCallback(async()=>{const w=jt==null?void 0:jt.absoluteUrl;if(!w)return;const S=await hb(w);er(S?"copied":"failed"),window.setTimeout(()=>er(""),1600)},[jt==null?void 0:jt.absoluteUrl]),pL=m.useCallback(async w=>{const S=FC(w),_=await hb(S);oe(_?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>oe(""),1600)},[]),hL=m.useCallback(async(w,S)=>{const _=String((w==null?void 0:w.id)||"");if(_){ai(_),Br("");try{const P=S==="permanent"?{id:_,expiresMode:"permanent",permanent:!0}:{id:_,expiresMode:"days",expiresInDays:Number(S||30)},T=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await Bs(),ge("分享有效期已更新")}catch(P){Br(String(P.message||P))}finally{ai("")}}},[Bs]),mL=m.useCallback(async w=>{const S=String((w==null?void 0:w.id)||"");if(S){ai(S),Br("");try{const _=await fetch(`/api/display/share?id=${encodeURIComponent(S)}`,{method:"DELETE"}),P=await _.json().catch(()=>({}));if(!_.ok||P.ok===!1)throw new Error(P.error||"撤销分享失败");await Bs(),ge("分享已撤销")}catch(_){Br(String(_.message||_))}finally{ai("")}}},[Bs]),gL=m.useCallback(w=>{g(S=>S.map(_=>_.id===w?{..._,selected:!1}:_)),Cn(S=>S===w?"":S)},[g]),Nl=m.useCallback(()=>{const w=Rg.current;if(!w)return;const S=w.getBoundingClientRect(),_=Math.min(420,Math.max(320,S.width+160)),P=12,T=Math.max(180,S.top-P*2),U=Math.min(560,T);T$({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-_-12,S.left)),top:Math.max(P,S.top-U-P),width:_,maxHeight:U,zIndex:1e4})},[]);m.useEffect(()=>{if(!Ef)return;Nl();const w=_=>{var T,U;const P=_.target;(T=Rg.current)!=null&&T.contains(P)||(U=lS.current)!=null&&U.contains(P)||Ig(!1)},S=_=>{_.key==="Escape"&&Ig(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",S),window.addEventListener("resize",Nl),window.addEventListener("scroll",Nl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",S),window.removeEventListener("resize",Nl),window.removeEventListener("scroll",Nl,!0)}},[Ef,Nl]);const Vf=m.useCallback(w=>{const S=MT(w);if(S.active&&(Oe.current=!0),S.finished&&(Oe.current=!1,ie.current=!0),gY(w)&&li(),d==="display"){R(T=>{var Y,ae;let U=T.nodePositions,X=T.nodeSizes;for(const pe of w||[]){const fe=Fp(pe==null?void 0:pe.id);if(!(!fe||!T.nodeIds.includes(fe))&&pe.type!=="select"){if(pe.type==="position"&&pe.position){const Ne=U[fe];if((Ne==null?void 0:Ne.x)===pe.position.x&&(Ne==null?void 0:Ne.y)===pe.position.y)continue;U===T.nodePositions&&(U={...T.nodePositions}),U[fe]={x:pe.position.x,y:pe.position.y};continue}if(pe.type==="dimensions"&&((Y=pe.dimensions)!=null&&Y.width)&&((ae=pe.dimensions)!=null&&ae.height)){const Ne=Ba({width:Math.round(Number(pe.dimensions.width)),height:Math.round(Number(pe.dimensions.height))},{display:!0});if(Ne){const We=X[fe];if((We==null?void 0:We.width)===Ne.width&&(We==null?void 0:We.height)===Ne.height)continue;X===T.nodeSizes&&(X={...T.nodeSizes}),X[fe]=Ne}}}}if(U===T.nodePositions&&X===T.nodeSizes)return T;const J={...T,nodePositions:U,nodeSizes:X};return H.current=J,J});const P=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");P.length>0&&K(T=>{const U=new Set(T);for(const J of P){const Y=Fp(J==null?void 0:J.id);Y&&(J.selected?U.add(Y):U.delete(Y))}const X=Array.from(U);return X.length===T.length&&X.every((J,Y)=>J===T[Y])?T:X});return}if(!je){const P=(w||[]).filter(T=>(T==null?void 0:T.type)==="select");P.length>0&&g(T=>ld(P,T));return}const _=(w||[]).filter(P=>{var T,U;return(P==null?void 0:P.type)==="dimensions"&&((T=P.dimensions)==null?void 0:T.width)&&((U=P.dimensions)==null?void 0:U.height)});g(P=>{const T=new Map;if(_.length>0){const J=new Map(P.map(Y=>[Y.id,Y]));for(const Y of _){const ae=J.get(Y.id),pe={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=hm(ae)?fb(pe):Ba(pe,{display:!!Rn(ae==null?void 0:ae.data)});fe&&T.set(Y.id,fe)}}const U=ld(w,P),X=T.size===0?U:U.map(J=>{const Y=T.get(J.id);if(!Y)return J;const ae={...J.data,nodeSize:Y};return Rn(J.data)&&(ae.displaySize=Y),{...J,width:Y.width,height:Y.height,data:ae}});return j.current=X,X}),_.length>0&&Hr(_.map(P=>P.id))},[li,Hr,g,d,je]),Kf=m.useCallback((w=[],{finish:S=!1}={})=>{const _=S?bY([...V.current,...w]):ob(w);S&&(V.current=[]),_.length>0&&Vf(_)},[Vf]),yL=m.useCallback(w=>{const{transient:S,committed:_,finishesInteraction:P}=xY(w);if(S.length>0){Oe.current||(Oe.current=!0,Sl.current=i0.current),V.current=ob([...V.current,...S]);const T=ld(S,Sl.current);Sl.current=T,s.getState().setNodes(T)}if(P){Sl.current=[],Kf(_,{finish:!0});return}_.length>0&&Vf(_)},[Vf,Kf,s]);m.useEffect(()=>{const w=()=>{!Oe.current&&V.current.length===0||(Kf([],{finish:!0}),Sl.current=[])},S=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w),window.addEventListener("blur",w),document.addEventListener("visibilitychange",S),()=>{window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",S),V.current=[],Sl.current=[]}},[Kf]);const wL=m.useCallback(w=>{if(d!=="display"){if(!je){const S=(w||[]).filter(_=>(_==null?void 0:_.type)==="select");S.length>0&&x(_=>{const P=em(S,_);return N.current=P,P});return}(w||[]).some(S=>(S==null?void 0:S.type)!=="select")&&li(),x(S=>{const _=em(w,S);return N.current=_,_})}},[li,x,d,je]),Cl=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const S=w.getBoundingClientRect();return r.screenToFlowPosition({x:S.left+S.width*.48,y:S.top+S.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),qf=m.useCallback(()=>{var w,S,_;if(Kt){const P=Number(((w=Kt.measured)==null?void 0:w.width)||Kt.width||260);return{x:Number(((S=Kt.position)==null?void 0:S.x)||0)+P+140,y:Number(((_=Kt.position)==null?void 0:_.y)||0)}}return Cl()},[Cl,Kt]),zi=m.useCallback((w,S={})=>{if(!je)return ge("Readonly workspace"),null;if(!w)return null;const _=mv(w)||w.id,P=qT(w),T=YT(w),U=S.id||AG(_,b),X=Uu(w.inputs),J=Uu(w.outputs),Y={definitionId:_,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:S.label||pm(w),role:"normal",body:S.body||"",...S.script||T?{script:S.script||T}:{},...S.scriptRef?{scriptRef:S.scriptRef}:{},...S.implementationRef?{implementationRef:S.implementationRef}:{},...S.implementationMode?{implementationMode:S.implementationMode}:{},input:S.inputs||X,output:S.outputs||J},ae={id:U,type:hc,position:S.position||Cl(),data:{label:Y.label,definitionId:_,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:KT(_,w),role:"normal",body:Y.body,...Y.script?{script:Y.script}:{},...Y.scriptRef?{scriptRef:Y.scriptRef}:{},...Y.implementationRef?{implementationRef:Y.implementationRef}:{},...Y.implementationMode?{implementationMode:Y.implementationMode}:{},inputs:Y.input,outputs:Y.output}},pe={...sb(ae,{...Z.current,[U]:Y},be),selected:!0};return li(),g(fe=>[...fe.map(Ne=>({...Ne,selected:!1})),pe]),S.openProperties&&Cn(U),U},[Cl,li,b,be,g,je]),xL=m.useCallback(w=>aw(w,j.current),[]),bL=m.useCallback(w=>{if(!je){ge("Readonly workspace");return}if(!aw(w,j.current)){ge("端口类型不匹配,已取消连线");return}ee(null),li(),g(S=>tw(S,w)),x(S=>{const _=S.filter(T=>!(T.target===w.target&&T.targetHandle===w.targetHandle)),P=fh({...w,markerEnd:{type:bi.ArrowClosed}},_);return N.current=P,P})},[li,x,g,je]),kL=m.useCallback((w,S)=>{if(!je)return;const _=CG(S,j.current);se.current=_?{..._,preferExisting:!!(w!=null&&w.shiftKey)}:null,ee(null)},[je]),vL=m.useCallback((w,S)=>{var He,Me,zt,rt;if(!je)return;const _=se.current;if(se.current=null,!_||S!=null&&S.toNode)return;const P=_G(be,_),T=EG(j.current,N.current,_);if(P.length===0&&T.length===0){ge(`没有匹配 ${_.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||_.preferExisting)?T.length>0?"existing":"create":P.length>0?"create":"existing",J=((Me=(He=w==null?void 0:w.changedTouches)==null?void 0:He[0])==null?void 0:Me.clientX)??(w==null?void 0:w.clientX),Y=((rt=(zt=w==null?void 0:w.changedTouches)==null?void 0:zt[0])==null?void 0:rt.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const ae=document.querySelector(".af-workspace-canvas .react-flow");if(!ae)return;const pe=ae.getBoundingClientRect(),fe=320,Ne=Math.max(P.length,T.length),We=Math.min(480,150+Ne*58),ze=Math.max(12,Math.min(J-pe.left,pe.width-fe-12)),Ve=Math.max(12,Math.min(Y-pe.top,pe.height-We-12));ee({left:ze,top:Ve,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:_,candidates:P,existingCandidates:T,mode:X,query:""})},[be,r,je]),SL=m.useCallback(w=>{if(!je){ge("Readonly workspace"),ee(null);return}const S=ue.current;if(!S||!(w!=null&&w.def))return;const _=zi(w.def,{position:S.flowPosition});if(!_)return;const P=S.draft.handleType==="source"?{source:S.draft.nodeId,sourceHandle:S.draft.handleId,target:_,targetHandle:`input-${w.slotIndex}`}:{source:_,sourceHandle:`output-${w.slotIndex}`,target:S.draft.nodeId,targetHandle:S.draft.handleId};g(T=>tw(T,P)),x(T=>{const U=T.filter(J=>!(J.target===P.target&&J.targetHandle===P.targetHandle)),X=fh({...P,markerEnd:{type:bi.ArrowClosed}},U);return N.current=X,X}),ee(null)},[zi,x,je]),jL=m.useCallback(w=>{if(!je){ge("Readonly workspace"),ee(null);return}const S=w==null?void 0:w.connection;if(!S||!aw(S,j.current)){ge("端口类型不匹配,已取消连线"),ee(null);return}g(_=>tw(_,S)),x(_=>{const P=_.filter(U=>!(U.target===S.target&&U.targetHandle===S.targetHandle)),T=fh({...S,markerEnd:{type:bi.ArrowClosed}},P);return N.current=T,T}),ee(null)},[x,g,je]),y0=m.useCallback(w=>{w&&(zi(w,{position:qf()}),q(!1),et(""))},[zi,qf]),w0=m.useCallback(w=>{w&&(wu(w,qf()),q(!1),et(""))},[wu,qf]),NL=m.useCallback(w=>{var _,P,T;if(ct||In)return;const S=w==null?void 0:w.target;NC(S)||(_=S==null?void 0:S.closest)!=null&&_.call(S,"button, a, [role='button'], .react-flow__handle")||(T=(P=C.current)==null?void 0:P.focus)==null||T.call(P,{preventScroll:!0})},[ct,In]);m.useEffect(()=>{const w=S=>{var ae;if(S.defaultPrevented)return;const _=wU(S.target)||NC(S.target);if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="s"){S.preventDefault(),Zt().catch(pe=>ge(String(pe.message||pe)));return}if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"){S.preventDefault(),S.stopPropagation(),yS(pe=>!pe);return}if(Og)return;if(Lg){(S.key==="Escape"||iC(S))&&(S.preventDefault(),Pf(!1));return}const P=S.key.toLowerCase(),T=(S.metaKey||S.ctrlKey)&&P==="c",U=(S.metaKey||S.ctrlKey)&&P==="v",X=_&&T&&HY(S.target);if(_&&!X)return;const J=(S.metaKey||S.ctrlKey)&&!S.shiftKey&&P==="z",Y=(S.metaKey||S.ctrlKey)&&(S.shiftKey&&P==="z"||P==="y");if(J||Y){if(ct){S.preventDefault(),S.stopPropagation(),ge("展示页布局会自动保存");return}if(!je){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),S.stopPropagation();const pe=J?RS():TS();ge(pe?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(T){if(ct)return;const pe=yo.current,fe=(j.current||[]).some(We=>We==null?void 0:We.selected)?j.current:(j.current||[]).map(We=>pe&&We.id===pe?{...We,selected:!0}:We),Ne=Bq(fe,N.current,Z.current);Ne&&(S.preventDefault(),S.stopPropagation(),B.current=Ne,VG(Ne),X&&typeof((ae=S.target)==null?void 0:ae.blur)=="function"&&S.target.blur(),ge(`Copied ${Ne.nodes.length} node${Ne.nodes.length>1?"s":""}`));return}if(U){if(ct){S.preventDefault(),S.stopPropagation();return}if(!je){S.preventDefault(),ge("Readonly workspace");return}const pe=B.current||KG();pe&&!B.current&&(B.current=pe);const fe=Hq(pe,j.current,N.current,Z.current);fe&&(S.preventDefault(),S.stopPropagation(),Z.current=fe.instances,ne(fe.instances),g(fe.nodes),x(fe.edges),ge(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(iC(S)&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),Pf(!0);return}if(P==="g"&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),a0();return}if(S.key==="a"||S.key==="A"){if(S.metaKey||S.ctrlKey){S.preventDefault(),ct?K(H.current.nodeIds):(g(pe=>pe.map(fe=>({...fe,selected:!0}))),x(pe=>pe.map(fe=>({...fe,selected:!1}))));return}if(S.altKey)return;if(ct){S.preventDefault(),Pe(!0);return}if(!je){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),q(!0);return}if((S.key==="v"||S.key==="V")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),wS("select");return}if((S.key==="h"||S.key==="H")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),wS("pan");return}(S.key==="f"||S.key==="F")&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&(S.preventDefault(),o0())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[a0,ct,Og,o0,TS,Zt,Lg,x,g,RS,je]);const CL=m.useCallback(w=>{fl(S=>{const _=new Set(S);return _.has(w)?_.delete(w):_.add(w),_})},[]),_L=m.useCallback((w,S)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:S.path,name:S.name,type:S.type})),w.dataTransfer.setData("text/plain",S.path)},[]),EL=m.useCallback((w,S)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",S.id),w.dataTransfer.setData("text/plain",S.id)},[]),Uf=m.useCallback(async(w,S)=>{const _=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),P=_.split(".").pop(),T=["jsx","tsx","js"].includes(P)?"display_react_app":P==="html"?"display_html":P==="csv"||P==="tsv"||P==="json"&&/\b(table|data|rows|report)\b/i.test(_)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(P)?"display_image":"display_markdown",U=be.find(fe=>fe.id===T);if(!U){ge("展示节点不可用");return}const X=T==="display_image";let J=String(w.path||"");if(!X){const fe=$r(a);fe.set("path",w.path);const Ne=await fetch(`/api/workspace/file?${fe.toString()}`),We=await Ne.json();if(!Ne.ok)throw new Error(We.error||"读取文件失败");J=String(We.content||"")}const Y=T==="display_image"?"src":"content",ae=Uu(U.inputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe),pe=Uu(U.outputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe);zi(U,{label:w.name||"Display",body:J,inputs:ae,outputs:pe,position:S}),ge(`已创建展示:${w.path}`)},[zi,a,be]),AL=m.useCallback(w=>{if(!je){ge("Readonly workspace");return}Uf(w,Cl()).catch(S=>ge(String(S.message||S)))},[Uf,Cl,je]),PL=m.useCallback(w=>{if(!je){w.preventDefault(),ge("Readonly workspace");return}const S=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(S){w.preventDefault();let X;try{X=JSON.parse(S)}catch{return}if(!(X!=null&&X.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Uf(X,J).catch(Y=>ge(String(Y.message||Y)));return}const _=w.dataTransfer.getData("application/agentflow-snippet");if(_){const X=Re.find(Y=>`${Y.id}@${Y.version}`===_);if(!X)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});wu(X,J);return}const P=w.dataTransfer.getData("application/agentflow-node");if(!P)return;const T=be.find(X=>X.id===P);if(!T)return;w.preventDefault();const U=r.screenToFlowPosition({x:w.clientX,y:w.clientY});zi(T,{position:U})},[Uf,zi,Re,wu,be,r,je]),IL=m.useCallback(w=>{if(!je)return;const S=Array.from(w.dataTransfer.types||[]);!S.includes("application/x-agentflow-workspace-file")&&!S.includes("application/agentflow-node")&&!S.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=S.includes("application/agentflow-node")||S.includes("application/agentflow-snippet")?"move":"copy")},[je]),RL=m.useCallback(async(w="")=>{if(!je){ge("Readonly workspace");return}const S=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!S)return;const _=w&&!S.includes("/")?`${w}/${S}`:S;try{const P=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_,content:""})}),T=await P.json();if(!P.ok)throw new Error(T.error||"创建文件失败");await Pn(),fl(U=>{const X=new Set(U);for(const J of zp(T.path||_))X.delete(J);return X}),ge(`已创建 ${T.path}`)}catch(P){ge(String(P.message||P))}},[a,Pn,je]),TL=m.useCallback(async(w="")=>{if(!je){ge("Readonly workspace");return}const S=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!S)return;const _=w&&!S.includes("/")?`${w}/${S}`:S;try{const P=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_})}),T=await P.json();if(!P.ok)throw new Error(T.error||"创建文件夹失败");await Pn(),fl(U=>{const X=new Set(U);for(const J of zp(T.path||_))X.delete(J);return T.path&&X.delete(T.path),X}),ge(`已创建 ${T.path}`)}catch(P){ge(String(P.message||P))}},[a,Pn,je]),ML=m.useCallback(async w=>{if(!je){ge("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const S=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),_=await S.json();if(!S.ok)throw new Error(_.error||"删除失败");ge(`已删除 ${_.path}`),await Pn()}catch(S){ge(String(S.message||S))}},[a,Pn,je]),$L=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const S=Yd(w.path,a,{download:!0});if(!S)return;const _=document.createElement("a");_.href=S,_.download=w.name||w.path.split("/").pop()||"download",_.rel="noopener",document.body.appendChild(_),_.click(),_.remove()},[a]),Yf=m.useCallback(async()=>{if(!je){ge("Readonly workspace");return}const w=pa.trim(),S=Wr,_=Os.find(X=>X.id===S)||null;if(!w||ns||(_==null?void 0:_.status)==="running"||(_==null?void 0:_.status)==="stopping")return;const P=_?Array.isArray(_.messages)?_.messages:[]:ha,T=$l(b,k,Z.current);Tg(""),uS(!0),gl(!0),yl(null);const U={role:"user",text:w,at:Date.now()};_?Un(X=>X.map(J=>J.id===S?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],U].slice(-180)}:J)):(bs("workspace"),ml(X=>[...X,U]));try{await Zt(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:Li,selectedSkills:Ls,selectedNodeIds:Bf,messages:P})}),J=await X.json();if(!X.ok)throw new Error(J.error||"生成失败");const ae={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};_?Un(pe=>pe.map(fe=>fe.id===S?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],ae].slice(-180)}:fe)):ml(pe=>[...pe,ae]),await ks(),ge("AI 生成完成")}catch(X){const J=String(X.message||X),Y={role:"assistant",text:J,error:!0,at:Date.now()};_?Un(ae=>ae.map(pe=>pe.id===S?{...pe,status:"failed",messages:[...Array.isArray(pe.messages)?pe.messages:[],Y].slice(-180)}:pe)):ml(ae=>[...ae,Y]),ge(J)}finally{uS(!1)}},[Wr,ha,Li,Os,ns,pa,k,a,ks,b,Zt,Bf,Ls,je]),ar=Os.find(w=>w.id===Wr)||null,Xg=ar?Array.isArray(ar.messages)?ar.messages:[]:ha,_l=ar&&(ar.status==="running"||ar.status==="stopping")||ns,LL=CJ(Xg,_l),Qg=_J(Xg),x0=ar?ar.status==="stopping"?`${ar.label} stopping`:ar.status==="running"?`${ar.label} running`:ar.status==="paused"?`${ar.label} paused`:ar.status==="failed"?`${ar.label} failed`:`${ar.label} done`:ns?"Workspace agent running":ha.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{Wr!=="workspace"&&(Os.some(w=>w.id===Wr)||bs(ya()))},[Wr,Os,ya]),m.useEffect(()=>{if(!nu)return;const w=window.requestAnimationFrame(()=>{var _,P;const S=dS.current;S&&(S.scrollTop=S.scrollHeight),(P=(_=Mg.current)==null?void 0:_.scrollIntoView)==null||P.call(_,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[Xg.length,Wr,x0,Qg.length,nu]);const OL=String(a.flowId||"").trim()||"Workspace",xo=(Nt==null?void 0:Nt.mode)==="single-node",b0=xo&&yu.find(w=>{var S;return w.id===Nt.sourceNodeId||((S=Nt.nodeIds)==null?void 0:S.includes(w.id))})||null,DL=xo&&b0?[b0]:yu;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} · ${$v}`:$v||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:OL}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",TY,"-STABLE"]})]}),Sf?i.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",Sf.ownerUsername||Sf.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:()=>Jg("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:d==="display"?"af-view-switch__active":"",onClick:()=>Jg("display"),children:"Display"}),i.jsx("button",{type:"button",className:d==="workflow"?"af-view-switch__active":"",onClick:()=>Jg("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${jS}`,title:`${PS} · ${NS}`,role:"status","aria-label":`${PS}:${NS}`,children:i.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),An?i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=An.conflictItems)!=null&&w.length?da(!0):m0()},title:["先下载当前本地草稿,再载入远端最新版本",...An.conflictPaths||[]].join(`
265
+ `),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,ct?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!je||pn||!(jt!=null&&jt.absoluteUrl)&&I.nodeIds.length===0,onClick:()=>{er(""),Xt(!0)},title:jt!=null&&jt.absoluteUrl?"查看展示链接":I.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:pn?"hourglass_empty":"ios_share"}),pn?"生成中":jt!=null&&jt.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!je||vl.length===0,onClick:()=>Pe(!0),title:vl.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:!je||!!(ln!=null&&ln.role&&ln.role!=="owner"),onClick:oL,title:ln!=null&&ln.role&&ln.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),Sf?null:i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:uL,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:!AS,onClick:()=>h(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:i.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),i.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!AS&&!cu,onClick:()=>v(!0),"aria-label":cu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:cu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:cu?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Pf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(nu?" af-composer-topbar-btn--active":"")+(ns?" af-composer-topbar-btn--running":""),disabled:!je||ct||In,onClick:()=>{yl(null),gl(w=>(w||bs(ya()),!w))},children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!je,onClick:()=>Zt().catch(w=>ge(String(w.message||w))),children:"Save"})]})]}),gs?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:gs}),i.jsx("button",{type:"button",onClick:()=>ys(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!ct&&!In&&(nu||at)?" af-workspace-body--drawer":"")+(!ct&&!In&&su?" af-workspace-body--sidebar-collapsed":"")+(ct?" af-workspace-body--display-mode":"")+(In?" af-workspace-body--workflow-mode":""),children:[!ct&&!In&&su?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:()=>q(!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:()=>Af(!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:()=>Af(!1),"aria-label":"展开侧边栏",title:(Rr==null?void 0:Rr.username)||(Rr==null?void 0:Rr.userId)||"展开侧边栏",children:nL})]})}):null,!ct&&!In?i.jsxs("aside",{ref:Ng,className:"af-workspace-sidebar"+(k$?" af-workspace-sidebar--resizing":""),"aria-hidden":su,style:{"--af-work-files-pane-height":`${Math.round(Cg)}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:()=>Af(!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:!je,onClick:()=>RL(Fi),"aria-label":"新增文件",title:Fi?`在 ${Fi} 新增文件`:"新增文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je,onClick:()=>TL(Fi),"aria-label":"新增文件夹",title:Fi?`在 ${Fi} 新增文件夹`:"新增文件夹",children:i.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),i.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je||Wv,onClick:()=>US(Fi),"aria-label":"上传文件",title:Fi?`上传到 ${Fi}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:Wv?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Pn(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:Kv,type:"file",multiple:!0,className:"af-visually-hidden",onChange:q$})]})]}),i.jsx("input",{className:"af-workspace-search",value:kg,onChange:w=>x$(w.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:eL,children:i.jsx(uM,{items:Z$,onOpen:AL,selectedPath:vg,collapsedDirs:b$,onToggleDir:CL,onSelect:w=>Sg(w.path||""),onFileDragStart:_L,onDelete:ML,onDownload:$L})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:P$,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:an==="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:Wt,onChange:w=>Lt(w.target.value),placeholder:an==="flows"?"搜索流程片段...":"搜索节点...","aria-label":an==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":an==="nodes",className:"af-palette-tab"+(an==="nodes"?" af-palette-tab--active":""),onClick:()=>re("nodes"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":an==="flows",className:"af-palette-tab"+(an==="flows"?" af-palette-tab--active":""),onClick:()=>re("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:an==="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:sL,disabled:tr.length<2,title:tr.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:["已选 ",tr.length," 节点 / ",Hf.length," 连线"]})]})}),_t?i.jsx("p",{className:"af-err af-palette-list-err",children:_t}):null,Ze?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):f0.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:f0.map(w=>{const S=`${w.id}@${w.version}`,_=w.displayName||w.name||w.id,P=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",S),T.dataTransfer.setData("text/plain",S)},onClick:()=>wu(w),title:P,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]})]})]}),P?i.jsx("span",{className:"af-palette-card-desc",children:P}):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"]})]})]},S)})})]}):i.jsx("p",{className:"af-palette-empty",children:Wt.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Dl.map(w=>{var S;return(S=qg[w])!=null&&S.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:qg[w].map(_=>{const P=RC(_.inputs,"input"),T=RC(_.outputs,"output"),U=db(_),X=Ku(_);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>EL(J,_),onClick:()=>zi(_),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:PC(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:[P.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[P.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:IC("input",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Mn(J==null?void 0:J.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:Op(J,Y)})]},`in-${Y}`)),P.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",P.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[T.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[T.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:IC("output",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Op(J,Y)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Mn(J==null?void 0:J.type)}})]},`out-${Y}`)),T.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",T.hidden]}):null]})]})]})]},_.id)})})]},w):null}),be.length>0&&Wt.trim()&&Dl.every(w=>{var S;return!((S=qg[w])!=null&&S.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,In?i.jsx(WJ,{flowParams:a,tapdId:or,setTapdId:_$,snapshot:cn,loading:E$,error:A$,actionRunning:_g,actionOutput:Eg,pendingConfirm:xs,conflict:eu,reviewPublishing:Ag,onRefresh:()=>du(or),onRunDryRun:F$,onConfirmAction:z$,onRetryConflict:B$,onPublishReview:H$}):i.jsxs("main",{ref:C,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:NL,children:[i.jsx(xR,{className:"af-flow-canvas af-workspace-flow"+(Dg==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ct?" af-workspace-flow--display-mode":""),nodes:zf,edges:X$,nodeTypes:wJ,onNodesChange:yL,onEdgesChange:wL,onConnect:ct?void 0:bL,onConnectStart:ct?void 0:kL,onConnectEnd:ct?void 0:vL,isValidConnection:ct?void 0:xL,onNodeClick:(w,S)=>{var _;if(ct){K([Fp(S.id)]);return}if((_=S==null?void 0:S.data)!=null&&_.isWorkspaceGroup){Cn("");return}if(w.detail>=3){gl(!1),g(P=>P.map(T=>({...T,selected:T.id===S.id}))),x(P=>P.map(T=>({...T,selected:!1}))),Cn(S.id);return}Yt&&Cn(S.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{ct?K([]):Cn("")},onDrop:ct?void 0:PL,onDragOver:ct?void 0:IL,nodesDraggable:je,nodesConnectable:ct?!1:je,edgesReconnectable:ct?!1:je,onlyRenderVisibleElements:zf.length>=80,deleteKeyCode:ct?null:je?["Backspace","Delete"]:null,selectionOnDrag:Dg==="select",panOnDrag:Dg==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(kR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ct&&G?(()=>{var J;const w=String(G.query||"").trim().toLowerCase(),S=G.mode==="create"?"create":"existing",_=Array.isArray(G.candidates)?G.candidates:[],P=Array.isArray(G.existingCandidates)?G.existingCandidates:[],T=w?_.filter(Y=>{var ae,pe,fe;return[(ae=Y.def)==null?void 0:ae.id,Y.displayLabel,Y.description,(pe=Y.slot)==null?void 0:pe.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(Ne=>String(Ne).toLowerCase().includes(w))}):_,U=w?P.filter(Y=>{var ae,pe;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(ae=Y.slot)==null?void 0:ae.name,(pe=Y.slot)==null?void 0:pe.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):P,X=G.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:G.left,top:G.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Mn((J=G.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),i.jsxs("span",{children:["匹配 ",G.draft.slotType," 节点"]})]}),i.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>ee(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:S==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:P.length===0,onClick:()=>ee(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:P.length})]}),i.jsxs("button",{type:"button",className:S==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:_.length===0,onClick:()=>ee(Y=>Y&&{...Y,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:G.query,onChange:Y=>ee(ae=>ae&&{...ae,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),i.jsxs("div",{className:"af-connect-node-menu__list",children:[S==="create"?T.map(Y=>{var fe,Ne;const ae=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),pe=Op(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>SL(Y),title:Y.description||Y.def.id,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),ae!==Y.def.id?i.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Mn((Ne=Y.slot)==null?void 0:Ne.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:pe})]})]},`${Y.def.id}-${Y.slotIndex}`)}):U.map(Y=>{var fe;const ae=Y.nodeLabel||Y.nodeId,pe=Op(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>jL(Y),title:`${Y.definitionId||Y.nodeId} · ${pe}`,children:[i.jsxs("span",{className:"af-connect-node-menu__item-main",children:[i.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),i.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),i.jsxs("span",{className:"af-connect-node-menu__port",children:[i.jsx("span",{children:X}),i.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Mn((fe=Y.slot)==null?void 0:fe.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:pe}),Y.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(S==="create"?T.length:U.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ct&&!In&&!M$?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:()=>$g(!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:tr.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):tr.map(w=>{var T,U;const S=String(((T=w.data)==null?void 0:T.label)??w.id),_=(U=w.data)!=null&&U.definitionId?String(w.data.definitionId):"",P=_&&_!==S?`${S} · ${w.id} · ${_}`:`${S} · ${w.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:P,children:[i.jsx("span",{className:"af-composer-node-chip-kind",children:_||"node"}),i.jsx("span",{className:"af-composer-node-chip-label",children:S}),i.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>gL(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:pa,rows:2,onChange:w=>Tg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),Yf())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!je})}),i.jsxs("div",{className:"af-composer-toolbar",children:[i.jsxs("div",{className:"af-composer-skills-field",children:[i.jsxs("button",{ref:Rg,type:"button",className:"af-composer-skills-button"+(Ls.length>0?" af-composer-skills-button--active":""),disabled:ns||!je,"aria-haspopup":"listbox","aria-expanded":Ef,onClick:()=>Ig(w=>!w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Ls.length>0?`Skills ${Ls.length}`:"Skills"})]}),Ef&&!ns?ur.createPortal(i.jsx("div",{ref:lS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:R$,children:$s.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[jl.groups.map(w=>{const S=Zo(w,$s),_=IF(w,Ug,$s),P=I$.has(w.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(P?" 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:S.length===0,onChange:T=>{const U=T.target.checked;Zc(X=>U?AF(X,S):PF(X,S))}}),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":P?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{aS(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:P?"expand_more":"expand_less"})]})]}),P?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:Ug.has(T.key),onChange:U=>{const X=U.target.checked;Zc(J=>X?J.includes(T.key)?J:[...J,T.key]:J.filter(Y=>Y!==T.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:T.name}),T.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:T.description}):null]})]},`${w.id}:${T.key}`))})]},w.id)}),jl.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:jl.ungrouped.length})]}),jl.ungrouped.map(w=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Ug.has(w.key),onChange:S=>{const _=S.target.checked;Zc(P=>_?P.includes(w.key)?P:[...P,w.key]:P.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:Li,onChange:w=>S$(w.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),tL.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(pa.trim()&&!ns?" af-composer-send--active":"")+(ns?" af-composer-send--stop":""),disabled:ns||!pa.trim()||!je,"aria-label":ns?"Running":"Send",onClick:()=>void Yf(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ns?"sync":"arrow_upward"})})]})]})]})}):!ct&&!In?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>$g(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!ct&&!In&&nu?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:()=>gl(!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"+(Wr==="workspace"?" af-composer-session-tab--active":""),ref:Wr==="workspace"?Mg:null,onClick:()=>bs("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Os.map(w=>i.jsxs("div",{role:"tab",tabIndex:0,ref:Wr===w.id?Mg:null,className:"af-composer-session-tab"+(Wr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>bs(w.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),bs(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:S=>{S.preventDefault(),S.stopPropagation(),V$(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"+(_l?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:x0}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:dS,children:[i.jsx(WC,{messages:LL,running:_l,showRunningIndicator:!ar}),Qg.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",..._l?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(WC,{messages:Qg,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:pa,rows:3,onChange:w=>Tg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),Yf())},placeholder:ar?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!je||_l}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!je||_l||!pa.trim(),onClick:()=>void Yf(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!ct&&!In&&at&&Kt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(zU,{draft:at,setDraft:ws,definitionId:String(((k0=Kt.data)==null?void 0:k0.definitionId)||Kt.id),systemPromptReadonly:String(((v0=Kt.data)==null?void 0:v0.description)||""),modelLists:fa,disabled:!je,onIdBlur:()=>Wg(!0),onClose:()=>Cn(""),onPublishToMarketplace:W$,error:p$,ioSlots:{inputs:Array.isArray(at==null?void 0:at.inputs)?at.inputs:[],outputs:Array.isArray(at==null?void 0:at.outputs)?at.outputs:[]}})}):null,!ct&&!In&&ru?ur.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>yl(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:i.jsx(NU,{flowParams:a,scheduleNodeId:ru.scheduleNodeId,runNodeId:ru.runNodeId,lastRunId:ru.lastRunId,label:ru.label,onClose:()=>yl(null)})})}),document.body):null,i.jsx(kU,{open:Lg,onClose:()=>Pf(!1)}),i.jsx(SU,{open:Og,onClose:()=>yS(!1),onJump:Kg,nodes:Q$}),i.jsx(BU,{open:p,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:lu,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),i.jsx(HU,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:lu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:cu,onDeleted:async()=>{v(!1),n("/projects")}}),w$&&An?ur.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"}),"解决 ",((S0=An.conflictItems)==null?void 0:S0.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>da(!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:()=>dl(Object.fromEntries((An.conflictItems||[]).map((w,S)=>[String(S),{mode:"local",manual:Tu(w)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>dl(Object.fromEntries((An.conflictItems||[]).map((w,S)=>[String(S),{mode:"remote",manual:Tu(w)}]))),children:"全部使用远端"})]})]}),(An.conflictItems||[]).map((w,S)=>{const _=bg[String(S)]||{mode:"local",manual:Tu(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(([P,T])=>i.jsx("button",{type:"button",className:_.mode===P?"is-active":"",onClick:()=>dl(U=>({...U,[String(S)]:{..._,mode:P}})),children:T},P))}),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:QC(w,"incoming")})]}),i.jsxs("div",{className:_.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:QC(w,"current")})]})]}),_.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:_.manual,onChange:P=>dl(T=>({...T,[String(S)]:{..._,manual:P.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${S}`)}),Hv?i.jsx("div",{className:"af-flow-snippet-error",children:Hv}):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:jf,onClick:()=>void m0(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:jf,onClick:()=>da(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:jf||!(An.conflictItems||[]).length,onClick:()=>void lL(),children:jf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,jn?ur.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:()=>br(!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:xn.name,onChange:w=>{const S=w.target.value;Qn(_=>({..._,name:S,id:_.id?_.id:S.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:xn.id,onChange:w=>Qn(S=>({...S,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:xn.description,onChange:w=>Qn(S=>({...S,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",tr.length," 个节点和 ",Hf.length," 条内部连线。"]}),ts?i.jsx("div",{className:"af-flow-snippet-error",children:ts}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>br(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:qn||!xn.name.trim(),onClick:()=>void iL(),children:qn?"发布中...":"发布"})]})]})}),document.body):null,n0?i.jsx(oJ,{node:n0,onClose:()=>Bn("")}):null,sr?ur.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":xo?"新建分享":"发布展示页",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"}),xo?"新建分享":"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Ir(!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:Nt.title,onChange:w=>le(S=>({...S,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),xo?null:i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:Nt.layout,onChange:w=>le(S=>({...S,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:OC(Nt),onChange:w=>{const S=w.target.value;le(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:lw.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":xo?"分享内容":"选择展示节点",children:[xo?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,DL.map(w=>{var _;const S=Array.isArray(Nt.nodeIds)&&Nt.nodeIds.includes(w.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:S,disabled:xo,onChange:()=>cL(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:[Rn(w.data)," · ",w.id]})]})]},w.id)})]}),jt!=null&&jt.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:jt.absoluteUrl,onFocus:w=>w.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(jt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void g0(),children:nn==="copied"?"已复制":nn==="failed"?"复制失败":"复制"})]}):null,kr?i.jsx("div",{className:"af-flow-snippet-error",children:kr}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Ir(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:pn||!Array.isArray(Nt.nodeIds)||Nt.nodeIds.length===0,onClick:()=>void dL(),children:pn?"生成中...":"生成链接"})]})]})}),document.body):null,Ft?ur.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:()=>{er(""),Xt(!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:[jt!=null&&jt.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:jt.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(jt.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 g0(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:nn==="copied"?"check":"content_copy"}),nn==="copied"?"已复制":nn==="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:OC(Nt),onChange:w=>{const S=w.target.value;le(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:lw.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))})]}),kr?i.jsx("div",{className:"af-flow-snippet-error",children:kr}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{er(""),Xt(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:pn||I.nodeIds.length===0,onClick:()=>void fL(),children:pn?"生成中...":jt!=null&&jt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,y$?ur.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:()=>wg(!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.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:Jc,onChange:w=>Dv(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Jc.trim()&&!xg&&(w.preventDefault(),h0())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:xg||!Jc.trim(),onClick:()=>void h0(),children:xg?"添加中...":"添加成员"})]}),Ov?i.jsx("div",{className:"af-flow-snippet-error",children:Ov}):null,i.jsx("div",{className:"af-workspace-member-list",children:((ln==null?void 0:ln.members)||[]).map(w=>{const S=w.userId===(ln==null?void 0:ln.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:S?"shield_person":"person"}),i.jsxs("div",{children:[i.jsx("strong",{children:w.username||w.userId}),i.jsx("small",{children:S?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),S?null:i.jsx("button",{type:"button",disabled:Fv===w.userId,onClick:()=>void aL(w),children:Fv===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:()=>wg(!1),children:"完成"})})]})}),document.body):null,ht?ur.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:()=>rn(!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:Vt.length?`${Vt.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void Bs(),disabled:tt,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),$i?i.jsx("div",{className:"af-flow-snippet-error",children:$i}):null,tt?i.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!tt&&Vt.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:Vt.map(w=>{const S=FC(w),_=go===w.id,P=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:BG(w)})]}),i.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:S,onFocus:T=>T.target.select()}),i.jsx("select",{className:"af-display-share-select",value:P,disabled:_,onChange:T=>void hL(w,T.target.value),"aria-label":"修改分享有效期",children:lw.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(S,"_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 pL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ms===w.id?"check":"content_copy"}),Ms===w.id?"已复制":"复制"]}),i.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:_,onClick:()=>void mL(w),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,Se?ur.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:()=>Pe(!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:wt,onChange:w=>Ot(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":d0.length||1},children:Wf.length>0?d0.map((w,S)=>i.jsx("div",{className:"af-display-picker-column",children:w.map(rL)},`display-picker-column-${S}`)):i.jsx("div",{className:"af-display-picker-empty",children:vl.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:()=>Pe(!1),children:"完成"})})]})}),document.body):null,Qc.nodeId?ur.createPortal(i.jsx(NJ,{files:cl,query:Qc.query,onQueryChange:w=>jg(S=>({...S,query:w})),onSelect:U$,onUpload:US,onClose:Bg}),document.body):null,!ct&&!In&&Dn?ur.createPortal(i.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>q(!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":he==="nodes",className:"af-workspace-quick-add__tab"+(he==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>De("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":he==="flows",className:"af-workspace-quick-add__tab"+(he==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>De("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:cS,value:Ee,onChange:w=>et(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),q(!1);else if(w.key==="ArrowDown"){w.preventDefault();const S=he==="flows"?gu.length:mu.length;bt(_=>Math.min(Math.max(0,S-1),_+1))}else w.key==="ArrowUp"?(w.preventDefault(),bt(S=>Math.max(0,S-1))):w.key==="Tab"?(w.preventDefault(),De(S=>S==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),he==="flows"?w0(gu[Nn]||gu[0]):y0(mu[Nn]||mu[0]))},placeholder:he==="flows"?"搜索流程片段...":"搜索节点...","aria-label":he==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:he==="flows"?gu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:Ze?"正在加载流程片段...":_t||"没有匹配的流程片段"}):gu.map((w,S)=>{const _=w.displayName||w.name||w.id,P=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(P||{}).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"+(S===Nn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>bt(S),onClick:()=>w0(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}`)}):mu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):mu.map((w,S)=>{const _=Vu(w),P=Ku(w),T=db(w);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Nn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>bt(S),onClick:()=>y0(w),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:PC(_)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:P}),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 qJ(){return i.jsx(zk,{children:i.jsx(KJ,{})})}function UJ(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 YJ(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 GJ(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 kM(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=GJ(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 xv(e){let t=kM(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 JJ(e){const t=xv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function XJ(e){const t=xv(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 vM(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 QJ(e,t,n={}){const r=String(e||"").trim();return r?vM(r,t,n):""}function ZJ({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,y=h?Math.max(12,p/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:b,height:y})},[]);m.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 h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.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=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,y=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h: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 yb({node:e,shareId:t,style:n,bare:r=!1}){const s=UJ(e),o=e.kind==="html"?xv(s):e.kind==="react"?lg(s):kM(s),a=e.kind==="html"?JJ(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:YJ(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(ZJ,{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:XJ(o)}):null,e.kind==="react"?i.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:cv(o)}):null,e.kind==="image"?i.jsx("img",{src:vM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(rv,{content:o,resolveSrc:(c,u)=>QJ(c,t,u)})}):null,e.kind==="chart"?i.jsx(iv,{content:o}):null,e.kind==="table"?i.jsx(sv,{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(yb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const tX={publicDisplay:eX};function nX(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 SM(){var l,c,u,d;const{path:e}=Ts(),t=m.useMemo(()=>nX(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function p(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(y.error||"展示页不存在");f||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return p(),()=>{f=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((p,h)=>{const y=p.position&&typeof p.position.x=="number"&&typeof p.position.y=="number"?p.position:{x:120+h*40,y:100+h*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=m.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),h=Number(f.y),y=Number(f.zoom);return!Number.isFinite(p)||!Number.isFinite(h)||!Number.isFinite(y)?null:{x:p,y:h,zoom:Math.min(Math.max(y,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return i.jsx("main",{className:"af-public-display-page",children:i.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return i.jsx("main",{className:"af-public-display-page",children:i.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),i.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return i.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:i.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>i.jsx(yb,{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(yb,{node:p,shareId:t},p.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(zk,{children:i.jsx(xR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:tX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:o||void 0,fitView:!o,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:i.jsx(kR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const xt=e=>typeof e=="string",Mu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},ZC=e=>e==null?"":""+e,rX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},sX=/###/g,e_=e=>e&&e.indexOf("###")>-1?e.replace(sX,"."):e,t_=e=>!e||xt(e),hd=(e,t,n)=>{const r=xt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(t_(e))return{};const o=e_(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return t_(e)?{}:{obj:e,k:e_(r[s])}},n_=(e,t,n)=>{const{obj:r,k:s}=hd(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=hd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=hd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},iX=(e,t,n,r)=>{const{obj:s,k:o}=hd(e,t,Object);s[o]=s[o]||[],s[o].push(n)},wm=(e,t)=>{const{obj:n,k:r}=hd(e,t);if(n)return n[r]},oX=(e,t,n)=>{const r=wm(e,n);return r!==void 0?r:wm(t,n)},jM=(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]):jM(e[r],t[r],n):e[r]=t[r]);return e},Ll=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var aX={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const lX=e=>xt(e)?e.replace(/[&<>"'\/]/g,t=>aX[t]):e;class cX{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 uX=[" ",",","?","!",";"],dX=new cX(20),fX=(e,t,n)=>{t=t||"",n=n||"";const r=uX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=dX.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},wb=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},xm=e=>e&&e.replace("_","-"),pX={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 bm{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||pX,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 bm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new bm(this.logger,t)}}var Si=new bm;class dg{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 r_ extends dg{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=wm(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:wb(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),n_(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=wm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?jM(c,r,o):c={...c,...r},n_(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 NM={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 s_={};class km extends dg{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=Si.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&&!fX(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 j=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${j}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${j}${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 h=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 j=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=j,f.usedParams=this.getUsedParamsDetails(n),f):j}if(o){const j=Array.isArray(p),N=j?[]:{},C=j?y:h;for(const I in p)if(Object.prototype.hasOwnProperty.call(p,I)){const R=`${C}${o}${I}`;N[I]=this.translate(R,{...n,joinArrays:!1,ns:l}),N[I]===R&&(N[I]=p[I])}p=N}}else if(k&&xt(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,N=!1;const C=n.count!==void 0&&!xt(n.count),I=km.hasDefaultValue(n),R=C?this.pluralResolver.getSuffix(u,n.count,n):"",H=n.ordinal&&C?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",A=C&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),L=A&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${R}`]||n[`defaultValue${H}`]||n.defaultValue;!this.isValidLookup(p)&&I&&(j=!0,p=L),this.isValidLookup(p)||(N=!0,p=a);const O=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:p,M=I&&L!==p&&this.options.updateMissing;if(N||j||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?L: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 K=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let $=0;$<z.length;$++)K.push(z[$]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(n.lng||this.language):K.push(n.lng||this.language);const F=($,W,E)=>{const Q=I&&E!==p?E:O;this.options.missingKeyHandler?this.options.missingKeyHandler($,c,W,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing($,c,W,Q,M,n),this.emit("missingKey",$,c,W,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?K.forEach($=>{const W=this.pluralResolver.getSuffixes($,n);A&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(E=>{F([$],a+E,n[`defaultValue${E}`]||L)})}):F(K,a,L))}p=this.extendTranslation(p,t,n,f,r),N&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(N||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,j?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),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),y=0;y<p;y++)h[y]=arguments[y];return o&&o[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=xt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=NM.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),h=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,!s_[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(s_[`${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 j;p&&(j=this.pluralResolver.getSuffix(g,n.count,n));const N=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(d+j),n.ordinal&&j.indexOf(C)===0&&k.push(d+j.replace(C,this.options.pluralSeparator)),h&&k.push(d+N)),y){const I=`${d}${this.options.contextSeparator}${n.context}`;k.push(I),p&&(k.push(I+j),n.ordinal&&j.indexOf(C)===0&&k.push(I+j.replace(C,this.options.pluralSeparator)),h&&k.push(I+N))}}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 dw=e=>e.charAt(0).toUpperCase()+e.slice(1);class i_{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Si.create("languageUtils")}getScriptPartFromCode(t){if(t=xm(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=xm(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]=dw(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]=dw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=dw(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}],mX={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 gX=["v1","v2","v3"],yX=["v4"],o_={zero:0,one:1,two:2,few:3,many:4,other:5},wX=()=>{const e={};return hX.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:mX[t.fc]}})}),e};class xX{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Si.create("pluralResolver"),(!this.options.compatibilityJSON||yX.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=wX(),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=xm(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)=>o_[s]-o_[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!gX.includes(this.options.compatibilityJSON)}}const a_=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=oX(e,t,n);return!o&&s&&xt(n)&&(o=wb(e,n,r),o===void 0&&(o=wb(t,n,r))),o},fw=e=>e.replace(/\$/g,"$$$$");class bX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Si.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:h,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:lX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?Ll(o):a||"{{",this.suffix=l?Ll(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?Ll(p):h||Ll("$t("),this.nestingSuffix=y?Ll(y):v||Ll(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=g||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,s){let o,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const g=a_(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...s,...n,interpolationkey:h}):g}const y=h.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(a_(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:h=>fw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?fw(this.escape(h)):fw(h)}].forEach(h=>{for(l=0;o=h.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof 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=ZC(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,o,a;const l=(c,u)=>{const 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 h=p.match(/'/g),y=p.match(/"/g);(h&&h.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=ZC(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 kX=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}},Ol=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(xm(r),s),t[a]=l),l(n)}};class vX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Si.create("formatter"),this.options=t,this.formats={number:Ol((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Ol((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Ol((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Ol((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Ol((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()]=Ol(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}=kX(c);if(this.formats[u]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[u](l,h,{...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 SX=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class jX extends dg{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=Si.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=>{iX(c.loaded,[o],a),SX(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 l_=()=>({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),Bp=()=>{},NX=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Xd extends dg{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=Si,this.modules={external:[]},NX(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=l_();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?Si.init(o(this.modules.logger),this.options):Si.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:typeof Intl<"u"&&(d=vX);const f=new i_(this.options);this.store=new r_(this.options.resources,this.options);const p=this.services;p.logger=Si,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new xX(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 bX(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new jX(o(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.languageDetector&&(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 km(this.services,this.options),this.translator.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Bp),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=Mu(),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]:Bp;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=Mu();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=Bp),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"&&NM.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=Mu();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 h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${p}${y}`):h=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(h,c)};return xt(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(o,t)))}loadNamespaces(t,n){const r=Mu();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=Mu();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 i_(l_());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 Xd(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new Xd(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 r_(this.store.data,s),o.services.resourceStore=o.store),o.translator=new km(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 xr=Xd.createInstance();xr.createInstance=Xd.createInstance;xr.createInstance;xr.dir;xr.init;xr.loadResources;xr.reloadResources;xr.use;xr.changeLanguage;xr.getFixedT;xr.t;xr.exists;xr.setDefaultNamespace;xr.hasLoadedNamespace;xr.loadNamespaces;xr.loadLanguages;function CX(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qd(e){"@babel/helpers - typeof";return Qd=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},Qd(e)}function _X(e,t){if(Qd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Qd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function EX(e){var t=_X(e,"string");return Qd(t)=="symbol"?t:t+""}function AX(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,EX(r.key),r)}}function PX(e,t,n){return t&&AX(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var CM=[],IX=CM.forEach,RX=CM.slice;function TX(e){return IX.call(RX.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var u_=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,MX=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(!u_.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!u_.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},d_={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=MX(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)}},$X={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=d_.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&d_.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},LX={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}},$u=null,f_=function(){if($u!==null)return $u;try{$u=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{$u=!1}return $u},OX={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&f_()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&f_()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Lu=null,p_=function(){if(Lu!==null)return Lu;try{Lu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Lu=!1}return Lu},DX={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&p_()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&p_()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},FX={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}},zX={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}},BX={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}},HX={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]}},_M=!1;try{document.cookie,_M=!0}catch{}var EM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];_M||EM.splice(1,1);function WX(){return{order:EM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var AM=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};CX(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return PX(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=TX(r,this.options||{},WX()),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($X),this.addDetector(LX),this.addDetector(OX),this.addDetector(DX),this.addDetector(FX),this.addDetector(zX),this.addDetector(BX),this.addDetector(HX)}},{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)}))}}])}();AM.type="languageDetector";const VX={name:"AgentFlow",tagline:"AI Workflow Orchestration"},KX={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},qX={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"},UX={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},YX={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},GX={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},JX={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},XX={app:VX,nav:KX,common:qX,status:UX,nodeTypes:YX,engine:GX,links:JX},QX="Flow Editor",ZX="Nodes",eQ="Edges",tQ="Properties",nQ={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}}"},sQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},iQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},oQ={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"},aQ={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)"},lQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},cQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},uQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},dQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},fQ={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"},pQ={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"},mQ={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."},gQ={mainNav:"Main Navigation"},yQ={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'},wQ={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}}"},xQ={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"},bQ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},kQ={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}}"},vQ={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"},SQ={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"},jQ={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"},NQ={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"},CQ={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"},_Q={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},EQ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},AQ={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"},PQ={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."},IQ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},RQ={save:"Save",cancel:"Cancel"},TQ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},MQ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},$Q={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"},LQ={title:QX,nodes:ZX,edges:eQ,properties:tQ,node:nQ,nodeProps:rQ,actions:sQ,panel:iQ,palette:oQ,pipeline:aQ,status:lQ,roles:cQ,phases:uQ,types:dQ,runContext:fQ,shortcuts:pQ,jumpPalette:hQ,emptyCanvas:mQ,sidebar:gQ,validation:yQ,composer:wQ,topbar:xQ,palette2:bQ,run:kQ,fileEdit:vQ,settings:SQ,schedule:jQ,history:NQ,nodePropsError:CQ,placeholder:_Q,time:EQ,userCheck:AQ,userAsk:PQ,toolPrint:IQ,provideEdit:RQ,runParams:TQ,runPreset:MQ,runConfig:$Q},OQ="Settings",DQ={engine:"Engine Settings",preferences:"Global Preferences"},FQ={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)."},zQ={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..."}},BQ={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."},HQ={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."},WQ={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."},VQ={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)"},KQ={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"},qQ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},UQ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},YQ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},GQ={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."},JQ={title:OQ,crumb:DQ,workspace:FQ,cursor:zQ,opencode:BQ,claudeCode:HQ,codex:WQ,env:VQ,allowlist:KQ,system:qQ,shortcuts:UQ,language:YQ,onboarding:GQ},XQ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},QQ={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)"},ZQ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},eZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},tZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},nZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},rZ={aiLabels:XQ,placeholders:QQ,actions:ZQ,labels:eZ,tooltips:tZ,rightPanel:nZ},sZ="Projects",iZ="All",oZ="Archived",aZ="Nodes",lZ="My Nodes",cZ="My Flows",uZ="Skills",dZ="Active Projects",fZ="Archived Pipelines",pZ="Global Nodes",hZ="All Nodes",mZ="My Nodes",gZ="Manage node versions published to the current workspace marketplace, {{count}} total.",yZ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",wZ="Global Skills",xZ="Create New Project",bZ="New Pipeline",kZ="SEARCH PIPELINES...",vZ="SEARCH NODES...",SZ="SEARCH FLOW SNIPPETS...",jZ="SEARCH SKILLS...",NZ="Refresh Resources",CZ="Loading pipelines...",_Z="Loading global resources...",EZ="Filter result: {{count}} items (matching title, description, path and tags)",AZ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",PZ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",IZ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",RZ="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",TZ="Executable building blocks for pipeline runtime",MZ="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.",$Z="Published local node packages",LZ="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",OZ="Published flow snippets",DZ="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",FZ="Operating guides for Composer and agents",zZ="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",BZ="No archived projects.",HZ="No active pipelines; archived items are in the Archived tab.",WZ="No global nodes available.",VZ="No marketplace nodes have been published.",KZ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",qZ="No skills available.",UZ="No description.",YZ='No node matches "{{query}}".',GZ='No flow snippet matches "{{query}}".',JZ='No skill matches "{{query}}".',XZ="{{inputs}} in / {{outputs}} out",QZ="Flow Snippet",ZZ="{{nodes}} nodes / {{edges}} edges",eee="Skill",tee="Node detail",nee="Flow snippet detail",ree="Skill detail",see="Type",iee="Source",oee="Package",aee="Version",lee="Path",cee="Editable",uee="Read only",dee="Editable",fee="Schema",pee="Inputs",hee="Outputs",mee="Runtime",gee="Node Body",yee="Files",wee="Usage",xee="No runtime manifest.",bee="No node body or README.",kee="No previewable files.",vee="Select a file to preview.",See="Binary file preview is not supported.",jee="Large file; showing the first 256KB only.",Nee="No pipelines using this node were found.",Cee="Node Management",_ee="Delete Node Version",Eee="Deleting...",Aee="AgentFlow checks all flow references before deleting; installed or used versions are kept.",Pee="Delete {{id}}@{{version}}? This cannot be undone.",Iee="Deleted {{id}}@{{version}}.",Ree="{{count}} flow(s) still use it.",Tee="Flow Snippet Management",Mee="Delete Flow Snippet",$ee="Deleting...",Lee="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",Oee="Delete {{id}}@{{version}}? This cannot be undone.",Dee="Deleted {{id}}@{{version}}.",Fee="No slots",zee="Purpose",Bee="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",Hee="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.",Wee="Scale",Vee="Flow Preview",Kee="Edges",qee="Snippet JSON",Uee="{{count}} more edge(s)",Yee="No previewable nodes.",Gee="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Jee="SKILL.md Preview",Xee="No preview content available.",Qee="Select a resource to inspect details.",Zee="Failed to load pipeline list.",ete="No pipelines in current workspace.",tte="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.",nte='No pipelines found matching "{{query}}". Try different keywords or clear the search.',rte="Recent Activity",ste="No recent activity",ite="No recent activity matching the keyword",ote="Recent Run",ate="Recent Open",lte={builtin:"Built-in",workspace:"Workspace",user:"User"},cte={flow:"Flow",global:"Global",marketplace:"Marketplace"},ute={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},dte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},fte="Open to edit this pipeline in the node canvas.",pte={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"},mte={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"},gte={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"},yte={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"},wte={title:sZ,all:iZ,archived:oZ,nodes:aZ,myNodes:lZ,myFlows:cZ,skills:uZ,activeProjects:dZ,archivedPipelines:fZ,globalNodes:pZ,nodeScopeAll:hZ,nodeScopeMine:mZ,myNodesHint:gZ,myFlowsHint:yZ,globalSkills:wZ,createNew:xZ,newPipeline:bZ,searchPipelines:kZ,searchNodes:vZ,searchFlows:SZ,searchSkills:jZ,refreshResources:NZ,loadingPipelines:CZ,loadingResources:_Z,filterResult:EZ,archivedHint:AZ,activeHint:PZ,nodesHint:IZ,skillsHint:RZ,nodesPurposeTitle:TZ,nodesPurposeDesc:MZ,myNodesPurposeTitle:$Z,myNodesPurposeDesc:LZ,myFlowsPurposeTitle:OZ,myFlowsPurposeDesc:DZ,skillsPurposeTitle:FZ,skillsPurposeDesc:zZ,noArchived:BZ,noActive:HZ,noNodes:WZ,noMyNodes:VZ,noMyFlows:KZ,noSkills:qZ,noDescription:UZ,noNodeMatch:YZ,noFlowSnippetMatch:GZ,noSkillMatch:JZ,nodeSlots:XZ,flowSnippet:QZ,flowSnippetNodes:ZZ,skill:eee,nodeDetail:tee,flowDetail:nee,skillDetail:ree,detailType:see,detailSource:iee,detailPackage:oee,detailVersion:aee,detailPath:lee,detailEditable:cee,readOnly:uee,editable:dee,nodeSchema:fee,nodeInputs:pee,nodeOutputs:hee,nodeRuntime:mee,nodeBody:gee,nodeFiles:yee,nodeUsage:wee,noRuntimeManifest:xee,noNodeBody:bee,noNodeFiles:kee,selectNodeFile:vee,binaryFile:See,fileTruncated:jee,noNodeUsage:Nee,myNodeManagement:Cee,deleteMyNode:_ee,deletingMyNode:Eee,deleteMyNodeHint:Aee,deleteMyNodeConfirm:Pee,deleteMyNodeSuccess:Iee,deleteMyNodeUsedBy:Ree,myFlowManagement:Tee,deleteMyFlow:Mee,deletingMyFlow:$ee,deleteMyFlowHint:Lee,deleteMyFlowConfirm:Oee,deleteMyFlowSuccess:Dee,noSlots:Fee,resourceMeaning:zee,nodesMeaning:Bee,myFlowsMeaning:Hee,flowSnippetScale:Wee,flowSnippetPreview:Vee,flowSnippetEdges:Kee,flowSnippetJson:qee,flowSnippetMoreEdges:Uee,noFlowSnippetPreview:Yee,skillsMeaning:Gee,skillPreview:Jee,skillPreviewEmpty:Xee,selectResource:Qee,loadFailed:Zee,noPipelines:ete,emptyHint:tte,noMatch:nte,recentActivity:rte,noRecentActivity:ste,noMatchRecent:ite,recentRun:ote,recentOpen:ate,sourceBadge:lte,resourceSource:cte,resourceFilter:ute,nodeDetailTabs:dte,defaultCardDesc:fte,hubCard:pte,newPipelineModal:hte,importModal:mte,deleteModal:gte,archiveModal:yte},xte="Back",bte="Next",kte="Skip",vte="Done",Ste="Start Creating",jte={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.`},Nte={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.`},Cte={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"},_te={back:xte,next:bte,skip:kte,done:vte,startCreate:Ste,projects:jte,flow:Nte,newPipeline:Cte},Ete={name:"AgentFlow",tagline:"AI 工作流编排"},Ate={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},Pte={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},Ite={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},Rte={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},Tte={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},Mte={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},$te={app:Ete,nav:Ate,common:Pte,status:Ite,nodeTypes:Rte,engine:Tte,links:Mte},Lte="流程编辑器",Ote="节点",Dte="连线",Fte="属性",zte={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:"编辑内容"},Bte={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}}"},Hte={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},Wte={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},Vte={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},Kte={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},qte={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},Ute={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},Yte={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},Gte={node:"节点",text:"文本",file:"文件",bool:"布尔"},Jte={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:"等待"},Xte={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},Qte={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},Zte={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},ene={mainNav:"主导航"},tne={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},nne={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:"停止后台运行"},sne={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},ine={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}} 的分支"},one={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},ane={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:"已复制"},lne={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:"定时配置已保存"},cne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},une={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},dne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},fne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},pne={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 槽位添加条目。"},mne={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},gne={save:"保存",cancel:"取消"},yne={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},wne={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},xne={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},bne={title:Lte,nodes:Ote,edges:Dte,properties:Fte,node:zte,nodeProps:Bte,actions:Hte,panel:Wte,palette:Vte,pipeline:Kte,status:qte,roles:Ute,phases:Yte,types:Gte,runContext:Jte,shortcuts:Xte,jumpPalette:Qte,emptyCanvas:Zte,sidebar:ene,validation:tne,composer:nne,topbar:rne,palette2:sne,run:ine,fileEdit:one,settings:ane,schedule:lne,history:cne,nodePropsError:une,placeholder:dne,time:fne,userCheck:pne,userAsk:hne,toolPrint:mne,provideEdit:gne,runParams:yne,runPreset:wne,runConfig:xne},kne="设置",vne={engine:"引擎设置",preferences:"全局首选项"},Sne={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},jne={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},Nne={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},Cne={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},_ne={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},Ene={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},Ane={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:"添加"},Pne={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},Ine={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},Rne={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},Tne={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},Mne={title:kne,crumb:vne,workspace:Sne,cursor:jne,opencode:Nne,claudeCode:Cne,codex:_ne,env:Ene,allowlist:Ane,system:Pne,shortcuts:Ine,language:Rne,onboarding:Tne},$ne={thinking:"思考",result:"结果",reply:"回复",error:"错误"},Lne={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},One={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},Dne={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},Fne={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},zne={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Bne={aiLabels:$ne,placeholders:Lne,actions:One,labels:Dne,tooltips:Fne,rightPanel:zne},Hne="项目",Wne="全部",Vne="已归档",Kne="Nodes",qne="我的 Nodes",Une="我的流程",Yne="Skills",Gne="活跃项目",Jne="已归档流水线",Xne="全局 Nodes",Qne="全部 Nodes",Zne="我的 Nodes",ere="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",tre="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",nre="全局 Skills",rre="创建新项目",sre="新建流水线",ire="搜索流水线…",ore="搜索 nodes…",are="搜索流程片段…",lre="搜索 skills…",cre="刷新资源",ure="加载流水线列表…",dre="加载全局资源…",fre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",pre="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",hre="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",mre="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",gre="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",yre="流程运行时的可执行积木",wre="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",xre="已发布的本地节点包",bre="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",kre="已发布的流程片段",vre="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",Sre="Composer/Agent 的操作指南",jre="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",Nre="暂无归档项目。",Cre="暂无未归档流水线;已归档项在 Archived 标签中查看。",_re="暂无可用全局 nodes。",Ere="暂无已发布的 marketplace nodes。",Are="暂无已发布的流程片段。可在画布中选中多个节点后发布。",Pre="暂无可用 skills。",Ire="暂无描述。",Rre="未找到与「{{query}}」匹配的 node。",Tre="未找到与「{{query}}」匹配的流程片段。",Mre="未找到与「{{query}}」匹配的 skill。",$re="{{inputs}} in / {{outputs}} out",Lre="流程片段",Ore="{{nodes}} 节点 / {{edges}} 连线",Dre="Skill",Fre="Node 详情",zre="流程片段详情",Bre="Skill 详情",Hre="类型",Wre="来源",Vre="包",Kre="版本",qre="路径",Ure="可编辑",Yre="只读",Gre="可编辑",Jre="Schema",Xre="输入",Qre="输出",Zre="Runtime",ese="节点内容",tse="Files",nse="Usage",rse="暂无 runtime manifest。",sse="暂无节点正文或 README。",ise="暂无可预览文件。",ose="请选择文件查看内容。",ase="二进制文件暂不支持预览。",lse="文件较大,仅显示前 256KB。",cse="暂未发现使用此 node 的流水线。",use="节点管理",dse="删除节点版本",fse="删除中…",pse="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",hse="确定删除 {{id}}@{{version}}?此操作不可撤销。",mse="已删除 {{id}}@{{version}}。",gse="仍有 {{count}} 个 Flow 使用它。",yse="流程片段管理",wse="删除流程片段",xse="删除中…",bse="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",kse="确定删除 {{id}}@{{version}}?此操作不可撤销。",vse="已删除 {{id}}@{{version}}。",Sse="无槽位",jse="作用",Nse="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",Cse="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",_se="规模",Ese="流程预览",Ase="连线",Pse="片段 JSON",Ise="还有 {{count}} 条连线",Rse="暂无可预览节点。",Tse="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Mse="SKILL.md 预览",$se="暂无可预览内容。",Lse="请选择一个资源查看详情。",Ose="未能加载流水线列表。",Dse="当前工作区暂无流水线。",Fse="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",zse="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Bse="最近打开或最近运行",Hse="暂无打开或运行记录",Wse="暂无与关键词匹配的最近记录",Vse="最近运行",Kse="最近打开",qse={builtin:"内置",workspace:"工作区",user:"用户"},Use={flow:"Flow",global:"Global",marketplace:"Marketplace"},Yse={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Gse={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Jse="打开以在节点画布中编辑此流水线。",Xse={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Qse={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:"关闭"},Zse={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:"关闭"},tie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},nie={title:Hne,all:Wne,archived:Vne,nodes:Kne,myNodes:qne,myFlows:Une,skills:Yne,activeProjects:Gne,archivedPipelines:Jne,globalNodes:Xne,nodeScopeAll:Qne,nodeScopeMine:Zne,myNodesHint:ere,myFlowsHint:tre,globalSkills:nre,createNew:rre,newPipeline:sre,searchPipelines:ire,searchNodes:ore,searchFlows:are,searchSkills:lre,refreshResources:cre,loadingPipelines:ure,loadingResources:dre,filterResult:fre,archivedHint:pre,activeHint:hre,nodesHint:mre,skillsHint:gre,nodesPurposeTitle:yre,nodesPurposeDesc:wre,myNodesPurposeTitle:xre,myNodesPurposeDesc:bre,myFlowsPurposeTitle:kre,myFlowsPurposeDesc:vre,skillsPurposeTitle:Sre,skillsPurposeDesc:jre,noArchived:Nre,noActive:Cre,noNodes:_re,noMyNodes:Ere,noMyFlows:Are,noSkills:Pre,noDescription:Ire,noNodeMatch:Rre,noFlowSnippetMatch:Tre,noSkillMatch:Mre,nodeSlots:$re,flowSnippet:Lre,flowSnippetNodes:Ore,skill:Dre,nodeDetail:Fre,flowDetail:zre,skillDetail:Bre,detailType:Hre,detailSource:Wre,detailPackage:Vre,detailVersion:Kre,detailPath:qre,detailEditable:Ure,readOnly:Yre,editable:Gre,nodeSchema:Jre,nodeInputs:Xre,nodeOutputs:Qre,nodeRuntime:Zre,nodeBody:ese,nodeFiles:tse,nodeUsage:nse,noRuntimeManifest:rse,noNodeBody:sse,noNodeFiles:ise,selectNodeFile:ose,binaryFile:ase,fileTruncated:lse,noNodeUsage:cse,myNodeManagement:use,deleteMyNode:dse,deletingMyNode:fse,deleteMyNodeHint:pse,deleteMyNodeConfirm:hse,deleteMyNodeSuccess:mse,deleteMyNodeUsedBy:gse,myFlowManagement:yse,deleteMyFlow:wse,deletingMyFlow:xse,deleteMyFlowHint:bse,deleteMyFlowConfirm:kse,deleteMyFlowSuccess:vse,noSlots:Sse,resourceMeaning:jse,nodesMeaning:Nse,myFlowsMeaning:Cse,flowSnippetScale:_se,flowSnippetPreview:Ese,flowSnippetEdges:Ase,flowSnippetJson:Pse,flowSnippetMoreEdges:Ise,noFlowSnippetPreview:Rse,skillsMeaning:Tse,skillPreview:Mse,skillPreviewEmpty:$se,selectResource:Lse,loadFailed:Ose,noPipelines:Dse,emptyHint:Fse,noMatch:zse,recentActivity:Bse,noRecentActivity:Hse,noMatchRecent:Wse,recentRun:Vse,recentOpen:Kse,sourceBadge:qse,resourceSource:Use,resourceFilter:Yse,nodeDetailTabs:Gse,defaultCardDesc:Jse,hubCard:Xse,newPipelineModal:Qse,importModal:Zse,deleteModal:eie,archiveModal:tie},rie="返回",sie="下一步",iie="跳过",oie="完成",aie="开始创建",lie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
303
+
304
+ 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
305
+
306
+ 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},cie={intro:`现在进入流程编辑器。
307
+
308
+ 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
309
+
310
+ 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
311
+
312
+ 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
313
+
314
+ 左侧节点面板可以自由拖拽、删除和调整连接。`},uie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},die={back:rie,next:sie,skip:iie,done:oie,startCreate:aie,projects:lie,flow:cie,newPipeline:uie},fie={en:{common:XX,flow:LQ,settings:JQ,composer:rZ,project:wte,onboarding:_te},zh:{common:$te,flow:bne,settings:Mne,composer:Bne,project:nie,onboarding:die}};xr.use(AM).use(AD).init({resources:fie,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 pie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function hie(e){return xr.changeLanguage(e)}const xb="agentflow-settings-opencode-plan-v1",Yu="CURSOR_API_KEYS",Gu="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",pw=new Set([Yu,Gu,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),PM=["cursor","opencode","claudeCode","codex"];function IM(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function bb(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function ka(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of PM)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(bb).filter(Boolean))]:[];return n}function Wi(e){if(!e||typeof e!="object")return IM();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 gc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function mie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ca(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()||gc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function h_(e){return Ca(e).map(({key:t,value:n})=>({key:t,value:n}))}function m_(){try{return localStorage.getItem(xb)??""}catch{return""}}function RM(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function gie(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()||gc(),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 g_(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||gc(),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 yie(e){const t=String(e||"").trim();return t?t.length<=10?RM(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function wie(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 xie({authUser:e}){const{t,i18n:n}=zr(["common","settings"]),r=n.language||"zh",[s,o]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[d,f]=m.useState(IM()),[p,h]=m.useState(()=>ka({})),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),[j,N]=m.useState(!1),[C,I]=m.useState(!1),[R,H]=m.useState(""),[A,L]=m.useState([]),[D,O]=m.useState(""),[M,K]=m.useState(!1),[z,F]=m.useState(""),[$,W]=m.useState(""),[E,Q]=m.useState(!1),[V,B]=m.useState(()=>new Set),[se,ue]=m.useState(""),[G,ee]=m.useState(""),[te,ne]=m.useState(!!(e!=null&&e.isAdmin)),[Z,ce]=m.useState(""),[de,me]=m.useState([]),[$e,Ce]=m.useState([]),[_e,Be]=m.useState(""),[ot,gt]=m.useState(""),[Te,st]=m.useState(!1),[mt,Rt]=m.useState(!1),[xe,Oe]=m.useState(""),[ie,ke]=m.useState(""),[Ke,Ue]=m.useState(""),[be,Pt]=m.useState(null),[tn,Wt]=m.useState(!1),[Lt,an]=m.useState(!1),[re,Re]=m.useState(""),Je=m.useRef(null),Ze=m.useRef(!1),Tt=m.useRef(!1),_t=m.useRef(""),Kn=m.useCallback(async()=>{l("");try{const oe=await fetch("/api/ui-context");if(!oe.ok)throw new Error("HTTP "+oe.status);const Se=await oe.json();o(typeof Se.workspaceRoot=="string"?Se.workspaceRoot:"")}catch(oe){l(String(oe.message||oe)),o("")}},[]),jn=m.useCallback(async()=>{x(""),N(!0),g("");try{const oe=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!oe.ok)throw new Error("HTTP "+oe.status);const Se=await oe.json();if(e!=null&&e.isAdmin)u(Wi(Se.modelLists)),f(Wi(Se.allModelLists)),h(ka(Se.hiddenModels));else{const Pe=Wi(Se);u(Pe),f(Pe),h(ka({}))}}catch(oe){x(String(oe.message||oe))}finally{N(!1)}},[e==null?void 0:e.isAdmin]),br=m.useCallback(async()=>{O("");try{const oe=await fetch("/api/user-env"),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Ca(Array.isArray(Se.env)?Se.env:[],"user").map(Ut=>({...Ut,scope:"user"})),Ot=[...e!=null&&e.isAdmin?Ca(Array.isArray(Se.globalEnv)?Se.globalEnv:[],"global").map(Ut=>({...Ut,scope:"global"})):[],...Pe];_t.current=JSON.stringify(Ot),L(Ot)}catch(oe){L([]),O(String(oe.message||oe))}finally{Tt.current=!0}},[e==null?void 0:e.isAdmin]),xn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){st(!0),Oe("");try{const oe=await fetch("/api/admin/user-allowlist"),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Se.allowlist&&typeof Se.allowlist=="object"?Se.allowlist:{};me(Array.isArray(Pe.fileUsers)?Pe.fileUsers.map(String):[]),Ce(Array.isArray(Pe.envUsers)?Pe.envUsers.map(String):[]),Be(typeof Pe.path=="string"?Pe.path:"")}catch(oe){Oe(String(oe.message||oe))}finally{st(!1)}}},[e==null?void 0:e.isAdmin]),Qn=m.useCallback(async oe=>{if(e!=null&&e.isAdmin){Rt(!0),Oe("");try{const Se=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:oe})}),Pe=await Se.json().catch(()=>({}));if(!Se.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+Se.status);const wt=Pe.allowlist&&typeof Pe.allowlist=="object"?Pe.allowlist:{};me(Array.isArray(wt.fileUsers)?wt.fileUsers.map(String):[]),Ce(Array.isArray(wt.envUsers)?wt.envUsers.map(String):[]),Be(typeof wt.path=="string"?wt.path:"")}catch(Se){Oe(String(Se.message||Se))}finally{Rt(!1)}}},[e==null?void 0:e.isAdmin]),qn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Wt(!0),Re("");try{const oe=await fetch("/api/admin/storage-config"),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Se.config&&typeof Se.config=="object"?Se.config:{};Pt(Pe),ke(typeof Pe.dataRoot=="string"?Pe.dataRoot:""),Ue(typeof Pe.skillsRoot=="string"?Pe.skillsRoot:"")}catch(oe){Re(String(oe.message||oe))}finally{Wt(!1)}}},[e==null?void 0:e.isAdmin]),mr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){an(!0),Re("");try{const oe=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:ie.trim(),skillsRoot:Ke.trim(),migrateLegacySkills:!0})}),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Se.config&&typeof Se.config=="object"?Se.config:{};Pt(Pe),ke(typeof Pe.dataRoot=="string"?Pe.dataRoot:""),Ue(typeof Pe.skillsRoot=="string"?Pe.skillsRoot:"")}catch(oe){Re(String(oe.message||oe))}finally{an(!1)}}},[e==null?void 0:e.isAdmin,ie,Ke]),ts=m.useCallback(async oe=>{const Se=Ca(oe),Pe=Se.filter(Ot=>Ot.scope!=="global"),wt=Se.filter(Ot=>Ot.scope==="global");K(!0),O("");try{const Ot=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:h_(Pe),...e!=null&&e.isAdmin?{globalEnv:h_(wt)}:{}})}),Ut=await Ot.json().catch(()=>({}));if(!Ot.ok)throw new Error(typeof Ut.error=="string"?Ut.error:"HTTP "+Ot.status);const Bn=Ca(Array.isArray(Ut.env)?Ut.env:[],"user").map(he=>({...he,scope:"user"})),q=[...e!=null&&e.isAdmin?Ca(Array.isArray(Ut.globalEnv)?Ut.globalEnv:[],"global").map(he=>({...he,scope:"global"})):[],...Bn];_t.current=JSON.stringify(q),L(q)}catch(Ot){O(String(Ot.message||Ot))}finally{K(!1)}},[e==null?void 0:e.isAdmin]),Pr=m.useCallback(async()=>{x(""),N(!0);try{const oe=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z.trim()})}),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);u(Wi(Se.modelLists)),e!=null&&e.isAdmin?await jn():f(Wi(Se.modelLists))}catch(oe){x(String(oe.message||oe))}finally{N(!1)}},[e==null?void 0:e.isAdmin,jn,Z]),gs=m.useCallback(async oe=>{if(!(e!=null&&e.isAdmin))return;const Se=ka(oe);h(Se),v(!0),g("");try{const Pe=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:Se})}),wt=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof wt.error=="string"?wt.error:"HTTP "+Pe.status);u(Wi(wt.modelLists)),f(Wi(wt.allModelLists)),h(ka(wt.hiddenModels))}catch(Pe){g(String(Pe.message||Pe)),jn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,jn]),ys=m.useCallback((oe,Se,Pe)=>{const wt=PM.includes(oe)?oe:"cursor",Ot=bb(Se);if(!Ot)return;const Ut=ka(p),Bn=new Set(Ut[wt]);Pe?Bn.delete(Ot):Bn.add(Ot),gs({...Ut,[wt]:Array.from(Bn)})},[p,gs]);m.useEffect(()=>{br(),e!=null&&e.isAdmin?(Kn(),jn(),xn(),qn(),(async()=>{try{const oe=await fetch("/api/agentflow-config");if(oe.ok){const Se=await oe.json(),Pe=typeof Se.opencodeProvider=="string"?Se.opencodeProvider:"";ce(Pe),Je.current=Pe;try{localStorage.setItem(xb,Pe)}catch{}}else{const Se=m_();ce(Se),Je.current=Se}}catch{const oe=m_();ce(oe),Je.current=oe}finally{Ze.current=!0}})()):(o(""),Ze.current=!1)},[e==null?void 0:e.isAdmin,Kn,jn,qn,xn,br]),m.useEffect(()=>{if(!Tt.current||JSON.stringify(Ca(A))===_t.current)return;const Se=setTimeout(()=>{ts(A)},350);return()=>clearTimeout(Se)},[A,ts]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!Ze.current)return;const oe=Z.trim();if(oe===Je.current)return;const Se=setTimeout(()=>{(async()=>{I(!0),H("");try{const Pe=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:oe})}),wt=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof wt.error=="string"?wt.error:"HTTP "+Pe.status);Je.current=oe;try{localStorage.setItem(xb,oe)}catch{}wt.modelLists&&(u(Wi(wt.modelLists)),e!=null&&e.isAdmin?jn():f(Wi(wt.modelLists)))}catch(Pe){H(String(Pe.message||Pe))}finally{I(!1)}})()},450);return()=>clearTimeout(Se)},[e==null?void 0:e.isAdmin,jn,Z]);const dn=e!=null&&e.isAdmin?d:c,sr=dn.cursor.length>0,Ir=dn.opencode.length>0,pn=dn.claudeCode.length>0,Zn=dn.codex.length>0,kr=ka(p),ir={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},jt=m.useCallback((oe,Se,Pe)=>{const wt=Array.isArray(Se)?Se:[];if(!(e!=null&&e.isAdmin))return i.jsx("pre",{className:"af-set-model-preview","aria-label":Pe,children:wt.join(`
315
+ `)});const Ot=new Set(kr[oe]||[]);return i.jsxs("div",{className:"af-set-model-visibility","aria-label":Pe,children:[i.jsxs("div",{className:"af-set-model-visibility-head",children:[i.jsxs("span",{children:["展示 ",ir[oe]||0," / ",wt.length]}),i.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),i.jsx("div",{className:"af-set-model-visibility-list",children:wt.map(Ut=>{const Bn=bb(Ut),Dn=!Ot.has(Bn);return i.jsxs("label",{className:"af-set-model-visibility-row",children:[i.jsx("input",{type:"checkbox",checked:Dn,disabled:y,onChange:q=>ys(oe,Ut,q.target.checked)}),i.jsx("span",{children:Ut})]},`${oe}-${Ut}`)})})]})},[e==null?void 0:e.isAdmin,kr,y,ir,ys]),Jt=de.length>0||$e.length>0,Nt=e!=null&&e.isAdmin?A:A.filter(oe=>!pw.has(String((oe==null?void 0:oe.key)||"").trim())),le=e!=null&&e.isAdmin&&te?"global":"user",ve=m.useMemo(()=>A.find(oe=>oe.key===Yu&&(oe.scope||"user")===le)||null,[le,A]),it=m.useMemo(()=>gie((ve==null?void 0:ve.value)||""),[ve==null?void 0:ve.value]),Ft=m.useMemo(()=>A.find(oe=>oe.key===Gu&&(oe.scope||"user")===le)||null,[le,A]),Xt=Ft!=null&&Ft.value?String(Ft.value):"30",nn=m.useCallback((oe,Se,Pe)=>{const wt=String(oe||"").trim();if(!wt)return;const Ot=String(Se??"");L(Ut=>{const Bn=Ut.find(Dn=>Dn.key===wt&&(Dn.scope||"user")===Pe);return Ot?Bn?Ut.map(Dn=>Dn.id===Bn.id?{...Dn,value:Ot,scope:Pe}:Dn):[{id:gc(),key:wt,value:Ot,scope:Pe},...Ut]:Ut.filter(Dn=>!(Dn.key===wt&&(Dn.scope||"user")===Pe))})},[]),er=m.useCallback(()=>{const oe=G.trim();if(!oe)return;const Se=[...it,{id:gc(),name:se.trim()||`Key ${it.length+1}`,key:oe,createdAt:new Date().toISOString()}];nn(Yu,g_(Se),le),ue(""),ee("")},[se,it,le,G,nn]),ht=m.useCallback(oe=>{const Se=it.filter(Pe=>Pe.id!==oe);nn(Yu,Se.length?g_(Se):"",le)},[it,le,nn]),rn=m.useCallback(oe=>{const Se=String(oe||"").replace(/[^\d]/g,"");if(!Se){nn(Gu,"",le);return}const Pe=Math.min(1440,Math.max(1,Number(Se)||30));nn(Gu,String(Pe),le)},[le,nn]),Vt=m.useCallback(()=>{var oe;s&&((oe=navigator.clipboard)==null||oe.writeText(s))},[s]),vr=m.useCallback(()=>{const oe=z.trim(),Se=$;if(oe){if(!mie(oe)){O(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&pw.has(oe)){O("该运行基础设施变量仅管理员可配置。");return}L(Pe=>[{id:gc(),key:oe,value:Se,scope:e!=null&&e.isAdmin&&E?"global":"user"},...Pe]),F(""),W("")}},[e==null?void 0:e.isAdmin,E,z,$,t]),tt=m.useCallback(oe=>{L(Se=>Se.filter(Pe=>Pe.id!==oe))},[]),On=m.useCallback((oe,Se)=>{const Pe=String((Se==null?void 0:Se.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Pe&&pw.has(Pe)){O("该运行基础设施变量仅管理员可配置。");return}L(wt=>wt.map(Ot=>Ot.id===oe?{...Ot,...Se}:Ot))},[e==null?void 0:e.isAdmin]),$i=m.useCallback(oe=>{B(Se=>{const Pe=new Set(Se);return Pe.has(oe)?Pe.delete(oe):Pe.add(oe),Pe})},[]),Br=m.useCallback(()=>{const oe=ot.trim();if(!oe)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(oe)){Oe("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Pe=>String(Pe||"").trim().toLowerCase())).has(oe.toLowerCase())){gt("");return}gt(""),Qn([...de,oe])},[ot,de,Qn]),go=m.useCallback(oe=>{const Se=String(oe||"").trim().toLowerCase();Se&&Qn(de.filter(Pe=>String(Pe||"").trim().toLowerCase()!==Se))},[de,Qn]),ai=m.useCallback(oe=>{const Se=oe.target.value;hie(Se)},[]),Ms=oe=>{const Se=wie(oe,r);return Se?t("settings:cursor.modelList.fetchedAt",{time:Se}):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,re?i.jsx("p",{className:"af-err af-settings-api-hint",children:re}):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:Vt,"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"+(sr?" af-set-badge--ok":" af-set-badge--muted"),children:t(sr?"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:sr?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(sr?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:sr?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${dn.cursor.length}`:"")+" · "+Ms(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),sr?jt("cursor",dn.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:()=>Pr(),disabled:j,children:t(j?"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"+(it.length?" af-set-badge--ok":" af-set-badge--muted"),children:[it.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:te?"":"is-active",onClick:()=>ne(!1),children:"个人"}),i.jsx("button",{type:"button",className:te?"is-active":"",onClick:()=>ne(!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:Xt,onChange:oe=>rn(oe.target.value)}),i.jsx("span",{children:"分钟"})]}),i.jsx("span",{className:"af-set-env-note",children:M?"保存中":le==="global"?"全局配置":"个人配置"})]}),i.jsx("div",{className:"af-set-cursor-key-list",children:it.length?it.map(oe=>i.jsxs("div",{className:"af-set-cursor-key-row",children:[i.jsxs("div",{className:"af-set-cursor-key-main",children:[i.jsx("strong",{children:oe.name}),i.jsx("code",{children:yie(oe.key)})]}),i.jsx("span",{className:"af-set-cursor-key-meta",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"历史 Key"}),i.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${oe.name}`,onClick:()=>ht(oe.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe.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:se,onChange:oe=>ue(oe.target.value),placeholder:"名称,例如 Team Key 1"}),i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:G,onChange:oe=>ee(oe.target.value),placeholder:"Cursor API Key"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:er,disabled:!G.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",Yu,";冷却时间保存到 ",Gu,"。个人配置会覆盖全局配置。"]})]}),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"+(Ir?" af-set-badge--ok":" af-set-badge--err"),children:t(Ir?"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:Z,onChange:oe=>ce(oe.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),C?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]}),Ir?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?` / ${dn.opencode.length}`:"")+" · "+Ms(c.opencodeFetchedAt)}),jt("opencode",dn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"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"+(pn?" af-set-badge--ok":" af-set-badge--err"),children:t(pn?"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:pn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(pn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:pn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${dn.claudeCode.length}`:"")+" · "+Ms(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),pn?jt("claudeCode",dn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"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"+(Zn?" af-set-badge--ok":" af-set-badge--err"),children:t(Zn?"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:Zn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Zn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Zn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${dn.codex.length}`:"")+" · "+Ms(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Zn?jt("codex",dn.codex,t("settings:codex.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"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:z,onChange:oe=>F(oe.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:E?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:E?"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:oe=>W(oe.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:vr,disabled:!z.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),Nt.map(oe=>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:oe.key,onChange:Se=>On(oe.id,{key:Se.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:oe.scope!=="global"?"is-active":"",onClick:()=>On(oe.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:oe.scope==="global"?"is-active":"",onClick:()=>On(oe.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:V.has(oe.id)?"text":"password",value:oe.value,onChange:Se=>On(oe.id,{value:Se.target.value}),placeholder:RM(oe.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>$i(oe.id),"aria-label":V.has(oe.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:V.has(oe.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:oe.key}),onClick:()=>tt(oe.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},oe.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"+(be!=null&&be.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:be!=null&&be.envLocked?"Env locked":"Configurable"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void qn(),disabled:tn||Lt,children:tn?"刷新中...":"刷新"})]}),re?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:re}):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:ie,onChange:oe=>ke(oe.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(be!=null&&be.envLocked)||Lt}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void mr(),"aria-label":"保存 AgentFlow Data Root",disabled:Lt||!!(be!=null&&be.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:Lt?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(be==null?void 0:be.dataRoot)||ie||"-"}),be!=null&&be.configPath?i.jsxs(i.Fragment,{children:[";配置文件:",i.jsx("code",{children:be.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 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",be!=null&&be.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:Ke,onChange:oe=>Ue(oe.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(be!=null&&be.skillsEnvLocked)||Lt}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void mr(),"aria-label":"保存 AgentFlow Skills Root",disabled:Lt||!!(be!=null&&be.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:Lt?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",i.jsx("code",{children:(be==null?void 0:be.skillsRoot)||Ke||"-"}),be!=null&&be.legacySkillsRootExists?i.jsxs(i.Fragment,{children:[";保存时会补迁移旧目录 ",i.jsx("code",{children:be.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),i.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",be!=null&&be.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"+(Jt?" af-set-badge--ok":" af-set-badge--muted"),children:t(Jt?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void xn(),disabled:Te,children:t(Te?"settings:allowlist.refreshing":"common:common.refresh")})]}),xe?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:xe}):null,_e?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",i.jsx("code",{children:_e})]}):null,i.jsxs("div",{className:"af-allowlist-grid",children:[i.jsxs("div",{className:"af-allowlist-main",children:[i.jsxs("div",{className:"af-allowlist-head",children:[i.jsx("span",{children:t("settings:allowlist.fileList")}),i.jsx("span",{children:mt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:de.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:de.length>0?de.map(oe=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:oe}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>go(oe),"aria-label":t("settings:allowlist.remove",{username:oe}),disabled:mt,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe)):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:ot,onChange:oe=>gt(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&Br()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Br,disabled:mt||!ot.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:$e.length>0?$e.map(oe=>i.jsx("code",{children:oe},oe)):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:ai,"aria-label":t("settings:language.description"),children:pie.map(oe=>i.jsxs("option",{value:oe.code,children:[oe.flag," ",oe.name]},oe.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function bie(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 kie(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function vie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function Sie({run:e,onClose:t}){const[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState("timeline"),d=m.useCallback(async({quiet:v=!1}={})=>{if(e!=null&&e.runId){v||o(!0),l("");try{const b=new URLSearchParams({runType:e.runType||"pipeline",userId:e.userId||"",flowId:e.flowId||"",flowSource:e.flowSource||"user",runId:e.runId}),g=await fetch(`/api/admin/run-detail?${b.toString()}`),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||`HTTP ${g.status}`);r(k)}catch(b){l(String((b==null?void 0:b.message)||b))}finally{v||o(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,e==null?void 0:e.runId,e==null?void 0:e.runType,e==null?void 0:e.userId]);m.useEffect(()=>{r(null),u("timeline"),d()},[d]),m.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=m.useMemo(()=>f.filter(v=>(v==null?void 0:v.kind)==="thinking"),[f]),h=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?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"," · ",vie(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:h.length})]})]}),n!=null&&n.truncated?i.jsx("div",{className:"af-admin-run-detail__notice",children:"日志较大,当前展示最新的 512 KB / 2000 条记录。"}):null,a?i.jsx("div",{className:"af-admin-run-detail__error",children:a}):null,s&&!n?i.jsx("div",{className:"af-admin-run-detail__empty",children:"正在读取 Run 详情..."}):null,i.jsx("div",{className:"af-admin-run-detail__body",children:c==="raw"?h.length>0?i.jsx("pre",{className:"af-admin-run-detail__raw",children:h.join(`
316
+ `)}):i.jsx("div",{className:"af-admin-run-detail__empty",children:"这个 Run 没有原始日志。"}):y.length>0?i.jsx("div",{className:"af-admin-run-detail__timeline",children:y.map((v,b)=>i.jsxs("article",{className:`af-admin-run-detail__event is-${v.kind||"process"}`,children:[i.jsxs("div",{className:"af-admin-run-detail__event-meta",children:[i.jsx("time",{children:bie(v.ts)}),i.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:kie(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 Mr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function Hp(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function hw(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 jie(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function mw(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 Nie(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function Cie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function _ie({authUser:e}){const{navigate:t}=Ts(),[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(null),[d,f]=m.useState(null),[p,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=m.useCallback(async()=>{if(e!=null&&e.isAdmin){o(!0),l("");try{const A=await fetch("/api/admin/usage-dashboard"),L=await A.json().catch(()=>({}));if(!A.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+A.status);r(L)}catch(A){r(null),l(String((A==null?void 0:A.message)||A))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),x=m.useCallback(async A=>{const L=String((A==null?void 0:A.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!L)){f({userId:L,username:String((A==null?void 0:A.username)||L)}),h([]),g(""),v(!0);try{const D=new URLSearchParams({userId:L}),O=await fetch(`/api/admin/user-workspaces?${D.toString()}`),M=await O.json().catch(()=>({}));if(!O.ok)throw new Error(M.error||"读取用户 Workspace 失败");f(M.owner||{userId:L,username:String((A==null?void 0:A.username)||L)}),h(Array.isArray(M.workspaces)?M.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),j=m.useCallback(A=>{const L=String((A==null?void 0:A.ownerUserId)||(d==null?void 0:d.userId)||"").trim(),D=String((A==null?void 0:A.id)||"").trim();if(!L||!D)return;const O=new URLSearchParams({flowId:D,flowSource:"user",adminOwnerId:L});A!=null&&A.archived&&O.set("archived","1"),t(`/workspace?${O.toString()}`)},[t,d==null?void 0:d.userId]);m.useEffect(()=>{k()},[k]);const N=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],C=m.useMemo(()=>{const D={top:20,right:24,bottom:42,left:42},O=980-D.left-D.right,M=250-D.top-D.bottom,K=N.length>0?N:[],z=Math.max(1,...K.map(V=>Number(V.runs||0))),F=Math.max(1,...K.flatMap(V=>[Number(V.users||0),Number(V.pipelines||0)])),$=V=>D.left+(K.length<=1?O/2:V*O/(K.length-1)),W=V=>D.top+M-Math.max(0,Number(V||0))/z*M,E=V=>D.top+M-Math.max(0,Number(V||0))/F*M,Q=V=>K.map((B,se)=>`${se===0?"M":"L"} ${$(se)} ${E(B[V])}`).join(" ");return{width:980,height:250,margin:D,innerHeight:M,rows:K,x:$,yRuns:W,yLine:E,lineUsers:Q("users"),linePipelines:Q("pipelines"),barWidth:Math.min(34,Math.max(12,O/Math.max(1,K.length)*.44))}},[N]),I=(n==null?void 0:n.usage)||{},R=(n==null?void 0:n.totals)||{},H=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:Hp(I.activeUserRate)}),i.jsxs("em",{children:[Mr(I.activeUsers)," / ",Mr(R.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:Hp(I.activePipelineRate)}),i.jsxs("em",{children:[Mr(I.activePipelines)," / ",Mr(R.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Mr(I.runs)}),i.jsxs("em",{children:[Mr(I.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:Hp(I.successRate)}),i.jsxs("em",{children:["失败率 ",Hp(I.failureRate)," · avg ",hw(I.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 ${C.width} ${C.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:C.margin.left,y1:C.margin.top+C.innerHeight,x2:C.width-C.margin.right,y2:C.margin.top+C.innerHeight}),[.25,.5,.75,1].map(A=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:C.margin.left,y1:C.margin.top+C.innerHeight-C.innerHeight*A,x2:C.width-C.margin.right,y2:C.margin.top+C.innerHeight-C.innerHeight*A},A)),C.rows.map((A,L)=>{const D=C.x(L),O=C.yRuns(A.runs),M=C.margin.top+C.innerHeight,K=Math.max(2,M-O);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:D-C.barWidth/2,y:M-K,width:C.barWidth,height:K,rx:"5",children:i.jsx("title",{children:`${A.date}: ${A.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:D,y:M+22,children:Mr(A.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:D,y:M+42,children:jie(A.date)})]},A.date)}),C.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:C.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:C.linePipelines}),C.rows.map((A,L)=>{const D=C.x(L);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:D,cy:C.yLine(A.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:D,cy:C.yLine(A.pipelines),r:"3.5"})]},`${A.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:H.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):H.map(A=>i.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(A),onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),u(A))},children:[i.jsxs("td",{children:[i.jsx("strong",{children:A.username||A.userId||"-"}),i.jsx("span",{children:A.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:A.flowId||"-"}),i.jsxs("span",{children:[A.runType==="workspace"?"Workspace Run":"Pipeline"," · ",A.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:mw(A.at)}),A.endedAt?i.jsxs("span",{children:["结束 ",mw(A.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:Cie(A.status)})})}),i.jsx("td",{children:hw(A.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:A.runId,children:Nie(A.runId)}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${A.userId}:${A.flowSource}:${A.flowId}:${A.runId}:${A.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(A=>{var L,D,O,M,K,z,F,$,W,E,Q,V,B;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:A.username||A.userId}),i.jsxs("span",{children:[A.userId,A.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Mr((L=A.pipelines)==null?void 0:L.total)}),i.jsxs("span",{children:[Mr((D=A.pipelines)==null?void 0:D.active)," active / ",Mr((O=A.pipelines)==null?void 0:O.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Mr((M=A.runs)==null?void 0:M.total)}),i.jsxs("span",{children:["avg ",hw((K=A.runs)==null?void 0:K.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Mr((z=A.runs)==null?void 0:z.success)]}),i.jsxs("em",{children:["失败 ",Mr((F=A.runs)==null?void 0:F.failed)]}),i.jsxs("em",{children:["运行中 ",Mr(($=A.runs)==null?void 0:$.running)]})]})}),i.jsx("td",{children:(W=A.runs)!=null&&W.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((E=A.runs)==null?void 0:E.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((Q=A.runs)==null?void 0:Q.lastRunStatus)||"unknown"," · ",mw(A.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})}),i.jsx("td",{children:i.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((V=A.pipelines)!=null&&V.total)||y&&(d==null?void 0:d.userId)===A.userId,onClick:()=>void x(A),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(d==null?void 0:d.userId)===A.userId?"读取中":`查看 ${Mr((B=A.pipelines)==null?void 0:B.total)}`]})})]},A.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),h([]),g("")},children:"关闭"})]}),b?i.jsx("div",{className:"af-project-admin-usage__error",children:b}):null,i.jsx("div",{className:"af-admin-user-workspaces__grid",children:y?i.jsx("p",{children:"正在读取 Workspace..."}):p.length===0?i.jsx("p",{children:"该用户暂无 Workspace。"}):p.map(A=>i.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>j(A),children:[i.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:A.archived?"inventory_2":"account_tree"}),i.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[i.jsx("strong",{children:A.id}),i.jsx("small",{children:A.description||(A.archived?"已归档 Workspace":"用户 Workspace")})]}),i.jsx("span",{className:"af-admin-user-workspace-card__status",children:A.archived?"已归档":"只读打开"})]},`${A.id}:${A.archived?"archived":"active"}`))})]}):null,c?i.jsx(Sie,{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 Eie(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 Aie({authUser:e}){const{navigate:t}=Ts(),[n,r]=m.useState(""),[s,o]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(k){v(!0),g("");try{const N=await fetch("/api/feedback"),C=await N.json().catch(()=>({}));if(!N.ok)throw new Error(C.error||"加载失败");h(Array.isArray(C.feedback)?C.feedback:[])}catch(N){g(String(N.message||N)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{x()},[x]);const j=async N=>{if(N.preventDefault(),!a){l(!0),u("");try{const C=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),I=await C.json().catch(()=>({}));if(!C.ok)throw new Error(I.error||"提交失败");f(!0),r(""),o("")}catch(C){u(String(C.message||C))}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(N=>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:N.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:N.username||N.userId||"unknown"}),i.jsx("span",{children:Eie(N.createdAt)})]})]}),N.contact?i.jsx("span",{className:"af-feedback-item__contact",children:N.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:N.content}),N.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:N.pageUrl}):null]},N.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:j,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:n,onChange:N=>r(N.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:N=>o(N.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 TM(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function y_(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:TM(),key:r,value:String(s??""),private:n.has(r)}))}function w_(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 yh(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:y_(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:y_(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 gw(){return yh({name:"",raw:{command:""}})}function Pie(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=w_(e.envRows),s=w_(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 x_(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function b_(e){return e?e.ok?"ok":"error":"unknown"}function kb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function Iie(e,t){return e&&e.label||t}async function yw(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 bv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function MM({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:bv(t)}}}},null,2)}function $M({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(bv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
318
+ `)}function Rie({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=MM({baseUrl:n,token:t}),s=$M({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: ${bv(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 Tie({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--${kb(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:Iie(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 k_({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:TM(),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 Mie(){var ue;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState(gw),[a,l]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[j,N]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[C,I]=m.useState(""),[R,H]=m.useState(""),A=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),L=A&&y[A.name]||null,D=m.useMemo(()=>MM({baseUrl:j,token:C}),[j,C]),O=m.useMemo(()=>$M({baseUrl:j,token:C}),[j,C]),M=m.useMemo(()=>Rie({baseUrl:j,token:C}),[j,C]),K=m.useCallback(async()=>{u(!0),g("");try{const G=await fetch("/api/mcps"),ee=await G.json().catch(()=>({}));if(!G.ok)throw new Error(ee.error||"MCP HTTP "+G.status);const te=Array.isArray(ee.servers)?ee.servers:[];t(String(ee.path||"")),r(te),a&&te.some(ne=>ne.name===a)&&o(yh(te.find(ne=>ne.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{K()},[K]);const z=()=>{l(""),o(gw()),x(""),g("")},F=G=>{l(G.name),o(yh(G)),x(""),g("")},$=m.useCallback(async()=>{if(!M)return;const G=await yw(M);H(G?"prompt":"copy-failed"),window.setTimeout(()=>H(""),1200)},[M]),W=m.useCallback(async()=>{const G=await yw(D);H(G?"cursor":"copy-failed"),window.setTimeout(()=>H(""),1200)},[D]),E=m.useCallback(async()=>{const G=await yw(O);H(G?"codex":"copy-failed"),window.setTimeout(()=>H(""),1200)},[O]),Q=m.useCallback(async()=>{try{const G=await fetch("/api/auth/session-token"),ee=await G.json().catch(()=>({}));if(!G.ok)throw new Error(typeof ee.error=="string"?ee.error:"HTTP "+G.status);I(String(ee.token||"")),H("token"),window.setTimeout(()=>H(""),1200)}catch(G){H(""),g(String(G.message||G))}},[]),V=async(G="")=>{h(!0),g(""),x("");try{const ee=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G?{name:G}:{})}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||"检测 MCP 失败");const ne=Array.isArray(te.results)?te.results:[];v(Z=>{const ce={...Z};for(const de of ne)de!=null&&de.name&&(ce[de.name]=de);return ce}),x(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(ee){g(String(ee.message||ee))}finally{h(!1)}},B=async()=>{f(!0),g(""),x("");try{const G=Pie(s);if(!G.nextName)throw new Error("请填写 MCP 名称");const ee=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||"保存 MCP 失败");const ne=Array.isArray(te.servers)?te.servers:[];r(ne),t(String(te.path||e)),l(G.nextName),o(yh(ne.find(Z=>Z.name===G.nextName)||null)),v(Z=>{const ce={...Z};return s.originalName&&s.originalName!==G.nextName&&delete ce[s.originalName],delete ce[G.nextName],ce}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(G){g(String(G.message||G))}finally{f(!1)}},se=async G=>{if(G!=null&&G.name&&window.confirm(`删除 MCP "${G.name}"?`)){f(!0),g(""),x("");try{const ee=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name})}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||"删除 MCP 失败");r(Array.isArray(te.servers)?te.servers:[]),l(""),o(gw()),v(ne=>{const Z={...ne};return delete Z[G.name],Z}),x("已删除。")}catch(ee){g(String(ee.message||ee))}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:K,disabled:c||d,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V(),disabled:p||c||d||n.length===0,children:p?"检测中...":"检测状态"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,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:j,onChange:G=>N(G.target.value),placeholder:"http://127.0.0.1:8875"})]}),i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Token"}),i.jsxs("div",{className:"af-set-mcp-token-row",children:[i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:C,onChange:G=>I(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:R==="token"?"已填入":"使用当前登录 Token"})]})]})]}),i.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Cursor mcp.json"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:W,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:E,children:R==="codex"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:O})]})]}),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:z,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:z,disabled:d,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var ee,te,ne,Z;return i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===G.name?" af-mcp-server-item--active":""),onClick:()=>F(G),children:[i.jsx("span",{className:"material-symbols-outlined",children:G.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:G.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${b_(y[G.name])}`,children:x_(y[G.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${kb((te=(ee=G.backends)==null?void 0:ee.cursor)==null?void 0:te.status)}`,children:"Cursor"}),i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${kb((Z=(ne=G.backends)==null?void 0:ne.codex)==null?void 0:Z.status)}`,children:"Codex"})]}),i.jsx("em",{children:G.url||[G.command,...G.args||[]].filter(Boolean).join(" ")})]})]},G.name)})})]}),i.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:A?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),A?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V(A.name),disabled:p||d,children:p?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>se(A),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,A?i.jsx(Tie,{server:A}):null,L?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${b_(L)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:x_(L)}),i.jsxs("span",{children:[L.elapsedMs||0,"ms"]})]}),L.error?i.jsx("p",{children:L.error}):null,(ue=L.tools)!=null&&ue.length?i.jsx("div",{className:"af-mcp-tools-list",children:L.tools.map(G=>i.jsxs("div",{className:"af-mcp-tool-row",children:[i.jsx("strong",{children:G.name}),G.description?i.jsx("span",{children:G.description}):null]},G.name))}):null]}):null,i.jsxs("div",{className:"af-mcp-form",children:[i.jsxs("label",{className:"af-set-label",children:["MCP 名称",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:G=>o(ee=>({...ee,name:G.target.value})),placeholder:"github"})]}),i.jsxs("label",{className:"af-set-label",children:["类型",i.jsxs("select",{className:"af-set-input",value:s.type,onChange:G=>o(ee=>({...ee,type:G.target.value})),children:[i.jsx("option",{value:"url",children:"URL / HTTP"}),i.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:G=>o(ee=>({...ee,url:G.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"af-set-label",children:["Command",i.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:G=>o(ee=>({...ee,command:G.target.value})),placeholder:"uvx"})]}),i.jsxs("label",{className:"af-set-label",children:["Args,每行一个",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:G=>o(ee=>({...ee,argsText:G.target.value})),placeholder:`mcp-server-example
320
+ --flag`})]})]}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",i.jsx("input",{className:"af-set-input",value:s.description,onChange:G=>o(ee=>({...ee,description:G.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(k_,{title:"Headers",rows:s.headerRows,onChange:G=>o(ee=>({...ee,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(k_,{title:"Env",rows:s.envRows,onChange:G=>o(ee=>({...ee,envRows:G})),placeholderKey:"TOKEN",placeholderValue:"..."}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",i.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:G=>o(ee=>({...ee,extraJson:G.target.value}))})]})]}),i.jsxs("div",{className:"af-mcp-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:z,disabled:d,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:B,disabled:d,children:d?"保存中...":"保存 MCP"})]})]})]})]})})]})}function $ie(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 v_(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function S_(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 Lie(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function Oie(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 Die(){const{navigate:e}=Ts(),[t,n]=m.useState([]),[r,s]=m.useState(!1),[o,a]=m.useState(""),[l,c]=m.useState(""),u=m.useCallback(async()=>{s(!0),a("");try{const p=await fetch("/api/schedules"),h=await p.json().catch(()=>({}));if(!p.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(p){a(String(p.message||p)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`;c(h),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=m.useMemo(()=>{const p=t.filter(y=>y.enabled).length,h=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:p,workspace:h,pipeline:t.length-h}},[t]);return i.jsxs("div",{className:"af-settings-page af-schedules-page",children:[i.jsxs("div",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"定时任务"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"定时任务"}),i.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),i.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[i.jsxs("div",{children:[i.jsx("span",{children:"全部"}),i.jsx("strong",{children:f.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"启用中"}),i.jsx("strong",{children:f.enabled})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Workspace"}),i.jsx("strong",{children:f.workspace})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Pipeline"}),i.jsx("strong",{children:f.pipeline})]})]}),o?i.jsx("div",{className:"af-schedules-error",children:o}):null,r?i.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?i.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,i.jsx("div",{className:"af-schedules-list",children:t.map(p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`,y=l===h,v=$ie(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:Lie(p)}),i.jsx("span",{className:`af-schedule-state ${p.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:Oie(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:S_(p.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:S_(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:v_(p),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),v_(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?"已启用":"已停用"]})]})]},h)})})]})})]})}const j_={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 N_(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 Fie(e){var c,u,d,f,p,h,y,v,b,g,k,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((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(j=>[`input.${j.name||"-"}`,`${j.type||"text"}${j.required?" · required":""}${j.default?` · default: ${j.default}`:""}`]),...s.map(j=>[`output.${j.name||"-"}`,j.type||"text"]),...o.map(j=>[`config.${j.key||"-"}`,j.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",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(b=t.ui)==null?void 0:b.card)==null?void 0:g.icon)||"extension"],...a.map(j=>[`action.${j.id||j.label||"-"}`,j.variant||j.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([j,N])=>[`sample.${j}`,String(N)]),["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 zie(){var O,M,K,z,F,$,W;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,o]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState(""),y=e||j_,v=m.useMemo(()=>Fie(y),[y]),b=m.useMemo(()=>v.find(E=>E.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((O=y==null?void 0:y.test)==null?void 0:O.inputs)||{},j=Array.isArray((M=y==null?void 0:y.test)==null?void 0:M.log)?y.test.log:[],N=((z=(K=g.ui)==null?void 0:K.card)==null?void 0:z.icon)||"event_repeat",C=(($=(F=g.ui)==null?void 0:F.card)==null?void 0:$.variant)||"default",I=k.enabled===!0,R=m.useCallback(async()=>{var E;l(!0),u("");try{const Q=await fetch("/api/node-studio/drafts"),V=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(V.error||"读取节点草稿失败");const B=Array.isArray(V.drafts)?V.drafts[0]:null;if(!(B!=null&&B.id)){t(null),h("");return}const se=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(B.id)}`),ue=await se.json().catch(()=>({}));if(!se.ok)throw new Error(ue.error||"读取节点草稿失败");t(ue.draft||null),h(String(((E=ue.draft)==null?void 0:E.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);m.useEffect(()=>{R()},[R]);const H=m.useCallback(async(E={})=>{var Q;f(!0),u("");try{const V=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",...E})}),B=await V.json().catch(()=>({}));if(!V.ok||B.ok===!1)throw new Error(B.error||"保存节点草稿失败");t(B.draft||e),h(String(((Q=B.draft||e)==null?void 0:Q.promptDraft)||""))}catch(V){u(String(V.message||V))}finally{f(!1)}},[e]),A=()=>{o(!0),window.setTimeout(()=>o(!1),900)},L=E=>{const Q={...k,enabled:E};t(V=>({...V||j_,config:Q})),H({config:{enabled:E}})},D=()=>{H({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:A,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((E,Q)=>i.jsx("div",{className:E.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:E.text||""},`${E.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:E=>h(E.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?C==="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:N}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:N_(y)})]}),i.jsxs("label",{className:"af-node-preview-toggle",children:[i.jsx("input",{type:"checkbox",checked:I,onChange:E=>L(E.target.checked)}),i.jsx("span",{children:I?"定时开启":"定时关闭"})]}),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:E=>H({config:{scheduleType:E.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:E=>H({config:{hour:E.target.value}}),children:[i.jsx("option",{children:"09"}),i.jsx("option",{children:"10"})]}),i.jsxs("select",{value:k.minute||"00",onChange:E=>H({config:{minute:E.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:I?"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:N}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:N_(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:((W=g.runtime)==null?void 0:W.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:A,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..."]:j.length?j:["No test run yet."]).map((E,Q)=>i.jsx("span",{children:E},`${E}-${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(E=>i.jsxs("button",{type:"button",className:E.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(E.id),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:E.icon}),E.label]},E.id))}),i.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([E,Q])=>i.jsxs("div",{className:"af-node-studio-internal-row",children:[i.jsx("span",{children:E}),i.jsx("strong",{children:Q})]},E))}),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 Bie(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Hie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function wh(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 Wie(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 ww(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function Wp(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 Vie(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||wh(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 Vi(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 Kie({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function C_({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(Kie,{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 qie(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState(ww),[k,x]=m.useState(""),[j,N]=m.useState([]),[C,I]=m.useState(""),R=m.useMemo(()=>y.findIndex((V,B)=>Vi(V,B)===C),[y,C]),A=!!m.useMemo(()=>p.find((V,B)=>Vi(V,B)===C)||null,[p,C]),L=m.useMemo(()=>{const V=String(b.credentialRef||"").trim();return V?j.some(B=>String((B==null?void 0:B.key)||"").trim()===V&&String((B==null?void 0:B.value)??"")!==""):!1},[b.credentialRef,j]),D=m.useCallback(async()=>{t(!0),l("");try{const[V,B]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),se=await V.json().catch(()=>({})),ue=await B.json().catch(()=>({}));if(!B.ok)throw new Error(typeof ue.error=="string"?ue.error:"ENV HTTP "+B.status);if(!V.ok)throw new Error(typeof se.error=="string"?se.error:"HTTP "+V.status);const G=Array.isArray(se.workspaces)?se.workspaces:[],ee=Array.isArray(se.customWorkspaces)?se.customWorkspaces:[];f(String(se.path||"")),h(G.filter(te=>te==null?void 0:te.builtin)),v(ee),N(Array.isArray(ue.env)?ue.env.map(te=>({key:String((te==null?void 0:te.key)||""),value:String((te==null?void 0:te.value)??"")})):[])}catch(V){l(String(V.message||V))}finally{t(!1)}},[]);m.useEffect(()=>{D()},[D]);const O=m.useCallback(async(V,B="")=>{r(!0),l(""),u("");try{const se=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:V})}),ue=await se.json().catch(()=>({}));if(!se.ok)throw new Error(typeof ue.error=="string"?ue.error:"HTTP "+se.status);const G=Array.isArray(ue.customWorkspaces)?ue.customWorkspaces:V;v(G),h((Array.isArray(ue.workspaces)?ue.workspaces:[]).filter(ee=>ee==null?void 0:ee.builtin)),f(String(ue.path||d)),B&&I(B),u("已保存")}catch(se){l(String(se.message||se))}finally{r(!1)}},[d]),M=m.useCallback(()=>{I(""),g(ww()),x(""),u(""),l("")},[]),K=m.useCallback((V,B)=>{I(Vi(V,B)),g(Wp(V)),x(""),u("")},[]),z=m.useCallback((V,B)=>{I(Vi(V,B)),g(Wp(V)),x(""),u("")},[]),F=m.useCallback(async(V,B)=>{const se=String(V||"").trim(),ue=String(B??"");if(!se||!ue)return;const G=j.filter(ne=>String((ne==null?void 0:ne.key)||"").trim()!==se);G.push({key:se,value:ue});const ee=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G})}),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof te.error=="string"?te.error:"ENV HTTP "+ee.status);N(Array.isArray(te.env)?te.env.map(ne=>({key:String((ne==null?void 0:ne.key)||""),value:String((ne==null?void 0:ne.value)??"")})):G)},[j]),$=m.useCallback(()=>{const V=Vie({...b,id:b.id||Bie()}),B=k.trim();if(V.kind==="git"&&B&&!V.credentialRef&&(V.credentialRef=Wie(b,V)),V.kind==="local"&&!V.path){l("本地知识库需要填写路径");return}if(V.kind==="git"&&!V.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!V.label){l("请填写名称");return}if(V.kind==="git"&&V.credentialRef&&!Hie(V.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const se=R>=0?y.map((ue,G)=>G===R?V:ue):[V,...y];g(Wp(V)),(async()=>{r(!0);try{B&&await F(V.credentialRef,B),x(""),await O(se,Vi(V))}catch(ue){l(String(ue.message||ue)),r(!1)}})()},[y,b,O,F,R,k]),W=m.useCallback(()=>{if(R<0)return;const V=y.filter((B,se)=>se!==R);g(ww()),I(""),O(V)},[y,O,R]),E=m.useCallback(async()=>{if(!A){if(R<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}o(!0),l(""),u("");try{const V=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),B=await V.json().catch(()=>({}));if(!V.ok)throw new Error(typeof B.error=="string"?B.error:"HTTP "+V.status);const se=Array.isArray(B.customWorkspaces)?B.customWorkspaces:y;v(se),h((Array.isArray(B.workspaces)?B.workspaces:[]).filter(ee=>ee==null?void 0:ee.builtin));const ue=se.find(ee=>String((ee==null?void 0:ee.id)||"")===String(b.id||""));ue&&g(Wp(ue));const G=String(B.commit||"").trim();u(B.changed?`已拉取更新${G?`:${G.slice(0,8)}`:""}`:`已是最新${G?`:${G.slice(0,8)}`:""}`)}catch(V){l(String(V.message||V))}finally{o(!1)}}},[y,b,A,R]),Q=m.useCallback(V=>{g(B=>({...B,...V}))},[]);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(V=>V.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((V,B)=>i.jsx(C_,{item:V,selected:Vi(V,B)===C,onClick:()=>K(V,B)},Vi(V,B))):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((V,B)=>i.jsx(C_,{item:V,selected:Vi(V,B)===C,onClick:()=>z(V,B),readOnly:!0},Vi(V,B)))]}),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:A?"查看内置知识库":R>=0?"编辑知识库":"新增知识库"}),i.jsx("p",{children:A?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),i.jsxs("label",{className:"af-workspaces-switch",children:[i.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:A,onChange:V=>Q({enabled:V.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:A,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:A,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:A,onChange:V=>Q({label:V.target.value}),placeholder:"Likee Android"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"类型"}),i.jsxs("select",{value:b.type,disabled:A,onChange:V=>Q({type:V.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:A,onChange:V=>Q({path:V.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:A,onChange:V=>{const B=V.target.value,se=wh(b.repoUrl),ue=String(b.mountPath||"").trim();Q({repoUrl:B,...!ue||ue===se?{mountPath:wh(B)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"分支"}),i.jsx("input",{value:b.branch,disabled:A,onChange:V=>Q({branch:V.target.value}),placeholder:"master"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"挂载目录"}),i.jsx("input",{value:b.mountPath,disabled:A,onChange:V=>Q({mountPath:V.target.value}),placeholder:wh(b.repoUrl)||"repo_name"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"凭证环境变量"}),i.jsx("input",{value:b.credentialRef,disabled:A,onChange:V=>Q({credentialRef:V.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:A,onChange:V=>x(V.target.value),placeholder:L?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 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:A,onChange:V=>Q({description:V.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),i.jsxs("div",{className:"af-workspaces-actions",children:[!A&&R>=0?i.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:W,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:E,disabled:A||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:A||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const Uie=[{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"}],Yie=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Gie=[{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"}],Jie=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Vp({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 Xie(){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(Vp,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(Vp,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(Vp,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(Vp,{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 xh({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 Qie(){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(xh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:Gie.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 LM(){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(Xie,{}),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(xh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:Uie.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(xh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:Yie.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(Qie,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(xh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:Jie.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 OM(e){return t=>typeof t===e}var Zie=OM("function"),eoe=e=>e===null,__=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",E_=e=>!toe(e)&&!eoe(e)&&(Zie(e)||typeof e=="object"),toe=OM("undefined");function noe(e,t,n){return coe(n,e,t)?!0:(uoe(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?roe(e,t,n):e instanceof Map&&t instanceof Map?ooe(e,t,n):e instanceof Set&&t instanceof Set?loe(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?soe(e,t):__(e)&&__(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?ioe(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():aoe(e,t,n))}function wf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!E_(e)||!t||!E_(t)?!1:noe(e,t,n)}function roe(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!wf(e[s],t[s],n))return!1;return!0}function soe(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 ioe(e,t,n){return e.message===t.message&&e.name===t.name&&wf(e.cause,t.cause,n)}function ooe(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(!wf(r[1],t.get(r[0]),n))return!1;return!0}function aoe(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)&&!wf(e[o],t[o],n))return!1}return!0}function loe(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 coe(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function uoe(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function kv(e,t){return wf(e,t,new WeakMap)}function xw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function doe(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function foe(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function poe(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function hoe(e,t){const n=poe();m.useEffect(()=>{if(!n)return e()},t)}function DM(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function moe(e,t){const n=m.useRef(t);return kv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function goe(e){m.useEffect(()=>{e()},[])}function yoe(e=0){const[t,n]=m.useState({height:xw()?window.innerHeight:0,width:xw()?window.innerWidth:0}),r=m.useRef(0),s=m.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return m.useEffect(()=>{if(!xw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),foe(window,"resize",o),()=>{doe(window,"resize",o)}},[]),t}var woe=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],xoe=["bigint","boolean","null","number","string","symbol","undefined"];function xf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(boe(t))return t}function oi(e){return t=>xf(t)===e}function boe(e){return woe.includes(e)}function Vc(e){return t=>typeof t===e}function koe(e){return xoe.includes(e)}var voe=["innerHTML","ownerDocument","style","attributes","nodeValue"],bf=e=>Array.isArray(e),Soe=e=>xf(e)==="AsyncGeneratorFunction",joe=oi("AsyncFunction"),Noe=Vc("bigint"),Coe=e=>e===!0||e===!1,_oe=oi("Date"),Eoe=oi("Error"),ra=Vc("function"),Aoe=oi("GeneratorFunction"),Poe=e=>typeof e=="number"&&Number.isInteger(e),vb=oi("Map"),FM=e=>Number.isNaN(e),vv=e=>e===null,zM=oi("Function"),Ioe=oi("Promise"),Roe=oi("RegExp"),Sb=oi("Set"),kf=Vc("string"),Toe=Vc("symbol"),Sv=Vc("undefined"),Moe=oi("WeakMap"),$oe=oi("WeakSet"),jv=e=>vv(e)||Sv(e),BM=e=>!Sv(e),Loe=e=>Vc("number")(e)&&!FM(e),Ooe=e=>kf(e)&&e.trim().length>0,Doe=e=>{if(!kf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},fg=e=>!jv(e)&&(ra(e)||typeof e=="object"),HM=e=>{if(xf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Foe=e=>vv(e)||koe(typeof e),zoe=e=>xf(e)==="URL",WM=e=>!jv(e)&&ra(e[Symbol.iterator]),Boe=e=>WM(e)&&ra(e.next)&&ra(e.throw),Hoe=e=>ra(e)&&/^class\s/.test(e.toString()),Woe=(e,t)=>!bf(e)||!ra(t)?!1:e.every(n=>t(n)),Voe=e=>fg(e)&&!HM(e)&&e.nodeType===1&&kf(e.nodeName)&&voe.every(t=>t in e),Koe=e=>kf(e)&&e.length===0||bf(e)&&e.length===0||fg(e)&&!vb(e)&&!Sb(e)&&Object.keys(e).length===0||Sb(e)&&e.size===0||vb(e)&&e.size===0,qoe=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Uoe=(e,t)=>bf(e)?e.indexOf(t)>-1:!1,Yoe=(e,t,n)=>{if(!fg(e)||!t)return!1;const r=e[t];return ra(n)?n(r):BM(r)};function St(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(bf(e))return"Array";if(zM(e))return"Function";const t=xf(e);return t||"Object"}St.array=bf;St.arrayOf=Woe;St.asyncGeneratorFunction=Soe;St.asyncFunction=joe;St.bigint=Noe;St.boolean=Coe;St.class=Hoe;St.date=_oe;St.defined=BM;St.domElement=Voe;St.empty=Koe;St.error=Eoe;St.function=ra;St.generator=Boe;St.generatorFunction=Aoe;St.instanceOf=qoe;St.integer=Poe;St.iterable=WM;St.map=vb;St.nan=FM;St.null=vv;St.nullOrUndefined=jv;St.nonEmptyString=Ooe;St.number=Loe;St.numericString=Doe;St.object=fg;St.oneOf=Uoe;St.plainFunction=zM;St.plainObject=HM;St.primitive=Foe;St.promise=Ioe;St.propertyOf=Yoe;St.regexp=Roe;St.set=Sb;St.string=kf;St.symbol=Toe;St.undefined=Sv;St.url=zoe;St.weakMap=Moe;St.weakSet=$oe;var _r=St;/* v8 ignore next -- @preserve */var Goe=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Joe=function(e,t){return e+Zd(t)},Zd=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(Joe,""):Goe(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Zd(e.props.children):""};Zd.default=Zd;var Xoe=Zd;const bw=ia(Xoe);var VM={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(N){return N!=="constructor"&&N!=="prototype"&&N!=="__proto__"}function a(N){let C=0;const I=N.length,R=new Array(I);for(C;C<I;++C)R[C]=g(N[C]);return R}function l(N){const C={};if(p&&Object.getPrototypeOf(N)!==t)return p(N);const I=f(N);let R,H,A;for(R=0,H=I.length;R<H;++R)o(A=I[R])&&(C[A]=g(N[A]));return C}function c(N,C){const I=N.length,R=C.length;let H=0;const A=new Array(I+R);for(H;H<I;++H)A[H]=g(N[H]);for(H=0;H<R;++H)A[H+I]=g(C[H]);return A}const u=Object.prototype.propertyIsEnumerable;function d(N){const C=Object.keys(N),I=Object.getOwnPropertySymbols(N);for(let R=0,H=I.length;R<H;++R)u.call(N,I[R])&&C.push(I[R]);return C}const f=s!=null&&s.symbols?d:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),y=(s==null?void 0:s.onlyDefinedProperties)===!0;function v(N){return typeof N!="object"||N===null}const b=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:g,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function g(N){return h(N)?Array.isArray(N)?a(N):l(N):N}function k(N,C){const I={},R=f(N),H=f(C);let A,L,D;for(A=0,L=R.length;A<L;++A)o(D=R[A])&&H.indexOf(D)===-1&&(I[D]=g(N[D]));for(A=0,L=H.length;A<L;++A)if(o(D=H[A]))if(D in N)R.indexOf(D)!==-1&&(p&&h(C[D])&&Object.getPrototypeOf(C[D])!==t?I[D]=p(C[D]):I[D]=x(N[D],C[D]));else{if(y&&typeof C[D]>"u")continue;I[D]=g(C[D])}return I}function x(N,C){if(y&&typeof C>"u")return g(N);const I=Array.isArray(C),R=Array.isArray(N);return v(C)?C:h(N)?I&&R?b(N,C):I!==R?g(C):k(N,C):g(C)}function j(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let N;for(let C=0,I=arguments.length;C<I;++C)N=x(N,arguments[C]);return N}return s!=null&&s.all?j:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(VM);var Qoe=VM.exports;const Zoe=ia(Qoe);var eae=new Error("Element already at target scroll position"),tae=new Error("Scroll cancelled"),nae=Math.min,A_=Date.now,rae={left:P_("scrollLeft"),top:P_("scrollTop")};function P_(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=iae);var a=A_(),l=n[e],c=s.ease||sae,u=isNaN(s.duration)?350:+s.duration,d=!1;return l===r?o(eae,n[e]):requestAnimationFrame(p),f;function f(){d=!0}function p(h){if(d)return o(tae,n[e]);var y=A_(),v=nae(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(p):requestAnimationFrame(function(){o(null,n[e])})}}}function sae(e){return .5*(1-Math.cos(Math.PI*e))}function iae(){}const oae=ia(rae);var KM={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(md,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})})(KM);var aae=KM.exports;const qM=ia(aae),lae=["top","right","bottom","left"],I_=["start","end"],R_=lae.reduce((e,t)=>e.concat(t,t+"-"+I_[0],t+"-"+I_[1]),[]),Mc=Math.min,Ha=Math.max,vm=Math.round,Kp=Math.floor,Ai=e=>({x:e,y:e}),cae={left:"right",right:"left",bottom:"top",top:"bottom"};function jb(e,t,n){return Ha(e,Mc(t,n))}function Kc(e,t){return typeof e=="function"?e(t):e}function uo(e){return e.split("-")[0]}function Pi(e){return e.split("-")[1]}function UM(e){return e==="x"?"y":"x"}function Nv(e){return e==="y"?"height":"width"}function zo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Cv(e){return UM(zo(e))}function YM(e,t,n){n===void 0&&(n=!1);const r=Pi(e),s=Cv(e),o=Nv(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=jm(a)),[a,jm(a)]}function uae(e){const t=jm(e);return[Sm(e),t,Sm(t)]}function Sm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const T_=["left","right"],M_=["right","left"],dae=["top","bottom"],fae=["bottom","top"];function pae(e,t,n){switch(e){case"top":case"bottom":return n?t?M_:T_:t?T_:M_;case"left":case"right":return t?dae:fae;default:return[]}}function hae(e,t,n,r){const s=Pi(e);let o=pae(uo(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(Sm)))),o}function jm(e){const t=uo(e);return cae[t]+e.slice(t.length)}function mae(e){return{top:0,right:0,bottom:0,left:0,...e}}function GM(e){return typeof e!="number"?mae(e):{top:e,right:e,bottom:e,left:e}}function Nm(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 $_(e,t,n){let{reference:r,floating:s}=e;const o=zo(t),a=Cv(t),l=Nv(a),c=uo(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 h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Pi(t)){case"start":h[a]-=p*(n&&u?-1:1);break;case"end":h[a]+=p*(n&&u?-1:1);break}return h}async function gae(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:h=0}=Kc(t,e),y=GM(h),b=l[p?f==="floating"?"reference":"floating":f],g=Nm(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)),j=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},N=Nm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-N.top+y.top)/j.y,bottom:(N.bottom-g.bottom+y.bottom)/j.y,left:(g.left-N.left+y.left)/j.x,right:(N.right-g.right+y.right)/j.x}}const yae=50,wae=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:gae},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}=$_(u,r,c),p=r,h=0;const y={};for(let v=0;v<o.length;v++){const b=o[v];if(!b)continue;const{name:g,fn:k}=b,{x,y:j,data:N,reset:C}=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=j??f,y[g]={...y[g],...N},C&&h<yae&&(h++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(u=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:d,y:f}=$_(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:y}},xae=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}=Kc(e,t)||{};if(u==null)return{};const f=GM(d),p={x:n,y:r},h=Cv(s),y=Nv(h),v=await a.getDimensions(u),b=h==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",j=o.reference[y]+o.reference[h]-p[h]-o.floating[y],N=p[h]-o.reference[h],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=C?C[x]:0;(!I||!await(a.isElement==null?void 0:a.isElement(C)))&&(I=l.floating[x]||o.floating[y]);const R=j/2-N/2,H=I/2-v[y]/2-1,A=Mc(f[g],H),L=Mc(f[k],H),D=A,O=I-v[y]-L,M=I/2-v[y]/2+R,K=jb(D,M,O),z=!c.arrow&&Pi(s)!=null&&M!==K&&o.reference[y]/2-(M<D?A:L)-v[y]/2<0,F=z?M<D?M-D:M-O:0;return{[h]:p[h]+F,data:{[h]:K,centerOffset:M-K-F,...z&&{alignmentOffset:F}},reset:z}}});function bae(e,t,n){return(e?[...n.filter(s=>Pi(s)===e),...n.filter(s=>Pi(s)!==e)]:n.filter(s=>uo(s)===s)).filter(s=>e?Pi(s)===e||(t?Sm(s)!==s:!1):!0)}const kae=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=R_,autoAlignment:h=!0,...y}=Kc(e,t),v=f!==void 0||p===R_?bae(f||null,h,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=YM(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const j=[b[uo(k)],b[x[0]],b[x[1]]],N=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:j}],C=v[g+1];if(C)return{data:{index:g+1,overflows:N},reset:{placement:C}};const I=N.map(A=>{const L=Pi(A.placement);return[A.placement,L&&d?A.overflows.slice(0,2).reduce((D,O)=>D+O,0):A.overflows[0],A.overflows]}).sort((A,L)=>A[1]-L[1]),H=((s=I.filter(A=>A[2].slice(0,Pi(A[0])?2:3).every(L=>L<=0))[0])==null?void 0:s[0])||I[0][0];return H!==l?{data:{index:g+1,overflows:N},reset:{placement:H}}:{}}}},vae=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:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=Kc(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=uo(s),k=zo(l),x=uo(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=p||(x||!v?[jm(l)]:uae(l)),C=y!=="none";!p&&C&&N.push(...hae(l,v,y,j));const I=[l,...N],R=await c.detectOverflow(t,b),H=[];let A=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&H.push(R[g]),f){const M=YM(s,a,j);H.push(R[M[0]],R[M[1]])}if(A=[...A,{placement:s,overflows:H}],!H.every(M=>M<=0)){var L,D;const M=(((L=o.flip)==null?void 0:L.index)||0)+1,K=I[M];if(K&&(!(f==="alignment"?k!==zo(K):!1)||A.every($=>zo($.placement)===k?$.overflows[0]>0:!0)))return{data:{index:M,overflows:A},reset:{placement:K}};let z=(D=A.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:D.placement;if(!z)switch(h){case"bestFit":{var O;const F=(O=A.filter($=>{if(C){const W=zo($.placement);return W===k||W==="y"}return!0}).map($=>[$.placement,$.overflows.filter(W=>W>0).reduce((W,E)=>W+E,0)]).sort(($,W)=>$[1]-W[1])[0])==null?void 0:O[0];F&&(z=F);break}case"initialPlacement":z=l;break}if(s!==z)return{reset:{placement:z}}}return{}}}},Sae=new Set(["left","top"]);async function jae(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=uo(n),l=Pi(n),c=zo(n)==="y",u=Sae.has(a)?-1:1,d=o&&c?-1:1,f=Kc(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*d,y:p*u}:{x:p*u,y:h*d}}const Nae=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 jae(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}}}}},Cae=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}=Kc(e,t),d={x:n,y:r},f=await o.detectOverflow(t,u),p=zo(uo(s)),h=UM(p);let y=d[h],v=d[p];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",x=y+f[g],j=y-f[k];y=jb(x,y,j)}if(l){const g=p==="y"?"top":"left",k=p==="y"?"bottom":"right",x=v+f[g],j=v-f[k];v=jb(x,v,j)}const b=c.fn({...t,[h]:y,[p]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[p]:l}}}}}};function pg(){return typeof window<"u"}function qc(e){return JM(e)?(e.nodeName||"").toLowerCase():"#document"}function ds(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Mi(e){var t;return(t=(JM(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function JM(e){return pg()?e instanceof Node||e instanceof ds(e).Node:!1}function ri(e){return pg()?e instanceof Element||e instanceof ds(e).Element:!1}function mo(e){return pg()?e instanceof HTMLElement||e instanceof ds(e).HTMLElement:!1}function L_(e){return!pg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ds(e).ShadowRoot}function vf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=si(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function _ae(e){return/^(table|td|th)$/.test(qc(e))}function hg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Eae=/transform|translate|scale|rotate|perspective|filter/,Aae=/paint|layout|strict|content/,va=e=>!!e&&e!=="none";let kw;function _v(e){const t=ri(e)?si(e):e;return va(t.transform)||va(t.translate)||va(t.scale)||va(t.rotate)||va(t.perspective)||!Ev()&&(va(t.backdropFilter)||va(t.filter))||Eae.test(t.willChange||"")||Aae.test(t.contain||"")}function Pae(e){let t=sa(e);for(;mo(t)&&!$c(t);){if(_v(t))return t;if(hg(t))return null;t=sa(t)}return null}function Ev(){return kw==null&&(kw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),kw}function $c(e){return/^(html|body|#document)$/.test(qc(e))}function si(e){return ds(e).getComputedStyle(e)}function mg(e){return ri(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sa(e){if(qc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||L_(e)&&e.host||Mi(e);return L_(t)?t.host:t}function XM(e){const t=sa(e);return $c(t)?e.ownerDocument?e.ownerDocument.body:e.body:mo(t)&&vf(t)?t:XM(t)}function ef(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=XM(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ds(s);if(o){const l=Nb(a);return t.concat(a,a.visualViewport||[],vf(s)?s:[],l&&n?ef(l):[])}else return t.concat(s,ef(s,[],n))}function Nb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function QM(e){const t=si(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=mo(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=vm(n)!==o||vm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Av(e){return ri(e)?e:e.contextElement}function yc(e){const t=Av(e);if(!mo(t))return Ai(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=QM(t);let a=(o?vm(n.width):n.width)/r,l=(o?vm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Iae=Ai(0);function ZM(e){const t=ds(e);return!Ev()||!t.visualViewport?Iae:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Rae(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ds(e)?!1:t}function sl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Av(e);let a=Ai(1);t&&(r?ri(r)&&(a=yc(r)):a=yc(e));const l=Rae(o,n,r)?ZM(o):Ai(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=ds(o),h=r&&ri(r)?ds(r):r;let y=p,v=Nb(y);for(;v&&r&&h!==y;){const b=yc(v),g=v.getBoundingClientRect(),k=si(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,j=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,d*=b.x,f*=b.y,c+=x,u+=j,y=ds(v),v=Nb(y)}}return Nm({width:d,height:f,x:c,y:u})}function gg(e,t){const n=mg(e).scrollLeft;return t?t.left+n:sl(Mi(e)).left+n}function e$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-gg(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Tae(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Mi(r),l=t?hg(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Ai(1);const d=Ai(0),f=mo(r);if((f||!f&&!o)&&((qc(r)!=="body"||vf(a))&&(c=mg(r)),f)){const h=sl(r);u=yc(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=a&&!f&&!o?e$(a,c):Ai(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 Mae(e){return Array.from(e.getClientRects())}function $ae(e){const t=Mi(e),n=mg(e),r=e.ownerDocument.body,s=Ha(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ha(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+gg(e);const l=-n.scrollTop;return si(r).direction==="rtl"&&(a+=Ha(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const O_=25;function Lae(e,t){const n=ds(e),r=Mi(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=Ev();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=gg(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-h);y<=O_&&(o-=y)}else u<=O_&&(o+=u);return{width:o,height:a,x:l,y:c}}function Oae(e,t){const n=sl(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=mo(e)?yc(e):Ai(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 D_(e,t,n){let r;if(t==="viewport")r=Lae(e,n);else if(t==="document")r=$ae(Mi(e));else if(ri(t))r=Oae(t,n);else{const s=ZM(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Nm(r)}function t$(e,t){const n=sa(e);return n===t||!ri(n)||$c(n)?!1:si(n).position==="fixed"||t$(n,t)}function Dae(e,t){const n=t.get(e);if(n)return n;let r=ef(e,[],!1).filter(l=>ri(l)&&qc(l)!=="body"),s=null;const o=si(e).position==="fixed";let a=o?sa(e):e;for(;ri(a)&&!$c(a);){const l=si(a),c=_v(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||vf(a)&&!c&&t$(e,a))?r=r.filter(d=>d!==a):s=l,a=sa(a)}return t.set(e,r),r}function Fae(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?hg(t)?[]:Dae(t,this._c):[].concat(n),r],l=D_(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 h=D_(t,a[p],s);c=Ha(h.top,c),u=Mc(h.right,u),d=Mc(h.bottom,d),f=Ha(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function zae(e){const{width:t,height:n}=QM(e);return{width:t,height:n}}function Bae(e,t,n){const r=mo(t),s=Mi(t),o=n==="fixed",a=sl(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Ai(0);function u(){c.x=gg(s)}if(r||!r&&!o)if((qc(t)!=="body"||vf(s))&&(l=mg(t)),r){const h=sl(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();o&&!r&&s&&u();const d=s&&!r&&!o?e$(s,l):Ai(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 vw(e){return si(e).position==="static"}function F_(e,t){if(!mo(e)||si(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Mi(e)===n&&(n=n.ownerDocument.body),n}function n$(e,t){const n=ds(e);if(hg(e))return n;if(!mo(e)){let s=sa(e);for(;s&&!$c(s);){if(ri(s)&&!vw(s))return s;s=sa(s)}return n}let r=F_(e,t);for(;r&&_ae(r)&&vw(r);)r=F_(r,t);return r&&$c(r)&&vw(r)&&!_v(r)?n:r||Pae(e)||n}const Hae=async function(e){const t=this.getOffsetParent||n$,n=this.getDimensions,r=await n(e.floating);return{reference:Bae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wae(e){return si(e).direction==="rtl"}const Vae={convertOffsetParentRelativeRectToViewportRelativeRect:Tae,getDocumentElement:Mi,getClippingRect:Fae,getOffsetParent:n$,getElementRects:Hae,getClientRects:Mae,getDimensions:zae,getScale:yc,isElement:ri,isRTL:Wae};function r$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Kae(e,t){let n=null,r;const s=Mi(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:h}=u;if(l||t(),!p||!h)return;const y=Kp(f),v=Kp(s.clientWidth-(d+p)),b=Kp(s.clientHeight-(f+h)),g=Kp(d),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Ha(0,Mc(1,c))||1};let j=!0;function N(C){const I=C[0].intersectionRatio;if(I!==c){if(!j)return a();I?a(!1,I):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!r$(u,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(N,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(N,x)}n.observe(e)}return a(!0),o}function z_(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=Av(e),d=s||o?[...u?ef(u):[],...t?ef(t):[]]:[];d.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?Kae(u,n):null;let p=-1,h=null;a&&(h=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?sl(e):null;c&&b();function b(){const g=sl(e);v&&!r$(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=h)==null||g.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const qae=Nae,Uae=kae,Yae=Cae,Gae=vae,B_=xae,Jae=(e,t,n)=>{const r=new Map,s={platform:Vae,...n},o={...s.platform,_c:r};return wae(e,t,{...s,platform:o})};var Xae=typeof document<"u",Qae=function(){},bh=Xae?m.useLayoutEffect:Qae;function Cm(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(!Cm(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)&&!Cm(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function s$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function H_(e,t){const n=s$(e);return Math.round(t*n)/n}function Sw(e){const t=m.useRef(e);return bh(()=>{t.current=e}),t}function W_(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]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);Cm(p,r)||h(r);const[y,v]=m.useState(null),[b,g]=m.useState(null),k=m.useCallback($=>{$!==C.current&&(C.current=$,v($))},[]),x=m.useCallback($=>{$!==I.current&&(I.current=$,g($))},[]),j=o||y,N=a||b,C=m.useRef(null),I=m.useRef(null),R=m.useRef(d),H=c!=null,A=Sw(c),L=Sw(s),D=Sw(u),O=m.useCallback(()=>{if(!C.current||!I.current)return;const $={placement:t,strategy:n,middleware:p};L.current&&($.platform=L.current),Jae(C.current,I.current,$).then(W=>{const E={...W,isPositioned:D.current!==!1};M.current&&!Cm(R.current,E)&&(R.current=E,ur.flushSync(()=>{f(E)}))})},[p,t,n,L,D]);bh(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const M=m.useRef(!1);bh(()=>(M.current=!0,()=>{M.current=!1}),[]),bh(()=>{if(j&&(C.current=j),N&&(I.current=N),j&&N){if(A.current)return A.current(j,N,O);O()}},[j,N,O,A,H]);const K=m.useMemo(()=>({reference:C,floating:I,setReference:k,setFloating:x}),[k,x]),z=m.useMemo(()=>({reference:j,floating:N}),[j,N]),F=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!z.floating)return $;const W=H_(z.floating,d.x),E=H_(z.floating,d.y);return l?{...$,transform:"translate("+W+"px, "+E+"px)",...s$(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:E}},[n,l,z.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:O,refs:K,elements:z,floatingStyles:F}),[d,O,K,z,F])}const Zae=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?B_({element:r.current,padding:s}).fn(n):{}:r?B_({element:r,padding:s}).fn(n):{}}}},V_=(e,t)=>{const n=qae(e);return{name:n.name,fn:n.fn,options:[e,t]}},ele=(e,t)=>{const n=Yae(e);return{name:n.name,fn:n.fn,options:[e,t]}},tle=(e,t)=>{const n=Gae(e);return{name:n.name,fn:n.fn,options:[e,t]}},nle=(e,t)=>{const n=Uae(e);return{name:n.name,fn:n.fn,options:[e,t]}},rle=(e,t)=>{const n=Zae(e);return{name:n.name,fn:n.fn,options:[e,t]}},sle={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},ile={beaconOptions:{offset:-18}},i$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},ole={isFixed:!1,locale:i$,placement:"bottom"},ale={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},$t={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},cr={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"},Xe={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},yi={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},At={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},lle="react-joyride-portal";function cle(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function rc(...e){return Zoe({all:!0,isMergeableObject:t=>!(!_r.plainObject(t)||m.isValidElement(t))})(...e)}function o$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Ui(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let o=bw(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&s&&(o=o.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&o$(e.type)==="function")try{o=Ui(e.type({}),t)}catch{o=bw(n)}else o=bw(n);return o}function pr(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 ule(e,t){const n=cle(t);return{...e,...n}}function tf(){}function dle(e){return Object.keys(e)}function _m(e,...t){if(!_r.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 K_(e,...t){if(!_r.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 Cb(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(o$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(_r.string(s)&&s.includes("{current}"))return m.cloneElement(e,{children:r(s)});if(Array.isArray(s))return m.cloneElement(e,{children:s.map(o=>typeof o=="string"?r(o):Cb(o,t,n))});if(_r.function(e.type)&&!Object.values(e.props).length)try{return Cb(e.type({}),t,n)}catch{return e}return e}function q_(e){return dle(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Pv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function U_(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 Iv(e){return e?e.getBoundingClientRect():null}function fle(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 Es(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 ple(e,t,n){const r=Iv(e),s=Uc(e),o=s?!s.isSameNode(Gr()):!1,a=n??Yc(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(Gr())||(c+=Gr().scrollTop)),Math.floor(c-t)}function Uc(e,t){if(!e)return Gr();const n=qM(e);if(n){if(n.isSameNode(Gr()))return t?document:Gr();if(!(n.scrollHeight>n.offsetHeight))return Gr()}return n}function hle(e){const t=e.getBoundingClientRect(),n=Gr(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function mle(e,t){if(!e)return 0;const n=qM(e)??Gr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Iv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(a$(e)||gle(e))){const d=e.getBoundingClientRect(),f=d.top-((s==null?void 0:s.top)??0),p=f+d.height,h=n.clientHeight,y=h*.2;f>=y&&p<=h-y?c=o:c=f+o}const u=Math.floor(c-t-r);return u<0?0:u}function gle(e){return e.offsetParent!==document.body}function a$(e){if(!e)return!1;const t=Uc(e);return t?!t.isSameNode(Gr()):!1}function Yc(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?Yc(e.parentNode,t):!1}function qp(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 Y_(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Xe.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Uc(s):Gr(),l=a?!a.isSameNode(Gr()):!1;return(r.isFixed||Yc(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Gr(){return document.scrollingElement??document.documentElement}function G_(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=oae.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function yle(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,o,a)=>s+s+o+o+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const l$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Up={...l$,borderRadius:4,padding:8};function wle(e,t){const{styles:n}=e,r=rc(n??{},t.styles??{});let{width:s}=t;Pv()&&(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 rc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...l$,display:"inline-flex",borderRadius:"50%",position:"relative"},beacon:{height:t.beaconSize,width:t.beaconSize},beaconInner:{animation:"joyride-beacon-inner 1.2s infinite ease-in-out",backgroundColor:t.primaryColor,borderRadius:"50%",display:"block",height:"50%",left:"50%",opacity:.7,position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:"50%"},beaconOuter:{animation:"joyride-beacon-outer 1.2s infinite ease-in-out",backgroundColor:`rgba(${yle(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:{...Up,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Up,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Up,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Up,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 xle=["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 Rv(e,t){if(!t)return null;const n=rc(ole,K_(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=rc(sle,e.options??{},K_(t,...xle)),s=wle(e,{...n,...r}),o=rc(ile,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:rc(i$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:ble(r.spotlightPadding),styles:s}}function ble(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 kle(e,t,n){const{action:r}=t,s=n&&[$t.PREV,$t.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function c$(e,t=!1){return _r.plainObject(e)?e.target?!0:(pr(t,"tour","target is missing from the step"),!1):(pr(t,"tour","step must be an object"),!1)}function u$(e,t=!1){return _r.array(e)?e.every(n=>c$(n,t)):(pr(t,"tour","steps must be an array"),!1)}var vle=class{constructor(e){Fn(this,"beaconPosition",null);Fn(this,"debug");Fn(this,"eventListeners",new Map);Fn(this,"listeners",new Set);Fn(this,"props");Fn(this,"snapshot");Fn(this,"state");Fn(this,"steps");Fn(this,"tooltipPosition",null);Fn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Fn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Fn(this,"getServerSnapshot",()=>this.snapshot);Fn(this,"getSnapshot",()=>this.snapshot);Fn(this,"getEventState",()=>_m(this.snapshot,"positioned"));Fn(this,"getState",()=>_m(this.snapshot,"positioned"));Fn(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&pr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Xe.BEACON_BEFORE||this.state.lifecycle===Xe.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)});Fn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Fn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Fn(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)}});Fn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Fn(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,!kv(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=_r.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,_r.number(t)&&pr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):_r.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&pr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:$t.INIT,controlled:s,index:o,lifecycle:Xe.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?At.READY:At.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===At.WAITING&&e.size>0?{...e,status:At.RUNNING}:e}getStep(e){return Rv(this.props,this.steps[e??this.state.index])}};function Sle(e){return new vle(e)}function J_(e,t){return Math.min(Math.max(e,0),t)}function jle(e,t,n){const r=m.useRef(t),s=m.useRef(n);return r.current=t,s.current=n,m.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(b=null)=>{const{index:g,status:k}=o();k===At.RUNNING&&e.current.updateState({action:$t.CLOSE,index:g+1,origin:b,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:g,size:k,status:x}=o();if(g){pr(r.current,"tour","go() is not supported in controlled mode");return}x===At.RUNNING&&e.current.updateState({action:$t.GO,index:b,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:At.FINISHED,waiting:!1})},info:()=>_m(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===At.RUNNING&&e.current.updateState({action:$t.NEXT,index:J_(g+1,k),lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===At.RUNNING&&e.current.updateState({action:$t.UPDATE,lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===At.RUNNING&&e.current.updateState({action:$t.PREV,index:J_(g-1,k),lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){pr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:$t.RESET,index:0,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:b?At.RUNNING:At.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===At.RUNNING&&e.current.updateState({action:$t.SKIP,lifecycle:Xe.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:At.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();s.current(),e.current.updateState({action:$t.START,index:_r.number(b)?b:g,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:k?At.RUNNING:At.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[At.FINISHED,At.SKIPPED].includes(k)||e.current.updateState({action:$t.STOP,index:g+(b?1:0),lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:At.PAUSED,waiting:!1})}}},[e])}const Nle=new Set(["origin","positioned"]);function Cle(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return pr(!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]&&!Nle.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||pr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function _le(e,t,n){const r=m.useRef(e),s=m.useRef(t);return r.current=e,s.current=t,m.useCallback((o,a,l)=>{var u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(u=r.current)==null||u.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Ro(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 Ele(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:h,size:y,status:v}=a,b=DM(l)??null,g=m.useRef(null),k=m.useRef(o),x=m.useRef(a),j=m.useRef(s),N=m.useRef(l),C=m.useRef(b),I=m.useRef(n),R=m.useRef(null),H=m.useRef(null),A=m.useRef(null);k.current=o,x.current=a,j.current=s,N.current=l,C.current=b,I.current=n;const L=()=>{R.current&&(clearInterval(R.current),R.current=null),H.current=null,A.current&&(A.current.cancel(),A.current=null)};m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D}=Ro(x.current,j.current);(D("action",[$t.NEXT,$t.PREV,$t.SKIP,$t.CLOSE])||g.current===$t.CLOSE&&u===$t.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!j.current)return()=>{L()};const{hasChanged:D}=Ro(x.current,j.current),O=N.current;if(D("index")&&L(),v!==At.RUNNING||!O||f!==Xe.INIT)return()=>{L()};const{hasChangedTo:M}=Ro(x.current,j.current);M("status",At.RUNNING)&&[At.IDLE,At.READY,At.PAUSED].includes(j.current.status)&&r(cr.TOUR_START,O),c.current.cleanupPositionData();const{debug:K}=k.current;if(O.before&&!A.current){pr(K,`step:${d}`,"before()",O),A.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(cr.STEP_BEFORE_HOOK,O,{action:g.current??x.current.action});const z=()=>{A.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:Xe.READY})},F=new AbortController,$=O.beforeTimeout;A.current={cancel:()=>F.abort()};const W=$?setTimeout(()=>{F.signal.aborted||(pr(K,`step:${d}`,"before()","timed out",`${$}ms`),F.abort(),t(O,"before_hook"),r(cr.ERROR,O,{error:new Error("Step before hook timed out")}),z())},$):null;O.before({...c.current.getState(),action:g.current??c.current.getState().action,step:O}).then(()=>{F.signal.aborted||(W&&clearTimeout(W),z())}).catch(E=>{F.signal.aborted||(W&&clearTimeout(W),t(O,"before_hook"),r(cr.ERROR,O,{error:E instanceof Error?E:new Error(String(E))}),z())})}else if(!A.current){R.current&&H.current!==O.target&&L();const z=Es(O.target);if(z&&qp(z))L(),c.current.updateState({action:g.current??$t.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(O.targetWaitTimeout===0)c.current.updateState({action:g.current??$t.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(!R.current){const{targetWaitTimeout:F}=O,$=Date.now();H.current=O.target,pr(K,`step:${d}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),R.current=setInterval(()=>{const W=Es(O.target),E=Date.now()-$,Q=E>=F;(W&&qp(W)||Q)&&(pr(K,`step:${d}`,"polling",W&&qp(W)?"found":"timed out",`${E}ms`),L(),c.current.updateState({action:g.current??$t.UPDATE,lifecycle:Xe.READY,waiting:!1}))},100)}}return()=>{L()}},[t,r,d,f,v,c]),m.useEffect(()=>{if(!j.current)return;const{hasChanged:D,hasChangedTo:O,previous:M}=Ro(x.current,j.current),K=N.current;if(!K)return;const z=Es(K.target),F=!!z;if(F&&qp(z)){if(O("lifecycle",Xe.READY)&&M.lifecycle===Xe.INIT&&r(cr.STEP_BEFORE,K,{action:g.current??x.current.action}),O("lifecycle",Xe.READY)){const $=x.current,W=kle(K,$,k.current.continuous)?Xe.TOOLTIP:Xe.BEACON,E=Es(K.scrollTarget??K.spotlightTarget??K.target),Q=Y_({isFirstStep:$.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:K,target:E,targetLifecycle:W}),V=W===Xe.TOOLTIP?Xe.TOOLTIP_BEFORE:Xe.BEACON_BEFORE;pr(k.current.debug,`step:${d}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:$t.UPDATE,lifecycle:V,scrolling:Q})}}else if(x.current.status===At.RUNNING&&f!==Xe.INIT&&f!==Xe.COMPLETE&&D("lifecycle")){pr(k.current.debug,`step:${d}`,F?"Target not visible":"Target not mounted",K),t(K,"target_not_found"),r(cr.TARGET_NOT_FOUND,K);const $=x.current;$.controlled||c.current.updateState({action:$t.UPDATE,index:$.index+($.action===$t.PREV?-1:1),lifecycle:Xe.INIT})}},[t,r,d,f,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D,previous:O}=Ro(x.current,j.current),M=N.current,K=C.current;if(M&&D("lifecycle",Xe.TOOLTIP_BEFORE)&&O.lifecycle===Xe.BEACON){const $=Es(M.scrollTarget??M.spotlightTarget??M.target);if(Y_({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:$,targetLifecycle:Xe.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const z=f===Xe.BEACON_BEFORE||f===Xe.TOOLTIP_BEFORE;if(M&&z&&!h){const $=f===Xe.TOOLTIP_BEFORE?Xe.TOOLTIP:Xe.BEACON;c.current.updateState({action:$t.UPDATE,lifecycle:$})}M&&D("lifecycle",Xe.BEACON)&&r(cr.BEACON,M),M&&D("lifecycle",Xe.TOOLTIP)&&r(cr.TOOLTIP,M);const F=x.current;if((F.status===At.RUNNING||F.controlled&&F.status===At.PAUSED&&M)&&K&&D("lifecycle",Xe.COMPLETE)&&O.lifecycle===Xe.TOOLTIP&&(r(cr.STEP_AFTER,K,{action:g.current??$t.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle}),K.after)){r(cr.STEP_AFTER_HOOK,K,{action:g.current??$t.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle});try{K.after({...c.current.getState(),action:g.current??$t.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle,step:K})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D,previous:O}=Ro(x.current,j.current),M=N.current,K=C.current;y&&!M&&f===Xe.INIT&&c.current.updateState({action:$t.UPDATE,lifecycle:Xe.COMPLETE,status:At.FINISHED}),!x.current.controlled&&v===At.RUNNING&&D("lifecycle",Xe.COMPLETE)&&d<y&&c.current.updateState({action:$t.UPDATE,lifecycle:Xe.INIT}),D("lifecycle",Xe.COMPLETE)&&d>=y&&c.current.updateState({action:$t.UPDATE,lifecycle:Xe.COMPLETE,status:At.FINISHED});const z=M??K??Rv(k.current,k.current.steps[d-1]);if(z&&D("status",[At.FINISHED,At.SKIPPED])){let F;M?F=d:K?F=O.index??d:F=d-1,r(cr.TOUR_END,z,{index:F}),x.current.controlled||I.current.reset(),g.current=null}M&&D("action",$t.STOP)&&(g.current=null,r(cr.TOUR_STATUS,M)),M&&D("action",$t.RESET)&&(r(cr.TOUR_STATUS,M),g.current=null)},[u,r,d,f,y,v,c])}function Ale({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,d=m.useRef(void 0),f=m.useRef(r),p=m.useRef(e);f.current=r,p.current=e,m.useEffect(()=>{const h=d.current;if(d.current=n,!h||n===h)return;const{hasChanged:y}=Ro(n,h);if(kv(h.steps,u)||(u$(u,o)?s.current.setSteps(u):(pr(o,"tour","Steps are not valid",u),t(cr.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(_r.number(c)&&y("stepIndex")){const v=_r.number(h.stepIndex)&&h.stepIndex<c?$t.NEXT:$t.PREV;[At.FINISHED,At.SKIPPED].includes(f.current.status)||s.current.updateState({action:v,index:c,lifecycle:Xe.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,s])}function Ple(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===Xe.BEACON_BEFORE&&(n!=null&&n.placement)){const f=Ile(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Xe.TOOLTIP_BEFORE){const{placement:f}=o;if(f==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+h;a-=p+y}else if(f==="left"||f==="right"){const p=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((d=Es(o.target))==null?void 0:d.getBoundingClientRect().height)??0,y=s+o.spotlightPadding.top+h/2-p/2;y<s&&(a-=s-y)}}return Math.max(0,a)}function Ile(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 Rle({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=m.useRef(null),p=m.useRef(r),h=m.useRef(t),y=m.useRef(n),v=m.useRef(s);p.current=r,h.current=t,y.current=n,v.current=s,m.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),m.useEffect(()=>{var N;if(!h.current||!v.current)return;const{hasChangedTo:b}=Ro(p.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,j=l===Xe.BEACON_BEFORE||l===Xe.TOOLTIP_BEFORE;if(d===At.RUNNING&&j&&u&&b("positioned",!0)){const C=Es(g.scrollTarget??g.spotlightTarget??g.target),I=o.current.getPositionData("beacon"),R=Uc(C),H=R?!R.isSameNode(Gr()):!1;(N=f.current)==null||N.call(f),(async()=>{if(H&&!Yc(R)){const F=Gr(),$=hle(R),W={initial:F.scrollTop,target:$,element:F,duration:x};e(cr.SCROLL_START,g,{scroll:W});const{cancel:E,promise:Q}=G_($,{element:F,duration:x});f.current=E,await Q,e(cr.SCROLL_END,g,{scroll:W})}const L=Math.floor(mle(C,g.scrollOffset))||0,D=H?L:Ple(L,{beaconPosition:I,lifecycle:l,scrollOffset:g.scrollOffset,step:g});pr(k,`step:${a}`,"scroll",H?"custom":"document",`${L} → ${D}`);const O=R,M={initial:O.scrollTop,target:D,element:O,duration:x};e(cr.SCROLL_START,g,{scroll:M});const{cancel:K,promise:z}=G_(D,{element:O,duration:x});f.current=K,await z,e(cr.SCROLL_END,g,{scroll:M}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,d,o])}function Tle(e){const t=moe(()=>ule(ale,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=m.useRef(Sle(t)),u=HI.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[d,f]=m.useState([]),p=m.useCallback((N,C)=>{f(I=>[...I,{reason:C,step:N}])},[]),h=m.useCallback(()=>{f([])},[]);Cle(c,n);const y=jle(c,n,h),v=_le(s,y,c),{index:b,size:g,status:k}=u,x=DM(u),j=m.useMemo(()=>Rv(t,l[b]),[b,t,l]);return goe(()=>{o&&g&&u$(l,n)&&y.start(a??r)}),hoe(()=>{o&&g&&k===At.IDLE&&c.current.updateState({status:At.READY})},[o,g,k]),Ale({controls:y,emitEvent:v,props:t,state:u,store:c}),Ele({addFailure:p,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:j,store:c}),Rle({emitEvent:v,previousState:x,props:t,state:u,step:j,store:c}),{controls:y,failures:d,mergedProps:t,state:u,step:j,store:c}}function Mle(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(_r.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=lle,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const $le={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Lle({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return tf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
321
+ @keyframes joyride-loader-spin {
322
+ to { transform: rotate(360deg); }
323
+ }
324
+ `)),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=dt.createElement(c,{step:t})}else l=dt.createElement("div",{style:{...$le,height:s,width:o,borderTopColor:t.primaryColor}});return dt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Ole={height:0,isFixed:!1,left:0,top:0,width:0};function Ou(e,t){const n=Es(e);if(!n)return Ole;const r=Iv(n),s=Yc(n),o=ple(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 Dle(e,t,n){const[r,s]=m.useState(()=>Ou(e,t)),o=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),u=m.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{s(f=>{const p=Ou(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]);m.useEffect(()=>{let f=null;const p=y=>{a.current=Uc(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(Ou(e,t))},h=Es(e);return h?p(h):(f=new MutationObserver(()=>{const y=Es(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]),m.useEffect(()=>{l.current&&!n&&s(Ou(e,t)),l.current=n},[n,e,t]);let d=r;return l.current&&!n&&(d=Ou(e,t)),d}function Fle(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function X_(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 zle=[Xe.BEACON_BEFORE,Xe.BEACON];function Ble(e){var z,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:h,target:y,waiting:v}=e,b=yoe(),g=Dle(p??y,d,u||v),k=m.useRef(null),x=(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE)&&l!=="center",[j,N]=m.useState(!1),C=c?(z=k.current)==null?void 0:z.offsetParent:null,I=(C==null?void 0:C.clientWidth)??b.width,R=(C==null?void 0:C.clientHeight)??fle()??b.height,H=((F=h.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",A=m.useMemo(()=>{const{backgroundColor:$,mixBlendMode:W,...E}=h.overlay;return{height:R,pointerEvents:"none",...E}},[R,h.overlay]),L=x&&!u&&!v;m.useEffect(()=>{L?requestAnimationFrame(()=>N(!0)):N(!1)},[L]);const D=n&&zle.includes(s),O=!n&&s!==Xe.TOOLTIP;if(r||!v&&(D||O))return null;let M="";if(L)if(c&&C){const $=Es(p??y);if($){const W=U_($),E=U_(C);M=X_(W.left-E.left-d.left,W.top-E.top-d.top,$.offsetWidth+d.left+d.right,$.offsetHeight+d.top+d.bottom,f)}}else M=X_(g.left,g.top,g.width,g.height,f);const K=Fle(I,R,M);return dt.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:A},dt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:R,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:I}},dt.createElement("path",{d:K,fill:H,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&dt.createElement("path",{d:M,fill:H,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&dt.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function d$(e){const{children:t,element:n}=e;return n?ur.createPortal(t,n):null}const Hle='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Wle(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return tf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Hle)],{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 Qi(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 Vle(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...Qi(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...Qi(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...Qi(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...Qi(e,t,n)};default:return null}}function Kle(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...Qi(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...Qi(e,r,n)};case"left":return{right:-n,top:t.y??0,...Qi(e,r,n)};case"right":return{left:-n,top:t.y??0,...Qi(e,r,n)};default:return{}}}function qle({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:o,styles:a}){const l=e;let c=null;if(l){if(!Qi(r,n,o))return null;c=dt.createElement("span",{style:{flexShrink:0}},dt.createElement(l,{base:n,placement:r,size:o}))}else{const u=Vle(r,n,o);if(!u)return null;c=dt.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},dt.createElement("polygon",{fill:"currentColor",points:u.points}))}return dt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...Kle(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function Ule(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=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return tf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
325
+ @keyframes joyride-beacon-inner {
326
+ 20% {
327
+ opacity: 0.9;
328
+ }
329
+
330
+ 90% {
331
+ opacity: 0.7;
332
+ }
333
+ }
334
+
335
+ @keyframes joyride-beacon-outer {
336
+ 0% {
337
+ transform: scale(1);
338
+ }
339
+
340
+ 45% {
341
+ opacity: 0.7;
342
+ transform: scale(0.75);
343
+ }
344
+
345
+ 100% {
346
+ opacity: 0.9;
347
+ transform: scale(1);
348
+ }
349
+ }
350
+ `)),document.head.appendChild(b);const g=setTimeout(()=>{_r.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)}},[h,a,c]);const y=Ui(o.open);let v;if(t){const b=t;v=dt.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else v=dt.createElement("span",{style:f.beacon},dt.createElement("span",{style:f.beaconOuter}),dt.createElement("span",{style:f.beaconInner}));return dt.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 Yle({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return dt.createElement("button",{style:o,type:"button",...t},dt.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"},dt.createElement("g",null,dt.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 Gle(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,h={};u.includes("primary")&&(h.primary=dt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=dt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=dt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&dt.createElement(Yle,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Ui(d),"aria-describedby":"joyride-tooltip-content"};return dt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},dt.createElement("div",{style:f.tooltipContainer},p&&dt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),dt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&dt.createElement("div",{style:f.tooltipFooter},dt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Jle(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(yi.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(yi.BUTTON_CLOSE):n.close(yi.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(yi.BUTTON_PRIMARY);return}n.next(yi.BUTTON_PRIMARY)},d=g=>{g.preventDefault(),n.skip(yi.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:j,nextWithProgress:N,skip:C}=a.locale,I=Ui(g),R=Ui(k),H=Ui(x),A=Ui(j),L=Ui(C);let D=k,O=R;if(t){if(D=j,O=A,a.showProgress&&!s){const M=Ui(N,{step:r+1,steps:o});D=Cb(N,r+1,o),O=M}s&&(D=x,O=H)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":R,children:k,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":O,children:D,"data-action":"primary",onClick:u,role:"button",title:O},skipProps:{"aria-label":L,children:C,"data-action":"skip",onClick:d,role:"button",title:L},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=dt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=dt.createElement(Gle,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function Xle(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Qle(e,t,n){var r,s;return e?[nle()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[tle({crossAxis:!1,fallbackPlacements:Xle(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Zle(e){var W,E,Q,V,B;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:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=p.placement==="center",x=p.placement==="auto",j=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=m.useMemo(()=>a$(h)?Uc(h):void 0,[h]),C=m.useMemo(()=>Yc(h),[h]),I=m.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),R=k||x?"bottom":p.placement,H=k?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||C?"fixed":"absolute"),A=m.useMemo(()=>{var se,ue,G,ee;return k?[{name:"center",fn:({rects:te})=>({x:(window.innerWidth-te.floating.width)/2,y:(window.innerHeight-te.floating.height)/2})}]:[V_(({placement:te})=>{var ce;let ne="right";te.startsWith("top")?ne="top":te.startsWith("bottom")?ne="bottom":te.startsWith("left")&&(ne="left");const Z=p.spotlightTarget?0:p.spotlightPadding[ne];return p.offset+Z+((ce=p.floatingOptions)!=null&&ce.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...Qle(x,p,R),ele({padding:10,...I,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(G=p.floatingOptions)!=null&&G.hideArrow?[]:[rle({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ee=p.floatingOptions)==null?void 0:ee.middleware)??[]]},[k,p,x,R,I]),L=W_({...k?{elements:{reference:j}}:{},placement:R,strategy:H,middleware:A}),D=W_({strategy:H,placement:p.beaconPlacement??(x||k?"bottom":p.placement),middleware:m.useMemo(()=>{var se,ue;return[V_(((ue=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:ue.offset)??-18)]},[(Q=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:z_});g.current=L.middlewareData,b.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:se,reference:ue}=L.elements;if(!(!ue||!se||s!==Xe.TOOLTIP))return z_(ue,se,L.update,(G=p.floatingOptions)==null?void 0:G.autoUpdate)},[s,L.update,(V=p.floatingOptions)==null?void 0:V.autoUpdate,p.target,L.elements]),m.useEffect(()=>{!k&&h&&L.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,L.refs]),m.useEffect(()=>{L.isPositioned&&c("tooltip",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:g.current})},[c,L.isPositioned,L.placement,L.x,L.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const O=p.zIndex+100,M=m.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||y({lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,y]),K=m.useCallback(se=>{se&&(L.refs.setFloating(se),u(se))},[L.refs,u]),{arrow:z,floater:F}=p.styles;let $=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const se=q_({...F,...L.floatingStyles,zIndex:O,opacity:a&&L.isPositioned?1:0,...!a&&{transition:"none"}});$=dt.createElement("div",{ref:K,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},dt.createElement(Jle,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((B=p.floatingOptions)!=null&&B.hideArrow)&&dt.createElement(qle,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:L.placement,position:L.middlewareData.arrow,size:p.arrowSize,styles:z}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&($=dt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:q_({...D.floatingStyles,zIndex:O})},dt.createElement(Ule,{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 dt.createElement(d$,{element:l},$)}function ece(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,h]=m.useState(null);Wle(d.disableFocusTrap?null:p,"[data-action=primary]");const y=Es(d.target),v=s===Xe.TOOLTIP;return!c$(d)||!_r.domElement(y)?null:dt.createElement(Zle,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:d,target:y,updateState:f})}function tce({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=Mle(c),{index:f,lifecycle:p,status:h}=n,y=h===At.RUNNING,[v,b]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const N=C=>{!r||p!==Xe.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(yi.KEYBOARD):e.close(yi.KEYBOARD))};return document.body.addEventListener("keydown",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,y,p,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(yi.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(yi.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const j=n.action===$t.START&&!r.skipBeacon&&r.placement!=="center";return dt.createElement(dt.Fragment,null,p!==Xe.INIT&&dt.createElement(ece,{...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}),dt.createElement(d$,{element:d},dt.createElement(dt.Fragment,null,v&&dt.createElement(Lle,{nonce:l,step:r}),!j&&dt.createElement(Ble,{...r,continuous:o,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function nce(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=Tle(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>_m(s,"positioned"),[s]),step:o,Tour:Pv()?dt.createElement(tce,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function rce(e){const{Tour:t}=nce(e);return t}function sce(e){return Pv()?dt.createElement(rce,e):null}function ice(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 oce(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function ace(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Yp="af:onboarding";function lce({page:e,hasNodes:t=!1}){const{t:n}=zr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?ice(n):t?oce(n):ace(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(Yp),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(Yp,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=d=>{var y;const f=d.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(Yp)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(Yp,JSON.stringify(b)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:i.jsx(sce,{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 cce="agentflow:recent-runs:v1",uce="agentflow:recent-runs:poller",dce=3e3,fce=8e3,pce=2e3,Q_=5e3,hce=16e3,Z_=[1e4,3e4,6e4];function mce(e){return Z_[Math.min(Math.max(e-1,0),Z_.length-1)]}function gce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function yce(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function wce(){const{navigate:e,path:t}=Ts(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=m.useRef(()=>{});m.useEffect(()=>{let j=!1,N=!1,C=!1,I=null,R=0,H=0,A=0,L=0,D=null,O=0,M=0;const K=gce(),z=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(cce):null,$=Ce=>{try{F==null||F.postMessage({...Ce,tabId:K,sentAt:Date.now()})}catch{}},W=()=>{const Ce=Date.now()-hce;for(const[_e,Be]of z)Be<Ce&&z.delete(_e);l(1+z.size)},E=(Ce="presence")=>{$({type:Ce,visible:!document.hidden})},Q=Ce=>{if(!j&&(Array.isArray(Ce.runs)&&r(Ce.runs),Ce.syncHealth&&typeof Ce.syncHealth=="object")){const _e=Ce.syncHealth;O=Number(_e.failureCount)||0,M=Number(_e.lastSuccessAt)||0,u(_e)}},V=Ce=>{Q(Ce),$({type:"state",...Ce})},B=()=>{R&&(window.clearTimeout(R),R=0)},se=Ce=>{B(),!(j||!N||document.hidden)&&(R=window.setTimeout(()=>{R=0,ue()},Math.max(0,Ce)))},ue=async()=>{if(j||!N||document.hidden||D)return;const Ce=new AbortController;D=Ce;let _e=!1;const Be=window.setTimeout(()=>{_e=!0,Ce.abort()},fce);try{const ot=await fetch("/api/pipeline-recent-runs",{signal:Ce.signal});if(!ot.ok)throw new Error(`HTTP ${ot.status}`);const gt=await ot.json();if(j||!N||document.hidden)return;O=0,M=Date.now();const Te=Array.isArray(gt.runs)?gt.runs:[];V({runs:Te.filter(st=>st&&st.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),se(dce)}catch(ot){const gt=Ce.signal.aborted&&!_e;if(j||!N||document.hidden||gt)return;O+=1,V({syncHealth:{status:"delayed",failureCount:O,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ot==null?void 0:ot.message)||ot)}`}}),se(mce(O))}finally{window.clearTimeout(Be),D===Ce&&(D=null)}},G=()=>{B(),D&&(D.abort(),D=null)},ee=()=>{if(G(),I){const Ce=I;I=null,Ce()}N=!1},te=(Ce=pce)=>{H&&window.clearTimeout(H),!(j||document.hidden||N||C)&&(H=window.setTimeout(()=>{H=0,Z()},Ce))},ne=()=>{j||document.hidden||N||(N=!0,se(0))},Z=async()=>{var Ce;if(!(j||document.hidden||N||C)){if(!((Ce=navigator.locks)!=null&&Ce.request)){ne();return}C=!0;try{await navigator.locks.request(uce,{mode:"exclusive",ifAvailable:!0},async _e=>{if(C=!1,!_e||j||document.hidden){te();return}N=!0,se(0),await new Promise(Be=>{I=Be}),I=null,N=!1})}catch{C=!1}finally{te()}}},ce=()=>{if(!j){if(N){O=0,se(0);return}$({type:"retry"}),te(0)}};d.current=ce,F&&(F.onmessage=Ce=>{const _e=Ce.data;if(!(!_e||_e.tabId===K)){if(_e.type==="hello"||_e.type==="presence"){z.set(_e.tabId,Date.now()),W(),_e.type==="hello"&&E();return}if(_e.type==="bye"){z.delete(_e.tabId),W(),te(0);return}if(_e.type==="state"){z.set(_e.tabId,Date.now()),W(),Q(_e);return}_e.type==="retry"&&N&&(O=0,se(0))}});const de=()=>{E(),document.hidden?ee():te(0)},me=()=>{E("bye"),ee()},$e=()=>{E("hello"),te(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",me),window.addEventListener("pageshow",$e),E("hello"),A=window.setInterval(E,Q_),L=window.setInterval(W,Q_),te(0),()=>{j=!0,d.current=()=>{},E("bye"),ee(),H&&window.clearTimeout(H),A&&window.clearInterval(A),L&&window.clearInterval(L),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",$e),F==null||F.close()}},[]);const f=j=>{const N=new URLSearchParams({flowId:j.flowId,flowSource:j.flowSource||"workspace"});e(`/flow?${N.toString()}`),o(!1)},p=t==="/flow"?new URLSearchParams(window.location.search):null,h=(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(j=>!j)};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:["最近成功:",yce(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:j=>{j.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(j=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(j.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(j),title:`${j.flowId} · ${j.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:j.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:j.runId.slice(0,12)})]},`${j.flowId}:${j.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 jw="0.1.118",xce=6e4,bce=30*6e4;function Lc(e){return String(e||"").trim().replace(/^v/i,"")}function kce(e,t){const n=Lc(e),r=Lc(t);return!!(n&&r&&n!==r)}function vce(e,t){return`agentflow.app-version.snooze:${Lc(e)}:${Lc(t)}`}function Sce(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function jce(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const o=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const d=Lc(u.version);if(!kce(jw,d)){t(null);return}const f=vce(jw,d);if(Sce(f)>Date.now())return;t({clientVersion:Lc(jw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),xce);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()+bce))}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 f$(e){return e==="/likee-context"||e==="/likee_context"}function Nce(){const{navigate:e}=Ts();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class Cce extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function _ce({authUser:e}){const{path:t}=Ts();return t==="/projects"||t==="/"?i.jsx(Il,{authUser:e}):t==="/nodes"?i.jsx(Il,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Il,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Il,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Il,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(qie,{authUser:e}):t==="/mcps"?i.jsx(Mie,{}):t==="/schedules"?i.jsx(Die,{}):t==="/node-studio"?i.jsx(zie,{}):t==="/flow"?i.jsx(Nce,{}):t==="/workspace"?i.jsx(qJ,{}):t.startsWith("/display")?i.jsx(SM,{}):t==="/settings"?i.jsx(xie,{authUser:e}):t==="/admin/usage"?i.jsx(_ie,{authUser:e}):t==="/feedback"?i.jsx(Aie,{authUser:e}):f$(t)?i.jsx(LM,{}):i.jsx(Il,{})}function Ece({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,d]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),d(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.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:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?i.jsx("p",{className:"af-auth-error",children:u}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Ace({authUser:e,onLogout:t}){const{path:n}=Ts(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(lce,{page:r?"flow":"projects"}):null,r?null:i.jsx(LD,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(_ce,{authUser:e})}),i.jsx(wce,{})]})}function Pce(){return i.jsx(Cce,{children:i.jsxs(yD,{children:[i.jsx(Ice,{}),i.jsx(jce,{})]})})}function Ice(){const{path:e}=Ts();return e.startsWith("/display")?i.jsx(SM,{}):f$(e)?i.jsx(LM,{}):i.jsx(Ece,{children:({user:t,onLogout:n})=>i.jsx(Ace,{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 eE=document.querySelector('link[rel="icon"]');eE&&(eE.href=gP);Nw.createRoot(document.getElementById("root")).render(i.jsx(dt.StrictMode,{children:i.jsx(Pce,{})}));