@fieldwangai/agentflow 0.1.48 → 0.1.49

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,238 @@
1
+ var b2=Object.defineProperty;var v2=(e,t,n)=>t in e?b2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Xn=(e,t,n)=>v2(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var of=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var iC={exports:{}},ag={},oC={exports:{}},Ot={};/**
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 Kf=Symbol.for("react.element"),k2=Symbol.for("react.portal"),S2=Symbol.for("react.fragment"),N2=Symbol.for("react.strict_mode"),j2=Symbol.for("react.profiler"),C2=Symbol.for("react.provider"),E2=Symbol.for("react.context"),_2=Symbol.for("react.forward_ref"),P2=Symbol.for("react.suspense"),A2=Symbol.for("react.memo"),I2=Symbol.for("react.lazy"),B0=Symbol.iterator;function T2(e){return e===null||typeof e!="object"?null:(e=B0&&e[B0]||e["@@iterator"],typeof e=="function"?e:null)}var aC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},lC=Object.assign,cC={};function Mu(e,t,n){this.props=e,this.context=t,this.refs=cC,this.updater=n||aC}Mu.prototype.isReactComponent={};Mu.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")};Mu.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function uC(){}uC.prototype=Mu.prototype;function Cb(e,t,n){this.props=e,this.context=t,this.refs=cC,this.updater=n||aC}var Eb=Cb.prototype=new uC;Eb.constructor=Cb;lC(Eb,Mu.prototype);Eb.isPureReactComponent=!0;var H0=Array.isArray,dC=Object.prototype.hasOwnProperty,_b={current:null},fC={key:!0,ref:!0,__self:!0,__source:!0};function pC(e,t,n){var r,s={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)dC.call(t,r)&&!fC.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),d=0;d<l;d++)c[d]=arguments[d+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:Kf,type:e,key:i,ref:a,props:s,_owner:_b.current}}function R2(e,t){return{$$typeof:Kf,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===Kf}function L2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var W0=/\/+/g;function cy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?L2(""+e.key):t.toString(36)}function _h(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case Kf:case k2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+cy(a,0):r,H0(s)?(n="",e!=null&&(n=e.replace(W0,"$&/")+"/"),_h(s,t,n,"",function(d){return d})):s!=null&&(Pb(s)&&(s=R2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(W0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",H0(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+cy(i,l);a+=_h(i,t,n,c,s)}else if(c=T2(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+cy(i,l++),a+=_h(i,t,n,c,s);else if(i==="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 $p(e,t,n){if(e==null)return e;var r=[],s=0;return _h(e,r,"","",function(i){return t.call(n,i,s++)}),r}function O2(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 as={current:null},Ph={transition:null},M2={ReactCurrentDispatcher:as,ReactCurrentBatchConfig:Ph,ReactCurrentOwner:_b};function hC(){throw Error("act(...) is not supported in production builds of React.")}Ot.Children={map:$p,forEach:function(e,t,n){$p(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return $p(e,function(){t++}),t},toArray:function(e){return $p(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}};Ot.Component=Mu;Ot.Fragment=S2;Ot.Profiler=j2;Ot.PureComponent=Cb;Ot.StrictMode=N2;Ot.Suspense=P2;Ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M2;Ot.act=hC;Ot.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=lC({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=_b.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)dC.call(t,c)&&!fC.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 d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:Kf,type:e.type,key:s,ref:i,props:r,_owner:a}};Ot.createContext=function(e){return e={$$typeof:E2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:C2,_context:e},e.Consumer=e};Ot.createElement=pC;Ot.createFactory=function(e){var t=pC.bind(null,e);return t.type=e,t};Ot.createRef=function(){return{current:null}};Ot.forwardRef=function(e){return{$$typeof:_2,render:e}};Ot.isValidElement=Pb;Ot.lazy=function(e){return{$$typeof:I2,_payload:{_status:-1,_result:e},_init:O2}};Ot.memo=function(e,t){return{$$typeof:A2,type:e,compare:t===void 0?null:t}};Ot.startTransition=function(e){var t=Ph.transition;Ph.transition={};try{e()}finally{Ph.transition=t}};Ot.unstable_act=hC;Ot.useCallback=function(e,t){return as.current.useCallback(e,t)};Ot.useContext=function(e){return as.current.useContext(e)};Ot.useDebugValue=function(){};Ot.useDeferredValue=function(e){return as.current.useDeferredValue(e)};Ot.useEffect=function(e,t){return as.current.useEffect(e,t)};Ot.useId=function(){return as.current.useId()};Ot.useImperativeHandle=function(e,t,n){return as.current.useImperativeHandle(e,t,n)};Ot.useInsertionEffect=function(e,t){return as.current.useInsertionEffect(e,t)};Ot.useLayoutEffect=function(e,t){return as.current.useLayoutEffect(e,t)};Ot.useMemo=function(e,t){return as.current.useMemo(e,t)};Ot.useReducer=function(e,t,n){return as.current.useReducer(e,t,n)};Ot.useRef=function(e){return as.current.useRef(e)};Ot.useState=function(e){return as.current.useState(e)};Ot.useSyncExternalStore=function(e,t,n){return as.current.useSyncExternalStore(e,t,n)};Ot.useTransition=function(){return as.current.useTransition()};Ot.version="18.3.1";oC.exports=Ot;var h=oC.exports;const at=sl(h);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var $2=h,D2=Symbol.for("react.element"),F2=Symbol.for("react.fragment"),z2=Object.prototype.hasOwnProperty,B2=$2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,H2={key:!0,ref:!0,__self:!0,__source:!0};function mC(e,t,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)z2.call(t,r)&&!H2.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:D2,type:e,key:i,ref:a,props:s,_owner:B2.current}}ag.Fragment=F2;ag.jsx=mC;ag.jsxs=mC;iC.exports=ag;var o=iC.exports,Ax={},gC={exports:{}},Us={},yC={exports:{}},xC={};/**
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(_,R){var P=_.length;_.push(R);e:for(;0<P;){var G=P-1>>>1,Z=_[G];if(0<s(Z,R))_[G]=R,_[P]=Z,P=G;else break e}}function n(_){return _.length===0?null:_[0]}function r(_){if(_.length===0)return null;var R=_[0],P=_.pop();if(P!==R){_[0]=P;e:for(var G=0,Z=_.length,V=Z>>>1;G<V;){var se=2*(G+1)-1,ue=_[se],fe=se+1,ge=_[fe];if(0>s(ue,P))fe<Z&&0>s(ge,ue)?(_[G]=ge,_[fe]=P,G=fe):(_[G]=ue,_[se]=P,G=se);else if(fe<Z&&0>s(ge,P))_[G]=ge,_[fe]=P,G=fe;else break e}}return R}function s(_,R){var P=_.sortIndex-R.sortIndex;return P!==0?P:_.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],d=[],f=1,u=null,p=3,m=!1,g=!1,b=!1,v=typeof setTimeout=="function"?setTimeout:null,y=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 w(_){for(var R=n(d);R!==null;){if(R.callback===null)r(d);else if(R.startTime<=_)r(d),R.sortIndex=R.expirationTime,t(c,R);else break;R=n(d)}}function j(_){if(b=!1,w(_),!g)if(n(c)!==null)g=!0,E(A);else{var R=n(d);R!==null&&D(j,R.startTime-_)}}function A(_,R){g=!1,b&&(b=!1,y(B),B=-1),m=!0;var P=p;try{for(w(R),u=n(c);u!==null&&(!(u.expirationTime>R)||_&&!L());){var G=u.callback;if(typeof G=="function"){u.callback=null,p=u.priorityLevel;var Z=G(u.expirationTime<=R);R=e.unstable_now(),typeof Z=="function"?u.callback=Z:u===n(c)&&r(c),w(R)}else r(c);u=n(c)}if(u!==null)var V=!0;else{var se=n(d);se!==null&&D(j,se.startTime-R),V=!1}return V}finally{u=null,p=P,m=!1}}var C=!1,$=null,B=-1,F=5,z=-1;function L(){return!(e.unstable_now()-z<F)}function O(){if($!==null){var _=e.unstable_now();z=_;var R=!0;try{R=$(!0,_)}finally{R?W():(C=!1,$=null)}}else C=!1}var W;if(typeof k=="function")W=function(){k(O)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,T=M.port2;M.port1.onmessage=O,W=function(){T.postMessage(null)}}else W=function(){v(O,0)};function E(_){$=_,C||(C=!0,W())}function D(_,R){B=v(function(){_(e.unstable_now())},R)}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(){g||m||(g=!0,E(A))},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"):F=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 R=3;break;default:R=p}var P=p;p=R;try{return _()}finally{p=P}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,R){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var P=p;p=_;try{return R()}finally{p=P}},e.unstable_scheduleCallback=function(_,R,P){var G=e.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?G+P:G):P=G,_){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=P+Z,_={id:f++,callback:R,priorityLevel:_,startTime:P,expirationTime:Z,sortIndex:-1},P>G?(_.sortIndex=P,t(d,_),n(c)===null&&_===n(d)&&(b?(y(B),B=-1):b=!0,D(j,P-G))):(_.sortIndex=Z,t(c,_),g||m||(g=!0,E(A))),_},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(_){var R=p;return function(){var P=p;p=R;try{return _.apply(this,arguments)}finally{p=P}}}})(xC);yC.exports=xC;var W2=yC.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 V2=h,Ws=W2;function Ne(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 wC=new Set,af={};function ac(e,t){mu(e,t),mu(e+"Capture",t)}function mu(e,t){for(af[e]=t,e=0;e<t.length;e++)wC.add(t[e])}var Jo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ix=Object.prototype.hasOwnProperty,U2=/^[: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]*$/,V0={},U0={};function K2(e){return Ix.call(U0,e)?!0:Ix.call(V0,e)?!1:U2.test(e)?U0[e]=!0:(V0[e]=!0,!1)}function q2(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"||q2(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 ls(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var Fr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Fr[e]=new ls(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Fr[t]=new ls(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Fr[e]=new ls(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Fr[e]=new ls(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){Fr[e]=new ls(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Fr[e]=new ls(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Fr[e]=new ls(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Fr[e]=new ls(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Fr[e]=new ls(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ab=/[\-:]([a-z])/g;function Ib(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(Ab,Ib);Fr[t]=new ls(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(Ab,Ib);Fr[t]=new ls(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(Ab,Ib);Fr[t]=new ls(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Fr[e]=new ls(e,1,!1,e.toLowerCase(),null,!1,!1)});Fr.xlinkHref=new ls("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Fr[e]=new ls(e,1,!1,e.toLowerCase(),null,!0,!0)});function Tb(e,t,n,r){var s=Fr.hasOwnProperty(t)?Fr[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?K2(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 sa=V2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Dp=Symbol.for("react.element"),Fc=Symbol.for("react.portal"),zc=Symbol.for("react.fragment"),Rb=Symbol.for("react.strict_mode"),Tx=Symbol.for("react.profiler"),bC=Symbol.for("react.provider"),vC=Symbol.for("react.context"),Lb=Symbol.for("react.forward_ref"),Rx=Symbol.for("react.suspense"),Lx=Symbol.for("react.suspense_list"),Ob=Symbol.for("react.memo"),_a=Symbol.for("react.lazy"),kC=Symbol.for("react.offscreen"),K0=Symbol.iterator;function dd(e){return e===null||typeof e!="object"?null:(e=K0&&e[K0]||e["@@iterator"],typeof e=="function"?e:null)}var Un=Object.assign,uy;function Pd(e){if(uy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);uy=t&&t[1]||""}return`
34
+ `+uy+e}var dy=!1;function fy(e,t){if(!e||dy)return"";dy=!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(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
+ `),i=r.stack.split(`
36
+ `),a=s.length-1,l=i.length-1;1<=a&&0<=l&&s[a]!==i[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==i[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==i[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{dy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Pd(e):""}function G2(e){switch(e.tag){case 5:return Pd(e.type);case 16:return Pd("Lazy");case 13:return Pd("Suspense");case 19:return Pd("SuspenseList");case 0:case 2:case 15:return e=fy(e.type,!1),e;case 11:return e=fy(e.type.render,!1),e;case 1:return e=fy(e.type,!0),e;default:return""}}function Ox(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 zc:return"Fragment";case Fc:return"Portal";case Tx:return"Profiler";case Rb:return"StrictMode";case Rx:return"Suspense";case Lx:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case vC:return(e.displayName||"Context")+".Consumer";case bC:return(e._context.displayName||"Context")+".Provider";case Lb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ob:return t=e.displayName||null,t!==null?t:Ox(e.type)||"Memo";case _a:t=e._payload,e=e._init;try{return Ox(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 Ox(t);case 8:return t===Rb?"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 Ja(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function SC(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function J2(e){var t=SC(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Fp(e){e._valueTracker||(e._valueTracker=J2(e))}function NC(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=SC(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Qh(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 Mx(e,t){var n=t.checked;return Un({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function q0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ja(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 jC(e,t){t=t.checked,t!=null&&Tb(e,"checked",t,!1)}function $x(e,t){jC(e,t);var n=Ja(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")?Dx(e,t.type,n):t.hasOwnProperty("defaultValue")&&Dx(e,t.type,Ja(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Y0(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 Dx(e,t,n){(t!=="number"||Qh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ad=Array.isArray;function ru(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=""+Ja(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 Fx(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ne(91));return Un({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function G0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ne(92));if(Ad(n)){if(1<n.length)throw Error(Ne(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Ja(n)}}function CC(e,t){var n=Ja(t.value),r=Ja(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 X0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function EC(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 zx(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?EC(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var zp,_C=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(zp=zp||document.createElement("div"),zp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=zp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function lf(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Bd={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},Q2=["Webkit","ms","Moz","O"];Object.keys(Bd).forEach(function(e){Q2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Bd[t]=Bd[e]})});function PC(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Bd.hasOwnProperty(e)&&Bd[e]?(""+t).trim():t+"px"}function AC(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=PC(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Z2=Un({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 Bx(e,t){if(t){if(Z2[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ne(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ne(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ne(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ne(62))}}function Hx(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 Wx=null;function Mb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Vx=null,su=null,iu=null;function J0(e){if(e=Gf(e)){if(typeof Vx!="function")throw Error(Ne(280));var t=e.stateNode;t&&(t=fg(t),Vx(e.stateNode,e.type,t))}}function IC(e){su?iu?iu.push(e):iu=[e]:su=e}function TC(){if(su){var e=su,t=iu;if(iu=su=null,J0(e),t)for(e=0;e<t.length;e++)J0(t[e])}}function RC(e,t){return e(t)}function LC(){}var py=!1;function OC(e,t,n){if(py)return e(t,n);py=!0;try{return RC(e,t,n)}finally{py=!1,(su!==null||iu!==null)&&(LC(),TC())}}function cf(e,t){var n=e.stateNode;if(n===null)return null;var r=fg(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(Ne(231,t,typeof n));return n}var Ux=!1;if(Jo)try{var fd={};Object.defineProperty(fd,"passive",{get:function(){Ux=!0}}),window.addEventListener("test",fd,fd),window.removeEventListener("test",fd,fd)}catch{Ux=!1}function eL(e,t,n,r,s,i,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Hd=!1,Zh=null,em=!1,Kx=null,tL={onError:function(e){Hd=!0,Zh=e}};function nL(e,t,n,r,s,i,a,l,c){Hd=!1,Zh=null,eL.apply(tL,arguments)}function rL(e,t,n,r,s,i,a,l,c){if(nL.apply(this,arguments),Hd){if(Hd){var d=Zh;Hd=!1,Zh=null}else throw Error(Ne(198));em||(em=!0,Kx=d)}}function lc(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 MC(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 Q0(e){if(lc(e)!==e)throw Error(Ne(188))}function sL(e){var t=e.alternate;if(!t){if(t=lc(e),t===null)throw Error(Ne(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return Q0(s),e;if(i===r)return Q0(s),t;i=i.sibling}throw Error(Ne(188))}if(n.return!==r.return)n=s,r=i;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a){for(l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a)throw Error(Ne(189))}}if(n.alternate!==r)throw Error(Ne(190))}if(n.tag!==3)throw Error(Ne(188));return n.stateNode.current===n?e:t}function $C(e){return e=sL(e),e!==null?DC(e):null}function DC(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=DC(e);if(t!==null)return t;e=e.sibling}return null}var FC=Ws.unstable_scheduleCallback,Z0=Ws.unstable_cancelCallback,iL=Ws.unstable_shouldYield,oL=Ws.unstable_requestPaint,ir=Ws.unstable_now,aL=Ws.unstable_getCurrentPriorityLevel,$b=Ws.unstable_ImmediatePriority,zC=Ws.unstable_UserBlockingPriority,tm=Ws.unstable_NormalPriority,lL=Ws.unstable_LowPriority,BC=Ws.unstable_IdlePriority,lg=null,ho=null;function cL(e){if(ho&&typeof ho.onCommitFiberRoot=="function")try{ho.onCommitFiberRoot(lg,e,void 0,(e.current.flags&128)===128)}catch{}}var $i=Math.clz32?Math.clz32:fL,uL=Math.log,dL=Math.LN2;function fL(e){return e>>>=0,e===0?32:31-(uL(e)/dL|0)|0}var Bp=64,Hp=4194304;function Id(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 nm(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=Id(l):(i&=a,i!==0&&(r=Id(i)))}else a=n&~s,a!==0?r=Id(a):i!==0&&(r=Id(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&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-$i(t),s=1<<n,r|=e[n],t&=~s;return r}function pL(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 hL(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-$i(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=pL(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function qx(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function HC(){var e=Bp;return Bp<<=1,!(Bp&4194240)&&(Bp=64),e}function hy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function qf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-$i(t),e[t]=n}function mL(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-$i(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Db(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-$i(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var on=0;function WC(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var VC,Fb,UC,KC,qC,Yx=!1,Wp=[],Fa=null,za=null,Ba=null,uf=new Map,df=new Map,Ta=[],gL="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 ek(e,t){switch(e){case"focusin":case"focusout":Fa=null;break;case"dragenter":case"dragleave":za=null;break;case"mouseover":case"mouseout":Ba=null;break;case"pointerover":case"pointerout":uf.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":df.delete(t.pointerId)}}function pd(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=Gf(t),t!==null&&Fb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function yL(e,t,n,r,s){switch(t){case"focusin":return Fa=pd(Fa,e,t,n,r,s),!0;case"dragenter":return za=pd(za,e,t,n,r,s),!0;case"mouseover":return Ba=pd(Ba,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return uf.set(i,pd(uf.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,df.set(i,pd(df.get(i)||null,e,t,n,r,s)),!0}return!1}function YC(e){var t=Fl(e.target);if(t!==null){var n=lc(t);if(n!==null){if(t=n.tag,t===13){if(t=MC(n),t!==null){e.blockedOn=t,qC(e.priority,function(){UC(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 Ah(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Gx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Wx=r,n.target.dispatchEvent(r),Wx=null}else return t=Gf(n),t!==null&&Fb(t),e.blockedOn=n,!1;t.shift()}return!0}function tk(e,t,n){Ah(e)&&n.delete(t)}function xL(){Yx=!1,Fa!==null&&Ah(Fa)&&(Fa=null),za!==null&&Ah(za)&&(za=null),Ba!==null&&Ah(Ba)&&(Ba=null),uf.forEach(tk),df.forEach(tk)}function hd(e,t){e.blockedOn===t&&(e.blockedOn=null,Yx||(Yx=!0,Ws.unstable_scheduleCallback(Ws.unstable_NormalPriority,xL)))}function ff(e){function t(s){return hd(s,e)}if(0<Wp.length){hd(Wp[0],e);for(var n=1;n<Wp.length;n++){var r=Wp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Fa!==null&&hd(Fa,e),za!==null&&hd(za,e),Ba!==null&&hd(Ba,e),uf.forEach(t),df.forEach(t),n=0;n<Ta.length;n++)r=Ta[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ta.length&&(n=Ta[0],n.blockedOn===null);)YC(n),n.blockedOn===null&&Ta.shift()}var ou=sa.ReactCurrentBatchConfig,rm=!0;function wL(e,t,n,r){var s=on,i=ou.transition;ou.transition=null;try{on=1,zb(e,t,n,r)}finally{on=s,ou.transition=i}}function bL(e,t,n,r){var s=on,i=ou.transition;ou.transition=null;try{on=4,zb(e,t,n,r)}finally{on=s,ou.transition=i}}function zb(e,t,n,r){if(rm){var s=Gx(e,t,n,r);if(s===null)Ny(e,t,r,sm,n),ek(e,r);else if(yL(s,e,t,n,r))r.stopPropagation();else if(ek(e,r),t&4&&-1<gL.indexOf(e)){for(;s!==null;){var i=Gf(s);if(i!==null&&VC(i),i=Gx(e,t,n,r),i===null&&Ny(e,t,r,sm,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else Ny(e,t,r,null,n)}}var sm=null;function Gx(e,t,n,r){if(sm=null,e=Mb(r),e=Fl(e),e!==null)if(t=lc(e),t===null)e=null;else if(n=t.tag,n===13){if(e=MC(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 sm=e,null}function GC(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(aL()){case $b:return 1;case zC:return 4;case tm:case lL:return 16;case BC:return 536870912;default:return 16}default:return 16}}var Oa=null,Bb=null,Ih=null;function XC(){if(Ih)return Ih;var e,t=Bb,n=t.length,r,s="value"in Oa?Oa.value:Oa.textContent,i=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[i-r];r++);return Ih=s.slice(e,1<r?1-r:void 0)}function Th(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 Vp(){return!0}function nk(){return!1}function Ks(e){function t(n,r,s,i,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Vp:nk,this.isPropagationStopped=nk,this}return Un(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=Vp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Vp)},persist:function(){},isPersistent:Vp}),t}var $u={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hb=Ks($u),Yf=Un({},$u,{view:0,detail:0}),vL=Ks(Yf),my,gy,md,cg=Un({},Yf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Wb,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!==md&&(md&&e.type==="mousemove"?(my=e.screenX-md.screenX,gy=e.screenY-md.screenY):gy=my=0,md=e),my)},movementY:function(e){return"movementY"in e?e.movementY:gy}}),rk=Ks(cg),kL=Un({},cg,{dataTransfer:0}),SL=Ks(kL),NL=Un({},Yf,{relatedTarget:0}),yy=Ks(NL),jL=Un({},$u,{animationName:0,elapsedTime:0,pseudoElement:0}),CL=Ks(jL),EL=Un({},$u,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),_L=Ks(EL),PL=Un({},$u,{data:0}),sk=Ks(PL),AL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},IL={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"},TL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function RL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=TL[e])?!!t[e]:!1}function Wb(){return RL}var LL=Un({},Yf,{key:function(e){if(e.key){var t=AL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Th(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?IL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Wb,charCode:function(e){return e.type==="keypress"?Th(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Th(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),OL=Ks(LL),ML=Un({},cg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ik=Ks(ML),$L=Un({},Yf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Wb}),DL=Ks($L),FL=Un({},$u,{propertyName:0,elapsedTime:0,pseudoElement:0}),zL=Ks(FL),BL=Un({},cg,{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}),HL=Ks(BL),WL=[9,13,27,32],Vb=Jo&&"CompositionEvent"in window,Wd=null;Jo&&"documentMode"in document&&(Wd=document.documentMode);var VL=Jo&&"TextEvent"in window&&!Wd,JC=Jo&&(!Vb||Wd&&8<Wd&&11>=Wd),ok=" ",ak=!1;function QC(e,t){switch(e){case"keyup":return WL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ZC(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bc=!1;function UL(e,t){switch(e){case"compositionend":return ZC(t);case"keypress":return t.which!==32?null:(ak=!0,ok);case"textInput":return e=t.data,e===ok&&ak?null:e;default:return null}}function KL(e,t){if(Bc)return e==="compositionend"||!Vb&&QC(e,t)?(e=XC(),Ih=Bb=Oa=null,Bc=!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 JC&&t.locale!=="ko"?null:t.data;default:return null}}var qL={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 lk(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!qL[e.type]:t==="textarea"}function eE(e,t,n,r){IC(r),t=im(t,"onChange"),0<t.length&&(n=new Hb("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Vd=null,pf=null;function YL(e){dE(e,0)}function ug(e){var t=Vc(e);if(NC(t))return e}function GL(e,t){if(e==="change")return t}var tE=!1;if(Jo){var xy;if(Jo){var wy="oninput"in document;if(!wy){var ck=document.createElement("div");ck.setAttribute("oninput","return;"),wy=typeof ck.oninput=="function"}xy=wy}else xy=!1;tE=xy&&(!document.documentMode||9<document.documentMode)}function uk(){Vd&&(Vd.detachEvent("onpropertychange",nE),pf=Vd=null)}function nE(e){if(e.propertyName==="value"&&ug(pf)){var t=[];eE(t,pf,e,Mb(e)),OC(YL,t)}}function XL(e,t,n){e==="focusin"?(uk(),Vd=t,pf=n,Vd.attachEvent("onpropertychange",nE)):e==="focusout"&&uk()}function JL(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ug(pf)}function QL(e,t){if(e==="click")return ug(t)}function ZL(e,t){if(e==="input"||e==="change")return ug(t)}function eO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Fi=typeof Object.is=="function"?Object.is:eO;function hf(e,t){if(Fi(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(!Ix.call(t,s)||!Fi(e[s],t[s]))return!1}return!0}function dk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fk(e,t){var n=dk(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=dk(n)}}function rE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?rE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function sE(){for(var e=window,t=Qh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Qh(e.document)}return t}function Ub(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 tO(e){var t=sE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&rE(n.ownerDocument.documentElement,n)){if(r!==null&&Ub(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=fk(n,i);var a=fk(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var nO=Jo&&"documentMode"in document&&11>=document.documentMode,Hc=null,Xx=null,Ud=null,Jx=!1;function pk(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Jx||Hc==null||Hc!==Qh(r)||(r=Hc,"selectionStart"in r&&Ub(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}),Ud&&hf(Ud,r)||(Ud=r,r=im(Xx,"onSelect"),0<r.length&&(t=new Hb("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Hc)))}function Up(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Wc={animationend:Up("Animation","AnimationEnd"),animationiteration:Up("Animation","AnimationIteration"),animationstart:Up("Animation","AnimationStart"),transitionend:Up("Transition","TransitionEnd")},by={},iE={};Jo&&(iE=document.createElement("div").style,"AnimationEvent"in window||(delete Wc.animationend.animation,delete Wc.animationiteration.animation,delete Wc.animationstart.animation),"TransitionEvent"in window||delete Wc.transitionend.transition);function dg(e){if(by[e])return by[e];if(!Wc[e])return e;var t=Wc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in iE)return by[e]=t[n];return e}var oE=dg("animationend"),aE=dg("animationiteration"),lE=dg("animationstart"),cE=dg("transitionend"),uE=new Map,hk="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 il(e,t){uE.set(e,t),ac(t,[e])}for(var vy=0;vy<hk.length;vy++){var ky=hk[vy],rO=ky.toLowerCase(),sO=ky[0].toUpperCase()+ky.slice(1);il(rO,"on"+sO)}il(oE,"onAnimationEnd");il(aE,"onAnimationIteration");il(lE,"onAnimationStart");il("dblclick","onDoubleClick");il("focusin","onFocus");il("focusout","onBlur");il(cE,"onTransitionEnd");mu("onMouseEnter",["mouseout","mouseover"]);mu("onMouseLeave",["mouseout","mouseover"]);mu("onPointerEnter",["pointerout","pointerover"]);mu("onPointerLeave",["pointerout","pointerover"]);ac("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ac("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ac("onBeforeInput",["compositionend","keypress","textInput","paste"]);ac("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ac("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ac("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Td="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(" "),iO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Td));function mk(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,rL(r,t,void 0,e),e.currentTarget=null}function dE(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 i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;mk(s,l,d),i=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;mk(s,l,d),i=c}}}if(em)throw e=Kx,em=!1,Kx=null,e}function Cn(e,t){var n=t[nw];n===void 0&&(n=t[nw]=new Set);var r=e+"__bubble";n.has(r)||(fE(t,e,2,!1),n.add(r))}function Sy(e,t,n){var r=0;t&&(r|=4),fE(n,e,r,t)}var Kp="_reactListening"+Math.random().toString(36).slice(2);function mf(e){if(!e[Kp]){e[Kp]=!0,wC.forEach(function(n){n!=="selectionchange"&&(iO.has(n)||Sy(n,!1,e),Sy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Kp]||(t[Kp]=!0,Sy("selectionchange",!1,t))}}function fE(e,t,n,r){switch(GC(t)){case 1:var s=wL;break;case 4:s=bL;break;default:s=zb}n=s.bind(null,t,n,e),s=void 0,!Ux||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 Ny(e,t,n,r,s){var i=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=Fl(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}OC(function(){var d=i,f=Mb(n),u=[];e:{var p=uE.get(e);if(p!==void 0){var m=Hb,g=e;switch(e){case"keypress":if(Th(n)===0)break e;case"keydown":case"keyup":m=OL;break;case"focusin":g="focus",m=yy;break;case"focusout":g="blur",m=yy;break;case"beforeblur":case"afterblur":m=yy;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=rk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=SL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=DL;break;case oE:case aE:case lE:m=CL;break;case cE:m=zL;break;case"scroll":m=vL;break;case"wheel":m=HL;break;case"copy":case"cut":case"paste":m=_L;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=ik}var b=(t&4)!==0,v=!b&&e==="scroll",y=b?p!==null?p+"Capture":null:p;b=[];for(var k=d,w;k!==null;){w=k;var j=w.stateNode;if(w.tag===5&&j!==null&&(w=j,y!==null&&(j=cf(k,y),j!=null&&b.push(gf(k,j,w)))),v)break;k=k.return}0<b.length&&(p=new m(p,g,null,n,f),u.push({event:p,listeners:b}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==Wx&&(g=n.relatedTarget||n.fromElement)&&(Fl(g)||g[Qo]))break e;if((m||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,m?(g=n.relatedTarget||n.toElement,m=d,g=g?Fl(g):null,g!==null&&(v=lc(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=d),m!==g)){if(b=rk,j="onMouseLeave",y="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(b=ik,j="onPointerLeave",y="onPointerEnter",k="pointer"),v=m==null?p:Vc(m),w=g==null?p:Vc(g),p=new b(j,k+"leave",m,n,f),p.target=v,p.relatedTarget=w,j=null,Fl(f)===d&&(b=new b(y,k+"enter",g,n,f),b.target=w,b.relatedTarget=v,j=b),v=j,m&&g)t:{for(b=m,y=g,k=0,w=b;w;w=Pc(w))k++;for(w=0,j=y;j;j=Pc(j))w++;for(;0<k-w;)b=Pc(b),k--;for(;0<w-k;)y=Pc(y),w--;for(;k--;){if(b===y||y!==null&&b===y.alternate)break t;b=Pc(b),y=Pc(y)}b=null}else b=null;m!==null&&gk(u,p,m,b,!1),g!==null&&v!==null&&gk(u,v,g,b,!0)}}e:{if(p=d?Vc(d):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var A=GL;else if(lk(p))if(tE)A=ZL;else{A=JL;var C=XL}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(A=QL);if(A&&(A=A(e,d))){eE(u,A,n,f);break e}C&&C(e,p,d),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Dx(p,"number",p.value)}switch(C=d?Vc(d):window,e){case"focusin":(lk(C)||C.contentEditable==="true")&&(Hc=C,Xx=d,Ud=null);break;case"focusout":Ud=Xx=Hc=null;break;case"mousedown":Jx=!0;break;case"contextmenu":case"mouseup":case"dragend":Jx=!1,pk(u,n,f);break;case"selectionchange":if(nO)break;case"keydown":case"keyup":pk(u,n,f)}var $;if(Vb)e:{switch(e){case"compositionstart":var B="onCompositionStart";break e;case"compositionend":B="onCompositionEnd";break e;case"compositionupdate":B="onCompositionUpdate";break e}B=void 0}else Bc?QC(e,n)&&(B="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(B="onCompositionStart");B&&(JC&&n.locale!=="ko"&&(Bc||B!=="onCompositionStart"?B==="onCompositionEnd"&&Bc&&($=XC()):(Oa=f,Bb="value"in Oa?Oa.value:Oa.textContent,Bc=!0)),C=im(d,B),0<C.length&&(B=new sk(B,e,null,n,f),u.push({event:B,listeners:C}),$?B.data=$:($=ZC(n),$!==null&&(B.data=$)))),($=VL?UL(e,n):KL(e,n))&&(d=im(d,"onBeforeInput"),0<d.length&&(f=new sk("onBeforeInput","beforeinput",null,n,f),u.push({event:f,listeners:d}),f.data=$))}dE(u,t)})}function gf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function im(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=cf(e,n),i!=null&&r.unshift(gf(e,i,s)),i=cf(e,t),i!=null&&r.push(gf(e,i,s))),e=e.return}return r}function Pc(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function gk(e,t,n,r,s){for(var i=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,s?(c=cf(n,i),c!=null&&a.unshift(gf(n,c,l))):s||(c=cf(n,i),c!=null&&a.push(gf(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var oO=/\r\n?/g,aO=/\u0000|\uFFFD/g;function yk(e){return(typeof e=="string"?e:""+e).replace(oO,`
38
+ `).replace(aO,"")}function qp(e,t,n){if(t=yk(t),yk(e)!==t&&n)throw Error(Ne(425))}function om(){}var Qx=null,Zx=null;function ew(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 tw=typeof setTimeout=="function"?setTimeout:void 0,lO=typeof clearTimeout=="function"?clearTimeout:void 0,xk=typeof Promise=="function"?Promise:void 0,cO=typeof queueMicrotask=="function"?queueMicrotask:typeof xk<"u"?function(e){return xk.resolve(null).then(e).catch(uO)}:tw;function uO(e){setTimeout(function(){throw e})}function jy(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),ff(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);ff(t)}function Ha(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 wk(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 Du=Math.random().toString(36).slice(2),co="__reactFiber$"+Du,yf="__reactProps$"+Du,Qo="__reactContainer$"+Du,nw="__reactEvents$"+Du,dO="__reactListeners$"+Du,fO="__reactHandles$"+Du;function Fl(e){var t=e[co];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Qo]||n[co]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=wk(e);e!==null;){if(n=e[co])return n;e=wk(e)}return t}e=n,n=e.parentNode}return null}function Gf(e){return e=e[co]||e[Qo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Vc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ne(33))}function fg(e){return e[yf]||null}var rw=[],Uc=-1;function ol(e){return{current:e}}function _n(e){0>Uc||(e.current=rw[Uc],rw[Uc]=null,Uc--)}function wn(e,t){Uc++,rw[Uc]=e.current,e.current=t}var Qa={},Xr=ol(Qa),vs=ol(!1),Xl=Qa;function gu(e,t){var n=e.type.contextTypes;if(!n)return Qa;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function ks(e){return e=e.childContextTypes,e!=null}function am(){_n(vs),_n(Xr)}function bk(e,t,n){if(Xr.current!==Qa)throw Error(Ne(168));wn(Xr,t),wn(vs,n)}function pE(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(Ne(108,X2(e)||"Unknown",s));return Un({},n,r)}function lm(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Qa,Xl=Xr.current,wn(Xr,e),wn(vs,vs.current),!0}function vk(e,t,n){var r=e.stateNode;if(!r)throw Error(Ne(169));n?(e=pE(e,t,Xl),r.__reactInternalMemoizedMergedChildContext=e,_n(vs),_n(Xr),wn(Xr,e)):_n(vs),wn(vs,n)}var Ho=null,pg=!1,Cy=!1;function hE(e){Ho===null?Ho=[e]:Ho.push(e)}function pO(e){pg=!0,hE(e)}function al(){if(!Cy&&Ho!==null){Cy=!0;var e=0,t=on;try{var n=Ho;for(on=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ho=null,pg=!1}catch(s){throw Ho!==null&&(Ho=Ho.slice(e+1)),FC($b,al),s}finally{on=t,Cy=!1}}return null}var Kc=[],qc=0,cm=null,um=0,si=[],ii=0,Jl=null,Uo=1,Ko="";function Ll(e,t){Kc[qc++]=um,Kc[qc++]=cm,cm=e,um=t}function mE(e,t,n){si[ii++]=Uo,si[ii++]=Ko,si[ii++]=Jl,Jl=e;var r=Uo;e=Ko;var s=32-$i(r)-1;r&=~(1<<s),n+=1;var i=32-$i(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Uo=1<<32-$i(t)+s|n<<s|r,Ko=i+e}else Uo=1<<i|n<<s|r,Ko=e}function Kb(e){e.return!==null&&(Ll(e,1),mE(e,1,0))}function qb(e){for(;e===cm;)cm=Kc[--qc],Kc[qc]=null,um=Kc[--qc],Kc[qc]=null;for(;e===Jl;)Jl=si[--ii],si[ii]=null,Ko=si[--ii],si[ii]=null,Uo=si[--ii],si[ii]=null}var Bs=null,Fs=null,$n=!1,Ti=null;function gE(e,t){var n=li(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 kk(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,Bs=e,Fs=Ha(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Bs=e,Fs=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Jl!==null?{id:Uo,overflow:Ko}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=li(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Bs=e,Fs=null,!0):!1;default:return!1}}function sw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function iw(e){if($n){var t=Fs;if(t){var n=t;if(!kk(e,t)){if(sw(e))throw Error(Ne(418));t=Ha(n.nextSibling);var r=Bs;t&&kk(e,t)?gE(r,n):(e.flags=e.flags&-4097|2,$n=!1,Bs=e)}}else{if(sw(e))throw Error(Ne(418));e.flags=e.flags&-4097|2,$n=!1,Bs=e}}}function Sk(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Bs=e}function Yp(e){if(e!==Bs)return!1;if(!$n)return Sk(e),$n=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ew(e.type,e.memoizedProps)),t&&(t=Fs)){if(sw(e))throw yE(),Error(Ne(418));for(;t;)gE(e,t),t=Ha(t.nextSibling)}if(Sk(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ne(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Fs=Ha(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Fs=null}}else Fs=Bs?Ha(e.stateNode.nextSibling):null;return!0}function yE(){for(var e=Fs;e;)e=Ha(e.nextSibling)}function yu(){Fs=Bs=null,$n=!1}function Yb(e){Ti===null?Ti=[e]:Ti.push(e)}var hO=sa.ReactCurrentBatchConfig;function gd(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(Ne(309));var r=n.stateNode}if(!r)throw Error(Ne(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var l=s.refs;a===null?delete l[i]:l[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(Ne(284));if(!n._owner)throw Error(Ne(290,e))}return e}function Gp(e,t){throw e=Object.prototype.toString.call(t),Error(Ne(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Nk(e){var t=e._init;return t(e._payload)}function xE(e){function t(y,k){if(e){var w=y.deletions;w===null?(y.deletions=[k],y.flags|=16):w.push(k)}}function n(y,k){if(!e)return null;for(;k!==null;)t(y,k),k=k.sibling;return null}function r(y,k){for(y=new Map;k!==null;)k.key!==null?y.set(k.key,k):y.set(k.index,k),k=k.sibling;return y}function s(y,k){return y=Ka(y,k),y.index=0,y.sibling=null,y}function i(y,k,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<k?(y.flags|=2,k):w):(y.flags|=2,k)):(y.flags|=1048576,k)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,k,w,j){return k===null||k.tag!==6?(k=Ry(w,y.mode,j),k.return=y,k):(k=s(k,w),k.return=y,k)}function c(y,k,w,j){var A=w.type;return A===zc?f(y,k,w.props.children,j,w.key):k!==null&&(k.elementType===A||typeof A=="object"&&A!==null&&A.$$typeof===_a&&Nk(A)===k.type)?(j=s(k,w.props),j.ref=gd(y,k,w),j.return=y,j):(j=Fh(w.type,w.key,w.props,null,y.mode,j),j.ref=gd(y,k,w),j.return=y,j)}function d(y,k,w,j){return k===null||k.tag!==4||k.stateNode.containerInfo!==w.containerInfo||k.stateNode.implementation!==w.implementation?(k=Ly(w,y.mode,j),k.return=y,k):(k=s(k,w.children||[]),k.return=y,k)}function f(y,k,w,j,A){return k===null||k.tag!==7?(k=Vl(w,y.mode,j,A),k.return=y,k):(k=s(k,w),k.return=y,k)}function u(y,k,w){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Ry(""+k,y.mode,w),k.return=y,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case Dp:return w=Fh(k.type,k.key,k.props,null,y.mode,w),w.ref=gd(y,null,k),w.return=y,w;case Fc:return k=Ly(k,y.mode,w),k.return=y,k;case _a:var j=k._init;return u(y,j(k._payload),w)}if(Ad(k)||dd(k))return k=Vl(k,y.mode,w,null),k.return=y,k;Gp(y,k)}return null}function p(y,k,w,j){var A=k!==null?k.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return A!==null?null:l(y,k,""+w,j);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Dp:return w.key===A?c(y,k,w,j):null;case Fc:return w.key===A?d(y,k,w,j):null;case _a:return A=w._init,p(y,k,A(w._payload),j)}if(Ad(w)||dd(w))return A!==null?null:f(y,k,w,j,null);Gp(y,w)}return null}function m(y,k,w,j,A){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(w)||null,l(k,y,""+j,A);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Dp:return y=y.get(j.key===null?w:j.key)||null,c(k,y,j,A);case Fc:return y=y.get(j.key===null?w:j.key)||null,d(k,y,j,A);case _a:var C=j._init;return m(y,k,w,C(j._payload),A)}if(Ad(j)||dd(j))return y=y.get(w)||null,f(k,y,j,A,null);Gp(k,j)}return null}function g(y,k,w,j){for(var A=null,C=null,$=k,B=k=0,F=null;$!==null&&B<w.length;B++){$.index>B?(F=$,$=null):F=$.sibling;var z=p(y,$,w[B],j);if(z===null){$===null&&($=F);break}e&&$&&z.alternate===null&&t(y,$),k=i(z,k,B),C===null?A=z:C.sibling=z,C=z,$=F}if(B===w.length)return n(y,$),$n&&Ll(y,B),A;if($===null){for(;B<w.length;B++)$=u(y,w[B],j),$!==null&&(k=i($,k,B),C===null?A=$:C.sibling=$,C=$);return $n&&Ll(y,B),A}for($=r(y,$);B<w.length;B++)F=m($,y,B,w[B],j),F!==null&&(e&&F.alternate!==null&&$.delete(F.key===null?B:F.key),k=i(F,k,B),C===null?A=F:C.sibling=F,C=F);return e&&$.forEach(function(L){return t(y,L)}),$n&&Ll(y,B),A}function b(y,k,w,j){var A=dd(w);if(typeof A!="function")throw Error(Ne(150));if(w=A.call(w),w==null)throw Error(Ne(151));for(var C=A=null,$=k,B=k=0,F=null,z=w.next();$!==null&&!z.done;B++,z=w.next()){$.index>B?(F=$,$=null):F=$.sibling;var L=p(y,$,z.value,j);if(L===null){$===null&&($=F);break}e&&$&&L.alternate===null&&t(y,$),k=i(L,k,B),C===null?A=L:C.sibling=L,C=L,$=F}if(z.done)return n(y,$),$n&&Ll(y,B),A;if($===null){for(;!z.done;B++,z=w.next())z=u(y,z.value,j),z!==null&&(k=i(z,k,B),C===null?A=z:C.sibling=z,C=z);return $n&&Ll(y,B),A}for($=r(y,$);!z.done;B++,z=w.next())z=m($,y,B,z.value,j),z!==null&&(e&&z.alternate!==null&&$.delete(z.key===null?B:z.key),k=i(z,k,B),C===null?A=z:C.sibling=z,C=z);return e&&$.forEach(function(O){return t(y,O)}),$n&&Ll(y,B),A}function v(y,k,w,j){if(typeof w=="object"&&w!==null&&w.type===zc&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Dp:e:{for(var A=w.key,C=k;C!==null;){if(C.key===A){if(A=w.type,A===zc){if(C.tag===7){n(y,C.sibling),k=s(C,w.props.children),k.return=y,y=k;break e}}else if(C.elementType===A||typeof A=="object"&&A!==null&&A.$$typeof===_a&&Nk(A)===C.type){n(y,C.sibling),k=s(C,w.props),k.ref=gd(y,C,w),k.return=y,y=k;break e}n(y,C);break}else t(y,C);C=C.sibling}w.type===zc?(k=Vl(w.props.children,y.mode,j,w.key),k.return=y,y=k):(j=Fh(w.type,w.key,w.props,null,y.mode,j),j.ref=gd(y,k,w),j.return=y,y=j)}return a(y);case Fc:e:{for(C=w.key;k!==null;){if(k.key===C)if(k.tag===4&&k.stateNode.containerInfo===w.containerInfo&&k.stateNode.implementation===w.implementation){n(y,k.sibling),k=s(k,w.children||[]),k.return=y,y=k;break e}else{n(y,k);break}else t(y,k);k=k.sibling}k=Ly(w,y.mode,j),k.return=y,y=k}return a(y);case _a:return C=w._init,v(y,k,C(w._payload),j)}if(Ad(w))return g(y,k,w,j);if(dd(w))return b(y,k,w,j);Gp(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,k!==null&&k.tag===6?(n(y,k.sibling),k=s(k,w),k.return=y,y=k):(n(y,k),k=Ry(w,y.mode,j),k.return=y,y=k),a(y)):n(y,k)}return v}var xu=xE(!0),wE=xE(!1),dm=ol(null),fm=null,Yc=null,Gb=null;function Xb(){Gb=Yc=fm=null}function Jb(e){var t=dm.current;_n(dm),e._currentValue=t}function ow(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 au(e,t){fm=e,Gb=Yc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(gs=!0),e.firstContext=null)}function ui(e){var t=e._currentValue;if(Gb!==e)if(e={context:e,memoizedValue:t,next:null},Yc===null){if(fm===null)throw Error(Ne(308));Yc=e,fm.dependencies={lanes:0,firstContext:e}}else Yc=Yc.next=e;return t}var zl=null;function Qb(e){zl===null?zl=[e]:zl.push(e)}function bE(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Qb(t)):(n.next=s.next,s.next=n),t.interleaved=n,Zo(e,r)}function Zo(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 Pa=!1;function Zb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vE(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 Xo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Wa(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,Zo(e,n)}return s=r.interleaved,s===null?(t.next=t,Qb(r)):(t.next=s.next,s.next=t),r.interleaved=t,Zo(e,n)}function Rh(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,Db(e,n)}}function jk(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function pm(e,t,n,r){var s=e.updateQueue;Pa=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,d=c.next;c.next=null,a===null?i=d:a.next=d,a=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==a&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=c))}if(i!==null){var u=s.baseState;a=0,f=d=c=null,l=i;do{var p=l.lane,m=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,b=l;switch(p=t,m=n,b.tag){case 1:if(g=b.payload,typeof g=="function"){u=g.call(m,u,p);break e}u=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,p=typeof g=="function"?g.call(m,u,p):g,p==null)break e;u=Un({},u,p);break e;case 2:Pa=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else m={eventTime:m,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=m,c=u):f=f.next=m,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(f===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);Zl|=a,e.lanes=a,e.memoizedState=u}}function Ck(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(Ne(191,s));s.call(r)}}}var Xf={},mo=ol(Xf),xf=ol(Xf),wf=ol(Xf);function Bl(e){if(e===Xf)throw Error(Ne(174));return e}function ev(e,t){switch(wn(wf,t),wn(xf,e),wn(mo,Xf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:zx(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=zx(t,e)}_n(mo),wn(mo,t)}function wu(){_n(mo),_n(xf),_n(wf)}function kE(e){Bl(wf.current);var t=Bl(mo.current),n=zx(t,e.type);t!==n&&(wn(xf,e),wn(mo,n))}function tv(e){xf.current===e&&(_n(mo),_n(xf))}var Wn=ol(0);function hm(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 Ey=[];function nv(){for(var e=0;e<Ey.length;e++)Ey[e]._workInProgressVersionPrimary=null;Ey.length=0}var Lh=sa.ReactCurrentDispatcher,_y=sa.ReactCurrentBatchConfig,Ql=0,Vn=null,wr=null,Ir=null,mm=!1,Kd=!1,bf=0,mO=0;function Kr(){throw Error(Ne(321))}function rv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Fi(e[n],t[n]))return!1;return!0}function sv(e,t,n,r,s,i){if(Ql=i,Vn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Lh.current=e===null||e.memoizedState===null?wO:bO,e=n(r,s),Kd){i=0;do{if(Kd=!1,bf=0,25<=i)throw Error(Ne(301));i+=1,Ir=wr=null,t.updateQueue=null,Lh.current=vO,e=n(r,s)}while(Kd)}if(Lh.current=gm,t=wr!==null&&wr.next!==null,Ql=0,Ir=wr=Vn=null,mm=!1,t)throw Error(Ne(300));return e}function iv(){var e=bf!==0;return bf=0,e}function io(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ir===null?Vn.memoizedState=Ir=e:Ir=Ir.next=e,Ir}function di(){if(wr===null){var e=Vn.alternate;e=e!==null?e.memoizedState:null}else e=wr.next;var t=Ir===null?Vn.memoizedState:Ir.next;if(t!==null)Ir=t,wr=e;else{if(e===null)throw Error(Ne(310));wr=e,e={memoizedState:wr.memoizedState,baseState:wr.baseState,baseQueue:wr.baseQueue,queue:wr.queue,next:null},Ir===null?Vn.memoizedState=Ir=e:Ir=Ir.next=e}return Ir}function vf(e,t){return typeof t=="function"?t(e):t}function Py(e){var t=di(),n=t.queue;if(n===null)throw Error(Ne(311));n.lastRenderedReducer=e;var r=wr,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var l=a=null,c=null,d=i;do{var f=d.lane;if((Ql&f)===f)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var u={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=u,a=r):c=c.next=u,Vn.lanes|=f,Zl|=f}d=d.next}while(d!==null&&d!==i);c===null?a=r:c.next=l,Fi(r,t.memoizedState)||(gs=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Vn.lanes|=i,Zl|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ay(e){var t=di(),n=t.queue;if(n===null)throw Error(Ne(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do i=e(i,a.action),a=a.next;while(a!==s);Fi(i,t.memoizedState)||(gs=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function SE(){}function NE(e,t){var n=Vn,r=di(),s=t(),i=!Fi(r.memoizedState,s);if(i&&(r.memoizedState=s,gs=!0),r=r.queue,ov(EE.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Ir!==null&&Ir.memoizedState.tag&1){if(n.flags|=2048,kf(9,CE.bind(null,n,r,s,t),void 0,null),Rr===null)throw Error(Ne(349));Ql&30||jE(n,t,s)}return s}function jE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Vn.updateQueue,t===null?(t={lastEffect:null,stores:null},Vn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function CE(e,t,n,r){t.value=n,t.getSnapshot=r,_E(t)&&PE(e)}function EE(e,t,n){return n(function(){_E(t)&&PE(e)})}function _E(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Fi(e,n)}catch{return!0}}function PE(e){var t=Zo(e,1);t!==null&&Di(t,e,1,-1)}function Ek(e){var t=io();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:vf,lastRenderedState:e},t.queue=e,e=e.dispatch=xO.bind(null,Vn,e),[t.memoizedState,e]}function kf(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Vn.updateQueue,t===null?(t={lastEffect:null,stores:null},Vn.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 AE(){return di().memoizedState}function Oh(e,t,n,r){var s=io();Vn.flags|=e,s.memoizedState=kf(1|t,n,void 0,r===void 0?null:r)}function hg(e,t,n,r){var s=di();r=r===void 0?null:r;var i=void 0;if(wr!==null){var a=wr.memoizedState;if(i=a.destroy,r!==null&&rv(r,a.deps)){s.memoizedState=kf(t,n,i,r);return}}Vn.flags|=e,s.memoizedState=kf(1|t,n,i,r)}function _k(e,t){return Oh(8390656,8,e,t)}function ov(e,t){return hg(2048,8,e,t)}function IE(e,t){return hg(4,2,e,t)}function TE(e,t){return hg(4,4,e,t)}function RE(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 LE(e,t,n){return n=n!=null?n.concat([e]):null,hg(4,4,RE.bind(null,t,e),n)}function av(){}function OE(e,t){var n=di();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&rv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ME(e,t){var n=di();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&rv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function $E(e,t,n){return Ql&21?(Fi(n,t)||(n=HC(),Vn.lanes|=n,Zl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,gs=!0),e.memoizedState=n)}function gO(e,t){var n=on;on=n!==0&&4>n?n:4,e(!0);var r=_y.transition;_y.transition={};try{e(!1),t()}finally{on=n,_y.transition=r}}function DE(){return di().memoizedState}function yO(e,t,n){var r=Ua(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},FE(e))zE(t,n);else if(n=bE(e,t,n,r),n!==null){var s=os();Di(n,e,r,s),BE(n,t,r)}}function xO(e,t,n){var r=Ua(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(FE(e))zE(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,l=i(a,n);if(s.hasEagerState=!0,s.eagerState=l,Fi(l,a)){var c=t.interleaved;c===null?(s.next=s,Qb(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=bE(e,t,s,r),n!==null&&(s=os(),Di(n,e,r,s),BE(n,t,r))}}function FE(e){var t=e.alternate;return e===Vn||t!==null&&t===Vn}function zE(e,t){Kd=mm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function BE(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Db(e,n)}}var gm={readContext:ui,useCallback:Kr,useContext:Kr,useEffect:Kr,useImperativeHandle:Kr,useInsertionEffect:Kr,useLayoutEffect:Kr,useMemo:Kr,useReducer:Kr,useRef:Kr,useState:Kr,useDebugValue:Kr,useDeferredValue:Kr,useTransition:Kr,useMutableSource:Kr,useSyncExternalStore:Kr,useId:Kr,unstable_isNewReconciler:!1},wO={readContext:ui,useCallback:function(e,t){return io().memoizedState=[e,t===void 0?null:t],e},useContext:ui,useEffect:_k,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Oh(4194308,4,RE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Oh(4194308,4,e,t)},useInsertionEffect:function(e,t){return Oh(4,2,e,t)},useMemo:function(e,t){var n=io();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=io();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=yO.bind(null,Vn,e),[r.memoizedState,e]},useRef:function(e){var t=io();return e={current:e},t.memoizedState=e},useState:Ek,useDebugValue:av,useDeferredValue:function(e){return io().memoizedState=e},useTransition:function(){var e=Ek(!1),t=e[0];return e=gO.bind(null,e[1]),io().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Vn,s=io();if($n){if(n===void 0)throw Error(Ne(407));n=n()}else{if(n=t(),Rr===null)throw Error(Ne(349));Ql&30||jE(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,_k(EE.bind(null,r,i,e),[e]),r.flags|=2048,kf(9,CE.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=io(),t=Rr.identifierPrefix;if($n){var n=Ko,r=Uo;n=(r&~(1<<32-$i(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=bf++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=mO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},bO={readContext:ui,useCallback:OE,useContext:ui,useEffect:ov,useImperativeHandle:LE,useInsertionEffect:IE,useLayoutEffect:TE,useMemo:ME,useReducer:Py,useRef:AE,useState:function(){return Py(vf)},useDebugValue:av,useDeferredValue:function(e){var t=di();return $E(t,wr.memoizedState,e)},useTransition:function(){var e=Py(vf)[0],t=di().memoizedState;return[e,t]},useMutableSource:SE,useSyncExternalStore:NE,useId:DE,unstable_isNewReconciler:!1},vO={readContext:ui,useCallback:OE,useContext:ui,useEffect:ov,useImperativeHandle:LE,useInsertionEffect:IE,useLayoutEffect:TE,useMemo:ME,useReducer:Ay,useRef:AE,useState:function(){return Ay(vf)},useDebugValue:av,useDeferredValue:function(e){var t=di();return wr===null?t.memoizedState=e:$E(t,wr.memoizedState,e)},useTransition:function(){var e=Ay(vf)[0],t=di().memoizedState;return[e,t]},useMutableSource:SE,useSyncExternalStore:NE,useId:DE,unstable_isNewReconciler:!1};function Pi(e,t){if(e&&e.defaultProps){t=Un({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function aw(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Un({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var mg={isMounted:function(e){return(e=e._reactInternals)?lc(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=os(),s=Ua(e),i=Xo(r,s);i.payload=t,n!=null&&(i.callback=n),t=Wa(e,i,s),t!==null&&(Di(t,e,s,r),Rh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=os(),s=Ua(e),i=Xo(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Wa(e,i,s),t!==null&&(Di(t,e,s,r),Rh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=os(),r=Ua(e),s=Xo(n,r);s.tag=2,t!=null&&(s.callback=t),t=Wa(e,s,r),t!==null&&(Di(t,e,r,n),Rh(t,e,r))}};function Pk(e,t,n,r,s,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!hf(n,r)||!hf(s,i):!0}function HE(e,t,n){var r=!1,s=Qa,i=t.contextType;return typeof i=="object"&&i!==null?i=ui(i):(s=ks(t)?Xl:Xr.current,r=t.contextTypes,i=(r=r!=null)?gu(e,s):Qa),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=mg,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Ak(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&&mg.enqueueReplaceState(t,t.state,null)}function lw(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Zb(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=ui(i):(i=ks(t)?Xl:Xr.current,s.context=gu(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(aw(e,t,i,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&&mg.enqueueReplaceState(s,s.state,null),pm(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function bu(e,t){try{var n="",r=t;do n+=G2(r),r=r.return;while(r);var s=n}catch(i){s=`
39
+ Error generating stack: `+i.message+`
40
+ `+i.stack}return{value:e,source:t,stack:s,digest:null}}function Iy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function cw(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var kO=typeof WeakMap=="function"?WeakMap:Map;function WE(e,t,n){n=Xo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){xm||(xm=!0,ww=r),cw(e,t)},n}function VE(e,t,n){n=Xo(-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(){cw(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){cw(e,t),typeof r!="function"&&(Va===null?Va=new Set([this]):Va.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Ik(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=MO.bind(null,e,t,n),t.then(e,e))}function Tk(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 Rk(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=Xo(-1,1),t.tag=2,Wa(n,t,1))),n.lanes|=1),e)}var SO=sa.ReactCurrentOwner,gs=!1;function ss(e,t,n,r){t.child=e===null?wE(t,null,n,r):xu(t,e.child,n,r)}function Lk(e,t,n,r,s){n=n.render;var i=t.ref;return au(t,s),r=sv(e,t,n,r,i,s),n=iv(),e!==null&&!gs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ea(e,t,s)):($n&&n&&Kb(t),t.flags|=1,ss(e,t,r,s),t.child)}function Ok(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!mv(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,UE(e,t,i,r,s)):(e=Fh(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:hf,n(a,r)&&e.ref===t.ref)return ea(e,t,s)}return t.flags|=1,e=Ka(i,r),e.ref=t.ref,e.return=t,t.child=e}function UE(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(hf(i,r)&&e.ref===t.ref)if(gs=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(gs=!0);else return t.lanes=e.lanes,ea(e,t,s)}return uw(e,t,n,r,s)}function KE(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},wn(Xc,Ms),Ms|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,wn(Xc,Ms),Ms|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,wn(Xc,Ms),Ms|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,wn(Xc,Ms),Ms|=r;return ss(e,t,s,n),t.child}function qE(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function uw(e,t,n,r,s){var i=ks(n)?Xl:Xr.current;return i=gu(t,i),au(t,s),n=sv(e,t,n,r,i,s),r=iv(),e!==null&&!gs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ea(e,t,s)):($n&&r&&Kb(t),t.flags|=1,ss(e,t,n,s),t.child)}function Mk(e,t,n,r,s){if(ks(n)){var i=!0;lm(t)}else i=!1;if(au(t,s),t.stateNode===null)Mh(e,t),HE(t,n,r),lw(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=ui(d):(d=ks(n)?Xl:Xr.current,d=gu(t,d));var f=n.getDerivedStateFromProps,u=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function";u||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Ak(t,a,r,d),Pa=!1;var p=t.memoizedState;a.state=p,pm(t,r,a,s),c=t.memoizedState,l!==r||p!==c||vs.current||Pa?(typeof f=="function"&&(aw(t,n,f,r),c=t.memoizedState),(l=Pa||Pk(t,n,l,r,p,c,d))?(u||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=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,vE(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Pi(t.type,l),a.props=d,u=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=ui(c):(c=ks(n)?Xl:Xr.current,c=gu(t,c));var m=n.getDerivedStateFromProps;(f=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==u||p!==c)&&Ak(t,a,r,c),Pa=!1,p=t.memoizedState,a.state=p,pm(t,r,a,s);var g=t.memoizedState;l!==u||p!==g||vs.current||Pa?(typeof m=="function"&&(aw(t,n,m,r),g=t.memoizedState),(d=Pa||Pk(t,n,d,r,p,g,c)||!1)?(f||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,g,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,g,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=g),a.props=r,a.state=g,a.context=c,r=d):(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 dw(e,t,n,r,i,s)}function dw(e,t,n,r,s,i){qE(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&vk(t,n,!1),ea(e,t,i);r=t.stateNode,SO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=xu(t,e.child,null,i),t.child=xu(t,null,l,i)):ss(e,t,l,i),t.memoizedState=r.state,s&&vk(t,n,!0),t.child}function YE(e){var t=e.stateNode;t.pendingContext?bk(e,t.pendingContext,t.pendingContext!==t.context):t.context&&bk(e,t.context,!1),ev(e,t.containerInfo)}function $k(e,t,n,r,s){return yu(),Yb(s),t.flags|=256,ss(e,t,n,r),t.child}var fw={dehydrated:null,treeContext:null,retryLane:0};function pw(e){return{baseLanes:e,cachePool:null,transitions:null}}function GE(e,t,n){var r=t.pendingProps,s=Wn.current,i=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),wn(Wn,s&1),e===null)return iw(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,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=xg(a,r,0,null),e=Vl(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=pw(n),t.memoizedState=fw,e):lv(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return NO(e,t,a,r,l,s,n);if(i){i=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=Ka(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=Ka(l,i):(i=Vl(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?pw(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=fw,r}return i=e.child,e=i.sibling,r=Ka(i,{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 lv(e,t){return t=xg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Xp(e,t,n,r){return r!==null&&Yb(r),xu(t,e.child,null,n),e=lv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function NO(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=Iy(Error(Ne(422))),Xp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=xg({mode:"visible",children:r.children},s,0,null),i=Vl(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&xu(t,e.child,null,a),t.child.memoizedState=pw(a),t.memoizedState=fw,i);if(!(t.mode&1))return Xp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(Ne(419)),r=Iy(i,r,void 0),Xp(e,t,a,r)}if(l=(a&e.childLanes)!==0,gs||l){if(r=Rr,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!==i.retryLane&&(i.retryLane=s,Zo(e,s),Di(r,e,s,-1))}return hv(),r=Iy(Error(Ne(421))),Xp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=$O.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Fs=Ha(s.nextSibling),Bs=t,$n=!0,Ti=null,e!==null&&(si[ii++]=Uo,si[ii++]=Ko,si[ii++]=Jl,Uo=e.id,Ko=e.overflow,Jl=t),t=lv(t,r.children),t.flags|=4096,t)}function Dk(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ow(e.return,t,n)}function Ty(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function XE(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(ss(e,t,r.children,n),r=Wn.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&&Dk(e,n,t);else if(e.tag===19)Dk(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(wn(Wn,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&&hm(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Ty(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&hm(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Ty(t,!0,n,null,i);break;case"together":Ty(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Mh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ea(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Zl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ne(153));if(t.child!==null){for(e=t.child,n=Ka(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ka(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function jO(e,t,n){switch(t.tag){case 3:YE(t),yu();break;case 5:kE(t);break;case 1:ks(t.type)&&lm(t);break;case 4:ev(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;wn(dm,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(wn(Wn,Wn.current&1),t.flags|=128,null):n&t.child.childLanes?GE(e,t,n):(wn(Wn,Wn.current&1),e=ea(e,t,n),e!==null?e.sibling:null);wn(Wn,Wn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return XE(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),wn(Wn,Wn.current),r)break;return null;case 22:case 23:return t.lanes=0,KE(e,t,n)}return ea(e,t,n)}var JE,hw,QE,ZE;JE=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}};hw=function(){};QE=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Bl(mo.current);var i=null;switch(n){case"input":s=Mx(e,s),r=Mx(e,r),i=[];break;case"select":s=Un({},s,{value:void 0}),r=Un({},r,{value:void 0}),i=[];break;case"textarea":s=Fx(e,s),r=Fx(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=om)}Bx(n,r);var a;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(af.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var c=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="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||(i||(i=[]),i.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(af.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Cn("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};ZE=function(e,t,n,r){n!==r&&(t.flags|=4)};function yd(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 qr(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 CO(e,t,n){var r=t.pendingProps;switch(qb(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qr(t),null;case 1:return ks(t.type)&&am(),qr(t),null;case 3:return r=t.stateNode,wu(),_n(vs),_n(Xr),nv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Yp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ti!==null&&(kw(Ti),Ti=null))),hw(e,t),qr(t),null;case 5:tv(t);var s=Bl(wf.current);if(n=t.type,e!==null&&t.stateNode!=null)QE(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ne(166));return qr(t),null}if(e=Bl(mo.current),Yp(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[co]=t,r[yf]=i,e=(t.mode&1)!==0,n){case"dialog":Cn("cancel",r),Cn("close",r);break;case"iframe":case"object":case"embed":Cn("load",r);break;case"video":case"audio":for(s=0;s<Td.length;s++)Cn(Td[s],r);break;case"source":Cn("error",r);break;case"img":case"image":case"link":Cn("error",r),Cn("load",r);break;case"details":Cn("toggle",r);break;case"input":q0(r,i),Cn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Cn("invalid",r);break;case"textarea":G0(r,i),Cn("invalid",r)}Bx(n,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var l=i[a];a==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&qp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&qp(r.textContent,l,e),s=["children",""+l]):af.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Cn("scroll",r)}switch(n){case"input":Fp(r),Y0(r,i,!0);break;case"textarea":Fp(r),X0(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=om)}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=EC(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[co]=t,e[yf]=r,JE(e,t,!1,!1),t.stateNode=e;e:{switch(a=Hx(n,r),n){case"dialog":Cn("cancel",e),Cn("close",e),s=r;break;case"iframe":case"object":case"embed":Cn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Td.length;s++)Cn(Td[s],e);s=r;break;case"source":Cn("error",e),s=r;break;case"img":case"image":case"link":Cn("error",e),Cn("load",e),s=r;break;case"details":Cn("toggle",e),s=r;break;case"input":q0(e,r),s=Mx(e,r),Cn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Un({},r,{value:void 0}),Cn("invalid",e);break;case"textarea":G0(e,r),s=Fx(e,r),Cn("invalid",e);break;default:s=r}Bx(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?AC(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&_C(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&lf(e,c):typeof c=="number"&&lf(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(af.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Cn("scroll",e):c!=null&&Tb(e,i,c,a))}switch(n){case"input":Fp(e),Y0(e,r,!1);break;case"textarea":Fp(e),X0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Ja(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?ru(e,!!r.multiple,i,!1):r.defaultValue!=null&&ru(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=om)}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 qr(t),null;case 6:if(e&&t.stateNode!=null)ZE(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ne(166));if(n=Bl(wf.current),Bl(mo.current),Yp(t)){if(r=t.stateNode,n=t.memoizedProps,r[co]=t,(i=r.nodeValue!==n)&&(e=Bs,e!==null))switch(e.tag){case 3:qp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&qp(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[co]=t,t.stateNode=r}return qr(t),null;case 13:if(_n(Wn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if($n&&Fs!==null&&t.mode&1&&!(t.flags&128))yE(),yu(),t.flags|=98560,i=!1;else if(i=Yp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(Ne(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ne(317));i[co]=t}else yu(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;qr(t),i=!1}else Ti!==null&&(kw(Ti),Ti=null),i=!0;if(!i)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||Wn.current&1?vr===0&&(vr=3):hv())),t.updateQueue!==null&&(t.flags|=4),qr(t),null);case 4:return wu(),hw(e,t),e===null&&mf(t.stateNode.containerInfo),qr(t),null;case 10:return Jb(t.type._context),qr(t),null;case 17:return ks(t.type)&&am(),qr(t),null;case 19:if(_n(Wn),i=t.memoizedState,i===null)return qr(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)yd(i,!1);else{if(vr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=hm(e),a!==null){for(t.flags|=128,yd(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return wn(Wn,Wn.current&1|2),t.child}e=e.sibling}i.tail!==null&&ir()>vu&&(t.flags|=128,r=!0,yd(i,!1),t.lanes=4194304)}else{if(!r)if(e=hm(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),yd(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!$n)return qr(t),null}else 2*ir()-i.renderingStartTime>vu&&n!==1073741824&&(t.flags|=128,r=!0,yd(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=ir(),t.sibling=null,n=Wn.current,wn(Wn,r?n&1|2:n&1),t):(qr(t),null);case 22:case 23:return pv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ms&1073741824&&(qr(t),t.subtreeFlags&6&&(t.flags|=8192)):qr(t),null;case 24:return null;case 25:return null}throw Error(Ne(156,t.tag))}function EO(e,t){switch(qb(t),t.tag){case 1:return ks(t.type)&&am(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return wu(),_n(vs),_n(Xr),nv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return tv(t),null;case 13:if(_n(Wn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ne(340));yu()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _n(Wn),null;case 4:return wu(),null;case 10:return Jb(t.type._context),null;case 22:case 23:return pv(),null;case 24:return null;default:return null}}var Jp=!1,Yr=!1,_O=typeof WeakSet=="function"?WeakSet:Set,He=null;function Gc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Jn(e,t,r)}else n.current=null}function mw(e,t,n){try{n()}catch(r){Jn(e,t,r)}}var Fk=!1;function PO(e,t){if(Qx=rm,e=sE(),Ub(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,d=0,f=0,u=e,p=null;t:for(;;){for(var m;u!==n||s!==0&&u.nodeType!==3||(l=a+s),u!==i||r!==0&&u.nodeType!==3||(c=a+r),u.nodeType===3&&(a+=u.nodeValue.length),(m=u.firstChild)!==null;)p=u,u=m;for(;;){if(u===e)break t;if(p===n&&++d===s&&(l=a),p===i&&++f===r&&(c=a),(m=u.nextSibling)!==null)break;u=p,p=u.parentNode}u=m}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Zx={focusedElem:e,selectionRange:n},rm=!1,He=t;He!==null;)if(t=He,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,He=e;else for(;He!==null;){t=He;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var b=g.memoizedProps,v=g.memoizedState,y=t.stateNode,k=y.getSnapshotBeforeUpdate(t.elementType===t.type?b:Pi(t.type,b),v);y.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ne(163))}}catch(j){Jn(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,He=e;break}He=t.return}return g=Fk,Fk=!1,g}function qd(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&mw(t,n,i)}s=s.next}while(s!==r)}}function gg(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 gw(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 e_(e){var t=e.alternate;t!==null&&(e.alternate=null,e_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[co],delete t[yf],delete t[nw],delete t[dO],delete t[fO])),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 t_(e){return e.tag===5||e.tag===3||e.tag===4}function zk(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||t_(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 yw(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=om));else if(r!==4&&(e=e.child,e!==null))for(yw(e,t,n),e=e.sibling;e!==null;)yw(e,t,n),e=e.sibling}function xw(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(xw(e,t,n),e=e.sibling;e!==null;)xw(e,t,n),e=e.sibling}var Or=null,Ai=!1;function va(e,t,n){for(n=n.child;n!==null;)n_(e,t,n),n=n.sibling}function n_(e,t,n){if(ho&&typeof ho.onCommitFiberUnmount=="function")try{ho.onCommitFiberUnmount(lg,n)}catch{}switch(n.tag){case 5:Yr||Gc(n,t);case 6:var r=Or,s=Ai;Or=null,va(e,t,n),Or=r,Ai=s,Or!==null&&(Ai?(e=Or,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Or.removeChild(n.stateNode));break;case 18:Or!==null&&(Ai?(e=Or,n=n.stateNode,e.nodeType===8?jy(e.parentNode,n):e.nodeType===1&&jy(e,n),ff(e)):jy(Or,n.stateNode));break;case 4:r=Or,s=Ai,Or=n.stateNode.containerInfo,Ai=!0,va(e,t,n),Or=r,Ai=s;break;case 0:case 11:case 14:case 15:if(!Yr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&mw(n,t,a),s=s.next}while(s!==r)}va(e,t,n);break;case 1:if(!Yr&&(Gc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Jn(n,t,l)}va(e,t,n);break;case 21:va(e,t,n);break;case 22:n.mode&1?(Yr=(r=Yr)||n.memoizedState!==null,va(e,t,n),Yr=r):va(e,t,n);break;default:va(e,t,n)}}function Bk(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new _O),t.forEach(function(r){var s=DO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Ci(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Or=l.stateNode,Ai=!1;break e;case 3:Or=l.stateNode.containerInfo,Ai=!0;break e;case 4:Or=l.stateNode.containerInfo,Ai=!0;break e}l=l.return}if(Or===null)throw Error(Ne(160));n_(i,a,s),Or=null,Ai=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){Jn(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)r_(t,e),t=t.sibling}function r_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Ci(t,e),ro(e),r&4){try{qd(3,e,e.return),gg(3,e)}catch(b){Jn(e,e.return,b)}try{qd(5,e,e.return)}catch(b){Jn(e,e.return,b)}}break;case 1:Ci(t,e),ro(e),r&512&&n!==null&&Gc(n,n.return);break;case 5:if(Ci(t,e),ro(e),r&512&&n!==null&&Gc(n,n.return),e.flags&32){var s=e.stateNode;try{lf(s,"")}catch(b){Jn(e,e.return,b)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,a=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&jC(s,i),Hx(l,a);var d=Hx(l,i);for(a=0;a<c.length;a+=2){var f=c[a],u=c[a+1];f==="style"?AC(s,u):f==="dangerouslySetInnerHTML"?_C(s,u):f==="children"?lf(s,u):Tb(s,f,u,d)}switch(l){case"input":$x(s,i);break;case"textarea":CC(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?ru(s,!!i.multiple,m,!1):p!==!!i.multiple&&(i.defaultValue!=null?ru(s,!!i.multiple,i.defaultValue,!0):ru(s,!!i.multiple,i.multiple?[]:"",!1))}s[yf]=i}catch(b){Jn(e,e.return,b)}}break;case 6:if(Ci(t,e),ro(e),r&4){if(e.stateNode===null)throw Error(Ne(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(b){Jn(e,e.return,b)}}break;case 3:if(Ci(t,e),ro(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{ff(t.containerInfo)}catch(b){Jn(e,e.return,b)}break;case 4:Ci(t,e),ro(e);break;case 13:Ci(t,e),ro(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(dv=ir())),r&4&&Bk(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Yr=(d=Yr)||f,Ci(t,e),Yr=d):Ci(t,e),ro(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(He=e,f=e.child;f!==null;){for(u=He=f;He!==null;){switch(p=He,m=p.child,p.tag){case 0:case 11:case 14:case 15:qd(4,p,p.return);break;case 1:Gc(p,p.return);var g=p.stateNode;if(typeof g.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(b){Jn(r,n,b)}}break;case 5:Gc(p,p.return);break;case 22:if(p.memoizedState!==null){Wk(u);continue}}m!==null?(m.return=p,He=m):Wk(u)}f=f.sibling}e:for(f=null,u=e;;){if(u.tag===5){if(f===null){f=u;try{s=u.stateNode,d?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=u.stateNode,c=u.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=PC("display",a))}catch(b){Jn(e,e.return,b)}}}else if(u.tag===6){if(f===null)try{u.stateNode.nodeValue=d?"":u.memoizedProps}catch(b){Jn(e,e.return,b)}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===e)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===e)break e;for(;u.sibling===null;){if(u.return===null||u.return===e)break e;f===u&&(f=null),u=u.return}f===u&&(f=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:Ci(t,e),ro(e),r&4&&Bk(e);break;case 21:break;default:Ci(t,e),ro(e)}}function ro(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(t_(n)){var r=n;break e}n=n.return}throw Error(Ne(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(lf(s,""),r.flags&=-33);var i=zk(e);xw(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=zk(e);yw(e,l,a);break;default:throw Error(Ne(161))}}catch(c){Jn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function AO(e,t,n){He=e,s_(e)}function s_(e,t,n){for(var r=(e.mode&1)!==0;He!==null;){var s=He,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||Jp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Yr;l=Jp;var d=Yr;if(Jp=a,(Yr=c)&&!d)for(He=s;He!==null;)a=He,c=a.child,a.tag===22&&a.memoizedState!==null?Vk(s):c!==null?(c.return=a,He=c):Vk(s);for(;i!==null;)He=i,s_(i),i=i.sibling;He=s,Jp=l,Yr=d}Hk(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,He=i):Hk(e)}}function Hk(e){for(;He!==null;){var t=He;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Yr||gg(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Yr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Pi(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Ck(t,i,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}Ck(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 d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var u=f.dehydrated;u!==null&&ff(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ne(163))}Yr||t.flags&512&&gw(t)}catch(p){Jn(t,t.return,p)}}if(t===e){He=null;break}if(n=t.sibling,n!==null){n.return=t.return,He=n;break}He=t.return}}function Wk(e){for(;He!==null;){var t=He;if(t===e){He=null;break}var n=t.sibling;if(n!==null){n.return=t.return,He=n;break}He=t.return}}function Vk(e){for(;He!==null;){var t=He;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{gg(4,t)}catch(c){Jn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Jn(t,s,c)}}var i=t.return;try{gw(t)}catch(c){Jn(t,i,c)}break;case 5:var a=t.return;try{gw(t)}catch(c){Jn(t,a,c)}}}catch(c){Jn(t,t.return,c)}if(t===e){He=null;break}var l=t.sibling;if(l!==null){l.return=t.return,He=l;break}He=t.return}}var IO=Math.ceil,ym=sa.ReactCurrentDispatcher,cv=sa.ReactCurrentOwner,ci=sa.ReactCurrentBatchConfig,qt=0,Rr=null,pr=null,$r=0,Ms=0,Xc=ol(0),vr=0,Sf=null,Zl=0,yg=0,uv=0,Yd=null,ms=null,dv=0,vu=1/0,Bo=null,xm=!1,ww=null,Va=null,Qp=!1,Ma=null,wm=0,Gd=0,bw=null,$h=-1,Dh=0;function os(){return qt&6?ir():$h!==-1?$h:$h=ir()}function Ua(e){return e.mode&1?qt&2&&$r!==0?$r&-$r:hO.transition!==null?(Dh===0&&(Dh=HC()),Dh):(e=on,e!==0||(e=window.event,e=e===void 0?16:GC(e.type)),e):1}function Di(e,t,n,r){if(50<Gd)throw Gd=0,bw=null,Error(Ne(185));qf(e,n,r),(!(qt&2)||e!==Rr)&&(e===Rr&&(!(qt&2)&&(yg|=n),vr===4&&Ra(e,$r)),Ss(e,r),n===1&&qt===0&&!(t.mode&1)&&(vu=ir()+500,pg&&al()))}function Ss(e,t){var n=e.callbackNode;hL(e,t);var r=nm(e,e===Rr?$r:0);if(r===0)n!==null&&Z0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Z0(n),t===1)e.tag===0?pO(Uk.bind(null,e)):hE(Uk.bind(null,e)),cO(function(){!(qt&6)&&al()}),n=null;else{switch(WC(r)){case 1:n=$b;break;case 4:n=zC;break;case 16:n=tm;break;case 536870912:n=BC;break;default:n=tm}n=f_(n,i_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function i_(e,t){if($h=-1,Dh=0,qt&6)throw Error(Ne(327));var n=e.callbackNode;if(lu()&&e.callbackNode!==n)return null;var r=nm(e,e===Rr?$r:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=bm(e,r);else{t=r;var s=qt;qt|=2;var i=a_();(Rr!==e||$r!==t)&&(Bo=null,vu=ir()+500,Wl(e,t));do try{LO();break}catch(l){o_(e,l)}while(!0);Xb(),ym.current=i,qt=s,pr!==null?t=0:(Rr=null,$r=0,t=vr)}if(t!==0){if(t===2&&(s=qx(e),s!==0&&(r=s,t=vw(e,s))),t===1)throw n=Sf,Wl(e,0),Ra(e,r),Ss(e,ir()),n;if(t===6)Ra(e,r);else{if(s=e.current.alternate,!(r&30)&&!TO(s)&&(t=bm(e,r),t===2&&(i=qx(e),i!==0&&(r=i,t=vw(e,i))),t===1))throw n=Sf,Wl(e,0),Ra(e,r),Ss(e,ir()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ne(345));case 2:Ol(e,ms,Bo);break;case 3:if(Ra(e,r),(r&130023424)===r&&(t=dv+500-ir(),10<t)){if(nm(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){os(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=tw(Ol.bind(null,e,ms,Bo),t);break}Ol(e,ms,Bo);break;case 4:if(Ra(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-$i(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=ir()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*IO(r/1960))-r,10<r){e.timeoutHandle=tw(Ol.bind(null,e,ms,Bo),r);break}Ol(e,ms,Bo);break;case 5:Ol(e,ms,Bo);break;default:throw Error(Ne(329))}}}return Ss(e,ir()),e.callbackNode===n?i_.bind(null,e):null}function vw(e,t){var n=Yd;return e.current.memoizedState.isDehydrated&&(Wl(e,t).flags|=256),e=bm(e,t),e!==2&&(t=ms,ms=n,t!==null&&kw(t)),e}function kw(e){ms===null?ms=e:ms.push.apply(ms,e)}function TO(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],i=s.getSnapshot;s=s.value;try{if(!Fi(i(),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 Ra(e,t){for(t&=~uv,t&=~yg,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-$i(t),r=1<<n;e[n]=-1,t&=~r}}function Uk(e){if(qt&6)throw Error(Ne(327));lu();var t=nm(e,0);if(!(t&1))return Ss(e,ir()),null;var n=bm(e,t);if(e.tag!==0&&n===2){var r=qx(e);r!==0&&(t=r,n=vw(e,r))}if(n===1)throw n=Sf,Wl(e,0),Ra(e,t),Ss(e,ir()),n;if(n===6)throw Error(Ne(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ol(e,ms,Bo),Ss(e,ir()),null}function fv(e,t){var n=qt;qt|=1;try{return e(t)}finally{qt=n,qt===0&&(vu=ir()+500,pg&&al())}}function ec(e){Ma!==null&&Ma.tag===0&&!(qt&6)&&lu();var t=qt;qt|=1;var n=ci.transition,r=on;try{if(ci.transition=null,on=1,e)return e()}finally{on=r,ci.transition=n,qt=t,!(qt&6)&&al()}}function pv(){Ms=Xc.current,_n(Xc)}function Wl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,lO(n)),pr!==null)for(n=pr.return;n!==null;){var r=n;switch(qb(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&am();break;case 3:wu(),_n(vs),_n(Xr),nv();break;case 5:tv(r);break;case 4:wu();break;case 13:_n(Wn);break;case 19:_n(Wn);break;case 10:Jb(r.type._context);break;case 22:case 23:pv()}n=n.return}if(Rr=e,pr=e=Ka(e.current,null),$r=Ms=t,vr=0,Sf=null,uv=yg=Zl=0,ms=Yd=null,zl!==null){for(t=0;t<zl.length;t++)if(n=zl[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=s,r.next=a}n.pending=r}zl=null}return e}function o_(e,t){do{var n=pr;try{if(Xb(),Lh.current=gm,mm){for(var r=Vn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}mm=!1}if(Ql=0,Ir=wr=Vn=null,Kd=!1,bf=0,cv.current=null,n===null||n.return===null){vr=1,Sf=t,pr=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=$r,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,f=l,u=f.tag;if(!(f.mode&1)&&(u===0||u===11||u===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var m=Tk(a);if(m!==null){m.flags&=-257,Rk(m,a,l,i,t),m.mode&1&&Ik(i,d,t),t=m,c=d;var g=t.updateQueue;if(g===null){var b=new Set;b.add(c),t.updateQueue=b}else g.add(c);break e}else{if(!(t&1)){Ik(i,d,t),hv();break e}c=Error(Ne(426))}}else if($n&&l.mode&1){var v=Tk(a);if(v!==null){!(v.flags&65536)&&(v.flags|=256),Rk(v,a,l,i,t),Yb(bu(c,l));break e}}i=c=bu(c,l),vr!==4&&(vr=2),Yd===null?Yd=[i]:Yd.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=WE(i,c,t);jk(i,y);break e;case 1:l=c;var k=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof k.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Va===null||!Va.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=VE(i,l,t);jk(i,j);break e}}i=i.return}while(i!==null)}c_(n)}catch(A){t=A,pr===n&&n!==null&&(pr=n=n.return);continue}break}while(!0)}function a_(){var e=ym.current;return ym.current=gm,e===null?gm:e}function hv(){(vr===0||vr===3||vr===2)&&(vr=4),Rr===null||!(Zl&268435455)&&!(yg&268435455)||Ra(Rr,$r)}function bm(e,t){var n=qt;qt|=2;var r=a_();(Rr!==e||$r!==t)&&(Bo=null,Wl(e,t));do try{RO();break}catch(s){o_(e,s)}while(!0);if(Xb(),qt=n,ym.current=r,pr!==null)throw Error(Ne(261));return Rr=null,$r=0,vr}function RO(){for(;pr!==null;)l_(pr)}function LO(){for(;pr!==null&&!iL();)l_(pr)}function l_(e){var t=d_(e.alternate,e,Ms);e.memoizedProps=e.pendingProps,t===null?c_(e):pr=t,cv.current=null}function c_(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=EO(n,t),n!==null){n.flags&=32767,pr=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{vr=6,pr=null;return}}else if(n=CO(n,t,Ms),n!==null){pr=n;return}if(t=t.sibling,t!==null){pr=t;return}pr=t=e}while(t!==null);vr===0&&(vr=5)}function Ol(e,t,n){var r=on,s=ci.transition;try{ci.transition=null,on=1,OO(e,t,n,r)}finally{ci.transition=s,on=r}return null}function OO(e,t,n,r){do lu();while(Ma!==null);if(qt&6)throw Error(Ne(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(Ne(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(mL(e,i),e===Rr&&(pr=Rr=null,$r=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Qp||(Qp=!0,f_(tm,function(){return lu(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=ci.transition,ci.transition=null;var a=on;on=1;var l=qt;qt|=4,cv.current=null,PO(e,n),r_(n,e),tO(Zx),rm=!!Qx,Zx=Qx=null,e.current=n,AO(n),oL(),qt=l,on=a,ci.transition=i}else e.current=n;if(Qp&&(Qp=!1,Ma=e,wm=s),i=e.pendingLanes,i===0&&(Va=null),cL(n.stateNode),Ss(e,ir()),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(xm)throw xm=!1,e=ww,ww=null,e;return wm&1&&e.tag!==0&&lu(),i=e.pendingLanes,i&1?e===bw?Gd++:(Gd=0,bw=e):Gd=0,al(),null}function lu(){if(Ma!==null){var e=WC(wm),t=ci.transition,n=on;try{if(ci.transition=null,on=16>e?16:e,Ma===null)var r=!1;else{if(e=Ma,Ma=null,wm=0,qt&6)throw Error(Ne(331));var s=qt;for(qt|=4,He=e.current;He!==null;){var i=He,a=i.child;if(He.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(He=d;He!==null;){var f=He;switch(f.tag){case 0:case 11:case 15:qd(8,f,i)}var u=f.child;if(u!==null)u.return=f,He=u;else for(;He!==null;){f=He;var p=f.sibling,m=f.return;if(e_(f),f===d){He=null;break}if(p!==null){p.return=m,He=p;break}He=m}}}var g=i.alternate;if(g!==null){var b=g.child;if(b!==null){g.child=null;do{var v=b.sibling;b.sibling=null,b=v}while(b!==null)}}He=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,He=a;else e:for(;He!==null;){if(i=He,i.flags&2048)switch(i.tag){case 0:case 11:case 15:qd(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,He=y;break e}He=i.return}}var k=e.current;for(He=k;He!==null;){a=He;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,He=w;else e:for(a=k;He!==null;){if(l=He,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:gg(9,l)}}catch(A){Jn(l,l.return,A)}if(l===a){He=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,He=j;break e}He=l.return}}if(qt=s,al(),ho&&typeof ho.onPostCommitFiberRoot=="function")try{ho.onPostCommitFiberRoot(lg,e)}catch{}r=!0}return r}finally{on=n,ci.transition=t}}return!1}function Kk(e,t,n){t=bu(n,t),t=WE(e,t,1),e=Wa(e,t,1),t=os(),e!==null&&(qf(e,1,t),Ss(e,t))}function Jn(e,t,n){if(e.tag===3)Kk(e,e,n);else for(;t!==null;){if(t.tag===3){Kk(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Va===null||!Va.has(r))){e=bu(n,e),e=VE(t,e,1),t=Wa(t,e,1),e=os(),t!==null&&(qf(t,1,e),Ss(t,e));break}}t=t.return}}function MO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=os(),e.pingedLanes|=e.suspendedLanes&n,Rr===e&&($r&n)===n&&(vr===4||vr===3&&($r&130023424)===$r&&500>ir()-dv?Wl(e,0):uv|=n),Ss(e,t)}function u_(e,t){t===0&&(e.mode&1?(t=Hp,Hp<<=1,!(Hp&130023424)&&(Hp=4194304)):t=1);var n=os();e=Zo(e,t),e!==null&&(qf(e,t,n),Ss(e,n))}function $O(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),u_(e,n)}function DO(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(Ne(314))}r!==null&&r.delete(t),u_(e,n)}var d_;d_=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||vs.current)gs=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return gs=!1,jO(e,t,n);gs=!!(e.flags&131072)}else gs=!1,$n&&t.flags&1048576&&mE(t,um,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Mh(e,t),e=t.pendingProps;var s=gu(t,Xr.current);au(t,n),s=sv(null,t,r,e,s,n);var i=iv();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,ks(r)?(i=!0,lm(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Zb(t),s.updater=mg,t.stateNode=s,s._reactInternals=t,lw(t,r,e,n),t=dw(null,t,r,!0,i,n)):(t.tag=0,$n&&i&&Kb(t),ss(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Mh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=zO(r),e=Pi(r,e),s){case 0:t=uw(null,t,r,e,n);break e;case 1:t=Mk(null,t,r,e,n);break e;case 11:t=Lk(null,t,r,e,n);break e;case 14:t=Ok(null,t,r,Pi(r.type,e),n);break e}throw Error(Ne(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Pi(r,s),uw(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Pi(r,s),Mk(e,t,r,s,n);case 3:e:{if(YE(t),e===null)throw Error(Ne(387));r=t.pendingProps,i=t.memoizedState,s=i.element,vE(e,t),pm(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=bu(Error(Ne(423)),t),t=$k(e,t,r,n,s);break e}else if(r!==s){s=bu(Error(Ne(424)),t),t=$k(e,t,r,n,s);break e}else for(Fs=Ha(t.stateNode.containerInfo.firstChild),Bs=t,$n=!0,Ti=null,n=wE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yu(),r===s){t=ea(e,t,n);break e}ss(e,t,r,n)}t=t.child}return t;case 5:return kE(t),e===null&&iw(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,ew(r,s)?a=null:i!==null&&ew(r,i)&&(t.flags|=32),qE(e,t),ss(e,t,a,n),t.child;case 6:return e===null&&iw(t),null;case 13:return GE(e,t,n);case 4:return ev(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=xu(t,null,r,n):ss(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Pi(r,s),Lk(e,t,r,s,n);case 7:return ss(e,t,t.pendingProps,n),t.child;case 8:return ss(e,t,t.pendingProps.children,n),t.child;case 12:return ss(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,wn(dm,r._currentValue),r._currentValue=a,i!==null)if(Fi(i.value,a)){if(i.children===s.children&&!vs.current){t=ea(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){a=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Xo(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),ow(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(Ne(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),ow(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}ss(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,au(t,n),s=ui(s),r=r(s),t.flags|=1,ss(e,t,r,n),t.child;case 14:return r=t.type,s=Pi(r,t.pendingProps),s=Pi(r.type,s),Ok(e,t,r,s,n);case 15:return UE(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Pi(r,s),Mh(e,t),t.tag=1,ks(r)?(e=!0,lm(t)):e=!1,au(t,n),HE(t,r,s),lw(t,r,s,n),dw(null,t,r,!0,e,n);case 19:return XE(e,t,n);case 22:return KE(e,t,n)}throw Error(Ne(156,t.tag))};function f_(e,t){return FC(e,t)}function FO(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 li(e,t,n,r){return new FO(e,t,n,r)}function mv(e){return e=e.prototype,!(!e||!e.isReactComponent)}function zO(e){if(typeof e=="function")return mv(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Lb)return 11;if(e===Ob)return 14}return 2}function Ka(e,t){var n=e.alternate;return n===null?(n=li(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 Fh(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")mv(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case zc:return Vl(n.children,s,i,t);case Rb:a=8,s|=8;break;case Tx:return e=li(12,n,t,s|2),e.elementType=Tx,e.lanes=i,e;case Rx:return e=li(13,n,t,s),e.elementType=Rx,e.lanes=i,e;case Lx:return e=li(19,n,t,s),e.elementType=Lx,e.lanes=i,e;case kC:return xg(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case bC:a=10;break e;case vC:a=9;break e;case Lb:a=11;break e;case Ob:a=14;break e;case _a:a=16,r=null;break e}throw Error(Ne(130,e==null?e:typeof e,""))}return t=li(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Vl(e,t,n,r){return e=li(7,e,r,t),e.lanes=n,e}function xg(e,t,n,r){return e=li(22,e,r,t),e.elementType=kC,e.lanes=n,e.stateNode={isHidden:!1},e}function Ry(e,t,n){return e=li(6,e,null,t),e.lanes=n,e}function Ly(e,t,n){return t=li(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function BO(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=hy(0),this.expirationTimes=hy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function gv(e,t,n,r,s,i,a,l,c){return e=new BO(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=li(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zb(i),e}function HO(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Fc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function p_(e){if(!e)return Qa;e=e._reactInternals;e:{if(lc(e)!==e||e.tag!==1)throw Error(Ne(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(ks(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ne(171))}if(e.tag===1){var n=e.type;if(ks(n))return pE(e,n,t)}return t}function h_(e,t,n,r,s,i,a,l,c){return e=gv(n,r,!0,e,s,i,a,l,c),e.context=p_(null),n=e.current,r=os(),s=Ua(n),i=Xo(r,s),i.callback=t??null,Wa(n,i,s),e.current.lanes=s,qf(e,s,r),Ss(e,r),e}function wg(e,t,n,r){var s=t.current,i=os(),a=Ua(s);return n=p_(n),t.context===null?t.context=n:t.pendingContext=n,t=Xo(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Wa(s,t,a),e!==null&&(Di(e,s,a,i),Rh(e,s,a)),a}function vm(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 qk(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function yv(e,t){qk(e,t),(e=e.alternate)&&qk(e,t)}function WO(){return null}var m_=typeof reportError=="function"?reportError:function(e){console.error(e)};function xv(e){this._internalRoot=e}bg.prototype.render=xv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ne(409));wg(e,t,null,null)};bg.prototype.unmount=xv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ec(function(){wg(null,e,null,null)}),t[Qo]=null}};function bg(e){this._internalRoot=e}bg.prototype.unstable_scheduleHydration=function(e){if(e){var t=KC();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ta.length&&t!==0&&t<Ta[n].priority;n++);Ta.splice(n,0,e),n===0&&YC(e)}};function wv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function vg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Yk(){}function VO(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=vm(a);i.call(d)}}var a=h_(t,r,e,0,null,!1,!1,"",Yk);return e._reactRootContainer=a,e[Qo]=a.current,mf(e.nodeType===8?e.parentNode:e),ec(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=vm(c);l.call(d)}}var c=gv(e,0,!1,null,null,!1,!1,"",Yk);return e._reactRootContainer=c,e[Qo]=c.current,mf(e.nodeType===8?e.parentNode:e),ec(function(){wg(t,c,n,r)}),c}function kg(e,t,n,r,s){var i=n._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var l=s;s=function(){var c=vm(a);l.call(c)}}wg(t,a,e,s)}else a=VO(n,t,e,s,r);return vm(a)}VC=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Id(t.pendingLanes);n!==0&&(Db(t,n|1),Ss(t,ir()),!(qt&6)&&(vu=ir()+500,al()))}break;case 13:ec(function(){var r=Zo(e,1);if(r!==null){var s=os();Di(r,e,1,s)}}),yv(e,1)}};Fb=function(e){if(e.tag===13){var t=Zo(e,134217728);if(t!==null){var n=os();Di(t,e,134217728,n)}yv(e,134217728)}};UC=function(e){if(e.tag===13){var t=Ua(e),n=Zo(e,t);if(n!==null){var r=os();Di(n,e,t,r)}yv(e,t)}};KC=function(){return on};qC=function(e,t){var n=on;try{return on=e,t()}finally{on=n}};Vx=function(e,t,n){switch(t){case"input":if($x(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=fg(r);if(!s)throw Error(Ne(90));NC(r),$x(r,s)}}}break;case"textarea":CC(e,n);break;case"select":t=n.value,t!=null&&ru(e,!!n.multiple,t,!1)}};RC=fv;LC=ec;var UO={usingClientEntryPoint:!1,Events:[Gf,Vc,fg,IC,TC,fv]},xd={findFiberByHostInstance:Fl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},KO={bundleType:xd.bundleType,version:xd.version,rendererPackageName:xd.rendererPackageName,rendererConfig:xd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:sa.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=$C(e),e===null?null:e.stateNode},findFiberByHostInstance:xd.findFiberByHostInstance||WO,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 Zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Zp.isDisabled&&Zp.supportsFiber)try{lg=Zp.inject(KO),ho=Zp}catch{}}Us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=UO;Us.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!wv(t))throw Error(Ne(200));return HO(e,t,null,n)};Us.createRoot=function(e,t){if(!wv(e))throw Error(Ne(299));var n=!1,r="",s=m_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=gv(e,1,!1,null,null,n,!1,r,s),e[Qo]=t.current,mf(e.nodeType===8?e.parentNode:e),new xv(t)};Us.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(Ne(188)):(e=Object.keys(e).join(","),Error(Ne(268,e)));return e=$C(t),e=e===null?null:e.stateNode,e};Us.flushSync=function(e){return ec(e)};Us.hydrate=function(e,t,n){if(!vg(t))throw Error(Ne(200));return kg(null,e,t,!0,n)};Us.hydrateRoot=function(e,t,n){if(!wv(e))throw Error(Ne(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=m_;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=h_(t,null,e,1,n??null,s,!1,i,a),e[Qo]=t.current,mf(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 bg(t)};Us.render=function(e,t,n){if(!vg(t))throw Error(Ne(200));return kg(null,e,t,!1,n)};Us.unmountComponentAtNode=function(e){if(!vg(e))throw Error(Ne(40));return e._reactRootContainer?(ec(function(){kg(null,null,e,!1,function(){e._reactRootContainer=null,e[Qo]=null})}),!0):!1};Us.unstable_batchedUpdates=fv;Us.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!vg(n))throw Error(Ne(200));if(e==null||e._reactInternals===void 0)throw Error(Ne(38));return kg(e,t,n,!1,r)};Us.version="18.3.1-next-f1338f8080-20240426";function g_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(g_)}catch(e){console.error(e)}}g_(),gC.exports=Us;var Mr=gC.exports,Gk=Mr;Ax.createRoot=Gk.createRoot,Ax.hydrateRoot=Gk.hydrateRoot;const y_=h.createContext(null);function Sw(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function qO(){const e=Sw(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function YO({children:e}){const[t,n]=h.useState(qO);h.useEffect(()=>{const i=()=>n(Sw(window.location.pathname));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const r=h.useCallback(i=>{const a=i.startsWith("/")?i:`/${i}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Sw(l.pathname),d=l.search||"";window.history.pushState({},"",c+d),n(c)},[]),s=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(y_.Provider,{value:s,children:e})}function ko(){const e=h.useContext(y_);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function GO(){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 Xk={};function Nw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&Xk[t[0]]||(typeof t[0]=="string"&&(Xk[t[0]]=new Date),GO(...t))}const x_=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function Jk(e,t,n){e.loadNamespaces(t,x_(e,n))}function Qk(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,x_(e,r))}function XO(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,i=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const d=t.services.backendConnector.state[`${l}|${c}`];return d===-1||d===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(i,e)))}function JO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Nw("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!i(s.isLanguageChangingTo,e))return!1}}):XO(e,t,n)}const QO=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,ZO={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},eM=e=>ZO[e],tM=e=>e.replace(QO,eM);let jw={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:tM};function nM(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};jw={...jw,...e}}function rM(){return jw}let w_;function sM(e){w_=e}function iM(){return w_}const oM={type:"3rdParty",init(e){nM(e.options.react),sM(e)}},aM=h.createContext();class lM{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const cM=(e,t)=>{const n=h.useRef();return h.useEffect(()=>{n.current=e},[e,t]),n.current};function vn(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=h.useContext(aM)||{},i=n||r||iM();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new lM),!i){Nw("You will need to pass in an i18next instance by using initReactI18next");const w=(A,C)=>typeof C=="string"?C:C&&typeof C=="object"&&typeof C.defaultValue=="string"?C.defaultValue:Array.isArray(A)?A[A.length-1]:A,j=[w,{},!1];return j.t=w,j.i18n={},j.ready=!1,j}i.options.react&&i.options.react.wait!==void 0&&Nw("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...rM(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let d=e||s||i.options&&i.options.defaultNS;d=typeof d=="string"?[d]:d||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(d);const f=(i.isInitialized||i.initializedStoreOnce)&&d.every(w=>JO(w,i,a));function u(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],c)}const[p,m]=h.useState(u);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const b=cM(g),v=h.useRef(!0);h.useEffect(()=>{const{bindI18n:w,bindI18nStore:j}=a;v.current=!0,!f&&!l&&(t.lng?Qk(i,t.lng,d,()=>{v.current&&m(u)}):Jk(i,d,()=>{v.current&&m(u)})),f&&b&&b!==g&&v.current&&m(u);function A(){v.current&&m(u)}return w&&i&&i.on(w,A),j&&i&&i.store.on(j,A),()=>{v.current=!1,w&&i&&w.split(" ").forEach(C=>i.off(C,A)),j&&i&&j.split(" ").forEach(C=>i.store.off(C,A))}},[i,g]);const y=h.useRef(!0);h.useEffect(()=>{v.current&&!y.current&&m(u),y.current=!1},[i,c]);const k=[p,i,f];if(k.t=p,k.i18n=i,k.ready=f,f||!f&&!l)return k;throw new Promise(w=>{t.lng?Qk(i,t.lng,d,()=>w()):Jk(i,d,()=>w())})}const b_="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",uM=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-nodes",labelKey:"common:nav.myNodes",icon:"deployed_code"},{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:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],dM=[{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 fM(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function pM({authUser:e,onLogout:t}){const{path:n,navigate:r}=ko(),{t:s}=vn(),[i,a]=h.useState(!1);return h.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),o.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[o.jsxs("div",{className:"af-brand",children:[o.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:o.jsx("img",{src:b_,alt:"",width:"36",height:"36",decoding:"async"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),o.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),o.jsx("nav",{className:"af-nav",children:uM.map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(fM(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[o.jsx("span",{className:"material-symbols-outlined",children:l.icon}),o.jsx("span",{children:s(l.labelKey)})]},l.to))}),o.jsxs("div",{className:"af-sidebar-footer",children:[o.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[o.jsx("span",{className:"material-symbols-outlined",children:"person"}),o.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?o.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,o.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:o.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!i&&dM.map(l=>{const c=s(l.labelKey);return o.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:o.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const v_="agentflow.pipelineRecent",hM=50,mM=15;function gM(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function k_(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(v_);return e?gM(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 eh(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=k_(),i=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,hM);try{localStorage.setItem(v_,JSON.stringify(i))}catch{}}function yM(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 Cw(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 i=Math.floor(s/60);if(i<60)return t("flow:time.minutesAgo",{n:i});const a=Math.floor(i/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,d=new Date(c);if(d.setDate(d.getDate()-1),l.toDateString()===d.toDateString())return t("flow:time.yesterday");const f=Math.floor(a/24);return f<7?t("flow:time.daysAgo",{n:f}):`${l.getMonth()+1}/${l.getDate()}`}function xM(e,t){if(e==null||!Number.isFinite(e)||e<=0)return"--";if(e<1e3)return t("flow:time.milliseconds",{n:Math.max(1,Math.round(e))});const n=e/1e3;return t("flow:time.seconds",{n:n>=10?Math.round(n):n.toFixed(1)})}function wM(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:yM(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,i)=>i.at-s.at),r.slice(0,mM)}var $s=Uint8Array,Jc=Uint16Array,bM=Int32Array,S_=new $s([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]),N_=new $s([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]),vM=new $s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),j_=function(e,t){for(var n=new Jc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new bM(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},C_=j_(S_,2),E_=C_.b,kM=C_.r;E_[28]=258,kM[258]=28;var SM=j_(N_,0),NM=SM.b,Ew=new Jc(32768);for(var En=0;En<32768;++En){var ka=(En&43690)>>1|(En&21845)<<1;ka=(ka&52428)>>2|(ka&13107)<<2,ka=(ka&61680)>>4|(ka&3855)<<4,Ew[En]=((ka&65280)>>8|(ka&255)<<8)>>1}var Xd=function(e,t,n){for(var r=e.length,s=0,i=new Jc(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new Jc(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new Jc(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],f=t-e[s],u=a[e[s]-1]++<<f,p=u|(1<<f)-1;u<=p;++u)l[Ew[u]>>c]=d}else for(l=new Jc(r),s=0;s<r;++s)e[s]&&(l[s]=Ew[a[e[s]-1]++]>>15-e[s]);return l},Jf=new $s(288);for(var En=0;En<144;++En)Jf[En]=8;for(var En=144;En<256;++En)Jf[En]=9;for(var En=256;En<280;++En)Jf[En]=7;for(var En=280;En<288;++En)Jf[En]=8;var __=new $s(32);for(var En=0;En<32;++En)__[En]=5;var jM=Xd(Jf,9,1),CM=Xd(__,5,1),Oy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ei=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},My=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},EM=function(e){return(e+7)/8|0},bv=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new $s(e.subarray(t,n))},_M=["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"],ri=function(e,t,n){var r=new Error(t||_M[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ri),!n)throw r;return r},PM=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new $s(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new $s(s*3));var d=function(we){var Ee=n.length;if(we>Ee){var Ae=new $s(Math.max(Ee*2,we));Ae.set(n),n=Ae}},f=t.f||0,u=t.p||0,p=t.b||0,m=t.l,g=t.d,b=t.m,v=t.n,y=s*8;do{if(!m){f=Ei(e,u,1);var k=Ei(e,u+1,3);if(u+=3,k)if(k==1)m=jM,g=CM,b=9,v=5;else if(k==2){var C=Ei(e,u,31)+257,$=Ei(e,u+10,15)+4,B=C+Ei(e,u+5,31)+1;u+=14;for(var F=new $s(B),z=new $s(19),L=0;L<$;++L)z[vM[L]]=Ei(e,u+L*3,7);u+=$*3;for(var O=Oy(z),W=(1<<O)-1,M=Xd(z,O,1),L=0;L<B;){var T=M[Ei(e,u,W)];u+=T&15;var w=T>>4;if(w<16)F[L++]=w;else{var E=0,D=0;for(w==16?(D=3+Ei(e,u,3),u+=2,E=F[L-1]):w==17?(D=3+Ei(e,u,7),u+=3):w==18&&(D=11+Ei(e,u,127),u+=7);D--;)F[L++]=E}}var _=F.subarray(0,C),R=F.subarray(C);b=Oy(_),v=Oy(R),m=Xd(_,b,1),g=Xd(R,v,1)}else ri(1);else{var w=EM(u)+4,j=e[w-4]|e[w-3]<<8,A=w+j;if(A>s){c&&ri(0);break}l&&d(p+j),n.set(e.subarray(w,A),p),t.b=p+=j,t.p=u=A*8,t.f=f;continue}if(u>y){c&&ri(0);break}}l&&d(p+131072);for(var P=(1<<b)-1,G=(1<<v)-1,Z=u;;Z=u){var E=m[My(e,u)&P],V=E>>4;if(u+=E&15,u>y){c&&ri(0);break}if(E||ri(2),V<256)n[p++]=V;else if(V==256){Z=u,m=null;break}else{var se=V-254;if(V>264){var L=V-257,ue=S_[L];se=Ei(e,u,(1<<ue)-1)+E_[L],u+=ue}var fe=g[My(e,u)&G],ge=fe>>4;fe||ri(3),u+=fe&15;var R=NM[ge];if(ge>3){var ue=N_[ge];R+=My(e,u)&(1<<ue)-1,u+=ue}if(u>y){c&&ri(0);break}l&&d(p+131072);var ae=p+se;if(p<R){var ve=i-R,_e=Math.min(R,ae);for(ve+p<0&&ri(3);p<_e;++p)n[p]=r[ve+p]}for(;p<ae;++p)n[p]=n[p-R]}}t.l=m,t.p=Z,t.b=p,t.f=f,m&&(f=1,t.m=b,t.d=g,t.n=v)}while(!f);return p!=n.length&&a?bv(n,0,p):n.subarray(0,p)},AM=new $s(0),uo=function(e,t){return e[t]|e[t+1]<<8},Ri=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},$y=function(e,t){return Ri(e,t)+Ri(e,t+4)*4294967296};function IM(e,t){return PM(e,{i:2},t&&t.out,t&&t.dictionary)}var _w=typeof TextDecoder<"u"&&new TextDecoder,TM=0;try{_w.decode(AM,{stream:!0}),TM=1}catch{}var RM=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:bv(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 LM(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(_w)return _w.decode(e);var s=RM(e),i=s.s,n=s.r;return n.length&&ri(8),i}}var OM=function(e,t){return t+30+uo(e,t+26)+uo(e,t+28)},MM=function(e,t,n){var r=uo(e,t+28),s=LM(e.subarray(t+46,t+46+r),!(uo(e,t+8)&2048)),i=t+46+r,a=Ri(e,t+20),l=n&&a==4294967295?$M(e,i):[a,Ri(e,t+24),Ri(e,t+42)],c=l[0],d=l[1],f=l[2];return[uo(e,t+10),c,d,s,i+uo(e,t+30)+uo(e,t+32),f]},$M=function(e,t){for(;uo(e,t)!=1;t+=4+uo(e,t+2));return[$y(e,t+12),$y(e,t+4),$y(e,t+20)]};function DM(e,t){for(var n={},r=e.length-22;Ri(e,r)!=101010256;--r)(!r||e.length-r>65558)&&ri(13);var s=uo(e,r+8);if(!s)return{};var i=Ri(e,r+16),a=i==4294967295||s==65535;if(a){var l=Ri(e,r-12);a=Ri(e,l)==101075792,a&&(s=Ri(e,l+32),i=Ri(e,l+48))}for(var c=0;c<s;++c){var d=MM(e,i,a),f=d[0],u=d[1],p=d[2],m=d[3],g=d[4],b=d[5],v=OM(e,b);i=g,f?f==8?n[m]=IM(e.subarray(v,v+u),{out:new $s(p)}):ri(14,"unknown compression type "+f):n[m]=bv(e,v,v+u)}return n}const FM=8*1024*1024,zM=500;function BM(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 HM(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function WM(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 VM=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function UM(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=DM(t),r=new Map;let s=0,i=0;for(const[c,d]of Object.entries(n)){if(c.endsWith("/"))continue;const f=BM(c);if(!f||HM(f))continue;const u=(d==null?void 0:d.length)??0;if(s+=u,s>FM||(i+=1,i>zM))return null;r.set(f,u)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const d=WM(c);d!==null&&a.add(d)}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 VM.test(l)?l:null}catch{return null}}const Dy=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function KM({file:e,onClose:t,onImported:n}){const{t:r}=vn(),s=h.useId(),i=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(""),[d,f]=h.useState("user"),[u,p]=h.useState(!1),[m,g]=h.useState(""),[b,v]=h.useState(null),y=b??e;h.useEffect(()=>{const A=requestAnimationFrame(()=>{var C;return(C=i.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(A)},[]),h.useEffect(()=>{let A=!1;return(async()=>{const C=y.name||"",$=C.toLowerCase();let B="";if($.endsWith(".zip")){if(B=await UM(y)||"",!B){const F=C.replace(/\.zip$/i,"");Dy.test(F)&&(B=F)}}else if($.endsWith(".yaml")||$.endsWith(".yml")){const F=C.replace(/\.ya?ml$/i,"");Dy.test(F)&&(B=F)}A||c(B)})(),()=>{A=!0}},[y]);const k=l.trim(),w=k.length>0&&Dy.test(k);async function j(A){if(A.preventDefault(),!(!w||u)){p(!0),g("");try{const C=new FormData;C.set("flowId",k),C.set("targetSpace",d),C.set("file",y,y.name);const $=await fetch("/api/flows/import",{method:"POST",body:C}),B=await $.json().catch(()=>({}));if(!$.ok){g(typeof B.error=="string"?B.error:r("project:importModal.importFailed"));return}n({id:B.flowId,source:B.flowSource??"user"})}catch(C){g(String((C==null?void 0:C.message)||C))}finally{p(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:A=>{A.target===A.currentTarget&&t()},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:A=>A.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:y.name})}),o.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:A=>{var $;const C=($=A.target.files)==null?void 0:$[0];C&&v(C),A.target.value=""}}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:A=>c(A.target.value),"aria-invalid":k.length>0&&!w}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),o.jsx("div",{className:"af-import-repick",children:o.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var A;return(A=a.current)==null?void 0:A.click()},children:r("project:importModal.changeFile")})}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:r("project:importModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||u,children:r(u?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const qM=/^[a-zA-Z][a-zA-Z0-9_-]*$/,Zk="af:newPipelineGuide";function YM({open:e,onClose:t,onCreated:n}){const{t:r}=vn(),s=h.useId(),i=h.useRef(null),[a,l]=h.useState(""),[c,d]=h.useState(""),[f,u]=h.useState("user"),[p,m]=h.useState(!1),[g,b]=h.useState(""),[v,y]=h.useState(!1);h.useEffect(()=>{if(!e)return;l(""),d(""),u("user"),b(""),m(!1),localStorage.getItem(Zk)==="true"&&y(!0);const $=requestAnimationFrame(()=>{var B;return(B=i.current)==null?void 0:B.focus()});return()=>cancelAnimationFrame($)},[e]);const k=()=>{localStorage.removeItem(Zk),y(!1)};if(!e)return null;const w=a.trim(),j=w.length>0&&qM.test(w);async function A(C){if(C.preventDefault(),!(!j||p)){m(!0),b(""),k();try{const $=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:w,description:c.trim(),targetSpace:f})}),B=await $.json().catch(()=>({}));if(!$.ok){b(typeof B.error=="string"?B.error:r("project:newPipelineModal.createFailed"));return}n({id:B.flowId,source:B.flowSource??"user"})}catch($){b(String(($==null?void 0:$.message)||$))}finally{m(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&(k(),t())},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),v?o.jsx("div",{className:"af-new-pipeline-guide",children:o.jsxs("div",{className:"af-new-pipeline-guide-content",children:[o.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),o.jsxs("div",{className:"af-new-pipeline-guide-text",children:[o.jsx("p",{children:o.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),o.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),o.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:k,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:A,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),o.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":w.length>0&&!j}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(v?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(v?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:C=>d(C.target.value)}),v?o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),g?o.jsx("p",{className:"af-err af-new-pipeline-err",children:g}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!j||p,children:r(p?"project:newPipelineModal.creating":v?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const P_="agentflow.pipelineViewPreference";function A_(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function I_(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(P_)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function GM(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(P_,JSON.stringify(e))}catch{}}function km(e){return e==="display"?"display":e==="pipeline"?"pipeline":"workspace"}function XM(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function T_(e,t,n,r=!1){if(!e)return;const s=I_();s[A_(e,t,r)]={view:km(n),at:Date.now()},GM(s)}function JM(e,t="workspace"){if(!(e!=null&&e.id))return km(t);const r=I_()[A_(e.id,e.source??"user",!!e.archived)],s=km((r==null?void 0:r.view)||t);return s==="pipeline"&&!XM(e)?"workspace":s}function Sm(e,t="workspace"){const n=km(t);if(!(e!=null&&e.id))return n==="pipeline"?"/flow":n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return e.archived&&r.set(n==="pipeline"?"flowArchived":"archived","1"),n==="display"&&r.set("view","display"),`/${n==="pipeline"?"flow":"workspace"}?${r.toString()}`}function th(e,t="workspace"){return Sm(e,JM(e,t))}function QM(e,t){const n=String(e||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),r=String(t||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),s=Math.max(n.length,r.length);for(let i=0;i<s;i+=1){const a=Number.isFinite(n[i])?n[i]:0,l=Number.isFinite(r[i])?r[i]:0;if(a!==l)return a>l?1:-1}return 0}function Pw(e){return String((e==null?void 0:e.version)||"").trim()}function ZM(e){const t=Pw(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 e$({onChanged:e}){const[t,n]=h.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[r,s]=h.useState([]),[i,a]=h.useState(""),[l,c]=h.useState("keyword"),[d,f]=h.useState([]),[u,p]=h.useState({}),[m,g]=h.useState(""),[b,v]=h.useState(""),[y,k]=h.useState(""),w=h.useCallback(async()=>{v("");try{const[F,z]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=global&agent=codex")]),L=await F.json().catch(()=>({}));F.ok&&n({available:!!L.available,version:typeof L.version=="string"?L.version:"",loggedIn:!!L.loggedIn,user:typeof L.user=="string"?L.user:"",error:typeof L.error=="string"?L.error:""});const O=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+z.status);s(Array.isArray(O.skills)?O.skills:[]),p({})}catch(F){v(String(F.message||F))}},[]);h.useEffect(()=>{w()},[w]);const j=h.useCallback(async()=>{const F=i.trim();if(F){g("search"),v(""),k("");try{const z=await fetch(`/api/skillhub/search?q=${encodeURIComponent(F)}&mode=${encodeURIComponent(l)}`),L=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+z.status);f(Array.isArray(L.items)?L.items:[])}catch(z){v(String(z.message||z))}finally{g("")}}},[i,l]),A=h.useCallback(async(F,z=!1)=>{const L=F&&typeof F=="object"?F:null,O=String(L?L.slug||L.name||L.collection||L.skillId||L.id:F||"").trim();if(O){g(`install:${O}`),v(""),k("");try{const W=L?{slug:L.slug||"",skillId:L.skillId||"",collection:L.collection||"",collectionName:L.collection&&L.name||"",target:"global",agent:"codex",force:z}:{slug:O,target:"global",agent:"codex",force:z},M=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),T=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+M.status);k(z?`已更新 ${O}`:`已安装 ${O}`),await w(),typeof e=="function"&&await e()}catch(W){v(String(W.message||W))}finally{g("")}}},[w,e]),C=h.useCallback(async()=>{if(r.length!==0){g("check-updates"),v(""),k("");try{const F=await Promise.all(r.map(async O=>{const W=String(O.name||"").trim();if(!W)return null;try{const M=await fetch(`/api/skillhub/search?q=${encodeURIComponent(W)}&mode=keyword`),T=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+M.status);const E=Array.isArray(T.items)?T.items:[],D=E.find(G=>G.slug===W||G.name===W||G.id===W)||E[0],_=Pw(O),R=String((D==null?void 0:D.version)||"").trim();let P="unknown";return D?_&&R?P=QM(_,R)<0?"update":"current":R&&(P="remote-only"):P="missing",[W,{state:P,latestVersion:R,installedVersion:_,summary:(D==null?void 0:D.summary)||""}]}catch(M){return[W,{state:"error",error:String(M.message||M),installedVersion:Pw(O)}]}})),z={};for(const O of F)O&&(z[O[0]]=O[1]);p(z);const L=Object.values(z).filter(O=>O.state==="update").length;k(L>0?`发现 ${L} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[r]),$=h.useCallback(async F=>{const z=String(F||"").trim();if(z){g(`uninstall:${z}`),v(""),k("");try{const L=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:z,target:"global",agent:"codex"})}),O=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+L.status);k(`已卸载 ${z}`),await w(),typeof e=="function"&&await e()}catch(L){v(String(L.message||L))}finally{g("")}}},[w,e]),B=h.useCallback(async()=>{g("update-cli"),v(""),k("");try{const F=await fetch("/api/skillhub/update",{method:"POST"}),z=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof z.error=="string"?z.error:"HTTP "+F.status);k("SkillHub CLI 已更新"),await w()}catch(F){v(String(F.message||F))}finally{g("")}},[w]);return o.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"搜索、安装、更新和卸载 Codex 全局 skills。"})]}),o.jsxs("div",{className:"af-set-skillhub-head-actions",children:[o.jsxs("div",{className:"af-set-skillhub-status",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),o.jsx("span",{children:t.loggedIn?`已登录 ${t.user}`:"未登录 SkillHub"}),o.jsx("span",{className:"af-set-badge"+(t.available?" af-set-badge--ok":" af-set-badge--err"),children:t.available?`v${t.version}`:"not found"})]}),o.jsxs("div",{className:"af-set-skillhub-toolbar",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:w,disabled:!!m,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:C,disabled:!!m||r.length===0,children:m==="check-updates"?"检查中…":"检查更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:!!m,children:m==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),o.jsxs("div",{className:"af-set-skillhub-search",children:[o.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:l,onChange:F=>{c(F.target.value),f([])},children:[o.jsx("option",{value:"keyword",children:"关键词"}),o.jsx("option",{value:"skillId",children:"Skill ID"}),o.jsx("option",{value:"collectionId",children:"Collection ID"})]}),o.jsx("input",{className:"af-set-input af-set-input--sm",value:i,onChange:F=>a(F.target.value),onKeyDown:F=>{F.key==="Enter"&&j()},placeholder:l==="collectionId"?"输入 collection id,例如 1":l==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>j(),disabled:!i.trim()||m==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),m==="search"?"搜索中…":"搜索"]})]}),b?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:b}):null,y?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:y}):null,o.jsxs("div",{className:"af-set-skillhub-grid",children:[o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"已安装"}),o.jsx("span",{children:r.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:r.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 Codex 全局 skills"}):r.map(F=>{const z=u[F.name],L=!z||z.state==="update"||z.state==="remote-only"||z.state==="unknown"||z.state==="error",O=m===`install:${F.name}`?"更新中…":(z==null?void 0:z.state)==="current"?"已最新":(z==null?void 0:z.state)==="update"&&z.latestVersion?`更新到 v${z.latestVersion}`:(z==null?void 0:z.state)==="remote-only"&&z.latestVersion?`安装 v${z.latestVersion}`:"重装";return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:F.displayName||F.name}),o.jsx("div",{className:"af-set-skillhub-meta",children:ZM(F)}),o.jsx("div",{className:"af-set-skillhub-version-row",children:z?z.state==="update"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",z.installedVersion?`v${z.installedVersion} -> `:"","v",z.latestVersion]}):z.state==="current"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",z.latestVersion||z.installedVersion]}):z.state==="remote-only"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",z.latestVersion,",本地版本未知"]}):z.state==="missing"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):z.state==="error"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),o.jsxs("div",{className:"af-set-skillhub-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>A(F.name,!0),disabled:!!m||!L,children:O}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>$(F.name),disabled:!!m,children:"卸载"})]})]},`${F.agent}:${F.path}:${F.name}`)})})]}),o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"搜索结果"}),o.jsx("span",{children:d.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(F=>{const z=F.slug||F.name,L=F.kind==="collection"||F.collection,O=!L&&r.some(W=>W.name===z||W.name===F.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:F.name||z}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[L?`collection:${F.collection}`:z,F.skillId?` · id:${F.skillId}`:"",F.version?` · ${F.version}`:""]}),F.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:F.summary}):null]}),o.jsx("button",{type:"button",className:O?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>A(F,O),disabled:!!m,children:O?"更新":L?"安装合集":"安装"})]},F.id||z)})})]})]})]})}function qa(e){return(Array.isArray(e==null?void 0:e.collections)?e.collections:[]).filter(n=>n&&typeof n=="object").map(n=>({id:String(n.id||n.name||"").trim(),name:String(n.name||n.id||"").trim(),skillKeys:Array.from(new Set((Array.isArray(n.skillKeys)?n.skillKeys:[]).map(r=>String(r||"").trim()).filter(Boolean))),builtin:!!n.builtin,createdAt:Number.isFinite(n.createdAt)?Number(n.createdAt):Date.now(),updatedAt:Number.isFinite(n.updatedAt)?Number(n.updatedAt):Date.now()})).filter(n=>n.id&&n.name)}function t$(e){return{version:1,collections:qa({collections:e})}}function Za(e,t){const n=new Set((Array.isArray(t)?t:[]).map(r=>r.key).filter(Boolean));return(Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).filter(r=>n.has(r))}function R_(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 L_(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function O_(e,t,n){const r=Za(e,n);if(r.length===0)return"empty";const s=r.filter(i=>t.has(i)).length;return s===0?"none":s===r.length?"all":"partial"}function n$(e,t,n){const r=String(e||"").trim().toLowerCase(),s=qa({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return Za(s,t)}function M_(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),i=String(t||"").trim().toLowerCase(),a=qa({collections:r}),l=n$(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const d=localStorage.getItem(e);if(d!==null){const f=JSON.parse(d);if(Array.isArray(f)){const u=new Set(s),p=f.map(String).filter(y=>u.has(y));if(s.length>0&&p.length===s.length)return c;const m=new Set(p),g=new Set(l),b=l.length>0&&l.every(y=>m.has(y)),v=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const k=Za(y,n);return k.length>0&&k.every(w=>m.has(w))});return l.length>0&&v&&!b?c:p}}}catch{}return c}function wd(e){return 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 r$(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 Aw(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function $_(e){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 s$="project:defaultCardDesc";function D_(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(s$)}function i$(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sr({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return o.jsx("span",{className:t,children:s});const i=new RegExp(`(${i$(r)})`,"gi"),a=s.split(i);return o.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?o.jsx("mark",{className:"af-search-hit",children:l},c):o.jsx("span",{children:l},c))})}function o$(e,t,n){const r=[String(e.id),D_(e,n),$_(e),Aw(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
+ `).toLowerCase()}function a$(e,t,n){return t?o$(e,t,n).includes(t):!0}function l$(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 Fy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
+ `).toLowerCase().includes(n):!0}function eS(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 tS(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const c$=["all","agent","control","provide","marketplace"],u$=["all","agent","control","provide"],F_="agentflow.projects.activityPanelOpen",Iw="agentflow.projects.activitySelected";function d$(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(F_);return e!=="0"}function nS(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function f$(){return typeof localStorage>"u"?"":localStorage.getItem(Iw)||""}function nh(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Mn(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 Sa(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function z_(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 B_(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 Tw(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 rS(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Tw(e,t))}function p$(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function sS(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 h$(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 zy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function m$(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 g$(e,t){const n=e.map(f=>f.id),r=new Set(n),s=new Map(n.map(f=>[f,0])),i=new Map(n.map(f=>[f,[]]));t.forEach(f=>{var u;!r.has(f.sourceId)||!r.has(f.targetId)||(s.set(f.targetId,(s.get(f.targetId)||0)+1),(u=i.get(f.sourceId))==null||u.push(f.targetId))});const a=new Map,l=n.filter(f=>(s.get(f)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(f=>a.set(f,0));for(let f=0;f<l.length;f+=1){const u=l[f],p=(a.get(u)||0)+1;for(const m of i.get(u)||[])(!a.has(m)||p>a.get(m))&&(a.set(m,p),l.push(m))}n.forEach((f,u)=>{a.has(f)||a.set(f,u%3)});const c=new Map,d=new Map;return n.forEach(f=>{const u=a.get(f)||0,p=c.get(u)||0;c.set(u,p+1),d.set(f,{x:u*190,y:p*86})}),d}function y$(e){var b,v,y,k;const t=z_(e),n=B_(e),r=new Map(t.map((w,j)=>[Tw(w,j),rS(w,j)])),s=t.map((w,j)=>({id:Tw(w,j),title:rS(w,j),meta:p$(w)})),i=n.map((w,j)=>{const A=sS(w,"source"),C=sS(w,"target");return{key:(w==null?void 0:w.id)||`${A}-${C}-${j}`,sourceId:A,targetId:C,source:r.get(A)||A||"?",target:r.get(C)||C||"?",label:h$(w)}}),a=(v=(b=e==null?void 0:e.snippet)==null?void 0:b.ui)!=null&&v.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(k=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&k.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=g$(s,i),d=s.map(w=>{const j=m$(a[w.id])||c.get(w.id)||{x:0,y:0},A=l[w.id]&&typeof l[w.id]=="object"?l[w.id]:{},C=Number(A.width),$=Number(A.height),B=Math.max(132,Math.min(210,Number.isFinite(C)?C*.62:150)),F=Math.max(48,Math.min(76,Number.isFinite($)?$*.46:54));return{...w,x:j.x,y:j.y,width:B,height:F}}),f=new Map(d.map(w=>[w.id,w])),u=i.map(w=>{const j=f.get(w.sourceId),A=f.get(w.targetId);if(!j||!A)return null;const C=j.x+j.width,$=j.y+j.height/2,B=A.x,F=A.y+A.height/2,z=Math.max(48,Math.abs(B-C)*.45);return{...w,path:`M ${C} ${$} C ${C+z} ${$}, ${B-z} ${F}, ${B} ${F}`,labelX:(C+B)/2,labelY:($+F)/2}}).filter(Boolean),p=d.reduce((w,j)=>({minX:Math.min(w.minX,j.x),minY:Math.min(w.minY,j.y),maxX:Math.max(w.maxX,j.x+j.width),maxY:Math.max(w.maxY,j.y+j.height)}),{minX:0,minY:0,maxX:420,maxY:220}),m=36,g=`${p.minX-m} ${p.minY-m} ${Math.max(360,p.maxX-p.minX+m*2)} ${Math.max(180,p.maxY-p.minY+m*2)}`;return{nodes:s,edges:i,diagram:{nodes:d,edges:u,viewBox:g}}}function Ac({resourceKind:e="",authUser:t=null}){var Ys,an,As,Is,Ts,Gs;const{t:n}=vn(),{navigate:r,path:s}=ko(),[i,a]=h.useState(e||"all"),[l,c]=h.useState([]),[d,f]=h.useState([]),[u,p]=h.useState([]),[m,g]=h.useState([]),[b,v]=h.useState([]),[y,k]=h.useState(""),[w,j]=h.useState(!1),[A,C]=h.useState([]),[$,B]=h.useState(""),[F,z]=h.useState(""),[L,O]=h.useState(!1),[W,M]=h.useState(!1),[T,E]=h.useState(!1),[D,_]=h.useState(null),[R,P]=h.useState(!1),[G,Z]=h.useState(""),[V,se]=h.useState(d$),[ue,fe]=h.useState(f$),[ge,ae]=h.useState("all"),[ve,_e]=h.useState(""),[we,Ee]=h.useState("overview"),[Ae,st]=h.useState({}),[ut,et]=h.useState(""),[Ct,Ue]=h.useState({}),[St,nn]=h.useState(""),[hn,An]=h.useState(""),[Bt,In]=h.useState({}),[Fn,le]=h.useState(""),[de,ze]=h.useState(""),[Qe,ot]=h.useState(""),[Qt,rn]=h.useState(""),[Tn,mn]=h.useState(""),[or,sn]=h.useState(!1),[kn,tn]=h.useState(""),[Sn,xe]=h.useState({hiddenBuiltins:[],promoted:[]}),Te=h.useRef(0),it=h.useRef(0),re=h.useCallback(async()=>{var he,Ie;const U=++it.current;B("");try{const Pe=await fetch("/api/flows");if(U!==it.current)return;if(!Pe.ok)throw new Error("HTTP "+Pe.status);const Ge=await Pe.json();if(U!==it.current)return;c(Array.isArray(Ge)?Ge:[])}catch(Pe){if(U!==it.current)return;c([]),B(String(Pe.message||Pe))}try{const Pe=await fetch("/api/pipeline-recent-runs");if(U!==it.current)return;if(Pe.ok){const Ge=await Pe.json();if(U!==it.current)return;C(Array.isArray(Ge.runs)?Ge.runs:[])}else C([])}catch{if(U!==it.current)return;C([])}if(t!=null&&t.isAdmin)try{const Pe=await fetch("/api/admin/builtin-flows");if(U!==it.current)return;const Ge=await Pe.json().catch(()=>({}));Pe.ok&&xe({hiddenBuiltins:Array.isArray((he=Ge==null?void 0:Ge.config)==null?void 0:he.hiddenBuiltins)?Ge.config.hiddenBuiltins:[],promoted:Array.isArray((Ie=Ge==null?void 0:Ge.config)==null?void 0:Ie.promoted)?Ge.config.promoted:[]})}catch{if(U!==it.current)return;xe({hiddenBuiltins:[],promoted:[]})}else xe({hiddenBuiltins:[],promoted:[]});O(!0)},[t==null?void 0:t.isAdmin]),je=h.useCallback(async(U,he)=>{if(!(t!=null&&t.isAdmin)||!(U!=null&&U.id))return;const Ie=`${he}:${U.source}:${U.id}`;tn(Ie),B("");try{const Pe=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:he,flowId:U.id,ownerUserId:U.ownerUserId||t.userId})}),Ge=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(Ge.error||"更新内置配置失败");await re()}catch(Pe){B(String(Pe.message||Pe))}finally{tn("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,re]),Ye=h.useCallback(async()=>{z(""),M(!1);try{const[U,he,Ie,Pe]=await Promise.all([fetch("/api/nodes"),fetch("/api/skills"),fetch("/api/skill-collections"),fetch("/api/marketplace/flow-snippets")]),Ge=await U.json().catch(()=>({})),Vt=await he.json().catch(()=>({})),Mt=await Ie.json().catch(()=>({})),er=await Pe.json().catch(()=>({}));if(!U.ok)throw new Error(Ge.error||"Nodes HTTP "+U.status);if(!he.ok)throw new Error(Vt.error||"Skills HTTP "+he.status);if(!Ie.ok)throw new Error(Mt.error||"Collections HTTP "+Ie.status);if(!Pe.ok)throw new Error(er.error||"Flow snippets HTTP "+Pe.status);f(Array.isArray(Ge.nodes)?Ge.nodes:Array.isArray(Ge)?Ge:[]),p(Array.isArray(Vt.skills)?Vt.skills:[]),v(qa(Mt)),g(Array.isArray(er.snippets)?er.snippets:[])}catch(U){f([]),p([]),g([]),v([]),z(String(U.message||U))}finally{M(!0)}},[]);h.useEffect(()=>{O(!1),re(),Ye()},[re,Ye]),h.useEffect(()=>{try{localStorage.setItem(F_,V?"1":"0")}catch{}},[V]),h.useEffect(()=>{try{ue?localStorage.setItem(Iw,ue):localStorage.removeItem(Iw)}catch{}},[ue]),h.useEffect(()=>{let U=!1;return fetch("/api/ui-context").then(he=>he.json()).then(he=>{U||sn(!!he.hideCommunityLinks)}).catch(()=>{}),()=>{U=!0}},[]);const jt=h.useCallback(async U=>{const he=qa({collections:U});j(!0),z("");try{const Ie=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t$(he))}),Pe=await Ie.json().catch(()=>({}));if(!Ie.ok)throw new Error(Pe.error||"Collections HTTP "+Ie.status);v(qa(Pe))}catch(Ie){z(String(Ie.message||Ie))}finally{j(!1)}},[]),Ke=h.useCallback(()=>{const U=y.trim();if(!U)return;const he=U.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Ie=new Set(b.map(Mt=>Mt.id));let Pe=he,Ge=2;for(;Ie.has(Pe);)Pe=`${he}-${Ge++}`;const Vt=Date.now();jt([...b,{id:Pe,name:U,skillKeys:[],createdAt:Vt,updatedAt:Vt}]),k(""),ae(`collection:${Pe}`)},[y,jt,b]),Nn=h.useCallback(U=>{const he=b.find(Pe=>Pe.id===U);if(he!=null&&he.builtin)return;const Ie=b.filter(Pe=>Pe.id!==U);ge===`collection:${U}`&&ae("all"),jt(Ie)},[ge,jt,b]),fi=h.useCallback((U,he,Ie)=>{const Pe=String(he||"").trim();if(!Pe)return;const Ge=Date.now(),Vt=b.map(Mt=>{if(Mt.id!==U)return Mt;const er=new Set(Mt.skillKeys||[]);return Ie?er.add(Pe):er.delete(Pe),{...Mt,skillKeys:Array.from(er),updatedAt:Ge}});jt(Vt)},[jt,b]),jo=h.useCallback(async U=>{const he=U==null?void 0:U.packageId,Ie=U==null?void 0:U.version;if(!he||!Ie||!window.confirm(n("project:deleteMyNodeConfirm",{id:he,version:Ie})))return;const Pe=Mn(U);ze(Pe),ot(""),z("");try{const Ge=new URLSearchParams({id:he,version:Ie}),Vt=await fetch(`/api/marketplace/node?${Ge.toString()}`,{method:"DELETE"}),Mt=await Vt.json().catch(()=>({}));if(!Vt.ok||(Mt==null?void 0:Mt.ok)===!1){const er=Array.isArray(Mt==null?void 0:Mt.usage)&&Mt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Mt.usage.length})}`:"";throw new Error(((Mt==null?void 0:Mt.error)||"Delete failed")+er)}ot(n("project:deleteMyNodeSuccess",{id:he,version:Ie})),Ue(er=>{const Er={...er};return delete Er[Pe],Er}),In(er=>{const Er={};for(const[Xs,Po]of Object.entries(er))Xs.startsWith(`${Pe}:`)||(Er[Xs]=Po);return Er}),_e(""),await Ye()}catch(Ge){ot(String(Ge.message||Ge))}finally{ze("")}},[Ye,n]),kr=h.useCallback(async U=>{const he=U==null?void 0:U.id,Ie=(U==null?void 0:U.version)||"1.0.0";if(!he||!Ie||!window.confirm(n("project:deleteMyFlowConfirm",{id:he,version:Ie})))return;const Pe=Sa(U);rn(Pe),mn(""),z("");try{const Ge=new URLSearchParams({id:he,version:Ie}),Vt=await fetch(`/api/marketplace/flow-snippet?${Ge.toString()}`,{method:"DELETE"}),Mt=await Vt.json().catch(()=>({}));if(!Vt.ok||(Mt==null?void 0:Mt.ok)===!1)throw new Error((Mt==null?void 0:Mt.error)||"Delete failed");mn(n("project:deleteMyFlowSuccess",{id:he,version:Ie})),_e(""),await Ye()}catch(Ge){mn(String(Ge.message||Ge))}finally{rn("")}},[Ye,n]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){a(e),ae("all"),_e(""),Ee("overview");return}a(U=>U==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const U=new URLSearchParams(window.location.search);let he=!1;if(U.get("tab")==="nodes"){r("/nodes");return}if(U.get("tab")==="my-nodes"){r("/my-nodes");return}if(U.get("tab")==="my-flows"){r("/my-flows");return}if(U.get("tab")==="skills"){r("/skills");return}if(U.get("tab")==="archived"&&(a("archived"),U.delete("tab"),he=!0),U.get("new")==="1"&&(E(!0),U.delete("new"),he=!0),he){const Ie=U.toString();window.history.replaceState({},"",Ie?`/projects?${Ie}`:"/projects")}},[s,r]);const Sr=h.useMemo(()=>wM(A,k_(),l),[A,l,s]),Co=h.useMemo(()=>Sr.filter(U=>l$(G,U)),[Sr,G]),ar=G.trim().toLowerCase(),qs=h.useMemo(()=>i==="archived"?l.filter(U=>U.archived):l.filter(U=>!U.archived),[l,i]),Oe=h.useMemo(()=>qs.filter(U=>a$(U,ar,n)),[qs,ar,n]),aa=h.useMemo(()=>new Set((Sn.promoted||[]).map(U=>String((U==null?void 0:U.id)||"").trim()).filter(Boolean)),[Sn.promoted]),pi=h.useMemo(()=>(Sn.hiddenBuiltins||[]).map(U=>String(U||"").trim()).filter(Boolean),[Sn.hiddenBuiltins]),Kn=i==="nodes"||i==="my-nodes",Le=i==="my-nodes",Ht=i==="my-flows",Nr=h.useMemo(()=>d.filter(U=>Le&&U.source!=="marketplace"?!1:(ge==="all"||(ge==="marketplace"?U.source==="marketplace":U.type===ge))&&Fy(G,[U.id,U.label,U.displayName,U.description,U.type,U.source,U.packageId,U.version])),[d,Le,G,ge]),mt=h.useMemo(()=>{const U=new Map;for(const he of b)U.set(he.id,new Set(he.skillKeys||[]));return U},[b]),Vi=h.useMemo(()=>[{id:"all",label:"全部"},...b.map(U=>({id:`collection:${U.id}`,label:U.name,count:U.skillKeys.length,collection:U})),{id:"ungrouped",label:"未分组"}],[b]),Zn=h.useMemo(()=>u.filter(U=>{var Pe;const he=Mn(U);let Ie=ge==="all";if(ge.startsWith("collection:")){const Ge=ge.slice(11);Ie=!!((Pe=mt.get(Ge))!=null&&Pe.has(he))}else ge==="ungrouped"&&(Ie=!Array.from(mt.values()).some(Ge=>Ge.has(he)));return Ie&&Fy(G,[U.name,U.id,U.description,U.sourceLabel,U.source,U.path])}),[u,G,ge,mt]),zn=h.useMemo(()=>m.filter(U=>Fy(G,[U.id,U.name,U.displayName,U.description,U.version,U.packageDir,Array.isArray(U.tags)?U.tags.join(" "):""])),[m,G]),jr=Kn||Ht||i==="skills",lt=h.useMemo(()=>Nr.find(U=>Mn(U)===ve)||Nr[0]||null,[Nr,ve]),Wt=h.useMemo(()=>Zn.find(U=>Mn(U)===ve)||Zn[0]||null,[Zn,ve]),Yt=h.useMemo(()=>zn.find(U=>Sa(U)===ve)||zn[0]||null,[zn,ve]),Rn=Wt?Ae[Mn(Wt)]:null,Je=lt?Ct[Mn(lt)]:null,lr=lt&&hn?Bt[`${Mn(lt)}:${hn}`]:null,_s=n(Kn?"project:searchNodes":Ht?"project:searchFlows":i==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(i!=="skills"||!Wt)return;const U=Mn(Wt);if(Ae[U])return;let he=!1;return et(U),fetch(`/api/skills/detail?key=${encodeURIComponent(U)}`).then(Ie=>Ie.json().then(Pe=>({ok:Ie.ok,json:Pe}))).then(({ok:Ie,json:Pe})=>{he||Ie&&Pe.skill&&st(Ge=>({...Ge,[U]:Pe.skill}))}).catch(()=>{}).finally(()=>{he||et("")}),()=>{he=!0}},[i,Wt,Ae]),h.useEffect(()=>{if(!Kn||!lt)return;const U=Mn(lt);if(Ct[U])return;let he=!1;return nn(U),fetch(`/api/nodes/detail?id=${encodeURIComponent(lt.id)}`).then(Ie=>Ie.json().then(Pe=>({ok:Ie.ok,json:Pe}))).then(({ok:Ie,json:Pe})=>{he||Ie&&Ue(Ge=>({...Ge,[U]:Pe}))}).catch(()=>{}).finally(()=>{he||nn("")}),()=>{he=!0}},[Kn,lt,Ct]),h.useEffect(()=>{if(!Kn)return;const U=Array.isArray(Je==null?void 0:Je.files)?Je.files:[];An(he=>{var Ie;return he&&U.some(Pe=>Pe.path===he)?he:((Ie=U[0])==null?void 0:Ie.path)||""})},[Kn,Je]),h.useEffect(()=>{if(!Kn||!lt||!hn)return;const U=`${Mn(lt)}:${hn}`;if(Bt[U])return;let he=!1;return le(U),fetch(`/api/nodes/file?id=${encodeURIComponent(lt.id)}&path=${encodeURIComponent(hn)}`).then(Ie=>Ie.json().then(Pe=>({ok:Ie.ok,json:Pe}))).then(({ok:Ie,json:Pe})=>{he||Ie&&In(Ge=>({...Ge,[U]:Pe}))}).catch(()=>{}).finally(()=>{he||le("")}),()=>{he=!0}},[Kn,lt,hn,Bt]),h.useEffect(()=>{ot("")},[ve,i]);const Cr=U=>{r(th(U,"workspace"))},hi=U=>{fe(nS(U)),r(th({id:U.flowId,source:U.flowSource,archived:!!U.archived},"workspace"))},Ps=h.useCallback(U=>{var he,Ie;U.preventDefault(),U.stopPropagation(),(Ie=(he=U.dataTransfer)==null?void 0:he.types)!=null&&Ie.includes("Files")&&(Te.current+=1,P(!0))},[]),Eo=h.useCallback(U=>{U.preventDefault(),U.stopPropagation(),Te.current-=1,Te.current<=0&&(Te.current=0,P(!1))},[]),Ui=h.useCallback(U=>{U.preventDefault(),U.stopPropagation()},[]),_o=h.useCallback(U=>{var Pe,Ge;U.preventDefault(),U.stopPropagation(),Te.current=0,P(!1);const he=(Ge=(Pe=U.dataTransfer)==null?void 0:Pe.files)==null?void 0:Ge[0];if(!he)return;const Ie=he.name.toLowerCase();!Ie.endsWith(".yaml")&&!Ie.endsWith(".yml")&&!Ie.endsWith(".zip")||_(he)},[]);return o.jsxs("div",{className:"af-projects"+(R?" af-projects--drop-target":""),onDragEnter:Ps,onDragLeave:Eo,onDragOver:Ui,onDrop:_o,children:[o.jsxs("header",{className:"af-projects-top",children:[e?o.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):o.jsxs("div",{className:"af-projects-tabs",children:[o.jsx("button",{type:"button",className:i==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>a("all"),children:n("project:all")}),o.jsx("button",{type:"button",className:i==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>a("archived"),children:n("project:archived")})]}),o.jsxs("div",{className:"af-projects-top-right",children:[o.jsxs("div",{className:"af-search-wrap",children:[o.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),o.jsx("input",{className:"af-search"+(G.trim()?" af-search--has-clear":""),type:"search",placeholder:_s,"aria-label":_s,autoComplete:"off",value:G,onChange:U=>Z(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(Z(""),U.currentTarget.blur())}}),G.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>Z(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),jr?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>Ye(),children:n("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(V?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":V,"aria-controls":"af-recent-activity-panel",onClick:()=>se(U=>!U),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>E(!0),children:n("project:createNew")})]})]})]}),o.jsxs("div",{className:"af-projects-body",children:[o.jsxs("section",{className:"af-projects-main",children:[o.jsxs("header",{className:"af-projects-section-head",children:[o.jsx("h2",{className:"af-projects-h2",children:n(i==="my-nodes"?"project:myNodes":i==="my-flows"?"project:myFlows":i==="nodes"?"project:globalNodes":i==="skills"?"project:globalSkills":i==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:ar?n("project:filterResult",{count:i==="nodes"||i==="my-nodes"?Nr.length:i==="my-flows"?zn.length:i==="skills"?Zn.length:Oe.length}):i==="my-nodes"?n("project:myNodesHint",{count:Nr.length}):i==="my-flows"?n("project:myFlowsHint",{count:zn.length}):i==="nodes"?n("project:nodesHint",{count:d.length}):i==="skills"?n("project:skillsHint",{count:u.length}):n(i==="archived"?"project:archivedHint":"project:activeHint")}),$?o.jsx("p",{className:"af-err af-projects-api-hint",children:$}):null,F&&jr?o.jsx("p",{className:"af-err af-projects-api-hint",children:F}):null]}),jr?o.jsxs("div",{className:"af-resource-toolbar",children:[i==="skills"?o.jsx(e$,{onChanged:Ye}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:Ht?"schema":Kn?Le?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(Ht?"project:myFlowsPurposeTitle":Le?"project:myNodesPurposeTitle":Kn?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(Ht?"project:myFlowsPurposeDesc":Le?"project:myNodesPurposeDesc":Kn?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),Ht?null:o.jsx("div",{className:"af-resource-filter-row",children:(Kn?(Le?u$:c$).map(U=>({id:U,label:n(`project:resourceFilter.${U}`)})):Vi).map(U=>U.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(ge===U.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ae(U.id),_e("")},children:[U.label,o.jsx("em",{children:U.count}),U.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),U.collection.builtin?null:o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:w,"aria-label":`删除 ${U.collection.name}`,onClick:()=>Nn(U.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},U.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(ge===U.id?" af-resource-filter--active":""),onClick:()=>{ae(U.id),_e("")},children:U.label},U.id))}),i==="skills"?o.jsx("div",{className:"af-skill-collections-manager",children:o.jsxs("div",{className:"af-skill-collections-create",children:[o.jsx("input",{className:"af-set-input af-set-input--sm",value:y,onChange:U=>k(U.target.value),onKeyDown:U=>{U.key==="Enter"&&Ke()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!y.trim()||w,onClick:()=>Ke(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Kn?o.jsx("div",{className:"af-resource-grid",children:Nr.length>0?Nr.map(U=>o.jsxs("button",{type:"button",className:"af-resource-card"+(lt&&Mn(U)===Mn(lt)?" af-resource-card--active":""),onClick:()=>_e(Mn(U)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:wd(U.type==="control"?"secondary":U.type==="provide"?"primary":"muted"),children:o.jsx(sr,{query:G,children:U.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(sr,{query:G,children:eS(U.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(sr,{query:G,children:U.label||U.displayName||U.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:G,children:U.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(sr,{query:G,children:U.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(U.inputs||{}).length,outputs:Object.keys(U.outputs||{}).length})})]}),U.packageId?o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),o.jsx("span",{className:"af-path-text",children:o.jsx(sr,{query:G,children:`${U.packageId}${U.version?` / ${U.version}`:""}`})})]}):null]},`${U.id}:${U.source||""}:${U.packageId||""}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:ar?n("project:noNodeMatch",{query:G.trim()}):n(Le?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):Ht?o.jsx("div",{className:"af-resource-grid",children:zn.length>0?zn.map(U=>{const he=z_(U),Ie=B_(U),Pe=Number.isFinite(Number(U.nodeCount))?Number(U.nodeCount):he.length,Ge=Number.isFinite(Number(U.edgeCount))?Number(U.edgeCount):Ie.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(Yt&&Sa(U)===Sa(Yt)?" af-resource-card--active":""),onClick:()=>_e(Sa(U)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:wd("primary"),children:o.jsx(sr,{query:G,children:U.version?`v${U.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(sr,{query:G,children:U.displayName||U.name||U.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:G,children:U.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Pe,edges:Ge})}),o.jsx("span",{children:o.jsx(sr,{query:G,children:U.id})})]}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),o.jsx("span",{className:"af-path-text",children:o.jsx(sr,{query:G,children:tS(U)})})]})]},Sa(U))}):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:ar?n("project:noFlowSnippetMatch",{query:G.trim()}):n("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i==="skills"?o.jsx("div",{className:"af-resource-grid",children:Zn.length>0?Zn.map(U=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Wt&&Mn(U)===Mn(Wt)?" af-resource-card--active":""),onClick:()=>_e(Mn(U)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:wd(U.source==="builtin"?"muted":"primary"),children:o.jsx(sr,{query:G,children:U.sourceLabel||U.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(sr,{query:G,children:U.name||U.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:G,children:U.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),o.jsx("span",{className:"af-path-text",children:o.jsx(sr,{query:G,children:U.path||U.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[b.filter(he=>he.skillKeys.includes(Mn(U))).slice(0,3).map(he=>o.jsx("span",{children:he.name},he.id)),b.filter(he=>he.skillKeys.includes(Mn(U))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},U.key||`${U.source}:${U.name}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:ar?n("project:noSkillMatch",{query:G.trim()}):n("project:noSkills")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):o.jsxs(o.Fragment,{children:[t!=null&&t.isAdmin&&i==="all"&&pi.length>0?o.jsxs("div",{className:"af-project-admin-panel",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"已隐藏内置"}),o.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),o.jsx("div",{className:"af-project-admin-hidden-list",children:pi.map(U=>{const he=kn===`show-builtin:builtin:${U}`;return o.jsxs("button",{type:"button",disabled:he,onClick:()=>je({id:U,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:U}),o.jsx("em",{children:he?"恢复中":"恢复"})]},U)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[Oe.length>0?Oe.map(U=>{const he=(t==null?void 0:t.isAdmin)&&U.source==="user"&&!U.archived&&!aa.has(U.id),Ie=(t==null?void 0:t.isAdmin)&&U.source==="admin",Pe=(t==null?void 0:t.isAdmin)&&U.source==="builtin",Ge=kn.endsWith(`:${U.source}:${U.id}`);return o.jsx("div",{className:"af-project-card",role:"button",tabIndex:0,onClick:()=>Cr(U),onKeyDown:Vt=>{(Vt.key==="Enter"||Vt.key===" ")&&(Vt.preventDefault(),Cr(U))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:wd(Aw(U.source,n).tone),children:o.jsx(sr,{query:G,children:Aw(U.source,n).label})}),U.archived?o.jsx("span",{className:wd("muted"),children:o.jsx(sr,{query:G,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(sr,{query:G,children:U.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:G,children:D_(U,n)})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),o.jsx("span",{className:"af-path-text",children:o.jsx(sr,{query:G,children:$_(U)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Vt=>Vt.stopPropagation(),onKeyDown:Vt=>Vt.stopPropagation(),children:[he?o.jsx("button",{type:"button",disabled:Ge,onClick:()=>je(U,"promote"),children:"设为内置"}):null,Ie?o.jsx("button",{type:"button",disabled:Ge,onClick:()=>je(U,"unpromote"),children:"取消内置"}):null,Pe?o.jsx("button",{type:"button",disabled:Ge,onClick:()=>je(U,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${U.id}:${U.source??"user"}:${U.archived?"a":""}`)}):L?qs.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:i==="archived"?n("project:noArchived"):l.length>0?n("project:noActive"):n($?"project:loadFailed":"project:noPipelines")}),!$&&l.length===0&&i==="all"?o.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:G.trim()})})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),o.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>E(!0),children:[o.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),o.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),or?null:o.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[o.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),o.jsxs("span",{className:"af-hub-card__eyebrow",children:[o.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),o.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),o.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),o.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),o.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),o.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),jr?o.jsx("aside",{className:"af-resource-detail","aria-label":n(Kn?"project:nodeDetail":Ht?"project:flowDetail":"project:skillDetail"),children:Kn&&lt?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h3",{children:lt.label||lt.displayName||lt.id}),o.jsx("p",{children:lt.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(U=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(we===U?" af-resource-detail-tab--active":""),onClick:()=>Ee(U),children:n(`project:nodeDetailTabs.${U}`)},U))}),St===Mn(lt)?o.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):we==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:lt.description||((Ys=Je==null?void 0:Je.node)==null?void 0:Ys.description)||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailType")}),o.jsx("dd",{children:lt.type||((an=Je==null?void 0:Je.node)==null?void 0:an.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:eS(lt.source,n)})]}),lt.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPackage")}),o.jsx("dd",{children:lt.packageId})]}):null,lt.version?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:lt.version})]}):null,lt.packageDir||Je!=null&&Je.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:lt.packageDir||(Je==null?void 0:Je.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(Je==null?void 0:Je.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),Le&&lt.source==="marketplace"?o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myNodeManagement")}),o.jsx("p",{children:n("project:deleteMyNodeHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:de===Mn(lt),onClick:()=>jo(lt),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),de===Mn(lt)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),Qe?o.jsx("p",{className:"af-resource-action-message",children:Qe}):null]}):null,o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:nodesMeaning")})]})]}):we==="schema"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeSchema")}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeInputs")}),nh(((As=Je==null?void 0:Je.node)==null?void 0:As.inputs)||lt.inputs).length>0?nh(((Is=Je==null?void 0:Je.node)==null?void 0:Is.inputs)||lt.inputs).map(U=>o.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),nh(((Ts=Je==null?void 0:Je.node)==null?void 0:Ts.outputs)||lt.outputs).length>0?nh(((Gs=Je==null?void 0:Je.node)==null?void 0:Gs.outputs)||lt.outputs).map(U=>o.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):o.jsx("em",{children:n("project:noSlots")})]})]}):we==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeRuntime")}),Je!=null&&Je.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Je.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),Je!=null&&Je.body?o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),o.jsx("pre",{className:"af-resource-skill-preview",children:Je.body})]}):o.jsx("p",{children:n("project:noNodeBody")})]}):we==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(Je==null?void 0:Je.files)&&Je.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:Je.files.map(U=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(hn===U.path?" af-node-file-item--active":""),onClick:()=>An(U.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:U.path})]},U.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[Fn===`${Mn(lt)}:${hn}`?n("project:loadingResources"):lr!=null&&lr.binary?n("project:binaryFile"):(lr==null?void 0:lr.content)||n("project:selectNodeFile"),lr!=null&&lr.truncated?`
43
+
44
+ ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFiles")})]}):o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(Je==null?void 0:Je.usage)&&Je.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:Je.usage.map(U=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:U.flowId}),o.jsxs("span",{children:[U.flowSource,U.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:U.instances.map(he=>he.label||he.instanceId).join(", ")})]},`${U.flowSource}:${U.flowId}:${U.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):Ht&&Yt?(()=>{const U=y$(Yt);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"schema"}),o.jsxs("div",{children:[o.jsx("h3",{children:Yt.displayName||Yt.name||Yt.id}),o.jsx("p",{children:Yt.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Yt.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:Yt.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:tS(Yt)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Yt.nodeCount))?Number(Yt.nodeCount):U.nodes.length,edges:Number.isFinite(Number(Yt.edgeCount))?Number(Yt.edgeCount):U.edges.length})})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:myFlowsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myFlowManagement")}),o.jsx("p",{children:n("project:deleteMyFlowHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Qt===Sa(Yt),onClick:()=>kr(Yt),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),Qt===Sa(Yt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),Tn?o.jsx("p",{className:"af-resource-action-message",children:Tn}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),U.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:U.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:o.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),o.jsx("g",{className:"af-flow-snippet-map__edges",children:U.diagram.edges.map(he=>o.jsxs("g",{children:[o.jsx("path",{d:he.path}),he.label?o.jsx("text",{x:he.labelX,y:he.labelY-5,textAnchor:"middle",children:zy(he.label,18)}):null]},he.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:U.diagram.nodes.map((he,Ie)=>o.jsxs("g",{transform:`translate(${he.x} ${he.y})`,children:[o.jsx("rect",{width:he.width,height:he.height,rx:"10"}),o.jsx("circle",{cx:"19",cy:he.height/2,r:"12"}),o.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:he.height/2+4,textAnchor:"middle",children:Ie+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:he.height/2-3,children:zy(he.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:he.height/2+16,children:zy(he.meta||he.id,20)})]},he.id))})]})}):o.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),o.jsxs("details",{className:"af-flow-snippet-json",children:[o.jsx("summary",{children:n("project:flowSnippetJson")}),o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Yt.snippet||{},null,2)})]})]})]})})():i==="skills"&&Wt?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:Wt.name||Wt.id}),o.jsx("p",{children:Wt.sourceLabel||Wt.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Wt.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:Wt.sourceLabel||Wt.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Wt.path||Wt.key})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:"Collections"}),b.length===0?o.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):o.jsx("div",{className:"af-skill-detail-collections",children:b.map(U=>{const he=Mn(Wt),Ie=U.skillKeys.includes(he);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Ie,disabled:w,onChange:Pe=>fi(U.id,he,Pe.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:U.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[U.skillKeys.length," skills"]})]})]},U.id)})})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:skillsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:skillPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:ut===Mn(Wt)?n("project:loadingResources"):(Rn==null?void 0:Rn.body)||(Rn==null?void 0:Rn.content)||n("project:skillPreviewEmpty")})]})]}):o.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):o.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(V?"":" af-activity--hidden"),"aria-hidden":!V,"aria-label":n("project:recentActivity"),children:[o.jsxs("h2",{className:"af-activity-title",children:[o.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),o.jsx("div",{className:"af-activity-list",children:Co.length===0?o.jsx("p",{className:"af-activity-empty",children:Sr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Co.map(U=>{const he=ue===nS(U);return o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(he?" af-activity-row--active":""),"aria-current":he?"page":void 0,onClick:()=>hi(U),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(sr,{query:G,children:U.flowId})}),o.jsx("span",{className:"af-activity-time",children:Cw(U.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:r$(U.kind),children:U.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[U.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",Cw(U.at,n)]})]})]},`${U.kind}-${U.flowId}-${U.flowSource}-${U.at}`)})})]})]}),o.jsx(YM,{open:T,onClose:()=>E(!1),onCreated:async U=>{E(!1),await re();const he=U.source??"user";r(th({id:U.id,source:he},"workspace"))}}),D?o.jsx(KM,{file:D,onClose:()=>_(null),onImported:async U=>{_(null),await re();const he=U.source??"user";r(th({id:U.id,source:he},"workspace"))}},`${D.name}-${D.size}-${D.lastModified}`):null]})}function mr(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=mr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var x$={value:()=>{}};function Sg(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new zh(n)}function zh(e){this._=e}function w$(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}})}zh.prototype=Sg.prototype={constructor:zh,on:function(e,t){var n=this._,r=w$(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=b$(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(s=(e=r[i]).type)n[s]=iS(n[s],e.name,t);else if(t==null)for(s in n)n[s]=iS(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 zh(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[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,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function b$(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function iS(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=x$,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Rw="http://www.w3.org/1999/xhtml";const oS={svg:"http://www.w3.org/2000/svg",xhtml:Rw,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ng(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),oS.hasOwnProperty(t)?{space:oS[t],local:e}:e}function v$(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Rw&&t.documentElement.namespaceURI===Rw?t.createElement(e):t.createElementNS(n,e)}}function k$(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function H_(e){var t=Ng(e);return(t.local?k$:v$)(t)}function S$(){}function vv(e){return e==null?S$:function(){return this.querySelector(e)}}function N$(e){typeof e!="function"&&(e=vv(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=new Array(a),c,d,f=0;f<a;++f)(c=i[f])&&(d=e.call(c,c.__data__,f,i))&&("__data__"in c&&(d.__data__=c.__data__),l[f]=d);return new Vs(r,this._parents)}function j$(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function C$(){return[]}function W_(e){return e==null?C$:function(){return this.querySelectorAll(e)}}function E$(e){return function(){return j$(e.apply(this,arguments))}}function _$(e){typeof e=="function"?e=E$(e):e=W_(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var a=t[i],l=a.length,c,d=0;d<l;++d)(c=a[d])&&(r.push(e.call(c,c.__data__,d,a)),s.push(c));return new Vs(r,s)}function V_(e){return function(){return this.matches(e)}}function U_(e){return function(t){return t.matches(e)}}var P$=Array.prototype.find;function A$(e){return function(){return P$.call(this.children,e)}}function I$(){return this.firstElementChild}function T$(e){return this.select(e==null?I$:A$(typeof e=="function"?e:U_(e)))}var R$=Array.prototype.filter;function L$(){return Array.from(this.children)}function O$(e){return function(){return R$.call(this.children,e)}}function M$(e){return this.selectAll(e==null?L$:O$(typeof e=="function"?e:U_(e)))}function $$(e){typeof e!="function"&&(e=V_(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],c,d=0;d<a;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&l.push(c);return new Vs(r,this._parents)}function K_(e){return new Array(e.length)}function D$(){return new Vs(this._enter||this._groups.map(K_),this._parents)}function Nm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Nm.prototype={constructor:Nm,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function F$(e){return function(){return e}}function z$(e,t,n,r,s,i){for(var a=0,l,c=t.length,d=i.length;a<d;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Nm(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function B$(e,t,n,r,s,i,a){var l,c,d=new Map,f=t.length,u=i.length,p=new Array(f),m;for(l=0;l<f;++l)(c=t[l])&&(p[l]=m=a.call(c,c.__data__,l,t)+"",d.has(m)?s[l]=c:d.set(m,c));for(l=0;l<u;++l)m=a.call(e,i[l],l,i)+"",(c=d.get(m))?(r[l]=c,c.__data__=i[l],d.delete(m)):n[l]=new Nm(e,i[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(p[l])===c&&(s[l]=c)}function H$(e){return e.__data__}function W$(e,t){if(!arguments.length)return Array.from(this,H$);var n=t?B$:z$,r=this._parents,s=this._groups;typeof e!="function"&&(e=F$(e));for(var i=s.length,a=new Array(i),l=new Array(i),c=new Array(i),d=0;d<i;++d){var f=r[d],u=s[d],p=u.length,m=V$(e.call(f,f&&f.__data__,d,r)),g=m.length,b=l[d]=new Array(g),v=a[d]=new Array(g),y=c[d]=new Array(p);n(f,u,b,v,y,m,t);for(var k=0,w=0,j,A;k<g;++k)if(j=b[k]){for(k>=w&&(w=k+1);!(A=v[w])&&++w<g;);j._next=A||null}}return a=new Vs(a,r),a._enter=l,a._exit=c,a}function V$(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function U$(){return new Vs(this._exit||this._groups.map(K_),this._parents)}function K$(e,t,n){var r=this.enter(),s=this,i=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?i.remove():n(i),r&&s?r.merge(s).order():s}function q$(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,a=Math.min(s,i),l=new Array(s),c=0;c<a;++c)for(var d=n[c],f=r[c],u=d.length,p=l[c]=new Array(u),m,g=0;g<u;++g)(m=d[g]||f[g])&&(p[g]=m);for(;c<s;++c)l[c]=n[c];return new Vs(l,this._parents)}function Y$(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],a;--s>=0;)(a=r[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function G$(e){e||(e=X$);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,c=s[i]=new Array(l),d,f=0;f<l;++f)(d=a[f])&&(c[f]=d);c.sort(t)}return new Vs(s,this._parents).order()}function X$(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function J$(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Q$(){return Array.from(this)}function Z$(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var a=r[s];if(a)return a}return null}function eD(){let e=0;for(const t of this)++e;return e}function tD(){return!this.node()}function nD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,a=s.length,l;i<a;++i)(l=s[i])&&e.call(l,l.__data__,i,s);return this}function rD(e){return function(){this.removeAttribute(e)}}function sD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function iD(e,t){return function(){this.setAttribute(e,t)}}function oD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function aD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function lD(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 cD(e,t){var n=Ng(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?sD:rD:typeof t=="function"?n.local?lD:aD:n.local?oD:iD)(n,t))}function q_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function uD(e){return function(){this.style.removeProperty(e)}}function dD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fD(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function pD(e,t,n){return arguments.length>1?this.each((t==null?uD:typeof t=="function"?fD:dD)(e,t,n??"")):ku(this.node(),e)}function ku(e,t){return e.style.getPropertyValue(t)||q_(e).getComputedStyle(e,null).getPropertyValue(t)}function hD(e){return function(){delete this[e]}}function mD(e,t){return function(){this[e]=t}}function gD(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yD(e,t){return arguments.length>1?this.each((t==null?hD:typeof t=="function"?gD:mD)(e,t)):this.node()[e]}function Y_(e){return e.trim().split(/^|\s+/)}function kv(e){return e.classList||new G_(e)}function G_(e){this._node=e,this._names=Y_(e.getAttribute("class")||"")}G_.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 X_(e,t){for(var n=kv(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function J_(e,t){for(var n=kv(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function xD(e){return function(){X_(this,e)}}function wD(e){return function(){J_(this,e)}}function bD(e,t){return function(){(t.apply(this,arguments)?X_:J_)(this,e)}}function vD(e,t){var n=Y_(e+"");if(arguments.length<2){for(var r=kv(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?bD:t?xD:wD)(n,t))}function kD(){this.textContent=""}function SD(e){return function(){this.textContent=e}}function ND(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function jD(e){return arguments.length?this.each(e==null?kD:(typeof e=="function"?ND:SD)(e)):this.node().textContent}function CD(){this.innerHTML=""}function ED(e){return function(){this.innerHTML=e}}function _D(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function PD(e){return arguments.length?this.each(e==null?CD:(typeof e=="function"?_D:ED)(e)):this.node().innerHTML}function AD(){this.nextSibling&&this.parentNode.appendChild(this)}function ID(){return this.each(AD)}function TD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function RD(){return this.each(TD)}function LD(e){var t=typeof e=="function"?e:H_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function OD(){return null}function MD(e,t){var n=typeof e=="function"?e:H_(e),r=t==null?OD:typeof t=="function"?t:vv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function $D(){var e=this.parentNode;e&&e.removeChild(this)}function DD(){return this.each($D)}function FD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function BD(e){return this.select(e?zD:FD)}function HD(e){return arguments.length?this.property("__data__",e):this.node().__data__}function WD(e){return function(t){e.call(this,t,this.__data__)}}function VD(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 UD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function KD(e,t,n){return function(){var r=this.__on,s,i=WD(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=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function qD(e,t,n){var r=VD(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,f;c<d;++c)for(s=0,f=l[c];s<i;++s)if((a=r[s]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?KD:UD,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function Q_(e,t,n){var r=q_(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 YD(e,t){return function(){return Q_(this,e,t)}}function GD(e,t){return function(){return Q_(this,e,t.apply(this,arguments))}}function XD(e,t){return this.each((typeof t=="function"?GD:YD)(e,t))}function*JD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,a;s<i;++s)(a=r[s])&&(yield a)}var Z_=[null];function Vs(e,t){this._groups=e,this._parents=t}function Qf(){return new Vs([[document.documentElement]],Z_)}function QD(){return this}Vs.prototype=Qf.prototype={constructor:Vs,select:N$,selectAll:_$,selectChild:T$,selectChildren:M$,filter:$$,data:W$,enter:D$,exit:U$,join:K$,merge:q$,selection:QD,order:Y$,sort:G$,call:J$,nodes:Q$,node:Z$,size:eD,empty:tD,each:nD,attr:cD,style:pD,property:yD,classed:vD,text:jD,html:PD,raise:ID,lower:RD,append:LD,insert:MD,remove:DD,clone:BD,datum:HD,on:qD,dispatch:XD,[Symbol.iterator]:JD};function Ds(e){return typeof e=="string"?new Vs([[document.querySelector(e)]],[document.documentElement]):new Vs([[e]],Z_)}function ZD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ii(e,t){if(e=ZD(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 eF={passive:!1},Nf={capture:!0,passive:!1};function By(e){e.stopImmediatePropagation()}function cu(e){e.preventDefault(),e.stopImmediatePropagation()}function eP(e){var t=e.document.documentElement,n=Ds(e).on("dragstart.drag",cu,Nf);"onselectstart"in t?n.on("selectstart.drag",cu,Nf):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function tP(e,t){var n=e.document.documentElement,r=Ds(e).on("dragstart.drag",null);t&&(r.on("click.drag",cu,Nf),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 rh=e=>()=>e;function Lw(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:c,dy:d,dispatch:f}){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:i,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:d,enumerable:!0,configurable:!0},_:{value:f}})}Lw.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tF(e){return!e.ctrlKey&&!e.button}function nF(){return this.parentNode}function rF(e,t){return t??{x:e.x,y:e.y}}function sF(){return navigator.maxTouchPoints||"ontouchstart"in this}function nP(){var e=tF,t=nF,n=rF,r=sF,s={},i=Sg("start","drag","end"),a=0,l,c,d,f,u=0;function p(j){j.on("mousedown.drag",m).filter(r).on("touchstart.drag",v).on("touchmove.drag",y,eF).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(j,A){if(!(f||!e.call(this,j,A))){var C=w(this,t.call(this,j,A),j,A,"mouse");C&&(Ds(j.view).on("mousemove.drag",g,Nf).on("mouseup.drag",b,Nf),eP(j.view),By(j),d=!1,l=j.clientX,c=j.clientY,C("start",j))}}function g(j){if(cu(j),!d){var A=j.clientX-l,C=j.clientY-c;d=A*A+C*C>u}s.mouse("drag",j)}function b(j){Ds(j.view).on("mousemove.drag mouseup.drag",null),tP(j.view,d),cu(j),s.mouse("end",j)}function v(j,A){if(e.call(this,j,A)){var C=j.changedTouches,$=t.call(this,j,A),B=C.length,F,z;for(F=0;F<B;++F)(z=w(this,$,j,A,C[F].identifier,C[F]))&&(By(j),z("start",j,C[F]))}}function y(j){var A=j.changedTouches,C=A.length,$,B;for($=0;$<C;++$)(B=s[A[$].identifier])&&(cu(j),B("drag",j,A[$]))}function k(j){var A=j.changedTouches,C=A.length,$,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),$=0;$<C;++$)(B=s[A[$].identifier])&&(By(j),B("end",j,A[$]))}function w(j,A,C,$,B,F){var z=i.copy(),L=Ii(F||C,A),O,W,M;if((M=n.call(j,new Lw("beforestart",{sourceEvent:C,target:p,identifier:B,active:a,x:L[0],y:L[1],dx:0,dy:0,dispatch:z}),$))!=null)return O=M.x-L[0]||0,W=M.y-L[1]||0,function T(E,D,_){var R=L,P;switch(E){case"start":s[B]=T,P=a++;break;case"end":delete s[B],--a;case"drag":L=Ii(_||D,A),P=a;break}z.call(E,j,new Lw(E,{sourceEvent:D,subject:M,target:p,identifier:B,active:P,x:L[0]+O,y:L[1]+W,dx:L[0]-R[0],dy:L[1]-R[1],dispatch:z}),$)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:rh(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:rh(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:rh(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:rh(!!j),p):r},p.on=function(){var j=i.on.apply(i,arguments);return j===i?p:j},p.clickDistance=function(j){return arguments.length?(u=(j=+j)*j,p):Math.sqrt(u)},p}function Sv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function rP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zf(){}var jf=.7,jm=1/jf,uu="\\s*([+-]?\\d+)\\s*",Cf="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",go="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iF=/^#([0-9a-f]{3,8})$/,oF=new RegExp(`^rgb\\(${uu},${uu},${uu}\\)$`),aF=new RegExp(`^rgb\\(${go},${go},${go}\\)$`),lF=new RegExp(`^rgba\\(${uu},${uu},${uu},${Cf}\\)$`),cF=new RegExp(`^rgba\\(${go},${go},${go},${Cf}\\)$`),uF=new RegExp(`^hsl\\(${Cf},${go},${go}\\)$`),dF=new RegExp(`^hsla\\(${Cf},${go},${go},${Cf}\\)$`),aS={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};Sv(Zf,tc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:lS,formatHex:lS,formatHex8:fF,formatHsl:pF,formatRgb:cS,toString:cS});function lS(){return this.rgb().formatHex()}function fF(){return this.rgb().formatHex8()}function pF(){return sP(this).formatHsl()}function cS(){return this.rgb().formatRgb()}function tc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?uS(t):n===3?new ys(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?sh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?sh(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=oF.exec(e))?new ys(t[1],t[2],t[3],1):(t=aF.exec(e))?new ys(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lF.exec(e))?sh(t[1],t[2],t[3],t[4]):(t=cF.exec(e))?sh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uF.exec(e))?pS(t[1],t[2]/100,t[3]/100,1):(t=dF.exec(e))?pS(t[1],t[2]/100,t[3]/100,t[4]):aS.hasOwnProperty(e)?uS(aS[e]):e==="transparent"?new ys(NaN,NaN,NaN,0):null}function uS(e){return new ys(e>>16&255,e>>8&255,e&255,1)}function sh(e,t,n,r){return r<=0&&(e=t=n=NaN),new ys(e,t,n,r)}function hF(e){return e instanceof Zf||(e=tc(e)),e?(e=e.rgb(),new ys(e.r,e.g,e.b,e.opacity)):new ys}function Ow(e,t,n,r){return arguments.length===1?hF(e):new ys(e,t,n,r??1)}function ys(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Sv(ys,Ow,rP(Zf,{brighter(e){return e=e==null?jm:Math.pow(jm,e),new ys(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?jf:Math.pow(jf,e),new ys(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ys(Ul(this.r),Ul(this.g),Ul(this.b),Cm(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:dS,formatHex:dS,formatHex8:mF,formatRgb:fS,toString:fS}));function dS(){return`#${Hl(this.r)}${Hl(this.g)}${Hl(this.b)}`}function mF(){return`#${Hl(this.r)}${Hl(this.g)}${Hl(this.b)}${Hl((isNaN(this.opacity)?1:this.opacity)*255)}`}function fS(){const e=Cm(this.opacity);return`${e===1?"rgb(":"rgba("}${Ul(this.r)}, ${Ul(this.g)}, ${Ul(this.b)}${e===1?")":`, ${e})`}`}function Cm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ul(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Hl(e){return e=Ul(e),(e<16?"0":"")+e.toString(16)}function pS(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Li(e,t,n,r)}function sP(e){if(e instanceof Li)return new Li(e.h,e.s,e.l,e.opacity);if(e instanceof Zf||(e=tc(e)),!e)return new Li;if(e instanceof Li)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-s,c=(i+s)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?i+s:2-i-s,a*=60):l=c>0&&c<1?0:a,new Li(a,l,c,e.opacity)}function gF(e,t,n,r){return arguments.length===1?sP(e):new Li(e,t,n,r??1)}function Li(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Sv(Li,gF,rP(Zf,{brighter(e){return e=e==null?jm:Math.pow(jm,e),new Li(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?jf:Math.pow(jf,e),new Li(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 ys(Hy(e>=240?e-240:e+120,s,r),Hy(e,s,r),Hy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Li(hS(this.h),ih(this.s),ih(this.l),Cm(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=Cm(this.opacity);return`${e===1?"hsl(":"hsla("}${hS(this.h)}, ${ih(this.s)*100}%, ${ih(this.l)*100}%${e===1?")":`, ${e})`}`}}));function hS(e){return e=(e||0)%360,e<0?e+360:e}function ih(e){return Math.max(0,Math.min(1,e||0))}function Hy(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 Nv=e=>()=>e;function yF(e,t){return function(n){return e+n*t}}function xF(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 wF(e){return(e=+e)==1?iP:function(t,n){return n-t?xF(t,n,e):Nv(isNaN(t)?n:t)}}function iP(e,t){var n=t-e;return n?yF(e,n):Nv(isNaN(e)?t:e)}const Em=function e(t){var n=wF(t);function r(s,i){var a=n((s=Ow(s)).r,(i=Ow(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),d=iP(s.opacity,i.opacity);return function(f){return s.r=a(f),s.g=l(f),s.b=c(f),s.opacity=d(f),s+""}}return r.gamma=e,r}(1);function bF(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;s<n;++s)r[s]=e[s]*(1-i)+t[s]*i;return r}}function vF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function kF(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),i=new Array(n),a;for(a=0;a<r;++a)s[a]=Jd(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<r;++a)i[a]=s[a](l);return i}}function SF(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ao(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function NF(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]=Jd(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Mw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wy=new RegExp(Mw.source,"g");function jF(e){return function(){return e}}function CF(e){return function(t){return e(t)+""}}function oP(e,t){var n=Mw.lastIndex=Wy.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Mw.exec(e))&&(s=Wy.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:ao(r,s)})),n=Wy.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?CF(c[0].x):jF(t):(t=c.length,function(d){for(var f=0,u;f<t;++f)l[(u=c[f]).i]=u.x(d);return l.join("")})}function Jd(e,t){var n=typeof t,r;return t==null||n==="boolean"?Nv(t):(n==="number"?ao:n==="string"?(r=tc(t))?(t=r,Em):oP:t instanceof tc?Em:t instanceof Date?SF:vF(t)?bF:Array.isArray(t)?kF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?NF:ao)(e,t)}var mS=180/Math.PI,$w={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function aP(e,t,n,r,s,i){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:i,rotate:Math.atan2(t,e)*mS,skewX:Math.atan(c)*mS,scaleX:a,scaleY:l}}var oh;function EF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$w:aP(t.a,t.b,t.c,t.d,t.e,t.f)}function _F(e){return e==null||(oh||(oh=document.createElementNS("http://www.w3.org/2000/svg","g")),oh.setAttribute("transform",e),!(e=oh.transform.baseVal.consolidate()))?$w:(e=e.matrix,aP(e.a,e.b,e.c,e.d,e.e,e.f))}function lP(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function i(d,f,u,p,m,g){if(d!==u||f!==p){var b=m.push("translate(",null,t,null,n);g.push({i:b-4,x:ao(d,u)},{i:b-2,x:ao(f,p)})}else(u||p)&&m.push("translate("+u+t+p+n)}function a(d,f,u,p){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),p.push({i:u.push(s(u)+"rotate(",null,r)-2,x:ao(d,f)})):f&&u.push(s(u)+"rotate("+f+r)}function l(d,f,u,p){d!==f?p.push({i:u.push(s(u)+"skewX(",null,r)-2,x:ao(d,f)}):f&&u.push(s(u)+"skewX("+f+r)}function c(d,f,u,p,m,g){if(d!==u||f!==p){var b=m.push(s(m)+"scale(",null,",",null,")");g.push({i:b-4,x:ao(d,u)},{i:b-2,x:ao(f,p)})}else(u!==1||p!==1)&&m.push(s(m)+"scale("+u+","+p+")")}return function(d,f){var u=[],p=[];return d=e(d),f=e(f),i(d.translateX,d.translateY,f.translateX,f.translateY,u,p),a(d.rotate,f.rotate,u,p),l(d.skewX,f.skewX,u,p),c(d.scaleX,d.scaleY,f.scaleX,f.scaleY,u,p),d=f=null,function(m){for(var g=-1,b=p.length,v;++g<b;)u[(v=p[g]).i]=v.x(m);return u.join("")}}}var PF=lP(EF,"px, ","px)","deg)"),AF=lP(_F,", ",")",")"),IF=1e-12;function gS(e){return((e=Math.exp(e))+1/e)/2}function TF(e){return((e=Math.exp(e))-1/e)/2}function RF(e){return((e=Math.exp(2*e))-1)/(e+1)}const Bh=function e(t,n,r){function s(i,a){var l=i[0],c=i[1],d=i[2],f=a[0],u=a[1],p=a[2],m=f-l,g=u-c,b=m*m+g*g,v,y;if(b<IF)y=Math.log(p/d)/t,v=function($){return[l+$*m,c+$*g,d*Math.exp(t*$*y)]};else{var k=Math.sqrt(b),w=(p*p-d*d+r*b)/(2*d*n*k),j=(p*p-d*d-r*b)/(2*p*n*k),A=Math.log(Math.sqrt(w*w+1)-w),C=Math.log(Math.sqrt(j*j+1)-j);y=(C-A)/t,v=function($){var B=$*y,F=gS(A),z=d/(n*k)*(F*RF(t*B+A)-TF(A));return[l+z*m,c+z*g,d*F/gS(t*B+A)]}}return v.duration=y*1e3*t/Math.SQRT2,v}return s.rho=function(i){var a=Math.max(.001,+i),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var Su=0,Rd=0,bd=0,cP=1e3,_m,Ld,Pm=0,nc=0,jg=0,Ef=typeof performance=="object"&&performance.now?performance:Date,uP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function jv(){return nc||(uP(LF),nc=Ef.now()+jg)}function LF(){nc=0}function Am(){this._call=this._time=this._next=null}Am.prototype=dP.prototype={constructor:Am,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?jv():+n)+(t==null?0:+t),!this._next&&Ld!==this&&(Ld?Ld._next=this:_m=this,Ld=this),this._call=e,this._time=n,Dw()},stop:function(){this._call&&(this._call=null,this._time=1/0,Dw())}};function dP(e,t,n){var r=new Am;return r.restart(e,t,n),r}function OF(){jv(),++Su;for(var e=_m,t;e;)(t=nc-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Su}function yS(){nc=(Pm=Ef.now())+jg,Su=Rd=0;try{OF()}finally{Su=0,$F(),nc=0}}function MF(){var e=Ef.now(),t=e-Pm;t>cP&&(jg-=t,Pm=e)}function $F(){for(var e,t=_m,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:_m=n);Ld=e,Dw(r)}function Dw(e){if(!Su){Rd&&(Rd=clearTimeout(Rd));var t=e-nc;t>24?(e<1/0&&(Rd=setTimeout(yS,e-Ef.now()-jg)),bd&&(bd=clearInterval(bd))):(bd||(Pm=Ef.now(),bd=setInterval(MF,cP)),Su=1,uP(yS))}}function xS(e,t,n){var r=new Am;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var DF=Sg("start","end","cancel","interrupt"),FF=[],fP=0,wS=1,Fw=2,Hh=3,bS=4,zw=5,Wh=6;function Cg(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;zF(e,n,{name:t,index:r,group:s,on:DF,tween:FF,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:fP})}function Cv(e,t){var n=Hi(e,t);if(n.state>fP)throw new Error("too late; already scheduled");return n}function So(e,t){var n=Hi(e,t);if(n.state>Hh)throw new Error("too late; already running");return n}function Hi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function zF(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=dP(i,0,n.time);function i(d){n.state=wS,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var f,u,p,m;if(n.state!==wS)return c();for(f in r)if(m=r[f],m.name===n.name){if(m.state===Hh)return xS(a);m.state===bS?(m.state=Wh,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=Wh,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(xS(function(){n.state===Hh&&(n.state=bS,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=Fw,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Fw){for(n.state=Hh,s=new Array(p=n.tween.length),f=0,u=-1;f<p;++f)(m=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++u]=m);s.length=u+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=zw,1),u=-1,p=s.length;++u<p;)s[u].call(e,f);n.state===zw&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wh,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Vh(e,t){var n=e.__transition,r,s,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){i=!1;continue}s=r.state>Fw&&r.state<zw,r.state=Wh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function BF(e){return this.each(function(){Vh(this,e)})}function HF(e,t){var n,r;return function(){var s=So(this,e),i=s.tween;if(i!==n){r=n=i;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 WF(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=So(this,e),a=i.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,d=s.length;c<d;++c)if(s[c].name===t){s[c]=l;break}c===d&&s.push(l)}i.tween=s}}function VF(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Hi(this.node(),n).tween,s=0,i=r.length,a;s<i;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?HF:WF)(n,e,t))}function Ev(e,t,n){var r=e._id;return e.each(function(){var s=So(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Hi(s,r).value[t]}}function pP(e,t){var n;return(typeof t=="number"?ao:t instanceof tc?Em:(n=tc(t))?(t=n,Em):oP)(e,t)}function UF(e){return function(){this.removeAttribute(e)}}function KF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qF(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttribute(e);return a===s?null:a===r?i:i=t(r=a,n)}}function YF(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?i:i=t(r=a,n)}}function GF(e,t,n){var r,s,i;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?i:(s=c,i=t(r=a,l)))}}function XF(e,t,n){var r,s,i;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?i:(s=c,i=t(r=a,l)))}}function JF(e,t){var n=Ng(e),r=n==="transform"?AF:pP;return this.attrTween(e,typeof t=="function"?(n.local?XF:GF)(n,r,Ev(this,"attr."+e,t)):t==null?(n.local?KF:UF)(n):(n.local?YF:qF)(n,r,t))}function QF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ZF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ez(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&ZF(e,i)),n}return s._value=t,s}function tz(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&QF(e,i)),n}return s._value=t,s}function nz(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=Ng(e);return this.tween(n,(r.local?ez:tz)(r,t))}function rz(e,t){return function(){Cv(this,e).delay=+t.apply(this,arguments)}}function sz(e,t){return t=+t,function(){Cv(this,e).delay=t}}function iz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rz:sz)(t,e)):Hi(this.node(),t).delay}function oz(e,t){return function(){So(this,e).duration=+t.apply(this,arguments)}}function az(e,t){return t=+t,function(){So(this,e).duration=t}}function lz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?oz:az)(t,e)):Hi(this.node(),t).duration}function cz(e,t){if(typeof t!="function")throw new Error;return function(){So(this,e).ease=t}}function uz(e){var t=this._id;return arguments.length?this.each(cz(t,e)):Hi(this.node(),t).ease}function dz(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;So(this,e).ease=n}}function fz(e){if(typeof e!="function")throw new Error;return this.each(dz(this._id,e))}function pz(e){typeof e!="function"&&(e=V_(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],c,d=0;d<a;++d)(c=i[d])&&e.call(c,c.__data__,d,i)&&l.push(c);return new ta(r,this._parents,this._name,this._id)}function hz(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),a=new Array(r),l=0;l<i;++l)for(var c=t[l],d=n[l],f=c.length,u=a[l]=new Array(f),p,m=0;m<f;++m)(p=c[m]||d[m])&&(u[m]=p);for(;l<r;++l)a[l]=t[l];return new ta(a,this._parents,this._name,this._id)}function mz(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 gz(e,t,n){var r,s,i=mz(t)?Cv:So;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function yz(e,t){var n=this._id;return arguments.length<2?Hi(this.node(),n).on.on(e):this.each(gz(n,e,t))}function xz(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function wz(){return this.on("end.remove",xz(this._id))}function bz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vv(e));for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a)for(var l=r[a],c=l.length,d=i[a]=new Array(c),f,u,p=0;p<c;++p)(f=l[p])&&(u=e.call(f,f.__data__,p,l))&&("__data__"in f&&(u.__data__=f.__data__),d[p]=u,Cg(d[p],t,n,p,d,Hi(f,n)));return new ta(i,this._parents,t,n)}function vz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=W_(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var c=r[l],d=c.length,f,u=0;u<d;++u)if(f=c[u]){for(var p=e.call(f,f.__data__,u,c),m,g=Hi(f,n),b=0,v=p.length;b<v;++b)(m=p[b])&&Cg(m,t,n,b,p,g);i.push(p),a.push(f)}return new ta(i,a,t,n)}var kz=Qf.prototype.constructor;function Sz(){return new kz(this._groups,this._parents)}function Nz(e,t){var n,r,s;return function(){var i=ku(this,e),a=(this.style.removeProperty(e),ku(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function hP(e){return function(){this.style.removeProperty(e)}}function jz(e,t,n){var r,s=n+"",i;return function(){var a=ku(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function Cz(e,t,n){var r,s,i;return function(){var a=ku(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),ku(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function Ez(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=So(this,e),d=c.on,f=c.value[i]==null?l||(l=hP(t)):void 0;(d!==n||s!==f)&&(r=(n=d).copy()).on(a,s=f),c.on=r}}function _z(e,t,n){var r=(e+="")=="transform"?PF:pP;return t==null?this.styleTween(e,Nz(e,r)).on("end.style."+e,hP(e)):typeof t=="function"?this.styleTween(e,Cz(e,r,Ev(this,"style."+e,t))).each(Ez(this._id,e)):this.styleTween(e,jz(e,r,t),n).on("end.style."+e,null)}function Pz(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Az(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&Pz(e,a,n)),r}return i._value=t,i}function Iz(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,Az(e,t,n??""))}function Tz(e){return function(){this.textContent=e}}function Rz(e){return function(){var t=e(this);this.textContent=t??""}}function Lz(e){return this.tween("text",typeof e=="function"?Rz(Ev(this,"text",e)):Tz(e==null?"":e+""))}function Oz(e){return function(t){this.textContent=e.call(this,t)}}function Mz(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Oz(s)),t}return r._value=e,r}function $z(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,Mz(e))}function Dz(){for(var e=this._name,t=this._id,n=mP(),r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,d=0;d<l;++d)if(c=a[d]){var f=Hi(c,t);Cg(c,e,n,d,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ta(r,this._parents,e,n)}function Fz(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,a){var l={value:a},c={value:function(){--s===0&&i()}};n.each(function(){var d=So(this,r),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&i()})}var zz=0;function ta(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function mP(){return++zz}var Fo=Qf.prototype;ta.prototype={constructor:ta,select:bz,selectAll:vz,selectChild:Fo.selectChild,selectChildren:Fo.selectChildren,filter:pz,merge:hz,selection:Sz,transition:Dz,call:Fo.call,nodes:Fo.nodes,node:Fo.node,size:Fo.size,empty:Fo.empty,each:Fo.each,on:yz,attr:JF,attrTween:nz,style:_z,styleTween:Iz,text:Lz,textTween:$z,remove:wz,tween:VF,delay:iz,duration:lz,ease:uz,easeVarying:fz,end:Fz,[Symbol.iterator]:Fo[Symbol.iterator]};function Bz(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Hz={time:null,delay:0,duration:250,ease:Bz};function Wz(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 Vz(e){var t,n;e instanceof ta?(t=e._id,e=e._name):(t=mP(),(n=Hz).time=jv(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,d=0;d<l;++d)(c=a[d])&&Cg(c,e,t,d,a,n||Wz(c,t));return new ta(r,this._parents,e,t)}Qf.prototype.interrupt=BF;Qf.prototype.transition=Vz;const ah=e=>()=>e;function Uz(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 qo(e,t,n){this.k=e,this.x=t,this.y=n}qo.prototype={constructor:qo,scale:function(e){return e===1?this:new qo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new qo(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 Eg=new qo(1,0,0);gP.prototype=qo.prototype;function gP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Eg;return e.__zoom}function Vy(e){e.stopImmediatePropagation()}function vd(e){e.preventDefault(),e.stopImmediatePropagation()}function Kz(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qz(){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 vS(){return this.__zoom||Eg}function Yz(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Gz(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xz(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=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>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function yP(){var e=Kz,t=qz,n=Xz,r=Yz,s=Gz,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Bh,d=Sg("start","zoom","end"),f,u,p,m=500,g=150,b=0,v=10;function y(M){M.property("__zoom",vS).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,T,E,D){var _=M.selection?M.selection():M;_.property("__zoom",vS),M!==_?A(M,T,E,D):_.interrupt().each(function(){C(this,arguments).event(D).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},y.scaleBy=function(M,T,E,D){y.scaleTo(M,function(){var _=this.__zoom.k,R=typeof T=="function"?T.apply(this,arguments):T;return _*R},E,D)},y.scaleTo=function(M,T,E,D){y.transform(M,function(){var _=t.apply(this,arguments),R=this.__zoom,P=E==null?j(_):typeof E=="function"?E.apply(this,arguments):E,G=R.invert(P),Z=typeof T=="function"?T.apply(this,arguments):T;return n(w(k(R,Z),P,G),_,a)},E,D)},y.translateBy=function(M,T,E,D){y.transform(M,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),a)},null,D)},y.translateTo=function(M,T,E,D,_){y.transform(M,function(){var R=t.apply(this,arguments),P=this.__zoom,G=D==null?j(R):typeof D=="function"?D.apply(this,arguments):D;return n(Eg.translate(G[0],G[1]).scale(P.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof E=="function"?-E.apply(this,arguments):-E),R,a)},D,_)};function k(M,T){return T=Math.max(i[0],Math.min(i[1],T)),T===M.k?M:new qo(T,M.x,M.y)}function w(M,T,E){var D=T[0]-E[0]*M.k,_=T[1]-E[1]*M.k;return D===M.x&&_===M.y?M:new qo(M.k,D,_)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function A(M,T,E,D){M.on("start.zoom",function(){C(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(D).end()}).tween("zoom",function(){var _=this,R=arguments,P=C(_,R).event(D),G=t.apply(_,R),Z=E==null?j(G):typeof E=="function"?E.apply(_,R):E,V=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),se=_.__zoom,ue=typeof T=="function"?T.apply(_,R):T,fe=c(se.invert(Z).concat(V/se.k),ue.invert(Z).concat(V/ue.k));return function(ge){if(ge===1)ge=ue;else{var ae=fe(ge),ve=V/ae[2];ge=new qo(ve,Z[0]-ae[0]*ve,Z[1]-ae[1]*ve)}P.zoom(null,ge)}})}function C(M,T,E){return!E&&M.__zooming||new $(M,T)}function $(M,T){this.that=M,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,T),this.taps=0}$.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,T){return this.mouse&&M!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var T=Ds(this.that).datum();d.call(M,this.that,new Uz(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),T)}};function B(M,...T){if(!e.apply(this,arguments))return;var E=C(this,T).event(M),D=this.__zoom,_=Math.max(i[0],Math.min(i[1],D.k*Math.pow(2,r.apply(this,arguments)))),R=Ii(M);if(E.wheel)(E.mouse[0][0]!==R[0]||E.mouse[0][1]!==R[1])&&(E.mouse[1]=D.invert(E.mouse[0]=R)),clearTimeout(E.wheel);else{if(D.k===_)return;E.mouse=[R,D.invert(R)],Vh(this),E.start()}vd(M),E.wheel=setTimeout(P,g),E.zoom("mouse",n(w(k(D,_),E.mouse[0],E.mouse[1]),E.extent,a));function P(){E.wheel=null,E.end()}}function F(M,...T){if(p||!e.apply(this,arguments))return;var E=M.currentTarget,D=C(this,T,!0).event(M),_=Ds(M.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",V,!0),R=Ii(M,E),P=M.clientX,G=M.clientY;eP(M.view),Vy(M),D.mouse=[R,this.__zoom.invert(R)],Vh(this),D.start();function Z(se){if(vd(se),!D.moved){var ue=se.clientX-P,fe=se.clientY-G;D.moved=ue*ue+fe*fe>b}D.event(se).zoom("mouse",n(w(D.that.__zoom,D.mouse[0]=Ii(se,E),D.mouse[1]),D.extent,a))}function V(se){_.on("mousemove.zoom mouseup.zoom",null),tP(se.view,D.moved),vd(se),D.event(se).end()}}function z(M,...T){if(e.apply(this,arguments)){var E=this.__zoom,D=Ii(M.changedTouches?M.changedTouches[0]:M,this),_=E.invert(D),R=E.k*(M.shiftKey?.5:2),P=n(w(k(E,R),D,_),t.apply(this,T),a);vd(M),l>0?Ds(this).transition().duration(l).call(A,P,D,M):Ds(this).call(y.transform,P,D,M)}}function L(M,...T){if(e.apply(this,arguments)){var E=M.touches,D=E.length,_=C(this,T,M.changedTouches.length===D).event(M),R,P,G,Z;for(Vy(M),P=0;P<D;++P)G=E[P],Z=Ii(G,this),Z=[Z,this.__zoom.invert(Z),G.identifier],_.touch0?!_.touch1&&_.touch0[2]!==Z[2]&&(_.touch1=Z,_.taps=0):(_.touch0=Z,R=!0,_.taps=1+!!f);f&&(f=clearTimeout(f)),R&&(_.taps<2&&(u=Z[0],f=setTimeout(function(){f=null},m)),Vh(this),_.start())}}function O(M,...T){if(this.__zooming){var E=C(this,T).event(M),D=M.changedTouches,_=D.length,R,P,G,Z;for(vd(M),R=0;R<_;++R)P=D[R],G=Ii(P,this),E.touch0&&E.touch0[2]===P.identifier?E.touch0[0]=G:E.touch1&&E.touch1[2]===P.identifier&&(E.touch1[0]=G);if(P=E.that.__zoom,E.touch1){var V=E.touch0[0],se=E.touch0[1],ue=E.touch1[0],fe=E.touch1[1],ge=(ge=ue[0]-V[0])*ge+(ge=ue[1]-V[1])*ge,ae=(ae=fe[0]-se[0])*ae+(ae=fe[1]-se[1])*ae;P=k(P,Math.sqrt(ge/ae)),G=[(V[0]+ue[0])/2,(V[1]+ue[1])/2],Z=[(se[0]+fe[0])/2,(se[1]+fe[1])/2]}else if(E.touch0)G=E.touch0[0],Z=E.touch0[1];else return;E.zoom("touch",n(w(P,G,Z),E.extent,a))}}function W(M,...T){if(this.__zooming){var E=C(this,T).event(M),D=M.changedTouches,_=D.length,R,P;for(Vy(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),R=0;R<_;++R)P=D[R],E.touch0&&E.touch0[2]===P.identifier?delete E.touch0:E.touch1&&E.touch1[2]===P.identifier&&delete E.touch1;if(E.touch1&&!E.touch0&&(E.touch0=E.touch1,delete E.touch1),E.touch0)E.touch0[1]=this.__zoom.invert(E.touch0[0]);else if(E.end(),E.taps===2&&(P=Ii(P,this),Math.hypot(u[0]-P[0],u[1]-P[1])<v)){var G=Ds(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:ah(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:ah(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:ah(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:ah([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),y):t},y.scaleExtent=function(M){return arguments.length?(i[0]=+M[0],i[1]=+M[1],y):[i[0],i[1]]},y.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],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(M){return arguments.length?(n=M,y):n},y.duration=function(M){return arguments.length?(l=+M,y):l},y.interpolate=function(M){return arguments.length?(c=M,y):c},y.on=function(){var M=d.on.apply(d,arguments);return M===d?y:M},y.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,y):Math.sqrt(b)},y.tapDistance=function(M){return arguments.length?(v=+M,y):v},y}const bo={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."},_f=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xP=["Enter"," ","Escape"],wP={"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 Nu;(function(e){e.Strict="strict",e.Loose="loose"})(Nu||(Nu={}));var Kl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Kl||(Kl={}));var Pf;(function(e){e.Partial="partial",e.Full="full"})(Pf||(Pf={}));const bP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var La;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(La||(La={}));var Ns;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ns||(Ns={}));var qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(qe||(qe={}));const kS={[qe.Left]:qe.Right,[qe.Right]:qe.Left,[qe.Top]:qe.Bottom,[qe.Bottom]:qe.Top};function vP(e){return e===null?null:e?"valid":"invalid"}const kP=e=>"id"in e&&"source"in e&&"target"in e,Jz=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),_v=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ep=(e,t=[0,0])=>{const{width:n,height:r}=ia(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},Qz=(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 i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):_v(s)?s:t.nodeLookup.get(s.id));const l=a?Im(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return _g(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Pg(n)},tp=(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=_g(n,Im(s)),r=!0)}),r?Pg(n):{x:0,y:0,width:0,height:0}},Pv=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...rp(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:f,selectable:u=!0,hidden:p=!1}=d;if(a&&!u||p)continue;const m=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=Af(l,Cu(d)),v=(m??0)*(g??0),y=i&&b>0;(!d.internals.handleBounds||y||b>=v||d.dragging)&&c.push(d)}return c},Zz=(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 e3(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 t3({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=e3(e,a),c=tp(l),d=Av(c,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(d,{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 SP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},f=a.origin??r;let u=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",bo.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(u=[[c,d],[c+m,d+g]])}else l&&Eu(a.extent)&&(u=[[a.extent[0][0]+c,a.extent[0][1]+d],[a.extent[1][0]+c,a.extent[1][1]+d]]);const p=Eu(u)?rc(t,u,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",bo.error015())),{position:{x:p.x-c+(a.measured.width??0)*f[0],y:p.y-d+(a.measured.height??0)*f[1]},positionAbsolute:p}}async function n3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const m=i.has(p.id),g=!m&&p.parentId&&a.find(b=>b.id===p.parentId);(m||g)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),f=Zz(a,c);for(const p of c)l.has(p.id)&&!f.find(g=>g.id===p.id)&&f.push(p);if(!s)return{edges:f,nodes:a};const u=await s({nodes:a,edges:f});return typeof u=="boolean"?u?{edges:f,nodes:a}:{edges:[],nodes:[]}:u}const ju=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),rc=(e={x:0,y:0},t,n)=>({x:ju(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:ju(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function NP(e,t,n){const{width:r,height:s}=ia(n),{x:i,y:a}=n.internals.positionAbsolute;return rc(e,[[i,a],[i+r,a+s]],t)}const SS=(e,t,n)=>e<t?ju(Math.abs(e-t),1,t)/t:e>n?-ju(Math.abs(e-n),1,t)/t:0,jP=(e,t,n=15,r=40)=>{const s=SS(e.x,r,t.width-r)*n,i=SS(e.y,r,t.height-r)*n;return[s,i]},_g=(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)}),Bw=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Pg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Cu=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=_v(e)?e.internals.positionAbsolute:ep(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Im=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=_v(e)?e.internals.positionAbsolute:ep(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},CP=(e,t)=>Pg(_g(Bw(e),Bw(t))),Af=(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)},NS=e=>Oi(e.width)&&Oi(e.height)&&Oi(e.x)&&Oi(e.y),Oi=e=>!isNaN(e)&&isFinite(e),r3=(e,t)=>{},np=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),rp=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?np(l,a):l},Tm=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Ic(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 s3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ic(e,n),s=Ic(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Ic(e.top??e.y??0,n),s=Ic(e.bottom??e.y??0,n),i=Ic(e.left??e.x??0,t),a=Ic(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:i,x:i+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function i3(e,t,n,r,s,i){const{x:a,y:l}=Tm(e,[t,n,r]),{x:c,y:d}=Tm({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=s-c,u=i-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(u)}}const Av=(e,t,n,r,s,i)=>{const a=s3(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,d=Math.min(l,c),f=ju(d,r,s),u=e.x+e.width/2,p=e.y+e.height/2,m=t/2-u*f,g=n/2-p*f,b=i3(e,m,g,f,t,n),v={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:m-v.left+v.right,y:g-v.top+v.bottom,zoom:f}},If=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Eu(e){return e!=null&&e!=="parent"}function ia(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 EP(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 _P(e,t={width:0,height:0},n,r,s){const i={...e},a=r.get(n);if(a){const l=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function jS(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function o3(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function a3(e){return{...wP,...e||{}}}function Qd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Mi(e),l=rp({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:d}=n?np(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const Iv=e=>({width:e.offsetWidth,height:e.offsetHeight}),PP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},l3=["INPUT","SELECT","TEXTAREA"];function AP(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:l3.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const IP=e=>"clientX"in e,Mi=(e,t)=>{var i,a;const n=IP(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[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)}},CS=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).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,...Iv(a)}})};function TP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:l}){const c=e*.125+s*.375+a*.375+n*.125,d=t*.125+i*.375+l*.375+r*.125,f=Math.abs(c-e),u=Math.abs(d-t);return[c,d,f,u]}function lh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ES({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case qe.Left:return[t-lh(t-r,i),n];case qe.Right:return[t+lh(r-t,i),n];case qe.Top:return[t,n-lh(n-s,i)];case qe.Bottom:return[t,n+lh(s-n,i)]}}function RP({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:i=qe.Top,curvature:a=.25}){const[l,c]=ES({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,f]=ES({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[u,p,m,g]=TP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${c} ${d},${f} ${r},${s}`,u,p,m,g]}function LP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[i,l,s,a]}function c3({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:i="basic"}){if(i==="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 u3({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=_g(Im(e),Im(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Af(a,Pg(i))>0}const d3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,f3=(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)),Tf=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||d3;let s;return kP(e)?s={...e}:s={...e,id:r(e)},f3(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function OP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=LP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const _S={[qe.Left]:{x:-1,y:0},[qe.Right]:{x:1,y:0},[qe.Top]:{x:0,y:-1},[qe.Bottom]:{x:0,y:1}},p3=({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},PS=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function h3({source:e,sourcePosition:t=qe.Bottom,target:n,targetPosition:r=qe.Top,center:s,offset:i,stepPosition:a}){const l=_S[t],c=_S[r],d={x:e.x+l.x*i,y:e.y+l.y*i},f={x:n.x+c.x*i,y:n.y+c.y*i},u=p3({source:d,sourcePosition:t,target:f}),p=u.x!==0?"x":"y",m=u[p];let g=[],b,v;const y={x:0,y:0},k={x:0,y:0},[,,w,j]=LP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(b=s.x??d.x+(f.x-d.x)*a,v=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,v=s.y??d.y+(f.y-d.y)*a);const B=[{x:b,y:d.y},{x:b,y:f.y}],F=[{x:d.x,y:v},{x:f.x,y:v}];l[p]===m?g=p==="x"?B:F:g=p==="x"?F:B}else{const B=[{x:d.x,y:f.y}],F=[{x:f.x,y:d.y}];if(p==="x"?g=l.x===m?F:B:g=l.y===m?B:F,t===r){const M=Math.abs(e[p]-n[p]);if(M<=i){const T=Math.min(i-1,i-M);l[p]===m?y[p]=(d[p]>e[p]?-1:1)*T:k[p]=(f[p]>n[p]?-1:1)*T}}if(t!==r){const M=p==="x"?"y":"x",T=l[p]===c[M],E=d[M]>f[M],D=d[M]<f[M];(l[p]===1&&(!T&&E||T&&D)||l[p]!==1&&(!T&&D||T&&E))&&(g=p==="x"?B:F)}const z={x:d.x+y.x,y:d.y+y.y},L={x:f.x+k.x,y:f.y+k.y},O=Math.max(Math.abs(z.x-g[0].x),Math.abs(L.x-g[0].x)),W=Math.max(Math.abs(z.y-g[0].y),Math.abs(L.y-g[0].y));O>=W?(b=(z.x+L.x)/2,v=g[0].y):(b=g[0].x,v=(z.y+L.y)/2)}const A={x:d.x+y.x,y:d.y+y.y},C={x:f.x+k.x,y:f.y+k.y};return[[e,...A.x!==g[0].x||A.y!==g[0].y?[A]:[],...g,...C.x!==g[g.length-1].x||C.y!==g[g.length-1].y?[C]:[],n],b,v,w,j]}function m3(e,t,n,r){const s=Math.min(PS(e,t)/2,PS(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+s*d},${a}Q ${i},${a} ${i},${a+s*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${a+s*c}Q ${i},${a} ${i+s*l},${a}`}function Hw({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:i=qe.Top,borderRadius:a=5,centerX:l,centerY:c,offset:d=20,stepPosition:f=.5}){const[u,p,m,g,b]=h3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:c},offset:d,stepPosition:f});let v=`M${u[0].x} ${u[0].y}`;for(let y=1;y<u.length-1;y++)v+=m3(u[y-1],u[y],u[y+1],a);return v+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[v,p,m,g,b]}function AS(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function g3(e){var u;const{sourceNode:t,targetNode:n}=e;if(!AS(t)||!AS(n))return null;const r=t.internals.handleBounds||IS(t.handles),s=n.internals.handleBounds||IS(n.handles),i=TS((r==null?void 0:r.source)??[],e.sourceHandle),a=TS(e.connectionMode===Nu.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!a)return(u=e.onError)==null||u.call(e,"008",bo.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||qe.Bottom,c=(a==null?void 0:a.position)||qe.Top,d=sc(t,i,l),f=sc(n,a,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function IS(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 sc(e,t,n=qe.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??ia(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case qe.Top:return{x:s+a/2,y:i};case qe.Right:return{x:s+a,y:i+l/2};case qe.Bottom:return{x:s+a/2,y:i+l};case qe.Left:return{x:s,y:i+l/2}}}function TS(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ww(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function y3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const d=Ww(c,t);i.has(d)||(a.push({id:d,color:c.color||n,...c}),i.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const MP=1e3,x3=10,Tv={nodeOrigin:[0,0],nodeExtent:_f,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},w3={...Tv,checkEquality:!0};function Rv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function b3(e,t,n){const r=Rv(Tv,n);for(const s of e.values())if(s.parentId)Ov(s,e,t,r);else{const i=ep(s,r.nodeOrigin),a=Eu(s.extent)?s.extent:r.nodeExtent,l=rc(i,a,ia(s));s.internals.positionAbsolute=l}}function v3(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 i={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(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function Lv(e){return e==="manual"}function Vw(e,t,n,r={}){var f,u;const s=Rv(w3,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Lv(s.zIndexMode)?MP:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const p of e){let m=a.get(p.id);if(s.checkEquality&&p===(m==null?void 0:m.internals.userNode))t.set(p.id,m);else{const g=ep(p,s.nodeOrigin),b=Eu(p.extent)?p.extent:s.nodeExtent,v=rc(g,b,ia(p));m={...s.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(u=p.measured)==null?void 0:u.height},internals:{positionAbsolute:v,handleBounds:v3(p,m),z:$P(p,l,s.zIndexMode),userNode:p}},t.set(p.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),p.parentId&&Ov(m,t,n,r,i),d||(d=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:d}}function k3(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 Ov(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Rv(Tv,r),d=e.parentId,f=t.get(d);if(!f){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}k3(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*x3),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const u=i&&!Lv(c)?MP:0,{x:p,y:m,z:g}=S3(e,f,a,l,u,c),{positionAbsolute:b}=e.internals,v=p!==b.x||m!==b.y;(v||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:p,y:m}:b,z:g}})}function $P(e,t,n){const r=Oi(e.zIndex)?e.zIndex:0;return Lv(n)?r:r+(e.selected?t:0)}function S3(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=ia(e),d=ep(e,n),f=Eu(e.extent)?rc(d,e.extent,c):d;let u=rc({x:a+f.x,y:l+f.y},r,c);e.extent==="parent"&&(u=NP(u,c,t));const p=$P(e,s,i),m=t.internals.z??0;return{x:u.x,y:u.y,z:m>=p?m+1:p}}function Mv(e,t,n,r=[0,0]){var a;const s=[],i=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const d=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??Cu(c),f=CP(d,l.rect);i.set(l.parentId,{expandedRect:f,parent:c})}return i.size>0&&i.forEach(({expandedRect:l,parent:c},d)=>{var w;const f=c.internals.positionAbsolute,u=ia(c),p=c.origin??r,m=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,g=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,b=Math.max(u.width,Math.round(l.width)),v=Math.max(u.height,Math.round(l.height)),y=(b-u.width)*p[0],k=(v-u.height)*p[1];(m>0||g>0||y||k)&&(s.push({id:d,type:"position",position:{x:c.position.x-m+y,y:c.position.y-g+k}}),(w=n.get(d))==null||w.forEach(j=>{e.some(A=>A.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+m,y:j.position.y+g}})})),(u.width<l.width||u.height<l.height||m||g)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:b+(m?p[0]*m-y:0),height:v+(g?p[1]*g-k:0)}})}),s}function N3(e,t,n,r,s,i,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const d=[],f=window.getComputedStyle(l),{m22:u}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const m of e.values()){const g=t.get(m.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=Iv(m.nodeElement),v=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(v||!g.internals.handleBounds||m.force))){const k=m.nodeElement.getBoundingClientRect(),w=Eu(g.extent)?g.extent:i;let{positionAbsolute:j}=g.internals;g.parentId&&g.extent==="parent"?j=NP(j,b,t.get(g.parentId)):w&&(j=rc(j,w,b));const A={...g,measured:b,internals:{...g.internals,positionAbsolute:j,handleBounds:{source:CS("source",m.nodeElement,k,u,g.id),target:CS("target",m.nodeElement,k,u,g.id)}}};t.set(g.id,A),g.parentId&&Ov(A,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,v&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&p.push({id:g.id,parentId:g.parentId,rect:Cu(A,s)}))}}if(p.length>0){const m=Mv(p,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function j3({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){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,i]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function RS(e,t,n,r,s,i){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)),i){a=`${s}-${e}-${i}`;const d=r.get(a)||new Map;r.set(a,d.set(n,t))}}function DP(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:s,target:i,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${i}-${l}`,f=`${i}-${l}--${s}-${a}`;RS("source",c,f,e,s,a),RS("target",c,d,e,i,l),t.set(r.id,r)}}function FP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:FP(n,t):!1}function LS(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 C3(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!FP(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&s.set(i,{id:i,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 Uy({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[d,f]of t){const u=(a=n.get(d))==null?void 0:a.internals.userNode;u&&s.push({...u,position:f.position,dragging:r})}if(!e)return[s[0],s];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:s[0],s]}function E3({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},a=np(i,t);return{x:a.x-i.x,y:a.y-i.y}}function _3({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,c=!1,d={x:0,y:0},f=null,u=!1,p=null,m=!1,g=!1,b=null;function v({noDragClassName:k,handleSelector:w,domNode:j,isSelectable:A,nodeId:C,nodeClickDistance:$=0}){p=Ds(j);function B({x:O,y:W}){const{nodeLookup:M,nodeExtent:T,snapGrid:E,snapToGrid:D,nodeOrigin:_,onNodeDrag:R,onSelectionDrag:P,onError:G,updateNodePositions:Z}=t();i={x:O,y:W};let V=!1;const se=l.size>1,ue=se&&T?Bw(tp(l)):null,fe=se&&D?E3({dragItems:l,snapGrid:E,x:O,y:W}):null;for(const[ge,ae]of l){if(!M.has(ge))continue;let ve={x:O-ae.distance.x,y:W-ae.distance.y};D&&(ve=fe?{x:Math.round(ve.x+fe.x),y:Math.round(ve.y+fe.y)}:np(ve,E));let _e=null;if(se&&T&&!ae.extent&&ue){const{positionAbsolute:Ae}=ae.internals,st=Ae.x-ue.x+T[0][0],ut=Ae.x+ae.measured.width-ue.x2+T[1][0],et=Ae.y-ue.y+T[0][1],Ct=Ae.y+ae.measured.height-ue.y2+T[1][1];_e=[[st,et],[ut,Ct]]}const{position:we,positionAbsolute:Ee}=SP({nodeId:ge,nextPosition:ve,nodeLookup:M,nodeExtent:_e||T,nodeOrigin:_,onError:G});V=V||ae.position.x!==we.x||ae.position.y!==we.y,ae.position=we,ae.internals.positionAbsolute=Ee}if(g=g||V,!!V&&(Z(l,!0),b&&(r||R||!C&&P))){const[ge,ae]=Uy({nodeId:C,dragItems:l,nodeLookup:M});r==null||r(b,l,ge,ae),R==null||R(b,ge,ae),C||P==null||P(b,ae)}}async function F(){if(!f)return;const{transform:O,panBy:W,autoPanSpeed:M,autoPanOnNodeDrag:T}=t();if(!T){c=!1,cancelAnimationFrame(a);return}const[E,D]=jP(d,f,M);(E!==0||D!==0)&&(i.x=(i.x??0)-E/O[2],i.y=(i.y??0)-D/O[2],await W({x:E,y:D})&&B(i)),a=requestAnimationFrame(F)}function z(O){var se;const{nodeLookup:W,multiSelectionActive:M,nodesDraggable:T,transform:E,snapGrid:D,snapToGrid:_,selectNodesOnDrag:R,onNodeDragStart:P,onSelectionDragStart:G,unselectNodesAndEdges:Z}=t();u=!0,(!R||!A)&&!M&&C&&((se=W.get(C))!=null&&se.selected||Z()),A&&R&&C&&(e==null||e(C));const V=Qd(O.sourceEvent,{transform:E,snapGrid:D,snapToGrid:_,containerBounds:f});if(i=V,l=C3(W,T,V,C),l.size>0&&(n||P||!C&&G)){const[ue,fe]=Uy({nodeId:C,dragItems:l,nodeLookup:W});n==null||n(O.sourceEvent,l,ue,fe),P==null||P(O.sourceEvent,ue,fe),C||G==null||G(O.sourceEvent,fe)}}const L=nP().clickDistance($).on("start",O=>{const{domNode:W,nodeDragThreshold:M,transform:T,snapGrid:E,snapToGrid:D}=t();f=(W==null?void 0:W.getBoundingClientRect())||null,m=!1,g=!1,b=O.sourceEvent,M===0&&z(O),i=Qd(O.sourceEvent,{transform:T,snapGrid:E,snapToGrid:D,containerBounds:f}),d=Mi(O.sourceEvent,f)}).on("drag",O=>{const{autoPanOnNodeDrag:W,transform:M,snapGrid:T,snapToGrid:E,nodeDragThreshold:D,nodeLookup:_}=t(),R=Qd(O.sourceEvent,{transform:M,snapGrid:T,snapToGrid:E,containerBounds:f});if(b=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||C&&!_.has(C))&&(m=!0),!m){if(!c&&W&&u&&(c=!0,F()),!u){const P=Mi(O.sourceEvent,f),G=P.x-d.x,Z=P.y-d.y;Math.sqrt(G*G+Z*Z)>D&&z(O)}(i.x!==R.xSnapped||i.y!==R.ySnapped)&&l&&u&&(d=Mi(O.sourceEvent,f),B(R))}}).on("end",O=>{if(!(!u||m)&&(c=!1,u=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:W,updateNodePositions:M,onNodeDragStop:T,onSelectionDragStop:E}=t();if(g&&(M(l,!1),g=!1),s||T||!C&&E){const[D,_]=Uy({nodeId:C,dragItems:l,nodeLookup:W,dragging:!1});s==null||s(O.sourceEvent,l,D,_),T==null||T(O.sourceEvent,D,_),C||E==null||E(O.sourceEvent,_)}}}).filter(O=>{const W=O.target;return!O.button&&(!k||!LS(W,`.${k}`,j))&&(!w||LS(W,w,j))});p.call(L)}function y(){p==null||p.on(".drag",null)}return{update:v,destroy:y}}function P3(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Af(s,Cu(i))>0&&r.push(i);return r}const A3=250;function I3(e,t,n,r){var l,c;let s=[],i=1/0;const a=P3(e,n,t+A3);for(const d of a){const f=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((c=d.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of f){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:p,y:m}=sc(d,u,u.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(m-e.y,2));g>t||(g<i?(s=[{...u,x:p,y:m}],i=g):g===i&&s.push({...u,x:p,y:m}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(f=>f.type===d)??s[0]}return s[0]}function zP(e,t,n,r,s,i=!1){var d,f,u;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((f=a.internals.handleBounds)==null?void 0:f.source)??[],...((u=a.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&i?{...c,...sc(a,c,c.position,!0)}:c}function BP(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function T3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const HP=()=>!0;function R3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:f,flowId:u,panBy:p,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:v,isValidConnection:y=HP,onReconnectEnd:k,updateConnection:w,getTransform:j,getFromHandle:A,autoPanSpeed:C,dragThreshold:$=1,handleDomNode:B}){const F=PP(e.target);let z=0,L;const{x:O,y:W}=Mi(e),M=BP(i,B),T=l==null?void 0:l.getBoundingClientRect();let E=!1;if(!T||!M)return;const D=zP(s,M,r,c,t);if(!D)return;let _=Mi(e,T),R=!1,P=null,G=!1,Z=null;function V(){if(!f||!T)return;const[we,Ee]=jP(_,T,C);p({x:we,y:Ee}),z=requestAnimationFrame(V)}const se={...D,nodeId:s,type:M,position:D.position},ue=c.get(s);let ge={inProgress:!0,isValid:null,from:sc(ue,se,qe.Left,!0),fromHandle:se,fromPosition:se.position,fromNode:ue,to:_,toHandle:null,toPosition:kS[se.position],toNode:null,pointer:_};function ae(){E=!0,w(ge),g==null||g(e,{nodeId:s,handleId:r,handleType:M})}$===0&&ae();function ve(we){if(!E){const{x:Ct,y:Ue}=Mi(we),St=Ct-O,nn=Ue-W;if(!(St*St+nn*nn>$*$))return;ae()}if(!A()||!se){_e(we);return}const Ee=j();_=Mi(we,T),L=I3(rp(_,Ee,!1,[1,1]),n,c,se),R||(V(),R=!0);const Ae=WP(we,{handle:L,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:F,lib:d,flowId:u,nodeLookup:c});Z=Ae.handleDomNode,P=Ae.connection,G=T3(!!L,Ae.isValid);const st=c.get(s),ut=st?sc(st,se,qe.Left,!0):ge.from,et={...ge,from:ut,isValid:G,to:Ae.toHandle&&G?Tm({x:Ae.toHandle.x,y:Ae.toHandle.y},Ee):_,toHandle:Ae.toHandle,toPosition:G&&Ae.toHandle?Ae.toHandle.position:kS[se.position],toNode:Ae.toHandle?c.get(Ae.toHandle.nodeId):null,pointer:_};w(et),ge=et}function _e(we){if(!("touches"in we&&we.touches.length>0)){if(E){(L||Z)&&P&&G&&(b==null||b(P));const{inProgress:Ee,...Ae}=ge,st={...Ae,toPosition:ge.toHandle?ge.toPosition:null};v==null||v(we,st),i&&(k==null||k(we,st))}m(),cancelAnimationFrame(z),R=!1,G=!1,P=null,Z=null,F.removeEventListener("mousemove",ve),F.removeEventListener("mouseup",_e),F.removeEventListener("touchmove",ve),F.removeEventListener("touchend",_e)}}F.addEventListener("mousemove",ve),F.addEventListener("mouseup",_e),F.addEventListener("touchmove",ve),F.addEventListener("touchend",_e)}function WP(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:d=HP,nodeLookup:f}){const u=i==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:g}=Mi(e),b=a.elementFromPoint(m,g),v=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:p,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const k=BP(void 0,v),w=v.getAttribute("data-nodeid"),j=v.getAttribute("data-handleid"),A=v.classList.contains("connectable"),C=v.classList.contains("connectableend");if(!w||!k)return y;const $={source:u?w:r,sourceHandle:u?j:s,target:u?r:w,targetHandle:u?s:j};y.connection=$;const F=A&&C&&(n===Nu.Strict?u&&k==="source"||!u&&k==="target":w!==r||j!==s);y.isValid=F&&d($),y.toHandle=zP(w,k,j,f,n,!0)}return y}const Uw={onPointerDown:R3,isValid:WP};function L3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Ds(e);function i({translateExtent:l,width:c,height:d,zoomStep:f=1,pannable:u=!0,zoomable:p=!0,inversePan:m=!1}){const g=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const j=n(),A=w.sourceEvent.ctrlKey&&If()?10:1,C=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*f,$=j[2]*Math.pow(2,C*A);t.scaleTo($)};let b=[0,0];const v=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},y=w=>{const j=n();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!t)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],C=[A[0]-b[0],A[1]-b[1]];b=A;const $=r()*Math.max(j[2],Math.log(j[2]))*(m?-1:1),B={x:j[0]-C[0]*$,y:j[1]-C[1]*$},F=[[0,0],[c,d]];t.setViewportConstrained({x:B.x,y:B.y,zoom:j[2]},F,l)},k=yP().on("start",v).on("zoom",u?y:null).on("zoom.wheel",p?g:null);s.call(k,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:Ii}}const Ag=e=>({x:e.x,y:e.y,zoom:e.k}),Ky=({x:e,y:t,zoom:n})=>Eg.translate(e,t).scale(n),Qc=(e,t)=>e.target.closest(`.${t}`),VP=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),O3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,qy=(e,t=0,n=O3,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},UP=e=>{const t=e.ctrlKey&&If()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function M3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(Qc(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(f.ctrlKey&&a){const v=Ii(f),y=UP(f),k=u*Math.pow(2,y);r.scaleTo(n,k,v,f);return}const p=f.deltaMode===1?20:1;let m=s===Kl.Vertical?0:f.deltaX*p,g=s===Kl.Horizontal?0:f.deltaY*p;!If()&&f.shiftKey&&s!==Kl.Vertical&&(m=f.deltaY*p,g=0),r.translateBy(n,-(m/u)*i,-(g/u)*i,{internal:!0});const b=Ag(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,b),e.panScrollTimeout=setTimeout(()=>{d==null||d(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,b))}}function $3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=Qc(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function D3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Ag(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 F3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&VP(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((l=i.sourceEvent)!=null&&l.internal)&&(s==null||s(i.sourceEvent,Ag(i.transform)))}}function z3({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&VP(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Ag(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function B3({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:f}){return u=>{var v;const p=e||t,m=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(Qc(u,`${d}-flow__node`)||Qc(u,`${d}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||f&&!g||Qc(u,l)&&g||Qc(u,c)&&(!g||s&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&((v=u.touches)==null?void 0:v.length)>1)return u.preventDefault(),!1;if(!p&&!s&&!m&&g||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&b}}function H3({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),u=yP().scaleExtent([t,n]).translateExtent(r),p=Ds(e).call(u);k({x:s.x,y:s.y,zoom:ju(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=p.on("wheel.zoom"),g=p.on("dblclick.zoom");u.wheelDelta(UP);function b(L,O){return p?new Promise(W=>{u==null||u.interpolate((O==null?void 0:O.interpolate)==="linear"?Jd:Bh).transform(qy(p,O==null?void 0:O.duration,O==null?void 0:O.ease,()=>W(!0)),L)}):Promise.resolve(!1)}function v({noWheelClassName:L,noPanClassName:O,onPaneContextMenu:W,userSelectionActive:M,panOnScroll:T,panOnDrag:E,panOnScrollMode:D,panOnScrollSpeed:_,preventScrolling:R,zoomOnPinch:P,zoomOnScroll:G,zoomOnDoubleClick:Z,zoomActivationKeyPressed:V,lib:se,onTransformChange:ue,connectionInProgress:fe,paneClickDistance:ge,selectionOnDrag:ae}){M&&!d.isZoomingOrPanning&&y();const ve=T&&!V&&!M;u.clickDistance(ae?1/0:!Oi(ge)||ge<0?0:ge);const _e=ve?M3({zoomPanValues:d,noWheelClassName:L,d3Selection:p,d3Zoom:u,panOnScrollMode:D,panOnScrollSpeed:_,zoomOnPinch:P,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):$3({noWheelClassName:L,preventScrolling:R,d3ZoomHandler:m});if(p.on("wheel.zoom",_e,{passive:!1}),!M){const Ee=D3({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:a});u.on("start",Ee);const Ae=F3({zoomPanValues:d,panOnDrag:E,onPaneContextMenu:!!W,onPanZoom:i,onTransformChange:ue});u.on("zoom",Ae);const st=z3({zoomPanValues:d,panOnDrag:E,panOnScroll:T,onPaneContextMenu:W,onPanZoomEnd:l,onDraggingChange:c});u.on("end",st)}const we=B3({zoomActivationKeyPressed:V,panOnDrag:E,zoomOnScroll:G,panOnScroll:T,zoomOnDoubleClick:Z,zoomOnPinch:P,userSelectionActive:M,noPanClassName:O,noWheelClassName:L,lib:se,connectionInProgress:fe});u.filter(we),Z?p.on("dblclick.zoom",g):p.on("dblclick.zoom",null)}function y(){u.on("zoom",null)}async function k(L,O,W){const M=Ky(L),T=u==null?void 0:u.constrain()(M,O,W);return T&&await b(T),new Promise(E=>E(T))}async function w(L,O){const W=Ky(L);return await b(W,O),new Promise(M=>M(W))}function j(L){if(p){const O=Ky(L),W=p.property("__zoom");(W.k!==L.zoom||W.x!==L.x||W.y!==L.y)&&(u==null||u.transform(p,O,null,{sync:!0}))}}function A(){const L=p?gP(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function C(L,O){return p?new Promise(W=>{u==null||u.interpolate((O==null?void 0:O.interpolate)==="linear"?Jd:Bh).scaleTo(qy(p,O==null?void 0:O.duration,O==null?void 0:O.ease,()=>W(!0)),L)}):Promise.resolve(!1)}function $(L,O){return p?new Promise(W=>{u==null||u.interpolate((O==null?void 0:O.interpolate)==="linear"?Jd:Bh).scaleBy(qy(p,O==null?void 0:O.duration,O==null?void 0:O.ease,()=>W(!0)),L)}):Promise.resolve(!1)}function B(L){u==null||u.scaleExtent(L)}function F(L){u==null||u.translateExtent(L)}function z(L){const O=!Oi(L)||L<0?0:L;u==null||u.clickDistance(O)}return{update:v,destroy:y,setViewport:w,setViewportConstrained:k,getViewport:A,scaleTo:C,scaleBy:$,setScaleExtent:B,setTranslateExtent:F,syncViewport:j,setClickDistance:z}}var _u;(function(e){e.Line="line",e.Handle="handle"})(_u||(_u={}));function W3({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){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&&i&&(c[1]=c[1]*-1),c}function OS(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 Na(e,t){return Math.max(0,t-e)}function ja(e,t){return Math.max(0,e-t)}function ch(e,t,n){return Math.max(0,t-e,e-n)}function MS(e,t){return e?!t:t}function V3(e,t,n,r,s,i,a,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:f,isVertical:u}=t,p=f&&u,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:v,minHeight:y,maxHeight:k}=r,{x:w,y:j,width:A,height:C,aspectRatio:$}=e;let B=Math.floor(f?m-e.pointerX:0),F=Math.floor(u?g-e.pointerY:0);const z=A+(c?-B:B),L=C+(d?-F:F),O=-i[0]*A,W=-i[1]*C;let M=ch(z,b,v),T=ch(L,y,k);if(a){let _=0,R=0;c&&B<0?_=Na(w+B+O,a[0][0]):!c&&B>0&&(_=ja(w+z+O,a[1][0])),d&&F<0?R=Na(j+F+W,a[0][1]):!d&&F>0&&(R=ja(j+L+W,a[1][1])),M=Math.max(M,_),T=Math.max(T,R)}if(l){let _=0,R=0;c&&B>0?_=ja(w+B,l[0][0]):!c&&B<0&&(_=Na(w+z,l[1][0])),d&&F>0?R=ja(j+F,l[0][1]):!d&&F<0&&(R=Na(j+L,l[1][1])),M=Math.max(M,_),T=Math.max(T,R)}if(s){if(f){const _=ch(z/$,y,k)*$;if(M=Math.max(M,_),a){let R=0;!c&&!d||c&&!d&&p?R=ja(j+W+z/$,a[1][1])*$:R=Na(j+W+(c?B:-B)/$,a[0][1])*$,M=Math.max(M,R)}if(l){let R=0;!c&&!d||c&&!d&&p?R=Na(j+z/$,l[1][1])*$:R=ja(j+(c?B:-B)/$,l[0][1])*$,M=Math.max(M,R)}}if(u){const _=ch(L*$,b,v)/$;if(T=Math.max(T,_),a){let R=0;!c&&!d||d&&!c&&p?R=ja(w+L*$+O,a[1][0])/$:R=Na(w+(d?F:-F)*$+O,a[0][0])/$,T=Math.max(T,R)}if(l){let R=0;!c&&!d||d&&!c&&p?R=Na(w+L*$,l[1][0])/$:R=ja(w+(d?F:-F)*$,l[0][0])/$,T=Math.max(T,R)}}}F=F+(F<0?T:-T),B=B+(B<0?M:-M),s&&(p?z>L*$?F=(MS(c,d)?-B:B)/$:B=(MS(c,d)?-F:F)*$:f?(F=B/$,d=c):(B=F*$,c=d));const E=c?w+B:w,D=d?j+F:j;return{width:A+(c?-B:B),height:C+(d?-F:F),x:i[0]*B*(c?-1:1)+E,y:i[1]*F*(d?-1:1)+D}}const KP={width:0,height:0,x:0,y:0},U3={...KP,pointerX:0,pointerY:0,aspectRatio:1};function K3(e){return[[0,0],[e.measured.width,e.measured.height]]}function q3(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,c=n[1]*a;return[[r-l,s-c],[r+i-l,s+a-c]]}function Y3({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Ds(e);let a={controlDirection:OS("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:f,keepAspectRatio:u,resizeDirection:p,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:v}){let y={...KP},k={...U3};a={boundaries:f,resizeDirection:p,keepAspectRatio:u,controlDirection:OS(d)};let w,j=null,A=[],C,$,B,F=!1;const z=nP().on("start",L=>{const{nodeLookup:O,transform:W,snapGrid:M,snapToGrid:T,nodeOrigin:E,paneDomNode:D}=n();if(w=O.get(t),!w)return;j=(D==null?void 0:D.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:R}=Qd(L.sourceEvent,{transform:W,snapGrid:M,snapToGrid:T,containerBounds:j});y={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},k={...y,pointerX:_,pointerY:R,aspectRatio:y.width/y.height},C=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(C=O.get(w.parentId),$=C&&w.extent==="parent"?K3(C):void 0),A=[],B=void 0;for(const[P,G]of O)if(G.parentId===t&&(A.push({id:P,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const Z=q3(G,w,G.origin??E);B?B=[[Math.min(Z[0][0],B[0][0]),Math.min(Z[0][1],B[0][1])],[Math.max(Z[1][0],B[1][0]),Math.max(Z[1][1],B[1][1])]]:B=Z}m==null||m(L,{...y})}).on("drag",L=>{const{transform:O,snapGrid:W,snapToGrid:M,nodeOrigin:T}=n(),E=Qd(L.sourceEvent,{transform:O,snapGrid:W,snapToGrid:M,containerBounds:j}),D=[];if(!w)return;const{x:_,y:R,width:P,height:G}=y,Z={},V=w.origin??T,{width:se,height:ue,x:fe,y:ge}=V3(k,a.controlDirection,E,a.boundaries,a.keepAspectRatio,V,$,B),ae=se!==P,ve=ue!==G,_e=fe!==_&&ae,we=ge!==R&&ve;if(!_e&&!we&&!ae&&!ve)return;if((_e||we||V[0]===1||V[1]===1)&&(Z.x=_e?fe:y.x,Z.y=we?ge:y.y,y.x=Z.x,y.y=Z.y,A.length>0)){const ut=fe-_,et=ge-R;for(const Ct of A)Ct.position={x:Ct.position.x-ut+V[0]*(se-P),y:Ct.position.y-et+V[1]*(ue-G)},D.push(Ct)}if((ae||ve)&&(Z.width=ae&&(!a.resizeDirection||a.resizeDirection==="horizontal")?se:y.width,Z.height=ve&&(!a.resizeDirection||a.resizeDirection==="vertical")?ue:y.height,y.width=Z.width,y.height=Z.height),C&&w.expandParent){const ut=V[0]*(Z.width??0);Z.x&&Z.x<ut&&(y.x=ut,k.x=k.x-(Z.x-ut));const et=V[1]*(Z.height??0);Z.y&&Z.y<et&&(y.y=et,k.y=k.y-(Z.y-et))}const Ee=W3({width:y.width,prevWidth:P,height:y.height,prevHeight:G,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Ae={...y,direction:Ee};(v==null?void 0:v(L,Ae))!==!1&&(F=!0,g==null||g(L,Ae),r(Z,D))}).on("end",L=>{F&&(b==null||b(L,{...y}),s==null||s({...y}),F=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var qP={exports:{}},YP={},GP={exports:{}},XP={};/**
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 Pu=h;function G3(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var X3=typeof Object.is=="function"?Object.is:G3,J3=Pu.useState,Q3=Pu.useEffect,Z3=Pu.useLayoutEffect,e5=Pu.useDebugValue;function t5(e,t){var n=t(),r=J3({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return Z3(function(){s.value=n,s.getSnapshot=t,Yy(s)&&i({inst:s})},[e,n,t]),Q3(function(){return Yy(s)&&i({inst:s}),e(function(){Yy(s)&&i({inst:s})})},[e]),e5(n),n}function Yy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!X3(e,n)}catch{return!0}}function n5(e,t){return t()}var r5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n5:t5;XP.useSyncExternalStore=Pu.useSyncExternalStore!==void 0?Pu.useSyncExternalStore:r5;GP.exports=XP;var JP=GP.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 Ig=h,s5=JP;function i5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var o5=typeof Object.is=="function"?Object.is:i5,a5=s5.useSyncExternalStore,l5=Ig.useRef,c5=Ig.useEffect,u5=Ig.useMemo,d5=Ig.useDebugValue;YP.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=l5(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=u5(function(){function c(m){if(!d){if(d=!0,f=m,m=r(m),s!==void 0&&a.hasValue){var g=a.value;if(s(g,m))return u=g}return u=m}if(g=u,o5(f,m))return g;var b=r(m);return s!==void 0&&s(g,b)?(f=m,g):(f=m,u=b)}var d=!1,f,u,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=a5(e,i[0],i[1]);return c5(function(){a.hasValue=!0,a.value=l},[l]),d5(l),l};qP.exports=YP;var f5=qP.exports;const p5=sl(f5),h5={},$S=e=>{let t;const n=new Set,r=(f,u)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const m=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,m))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(h5?"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()}},d=t=e(r,s,c);return c},m5=e=>e?$S(e):$S,{useDebugValue:g5}=at,{useSyncExternalStoreWithSelector:y5}=p5,x5=e=>e;function QP(e,t=x5,n){const r=y5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return g5(r),r}const DS=(e,t)=>{const n=m5(e),r=(s,i=t)=>QP(n,s,i);return Object.assign(r,n),r},w5=(e,t)=>e?DS(e,t):DS;function Dn(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 Tg=h.createContext(null),b5=Tg.Provider,ZP=bo.error001();function Kt(e,t){const n=h.useContext(Tg);if(n===null)throw new Error(ZP);return QP(n,e,t)}function Pn(){const e=h.useContext(Tg);if(e===null)throw new Error(ZP);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const FS={display:"none"},v5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},eA="react-flow__node-desc",tA="react-flow__edge-desc",k5="react-flow__aria-live",S5=e=>e.ariaLiveMessage,N5=e=>e.ariaLabelConfig;function j5({rfId:e}){const t=Kt(S5);return o.jsx("div",{id:`${k5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:v5,children:t})}function C5({rfId:e,disableKeyboardA11y:t}){const n=Kt(N5);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${eA}-${e}`,style:FS,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${tA}-${e}`,style:FS,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(j5,{rfId:e})]})}const Au=h.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:mr(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});Au.displayName="Panel";function E5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(Au,{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:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const _5=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}},uh=e=>e.id;function P5(e,t){return Dn(e.selectedNodes.map(uh),t.selectedNodes.map(uh))&&Dn(e.selectedEdges.map(uh),t.selectedEdges.map(uh))}function A5({onSelectionChange:e}){const t=Pn(),{selectedNodes:n,selectedEdges:r}=Kt(_5,P5);return h.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const I5=e=>!!e.onSelectionChangeHandlers;function T5({onSelectionChange:e}){const t=Kt(I5);return e||t?o.jsx(A5,{onSelectionChange:e}):null}const Kw=typeof window<"u"?h.useLayoutEffect:h.useEffect,nA=[0,0],R5={x:0,y:0,zoom:1},L5=["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"],zS=[...L5,"rfId"],O5=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}),BS={translateExtent:_f,nodeOrigin:nA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function M5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Kt(O5,Dn),d=Pn();Kw(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=BS,l()}),[]);const f=h.useRef(BS);return Kw(()=>{for(const u of zS){const p=e[u],m=f.current[u];p!==m&&(typeof e[u]>"u"||(u==="nodes"?t(p):u==="edges"?n(p):u==="minZoom"?r(p):u==="maxZoom"?s(p):u==="translateExtent"?i(p):u==="nodeExtent"?a(p):u==="ariaLabelConfig"?d.setState({ariaLabelConfig:a3(p)}):u==="fitView"?d.setState({fitViewQueued:p}):u==="fitViewOptions"?d.setState({fitViewOptions:p}):d.setState({[u]:p})))}f.current=e},zS.map(u=>e[u])),null}function HS(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function $5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const s=HS(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=HS())!=null&&r.matches?"dark":"light"}const WS=typeof document<"u"?document:null;function Rf(e=null,t={target:WS,actInsideInputWithModifier:!0}){const[n,r]=h.useState(!1),s=h.useRef(!1),i=h.useRef(new Set([])),[a,l]=h.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
61
+ `).replace(`
62
+
63
+ `,`
64
+ +`).split(`
65
+ `)),f=d.reduce((u,p)=>u.concat(...p),[]);return[d,f]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??WS,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var v,y;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&AP(m))return!1;const b=US(m.code,l);if(i.current.add(m[b]),VS(a,i.current,!1)){const k=((y=(v=m.composedPath)==null?void 0:v.call(m))==null?void 0:y[0])||m.target,w=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!w)&&m.preventDefault(),r(!0)}},u=m=>{const g=US(m.code,l);VS(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(m[g]),m.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function VS(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function US(e,t){return t.includes(e)?"code":"key"}const D5=()=>{const e=Pn();return h.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},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:i,maxZoom:a,panZoom:l}=e.getState(),c=Av(t,r,s,i,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:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-c},f=n.snapGrid??s,u=n.snapToGrid??i;return rp(d,r,u,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=Tm(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function rA(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const c of a)F5(c,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function F5(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 Rm(e,t){return rA(e,t)}function $v(e,t){return rA(e,t)}function Ml(e,t){return{id:e,type:"select",selected:t}}function Zc(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(Ml(i.id,a)))}return r}function KS({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,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:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function qS(e){return{id:e.id,type:"remove"}}const YS=e=>Jz(e),z5=e=>kP(e);function sA(e){return h.forwardRef(e)}function GS(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>B5(()=>n(s=>s+BigInt(1))));return Kw(()=>{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 iA=h.createContext(null);function H5({children:e}){const t=Pn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:f,onNodesChange:u,nodeLookup:p,fitViewQueued:m,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let v=KS({items:b,lookup:p});for(const y of g.values())v=y(v);f&&d(b),v.length>0?u==null||u(v):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:k,setNodes:w}=t.getState();y&&w(k)})},[]),r=GS(n),s=h.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:p}=t.getState();let m=c;for(const g of l)m=typeof g=="function"?g(m):g;f?d(m):u&&u(KS({items:m,lookup:p}))},[]),i=GS(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(iA.Provider,{value:a,children:e})}function W5(){const e=h.useContext(iA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const V5=e=>!!e.panZoom;function cc(){const e=D5(),t=Pn(),n=W5(),r=Kt(V5),s=h.useMemo(()=>{const i=u=>t.getState().nodeLookup.get(u),a=u=>{n.nodeQueue.push(u)},l=u=>{n.edgeQueue.push(u)},c=u=>{var y,k;const{nodeLookup:p,nodeOrigin:m}=t.getState(),g=YS(u)?u:p.get(u.id),b=g.parentId?_P(g.position,g.measured,g.parentId,p,m):g.position,v={...g,position:b,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((k=g.measured)==null?void 0:k.height)??g.height};return Cu(v)},d=(u,p,m={replace:!1})=>{a(g=>g.map(b=>{if(b.id===u){const v=typeof p=="function"?p(b):p;return m.replace&&YS(v)?v:{...b,...v}}return b}))},f=(u,p,m={replace:!1})=>{l(g=>g.map(b=>{if(b.id===u){const v=typeof p=="function"?p(b):p;return m.replace&&z5(v)?v:{...b,...v}}return b}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var p;return(p=i(u))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(p=>({...p}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:a,setEdges:l,addNodes:u=>{const p=Array.isArray(u)?u:[u];n.nodeQueue.push(m=>[...m,...p])},addEdges:u=>{const p=Array.isArray(u)?u:[u];n.edgeQueue.push(m=>[...m,...p])},toObject:()=>{const{nodes:u=[],edges:p=[],transform:m}=t.getState(),[g,b,v]=m;return{nodes:u.map(y=>({...y})),edges:p.map(y=>({...y})),viewport:{x:g,y:b,zoom:v}}},deleteElements:async({nodes:u=[],edges:p=[]})=>{const{nodes:m,edges:g,onNodesDelete:b,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:k,onDelete:w,onBeforeDelete:j}=t.getState(),{nodes:A,edges:C}=await n3({nodesToRemove:u,edgesToRemove:p,nodes:m,edges:g,onBeforeDelete:j}),$=C.length>0,B=A.length>0;if($){const F=C.map(qS);v==null||v(C),k(F)}if(B){const F=A.map(qS);b==null||b(A),y(F)}return(B||$)&&(w==null||w({nodes:A,edges:C})),{deletedNodes:A,deletedEdges:C}},getIntersectingNodes:(u,p=!0,m)=>{const g=NS(u),b=g?u:c(u),v=m!==void 0;return b?(m||t.getState().nodes).filter(y=>{const k=t.getState().nodeLookup.get(y.id);if(k&&!g&&(y.id===u.id||!k.internals.positionAbsolute))return!1;const w=Cu(v?y:k),j=Af(w,b);return p&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(u,p,m=!0)=>{const b=NS(u)?u:c(u);if(!b)return!1;const v=Af(b,p);return m&&v>0||v>=p.width*p.height||v>=b.width*b.height},updateNode:d,updateNodeData:(u,p,m={replace:!1})=>{d(u,g=>{const b=typeof p=="function"?p(g):p;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},updateEdge:f,updateEdgeData:(u,p,m={replace:!1})=>{f(u,g=>{const b=typeof p=="function"?p(g):p;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},getNodesBounds:u=>{const{nodeLookup:p,nodeOrigin:m}=t.getState();return Qz(u,{nodeLookup:p,nodeOrigin:m})},getHandleConnections:({type:u,id:p,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}-${u}${p?`-${p}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:p,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}${u?p?`-${u}-${p}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const p=t.getState().fitViewResolver??o3();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:p}),n.nodeQueue.push(m=>[...m]),p.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const XS=e=>e.selected,U5=typeof window<"u"?window:void 0;function K5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Pn(),{deleteElements:r}=cc(),s=Rf(e,{actInsideInputWithModifier:!1}),i=Rf(t,{target:U5});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(XS),edges:a.filter(XS)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function q5(e){const t=Pn();h.useEffect(()=>{const n=()=>{var s,i,a,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=Iv(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",bo.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 Rg={position:"absolute",width:"100%",height:"100%",top:0,left:0},Y5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function G5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Kl.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:f,maxZoom:u,zoomActivationKeyCode:p,preventScrolling:m=!0,children:g,noWheelClassName:b,noPanClassName:v,onViewportChange:y,isControlledViewport:k,paneClickDistance:w,selectionOnDrag:j}){const A=Pn(),C=h.useRef(null),{userSelectionActive:$,lib:B,connectionInProgress:F}=Kt(Y5,Dn),z=Rf(p),L=h.useRef();q5(C);const O=h.useCallback(W=>{y==null||y({x:W[0],y:W[1],zoom:W[2]}),k||A.setState({transform:W})},[y,k]);return h.useEffect(()=>{if(C.current){L.current=H3({domNode:C.current,minZoom:f,maxZoom:u,translateExtent:d,viewport:c,onDraggingChange:E=>A.setState(D=>D.paneDragging===E?D:{paneDragging:E}),onPanZoomStart:(E,D)=>{const{onViewportChangeStart:_,onMoveStart:R}=A.getState();R==null||R(E,D),_==null||_(D)},onPanZoom:(E,D)=>{const{onViewportChange:_,onMove:R}=A.getState();R==null||R(E,D),_==null||_(D)},onPanZoomEnd:(E,D)=>{const{onViewportChangeEnd:_,onMoveEnd:R}=A.getState();R==null||R(E,D),_==null||_(D)}});const{x:W,y:M,zoom:T}=L.current.getViewport();return A.setState({panZoom:L.current,transform:[W,M,T],domNode:C.current.closest(".react-flow")}),()=>{var E;(E=L.current)==null||E.destroy()}}},[]),h.useEffect(()=>{var W;(W=L.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:z,preventScrolling:m,noPanClassName:v,userSelectionActive:$,noWheelClassName:b,lib:B,onTransformChange:O,connectionInProgress:F,selectionOnDrag:j,paneClickDistance:w})},[e,t,n,r,s,i,a,l,z,m,v,$,b,B,O,F,j,w]),o.jsx("div",{className:"react-flow__renderer",ref:C,style:Rg,children:g})}const X5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function J5(){const{userSelectionActive:e,userSelectionRect:t}=Kt(X5,Dn);return e&&t?o.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 Gy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Q5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Z5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Pf.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:m,children:g}){const b=Pn(),{userSelectionActive:v,elementsSelectable:y,dragging:k,connectionInProgress:w}=Kt(Q5,Dn),j=y&&(e||v),A=h.useRef(null),C=h.useRef(),$=h.useRef(new Set),B=h.useRef(new Set),F=h.useRef(!1),z=_=>{if(F.current||w){F.current=!1;return}c==null||c(_),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},L=_=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){_.preventDefault();return}d==null||d(_)},O=f?_=>f(_):void 0,W=_=>{F.current&&(_.stopPropagation(),F.current=!1)},M=_=>{var ue,fe;const{domNode:R}=b.getState();if(C.current=R==null?void 0:R.getBoundingClientRect(),!C.current)return;const P=_.target===A.current;if(!P&&!!_.target.closest(".nokey")||!e||!(i&&P||t)||_.button!==0||!_.isPrimary)return;(fe=(ue=_.target)==null?void 0:ue.setPointerCapture)==null||fe.call(ue,_.pointerId),F.current=!1;const{x:V,y:se}=Mi(_.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:se,x:V,y:se}}),P||(_.stopPropagation(),_.preventDefault())},T=_=>{const{userSelectionRect:R,transform:P,nodeLookup:G,edgeLookup:Z,connectionLookup:V,triggerNodeChanges:se,triggerEdgeChanges:ue,defaultEdgeOptions:fe,resetSelectedElements:ge}=b.getState();if(!C.current||!R)return;const{x:ae,y:ve}=Mi(_.nativeEvent,C.current),{startX:_e,startY:we}=R;if(!F.current){const et=t?0:s;if(Math.hypot(ae-_e,ve-we)<=et)return;ge(),a==null||a(_)}F.current=!0;const Ee={startX:_e,startY:we,x:ae<_e?ae:_e,y:ve<we?ve:we,width:Math.abs(ae-_e),height:Math.abs(ve-we)},Ae=$.current,st=B.current;$.current=new Set(Pv(G,Ee,P,n===Pf.Partial,!0).map(et=>et.id)),B.current=new Set;const ut=(fe==null?void 0:fe.selectable)??!0;for(const et of $.current){const Ct=V.get(et);if(Ct)for(const{edgeId:Ue}of Ct.values()){const St=Z.get(Ue);St&&(St.selectable??ut)&&B.current.add(Ue)}}if(!jS(Ae,$.current)){const et=Zc(G,$.current,!0);se(et)}if(!jS(st,B.current)){const et=Zc(Z,B.current);ue(et)}b.setState({userSelectionRect:Ee,userSelectionActive:!0,nodesSelectionActive:!1})},E=_=>{var R,P;_.button===0&&((P=(R=_.target)==null?void 0:R.releasePointerCapture)==null||P.call(R,_.pointerId),!v&&_.target===A.current&&b.getState().userSelectionRect&&(z==null||z(_)),b.setState({userSelectionActive:!1,userSelectionRect:null}),F.current&&(l==null||l(_),b.setState({nodesSelectionActive:$.current.size>0})))},D=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:mr(["react-flow__pane",{draggable:D,dragging:k,selection:e}]),onClick:j?void 0:Gy(z,A),onContextMenu:Gy(L,A),onWheel:Gy(O,A),onPointerEnter:j?void 0:u,onPointerMove:j?T:p,onPointerUp:j?E:void 0,onPointerDownCapture:j?M:void 0,onClickCapture:j?W:void 0,onPointerLeave:m,ref:A,style:Rg,children:[g,o.jsx(J5,{})]})}function qw({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),d=l.get(e);if(!d){c==null||c("012",bo.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function oA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=Pn(),[c,d]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=_3({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{qw({id:u,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var u;(u=f.current)==null||u.destroy()}},[n,r,t,i,e,s,a]),c}const eB=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function aA(){const e=Pn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:f}=e.getState(),u=new Map,p=eB(a),m=s?i[0]:5,g=s?i[1]:5,b=n.direction.x*m*n.factor,v=n.direction.y*g*n.factor;for(const[,y]of d){if(!p(y))continue;let k={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+v};s&&(k=np(k,i));const{position:w,positionAbsolute:j}=SP({nodeId:y.id,nextPosition:k,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});y.position=w,y.internals.positionAbsolute=j,u.set(y.id,y)}c(u)},[])}const Dv=h.createContext(null),tB=Dv.Provider;Dv.Consumer;const lA=()=>h.useContext(Dv),nB=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),rB=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,f=(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:f,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Nu.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:f&&d}};function sB({type:e="source",position:t=qe.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:f,onTouchStart:u,...p},m){var T,E;const g=a||null,b=e==="target",v=Pn(),y=lA(),{connectOnClick:k,noPanClassName:w,rfId:j}=Kt(nB,Dn),{connectingFrom:A,connectingTo:C,clickConnecting:$,isPossibleEndHandle:B,connectionInProcess:F,clickConnectionInProcess:z,valid:L}=Kt(rB(y,g,e),Dn);y||(E=(T=v.getState()).onError)==null||E.call(T,"010",bo.error010());const O=D=>{const{defaultEdgeOptions:_,onConnect:R,hasDefaultEdges:P}=v.getState(),G={..._,...D};if(P){const{edges:Z,setEdges:V}=v.getState();V(Tf(G,Z))}R==null||R(G),l==null||l(G)},W=D=>{if(!y)return;const _=IP(D.nativeEvent);if(s&&(_&&D.button===0||!_)){const R=v.getState();Uw.onPointerDown(D.nativeEvent,{handleDomNode:D.currentTarget,autoPanOnConnect:R.autoPanOnConnect,connectionMode:R.connectionMode,connectionRadius:R.connectionRadius,domNode:R.domNode,nodeLookup:R.nodeLookup,lib:R.lib,isTarget:b,handleId:g,nodeId:y,flowId:R.rfId,panBy:R.panBy,cancelConnection:R.cancelConnection,onConnectStart:R.onConnectStart,onConnectEnd:(...P)=>{var G,Z;return(Z=(G=v.getState()).onConnectEnd)==null?void 0:Z.call(G,...P)},updateConnection:R.updateConnection,onConnect:O,isValidConnection:n||((...P)=>{var G,Z;return((Z=(G=v.getState()).isValidConnection)==null?void 0:Z.call(G,...P))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:R.autoPanSpeed,dragThreshold:R.connectionDragThreshold})}_?f==null||f(D):u==null||u(D)},M=D=>{const{onClickConnectStart:_,onClickConnectEnd:R,connectionClickStartHandle:P,connectionMode:G,isValidConnection:Z,lib:V,rfId:se,nodeLookup:ue,connection:fe}=v.getState();if(!y||!P&&!s)return;if(!P){_==null||_(D.nativeEvent,{nodeId:y,handleId:g,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const ge=PP(D.target),ae=n||Z,{connection:ve,isValid:_e}=Uw.isValid(D.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:G,fromNodeId:P.nodeId,fromHandleId:P.id||null,fromType:P.type,isValidConnection:ae,flowId:se,doc:ge,lib:V,nodeLookup:ue});_e&&ve&&O(ve);const we=structuredClone(fe);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,R==null||R(D,we),v.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${j}-${y}-${g}-${e}`,className:mr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:$,connectingfrom:A,connectingto:C,valid:L,connectionindicator:r&&(!F||B)&&(F||z?i:s)}]),onMouseDown:W,onTouchStart:W,onClick:k?M:void 0,ref:m,...p,children:c})}const Cs=h.memo(sA(sB));function iB({data:e,isConnectable:t,sourcePosition:n=qe.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Cs,{type:"source",position:n,isConnectable:t})]})}function oB({data:e,isConnectable:t,targetPosition:n=qe.Top,sourcePosition:r=qe.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Cs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Cs,{type:"source",position:r,isConnectable:t})]})}function aB(){return null}function lB({data:e,isConnectable:t,targetPosition:n=qe.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Cs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Lm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},JS={input:iB,default:oB,output:lB,group:aB};function cB(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 uB=e=>{const{width:t,height:n,x:r,y:s}=tp(e.nodeLookup,{filter:i=>!!i.selected});return{width:Oi(t)?t:null,height:Oi(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function dB({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Pn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Kt(uB,Dn),c=aA(),d=h.useRef(null);h.useEffect(()=>{var m;n||(m=d.current)==null||m.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&i!==null;if(oA({nodeRef:d,disabled:!f}),!f)return null;const u=e?m=>{const g=r.getState().nodes.filter(b=>b.selected);e(m,g)}:void 0,p=m=>{Object.prototype.hasOwnProperty.call(Lm,m.key)&&(m.preventDefault(),c({direction:Lm[m.key],factor:m.shiftKey?4:1}))};return o.jsx("div",{className:mr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const QS=typeof window<"u"?window:void 0,fB=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function cA({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:u,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:k,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:A,panOnScrollMode:C,zoomOnDoubleClick:$,panOnDrag:B,defaultViewport:F,translateExtent:z,minZoom:L,maxZoom:O,preventScrolling:W,onSelectionContextMenu:M,noWheelClassName:T,noPanClassName:E,disableKeyboardA11y:D,onViewportChange:_,isControlledViewport:R}){const{nodesSelectionActive:P,userSelectionActive:G}=Kt(fB,Dn),Z=Rf(d,{target:QS}),V=Rf(b,{target:QS}),se=V||B,ue=V||j,fe=f&&se!==!0,ge=Z||G||fe;return K5({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(G5,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:k,zoomOnPinch:w,panOnScroll:ue,panOnScrollSpeed:A,panOnScrollMode:C,zoomOnDoubleClick:$,panOnDrag:!Z&&se,defaultViewport:F,translateExtent:z,minZoom:L,maxZoom:O,zoomActivationKeyCode:v,preventScrolling:W,noWheelClassName:T,noPanClassName:E,onViewportChange:_,isControlledViewport:R,paneClickDistance:l,selectionOnDrag:fe,children:o.jsxs(Z5,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:se,isSelecting:!!ge,selectionMode:u,selectionKeyPressed:Z,paneClickDistance:l,selectionOnDrag:fe,children:[e,P&&o.jsx(dB,{onSelectionContextMenu:M,noPanClassName:E,disableKeyboardA11y:D})]})})}cA.displayName="FlowRenderer";const pB=h.memo(cA),hB=e=>t=>e?Pv(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 mB(e){return Kt(h.useCallback(hB(e),[e]),Dn)}const gB=e=>e.updateNodeInternals;function yB(){const e=Kt(gB),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function xB({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Pn(),i=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),d=h.useRef(t),f=n&&!!e.internals.handleBounds;return h.useEffect(()=>{i.current&&!e.hidden&&(!f||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[f,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(i.current){const u=d.current!==t,p=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(u||p||m)&&(d.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function wB({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:f,resizeObserver:u,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:g,rfId:b,nodeTypes:v,nodeClickDistance:y,onError:k}){const{node:w,internals:j,isParent:A}=Kt(ae=>{const ve=ae.nodeLookup.get(e),_e=ae.parentLookup.has(e);return{node:ve,internals:ve.internals,isParent:_e}},Dn);let C=w.type||"default",$=(v==null?void 0:v[C])||JS[C];$===void 0&&(k==null||k("003",bo.error003(C)),C="default",$=(v==null?void 0:v.default)||JS.default);const B=!!(w.draggable||l&&typeof w.draggable>"u"),F=!!(w.selectable||c&&typeof w.selectable>"u"),z=!!(w.connectable||d&&typeof w.connectable>"u"),L=!!(w.focusable||f&&typeof w.focusable>"u"),O=Pn(),W=EP(w),M=xB({node:w,nodeType:C,hasDimensions:W,resizeObserver:u}),T=oA({nodeRef:M,disabled:w.hidden||!B,noDragClassName:p,handleSelector:w.dragHandle,nodeId:e,isSelectable:F,nodeClickDistance:y}),E=aA();if(w.hidden)return null;const D=ia(w),_=cB(w),R=F||B||t||n||r||s,P=n?ae=>n(ae,{...j.userNode}):void 0,G=r?ae=>r(ae,{...j.userNode}):void 0,Z=s?ae=>s(ae,{...j.userNode}):void 0,V=i?ae=>i(ae,{...j.userNode}):void 0,se=a?ae=>a(ae,{...j.userNode}):void 0,ue=ae=>{const{selectNodesOnDrag:ve,nodeDragThreshold:_e}=O.getState();F&&(!ve||!B||_e>0)&&qw({id:e,store:O,nodeRef:M}),t&&t(ae,{...j.userNode})},fe=ae=>{if(!(AP(ae.nativeEvent)||g)){if(xP.includes(ae.key)&&F){const ve=ae.key==="Escape";qw({id:e,store:O,unselect:ve,nodeRef:M})}else if(B&&w.selected&&Object.prototype.hasOwnProperty.call(Lm,ae.key)){ae.preventDefault();const{ariaLabelConfig:ve}=O.getState();O.setState({ariaLiveMessage:ve["node.a11yDescription.ariaLiveMessage"]({direction:ae.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),E({direction:Lm[ae.key],factor:ae.shiftKey?4:1})}}},ge=()=>{var st;if(g||!((st=M.current)!=null&&st.matches(":focus-visible")))return;const{transform:ae,width:ve,height:_e,autoPanOnNodeFocus:we,setCenter:Ee}=O.getState();if(!we)return;Pv(new Map([[e,w]]),{x:0,y:0,width:ve,height:_e},ae,!0).length>0||Ee(w.position.x+D.width/2,w.position.y+D.height/2,{zoom:ae[2]})};return o.jsx("div",{className:mr(["react-flow__node",`react-flow__node-${C}`,{[m]:B},w.className,{selected:w.selected,selectable:F,parent:A,draggable:B,dragging:T}]),ref:M,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:R?"all":"none",visibility:W?"visible":"hidden",...w.style,..._},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:P,onMouseMove:G,onMouseLeave:Z,onContextMenu:V,onClick:ue,onDoubleClick:se,onKeyDown:L?fe:void 0,tabIndex:L?0:void 0,onFocus:L?ge:void 0,role:w.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${eA}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:o.jsx(tB,{value:e,children:o.jsx($,{id:e,data:w.data,type:C,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:F,draggable:B,deletable:w.deletable??!0,isConnectable:z,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:T,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...D})})})}var bB=h.memo(wB);const vB=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function uA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Kt(vB,Dn),a=mB(e.onlyRenderVisibleElements),l=yB();return o.jsx("div",{className:"react-flow__nodes",style:Rg,children:a.map(c=>o.jsx(bB,{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:i},c))})}uA.displayName="NodeRenderer";const kB=h.memo(uA);function SB(e){return Kt(h.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&u3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Dn)}const NB=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},jB=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ZS={[Ns.Arrow]:NB,[Ns.ArrowClosed]:jB};function CB(e){const t=Pn();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(ZS,e)?ZS[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",bo.error009(e)),null)},[e])}const EB=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=CB(t);return c?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:o.jsx(c,{color:n,strokeWidth:a})}):null},dA=({defaultColor:e,rfId:t})=>{const n=Kt(i=>i.edges),r=Kt(i=>i.defaultEdgeOptions),s=h.useMemo(()=>y3(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?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:s.map(i=>o.jsx(EB,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};dA.displayName="MarkerDefinitions";var _B=h.memo(dA);function fA({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...f}){const[u,p]=h.useState({x:1,y:0,width:0,height:0}),m=mr(["react-flow__edge-textwrapper",d]),g=h.useRef(null);return h.useEffect(()=>{if(g.current){const b=g.current.getBBox();p({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:m,visibility:u.width?"visible":"hidden",...f,children:[s&&o.jsx("rect",{width:u.width+2*a[0],x:-a[0],y:-a[1],height:u.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}fA.displayName="EdgeText";const PB=h.memo(fA);function Lg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...f}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...f,d:e,fill:"none",className:mr(["react-flow__edge-path",f.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&Oi(t)&&Oi(n)?o.jsx(PB,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function eN({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 pA({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:i=qe.Top}){const[a,l]=eN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=eN({pos:i,x1:r,y1:s,x2:e,y2:t}),[f,u,p,m]=TP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${s}`,f,u,p,m]}function hA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,interactionWidth:y})=>{const[k,w,j]=pA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),A=e.isInternal?void 0:t;return o.jsx(Lg,{id:A,path:k,labelX:w,labelY:j,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,interactionWidth:y})})}const AB=hA({isInternal:!1}),mA=hA({isInternal:!0});AB.displayName="SimpleBezierEdge";mA.displayName="SimpleBezierEdgeInternal";function gA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,sourcePosition:m=qe.Bottom,targetPosition:g=qe.Top,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:k})=>{const[w,j,A]=Hw({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),C=e.isInternal?void 0:t;return o.jsx(Lg,{id:C,path:w,labelX:j,labelY:A,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:b,markerStart:v,interactionWidth:k})})}const yA=gA({isInternal:!1}),xA=gA({isInternal:!0});yA.displayName="SmoothStepEdge";xA.displayName="SmoothStepEdgeInternal";function wA(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(yA,{...n,id:r,pathOptions:h.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const IB=wA({isInternal:!1}),bA=wA({isInternal:!0});IB.displayName="StepEdge";bA.displayName="StepEdgeInternal";function vA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:g,interactionWidth:b})=>{const[v,y,k]=OP({sourceX:n,sourceY:r,targetX:s,targetY:i}),w=e.isInternal?void 0:t;return o.jsx(Lg,{id:w,path:v,labelX:y,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:u,style:p,markerEnd:m,markerStart:g,interactionWidth:b})})}const TB=vA({isInternal:!1}),kA=vA({isInternal:!0});TB.displayName="StraightEdge";kA.displayName="StraightEdgeInternal";function SA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=qe.Bottom,targetPosition:l=qe.Top,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:k})=>{const[w,j,A]=RP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),C=e.isInternal?void 0:t;return o.jsx(Lg,{id:C,path:w,labelX:j,labelY:A,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:v,interactionWidth:k})})}const RB=SA({isInternal:!1}),NA=SA({isInternal:!0});RB.displayName="BezierEdge";NA.displayName="BezierEdgeInternal";const tN={default:NA,straight:kA,step:bA,smoothstep:xA,simplebezier:mA},nN={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},LB=(e,t,n)=>n===qe.Left?e-t:n===qe.Right?e+t:e,OB=(e,t,n)=>n===qe.Top?e-t:n===qe.Bottom?e+t:e,rN="react-flow__edgeupdater";function sN({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:l}){return o.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:mr([rN,`${rN}-${l}`]),cx:LB(t,r,e),cy:OB(n,r,e),r,stroke:"transparent",fill:"transparent"})}function MB({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:f,onReconnectEnd:u,setReconnecting:p,setUpdateHover:m}){const g=Pn(),b=(j,A)=>{if(j.button!==0)return;const{autoPanOnConnect:C,domNode:$,connectionMode:B,connectionRadius:F,lib:z,onConnectStart:L,cancelConnection:O,nodeLookup:W,rfId:M,panBy:T,updateConnection:E}=g.getState(),D=A.type==="target",_=(G,Z)=>{p(!1),u==null||u(G,n,A.type,Z)},R=G=>d==null?void 0:d(n,G),P=(G,Z)=>{p(!0),f==null||f(j,n,A.type),L==null||L(G,Z)};Uw.onPointerDown(j.nativeEvent,{autoPanOnConnect:C,connectionMode:B,connectionRadius:F,domNode:$,handleId:A.id,nodeId:A.nodeId,nodeLookup:W,isTarget:D,edgeUpdaterType:A.type,lib:z,flowId:M,cancelConnection:O,panBy:T,isValidConnection:(...G)=>{var Z,V;return((V=(Z=g.getState()).isValidConnection)==null?void 0:V.call(Z,...G))??!0},onConnect:R,onConnectStart:P,onConnectEnd:(...G)=>{var Z,V;return(V=(Z=g.getState()).onConnectEnd)==null?void 0:V.call(Z,...G)},onReconnectEnd:_,updateConnection:E,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},v=j=>b(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=j=>b(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>m(!0),w=()=>m(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(sN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:v,onMouseEnter:k,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&o.jsx(sN,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:k,onMouseOut:w,type:"target"})]})}function $B({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,rfId:g,edgeTypes:b,noPanClassName:v,onError:y,disableKeyboardA11y:k}){let w=Kt(Ee=>Ee.edgeLookup.get(e));const j=Kt(Ee=>Ee.defaultEdgeOptions);w=j?{...j,...w}:w;let A=w.type||"default",C=(b==null?void 0:b[A])||tN[A];C===void 0&&(y==null||y("011",bo.error011(A)),A="default",C=(b==null?void 0:b.default)||tN.default);const $=!!(w.focusable||t&&typeof w.focusable>"u"),B=typeof u<"u"&&(w.reconnectable||n&&typeof w.reconnectable>"u"),F=!!(w.selectable||r&&typeof w.selectable>"u"),z=h.useRef(null),[L,O]=h.useState(!1),[W,M]=h.useState(!1),T=Pn(),{zIndex:E,sourceX:D,sourceY:_,targetX:R,targetY:P,sourcePosition:G,targetPosition:Z}=Kt(h.useCallback(Ee=>{const Ae=Ee.nodeLookup.get(w.source),st=Ee.nodeLookup.get(w.target);if(!Ae||!st)return{zIndex:w.zIndex,...nN};const ut=g3({id:e,sourceNode:Ae,targetNode:st,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:Ee.connectionMode,onError:y});return{zIndex:c3({selected:w.selected,zIndex:w.zIndex,sourceNode:Ae,targetNode:st,elevateOnSelect:Ee.elevateEdgesOnSelect,zIndexMode:Ee.zIndexMode}),...ut||nN}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),Dn),V=h.useMemo(()=>w.markerStart?`url('#${Ww(w.markerStart,g)}')`:void 0,[w.markerStart,g]),se=h.useMemo(()=>w.markerEnd?`url('#${Ww(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||D===null||_===null||R===null||P===null)return null;const ue=Ee=>{var et;const{addSelectedEdges:Ae,unselectNodesAndEdges:st,multiSelectionActive:ut}=T.getState();F&&(T.setState({nodesSelectionActive:!1}),w.selected&&ut?(st({nodes:[],edges:[w]}),(et=z.current)==null||et.blur()):Ae([e])),s&&s(Ee,w)},fe=i?Ee=>{i(Ee,{...w})}:void 0,ge=a?Ee=>{a(Ee,{...w})}:void 0,ae=l?Ee=>{l(Ee,{...w})}:void 0,ve=c?Ee=>{c(Ee,{...w})}:void 0,_e=d?Ee=>{d(Ee,{...w})}:void 0,we=Ee=>{var Ae;if(!k&&xP.includes(Ee.key)&&F){const{unselectNodesAndEdges:st,addSelectedEdges:ut}=T.getState();Ee.key==="Escape"?((Ae=z.current)==null||Ae.blur(),st({edges:[w]})):ut([e])}};return o.jsx("svg",{style:{zIndex:E},children:o.jsxs("g",{className:mr(["react-flow__edge",`react-flow__edge-${A}`,w.className,v,{selected:w.selected,animated:w.animated,inactive:!F&&!s,updating:L,selectable:F}]),onClick:ue,onDoubleClick:fe,onContextMenu:ge,onMouseEnter:ae,onMouseMove:ve,onMouseLeave:_e,onKeyDown:$?we:void 0,tabIndex:$?0:void 0,role:w.ariaRole??($?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":$?`${tA}-${g}`:void 0,ref:z,...w.domAttributes,children:[!W&&o.jsx(C,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:F,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:D,sourceY:_,targetX:R,targetY:P,sourcePosition:G,targetPosition:Z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:V,markerEnd:se,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),B&&o.jsx(MB,{edge:w,isReconnectable:B,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,sourceX:D,sourceY:_,targetX:R,targetY:P,sourcePosition:G,targetPosition:Z,setUpdateHover:O,setReconnecting:M})]})})}var DB=h.memo($B);const FB=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function jA({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:p,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:k,onError:w}=Kt(FB,Dn),j=SB(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(_B,{defaultColor:e,rfId:n}),j.map(A=>o.jsx(DB,{id:A,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:k,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:f,reconnectRadius:u,onDoubleClick:p,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:w,edgeTypes:r,disableKeyboardA11y:b},A))]})}jA.displayName="EdgeRenderer";const zB=h.memo(jA),BB=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function HB({children:e}){const t=Kt(BB);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function WB(e){const t=cc(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const VB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function UB(e){const t=Kt(VB),n=Pn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function KB(e){return e.connection.inProgress?{...e.connection,to:rp(e.connection.to,e.transform)}:{...e.connection}}function qB(e){return KB}function YB(e){const t=qB();return Kt(t,Dn)}const GB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function XB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Kt(GB,Dn);return!(i&&s&&c)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:mr(["react-flow__connection",vP(l)]),children:o.jsx(CA,{style:t,type:n,CustomComponent:r,isValid:l})})})}const CA=({style:e,type:t=La.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:f,toHandle:u,toPosition:p,pointer:m}=YB();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:c,toPosition:p,connectionStatus:vP(r),toNode:f,toHandle:u,pointer:m});let g="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case La.Bezier:[g]=RP(b);break;case La.SimpleBezier:[g]=pA(b);break;case La.Step:[g]=Hw({...b,borderRadius:0});break;case La.SmoothStep:[g]=Hw(b);break;default:[g]=OP(b)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};CA.displayName="ConnectionLine";const JB={};function iN(e=JB){h.useRef(e),Pn(),h.useEffect(()=>{},[e])}function QB(){Pn(),h.useRef(!1),h.useEffect(()=>{},[])}function EA({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:p,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:k,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:A,panActivationKeyCode:C,zoomActivationKeyCode:$,deleteKeyCode:B,onlyRenderVisibleElements:F,elementsSelectable:z,defaultViewport:L,translateExtent:O,minZoom:W,maxZoom:M,preventScrolling:T,defaultMarkerColor:E,zoomOnScroll:D,zoomOnPinch:_,panOnScroll:R,panOnScrollSpeed:P,panOnScrollMode:G,zoomOnDoubleClick:Z,panOnDrag:V,onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:fe,onPaneMouseLeave:ge,onPaneScroll:ae,onPaneContextMenu:ve,paneClickDistance:_e,nodeClickDistance:we,onEdgeContextMenu:Ee,onEdgeMouseEnter:Ae,onEdgeMouseMove:st,onEdgeMouseLeave:ut,reconnectRadius:et,onReconnect:Ct,onReconnectStart:Ue,onReconnectEnd:St,noDragClassName:nn,noWheelClassName:hn,noPanClassName:An,disableKeyboardA11y:Bt,nodeExtent:In,rfId:Fn,viewport:le,onViewportChange:de}){return iN(e),iN(t),QB(),WB(n),UB(le),o.jsx(pB,{onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:fe,onPaneMouseLeave:ge,onPaneContextMenu:ve,onPaneScroll:ae,paneClickDistance:_e,deleteKeyCode:B,selectionKeyCode:k,selectionOnDrag:w,selectionMode:j,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:A,panActivationKeyCode:C,zoomActivationKeyCode:$,elementsSelectable:z,zoomOnScroll:D,zoomOnPinch:_,zoomOnDoubleClick:Z,panOnScroll:R,panOnScrollSpeed:P,panOnScrollMode:G,panOnDrag:V,defaultViewport:L,translateExtent:O,minZoom:W,maxZoom:M,onSelectionContextMenu:u,preventScrolling:T,noDragClassName:nn,noWheelClassName:hn,noPanClassName:An,disableKeyboardA11y:Bt,onViewportChange:de,isControlledViewport:!!le,children:o.jsxs(HB,{children:[o.jsx(zB,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:Ct,onReconnectStart:Ue,onReconnectEnd:St,onlyRenderVisibleElements:F,onEdgeContextMenu:Ee,onEdgeMouseEnter:Ae,onEdgeMouseMove:st,onEdgeMouseLeave:ut,reconnectRadius:et,defaultMarkerColor:E,noPanClassName:An,disableKeyboardA11y:Bt,rfId:Fn}),o.jsx(XB,{style:b,type:g,component:v,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(kB,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:we,onlyRenderVisibleElements:F,noPanClassName:An,noDragClassName:nn,disableKeyboardA11y:Bt,nodeExtent:In,rfId:Fn}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}EA.displayName="GraphView";const ZB=h.memo(EA),oN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:u,zIndexMode:p="basic"}={})=>{const m=new Map,g=new Map,b=new Map,v=new Map,y=r??t??[],k=n??e??[],w=f??[0,0],j=u??_f;DP(b,v,y);const{nodesInitialized:A}=Vw(k,m,g,{nodeOrigin:w,nodeExtent:j,zIndexMode:p});let C=[0,0,1];if(a&&s&&i){const $=tp(m,{filter:L=>!!((L.width||L.initialWidth)&&(L.height||L.initialHeight))}),{x:B,y:F,zoom:z}=Av($,s,i,c,d,(l==null?void 0:l.padding)??.1);C=[B,F,z]}return{rfId:"1",width:s??0,height:i??0,transform:C,nodes:k,nodesInitialized:A,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:v,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:_f,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Nu.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:{...bP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:r3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:wP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},e4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p})=>w5((m,g)=>{async function b(){const{nodeLookup:v,panZoom:y,fitViewOptions:k,fitViewResolver:w,width:j,height:A,minZoom:C,maxZoom:$}=g();y&&(await t3({nodes:v,width:j,height:A,panZoom:y,minZoom:C,maxZoom:$},k),w==null||w.resolve(!0),m({fitViewResolver:null}))}return{...oN({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:f,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:v=>{const{nodeLookup:y,parentLookup:k,nodeOrigin:w,elevateNodesOnSelect:j,fitViewQueued:A,zIndexMode:C,nodesSelectionActive:$}=g(),{nodesInitialized:B,hasSelectedNodes:F}=Vw(v,y,k,{nodeOrigin:w,nodeExtent:u,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:C}),z=$&&F;A&&B?(b(),m({nodes:v,nodesInitialized:B,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):m({nodes:v,nodesInitialized:B,nodesSelectionActive:z})},setEdges:v=>{const{connectionLookup:y,edgeLookup:k}=g();DP(y,k,v),m({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:k}=g();k(v),m({hasDefaultNodes:!0})}if(y){const{setEdges:k}=g();k(y),m({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:k,parentLookup:w,domNode:j,nodeOrigin:A,nodeExtent:C,debug:$,fitViewQueued:B,zIndexMode:F}=g(),{changes:z,updatedInternals:L}=N3(v,k,w,j,A,C,F);L&&(b3(k,w,{nodeOrigin:A,nodeExtent:C,zIndexMode:F}),B?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(z==null?void 0:z.length)>0&&($&&console.log("React Flow: trigger node changes",z),y==null||y(z)))},updateNodePositions:(v,y=!1)=>{const k=[];let w=[];const{nodeLookup:j,triggerNodeChanges:A,connection:C,updateConnection:$,onNodesChangeMiddlewareMap:B}=g();for(const[F,z]of v){const L=j.get(F),O=!!(L!=null&&L.expandParent&&(L!=null&&L.parentId)&&(z!=null&&z.position)),W={id:F,type:"position",position:O?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:y};if(L&&C.inProgress&&C.fromNode.id===L.id){const M=sc(L,C.fromHandle,qe.Left,!0);$({...C,from:M})}O&&L.parentId&&k.push({id:F,parentId:L.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),w.push(W)}if(k.length>0){const{parentLookup:F,nodeOrigin:z}=g(),L=Mv(k,j,F,z);w.push(...L)}for(const F of B.values())w=F(w);A(w)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:k,nodes:w,hasDefaultNodes:j,debug:A}=g();if(v!=null&&v.length){if(j){const C=Rm(v,w);k(C)}A&&console.log("React Flow: trigger node changes",v),y==null||y(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:k,edges:w,hasDefaultEdges:j,debug:A}=g();if(v!=null&&v.length){if(j){const C=$v(v,w);k(C)}A&&console.log("React Flow: trigger edge changes",v),y==null||y(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:k,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:A}=g();if(y){const C=v.map($=>Ml($,!0));j(C);return}j(Zc(w,new Set([...v]),!0)),A(Zc(k))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:k,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:A}=g();if(y){const C=v.map($=>Ml($,!0));A(C);return}A(Zc(k,new Set([...v]))),j(Zc(w,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:k,nodes:w,nodeLookup:j,triggerNodeChanges:A,triggerEdgeChanges:C}=g(),$=v||w,B=y||k,F=[];for(const L of $){if(!L.selected)continue;const O=j.get(L.id);O&&(O.selected=!1),F.push(Ml(L.id,!1))}const z=[];for(const L of B)L.selected&&z.push(Ml(L.id,!1));A(F),C(z)},setMinZoom:v=>{const{panZoom:y,maxZoom:k}=g();y==null||y.setScaleExtent([v,k]),m({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:k}=g();y==null||y.setScaleExtent([k,v]),m({maxZoom:v})},setTranslateExtent:v=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(v),m({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:k,triggerEdgeChanges:w,elementsSelectable:j}=g();if(!j)return;const A=y.reduce(($,B)=>B.selected?[...$,Ml(B.id,!1)]:$,[]),C=v.reduce(($,B)=>B.selected?[...$,Ml(B.id,!1)]:$,[]);k(A),w(C)},setNodeExtent:v=>{const{nodes:y,nodeLookup:k,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:A,nodeExtent:C,zIndexMode:$}=g();v[0][0]===C[0][0]&&v[0][1]===C[0][1]&&v[1][0]===C[1][0]&&v[1][1]===C[1][1]||(Vw(y,k,w,{nodeOrigin:j,nodeExtent:v,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:$}),m({nodeExtent:v}))},panBy:v=>{const{transform:y,width:k,height:w,panZoom:j,translateExtent:A}=g();return j3({delta:v,panZoom:j,transform:y,translateExtent:A,width:k,height:w})},setCenter:async(v,y,k)=>{const{width:w,height:j,maxZoom:A,panZoom:C}=g();if(!C)return Promise.resolve(!1);const $=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:A;return await C.setViewport({x:w/2-v*$,y:j/2-y*$,zoom:$},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...bP}})},updateConnection:v=>{m({connection:v})},reset:()=>m({...oN()})}},Object.is);function Og({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:f,nodeExtent:u,zIndexMode:p,children:m}){const[g]=h.useState(()=>e4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:u,zIndexMode:p}));return o.jsx(b5,{value:g,children:o.jsx(H5,{children:m})})}function t4({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m}){return h.useContext(Tg)?o.jsx(o.Fragment,{children:e}):o.jsx(Og,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:u,nodeExtent:p,zIndexMode:m,children:e})}const n4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function r4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:f,onMoveStart:u,onMoveEnd:p,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:k,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:A,onNodeDoubleClick:C,onNodeDragStart:$,onNodeDrag:B,onNodeDragStop:F,onNodesDelete:z,onEdgesDelete:L,onDelete:O,onSelectionChange:W,onSelectionDragStart:M,onSelectionDrag:T,onSelectionDragStop:E,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:R,onBeforeDelete:P,connectionMode:G,connectionLineType:Z=La.Bezier,connectionLineStyle:V,connectionLineComponent:se,connectionLineContainerStyle:ue,deleteKeyCode:fe="Backspace",selectionKeyCode:ge="Shift",selectionOnDrag:ae=!1,selectionMode:ve=Pf.Full,panActivationKeyCode:_e="Space",multiSelectionKeyCode:we=If()?"Meta":"Control",zoomActivationKeyCode:Ee=If()?"Meta":"Control",snapToGrid:Ae,snapGrid:st,onlyRenderVisibleElements:ut=!1,selectNodesOnDrag:et,nodesDraggable:Ct,autoPanOnNodeFocus:Ue,nodesConnectable:St,nodesFocusable:nn,nodeOrigin:hn=nA,edgesFocusable:An,edgesReconnectable:Bt,elementsSelectable:In=!0,defaultViewport:Fn=R5,minZoom:le=.5,maxZoom:de=2,translateExtent:ze=_f,preventScrolling:Qe=!0,nodeExtent:ot,defaultMarkerColor:Qt="#b1b1b7",zoomOnScroll:rn=!0,zoomOnPinch:Tn=!0,panOnScroll:mn=!1,panOnScrollSpeed:or=.5,panOnScrollMode:sn=Kl.Free,zoomOnDoubleClick:kn=!0,panOnDrag:tn=!0,onPaneClick:Sn,onPaneMouseEnter:xe,onPaneMouseMove:Te,onPaneMouseLeave:it,onPaneScroll:re,onPaneContextMenu:je,paneClickDistance:Ye=1,nodeClickDistance:jt=0,children:Ke,onReconnect:Nn,onReconnectStart:fi,onReconnectEnd:jo,onEdgeContextMenu:kr,onEdgeDoubleClick:Sr,onEdgeMouseEnter:Co,onEdgeMouseMove:ar,onEdgeMouseLeave:qs,reconnectRadius:Oe=10,onNodesChange:aa,onEdgesChange:pi,noDragClassName:Kn="nodrag",noWheelClassName:Le="nowheel",noPanClassName:Ht="nopan",fitView:Nr,fitViewOptions:mt,connectOnClick:Vi,attributionPosition:Zn,proOptions:zn,defaultEdgeOptions:jr,elevateNodesOnSelect:lt=!0,elevateEdgesOnSelect:Wt=!1,disableKeyboardA11y:Yt=!1,autoPanOnConnect:Rn,autoPanOnNodeDrag:Je,autoPanSpeed:lr,connectionRadius:_s,isValidConnection:Cr,onError:hi,style:Ps,id:Eo,nodeDragThreshold:Ui,connectionDragThreshold:_o,viewport:Ys,onViewportChange:an,width:As,height:Is,colorMode:Ts="light",debug:Gs,onScroll:U,ariaLabelConfig:he,zIndexMode:Ie="basic",...Pe},Ge){const Vt=Eo||"1",Mt=$5(Ts),er=h.useCallback(Er=>{Er.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),U==null||U(Er)},[U]);return o.jsx("div",{"data-testid":"rf__wrapper",...Pe,onScroll:er,style:{...Ps,...n4},ref:Ge,className:mr(["react-flow",s,Mt]),id:Eo,role:"application",children:o.jsxs(t4,{nodes:e,edges:t,width:As,height:Is,fitView:Nr,fitViewOptions:mt,minZoom:le,maxZoom:de,nodeOrigin:hn,nodeExtent:ot,zIndexMode:Ie,children:[o.jsx(M5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:Ct,autoPanOnNodeFocus:Ue,nodesConnectable:St,nodesFocusable:nn,edgesFocusable:An,edgesReconnectable:Bt,elementsSelectable:In,elevateNodesOnSelect:lt,elevateEdgesOnSelect:Wt,minZoom:le,maxZoom:de,nodeExtent:ot,onNodesChange:aa,onEdgesChange:pi,snapToGrid:Ae,snapGrid:st,connectionMode:G,translateExtent:ze,connectOnClick:Vi,defaultEdgeOptions:jr,fitView:Nr,fitViewOptions:mt,onNodesDelete:z,onEdgesDelete:L,onDelete:O,onNodeDragStart:$,onNodeDrag:B,onNodeDragStop:F,onSelectionDrag:T,onSelectionDragStart:M,onSelectionDragStop:E,onMove:f,onMoveStart:u,onMoveEnd:p,noPanClassName:Ht,nodeOrigin:hn,rfId:Vt,autoPanOnConnect:Rn,autoPanOnNodeDrag:Je,autoPanSpeed:lr,onError:hi,connectionRadius:_s,isValidConnection:Cr,selectNodesOnDrag:et,nodeDragThreshold:Ui,connectionDragThreshold:_o,onBeforeDelete:P,debug:Gs,ariaLabelConfig:he,zIndexMode:Ie}),o.jsx(ZB,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:A,onNodeDoubleClick:C,nodeTypes:i,edgeTypes:a,connectionLineType:Z,connectionLineStyle:V,connectionLineComponent:se,connectionLineContainerStyle:ue,selectionKeyCode:ge,selectionOnDrag:ae,selectionMode:ve,deleteKeyCode:fe,multiSelectionKeyCode:we,panActivationKeyCode:_e,zoomActivationKeyCode:Ee,onlyRenderVisibleElements:ut,defaultViewport:Fn,translateExtent:ze,minZoom:le,maxZoom:de,preventScrolling:Qe,zoomOnScroll:rn,zoomOnPinch:Tn,zoomOnDoubleClick:kn,panOnScroll:mn,panOnScrollSpeed:or,panOnScrollMode:sn,panOnDrag:tn,onPaneClick:Sn,onPaneMouseEnter:xe,onPaneMouseMove:Te,onPaneMouseLeave:it,onPaneScroll:re,onPaneContextMenu:je,paneClickDistance:Ye,nodeClickDistance:jt,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:R,onReconnect:Nn,onReconnectStart:fi,onReconnectEnd:jo,onEdgeContextMenu:kr,onEdgeDoubleClick:Sr,onEdgeMouseEnter:Co,onEdgeMouseMove:ar,onEdgeMouseLeave:qs,reconnectRadius:Oe,defaultMarkerColor:Qt,noDragClassName:Kn,noWheelClassName:Le,noPanClassName:Ht,rfId:Vt,disableKeyboardA11y:Yt,nodeExtent:ot,viewport:Ys,onViewportChange:an}),o.jsx(T5,{onSelectionChange:W}),Ke,o.jsx(E5,{proOptions:zn,position:Zn}),o.jsx(C5,{rfId:Vt,disableKeyboardA11y:Yt})]})})}var Fv=sA(r4);function zv(){const e=Pn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],i=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&i.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function _A(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>Rm(s,i)),[]);return[t,n,r]}function PA(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>$v(s,i)),[]);return[t,n,r]}function s4({dimensions:e,lineWidth:t,variant:n,className:r}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:mr(["react-flow__background-pattern",n,r])})}function i4({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:mr(["react-flow__background-pattern","dots",t])})}var Ya;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ya||(Ya={}));const o4={[Ya.Dots]:1,[Ya.Lines]:1,[Ya.Cross]:6},a4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function AA({id:e,variant:t=Ya.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:d,patternClassName:f}){const u=h.useRef(null),{transform:p,patternId:m}=Kt(a4,Dn),g=r||o4[t],b=t===Ya.Dots,v=t===Ya.Cross,y=Array.isArray(n)?n:[n,n],k=[y[0]*p[2]||1,y[1]*p[2]||1],w=g*p[2],j=Array.isArray(i)?i:[i,i],A=v?[w,w]:k,C=[j[0]*p[2]||1+A[0]/2,j[1]*p[2]||1+A[1]/2],$=`${m}${e||""}`;return o.jsxs("svg",{className:mr(["react-flow__background",d]),style:{...c,...Rg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:u,"data-testid":"rf__background",children:[o.jsx("pattern",{id:$,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:b?o.jsx(i4,{radius:w/2,className:f}):o.jsx(s4,{dimensions:A,lineWidth:s,variant:t,className:f})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${$})`})]})}AA.displayName="Background";const Bv=h.memo(AA);function l4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function c4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function u4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.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 d4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.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 f4(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.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 dh({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:mr(["react-flow__controls-button",t]),...n,children:e})}const p4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function IA({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:f,position:u="bottom-left",orientation:p="vertical","aria-label":m}){const g=Pn(),{isInteractive:b,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:k}=Kt(p4,Dn),{zoomIn:w,zoomOut:j,fitView:A}=cc(),C=()=>{w(),i==null||i()},$=()=>{j(),a==null||a()},B=()=>{A(s),l==null||l()},F=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},z=p==="horizontal"?"horizontal":"vertical";return o.jsxs(Au,{className:mr(["react-flow__controls",z,d]),position:u,style:e,"data-testid":"rf__controls","aria-label":m??k["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(dh,{onClick:C,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(l4,{})}),o.jsx(dh,{onClick:$,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:v,children:o.jsx(c4,{})})]}),n&&o.jsx(dh,{className:"react-flow__controls-fitview",onClick:B,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:o.jsx(u4,{})}),r&&o.jsx(dh,{className:"react-flow__controls-interactive",onClick:F,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:b?o.jsx(f4,{}):o.jsx(d4,{})}),f]})}IA.displayName="Controls";const h4=h.memo(IA);function m4({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:f,shapeRendering:u,selected:p,onClick:m}){const{background:g,backgroundColor:b}=i||{},v=a||g||b;return o.jsx("rect",{className:mr(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:v,stroke:l,strokeWidth:c},shapeRendering:u,onClick:m?y=>m(y,e):void 0})}const g4=h.memo(m4),y4=e=>e.nodes.map(t=>t.id),Xy=e=>e instanceof Function?e:()=>e;function x4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=g4,onClick:a}){const l=Kt(y4,Dn),c=Xy(t),d=Xy(e),f=Xy(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(b4,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:u},p))})}function w4({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:f,y:u,width:p,height:m}=Kt(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const v=b.internals.userNode,{x:y,y:k}=b.internals.positionAbsolute,{width:w,height:j}=ia(v);return{node:v,x:y,y:k,width:w,height:j}},Dn);return!d||d.hidden||!EP(d)?null:o.jsx(l,{x:f,y:u,width:p,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:c,id:d.id})}const b4=h.memo(w4);var v4=h.memo(x4);const k4=200,S4=150,N4=e=>!e.hidden,j4=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?CP(tp(e.nodeLookup,{filter:N4}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},C4="react-flow__minimap-desc";function TA({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:f,maskStrokeWidth:u,position:p="bottom-right",onClick:m,onNodeClick:g,pannable:b=!1,zoomable:v=!1,ariaLabel:y,inversePan:k,zoomStep:w=1,offsetScale:j=5}){const A=Pn(),C=h.useRef(null),{boundingRect:$,viewBB:B,rfId:F,panZoom:z,translateExtent:L,flowWidth:O,flowHeight:W,ariaLabelConfig:M}=Kt(j4,Dn),T=(e==null?void 0:e.width)??k4,E=(e==null?void 0:e.height)??S4,D=$.width/T,_=$.height/E,R=Math.max(D,_),P=R*T,G=R*E,Z=j*R,V=$.x-(P-$.width)/2-Z,se=$.y-(G-$.height)/2-Z,ue=P+Z*2,fe=G+Z*2,ge=`${C4}-${F}`,ae=h.useRef(0),ve=h.useRef();ae.current=R,h.useEffect(()=>{if(C.current&&z)return ve.current=L3({domNode:C.current,panZoom:z,getTransform:()=>A.getState().transform,getViewScale:()=>ae.current}),()=>{var Ae;(Ae=ve.current)==null||Ae.destroy()}},[z]),h.useEffect(()=>{var Ae;(Ae=ve.current)==null||Ae.update({translateExtent:L,width:O,height:W,inversePan:k,pannable:b,zoomStep:w,zoomable:v})},[b,v,k,w,L,O,W]);const _e=m?Ae=>{var et;const[st,ut]=((et=ve.current)==null?void 0:et.pointer(Ae))||[0,0];m(Ae,{x:st,y:ut})}:void 0,we=g?h.useCallback((Ae,st)=>{const ut=A.getState().nodeLookup.get(st).internals.userNode;g(Ae,ut)},[]):void 0,Ee=y??M["minimap.ariaLabel"];return o.jsx(Au,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*R: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:mr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:T,height:E,viewBox:`${V} ${se} ${ue} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ge,ref:C,onClick:_e,children:[Ee&&o.jsx("title",{id:ge,children:Ee}),o.jsx(v4,{onClick:we,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-Z},${se-Z}h${ue+Z*2}v${fe+Z*2}h${-ue-Z*2}z
66
+ M${B.x},${B.y}h${B.width}v${B.height}h${-B.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}TA.displayName="MiniMap";const E4=h.memo(TA),_4=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,P4={[_u.Line]:"right",[_u.Handle]:"bottom-right"};function A4({nodeId:e,position:t,variant:n=_u.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:p,autoScale:m=!0,shouldResize:g,onResizeStart:b,onResize:v,onResizeEnd:y}){const k=lA(),w=typeof e=="string"?e:k,j=Pn(),A=h.useRef(null),C=n===_u.Handle,$=Kt(h.useCallback(_4(C&&m),[C,m]),Dn),B=h.useRef(null),F=t??P4[n];h.useEffect(()=>{if(!(!A.current||!w))return B.current||(B.current=Y3({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:L,transform:O,snapGrid:W,snapToGrid:M,nodeOrigin:T,domNode:E}=j.getState();return{nodeLookup:L,transform:O,snapGrid:W,snapToGrid:M,nodeOrigin:T,paneDomNode:E}},onChange:(L,O)=>{const{triggerNodeChanges:W,nodeLookup:M,parentLookup:T,nodeOrigin:E}=j.getState(),D=[],_={x:L.x,y:L.y},R=M.get(w);if(R&&R.expandParent&&R.parentId){const P=R.origin??E,G=L.width??R.measured.width??0,Z=L.height??R.measured.height??0,V={id:R.id,parentId:R.parentId,rect:{width:G,height:Z,..._P({x:L.x??R.position.x,y:L.y??R.position.y},{width:G,height:Z},R.parentId,M,P)}},se=Mv([V],M,T,E);D.push(...se),_.x=L.x?Math.max(P[0]*G,L.x):void 0,_.y=L.y?Math.max(P[1]*Z,L.y):void 0}if(_.x!==void 0&&_.y!==void 0){const P={id:w,type:"position",position:{..._}};D.push(P)}if(L.width!==void 0&&L.height!==void 0){const G={id:w,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:L.width,height:L.height}};D.push(G)}for(const P of O){const G={...P,type:"position"};D.push(G)}W(D)},onEnd:({width:L,height:O})=>{const W={id:w,type:"dimensions",resizing:!1,dimensions:{width:L,height:O}};j.getState().triggerNodeChanges([W])}})),B.current.update({controlPosition:F,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:f},keepAspectRatio:u,resizeDirection:p,onResizeStart:b,onResize:v,onResizeEnd:y,shouldResize:g}),()=>{var L;(L=B.current)==null||L.destroy()}},[F,l,c,d,f,u,b,v,y,g]);const z=F.split("-");return o.jsx("div",{className:mr(["react-flow__resize-control","nodrag",...z,n,r]),ref:A,style:{...s,scale:$,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:i})}const RA=h.memo(A4);function I4(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const T4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,R4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,L4={};function aN(e,t){return(L4.jsx?R4:T4).test(e)}const O4=/[ \t\n\f\r]/g;function M4(e){return typeof e=="object"?e.type==="text"?lN(e.value):!1:lN(e)}function lN(e){return e.replace(O4,"")===""}let sp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};sp.prototype.normal={};sp.prototype.property={};sp.prototype.space=void 0;function LA(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new sp(n,r,t)}function Yw(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 $4=0;const _t=uc(),fr=uc(),Gw=uc(),Ce=uc(),xn=uc(),du=uc(),Os=uc();function uc(){return 2**++$4}const Xw=Object.freeze(Object.defineProperty({__proto__:null,boolean:_t,booleanish:fr,commaOrSpaceSeparated:Os,commaSeparated:du,number:Ce,overloadedBoolean:Gw,spaceSeparated:xn},Symbol.toStringTag,{value:"Module"})),Jy=Object.keys(Xw);class Hv extends Es{constructor(t,n,r,s){let i=-1;if(super(t,n),cN(this,"space",s),typeof r=="number")for(;++i<Jy.length;){const a=Jy[i];cN(this,Jy[i],(r&Xw[a])===Xw[a])}}}Hv.prototype.defined=!0;function cN(e,t,n){n&&(e[t]=n)}function Fu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Hv(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Yw(r)]=r,n[Yw(i.attribute)]=r}return new sp(t,n,e.space)}const OA=Fu({properties:{ariaActiveDescendant:null,ariaAtomic:fr,ariaAutoComplete:null,ariaBusy:fr,ariaChecked:fr,ariaColCount:Ce,ariaColIndex:Ce,ariaColSpan:Ce,ariaControls:xn,ariaCurrent:null,ariaDescribedBy:xn,ariaDetails:null,ariaDisabled:fr,ariaDropEffect:xn,ariaErrorMessage:null,ariaExpanded:fr,ariaFlowTo:xn,ariaGrabbed:fr,ariaHasPopup:null,ariaHidden:fr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:xn,ariaLevel:Ce,ariaLive:null,ariaModal:fr,ariaMultiLine:fr,ariaMultiSelectable:fr,ariaOrientation:null,ariaOwns:xn,ariaPlaceholder:null,ariaPosInSet:Ce,ariaPressed:fr,ariaReadOnly:fr,ariaRelevant:null,ariaRequired:fr,ariaRoleDescription:xn,ariaRowCount:Ce,ariaRowIndex:Ce,ariaRowSpan:Ce,ariaSelected:fr,ariaSetSize:Ce,ariaSort:null,ariaValueMax:Ce,ariaValueMin:Ce,ariaValueNow:Ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function MA(e,t){return t in e?e[t]:t}function $A(e,t){return MA(e,t.toLowerCase())}const D4=Fu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:du,acceptCharset:xn,accessKey:xn,action:null,allow:null,allowFullScreen:_t,allowPaymentRequest:_t,allowUserMedia:_t,alt:null,as:null,async:_t,autoCapitalize:null,autoComplete:xn,autoFocus:_t,autoPlay:_t,blocking:xn,capture:null,charSet:null,checked:_t,cite:null,className:xn,cols:Ce,colSpan:null,content:null,contentEditable:fr,controls:_t,controlsList:xn,coords:Ce|du,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_t,defer:_t,dir:null,dirName:null,disabled:_t,download:Gw,draggable:fr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_t,formTarget:null,headers:xn,height:Ce,hidden:Gw,high:Ce,href:null,hrefLang:null,htmlFor:xn,httpEquiv:xn,id:null,imageSizes:null,imageSrcSet:null,inert:_t,inputMode:null,integrity:null,is:null,isMap:_t,itemId:null,itemProp:xn,itemRef:xn,itemScope:_t,itemType:xn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_t,low:Ce,manifest:null,max:null,maxLength:Ce,media:null,method:null,min:null,minLength:Ce,multiple:_t,muted:_t,name:null,nonce:null,noModule:_t,noValidate:_t,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:_t,optimum:Ce,pattern:null,ping:xn,placeholder:null,playsInline:_t,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_t,referrerPolicy:null,rel:xn,required:_t,reversed:_t,rows:Ce,rowSpan:Ce,sandbox:xn,scope:null,scoped:_t,seamless:_t,selected:_t,shadowRootClonable:_t,shadowRootDelegatesFocus:_t,shadowRootMode:null,shape:null,size:Ce,sizes:null,slot:null,span:Ce,spellCheck:fr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ce,step:null,style:null,tabIndex:Ce,target:null,title:null,translate:null,type:null,typeMustMatch:_t,useMap:null,value:fr,width:Ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:xn,axis:null,background:null,bgColor:null,border:Ce,borderColor:null,bottomMargin:Ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_t,declare:_t,event:null,face:null,frame:null,frameBorder:null,hSpace:Ce,leftMargin:Ce,link:null,longDesc:null,lowSrc:null,marginHeight:Ce,marginWidth:Ce,noResize:_t,noHref:_t,noShade:_t,noWrap:_t,object:null,profile:null,prompt:null,rev:null,rightMargin:Ce,rules:null,scheme:null,scrolling:fr,standby:null,summary:null,text:null,topMargin:Ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_t,disableRemotePlayback:_t,prefix:null,property:null,results:Ce,security:null,unselectable:null},space:"html",transform:$A}),F4=Fu({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:Os,accentHeight:Ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ce,amplitude:Ce,arabicForm:null,ascent:Ce,attributeName:null,attributeType:null,azimuth:Ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ce,by:null,calcMode:null,capHeight:Ce,className:xn,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:Ce,diffuseConstant:Ce,direction:null,display:null,dur:null,divisor:Ce,dominantBaseline:null,download:_t,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ce,enableBackground:null,end:null,event:null,exponent:Ce,externalResourcesRequired:null,fill:null,fillOpacity:Ce,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:du,g2:du,glyphName:du,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ce,horizOriginX:Ce,horizOriginY:Ce,id:null,ideographic:Ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ce,k:Ce,k1:Ce,k2:Ce,k3:Ce,k4:Ce,kernelMatrix:Os,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ce,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:Ce,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:Ce,overlineThickness:Ce,paintOrder:null,panose1:null,path:null,pathLength:Ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:xn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ce,pointsAtY:Ce,pointsAtZ:Ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Os,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Os,rev:Os,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Os,requiredFeatures:Os,requiredFonts:Os,requiredFormats:Os,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:Ce,specularExponent:Ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ce,strikethroughThickness:Ce,string:null,stroke:null,strokeDashArray:Os,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ce,strokeOpacity:Ce,strokeWidth:null,style:null,surfaceScale:Ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Os,tabIndex:Ce,tableValues:null,target:null,targetX:Ce,targetY:Ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Os,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ce,underlineThickness:Ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ce,values:null,vAlphabetic:Ce,vMathematical:Ce,vectorEffect:null,vHanging:Ce,vIdeographic:Ce,version:null,vertAdvY:Ce,vertOriginX:Ce,vertOriginY:Ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:MA}),DA=Fu({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()}}),FA=Fu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:$A}),zA=Fu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),z4={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"},B4=/[A-Z]/g,uN=/-[a-z]/g,H4=/^data[-\w.:]+$/i;function W4(e,t){const n=Yw(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"&&H4.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(uN,U4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!uN.test(i)){let a=i.replace(B4,V4);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Hv}return new s(r,t)}function V4(e){return"-"+e.toLowerCase()}function U4(e){return e.charAt(1).toUpperCase()}const K4=LA([OA,D4,DA,FA,zA],"html"),Wv=LA([OA,F4,DA,FA,zA],"svg");function q4(e){return e.join(" ").trim()}var Vv={},dN=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Y4=/\n/g,G4=/^\s*/,X4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,J4=/^:\s*/,Q4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Z4=/^[;\s]*/,eH=/^\s+|\s+$/g,tH=`
67
+ `,fN="/",pN="*",Dl="",nH="comment",rH="declaration";function sH(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(g){var b=g.match(Y4);b&&(n+=b.length);var v=g.lastIndexOf(tH);r=~v?g.length-v:r+g.length}function i(){var g={line:n,column:r};return function(b){return b.position=new a(g),d(),b}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var v=b[0];return s(v),e=e.slice(v.length),b}}function d(){c(G4)}function f(g){var b;for(g=g||[];b=u();)b!==!1&&g.push(b);return g}function u(){var g=i();if(!(fN!=e.charAt(0)||pN!=e.charAt(1))){for(var b=2;Dl!=e.charAt(b)&&(pN!=e.charAt(b)||fN!=e.charAt(b+1));)++b;if(b+=2,Dl===e.charAt(b-1))return l("End of comment missing");var v=e.slice(2,b-2);return r+=2,s(v),e=e.slice(b),r+=2,g({type:nH,comment:v})}}function p(){var g=i(),b=c(X4);if(b){if(u(),!c(J4))return l("property missing ':'");var v=c(Q4),y=g({type:rH,property:hN(b[0].replace(dN,Dl)),value:v?hN(v[0].replace(dN,Dl)):Dl});return c(Z4),y}}function m(){var g=[];f(g);for(var b;b=p();)b!==!1&&(g.push(b),f(g));return g}return d(),m()}function hN(e){return e?e.replace(eH,Dl):Dl}var iH=sH,oH=of&&of.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Vv,"__esModule",{value:!0});Vv.default=lH;const aH=oH(iH);function lH(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,aH.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:l}=i;s?t(a,l,i):l&&(n=n||{},n[a]=l)}),n}var Mg={};Object.defineProperty(Mg,"__esModule",{value:!0});Mg.camelCase=void 0;var cH=/^--[a-zA-Z0-9_-]+$/,uH=/-([a-z])/g,dH=/^[^-]+$/,fH=/^-(webkit|moz|ms|o|khtml)-/,pH=/^-(ms)-/,hH=function(e){return!e||dH.test(e)||cH.test(e)},mH=function(e,t){return t.toUpperCase()},mN=function(e,t){return"".concat(t,"-")},gH=function(e,t){return t===void 0&&(t={}),hH(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(pH,mN):e=e.replace(fH,mN),e.replace(uH,mH))};Mg.camelCase=gH;var yH=of&&of.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},xH=yH(Vv),wH=Mg;function Jw(e,t){var n={};return!e||typeof e!="string"||(0,xH.default)(e,function(r,s){r&&s&&(n[(0,wH.camelCase)(r,t)]=s)}),n}Jw.default=Jw;var bH=Jw;const vH=sl(bH),BA=HA("end"),Uv=HA("start");function HA(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 kH(e){const t=Uv(e),n=BA(e);if(t&&n)return{start:t,end:n}}function Zd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?gN(e.position):"start"in e||"end"in e?gN(e):"line"in e||"column"in e?Qw(e):""}function Qw(e){return yN(e&&e.line)+":"+yN(e&&e.column)}function gN(e){return Qw(e&&e.start)+"-"+Qw(e&&e.end)}function yN(e){return e&&typeof e=="number"?e:1}class Jr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?i.ruleId=r:(i.source=r.slice(0,c),i.ruleId=r.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.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=Zd(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Jr.prototype.file="";Jr.prototype.name="";Jr.prototype.reason="";Jr.prototype.message="";Jr.prototype.stack="";Jr.prototype.column=void 0;Jr.prototype.line=void 0;Jr.prototype.ancestors=void 0;Jr.prototype.cause=void 0;Jr.prototype.fatal=void 0;Jr.prototype.place=void 0;Jr.prototype.ruleId=void 0;Jr.prototype.source=void 0;const Kv={}.hasOwnProperty,SH=new Map,NH=/[A-Z]/g,jH=new Set(["table","tbody","thead","tfoot","tr"]),CH=new Set(["td","th"]),WA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function EH(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=OH(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=LH(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"?Wv:K4,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=VA(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function VA(e,t,n){if(t.type==="element")return _H(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return PH(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return IH(e,t,n);if(t.type==="mdxjsEsm")return AH(e,t);if(t.type==="root")return TH(e,t,n);if(t.type==="text")return RH(e,t)}function _H(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Wv,e.schema=s),e.ancestors.push(t);const i=KA(e,t.tagName,!1),a=MH(e,t);let l=Yv(e,t);return jH.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!M4(c):!0})),UA(e,a,i,t),qv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function PH(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)}Lf(e,t.position)}function AH(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Lf(e,t.position)}function IH(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Wv,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:KA(e,t.name,!0),a=$H(e,t),l=Yv(e,t);return UA(e,a,i,t),qv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function TH(e,t,n){const r={};return qv(r,Yv(e,t)),e.create(t,e.Fragment,r,n)}function RH(e,t){return t.value}function UA(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function LH(e,t,n){return r;function r(s,i,a,l){const d=Array.isArray(a.children)?n:t;return l?d(i,a,l):d(i,a)}}function OH(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=Uv(r);return t(s,i,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function MH(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Kv.call(t.properties,s)){const i=DH(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&CH.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function $H(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Lf(e,t.position);else{const s=r.name;let i;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,i=e.evaluater.evaluateExpression(l.expression)}else Lf(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Yv(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:SH;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const d=s.get(c)||0;a=c+"-"+d,s.set(c,d+1)}}const l=VA(e,i,a);l!==void 0&&n.push(l)}return n}function DH(e,t,n){const r=W4(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?I4(n):q4(n)),r.property==="style"){let s=typeof n=="object"?n:FH(e,String(n));return e.stylePropertyNameCase==="css"&&(s=zH(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?z4[r.property]||r.property:r.attribute,n]}}function FH(e,t){try{return vH(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Jr("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=WA+"#cannot-parse-style-attribute",s}}function KA(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const l=aN(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=aN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Kv.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Lf(e)}function Lf(e,t){const n=new Jr("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=WA+"#cannot-handle-mdx-estrees-without-createevaluater",n}function zH(e){const t={};let n;for(n in e)Kv.call(e,n)&&(t[BH(n)]=e[n]);return t}function BH(e){let t=e.replace(NH,HH);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function HH(e){return"-"+e.toLowerCase()}const Qy={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"]},WH={};function VH(e,t){const n=WH,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return qA(e,r,s)}function qA(e,t,n){if(UH(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 xN(e.children,t,n)}return Array.isArray(e)?xN(e,t,n):""}function xN(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=qA(e[s],t,n);return r.join("")}function UH(e){return!!(e&&typeof e=="object")}const wN=document.createElement("i");function Gv(e){const t="&"+e+";";wN.innerHTML=t;const n=wN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function vo(e,t,n,r){const s=e.length;let i=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);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function oi(e,t){return e.length>0?(vo(e,e.length,0,t),e):t}const bN={}.hasOwnProperty;function KH(e){const t={};let n=-1;for(;++n<e.length;)qH(t,e[n]);return t}function qH(e,t){let n;for(n in t){const s=(bN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){bN.call(s,a)||(s[a]=[]);const l=i[a];YH(s[a],Array.isArray(l)?l:l?[l]:[])}}}function YH(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);vo(e,0,0,r)}function YA(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 fu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const fo=ll(/[A-Za-z]/),zs=ll(/[\dA-Za-z]/),GH=ll(/[#-'*+\--9=?A-Z^-~]/);function Zw(e){return e!==null&&(e<32||e===127)}const eb=ll(/\d/),XH=ll(/[\dA-Fa-f]/),JH=ll(/[!-/:-@[-`{-~]/);function xt(e){return e!==null&&e<-2}function js(e){return e!==null&&(e<0||e===32)}function en(e){return e===-2||e===-1||e===32}const QH=ll(new RegExp("\\p{P}|\\p{S}","u")),ZH=ll(/\s/);function ll(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function zu(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&zs(e.charCodeAt(n+1))&&zs(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),s=1):a="�"}else a=String.fromCharCode(i);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 bn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return en(c)?(e.enter(n),l(c)):t(c)}function l(c){return en(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const e8={tokenize:t8};function t8(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"),bn(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(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 xt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const n8={tokenize:r8},vN={tokenize:s8};function r8(e){const t=this,n=[];let r=0,s,i,a;return l;function l(w){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,c,d)(w)}return d(w)}function c(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const j=t.events.length;let A=j,C;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){C=t.events[A][1].end;break}y(r);let $=j;for(;$<t.events.length;)t.events[$][1].end={...C},$++;return vo(t.events,A+1,0,t.events.slice(j)),t.events.length=$,d(w)}return l(w)}function d(w){if(r===n.length){if(!s)return p(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(vN,f,u)(w)}function f(w){return s&&k(),y(r),p(w)}function u(w){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(w)}function p(w){return t.containerState={},e.attempt(vN,m,g)(w)}function m(w){return r++,n.push([t.currentConstruct,t.containerState]),p(w)}function g(w){if(w===null){s&&k(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),b(w)}function b(w){if(w===null){v(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return xt(w)?(e.consume(w),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),b)}function v(w,j){const A=t.sliceStream(w);if(j&&A.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(A),t.parser.lazy[w.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 $=t.events.length;let B=$,F,z;for(;B--;)if(t.events[B][0]==="exit"&&t.events[B][1].type==="chunkFlow"){if(F){z=t.events[B][1].end;break}F=!0}for(y(r),C=$;C<t.events.length;)t.events[C][1].end={...z},C++;vo(t.events,B+1,0,t.events.slice($)),t.events.length=C}}function y(w){let j=n.length;for(;j-- >w;){const A=n[j];t.containerState=A[1],A[0].exit.call(t,e)}n.length=w}function k(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function s8(e,t,n){return bn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function kN(e){if(e===null||js(e)||ZH(e))return 1;if(QH(e))return 2}function Xv(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const tb={name:"attention",resolveAll:i8,tokenize:o8};function i8(e,t){let n=-1,r,s,i,a,l,c,d,f;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 u={...e[r][1].end},p={...e[n][1].start};SN(u,-c),SN(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:u,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={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},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=oi(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=oi(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=oi(d,Xv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=oi(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,d=oi(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,vo(e,r-1,n-r+3,d),n=r+d.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function o8(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=kN(r);let i;return a;function a(c){return i=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===i)return e.consume(c),l;const d=e.exit("attentionSequence"),f=kN(c),u=!f||f===2&&s||n.includes(c),p=!s||s===2&&f||n.includes(r);return d._open=!!(i===42?u:u&&(s||!p)),d._close=!!(i===42?p:p&&(f||!u)),t(c)}}function SN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const a8={name:"autolink",tokenize:l8};function l8(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(m){return fo(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||zs(m)?(r=1,l(m)):d(m)}function l(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||zs(m))&&r++<32?(e.consume(m),l):(r=0,d(m))}function c(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||Zw(m)?n(m):(e.consume(m),c)}function d(m){return m===64?(e.consume(m),f):GH(m)?(e.consume(m),d):n(m)}function f(m){return zs(m)?u(m):n(m)}function u(m){return m===46?(e.consume(m),r=0,f):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||zs(m))&&r++<63){const g=m===45?p:u;return e.consume(m),g}return n(m)}}const $g={partial:!0,tokenize:c8};function c8(e,t,n){return r;function r(i){return en(i)?bn(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||xt(i)?t(i):n(i)}}const GA={continuation:{tokenize:d8},exit:f8,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"),i}return n(a)}function i(a){return en(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function d8(e,t,n){const r=this;return s;function s(a){return en(a)?bn(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(GA,t,n)(a)}}function f8(e){e.exit("blockQuote")}const XA={name:"characterEscape",tokenize:p8};function p8(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return JH(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const JA={name:"characterReference",tokenize:h8};function h8(e,t,n){const r=this;let s=0,i,a;return l;function l(u){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),c}function c(u){return u===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(u),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=zs,f(u))}function d(u){return u===88||u===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(u),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=XH,f):(e.enter("characterReferenceValue"),i=7,a=eb,f(u))}function f(u){if(u===59&&s){const p=e.exit("characterReferenceValue");return a===zs&&!Gv(r.sliceSerialize(p))?n(u):(e.enter("characterReferenceMarker"),e.consume(u),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(u)&&s++<i?(e.consume(u),f):n(u)}}const NN={partial:!0,tokenize:g8},jN={concrete:!0,name:"codeFenced",tokenize:m8};function m8(e,t,n){const r=this,s={partial:!0,tokenize:A};let i=0,a=0,l;return c;function c(C){return d(C)}function d(C){const $=r.events[r.events.length-1];return i=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,l=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(C)}function f(C){return C===l?(a++,e.consume(C),f):a<3?n(C):(e.exit("codeFencedFenceSequence"),en(C)?bn(e,u,"whitespace")(C):u(C))}function u(C){return C===null||xt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(NN,b,j)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||xt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u(C)):en(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),bn(e,m,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function m(C){return C===null||xt(C)?u(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(C))}function g(C){return C===null||xt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),u(C)):C===96&&C===l?n(C):(e.consume(C),g)}function b(C){return e.attempt(s,j,v)(C)}function v(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),y}function y(C){return i>0&&en(C)?bn(e,k,"linePrefix",i+1)(C):k(C)}function k(C){return C===null||xt(C)?e.check(NN,b,j)(C):(e.enter("codeFlowValue"),w(C))}function w(C){return C===null||xt(C)?(e.exit("codeFlowValue"),k(C)):(e.consume(C),w)}function j(C){return e.exit("codeFenced"),t(C)}function A(C,$,B){let F=0;return z;function z(T){return C.enter("lineEnding"),C.consume(T),C.exit("lineEnding"),L}function L(T){return C.enter("codeFencedFence"),en(T)?bn(C,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):O(T)}function O(T){return T===l?(C.enter("codeFencedFenceSequence"),W(T)):B(T)}function W(T){return T===l?(F++,C.consume(T),W):F>=a?(C.exit("codeFencedFenceSequence"),en(T)?bn(C,M,"whitespace")(T):M(T)):B(T)}function M(T){return T===null||xt(T)?(C.exit("codeFencedFence"),$(T)):B(T)}}}function g8(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"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Zy={name:"codeIndented",tokenize:x8},y8={partial:!0,tokenize:w8};function x8(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),bn(e,i,"linePrefix",5)(d)}function i(d){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):xt(d)?e.attempt(y8,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||xt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function w8(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):bn(e,i,"linePrefix",5)(a)}function i(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):xt(a)?s(a):n(a)}}const b8={name:"codeText",previous:k8,resolve:v8,tokenize:S8};function v8(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 k8(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function S8(e,t,n){let r=0,s,i;return a;function a(u){return e.enter("codeText"),e.enter("codeTextSequence"),l(u)}function l(u){return u===96?(e.consume(u),r++,l):(e.exit("codeTextSequence"),c(u))}function c(u){return u===null?n(u):u===32?(e.enter("space"),e.consume(u),e.exit("space"),c):u===96?(i=e.enter("codeTextSequence"),s=0,f(u)):xt(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("codeTextData"),d(u))}function d(u){return u===null||u===32||u===96||xt(u)?(e.exit("codeTextData"),c(u)):(e.consume(u),d)}function f(u){return u===96?(e.consume(u),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(u)):(i.type="codeTextData",d(u))}}class N8{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 i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&kd(this.left,r),i.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),kd(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),kd(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);kd(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);kd(this.left,n.reverse())}}}function kd(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 QA(e){const t={};let n=-1,r,s,i,a,l,c,d;const f=new N8(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,j8(f,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=f.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(f.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...f.get(s)[1].start},l=f.slice(s,n),l.unshift(r),f.splice(s,n-s+1,l))}}return vo(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function j8(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],d={};let f,u,p=-1,m=n,g=0,b=0;const v=[b];for(;m;){for(;e.get(++s)[1]!==m;);i.push(s),m._tokenizer||(f=r.sliceStream(m),m.next||f.push(null),u&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),u=m,m=m.next}for(m=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(b=p+1,v.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):v.pop(),p=v.length;p--;){const y=l.slice(v[p],v[p+1]),k=i.pop();c.push([k,k+y.length-1]),e.splice(k,2,y)}for(c.reverse(),p=-1;++p<c.length;)d[g+c[p][0]]=g+c[p][1],g+=c[p][1]-c[p][0]-1;return d}const C8={resolve:_8,tokenize:P8},E8={partial:!0,tokenize:A8};function _8(e){return QA(e),e}function P8(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?i(l):xt(l)?e.check(E8,a,i)(l):(e.consume(l),s)}function i(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 A8(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),bn(e,i,"linePrefix")}function i(a){if(a===null||xt(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 ZA(e,t,n,r,s,i,a,l,c){const d=c||Number.POSITIVE_INFINITY;let f=0;return u;function u(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),p):y===null||y===32||y===41||Zw(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(y))}function p(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===62?(e.exit("chunkString"),e.exit(l),p(y)):y===null||y===60||xt(y)?n(y):(e.consume(y),y===92?g:m)}function g(y){return y===60||y===62||y===92?(e.consume(y),m):m(y)}function b(y){return!f&&(y===null||y===41||js(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):f<d&&y===40?(e.consume(y),f++,b):y===41?(e.consume(y),f--,b):y===null||y===32||y===40||Zw(y)?n(y):(e.consume(y),y===92?v:b)}function v(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function eI(e,t,n,r,s,i){const a=this;let l=0,c;return d;function d(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(i),f}function f(m){return l>999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(i),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):xt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===null||m===91||m===93||xt(m)||l++>999?(e.exit("chunkString"),f(m)):(e.consume(m),c||(c=!en(m)),m===92?p:u)}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,u):u(m)}}function tI(e,t,n,r,s,i){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(i),d(p))}function d(p){return p===a?(e.exit(i),c(a)):p===null?n(p):xt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),bn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||xt(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?u:f)}function u(p){return p===a||p===92?(e.consume(p),f):f(p)}}function ef(e,t){let n;return r;function r(s){return xt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):en(s)?bn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const I8={name:"definition",tokenize:R8},T8={partial:!0,tokenize:L8};function R8(e,t,n){const r=this;let s;return i;function i(m){return e.enter("definition"),a(m)}function a(m){return eI.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=fu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return js(m)?ef(e,d)(m):d(m)}function d(m){return ZA(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(T8,u,u)(m)}function u(m){return en(m)?bn(e,p,"whitespace")(m):p(m)}function p(m){return m===null||xt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function L8(e,t,n){return r;function r(l){return js(l)?ef(e,s)(l):n(l)}function s(l){return tI(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return en(l)?bn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||xt(l)?t(l):n(l)}}const O8={name:"hardBreakEscape",tokenize:M8};function M8(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return xt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const $8={name:"headingAtx",resolve:D8,tokenize:F8};function D8(e,t){let n=e.length-2,r=3,s,i;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},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},vo(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function F8(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||js(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||xt(f)?(e.exit("atxHeading"),t(f)):en(f)?bn(e,l,"whitespace")(f):(e.enter("atxHeadingText"),d(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),l(f))}function d(f){return f===null||f===35||js(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),d)}}const z8=["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"],CN=["pre","script","style","textarea"],B8={concrete:!0,name:"htmlFlow",resolveTo:V8,tokenize:U8},H8={partial:!0,tokenize:q8},W8={partial:!0,tokenize:K8};function V8(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 U8(e,t,n){const r=this;let s,i,a,l,c;return d;function d(V){return f(V)}function f(V){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(V),u}function u(V){return V===33?(e.consume(V),p):V===47?(e.consume(V),i=!0,b):V===63?(e.consume(V),s=3,r.interrupt?t:P):fo(V)?(e.consume(V),a=String.fromCharCode(V),v):n(V)}function p(V){return V===45?(e.consume(V),s=2,m):V===91?(e.consume(V),s=5,l=0,g):fo(V)?(e.consume(V),s=4,r.interrupt?t:P):n(V)}function m(V){return V===45?(e.consume(V),r.interrupt?t:P):n(V)}function g(V){const se="CDATA[";return V===se.charCodeAt(l++)?(e.consume(V),l===se.length?r.interrupt?t:O:g):n(V)}function b(V){return fo(V)?(e.consume(V),a=String.fromCharCode(V),v):n(V)}function v(V){if(V===null||V===47||V===62||js(V)){const se=V===47,ue=a.toLowerCase();return!se&&!i&&CN.includes(ue)?(s=1,r.interrupt?t(V):O(V)):z8.includes(a.toLowerCase())?(s=6,se?(e.consume(V),y):r.interrupt?t(V):O(V)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(V):i?k(V):w(V))}return V===45||zs(V)?(e.consume(V),a+=String.fromCharCode(V),v):n(V)}function y(V){return V===62?(e.consume(V),r.interrupt?t:O):n(V)}function k(V){return en(V)?(e.consume(V),k):z(V)}function w(V){return V===47?(e.consume(V),z):V===58||V===95||fo(V)?(e.consume(V),j):en(V)?(e.consume(V),w):z(V)}function j(V){return V===45||V===46||V===58||V===95||zs(V)?(e.consume(V),j):A(V)}function A(V){return V===61?(e.consume(V),C):en(V)?(e.consume(V),A):w(V)}function C(V){return V===null||V===60||V===61||V===62||V===96?n(V):V===34||V===39?(e.consume(V),c=V,$):en(V)?(e.consume(V),C):B(V)}function $(V){return V===c?(e.consume(V),c=null,F):V===null||xt(V)?n(V):(e.consume(V),$)}function B(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||js(V)?A(V):(e.consume(V),B)}function F(V){return V===47||V===62||en(V)?w(V):n(V)}function z(V){return V===62?(e.consume(V),L):n(V)}function L(V){return V===null||xt(V)?O(V):en(V)?(e.consume(V),L):n(V)}function O(V){return V===45&&s===2?(e.consume(V),E):V===60&&s===1?(e.consume(V),D):V===62&&s===4?(e.consume(V),G):V===63&&s===3?(e.consume(V),P):V===93&&s===5?(e.consume(V),R):xt(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(H8,Z,W)(V)):V===null||xt(V)?(e.exit("htmlFlowData"),W(V)):(e.consume(V),O)}function W(V){return e.check(W8,M,Z)(V)}function M(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),T}function T(V){return V===null||xt(V)?W(V):(e.enter("htmlFlowData"),O(V))}function E(V){return V===45?(e.consume(V),P):O(V)}function D(V){return V===47?(e.consume(V),a="",_):O(V)}function _(V){if(V===62){const se=a.toLowerCase();return CN.includes(se)?(e.consume(V),G):O(V)}return fo(V)&&a.length<8?(e.consume(V),a+=String.fromCharCode(V),_):O(V)}function R(V){return V===93?(e.consume(V),P):O(V)}function P(V){return V===62?(e.consume(V),G):V===45&&s===2?(e.consume(V),P):O(V)}function G(V){return V===null||xt(V)?(e.exit("htmlFlowData"),Z(V)):(e.consume(V),G)}function Z(V){return e.exit("htmlFlow"),t(V)}}function K8(e,t,n){const r=this;return s;function s(a){return xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function q8(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt($g,t,n)}}const Y8={name:"htmlText",tokenize:G8};function G8(e,t,n){const r=this;let s,i,a;return l;function l(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),c}function c(P){return P===33?(e.consume(P),d):P===47?(e.consume(P),A):P===63?(e.consume(P),w):fo(P)?(e.consume(P),B):n(P)}function d(P){return P===45?(e.consume(P),f):P===91?(e.consume(P),i=0,g):fo(P)?(e.consume(P),k):n(P)}function f(P){return P===45?(e.consume(P),m):n(P)}function u(P){return P===null?n(P):P===45?(e.consume(P),p):xt(P)?(a=u,D(P)):(e.consume(P),u)}function p(P){return P===45?(e.consume(P),m):u(P)}function m(P){return P===62?E(P):P===45?p(P):u(P)}function g(P){const G="CDATA[";return P===G.charCodeAt(i++)?(e.consume(P),i===G.length?b:g):n(P)}function b(P){return P===null?n(P):P===93?(e.consume(P),v):xt(P)?(a=b,D(P)):(e.consume(P),b)}function v(P){return P===93?(e.consume(P),y):b(P)}function y(P){return P===62?E(P):P===93?(e.consume(P),y):b(P)}function k(P){return P===null||P===62?E(P):xt(P)?(a=k,D(P)):(e.consume(P),k)}function w(P){return P===null?n(P):P===63?(e.consume(P),j):xt(P)?(a=w,D(P)):(e.consume(P),w)}function j(P){return P===62?E(P):w(P)}function A(P){return fo(P)?(e.consume(P),C):n(P)}function C(P){return P===45||zs(P)?(e.consume(P),C):$(P)}function $(P){return xt(P)?(a=$,D(P)):en(P)?(e.consume(P),$):E(P)}function B(P){return P===45||zs(P)?(e.consume(P),B):P===47||P===62||js(P)?F(P):n(P)}function F(P){return P===47?(e.consume(P),E):P===58||P===95||fo(P)?(e.consume(P),z):xt(P)?(a=F,D(P)):en(P)?(e.consume(P),F):E(P)}function z(P){return P===45||P===46||P===58||P===95||zs(P)?(e.consume(P),z):L(P)}function L(P){return P===61?(e.consume(P),O):xt(P)?(a=L,D(P)):en(P)?(e.consume(P),L):F(P)}function O(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),s=P,W):xt(P)?(a=O,D(P)):en(P)?(e.consume(P),O):(e.consume(P),M)}function W(P){return P===s?(e.consume(P),s=void 0,T):P===null?n(P):xt(P)?(a=W,D(P)):(e.consume(P),W)}function M(P){return P===null||P===34||P===39||P===60||P===61||P===96?n(P):P===47||P===62||js(P)?F(P):(e.consume(P),M)}function T(P){return P===47||P===62||js(P)?F(P):n(P)}function E(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):n(P)}function D(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),_}function _(P){return en(P)?bn(e,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):R(P)}function R(P){return e.enter("htmlTextData"),a(P)}}const Jv={name:"labelEnd",resolveAll:Z8,resolveTo:e6,tokenize:t6},X8={tokenize:n6},J8={tokenize:r6},Q8={tokenize:s6};function Z8(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&&vo(e,0,e.length,n),e}function e6(e,t){let n=e.length,r=0,s,i,a,l;for(;n--;)if(s=e[n][1],i){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&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const c={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=oi(l,e.slice(i+1,i+r+3)),l=oi(l,[["enter",f,t]]),l=oi(l,Xv(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=oi(l,[["exit",f,t],e[a-2],e[a-1],["exit",d,t]]),l=oi(l,e.slice(a+1)),l=oi(l,[["exit",c,t]]),vo(e,i,e.length,l),e}function t6(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return l;function l(p){return i?i._inactive?u(p):(a=r.parser.defined.includes(fu(r.sliceSerialize({start:i.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(X8,f,a?f:u)(p):p===91?e.attempt(J8,f,a?d:u)(p):a?f(p):u(p)}function d(p){return e.attempt(Q8,f,u)(p)}function f(p){return t(p)}function u(p){return i._balanced=!0,n(p)}}function n6(e,t,n){return r;function r(u){return e.enter("resource"),e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),s}function s(u){return js(u)?ef(e,i)(u):i(u)}function i(u){return u===41?f(u):ZA(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return js(u)?ef(e,c)(u):f(u)}function l(u){return n(u)}function c(u){return u===34||u===39||u===40?tI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):f(u)}function d(u){return js(u)?ef(e,f)(u):f(u)}function f(u){return u===41?(e.enter("resourceMarker"),e.consume(u),e.exit("resourceMarker"),e.exit("resource"),t):n(u)}}function r6(e,t,n){const r=this;return s;function s(l){return eI.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(fu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function s6(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const i6={name:"labelStartImage",resolveAll:Jv.resolveAll,tokenize:o6};function o6(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(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 a6={name:"labelStartLink",resolveAll:Jv.resolveAll,tokenize:l6};function l6(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"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const ex={name:"lineEnding",tokenize:c6};function c6(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),bn(e,t,"linePrefix")}}const Uh={name:"thematicBreak",tokenize:u6};function u6(e,t,n){let r=0,s;return i;function i(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),c(d)):r>=3&&(d===null||xt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),en(d)?bn(e,l,"whitespace")(d):l(d))}}const hs={continuation:{tokenize:h6},exit:g6,name:"list",tokenize:p6},d6={partial:!0,tokenize:y6},f6={partial:!0,tokenize:m6};function p6(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:eb(m)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(Uh,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return eb(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check($g,r.interrupt?n:f,e.attempt(d6,p,u))}function f(m){return r.containerState.initialBlankLine=!0,i++,p(m)}function u(m){return en(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function h6(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check($g,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,bn(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!en(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(f6,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,bn(e,e.attempt(hs,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function m6(e,t,n){const r=this;return bn(e,s,"listItemIndent",r.containerState.size+1);function s(i){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(i):n(i)}}function g6(e){e.exit(this.containerState.type)}function y6(e,t,n){const r=this;return bn(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!en(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const EN={name:"setextUnderline",resolveTo:x6,tokenize:w6};function x6(e,t){let n=e.length,r,s,i;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),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function w6(e,t,n){const r=this;let s;return i;function i(d){let f=r.events.length,u;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){u=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||u)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===s?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),en(d)?bn(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||xt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const b6={tokenize:v6};function v6(e){const t=this,n=e.attempt($g,r,e.attempt(this.parser.constructs.flowInitial,s,bn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(C8,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const k6={resolveAll:rI()},S6=nI("string"),N6=nI("text");function nI(e){return{resolveAll:rI(e==="text"?j6:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,l);return a;function a(f){return d(f)?i(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return d(f)?(n.exit("data"),i(f)):(n.consume(f),c)}function d(f){if(f===null)return!0;const u=s[f];let p=-1;if(u)for(;++p<u.length;){const m=u[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function rI(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function j6(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 i=s.length,a=-1,l=0,c;for(;i--;){const d=s[i];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)c=!0,l++;else if(d!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const C6={42:hs,43:hs,45:hs,48:hs,49:hs,50:hs,51:hs,52:hs,53:hs,54:hs,55:hs,56:hs,57:hs,62:GA},E6={91:I8},_6={[-2]:Zy,[-1]:Zy,32:Zy},P6={35:$8,42:Uh,45:[EN,Uh],60:B8,61:EN,95:Uh,96:jN,126:jN},A6={38:JA,92:XA},I6={[-5]:ex,[-4]:ex,[-3]:ex,33:i6,38:JA,42:tb,60:[a8,Y8],91:a6,92:[O8,XA],93:Jv,95:tb,96:b8},T6={null:[tb,k6]},R6={null:[42,95]},L6={null:[]},O6=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:R6,contentInitial:E6,disable:L6,document:C6,flow:P6,flowInitial:_6,insideSpan:T6,string:A6,text:I6},Symbol.toStringTag,{value:"Module"}));function M6(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={},i=[];let a=[],l=[];const c={attempt:$(A),check:$(C),consume:k,enter:w,exit:j,interrupt:$(C,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:u};let f=t.tokenize.call(d,c);return t.resolveAll&&i.push(t),d;function u(L){return a=oi(a,L),v(),a[a.length-1]!==null?[]:(B(t,0),d.events=Xv(i,d.events,d),d.events)}function p(L,O){return D6(m(L),O)}function m(L){return $6(a,L)}function g(){const{_bufferIndex:L,_index:O,line:W,column:M,offset:T}=r;return{_bufferIndex:L,_index:O,line:W,column:M,offset:T}}function b(L){s[L.line]=L.column,z()}function v(){let L;for(;r._index<a.length;){const O=a[r._index];if(typeof O=="string")for(L=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===L&&r._bufferIndex<O.length;)y(O.charCodeAt(r._bufferIndex));else y(O)}}function y(L){f=f(L)}function k(L){xt(L)?(r.line++,r.column=1,r.offset+=L===-3?2:1,z()):L!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=L}function w(L,O){const W=O||{};return W.type=L,W.start=g(),d.events.push(["enter",W,d]),l.push(W),W}function j(L){const O=l.pop();return O.end=g(),d.events.push(["exit",O,d]),O}function A(L,O){B(L,O.from)}function C(L,O){O.restore()}function $(L,O){return W;function W(M,T,E){let D,_,R,P;return Array.isArray(M)?Z(M):"tokenize"in M?Z([M]):G(M);function G(fe){return ge;function ge(ae){const ve=ae!==null&&fe[ae],_e=ae!==null&&fe.null,we=[...Array.isArray(ve)?ve:ve?[ve]:[],...Array.isArray(_e)?_e:_e?[_e]:[]];return Z(we)(ae)}}function Z(fe){return D=fe,_=0,fe.length===0?E:V(fe[_])}function V(fe){return ge;function ge(ae){return P=F(),R=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?ue():fe.tokenize.call(O?Object.assign(Object.create(d),O):d,c,se,ue)(ae)}}function se(fe){return L(R,P),T}function ue(fe){return P.restore(),++_<D.length?V(D[_]):E}}}function B(L,O){L.resolveAll&&!i.includes(L)&&i.push(L),L.resolve&&vo(d.events,O,d.events.length-O,L.resolve(d.events.slice(O),d)),L.resolveTo&&(d.events=L.resolveTo(d.events,d))}function F(){const L=g(),O=d.previous,W=d.currentConstruct,M=d.events.length,T=Array.from(l);return{from:M,restore:E};function E(){r=L,d.previous=O,d.currentConstruct=W,d.events.length=M,l=T,z()}}function z(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function $6(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function D6(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){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(i)}s=i===-2,r.push(a)}return r.join("")}function F6(e){const r={constructs:KH([O6,...(e||{}).extensions||[]]),content:s(e8),defined:[],document:s(n8),flow:s(b6),lazy:{},string:s(S6),text:s(N6)};return r;function s(i){return a;function a(l){return M6(r,i,l)}}}function z6(e){for(;!QA(e););return e}const _N=/[\0\t\n\r]/g;function B6(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let d,f,u,p,m;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t="",n&&(i.charCodeAt(0)===65279&&u++,n=void 0);u<i.length;){if(_N.lastIndex=u,d=_N.exec(i),p=d&&d.index!==void 0?d.index:i.length,m=i.charCodeAt(p),!d){t=i.slice(u);break}if(m===10&&u===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),u<p&&(c.push(i.slice(u,p)),e+=p-u),m){case 0:{c.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,c.push(-2);e++<f;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}u=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const H6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function W6(e){return e.replace(H6,V6)}function V6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return YA(n.slice(i?2:1),i?16:10)}return Gv(n)||e}const sI={}.hasOwnProperty;function U6(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),K6(n)(z6(F6(n).document().write(B6()(e,t,!0))))}function K6(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(St),autolinkProtocol:F,autolinkEmail:F,atxHeading:i(ut),blockQuote:i(_e),characterEscape:F,characterReference:F,codeFenced:i(we),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(we,a),codeText:i(Ee,a),codeTextData:F,data:F,codeFlowValue:F,definition:i(Ae),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(st),hardBreakEscape:i(et),hardBreakTrailing:i(et),htmlFlow:i(Ct,a),htmlFlowData:F,htmlText:i(Ct,a),htmlTextData:F,image:i(Ue),label:a,link:i(St),listItem:i(hn),listItemValue:p,listOrdered:i(nn,u),listUnordered:i(nn),paragraph:i(An),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ut),strong:i(Bt),thematicBreak:i(Fn)},exit:{atxHeading:c(),atxHeadingSequence:A,autolink:c(),autolinkEmail:ve,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:z,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:fe,characterReference:ge,codeFenced:c(v),codeFencedFence:b,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:z,codeIndented:c(y),codeText:c(T),codeTextData:z,data:z,definition:c(),definitionDestinationString:j,definitionLabelString:k,definitionTitleString:w,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(W),htmlFlowData:z,htmlText:c(M),htmlTextData:z,image:c(D),label:R,labelText:_,lineEnding:L,link:c(E),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:P,resourceTitleString:G,resource:Z,setextHeading:c(B),setextHeadingLineSequence:$,setextHeadingText:C,strong:c(),thematicBreak:c()}};iI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(le){let de={type:"root",children:[]};const ze={stack:[de],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:f,data:n},Qe=[];let ot=-1;for(;++ot<le.length;)if(le[ot][1].type==="listOrdered"||le[ot][1].type==="listUnordered")if(le[ot][0]==="enter")Qe.push(ot);else{const Qt=Qe.pop();ot=s(le,Qt,ot)}for(ot=-1;++ot<le.length;){const Qt=t[le[ot][0]];sI.call(Qt,le[ot][1].type)&&Qt[le[ot][1].type].call(Object.assign({sliceSerialize:le[ot][2].sliceSerialize},ze),le[ot][1])}if(ze.tokenStack.length>0){const Qt=ze.tokenStack[ze.tokenStack.length-1];(Qt[1]||PN).call(ze,void 0,Qt[0])}for(de.position={start:Ca(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:Ca(le.length>0?le[le.length-2][1].end:{line:1,column:1,offset:0})},ot=-1;++ot<t.transforms.length;)de=t.transforms[ot](de)||de;return de}function s(le,de,ze){let Qe=de-1,ot=-1,Qt=!1,rn,Tn,mn,or;for(;++Qe<=ze;){const sn=le[Qe];switch(sn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{sn[0]==="enter"?ot++:ot--,or=void 0;break}case"lineEndingBlank":{sn[0]==="enter"&&(rn&&!or&&!ot&&!mn&&(mn=Qe),or=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:or=void 0}if(!ot&&sn[0]==="enter"&&sn[1].type==="listItemPrefix"||ot===-1&&sn[0]==="exit"&&(sn[1].type==="listUnordered"||sn[1].type==="listOrdered")){if(rn){let kn=Qe;for(Tn=void 0;kn--;){const tn=le[kn];if(tn[1].type==="lineEnding"||tn[1].type==="lineEndingBlank"){if(tn[0]==="exit")continue;Tn&&(le[Tn][1].type="lineEndingBlank",Qt=!0),tn[1].type="lineEnding",Tn=kn}else if(!(tn[1].type==="linePrefix"||tn[1].type==="blockQuotePrefix"||tn[1].type==="blockQuotePrefixWhitespace"||tn[1].type==="blockQuoteMarker"||tn[1].type==="listItemIndent"))break}mn&&(!Tn||mn<Tn)&&(rn._spread=!0),rn.end=Object.assign({},Tn?le[Tn][1].start:sn[1].end),le.splice(Tn||Qe,0,["exit",rn,sn[2]]),Qe++,ze++}if(sn[1].type==="listItemPrefix"){const kn={type:"listItem",_spread:!1,start:Object.assign({},sn[1].start),end:void 0};rn=kn,le.splice(Qe,0,["enter",kn,sn[2]]),Qe++,ze++,mn=void 0,or=!0}}}return le[de][1]._spread=Qt,ze}function i(le,de){return ze;function ze(Qe){l.call(this,le(Qe),Qe),de&&de.call(this,Qe)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(le,de,ze){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([de,ze||void 0]),le.position={start:Ca(de.start),end:void 0}}function c(le){return de;function de(ze){le&&le.call(this,ze),d.call(this,ze)}}function d(le,de){const ze=this.stack.pop(),Qe=this.tokenStack.pop();if(Qe)Qe[0].type!==le.type&&(de?de.call(this,le,Qe[0]):(Qe[1]||PN).call(this,le,Qe[0]));else throw new Error("Cannot close `"+le.type+"` ("+Zd({start:le.start,end:le.end})+"): it’s not open");ze.position.end=Ca(le.end)}function f(){return VH(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function p(le){if(this.data.expectingFirstListItemValue){const de=this.stack[this.stack.length-2];de.start=Number.parseInt(this.sliceSerialize(le),10),this.data.expectingFirstListItemValue=void 0}}function m(){const le=this.resume(),de=this.stack[this.stack.length-1];de.lang=le}function g(){const le=this.resume(),de=this.stack[this.stack.length-1];de.meta=le}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const le=this.resume(),de=this.stack[this.stack.length-1];de.value=le.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const le=this.resume(),de=this.stack[this.stack.length-1];de.value=le.replace(/(\r?\n|\r)$/g,"")}function k(le){const de=this.resume(),ze=this.stack[this.stack.length-1];ze.label=de,ze.identifier=fu(this.sliceSerialize(le)).toLowerCase()}function w(){const le=this.resume(),de=this.stack[this.stack.length-1];de.title=le}function j(){const le=this.resume(),de=this.stack[this.stack.length-1];de.url=le}function A(le){const de=this.stack[this.stack.length-1];if(!de.depth){const ze=this.sliceSerialize(le).length;de.depth=ze}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function $(le){const de=this.stack[this.stack.length-1];de.depth=this.sliceSerialize(le).codePointAt(0)===61?1:2}function B(){this.data.setextHeadingSlurpLineEnding=void 0}function F(le){const ze=this.stack[this.stack.length-1].children;let Qe=ze[ze.length-1];(!Qe||Qe.type!=="text")&&(Qe=In(),Qe.position={start:Ca(le.start),end:void 0},ze.push(Qe)),this.stack.push(Qe)}function z(le){const de=this.stack.pop();de.value+=this.sliceSerialize(le),de.position.end=Ca(le.end)}function L(le){const de=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ze=de.children[de.children.length-1];ze.position.end=Ca(le.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(de.type)&&(F.call(this,le),z.call(this,le))}function O(){this.data.atHardBreak=!0}function W(){const le=this.resume(),de=this.stack[this.stack.length-1];de.value=le}function M(){const le=this.resume(),de=this.stack[this.stack.length-1];de.value=le}function T(){const le=this.resume(),de=this.stack[this.stack.length-1];de.value=le}function E(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=de,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function D(){const le=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";le.type+="Reference",le.referenceType=de,delete le.url,delete le.title}else delete le.identifier,delete le.label;this.data.referenceType=void 0}function _(le){const de=this.sliceSerialize(le),ze=this.stack[this.stack.length-2];ze.label=W6(de),ze.identifier=fu(de).toLowerCase()}function R(){const le=this.stack[this.stack.length-1],de=this.resume(),ze=this.stack[this.stack.length-1];if(this.data.inReference=!0,ze.type==="link"){const Qe=le.children;ze.children=Qe}else ze.alt=de}function P(){const le=this.resume(),de=this.stack[this.stack.length-1];de.url=le}function G(){const le=this.resume(),de=this.stack[this.stack.length-1];de.title=le}function Z(){this.data.inReference=void 0}function V(){this.data.referenceType="collapsed"}function se(le){const de=this.resume(),ze=this.stack[this.stack.length-1];ze.label=de,ze.identifier=fu(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function ue(le){this.data.characterReferenceType=le.type}function fe(le){const de=this.sliceSerialize(le),ze=this.data.characterReferenceType;let Qe;ze?(Qe=YA(de,ze==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Qe=Gv(de);const ot=this.stack[this.stack.length-1];ot.value+=Qe}function ge(le){const de=this.stack.pop();de.position.end=Ca(le.end)}function ae(le){z.call(this,le);const de=this.stack[this.stack.length-1];de.url=this.sliceSerialize(le)}function ve(le){z.call(this,le);const de=this.stack[this.stack.length-1];de.url="mailto:"+this.sliceSerialize(le)}function _e(){return{type:"blockquote",children:[]}}function we(){return{type:"code",lang:null,meta:null,value:""}}function Ee(){return{type:"inlineCode",value:""}}function Ae(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function st(){return{type:"emphasis",children:[]}}function ut(){return{type:"heading",depth:0,children:[]}}function et(){return{type:"break"}}function Ct(){return{type:"html",value:""}}function Ue(){return{type:"image",title:null,url:"",alt:null}}function St(){return{type:"link",title:null,url:"",children:[]}}function nn(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function hn(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function An(){return{type:"paragraph",children:[]}}function Bt(){return{type:"strong",children:[]}}function In(){return{type:"text",value:""}}function Fn(){return{type:"thematicBreak"}}}function Ca(e){return{line:e.line,column:e.column,offset:e.offset}}function iI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?iI(e,r):q6(e,r)}}function q6(e,t){let n;for(n in t)if(sI.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 PN(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Zd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Zd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Zd({start:t.start,end:t.end})+") is still open")}function Y6(e){const t=this;t.parser=n;function n(r){return U6(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function G6(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 X6(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `}]}function J6(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 i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function Q6(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Z6(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function e9(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=zu(r.toLowerCase()),i=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=i+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 d={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,d),e.applyData(t,d)}function t9(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 n9(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function oI(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),i=s[0];i&&i.type==="text"?i.value="["+i.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 r9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return oI(e,t);const s={src:zu(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)}function s9(e,t){const n={src:zu(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 i9(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 o9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return oI(e,t);const s={href:zu(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function a9(e,t){const n={href:zu(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 l9(e,t,n){const r=e.all(t),s=n?c9(n):aI(t),i={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let u;f&&f.type==="element"&&f.tagName==="p"?u=f:(u={type:"element",tagName:"p",properties:{},children:[]},r.unshift(u)),u.children.length>0&&u.children.unshift({type:"text",value:" "}),u.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const f=r[l];(s||l!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
72
+ `}),f.type==="element"&&f.tagName==="p"&&!s?a.push(...f.children):a.push(f)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
+ `});const d={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,d),e.applyData(t,d)}function c9(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=aI(n[r])}return t}function aI(e){const t=e.spread;return t??e.children.length>1}function u9(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 i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function d9(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function f9(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function p9(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function h9(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=Uv(t.children[1]),c=BA(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),s.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function m9(e,t,n){const r=n?n.children:void 0,i=(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 d=[];for(;++c<l;){const u=t.children[c],p={},m=a?a[c]:void 0;m&&(p.align=m);let g={type:"element",tagName:i,properties:p,children:[]};u&&(g.children=e.all(u),e.patch(u,g),g=e.applyData(u,g)),d.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,f),e.applyData(t,f)}function g9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const AN=9,IN=32;function y9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(TN(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(TN(t.slice(s),s>0,!1)),i.join("")}function TN(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===AN||i===IN;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===AN||i===IN;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function x9(e,t){const n={type:"text",value:y9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function w9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const b9={blockquote:G6,break:X6,code:J6,delete:Q6,emphasis:Z6,footnoteReference:e9,heading:t9,html:n9,imageReference:r9,image:s9,inlineCode:i9,linkReference:o9,link:a9,listItem:l9,list:u9,paragraph:d9,root:f9,strong:p9,table:h9,tableCell:g9,tableRow:m9,text:x9,thematicBreak:w9,toml:fh,yaml:fh,definition:fh,footnoteDefinition:fh};function fh(){}const lI=-1,Dg=0,tf=1,Om=2,Qv=3,Zv=4,e0=5,t0=6,cI=7,uI=8,RN=typeof self=="object"?self:globalThis,v9=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,a]=t[s];switch(i){case Dg:case lI:return n(a,s);case tf:{const l=n([],s);for(const c of a)l.push(r(c));return l}case Om:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case Qv:return n(new Date(a),s);case Zv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case e0:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case t0:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case cI:{const{name:l,message:c}=a;return n(new RN[l](c),s)}case uI: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 RN[i](a),s)};return r},LN=e=>v9(new Map,e)(0),Tc="",{toString:k9}={},{keys:S9}=Object,Sd=e=>{const t=typeof e;if(t!=="object"||!e)return[Dg,t];const n=k9.call(e).slice(8,-1);switch(n){case"Array":return[tf,Tc];case"Object":return[Om,Tc];case"Date":return[Qv,Tc];case"RegExp":return[Zv,Tc];case"Map":return[e0,Tc];case"Set":return[t0,Tc];case"DataView":return[tf,n]}return n.includes("Array")?[tf,n]:n.includes("Error")?[cI,n]:[Om,n]},ph=([e,t])=>e===Dg&&(t==="function"||t==="symbol"),N9=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},i=a=>{if(n.has(a))return n.get(a);let[l,c]=Sd(a);switch(l){case Dg:{let f=a;switch(c){case"bigint":l=uI,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return s([lI],a)}return s([l,f],a)}case tf:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const f=[],u=s([l,f],a);for(const p of a)f.push(i(p));return u}case Om:{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 i(a.toJSON());const f=[],u=s([l,f],a);for(const p of S9(a))(e||!ph(Sd(a[p])))&&f.push([i(p),i(a[p])]);return u}case Qv:return s([l,a.toISOString()],a);case Zv:{const{source:f,flags:u}=a;return s([l,{source:f,flags:u}],a)}case e0:{const f=[],u=s([l,f],a);for(const[p,m]of a)(e||!(ph(Sd(p))||ph(Sd(m))))&&f.push([i(p),i(m)]);return u}case t0:{const f=[],u=s([l,f],a);for(const p of a)(e||!ph(Sd(p)))&&f.push(i(p));return u}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return i},ON=(e,{json:t,lossy:n}={})=>{const r=[];return N9(!(t||n),!!t,new Map,r)(e),r},Mm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?LN(ON(e,t)):structuredClone(e):(e,t)=>LN(ON(e,t));function j9(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 C9(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function E9(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||j9,r=e.options.footnoteBackLabel||C9,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[c]);if(!d)continue;const f=e.all(d),u=String(d.identifier).toUpperCase(),p=zu(u.toLowerCase());let m=0;const g=[],b=e.footnoteCounts.get(u);for(;b!==void 0&&++m<=b;){g.length>0&&g.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,m);typeof k=="string"&&(k={type:"text",value:k}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,m),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const v=f[f.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const k=v.children[v.children.length-1];k&&k.type==="text"?k.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...g)}else f.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(d,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Mm(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 dI=function(e){if(e==null)return I9;if(typeof e=="function")return Fg(e);if(typeof e=="object")return Array.isArray(e)?_9(e):P9(e);if(typeof e=="string")return A9(e);throw new Error("Expected function, string, or object as test")};function _9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=dI(e[n]);return Fg(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function P9(e){const t=e;return Fg(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function A9(e){return Fg(t);function t(n){return n&&n.type===e}}function Fg(e){return t;function t(n,r,s){return!!(T9(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function I9(){return!0}function T9(e){return e!==null&&typeof e=="object"&&"type"in e}const fI=[],R9=!0,MN=!1,L9="skip";function O9(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=dI(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,f){const u=c&&typeof c=="object"?c:{};if(typeof u.type=="string"){const m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=fI,g,b,v;if((!t||i(c,d,f[f.length-1]||void 0))&&(m=M9(n(c,f)),m[0]===MN))return m;if("children"in c&&c.children){const y=c;if(y.children&&m[0]!==L9)for(b=(r?y.children.length:-1)+a,v=f.concat(y);b>-1&&b<y.children.length;){const k=y.children[b];if(g=l(k,b,v)(),g[0]===MN)return g;b=typeof g[1]=="number"?g[1]:b+a}}return m}}}function M9(e){return Array.isArray(e)?e:typeof e=="number"?[R9,e]:e==null?fI:[e]}function pI(e,t,n,r){let s,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,s=n):(i=t,a=n,s=r),O9(e,i,l,s);function l(c,d){const f=d[d.length-1],u=f?f.children.indexOf(c):void 0;return a(c,u,f)}}const nb={}.hasOwnProperty,$9={};function D9(e,t){const n=t||$9,r=new Map,s=new Map,i=new Map,a={...b9,...n.handlers},l={all:d,applyData:z9,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:F9,wrap:H9};return pI(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const u=f.type==="definition"?r:s,p=String(f.identifier).toUpperCase();u.has(p)||u.set(p,f)}}),l;function c(f,u){const p=f.type,m=l.handlers[p];if(nb.call(l.handlers,p)&&m)return m(l,f,u);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in f){const{children:b,...v}=f,y=Mm(v);return y.children=l.all(f),y}return Mm(f)}return(l.options.unknownHandler||B9)(l,f,u)}function d(f){const u=[];if("children"in f){const p=f.children;let m=-1;for(;++m<p.length;){const g=l.one(p[m],f);if(g){if(m&&p[m-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=$N(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=$N(b.value))}Array.isArray(g)?u.push(...g):u.push(g)}}}return u}}function F9(e,t){e.position&&(t.position=kH(e))}function z9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=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"&&i&&Object.assign(n.properties,Mm(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function B9(e,t){const n=t.data||{},r="value"in t&&!(nb.call(n,"hProperties")||nb.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 H9(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
76
+ `});++r<e.length;)r&&n.push({type:"text",value:`
77
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
78
+ `}),n}function $N(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function DN(e,t){const n=D9(e,t),r=n.one(e,void 0),s=E9(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
79
+ `},s),i}function W9(e,t){return e&&"run"in e?async function(n,r){const s=DN(n,{file:r,...t});await e.run(s,r)}:function(n,r){return DN(n,{file:r,...e||t})}}function FN(e){if(e)throw e}var Kh=Object.prototype.hasOwnProperty,hI=Object.prototype.toString,zN=Object.defineProperty,BN=Object.getOwnPropertyDescriptor,HN=function(t){return typeof Array.isArray=="function"?Array.isArray(t):hI.call(t)==="[object Array]"},WN=function(t){if(!t||hI.call(t)!=="[object Object]")return!1;var n=Kh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Kh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Kh.call(t,s)},VN=function(t,n){zN&&n.name==="__proto__"?zN(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},UN=function(t,n){if(n==="__proto__")if(Kh.call(t,n)){if(BN)return BN(t,n).value}else return;return t[n]},V9=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,d=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<d;++c)if(t=arguments[c],t!=null)for(n in t)r=UN(l,n),s=UN(t,n),l!==s&&(f&&s&&(WN(s)||(i=HN(s)))?(i?(i=!1,a=r&&HN(r)?r:[]):a=r&&WN(r)?r:{},VN(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&VN(l,{name:n,newValue:s}));return l};const tx=sl(V9);function rb(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 U9(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-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,...d){const f=e[++i];let u=-1;if(c){a(c);return}for(;++u<s.length;)(d[u]===null||d[u]===void 0)&&(d[u]=s[u]);s=d,f?K9(f,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function K9(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(d){const f=d;if(l&&n)throw f;return s(f)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...l){n||(n=!0,t(a,...l))}function i(a){s(null,a)}}const oo={basename:q9,dirname:Y9,extname:G9,join:X9,sep:"/"};function q9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ip(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!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(i){n=s+1;break}}else a<0&&(i=!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 Y9(e){if(ip(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 G9(e){ip(e);let t=e.length,n=-1,r=0,s=-1,i=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:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function X9(...e){let t=-1,n;for(;++t<e.length;)ip(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":J9(n)}function J9(e){ip(e);const t=e.codePointAt(0)===47;let n=Q9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function Q9(e,t){let n="",r=0,s=-1,i=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||i===1))if(s!==a-1&&i===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,i=0;continue}}else if(n.length>0){n="",r=0,s=a,i=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,i=0}else l===46&&i>-1?i++:i=-1}return n}function ip(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Z9={cwd:eW};function eW(){return"/"}function sb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function tW(e){if(typeof e=="string")e=new URL(e);else if(!sb(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 nW(e)}function nW(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 nx=["history","path","basename","stem","extname","dirname"];class mI{constructor(t){let n;t?sb(t)?n={path:t}:typeof t=="string"||rW(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Z9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<nx.length;){const i=nx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)nx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?oo.basename(this.path):void 0}set basename(t){sx(t,"basename"),rx(t,"basename"),this.path=oo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?oo.dirname(this.path):void 0}set dirname(t){KN(this.basename,"dirname"),this.path=oo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?oo.extname(this.path):void 0}set extname(t){if(rx(t,"extname"),KN(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=oo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){sb(t)&&(t=tW(t)),sx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?oo.basename(this.path,this.extname):void 0}set stem(t){sx(t,"stem"),rx(t,"stem"),this.path=oo.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 Jr(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 rx(e,t){if(e&&e.includes(oo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+oo.sep+"`")}function sx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function KN(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function rW(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const sW=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},iW={}.hasOwnProperty;class n0 extends sW{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=U9()}copy(){const t=new n0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(tx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(ax("data",this.frozen),this.namespace[t]=n,this):iW.call(this.namespace,t)&&this.namespace[t]||void 0:t?(ax("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=hh(t),r=this.parser||this.Parser;return ix("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ix("process",this.parser||this.Parser),ox("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=hh(t),c=r.parse(l);r.run(c,l,function(f,u,p){if(f||!u||!p)return d(f);const m=u,g=r.stringify(m,p);lW(g)?p.value=g:p.result=g,d(f,p)});function d(f,u){f||!u?a(f):i?i(u):n(void 0,u)}}}processSync(t){let n=!1,r;return this.freeze(),ix("processSync",this.parser||this.Parser),ox("processSync",this.compiler||this.Compiler),this.process(t,s),YN("processSync","process",n),r;function s(i,a){n=!0,FN(i),r=a}}run(t,n,r){qN(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const c=hh(n);s.run(t,c,d);function d(f,u,p){const m=u||t;f?l(f):a?a(m):r(void 0,m,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),YN("runSync","run",r),s;function i(a,l){FN(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=hh(n),s=this.compiler||this.Compiler;return ox("stringify",s),qN(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(ax("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 i(d){if(typeof d=="function")c(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[f,...u]=d;c(f,u)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))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(d.plugins),d.settings&&(s.settings=tx(!0,s.settings,d.settings))}function l(d){let f=-1;if(d!=null)if(Array.isArray(d))for(;++f<d.length;){const u=d[f];i(u)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,f){let u=-1,p=-1;for(;++u<r.length;)if(r[u][0]===d){p=u;break}if(p===-1)r.push([d,...f]);else if(f.length>0){let[m,...g]=f;const b=r[p][1];rb(b)&&rb(m)&&(m=tx(!0,b,m)),r[p]=[d,m,...g]}}}}const oW=new n0().freeze();function ix(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ox(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ax(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 qN(e){if(!rb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function YN(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function hh(e){return aW(e)?e:new mI(e)}function aW(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function lW(e){return typeof e=="string"||cW(e)}function cW(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const uW="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",GN=[],XN={allowDangerousHtml:!0},dW=/^(https?|ircs?|mailto|xmpp)$/i,fW=[{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 Bu(e){const t=pW(e),n=hW(e);return mW(t.runSync(t.parse(n),n),e)}function pW(e){const t=e.rehypePlugins||GN,n=e.remarkPlugins||GN,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...XN}:XN;return oW().use(Y6).use(n).use(W9,r).use(t)}function hW(e){const t=e.children||"",n=new mI;return typeof t=="string"&&(n.value=t),n}function mW(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||gW;for(const f of fW)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+uW+f.id,void 0);return pI(e,d),EH(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(f,u,p){if(f.type==="raw"&&p&&typeof u=="number")return a?p.children.splice(u,1):p.children[u]={type:"text",value:f.value},u;if(f.type==="element"){let m;for(m in Qy)if(Object.hasOwn(Qy,m)&&Object.hasOwn(f.properties,m)){const g=f.properties[m],b=Qy[m];(b===null||b.includes(f.tagName))&&(f.properties[m]=c(String(g||""),m,f))}}if(f.type==="element"){let m=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!m&&r&&typeof u=="number"&&(m=!r(f,u,p)),m&&p&&typeof u=="number")return l&&f.children?p.children.splice(u,1,...f.children):p.children.splice(u,1),u}}}function gW(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||dW.test(e.slice(0,t))?e:""}function yW(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function $m(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>$m(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${$m(t[r])}`).join(",")}}`}function JN(e){return $m({id:e.id,type:e.type,position:e.position,data:e.data,parentId:e.parentId,extent:e.extent,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition,hidden:e.hidden})}function Of(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function QN(e){return $m({source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,type:e.type,label:e.label,data:e.data,markerStart:e.markerStart,markerEnd:e.markerEnd,animated:e.animated,hidden:e.hidden,style:e.style})}function ZN(e,t){return!yW(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function ej(e,t=!1){const n=new Map;for(const r of e){const s=Of(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function xW(e,t,n,r){const s=new Map(e.map(k=>[k.id,k])),i=new Set(n.map(k=>k.id)),a=new Set,l=[],c=[],d=n.map(k=>{const w=s.get(k.id);return w?JN(w)===JN(k)?(a.add(k.id),w):(c.push(k.id),ZN(k,w)):(l.push(k.id),k)}),f=ej(t),u=ej(r,!0),p=new Set,m=[],g=[],b=r.map(k=>{const w=Of(k),j=f.get(w);return j?QN(j)===QN(k)?(p.add(w),j):(g.push(w),ZN(k,j)):(m.push(w),k)}),v=e.filter(k=>!i.has(k.id)).map(k=>k.id),y=t.map(k=>Of(k)).filter(k=>!u.has(k));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:v,addedEdgeKeys:m,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:v.length,nodeReused:a.size,edgeAdded:m.length,edgeRemoved:y.length,edgeReused:p.size,nextEdgeCount:u.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function gI(e){return typeof e>"u"||e===null}function wW(e){return typeof e=="object"&&e!==null}function bW(e){return Array.isArray(e)?e:gI(e)?[]:[e]}function vW(e,t){var n,r,s,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)s=i[n],e[s]=t[s];return e}function kW(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function SW(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var NW=gI,jW=wW,CW=bW,EW=kW,_W=SW,PW=vW,br={isNothing:NW,isObject:jW,toArray:CW,repeat:EW,isNegativeZero:_W,extend:PW};function yI(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+=`
80
+
81
+ `+e.mark.snippet),r+" "+n):r}function Mf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=yI(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Mf.prototype=Object.create(Error.prototype);Mf.prototype.constructor=Mf;Mf.prototype.toString=function(t){return this.name+": "+yI(this,t)};var is=Mf;function lx(e,t,n,r,s){var i="",a="",l=Math.floor(s/2)-1;return r-t>l&&(i=" ... ",t=r-l+i.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function cx(e,t){return br.repeat(" ",t-e.length)+e}function AW(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],i,a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,s.length).toString().length,u=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)d=lx(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),u),l=br.repeat(" ",t.indent)+cx((e.line-c+1).toString(),f)+" | "+d.str+`
82
+ `+l;for(d=lx(e.buffer,r[a],s[a],e.position,u),l+=br.repeat(" ",t.indent)+cx((e.line+1).toString(),f)+" | "+d.str+`
83
+ `,l+=br.repeat("-",t.indent+f+3+d.pos)+`^
84
+ `,c=1;c<=t.linesAfter&&!(a+c>=s.length);c++)d=lx(e.buffer,r[a+c],s[a+c],e.position-(r[a]-r[a+c]),u),l+=br.repeat(" ",t.indent)+cx((e.line+c+1).toString(),f)+" | "+d.str+`
85
+ `;return l.replace(/\n$/,"")}var IW=AW,TW=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],RW=["scalar","sequence","mapping"];function LW(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function OW(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(TW.indexOf(n)===-1)throw new is('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=LW(t.styleAliases||null),RW.indexOf(this.kind)===-1)throw new is('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Dr=OW;function tj(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(i,a){i.tag===r.tag&&i.kind===r.kind&&i.multi===r.multi&&(s=a)}),n[s]=r}),n}function MW(){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 ib(e){return this.extend(e)}ib.prototype.extend=function(t){var n=[],r=[];if(t instanceof Dr)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 is("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof Dr))throw new is("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new is("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(i.multi)throw new is("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(i){if(!(i instanceof Dr))throw new is("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(ib.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=tj(s,"implicit"),s.compiledExplicit=tj(s,"explicit"),s.compiledTypeMap=MW(s.compiledImplicit,s.compiledExplicit),s};var xI=ib,wI=new Dr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),bI=new Dr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),vI=new Dr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),kI=new xI({explicit:[wI,bI,vI]});function $W(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function DW(){return null}function FW(e){return e===null}var SI=new Dr("tag:yaml.org,2002:null",{kind:"scalar",resolve:$W,construct:DW,predicate:FW,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function zW(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 BW(e){return e==="true"||e==="True"||e==="TRUE"}function HW(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var NI=new Dr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:zW,construct:BW,predicate:HW,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 WW(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function VW(e){return 48<=e&&e<=55}function UW(e){return 48<=e&&e<=57}function KW(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(!WW(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!VW(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!UW(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function qW(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 YW(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!br.isNegativeZero(e)}var jI=new Dr("tag:yaml.org,2002:int",{kind:"scalar",resolve:KW,construct:qW,predicate:YW,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"]}}),GW=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function XW(e){return!(e===null||!GW.test(e)||e[e.length-1]==="_")}function JW(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 QW=/^[-+]?[0-9]+e/;function ZW(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(br.isNegativeZero(e))return"-0.0";return n=e.toString(10),QW.test(n)?n.replace("e",".e"):n}function eV(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||br.isNegativeZero(e))}var CI=new Dr("tag:yaml.org,2002:float",{kind:"scalar",resolve:XW,construct:JW,predicate:eV,represent:ZW,defaultStyle:"lowercase"}),EI=kI.extend({implicit:[SI,NI,jI,CI]}),_I=EI,PI=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),AI=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 tV(e){return e===null?!1:PI.exec(e)!==null||AI.exec(e)!==null}function nV(e){var t,n,r,s,i,a,l,c=0,d=null,f,u,p;if(t=PI.exec(e),t===null&&(t=AI.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(i=+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]&&(f=+t[10],u=+(t[11]||0),d=(f*60+u)*6e4,t[9]==="-"&&(d=-d)),p=new Date(Date.UTC(n,r,s,i,a,l,c)),d&&p.setTime(p.getTime()-d),p}function rV(e){return e.toISOString()}var II=new Dr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:tV,construct:nV,instanceOf:Date,represent:rV});function sV(e){return e==="<<"||e===null}var TI=new Dr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:sV}),r0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
+ \r`;function iV(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=r0;for(n=0;n<s;n++)if(t=i.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function oV(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=r0,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|i.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 aV(e){var t="",n=0,r,s,i=e.length,a=r0;for(r=0;r<i;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=i%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 lV(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var RI=new Dr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:iV,construct:oV,predicate:lV,represent:aV}),cV=Object.prototype.hasOwnProperty,uV=Object.prototype.toString;function dV(e){if(e===null)return!0;var t=[],n,r,s,i,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,uV.call(s)!=="[object Object]")return!1;for(i in s)if(cV.call(s,i))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(i)===-1)t.push(i);else return!1}return!0}function fV(e){return e!==null?e:[]}var LI=new Dr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dV,construct:fV}),pV=Object.prototype.toString;function hV(e){if(e===null)return!0;var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],pV.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function mV(e){if(e===null)return[];var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),i[t]=[s[0],r[s[0]]];return i}var OI=new Dr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:hV,construct:mV}),gV=Object.prototype.hasOwnProperty;function yV(e){if(e===null)return!0;var t,n=e;for(t in n)if(gV.call(n,t)&&n[t]!==null)return!1;return!0}function xV(e){return e!==null?e:{}}var MI=new Dr("tag:yaml.org,2002:set",{kind:"mapping",resolve:yV,construct:xV}),s0=_I.extend({implicit:[II,TI],explicit:[RI,LI,OI,MI]}),el=Object.prototype.hasOwnProperty,Dm=1,$I=2,DI=3,Fm=4,ux=1,wV=2,nj=3,bV=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,vV=/[\x85\u2028\u2029]/,kV=/[,\[\]\{\}]/,FI=/^(?:!|!!|![a-z\-]+!)$/i,zI=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function rj(e){return Object.prototype.toString.call(e)}function yo(e){return e===10||e===13}function ql(e){return e===9||e===32}function xs(e){return e===9||e===32||e===10||e===13}function eu(e){return e===44||e===91||e===93||e===123||e===125}function SV(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function NV(e){return e===120?2:e===117?4:e===85?8:0}function jV(e){return 48<=e&&e<=57?e-48:-1}function sj(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
87
+ `: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":""}function CV(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function BI(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var HI=new Array(256),WI=new Array(256);for(var Rc=0;Rc<256;Rc++)HI[Rc]=sj(Rc)?1:0,WI[Rc]=sj(Rc);function EV(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||s0,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function VI(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=IW(n),new is(t,n)}function rt(e,t){throw VI(e,t)}function zm(e,t){e.onWarning&&e.onWarning.call(null,VI(e,t))}var ij={YAML:function(t,n,r){var s,i,a;t.version!==null&&rt(t,"duplication of %YAML directive"),r.length!==1&&rt(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&rt(t,"ill-formed argument of the YAML directive"),i=parseInt(s[1],10),a=parseInt(s[2],10),i!==1&&rt(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&zm(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,i;r.length!==2&&rt(t,"TAG directive accepts exactly two arguments"),s=r[0],i=r[1],FI.test(s)||rt(t,"ill-formed tag handle (first argument) of the TAG directive"),el.call(t.tagMap,s)&&rt(t,'there is a previously declared suffix for "'+s+'" tag handle'),zI.test(i)||rt(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{rt(t,"tag prefix is malformed: "+i)}t.tagMap[s]=i}};function Ga(e,t,n,r){var s,i,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,i=l.length;s<i;s+=1)a=l.charCodeAt(s),a===9||32<=a&&a<=1114111||rt(e,"expected valid JSON character");else bV.test(l)&&rt(e,"the stream contains non-printable characters");e.result+=l}}function oj(e,t,n,r){var s,i,a,l;for(br.isObject(n)||rt(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),a=0,l=s.length;a<l;a+=1)i=s[a],el.call(t,i)||(BI(t,i,n[i]),r[i]=!0)}function tu(e,t,n,r,s,i,a,l,c){var d,f;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,f=s.length;d<f;d+=1)Array.isArray(s[d])&&rt(e,"nested arrays are not supported inside keys"),typeof s=="object"&&rj(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&rj(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(i))for(d=0,f=i.length;d<f;d+=1)oj(e,t,i[d],n);else oj(e,t,i,n);else!e.json&&!el.call(n,s)&&el.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,rt(e,"duplicated mapping key")),BI(t,s,i),delete n[s];return t}function i0(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):rt(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function hr(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;ql(s);)s===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),s=e.input.charCodeAt(++e.position);if(t&&s===35)do s=e.input.charCodeAt(++e.position);while(s!==10&&s!==13&&s!==0);if(yo(s))for(i0(e),s=e.input.charCodeAt(e.position),r++,e.lineIndent=0;s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&zm(e,"deficient indentation"),r}function zg(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||xs(n)))}function o0(e,t){t===1?e.result+=" ":t>1&&(e.result+=br.repeat(`
88
+ `,t-1))}function _V(e,t,n){var r,s,i,a,l,c,d,f,u=e.kind,p=e.result,m;if(m=e.input.charCodeAt(e.position),xs(m)||eu(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(s=e.input.charCodeAt(e.position+1),xs(s)||n&&eu(s)))return!1;for(e.kind="scalar",e.result="",i=a=e.position,l=!1;m!==0;){if(m===58){if(s=e.input.charCodeAt(e.position+1),xs(s)||n&&eu(s))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),xs(r))break}else{if(e.position===e.lineStart&&zg(e)||n&&eu(m))break;if(yo(m))if(c=e.line,d=e.lineStart,f=e.lineIndent,hr(e,!1,-1),e.lineIndent>=t){l=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=c,e.lineStart=d,e.lineIndent=f;break}}l&&(Ga(e,i,a,!1),o0(e,e.line-c),i=a=e.position,l=!1),ql(m)||(a=e.position+1),m=e.input.charCodeAt(++e.position)}return Ga(e,i,a,!1),e.result?!0:(e.kind=u,e.result=p,!1)}function PV(e,t){var n,r,s;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=s=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(Ga(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,s=e.position;else return!0;else yo(n)?(Ga(e,r,s,!0),o0(e,hr(e,!1,t)),r=s=e.position):e.position===e.lineStart&&zg(e)?rt(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);rt(e,"unexpected end of the stream within a single quoted scalar")}function AV(e,t){var n,r,s,i,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return Ga(e,n,e.position,!0),e.position++,!0;if(l===92){if(Ga(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),yo(l))hr(e,!1,t);else if(l<256&&HI[l])e.result+=WI[l],e.position++;else if((a=NV(l))>0){for(s=a,i=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=SV(l))>=0?i=(i<<4)+a:rt(e,"expected hexadecimal character");e.result+=CV(i),e.position++}else rt(e,"unknown escape sequence");n=r=e.position}else yo(l)?(Ga(e,n,r,!0),o0(e,hr(e,!1,t)),n=r=e.position):e.position===e.lineStart&&zg(e)?rt(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}rt(e,"unexpected end of the stream within a double quoted scalar")}function IV(e,t){var n=!0,r,s,i,a=e.tag,l,c=e.anchor,d,f,u,p,m,g=Object.create(null),b,v,y,k;if(k=e.input.charCodeAt(e.position),k===91)f=93,m=!1,l=[];else if(k===123)f=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),k=e.input.charCodeAt(++e.position);k!==0;){if(hr(e,!0,t),k=e.input.charCodeAt(e.position),k===f)return e.position++,e.tag=a,e.anchor=c,e.kind=m?"mapping":"sequence",e.result=l,!0;n?k===44&&rt(e,"expected the node content, but found ','"):rt(e,"missed comma between flow collection entries"),v=b=y=null,u=p=!1,k===63&&(d=e.input.charCodeAt(e.position+1),xs(d)&&(u=p=!0,e.position++,hr(e,!0,t))),r=e.line,s=e.lineStart,i=e.position,Iu(e,t,Dm,!1,!0),v=e.tag,b=e.result,hr(e,!0,t),k=e.input.charCodeAt(e.position),(p||e.line===r)&&k===58&&(u=!0,k=e.input.charCodeAt(++e.position),hr(e,!0,t),Iu(e,t,Dm,!1,!0),y=e.result),m?tu(e,l,g,v,b,y,r,s,i):u?l.push(tu(e,null,g,v,b,y,r,s,i)):l.push(b),hr(e,!0,t),k=e.input.charCodeAt(e.position),k===44?(n=!0,k=e.input.charCodeAt(++e.position)):n=!1}rt(e,"unexpected end of the stream within a flow collection")}function TV(e,t){var n,r,s=ux,i=!1,a=!1,l=t,c=0,d=!1,f,u;if(u=e.input.charCodeAt(e.position),u===124)r=!1;else if(u===62)r=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)ux===s?s=u===43?nj:wV:rt(e,"repeat of a chomping mode identifier");else if((f=jV(u))>=0)f===0?rt(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?rt(e,"repeat of an indentation width identifier"):(l=t+f-1,a=!0);else break;if(ql(u)){do u=e.input.charCodeAt(++e.position);while(ql(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!yo(u)&&u!==0)}for(;u!==0;){for(i0(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),yo(u)){c++;continue}if(e.lineIndent<l){s===nj?e.result+=br.repeat(`
89
+ `,i?1+c:c):s===ux&&i&&(e.result+=`
90
+ `);break}for(r?ql(u)?(d=!0,e.result+=br.repeat(`
91
+ `,i?1+c:c)):d?(d=!1,e.result+=br.repeat(`
92
+ `,c+1)):c===0?i&&(e.result+=" "):e.result+=br.repeat(`
93
+ `,c):e.result+=br.repeat(`
94
+ `,i?1+c:c),i=!0,a=!0,c=0,n=e.position;!yo(u)&&u!==0;)u=e.input.charCodeAt(++e.position);Ga(e,n,e.position,!1)}return!0}function aj(e,t){var n,r=e.tag,s=e.anchor,i=[],a,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=i),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,rt(e,"tab characters must not be used in indentation")),!(c!==45||(a=e.input.charCodeAt(e.position+1),!xs(a))));){if(l=!0,e.position++,hr(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Iu(e,t,DI,!1,!0),i.push(e.result),hr(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)rt(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=i,!0):!1}function RV(e,t,n){var r,s,i,a,l,c,d=e.tag,f=e.anchor,u={},p=Object.create(null),m=null,g=null,b=null,v=!1,y=!1,k;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),k=e.input.charCodeAt(e.position);k!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,rt(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),i=e.line,(k===63||k===58)&&xs(r))k===63?(v&&(tu(e,u,p,m,g,null,a,l,c),m=g=b=null),y=!0,v=!0,s=!0):v?(v=!1,s=!0):rt(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,k=r;else{if(a=e.line,l=e.lineStart,c=e.position,!Iu(e,n,$I,!1,!0))break;if(e.line===i){for(k=e.input.charCodeAt(e.position);ql(k);)k=e.input.charCodeAt(++e.position);if(k===58)k=e.input.charCodeAt(++e.position),xs(k)||rt(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(tu(e,u,p,m,g,null,a,l,c),m=g=b=null),y=!0,v=!1,s=!1,m=e.tag,g=e.result;else if(y)rt(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(y)rt(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===i||e.lineIndent>t)&&(v&&(a=e.line,l=e.lineStart,c=e.position),Iu(e,t,Fm,!0,s)&&(v?g=e.result:b=e.result),v||(tu(e,u,p,m,g,b,a,l,c),m=g=b=null),hr(e,!0,-1),k=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&k!==0)rt(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&tu(e,u,p,m,g,null,a,l,c),y&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=u),y}function LV(e){var t,n=!1,r=!1,s,i,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&rt(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,s="!!",a=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):rt(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!xs(a);)a===33&&(r?rt(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),FI.test(s)||rt(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),kV.test(i)&&rt(e,"tag suffix cannot contain flow indicator characters")}i&&!zI.test(i)&&rt(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{rt(e,"tag name is malformed: "+i)}return n?e.tag=i:el.call(e.tagMap,s)?e.tag=e.tagMap[s]+i:s==="!"?e.tag="!"+i:s==="!!"?e.tag="tag:yaml.org,2002:"+i:rt(e,'undeclared tag handle "'+s+'"'),!0}function OV(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&rt(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!xs(n)&&!eu(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&rt(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function MV(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!xs(r)&&!eu(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&rt(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),el.call(e.anchorMap,n)||rt(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],hr(e,!0,-1),!0}function Iu(e,t,n,r,s){var i,a,l,c=1,d=!1,f=!1,u,p,m,g,b,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=a=l=Fm===n||DI===n,r&&hr(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;LV(e)||OV(e);)hr(e,!0,-1)?(d=!0,l=i,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||s),(c===1||Fm===n)&&(Dm===n||$I===n?b=t:b=t+1,v=e.position-e.lineStart,c===1?l&&(aj(e,v)||RV(e,v,b))||IV(e,b)?f=!0:(a&&TV(e,b)||PV(e,b)||AV(e,b)?f=!0:MV(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&rt(e,"alias node should not have any properties")):_V(e,b,Dm===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&aj(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&rt(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,p=e.implicitTypes.length;u<p;u+=1)if(g=e.implicitTypes[u],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(el.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,m=e.typeMap.multi[e.kind||"fallback"],u=0,p=m.length;u<p;u+=1)if(e.tag.slice(0,m[u].tag.length)===m[u].tag){g=m[u];break}g||rt(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&rt(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):rt(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function $V(e){var t=e.position,n,r,s,i=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(hr(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(i=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!xs(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&rt(e,"directive name must not be less than one character in length");a!==0;){for(;ql(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!yo(a));break}if(yo(a))break;for(n=e.position;a!==0&&!xs(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&i0(e),el.call(ij,r)?ij[r](e,r,s):zm(e,'unknown document directive "'+r+'"')}if(hr(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,hr(e,!0,-1)):i&&rt(e,"directives end mark is expected"),Iu(e,e.lineIndent-1,Fm,!1,!0),hr(e,!0,-1),e.checkLineBreaks&&vV.test(e.input.slice(t,e.position))&&zm(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&zg(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,hr(e,!0,-1));return}if(e.position<e.length-1)rt(e,"end of the stream or a document separator is expected");else return}function UI(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
95
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new EV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,rt(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)$V(n);return n.documents}function DV(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=UI(e,n);if(typeof t!="function")return r;for(var s=0,i=r.length;s<i;s+=1)t(r[s])}function FV(e,t){var n=UI(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new is("expected a single document in the stream, but found more")}}var zV=DV,BV=FV,KI={loadAll:zV,load:BV},qI=Object.prototype.toString,YI=Object.prototype.hasOwnProperty,a0=65279,HV=9,$f=10,WV=13,VV=32,UV=33,KV=34,ob=35,qV=37,YV=38,GV=39,XV=42,GI=44,JV=45,Bm=58,QV=61,ZV=62,eU=63,tU=64,XI=91,JI=93,nU=96,QI=123,rU=124,ZI=125,Qr={};Qr[0]="\\0";Qr[7]="\\a";Qr[8]="\\b";Qr[9]="\\t";Qr[10]="\\n";Qr[11]="\\v";Qr[12]="\\f";Qr[13]="\\r";Qr[27]="\\e";Qr[34]='\\"';Qr[92]="\\\\";Qr[133]="\\N";Qr[160]="\\_";Qr[8232]="\\L";Qr[8233]="\\P";var sU=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],iU=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function oU(e,t){var n,r,s,i,a,l,c;if(t===null)return{};for(n={},r=Object.keys(t),s=0,i=r.length;s<i;s+=1)a=r[s],l=String(t[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),c=e.compiledTypeMap.fallback[a],c&&YI.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}function aU(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new is("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+br.repeat("0",r-t.length)+t}var lU=1,Df=2;function cU(e){this.schema=e.schema||s0,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=br.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=oU(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?Df:lU,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function lj(e,t){for(var n=br.repeat(" ",t),r=0,s=-1,i="",a,l=e.length;r<l;)s=e.indexOf(`
96
+ `,r),s===-1?(a=e.slice(r),r=l):(a=e.slice(r,s+1),r=s+1),a.length&&a!==`
97
+ `&&(i+=n),i+=a;return i}function ab(e,t){return`
98
+ `+br.repeat(" ",e.indent*t)}function uU(e,t){var n,r,s;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(s=e.implicitTypes[n],s.resolve(t))return!0;return!1}function Hm(e){return e===VV||e===HV}function Ff(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==a0||65536<=e&&e<=1114111}function cj(e){return Ff(e)&&e!==a0&&e!==WV&&e!==$f}function uj(e,t,n){var r=cj(e),s=r&&!Hm(e);return(n?r:r&&e!==GI&&e!==XI&&e!==JI&&e!==QI&&e!==ZI)&&e!==ob&&!(t===Bm&&!s)||cj(t)&&!Hm(t)&&e===ob||t===Bm&&s}function dU(e){return Ff(e)&&e!==a0&&!Hm(e)&&e!==JV&&e!==eU&&e!==Bm&&e!==GI&&e!==XI&&e!==JI&&e!==QI&&e!==ZI&&e!==ob&&e!==YV&&e!==XV&&e!==UV&&e!==rU&&e!==QV&&e!==ZV&&e!==GV&&e!==KV&&e!==qV&&e!==tU&&e!==nU}function fU(e){return!Hm(e)&&e!==Bm}function Od(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function eT(e){var t=/^\n* /;return t.test(e)}var tT=1,lb=2,nT=3,rT=4,$c=5;function pU(e,t,n,r,s,i,a,l){var c,d=0,f=null,u=!1,p=!1,m=r!==-1,g=-1,b=dU(Od(e,0))&&fU(Od(e,e.length-1));if(t||a)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Od(e,c),!Ff(d))return $c;b=b&&uj(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Od(e,c),d===$f)u=!0,m&&(p=p||c-g-1>r&&e[g+1]!==" ",g=c);else if(!Ff(d))return $c;b=b&&uj(d,f,l),f=d}p=p||m&&c-g-1>r&&e[g+1]!==" "}return!u&&!p?b&&!a&&!s(e)?tT:i===Df?$c:lb:n>9&&eT(e)?$c:a?i===Df?$c:lb:p?rT:nT}function hU(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===Df?'""':"''";if(!e.noCompatMode&&(sU.indexOf(t)!==-1||iU.test(t)))return e.quotingType===Df?'"'+t+'"':"'"+t+"'";var i=e.indent*Math.max(1,n),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),l=r||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return uU(e,d)}switch(pU(t,l,e.indent,a,c,e.quotingType,e.forceQuotes&&!r,s)){case tT:return t;case lb:return"'"+t.replace(/'/g,"''")+"'";case nT:return"|"+dj(t,e.indent)+fj(lj(t,i));case rT:return">"+dj(t,e.indent)+fj(lj(mU(t,a),i));case $c:return'"'+gU(t)+'"';default:throw new is("impossible error: invalid scalar style")}}()}function dj(e,t){var n=eT(e)?String(t):"",r=e[e.length-1]===`
99
+ `,s=r&&(e[e.length-2]===`
100
+ `||e===`
101
+ `),i=s?"+":r?"":"-";return n+i+`
102
+ `}function fj(e){return e[e.length-1]===`
103
+ `?e.slice(0,-1):e}function mU(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var d=e.indexOf(`
104
+ `);return d=d!==-1?d:e.length,n.lastIndex=d,pj(e.slice(0,d),t)}(),s=e[0]===`
105
+ `||e[0]===" ",i,a;a=n.exec(e);){var l=a[1],c=a[2];i=c[0]===" ",r+=l+(!s&&!i&&c!==""?`
106
+ `:"")+pj(c,t),s=i}return r}function pj(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,i,a=0,l=0,c="";r=n.exec(e);)l=r.index,l-s>t&&(i=a>s?a:l,c+=`
107
+ `+e.slice(s,i),s=i+1),a=l;return c+=`
108
+ `,e.length-s>t&&a>s?c+=e.slice(s,a)+`
109
+ `+e.slice(a+1):c+=e.slice(s),c.slice(1)}function gU(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Od(e,s),r=Qr[n],!r&&Ff(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||aU(n);return t}function yU(e,t,n){var r="",s=e.tag,i,a,l;for(i=0,a=n.length;i<a;i+=1)l=n[i],e.replacer&&(l=e.replacer.call(n,String(i),l)),(na(e,t,l,!1,!1)||typeof l>"u"&&na(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function hj(e,t,n,r){var s="",i=e.tag,a,l,c;for(a=0,l=n.length;a<l;a+=1)c=n[a],e.replacer&&(c=e.replacer.call(n,String(a),c)),(na(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&na(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=ab(e,t)),e.dump&&$f===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=i,e.dump=s||"[]"}function xU(e,t,n){var r="",s=e.tag,i=Object.keys(n),a,l,c,d,f;for(a=0,l=i.length;a<l;a+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=i[a],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),na(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),na(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=s,e.dump="{"+r+"}"}function wU(e,t,n,r){var s="",i=e.tag,a=Object.keys(n),l,c,d,f,u,p;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new is("sortKeys must be a boolean or a function");for(l=0,c=a.length;l<c;l+=1)p="",(!r||s!=="")&&(p+=ab(e,t)),d=a[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),na(e,t+1,d,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&$f===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,u&&(p+=ab(e,t)),na(e,t+1,f,!0,u)&&(e.dump&&$f===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=i,e.dump=s||"{}"}function mj(e,t,n){var r,s,i,a,l,c;for(s=n?e.explicitTypes:e.implicitTypes,i=0,a=s.length;i<a;i+=1)if(l=s[i],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,qI.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(YI.call(l.represent,c))r=l.represent[c](t,c);else throw new is("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function na(e,t,n,r,s,i,a){e.tag=null,e.dump=n,mj(e,n,!1)||mj(e,n,!0);var l=qI.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",u,p;if(f&&(u=e.duplicates.indexOf(n),p=u!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(s=!1),p&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(f&&p&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(wU(e,t,e.dump,s),p&&(e.dump="&ref_"+u+e.dump)):(xU(e,t,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?hj(e,t-1,e.dump,s):hj(e,t,e.dump,s),p&&(e.dump="&ref_"+u+e.dump)):(yU(e,t,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&hU(e,e.dump,t,i,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new is("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function bU(e,t){var n=[],r=[],s,i;for(cb(e,n,r),s=0,i=r.length;s<i;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(i)}function cb(e,t,n){var r,s,i;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,i=e.length;s<i;s+=1)cb(e[s],t,n);else for(r=Object.keys(e),s=0,i=r.length;s<i;s+=1)cb(e[r[s]],t,n)}function vU(e,t){t=t||{};var n=new cU(t);n.noRefs||bU(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),na(n,0,r,!0,!0)?n.dump+`
110
+ `:""}var kU=vU,SU={dump:kU};function l0(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var NU=Dr,jU=xI,CU=kI,EU=EI,_U=_I,PU=s0,AU=KI.load,IU=KI.loadAll,TU=SU.dump,RU=is,LU={binary:RI,float:CI,map:vI,null:SI,pairs:OI,set:MI,timestamp:II,bool:NI,int:jI,merge:TI,omap:LI,seq:bI,str:wI},OU=l0("safeLoad","load"),MU=l0("safeLoadAll","loadAll"),$U=l0("safeDump","dump"),sT={Type:NU,Schema:jU,FAILSAFE_SCHEMA:CU,JSON_SCHEMA:EU,CORE_SCHEMA:_U,DEFAULT_SCHEMA:PU,load:AU,loadAll:IU,dump:TU,YAMLException:RU,types:LU,safeLoad:OU,safeLoadAll:MU,safeDump:$U};const tl=["requirement","planning","code","test","normal"],ub={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},DU=["agent","control","provide","condition","jump","condition_jump","start","end"];function FU(e){return DU.includes(e)?e:"agent"}function zU(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function BU(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=sT.load(e);if(!n||typeof n!="object")return{error:"flow.yaml 格式无效:根内容不是对象"};const r=n,s=r.instances&&typeof r.instances=="object"?r.instances:{},i=Array.isArray(r.edges)?r.edges:Array.isArray((t=r.flow)==null?void 0:t.edges)?r.flow.edges:[],a=r.ui&&typeof r.ui=="object"?r.ui:{},l=a.nodePositions&&typeof a.nodePositions=="object"?a.nodePositions:{},c=a.nodeSizes&&typeof a.nodeSizes=="object"?a.nodeSizes:{},d=a.viewport&&typeof a.viewport=="object"?a.viewport:null,f=d&&Number.isFinite(Number(d.x))&&Number.isFinite(Number(d.y))&&Number.isFinite(Number(d.zoom))?{x:Number(d.x),y:Number(d.y),zoom:Math.min(Math.max(Number(d.zoom),.1),4)}:void 0,u=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,p=new Set(Object.keys(s));for(const b of i)b!=null&&b.source&&p.add(String(b.source)),b!=null&&b.target&&p.add(String(b.target));const m=Array.from(p).map(b=>{const v=s[b],y=l[b]&&typeof l[b].x=="number"&&typeof l[b].y=="number"?{x:l[b].x,y:l[b].y}:{x:0,y:0},k=c[b]&&typeof c[b].width=="number"&&typeof c[b].height=="number"?{width:c[b].width,height:c[b].height}:null,w=(v==null?void 0:v.definitionId)??b,j=zU(w),A=(v==null?void 0:v.label)!=null?String(v.label):b,C=(v==null?void 0:v.role)!=null?String(v.role).trim():"",$=ub[C]||C,B=tl.includes($)?$:"normal",F=(v==null?void 0:v.model)!=null?String(v.model).trim():void 0,z=(v==null?void 0:v.body)!=null?String(v.body):"",L=(v==null?void 0:v.script)!=null?String(v.script):"",O=Array.isArray(v==null?void 0:v.images)?v.images:[];return{id:b,type:FU(j),position:y,...k?{width:k.width,height:k.height}:{},data:{label:A,definitionId:w,schemaType:j,role:B,model:F||void 0,body:z,images:O,...k?{displaySize:k}:{},...L.trim()!==""?{script:L}:{}}}}),g=i.filter(b=>(b==null?void 0:b.source)&&(b==null?void 0:b.target)).map((b,v)=>({id:`e-${b.source}-${b.target}-${v}`,source:String(b.source),target:String(b.target),sourceHandle:b.sourceHandle??void 0,targetHandle:b.targetHandle??void 0,markerEnd:{type:Ns.ArrowClosed}}));return{nodes:m,edges:g,instances:s,description:u,...f?{viewport:f}:{}}}catch(n){const r=n instanceof Error?n.message:String(n);let s="";if(/bad indentation of a mapping entry|expected.*scalar|mapping values are not allowed/i.test(r)){const i=r.match(/\((\d+):/);s=`
111
+
112
+ 💡 提示:通常由 ${i?`第 ${i[1]} 行附近`:""}的 \`script\` / \`body\` / \`value\` 字段裸写命令字符串引起。
113
+ YAML 中含 \`: \`、\`"\`、\`'\` 等特殊字符的多行字符串必须使用 \`|\` 块标量。
114
+
115
+ ✅ 正确写法:
116
+ \`\`\`yaml
117
+ script: |
118
+ node -e "console.log('TODO: scripts/x.mjs')"
119
+ \`\`\`
120
+ ❌ 错误写法(当前文件):
121
+ \`\`\`yaml
122
+ script: node -e "console.log('TODO: scripts/x.mjs')"
123
+ \`\`\``}return{error:`flow.yaml 解析失败:${r}${s}`}}}function op(e,t){var s,i,a,l,c,d,f,u,p,m,g,b;const n=v=>{const y={type:(v==null?void 0:v.type)??"node",name:(v==null?void 0:v.name)??"",value:(v==null?void 0:v.value)??(v==null?void 0:v.default)??""};return(v==null?void 0:v.required)===!0&&(y.required=!0),(v==null?void 0:v.showOnNode)!=null&&(y.showOnNode=!!v.showOnNode),y},r={};for(const v of e){const y=t[v.id]&&typeof t[v.id]=="object"?{...t[v.id]}:{},k=((s=v.data)==null?void 0:s.definitionId)||v.id,w=((i=v.data)==null?void 0:i.inputs)??[],j=((a=v.data)==null?void 0:a.outputs)??[],A=((l=v.data)==null?void 0:l.role)!=null?String(v.data.role).trim():"",C=y.role!=null?String(y.role).trim():"",$=ub[A]||A,B=ub[C]||C,F=tl.includes($)?$:tl.includes(B)?B:"normal",z=Array.isArray(w)?w.map(n):Array.isArray(y.input)?y.input.map(V=>n(V)):[],L=Array.isArray(j)?j.map(n):Array.isArray(y.output)?y.output.map(V=>n(V)):[],O=((c=v.data)==null?void 0:c.label)!=null?String(v.data.label):y.label!=null?String(y.label):v.id,W=(d=v.data)==null?void 0:d.body,M=W!=null?String(W):y.body!=null?String(y.body):"";let T=((f=v.data)==null?void 0:f.model)!=null&&String(v.data.model).trim()!==""?String(v.data.model).trim():y.model!=null&&String(y.model).trim()!==""?String(y.model).trim():void 0;(T===""||T==="default")&&(T=void 0);const E={...y,definitionId:k,label:O,role:F,model:T,input:z,output:L},D=((u=v.data)==null?void 0:u.marketplaceRef)||y.marketplaceRef;D?E.marketplaceRef=String(D):delete E.marketplaceRef;const _=((p=v.data)==null?void 0:p.marketplacePackageId)||y.marketplacePackageId;_?E.marketplacePackageId=String(_):delete E.marketplacePackageId;const R=((m=v.data)==null?void 0:m.marketplaceVersion)||y.marketplaceVersion;R?E.marketplaceVersion=String(R):delete E.marketplaceVersion,k.startsWith("provide_")||M.trim()===""?delete E.body:E.body=M;const P=Array.isArray((g=v.data)==null?void 0:g.images)?v.data.images:Array.isArray(y.images)?y.images:[];P.length>0?E.images=P:delete E.images;const G=(b=v.data)==null?void 0:b.script,Z=G!=null?String(G):y.script!=null?String(y.script):"";Z.trim()===""?delete E.script:E.script=Z,delete E.temperature,delete E.maxTokens,delete E.description,r[v.id]=E}return r}function nf(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function HU(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 iT(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)),i=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>nf(a)),edges:i.map(a=>nf(a)),instances:op(r,n||{})}}function oT(e,t,n,r,s={}){var u;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const i=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,HU(p.id,a));const c=e.nodes.map(p=>{var g,b;const m=l.get(p.id);return{...nf(p),id:m,selected:!0,dragging:!1,position:{x:Number(((g=p.position)==null?void 0:g.x)||0)+i.x,y:Number(((b=p.position)==null?void 0:b.y)||0)+i.y}}}),d=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,m)=>{const g=l.get(p.source),b=l.get(p.target);return{...nf(p),id:`e-${g}-${b}-${Date.now()}-${m}`,source:g,target:b,selected:!1}}),f={...r||{}};for(const[p,m]of l.entries()){const g=(u=e.instances)==null?void 0:u[p];g&&(f[m]={...nf(g),label:g.label!=null?String(g.label):m})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...d],instances:f,pastedNodeIds:c.map(p=>p.id)}}function gj(e,t,n,r){var f,u,p,m;const s=op(e,n),i=t.map(g=>({source:g.source,target:g.target,sourceHandle:g.sourceHandle??null,targetHandle:g.targetHandle??null})),a={},l={};for(const g of e){const b=g.position??{x:0,y:0};a[g.id]={x:b.x,y:b.y};const v=Number(((u=(f=g.data)==null?void 0:f.displaySize)==null?void 0:u.width)||g.width||0),y=Number(((m=(p=g.data)==null?void 0:p.displaySize)==null?void 0:m.height)||g.height||0);v>0&&y>0&&(l[g.id]={width:Math.round(v),height:Math.round(y)})}const c={nodePositions:a};Object.keys(l).length>0&&(c.nodeSizes=l),r!=null&&r.viewport&&Number.isFinite(Number(r.viewport.x))&&Number.isFinite(Number(r.viewport.y))&&Number.isFinite(Number(r.viewport.zoom))&&(c.viewport={x:Number(r.viewport.x),y:Number(r.viewport.y),zoom:Math.min(Math.max(Number(r.viewport.zoom),.1),4)}),(r==null?void 0:r.description)!=null&&String(r.description).trim()!==""&&(c.description=String(r.description).trim());const d={instances:s,edges:i,ui:c};return sT.dump(d,{lineWidth:-1})}function WU(e){var s,i;const t={inputNames:[],outputNames:[]},n=Array.isArray((s=e.data)==null?void 0:s.inputs)?e.data.inputs:[],r=Array.isArray((i=e.data)==null?void 0:i.outputs)?e.data.outputs:[];for(let a=0;a<n.length;a++){const l=n[a],c=(l&&l.name!=null?String(l.name).trim():"")||`input-${a}`;t.inputNames.push(c)}for(let a=0;a<r.length;a++){const l=r[a],c=(l&&l.name!=null?String(l.name).trim():"")||`output-${a}`;t.outputNames.push(c)}return t}function VU(e,t,n){var c,d,f;const r=new Set(e.map(u=>u.id)),s={};for(const u of e)s[u.id]=WU(u);const i=new Map,a=new Map;for(const u of t)u.target&&r.has(u.target)&&(i.has(u.target)||i.set(u.target,new Set),u.targetHandle&&i.get(u.target).add(u.targetHandle)),u.source&&r.has(u.source)&&(a.has(u.source)||a.set(u.source,new Set),u.sourceHandle&&a.get(u.source).add(u.sourceHandle));const l=[];for(const u of e){const p=((c=u.data)==null?void 0:c.definitionId)!=null?String(u.data.definitionId):"",m=s[u.id]||{inputNames:[],outputNames:[]},g=m.inputNames.length,b=m.outputNames.length;if(!(p==="control_start"||p.startsWith("provide_"))&&g>0)for(let k=0;k<g;k++){const w=`input-${k}`;if(!((d=i.get(u.id))==null?void 0:d.has(w))){const A=m.inputNames[k]||w;l.push({nodeId:u.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:A,handle:w}),key:`${u.id}-${w}-in`})}}if(!(p==="control_end")&&b>0)for(let k=0;k<b;k++){const w=`output-${k}`;if(!((f=a.get(u.id))==null?void 0:f.has(w))){const A=m.outputNames[k]||w;l.push({nodeId:u.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:A,handle:w}),key:`${u.id}-${w}-out`})}}}return l}const Wm=/\[image\s+(\d+)\]/gi;function ws(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 UU(e){return`image ${ws(e).length+1}`}function KU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function qU(e,t){const n=ws(e),r=String(t||""),s=new Set;Wm.lastIndex=0;let i;for(;i=Wm.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function YU(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 aT(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 Vm(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 lT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=ws(n);for(const a of r){const l=await YU(a),c=UU(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=KU(s,c)}return{body:s,images:i}}function db(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),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const GU={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"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],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_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_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function XU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(GU[e]||[]).includes(s)?r:s}const JU={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"])},QU={control_cd_workspace:new Set(["mode","label","cwd","previous"]),control_user_workspace:new Set(["cwd"]),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"])},ZU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_image","display_chart","display_table"]);function eK(e,t){if(!ZU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function tK(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function nK(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();if(!n)return t;const r=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(r.entry||r.command)&&n==="tool_nodejs"?t:n}function yj(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,f;const i=n[s],l=n.find(u=>(u==null?void 0:u.name)&&u.name===r.name)||i;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((d=JU[e])==null?void 0:d.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...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&&eK(e,r)?{showOnNode:!0}:{},...(f=QU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function cT(e){var s,i;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((i=e==null?void 0:e.data)==null?void 0:i.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=db(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function zf(e,t,n,r,s){var D,_,R,P,G,Z,V,se,ue,fe,ge,ae,ve,_e,we,Ee,Ae,st,ut,et,Ct;const i=((D=e.data)==null?void 0:D.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Ue=>Ue.id===i),l=t[e.id];let c=[],d=[],f=((_=e.data)==null?void 0:_.label)??e.id,u,p,m,g,b;const v=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(db)),Array.isArray(l.output)&&(d=l.output.map(db)),l.label&&(f=String(l.label)),l.role&&typeof l.role=="string"&&(u=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(m=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(b=String(l.script)));const y=u??(typeof((R=e.data)==null?void 0:R.role)=="string"?e.data.role:"普通"),k=p??((P=e.data)==null?void 0:P.model)??void 0,w=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=w!==""?w:void 0,A=m??((G=e.data)==null?void 0:G.body)??"",C=Array.isArray(g)?g:Array.isArray((Z=e.data)==null?void 0:Z.images)?e.data.images:[],$=b!==void 0?b:((V=e.data)==null?void 0:V.script)!=null?String(e.data.script):"",B=String(e.id),F=(se=r==null?void 0:r[s])==null?void 0:se[B],z=(ue=F==null?void 0:F.label)==null?void 0:ue.label,L=F==null?void 0:F.body,O=F==null?void 0:F.description;v||(c.length===0&&((fe=a==null?void 0:a.inputs)!=null&&fe.length)&&(c=a.inputs.map(Ue=>({...Ue}))),d.length===0&&((ge=a==null?void 0:a.outputs)!=null&&ge.length)&&(d=a.outputs.map(Ue=>({...Ue}))));const W=nK(a,(a==null?void 0:a.id)??i),M=(l==null?void 0:l.marketplaceRef)||((ae=e.data)==null?void 0:ae.marketplaceRef)||tK(a);if(W==="agent_subAgent"&&!d.some(Ue=>(Ue==null?void 0:Ue.name)==="result")){const Ue=(ve=a==null?void 0:a.outputs)==null?void 0:ve.find(St=>(St==null?void 0:St.name)==="result");d=[...d,Ue?{...Ue}:{type:"text",name:"result",default:""}]}if((W==="display_markdown"||W==="display_mermaid"||W==="display_ascii"||W==="display_chart"||W==="display_table")&&!d.some(Ue=>(Ue==null?void 0:Ue.name)==="next")){const Ue=(_e=a==null?void 0:a.outputs)==null?void 0:_e.find(St=>(St==null?void 0:St.name)==="next");d=[...d,Ue?{...Ue}:{type:"node",name:"next",default:""}]}if(W==="workspace_run"){if(!c.some(Ue=>(Ue==null?void 0:Ue.name)==="prev")){const Ue=(we=a==null?void 0:a.inputs)==null?void 0:we.find(St=>(St==null?void 0:St.name)==="prev");c=[Ue?{...Ue}:{type:"node",name:"prev",default:""},...c]}if(!d.some(Ue=>(Ue==null?void 0:Ue.name)==="next")){const Ue=(Ee=a==null?void 0:a.outputs)==null?void 0:Ee.find(St=>(St==null?void 0:St.name)==="next");d=[...d,Ue?{...Ue}:{type:"node",name:"next",default:""}]}}c=yj(W,c,a==null?void 0:a.inputs),d=yj(W,d,a==null?void 0:a.outputs),W.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(A).trim()!==""&&(d=d.map((Ue,St)=>St===0?{...Ue,default:A,value:A}:Ue));const T=XU(W,z||f,a),E=W==="tool_nodejs"||String($).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:z||f,displayLabel:T,definitionDisplayName:a==null?void 0:a.displayName,definitionId:W,...M?{marketplaceRef:M}:{},...l!=null&&l.marketplacePackageId||(Ae=e.data)!=null&&Ae.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((st=e.data)==null?void 0:st.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(ut=e.data)!=null&&ut.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((et=e.data)==null?void 0:et.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((Ct=e.data)==null?void 0:Ct.schemaType)??e.type??"agent",role:y,model:k,body:L||A,images:C,script:$,inputs:c,outputs:d,description:O||j,originalLabel:f,originalBody:A,...E?{script:$}:{}}}}function uT(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var f,u,p,m;const s=n.get(r.source),i=n.get(r.target),a=((u=(f=s==null?void 0:s.data)==null?void 0:f.outputs)==null?void 0:u.length)??0,l=((m=(p=i==null?void 0:i.data)==null?void 0:p.inputs)==null?void 0:m.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,d=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&i&&c>=0&&c<a&&d>=0&&d<l})}function xj(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 wj(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function Um(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=xj(t==null?void 0:t.sourceHandle,"output"),i=xj(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var d,f,u,p;if(c.id===n){const m=wj((d=c.data)==null?void 0:d.outputs,s);if(m!==((f=c.data)==null?void 0:f.outputs))return a=!0,{...c,data:{...c.data,outputs:m}}}if(c.id===r){const m=wj((u=c.data)==null?void 0:u.inputs,i);if(m!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:m}}}return c});return a?l:e}const bj=80,rK=220;function sK(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...c}=e;return c}function iK(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function mh(e,t,n){const r={nodes:Array.isArray(e)?e.map(sK):[],edges:Array.isArray(t)?t.map(iK):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function dx(e,t){const n=[...e,t];return n.length>bj?n.slice(n.length-bj):n}function dT({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=h.useState(0),l=h.useRef([]),c=h.useRef([]),d=h.useRef(null),f=h.useRef(null),u=h.useRef(null),p=h.useRef(null),m=h.useRef(!1),g=h.useCallback(()=>a(A=>A+1),[]),b=h.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),v=h.useCallback(()=>{b();const A=f.current,C=u.current;return f.current=null,u.current=null,!A||!C||A.signature===C.signature?(C&&(d.current=C),!1):(l.current=dx(l.current,A),c.current=[],d.current=C,g(),!0)},[g,b]),y=h.useCallback((A=[],C=[],$={})=>{b(),l.current=[],c.current=[],f.current=null,u.current=null,d.current=mh(A,C,$),m.current=!1,g()},[g,b]),k=h.useCallback(A=>{m.current=!0,d.current=A,f.current=null,u.current=null,b(),s==null||s(A.value),g()},[g,b,s]),w=h.useCallback(()=>{v();const A=d.current||mh(e,t,n),C=l.current.pop();return C?(c.current=dx(c.current,A),k(C),!0):(g(),!1)},[g,t,n,v,e,k]),j=h.useCallback(()=>{v();const A=d.current||mh(e,t,n),C=c.current.pop();return C?(l.current=dx(l.current,A),k(C),!0):(g(),!1)},[g,t,n,v,e,k]);return h.useEffect(()=>()=>b(),[b]),h.useEffect(()=>{if(!r)return;const A=mh(e,t,n);if(!d.current){d.current=A;return}if(m.current){m.current=!1,d.current=A;return}A.signature!==d.current.signature&&(f.current||(f.current=d.current),u.current=A,b(),p.current=window.setTimeout(()=>{v()},rK))},[b,t,r,n,v,e]),{canUndo:l.current.length>0||!!f.current,canRedo:c.current.length>0,resetHistory:y,undo:w,redo:j,version:i}}function Qn(e){switch(Km(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Km(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 oK(e,t){const n=Km(e),r=Km(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const aK=new Set(["workspaceContext","skillsContext","mcpContext"]);function fb(e){const t=Km(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&aK.has(n)?`${t}+${n}`:t}function fT(e){return fb(e)}function Tu(e,t){if(!e||!t||!oK(e.type,t.type))return!1;const n=fb(e),r=fb(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function lK(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 Ru(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=lK(t,n==="source"?"output":"input");return i<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[i]||null}function zo(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function cK(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 uK(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function dK(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function dr(e){e.stopPropagation()}function fK(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pK(e,t){const n=`\\[${fK(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
+ `).replace(/\n{3,}/g,`
125
+
126
+ `).trimEnd()}function fx(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function hK(e){const t=String(e||"");let n="",r=0;Wm.lastIndex=0;let s;for(;s=Wm.exec(t);)n+=fx(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${fx(s[0])}</span>`,r=s.index+s[0].length;return n+=fx(t.slice(r)),n||" "}function mK(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=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,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+i+a+l)}function pT({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var tn,Sn;const{t:f}=vn(),u=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=cK(e),b=uK(g),v=(e==null?void 0:e.isRunMode)??!1,y=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,w=(e==null?void 0:e.isDim)??!1,j=(e==null?void 0:e.nodeStatus)??null,A=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",$=C.startsWith("provide_"),B=C==="provide_bool",F=C==="provide_str",z=C==="provide_file",L=C==="agent_subAgent",O=L&&!v,W=B?dK(p[0]):!1,M=$?String(((tn=p[0])==null?void 0:tn.value)??((Sn=p[0])==null?void 0:Sn.default)??(e==null?void 0:e.body)??""):"",T=String((e==null?void 0:e.body)||""),E=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),D=!$&&!O&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",_=ws(e==null?void 0:e.images),R=h.useRef(!1),P=h.useRef(!1),G=h.useRef(null),Z=h.useRef(null),V=h.useRef(null),[se,ue]=h.useState(M),[fe,ge]=h.useState(T);h.useEffect(()=>{R.current||ue(M)},[n,M]),h.useEffect(()=>{P.current||ge(T)},[n,T]),h.useEffect(()=>{const xe=Z.current;if(!xe)return;const Te=mK(xe,fe);xe.style.minHeight=`${Te}px`,xe.style.height="",V.current&&(V.current.style.minHeight=`${Te}px`,V.current.style.height="")},[fe]),h.useEffect(()=>{const xe=G.current,Te=e==null?void 0:e.onNodeContentResize;if(!O||!xe||!Te||typeof ResizeObserver>"u")return;let it=0;const re=()=>{window.cancelAnimationFrame(it),it=window.requestAnimationFrame(()=>Te(n))},je=new ResizeObserver(re);return je.observe(xe),re(),()=>{window.cancelAnimationFrame(it),je.disconnect()}},[e==null?void 0:e.onNodeContentResize,O,n]);const ae=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],ve=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],_e=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],we=((e==null?void 0:e.model)??"").trim(),Ee=m==="agent"&&!C.startsWith("tool_nodejs"),Ae=new Set(ae.map(zo)),st=new Set(ve.map(zo)),ut=new Set(_e.map(zo)),et=we?we.startsWith("cursor:")||we.startsWith("opencode:")||we.startsWith("claude-code:")?we:ut.has(we)?`claude-code:${we}`:st.has(we)?`opencode:${we}`:Ae.has(we)?`cursor:${we}`:we:"",Ct=we&&!et.startsWith("cursor:")&&!et.startsWith("opencode:")&&!et.startsWith("claude-code:")&&!Ae.has(we)&&!st.has(we)&&!ut.has(we),Ue=we.startsWith("cursor:")?we.slice(7):we.startsWith("opencode:")?we.slice(9):we.startsWith("claude-code:")?we.slice(12):we,St=xe=>{if(y)return;const Te=xe.target.value;d&&d(n,Te)},nn=xe=>{xe.stopPropagation(),!y&&r&&r(n)},hn=xe=>{xe.stopPropagation(),s&&s()},An=xe=>{xe.stopPropagation(),!y&&(i==null||i(n,xe.target.value==="true"?"true":"false"))},Bt=xe=>{if(xe.stopPropagation(),y)return;const Te=xe.target.value;ue(Te),R.current||i==null||i(n,Te)},In=xe=>{xe.stopPropagation(),R.current=!0},Fn=xe=>{if(xe.stopPropagation(),y)return;R.current=!1;const Te=xe.currentTarget.value;ue(Te),i==null||i(n,Te)},le=()=>{y||i==null||i(n,se)},de=xe=>{if(xe.stopPropagation(),y)return;const Te=window.prompt("文件路径",se);Te!=null&&(ue(Te),i==null||i(n,Te))},ze=xe=>{if(ge(xe),a==null||a(n,xe),l){const Te=qU(_,xe);(Te.length!==_.length||Te.some((it,re)=>{var je;return it.id!==((je=_[re])==null?void 0:je.id)}))&&l(n,Te)}},Qe=xe=>{if(xe.stopPropagation(),y)return;const Te=xe.target.value;P.current?ge(Te):ze(Te)},ot=xe=>{xe.stopPropagation(),!y&&(P.current=!0)},Qt=xe=>{if(xe.stopPropagation(),y)return;P.current=!1;const Te=xe.currentTarget.value;ze(Te)},rn=()=>{y||ze(fe)},Tn=async xe=>{if(y)return;const Te=await lT({files:xe,body:fe,images:_});Te&&(ge(Te.body),a==null||a(n,Te.body),l==null||l(n,Te.images))},mn=(xe,Te)=>{if(xe.stopPropagation(),y)return;const it=_.filter(je=>je.id!==Te.id),re=pK(fe,Te.label);ge(re),a==null||a(n,re),l==null||l(n,it)},or=xe=>{if(y)return;const Te=aT(xe);Te.length!==0&&(xe.preventDefault(),xe.stopPropagation(),Tn(Te).catch(()=>{}))},sn=xe=>{if(y)return;const Te=Vm(xe);Te.length!==0&&(xe.preventDefault(),xe.stopPropagation(),Tn(Te).catch(()=>{}))},kn=()=>{const xe=Z.current,Te=V.current;!xe||!Te||(Te.scrollTop=xe.scrollTop,Te.scrollLeft=xe.scrollLeft)};return o.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":"")+(w?" af-flow-node--dim":"")+(O?" af-flow-node--inline-body-editor":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:b}),!v&&Ee&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:dr,onMouseDown:dr,onClick:dr,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:et,onChange:St,onPointerDown:dr,onMouseDown:dr,onClick:dr,"aria-label":f("flow:node.model"),title:Ue||f("flow:node.defaultModel"),disabled:y,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),Ct&&o.jsx("option",{value:we,children:we}),ae.length>0&&o.jsx("optgroup",{label:"Cursor",children:ae.map(xe=>o.jsx("option",{value:`cursor:${zo(xe)}`,children:zo(xe)},`c-${xe}`))}),ve.length>0&&o.jsx("optgroup",{label:"OpenCode",children:ve.map(xe=>o.jsx("option",{value:`opencode:${zo(xe)}`,children:zo(xe)},`o-${xe}`))}),_e.length>0&&o.jsx("optgroup",{label:"Claude Code",children:_e.map(xe=>o.jsx("option",{value:`claude-code:${zo(xe)}`,children:zo(xe)},`cc-${xe}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),j==="running"&&!k&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),j==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:A!=null&&String(A).trim()!==""?A:"--"}),j==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!v&&$&&!B&&!F&&!z&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:hn,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!v&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:y,onClick:nn,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:u.map((xe,Te)=>{if(xe.showOnNode===!1)return null;const it=f("flow:node.inputTooltip",{name:xe.name||`#${Te}`,type:xe.type})+(xe.default!=null&&xe.default!==""?f("flow:node.defaultSuffix",{value:xe.default}):""),re=xe.name||`#${Te+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[re,xe.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Cs,{type:"target",position:qe.Left,id:`input-${Te}`,className:"af-flow-node__handle",style:{background:Qn(xe.type)},title:it})]},`in-${Te}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:E}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,B?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(W?" af-flow-node__bool-select--true":""),value:W?"true":"false",onChange:An,onPointerDown:dr,onMouseDown:dr,onClick:dr,"aria-label":"Boolean value",title:W?"true":"false",disabled:y,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):F?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:se,onChange:Bt,onCompositionStart:In,onCompositionEnd:Fn,onBlur:le,onPointerDown:dr,onMouseDown:dr,onClick:dr,placeholder:"输入文本",rows:2,readOnly:y}):z?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:dr,onMouseDown:dr,onClick:dr,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:se,onChange:Bt,onCompositionStart:In,onCompositionEnd:Fn,onBlur:le,placeholder:"选择或输入文件路径",title:se||"选择或输入文件路径",readOnly:y}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:y,onClick:de,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):L&&!v?o.jsxs("div",{ref:G,className:"af-flow-node__prompt-stack nodrag",onPointerDown:dr,onMouseDown:dr,onClick:dr,children:[o.jsx("pre",{ref:V,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:hK(fe)+`
127
+ `}}),o.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:fe,onChange:Qe,onCompositionStart:ot,onCompositionEnd:Qt,onBlur:rn,onPaste:or,onDrop:sn,onScroll:kn,onDragOver:xe=>{Vm(xe).length>0&&xe.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,L&&_.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:_.map((xe,Te)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:xe.name,children:[o.jsx("img",{src:xe.dataUrl,alt:""}),o.jsxs("span",{children:["[",xe.label||`image ${Te+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:it=>mn(it,xe),onPointerDown:dr,onMouseDown:dr,"aria-label":`删除 ${xe.label||`image ${Te+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},xe.id||Te))}):null,D?o.jsx("span",{className:"af-flow-node__prompt-preview",title:D,children:D}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((xe,Te)=>{if(xe.showOnNode===!1)return null;const it=f("flow:node.outputTooltip",{name:xe.name||`#${Te}`,type:xe.type})+(xe.default!=null&&xe.default!==""?f("flow:node.defaultSuffix",{value:xe.default}):""),re=xe.name||`#${Te+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[re,xe.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Cs,{type:"source",position:qe.Right,id:`output-${Te}`,className:"af-flow-node__handle",style:{background:Qn(xe.type)},title:it})]},`out-${Te}`)})})]})]})}const ap="flowNode";function hT(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 qm(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function gK(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function yK({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=vn(),a=h.useId(),l=h.useRef(null),[c,d]=h.useState(""),[f,u]=h.useState(!1),[p,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),u(!1);const y=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),b=g===n;async function v(y){if(y.preventDefault(),!(!b||f)){u(!0),m("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await k.json().catch(()=>({}));if(!k.ok){m(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(k){m(String((k==null?void 0:k.message)||k))}finally{u(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:v,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!b})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||f,children:i(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function vj({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:f}){const{t:u}=vn(),p=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=m.current)==null?void 0:w.focus()});function k(w){w.key==="Escape"&&f(),w.key==="Enter"&&d()}return window.addEventListener("keydown",k),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",k)}},[e,f,d]),!e)return null;const g=r??u("common:common.confirm","确定"),b=s??u("common:common.cancel","取消"),v=t??u("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&f()},children:o.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:v}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:f,"aria-label":b,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:f,children:b}),a&&c?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function xK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=vn(),l=h.useId(),c=h.useRef(null),[d,f]=h.useState(""),[u,p]=h.useState(!1),[m,g]=h.useState("");if(h.useEffect(()=>{if(!e)return;f(""),g(""),p(!1);const k=requestAnimationFrame(()=>{var w;return(w=c.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(k)},[e,n]),!e)return null;const b=d.trim(),v=b===n;async function y(k){if(k.preventDefault(),!v||u)return;p(!0),g("");let w=null;try{const j=new AbortController;w=setTimeout(()=>j.abort(),15e3);const A=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:b,flowArchived:s}),signal:j.signal}),C=await A.json().catch(()=>({}));if(!A.ok){g(typeof C.error=="string"?C.error:a("project:deleteModal.deleteFailed"));return}try{for(let $=localStorage.length-1;$>=0;$--){const B=localStorage.key($);B&&(B.startsWith(`af:composer-sessions:${n}:${r}`)||B.startsWith(`af:composer-active-session:${n}:${r}`)||B.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(B)}}catch{}await i()}catch(j){if((j==null?void 0:j.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((j==null?void 0:j.message)||j))}finally{w&&clearTimeout(w),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:k=>{k.target===k.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:k=>f(k.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!v})]}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!v||u,children:a(u?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function wK({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function _i({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(wK,{children:t})]},n))})}function mT({open:e,onClose:t}){const{t:n}=vn(),r=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=gK()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.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:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(_i,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(_i,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(_i,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(_i,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(_i,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(_i,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(_i,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(_i,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(_i,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(_i,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(_i,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function bK(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function gT({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=vn(),[i,a]=h.useState(""),[l,c]=h.useState(0),d=h.useRef(null),f=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var b;return(b=d.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(g)},[e]);const u=h.useMemo(()=>{const g=(r||[]).map(y=>{var k,w,j;return{id:y.id,label:((k=y.data)==null?void 0:k.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),b=i.trim(),v=g.map(y=>({e:y,s:bK(y,b)})).filter(y=>y.s>0);return v.sort((y,k)=>k.s-y.s||y.e.id.localeCompare(k.e.id)),v.slice(0,50).map(y=>y.e)},[r,i]);if(h.useEffect(()=>{l>=u.length&&c(0)},[u.length,l]),h.useEffect(()=>{var b;const g=(b=f.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const b=u[g];b&&(n(b.id),t())},m=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(b=>Math.min(u.length-1,b+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(b=>Math.max(0,b-1));return}g.key==="Enter"&&(g.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:g=>{a(g.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:u.length})]}),u.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:u.map((g,b)=>o.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(b),onMouseDown:v=>{v.preventDefault(),p(b)},children:[o.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&o.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function vK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=vn(),f=h.useId(),u=h.useRef(null),p=h.useRef(null),[m,g]=h.useState(""),[b,v]=h.useState(""),[y,k]=h.useState(!1),[w,j]=h.useState(!1),[A,C]=h.useState(!1),[$,B]=h.useState(""),[F,z]=h.useState("");if(h.useEffect(()=>{if(!e||!i)return;g(""),v(""),B(""),z(""),k(!0),j(!1),C(!1);const E=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const _=await fetch(`/api/pipeline-file-content?${E}`),R=await _.json();if(!_.ok)throw new Error(R.error||"HTTP "+_.status);g(R.content||""),v(R.content||"")}catch(_){B(_.message||String(_))}finally{k(!1)}})();const D=requestAnimationFrame(()=>{var _;return(_=u.current)==null?void 0:_.focus()});return()=>cancelAnimationFrame(D)},[e,i,n,r,s]),!e)return null;const L=m!==b;async function O(E){if(E.preventDefault(),!w){j(!0),B(""),z("");try{const D=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),_=await fetch(`/api/pipeline-file-save?${D}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),R=await _.json();if(!_.ok)throw new Error(R.error||"HTTP "+_.status);v(m),z(d("flow:fileEdit.saved")),l&&l()}catch(D){B(D.message||String(D))}finally{j(!1)}}}async function W(){if(!(!c||A||!m)){C(!0),B("");try{const E=await c(m);typeof E=="string"&&E&&g(E)}catch(E){B(E.message||String(E))}finally{C(!1)}}}function M(){g(b),B(""),z("")}const T=m.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:E=>{E.target===E.currentTarget&&t()},children:o.jsxs("div",{ref:u,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:E=>E.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:y?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):$&&!m?o.jsx("div",{className:"af-file-edit-error",children:$}):o.jsxs(o.Fragment,{children:[T&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:m,onChange:E=>g(E.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),($||F)&&!y&&o.jsx("div",{className:`af-file-edit-status${F?" af-file-edit-status--success":""}`,children:F||$}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:M,disabled:!L||w||A,children:d("flow:fileEdit.reset")}),c&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:W,disabled:A||w||!m,children:d(A?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:O,disabled:!L||w||A,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const yT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),kK=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function SK(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 NK(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 kj(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 xT(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(yT.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 wT(e){return{inputNames:kj(e==null?void 0:e.inputs),outputNames:kj(e==null?void 0:e.outputs)}}function jK(e,t,n){const r=wT(t),s=NK(e),i=[];for(const a of s)if(!xT(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function CK(e,t){const n=wT(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],c=xT(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function EK(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function _K(e){return e.map(t=>{const n=EK(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 PK(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 i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):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 i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of kK)yT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function AK(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function IK(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 i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}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),d=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function gh({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:f}=vn(),u=h.useId(),p=h.useRef(null),m=h.useRef(null),[g,b]=h.useState(0),[v,y]=h.useState(0),[k,w]=h.useState(null),j=h.useMemo(()=>ws(c),[c]),A=h.useMemo(()=>jK(e,a,f),[e,a,f]),C=A.length>0,$=h.useMemo(()=>CK(e,a),[e,a]),B=h.useMemo(()=>_K($),[$]),F=h.useMemo(()=>n?null:SK(e,g),[e,g,n]),z=h.useMemo(()=>{if(!F)return[];const E=PK(a,f);return AK(E,F.query)},[F,a,f]);h.useEffect(()=>{y(E=>{const D=Math.max(0,z.length-1);return Math.min(Math.max(0,E),D)})},[z.length]);const L=h.useCallback(()=>{const E=p.current;if(!E||!F||z.length===0){w(null);return}const D=IK(E,g);if(!D){w(null);return}const _=4,R=44,P=13.5*16,G=Math.min(z.length*R+8,P);let Z=D.bottom+_;Z+G>window.innerHeight-8&&(Z=Math.max(8,D.top-G-_));const V=288;let se=D.left;se=Math.max(8,Math.min(se,window.innerWidth-V-8)),w({top:Z,left:se})},[F,z.length,g]);h.useLayoutEffect(()=>{if(!F||z.length===0){w(null);return}const E=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(E)},[F,z.length,g,e,L]),h.useEffect(()=>{if(!F||z.length===0)return;const E=()=>L();return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[F,z.length,L]);const O=h.useCallback(E=>{if(!F)return;const{atIndex:D}=F,_=e.slice(0,D)+"${"+E+"}"+e.slice(g);t(_);const R=D+E.length+3;queueMicrotask(()=>{const P=p.current;P&&(P.focus(),P.setSelectionRange(R,R)),b(R)})},[F,e,g,t]),W=h.useCallback(()=>{const E=p.current,D=m.current;!E||!D||(D.scrollTop=E.scrollTop,D.scrollLeft=E.scrollLeft,F&&z.length>0&&queueMicrotask(()=>L()))},[F,z.length,L]),M=h.useCallback(E=>{if(!n&&F&&z.length>0&&(E.key==="ArrowDown"||E.key==="ArrowUp"||E.key==="Enter")){if(E.key==="ArrowDown")E.preventDefault(),y(D=>(D+1)%z.length);else if(E.key==="ArrowUp")E.preventDefault(),y(D=>(D-1+z.length)%z.length);else if(E.key==="Enter"&&!E.shiftKey){E.preventDefault();const D=z[v];D&&O(D.insert)}}},[n,F,z,v,O]),T=h.useCallback(async E=>{if(n||typeof d!="function")return!1;const D=await lT({files:E,body:e,images:j});return D?(t(D.body),d(D.images),queueMicrotask(()=>{const _=p.current;if(!_)return;_.focus();const R=D.body.length;_.setSelectionRange(R,R),b(R)}),!0):!1},[n,j,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((E,D)=>o.jsxs("span",{className:"af-body-image-chip",title:E.name,children:[o.jsx("img",{src:E.dataUrl,alt:""}),o.jsxs("span",{children:["[",E.label||`image ${D+1}`,"]"]})]},E.id||D))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:B+`
128
+ `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?u:void 0,onChange:E=>{t(E.target.value),b(E.target.selectionStart??E.target.value.length)},onSelect:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??0)},onClick:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??0)},onKeyUp:E=>{const D=E.target;D instanceof HTMLTextAreaElement&&b(D.selectionStart??D.value.length)},onKeyDown:M,onPaste:E=>{const D=aT(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onDragOver:E=>{Vm(E).length>0&&E.preventDefault()},onDrop:E=>{const D=Vm(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onScroll:W})]}),F&&z.length>0&&k?Mr.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:z.map((E,D)=>o.jsx("li",{role:"option","aria-selected":D===v,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(D===v?" af-composer-mention-item--active":""),onMouseDown:_=>_.preventDefault(),onMouseEnter:()=>y(D),onClick:()=>O(E.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${E.insert}}`}),E.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:E.subtitle}):null]})},`${E.section}-${E.insert}`))}),document.body):null,C?o.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:A.map(E=>E.message).join(" · ")}):null]})}const bT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function yh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Sj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=vn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((p,m)=>m!==u)),d=(u,p,m)=>{const g=n.map((b,v)=>{if(v!==u)return b;const y={...b,[p]:m};return p==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.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")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((u,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.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:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function vT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:f,ioSlots:u}){const{t:p}=vn(),[m,g]=h.useState(!1),[b,v]=h.useState(!1),[y,k]=h.useState({status:"idle",message:""}),w=h.useCallback(O=>{t(W=>W&&{...W,...O})},[t]),{cursorList:j,opencodeList:A,claudeCodeList:C,currentNotInLists:$}=h.useMemo(()=>{const O=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],M=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],T=new Set([...O,...W,...M].map(yh)),E=((e==null?void 0:e.model)??"").trim(),D=E.startsWith("cursor:")?E.slice(7):E.startsWith("opencode:")?E.slice(9):E.startsWith("claude-code:")?E.slice(12):E,_=E&&!T.has(D)?E:"";return{cursorList:O,opencodeList:W,claudeCodeList:M,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const B=String(e.script??""),F=n==="tool_nodejs"||B.trim()!=="",z=typeof c=="function"&&!i&&(e==null?void 0:e.newId),L=async()=>{if(z){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 o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:L,disabled:!z||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:O=>w({newId:O.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:O=>w({label:O.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:tl.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>w({role:O.target.value}),disabled:i,children:tl.map(O=>o.jsx("option",{value:O,children:O},O))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const O=(e.model||"").trim();return O?$||O:""})(),onChange:O=>w({model:O.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),$?o.jsxs("option",{value:$,children:[$,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?o.jsx("optgroup",{label:"Cursor",children:j.map(O=>o.jsx("option",{value:yh(O),children:O},`c-${O}`))}):null,A.length>0?o.jsx("optgroup",{label:"OpenCode",children:A.map(O=>o.jsx("option",{value:yh(O),children:O},`o-${O}`))}):null,C.length>0?o.jsx("optgroup",{label:"Claude Code",children:C.map(O=>o.jsx("option",{value:`claude-code:${yh(O)}`,children:O},`cc-${O}`))}):null]})]}),o.jsx(Sj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>w({inputs:O}),disabled:i,requiredReadonly:!d}),o.jsx(Sj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>w({outputs:O}),disabled:i,requiredReadonly:!d}),F?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>v(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(gh,{value:B,onChange:O=>w({script:O}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(gh,{value:e.body,onChange:O=>w({body:O}),images:e.images,onImagesChange:O=>w({images:O}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.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&&v(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>v(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(gh,{value:B,onChange:O=>w({script:O}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?o.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&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(gh,{value:e.body,onChange:O=>w({body:O}),images:e.images,onImagesChange:O=>w({images:O}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function c0(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function TK(e){const t=c0(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function kT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Nj({text:e}){const{t}=vn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Bu,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function jj({o:e}){var r;const{t}=vn(),n=c0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:kT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(Bu,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Cj(e){return TK(e)}function Ej(e){var r;if(!e)return null;const t=c0(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?kT(String(n)):String(n)}function _j({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Pj=2e4,ST="af:run-node-ctx-width";function qh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function $a(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):$a(qh())}function RK(){try{const e=localStorage.getItem(ST);if(e==null)return $a(qh());const t=parseInt(e,10);return Number.isFinite(t)?$a(t):$a(qh())}catch{return $a(qh())}}async function Aj(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function LK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function OK({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=vn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(RK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,p]=h.useState(!0),[m,g]=h.useState(""),[b,v]=h.useState([]),[y,k]=h.useState(null),[w,j]=h.useState(null),A=h.useRef(null),C=h.useRef(null),$=h.useRef(0),B=h.useRef(0);h.useLayoutEffect(()=>{const _=window.matchMedia("(max-width: 960px)"),R=()=>l(_.matches);return _.addEventListener("change",R),()=>_.removeEventListener("change",R)},[]),h.useEffect(()=>{function _(){d(R=>$a(R))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const F=h.useCallback(()=>{d(_=>{const R=$a(_);try{localStorage.setItem(ST,String(R))}catch{}return R})},[]),z=h.useCallback(_=>{if(a||_.button!==0)return;_.preventDefault();const R=_.currentTarget;f.current={active:!0,pointerId:_.pointerId,startX:_.clientX,startW:c},R.setPointerCapture(_.pointerId)},[a,c]),L=h.useCallback(_=>{const R=f.current;if(!R.active||_.pointerId!==R.pointerId)return;const P=R.startX-_.clientX;d($a(R.startW+P))},[]),O=h.useCallback(_=>{const R=f.current;if(!(!R.active||_.pointerId!==R.pointerId)){R.active=!1;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}F()}},[F]),W=h.useCallback(()=>{const _=f.current;_.active&&(_.active=!1,F())},[F]),M=h.useCallback(_=>{const R=Array.isArray(_)?_:[];v(R),k(P=>P&&R.some(G=>G.execId===P)?P:R.length>0?R[R.length-1].execId:null)},[]),T=h.useCallback(()=>{if(!e||!t)return;const _=++$.current,R=new AbortController,P=window.setTimeout(()=>R.abort(),Pj);(async()=>{try{const G=await Aj(t,e,n,R.signal);if(_!==$.current)return;M(Array.isArray(G.rounds)?G.rounds:[])}catch{}finally{window.clearTimeout(P)}})()},[e,t,n,M]);h.useEffect(()=>{if(!e||!t){p(!1),g(""),v([]);return}const _=++B.current;p(!0),g(""),v([]),k(null);const R=new AbortController,P=window.setTimeout(()=>R.abort(),Pj);return(async()=>{try{const G=await Aj(t,e,n,R.signal);if(_!==B.current)return;M(Array.isArray(G.rounds)?G.rounds:[])}catch(G){if(_!==B.current)return;const Z=(G==null?void 0:G.name)==="AbortError"?"requestTimeout":G.message||String(G);g(Z)}finally{window.clearTimeout(P),_===B.current&&p(!1)}})(),()=>{R.abort(),B.current++,$.current++}},[e,t,n,M]),h.useEffect(()=>{r&&T()},[r,T]),h.useEffect(()=>{clearInterval(C.current);const _=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(_&&_.status==="running"))&&e&&t&&(C.current=setInterval(()=>T(),2e3)),()=>clearInterval(C.current)},[b,e,t,n,r,T]),h.useEffect(()=>{A.current&&(A.current.scrollTop=0)},[y]);const E=b.find(_=>_.execId===y),D=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:D,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:z,onPointerMove:L,onPointerUp:O,onPointerCancel:O,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:LK(i,m)}),!u&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+$K((E==null?void 0:E.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:_=>{const R=_.target.value;k(R==="latest"?"latest":Number(R))},children:[...b].reverse().map(_=>{const R=_.execId==="latest"?i("flow:runContext.latest"):`#${_.execId}`,P=DK(i,_.status),G=_.finishedAt?` · ${MK(_.finishedAt)}`:"";return o.jsx("option",{value:String(_.execId),children:`${R} · ${P}${G}`},_.execId)})})]}),E&&o.jsxs("div",{className:"af-run-ctx-body",ref:A,children:[E.inputs&&E.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),E.inputs.map((_,R)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:_.value})]},`${_.slot}-${R}`))]}),E.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Nj,{text:E.prompt})]}),E.outputs&&E.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),E.outputs.map((_,R)=>{const P=Cj(_),G=Ej(_);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),P?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:P}):null,o.jsx(_j,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(jj,{o:_})]},`${_.slot}-${R}`)})]}),!E.prompt&&(!E.outputs||E.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&E&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:_=>{_.target===_.currentTarget&&j(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&E.prompt!=null&&o.jsx(Nj,{text:E.prompt}),w==="output"&&E.outputs&&E.outputs.map((_,R)=>{const P=Cj(_),G=Ej(_);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:_.slot}),P?o.jsx("span",{className:"af-run-ctx-format-badge",children:P}):null,o.jsx(_j,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(jj,{o:_})]},`${_.slot}-${R}`)})]})]})})]})}function MK(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function $K(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function DK(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function FK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=vn(),[d,f]=h.useState({}),[u,p]=h.useState(null),[m,g]=h.useState({}),[b,v]=h.useState(!0),[y,k]=h.useState(!1),[w,j]=h.useState(""),[A,C]=h.useState(!1),[$,B]=h.useState(null),F=h.useRef(null),z=h.useRef(!0),L=h.useRef({});h.useMemo(()=>{var P,G,Z;const R={};for(const V of r){const se=(Z=(G=(P=V.data)==null?void 0:P.outputs)==null?void 0:G[0])==null?void 0:Z.default;se!=null&&se!==""&&(R[V.id]=String(se))}return L.current=R,R},[r]);const O=h.useMemo(()=>{var P;const R={};for(const G of i){if(!((P=G.data)!=null&&P.inputs))continue;const Z=G.data.inputs;for(let V=0;V<Z.length;V++){const se=Z[V];if(!(se!=null&&se.name))continue;const ue=s.find(ge=>ge.target===G.id&&ge.targetHandle===`input-${V}`);if(!(ue!=null&&ue.source))continue;r.find(ge=>ge.id===ue.source)&&(R[ue.source]=se.name)}}return R},[i,s,r]);h.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]),h.useEffect(()=>{if(!e){v(!1);return}v(!0);const R=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&R.set("archived","1"),fetch(`/api/flow/run-config?${R.toString()}`).then(P=>{if(!P.ok)throw new Error(`HTTP ${P.status}`);return P.json()}).then(P=>{var Z;if(!z.current)return;f(P.presets||{}),p(P.activePreset||null);const G=P.activePreset&&((Z=P.presets)!=null&&Z[P.activePreset])?P.presets[P.activePreset]:{};g({...L.current,...G}),v(!1)}).catch(()=>{z.current&&(g(L.current),v(!1))})},[e,t,n]),h.useEffect(()=>{var P;if(!a)return;const R={};for(const[G,Z]of Object.entries(m)){const V=O[G];if(!V)continue;const se=r.find(fe=>fe.id===G);if(!se)continue;(((P=se.data)==null?void 0:P.definitionId)||"").startsWith("provide_file")?R[V]={type:"file",path:Z}:R[V]={type:"str",value:Z}}a(R)},[m,O,r,a]);const W=h.useCallback((R,P)=>{g(G=>({...G,[R]:P}))},[]),M=h.useCallback(R=>{R!==u&&(p(R),R&&d[R]?g({...L.current,...d[R]}):g(L.current))},[u,d]),T=h.useCallback(async()=>{if(w.trim()){k(!0);try{const R={...d,[w.trim()]:m},P={flowId:e,flowSource:t,archived:n,presets:R,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)})).ok&&(f(R),p(w.trim()),j(""),C(!1))}finally{k(!1)}}},[e,t,n,d,m,w]),E=h.useCallback(async()=>{if(u){k(!0);try{const R={...d};delete R[u];const P=Object.keys(R)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:R,activePreset:P})})).ok&&(f(R),p(P),P&&R[P]?g({...L.current,...R[P]}):g(L.current))}finally{k(!1)}}},[e,t,n,d,u]),D=h.useCallback(async()=>{if(u){k(!0);try{const R={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:R,activePreset:u})})).ok&&f(R)}finally{k(!1)}}},[e,t,n,d,u,m]),_=Object.keys(d);return _.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:R=>M(R.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),_.map(R=>o.jsx("option",{value:R,children:R},R))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>C(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:D,disabled:y,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:E,disabled:y,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),A&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:w,onChange:R=>j(R.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:T,disabled:y||!w.trim(),children:c(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{C(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(R=>{var ge,ae;const P=((ge=R.data)==null?void 0:ge.definitionId)||"",G=P.startsWith("provide_file"),Z=P==="provide_bool",V=((ae=R.data)==null?void 0:ae.label)||R.id,se=R.id,ue=m[se]||"",fe=["true","1","yes","on"].includes(String(ue).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(G?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:G?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>B({instanceId:se,label:V,content:ue}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:se}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(fe?" af-run-config-bool-toggle--true":""),onClick:()=>W(se,fe?"false":"true"),"aria-pressed":fe,children:fe?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:ve=>W(se,ve.target.value),placeholder:c(G?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},se)})})]}),$&&Mr.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:$.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>B(null),"aria-label":c("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:F,className:"af-provide-edit-modal__textarea",defaultValue:$.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!$||!F.current||(W($.instanceId,F.current.value),B(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>B(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const NT={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},zK={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function BK(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function HK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function WK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function Ij(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(NT))if(r.includes(e))return n;return"other"}function VK({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=zK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),c=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=i[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(u=>{u.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:HK(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function UK({open:e,onClose:t,flowId:n}){var B;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,c]=h.useState(null),[d,f]=h.useState(null),[u,p]=h.useState(!1),[m,g]=h.useState(!0),[b,v]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,k]=h.useState(""),w=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const F=m&&n?`?flowId=${encodeURIComponent(n)}`:"",L=await(await fetch(`/api/composer-logs${F}`)).json();s(Array.isArray(L.sessions)?L.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),A=h.useCallback(async F=>{if(!F){f(null);return}p(!0);try{const L=await(await fetch(`/api/composer-logs/${encodeURIComponent(F)}`)).json();f(L)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return A(l),w.current=setInterval(()=>A(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,A]);const C=h.useMemo(()=>{const F=(d==null?void 0:d.events)||[],z=y.trim().toLowerCase();return F.filter(L=>{const O=Ij(L.tag,L.payload);return!b[O]&&O!=="other"?!1:z?[L.tag,JSON.stringify(L.payload||"")].join(" ").toLowerCase().includes(z):!0})},[d,b,y]),$=h.useMemo(()=>{const F=(d==null?void 0:d.events)||[],z={};for(const L of F){const O=Ij(L.tag,L.payload);z[O]=(z[O]||0)+1}return z},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:F=>g(F.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(F=>{const z=l===F.sessionId;return o.jsxs("div",{onClick:()=>c(F.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:z?"rgba(124,77,255,0.18)":"transparent",borderLeft:z?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:WK(F.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:F.flowId||"(no flow)"}),F.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:F.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[BK(F.size)," · ",F.model||"default"]})]},F.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(NT).map(F=>o.jsxs("button",{type:"button",onClick:()=>v(z=>({...z,[F]:!z[F]})),style:{background:b[F]?"rgba(124,77,255,0.25)":"transparent",color:b[F]?"#e8deff":"#6a6a6a",border:`1px solid ${b[F]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[F," ",$[F]!=null?`(${$[F]})`:""]},F)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:F=>k(F.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&C.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((B=d.events)==null?void 0:B.length)||0," total)"]}),C.map((F,z)=>o.jsx(VK,{event:F,defaultExpanded:F.tag==="error"},`${F.ts}_${z}`))]})]})]})]}):null}const KK="0.1.49";function Tj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function px(e,t){return t==="running"?Tj(e):e==null||!Number.isFinite(e)||e<=0?"--":Tj(e)}const jT=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function qK(e){var k,w,j,A,C,$,B,F,z,L,O;const{setNodes:t}=cc(),n=zv(),{modelLists:r,onModelChange:s}=h.useContext(jT),i=h.useRef(null),a=!!((k=e.data)!=null&&k.readOnly),l=(w=e.data)!=null&&w.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((A=e.data)!=null&&A.isRunMode)&&!a,d=h.useCallback(W=>{const M=()=>n(W);window.requestAnimationFrame(M),window.setTimeout(M,80)},[n]),f=h.useCallback((W,M)=>{const T=zj(M);T&&(t(E=>E.map(D=>{var P,G,Z,V,se,ue;if(D.id!==W)return D;const _=Number(((G=(P=D.data)==null?void 0:P.displaySize)==null?void 0:G.width)||D.width||((Z=D.measured)==null?void 0:Z.width)||0),R=Number(((se=(V=D.data)==null?void 0:V.displaySize)==null?void 0:se.height)||D.height||((ue=D.measured)==null?void 0:ue.height)||0);return Math.abs(_-T.width)<2&&Math.abs(R-T.height)<2?D:{...D,width:T.width,height:T.height,data:{...D.data,displaySize:T}}})),d(W))},[d,t]),u=h.useCallback(W=>{if(a)return;const M=i.current;if(!M)return;const T=M.getBoundingClientRect();f(W,{width:Math.max(T.width,M.scrollWidth),height:Math.max(T.height,M.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var se,ue,fe,ge,ae,ve;if(!c)return;W.preventDefault(),W.stopPropagation();const M=i.current,T=M==null?void 0:M.getBoundingClientRect(),E=Number(((ue=(se=e.data)==null?void 0:se.displaySize)==null?void 0:ue.width)||e.width||((fe=e.measured)==null?void 0:fe.width)||(T==null?void 0:T.width)||PT),D=Number(((ae=(ge=e.data)==null?void 0:ge.displaySize)==null?void 0:ae.height)||e.height||((ve=e.measured)==null?void 0:ve.height)||(T==null?void 0:T.height)||pb),_=W.clientX,R=W.clientY,P=e.id;let G=0;const Z=_e=>{const we=zj({width:E+_e.clientX-_,height:D+_e.clientY-R});we&&(window.cancelAnimationFrame(G),G=window.requestAnimationFrame(()=>f(P,we)))},V=()=>{window.cancelAnimationFrame(G),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(P)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,($=(C=e.data)==null?void 0:C.displaySize)==null?void 0:$.height,(F=(B=e.data)==null?void 0:B.displaySize)==null?void 0:F.width,e.height,e.id,(z=e.measured)==null?void 0:z.height,(L=e.measured)==null?void 0:L.width,e.width,d,c]),m=h.useCallback(W=>{t(M=>M.filter(T=>T.id!==W))},[t]),g=h.useCallback(()=>{var E,D,_,R,P,G,Z,V;const W=((E=e.data)==null?void 0:E.definitionId)||"",M=((D=e.data)==null?void 0:D.label)||e.id,T=((P=(R=(_=e.data)==null?void 0:_.outputs)==null?void 0:R[0])==null?void 0:P.value)||((V=(Z=(G=e.data)==null?void 0:G.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:M,definitionId:W,content:T},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,M)=>{t(T=>T.map(E=>{var _;if(E.id!==W)return E;const D=Array.isArray((_=E.data)==null?void 0:_.outputs)&&E.data.outputs.length?E.data.outputs.map((R,P)=>P===0?{...R,default:M,value:M}:R):[{type:"bool",name:"value",default:M,value:M}];return{...E,data:{...E.data,body:"",outputs:D}}}))},[t]),v=h.useCallback((W,M)=>{t(T=>T.map(E=>E.id===W?{...E,data:{...E.data,body:M}}:E))},[t]),y=h.useCallback((W,M)=>{t(T=>T.map(E=>E.id===W?{...E,data:{...E.data,images:ws(M)}}:E))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx(pT,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:b,onNodeBodyChange:v,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":((O=e.data)==null?void 0:O.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const YK={[ap]:qK},Md=["CONTROL","TOOL","PROVIDE","AGENT"],GK=1200,Rj="af-flow-node--sync-flash",Lj="af-flow-edge--sync-flash";function Oj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function Mj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function u0(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function XK(e){const t=u0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function xh(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function CT(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function ET(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function hx(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 $j(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(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function Dj(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 JK(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function QK(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function _T(e,t,n,r,s){const i=XK(e),a={id:t,type:ap,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return zf(a,r,s)}const PT=320,ZK=220,e7=1600,pb=104,t7=900;function Fj(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function zj(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:Fj(t,ZK,e7)||PT,height:Fj(n,pb,t7)||pb}}function n7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,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 Bj(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(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=Ru(i,e.sourceHandle||"output-0","source"),c=Ru(a,e.targetHandle||"input-0","target");return!l||!c?!1:Tu(l,c)}function r7(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 i=t.find(l=>l.id===n),a=Ru(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:fT(a)}:null}function s7(e,t,n){var a;const r=_T(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const c=i[l];if(n.handleType==="source"?Tu(n.slot,c):Tu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function i7(e,t){return t?e.map((n,r)=>{const s=s7(n,e,t);if(!s)return null;const i=u0(n);return{def:n,order:r,category:i,categoryRank:Md.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:CT(s.hydrated.data||n),description:ET(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const o7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function a7(e){const t=new Set,n=[];let r;const s=new RegExp(o7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function Hj(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function Wo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function wh(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=i.map(Wo),d=a.map(Wo);return l.map(Wo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function l7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function mx(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function c7({steps:e}){const{t}=vn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
+ `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:l7(s)}):null]}):null})]},n.index)})})}function u7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function d7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
+ ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function f7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function p7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function Wj({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=vn(),a=h.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return h.useEffect(()=>{if(!s||!a.current)return;const c=a.current;requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(Vj,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(Vj,{segments:t,running:n})})]})}function Vj({segments:e,running:t=!1}){const{t:n}=vn(),r=e.filter(u=>u.kind==="assistant").map(u=>u.text).join(""),s=e.filter(u=>u.kind==="result").map(u=>u.text).join(""),i=u7(r,s),a=e.filter(u=>u.kind==="error").map(u=>u.text).join(`
131
+ `),l=e.filter(u=>u.kind!=="error"),c=i?l.filter(u=>u.kind!=="result"):l,d=d7(c),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((u,p)=>o.jsxs("section",{className:p7(u.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:f7(u.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`${u.kind}-${p}`)),t&&!f?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function h7({fitViewEpoch:e}){const{fitView:t}=cc(),n=h.useRef(t);return n.current=t,h.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function m7({onReady:e}){const t=zv();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function Uj(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function Kj(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)}}const Yh=1500,qj=500,g7=262144,y7=2e3;function gx(e){return typeof e!="string"?"":e.length<=y7?e:`[log line truncated, ${e.length} chars]`}const x7=Yh;function w7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:gx(s)}}catch{return{ts:n,type:"info",text:gx(s)}}return{ts:n,type:"log",text:gx(`[${r}] ${s}`)}}function Yj(e){if(!e)return[];const t=[],n=e.split(`
132
+ `);for(let r=n.length-1;r>=0&&t.length<x7;r--){const s=n[r];if(!s)continue;const i=w7(s);i&&t.push(i)}return t.reverse(),t}function b7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const i=e[s],a=t[s];if(!a)return!1;if(i!==a&&(i.status!==a.status||(i.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function v7(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function k7({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:f,onNodeClick:u,onNodeDoubleClick:p,onEdgeClick:m,onFlowInit:g,onDrop:b,onDragOver:v,hideMinimapAndControls:y,bottomSlot:k}){const{t:w}=vn(),j=!s,A=j||t==="pan"?!0:[1,2],C=j?!1:t==="select",$="af-flow-canvas"+(j?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),B=h.useCallback(()=>{},[]),F=h.useMemo(()=>{const z=new Map(n.map(T=>[T.id,T])),L=new Set(n.filter(T=>T.selected).map(T=>T.id)),O=L.size>0,W=(T,E)=>{const D=/^#([0-9a-f]{6})$/i.exec(T);if(!D)return T;const _=parseInt(D[1],16);return`rgba(${_>>16&255}, ${_>>8&255}, ${_&255}, ${E})`},M="#ff5169";return r.map(T=>{var we,Ee,Ae,st;const E=z.get(T.source),D=z.get(T.target),_=/^output-(\d+)$/.exec(T.sourceHandle||""),R=/^input-(\d+)$/.exec(T.targetHandle||""),P=E&&_?(Ee=(we=E.data)==null?void 0:we.outputs)==null?void 0:Ee[parseInt(_[1],10)]:null,G=D&&R?(st=(Ae=D.data)==null?void 0:Ae.inputs)==null?void 0:st[parseInt(R[1],10)]:null,Z=P!=null&&P.type?Qn(P.type):null,V=G!=null&&G.type?Qn(G.type):null,se=Z&&V&&Z!==V,ue=O&&(L.has(T.source)||L.has(T.target)),fe=T.style||{};if(se){const ut=T.selected?.95:ue?.85:.78,et=W(M,ut);return{...T,className:((T.className||"")+" af-flow-edge--type-mismatch"+(ue?" af-flow-edge--adjacent":"")).trim(),style:{...fe,stroke:et,strokeWidth:ue?2.75:2.5,strokeDasharray:"6 4"},markerEnd:T.markerEnd&&typeof T.markerEnd=="object"?{...T.markerEnd,color:et}:{type:Ns.ArrowClosed,color:et}}}const ge=Z||V;if(!ge)return ue?{...T,className:((T.className||"")+" af-flow-edge--adjacent").trim(),style:{...fe,strokeWidth:2.5}}:T;const ae=ue||T.selected?.7:.38,ve=W(ge,ae),_e=ue?2.5:fe.strokeWidth??2;return{...T,className:((T.className||"")+(ue?" af-flow-edge--adjacent":"")).trim(),style:{...fe,stroke:ve,strokeWidth:_e},markerEnd:T.markerEnd&&typeof T.markerEnd=="object"?{...T.markerEnd,color:ve}:{type:Ns.ArrowClosed,color:ve}}})},[n,r]);return o.jsxs(Fv,{className:$,nodes:n,edges:F,onNodesChange:s||B,onEdgesChange:i||B,onConnect:j?void 0:a,onConnectStart:j?void 0:l,onConnectEnd:j?void 0:c,isValidConnection:j?void 0:d,onNodesDelete:j?void 0:f,onNodeClick:u,onNodeDoubleClick:j?void 0:p,onEdgeClick:j?void 0:m,onInit:g,onDrop:j?void 0:b,onDragOver:j?void 0:v,nodeTypes:YK,selectionOnDrag:C,panOnDrag:A,nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j,edgesFocusable:!j,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[o.jsx(Bv,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx(Au,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(y?" af-flow-bottom-unified-panel--solo":""),children:o.jsxs("div",{className:"af-flow-bottom-unified-row"+(y?" af-flow-bottom-unified-row--solo":""),children:[y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:o.jsx(E4,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:z=>{var O;const L=(((O=z.data)==null?void 0:O.schemaType)??"agent").toLowerCase();return L==="control"?"rgba(237, 108, 2, 0.85)":L==="provide"?"rgba(0, 228, 117, 0.35)":L==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:k}),y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(h4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&o.jsx(Au,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:z,color:L})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:L}}),o.jsx("span",{className:"af-pin-legend__label",children:z})]},z))}),o.jsx(h7,{fitViewEpoch:e}),!j&&n.length===0?o.jsxs("div",{className:"af-flow-empty-hint",children:[o.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),o.jsx("p",{className:"af-flow-empty-hint-text",children:w("flow:emptyCanvas.composerHint")}),o.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:w("flow:emptyCanvas.composerSub")}})]}):null]})}function Gj(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&t.set("flowArchived","1"),window.history.replaceState({},"","/flow?"+t.toString())}function S7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function ni(e){return e==="builtin"||e==="admin"}function Lc(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function N7(e){var r,s,i,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const AT="af:run-console-height",rf=230,Nd={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},bh={};function Gh(e){if(!Number.isFinite(e))return rf;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function j7(){try{const e=localStorage.getItem(AT);if(e==null)return rf;const t=parseInt(e,10);return Number.isFinite(t)?Gh(t):rf}catch{return rf}}function C7(){var D0,F0;const{t:e,i18n:t}=vn(),{navigate:n,path:r}=ko(),s=h.useRef(null),i=h.useRef(new Map),a=h.useCallback(x=>{s.current=typeof x=="function"?x:null},[]),[l,c]=h.useState([]),[d,f]=h.useState(""),[u,p]=h.useState(null),[m,g]=h.useState(0),[b,v]=h.useState(""),[y,k]=h.useState(""),[w,j]=h.useState(""),[A,C]=h.useState(""),[$,B]=h.useState(!1),[F,z]=h.useState(""),[L,O]=h.useState(!1),[W,M]=h.useState(""),[T,E]=h.useState(!1),[D,_]=h.useState(!1),[R,P]=h.useState(!1),[G,Z]=h.useState(null),[V,se]=h.useState(!1),[ue,fe]=h.useState(!1),ge=h.useRef(!1),[ae,ve]=h.useState([]),[_e,we]=h.useState(""),[Ee,Ae]=h.useState("nodes"),st=h.useRef(null),[ut,et]=h.useState([]),[Ct,Ue]=h.useState(!1),[St,nn]=h.useState(""),[hn,An]=h.useState(!1),[Bt,In]=h.useState({name:"",id:"",description:""}),[Fn,le]=h.useState(!1),[de,ze]=h.useState(""),[Qe,ot]=h.useState(""),Qt=h.useRef(null),[rn,Tn]=h.useState([]),[mn,or]=h.useState(!1),[sn,kn]=h.useState(""),[tn,Sn]=h.useState(""),[xe,Te]=h.useState(null),[it,re]=h.useState(null),[je,Ye]=h.useState([]),[jt,Ke]=h.useState(""),[Nn,fi]=h.useState(!1),jo=h.useCallback(x=>{Qt.current&&window.clearTimeout(Qt.current),ot(x),Qt.current=window.setTimeout(()=>{ot(""),Qt.current=null},3800)},[]),kr=h.useCallback(x=>{const N=String(x||"").trim();if(!N)return;const H=()=>{var q;return(q=s.current)==null?void 0:q.call(s,N)};window.requestAnimationFrame(H),window.setTimeout(H,80)},[]);h.useEffect(()=>()=>{Qt.current&&window.clearTimeout(Qt.current)},[]);const[Sr,Co]=h.useState(!1),[ar,qs]=h.useState({files:[]}),[Oe,aa]=h.useState(!1),[pi,Kn]=h.useState(!0);h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/flows",{method:"HEAD"}).then(q=>{x||Kn(q.ok)}).catch(()=>{x||Kn(!1)})};N();const H=window.setInterval(N,5e3);return()=>{x=!0,window.clearInterval(H)}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/dev-info").then(N=>N.json()).then(N=>{x||hi(!!(N!=null&&N.isDev))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{u!=null&&u.id&&T_(u.id,u.source??"user","pipeline",!!u.archived)},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const[Le,Ht]=h.useState("edit"),[Nr,mt]=h.useState([]),Vi=h.useRef(0),[Zn,zn]=h.useState(new Set),[jr,lt]=h.useState({}),[Wt,Yt]=h.useState(null),[Rn,Je]=h.useState(0),[lr,_s]=h.useState(!1),[Cr,hi]=h.useState(!1),[Ps,Eo]=h.useState(!1),[Ui,_o]=h.useState(j7),Ys=h.useRef({active:!1,pointerId:-1,startY:0,startH:rf}),[an,As]=h.useState(null),[Is,Ts]=h.useState(null),[Gs,U]=h.useState({}),he=h.useRef(Gs);h.useEffect(()=>{he.current=Gs},[Gs]);const[Ie,Pe]=h.useState(!1),[Ge,Vt]=h.useState(!1),[Mt,er]=h.useState({}),[Er,Xs]=h.useState({}),[Po,Br]=h.useState(null),[cr,la]=h.useState(Nd),[cl,Yu]=h.useState(!1),[tr,dc]=h.useState(!1),[Ki,Ao]=h.useState(""),[Io,fc]=h.useState(""),[Gt,pc]=h.useState(bh),[Ln,qi]=h.useState(null),mi=h.useRef(0),Js=h.useRef(null),ca=h.useRef(null),ul=h.useRef(!0),Yi=h.useRef(!1),[ur,dl]=h.useState(null),[To,fl]=h.useState(null),[Hr,ua]=h.useState(!1),[gi,da]=h.useState(""),[Gi,cs]=h.useState(!1),pp=h.useRef(null),[_r,pl]=h.useState(null),[Xi,hl]=h.useState(!1),[Re,Qs]=h.useState(null),[ml,Gu]=h.useState(!1),[qn,Ro]=h.useState(null),jn=h.useRef(null),[us,gl]=h.useState(""),[hc,fa]=h.useState(0),[pa,ha]=h.useState(0),[ma,Xu]=h.useState("pan"),[yl,ga]=h.useState(!1),[mc,xl]=h.useState(!1),ya=h.useRef(null),gc=h.useRef(null),xa=h.useRef(null),[hp,mp]=h.useState(0),[gt,wa]=h.useState(null),[gp,wl]=h.useState(""),[wt,yp]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[Ji,ds]=h.useState(""),[yc,xc]=h.useState(""),[Wr,pt]=h.useState([]),[$t,Lo]=h.useState([]),[xp,Ju]=h.useState(!1),[wc,Yg]=h.useState([]),[wp,Gg]=h.useState(!1),[Xg,bp]=h.useState(()=>new Set),[ba,Oo]=h.useState(!1),Mo=h.useRef(null),vp=h.useRef(null),[Jg,Qu]=h.useState({}),yi=h.useCallback(x=>{if(!x)return null;const N=x.id,H=x.source??"user",q=x.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${N}:${H}${q?":"+q:""}`,activeKey:`af:composer-active-session:${N}:${H}${q?":"+q:""}`}},[]),Yn=h.useCallback(x=>{if(!x)return"";const N=x.id,H=x.source??"user",q=x.archived?"archived":"";return`af:composer-skills:pipeline:${N}:${H}${q?":"+q:""}`},[]),bl=h.useCallback(x=>{const N=yi(x);if(!N)return{sessions:[],activeSessionId:null};try{const H=localStorage.getItem(N.sessionsKey);if(!H)return{sessions:[],activeSessionId:null};const q=JSON.parse(H);if(!Array.isArray(q))return{sessions:[],activeSessionId:null};const Y=q.filter(ee=>ee&&typeof ee.id=="string").map(ee=>({...ee,running:!1,statusLine:ee.running?e("flow:composer.pageRefreshReset"):ee.statusLine,steps:[]}));let J=null;try{J=localStorage.getItem(N.activeKey),J&&!Y.some(ee=>ee.id===J)&&(J=null)}catch{J=null}return{sessions:Y,activeSessionId:J}}catch{return{sessions:[],activeSessionId:null}}},[yi]),$o=h.useCallback((x,N,H)=>{const q=yi(x);if(q)try{localStorage.setItem(q.sessionsKey,JSON.stringify(N)),H?localStorage.setItem(q.activeKey,H):localStorage.removeItem(q.activeKey)}catch{}},[yi]),xi=h.useRef(0),bc=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[Zr,es]=h.useState([]),[gr,wi]=h.useState(null),bi=h.useMemo(()=>Yn(u),[Yn,u]),[kp,Zu]=h.useState(""),vl=h.useMemo(()=>{if(!u)return null;const x=u.id,N=u.source??"user",H=u.archived?"archived":"";return`${x}:${N}${H?":"+H:""}`},[u]),vc=h.useRef(!1);h.useEffect(()=>{if(!vl){es([]),wi(null),bc.current={sessions:[],activeSessionId:null,flowKey:null};return}const x=bc.current;if(x.flowKey===vl)return;x.flowKey=vl,vc.current&&x.sessions.length>0&&$o(u,x.sessions,x.activeSessionId);const{sessions:N,activeSessionId:H}=bl(u);if(N.length===0){const q=`session-1-${Date.now()}`,Y={id:q,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};x.sessions=[Y],x.activeSessionId=q,es([Y]),wi(q)}else{const q=N[N.length-1];if(q&&(!q.thread||q.thread.length===0))xi.current=mx(N),x.sessions=N,x.activeSessionId=q.id,es(N),wi(q.id);else{const J=mx(N)+1;xi.current=J;const ee=`session-${J}-${Date.now()}`,ne={id:ee,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},pe=[...N,ne];x.sessions=pe,x.activeSessionId=ee,es(pe),wi(ee)}}vc.current=!0},[vl,u,bl,$o]);const ln=h.useMemo(()=>Zr.find(x=>x.id===gr)||null,[Zr,gr]),On=(ln==null?void 0:ln.running)??!1,kl=(ln==null?void 0:ln.statusLine)??"",Sl=(ln==null?void 0:ln.segments)??[],Nl=(ln==null?void 0:ln.thread)??[],ed=(ln==null?void 0:ln.steps)??[];ln==null||ln.outputDismissed;const Nt=(ln==null?void 0:ln.phaseContext)??null,Do=h.useRef([]),[td,kc]=h.useState(!1),vi=h.useRef(null),jl=h.useRef(null);h.useEffect(()=>{const x=jl.current;x&&requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight})},[Nl,Sl]);const Rs=h.useRef(null),nd=h.useRef(!1),Qg=h.useRef(null),Sp=h.useCallback(x=>{const N=++xi.current,H=`session-${N}-${Date.now()}`,q={id:H,label:x||e("flow:composer.conversationLabel",{n:N}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return es(Y=>[...Y,q]),wi(H),H},[]);h.useEffect(()=>{!u||!vc.current||(bc.current.sessions=Zr,bc.current.activeSessionId=gr,$o(u,Zr,gr))},[Zr,gr,u,$o]),h.useEffect(()=>{xi.current=Math.max(xi.current,mx(Zr))},[Zr]);const Np=h.useCallback(x=>{var N;Rs.current===x&&((N=vi.current)==null||N.abort()),es(H=>{const q=H.filter(J=>J.id!==x);if(H.some((J,ee)=>J.id===x&&H.findIndex(ne=>ne.id===gr)===ee)||gr===x){const J=q;J.length>0?wi(J[J.length-1].id):setTimeout(()=>{xi.current=0;const ee=++xi.current,ne=`session-${ee}-${Date.now()}`,pe={id:ne,label:e("flow:composer.conversationLabel",{n:ee}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};es(ye=>[...ye,pe]),wi(ne)},0)}return q})},[gr]),Vr=h.useCallback(x=>{es(N=>{const H=N.findIndex(J=>J.id===gr);if(H<0)return N;const q={...N[H]};x(q);const Y=[...N];return Y[H]=q,Y})},[gr]),rd=h.useCallback(x=>{Vr(N=>{N.running=x})},[Vr]),Ls=h.useCallback(x=>{Vr(N=>{N.statusLine=x})},[Vr]),Zs=h.useCallback(x=>{Vr(N=>{typeof x=="function"?N.segments=x(N.segments):N.segments=x})},[Vr]),jp=h.useCallback(x=>{Vr(N=>{typeof x=="function"?N.thread=x(N.thread):N.thread=x})},[Vr]),Cl=h.useCallback(x=>{Vr(N=>{typeof x=="function"?N.steps=x(N.steps):N.steps=x})},[Vr]),El=h.useCallback(x=>{Vr(N=>{N.outputDismissed=x})},[Vr]),_l=h.useCallback(x=>{Vr(N=>{N.phaseContext=typeof x=="function"?x(N.phaseContext):x})},[Vr]),Cp=h.useCallback(x=>{wi(x),es(N=>{const H=N.findIndex(Y=>Y.id===x);if(H<0||!N[H].outputDismissed)return N;const q=[...N];return q[H]={...N[H],outputDismissed:!1},q})},[]);h.useEffect(()=>{Do.current=Sl},[Sl]);const yr=h.useRef({}),sd=h.useRef(!1),ei=h.useRef(null),Sc=h.useRef(null),ki=h.useRef(null),nr=h.useRef(!1),id=h.useRef(0),Pl=h.useRef(""),[At,bt,Ep]=_A([]),[S,I,K]=PA([]),X=h.useRef(At),Q=h.useRef(S),ie=h.useRef(null),te=h.useRef(null),oe=h.useRef(null),me=h.useRef(null),[be,Fe]=h.useState(null),Xe=h.useCallback(x=>{var N;yr.current=(N=x==null?void 0:x.extra)!=null&&N.instances&&typeof x.extra.instances=="object"?x.extra.instances:{},bt(Array.isArray(x==null?void 0:x.nodes)?x.nodes:[]),I(Array.isArray(x==null?void 0:x.edges)?x.edges:[]),Fe(null)},[I,bt]),yt=h.useMemo(()=>({instances:yr.current}),[S,At]),{resetHistory:tt,undo:Dt,redo:Bn}=dT({nodes:At,edges:S,extra:yt,enabled:!!u&&nr.current&&Le==="edit",onRestore:Xe}),Gn=h.useMemo(()=>At.filter(x=>{var N;return(((N=x.data)==null?void 0:N.definitionId)||"").startsWith("provide_")}),[At]),It=h.useMemo(()=>{var N;const x={};for(const H of At){if(!((N=H.data)!=null&&N.inputs))continue;const q=H.data.inputs;for(let Y=0;Y<q.length;Y++){const J=q[Y];if(!(J!=null&&J.name))continue;const ee=S.find(pe=>pe.target===H.id&&pe.targetHandle===`input-${Y}`);if(!(ee!=null&&ee.source))continue;Gn.find(pe=>pe.id===ee.source)&&(x[ee.source]=J.name)}}return x},[At,S,Gn]),rr=h.useMemo(()=>{if(Le==="edit"||Zn.size===0)return null;const x=new Set(Zn);for(const N of S)Zn.has(N.source)&&x.add(N.target),Zn.has(N.target)&&x.add(N.source);return x},[Le,Zn,S]),Qi=h.useMemo(()=>Le==="edit"?At:At.map(x=>{var N,H;return{...x,draggable:!1,connectable:!1,data:{...x.data,isRunMode:!0,isExecuting:Zn.has(x.id),nodeStatus:((N=jr[x.id])==null?void 0:N.status)??null,nodeElapsed:((H=jr[x.id])==null?void 0:H.elapsed)??null,isDim:rr?!rr.has(x.id):!1}}}),[Le,At,Zn,jr,rr]),Ur=h.useMemo(()=>rr?S.map(x=>{const N=Zn.has(x.source)||Zn.has(x.target),H=x.className?x.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",q=N?"af-flow-edge--focus":"af-flow-edge--dim";return{...x,className:(H?H+" ":"")+q}}):S,[S,Zn,rr]);h.useEffect(()=>{if(!u){Xs({}),Br(null),la(Nd),pc(bh),qi(null),Ao(""),fc("");return}const x=new URLSearchParams({flowId:u.id,flowSource:u.source||"user"});u.archived&&x.set("archived","1"),fetch(`/api/flow/run-config?${x.toString()}`).then(N=>N.json()).then(N=>{Xs(N.presets||{}),Br(N.activePreset||null)}).catch(()=>{Xs({}),Br(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const xr=h.useCallback(x=>{mi.current+=1,la(x)},[]),ct=h.useCallback(async(x,N={})=>{if(!x)return;const H=!!N.quiet,q=!!N.force,Y=mi.current;H||(Yu(!0),Ao(""),fc(""));const J=new URLSearchParams({flowId:x.id,flowSource:x.source||"user"});x.archived&&J.set("archived","1");try{const ee=await fetch(`/api/flow/schedule?${J.toString()}`),ne=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(ne.error||`HTTP ${ee.status}`);if(!q&&mi.current!==Y)return;la({...Nd,...ne.schedule||{}}),pc(ne.state&&typeof ne.state=="object"?ne.state:bh),qi(ne.status||null)}catch(ee){if(!q&&mi.current!==Y)return;la(Nd),pc(bh),qi(null),Ao(String(ee.message||ee))}finally{Yu(!1)}},[]);h.useEffect(()=>{if(!u)return;let x=!1;return(async()=>{await ct(u)})(),()=>{x=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,ct]),h.useEffect(()=>{var H,q,Y,J;if(!Po||!Er[Po]||Gn.length===0)return;const x=Er[Po],N={};for(const ee of Gn){const ne=It[ee.id];if(!ne)continue;const pe=((H=ee.data)==null?void 0:H.definitionId)||"",ye=x[ee.id]??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"";pe.startsWith("provide_file")?N[ne]={type:"file",path:ye}:N[ne]={type:"str",value:ye}}Object.keys(N).length>0&&U(N)},[Po,Er,Gn,It]);const gn=h.useCallback(()=>{if(!qn||!jn.current)return;const x=jn.current.value;bt(N=>N.map(H=>{var q,Y;return H.id!==qn.instanceId?H:{...H,data:{...H.data,outputs:((Y=(q=H.data)==null?void 0:q.outputs)==null?void 0:Y.map((J,ee)=>ee===0?{...J,default:x}:J))||[{type:"text",name:"value",default:x}]}}})),Ro(null)},[qn,bt]),Ze=h.useMemo(()=>{const x=At.filter(N=>N.selected);return x.length===1?x[0]:null},[At]),ts=h.useMemo(()=>u?VU(At,S,e):[],[u,At,S,e]),Nc=h.useMemo(()=>ts.map(x=>x.key).join("|"),[ts]),ke=h.useMemo(()=>ts.some(x=>String((x==null?void 0:x.level)||"warning").toLowerCase()==="error"),[ts]);h.useLayoutEffect(()=>{se(ts.length>0&&!ke)},[Nc,u==null?void 0:u.id,u==null?void 0:u.source,ts.length,ke]),xa.current=Ze,h.useEffect(()=>{X.current=At},[At]),h.useEffect(()=>{const x=i.current,N=new Map,H=[];for(const ee of At){const ne=n7(ee);N.set(ee.id,ne),x.get(ee.id)!==ne&&H.push(ee.id)}if(i.current=N,H.length===0)return;const q=()=>H.forEach(ee=>{var ne;return(ne=s.current)==null?void 0:ne.call(s,ee)}),Y=window.requestAnimationFrame(q),J=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Y),window.clearTimeout(J)}},[At]),h.useEffect(()=>{Q.current=S},[S]),h.useEffect(()=>{oe.current=be},[be]),h.useEffect(()=>{if(!be)return;const x=H=>{H.key==="Escape"&&Fe(null)},N=H=>{var q,Y;(Y=(q=H.target)==null?void 0:q.closest)!=null&&Y.call(q,".af-connect-node-menu")||Fe(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",N)}},[be]),h.useEffect(()=>()=>{ki.current!=null&&(clearTimeout(ki.current),ki.current=null)},[]);const ft=h.useMemo(()=>{var N;if(!Ze)return null;const x=(N=Ze.data)==null?void 0:N.definitionId;return ae.find(H=>H.id===x)??null},[Ze,ae]),dt=h.useMemo(()=>{const x={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const N of ae){const H=u0(N);x[H].push(N)}for(const N of Md)x[N].sort((H,q)=>H.id.localeCompare(q.id));return x},[ae]),nt=h.useMemo(()=>{const x=_e.trim().toLowerCase();if(!x)return dt;const N={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const H of Md)N[H]=dt[H].filter(q=>QK(q,x));return N},[dt,_e]),$e=h.useMemo(()=>Md.reduce((x,N)=>x+nt[N].length,0),[nt]),Tt=h.useMemo(()=>ae.filter(x=>{const N=String(x.id??""),H=String(x.source??"");return N.startsWith("marketplace:")||H==="marketplace"||H==="collection"}),[ae]),Xt=h.useMemo(()=>{const x=new Set;for(const N of Tt){const H=String(N.id??"");if(H&&(x.add(H),H.startsWith("marketplace:"))){const q=H.slice(12),[Y]=q.split("@");Y&&x.add(`marketplace:${Y}`)}}return x},[Tt]),Ft=h.useCallback(async()=>{f("");try{const x=await fetch("/api/flows");if(!x.ok)throw new Error("HTTP "+x.status);c(await x.json())}catch(x){f(String(x.message||x))}},[]);h.useEffect(()=>{Ft()},[Ft]),h.useEffect(()=>{if(r!=="/flow")return;const x=new URLSearchParams(window.location.search);x.get("new")==="1"&&!x.get("flowId")&&n("/projects?new=1")},[r,n]),h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/model-lists").then(q=>q.json()).then(q=>{x||yp({cursor:Array.isArray(q.cursor)?q.cursor.map(String):[],opencode:Array.isArray(q.opencode)?q.opencode.map(String):[],claudeCode:Array.isArray(q.claudeCode)?q.claudeCode.map(String):[]})}).catch(()=>{})};N();const H=setTimeout(N,4e3);return()=>{x=!0,clearTimeout(H)}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skills").then(N=>N.json()).then(N=>{if(x)return;const H=Array.isArray(N.skills)?N.skills.filter(q=>q&&typeof q.key=="string"&&q.key.trim()).map(q=>({key:String(q.key),name:String(q.name||q.id||q.key),description:q.description?String(q.description):"",sourceLabel:q.sourceLabel?String(q.sourceLabel):""})):[];pt(H),Ju(!0)}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skill-collections").then(N=>N.json()).then(N=>{x||(Yg(qa(N)),Gg(!0))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{if(Zu(""),!(!xp||!wp)){if(!bi){Lo([]);return}Lo(M_(bi,"pipeline",Wr,wc)),Zu(bi)}},[wc,wp,Wr,xp,bi]),h.useEffect(()=>{if(!(kp!==bi||!bi))try{localStorage.setItem(bi,JSON.stringify($t))}catch{}},[$t,bi,kp]);const cn=h.useCallback(async x=>{const N=x.source??"user",H=!!x.archived,q=new URLSearchParams({flowId:x.id,flowSource:N});H&&q.set("archived","1");const Y=new URLSearchParams({flowId:x.id,flowSource:N});H&&Y.set("archived","1"),Y.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[J,ee]=await Promise.all([fetch("/api/flow?"+q.toString()),fetch("/api/nodes?"+Y.toString())]),ne=await J.json();if(!J.ok||ne.error)throw new Error(ne.error||e("flow:nodePropsError.loadFlowFailed"));const pe=await ee.json();if(!ee.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const ye=Array.isArray(pe)?pe:Array.isArray(pe==null?void 0:pe.nodes)?pe.nodes:[],De=!Array.isArray(pe)&&(pe==null?void 0:pe.pipelineTranslations)||{},ce=BU(ne.flowYaml||"");if(ce.error)throw new Error(ce.error);const Me={...ce.instances||{}},Se=ce.nodes.map(un=>zf(un,Me,ye,De,x.id)),ht=uT(ce.edges,Se);return{flowSource:N,paletteList:ye,instances:Me,flowDescriptionText:ce.description??"",viewport:Kj(ce.viewport),nodes:Se,edges:ht}},[t.language,e]),Rt=h.useCallback(async(x,N={})=>{const H=!!N.preserveComposer,q=H&&!!N.incrementalSync;nr.current=!1,id.current+=1,p(x),k(""),H||(j(""),we(""),re(null),v(""),z(""),M(""),gl(""),jp([]),Zs([]),Cl([]),El(!1),_l(null),Xu("pan")),q||(yr.current={},bt([]),I([])),Gj(x);try{const Y=await cn(x);if(ve(Y.paletteList),yr.current=Y.instances,v(Y.flowDescriptionText),z(x.id||""),q){const J=X.current,ee=Q.current;try{const ne=xW(J,ee,Y.nodes,Y.edges),pe=new Set([...ne.changes.addedNodeIds,...ne.changes.updatedNodeIds]),ye=new Set([...ne.changes.addedEdgeKeys,...ne.changes.updatedEdgeKeys]),De=pe.size>0?ne.nodes.map(Me=>pe.has(Me.id)?{...Me,className:Oj(Me.className,Rj)}:Me):ne.nodes,ce=ye.size>0?ne.edges.map(Me=>ye.has(Of(Me))?{...Me,className:Oj(Me.className,Lj)}:Me):ne.edges;bt(De),I(ce),ki.current!=null&&(clearTimeout(ki.current),ki.current=null),(pe.size>0||ye.size>0)&&(ki.current=window.setTimeout(()=>{ki.current=null,pe.size>0&&bt(Me=>Me.map(Se=>{if(!pe.has(Se.id))return Se;const ht=Mj(Se.className,Rj);return ht===String(Se.className||"")?Se:{...Se,className:ht}})),ye.size>0&&I(Me=>Me.map(Se=>{if(!ye.has(Of(Se)))return Se;const ht=Mj(Se.className,Lj);return ht===String(Se.className||"")?Se:{...Se,className:ht}}))},GK))}catch{bt(Y.nodes),I(Y.edges)}}else if(bt(Y.nodes),I(Y.edges),Sc.current=Y.viewport||null,Y.viewport){const J=()=>{var ee;try{(ee=ei.current)==null||ee.setViewport(Y.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else g(J=>J+1);eh(x.id,Y.flowSource),mp(J=>J+1),tt(Y.nodes,Y.edges,{instances:Y.instances});try{Pl.current=gj(Y.nodes,Y.edges,Y.instances,{description:Y.flowDescriptionText,viewport:Sc.current})}catch{Pl.current=""}nr.current=!0}catch(Y){k(String(Y.message||Y))}},[cn,tt,bt,I]),Et=h.useCallback(async()=>{if(!(u!=null&&u.id))return;const x=u.source??"user",N=new URLSearchParams({flowId:u.id,flowSource:x});u.archived&&N.set("archived","1"),N.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const H=await fetch("/api/nodes?"+N.toString()),q=await H.json();if(!H.ok)throw new Error((q==null?void 0:q.error)||e("flow:nodePropsError.loadNodesFailed"));const Y=Array.isArray(q)?q:Array.isArray(q==null?void 0:q.nodes)?q.nodes:[];ve(Y)},[u,e,t.language]),Zt=h.useCallback(async()=>{or(!0),kn("");try{const x=await fetch("/api/marketplace/nodes"),N=await x.json().catch(()=>({}));if(!x.ok)throw new Error((N==null?void 0:N.error)||"Failed to load marketplace nodes");Tn(Array.isArray(N==null?void 0:N.nodes)?N.nodes:[])}catch(x){kn(String(x.message||x)),Tn([])}finally{or(!1)}},[]),Pr=h.useCallback(async()=>{Ue(!0),nn("");try{const x=await fetch("/api/marketplace/flow-snippets"),N=await x.json().catch(()=>({}));if(!x.ok)throw new Error((N==null?void 0:N.error)||"Failed to load flow snippets");et(Array.isArray(N==null?void 0:N.snippets)?N.snippets:[])}catch(x){nn(String(x.message||x)),et([])}finally{Ue(!1)}},[]);h.useEffect(()=>{u&&(Zt(),Pr())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Zt,Pr]);const Si=h.useCallback(async x=>{if(!u||!x)return;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`;if(N){Sn(N),kn("");try{const H=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,nodeSpec:N})}),q=await H.json().catch(()=>({}));if(!H.ok||(q==null?void 0:q.ok)===!1)throw new Error((q==null?void 0:q.error)||"Failed to install marketplace node");await Et()}catch(H){kn(String(H.message||H))}finally{Sn("")}}},[u,Et]),Zi=h.useCallback(async(x,N)=>{const H={packageId:(x==null?void 0:x.newId)||(x==null?void 0:x.id)||(x==null?void 0:x.label),label:(x==null?void 0:x.label)||(x==null?void 0:x.newId)||(x==null?void 0:x.id),version:"1.0.0",definitionId:N,body:(x==null?void 0:x.body)||"",script:(x==null?void 0:x.script)||"",inputs:Array.isArray(x==null?void 0:x.inputs)?x.inputs:[],outputs:Array.isArray(x==null?void 0:x.outputs)?x.outputs:[],flowId:u==null?void 0:u.id,flowSource:(u==null?void 0:u.source)||"user"},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),Y=await q.json();if(!q.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Publish failed");return await Et(),Y},[Et,u]),eo=h.useCallback(async()=>{var q;if(!u||ge.current)return;const x=u.id,N=u.source??"user",H=((q=xa.current)==null?void 0:q.id)??null;ge.current=!0,fe(!0);try{await Rt({id:x,source:N,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),H&&bt(Y=>Y.map(J=>({...J,selected:J.id===H})))}finally{ge.current=!1,fe(!1)}},[u,u==null?void 0:u.archived,Rt,bt]);h.useEffect(()=>{if(sd.current||l.length===0)return;const x=new URLSearchParams(window.location.search),N=x.get("flowId");if(!N)return;const H=x.get("flowSource")??"user",q=x.get("flowArchived")==="1",Y=l.find(J=>J.id===N&&(J.source??"user")===H&&!!J.archived===q);Y&&(sd.current=!0,Rt(Y))},[l,Rt]);const jc=h.useRef(0);h.useEffect(()=>{if(!u)return;const x=u.id,N=u.source??"user",H=!!u.archived;jc.current=0;let q=!1;const Y=async()=>{var ne;if(q)return;const ee=new URLSearchParams({flowId:x,flowSource:N,v:String(jc.current)});H&&ee.set("archived","1");try{const pe=await fetch("/api/flow-editor-sync-poll?"+ee.toString());if(!pe.ok||q)return;const ye=await pe.json();if(q)return;if(ye.changed){jc.current=ye.version;const De=((ne=xa.current)==null?void 0:ne.id)??null;await Rt({id:x,source:N,archived:H},{preserveComposer:!0,incrementalSync:!0}),await ct({id:x,source:N,archived:H},{quiet:!0,force:!0}),De&&bt(ce=>ce.map(Me=>({...Me,selected:Me.id===De})))}else jc.current=ye.version}catch{}},J=window.setInterval(Y,2e3);return Y(),()=>{q=!0,window.clearInterval(J)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Rt,ct,bt]);const Zg=h.useMemo(()=>w?w.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":w===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[w]);h.useEffect(()=>{if(!w)return;w===e("flow:status.saved")||w.startsWith(e("flow:status.runInTerminal"));const x=w.startsWith(e("flow:status.runInTerminal"))?5200:2800,N=window.setTimeout(()=>j(""),x);return()=>clearTimeout(N)},[w,e]),h.useEffect(()=>{C("")},[u==null?void 0:u.id,u==null?void 0:u.source]),h.useEffect(()=>{const x=()=>{window.__provideEditContent&&(Ro(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",x),()=>window.removeEventListener("provide-expand",x)},[]),h.useEffect(()=>{var ne,pe,ye,De,ce,Me,Se;if(!Ze){wa(null);return}const x=yr.current[Ze.id]||{},{inputs:N,outputs:H}=cT(Ze),q=String(((ne=Ze.data)==null?void 0:ne.definitionId)??Ze.id??""),Y=((pe=Ze.data)==null?void 0:pe.script)!=null?String(Ze.data.script):void 0,J=x.script!=null?String(x.script):void 0,ee=q==="tool_nodejs"||Y&&Y.trim()!==""||J&&J.trim()!==""?String(Y??J??""):"";wa({id:Ze.id,newId:Ze.id,label:String(((ye=Ze.data)==null?void 0:ye.label)??Ze.id),role:((De=Ze.data)==null?void 0:De.role)??"普通",model:String(((ce=Ze.data)==null?void 0:ce.model)??x.model??""),body:String(((Me=Ze.data)==null?void 0:Me.body)??x.body??""),images:ws(((Se=Ze.data)==null?void 0:Se.images)??x.images),script:ee,inputs:N,outputs:H})},[Ze==null?void 0:Ze.id,hp]),h.useEffect(()=>{u&&(Ze||(gc.current=null,re(x=>x==="node"?null:x)))},[u,Ze==null?void 0:Ze.id]);const _p=h.useCallback(()=>{gc.current=null,re(x=>x==="settings"||x==="history"?x:"node")},[]),DR=h.useCallback((x,N)=>{x.metaKey||x.ctrlKey||x.shiftKey||Le!=="edit"&&Ts((N==null?void 0:N.id)??null)},[Le]),FR=h.useCallback((x,N)=>{Le==="edit"&&(x.preventDefault(),bt(H=>H.map(q=>({...q,selected:q.id===N.id}))),I(H=>H.map(q=>({...q,selected:!1}))),_p())},[_p,Le,I,bt]),zR=h.useCallback((x,N)=>{if(Le!=="edit")return;const H=x.metaKey||x.ctrlKey||x.shiftKey;I(q=>q.map(Y=>Y.id===N.id?{...Y,selected:!Y.selected||!H}:H?Y:{...Y,selected:!1})),H||bt(q=>q.map(Y=>({...Y,selected:!1})))},[Le,I,bt]),BR=h.useCallback(x=>Bj(x,X.current),[]),HR=h.useCallback(x=>{if(!Bj(x,X.current)){j("端口类型不匹配,已取消连线");return}Fe(null),bt(N=>Um(N,x)),I(N=>{const H=N.filter(q=>!(q.target===x.target&&q.targetHandle===x.targetHandle));return Tf({...x,markerEnd:{type:Ns.ArrowClosed}},H)})},[I,bt]),WR=h.useCallback((x,N)=>{te.current=r7(N,X.current),Fe(null)},[]),VR=h.useCallback((x,N)=>{var Se,ht,un,dn;const H=te.current;if(te.current=null,!u||!H||N!=null&&N.toNode)return;const q=i7(ae,H);if(q.length===0){j(`没有匹配 ${H.slotType} 端口的节点`);return}const Y=((ht=(Se=x==null?void 0:x.changedTouches)==null?void 0:Se[0])==null?void 0:ht.clientX)??(x==null?void 0:x.clientX),J=((dn=(un=x==null?void 0:x.changedTouches)==null?void 0:un[0])==null?void 0:dn.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(Y)||!Number.isFinite(J))return;const ee=ei.current,ne=document.querySelector(".af-pipeline-flow .react-flow");if(!ee||!ne)return;const pe=ne.getBoundingClientRect(),ye=320,De=Math.min(440,104+q.length*58),ce=Math.max(12,Math.min(Y-pe.left,pe.width-ye-12)),Me=Math.max(12,Math.min(J-pe.top,pe.height-De-12));Fe({left:ce,top:Me,flowPosition:ee.screenToFlowPosition({x:Y,y:J}),draft:H,candidates:q,query:""})},[ae,u]),UR=h.useCallback(x=>{for(const N of x)delete yr.current[N.id]},[]),KR=h.useCallback(x=>{ei.current=x},[]),qR=h.useCallback(x=>{bt(H=>H.map(q=>({...q,selected:q.id===x}))),I(H=>H.map(q=>({...q,selected:!1}))),_p();const N=()=>{var pe,ye,De;const H=ei.current;if(!(H!=null&&H.getNode))return;const q=H.getNode(x);if(!q)return;const Y=(pe=H.getInternalNode)==null?void 0:pe.call(H,x),J=((ye=Y==null?void 0:Y.measured)==null?void 0:ye.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((De=Y==null?void 0:Y.measured)==null?void 0:De.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:ne}=H.getViewport();H.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:Uj(ne),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(N))},[bt,I,_p]),YR=h.useCallback(x=>{bt(H=>H.map(q=>({...q,selected:q.id===x}))),I(H=>H.map(q=>({...q,selected:!1})));const N=()=>{var ye,De,ce;const H=ei.current;if(!(H!=null&&H.getNode))return;const q=H.getNode(x);if(!q)return;const Y=(ye=H.getInternalNode)==null?void 0:ye.call(H,x),J=((De=Y==null?void 0:Y.measured)==null?void 0:De.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((ce=Y==null?void 0:Y.measured)==null?void 0:ce.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:ne}=H.getViewport(),pe=Uj(ne);H.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:pe,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(N))},[bt,I]),Cc=h.useCallback((x,N)=>{const H=`node-${Date.now()}`;return _T(x,H,N,yr.current,ae)},[ae]),j0=h.useCallback(x=>{if(!u||!x)return;let N={x:180,y:160};const H=ei.current,q=document.querySelector(".af-pipeline-flow .react-flow");if(H&&q){const Y=q.getBoundingClientRect();N=H.screenToFlowPosition({x:Y.left+Y.width*.45,y:Y.top+Y.height*.38})}bt(Y=>[...Y,Cc(x,N)])},[u,bt,Cc]),GR=h.useCallback(x=>{const N=oe.current;if(!u||!N||!(x!=null&&x.def))return;const H=Cc(x.def,N.flowPosition),q=N.draft.handleType==="source"?{source:N.draft.nodeId,sourceHandle:N.draft.handleId,target:H.id,targetHandle:`input-${x.slotIndex}`}:{source:H.id,sourceHandle:`output-${x.slotIndex}`,target:N.draft.nodeId,targetHandle:N.draft.handleId};bt(Y=>Um([...Y,H],q)),I(Y=>{const J=Y.filter(ee=>!(ee.target===q.target&&ee.targetHandle===q.targetHandle));return Tf({...q,markerEnd:{type:Ns.ArrowClosed}},J)}),Fe(null)},[u,Cc,bt,I]),XR=h.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),JR=h.useCallback(x=>{var ee;if(x.preventDefault(),!u)return;const N=ei.current;if(!N)return;const H=N.screenToFlowPosition({x:x.clientX,y:x.clientY}),q=x.dataTransfer.getData("application/agentflow-snippet");if(q){const ne=ut.find(pe=>`${pe.id}@${pe.version}`===q);ne&&((ee=me.current)==null||ee.call(me,ne,H));return}const Y=x.dataTransfer.getData("application/agentflow-node");if(!Y)return;const J=ae.find(ne=>ne.id===Y);J&&bt(ne=>[...ne,Cc(J,H)])},[u,ae,ut,bt,Cc]),ti=h.useCallback(async(x,N)=>{if(!u)return;const H=gj(x,N,yr.current,{description:b,viewport:Sc.current});if(H!==Pl.current){j(e("flow:status.saving"));try{const q=S7(u.source),Y=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:q,flowYaml:H,...u.archived?{flowArchived:!0}:{}})}),J=await Y.json();if(!Y.ok||!J.success)throw new Error(J.error||e("flow:status.saveFailed"));if(Pl.current=H,j(e("flow:status.saved")),ni(u.source)&&q==="workspace"){const ee={id:u.id,source:"workspace",path:void 0};p(ee),Gj(ee),eh(u.id,"workspace")}}catch(q){j(e("flow:status.saveFailed")+": "+(q.message||q))}}},[u,b]);h.useEffect(()=>{if(!u||!nr.current||Le!=="edit"||u.archived)return;const x=id.current,N=setTimeout(()=>{x===id.current&&nr.current&&ti(X.current,Q.current)},400);return()=>clearTimeout(N)},[At,S,b,Le,u,ti]);const Pp=h.useCallback(async x=>{if(!u||u.archived)return;const N=u.source??"user";if(!(N!=="user"&&N!=="workspace")&&N!==x){B(!0),C("");try{const H=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:N,toSource:x})}),q=await H.json().catch(()=>({}));if(!H.ok)throw new Error(typeof q.error=="string"?q.error:e("flow:composer.requestFailed"));const Y=q.flowSource==="workspace"||q.flowSource==="user"?q.flowSource:x;let J={id:u.id,source:Y,archived:u.archived};try{const ee=await fetch("/api/flows");if(ee.ok){const ne=await ee.json(),pe=Array.isArray(ne)?ne.find(ye=>ye.id===u.id&&(ye.source??"user")===Y&&!!ye.archived==!!u.archived):null;pe&&(J=pe)}}catch{}await Rt(J,{preserveComposer:!0}),eh(u.id,Y)}catch(H){C(String(H.message||H))}finally{B(!1)}}},[u,Rt]),ey=h.useCallback(async()=>{if(u){dc(!0),Ao(""),fc("");try{const x=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",archived:!!u.archived,schedule:cr})}),N=await x.json().catch(()=>({}));if(!x.ok||!N.success)throw new Error(N.error||"Failed to save schedule");la({...Nd,...N.schedule||{}}),fc(e("flow:schedule.saved")),await ct(u,{quiet:!0,force:!0})}catch(x){Ao(String(x.message||x))}finally{dc(!1)}}},[u,cr,ct,e]),QR=h.useCallback(async()=>{u&&(await ti(X.current,Q.current),!u.archived&&u.source!=="builtin"&&await ey())},[u,ti,ey]),Ap=h.useCallback(async()=>{if(!u||!F.trim())return;const x=F.trim();if(x===u.id){M("");return}O(!0),M("");try{const N=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",newFlowId:x})}),H=await N.json().catch(()=>({}));if(!N.ok)throw new Error(typeof H.error=="string"?H.error:e("flow:composer.requestFailed"));let q={id:H.flowId,source:H.flowSource??u.source,archived:u.archived};try{const Y=await fetch("/api/flows");if(Y.ok){const J=await Y.json(),ee=Array.isArray(J)?J.find(ne=>ne.id===H.flowId&&(ne.source??"user")===(H.flowSource??u.source)):null;ee&&(q=ee)}}catch{}await Rt(q,{preserveComposer:!0}),eh(H.flowId,H.flowSource??u.source)}catch(N){M(String(N.message||N))}finally{O(!1)}},[u,F,Rt]),C0=h.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{E(!0),setTimeout(()=>E(!1),2e3)}).catch(()=>{})},[]),ty=h.useCallback(()=>{ti(At,S)},[ti,At,S]),E0=h.useCallback(()=>{var N,H;if(!u)return;const x=Kj((H=(N=ei.current)==null?void 0:N.getViewport)==null?void 0:H.call(N));x&&(Sc.current=x,j("已固定 Pipeline 进入视角"),ti(X.current,Q.current))},[ti,u]),ZR=h.useCallback((x,N)=>{const H=N.trim()===""||N==="default"?void 0:N.trim(),q=At.map(Y=>Y.id===x?{...Y,data:{...Y.data,model:H}}:Y);bt(q),ti(q,S)},[At,S,bt,ti]),Ip=h.useCallback(()=>{var ht,un;if(!gt||!u||!Ze)return!1;const x=Ze.id,N=gt.newId.trim();if(wl(""),!bT.test(N))return wl(e("flow:nodePropsError.invalidInstanceId")),!1;if(At.some(dn=>dn.id===N&&dn.id!==x))return wl(e("flow:nodePropsError.duplicateInstanceId")),!1;const H=gt.role.trim(),q=tl.includes(H)?H:"普通",Y=gt.model.trim(),J=dn=>(Array.isArray(dn)?dn:[]).map(Ut=>({type:String((Ut==null?void 0:Ut.type)??"节点").trim()||"节点",name:String((Ut==null?void 0:Ut.name)??""),default:String((Ut==null?void 0:Ut.default)??""),required:!!(Ut!=null&&Ut.required),showOnNode:(Ut==null?void 0:Ut.showOnNode)!=null?Ut.showOnNode!==!1:!!(Ut!=null&&Ut.required)||String((Ut==null?void 0:Ut.type)??"节点").trim().toLowerCase()==="node"})),ee=J(gt.inputs),ne=J(gt.outputs),pe=String(((ht=Ze.data)==null?void 0:ht.definitionId)??N),ye=pe.startsWith("provide_"),De={...Ze.data,label:gt.label.trim()||N,role:q,model:Y===""||Y==="default"?void 0:Y,body:ye?"":gt.body,images:ye?[]:ws(gt.images),inputs:ee,outputs:ye&&Array.isArray((un=Ze.data)==null?void 0:un.outputs)?Ze.data.outputs:ne},ce=String(gt.script??"").trim();pe==="tool_nodejs"||ce!==""?De.script=String(gt.script??""):delete De.script;let Me,Se=S;if(N!==x){const dn={...yr.current},Ut={...dn[x]||{}};delete dn[x],dn[N]=Ut,yr.current=dn,Me=At.map(vt=>vt.id!==x?vt:{...vt,id:N,selected:!0,data:De}),Se=S.map((vt,Jt)=>({...vt,source:vt.source===x?N:vt.source,target:vt.target===x?N:vt.target,id:`e-${vt.source===x?N:vt.source}-${vt.target===x?N:vt.target}-${Jt}`}))}else Me=At.map(dn=>dn.id===x?{...dn,data:De}:dn);return bt(Me),I(Se),kr(N),ti(Me,Se),!0},[gt,u,Ze,At,S,bt,I,kr,ti]),ny=h.useCallback(()=>{var un,dn;if(!gt||!u||!Ze)return!1;const x=Ze.id,N=gt.role.trim(),H=tl.includes(N)?N:"普通",q=gt.model.trim(),Y=Ut=>(Array.isArray(Ut)?Ut:[]).map(vt=>({type:String((vt==null?void 0:vt.type)??"节点").trim()||"节点",name:String((vt==null?void 0:vt.name)??""),default:String((vt==null?void 0:vt.default)??""),required:!!(vt!=null&&vt.required),showOnNode:(vt==null?void 0:vt.showOnNode)!=null?vt.showOnNode!==!1:!!(vt!=null&&vt.required)||String((vt==null?void 0:vt.type)??"节点").trim().toLowerCase()==="node"})),J=Y(gt.inputs),ee=Y(gt.outputs),ne=String(((un=Ze.data)==null?void 0:un.definitionId)??x),pe=ne.startsWith("provide_"),ye=gt.label.trim()||x,De=q===""||q==="default"?void 0:q,ce={...Ze.data,label:ye,role:H,model:De,body:pe?"":gt.body,images:pe?[]:ws(gt.images),inputs:J,outputs:pe&&Array.isArray((dn=Ze.data)==null?void 0:dn.outputs)?Ze.data.outputs:ee},Me=String(gt.script??"").trim();ne==="tool_nodejs"||Me!==""?ce.script=String(gt.script??""):delete ce.script;const Se=Ze.data||{};return(Se.label!==ce.label||Se.role!==ce.role||Se.model!==ce.model||Se.body!==ce.body||JSON.stringify(ws(Se.images))!==JSON.stringify(ce.images)||(Se.script??void 0)!==(ce.script??void 0)||JSON.stringify(Se.inputs||[])!==JSON.stringify(J)||JSON.stringify(Se.outputs||[])!==JSON.stringify(ee))&&(bt(Ut=>Ut.map(vt=>vt.id===x?{...vt,data:ce}:vt)),kr(x)),!0},[gt,u,Ze,bt,kr]),_0=h.useRef(ny);h.useEffect(()=>{_0.current=ny},[ny]),h.useEffect(()=>{if(!gt||!u||!nr.current||Le!=="edit")return;const x=setTimeout(()=>{_0.current()},400);return()=>clearTimeout(x)},[gt,u,Le]);const e2=h.useCallback(()=>{if(!(!gt||!Ze)){if(gt.newId.trim()===Ze.id){wl("");return}Ip()}},[gt,Ze,Ip]);h.useEffect(()=>{const x=N=>{var ee,ne,pe;if(Le!=="edit")return;const H=hT(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){if(it==="node"&&Ze&&gt){N.preventDefault(),N.stopPropagation(),Ip()||ty();return}if(H)return;N.preventDefault(),N.stopPropagation(),ty();return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),xl(ye=>!ye);return}if(mc)return;if(yl){if(N.key==="Escape"){N.preventDefault(),ga(!1);return}if(qm(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ga(!1);return}(N.key==="v"||N.key==="V"||N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey&&N.preventDefault();return}if(H)return;const q=N.key.toLowerCase(),Y=(N.metaKey||N.ctrlKey)&&!N.shiftKey&&q==="z",J=(N.metaKey||N.ctrlKey)&&(N.shiftKey&&q==="z"||q==="y");if(Y||J){N.preventDefault(),N.stopPropagation();const ye=Y?Dt():Bn();j(ye?Y?"Undo canvas change":"Redo canvas change":Y?"Nothing to undo":"Nothing to redo");return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="c"){const ye=iT(X.current,Q.current,yr.current);ye&&(N.preventDefault(),N.stopPropagation(),ie.current=ye,j(`Copied ${ye.nodes.length} node${ye.nodes.length>1?"s":""}`));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="v"){const ye=oT(ie.current,X.current,Q.current,yr.current);ye&&(N.preventDefault(),N.stopPropagation(),yr.current=ye.instances,bt(ye.nodes),I(ye.edges),j(`Pasted ${ye.pastedNodeIds.length} node${ye.pastedNodeIds.length>1?"s":""}`));return}if((N.key==="a"||N.key==="A")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),(ee=st.current)==null||ee.focus(),(pe=(ne=st.current)==null?void 0:ne.select)==null||pe.call(ne);return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="a"){N.preventDefault(),N.stopPropagation(),bt(ye=>ye.map(De=>({...De,selected:!0}))),I(ye=>ye.map(De=>({...De,selected:!1})));return}if(qm(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ga(ye=>!ye);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Xu("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Xu("pan");return}if((N.key==="f"||N.key==="F")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),E0();return}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[ty,E0,yl,mc,it,Ze,gt,Ip,Le,Dt,Bn]),h.useEffect(()=>{if(Le!=="running"||Wt==null)return;let x=Math.floor((Date.now()-Wt)/1e3);const N=setInterval(()=>{const H=Date.now()-Wt,q=Math.floor(H/1e3);q!==x&&(x=q,Je(H))},500);return()=>clearInterval(N)},[Le,Wt]),h.useEffect(()=>{const x=ca.current;!x||!x.parentElement||ul.current&&(Yi.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Yi.current=!1}))},[Nr]),h.useEffect(()=>{const x=ca.current;if(!x)return;const N=x.parentElement;if(!N)return;const H=()=>{if(Yi.current)return;const q=N.scrollHeight-N.scrollTop-N.clientHeight;ul.current=q<40};return N.addEventListener("scroll",H,{passive:!0}),()=>N.removeEventListener("scroll",H)},[lr,Le]),h.useEffect(()=>{if(Le==="edit"||!lr)return;ul.current=!0;const x=ca.current;x&&(Yi.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Yi.current=!1}))},[Le,lr]),h.useEffect(()=>{Nr.length>Yh+qj&&mt(x=>x.length>Yh+qj?x.slice(-Yh):x)},[Nr]);const t2=h.useCallback(x=>{if(x.button!==0)return;x.preventDefault();const N=x.currentTarget;Ys.current={active:!0,pointerId:x.pointerId,startY:x.clientY,startH:Ui},N.setPointerCapture(x.pointerId)},[Ui]),n2=h.useCallback(x=>{const N=Ys.current;if(!N.active||x.pointerId!==N.pointerId)return;const H=N.startY-x.clientY;_o(Gh(N.startH+H))},[]),Tp=h.useCallback(()=>{_o(x=>{const N=Gh(x);try{localStorage.setItem(AT,String(N))}catch{}return N})},[]),P0=h.useCallback(x=>{const N=Ys.current;if(!(!N.active||x.pointerId!==N.pointerId)){N.active=!1;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}Tp()}},[Tp]),r2=h.useCallback(()=>{const x=Ys.current;x.active&&(x.active=!1,Tp())},[Tp]);h.useEffect(()=>{function x(){_o(N=>Gh(N))}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const to=h.useCallback(async(x={})=>{if(!u)return;const N=x.runUuid!=null&&String(x.runUuid).trim()?String(x.runUuid).trim():null,H=x.cliInputsOverride??he.current,q=!!x.prepareOnly;if(Ht(q?"ready":"running"),mt(q?[]:[{ts:new Date().toISOString(),type:"info",text:N?e("flow:run.connectingApiResume",{uuid:N}):e("flow:run.connectingApi")}]),zn(new Set),lt({}),_s(!q),re(null),N||As(null),q)return;if(!N){const J=Date.now();Yt(J),Je(0)}const Y=new AbortController;Js.current=Y;try{const J=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user",...N?{uuid:N}:{},cliInputs:H}),signal:Y.signal});if(!J.ok){const ce=await J.json().catch(()=>({error:e("flow:composer.requestFailed")}));mt(Me=>[...Me,{ts:new Date().toISOString(),type:"error",text:ce.error||e("flow:composer.requestFailed")}]),Ht("error");return}if(mt(ce=>[...ce,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){mt(ce=>[...ce,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),Ht("error");return}const ee=J.body.getReader(),ne=new TextDecoder;let pe="";const ye=ce=>{const Me=ce.ts||new Date().toISOString();if(ce.type==="event")if(ce.event==="node-start")zn(Se=>new Set(Se).add(ce.instanceId)),lt(Se=>({...Se,[ce.instanceId]:{status:"running",startMs:Date.now()}})),mt(Se=>[...Se,{ts:Me,type:"node-start",text:ce.label?e("flow:run.nodeStartWithLabel",{instanceId:ce.instanceId,label:ce.label}):e("flow:run.nodeStart",{instanceId:ce.instanceId})}]);else if(ce.event==="node-done"){zn(ht=>{const un=new Set(ht);return un.delete(ce.instanceId),un});const Se=ce.elapsed??null;lt(ht=>({...ht,[ce.instanceId]:{status:"success",elapsed:Se}})),mt(ht=>[...ht,{ts:Me,type:"node-done",text:Se?e("flow:run.nodeDoneWithElapsed",{instanceId:ce.instanceId,elapsed:Se}):e("flow:run.nodeDone",{instanceId:ce.instanceId})}])}else if(ce.event==="node-failed")zn(Se=>{const ht=new Set(Se);return ht.delete(ce.instanceId),ht}),lt(Se=>({...Se,[ce.instanceId]:{status:"failed",elapsed:ce.elapsed??null}})),mt(Se=>[...Se,{ts:Me,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:ce.instanceId})}]);else if(ce.event==="apply-start"){if(ce.uuid&&As(String(ce.uuid)),typeof ce.runStartTime=="number"&&ce.runStartTime>0)Yt(ce.runStartTime),Je(Math.max(0,Date.now()-ce.runStartTime));else if(typeof ce.totalExecutedMs=="number"&&ce.totalExecutedMs>0){const Se=Date.now()-ce.totalExecutedMs;Yt(Se),Je(ce.totalExecutedMs)}mt(Se=>[...Se,{ts:Me,type:"info",text:e("flow:run.pipelineStart",{uuid:ce.uuid||"?"})}])}else ce.event==="apply-done"?mt(Se=>[...Se,{ts:Me,type:"info",text:ce.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:ce.totalElapsed}):e("flow:run.pipelineDone")}]):ce.event==="apply-paused"?mt(Se=>[...Se,{ts:Me,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(ce.pendingNodes||[]).join(", ")})}]):mt(Se=>[...Se,{ts:Me,type:"event",text:`[${ce.event}] ${JSON.stringify(ce)}`}]);else ce.type==="user-check-content"?(dl({instanceId:ce.instanceId,execId:ce.execId??1,inputPath:ce.inputPath,outputPath:ce.outputPath,content:ce.content||""}),fl(ce.content||""),ua(!1),da(""),cs(!1),mt(Se=>[...Se,{ts:Me,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:ce.instanceId})}])):ce.type==="user-ask-prompt"?(pl({instanceId:ce.instanceId,execId:ce.execId??1,question:ce.question||"",options:Array.isArray(ce.options)?ce.options:[]}),hl(!1),mt(Se=>[...Se,{ts:Me,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:ce.instanceId,defaultValue:`等待用户选择 (${ce.instanceId})`})}])):ce.type==="tool-print-content"?(Qs({instanceId:ce.instanceId,execId:ce.execId??1,content:ce.content||"",createdAt:Date.now()}),Gu(!1)):ce.type==="log"?mt(Se=>[...Se,{ts:Me,type:"log",text:ce.text!=null?String(ce.text):""}]):ce.type==="error"?mt(Se=>[...Se,{ts:Me,type:"error",text:ce.message||e("flow:run.unknownError")}]):ce.type==="done"?mt(Se=>[...Se,{ts:Me,type:"done",text:e("flow:run.executionEnd",{exitCode:ce.exitCode??"?"})}]):mt(Se=>[...Se,{ts:Me,type:"log",text:JSON.stringify(ce)}])},De=ce=>{if(ce.trim())try{ye(JSON.parse(ce))}catch{mt(Me=>[...Me,{ts:new Date().toISOString(),type:"log",text:ce}])}};for(;;){const{done:ce,value:Me}=await ee.read();pe+=ne.decode(Me??new Uint8Array,{stream:!ce});const Se=pe.split(`
133
+ `);pe=Se.pop()??"";for(const ht of Se)De(ht);if(ce)break}pe.trim()&&De(pe),Ht("done")}catch(J){J.name==="AbortError"?(mt(ee=>[...ee,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),Ht("stopped")):(mt(ee=>[...ee,{ts:new Date().toISOString(),type:"error",text:J.message||e("flow:run.unknownError")}]),Ht("error"))}finally{Js.current=null,zn(new Set)}},[u]),[s2,ry]=h.useState(!1),i2=h.useCallback(()=>{ry(!0)},[]),o2=h.useCallback(async()=>{if(ry(!1),Js.current&&(Js.current.abort(),Js.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}Ht("stopped"),zn(new Set)},[u]),Al=h.useCallback(()=>{Ht("edit"),zn(new Set),lt({}),Ts(null),As(null)},[]),[a2,Rp]=h.useState(!1),l2=h.useCallback(async()=>{if(Rp(!1),Js.current&&(Js.current.abort(),Js.current=null),u)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source||"user"})})}catch{}Al()},[u,Al]),c2=h.useCallback(()=>{Rp(!1),n("/projects")},[n]),u2=h.useCallback(x=>{const N=x.runId!=null&&String(x.runId).trim()?String(x.runId).trim():null,H=x.flowId!=null&&String(x.flowId).trim()?String(x.flowId).trim():(u==null?void 0:u.id)!=null?String(u.id):null;As(N);const q=x.status||"unknown";let Y="stopped";q==="success"?Y="done":q==="failed"?Y="error":q==="running"?Y="running":Y="stopped",Ht(Y);const J=typeof x.at=="number"?x.at:null;if(Y==="running"&&J!=null?(Yt(J),Je(Math.max(0,Date.now()-J))):J!=null&&typeof x.endedAt=="number"&&x.endedAt>J?(Yt(null),Je(x.endedAt-J)):(Yt(null),Je(Math.max(0,x.durationMs??0))),mt([]),zn(new Set),lt({}),Ts(null),re(null),_s(!1),N&&H){const ee=new URLSearchParams({flowId:H,runId:N});fetch(`/api/run-node-statuses?${ee}`).then(ne=>ne.json()).then(ne=>{const pe=ne.statuses&&typeof ne.statuses=="object"?ne.statuses:{},ye={};for(const[De,ce]of Object.entries(pe))ce&&typeof ce=="object"&&typeof ce.status=="string"&&(ye[De]={status:ce.status,...ce.elapsed!=null&&String(ce.elapsed).trim()!==""?{elapsed:String(ce.elapsed)}:{}});lt(ye)}).catch(()=>{})}},[u==null?void 0:u.id]);h.useEffect(()=>{if(!(u!=null&&u.id)||Le!=="edit")return;let x=!1;return(async()=>{try{const N=await fetch("/api/pipeline-recent-runs"),H=await N.json();if(x||!N.ok)return;const Y=(Array.isArray(H.runs)?H.runs:[]).find(ne=>ne.flowId===u.id&&ne.status==="running");if(!Y||x)return;const J=Y.runId||null;As(J),Ht("running"),_s(!0),Yt(Y.at||Date.now()),Vi.current=0;const ee=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${J},已恢复运行视图`}];if(J){const ne=new URLSearchParams({flowId:u.id,runId:J}),ye=await(await fetch(`/api/run-node-statuses?${ne}`)).json();if(x)return;const De=ye.statuses&&typeof ye.statuses=="object"?ye.statuses:{},ce={},Me=new Set;for(const[Se,ht]of Object.entries(De))ht&&typeof ht=="object"&&typeof ht.status=="string"&&(ce[Se]={status:ht.status,...ht.elapsed!=null&&String(ht.elapsed).trim()!==""?{elapsed:String(ht.elapsed)}:{}},ht.status==="running"&&Me.add(Se));lt(ce),zn(Me);try{const Se=new URLSearchParams({flowId:u.id,runId:J,sinceBytes:"0",tailBytes:"262144"}),ht=await fetch(`/api/run-log?${Se}`);if(ht.ok){const un=await ht.json();if(!x){Vi.current=Number(un.bytes||0);const dn=Yj(typeof un.text=="string"?un.text:"");mt([...dn,...ee]);return}}}catch{}}mt(ee)}catch{}})(),()=>{x=!0}},[u==null?void 0:u.id]),h.useEffect(()=>{if(Le==="edit"||!(u!=null&&u.id)||!an)return;let x=!1,N=null;const H=async()=>{try{const q=new URLSearchParams({flowId:u.id,runId:an}),Y=await fetch(`/api/run-node-statuses?${q}`);if(!Y.ok)return;const J=await Y.json();if(x)return;const ee=J.statuses&&typeof J.statuses=="object"?J.statuses:{},ne={},pe=new Set;for(const[ye,De]of Object.entries(ee))De&&typeof De=="object"&&typeof De.status=="string"&&(ne[ye]={status:De.status,...De.elapsed!=null&&String(De.elapsed).trim()!==""?{elapsed:String(De.elapsed)}:{}},De.status==="running"&&pe.add(ye));lt(ye=>b7(ye,ne)?ye:ne),zn(ye=>v7(ye,pe)?ye:pe);try{const ye=new URLSearchParams({flowId:u.id,runId:an,sinceBytes:String(Vi.current||0),tailBytes:String(g7)}),De=await fetch(`/api/run-log?${ye}`);if(De.ok){const ce=await De.json();if(x)return;const Me=Number(ce.bytes||0),Se=typeof ce.text=="string"?ce.text:"";if(Se){const ht=Yj(Se);ht.length>0&&mt(un=>[...un,...ht])}Vi.current=Me}}catch{}try{const ye=await fetch("/api/pipeline-recent-runs");if(!ye.ok)return;const De=await ye.json();if(x)return;const Me=(Array.isArray(De.runs)?De.runs:[]).find(Se=>Se.flowId===u.id&&Se.runId===an);if(Me&&Me.status){const Se=Me.status;Se==="running"?Ht(ht=>ht==="running"?ht:"running"):Se==="success"?Ht("done"):Se==="failed"?Ht("error"):(Se==="stopped"||Se==="interrupted")&&Ht("stopped")}}catch{}}catch{}};return H(),N=window.setInterval(H,2500),()=>{x=!0,N&&window.clearInterval(N)}},[Le,u==null?void 0:u.id,an]),h.useEffect(()=>{if(it!=="history"||!u)return;let x=!1;return(async()=>{fi(!0),Ke("");try{const N=await fetch("/api/pipeline-recent-runs"),H=await N.json();if(!N.ok)throw new Error(H.error||"HTTP "+N.status);x||Ye(Array.isArray(H.runs)?H.runs:[])}catch(N){x||(Ke(String(N.message||N)),Ye([]))}finally{x||fi(!1)}})(),()=>{x=!0}},[it,u]),h.useEffect(()=>{if(!u){qs({files:[]});return}let x=!1;return(async()=>{aa(!0);try{const N=new URLSearchParams({flowId:u.id,flowSource:u.source||"user",archived:u.archived?"1":"0"}),H=await fetch(`/api/pipeline-files?${N}`),q=await H.json();if(!H.ok)throw new Error(q.error||"HTTP "+H.status);x||qs({files:Array.isArray(q.files)?q.files:[],path:q.path,error:q.error})}catch(N){x||qs({files:[],error:N.message||String(N)})}finally{x||aa(!1)}})(),()=>{x=!0}},[u]);const od=h.useMemo(()=>u?je.filter(x=>x&&x.flowId===u.id).sort((x,N)=>N.at-x.at):[],[je,u]),ns=h.useMemo(()=>{let x=0,N=0,H=0,q=0,Y=0;for(const J of od){const ee=J.status||"unknown";ee==="success"?x+=1:ee==="failed"?N+=1:ee==="running"?H+=1:ee==="stopped"?q+=1:ee==="interrupted"&&(Y+=1)}return{success:x,failed:N,running:H,stopped:q,interrupted:Y}},[od]),ad=h.useMemo(()=>u?Hj(us,hc):null,[u,us,hc]),Ni=h.useMemo(()=>{if(!ad||!u)return[];const x=ad.query.toLowerCase(),N=Y=>x?Y.some(J=>J&&String(J).toLowerCase().includes(x)):!0,H=At.map(Y=>{var ye,De;const J=Y.id,ee=String(((ye=Y.data)==null?void 0:ye.label)??J),ne=(De=Y.data)!=null&&De.definitionId?String(Y.data.definitionId):"",pe=[ee!==J?ee:"",ne&&ne!==J?ne:""].filter(Boolean);return{id:J,label:ee,defId:ne,subs:pe}}).filter(({id:Y,label:J,defId:ee})=>N([Y,J,ee])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,18).map(({id:Y,label:J,defId:ee})=>{const ne=[J!==Y?J:null,ee||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:Y,title:Y,subtitle:ne}}),q=ae.filter(Y=>Y&&Y.id&&N([Y.id,Y.label,Y.description])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,22).map(Y=>({kind:"definition",id:Y.id,title:Y.id,subtitle:Y.label&&Y.label!==Y.id?String(Y.label):String(Y.type||"")}));return[...H,...q]},[ad,At,ae,u]),ld=h.useMemo(()=>{const x=Ni.filter(H=>H.kind==="instance"),N=Ni.filter(H=>H.kind==="definition");return{instances:x,definitions:N}},[Ni]);h.useEffect(()=>{ha(x=>{const N=Math.max(0,Ni.length-1);return Math.min(Math.max(0,x),N)})},[Ni]);const A0=h.useMemo(()=>a7(us),[us]),Lr=h.useMemo(()=>At.filter(x=>x.selected),[At]),sy=h.useMemo(()=>new Set(Lr.map(x=>x.id)),[Lr]),Lp=h.useMemo(()=>S.filter(x=>sy.has(x.source)&&sy.has(x.target)),[S,sy]),I0=h.useMemo(()=>{const x=_e.trim().toLowerCase();return x?ut.filter(N=>[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].filter(Boolean).some(H=>String(H).toLowerCase().includes(x))):ut},[ut,_e]),T0=h.useCallback((x,N)=>{const H=String(x||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",q=Date.now().toString(36);let Y=`${H}-${q}`,J=2;for(;N.has(Y);)Y=`${H}-${q}-${J}`,J+=1;return N.add(Y),Y},[]),R0=h.useCallback((x,N)=>{var Jt,rs;if(!u||!x)return;const H=x.snippet&&typeof x.snippet=="object"?x.snippet:{},q=H.instances&&typeof H.instances=="object"?H.instances:{},Y=Object.keys(q);if(Y.length===0)return;const J=new Set(X.current.map(We=>We.id)),ee={};for(const We of Y)ee[We]=T0(We,J);const ne=(Jt=H.ui)!=null&&Jt.nodePositions&&typeof H.ui.nodePositions=="object"?H.ui.nodePositions:{},pe=(rs=H.ui)!=null&&rs.nodeSizes&&typeof H.ui.nodeSizes=="object"?H.ui.nodeSizes:{},ye=Y.map(We=>{const fn=ne[We];return{id:We,x:typeof(fn==null?void 0:fn.x)=="number"?fn.x:0,y:typeof(fn==null?void 0:fn.y)=="number"?fn.y:0}}),De=Math.min(...ye.map(We=>We.x)),ce=Math.min(...ye.map(We=>We.y));let Me=N||{x:180,y:160};const Se=ei.current,ht=document.querySelector(".af-pipeline-flow .react-flow");if(!N&&Se&&ht){const We=ht.getBoundingClientRect();Me=Se.screenToFlowPosition({x:We.left+We.width*.48,y:We.top+We.height*.32})}const un={};for(const We of Y)un[ee[We]]={...q[We]||{}};yr.current={...yr.current,...un};const dn=Y.map(We=>{const fn=q[We]||{},no=ye.find(ud=>ud.id===We)||{x:0,y:0},ji=pe[We]&&typeof pe[We].width=="number"&&typeof pe[We].height=="number"?{width:pe[We].width,height:pe[We].height}:null,Tl={id:ee[We],type:"flowNode",selected:!0,position:{x:Me.x+(no.x-De),y:Me.y+(no.y-ce)},...ji?{width:ji.width,height:ji.height}:{},data:{label:fn.label||ee[We],definitionId:fn.definitionId||We,role:fn.role||"normal",body:fn.body||"",script:fn.script||"",...ji?{displaySize:ji}:{}}};return zf(Tl,yr.current,ae,{},u.id)}),Ut=new Set(Y),vt=(Array.isArray(H.edges)?H.edges:[]).filter(We=>Ut.has(We==null?void 0:We.source)&&Ut.has(We==null?void 0:We.target)).map((We,fn)=>({id:`e-${ee[We.source]}-${ee[We.target]}-${Date.now()}-${fn}`,source:ee[We.source],target:ee[We.target],sourceHandle:We.sourceHandle??void 0,targetHandle:We.targetHandle??void 0,markerEnd:{type:Ns.ArrowClosed}}));bt(We=>[...We.map(fn=>({...fn,selected:!1})),...dn]),I(We=>[...We.map(fn=>({...fn,selected:!1})),...vt]),j(`已添加流程片段:${x.displayName||x.id}`)},[T0,ae,u,I,bt]);me.current=R0;const d2=h.useCallback(()=>{var H,q;if(Lr.length<2){nn("请先在画布上选择至少两个节点。"),Ae("flows");return}const x=Lr[0],N=Lr.length===2?`${((H=x.data)==null?void 0:H.label)||x.id} 片段`:`${((q=x.data)==null?void 0:q.label)||x.id} 等 ${Lr.length} 个节点`;In({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),ze(""),An(!0),Ae("flows")},[Lr]),f2=h.useCallback(async()=>{var J,ee;if(!u||Lr.length<2)return;const x=Bt.name.trim();if(!x){ze("请填写片段名称。");return}const N=op(Lr,yr.current),H={},q={};for(const ne of Lr){H[ne.id]={x:((J=ne.position)==null?void 0:J.x)||0,y:((ee=ne.position)==null?void 0:ee.y)||0};const pe=N7(ne);pe&&(q[ne.id]=pe)}const Y=Lp.map(ne=>({source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle??null,targetHandle:ne.targetHandle??null}));le(!0),ze("");try{const ne=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Bt.id,name:x,displayName:x,version:"1.0.0",description:Bt.description,snippet:{instances:N,edges:Y,ui:{nodePositions:H,nodeSizes:q}}})}),pe=await ne.json().catch(()=>({}));if(!ne.ok||(pe==null?void 0:pe.ok)===!1)throw new Error((pe==null?void 0:pe.error)||"Publish failed");An(!1),j(`流程片段已发布:${pe.id||x}`),jo(`流程片段已发布:${pe.id||x}`),await Pr(),Ae("flows")}catch(ne){ze(String(ne.message||ne))}finally{le(!1)}},[u,Lr,Lp,Bt,Pr,jo]),Op=h.useMemo(()=>{const x=[],N=new Set;for(const Y of Lr)N.add(Y.id),x.push({node:Y,kind:"canvas"});const H=new Map(At.map(Y=>[Y.id,Y])),q=new Map(ae.map(Y=>[Y.id,Y]));for(const Y of A0){if(N.has(Y))continue;const J=H.get(Y);if(J){N.add(Y),x.push({node:J,kind:"mention"});continue}const ee=q.get(Y);ee&&(N.add(Y),x.push({definition:ee,kind:"definition"}))}return x},[Lr,A0,At,ae]),fs=h.useMemo(()=>{const x=Array.isArray(wt==null?void 0:wt.cursor)?wt.cursor:[],N=Array.isArray(wt==null?void 0:wt.opencode)?wt.opencode:[],H=Array.isArray(wt==null?void 0:wt.claudeCode)?wt.claudeCode:[],q=N.map(ye=>`opencode:${Wo(ye)}`),Y=H.map(ye=>`claude-code:${Wo(ye)}`),J=new Set([...x,...N,...H].map(Wo).concat(q).concat(Y)),ee=(Ji||"").trim(),ne=wh(Ji,x,N,H),pe=ne&&!J.has(ne)&&!J.has(ee)?ee:"";return{cursorList:x,opencodeList:N,claudeCodeList:H,currentNotInLists:pe}},[wt,Ji]),iy=h.useMemo(()=>new Set($t),[$t]),oy=$t.length,Mp=h.useMemo(()=>{const x=new Map(Wr.map(J=>[J.key,J])),N=new Set,H=new Set,q=wc.map(J=>{const ee=Za(J,Wr).map(ne=>x.get(ne)).filter(Boolean);for(const ne of ee)N.add(ne.key),H.add(String(ne.name||ne.id||ne.key||"").trim());return{...J,skills:ee}}).filter(J=>J.skills.length>0),Y=Wr.filter(J=>{const ee=String(J.name||J.id||J.key||"").trim();return!N.has(J.key)&&!H.has(ee)});return{groups:q,ungrouped:Y}},[wc,Wr]),Ec=h.useCallback(()=>{const x=Mo.current;if(!x)return;const N=x.getBoundingClientRect(),H=Math.min(400,Math.max(300,window.innerWidth-24)),q=Math.min(Math.max(12,N.right-H),window.innerWidth-H-12),Y=Math.max(140,N.top-22),J=Math.min(360,Y);Qu({position:"fixed",left:`${q}px`,top:`${Math.max(12,N.top-J-10)}px`,width:`${H}px`,maxHeight:`${J}px`})},[]);h.useEffect(()=>{const x=Array.isArray(wt==null?void 0:wt.cursor)?wt.cursor:[],N=Array.isArray(wt==null?void 0:wt.opencode)?wt.opencode:[],H=Array.isArray(wt==null?void 0:wt.claudeCode)?wt.claudeCode:[];ds(q=>{const Y=wh(q,x,N,H);return Y===q?q:Y})},[wt.cursor,wt.opencode,wt.claudeCode]),h.useEffect(()=>{if(!ba)return;Ec();const x=H=>{var Y,J;const q=H.target;(Y=Mo.current)!=null&&Y.contains(q)||(J=vp.current)!=null&&J.contains(q)||Oo(!1)},N=H=>{H.key==="Escape"&&Oo(!1)};return window.addEventListener("resize",Ec),window.addEventListener("scroll",Ec,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",N),()=>{window.removeEventListener("resize",Ec),window.removeEventListener("scroll",Ec,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",N)}},[ba,Ec]);const Il=h.useCallback(async(x,N={})=>{var vt;if(!u||nd.current)return;const H=N.phaseContextSnapshot,q=(typeof x=="string"?x:us).trim();if(!q)return;const Y=Do.current;nd.current=!0,rd(!0),Ls(e("flow:composer.connecting")),re(Jt=>Jt!=="composer"?"composer":Jt);const J=[...Nl];if(Y.length>0&&J.push({type:"assistant",segments:[...Y]}),jp([...J,{type:"user",text:q}]),J.filter(Jt=>Jt.type==="user").length===0){const Jt=q.replace(/\s+/g," ").slice(0,30)+(q.length>30?"…":"");es(rs=>rs.map(We=>We.id===gr?{...We,label:Jt}:We))}const ee=J.map(Jt=>Jt.type==="user"?{role:"user",text:Jt.text}:{role:"assistant",text:(Jt.segments||[]).filter(We=>We.kind==="assistant"||We.kind==="result").map(We=>We.text).join(`
134
+ `)}).filter(Jt=>Jt.text),ne=H??Nt;gl(""),Zs([]),Cl([]),El(!1);const pe=new AbortController;vi.current=pe,Rs.current=gr;let ye=null;const De=Array.isArray(wt==null?void 0:wt.cursor)?wt.cursor:[],ce=Array.isArray(wt==null?void 0:wt.opencode)?wt.opencode:[],Me=Array.isArray(wt==null?void 0:wt.claudeCode)?wt.claudeCode:[],Se=wh(Ji,De,ce,Me),ht=Op.filter(Jt=>Jt.kind!=="definition"&&Jt.node).map(Jt=>Jt.node.id),un=u;let dn=!1,Ut=!1;try{ye=setTimeout(()=>pe.abort(),12e4);const Jt={prompt:q,model:Se,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:ht,thread:ee,selectedSkills:$t};ne&&ne.nextPhase&&!ne.isLastPhase&&(Jt.phaseContext={phaseIndex:ne.nextPhase.index,phases:ne.phases,userPromptOriginal:ne.userPromptOriginal||q}),yc&&(Jt.phaseRole=yc);const rs=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Jt),signal:pe.signal});if(ye&&(clearTimeout(ye),ye=null),!rs.ok){let ji=rs.statusText||e("flow:composer.requestFailed");try{const Tl=await rs.json();Tl&&Tl.error&&(ji=String(Tl.error))}catch{}Ls(ji),Zs([{kind:"error",text:ji}]);return}const We=(vt=rs.body)==null?void 0:vt.getReader();if(!We){Ls(e("flow:composer.cannotReadStream"));return}const fn=new TextDecoder;let no="";for(;;){const{done:ji,value:Tl}=await We.read();if(ji)break;for(no+=fn.decode(Tl,{stream:!0});;){const ud=no.indexOf(`
135
+ `);if(ud<0)break;const z0=no.slice(0,ud).trim();if(no=no.slice(ud+1),!z0)continue;let Ve;try{Ve=JSON.parse(z0)}catch{continue}if(Ve.type==="status"&&typeof Ve.line=="string"&&Ls(Ve.line),Ve.type==="natural"&&typeof Ve.text=="string"&&Ve.text){const yn=typeof Ve.kind=="string"&&Ve.kind?Ve.kind:"assistant";Zs(pn=>[...pn,{kind:yn,text:Ve.text}])}if(Ve.type==="error"&&Ve.message){Ut=!0;const yn=Ve.code?` [${Ve.code}]`:"",pn=String(Ve.message)+yn;Ls(pn),Zs(ps=>[...ps,{kind:"error",text:pn}])}if(Ve.type==="plan"&&Array.isArray(Ve.steps)){Cl(Ve.steps.map(pn=>({...pn,status:"pending"})));const yn=Ve.steps.map((pn,ps)=>`${ps+1}. ${pn.description||pn.type}`).join(`
136
+ `);Zs(pn=>[...pn,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Ve.steps.length,summary:yn})}])}if(Ve.type==="step-start"){const yn=Ve.index??0,pn=Ve.total??0,ps=Ve.tier?` [${Ve.tier}]`:"",x2=Ve.model?` (${Ve.model})`:"";Ls(e("flow:composer.step",{current:yn+1,total:pn,description:(Ve.description||"")+ps+x2})),Cl(w2=>w2.map(_c=>_c.index===yn?{..._c,status:"running",model:Ve.model,tier:Ve.tier,nodeRole:Ve.nodeRole??_c.nodeRole,instanceId:Ve.instanceId??_c.instanceId,instanceLabel:Ve.instanceLabel??_c.instanceLabel}:_c))}if(Ve.type==="step-progress"){const yn=Ve.index??0,pn=Ve.total??0;Ls(e("flow:composer.step",{current:yn+1,total:pn,description:Ve.description||""}))}if(Ve.type==="step-done"){const yn=Ve.index??0;Cl(pn=>pn.map(ps=>ps.index===yn?{...ps,status:Ve.success?"done":"error"}:ps))}if(Ve.type==="phase-plan"&&Array.isArray(Ve.phases)){_l(pn=>({...pn||{},phases:Ve.phases,currentPhase:Ve.currentPhase??0,phaseTotal:Ve.phaseTotal??Ve.phases.length,phaseName:Ve.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(pn==null?void 0:pn.userPromptOriginal)||q}));const yn=Ve.phases.map((pn,ps)=>`${ps+1}. ${pn.label}`).join(" → ");Zs(pn=>[...pn,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Ve.phases.length,labels:yn,current:Ve.phaseName||""})}])}Ve.type==="phase-complete"&&(_l(yn=>{var ps;return{...yn||{},phases:Ve.phases||(yn==null?void 0:yn.phases)||[],currentPhase:Ve.phaseIndex??0,phaseTotal:Ve.phaseTotal??((ps=Ve.phases)==null?void 0:ps.length)??0,phaseName:Ve.phaseName||"",isLastPhase:!!Ve.isLastPhase,nextPhase:Ve.nextPhase||null,userPromptOriginal:Ve.userPromptOriginal||(yn==null?void 0:yn.userPromptOriginal)||q}}),!Ve.isLastPhase&&Ve.nextPhase&&Zs(yn=>[...yn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Ve.phaseName||e("flow:composer.nextPhase"),nextPhase:Ve.nextPhase.label})}])),Ve.type==="done"&&(dn=!0,Ls(yn=>yn||e("flow:composer.done")))}}}catch(Jt){const rs=Jt;if(rs.name==="AbortError"){const We=e(ye?"flow:composer.connectTimeout":"flow:composer.aborted");Ls(We),Zs(fn=>[...fn,{kind:"error",text:We}])}else{const We=rs.code||rs.name||"UNKNOWN",fn=`${rs.message||String(Jt)} [${We}]`;Ls(fn),Zs(no=>[...no,{kind:"error",text:fn}])}}finally{if(nd.current=!1,rd(!1),vi.current=null,Rs.current=null,ye&&clearTimeout(ye),dn&&un){const Jt={id:un.id,source:un.source??"user",archived:un.archived};(async()=>(await Rt(Jt,{preserveComposer:!0,incrementalSync:!0}),await ct(Jt,{quiet:!0,force:!0})))()}}},[u,us,Ji,wt,Op,Rt,ct,Nl,gr,Nt,yc,$t]);Qg.current=Il;const L0=h.useCallback(()=>{!Nt||Nt.isLastPhase||(_l(null),Il(e("flow:composer.skipRemainingPhases")))},[Nt,Il]),O0=h.useCallback(()=>{if(!Nt||Nt.isLastPhase||!Nt.nextPhase)return;const x=String(Nt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Il(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:Nt})},[Nt,Il]);h.useEffect(()=>{if(!td)return;const x=N=>{N.key==="Escape"&&kc(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[td]),h.useEffect(()=>{Le!=="edit"&&kc(!1)},[Le]),h.useLayoutEffect(()=>{const x=ya.current;if(!x)return;if(!u){x.style.height="";return}x.style.height="0px";const N=getComputedStyle(x),H=parseFloat(N.lineHeight),q=(parseFloat(N.paddingTop)||0)+(parseFloat(N.paddingBottom)||0),Y=Number.isFinite(H)&&H>0?H:13*1.45,J=q+Y*2,ee=q+Y*10,ne=Math.min(Math.max(x.scrollHeight,J),ee);x.style.height=`${ne}px`},[us,u]);const ay=h.useCallback(x=>{const N=us,H=hc,q=Hj(N,H);if(!q)return;const Y=N.slice(0,q.atIndex)+`@${x} `+N.slice(H);gl(Y);const J=q.atIndex+x.length+2;queueMicrotask(()=>{const ee=ya.current;ee&&(ee.focus(),ee.setSelectionRange(J,J)),fa(J)})},[us,hc]),ly=h.useCallback(x=>{gl(N=>{const H=`@${x}`,q=N.indexOf(H);return q<0?N:N.slice(0,q)+N.slice(q+H.length)})},[]),M0=h.useCallback(x=>{x.kind==="canvas"?bt(N=>N.map(H=>H.id===x.node.id?{...H,selected:!1}:H)):x.kind==="mention"?ly(x.node.id):ly(x.definition.id)},[bt,ly]),p2=h.useCallback(()=>{re(x=>x==="history"?null:"history")},[]),h2=h.useCallback(()=>{re(x=>x==="settings"?null:"settings")},[]),m2=h.useCallback(()=>{re(x=>x==="composer"?null:"composer")},[]),cd=h.useCallback(()=>{re(x=>(x==="node"&&xa.current&&(gc.current=xa.current.id),null))},[]),$0=h.useCallback(()=>{ga(x=>!x)},[]),g2=()=>{if(!u)return null;const x=tr||u.archived||ni(u.source),N=Ln!=null&&Ln.running?e("flow:schedule.running"):cr.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),H=Ln!=null&&Ln.running?"running":cr.enabled?"waiting":"disabled",q=rn.slice(0,12),Y=u.archived||ni(u.source);return o.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[o.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[o.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),o.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),o.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),o.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),o.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),o.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),o.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),o.jsxs("main",{className:"af-pipeline-settings-main",children:[o.jsxs("div",{className:"af-pipeline-settings-main-head",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),o.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:cd,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),o.jsx("h2",{children:e("flow:settings.basicInfo")})]}),o.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:F,onChange:J=>{z(J.target.value),M("")},onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),Ap())},onBlur:()=>{F.trim()&&F.trim()!==u.id&&Ap()},placeholder:u.id,disabled:L,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Lc(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Lc(u.source??"user",e)}),u.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),W?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:W}):null]}),o.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),u.owner||"bigo"]})]})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:b,onChange:J=>v(J.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),o.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),o.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof u.path=="string"&&u.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:u.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>C0(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:T?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:$,onClick:()=>Pp("workspace"),children:e($?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:$,onClick:()=>Pp("user"),children:e($?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),A?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:A}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),o.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),o.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),o.jsxs("div",{className:"af-pipeline-market-row",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-pipeline-market-count",children:[rn.length," ",e("flow:settings.marketNodesUnit")]}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:Zt,disabled:mn,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(mn?"common:common.loading":"common:common.refresh")]})]}),sn?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:sn}):null,mn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):q.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:q.map(J=>{const ee=J.definitionId||`marketplace:${J.id}${J.version?`@${J.version}`:""}`,ne=Xt.has(ee)||Xt.has(`marketplace:${J.id}`),pe=Tt.find(Me=>String(Me.id)===ee||String(Me.id)===`marketplace:${J.id}`),ye=tn===ee,De=xh(J.inputs||J.input),ce=xh(J.outputs||J.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ne?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:J.displayName||J.label||J.id}),o.jsx("span",{children:J.version?`v${J.version}`:ee})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:J.description||e("flow:settings.marketplaceNoDescription")}),o.jsxs("div",{className:"af-pipeline-market-io",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:De.length>0?De.map(Me=>o.jsx("span",{className:"af-pipeline-market-chip",children:Me},`in-${ee}-${Me}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:ce.length>0?ce.map(Me=>o.jsx("span",{className:"af-pipeline-market-chip",children:Me},`out-${ee}-${Me}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),o.jsxs("div",{className:"af-pipeline-market-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>Te(J),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:ne?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:Y||ye,onClick:()=>{ne&&pe?(j0(pe),re(null)):Si(J)},children:e(ye?"flow:settings.installingNode":ne?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},ee)})}):o.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),o.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),o.jsx("h2",{children:e("flow:schedule.title")})]}),cl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[o.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!cr.enabled,disabled:x,onChange:J=>xr(ee=>({...ee,enabled:J.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:cr.cron||"",disabled:x,onChange:J=>xr(ee=>({...ee,cron:J.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:cr.timezone||"",disabled:x,onChange:J=>xr(ee=>({...ee,timezone:J.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:cr.preset||"",disabled:x,onChange:J=>xr(ee=>({...ee,preset:J.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Er).map(J=>o.jsx("option",{value:J,children:J},J))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${H}`}),o.jsx("span",{children:cr.nextRunAt?e("flow:schedule.nextRun",{time:new Date(cr.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),o.jsxs("span",{children:[e("flow:schedule.runtime"),":",N]})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[Gt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Gt.lastTriggeredAt).toLocaleString()})]}):null,Gt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Gt.lastSkippedAt).toLocaleString(),Gt.lastSkipReason?` · ${Gt.lastSkipReason}`:""]})]}):null,Gt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Gt.lastRunUuid})]}):null,Gt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Gt.lastExitCode)})]}):null,Gt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Gt.lastFinishedAt).toLocaleString()})]}):null]}),Ln!=null&&Ln.lastError||Gt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Ln==null?void 0:Ln.lastError)||Gt.lastError}):null,u.archived||ni(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Ki?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Ki}):null,Io?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Io}):null]})]}),o.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),o.jsx("h2",{children:e("flow:pipeline.metadata")})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[At.length," ",e("flow:pipeline.nodesUnit")]})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),o.jsx("dd",{children:Tt.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Lc(u.source??"user",e)})]})]})]})]}),o.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[o.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h2",{children:u.id}),o.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${H}`,children:N})]})]}),o.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsx("dd",{children:At.length})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.owner")}),o.jsx("dd",{children:u.owner||"bigo"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Lc(u.source??"user",e)})]})]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.quickActions")}),o.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void QR(),disabled:tr,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(tr?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:cd,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.help")}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},y2=()=>{const x=xe;if(!x)return null;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,H=x.displayName||x.label||x.id,q=xh(x.inputs||x.input),Y=xh(x.outputs||x.output);return Mr.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:J=>{J.target===J.currentTarget&&Te(null)},children:o.jsxs("div",{className:"af-market-preview-dialog",children:[o.jsxs("div",{className:"af-market-preview-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),o.jsx("h2",{children:H})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Te(null),"aria-label":e("flow:settings.closePreview"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-market-preview-body",children:[o.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:o.jsxs("div",{className:"af-market-preview-node",children:[o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(q.length>0?q:[""]).slice(0,4).map((J,ee)=>o.jsx("span",{title:J},`preview-in-${ee}`))}),o.jsxs("div",{className:"af-market-preview-node-main",children:[o.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("strong",{children:H}),o.jsx("span",{children:N})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(Y.length>0?Y:[""]).slice(0,4).map((J,ee)=>o.jsx("span",{title:J},`preview-out-${ee}`))})]})}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodeFunction")}),o.jsx("p",{children:x.description||e("flow:settings.marketplaceNoDescription")})]}),o.jsxs("div",{className:"af-market-preview-io-grid",children:[o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:q.length>0?q.map(J=>o.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-input-${J}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:Y.length>0?Y.map(J=>o.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-output-${J}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),o.jsxs("dl",{className:"af-market-preview-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.definitionId")}),o.jsx("dd",{children:N})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.version")}),o.jsx("dd",{children:x.version||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagePath")}),o.jsx("dd",{children:x.packageDir||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagedFiles")}),o.jsx("dd",{children:Array.isArray(x.packagedFiles)&&x.packagedFiles.length>0?x.packagedFiles.map(J=>J.to||J).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(Og,{children:[o.jsx(m7,{onReady:a}),o.jsxs(jT.Provider,{value:{modelLists:wt,onModelChange:ZR},children:[o.jsxs("div",{className:"af-pipeline-page"+(Le!=="edit"?" af-pipeline-page--run-mode":""),children:[o.jsxs("header",{className:"af-pipeline-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Le==="running"?Rp(!0):Le!=="edit"?Al():n("/projects")},"aria-label":e(Le!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Le!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",KK,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),o.jsx("button",{type:"button",onClick:()=>n(Sm(u,"workspace")),children:"Workspace"}),o.jsx("button",{type:"button",onClick:()=>n(Sm(u,"display")),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[Cr&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Ps?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Eo(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Le==="running"&&o.jsxs("div",{className:"af-run-timer",children:[o.jsx("span",{className:"af-run-timer__dot"}),o.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),o.jsx("span",{className:"af-run-timer__value",children:px(Rn,"running")})]}),Le==="stopped"&&o.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[o.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),o.jsx("span",{className:"af-run-timer__value",children:px(Rn,"stopped")})]}),(Le==="done"||Le==="error")&&o.jsxs("div",{className:"af-run-timer"+(Le==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:Le==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:px(Rn,Le)})]}),Le!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(lr?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>_s(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Le==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(it==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!u,onClick:p2,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(it==="settings"?" af-icon-btn--active":""),onClick:h2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!u,children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(it==="composer"?" af-composer-topbar-btn--active":"")+(On?" af-composer-topbar-btn--running":""),onClick:m2,"aria-label":"AI Composer",title:"AI Composer",disabled:!u,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(yl?" af-icon-btn--active":""),onClick:$0,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!u,children:o.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!u||ni(u.source)||u.source!=="user"&&u.source!=="workspace",onClick:()=>P(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!u||ni(u.source)||u.archived||u.source!=="user"&&u.source!=="workspace",onClick:()=>_(!0),children:"Archive"})]}),Le==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:i2,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Le==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void to(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Al,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Le==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void to({runUuid:an}),title:an?e("flow:topbar.resumeTitle",{uuid:an}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Al,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Le==="done"||Le==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void to(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Al,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):o.jsxs("div",{className:"af-run-btn-group",children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!u,onClick:()=>void to(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!u,onClick:()=>Pe(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":Ie,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),Ie&&u&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var N,H,q,Y,J;Pe(!1);const x={};for(const ee of Gn){const ne=It[ee.id];ne&&(x[ne]=((N=Gs[ne])==null?void 0:N.value)??((H=Gs[ne])==null?void 0:H.path)??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"")}er(x),Vt(!0)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Pe(!1),to({prepareOnly:!0})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),o.jsx("div",{className:"af-run-dropdown-divider"}),o.jsxs("div",{className:"af-run-dropdown-section",children:[o.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Pe(!1),to()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(Er).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var q;Pe(!1);const N=Er[x]||{},H={};for(const Y of Gn){const J=It[Y.id];if(!J)continue;const ee=((q=Y.data)==null?void 0:q.definitionId)||"",ne=N[Y.id]??"";ee.startsWith("provide_file")?H[J]={type:"file",path:ne}:H[J]={type:"str",value:ne}}to({cliInputsOverride:H})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),Qe?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:Qe}),o.jsx("button",{type:"button",onClick:()=>ot(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(Le!=="edit"?" af-pipeline-body--run-mode":""),children:[Le==="edit"&&it!=="settings"?o.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[o.jsxs("div",{className:`af-palette-workspace${Sr?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Co(x=>!x),"aria-expanded":Sr,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:Sr?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:u&&(u.path||ar.path)||"",children:u?u.id:e("flow:palette2.noPipelineSelected")}),Sr&&o.jsx("div",{className:"af-palette-workspace-tree",children:Oe?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):ar.error?o.jsx("div",{className:"af-palette-workspace-empty",children:ar.error}):u?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-palette-workspace-group",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),o.jsx("span",{children:u.id}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",ar.files.length,")"]})]}),ar.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:ar.files.filter(x=>x.type==="file").map(x=>o.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:x.path,onClick:()=>Z({filePath:x.path,fileName:x.name}),children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:x.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:x.name}),x.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:x.size<1024?`${x.size}B`:x.size<1024*1024?`${(x.size/1024).toFixed(1)}KB`:`${(x.size/1024/1024).toFixed(1)}MB`})]},x.path))}):ar.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),ar.files.filter(x=>{var N;return x.type==="directory"&&((N=x.children)==null?void 0:N.length)>0}).map(x=>o.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:x.icon}),o.jsxs("span",{children:[x.name,"/"]}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",x.children.length,")"]})]}),o.jsx("ul",{className:"af-palette-workspace-list",children:x.children.map(N=>o.jsxs("li",{className:`af-palette-workspace-item${N.type==="file"?" af-palette-workspace-item--clickable":""}`,title:N.path,onClick:N.type==="file"?()=>Z({filePath:N.path,fileName:N.name}):void 0,children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:N.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:N.name}),N.type==="file"&&N.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:N.size<1024?`${N.size}B`:N.size<1024*1024?`${(N.size/1024).toFixed(1)}KB`:`${(N.size/1024/1024).toFixed(1)}MB`})]},N.path))})]},x.path))]}):o.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),o.jsxs("div",{className:"af-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Ee==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:st,type:"search",className:"af-palette-search-input",value:_e,onChange:x=>we(x.target.value),placeholder:(Ee==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Ee==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Ee==="nodes",className:"af-palette-tab"+(Ee==="nodes"?" af-palette-tab--active":""),onClick:()=>Ae("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Ee==="flows",className:"af-palette-tab"+(Ee==="flows"?" af-palette-tab--active":""),onClick:()=>Ae("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?o.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,o.jsx("div",{className:"af-node-palette-scroll",children:Ee==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:d2,disabled:!u||Lr.length<2,title:Lr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Lr.length," 节点 / ",Lp.length," 连线"]})]})}),St?o.jsx("p",{className:"af-err af-palette-list-err",children:St}):null,Ct?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):I0.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:I0.map(x=>{const N=`${x.id}@${x.version}`,H=x.displayName||x.name||x.id,q=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>R0(x),draggable:!!u,onDragStart:Y=>{Y.dataTransfer.setData("application/agentflow-snippet",N),Y.dataTransfer.effectAllowed="move"},disabled:!u,title:q,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:H}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),q?o.jsx("span",{className:"af-palette-card-desc",children:q}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[x.nodeCount||0," nodes"]}),o.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},N)})})]}):o.jsx("p",{className:"af-palette-empty",children:_e.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Md.filter(x=>nt[x].length>0).map(x=>o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[o.jsx("h3",{className:"af-palette-cat",children:x}),o.jsx("div",{className:"af-palette-cards",children:nt[x].map(N=>{const H=Dj(N.inputs,"input"),q=Dj(N.outputs,"output"),J=N.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":ET(N),ee=CT(N);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>j0(N),draggable:!!u,onDragStart:ne=>{ne.dataTransfer.setData("application/agentflow-node",N.id),ne.dataTransfer.effectAllowed="move"},disabled:!u,title:J||N.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:JK(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:ee}),ee!==N.id?o.jsx("span",{className:"af-palette-card-id",children:N.id}):null]})]}),J?o.jsx("span",{className:"af-palette-card-desc",children:J}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[H.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[H.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:$j("input",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Qn(ne==null?void 0:ne.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:hx(ne,pe)})]},`in-${pe}`)),H.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",H.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[q.shown.map((ne,pe)=>o.jsxs("span",{className:"af-palette-card-port",title:$j("output",ne,pe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:hx(ne,pe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Qn(ne==null?void 0:ne.type)}})]},`out-${pe}`)),q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",q.hidden]}):null]})]})]})]},N.id)})})]},x)),u&&ae.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,u&&ae.length>0&&_e.trim()&&$e===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,u?null:o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),o.jsxs("footer",{className:"af-palette-engine",children:[o.jsxs("div",{className:"af-palette-engine-head",children:[o.jsx("span",{className:"af-palette-engine-dot"+(pi?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(pi?"common:engine.online":"common:engine.offline")})]}),w?o.jsx("div",{className:"af-palette-tip"+Zg,role:"status","aria-live":"polite",children:w}):null]})]}):Le!=="edit"&&u?o.jsx(FK,{flowId:u.id,flowSource:u.source||"user",flowArchived:u.archived,provideNodes:Gn,edges:S,nodes:At,onCliInputsChange:U,onBackToEdit:Al}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,u&&ts.length>0&&!V?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[o.jsxs("div",{className:"af-flow-slot-warnings-head",children:[o.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),o.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",disabled:ue,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void eo(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),o.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>se(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:ts.map(x=>o.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',o.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:x.nodeId}),onClick:N=>{N.preventDefault(),qR(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,u&&ts.length>0&&V?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:ts.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:$0,title:e("flow:validation.shortcutHint"),children:[o.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),o.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>se(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:ue,onClick:()=>void eo(),children:e("common:common.refresh")})]})]}):null,it==="settings"&&u&&Le==="edit"?g2():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:u?o.jsxs(o.Fragment,{children:[o.jsx(k7,{fitViewEpoch:m,canvasTool:ma,nodes:Qi,edges:Ur,onNodesChange:Le!=="edit"?void 0:Ep,onEdgesChange:Le!=="edit"?void 0:K,onConnect:Le!=="edit"?void 0:HR,onConnectStart:Le!=="edit"?void 0:WR,onConnectEnd:Le!=="edit"?void 0:VR,isValidConnection:Le!=="edit"?void 0:BR,onNodesDelete:Le!=="edit"?void 0:UR,onNodeClick:DR,onNodeDoubleClick:FR,onEdgeClick:zR,onFlowInit:KR,onDrop:JR,onDragOver:XR,hideMinimapAndControls:!!(u&&it),bottomSlot:Le==="edit"?o.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:Op.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Op.map((x,N)=>{var pe,ye;if(x.kind==="definition"){const De=x.definition,ce=String(De.label??De.id),Me=[De.id,De.description?String(De.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:Me,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:ce}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>M0(x),"aria-label":e("flow:composer.removeFromInput",{id:De.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${De.id}`)}const H=x.node,q=x.kind,Y=String(((pe=H.data)==null?void 0:pe.label)??H.id),J=(ye=H.data)!=null&&ye.definitionId?String(H.data.definitionId):"",ee=J&&J!==Y?`${Y} · ${H.id} · ${J}`:`${Y} · ${H.id}`,ne=q==="canvas"?e("flow:composer.deselectNode",{id:H.id}):e("flow:composer.removeFromInput",{id:H.id});return o.jsxs("div",{className:"af-composer-node-chip"+(q==="mention"?" af-composer-node-chip--mention":""),title:ee,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:Y}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>M0(x),"aria-label":ne,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},H.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsxs("div",{className:"af-composer-input-wrap",children:[o.jsx("textarea",{ref:ya,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!u,value:us,rows:2,onChange:x=>{gl(x.target.value),fa(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&fa(N.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),Il();return}if(ad&&Ni.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),ha(N=>(N+1)%Ni.length);else if(x.key==="ArrowUp")x.preventDefault(),ha(N=>(N-1+Ni.length)%Ni.length);else if(x.key==="Enter"){x.preventDefault();const N=Ni[pa];N&&ay(N.id)}}},onKeyUp:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&fa(N.selectionStart??N.value.length)},onClick:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&fa(N.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),ad&&u&&Ni.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[ld.instances.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,ld.instances.map((x,N)=>{const H=N;return o.jsx("li",{role:"option","aria-selected":H===pa,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===pa?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>ha(H),onClick:()=>ay(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`i-${x.id}`)}),ld.definitions.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,ld.definitions.map((x,N)=>{const H=ld.instances.length+N;return o.jsx("li",{role:"option","aria-selected":H===pa,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===pa?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>ha(H),onClick:()=>ay(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`d-${x.id}`)})]}):null]}),o.jsxs("div",{className:"af-composer-toolbar",children:[Zr.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:gr||"",onChange:x=>{x.target.value==="__new__"?Sp():Cp(x.target.value)},disabled:On,"aria-label":e("flow:composer.switchConversation"),children:[Zr.map(x=>o.jsxs("option",{value:x.id,children:[x.label,x.running?" ⏳":""]},x.id)),o.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:Mo,type:"button",className:"af-composer-skills-button"+(oy>0?" af-composer-skills-button--active":""),disabled:!u||On,"aria-haspopup":"listbox","aria-expanded":ba,onClick:()=>Oo(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:oy>0?`Skills ${oy}`:"Skills"})]}),ba&&!On?Mr.createPortal(o.jsx("div",{ref:vp,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:Jg,children:Wr.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Mp.groups.map(x=>{const N=Za(x,Wr),H=O_(x,iy,Wr),q=Xg.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(q?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:H==="all",disabled:N.length===0,onChange:Y=>{const J=Y.target.checked;Lo(ee=>J?R_(ee,N):L_(ee,N))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:x.name}),x.builtin?o.jsx("em",{children:"built-in"}):null,H==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":q?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{bp(Y=>{const J=new Set(Y);return J.has(x.id)?J.delete(x.id):J.add(x.id),J})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:q?"expand_more":"expand_less"})]})]}),q?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(Y=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:iy.has(Y.key),onChange:J=>{const ee=J.target.checked;Lo(ne=>ee?ne.includes(Y.key)?ne:[...ne,Y.key]:ne.filter(pe=>pe!==Y.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Y.name}),Y.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Y.description}):null]})]},`${x.id}:${Y.key}`))})]},x.id)}),Mp.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:Mp.ungrouped.length})]}),Mp.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:iy.has(x.key),onChange:N=>{const H=N.target.checked;Lo(q=>H?q.includes(x.key)?q:[...q,x.key]:q.filter(Y=>Y!==x.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.key}`))]}):null]})}),document.body):null]}),o.jsxs("label",{className:"af-composer-model-field",children:[o.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),o.jsxs("select",{className:"af-composer-model-select",value:(Ji||"").trim()?fs.currentNotInLists?fs.currentNotInLists:wh(Ji,fs.cursorList,fs.opencodeList,fs.claudeCodeList):"",onChange:x=>ds(x.target.value),disabled:!u||On,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),fs.currentNotInLists?o.jsxs("option",{value:fs.currentNotInLists,children:[fs.currentNotInLists,e("flow:composer.modelNotInList")]}):null,fs.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:fs.cursorList.map(x=>o.jsx("option",{value:Wo(x),children:x},`composer-c-${x}`))}):null,fs.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:fs.opencodeList.map(x=>o.jsx("option",{value:`opencode:${Wo(x)}`,children:x},`composer-o-${x}`))}):null,fs.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:fs.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${Wo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(u&&us.trim()&&!On?" af-composer-send--active":"")+(On?" af-composer-send--stop":""),disabled:!u||!On&&!us.trim(),"aria-label":e(On?"flow:composer.stopGeneration":"flow:composer.send"),title:On?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(On){(x=vi.current)==null||x.abort();return}Il()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:On?"stop":"arrow_upward"})})]})]}),td?Mr.createPortal(o.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:x=>{x.target===x.currentTarget&&kc(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[o.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[o.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),o.jsx("div",{className:"af-composer-thread-dialog-status"+(On?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:kl||void 0,children:On&&!kl?e("flow:composer.executing"):kl||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>kc(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),ed.length>1&&!(Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(c7,{steps:ed})}):null,Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Nt.phases.map((x,N)=>{const H=x.status||(N<(Nt.currentPhase??0)?"done":N===(Nt.currentPhase??0)?On?"running":Nt.nextPhase||Nt.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:N+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||N)})}):null,o.jsx("div",{className:"af-composer-thread-dialog-scroll",children:o.jsx(Wj,{thread:Nl,liveSegments:Sl,running:On})}),Nt&&!Nt.isLastPhase&&Nt.nextPhase&&!On?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Nt.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:O0,children:e("flow:composer.phaseReviewContinue",{label:Nt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:L0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),be&&Le==="edit"?(()=>{var q;const x=String(be.query||"").trim().toLowerCase(),N=x?be.candidates.filter(Y=>{var J,ee,ne;return[(J=Y.def)==null?void 0:J.id,Y.displayLabel,Y.description,(ee=Y.slot)==null?void 0:ee.name,(ne=Y.slot)==null?void 0:ne.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(x))}):be.candidates,H=be.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:be.left,top:be.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Qn((q=be.draft.slot)==null?void 0:q.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",be.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>Fe(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:be.query,onChange:Y=>Fe(J=>J&&{...J,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[N.map(Y=>{var ne,pe;const J=Y.displayLabel||((ne=Y.def)==null?void 0:ne.id),ee=hx(Y.slot,Y.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>GR(Y),title:Y.description||Y.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:J}),J!==Y.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:H}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Qn((pe=Y.slot)==null?void 0:pe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:ee})]})]},`${Y.def.id}-${Y.slotIndex}`)}),N.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):o.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Le!=="edit"&&lr&&o.jsxs("div",{className:"af-run-console",style:{height:Ui},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:t2,onPointerMove:n2,onPointerUp:P0,onPointerCancel:P0,onLostPointerCapture:r2}),o.jsxs("div",{className:"af-run-console__head",children:[o.jsxs("span",{className:"af-run-console__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),o.jsxs("div",{className:"af-run-console__head-right",children:[Le==="running"&&o.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),o.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>_s(!1),"aria-label":e("flow:run.closeLog"),children:o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),o.jsxs("div",{className:"af-run-console__body",children:[Nr.map((x,N)=>o.jsxs("div",{className:"af-run-console__line"+(x.type==="error"?" af-run-console__line--error":"")+(x.type==="warn"?" af-run-console__line--warn":"")+(x.type==="node-start"?" af-run-console__line--start":"")+(x.type==="node-done"?" af-run-console__line--done":"")+(x.type==="node-failed"?" af-run-console__line--error":"")+(x.type==="done"?" af-run-console__line--done":""),children:[o.jsxs("span",{className:"af-run-console__ts",children:["[",x.ts?new Date(x.ts).toLocaleTimeString():"--:--:--","]"]}),o.jsx("span",{className:"af-run-console__text",children:x.text!=null?String(x.text):""})]},N)),o.jsx("div",{ref:ca})]})]})]}),Le!=="edit"&&Is&&u?o.jsx(OK,{instanceId:Is,flowId:u.id,runId:an,nodeStatus:((D0=jr[Is])==null?void 0:D0.status)??null,onClose:()=>Ts(null)}):null,it&&it!=="settings"&&u&&Le==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(it==="node"?" af-pipeline-drawer--wide":"")+(it==="composer"?" af-pipeline-drawer--wide":""),"aria-label":it==="settings"?e("flow:settings.title"):it==="history"?e("flow:history.title"):it==="composer"?"AI Composer":e("flow:nodeProps.title"),children:it==="composer"?o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:cd,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Zr.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[Zr.map(x=>o.jsxs("button",{type:"button",ref:N=>{N&&x.id===gr&&N.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===gr?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Cp(x.id),title:x.label,children:[o.jsx("span",{className:"af-composer-session-label",children:x.label}),o.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:N=>{N.stopPropagation(),Np(x.id)},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),Np(x.id))},title:x.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},x.id)),o.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>Sp(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(On?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:On&&!kl?e("flow:composer.executing"):kl||e("flow:composer.ready")}),Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Nt.phases.map((x,N)=>{const H=x.status||(N<(Nt.currentPhase??0)?"done":N===(Nt.currentPhase??0)?On?"running":Nt.isLastPhase&&N===Nt.phases.length-1||Nt.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:N+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||N)})}):null,o.jsx("div",{className:"af-composer-sidebar-thread",ref:jl,children:o.jsx(Wj,{thread:Nl,liveSegments:Sl,running:On})}),Nt&&!Nt.isLastPhase&&Nt.nextPhase&&!On?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Nt.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:O0,children:e("flow:composer.phaseReviewContinue",{label:Nt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:L0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):it==="node"&&Ze?gt?o.jsx(vT,{draft:gt,setDraft:wa,definitionId:String(((F0=Ze.data)==null?void 0:F0.definitionId)??Ze.id),systemPromptReadonly:String((ft==null?void 0:ft.description)??""),modelLists:wt,disabled:!u,onIdBlur:e2,onClose:cd,onPublishToMarketplace:Zi,error:gp,ioSlots:{inputs:Array.isArray(gt==null?void 0:gt.inputs)?gt.inputs:[],outputs:Array.isArray(gt==null?void 0:gt.outputs)?gt.outputs:[]}}):o.jsx("div",{className:"af-pipeline-drawer-body",children:o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:e(it==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:cd,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-pipeline-drawer-body",children:it==="settings"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(u.source==="user"||u.source==="workspace")&&!u.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:F,onChange:x=>{z(x.target.value),M("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Ap())},onBlur:()=>{F.trim()&&F.trim()!==u.id&&Ap()},placeholder:u.id,disabled:L,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Lc(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Lc(u.source??"user",e)}),u.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),W?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:W}):null]}),typeof u.path=="string"&&u.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:u.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>C0(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:T?"check":"content_copy"})})]})]}):null,u.source==="user"||u.source==="workspace"?u.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:u.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:$,onClick:()=>Pp("workspace"),children:e($?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:$,onClick:()=>Pp("user"),children:e($?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),A?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:A}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:b,onChange:x=>v(x.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),cl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-new-pipeline-radio",children:[o.jsx("input",{type:"checkbox",checked:!!cr.enabled,disabled:tr||u.archived||ni(u.source),onChange:x=>xr(N=>({...N,enabled:x.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:cr.cron||"",disabled:tr||u.archived||ni(u.source),onChange:x=>xr(N=>({...N,cron:x.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:cr.timezone||"",disabled:tr||u.archived||ni(u.source),onChange:x=>xr(N=>({...N,timezone:x.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:cr.preset||"",disabled:tr||u.archived||ni(u.source),onChange:x=>xr(N=>({...N,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Er).map(x=>o.jsx("option",{value:x,children:x},x))]})]}),o.jsx("div",{className:"af-pipeline-drawer-readonly",children:o.jsx("span",{children:e("flow:schedule.overlapSkip")})}),cr.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(cr.nextRunAt).toLocaleString()})}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),o.jsxs("dl",{className:"af-pipeline-meta-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.runtime")}),o.jsx("dd",{children:Ln!=null&&Ln.running?e("flow:schedule.running"):cr.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Gt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Gt.lastTriggeredAt).toLocaleString()})]}):null,Gt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Gt.lastSkippedAt).toLocaleString(),Gt.lastSkipReason?` · ${Gt.lastSkipReason}`:""]})]}):null,Gt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Gt.lastRunUuid})]}):null,Gt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Gt.lastExitCode)})]}):null,Gt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Gt.lastFinishedAt).toLocaleString()})]}):null]}),Ln!=null&&Ln.lastError||Gt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(Ln==null?void 0:Ln.lastError)||Gt.lastError}):null,u.archived||ni(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Ki?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Ki}):null,Io?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Io}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:tr||u.archived||ni(u.source),onClick:ey,children:e(tr?"flow:schedule.saving":"flow:schedule.save")})]})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),o.jsx("dl",{className:"af-pipeline-meta-dl",children:o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[At.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),o.jsx("strong",{children:u.id})]}),Nn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):jt?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:jt}):od.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[ns.success+ns.failed+ns.running+ns.stopped+ns.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[ns.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:ns.success})}):null,ns.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:ns.failed})}):null,ns.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:ns.stopped})}):null,ns.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:ns.interrupted})}):null,ns.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:ns.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:od.map((x,N)=>{const H=x.status||"unknown",q=H==="success"?"af-exec-history-card--success":H==="failed"?"af-exec-history-card--failed":H==="stopped"?"af-exec-history-card--stopped":H==="interrupted"?"af-exec-history-card--interrupted":H==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",Y=e(H==="success"?"flow:history.success":H==="failed"?"flow:history.failed":H==="stopped"?"flow:history.stopped":H==="interrupted"?"flow:history.interrupted":H==="running"?"flow:history.running":"flow:history.unknown"),J=H==="success"?"check_circle":H==="failed"?"error":H==="stopped"?"stop_circle":H==="interrupted"?"sync_disabled":H==="running"?"progress_activity":"help",ee=x.runId||`${x.at}-${N}`,ne=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:od.length-N});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${q}`,onClick:()=>u2(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:ne}),o.jsx("span",{className:"af-exec-history-card-time",children:Cw(x.at,e)})]}),o.jsxs("div",{className:"af-exec-history-card-bottom",children:[o.jsxs("span",{className:"af-exec-history-card-status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J}),Y]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),xM(x.durationMs,e)]})]})]})},`${u.id}-${ee}`)})})]})]})})]})}):null]}),o.jsx(vj,{open:s2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:o2,onCancel:()=>ry(!1)}),o.jsx(vj,{open:a2,title:e("flow:run.backPromptTitle",{defaultValue:"返回项目列表"}),message:e("flow:run.backPromptMessage",{defaultValue:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。"}),confirmLabel:e("flow:run.backBackground",{defaultValue:"后台运行并退出"}),secondaryLabel:e("flow:run.backStopEdit",{defaultValue:"停止并进入编辑"}),secondaryDestructive:!0,onConfirm:c2,onSecondary:l2,onCancel:()=>Rp(!1)}),o.jsx(mT,{open:yl,onClose:()=>ga(!1)}),y2(),o.jsx(gT,{open:mc,onClose:()=>xl(!1),onJump:YR,nodes:At}),o.jsx(UK,{open:Ps,onClose:()=>Eo(!1),flowId:(u==null?void 0:u.id)??""}),o.jsx(yK,{open:D,onClose:()=>_(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",onArchived:async()=>{_(!1),await Ft(),n("/projects?tab=archived")}}),o.jsx(xK,{open:R&&!!(u!=null&&u.id),onClose:()=>P(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),onDeleted:async()=>{P(!1),p(null),bt([]),I([]),_l(null),await Ft(),n("/projects")}}),hn&&Mr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>An(!1),"aria-label":e("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Bt.name,onChange:x=>{const N=x.target.value;In(H=>({...H,name:N,id:H.id?H.id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Bt.id,onChange:x=>In(N=>({...N,id:x.target.value})),placeholder:"pr-check-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Bt.description,onChange:x=>In(N=>({...N,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Lr.length," 个节点和 ",Lp.length," 条内部连线。"]}),de?o.jsx("div",{className:"af-flow-snippet-error",children:de}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>An(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Fn||!Bt.name.trim(),onClick:()=>void f2(),children:Fn?"发布中…":"发布"})]})]})}),document.body),o.jsx(vK,{open:!!G,onClose:()=>Z(null),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),filePath:(G==null?void 0:G.filePath)??"",fileName:(G==null?void 0:G.fileName)??"",onSaved:()=>{qs(x=>({...x}))}})]}),ur&&Le!=="edit"&&Mr.createPortal(o.jsx("div",{className:"af-user-check-modal-overlay",children:o.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-check-modal__head",children:[o.jsxs("span",{className:"af-user-check-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:ur.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:Hr?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!ur||!u||!an)return;const x=To||ur.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"save-user-check-content",runUuid:an,instanceId:ur.instanceId,content:x})})).ok?(dl(H=>H&&{...H,content:x}),ua(!1),mt(H=>[...H,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):mt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{mt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{fl(ur.content),ua(!1)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>ua(!0),children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),o.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>dl(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:Hr?o.jsx("textarea",{ref:pp,className:"af-user-check-modal__textarea",value:To||ur.content,onChange:x=>fl(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:To||ur.content})})}),o.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[o.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:gi,onChange:x=>da(x.target.value),disabled:Gi}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Gi||!gi.trim(),onClick:()=>{!ur||!u||!an||!gi.trim()||(cs(!0),mt(x=>[...x,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"ai-edit-user-check-content",runUuid:an,instanceId:ur.instanceId,content:To||ur.content,prompt:gi})}).then(x=>x.json()).then(x=>{cs(!1),x.ok&&x.content?(fl(x.content),ua(!0),da(""),mt(N=>[...N,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):mt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{cs(!1),mt(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Gi?o.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):o.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),o.jsxs("div",{className:"af-user-check-modal__foot",children:[o.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!ur||!u||!an)return;const x=To||ur.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"save-user-check-content",runUuid:an,instanceId:ur.instanceId,content:x})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"confirm-user-check",runUuid:an,instanceId:ur.instanceId,execId:ur.execId})}),dl(null),da(""),to({runUuid:an})):mt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{mt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),_r&&Le!=="edit"&&Mr.createPortal(o.jsx("div",{className:"af-user-ask-modal-overlay",children:o.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-ask-modal__head",children:[o.jsxs("span",{className:"af-user-ask-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:_r.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>pl(null),"aria-label":e("flow:userAsk.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),o.jsxs("div",{className:"af-user-ask-modal__body",children:[_r.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:_r.question})}):null,_r.options.length===0?o.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):o.jsx("div",{className:"af-user-ask-modal__options",children:_r.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:Xi,onClick:async()=>{if(!(!_r||!u||!an)){hl(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:u.source??"user",action:"confirm-user-ask",runUuid:an,instanceId:_r.instanceId,execId:_r.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(pl(null),hl(!1),to({runUuid:an})):(hl(!1),mt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{hl(!1),mt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[o.jsxs("span",{className:"af-user-ask-option__index",children:["[",x.index,"]"]}),o.jsx("span",{className:"af-user-ask-option__label",children:x.label})]},x.name))})]}),o.jsx("div",{className:"af-user-ask-modal__foot",children:o.jsx("span",{className:"af-user-ask-modal__hint",children:e(Xi?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),Re&&Le!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(ml?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[o.jsxs("div",{className:"af-tool-print-toast__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"print"}),o.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:Re.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Gu(x=>!x),"aria-label":e(ml?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(ml?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:ml?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Qs(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-tool-print-toast__body",children:o.jsx("div",{className:"af-tool-print-toast__markdown",children:o.jsx(Bu,{children:Re.content})})})]}),qn&&o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:qn.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Ro(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:jn,className:"af-provide-edit-modal__textarea",defaultValue:qn.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:gn,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>Ro(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Ge&&o.jsx("div",{className:"af-run-params-overlay",children:o.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-run-params-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),o.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),o.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>Vt(!1),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-run-params-modal__body",children:Gn.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:Gn.map(x=>{var pe,ye;const N=It[x.id];if(!N)return null;const H=((pe=x.data)==null?void 0:pe.definitionId)||"",q=H.startsWith("provide_file"),Y=H==="provide_bool",J=((ye=x.data)==null?void 0:ye.label)||x.id,ee=Mt[N]??"",ne=["true","1","yes","on"].includes(String(ee).trim().toLowerCase());return o.jsxs("div",{className:"af-run-params-item",children:[o.jsxs("div",{className:"af-run-params-item__head",children:[o.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(q?" af-run-params-item__icon--file":""),children:q?"description":Y?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:J}),o.jsx("span",{className:"af-run-params-item__slot",children:N})]}),Y?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ne?" af-run-config-bool-toggle--true":""),onClick:()=>er(De=>({...De,[N]:ne?"false":"true"})),"aria-pressed":ne,children:ne?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:ee,onChange:De=>er(ce=>({...ce,[N]:De.target.value})),placeholder:e(q?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},x.id)})})}),o.jsxs("div",{className:"af-run-params-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var N;const x={};for(const H of Gn){const q=It[H.id];if(!q)continue;const Y=((N=H.data)==null?void 0:N.definitionId)||"",J=Mt[q]??"";Y.startsWith("provide_file")?x[q]={type:"file",path:J}:x[q]={type:"str",value:J}}Vt(!1),Pe(!1),to({cliInputsOverride:x})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),o.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>Vt(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const E7="modulepreload",_7=function(e){return"/"+e},Xj={},IT=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=_7(c),c in Xj)return;Xj[c]=!0;const d=c.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const u=document.createElement("link");if(u.rel=d?"stylesheet":E7,d||(u.as="script"),u.crossOrigin="",u.href=c,l&&u.setAttribute("nonce",l),document.head.appendChild(u),d)return new Promise((p,m)=>{u.addEventListener("load",p),u.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(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"&&i(l.reason);return t().catch(i)})},P7=new Set(["echarts"]),A7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),I7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),T7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Xa(e){return e&&typeof e=="object"&&!Array.isArray(e)}function ic(e,t){if(!Xa(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Xa(n[r])&&Xa(s)&&(n[r]=ic(n[r],s));return n}function Bg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Xa(n)?ic(n,t):n):Xa(e)?ic(e,t):e}function R7(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:json|chart|echarts)?\s*\n?([\s\S]*?)```/i);if(n!=null&&n[1])t=n[1].trim();else{const r=t.indexOf("{"),s=t.lastIndexOf("}");r>=0&&s>r&&(t=t.slice(r,s+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function hb(e,t="$"){if(e!=null){if(typeof e=="string"){if(/<\s*(script|iframe|object|embed|link|meta)\b/i.test(e))throw new Error(`${t} contains unsafe HTML`);if(/\bjavascript\s*:/i.test(e)||/\bdata\s*:\s*text\/html/i.test(e))throw new Error(`${t} contains unsafe URL text`);return}if(Array.isArray(e)){e.forEach((n,r)=>hb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||I7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);hb(r,`${t}.${n}`)}}}function L7(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!A7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function 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:ic(e,t)}function M7(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!Xa(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return ic(i,n)}):Xa(e)?ic(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function $7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Bg(e,n)}function Jj(e,t="rgba(255, 255, 255, 0.62)"){return Bg(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 D7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Bg(e,n)}function F7(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:Bg(e,t)}function z7(e,t,n){const r=M7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Xa(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??T7,textStyle:ic(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:O7(e.tooltip),legend:$7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?D7(e.grid,s||i):e.grid,xAxis:Jj(e.xAxis),yAxis:Jj(e.yAxis),radar:F7(e.radar),series:t}}function TT(e){const t=R7(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(!P7.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");hb(n);const r=L7(n.option.series),s=n.title==null?"":String(n.title),i=z7(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}const B7="af:workspace-graph:v2",Dc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],H7=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),W7={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:""}]},V7={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}]},U7={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}]},K7=new Set(["png","jpg","jpeg","gif","webp","svg"]),q7=320,RT=180,LT=960,mb=96,OT=900,gb="display-ref:",Y7="0.1.49";function G7(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Aa(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function Ym(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 K7.has(n)}function d0(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=Aa(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function X7(e,t){const n=String(e||"").trim();if(!n)return"";const r=Aa(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function J7(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";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function Q7(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function Z7(e){const t=String(e||"").trim();if(!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 i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function Qj(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function MT(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 $T(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function f0(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function $d(e){const t=String(f0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function Zj(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Gm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Dd(e){return Gm(e)}function yb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function yx(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 e1(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(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function t1(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 n1(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])),i=Ru(s.get(n),e.sourceHandle||"output-0","source"),a=Ru(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Tu(i,a))}function eq(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 i=t.find(l=>l.id===n),a=Ru(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:fT(a)}:null}function tq(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 i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Tu(t.slot,a):Tu(a,t.slot)))continue;const c=$d(n);return{def:n,order:r,category:c,categoryRank:Dc.indexOf(c),slot:a,slotIndex:i,displayLabel:Dd(n),description:yb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function Fd(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 nq(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 i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function rq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function vh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:rq(t),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 DT(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,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 sq(e){var s,i;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:{};return[DT(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.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)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function xx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=zT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const g=r[m]||{},b=g.definitionId||m,v=t.find(B=>B.id===b),y=f0(v)||b,k=t.find(B=>B.id===y)||v,w=g.marketplaceRef||$T(v),j=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},A=!!Hn(y),C=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,$=pu(C,{display:A});return{id:m,type:ap,position:j,...$?{width:$.width,height:$.height}:{},data:{label:g.label||Gm(v)||Gm(k)||m,definitionId:y,...w?{marketplaceRef:w}:{},...v!=null&&v.packageId?{marketplacePackageId:v.packageId}:{},...v!=null&&v.version?{marketplaceVersion:v.version}:{},schemaType:MT(y,k||v),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...$?{nodeSize:$}:{},...A&&$?{displaySize:$}:{}}}}).map(m=>zf(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,g)=>({id:m.id||`we-${m.source}-${m.target}-${g}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:Ns.ArrowClosed}}));return{nodes:d,edges:uT(f,d),instances:r}}function r1(e){return`${gb}${e}`}function wx(e){const t=String(e||"");return t.startsWith(gb)?t.slice(gb.length):t}function FT(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 xb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Hn((p=u==null?void 0:u.data)==null?void 0:p.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const u of r){const p=String(u||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,p)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const p=pu(d[u],{display:!0});p&&(c[u]=p)});const f=FT(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function iq(e,t=[]){return xb(e,t)}function oq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function s1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function pu(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:s1(n,RT,LT)||q7,height:s1(r,mb,OT)||mb}}function zd(e){var s,i,a,l,c,d,f,u,p,m,g;const t=!!Hn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.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?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:u.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return pu({width:n,height:r},{display:t})}function kh(e,t,n){var l,c;const r=zT(op(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((c=d.position)==null?void 0:c.y)||0};const f=zd(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function zT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Hn(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 Hn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Yl(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Hn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Hu(e){let t=String(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 i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[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((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function BT(e){const t=Hu(e);if(!t.trim())return"";if(/<base\s+[^>]*target\s*=/i.test(t))return t;const n='<base target="_blank">';return/<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 aq(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 lq(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function i1(e,t){const n=URL.createObjectURL(e);try{lq(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function cq(e){const t=Hu(e),n=new DOMParser().parseFromString(t||"<body></body>","text/html"),r=new XMLSerializer,s=Array.from(n.querySelectorAll("style")).map(a=>r.serializeToString(a)).join(`
137
+ `),i=n.body?Array.from(n.body.childNodes).map(a=>r.serializeToString(a)).join(""):t;return`
138
+ <style>
139
+ * { box-sizing: border-box; }
140
+ html, body { margin: 0; min-height: 100%; background: transparent; }
141
+ .af-html-snapshot-root { width: 100%; min-height: 100%; overflow: hidden; }
142
+ </style>
143
+ ${s}
144
+ <div xmlns="http://www.w3.org/1999/xhtml" class="af-html-snapshot-root">${i}</div>
145
+ `}async function uq({content:e,width:t,height:n,filename:r}){const s=Math.max(1,Math.round(Number(t)||960)),i=Math.max(1,Math.round(Number(n)||640)),a=`<?xml version="1.0" encoding="UTF-8"?>
146
+ <svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${i}" viewBox="0 0 ${s} ${i}">
147
+ <foreignObject width="100%" height="100%">
148
+ <div xmlns="http://www.w3.org/1999/xhtml" style="width:${s}px;height:${i}px;overflow:hidden;background:#ffffff;">
149
+ ${cq(e)}
150
+ </div>
151
+ </foreignObject>
152
+ </svg>`,l=new Blob([a],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(l);try{const d=new Image;d.decoding="async",d.src=c,await d.decode();const f=document.createElement("canvas");f.width=s,f.height=i;const u=f.getContext("2d");if(!u)throw new Error("Canvas is unavailable");u.drawImage(d,0,0,s,i);const p=await new Promise(m=>f.toBlob(m,"image/png"));if(!p)throw new Error("Could not encode PNG");i1(p,r)}catch(d){throw i1(l,r.replace(/\.png$/i,".svg")),d}finally{URL.revokeObjectURL(c)}}function dq(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 fq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function Yo(e){let t=String(e||"").trim();return t.includes("|")?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())):[]}function HT(e){const t=Yo(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function WT(e){return Yo(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function pq(e){const t=String(e||"").replace(/\r\n/g,`
153
+ `).split(`
154
+ `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
155
+ `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"";if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&Yo(l).length>1&&HT(t[a+1])){i();const c=Yo(l),d=WT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Yo(t[a]).length>1;)f.push(Yo(t[a])),a++;n.push({type:"table",headers:c,align:d,rows:f});continue}r.push(l),a++}return i(),n}function VT(e,t=!1){return{...t?{p:({children:n})=>o.jsx(o.Fragment,{children:n})}:{},img:({src:n,alt:r})=>o.jsx("img",{src:d0(n,e),alt:r||"",loading:"lazy"}),a:({href:n,children:r})=>o.jsx("a",{href:n||"",target:"_blank",rel:"noopener noreferrer",children:r})}}function o1({children:e,flowParams:t}){return o.jsx(Bu,{components:VT(t,!0),children:String(e||"")})}function UT({content:e,flowParams:t}){const n=h.useMemo(()=>pq(e),[e]),r=h.useMemo(()=>VT(t),[t]);return o.jsx(o.Fragment,{children:n.map((s,i)=>s.type!=="table"?o.jsx(Bu,{components:r,children:s.text},`md-${i}`):o.jsx("div",{className:"af-work-display-table-wrap",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:s.headers.map((a,l)=>o.jsx("th",{style:{textAlign:s.align[l]||"left"},children:o.jsx(o1,{flowParams:t,children:a})},l))})}),o.jsx("tbody",{children:s.rows.map((a,l)=>o.jsx("tr",{children:s.headers.map((c,d)=>o.jsx("td",{style:{textAlign:s.align[d]||"left"},children:o.jsx(o1,{flowParams:t,children:a[d]||""})},d))},l))})]})},`table-${i}`))})}function hq(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
156
+ `);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(i){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
157
+ `?(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 so(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 mq(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>so(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>so(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>so(i[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,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:so(s)||`Column ${i+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,i)=>({key:String(i),label:so(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>so(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>so(s[a])):s&&typeof s=="object"?r.map(i=>so(s[i.key])):r.map((i,a)=>a===0?so(s):""))}}function gq(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=mq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
158
+ `).split(`
159
+ `).filter(l=>l.trim());if(s.length>=2&&Yo(s[0]).length>1&&HT(s[1])){const l=Yo(s[0]),c=WT(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>Yo(d)),error:""}}const i=r.includes(" ")?" ":",",a=hq(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function KT({content:e}){const t=h.useMemo(()=>gq(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:so(n[i])},`${s.key}-${i}`))},r))})]})})}function yq(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const i=(l,c="")=>{const d=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(d)?c&&(n.get(d).label=c):n.set(d,{id:d,label:c||d}),d},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),d=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return d?i(d[1],d[2]||d[3]||d[4]||d[1]):i(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 d=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(d){r.push({from:a(d[1]),to:a(d[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function qT({code:e}){const t=h.useMemo(()=>yq(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,i=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((f,u)=>{l.set(f.id,{x:24+(n?u*(r+i):u%3*(r+i)),y:24+(n?u%3*(s+a):u*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(f=>f.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(f=>f.y+s+24));return o.jsx("div",{className:"af-work-node__mermaid-preview",children:o.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,role:"img","aria-label":"Mermaid preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((f,u)=>{const p=l.get(f.from),m=l.get(f.to);if(!p||!m)return null;const g=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+m.x+r)/2} ${p.y+s/2}, ${(p.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return o.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${f.from}-${f.to}-${u}`)}),t.nodes.map(f=>{const u=l.get(f.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-work-node__mermaid-box",x:u.x,y:u.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-work-node__mermaid-text",x:u.x+r/2,y:u.y+s/2+5,textAnchor:"middle",children:f.label.slice(0,22)})]},f.id)})]})})}function Ea({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,i]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const u=Math.max(1,f.scrollHeight),p=Math.max(1,f.clientHeight),m=u>p+1,g=m?Math.max(12,p/u*100):100,b=Math.max(0,100-g),v=m?Math.min(b,f.scrollTop/Math.max(1,u-p)*b):0;i({visible:m,top:v,height:g})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),u=n.current;if(!u||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const p=new ResizeObserver(a);p.observe(u);for(const m of Array.from(u.children))p.observe(m);return()=>{cancelAnimationFrame(f),p.disconnect()}},[t,a]);const l=h.useCallback(f=>{const u=n.current;if(!u)return;const p=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTop=Math.min(1,Math.max(0,f))*p,a()},[a]),c=h.useCallback((f,u=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),g=s.height/100*m.height,b=Math.max(1,m.height-g);return(f-m.top-u)/b},[s.height]),d=h.useCallback(f=>{var j,A;if(!s.visible)return;f.preventDefault(),f.stopPropagation();const u=r.current;if(!u)return;const p=u.getBoundingClientRect(),m=s.top/100*p.height,g=s.height/100*p.height,v=f.clientY>=p.top+m&&f.clientY<=p.top+m+g?f.clientY-p.top-m:g/2;l(c(f.clientY,v));const y=f.pointerId;(A=(j=f.currentTarget).setPointerCapture)==null||A.call(j,y);const k=C=>{C.preventDefault(),l(c(C.clientY,v))},w=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[o.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function YT({content:e}){const t=h.useRef(null),n=h.useMemo(()=>TT(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),IT(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.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),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}function xq({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Hn(e==null?void 0:e.definitionId);if(!s)return null;const i=Yl(e),a=s==="html"?Hu(i):i;if(!a.trim())return o.jsx(Ea,{className:"af-work-display-empty",children:"No display content"});if(s==="html")return o.jsx(Ea,{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||"HTML preview",sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:BT(a)},r)});if(s==="image"){const l=d0(a,t);return o.jsx(Ea,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:l,alt:dq(e),loading:"lazy"})})}return s==="markdown"?o.jsx(Ea,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(UT,{content:a,flowParams:t})}):s==="chart"?o.jsx(Ea,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(YT,{content:a})}):s==="table"?o.jsx(Ea,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(KT,{content:a})}):s==="mermaid"?o.jsxs(Ea,{className:"af-work-display-body",children:[o.jsx(qT,{code:a}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:a})]}):o.jsx(Ea,{className:"af-work-display-body af-work-display-body--ascii",children:o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:a})})}function wq({node:e}){var s,i,a,l,c;const t=Hn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Yl(e==null?void 0:e.data),r=t==="html"?Hu(n):n;return r.trim()?t==="html"?o.jsx("iframe",{title:((i=e==null?void 0:e.data)==null?void 0:i.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:BT(r)}):t==="image"?o.jsx("img",{src:d0(r,(a=e==null?void 0:e.data)==null?void 0:a.flowParams),alt:((l=e==null?void 0:e.data)==null?void 0:l.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?o.jsx("div",{className:"af-display-picker-preview__markdown",children:o.jsx(UT,{content:r,flowParams:(c=e==null?void 0:e.data)==null?void 0:c.flowParams})}):t==="chart"?o.jsx(YT,{content:r}):t==="table"?o.jsx(KT,{content:r}):t==="mermaid"?o.jsxs("div",{className:"af-display-picker-preview__diagram",children:[o.jsx(qT,{code:r}),o.jsx("pre",{children:r})]}):o.jsx("pre",{className:"af-display-picker-preview__pre",children:r}):o.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function bq({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=h.useRef(null),i=h.useRef(null),[a,l]=h.useState(!1),c=h.useCallback(f=>{const u=String(e||""),p=s.current,m=Number((p==null?void 0:p.selectionStart)??u.length),g=Number((p==null?void 0:p.selectionEnd)??m),b=u.slice(0,m),v=u.slice(g),y=b&&!b.endsWith(`
160
+ `)?`
161
+ `:"",k=v&&!v.startsWith(`
162
+ `)?`
163
+ `:"",w=`${b}${y}${f}${k}${v}`;t==null||t(w),window.requestAnimationFrame(()=>{var A,C;const j=b.length+y.length+f.length;(A=s.current)==null||A.focus(),(C=s.current)==null||C.setSelectionRange(j,j)})},[t,e]),d=h.useCallback(async f=>{if(!r&&!(!f||a)){l(!0);try{const u=await(n==null?void 0:n(f)),p=String(u||"").trim();if(p){const m=String(f.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";c(`![${m}](${p})`)}}finally{l(!1)}}},[c,n,r,a]);return o.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:f=>f.stopPropagation(),onDragOver:f=>{var p;Array.from(((p=f.dataTransfer)==null?void 0:p.items)||[]).some(m=>String((m==null?void 0:m.type)||"").startsWith("image/"))&&(f.preventDefault(),f.dataTransfer.dropEffect="copy")},onDrop:f=>{var p;const u=Array.from(((p=f.dataTransfer)==null?void 0:p.files)||[]).find(Ym);u&&(f.preventDefault(),d(u))},children:[o.jsxs("div",{className:"af-work-display-editor__toolbar",children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:a||r,onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:a?"hourglass_top":"add_photo_alternate"})}),o.jsx("input",{ref:i,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:f=>{var p;const u=(p=f.target.files)==null?void 0:p[0];f.target.value="",u&&d(u)}})]}),o.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:f=>t==null?void 0:t(f.target.value),onKeyDown:f=>{f.key==="Escape"&&f.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r})]})}function vq({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},i=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=h.useState(a),d=h.useRef(!1),f=String(s.candidateContent||""),u=!!s.running,p=!!(t!=null&&t.readOnly),m=String(s.error||"");return h.useEffect(()=>{d.current||c(a)},[a]),!n&&!r?null:n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-work-node-chat__head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"继续微调"}),o.jsx("span",{children:(t==null?void 0:t.label)||e})]}),o.jsx("button",{type:"button",onClick:()=>{var g;return(g=t==null?void 0:t.onCloseNodeChat)==null?void 0:g.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.length>0||u||m||f.trim()?o.jsxs("div",{className:"af-work-node-chat__messages",children:[i.slice(-4).map((g,b)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${g.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:g.role==="assistant"?"AI":"你"}),o.jsx("p",{children:g.text})]},`${g.at||b}-${b}`)),u?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,m?o.jsx("div",{className:"af-work-node-chat__error",children:m}):null]}):null,o.jsxs("div",{className:"af-work-node-chat__composer",children:[o.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:u||p,"aria-label":"添加上下文",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),o.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:u||p,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{d.current=!0},onCompositionEnd:g=>{var v;d.current=!1;const b=g.currentTarget.value;c(b),(v=t==null?void 0:t.onUpdateNodeChatDraft)==null||v.call(t,e,b)},onChange:g=>{var v;const b=g.target.value;c(b),d.current||(v=t==null?void 0:t.onUpdateNodeChatDraft)==null||v.call(t,e,b)},onKeyDown:g=>{var b,v;g.isComposing||(b=g.nativeEvent)!=null&&b.isComposing||g.keyCode===229||(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),(v=t==null?void 0:t.onSendNodeChat)==null||v.call(t,e,l))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:u||p||!l.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onSendNodeChat)==null?void 0:g.call(t,e,l)},"aria-label":"发送",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),o.jsxs("div",{className:"af-work-node-chat__actions",children:[o.jsx("button",{type:"button",disabled:u||p||!f.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"replace")},children:"替换当前内容"}),o.jsx("button",{type:"button",disabled:u||p||!f.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"append")},children:"追加"})]})]}):o.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:g=>{var b;g.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function kq(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function Sq(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function Nq(e,t){const n=Hn(t==null?void 0:t.definitionId)||"markdown";return`outputs/${Sq((t==null?void 0:t.label)||e||n)}.${kq(n)}`}function jq({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((E,D)=>({slot:E,idx:D})).sort((E,D)=>{var Z,V,se,ue;const _=String(((Z=E.slot)==null?void 0:Z.name)||"").trim(),R=String(((V=D.slot)==null?void 0:V.name)||"").trim();if(_==="next"&&R!=="next")return-1;if(R==="next"&&_!=="next")return 1;const P=String(((se=E.slot)==null?void 0:se.type)||"").trim(),G=String(((ue=D.slot)==null?void 0:ue.type)||"").trim();return P==="node"&&G!=="node"?-1:G==="node"&&P!=="node"?1:E.idx-D.idx}),l=Hn(t==null?void 0:t.definitionId),c=h.useRef(null),[d,f]=h.useState(0),[u,p]=h.useState(!1),[m,g]=h.useState(!1),[b,v]=h.useState(!1),[y,k]=h.useState(""),[w,j]=h.useState(!1),A=h.useRef(null),C=l==="markdown"?Yl(t):"",$=!!(t!=null&&t.readOnly),B=!!(t!=null&&t.displayPageMode);h.useEffect(()=>{if(!m)return;const E=()=>g(!1);return window.addEventListener("pointerup",E,!0),window.addEventListener("pointercancel",E,!0),window.addEventListener("mouseup",E,!0),window.addEventListener("blur",E),()=>{window.removeEventListener("pointerup",E,!0),window.removeEventListener("pointercancel",E,!0),window.removeEventListener("mouseup",E,!0),window.removeEventListener("blur",E)}},[m]),h.useEffect(()=>{b||k(String(C||""))},[C,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),z=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,L=h.useCallback(async()=>{var P,G;if(l!=="html"||u)return;const E=Hu(Yl(t));if(!E.trim())return;const D=(G=(P=c.current)==null?void 0:P.getBoundingClientRect)==null?void 0:G.call(P),_=Math.round((D==null?void 0:D.width)||Math.max(320,Number((z==null?void 0:z.width)||960)-2)),R=Math.round((D==null?void 0:D.height)||Math.max(180,Number((z==null?void 0:z.height)||640)-46));p(!0);try{await uq({content:E,width:_,height:R,filename:aq((t==null?void 0:t.label)||e||"html-render","png")})}catch(Z){console.warn("Failed to save HTML display as PNG; downloaded SVG fallback.",Z)}finally{p(!1)}},[t,z==null?void 0:z.height,z==null?void 0:z.width,e,l,u]),O=h.useCallback(E=>{var D;$||!E||l!=="image"||(D=t==null?void 0:t.onUploadImageToDisplayNode)==null||D.call(t,e,E)},[t,e,l,$]),W=h.useCallback(E=>{var R,P;$||l!=="image"||!(Array.from(((R=E.dataTransfer)==null?void 0:R.files)||[]).some(Ym)||Array.from(((P=E.dataTransfer)==null?void 0:P.items)||[]).some(G=>String((G==null?void 0:G.type)||"").startsWith("image/")))||(E.preventDefault(),E.stopPropagation(),E.dataTransfer.dropEffect="copy",j(!0))},[l,$]),M=h.useCallback(E=>{l==="image"&&(E.currentTarget.contains(E.relatedTarget)||j(!1))},[l]),T=h.useCallback(E=>{var _;if(l!=="image")return;const D=Array.from(((_=E.dataTransfer)==null?void 0:_.files)||[]).find(Ym);D&&(E.preventDefault(),E.stopPropagation(),j(!1),O(D))},[l,O]);return o.jsxs("div",{className:"af-work-display-card"+(z?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(m?" af-work-display-card--resizing":"")+(w?" af-work-display-card--image-drop":"")+(B?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:z?{width:z.width,height:z.height}:void 0,onDragOver:W,onDragLeave:M,onDrop:T,children:[o.jsx(RA,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>g(!0),onResizeEnd:()=>g(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((E,D)=>{if(E.showOnNode===!1)return null;const _=`${4.15+D*1.75}rem`,R=E.name||`#${D+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:_},children:R}),o.jsx(Cs,{type:"target",position:qe.Left,id:`input-${D}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:_,background:Qn(E.type)},title:`${R} · ${E.type}`})]},`in-${D}`)}),a.map(({slot:E,idx:D},_)=>{if(E.showOnNode===!1)return null;const R=`${4.15+_*1.75}rem`,P=E.name||`#${D+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:R},children:P}),o.jsx(Cs,{type:"source",position:qe.Right,id:`output-${D}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:R,background:Qn(E.type)},title:`${P} · ${E.type}`})]},`out-${D}`)}),o.jsxs("div",{className:"af-work-display-card__head",children:[o.jsxs("div",{className:"af-work-display-card__title",children:[o.jsx("span",{className:"material-symbols-outlined",children:fq(l)}),o.jsx("strong",{children:F}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:E=>E.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var E,D,_,R;try{(R=(_=(D=(E=c.current)==null?void 0:E.contentWindow)==null?void 0:D.history)==null?void 0:_.back)==null||R.call(_)}catch{}},"aria-label":"后退",title:"后退",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var E,D,_,R;try{(R=(_=(D=(E=c.current)==null?void 0:E.contentWindow)==null?void 0:D.history)==null?void 0:_.forward)==null||R.call(_)}catch{}},"aria-label":"前进",title:"前进",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>f(E=>E+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:u,onClick:L,"aria-label":"截图另存为图片",title:"截图另存为图片",children:o.jsx("span",{className:"material-symbols-outlined",children:u?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:E=>E.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:$,onClick:()=>{var E;(E=t==null?void 0:t.onSetDisplayNodeContent)==null||E.call(t,e,y,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),v(!1)},"aria-label":"保存并预览",title:"保存并预览",children:o.jsx("span",{className:"material-symbols-outlined",children:"done"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{k(String(C||"")),v(!1)},"aria-label":"取消编辑",title:"取消编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:$,onClick:E=>{E.stopPropagation(),k(String(C||"")),v(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:A,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:E=>{var _;const D=(_=E.target.files)==null?void 0:_[0];E.target.value="",D&&O(D)}}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:$,onClick:E=>{var D;E.stopPropagation(),(D=A.current)==null||D.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:$,onClick:()=>{var E;return(E=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:E.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"save"})}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:$,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?o.jsx(bq,{value:y,onChange:k,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:$}):o.jsx(xq,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:c,htmlFrameVersion:d}),o.jsx(vq,{nodeId:e,data:t})]})}function Cq({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=(t==null?void 0:t.runningRunNodeId)===e,l=(t==null?void 0:t.nodeStatus)==="stopped",c=!!(t!=null&&t.readOnly);return o.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":"")+(l?" af-work-run-card--stopped":""),children:[s.map((d,f)=>{if(d.showOnNode===!1)return null;const u=`${2.25+f*1.75}rem`,p=d.name||`#${f+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:u},children:p}),o.jsx(Cs,{type:"target",position:qe.Left,id:`input-${f}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:u,background:Qn(d.type)},title:`${p} · ${d.type}`})]},`in-${f}`)}),i.map((d,f)=>{if(d.showOnNode===!1)return null;const u=`${2.25+f*1.75}rem`,p=d.name||`#${f+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:u},children:p}),o.jsx(Cs,{type:"source",position:qe.Right,id:`output-${f}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:u,background:Qn(d.type)},title:`${p} · ${d.type}`})]},`out-${f}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:c,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:c,onClick:d=>{var f,u;d.stopPropagation(),a?(f=t==null?void 0:t.onStopWorkspaceNode)==null||f.call(t,e):(u=t==null?void 0:t.onRunWorkspaceNode)==null||u.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),o.jsx("span",{children:a?"Stop":"Run line"})]})]})}function Eq(e){var m,g,b,v,y,k,w,j,A,C,$,B,F;const{setEdges:t,setNodes:n}=cc(),r=(m=e.data)==null?void 0:m.onSyncNodePropDraft,s=!!((g=e.data)!=null&&g.readOnly),[i,a]=h.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=h.useCallback(z=>{s||(n(L=>L.filter(O=>O.id!==z)),t(L=>L.filter(O=>O.source!==z&&O.target!==z)))},[s,t,n]),d=h.useCallback((z,L)=>{s||(n(O=>O.map(W=>W.id===z?{...W,data:{...W.data,model:L}}:W)),r==null||r(z,{model:L}))},[s,n,r]),f=h.useCallback((z,L)=>{s||(n(O=>O.map(W=>{var T;if(W.id!==z)return W;const M=Array.isArray((T=W.data)==null?void 0:T.outputs)&&W.data.outputs.length?W.data.outputs.map((E,D)=>D===0?{...E,default:L,value:L}:E):[{type:"bool",name:"value",default:L,value:L}];return{...W,data:{...W.data,body:"",outputs:M}}})),r==null||r(z,O=>({body:"",outputs:Array.isArray(O==null?void 0:O.outputs)&&O.outputs.length?O.outputs.map((M,T)=>T===0?{...M,default:L,value:L}:M):[{type:"bool",name:"value",default:L,value:L}]})))},[s,n,r]),u=h.useCallback((z,L)=>{s||(n(O=>O.map(W=>W.id===z?{...W,data:{...W.data,body:L}}:W)),r==null||r(z,{body:L}))},[s,n,r]),p=h.useCallback((z,L)=>{if(s)return;const O=ws(L);n(W=>W.map(M=>M.id===z?{...M,data:{...M.data,images:O}}:M)),r==null||r(z,{images:O})},[s,n,r]);return Hn((v=e.data)==null?void 0:v.definitionId)?o.jsx(jq,{...e,deleteNode:c}):((y=e.data)==null?void 0:y.definitionId)==="workspace_run"?o.jsx(Cq,{...e,deleteNode:c}):((k=e.data)==null?void 0:k.definitionId)==="control_load_skills"?o.jsx(Fq,{...e,deleteNode:c,skills:(w=e.data)==null?void 0:w.skills,skillCollections:(j=e.data)==null?void 0:j.skillCollections,onChangeSkillKeys:(A=e.data)==null?void 0:A.onChangeLoadSkillKeys}):((C=e.data)==null?void 0:C.definitionId)==="control_load_mcp"?o.jsx(zq,{...e,deleteNode:c,servers:($=e.data)==null?void 0:$.mcpServers,onChangeMcpNames:(B=e.data)==null?void 0:B.onChangeLoadMcpNames}):o.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(i?" af-work-flow-node--resizing":""),style:l?{width:l.width,height:l.height}:void 0,children:[s?null:o.jsx(RA,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:RT,minHeight:mb,maxWidth:LT,maxHeight:OT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),o.jsx(pT,{...e,deleteNode:c,modelLists:(F=e.data)==null?void 0:F.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:u,onNodeImagesChange:p})]})}const _q={[ap]:Eq};function GT(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&GT(n.children,t);return t}function XT(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&XT(n.children,t));return t}function Sh(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 Pq(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function Aq(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(i,a,l)=>{const c=r[a],d=l?`${l}/${c}`:c,f=a===r.length-1;let u=!1;const p=(Array.isArray(i)?i:[]).map(m=>m.name!==c?m:(u=!0,f?{...m,type:"file",name:c,path:d,icon:Fd(c),size:n}:{...m,type:"directory",name:c,path:d,icon:Fd(c,!0),children:s(m.children||[],a+1,d)}));return u||p.push(f?{type:"file",name:c,path:d,icon:Fd(c),size:n}:{type:"directory",name:c,path:d,icon:Fd(c,!0),children:s([],a+1,d)}),Pq(p)};return s(e||[],0,"")}function JT({items:e,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:c}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(d=>{var p;const f=d.type==="directory",u=f&&(r==null?void 0:r.has(d.path));return o.jsxs("li",{children:[o.jsxs("div",{className:"af-work-file-row",children:[o.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+d.type,draggable:!f,onDragStart:m=>{f||c==null||c(m,d)},onClick:()=>f?s==null?void 0:s(d.path):n(d),title:d.path,children:[f?o.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:u?"chevron_right":"expand_more"}):null,o.jsx("span",{className:"material-symbols-outlined",children:d.icon||Fd(d.name,f)}),o.jsx("span",{children:d.name})]}),f?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>i==null?void 0:i(d.path),title:"新增文件","aria-label":`在 ${d.name} 新增文件`,children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>a==null?void 0:a(d.path),title:"新增文件夹","aria-label":`在 ${d.name} 新增文件夹`,children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})})]}):null,f?null:o.jsx("a",{className:"af-work-file-action",href:X7(d.path,t),download:d.name,onClick:m=>m.stopPropagation(),title:"下载","aria-label":`下载 ${d.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"download"})}),o.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:()=>l==null?void 0:l(d),title:"删除","aria-label":`删除 ${d.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]}),f&&!u&&((p=d.children)!=null&&p.length)?o.jsx(JT,{items:d.children,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:c}):null]},d.path)})})}function Iq({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return o.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,i)=>{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 o.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[o.jsx("div",{className:"af-composer-ai-block-label",children:l}),o.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${i}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function Xm(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 Tq(e){const t=Xm((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 Xm((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Rq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function Lq(e){const t=Xm((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 Xm((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Oq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function a1(e){var r,s,i,a,l,c;if(!e)return null;const{inputs:t,outputs:n}=cT(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(((i=e.data)==null?void 0:i.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:ws((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),inputs:t,outputs:n}}function l1(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 Mq(e,t,n){var f,u;const r=String(((f=e==null?void 0:e.data)==null?void 0:f.definitionId)??n),s=r.startsWith("provide_"),i=String((t==null?void 0:t.role)||"").trim(),a=tl.includes(i)?i:"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?[]:ws(t==null?void 0:t.images),inputs:l1(t==null?void 0:t.inputs),outputs:s&&Array.isArray((u=e.data)==null?void 0:u.outputs)?e.data.outputs:l1(t==null?void 0:t.outputs)},d=String((t==null?void 0:t.script)??"").trim();return r==="tool_nodejs"||d!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script,c}function c1({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:i=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),c=i?l:a;if(i){if(!bT.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(b=>b.id===c&&b.id!==a))return{ok:!1,error:"Duplicate instance id"}}const d=Mq(r,s,c),f=r.data||{};if(!(c!==a||f.label!==d.label||f.role!==d.role||f.model!==d.model||f.body!==d.body||JSON.stringify(ws(f.images))!==JSON.stringify(d.images)||(f.script??void 0)!==(d.script??void 0)||JSON.stringify(f.inputs||[])!==JSON.stringify(d.inputs||[])||JSON.stringify(f.outputs||[])!==JSON.stringify(d.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const p=e.map(b=>b.id===a?{...b,id:c,selected:!0,data:d}:b);let m=t,g=n;if(c!==a){g={...n||{}};const b={...g[a]||{}};delete g[a],g[c]=b,m=t.map((v,y)=>({...v,source:v.source===a?c:v.source,target:v.target===a?c:v.target,id:`we-${v.source===a?c:v.source}-${v.target===a?c:v.target}-${y}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:m,instances:g}}function $q(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function Dq(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","inputs","outputs"])$q(e[s],t[s])&&(r[s]=n[s]);return r}function Fq({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:i,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:[],d=Array.isArray(s)?s:[],f=Array.isArray(i)?i:[],[u,p]=h.useState(!1),[m,g]=h.useState(""),[b,v]=h.useState(()=>new Set),y=h.useRef(null),k=h.useRef(null),[w,j]=h.useState({visible:!1,top:0,height:100}),A=h.useMemo(()=>new Set(Tq(t)),[t]),C=h.useMemo(()=>new Map(d.map(T=>[T.key,T])),[d]),$=h.useMemo(()=>{const T=new Set,E=f.map(_=>{const R=Za(_,d).map(P=>C.get(P)).filter(Boolean);for(const P of R)T.add(P.key);return{..._,skills:R}}).filter(_=>_.skills.length>0),D=d.filter(_=>!T.has(_.key));return{collectionGroups:E,ungrouped:D}},[C,f,d]);h.useEffect(()=>{v(T=>{let E=!1;const D=new Set(T);for(const _ of $.collectionGroups)D.has(_.id)||(D.add(_.id),E=!0);return E?D:T})},[$.collectionGroups]);const B=h.useMemo(()=>{const T=m.trim().toLowerCase();if(!T)return $;const E=_=>[_==null?void 0:_.key,_==null?void 0:_.name,_==null?void 0:_.description].map(P=>String(P||"").toLowerCase()).join(" ").includes(T);return{collectionGroups:$.collectionGroups.map(_=>{const P=[_==null?void 0:_.id,_==null?void 0:_.name,_==null?void 0:_.description].map(G=>String(G||"").toLowerCase()).join(" ").includes(T)?_.skills:_.skills.filter(E);return{..._,skills:P}}).filter(_=>_.skills.length>0),ungrouped:$.ungrouped.filter(E)}},[$,m]),F=h.useCallback((T,E)=>{const D=new Set(A);for(const _ of T)E?D.add(_):D.delete(_);a==null||a(e,Array.from(D))},[e,A,a]),z=h.useCallback(T=>{v(E=>{const D=new Set(E);return D.has(T)?D.delete(T):D.add(T),D})},[]),L=h.useCallback(()=>{const T=y.current;if(!T)return;const E=Math.max(1,T.scrollHeight),D=Math.max(1,T.clientHeight),_=E>D+1,R=_?Math.max(12,D/E*100):100,P=Math.max(0,100-R),G=_?Math.min(P,T.scrollTop/Math.max(1,E-D)*P):0;j({visible:_,top:G,height:R})},[]);h.useEffect(()=>{if(!u)return;const T=requestAnimationFrame(L);return()=>cancelAnimationFrame(T)},[b,B,A.size,u,L]);const O=h.useCallback(T=>{const E=y.current;if(!E)return;const D=Math.max(0,E.scrollHeight-E.clientHeight);E.scrollTop=Math.min(1,Math.max(0,T))*D,L()},[L]),W=h.useCallback((T,E=0)=>{const D=k.current;if(!D)return 0;const _=D.getBoundingClientRect(),R=w.height/100*_.height,P=Math.max(1,_.height-R);return(T-_.top-E)/P},[w.height]),M=h.useCallback(T=>{var ue,fe;if(!w.visible)return;T.preventDefault(),T.stopPropagation();const E=k.current;if(!E)return;const D=E.getBoundingClientRect(),_=w.top/100*D.height,R=w.height/100*D.height,G=T.clientY>=D.top+_&&T.clientY<=D.top+_+R?T.clientY-D.top-_:R/2;O(W(T.clientY,G));const Z=T.pointerId;(fe=(ue=T.currentTarget).setPointerCapture)==null||fe.call(ue,Z);const V=ge=>{ge.preventDefault(),O(W(ge.clientY,G))},se=()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",se),window.removeEventListener("pointercancel",se)};window.addEventListener("pointermove",V),window.addEventListener("pointerup",se),window.addEventListener("pointercancel",se)},[W,O,w.height,w.top,w.visible]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[l.map((T,E)=>{if(T.showOnNode===!1)return null;const D=`${2.6+E*1.7}rem`,_=T.name||`#${E+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:_}),o.jsx(Cs,{type:"target",position:qe.Left,id:`input-${E}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:Qn(T.type)},title:`${_} · ${T.type}`})]},`in-${E}`)}),c.map((T,E)=>{if(T.showOnNode===!1)return null;const D=`${2.6+E*1.7}rem`,_=T.name||`#${E+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:_}),o.jsx(Cs,{type:"source",position:qe.Right,id:`output-${E}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:Qn(T.type)},title:`${_} · ${T.type}`})]},`out-${E}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:T=>{var E;T.stopPropagation(),u||(E=t==null?void 0:t.onRefreshSkills)==null||E.call(t),p(D=>!D)},children:[o.jsx("span",{children:A.size>0?`${A.size} skills selected`:"选择 Skills"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:T=>T.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:m,onChange:T=>g(T.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),m?o.jsx("button",{type:"button",onClick:()=>g(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:y,className:"af-work-load-skills-menu",onScroll:L,children:[B.collectionGroups.map(T=>{const E=T.skills.map(P=>P.key),D=E.filter(P=>A.has(P)).length,_=E.length>0&&D===E.length,R=b.has(T.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(R?" af-work-load-skills-menu__group--collapsed":""),children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[o.jsx("input",{type:"checkbox",checked:_,onChange:P=>F(E,P.target.checked),"aria-label":`选择 ${T.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>z(T.id),"aria-expanded":!R,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:T.name}),T.description?o.jsx("em",{children:T.description}):null]})}),o.jsxs("small",{children:[D,"/",E.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>z(T.id),"aria-label":R?`展开 ${T.name}`:`收起 ${T.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:R?"chevron_right":"expand_more"})})]}),R?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:T.skills.map(P=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:A.has(P.key),onChange:G=>F([P.key],G.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:P.name}),P.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:P.description}):null]})]},`${T.id}:${P.key}`))})]},T.id)}),B.ungrouped.length>0?o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("small",{children:B.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:B.ungrouped.map(T=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:A.has(T.key),onChange:E=>F([T.key],E.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:T.name}),T.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:T.description}):null]})]},`ungrouped:${T.key}`))})]}):null,B.collectionGroups.length===0&&B.ungrouped.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),o.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(w.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:M,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${w.height}%`,top:`${w.top}%`}})})]}):null]})]})}function zq({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:i}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,d]=h.useState(!1),[f,u]=h.useState(""),p=h.useMemo(()=>new Set(Lq(t)),[t]),m=h.useMemo(()=>(Array.isArray(s)?s:[]).map(v=>({name:String((v==null?void 0:v.name)||""),description:String((v==null?void 0:v.description)||""),detail:String((v==null?void 0:v.url)||[v==null?void 0:v.command,...Array.isArray(v==null?void 0:v.args)?v.args:[]].filter(Boolean).join(" ")||""),type:String((v==null?void 0:v.type)||"")})).filter(v=>v.name),[s]),g=h.useMemo(()=>{const v=f.trim().toLowerCase();return v?m.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(v)):m},[f,m]),b=h.useCallback((v,y)=>{const k=new Set(p);for(const w of v)y?k.add(w):k.delete(w);i==null||i(e,Array.from(k))},[e,p,i]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[a.map((v,y)=>{if(v.showOnNode===!1)return null;const k=`${2.6+y*1.7}rem`,w=v.name||`#${y+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:w}),o.jsx(Cs,{type:"target",position:qe.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:Qn(v.type)},title:`${w} · ${v.type}`})]},`in-${y}`)}),l.map((v,y)=>{if(v.showOnNode===!1)return null;const k=`${2.6+y*1.7}rem`,w=v.name||`#${y+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:w}),o.jsx(Cs,{type:"source",position:qe.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:Qn(v.type)},title:`${w} · ${v.type}`})]},`out-${y}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"hub"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:v=>{var y;v.stopPropagation(),c||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),d(k=>!k)},children:[o.jsx("span",{children:p.size>0?`${p.size} MCP selected`:"选择 MCP"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:f,onChange:v=>u(v.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),f?o.jsx("button",{type:"button",onClick:()=>u(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{className:"af-work-load-skills-menu",children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"MCP Servers"}),o.jsx("small",{children:g.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(v=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:p.has(v.name),onChange:y=>b([v.name],y.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:v.name}),v.description||v.detail?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:v.description||v.detail}):null]})]},v.name))})]}),g.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>i==null?void 0:i(e,[]),children:"清空"})]})]}):null]})]})}function Bq(){var bt,Ep;const{i18n:e}=vn(),{navigate:t}=ko(),n=cc(),r=zv(),s=h.useMemo(G7,[]),[i,a]=h.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[l,c]=_A([]),[d,f,u]=PA([]),p=h.useRef([]),m=h.useRef([]),[g,b]=h.useState(()=>xb(null,[])),v=h.useRef(g),[y,k]=h.useState(null),w=h.useRef(null),[j,A]=h.useState([]),C=h.useRef(new Map),$=h.useRef(new Map),B=h.useRef(null),F=h.useRef(null),z=h.useRef(null),[L,O]=h.useState(null),[W,M]=h.useState({}),T=h.useRef({}),E=h.useRef(!1),D=h.useRef(null),[_,R]=h.useState([]),[P,G]=h.useState(""),[Z,V]=h.useState("nodes"),[se,ue]=h.useState([]),[fe,ge]=h.useState(!1),[ae,ve]=h.useState(""),[_e,we]=h.useState(!1),[Ee,Ae]=h.useState({name:"",id:"",description:""}),[st,ut]=h.useState(!1),[et,Ct]=h.useState(""),[Ue,St]=h.useState(""),nn=h.useRef(null),[hn,An]=h.useState(!1),[Bt,In]=h.useState(!1),[Fn,le]=h.useState(""),[de,ze]=h.useState(null),[Qe,ot]=h.useState({title:"",layout:"gallery",nodeIds:[]}),[Qt,rn]=h.useState(!1),[Tn,mn]=h.useState(!1),[or,sn]=h.useState(""),[kn,tn]=h.useState(!1),[Sn,xe]=h.useState("nodes"),[Te,it]=h.useState(""),[re,je]=h.useState(0),[Ye,jt]=h.useState(""),[Ke,Nn]=h.useState(null),fi=h.useRef(null),[jo,kr]=h.useState(""),[Sr,Co]=h.useState([]),[ar,qs]=h.useState(""),[Oe,aa]=h.useState(!0),[pi,Kn]=h.useState(""),[Le,Ht]=h.useState(()=>new Set),Nr=h.useRef(null),[mt,Vi]=h.useState(()=>{try{const S=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(S)&&S>=160)return S}catch{}return 360}),[Zn,zn]=h.useState(!1),[jr,lt]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[Wt,Yt]=h.useState(""),[Rn,Je]=h.useState([]),[lr,_s]=h.useState(!1),[Cr,hi]=h.useState([]),[Ps,Eo]=h.useState([]),[Ui,_o]=h.useState(!1),[Ys,an]=h.useState([]),As=h.useCallback(S=>{nn.current&&window.clearTimeout(nn.current),St(S),nn.current=window.setTimeout(()=>{St(""),nn.current=null},3800)},[]),Is=h.useCallback(S=>{const I=String(S||"").trim();if(!I)return;const K=()=>r(I);window.requestAnimationFrame(K),window.setTimeout(K,80)},[r]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(mt)))}catch{}},[mt]);const Ts=h.useCallback(S=>{const I=Nr.current;if(!I)return;const K=I.getBoundingClientRect(),X=16,Q=150,ie=230,te=K.top+X,oe=K.bottom-X,me=Math.max(Q,oe-te-ie),be=Math.min(Math.max(S-te,Q),me);Vi(be)},[]),Gs=h.useCallback(S=>{S.preventDefault(),S.stopPropagation(),zn(!0),Ts(S.clientY);const I=X=>{X.preventDefault(),Ts(X.clientY)},K=()=>{zn(!1),window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",K,!0),window.removeEventListener("pointercancel",K,!0)};window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",K,!0),window.addEventListener("pointercancel",K,!0)},[Ts]);h.useEffect(()=>()=>{nn.current&&window.clearTimeout(nn.current)},[]);const[U,he]=h.useState(()=>new Set),[Ie,Pe]=h.useState(!1),Ge=h.useRef(null),Vt=h.useRef(null),Mt=h.useRef(null),[er,Er]=h.useState({}),[Xs,Po]=h.useState(""),[Br,cr]=h.useState(!1),[la,cl]=h.useState([]),[Yu,tr]=h.useState([]),[dc,Ki]=h.useState("workspace"),[Ao,Io]=h.useState(!1),[fc,Gt]=h.useState(!0),[pc,Ln]=h.useState(""),[qi,mi]=h.useState({}),[Js,ca]=h.useState(!1),[ul,Yi]=h.useState(!1),[ur,dl]=h.useState(!1),[To,fl]=h.useState("pan"),[Hr,ua]=h.useState(null),[gi,da]=h.useState(""),Gi=h.useRef(null),cs=h.useRef(!1),[pp,_r]=h.useState(()=>new Set),[pl,Xi]=h.useState({}),[hl,Re]=h.useState(""),Qs=h.useMemo(()=>J7(s),[s]),[ml,Gu]=h.useState("");h.useEffect(()=>{s.flowId&&T_(s.flowId,s.flowSource||"user","workspace",!!s.archived)},[s]),h.useEffect(()=>{const S=()=>{a(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[]),h.useEffect(()=>{cl([]),tr([]),Ki("workspace"),Gt(!0)},[s]);const qn=h.useCallback(async()=>{const S=Aa(s),I=await fetch(`/api/workspace/files?${S.toString()}`),K=await I.json();if(!I.ok)throw new Error(K.error||"读取 workspace 失败");const X=K.files||[];Co(X),Ht(new Set(XT(X))),qs(K.root||"")},[s]),Ro=h.useCallback(async()=>{ge(!0),ve("");try{const S=await fetch("/api/marketplace/flow-snippets"),I=await S.json().catch(()=>({}));if(!S.ok)throw new Error(I.error||"读取流程片段失败");ue(Array.isArray(I.snippets)?I.snippets:[])}catch(S){ve(String(S.message||S)),ue([])}finally{ge(!1)}},[]),jn=h.useCallback(async(S=l,I=d)=>{var ie;if(!E.current)return;if(!Oe)throw Re("Readonly workspace"),new Error("Readonly workspace");const K=kh(S,I,T.current);K.ui={...K.ui||{},...w.current?{viewport:w.current}:{},displayPage:iq(v.current,S)};const X=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,graph:K})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"保存 workspace graph 失败");T.current=((ie=Q.graph)==null?void 0:ie.instances)||K.instances,M(T.current),Re("Workspace graph saved")},[d,s,l,Oe]),us=h.useCallback(S=>{var K;const I=(K=S==null?void 0:S.extra)!=null&&K.instances&&typeof S.extra.instances=="object"?S.extra.instances:{};T.current=I,M(I),c(Array.isArray(S==null?void 0:S.nodes)?S.nodes:[]),f(Array.isArray(S==null?void 0:S.edges)?S.edges:[]),jt(""),O(null)},[f,c]),gl=h.useMemo(()=>({instances:W}),[W]),hc=dT({nodes:l,edges:d,extra:gl,enabled:E.current,onRestore:us}),{resetHistory:fa,undo:pa,redo:ha}=hc,ma=h.useCallback(async()=>{var yt,tt;E.current=!1;const S=Aa(s),I=Aa(s);I.set("lang",String(e.language||"zh").startsWith("zh")?"zh":"en");const[K,X]=await Promise.all([fetch(`/api/nodes?${I.toString()}`),fetch(`/api/workspace/graph?${S.toString()}`),qn()]),Q=await K.json(),ie=await X.json();if(!K.ok)throw new Error(Q.error||"读取节点定义失败");if(!X.ok)throw new Error(ie.error||"读取 workspace graph 失败");const te=[...(Array.isArray(Q)?Q:Q.nodes||[]).filter(Dt=>!H7.has(Dt.id)),V7,U7,W7];R(te);const oe=ie.graph||JSON.parse(localStorage.getItem(B7)||"null")||{},me=xx(oe,te),be=xb((yt=oe==null?void 0:oe.ui)==null?void 0:yt.displayPage,me.nodes),Fe=FT((tt=oe==null?void 0:oe.ui)==null?void 0:tt.viewport);T.current=me.instances,M(me.instances),c(me.nodes),f(me.edges),b(be),v.current=be,k(Fe),w.current=Fe,A([]),fa(me.nodes,me.edges,{instances:me.instances});const Xe=ie.writable!==!1;aa(Xe),Re(Xe?"Workspace ready":"Readonly workspace"),E.current=!0},[s,e.language,qn,fa,f,c]),Xu=h.useCallback(async(S,I)=>{const K={packageId:(S==null?void 0:S.newId)||(S==null?void 0:S.id)||(S==null?void 0:S.label),label:(S==null?void 0:S.label)||(S==null?void 0:S.newId)||(S==null?void 0:S.id),version:"1.0.0",definitionId:I,body:(S==null?void 0:S.body)||"",script:(S==null?void 0:S.script)||"",inputs:Array.isArray(S==null?void 0:S.inputs)?S.inputs:[],outputs:Array.isArray(S==null?void 0:S.outputs)?S.outputs:[],flowId:s.flowId,flowSource:s.flowSource||"user",archived:!!s.archived},X=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)}),Q=await X.json().catch(()=>({}));if(!X.ok||(Q==null?void 0:Q.ok)===!1)throw new Error((Q==null?void 0:Q.error)||"Publish failed");return await ma(),Re(`Published node ${Q.definitionId||Q.id||K.packageId}`),Q},[s,ma]),yl=h.useCallback((S="workspace")=>{Io(!0),Nn(null),Ki(S||"workspace")},[]),ga=h.useCallback(async(S="")=>{const I=String(S||gi||"").trim();if(I){cs.current=!0,Gi.current&&(Gi.current.abort(),Gi.current=null),da(""),_r(new Set),Xi(K=>{const X={...K};for(const[Q,ie]of Object.entries(X))(ie==null?void 0:ie.status)==="running"&&(X[Q]={status:"stopped"});return X[I]={status:"stopped"},X}),Re(`Workspace run stopped: ${I}`),tr(K=>K.map(X=>X.runNodeId===I&&X.status==="running"?{...X,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(X.messages)?X.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:X));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,runNodeId:I})})}catch{}}},[s,gi]),mc=h.useCallback(async S=>{if(!Oe){Re("Readonly workspace");return}if(!S||gi)return;let I=l,K=d,X=T.current;const Q=fi.current;if(Q!=null&&Q.id){const be=I.find(Xe=>Xe.id===Q.id),Fe=c1({nodes:I,edges:K,instances:X,selectedNode:be,draft:Q,allowRename:!1});if(Fe!=null&&Fe.error){kr(Fe.error),Re(Fe.error);return}Fe!=null&&Fe.ok&&Fe.changed&&(I=Fe.nodes,K=Fe.edges,X=Fe.instances,T.current=X,M(X),c(I),f(K),Is(Fe.nextId||Q.id))}const ie=kh(I,K,X),te=`run-${Date.now()}-${String(S).replace(/[^a-z0-9_-]+/gi,"_")}`,oe=`Run ${S}`,me=new AbortController;Gi.current=me,cs.current=!1,da(S),_r(new Set([S])),Xi({[S]:{status:"running"}}),Re(`Running ${S}...`),Ki(te),tr(be=>[...be.slice(-7),{id:te,label:oe,runNodeId:S,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await jn(I,K);const be=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:me.signal,body:JSON.stringify({...s,graph:ie,runNodeId:S,model:Wt,selectedSkills:Cr,stream:!0})});if(!be.ok){const ke=await be.json().catch(()=>({}));throw new Error(ke.error||"Workspace run failed")}if(!be.body)throw new Error("Workspace run stream unavailable");const Fe=be.body.getReader(),Xe=new TextDecoder;let yt="",tt=[],Dt=[],Bn=S;const Gn=(ke,ft)=>{var Tt,Xt;const dt=l.find(Ft=>Ft.id===ke),nt=String(((Tt=dt==null?void 0:dt.data)==null?void 0:Tt.label)||ke||"").trim(),$e=String(ft||((Xt=dt==null?void 0:dt.data)==null?void 0:Xt.definitionId)||"").trim();return $e&&$e!==nt?`${nt} (${$e})`:nt},It=(ke,ft,dt)=>{const nt=String(ke||"").trim();nt&&tr($e=>$e.map(Tt=>{if(Tt.id!==te)return Tt;const Ft=[...Array.isArray(Tt.steps)?Tt.steps:[]],cn=Ft.findIndex(eo=>eo.id===nt),Rt={id:nt,label:Gn(nt,ft),status:dt};cn>=0?Ft[cn]={...Ft[cn],...Rt}:Ft.push(Rt);const Et=Ft.map((eo,jc)=>{const Zg=eo.status==="done"?"[done]":eo.status==="failed"?"[failed]":"[running]";return`${jc+1}. ${Zg} ${eo.label}`}).join(`
164
+ `),Zt=Array.isArray(Tt.messages)?Tt.messages:[],Pr=Zt.findIndex(eo=>eo.kind==="run-summary"),Si={role:"assistant",kind:"run-summary",text:Et||"准备运行...",at:Date.now()},Zi=[...Zt];return Pr>=0?Zi[Pr]=Si:Zi.unshift(Si),{...Tt,steps:Ft,messages:Zi.slice(-160)}}))},rr=ke=>{const ft=String(ke||"").trim();if(!ft)return;const dt=Bn;Bn=ft,_r(new Set([ft])),Xi(nt=>{var $e;return{...nt,...dt&&dt!==ft&&(($e=nt[dt])==null?void 0:$e.status)==="running"?{[dt]:{status:"success"}}:{},[ft]:{status:"running"}}})},Qi=ke=>{const ft=String(ke||"").trim();ft&&(_r(dt=>{const nt=new Set(dt);return nt.delete(ft),nt}),Xi(dt=>({...dt,[ft]:{status:"success"}})))},Ur=(ke,ft)=>{const dt=String(ft||"");if(!dt.trim())return;const nt=["assistant","thinking","result","error","prompt"].includes(ke)?ke:"assistant";tr($e=>$e.map(Tt=>{if(Tt.id!==te)return Tt;let Xt=Array.isArray(Tt.messages)?Tt.messages:[];if(nt==="result"){const Rt=[...Xt].reverse().find(Et=>Et.kind==="assistant");if(String((Rt==null?void 0:Rt.text)||"").trim()===dt.trim())return Tt}if(nt==="assistant"){const Rt=Xt.findIndex(Et=>Et.kind==="result"&&String(Et.text||"").trim()===dt.trim());Rt>=0&&(Xt=Xt.filter((Et,Zt)=>Zt!==Rt))}const Ft=[...Xt],cn=Ft[Ft.length-1];return cn&&cn.kind===nt&&!cn.error?Ft[Ft.length-1]={...cn,text:`${cn.text||""}${cn.text?`
165
+ `:""}${dt}`}:Ft.push({role:"assistant",kind:nt,text:dt,...nt==="error"?{error:!0}:{},at:Date.now()}),{...Tt,messages:Ft.slice(-160)}}))},xr=ke=>{const ft=String(ke||"");ft.trim()&&tr(dt=>dt.map(nt=>{var Ft;if(nt.id!==te)return nt;const $e=Array.isArray(nt.messages)?nt.messages:[],Tt=$e.findIndex(cn=>cn.kind==="thinking"),Xt=[...$e];if(Tt>=0){const cn=String(((Ft=Xt[Tt])==null?void 0:Ft.text)||"");Xt[Tt]={...Xt[Tt],text:`${cn}${cn&&!cn.endsWith(`
166
+ `),""}${ft}`,at:Date.now()}}else{const cn=Xt.findIndex(Rt=>Rt.kind==="activity");Xt.splice(cn>=0?cn+1:Xt.length,0,{role:"assistant",kind:"thinking",text:ft,at:Date.now()})}return{...nt,messages:Xt.slice(-160)}}))},ct=ke=>{const ft=Z7(ke);ft&&tr(dt=>dt.map(nt=>{if(nt.id!==te)return nt;const $e=Array.isArray(nt.activities)?nt.activities:[],Tt=$e[$e.length-1]===ft?$e:[...$e,ft].slice(-8),Xt=Array.isArray(nt.messages)?nt.messages:[],Ft=Xt.findIndex(Et=>Et.kind==="activity"),cn={role:"assistant",kind:"activity",text:Tt.map((Et,Zt)=>`${Zt+1}. ${Et}`).join(`
167
+ `),at:Date.now()},Rt=[...Xt];if(Ft>=0)Rt[Ft]=cn;else{const Et=Rt.findIndex(Zt=>Zt.kind==="run-summary");Rt.splice(Et>=0?Et+1:0,0,cn)}return{...nt,activities:Tt,messages:Rt.slice(-160)}}))},gn=ke=>{const ft=String((ke==null?void 0:ke.source)||"runner"),dt=String((ke==null?void 0:ke.stream)||""),nt=String((ke==null?void 0:ke.eventType)||"event"),$e=String((ke==null?void 0:ke.text)||"").trim();if(!$e)return;const Tt=`[${ft}${dt?`:${dt}`:""}] ${nt}
168
+ ${$e}`;tr(Xt=>Xt.map(Ft=>{if(Ft.id!==te)return Ft;const Rt=[...Array.isArray(Ft.rawTrace)?Ft.rawTrace:[],Tt].slice(-80),Et=Array.isArray(Ft.messages)?Ft.messages:[],Zt=Et.findIndex(Zi=>Zi.kind==="raw"),Pr={role:"assistant",kind:"raw",text:Rt.join(`
169
+
170
+ ---
171
+
172
+ `),at:Date.now()},Si=[...Et];return Zt>=0?Si[Zt]=Pr:Si.push(Pr),{...Ft,rawTrace:Rt,messages:Si.slice(-160)}}))},Ze=ke=>{tr(ft=>ft.map(dt=>dt.id===te?{...dt,status:ke,endedAt:Date.now()}:dt))},ts=ke=>{const ft=new Set,dt=String((ke==null?void 0:ke.nodeId)||"").trim();dt&&ft.add(dt);for(const nt of Array.isArray(ke==null?void 0:ke.displayNodeIds)?ke.displayNodeIds:[]){const $e=String(nt||"").trim();$e&&ft.add($e)}for(const nt of Array.isArray(ke==null?void 0:ke.touchedNodeIds)?ke.touchedNodeIds:[]){const $e=String(nt||"").trim();$e&&ft.add($e)}if(ft.size===0)for(const nt of Array.isArray(ke==null?void 0:ke.order)?ke.order:[]){const $e=String(nt||"").trim();$e&&ft.add($e)}return ft},Nc=(ke,ft=null)=>{const dt=xx(ke||ie,_),nt=new Map(dt.nodes.map(Xt=>[Xt.id,Xt])),$e=dt.instances||{},Tt=ft instanceof Set?ft:null;c(Xt=>{const Ft=new Set(Xt.map(Et=>Et.id)),Rt={...kh(Xt,m.current,T.current).instances||{}};for(const[Et,Zt]of Object.entries($e)){if(Tt&&!Tt.has(Et)||!Ft.has(Et))continue;const Pr=Rt[Et];Hn((Zt==null?void 0:Zt.definitionId)||(Pr==null?void 0:Pr.definitionId))?Rt[Et]=Zt:Array.isArray(Zt==null?void 0:Zt.output)&&(Rt[Et]={...Pr||Zt,output:Zt.output})}return T.current=Rt,M(Rt),Xt.map(Et=>{var Pr,Si,Zi;if(Tt&&!Tt.has(Et.id))return Et;const Zt=nt.get(Et.id);return Zt?Hn(((Pr=Zt.data)==null?void 0:Pr.definitionId)||((Si=Et.data)==null?void 0:Si.definitionId))?{...Et,data:{...Et.data,...Zt.data}}:Array.isArray((Zi=Zt.data)==null?void 0:Zi.outputs)?{...Et,data:{...Et.data,outputs:Zt.data.outputs}}:Et:Et})})};for(;;){const{value:ke,done:ft}=await Fe.read();if(ft)break;yt+=Xe.decode(ke,{stream:!0});const dt=yt.split(`
173
+ `);yt=dt.pop()||"";for(const nt of dt){if(!nt.trim())continue;const $e=JSON.parse(nt);if($e.type==="error")throw new Error($e.error||"Workspace run failed");if($e.type==="stopped"){cs.current=!0,tt=Array.isArray($e.order)?$e.order:tt;continue}if($e.type==="node-start"&&(Re(`Running ${$e.nodeId}...`),rr($e.nodeId),It($e.nodeId,$e.definitionId,"running")),$e.type==="node-done"&&(Qi($e.nodeId),It($e.nodeId,$e.definitionId,"done")),$e.type==="status"&&ct($e.line||$e.message||""),$e.type==="paused"&&(Dt=Array.isArray($e.nodeIds)?$e.nodeIds:[]),$e.type==="natural"&&($e.kind==="thinking"?xr($e.text||""):Ur($e.kind,$e.text||"")),$e.type==="raw"){const Tt=Qj($e);Tt&&xr(Tt),gn($e)}$e.type==="graph"&&$e.graph&&Nc($e.graph,ts($e)),$e.type==="done"&&($e.graph&&Nc($e.graph,ts($e)),tt=Array.isArray($e.order)?$e.order:[],Dt=Array.isArray($e.pauseNodeIds)?$e.pauseNodeIds:Dt)}}if(yt.trim()){const ke=JSON.parse(yt);if(ke.type==="error")throw new Error(ke.error||"Workspace run failed");if(ke.type==="stopped"&&(cs.current=!0),ke.type==="node-start"&&(Re(`Running ${ke.nodeId}...`),rr(ke.nodeId),It(ke.nodeId,ke.definitionId,"running")),ke.type==="node-done"&&(Qi(ke.nodeId),It(ke.nodeId,ke.definitionId,"done")),ke.type==="status"&&ct(ke.line||ke.message||""),ke.type==="paused"&&(Dt=Array.isArray(ke.nodeIds)?ke.nodeIds:[]),ke.type==="natural"&&(ke.kind==="thinking"?xr(ke.text||""):Ur(ke.kind,ke.text||"")),ke.type==="raw"){const ft=Qj(ke);ft&&xr(ft),gn(ke)}ke.type==="graph"&&ke.graph&&Nc(ke.graph,ts(ke)),ke.type==="done"&&(ke.graph&&Nc(ke.graph,ts(ke)),tt=Array.isArray(ke.order)?ke.order:[],Dt=Array.isArray(ke.pauseNodeIds)?ke.pauseNodeIds:Dt)}cs.current&&(_r(new Set),Xi(ke=>{var dt;const ft=((dt=Object.entries(ke).find(([,nt])=>(nt==null?void 0:nt.status)==="running"))==null?void 0:dt[0])||S;return ft?{...ke,[ft]:{status:"stopped"}}:ke})),Re(cs.current?`Workspace run stopped: ${S}`:Dt.length?`Workspace run paused at ${Dt.join(", ")}`:`Workspace run done: ${tt.length?tt.join(" -> "):S}`),Ze(cs.current?"stopped":Dt.length?"paused":"done"),cs.current||await qn()}catch(be){if(cs.current||(be==null?void 0:be.name)==="AbortError"){_r(new Set),Xi(Fe=>{var yt;const Xe=((yt=Object.entries(Fe).find(([,tt])=>(tt==null?void 0:tt.status)==="running"))==null?void 0:yt[0])||S;return Xe?{...Fe,[Xe]:{status:"stopped"}}:Fe}),Re(`Workspace run stopped: ${S}`),tr(Fe=>Fe.map(Xe=>Xe.id===te?{...Xe,status:"stopped",endedAt:Date.now()}:Xe));return}_r(new Set),Xi(Fe=>{var yt;const Xe=(yt=Object.entries(Fe).find(([,tt])=>(tt==null?void 0:tt.status)==="running"))==null?void 0:yt[0];return Xe?{...Fe,[Xe]:{status:"failed"}}:Fe}),Re(String(be.message||be)),tr(Fe=>Fe.map(Xe=>Xe.id===te?{...Xe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Xe.messages)?Xe.messages:[],{role:"assistant",error:!0,text:String(be.message||be),at:Date.now()}].slice(-160)}:Xe))}finally{Gi.current===me&&(Gi.current=null),da(""),_r(new Set)}},[Wt,d,s,qn,l,_,Is,gi,jn,Cr,f,c,Oe]),xl=h.useCallback(async()=>{try{const I=await(await fetch("/api/skills")).json().catch(()=>({})),K=Array.isArray(I.skills)?I.skills.map(X=>({key:String(X.key),name:String(X.name||X.id||X.key),description:X.description?String(X.description):"",sourceLabel:X.sourceLabel?String(X.sourceLabel):""})):[];Je(K),_s(!0)}catch{_s(!0)}},[]),ya=h.useCallback(async()=>{try{const I=await(await fetch("/api/mcps")).json().catch(()=>({})),K=Array.isArray(I.servers)?I.servers.map(X=>({name:String((X==null?void 0:X.name)||""),type:String((X==null?void 0:X.type)||""),url:String((X==null?void 0:X.url)||""),command:String((X==null?void 0:X.command)||""),args:Array.isArray(X==null?void 0:X.args)?X.args.map(String):[],description:String((X==null?void 0:X.description)||"")})).filter(X=>X.name):[];an(K)}catch{an([])}},[]);h.useEffect(()=>{ma().catch(S=>Re(String(S.message||S))),Ro(),fetch("/api/model-lists").then(S=>S.json()).then(S=>lt({cursor:Array.isArray(S.cursor)?S.cursor.map(String):[],opencode:Array.isArray(S.opencode)?S.opencode.map(String):[],claudeCode:Array.isArray(S.claudeCode)?S.claudeCode.map(String):[]})).catch(()=>{}),xl(),ya(),fetch("/api/skill-collections").then(S=>S.json()).then(S=>{Eo(qa(S)),_o(!0)}).catch(()=>{}),fetch("/api/auth/me").then(S=>S.json()).then(S=>ua(S.user||null)).catch(()=>ua(null))},[ma,Ro,ya,xl,Qs]),h.useEffect(()=>{if(Gu(""),!(!lr||!Ui)){if(!Qs){hi([]);return}hi(M_(Qs,"workspace",Rn,Ps)),Gu(Qs)}},[Ps,Ui,Rn,lr,Qs]),h.useEffect(()=>{if(!(ml!==Qs||!Qs))try{localStorage.setItem(Qs,JSON.stringify(Cr))}catch{}},[Cr,Qs,ml]),h.useEffect(()=>{T.current=W},[W]),h.useEffect(()=>{p.current=l},[l]),h.useEffect(()=>{const S=C.current,I=new Map,K=[];for(const te of l){const oe=DT(te);I.set(te.id,oe),S.get(te.id)!==oe&&K.push(te.id)}if(C.current=I,K.length===0)return;const X=()=>K.forEach(te=>r(te)),Q=window.requestAnimationFrame(X),ie=window.setTimeout(X,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(ie)}},[l,r]),h.useEffect(()=>{m.current=d},[d]),h.useEffect(()=>{v.current=g},[g]),h.useEffect(()=>{w.current=y},[y]),h.useEffect(()=>{fi.current=Ke},[Ke]),h.useEffect(()=>{z.current=L},[L]),h.useEffect(()=>{if(!L)return;const S=K=>{K.key==="Escape"&&O(null)},I=K=>{var X,Q;(Q=(X=K.target)==null?void 0:X.closest)!=null&&Q.call(X,".af-connect-node-menu")||O(null)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",I),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",I)}},[L]),h.useEffect(()=>{if(E.current&&Oe)return D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{jn().catch(S=>Re(String(S.message||S)))},650),()=>{D.current&&window.clearTimeout(D.current)}},[l,d,g,jn,Oe]);const gc=h.useCallback((S,I)=>{if(!Oe){Re("Readonly workspace");return}const K=Rq(I),X=me=>Array.isArray(me)?me.map(be=>(be==null?void 0:be.name)!=="skillKeys"&&(be==null?void 0:be.name)!=="skillsContext"&&(be==null?void 0:be.type)!=="text"?be:{...be,default:K,value:K}):[],Q=l.map(me=>{var be;return me.id!==S?me:{...me,data:{...me.data,body:K,inputs:X((be=me.data)==null?void 0:be.inputs)}}}),ie=T.current||{},te=ie[S]&&typeof ie[S]=="object"?ie[S]:{},oe={...ie,[S]:{...te,body:K,input:X(te.input)}};T.current=oe,c(Q),M(oe),Nn(me=>!me||me.id!==S?me:{...me,body:K,inputs:X(me.inputs)}),jn(Q,d).catch(me=>Re(String(me.message||me)))},[d,l,jn,c,Oe]),xa=h.useCallback((S,I)=>{if(!Oe){Re("Readonly workspace");return}const K=Oq(I),X=me=>Array.isArray(me)?me.map(be=>(be==null?void 0:be.name)!=="serverNames"&&(be==null?void 0:be.name)!=="mcpContext"&&(be==null?void 0:be.type)!=="text"?be:{...be,default:K,value:K}):[],Q=l.map(me=>{var be;return me.id!==S?me:{...me,data:{...me.data,body:K,inputs:X((be=me.data)==null?void 0:be.inputs)}}}),ie=T.current||{},te=ie[S]&&typeof ie[S]=="object"?ie[S]:{},oe={...ie,[S]:{...te,body:K,input:X(te.input)}};T.current=oe,c(Q),M(oe),Nn(me=>!me||me.id!==S?me:{...me,body:K,inputs:X(me.inputs)}),jn(Q,d).catch(me=>Re(String(me.message||me)))},[d,l,jn,c,Oe]),hp=h.useCallback(S=>{const I=String(S||"").trim();I&&(Ln(K=>K===I?"":I),mi(K=>({...K,[I]:K[I]||{sessionId:`nodechat_${Date.now()}_${I.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),mp=h.useCallback((S,I)=>{const K=String(S||"").trim();K&&mi(X=>({...X,[K]:{...X[K]||{sessionId:`nodechat_${Date.now()}_${K.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(I||""),error:""}}))},[]),gt=h.useCallback((S,I,K="replace",X={})=>{var Gn;if(!Oe){Re("Readonly workspace");return}const Q=String(S||"").trim();if(!Q)return;const ie=p.current.find(It=>It.id===Q),te=Hn((Gn=ie==null?void 0:ie.data)==null?void 0:Gn.definitionId),oe=te==="html"?Hu(I):String(I||""),me=ie?Yl(ie.data):"",be=K==="append"&&String(me||"").trim()?`${String(me).replace(/\s+$/g,"")}
174
+
175
+ ${oe.trim()}`:oe,Fe=te==="image"?"src":"content",Xe=It=>{let rr=!1;return(Array.isArray(It)?It:[]).map(Ur=>{const xr=String((Ur==null?void 0:Ur.name)||""),ct=String((Ur==null?void 0:Ur.type)||"");return!rr&&(xr===Fe||xr==="filePath"||ct==="text")?(rr=!0,{...Ur,default:be,value:be}):Ur})},yt=p.current.map(It=>{var rr,Qi;return It.id!==Q?It:{...It,data:{...It.data,body:be,inputs:Xe((rr=It.data)==null?void 0:rr.inputs),outputs:Xe((Qi=It.data)==null?void 0:Qi.outputs)}}}),tt=T.current||{},Dt=tt[Q]&&typeof tt[Q]=="object"?tt[Q]:{},Bn={...tt,[Q]:{...Dt,body:be,input:Xe(Dt.input),output:Xe(Dt.output)}};T.current=Bn,c(yt),M(Bn),Nn(It=>(It==null?void 0:It.id)===Q?{...It,body:be}:It),(X==null?void 0:X.logChat)!==!1&&mi(It=>{var rr;return{...It,[Q]:{...It[Q]||{},candidateContent:"",messages:[...(rr=It[Q])!=null&&rr.messages&&Array.isArray(It[Q].messages)?It[Q].messages:[],{role:"assistant",text:K==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),jn(yt,m.current).catch(It=>Re(String(It.message||It))),Re(String((X==null?void 0:X.statusMessage)||"")||(K==="append"?"已追加节点内容":"已替换节点内容"))},[jn,c,Oe]),wa=h.useCallback(async S=>{if(!Oe)return Re("Readonly workspace"),"";if(!Ym(S))return Re("请选择图片文件"),"";try{const I=new FormData;I.set("file",S),I.set("dir","img"),s.flowId&&I.set("flowId",s.flowId),s.flowSource&&I.set("flowSource",s.flowSource),s.archived&&I.set("archived","1");const K=await fetch("/api/workspace/upload",{method:"POST",body:I}),X=await K.json().catch(()=>({}));if(!K.ok)throw new Error(X.error||"上传图片失败");const Q=String(X.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await qn(),Ht(ie=>{const te=new Set(ie);for(const oe of Sh(Q))te.delete(oe);return te}),Re(`已上传图片 ${Q}`),Q}catch(I){return Re(String(I.message||I)),""}},[s,qn,Oe]),gp=h.useCallback(async(S,I)=>{const K=String(S||"").trim();if(!K)return;const X=await wa(I);X&&gt(K,X,"replace",{logChat:!1,statusMessage:`已上传图片 ${X}`})},[gt,wa]),wl=h.useCallback((S,I="replace")=>{var Q;const K=String(S||"").trim(),X=String(((Q=qi[K])==null?void 0:Q.candidateContent)||"").trim();!K||!X||gt(K,X,I)},[qi,gt]),wt=h.useCallback(async(S,I=void 0)=>{var be,Fe,Xe;if(!Oe){Re("Readonly workspace");return}const K=String(S||"").trim();if(!K)return;const X=qi[K]||{},Q=String(I!==void 0?I:X.draft||"").trim();if(!Q||X.running)return;const ie=p.current.find(yt=>yt.id===K);if(!ie)return;const te={role:"user",text:Q,at:Date.now()},oe=Array.isArray(X.messages)?X.messages:[],me=X.sessionId||`nodechat_${Date.now()}_${K.replace(/[^a-z0-9_-]+/gi,"_")}`;mi(yt=>({...yt,[K]:{...X,sessionId:me,messages:[...oe,te],draft:"",running:!0,error:""}}));try{const yt=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,sessionId:me,node:{id:K,label:((be=ie.data)==null?void 0:be.label)||K,definitionId:((Fe=ie.data)==null?void 0:Fe.definitionId)||""},nodeKind:Hn((Xe=ie.data)==null?void 0:Xe.definitionId)||"markdown",currentContent:Yl(ie.data),messages:oe,message:Q,model:Wt})}),tt=await yt.json().catch(()=>({}));if(!yt.ok)throw new Error(tt.error||"节点微调失败");const Dt=String(tt.candidateContent||tt.reply||"").trim();mi(Bn=>{var Gn;return{...Bn,[K]:{...Bn[K]||{},sessionId:String(tt.sessionId||me),running:!1,candidateContent:Dt,messages:[...(Gn=Bn[K])!=null&&Gn.messages&&Array.isArray(Bn[K].messages)?Bn[K].messages:[...oe,te],{role:"assistant",text:Dt||"已生成候选内容。",at:Date.now()}]}}})}catch(yt){const tt=String(yt.message||yt);mi(Dt=>({...Dt,[K]:{...Dt[K]||{},running:!1,error:tt}})),Re(tt)}},[Wt,s,qi,Oe]),yp=h.useCallback(async(S,I)=>{if(!Oe){Re("Readonly workspace");return}const K=Yl(I);if(!String(K||"").trim()){Re("展示节点没有可保存内容");return}const X=Nq(S,I),Q=window.prompt("保存到 workspace 相对路径",X);if(Q)try{const ie=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Q,content:K})}),te=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(te.error||"保存文件失败");const oe=te.path||Q,me=Aa(s);me.set("path",oe);const be=await fetch(`/api/workspace/file?${me.toString()}`);if(!be.ok){const Fe=await be.json().catch(()=>({}));throw new Error(Fe.error||`保存后读取失败:${oe}`)}await qn(),Co(Fe=>Aq(Fe,oe,String(K||"").length)),Ht(Fe=>{const Xe=new Set(Fe);for(const yt of Sh(oe))Xe.delete(yt);return Xe}),Re(`已保存 ${oe}`)}catch(ie){Re(String(ie.message||ie))}},[s,qn,Oe]),Ji=h.useCallback((S,I)=>{const K=String(S||"");K&&Nn(X=>{if(!X||X.id!==K)return X;const Q=typeof I=="function"?I(X):I;return!Q||typeof Q!="object"?X:{...X,...Q}})},[]),ds=h.useMemo(()=>l.map(S=>{var I,K;return{...S,data:{...S.data,selected:S.selected===!0,modelLists:jr,showBodyPreview:!0,isExecuting:pp.has(S.id),nodeStatus:((I=pl[S.id])==null?void 0:I.status)??null,nodeElapsed:((K=pl[S.id])==null?void 0:K.elapsed)??null,flowParams:s,readOnly:!Oe,onRunWorkspaceNode:mc,onStopWorkspaceNode:ga,runningRunNodeId:gi,skills:Rn,skillCollections:Ps,onChangeLoadSkillKeys:gc,onRefreshSkills:xl,mcpServers:Ys,onChangeLoadMcpNames:xa,onRefreshMcps:ya,onSaveDisplayNodeToFile:yp,onUploadWorkspaceImage:wa,onUploadImageToDisplayNode:gp,nodeChatActive:pc===S.id,nodeChat:qi[S.id]||null,onSetDisplayNodeContent:gt,onToggleNodeChat:hp,onCloseNodeChat:()=>Ln(""),onUpdateNodeChatDraft:mp,onSendNodeChat:wt,onApplyNodeChatCandidate:wl,onSyncNodePropDraft:Ji}}}),[pc,wl,xa,gc,s,Ys,jr,qi,l,ya,xl,mc,gi,yp,wt,gt,Ps,Rn,ga,Ji,hp,mp,gp,wa,pp,pl,Oe]),yc=h.useMemo(()=>new Map(ds.map(S=>[S.id,S])),[ds]),xc=h.useMemo(()=>{const S=new Set(j);return g.nodeIds.map((I,K)=>{var oe;const X=yc.get(I);if(!X||!Hn((oe=X.data)==null?void 0:oe.definitionId))return null;const Q=zd(X)||{width:520,height:320},ie=pu(g.nodeSizes[I]||Q,{display:!0})||Q,te=g.nodePositions[I]||{x:180+K*36,y:120+K*28};return{...X,id:r1(I),position:te,selected:S.has(I),width:ie.width,height:ie.height,data:{...X.data,sourceNodeId:I,displayPageMode:!0,readOnly:!0,selected:S.has(I),displaySize:ie,nodeSize:ie}}}).filter(Boolean)},[g,yc,j]),Wr=h.useMemo(()=>ds.filter(S=>{var I;return Hn((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}),[ds]),pt=i==="display";h.useEffect(()=>{if(!pt||!g.viewport)return;const S=g.viewport,I=()=>{try{n.setViewport(S,{duration:0})}catch{}},K=window.requestAnimationFrame(()=>window.requestAnimationFrame(I));return()=>window.cancelAnimationFrame(K)},[g.viewport,pt,n]),h.useEffect(()=>{if(pt||!y)return;const S=y,I=()=>{try{n.setViewport(S,{duration:0})}catch{}},K=window.requestAnimationFrame(()=>window.requestAnimationFrame(I));return()=>window.cancelAnimationFrame(K)},[pt,n,y]),h.useEffect(()=>{const S=$.current,I=new Map,K=[];for(const te of[...ds,...xc]){const oe=sq(te);I.set(te.id,oe),S.get(te.id)!==oe&&K.push(te.id)}if($.current=I,K.length===0)return;const X=()=>K.forEach(te=>r(te)),Q=window.requestAnimationFrame(X),ie=window.setTimeout(X,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(ie)}},[xc,ds,r]);const $t=h.useMemo(()=>l.find(S=>S.id===Ye)||null,[l,Ye]),Lo=h.useRef({id:"",draft:null}),xp=h.useMemo(()=>{const S=a1($t);return S?JSON.stringify(S):""},[$t]);h.useEffect(()=>{if(!$t){Lo.current={id:"",draft:null},Nn(null),kr("");return}const S=a1($t),I=Lo.current;Lo.current={id:$t.id,draft:S},Nn(K=>!K||K.id!==$t.id||I.id!==$t.id||!I.draft?S:Dq(K,I.draft,S)),kr("")},[$t==null?void 0:$t.id,xp]);const Ju=h.useCallback((S=!1)=>{if(!Ke||!$t)return!1;if(!Oe)return kr("Readonly workspace"),Re("Readonly workspace"),!1;kr("");const I=c1({nodes:l,edges:d,instances:T.current,selectedNode:$t,draft:Ke,allowRename:S});return I!=null&&I.error?(kr(I.error),!1):(!(I!=null&&I.ok)||!I.changed||(T.current=I.instances,M(I.instances),c(I.nodes),f(I.edges),I.nextId!==$t.id&&jt(I.nextId),Is(I.nextId)),!0)},[d,Ke,l,$t,f,c,Is,Oe]);h.useEffect(()=>{if(!Oe||!Ke||!$t)return;const S=window.setTimeout(()=>{Ju(!1)},350);return()=>window.clearTimeout(S)},[Ke==null?void 0:Ke.label,Ke==null?void 0:Ke.role,Ke==null?void 0:Ke.model,Ke==null?void 0:Ke.body,JSON.stringify((Ke==null?void 0:Ke.images)||[]),Ke==null?void 0:Ke.script,JSON.stringify((Ke==null?void 0:Ke.inputs)||[]),JSON.stringify((Ke==null?void 0:Ke.outputs)||[]),Ju,$t==null?void 0:$t.id,Oe]);const wc=h.useMemo(()=>{const S=new Map(ds.map(I=>[I.id,I]));return d.map(I=>{var be,Fe,Xe,yt;const K=S.get(I.source),X=S.get(I.target),Q=/^output-(\d+)$/.exec(I.sourceHandle||""),ie=/^input-(\d+)$/.exec(I.targetHandle||""),te=K&&Q?(Fe=(be=K.data)==null?void 0:be.outputs)==null?void 0:Fe[parseInt(Q[1],10)]:null,oe=X&&ie?(yt=(Xe=X.data)==null?void 0:Xe.inputs)==null?void 0:yt[parseInt(ie[1],10)]:null,me=te!=null&&te.type?Qn(te.type):oe!=null&&oe.type?Qn(oe.type):"";return me?{...I,style:{...I.style||{},stroke:me,strokeWidth:2},markerEnd:{type:Ns.ArrowClosed,color:me}}:I})},[d,ds]),Yg=pt?xc:ds,wp=pt?[]:wc,Gg=h.useMemo(()=>pt?xc.map(S=>({...S,id:wx(S.id)})):ds,[xc,ds,pt]),Xg=h.useCallback(S=>{const I=String(S||"").trim();if(!I)return;const K=pt?r1(I):I;pt?A([I]):(c(Q=>Q.map(ie=>({...ie,selected:ie.id===K}))),f(Q=>Q.map(ie=>({...ie,selected:!1}))),jt(K));const X=()=>{var be,Fe,Xe;const Q=n.getNode(K);if(!Q)return;const ie=(be=n.getInternalNode)==null?void 0:be.call(n,K),te=((Fe=ie==null?void 0:ie.measured)==null?void 0:Fe.width)??(ie==null?void 0:ie.width)??Q.width??260,oe=((Xe=ie==null?void 0:ie.measured)==null?void 0:Xe.height)??(ie==null?void 0:ie.height)??Q.height??120,{zoom:me}=n.getViewport();n.setCenter(Q.position.x+te/2,Q.position.y+oe/2,{zoom:oq(me),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(X))},[pt,n,f,c]),bp=h.useCallback(()=>{const S=n.getViewport(),I={x:Number(S.x)||0,y:Number(S.y)||0,zoom:Math.min(Math.max(Number(S.zoom)||1,.1),4)};if(pt){const K={...v.current,viewport:I};v.current=K,b(K),Re("已固定 Display 进入视角")}else w.current=I,k(I),Re("已固定 Workspace 进入视角");jn(p.current,m.current).catch(K=>Re(String(K.message||K)))},[pt,n,jn]),ba=h.useMemo(()=>{const S=P.trim().toLowerCase(),I={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const K of _)S&&![K.id,K.label,K.displayName,K.description].some(X=>String(X||"").toLowerCase().includes(S))||I[$d(K)].push(K);for(const K of Dc)I[K].sort((X,Q)=>X.id.localeCompare(Q.id));return I},[_,P]),Oo=h.useMemo(()=>{const S=Te.trim().toLowerCase();return _.filter(I=>!S||[I.id,I.label,I.displayName,I.description].some(K=>String(K||"").toLowerCase().includes(S))).sort((I,K)=>{const X=Dc.indexOf($d(I)),Q=Dc.indexOf($d(K));return X!==Q?X-Q:Dd(I).localeCompare(Dd(K))}).slice(0,30)},[_,Te]),Mo=h.useMemo(()=>{const S=Te.trim().toLowerCase();return se.filter(I=>!S||[I.id,I.version,I.displayName,I.name,I.description,...Array.isArray(I.tags)?I.tags:[]].some(K=>String(K||"").toLowerCase().includes(S))).sort((I,K)=>String(I.displayName||I.name||I.id).localeCompare(String(K.displayName||K.name||K.id))).slice(0,30)},[se,Te]);h.useEffect(()=>{je(0)},[Te,kn,Sn]),h.useEffect(()=>{if(!kn)return;const S=window.setTimeout(()=>{var I;return(I=Mt.current)==null?void 0:I.focus()},0);return()=>window.clearTimeout(S)},[kn]);const vp=h.useMemo(()=>{const S=pi.trim().toLowerCase();return S?GT(Sr).filter(I=>I.path.toLowerCase().includes(S)):Sr},[pi,Sr]),Jg=[...(jr.cursor||[]).map(S=>({label:`Cursor · ${S.split(" - ")[0]}`,value:`cursor:${S.split(" - ")[0]}`})),...(jr.opencode||[]).map(S=>({label:`OpenCode · ${S.split(" - ")[0]}`,value:`opencode:${S.split(" - ")[0]}`})),...(jr.claudeCode||[]).map(S=>({label:`Claude · ${S.split(" - ")[0]}`,value:`claude-code:${S.split(" - ")[0]}`}))],Qu=h.useMemo(()=>new Set(Cr),[Cr]),yi=h.useMemo(()=>{const S=new Map(Rn.map(ie=>[ie.key,ie])),I=new Set,K=new Set,X=Ps.map(ie=>{const te=Za(ie,Rn).map(oe=>S.get(oe)).filter(Boolean);for(const oe of te)I.add(oe.key),K.add(String(oe.name||oe.id||oe.key||"").trim());return{...ie,skills:te}}).filter(ie=>ie.skills.length>0),Q=Rn.filter(ie=>{const te=String(ie.name||ie.id||ie.key||"").trim();return!I.has(ie.key)&&!K.has(te)});return{groups:X,ungrouped:Q}},[Ps,Rn]);h.useEffect(()=>{he(S=>{let I=!1;const K=new Set(S);for(const X of yi.groups)K.has(X.id)||(K.add(X.id),I=!0);return I?K:S})},[yi.groups]);const Yn=h.useMemo(()=>{const S=l.filter(I=>I.selected);return S.length>0?S:Ye?l.filter(I=>I.id===Ye):[]},[l,Ye]),bl=h.useMemo(()=>Yn.map(S=>S.id),[Yn]),$o=h.useMemo(()=>l.filter(S=>{var I;return Hn((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}),[l]),xi=h.useMemo(()=>Yn.filter(S=>{var I;return Hn((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}).map(S=>S.id),[Yn]),bc=h.useMemo(()=>{const S=String((Hr==null?void 0:Hr.username)||(Hr==null?void 0:Hr.userId)||"").trim();return S?S.slice(0,1).toUpperCase():"?"},[Hr]),Zr=h.useMemo(()=>new Set(bl),[bl]),es=h.useMemo(()=>d.filter(S=>Zr.has(S.source)&&Zr.has(S.target)),[d,Zr]),gr=h.useCallback(S=>{const I=S==="display"?"display":"workspace";a(I),jt(""),A([]),O(null),tn(!1),mn(!1);const K=Aa(s);I==="display"&&K.set("view","display");const X=`/workspace${K.toString()?`?${K.toString()}`:""}`;window.history.pushState({},"",X)},[s]),wi=h.useCallback(S=>{var X;const I=String(S||"").trim();if(!I)return;const K=p.current.find(Q=>Q.id===I);if(!K||!Hn((X=K.data)==null?void 0:X.definitionId)){Re("展示节点不可用");return}b(Q=>{if(Q.nodeIds.includes(I))return Q;const ie=Q.nodeIds.length,te=zd(K);return{nodeIds:[...Q.nodeIds,I],nodePositions:{...Q.nodePositions,[I]:{x:180+ie*36,y:120+ie*28}},nodeSizes:{...Q.nodeSizes,...te?{[I]:te}:{}}}}),A([I])},[]),bi=h.useCallback(S=>{const I=String(S||"").trim();I&&(b(K=>{const X=K.nodeIds.filter(te=>te!==I),Q={...K.nodePositions},ie={...K.nodeSizes};return delete Q[I],delete ie[I],{nodeIds:X,nodePositions:Q,nodeSizes:ie}}),A(K=>K.filter(X=>X!==I)))},[]),kp=h.useCallback(S=>{const I=String(S||"").trim();I&&(v.current.nodeIds.includes(I)?bi(I):wi(I))},[wi,bi]),Zu=h.useMemo(()=>{const S=or.trim().toLowerCase();return S?Wr.filter(I=>{var K,X;return[I.id,(K=I.data)==null?void 0:K.label,(X=I.data)==null?void 0:X.definitionId].filter(Boolean).some(Q=>String(Q).toLowerCase().includes(S))}):Wr},[Wr,or]),vl=h.useMemo(()=>{const S=P.trim().toLowerCase();return S?se.filter(I=>[I.id,I.version,I.displayName,I.name,I.description,...Array.isArray(I.tags)?I.tags:[]].filter(Boolean).some(K=>String(K).toLowerCase().includes(S))):se},[se,P]),vc=h.useCallback((S,I)=>{const K=String(S||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let X=`${K}_${Date.now().toString(36)}`,Q=2;for(;I.has(X);)X=`${K}_${Date.now().toString(36)}_${Q}`,Q+=1;return I.add(X),X},[]),ln=h.useCallback((S,I)=>{var Ur,xr;if(!Oe){Re("Readonly workspace");return}const K=S!=null&&S.snippet&&typeof S.snippet=="object"?S.snippet:{},X=K.instances&&typeof K.instances=="object"?K.instances:{},Q=Object.keys(X);if(Q.length===0)return;const ie=new Set(p.current.map(ct=>ct.id)),te={};for(const ct of Q)te[ct]=vc(ct,ie);const oe=(Ur=K.ui)!=null&&Ur.nodePositions&&typeof K.ui.nodePositions=="object"?K.ui.nodePositions:{},me=(xr=K.ui)!=null&&xr.nodeSizes&&typeof K.ui.nodeSizes=="object"?K.ui.nodeSizes:{},be=Q.map(ct=>{const gn=oe[ct];return{id:ct,x:typeof(gn==null?void 0:gn.x)=="number"?gn.x:0,y:typeof(gn==null?void 0:gn.y)=="number"?gn.y:0}}),Fe=Math.min(...be.map(ct=>ct.x)),Xe=Math.min(...be.map(ct=>ct.y));let yt=I||{x:360+p.current.length*24,y:180+p.current.length*18};if(!I){const ct=document.querySelector(".af-workspace-canvas .react-flow");if(ct){const gn=ct.getBoundingClientRect();yt=n.screenToFlowPosition({x:gn.left+gn.width*.48,y:gn.top+gn.height*.32})}}const tt={},Dt={},Bn={};for(const ct of be){const gn=te[ct.id];tt[gn]={...X[ct.id]||{}},Dt[gn]={x:yt.x+(ct.x-Fe),y:yt.y+(ct.y-Xe)};const Ze=me[ct.id];typeof(Ze==null?void 0:Ze.width)=="number"&&typeof(Ze==null?void 0:Ze.height)=="number"&&(Bn[gn]={width:Ze.width,height:Ze.height})}const Gn=new Set(Q),It=(Array.isArray(K.edges)?K.edges:[]).filter(ct=>Gn.has(ct==null?void 0:ct.source)&&Gn.has(ct==null?void 0:ct.target)).map(ct=>({source:te[ct.source],target:te[ct.target],sourceHandle:ct.sourceHandle??null,targetHandle:ct.targetHandle??null})),rr=xx({instances:tt,edges:It,ui:{nodePositions:Dt,nodeSizes:Bn}},_),Qi=rr.nodes.map(ct=>({...ct,selected:!0}));T.current={...T.current,...rr.instances},M(T.current),c(ct=>[...ct.map(gn=>({...gn,selected:!1})),...Qi]),f(ct=>[...ct.map(gn=>({...gn,selected:!1})),...rr.edges]),Re(`已添加流程片段:${S.displayName||S.id}`)},[vc,_,n,f,c,Oe]),On=h.useCallback(()=>{var K,X;if(Yn.length<2){ve("请先在 workspace 画布上选择至少两个节点。"),V("flows");return}const S=Yn[0],I=Yn.length===2?`${((K=S.data)==null?void 0:K.label)||S.id} 片段`:`${((X=S.data)==null?void 0:X.label)||S.id} 等 ${Yn.length} 个节点`;Ae({name:I,id:I.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Ct(""),we(!0),V("flows")},[Yn]),kl=h.useCallback(async()=>{var Q,ie;if(Yn.length<2)return;const S=Ee.name.trim();if(!S){Ct("请填写片段名称。");return}const I={},K={};for(const te of Yn){I[te.id]={x:((Q=te.position)==null?void 0:Q.x)||0,y:((ie=te.position)==null?void 0:ie.y)||0};const oe=zd(te);oe&&(K[te.id]=oe)}const X=es.map(te=>({source:te.source,target:te.target,sourceHandle:te.sourceHandle??null,targetHandle:te.targetHandle??null}));ut(!0),Ct("");try{const te=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Ee.id,name:S,displayName:S,version:"1.0.0",description:Ee.description,snippet:{instances:op(Yn,T.current),edges:X,ui:{nodePositions:I,nodeSizes:K}}})}),oe=await te.json().catch(()=>({}));if(!te.ok||oe.ok===!1)throw new Error(oe.error||"发布流程片段失败");we(!1),Re(`流程片段已发布:${oe.id||S}`),As(`流程片段已发布:${oe.id||S}`),await Ro(),V("flows")}catch(te){Ct(String(te.message||te))}finally{ut(!1)}},[Ro,Ee,es,Yn,As]);h.useCallback(()=>{if($o.length===0){Re("当前 workspace 没有 display 节点");return}const S=xi.length>0?xi:$o.map(K=>K.id),I=s.flowId?`${s.flowId} 展示页`:"AgentFlow Display";ot({title:I,layout:"gallery",nodeIds:S}),le(""),ze(null),An(!0)},[s.flowId,xi,$o]);const Sl=h.useCallback(S=>{ot(I=>{const K=Array.isArray(I.nodeIds)?I.nodeIds:[];return K.includes(S)?{...I,nodeIds:K.filter(X=>X!==S)}:{...I,nodeIds:[...K,S]}})},[]),Nl=h.useCallback(async()=>{var K;const S=Qe.title.trim(),I=Array.isArray(Qe.nodeIds)?Qe.nodeIds:[];if(I.length===0){le("请选择至少一个 display 节点。");return}In(!0),le(""),ze(null);try{await jn(l,d);const X=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,title:S,layout:Qe.layout,nodeIds:I})}),Q=await X.json().catch(()=>({}));if(!X.ok||Q.ok===!1)throw new Error(Q.error||"发布展示页失败");const ie=new URL(Q.url||`/display/${((K=Q.share)==null?void 0:K.id)||""}`,window.location.origin).href;ze({...Q,absoluteUrl:ie}),Re("展示页已生成")}catch(X){le(String(X.message||X))}finally{In(!1)}},[Qe,d,s,l,jn]),ed=h.useCallback(async()=>{var I;const S=Array.isArray(g.nodeIds)?g.nodeIds:[];if(S.length===0){le("请先添加至少一个展示节点。"),Re("请先添加至少一个展示节点"),mn(!0);return}In(!0),le("");try{await jn(l,d);const K=s.flowId?`${s.flowId} 展示页`:"AgentFlow Display",X=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,title:K,layout:"canvas",nodeIds:S})}),Q=await X.json().catch(()=>({}));if(!X.ok||Q.ok===!1)throw new Error(Q.error||"生成展示链接失败");const ie=new URL(Q.url||`/display/${((I=Q.share)==null?void 0:I.id)||""}`,window.location.origin).href;ze({...Q,absoluteUrl:ie}),rn(!0),Re("展示链接已生成")}catch(K){const X=String(K.message||K);le(X),Re(X)}finally{In(!1)}},[g.nodeIds,d,s,l,jn]),Nt=h.useCallback(S=>{c(I=>I.map(K=>K.id===S?{...K,selected:!1}:K)),jt(I=>I===S?"":I)},[c]),Do=h.useCallback(()=>{const S=Ge.current;if(!S)return;const I=S.getBoundingClientRect(),K=Math.min(420,Math.max(320,I.width+160)),X=12,Q=Math.max(180,I.top-X*2),ie=Math.min(560,Q);Er({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-K-12,I.left)),top:Math.max(X,I.top-ie-X),width:K,maxHeight:ie,zIndex:1e4})},[]);h.useEffect(()=>{if(!Ie)return;Do();const S=K=>{var Q,ie;const X=K.target;(Q=Ge.current)!=null&&Q.contains(X)||(ie=Vt.current)!=null&&ie.contains(X)||Pe(!1)},I=K=>{K.key==="Escape"&&Pe(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",I),window.addEventListener("resize",Do),window.addEventListener("scroll",Do,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",I),window.removeEventListener("resize",Do),window.removeEventListener("scroll",Do,!0)}},[Ie,Do]);const td=h.useCallback(S=>{var X,Q,ie;if(i==="display"){const te=[];let oe=!1;b(me=>{var Xe,yt;const be={...me.nodePositions},Fe={...me.nodeSizes};for(const tt of S||[]){const Dt=wx(tt==null?void 0:tt.id);if(!(!Dt||!me.nodeIds.includes(Dt))){if(tt.type==="select"){tt.selected&&te.push(Dt);continue}if(tt.type==="position"&&tt.position){be[Dt]={x:tt.position.x,y:tt.position.y},oe=!0;continue}if(tt.type==="dimensions"&&((Xe=tt.dimensions)!=null&&Xe.width)&&((yt=tt.dimensions)!=null&&yt.height)){const Bn=pu({width:Math.round(Number(tt.dimensions.width)),height:Math.round(Number(tt.dimensions.height))},{display:!0});Bn&&(Fe[Dt]=Bn,oe=!0)}}}return oe?{...me,nodePositions:be,nodeSizes:Fe}:me}),(S||[]).some(me=>(me==null?void 0:me.type)==="select")&&A(te);return}if(!Oe){const te=(S||[]).filter(oe=>(oe==null?void 0:oe.type)==="select");te.length>0&&c(oe=>Rm(te,oe));return}const I=new Map;for(const te of S||[])if((te==null?void 0:te.type)==="dimensions"&&((X=te.dimensions)!=null&&X.width)&&((Q=te.dimensions)!=null&&Q.height)){const oe=l.find(Fe=>Fe.id===te.id),me=!!Hn((ie=oe==null?void 0:oe.data)==null?void 0:ie.definitionId),be=pu({width:Math.round(Number(te.dimensions.width)),height:Math.round(Number(te.dimensions.height))},{display:me});be&&I.set(te.id,be)}const K=Array.from(I.keys());if(c(te=>Rm(S,te).map(oe=>{var be;const me=I.get(oe.id);return me?Hn((be=oe.data)==null?void 0:be.definitionId)?{...oe,width:me.width,height:me.height,data:{...oe.data,nodeSize:me,displaySize:me}}:{...oe,width:me.width,height:me.height,data:{...oe.data,nodeSize:me}}:oe})),K.length>0){const te=()=>K.forEach(oe=>r(oe));window.requestAnimationFrame(te),window.setTimeout(te,80)}},[l,c,r,i,Oe]),kc=h.useCallback(S=>{if(i!=="display"){if(!Oe){const I=(S||[]).filter(K=>(K==null?void 0:K.type)==="select");I.length>0&&f(K=>$v(I,K));return}u(S)}},[u,f,i,Oe]),vi=h.useCallback(()=>{const S=document.querySelector(".af-workspace-canvas .react-flow");if(S){const I=S.getBoundingClientRect();return n.screenToFlowPosition({x:I.left+I.width*.48,y:I.top+I.height*.32})}return{x:360+l.length*36,y:180+l.length*28}},[l.length,n]),jl=h.useCallback(()=>{var S,I,K;if($t){const X=Number(((S=$t.measured)==null?void 0:S.width)||$t.width||260);return{x:Number(((I=$t.position)==null?void 0:I.x)||0)+X+140,y:Number(((K=$t.position)==null?void 0:K.y)||0)}}return vi()},[vi,$t]),Rs=h.useCallback((S,I={})=>{if(!Oe)return Re("Readonly workspace"),null;if(!S)return null;const K=f0(S)||S.id,X=$T(S),Q=I.id||nq(K,l),ie=vh(S.inputs),te=vh(S.outputs),oe={definitionId:K,...X?{marketplaceRef:X}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},label:I.label||Gm(S),role:"normal",body:I.body||"",input:I.inputs||ie,output:I.outputs||te},me={id:Q,type:ap,position:I.position||vi(),data:{label:oe.label,definitionId:K,...X?{marketplaceRef:X}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},schemaType:MT(K,S),role:"normal",body:oe.body,inputs:oe.input,outputs:oe.output}},be={...zf(me,{...T.current,[Q]:oe},_),selected:!0};return c(Fe=>[...Fe.map(Xe=>({...Xe,selected:!1})),be]),I.openProperties&&jt(Q),Q},[vi,l,_,c,Oe]),nd=h.useCallback(S=>n1(S,p.current),[]),Qg=h.useCallback(S=>{if(!Oe){Re("Readonly workspace");return}if(!n1(S,p.current)){Re("端口类型不匹配,已取消连线");return}O(null),c(I=>Um(I,S)),f(I=>{const K=I.filter(X=>!(X.target===S.target&&X.targetHandle===S.targetHandle));return Tf({...S,markerEnd:{type:Ns.ArrowClosed}},K)})},[f,c,Oe]),Sp=h.useCallback((S,I)=>{Oe&&(F.current=eq(I,p.current),O(null))},[Oe]),Np=h.useCallback((S,I)=>{var yt,tt,Dt,Bn;if(!Oe)return;const K=F.current;if(F.current=null,!K||I!=null&&I.toNode)return;const X=tq(_,K);if(X.length===0){Re(`没有匹配 ${K.slotType} 端口的节点`);return}const Q=((tt=(yt=S==null?void 0:S.changedTouches)==null?void 0:yt[0])==null?void 0:tt.clientX)??(S==null?void 0:S.clientX),ie=((Bn=(Dt=S==null?void 0:S.changedTouches)==null?void 0:Dt[0])==null?void 0:Bn.clientY)??(S==null?void 0:S.clientY);if(!Number.isFinite(Q)||!Number.isFinite(ie))return;const te=document.querySelector(".af-workspace-canvas .react-flow");if(!te)return;const oe=te.getBoundingClientRect(),me=320,be=Math.min(440,104+X.length*58),Fe=Math.max(12,Math.min(Q-oe.left,oe.width-me-12)),Xe=Math.max(12,Math.min(ie-oe.top,oe.height-be-12));O({left:Fe,top:Xe,flowPosition:n.screenToFlowPosition({x:Q,y:ie}),draft:K,candidates:X,query:""})},[_,n,Oe]),Vr=h.useCallback(S=>{if(!Oe){Re("Readonly workspace"),O(null);return}const I=z.current;if(!I||!(S!=null&&S.def))return;const K=Rs(S.def,{position:I.flowPosition});if(!K)return;const X=I.draft.handleType==="source"?{source:I.draft.nodeId,sourceHandle:I.draft.handleId,target:K,targetHandle:`input-${S.slotIndex}`}:{source:K,sourceHandle:`output-${S.slotIndex}`,target:I.draft.nodeId,targetHandle:I.draft.handleId};c(Q=>Um(Q,X)),f(Q=>{const ie=Q.filter(te=>!(te.target===X.target&&te.targetHandle===X.targetHandle));return Tf({...X,markerEnd:{type:Ns.ArrowClosed}},ie)}),O(null)},[Rs,f,Oe]),rd=h.useCallback(S=>{S&&(Rs(S,{position:jl()}),tn(!1),it(""))},[Rs,jl]),Ls=h.useCallback(S=>{S&&(ln(S,jl()),tn(!1),it(""))},[ln,jl]);h.useEffect(()=>{const S=I=>{if(I.defaultPrevented)return;const K=hT(I.target)||Q7(I.target);if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="s"){I.preventDefault(),jn().catch(te=>Re(String(te.message||te)));return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="k"){I.preventDefault(),I.stopPropagation(),dl(te=>!te);return}if(ur)return;if(ul){(I.key==="Escape"||qm(I))&&(I.preventDefault(),Yi(!1));return}if(K)return;const X=I.key.toLowerCase(),Q=(I.metaKey||I.ctrlKey)&&!I.shiftKey&&X==="z",ie=(I.metaKey||I.ctrlKey)&&(I.shiftKey&&X==="z"||X==="y");if(Q||ie){if(pt){I.preventDefault(),I.stopPropagation(),Re("展示页布局会自动保存");return}if(!Oe){I.preventDefault(),Re("Readonly workspace");return}I.preventDefault(),I.stopPropagation();const te=Q?pa():ha();Re(te?Q?"Undo canvas change":"Redo canvas change":Q?"Nothing to undo":"Nothing to redo");return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="c"){if(pt)return;const te=iT(p.current,m.current,T.current);te&&(I.preventDefault(),I.stopPropagation(),B.current=te,Re(`Copied ${te.nodes.length} node${te.nodes.length>1?"s":""}`));return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="v"){if(pt){I.preventDefault(),I.stopPropagation();return}if(!Oe){I.preventDefault(),Re("Readonly workspace");return}const te=oT(B.current,p.current,m.current,T.current);te&&(I.preventDefault(),I.stopPropagation(),T.current=te.instances,M(te.instances),c(te.nodes),f(te.edges),Re(`Pasted ${te.pastedNodeIds.length} node${te.pastedNodeIds.length>1?"s":""}`));return}if(qm(I)&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),Yi(!0);return}if(I.key==="a"||I.key==="A"){if(I.metaKey||I.ctrlKey){I.preventDefault(),pt?A(v.current.nodeIds):(c(te=>te.map(oe=>({...oe,selected:!0}))),f(te=>te.map(oe=>({...oe,selected:!1}))));return}if(I.altKey)return;if(pt){I.preventDefault(),mn(!0);return}if(!Oe){I.preventDefault(),Re("Readonly workspace");return}I.preventDefault(),tn(!0);return}if((I.key==="v"||I.key==="V")&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),fl("select");return}if((I.key==="h"||I.key==="H")&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),fl("pan");return}(I.key==="f"||I.key==="F")&&!I.metaKey&&!I.ctrlKey&&!I.altKey&&(I.preventDefault(),bp())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[pt,ur,bp,ha,jn,ul,f,c,pa,Oe]);const Zs=h.useCallback(S=>{Ht(I=>{const K=new Set(I);return K.has(S)?K.delete(S):K.add(S),K})},[]),jp=h.useCallback((S,I)=>{S.dataTransfer.effectAllowed="copy",S.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:I.path,name:I.name,type:I.type})),S.dataTransfer.setData("text/plain",I.path)},[]),Cl=h.useCallback((S,I)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("application/agentflow-node",I.id),S.dataTransfer.setData("text/plain",I.id)},[]),El=h.useCallback(async(S,I)=>{const K=String((S==null?void 0:S.name)||(S==null?void 0:S.path)||"").toLowerCase(),X=K.split(".").pop(),Q=X==="html"?"display_html":X==="csv"||X==="tsv"||X==="json"&&/\b(table|data|rows|report)\b/i.test(K)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(X)?"display_image":"display_markdown",ie=_.find(Xe=>Xe.id===Q);if(!ie){Re("展示节点不可用");return}const te=Q==="display_image";let oe=String(S.path||"");if(!te){const Xe=Aa(s);Xe.set("path",S.path);const yt=await fetch(`/api/workspace/file?${Xe.toString()}`),tt=await yt.json();if(!yt.ok)throw new Error(tt.error||"读取文件失败");oe=String(tt.content||"")}const me=Q==="display_image"?"src":"content",be=vh(ie.inputs).map(Xe=>Xe.name===me?{...Xe,default:oe,value:oe}:Xe),Fe=vh(ie.outputs).map(Xe=>Xe.name===me?{...Xe,default:oe,value:oe}:Xe);Rs(ie,{label:S.name||"Display",body:oe,inputs:be,outputs:Fe,position:I}),Re(`已创建展示:${S.path}`)},[Rs,s,_]),_l=h.useCallback(S=>{if(!Oe){Re("Readonly workspace");return}El(S,vi()).catch(I=>Re(String(I.message||I)))},[El,vi,Oe]),Cp=h.useCallback(S=>{if(!Oe){S.preventDefault(),Re("Readonly workspace");return}const I=S.dataTransfer.getData("application/x-agentflow-workspace-file");if(I){S.preventDefault();let te;try{te=JSON.parse(I)}catch{return}if(!(te!=null&&te.path))return;const oe=n.screenToFlowPosition({x:S.clientX,y:S.clientY});El(te,oe).catch(me=>Re(String(me.message||me)));return}const K=S.dataTransfer.getData("application/agentflow-snippet");if(K){const te=se.find(me=>`${me.id}@${me.version}`===K);if(!te)return;S.preventDefault();const oe=n.screenToFlowPosition({x:S.clientX,y:S.clientY});ln(te,oe);return}const X=S.dataTransfer.getData("application/agentflow-node");if(!X)return;const Q=_.find(te=>te.id===X);if(!Q)return;S.preventDefault();const ie=n.screenToFlowPosition({x:S.clientX,y:S.clientY});Rs(Q,{position:ie})},[El,Rs,se,ln,_,n,Oe]),yr=h.useCallback(S=>{if(!Oe)return;const I=Array.from(S.dataTransfer.types||[]);!I.includes("application/x-agentflow-workspace-file")&&!I.includes("application/agentflow-node")&&!I.includes("application/agentflow-snippet")||(S.preventDefault(),S.dataTransfer.dropEffect=I.includes("application/agentflow-node")||I.includes("application/agentflow-snippet")?"move":"copy")},[Oe]),sd=h.useCallback(async(S="")=>{if(!Oe){Re("Readonly workspace");return}const I=window.prompt("新文件名",S?`${S}/notes.md`:"notes.md");if(!I)return;const K=S&&!I.includes("/")?`${S}/${I}`:I;try{const X=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:K,content:""})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"创建文件失败");await qn(),Ht(ie=>{const te=new Set(ie);for(const oe of Sh(Q.path||K))te.delete(oe);return te}),Re(`已创建 ${Q.path}`)}catch(X){Re(String(X.message||X))}},[s,qn,Oe]),ei=h.useCallback(async(S="")=>{if(!Oe){Re("Readonly workspace");return}const I=window.prompt("新文件夹名",S?`${S}/docs`:"docs");if(!I)return;const K=S&&!I.includes("/")?`${S}/${I}`:I;try{const X=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:K})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"创建文件夹失败");await qn(),Ht(ie=>{const te=new Set(ie);for(const oe of Sh(Q.path||K))te.delete(oe);return Q.path&&te.delete(Q.path),te}),Re(`已创建 ${Q.path}`)}catch(X){Re(String(X.message||X))}},[s,qn,Oe]),Sc=h.useCallback(async S=>{if(!Oe){Re("Readonly workspace");return}if(!(!(S!=null&&S.path)||!window.confirm(`删除 ${S.path}?`)))try{const I=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:S.path})}),K=await I.json();if(!I.ok)throw new Error(K.error||"删除失败");Re(`已删除 ${K.path}`),await qn()}catch(I){Re(String(I.message||I))}},[s,qn,Oe]),ki=h.useCallback(async()=>{if(!Oe){Re("Readonly workspace");return}const S=Xs.trim();if(!S||Br)return;const I=kh(l,d,T.current);Po(""),cr(!0),yl("workspace"),cl(K=>[...K,{role:"user",text:S,at:Date.now()}]);try{await jn(l,d);const K=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,prompt:S,outputKind:"markdown",workspaceGraph:I,allowFlowYaml:!1,model:Wt,selectedSkills:Cr,selectedNodeIds:bl})}),X=await K.json();if(!K.ok)throw new Error(X.error||"生成失败");const Q=String(X.content||"").trim();cl(ie=>[...ie,{role:"assistant",text:Q,at:Date.now()}]),await ma(),Re("AI 生成完成")}catch(K){const X=String(K.message||K);cl(Q=>[...Q,{role:"assistant",text:X,error:!0,at:Date.now()}]),Re(X)}finally{cr(!1)}},[Wt,Br,Xs,d,s,ma,l,yl,jn,bl,Cr,Oe]),nr=Yu.find(S=>S.id===dc)||null,id=nr?Array.isArray(nr.messages)?nr.messages:[]:la,Pl=nr?nr.status==="running":Br,At=nr?nr.status==="running"?`${nr.label} running`:nr.status==="paused"?`${nr.label} paused`:nr.status==="failed"?`${nr.label} failed`:`${nr.label} done`:Br?"Workspace agent running":la.length>0?"Workspace conversation":"Ready";return o.jsxs("div",{className:"af-workspace-page",children:[o.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>t("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:s.flowId?`${s.flowId} · ${ar}`:ar||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",Y7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{t(Sm({id:s.flowId,source:s.flowSource||"user",archived:!!s.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:i==="workspace"?"af-view-switch__active":"",onClick:()=>gr("workspace"),children:"Workspace"}),o.jsx("button",{type:"button",className:i==="display"?"af-view-switch__active":"",onClick:()=>gr("display"),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:hl}),pt?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Bt||!(de!=null&&de.absoluteUrl)&&g.nodeIds.length===0,onClick:()=>{de!=null&&de.absoluteUrl?rn(!0):ed()},title:de!=null&&de.absoluteUrl?"查看展示链接":g.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Bt?"hourglass_empty":"ios_share"}),Bt?"生成中":de!=null&&de.absoluteUrl?"展示链接":"生成链接"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Wr.length===0,onClick:()=>mn(!0),title:Wr.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Yi(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Ao?" af-composer-topbar-btn--active":"")+(Br?" af-composer-topbar-btn--running":""),disabled:pt,onClick:()=>Io(S=>!S),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Oe,onClick:()=>jn().catch(S=>Re(String(S.message||S))),children:"Save"})]})]}),Ue?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:Ue}),o.jsx("button",{type:"button",onClick:()=>St(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(!pt&&(Ao||Ke)?" af-workspace-body--drawer":"")+(!pt&&Js?" af-workspace-body--sidebar-collapsed":"")+(pt?" af-workspace-body--display-mode":""),children:[!pt&&Js?o.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:o.jsxs("div",{className:"af-workspace-rail__stack",children:[o.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>tn(!0),"aria-label":"添加节点",title:"添加节点",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),o.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>ca(!1),"aria-label":"展开文件",title:"展开文件",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),o.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),o.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>ca(!1),"aria-label":"展开侧边栏",title:(Hr==null?void 0:Hr.username)||(Hr==null?void 0:Hr.userId)||"展开侧边栏",children:bc})]})}):null,pt?null:o.jsxs("aside",{ref:Nr,className:"af-workspace-sidebar"+(Zn?" af-workspace-sidebar--resizing":""),"aria-hidden":Js,style:{"--af-work-files-pane-height":`${Math.round(mt)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>ca(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Oe,onClick:()=>sd(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Oe,onClick:()=>ei(""),"aria-label":"新增文件夹",title:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void qn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:pi,onChange:S=>Kn(S.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(JT,{items:vp,flowParams:s,onOpen:_l,collapsedDirs:Le,onToggleDir:Zs,onCreateFile:sd,onCreateFolder:ei,onDelete:Sc,onFileDragStart:jp})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:Gs,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Z==="flows"?"搜索流程片段":"搜索节点"}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",className:"af-palette-search-input",value:P,onChange:S=>G(S.target.value),placeholder:Z==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Z==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Z==="nodes",className:"af-palette-tab"+(Z==="nodes"?" af-palette-tab--active":""),onClick:()=>V("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Z==="flows",className:"af-palette-tab"+(Z==="flows"?" af-palette-tab--active":""),onClick:()=>V("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),o.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:Z==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:On,disabled:Yn.length<2,title:Yn.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Yn.length," 节点 / ",es.length," 连线"]})]})}),ae?o.jsx("p",{className:"af-err af-palette-list-err",children:ae}):null,fe?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):vl.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:vl.map(S=>{const I=`${S.id}@${S.version}`,K=S.displayName||S.name||S.id,X=S.description||`${S.nodeCount||0} 个节点,${S.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:Q=>{Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("application/agentflow-snippet",I),Q.dataTransfer.setData("text/plain",I)},onClick:()=>ln(S),title:X,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:K}),o.jsxs("span",{className:"af-palette-card-id",children:[S.id,"@",S.version]})]})]}),X?o.jsx("span",{className:"af-palette-card-desc",children:X}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[S.nodeCount||0," nodes"]}),o.jsxs("span",{children:[S.edgeCount||0," edges"]})]})]},I)})})]}):o.jsx("p",{className:"af-palette-empty",children:P.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Dc.map(S=>{var I;return(I=ba[S])!=null&&I.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${S}`,children:[o.jsx("h3",{className:"af-palette-cat",children:S}),o.jsx("div",{className:"af-palette-cards",children:ba[S].map(K=>{const X=t1(K.inputs,"input"),Q=t1(K.outputs,"output"),ie=yb(K),te=Dd(K);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:oe=>Cl(oe,K),onClick:()=>Rs(K),title:ie||K.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:Zj(S)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:te}),te!==K.id?o.jsx("span",{className:"af-palette-card-id",children:K.id}):null]})]}),ie?o.jsx("span",{className:"af-palette-card-desc",children:ie}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[X.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[X.shown.map((oe,me)=>o.jsxs("span",{className:"af-palette-card-port",title:e1("input",oe,me),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Qn(oe==null?void 0:oe.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:yx(oe,me)})]},`in-${me}`)),X.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",X.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[Q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((oe,me)=>o.jsxs("span",{className:"af-palette-card-port",title:e1("output",oe,me),children:[o.jsx("span",{className:"af-palette-card-port-name",children:yx(oe,me)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Qn(oe==null?void 0:oe.type)}})]},`out-${me}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},K.id)})})]},S):null}),_.length>0&&P.trim()&&Dc.every(S=>{var I;return!((I=ba[S])!=null&&I.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(Fv,{className:"af-flow-canvas af-workspace-flow"+(To==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(pt?" af-workspace-flow--display-mode":""),nodes:Yg,edges:wp,nodeTypes:_q,onNodesChange:td,onEdgesChange:kc,onConnect:pt?void 0:Qg,onConnectStart:pt?void 0:Sp,onConnectEnd:pt?void 0:Np,isValidConnection:pt?void 0:nd,onNodeClick:(S,I)=>{if(pt){A([wx(I.id)]);return}Ye&&jt(I.id)},onNodeDoubleClick:(S,I)=>{S.preventDefault(),!pt&&(Io(!1),c(K=>K.map(X=>({...X,selected:X.id===I.id}))),f(K=>K.map(X=>({...X,selected:!1}))),jt(I.id))},onPaneClick:()=>{pt?A([]):jt("")},onDrop:pt?void 0:Cp,onDragOver:pt?void 0:yr,nodesDraggable:pt?!0:Oe,nodesConnectable:pt?!1:Oe,edgesReconnectable:pt?!1:Oe,deleteKeyCode:pt?null:Oe?["Backspace","Delete"]:null,selectionOnDrag:To==="select",panOnDrag:To==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(Bv,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!pt&&L?(()=>{var X;const S=String(L.query||"").trim().toLowerCase(),I=S?L.candidates.filter(Q=>{var ie,te,oe;return[(ie=Q.def)==null?void 0:ie.id,Q.displayLabel,Q.description,(te=Q.slot)==null?void 0:te.name,(oe=Q.slot)==null?void 0:oe.type].filter(Boolean).some(me=>String(me).toLowerCase().includes(S))}):L.candidates,K=L.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:L.left,top:L.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Qn((X=L.draft.slot)==null?void 0:X.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",L.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>O(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:L.query,onChange:Q=>O(ie=>ie&&{...ie,query:Q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[I.map(Q=>{var oe,me;const ie=Q.displayLabel||((oe=Q.def)==null?void 0:oe.id),te=yx(Q.slot,Q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>Vr(Q),title:Q.description||Q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:ie}),ie!==Q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:K}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Qn((me=Q.slot)==null?void 0:me.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:te})]})]},`${Q.def.id}-${Q.slotIndex}`)}),I.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!pt&&!fc?o.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Gt(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),o.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:Yn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Yn.map(S=>{var Q,ie;const I=String(((Q=S.data)==null?void 0:Q.label)??S.id),K=(ie=S.data)!=null&&ie.definitionId?String(S.data.definitionId):"",X=K&&K!==I?`${I} · ${S.id} · ${K}`:`${I} · ${S.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:X,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:K||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:I}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Nt(S.id),"aria-label":`取消选择 ${S.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},S.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsx("div",{className:"af-composer-input-wrap",children:o.jsx("textarea",{className:"af-composer-textarea",value:Xs,rows:2,onChange:S=>Po(S.target.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),ki())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Oe})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:Ge,type:"button",className:"af-composer-skills-button"+(Cr.length>0?" af-composer-skills-button--active":""),disabled:Br||!Oe,"aria-haspopup":"listbox","aria-expanded":Ie,onClick:()=>Pe(S=>!S),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:Cr.length>0?`Skills ${Cr.length}`:"Skills"})]}),Ie&&!Br?Mr.createPortal(o.jsx("div",{ref:Vt,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:er,children:Rn.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[yi.groups.map(S=>{const I=Za(S,Rn),K=O_(S,Qu,Rn),X=U.has(S.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(X?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:K==="all",disabled:I.length===0,onChange:Q=>{const ie=Q.target.checked;hi(te=>ie?R_(te,I):L_(te,I))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:S.name}),S.builtin?o.jsx("em",{children:"built-in"}):null,K==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":X?`展开 ${S.name}`:`收起 ${S.name}`,onClick:()=>{he(Q=>{const ie=new Set(Q);return ie.has(S.id)?ie.delete(S.id):ie.add(S.id),ie})},children:[o.jsx("span",{children:S.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X?"expand_more":"expand_less"})]})]}),X?null:o.jsx("div",{className:"af-composer-skill-group-items",children:S.skills.map(Q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Qu.has(Q.key),onChange:ie=>{const te=ie.target.checked;hi(oe=>te?oe.includes(Q.key)?oe:[...oe,Q.key]:oe.filter(me=>me!==Q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Q.name}),Q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Q.description}):null]})]},`${S.id}:${Q.key}`))})]},S.id)}),yi.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:yi.ungrouped.length})]}),yi.ungrouped.map(S=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Qu.has(S.key),onChange:I=>{const K=I.target.checked;hi(X=>K?X.includes(S.key)?X:[...X,S.key]:X.filter(Q=>Q!==S.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:S.name}),S.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:S.description}):null]})]},`ungrouped:${S.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:Wt,onChange:S=>Yt(S.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),Jg.map(S=>o.jsx("option",{value:S.value,children:S.label},S.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(Xs.trim()&&!Br?" af-composer-send--active":"")+(Br?" af-composer-send--stop":""),disabled:Br||!Xs.trim()||!Oe,"aria-label":Br?"Running":"Send",onClick:()=>void ki(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Br?"sync":"arrow_upward"})})]})]})]})}):pt?null:o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Gt(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!pt&&Ao?o.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Io(!1),"aria-label":"关闭 AI 对话侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-composer-session-tabs",children:[o.jsx("button",{type:"button",className:"af-composer-session-tab"+(dc==="workspace"?" af-composer-session-tab--active":""),onClick:()=>Ki("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Yu.map(S=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(dc===S.id?" af-composer-session-tab--active":"")+(S.status==="running"?" af-composer-session-tab--running":""),onClick:()=>Ki(S.id),title:S.runNodeId||S.label,children:o.jsx("span",{className:"af-composer-session-label",children:S.label})},S.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Pl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:At}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(Iq,{messages:id,running:Pl,showRunningIndicator:!nr})})]})}):!pt&&Ke&&$t?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(vT,{draft:Ke,setDraft:Nn,definitionId:String(((bt=$t.data)==null?void 0:bt.definitionId)||$t.id),systemPromptReadonly:String(((Ep=$t.data)==null?void 0:Ep.description)||""),modelLists:jr,disabled:!Oe,onIdBlur:()=>Ju(!0),onClose:()=>jt(""),onPublishToMarketplace:Xu,error:jo,ioSlots:{inputs:Array.isArray(Ke==null?void 0:Ke.inputs)?Ke.inputs:[],outputs:Array.isArray(Ke==null?void 0:Ke.outputs)?Ke.outputs:[]}})}):null,o.jsx(mT,{open:ul,onClose:()=>Yi(!1)}),o.jsx(gT,{open:ur,onClose:()=>dl(!1),onJump:Xg,nodes:Gg}),_e?Mr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>we(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:Ee.name,onChange:S=>{const I=S.target.value;Ae(K=>({...K,name:I,id:K.id?K.id:I.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:Ee.id,onChange:S=>Ae(I=>({...I,id:S.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:Ee.description,onChange:S=>Ae(I=>({...I,description:S.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Yn.length," 个节点和 ",es.length," 条内部连线。"]}),et?o.jsx("div",{className:"af-flow-snippet-error",children:et}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>we(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:st||!Ee.name.trim(),onClick:()=>void kl(),children:st?"发布中...":"发布"})]})]})}),document.body):null,hn?Mr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"发布展示页",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),"发布展示页"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>An(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{type:"text",value:Qe.title,onChange:S=>ot(I=>({...I,title:S.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"布局"}),o.jsxs("select",{className:"af-display-share-select",value:Qe.layout,onChange:S=>ot(I=>({...I,layout:S.target.value})),children:[o.jsx("option",{value:"gallery",children:"Gallery"}),o.jsx("option",{value:"document",children:"Document"}),o.jsx("option",{value:"slides",children:"Slides"})]})]}),o.jsx("div",{className:"af-display-share-node-list",role:"group","aria-label":"选择展示节点",children:$o.map(S=>{var K,X;const I=Array.isArray(Qe.nodeIds)&&Qe.nodeIds.includes(S.id);return o.jsxs("label",{className:"af-display-share-node-row",children:[o.jsx("input",{type:"checkbox",checked:I,onChange:()=>Sl(S.id)}),o.jsxs("span",{className:"af-display-share-node-row__main",children:[o.jsx("strong",{children:((K=S.data)==null?void 0:K.label)||S.id}),o.jsxs("small",{children:[Hn((X=S.data)==null?void 0:X.definitionId)," · ",S.id]})]})]},S.id)})}),de!=null&&de.absoluteUrl?o.jsxs("div",{className:"af-display-share-result",children:[o.jsx("input",{type:"text",readOnly:!0,value:de.absoluteUrl,onFocus:S=>S.target.select()}),o.jsx("button",{type:"button",onClick:()=>window.open(de.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),o.jsx("button",{type:"button",onClick:()=>{var S;return(S=navigator.clipboard)==null?void 0:S.writeText(de.absoluteUrl).catch(()=>{})},children:"复制"})]}):null,Fn?o.jsx("div",{className:"af-flow-snippet-error",children:Fn}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>An(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Bt||!Array.isArray(Qe.nodeIds)||Qe.nodeIds.length===0,onClick:()=>void Nl(),children:Bt?"生成中...":"生成链接"})]})]})}),document.body):null,Qt?Mr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>rn(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[de!=null&&de.absoluteUrl?o.jsxs("div",{className:"af-display-link-modal__url",children:[o.jsx("input",{type:"text",readOnly:!0,value:de.absoluteUrl,onFocus:S=>S.target.select(),autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>window.open(de.absoluteUrl,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>{var S;return(S=navigator.clipboard)==null?void 0:S.writeText(de.absoluteUrl).catch(()=>{})},children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),"复制"]})]}):o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),Fn?o.jsx("div",{className:"af-flow-snippet-error",children:Fn}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>rn(!1),children:"关闭"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Bt||g.nodeIds.length===0,onClick:()=>void ed(),children:Bt?"生成中...":de!=null&&de.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,Tn?Mr.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>mn(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-display-picker-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:or,onChange:S=>sn(S.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),o.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",children:Zu.length>0?Zu.map(S=>{var ie,te;const I=g.nodeIds.includes(S.id),K=zd(S)||{width:420,height:260},X=Math.max(1,Math.round(Number(K.width)||420)),Q=Math.max(1,Math.round(Number(K.height)||260));return o.jsxs("button",{type:"button",className:"af-display-picker-card"+(I?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${X} / ${Q}`},onClick:()=>kp(S.id),children:[o.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:o.jsx("input",{type:"checkbox",checked:I,readOnly:!0,tabIndex:-1})}),o.jsx("span",{className:"af-display-picker-card__preview",children:o.jsx(wq,{node:S})}),o.jsxs("span",{className:"af-display-picker-card__meta",children:[o.jsx("strong",{children:((ie=S.data)==null?void 0:ie.label)||S.id}),o.jsxs("small",{children:[Hn((te=S.data)==null?void 0:te.definitionId)," · ",S.id]})]})]},S.id)}):o.jsx("div",{className:"af-display-picker-empty",children:Wr.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>mn(!1),children:"完成"})})]})}),document.body):null,!pt&&kn?Mr.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>tn(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[o.jsx("button",{type:"button",role:"tab","aria-selected":Sn==="nodes",className:"af-workspace-quick-add__tab"+(Sn==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>xe("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":Sn==="flows",className:"af-workspace-quick-add__tab"+(Sn==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>xe("flows"),children:"流程"})]}),o.jsxs("div",{className:"af-workspace-quick-add__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:Mt,value:Te,onChange:S=>it(S.target.value),onKeyDown:S=>{if(S.key==="Escape")S.preventDefault(),tn(!1);else if(S.key==="ArrowDown"){S.preventDefault();const I=Sn==="flows"?Mo.length:Oo.length;je(K=>Math.min(Math.max(0,I-1),K+1))}else S.key==="ArrowUp"?(S.preventDefault(),je(I=>Math.max(0,I-1))):S.key==="Tab"?(S.preventDefault(),xe(I=>I==="nodes"?"flows":"nodes")):S.key==="Enter"&&(S.preventDefault(),Sn==="flows"?Ls(Mo[re]||Mo[0]):rd(Oo[re]||Oo[0]))},placeholder:Sn==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Sn==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:Sn==="flows"?Mo.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:fe?"正在加载流程片段...":ae||"没有匹配的流程片段"}):Mo.map((S,I)=>{const K=S.displayName||S.name||S.id,X=S.snippet&&typeof S.snippet=="object"?S.snippet.instances:null,Q=S.snippet&&typeof S.snippet=="object"?S.snippet.edges:null,ie=Number.isFinite(Number(S.nodeCount))?Number(S.nodeCount):Object.keys(X||{}).length,te=Number.isFinite(Number(S.edgeCount))?Number(S.edgeCount):Array.isArray(Q)?Q.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(I===re?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>je(I),onClick:()=>Ls(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:K}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[S.id,S.version?` · v${S.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:S.description||`${ie} 节点 / ${te} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${S.id}@${S.version}`)}):Oo.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Oo.map((S,I)=>{const K=$d(S),X=Dd(S),Q=yb(S);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(I===re?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>je(I),onClick:()=>rd(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:Zj(K)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:X}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:S.id}),Q?o.jsx("span",{className:"af-workspace-quick-add__desc",children:Q}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:K})]},S.id)})})]})}),document.body):null]})]})}function Hq(){return o.jsx(Og,{children:o.jsx(Bq,{})})}function Wq(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(),i=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)||(i?r(i):""))}function Vq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function QT(e){let t=String(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 i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[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((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function Uq(e){const t=QT(e);if(!t.trim())return"";if(/<base\s+[^>]*target\s*=/i.test(t))return t;const n='<base target="_blank">';return/<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 ZT(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=new URLSearchParams;return r.set("id",t),r.set("path",n),`/api/display/file/raw?${r.toString()}`}function Kq(e,t){const n=String(e||"").trim();return n?ZT(n,t):""}function qq({content:e,shareId:t}){return o.jsx("div",{className:"af-public-display-markdown",children:o.jsx(Bu,{components:{img({src:n="",alt:r=""}){return o.jsx("img",{src:Kq(n,t),alt:r,loading:"lazy"})},a({href:n="",children:r}){return o.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:r})}},children:e})})}function Yq(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n)&&n.every(r=>r&&typeof r=="object"&&!Array.isArray(r))){const r=Array.from(new Set(n.flatMap(s=>Object.keys(s))));return[r,...n.map(s=>r.map(i=>s[i]??""))]}if(Array.isArray(n)&&n.every(Array.isArray))return n}catch{}return t.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).filter(n=>!/^\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?$/.test(n)).map(n=>n.replace(/^\||\|$/g,"").split("|").map(r=>r.trim()))}function Gq({content:e}){const t=Yq(e);if(!t.length)return o.jsx("pre",{children:e});const[n,...r]=t;return o.jsx("div",{className:"af-public-display-table-wrap",children:o.jsxs("table",{className:"af-public-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:n.map((s,i)=>o.jsx("th",{children:String(s)},i))})}),o.jsx("tbody",{children:r.map((s,i)=>o.jsx("tr",{children:n.map((a,l)=>o.jsx("td",{children:String(s[l]??"")},l))},i))})]})})}function Xq({content:e}){const t=h.useRef(null),n=h.useMemo(()=>TT(e),[e]),[r,s]=h.useState("");return h.useEffect(()=>{let i=!1,a=null,l=null;if(!(!n.ok||!t.current))return s(""),IT(()=>import("./index-DgQRkS4v.js"),[]).then(c=>{if(i||!t.current)return;a=c.init(t.current,null,{renderer:"canvas"}),a.setOption(n.option,!0);const d=()=>a==null?void 0:a.resize();l=new ResizeObserver(d),l.observe(t.current),window.addEventListener("resize",d),window.requestAnimationFrame(d)}).catch(c=>{i||s(String((c==null?void 0:c.message)||c))}),()=>{var c,d;i=!0,(c=l==null?void 0:l.disconnect)==null||c.call(l),(d=a==null?void 0:a.dispose)==null||d.call(a)}},[n]),!n.ok||r?o.jsxs("div",{className:"af-public-display-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r||n.error})]}):o.jsx("div",{ref:t,className:"af-public-display-chart"})}function Jq({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,i]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const u=Math.max(1,f.scrollHeight),p=Math.max(1,f.clientHeight),m=u>p+1,g=m?Math.max(12,p/u*100):100,b=Math.max(0,100-g),v=m?Math.min(b,f.scrollTop/Math.max(1,u-p)*b):0;i({visible:m,top:v,height:g})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),u=n.current;if(!u||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const p=new ResizeObserver(a);p.observe(u);for(const m of Array.from(u.children))p.observe(m);return()=>{cancelAnimationFrame(f),p.disconnect()}},[t,a]);const l=h.useCallback(f=>{const u=n.current;if(!u)return;const p=Math.max(0,u.scrollHeight-u.clientHeight);u.scrollTop=Math.min(1,Math.max(0,f))*p,a()},[a]),c=h.useCallback((f,u=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),g=s.height/100*m.height,b=Math.max(1,m.height-g);return(f-m.top-u)/b},[s.height]),d=h.useCallback(f=>{if(!s.visible)return;f.preventDefault(),f.stopPropagation();const u=r.current;if(!u)return;const p=u.getBoundingClientRect(),m=s.top/100*p.height,g=s.height/100*p.height,v=f.clientY>=p.top+m&&f.clientY<=p.top+m+g?f.clientY-p.top-m:g/2;l(c(f.clientY,v));const y=w=>{w.preventDefault(),l(c(w.clientY,v))},k=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[o.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function Qq({node:e,shareId:t,style:n}){const r=Wq(e),s=e.kind==="html"?QT(r):r,i=`af-public-display-node__body--${e.kind||"unknown"}`;return o.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}`,style:n,children:[o.jsx("div",{className:"af-public-display-node__head",children:o.jsxs("div",{className:"af-public-display-node__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Vq(e.kind)}),o.jsx("strong",{children:e.label||e.id}),o.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),o.jsx(Jq,{className:i,children:s.trim()?o.jsxs(o.Fragment,{children:[e.kind==="html"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:Uq(s)}):null,e.kind==="image"?o.jsx("img",{src:ZT(s,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?o.jsx(qq,{content:s,shareId:t}):null,e.kind==="chart"?o.jsx(Xq,{content:s}):null,e.kind==="table"?o.jsx(Gq,{content:s}):null,e.kind==="mermaid"||e.kind==="ascii"?o.jsx("pre",{children:s}):null]}):o.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function Zq({data:e}){return o.jsx(Qq,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const eY={publicDisplay:Zq};function tY(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 eR(){var a;const{path:e}=ko(),t=h.useMemo(()=>tY(e),[e]),[n,r]=h.useState({loading:!0,error:"",share:null,nodes:[]});h.useEffect(()=>{let l=!1;async function c(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(d=>({...d,loading:!0,error:""}));try{const d=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),f=await d.json().catch(()=>({}));if(!d.ok)throw new Error(f.error||"展示页不存在");l||r({loading:!1,error:"",share:f.share||null,nodes:Array.isArray(f.nodes)?f.nodes:[]})}catch(d){l||r({loading:!1,error:String((d==null?void 0:d.message)||d),share:null,nodes:[]})}}return c(),()=>{l=!0}},[t]);const s=h.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((c,d)=>{const f=c.position&&typeof c.position.x=="number"&&typeof c.position.y=="number"?c.position:{x:120+d*40,y:100+d*32},u=c.size&&typeof c.size.width=="number"&&typeof c.size.height=="number"?c.size:{width:520,height:320};return{id:c.id,type:"publicDisplay",position:f,data:{node:c,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(u.width)||520),height:Math.max(1,Number(u.height)||320)}}}),[t,n.nodes]),i=h.useMemo(()=>{var u;const l=(u=n.share)==null?void 0:u.viewport;if(!l||typeof l!="object")return null;const c=Number(l.x),d=Number(l.y),f=Number(l.zoom);return!Number.isFinite(c)||!Number.isFinite(d)||!Number.isFinite(f)?null:{x:c,y:d,zoom:Math.min(Math.max(f,.1),4)}},[(a=n.share)==null?void 0:a.viewport]);return n.loading?o.jsx("main",{className:"af-public-display-page",children:o.jsx("div",{className:"af-public-display-status",children:"Loading..."})}):n.error?o.jsx("main",{className:"af-public-display-page",children:o.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),o.jsx("span",{children:n.error})]})}):o.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:o.jsx(Og,{children:o.jsx(Fv,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:eY,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:i||void 0,fitView:!i,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:o.jsx(Bv,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const kt=e=>typeof e=="string",jd=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},u1=e=>e==null?"":""+e,nY=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},rY=/###/g,d1=e=>e&&e.indexOf("###")>-1?e.replace(rY,"."):e,f1=e=>!e||kt(e),sf=(e,t,n)=>{const r=kt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(f1(e))return{};const i=d1(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return f1(e)?{}:{obj:e,k:d1(r[s])}},p1=(e,t,n)=>{const{obj:r,k:s}=sf(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let i=t[t.length-1],a=t.slice(0,t.length-1),l=sf(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=sf(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},sY=(e,t,n,r)=>{const{obj:s,k:i}=sf(e,t,Object);s[i]=s[i]||[],s[i].push(n)},Jm=(e,t)=>{const{obj:n,k:r}=sf(e,t);if(n)return n[r]},iY=(e,t,n)=>{const r=Jm(e,n);return r!==void 0?r:Jm(t,n)},tR=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?kt(e[r])||e[r]instanceof String||kt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):tR(e[r],t[r],n):e[r]=t[r]);return e},Oc=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var oY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const aY=e=>kt(e)?e.replace(/[&<>"'\/]/g,t=>oY[t]):e;class lY{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 cY=[" ",",","?","!",";"],uY=new lY(20),dY=(e,t,n)=>{t=t||"",n=n||"";const r=cY.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=uY.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!s.test(e);if(!i){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(i=!0)}return i},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 i=0;i<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let c=i;c<r.length;++c)if(c!==i&&(l+=n),l+=r[c],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;i+=c-i+1;break}s=a}return s},Qm=e=>e&&e.replace("_","-"),fY={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 Zm{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||fY,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:(kt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Zm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Zm(this.logger,t)}}var po=new Zm;class Hg{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 d=0;d<c;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let d=0;d<c;d++)l.apply(l,[t,...r])})}}class h1 extends Hg{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 i=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):kt(r)&&i?l.push(...r.split(i)):l.push(r)));const c=Jm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!kt(r)?c:wb(this.data&&this.data[t]&&this.data[t][n],r,i)}addResource(t,n,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=i.keySeparator!==void 0?i.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),p1(this.data,l,s),i.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 i in r)(kt(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,i){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=Jm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?tR(c,r,i):c={...c,...r},p1(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 nR={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(i=>{this.processors[i]&&(t=this.processors[i].process(t,n,r,s))}),t}};const m1={};class eg extends Hg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),nY(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=po.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 i=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!dY(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:kt(i)?[i]:i};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),t=d.join(s)}return{key:t,namespaces:kt(i)?[i]:i}}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,i=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],d=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(f){const j=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${j}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${j}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const u=this.resolve(t,n);let p=u&&u.res;const m=u&&u.usedKey||a,g=u&&u.exactUsedKey||a,b=Object.prototype.toString.apply(p),v=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!kt(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&w&&v.indexOf(b)<0&&!(kt(y)&&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(m,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(u.res=j,u.usedParams=this.getUsedParamsDetails(n),u):j}if(i){const j=Array.isArray(p),A=j?[]:{},C=j?g:m;for(const $ in p)if(Object.prototype.hasOwnProperty.call(p,$)){const B=`${C}${i}${$}`;A[$]=this.translate(B,{...n,joinArrays:!1,ns:l}),A[$]===B&&(A[$]=p[$])}p=A}}else if(k&&kt(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,A=!1;const C=n.count!==void 0&&!kt(n.count),$=eg.hasDefaultValue(n),B=C?this.pluralResolver.getSuffix(d,n.count,n):"",F=n.ordinal&&C?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",z=C&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),L=z&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${B}`]||n[`defaultValue${F}`]||n.defaultValue;!this.isValidLookup(p)&&$&&(j=!0,p=L),this.isValidLookup(p)||(A=!0,p=a);const W=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&A?void 0:p,M=$&&L!==p&&this.options.updateMissing;if(A||j||M){if(this.logger.log(M?"updateKey":"missingKey",d,c,a,M?L:p),i){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 T=[];const E=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&E&&E[0])for(let _=0;_<E.length;_++)T.push(E[_]);else this.options.saveMissingTo==="all"?T=this.languageUtils.toResolveHierarchy(n.lng||this.language):T.push(n.lng||this.language);const D=(_,R,P)=>{const G=$&&P!==p?P:W;this.options.missingKeyHandler?this.options.missingKeyHandler(_,c,R,G,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,c,R,G,M,n),this.emit("missingKey",_,c,R,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?T.forEach(_=>{const R=this.pluralResolver.getSuffixes(_,n);z&&n[`defaultValue${this.options.pluralSeparator}zero`]&&R.indexOf(`${this.options.pluralSeparator}zero`)<0&&R.push(`${this.options.pluralSeparator}zero`),R.forEach(P=>{D([_],a+P,n[`defaultValue${P}`]||L)})}):D(T,a,L))}p=this.extendTranslation(p,t,n,u,r),A&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(A||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?(u.res=p,u.usedParams=this.getUsedParamsDetails(n),u):p}extendTranslation(t,n,r,s,i){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 d=kt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(d){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let u=r.replace&&!kt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),t=this.interpolator.interpolate(t,u,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;f<m&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return i&&i[0]===m[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${n[0]}`),null):a.translate(...m,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=kt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=nR.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,i,a,l;return kt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),f=d.key;s=f;let u=d.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const p=n.count!==void 0&&!kt(n.count),m=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(kt(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);u.forEach(v=>{this.isValidLookup(r)||(l=v,!m1[`${b[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(m1[`${b[0]}-${v}`]=!0,this.logger.warn(`key "${s}" for languages "${b.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!!!")),b.forEach(y=>{if(this.isValidLookup(r))return;a=y;const k=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,y,v,n);else{let j;p&&(j=this.pluralResolver.getSuffix(y,n.count,n));const A=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(f+j),n.ordinal&&j.indexOf(C)===0&&k.push(f+j.replace(C,this.options.pluralSeparator)),m&&k.push(f+A)),g){const $=`${f}${this.options.contextSeparator}${n.context}`;k.push($),p&&(k.push($+j),n.ordinal&&j.indexOf(C)===0&&k.push($+j.replace(C,this.options.pluralSeparator)),m&&k.push($+A))}}let w;for(;w=k.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,v,w,n))}))})}),{res:r,usedKey:s,exactUsedKey:i,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&&!kt(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 i of n)delete s[i]}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 bx=e=>e.charAt(0).toUpperCase()+e.slice(1);class g1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=po.create("languageUtils")}getScriptPartFromCode(t){if(t=Qm(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=Qm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(kt(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]=bx(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]=bx(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=bx(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(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),kt(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=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return kt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):kt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let pY=[{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}],hY={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 mY=["v1","v2","v3"],gY=["v4"],y1={zero:0,one:1,two:2,few:3,many:4,other:5},yY=()=>{const e={};return pY.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:hY[t.fc]}})}),e};class xY{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=po.create("pluralResolver"),(!this.options.compatibilityJSON||gY.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=yY(),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=Qm(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];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[i]=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,i)=>y1[s]-y1[i]).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 i=()=>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()}`:i():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!mY.includes(this.options.compatibilityJSON)}}const x1=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,i=iY(e,t,n);return!i&&s&&kt(n)&&(i=wb(e,n,r),i===void 0&&(i=wb(t,n,r))),i},vx=e=>e.replace(/\$/g,"$$$$");class wY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=po.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:i,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:f,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:v,maxReplaces:y,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:aY,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?Oc(i):a||"{{",this.suffix=l?Oc(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?Oc(p):m||Oc("$t("),this.nestingSuffix=g?Oc(g):b||Oc(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=y||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 i,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const y=x1(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:m}):y}const g=m.split(this.formatSeparator),b=g.shift().trim(),v=g.join(this.formatSeparator).trim();return this.format(x1(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,u=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>vx(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?vx(this.escape(m)):vx(m)}].forEach(m=>{for(l=0;i=m.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const v=f(t,i,s);a=kt(v)?v:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!kt(a)&&!this.useRawValueToEscape&&(a=u1(a));const b=m.safeValue(a);if(t=t.replace(i[0],b),u?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=i[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(c,d)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const u=c.split(new RegExp(`${f}[ ]*{`));let p=`{${u[1]}`;c=u[0],p=this.interpolate(p,a);const m=p.match(/'/g),g=p.match(/"/g);(m&&m.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${c}${f}${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&&!kt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const f=s[1].split(this.formatSeparator).map(u=>u.trim());s[1]=f.shift(),c=f,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!kt(i))return i;kt(i)||(i=u1(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=c.reduce((f,u)=>this.format(f,u,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const bY=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(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Mc=e=>{const t={};return(n,r,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const a=r+JSON.stringify(i);let l=t[a];return l||(l=e(Qm(r),s),t[a]=l),l(n)}};class vY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=po.create("formatter"),this.options=t,this.formats={number:Mc((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:Mc((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:Mc((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:Mc((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:Mc((n,r)=>{const s=new Intl.ListFormat(n,{...r});return i=>s.format(i)})},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()]=Mc(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(c=>c.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,c)=>{const{formatName:d,formatOptions:f}=bY(c);if(this.formats[d]){let u=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=p.locale||p.lng||s.locale||s.lng||r;u=this.formats[d](l,m,{...f,...s,...p})}catch(p){this.logger.warn(p)}return u}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const kY=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class SY extends Hg{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=po.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 i={},a={},l={},c={};return t.forEach(d=>{let f=!0;n.forEach(u=>{const p=`${d}|${u}`;!r.reload&&this.store.hasResourceBundle(d,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,f=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),c[u]===void 0&&(c[u]=!0)))}),f||(l[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const s=t.split("|"),i=s[0],a=s[1];n&&this.emit("failedLoading",i,a,n),!n&&r&&this.store.addResourceBundle(i,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=>{sY(c.loaded,[i],a),kY(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const f=c.loaded[d];f.length&&f.forEach(u=>{l[d][u]===void 0&&(l[d][u]=!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,i=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:i,callback:a});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,f)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}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();kt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),kt(n)&&(n=[n]);const i=this.queueLoad(t,n,r,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.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],i=r[1];this.read(s,i,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${i} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,i){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:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,r,s,c):f=d(t,n,r,s),f&&typeof f.then=="function"?f.then(u=>l(null,u)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const w1=()=>({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]),kt(e[1])&&(t.defaultValue=e[1]),kt(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}}),b1=e=>(kt(e.ns)&&(e.ns=[e.ns]),kt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),kt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Nh=()=>{},NY=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Bf extends Hg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=b1(t),this.services={},this.logger=po,this.modules={external:[]},NY(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&&(kt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=w1();this.options={...s,...this.options,...b1(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 i=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?po.init(i(this.modules.logger),this.options):po.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=vY);const u=new g1(this.options);this.store=new h1(this.options.resources,this.options);const p=this.services;p.logger=po,p.resourceStore=this.store,p.languageUtils=u,p.pluralResolver=new xY(u,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new wY(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new SY(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(m){for(var g=arguments.length,b=new Array(g>1?g-1:0),v=1;v<g;v++)b[v-1]=arguments[v];t.emit(m,...b)}),this.modules.languageDetector&&(p.languageDetector=i(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=i(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new eg(this.services,this.options),this.translator.on("*",function(m){for(var g=arguments.length,b=new Array(g>1?g-1:0),v=1;v<g;v++)b[v-1]=arguments[v];t.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Nh),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[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(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const c=jd(),d=()=>{const f=(u,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(u,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nh;const s=kt(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 i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};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(i,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=jd();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=Nh),this.services.backendConnector.reload(t,n,i=>{s.resolve(),r(i)}),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"&&nR.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=jd();this.emit("languageChanging",t);const i=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,d)=>{d?(i(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):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 d=kt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,f=>{a(f,d)})};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 i=function(a,l){let c;if(typeof l!="object"){for(var d=arguments.length,f=new Array(d>2?d-2:0),u=2;u<d;u++)f[u-2]=arguments[u];c=s.options.overloadTranslationOptionHandler([a,l].concat(f))}else c={...l};c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const p=s.options.keySeparator||".";let m;return c.keyPrefix&&Array.isArray(a)?m=a.map(g=>`${c.keyPrefix}${p}${g}`):m=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(m,c)};return kt(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=r,i}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,i=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===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(i,t)))}loadNamespaces(t,n){const r=jd();return this.options.ns?(kt(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=jd();kt(t)&&(t=[t]);const s=this.options.preload||[],i=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=s.concat(i),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 g1(w1());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 Bf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nh;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new Bf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new h1(this.store.data,s),i.services.resourceStore=i.store),i.translator=new eg(i.services,s),i.translator.on("*",function(l){for(var c=arguments.length,d=new Array(c>1?c-1:0),f=1;f<c;f++)d[f-1]=arguments[f];i.emit(l,...d)}),i.init(s,n),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const zr=Bf.createInstance();zr.createInstance=Bf.createInstance;zr.createInstance;zr.dir;zr.init;zr.loadResources;zr.reloadResources;zr.use;zr.changeLanguage;zr.getFixedT;zr.t;zr.exists;zr.setDefaultNamespace;zr.hasLoadedNamespace;zr.loadNamespaces;zr.loadLanguages;function jY(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Hf(e){"@babel/helpers - typeof";return Hf=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},Hf(e)}function CY(e,t){if(Hf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Hf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function EY(e){var t=CY(e,"string");return Hf(t)=="symbol"?t:t+""}function _Y(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,EY(r.key),r)}}function PY(e,t,n){return t&&_Y(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var rR=[],AY=rR.forEach,IY=rR.slice;function TY(e){return AY.call(IY.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var v1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,RY=function(t,n,r){var s=r||{};s.path=s.path||"/";var i=encodeURIComponent(n),a="".concat(t,"=").concat(i);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(!v1.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!v1.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},k1={create:function(t,n,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=RY(t,encodeURIComponent(n),i)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var i=r[s];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(n)===0)return i.substring(n.length,i.length)}return null},remove:function(t){this.create(t,"",-1)}},LY={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=k1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&k1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},OY={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),i=s.split("&"),a=0;a<i.length;a++){var l=i[a].indexOf("=");if(l>0){var c=i[a].substring(0,l);c===t.lookupQuerystring&&(n=i[a].substring(l+1))}}}return n}},Cd=null,S1=function(){if(Cd!==null)return Cd;try{Cd=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Cd=!1}return Cd},MY={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&S1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&S1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Ed=null,N1=function(){if(Ed!==null)return Ed;try{Ed=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ed=!1}return Ed},$Y={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&N1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&N1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},DY={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}},FY={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}},zY={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}},BY={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]}},sR=!1;try{document.cookie,sR=!0}catch{}var iR=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];sR||iR.splice(1,1);function HY(){return{order:iR,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var oR=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};jY(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return PY(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=TY(r,this.options||{},HY()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(i){return i.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(LY),this.addDetector(OY),this.addDetector(MY),this.addDetector($Y),this.addDetector(DY),this.addDetector(FY),this.addDetector(zY),this.addDetector(BY)}},{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(i){if(r.detectors[i]){var a=r.detectors[i].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(i){return r.options.convertDetectedLanguage(i)}),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(i){s.detectors[i]&&s.detectors[i].cacheUserLanguage(n,s.options)}))}}])}();oR.type="languageDetector";const WY={name:"AgentFlow",tagline:"AI Workflow Orchestration"},VY={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},UY={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"},KY={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},qY={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},YY={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},GY={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},XY={app:WY,nav:VY,common:UY,status:KY,nodeTypes:qY,engine:YY,links:GY},JY="Flow Editor",QY="Nodes",ZY="Edges",eG="Properties",tG={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"},nG={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",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",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}}"},rG={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},sG={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},iG={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"},oG={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)"},aG={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},lG={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},cG={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},uG={node:"Node",text:"Text",file:"File",bool:"Boolean"},dG={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"},fG={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"},pG={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},hG={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."},mG={mainNav:"Main Navigation"},gG={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'},yG={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):
176
+ {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
177
+ 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}}"},xG={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"},wG={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},bG={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}}"},vG={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"},kG={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"},SG={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"},NG={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"},jG={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"},CG={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},EG={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},_G={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"},PG={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."},AG={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},IG={save:"Save",cancel:"Cancel"},TG={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},RG={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},LG={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"},OG={title:JY,nodes:QY,edges:ZY,properties:eG,node:tG,nodeProps:nG,actions:rG,panel:sG,palette:iG,pipeline:oG,status:aG,roles:lG,phases:cG,types:uG,runContext:dG,shortcuts:fG,jumpPalette:pG,emptyCanvas:hG,sidebar:mG,validation:gG,composer:yG,topbar:xG,palette2:wG,run:bG,fileEdit:vG,settings:kG,schedule:SG,history:NG,nodePropsError:jG,placeholder:CG,time:EG,userCheck:_G,userAsk:PG,toolPrint:AG,provideEdit:IG,runParams:TG,runPreset:RG,runConfig:LG},MG="Settings",$G={engine:"Engine Settings",preferences:"Global Preferences"},DG={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)."},FG={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..."}},zG={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."},BG={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."},HG={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)"},WG={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},VG={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},UG={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},KG={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."},qG={title:MG,crumb:$G,workspace:DG,cursor:FG,opencode:zG,claudeCode:BG,env:HG,system:WG,shortcuts:VG,language:UG,onboarding:KG},YG={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},GG={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)"},XG={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},JG={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},QG={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},ZG={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},eX={aiLabels:YG,placeholders:GG,actions:XG,labels:JG,tooltips:QG,rightPanel:ZG},tX="Projects",nX="All",rX="Archived",sX="Nodes",iX="My Nodes",oX="My Flows",aX="Skills",lX="Active Projects",cX="Archived Pipelines",uX="Global Nodes",dX="Manage node versions published to the current workspace marketplace, {{count}} total.",fX="Manage flow snippets published to the current workspace marketplace, {{count}} total.",pX="Global Skills",hX="Create New Project",mX="New Pipeline",gX="SEARCH PIPELINES...",yX="SEARCH NODES...",xX="SEARCH FLOW SNIPPETS...",wX="SEARCH SKILLS...",bX="Refresh Resources",vX="Loading pipelines...",kX="Loading global resources...",SX="Filter result: {{count}} items (matching title, description, path and tags)",NX="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",jX="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",CX="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",EX="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",_X="Executable building blocks for pipeline runtime",PX="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.",AX="Published local node packages",IX="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",TX="Published flow snippets",RX="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",LX="Operating guides for Composer and agents",OX="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",MX="No archived projects.",$X="No active pipelines; archived items are in the Archived tab.",DX="No global nodes available.",FX="No marketplace nodes have been published.",zX="No flow snippets have been published. Select multiple canvas nodes and publish them first.",BX="No skills available.",HX="No description.",WX='No node matches "{{query}}".',VX='No flow snippet matches "{{query}}".',UX='No skill matches "{{query}}".',KX="{{inputs}} in / {{outputs}} out",qX="Flow Snippet",YX="{{nodes}} nodes / {{edges}} edges",GX="Skill",XX="Node detail",JX="Flow snippet detail",QX="Skill detail",ZX="Type",eJ="Source",tJ="Package",nJ="Version",rJ="Path",sJ="Editable",iJ="Read only",oJ="Editable",aJ="Schema",lJ="Inputs",cJ="Outputs",uJ="Runtime",dJ="Node Body",fJ="Files",pJ="Usage",hJ="No runtime manifest.",mJ="No node body or README.",gJ="No previewable files.",yJ="Select a file to preview.",xJ="Binary file preview is not supported.",wJ="Large file; showing the first 256KB only.",bJ="No pipelines using this node were found.",vJ="Node Management",kJ="Delete Node Version",SJ="Deleting...",NJ="AgentFlow checks all flow references before deleting; installed or used versions are kept.",jJ="Delete {{id}}@{{version}}? This cannot be undone.",CJ="Deleted {{id}}@{{version}}.",EJ="{{count}} flow(s) still use it.",_J="Flow Snippet Management",PJ="Delete Flow Snippet",AJ="Deleting...",IJ="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",TJ="Delete {{id}}@{{version}}? This cannot be undone.",RJ="Deleted {{id}}@{{version}}.",LJ="No slots",OJ="Purpose",MJ="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",$J="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.",DJ="Scale",FJ="Flow Preview",zJ="Edges",BJ="Snippet JSON",HJ="{{count}} more edge(s)",WJ="No previewable nodes.",VJ="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",UJ="SKILL.md Preview",KJ="No preview content available.",qJ="Select a resource to inspect details.",YJ="Failed to load pipeline list.",GJ="No pipelines in current workspace.",XJ="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.",JJ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',QJ="Recent Activity",ZJ="No recent activity",eQ="No recent activity matching the keyword",tQ="Recent Run",nQ="Recent Open",rQ={builtin:"Built-in",workspace:"Workspace",user:"User"},sQ={flow:"Flow",global:"Global",marketplace:"Marketplace"},iQ={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},oQ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},aQ="Open to edit this pipeline in the node canvas.",lQ={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>"},cQ={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"},uQ={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"},dQ={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"},fQ={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"},pQ={title:tX,all:nX,archived:rX,nodes:sX,myNodes:iX,myFlows:oX,skills:aX,activeProjects:lX,archivedPipelines:cX,globalNodes:uX,myNodesHint:dX,myFlowsHint:fX,globalSkills:pX,createNew:hX,newPipeline:mX,searchPipelines:gX,searchNodes:yX,searchFlows:xX,searchSkills:wX,refreshResources:bX,loadingPipelines:vX,loadingResources:kX,filterResult:SX,archivedHint:NX,activeHint:jX,nodesHint:CX,skillsHint:EX,nodesPurposeTitle:_X,nodesPurposeDesc:PX,myNodesPurposeTitle:AX,myNodesPurposeDesc:IX,myFlowsPurposeTitle:TX,myFlowsPurposeDesc:RX,skillsPurposeTitle:LX,skillsPurposeDesc:OX,noArchived:MX,noActive:$X,noNodes:DX,noMyNodes:FX,noMyFlows:zX,noSkills:BX,noDescription:HX,noNodeMatch:WX,noFlowSnippetMatch:VX,noSkillMatch:UX,nodeSlots:KX,flowSnippet:qX,flowSnippetNodes:YX,skill:GX,nodeDetail:XX,flowDetail:JX,skillDetail:QX,detailType:ZX,detailSource:eJ,detailPackage:tJ,detailVersion:nJ,detailPath:rJ,detailEditable:sJ,readOnly:iJ,editable:oJ,nodeSchema:aJ,nodeInputs:lJ,nodeOutputs:cJ,nodeRuntime:uJ,nodeBody:dJ,nodeFiles:fJ,nodeUsage:pJ,noRuntimeManifest:hJ,noNodeBody:mJ,noNodeFiles:gJ,selectNodeFile:yJ,binaryFile:xJ,fileTruncated:wJ,noNodeUsage:bJ,myNodeManagement:vJ,deleteMyNode:kJ,deletingMyNode:SJ,deleteMyNodeHint:NJ,deleteMyNodeConfirm:jJ,deleteMyNodeSuccess:CJ,deleteMyNodeUsedBy:EJ,myFlowManagement:_J,deleteMyFlow:PJ,deletingMyFlow:AJ,deleteMyFlowHint:IJ,deleteMyFlowConfirm:TJ,deleteMyFlowSuccess:RJ,noSlots:LJ,resourceMeaning:OJ,nodesMeaning:MJ,myFlowsMeaning:$J,flowSnippetScale:DJ,flowSnippetPreview:FJ,flowSnippetEdges:zJ,flowSnippetJson:BJ,flowSnippetMoreEdges:HJ,noFlowSnippetPreview:WJ,skillsMeaning:VJ,skillPreview:UJ,skillPreviewEmpty:KJ,selectResource:qJ,loadFailed:YJ,noPipelines:GJ,emptyHint:XJ,noMatch:JJ,recentActivity:QJ,noRecentActivity:ZJ,noMatchRecent:eQ,recentRun:tQ,recentOpen:nQ,sourceBadge:rQ,resourceSource:sQ,resourceFilter:iQ,nodeDetailTabs:oQ,defaultCardDesc:aQ,hubCard:lQ,newPipelineModal:cQ,importModal:uQ,deleteModal:dQ,archiveModal:fQ},hQ="Back",mQ="Next",gQ="Skip",yQ="Done",xQ="Start Creating",wQ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
178
+
179
+ Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
180
+
181
+ Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},bQ={intro:`Now you're in the flow editor.
182
+
183
+ Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
184
+
185
+ The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
186
+
187
+ Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
188
+
189
+ The left node panel allows you to freely drag, delete, and adjust connections.`},vQ={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"},kQ={back:hQ,next:mQ,skip:gQ,done:yQ,startCreate:xQ,projects:wQ,flow:bQ,newPipeline:vQ},SQ={name:"AgentFlow",tagline:"AI 工作流编排"},NQ={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},jQ={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},CQ={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},EQ={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},_Q={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},PQ={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},AQ={app:SQ,nav:NQ,common:jQ,status:CQ,nodeTypes:EQ,engine:_Q,links:PQ},IQ="流程编辑器",TQ="节点",RQ="连线",LQ="属性",OQ={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:"编辑内容"},MQ={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{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}}"},$Q={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},DQ={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},FQ={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},zQ={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},BQ={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},HQ={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},WQ={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},VQ={node:"节点",text:"文本",file:"文件",bool:"布尔"},UQ={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:"等待"},KQ={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},qQ={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},YQ={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},GQ={mainNav:"主导航"},XQ={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},JQ={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}} 步):
190
+ {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
191
+ 当前:{{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}}"},QQ={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},ZQ={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},eZ={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}} 的分支"},tZ={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},nZ={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:"已复制"},rZ={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:"定时配置已保存"},sZ={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},iZ={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},oZ={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},aZ={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},lZ={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},cZ={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},uZ={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},dZ={save:"保存",cancel:"取消"},fZ={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},pZ={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},hZ={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},mZ={title:IQ,nodes:TQ,edges:RQ,properties:LQ,node:OQ,nodeProps:MQ,actions:$Q,panel:DQ,palette:FQ,pipeline:zQ,status:BQ,roles:HQ,phases:WQ,types:VQ,runContext:UQ,shortcuts:KQ,jumpPalette:qQ,emptyCanvas:YQ,sidebar:GQ,validation:XQ,composer:JQ,topbar:QQ,palette2:ZQ,run:eZ,fileEdit:tZ,settings:nZ,schedule:rZ,history:sZ,nodePropsError:iZ,placeholder:oZ,time:aZ,userCheck:lZ,userAsk:cZ,toolPrint:uZ,provideEdit:dZ,runParams:fZ,runPreset:pZ,runConfig:hZ},gZ="设置",yZ={engine:"引擎设置",preferences:"全局首选项"},xZ={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},wZ={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},bZ={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},vZ={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},kZ={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},SZ={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},NZ={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},jZ={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},CZ={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},EZ={title:gZ,crumb:yZ,workspace:xZ,cursor:wZ,opencode:bZ,claudeCode:vZ,env:kZ,system:SZ,shortcuts:NZ,language:jZ,onboarding:CZ},_Z={thinking:"思考",result:"结果",reply:"回复",error:"错误"},PZ={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},AZ={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},IZ={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},TZ={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},RZ={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},LZ={aiLabels:_Z,placeholders:PZ,actions:AZ,labels:IZ,tooltips:TZ,rightPanel:RZ},OZ="项目",MZ="全部",$Z="已归档",DZ="Nodes",FZ="我的 Nodes",zZ="我的流程",BZ="Skills",HZ="活跃项目",WZ="已归档流水线",VZ="全局 Nodes",UZ="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",KZ="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",qZ="全局 Skills",YZ="创建新项目",GZ="新建流水线",XZ="搜索流水线…",JZ="搜索 nodes…",QZ="搜索流程片段…",ZZ="搜索 skills…",eee="刷新资源",tee="加载流水线列表…",nee="加载全局资源…",ree="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",see="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",iee="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",oee="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",aee="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",lee="流程运行时的可执行积木",cee="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",uee="已发布的本地节点包",dee="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",fee="已发布的流程片段",pee="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",hee="Composer/Agent 的操作指南",mee="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",gee="暂无归档项目。",yee="暂无未归档流水线;已归档项在 Archived 标签中查看。",xee="暂无可用全局 nodes。",wee="暂无已发布的 marketplace nodes。",bee="暂无已发布的流程片段。可在画布中选中多个节点后发布。",vee="暂无可用 skills。",kee="暂无描述。",See="未找到与「{{query}}」匹配的 node。",Nee="未找到与「{{query}}」匹配的流程片段。",jee="未找到与「{{query}}」匹配的 skill。",Cee="{{inputs}} in / {{outputs}} out",Eee="流程片段",_ee="{{nodes}} 节点 / {{edges}} 连线",Pee="Skill",Aee="Node 详情",Iee="流程片段详情",Tee="Skill 详情",Ree="类型",Lee="来源",Oee="包",Mee="版本",$ee="路径",Dee="可编辑",Fee="只读",zee="可编辑",Bee="Schema",Hee="输入",Wee="输出",Vee="Runtime",Uee="节点内容",Kee="Files",qee="Usage",Yee="暂无 runtime manifest。",Gee="暂无节点正文或 README。",Xee="暂无可预览文件。",Jee="请选择文件查看内容。",Qee="二进制文件暂不支持预览。",Zee="文件较大,仅显示前 256KB。",ete="暂未发现使用此 node 的流水线。",tte="节点管理",nte="删除节点版本",rte="删除中…",ste="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",ite="确定删除 {{id}}@{{version}}?此操作不可撤销。",ote="已删除 {{id}}@{{version}}。",ate="仍有 {{count}} 个 Flow 使用它。",lte="流程片段管理",cte="删除流程片段",ute="删除中…",dte="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",fte="确定删除 {{id}}@{{version}}?此操作不可撤销。",pte="已删除 {{id}}@{{version}}。",hte="无槽位",mte="作用",gte="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",yte="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",xte="规模",wte="流程预览",bte="连线",vte="片段 JSON",kte="还有 {{count}} 条连线",Ste="暂无可预览节点。",Nte="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",jte="SKILL.md 预览",Cte="暂无可预览内容。",Ete="请选择一个资源查看详情。",_te="未能加载流水线列表。",Pte="当前工作区暂无流水线。",Ate="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Ite="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Tte="最近打开或最近运行",Rte="暂无打开或运行记录",Lte="暂无与关键词匹配的最近记录",Ote="最近运行",Mte="最近打开",$te={builtin:"内置",workspace:"工作区",user:"用户"},Dte={flow:"Flow",global:"Global",marketplace:"Marketplace"},Fte={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},zte={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Bte="打开以在节点画布中编辑此流水线。",Hte={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Wte={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:"关闭"},Vte={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Ute={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Kte={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},qte={title:OZ,all:MZ,archived:$Z,nodes:DZ,myNodes:FZ,myFlows:zZ,skills:BZ,activeProjects:HZ,archivedPipelines:WZ,globalNodes:VZ,myNodesHint:UZ,myFlowsHint:KZ,globalSkills:qZ,createNew:YZ,newPipeline:GZ,searchPipelines:XZ,searchNodes:JZ,searchFlows:QZ,searchSkills:ZZ,refreshResources:eee,loadingPipelines:tee,loadingResources:nee,filterResult:ree,archivedHint:see,activeHint:iee,nodesHint:oee,skillsHint:aee,nodesPurposeTitle:lee,nodesPurposeDesc:cee,myNodesPurposeTitle:uee,myNodesPurposeDesc:dee,myFlowsPurposeTitle:fee,myFlowsPurposeDesc:pee,skillsPurposeTitle:hee,skillsPurposeDesc:mee,noArchived:gee,noActive:yee,noNodes:xee,noMyNodes:wee,noMyFlows:bee,noSkills:vee,noDescription:kee,noNodeMatch:See,noFlowSnippetMatch:Nee,noSkillMatch:jee,nodeSlots:Cee,flowSnippet:Eee,flowSnippetNodes:_ee,skill:Pee,nodeDetail:Aee,flowDetail:Iee,skillDetail:Tee,detailType:Ree,detailSource:Lee,detailPackage:Oee,detailVersion:Mee,detailPath:$ee,detailEditable:Dee,readOnly:Fee,editable:zee,nodeSchema:Bee,nodeInputs:Hee,nodeOutputs:Wee,nodeRuntime:Vee,nodeBody:Uee,nodeFiles:Kee,nodeUsage:qee,noRuntimeManifest:Yee,noNodeBody:Gee,noNodeFiles:Xee,selectNodeFile:Jee,binaryFile:Qee,fileTruncated:Zee,noNodeUsage:ete,myNodeManagement:tte,deleteMyNode:nte,deletingMyNode:rte,deleteMyNodeHint:ste,deleteMyNodeConfirm:ite,deleteMyNodeSuccess:ote,deleteMyNodeUsedBy:ate,myFlowManagement:lte,deleteMyFlow:cte,deletingMyFlow:ute,deleteMyFlowHint:dte,deleteMyFlowConfirm:fte,deleteMyFlowSuccess:pte,noSlots:hte,resourceMeaning:mte,nodesMeaning:gte,myFlowsMeaning:yte,flowSnippetScale:xte,flowSnippetPreview:wte,flowSnippetEdges:bte,flowSnippetJson:vte,flowSnippetMoreEdges:kte,noFlowSnippetPreview:Ste,skillsMeaning:Nte,skillPreview:jte,skillPreviewEmpty:Cte,selectResource:Ete,loadFailed:_te,noPipelines:Pte,emptyHint:Ate,noMatch:Ite,recentActivity:Tte,noRecentActivity:Rte,noMatchRecent:Lte,recentRun:Ote,recentOpen:Mte,sourceBadge:$te,resourceSource:Dte,resourceFilter:Fte,nodeDetailTabs:zte,defaultCardDesc:Bte,hubCard:Hte,newPipelineModal:Wte,importModal:Vte,deleteModal:Ute,archiveModal:Kte},Yte="返回",Gte="下一步",Xte="跳过",Jte="完成",Qte="开始创建",Zte={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
192
+
193
+ 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
194
+
195
+ 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},ene={intro:`现在进入流程编辑器。
196
+
197
+ 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
198
+
199
+ 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
200
+
201
+ 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
202
+
203
+ 左侧节点面板可以自由拖拽、删除和调整连接。`},tne={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},nne={back:Yte,next:Gte,skip:Xte,done:Jte,startCreate:Qte,projects:Zte,flow:ene,newPipeline:tne},rne={en:{common:XY,flow:OG,settings:qG,composer:eX,project:pQ,onboarding:kQ},zh:{common:AQ,flow:mZ,settings:EZ,composer:LZ,project:qte,onboarding:nne}};zr.use(oR).use(oM).init({resources:rne,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 sne=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function ine(e){return zr.changeLanguage(e)}const bb="agentflow-settings-opencode-plan-v1";function kx(e){if(!e||typeof e!="object")return{cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null};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):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null}}function aR(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function one(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function $l(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(),i=String(r.value??""),a=String(r.id??"").trim()||aR(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!i||n.push({id:a,key:s,value:i,scope:c})}return n}function j1(e){return $l(e).map(({key:t,value:n})=>({key:t,value:n}))}function C1(){try{return localStorage.getItem(bb)??""}catch{return""}}function ane(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function E1(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 lne({authUser:e}){const{t,i18n:n}=vn(["common","settings"]),r=n.language||"zh",[s,i]=h.useState(""),[a,l]=h.useState(""),[c,d]=h.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[f,u]=h.useState(""),[p,m]=h.useState(!1),[g,b]=h.useState(!1),[v,y]=h.useState(""),[k,w]=h.useState([]),[j,A]=h.useState(""),[C,$]=h.useState(!1),[B,F]=h.useState(""),[z,L]=h.useState(""),[O,W]=h.useState(!1),[M,T]=h.useState(()=>new Set),[E,D]=h.useState(""),[_,R]=h.useState([]),[P,G]=h.useState(!1),[Z,V]=h.useState(""),[se,ue]=h.useState([]),[fe,ge]=h.useState([]),[ae,ve]=h.useState(""),[_e,we]=h.useState(""),[Ee,Ae]=h.useState(!1),[st,ut]=h.useState(!1),[et,Ct]=h.useState(""),Ue=h.useRef(null),St=h.useRef(!1),nn=h.useRef(!1),hn=h.useRef(""),An=h.useCallback(async()=>{l("");try{const re=await fetch("/api/ui-context");if(!re.ok)throw new Error("HTTP "+re.status);const je=await re.json();i(typeof je.workspaceRoot=="string"?je.workspaceRoot:"")}catch(re){l(String(re.message||re)),i("")}},[]),Bt=h.useCallback(async()=>{u(""),m(!0);try{const re=await fetch("/api/model-lists");if(!re.ok)throw new Error("HTTP "+re.status);const je=await re.json();d(kx(je))}catch(re){u(String(re.message||re))}finally{m(!1)}},[]),In=h.useCallback(async()=>{A("");try{const re=await fetch("/api/user-env"),je=await re.json().catch(()=>({}));if(!re.ok)throw new Error(typeof je.error=="string"?je.error:"HTTP "+re.status);const Ye=$l(Array.isArray(je.env)?je.env:[],"user").map(Nn=>({...Nn,scope:"user"})),Ke=[...e!=null&&e.isAdmin?$l(Array.isArray(je.globalEnv)?je.globalEnv:[],"global").map(Nn=>({...Nn,scope:"global"})):[],...Ye];hn.current=JSON.stringify(Ke),w(Ke)}catch(re){w([]),A(String(re.message||re))}finally{nn.current=!0}},[e==null?void 0:e.isAdmin]),Fn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){G(!0),V("");try{const re=await fetch("/api/feedback"),je=await re.json().catch(()=>({}));if(!re.ok)throw new Error(typeof je.error=="string"?je.error:"HTTP "+re.status);R(Array.isArray(je.feedback)?je.feedback:[])}catch(re){V(String(re.message||re))}finally{G(!1)}}},[e==null?void 0:e.isAdmin]),le=h.useCallback(async()=>{if(e!=null&&e.isAdmin){Ae(!0),Ct("");try{const re=await fetch("/api/admin/user-allowlist"),je=await re.json().catch(()=>({}));if(!re.ok)throw new Error(typeof je.error=="string"?je.error:"HTTP "+re.status);const Ye=je.allowlist&&typeof je.allowlist=="object"?je.allowlist:{};ue(Array.isArray(Ye.fileUsers)?Ye.fileUsers.map(String):[]),ge(Array.isArray(Ye.envUsers)?Ye.envUsers.map(String):[]),ve(typeof Ye.path=="string"?Ye.path:"")}catch(re){Ct(String(re.message||re))}finally{Ae(!1)}}},[e==null?void 0:e.isAdmin]),de=h.useCallback(async re=>{if(e!=null&&e.isAdmin){ut(!0),Ct("");try{const je=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:re})}),Ye=await je.json().catch(()=>({}));if(!je.ok)throw new Error(typeof Ye.error=="string"?Ye.error:"HTTP "+je.status);const jt=Ye.allowlist&&typeof Ye.allowlist=="object"?Ye.allowlist:{};ue(Array.isArray(jt.fileUsers)?jt.fileUsers.map(String):[]),ge(Array.isArray(jt.envUsers)?jt.envUsers.map(String):[]),ve(typeof jt.path=="string"?jt.path:"")}catch(je){Ct(String(je.message||je))}finally{ut(!1)}}},[e==null?void 0:e.isAdmin]),ze=h.useCallback(async re=>{const je=$l(re),Ye=je.filter(Ke=>Ke.scope!=="global"),jt=je.filter(Ke=>Ke.scope==="global");$(!0),A("");try{const Ke=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:j1(Ye),...e!=null&&e.isAdmin?{globalEnv:j1(jt)}:{}})}),Nn=await Ke.json().catch(()=>({}));if(!Ke.ok)throw new Error(typeof Nn.error=="string"?Nn.error:"HTTP "+Ke.status);const fi=$l(Array.isArray(Nn.env)?Nn.env:[],"user").map(Sr=>({...Sr,scope:"user"})),kr=[...e!=null&&e.isAdmin?$l(Array.isArray(Nn.globalEnv)?Nn.globalEnv:[],"global").map(Sr=>({...Sr,scope:"global"})):[],...fi];hn.current=JSON.stringify(kr),w(kr)}catch(Ke){A(String(Ke.message||Ke))}finally{$(!1)}},[e==null?void 0:e.isAdmin]),Qe=h.useCallback(async()=>{u(""),m(!0);try{const re=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:E.trim()})}),je=await re.json().catch(()=>({}));if(!re.ok)throw new Error(typeof je.error=="string"?je.error:"HTTP "+re.status);d(kx(je.modelLists))}catch(re){u(String(re.message||re))}finally{m(!1)}},[E]);h.useEffect(()=>{An(),Bt(),In(),e!=null&&e.isAdmin&&(Fn(),le()),(async()=>{try{const re=await fetch("/api/agentflow-config");if(re.ok){const je=await re.json(),Ye=typeof je.opencodeProvider=="string"?je.opencodeProvider:"";D(Ye),Ue.current=Ye;try{localStorage.setItem(bb,Ye)}catch{}}else{const je=C1();D(je),Ue.current=je}}catch{const re=C1();D(re),Ue.current=re}finally{St.current=!0}})()},[e==null?void 0:e.isAdmin,An,Fn,Bt,le,In]),h.useEffect(()=>{if(!nn.current||JSON.stringify($l(k))===hn.current)return;const je=setTimeout(()=>{ze(k)},350);return()=>clearTimeout(je)},[k,ze]),h.useEffect(()=>{if(!St.current)return;const re=E.trim();if(re===Ue.current)return;const je=setTimeout(()=>{(async()=>{b(!0),y("");try{const Ye=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:re})}),jt=await Ye.json().catch(()=>({}));if(!Ye.ok)throw new Error(typeof jt.error=="string"?jt.error:"HTTP "+Ye.status);Ue.current=re;try{localStorage.setItem(bb,re)}catch{}jt.modelLists&&d(kx(jt.modelLists))}catch(Ye){y(String(Ye.message||Ye))}finally{b(!1)}})()},450);return()=>clearTimeout(je)},[E]);const ot=c.cursor.length>0,Qt=c.opencode.length>0,rn=c.claudeCode.length>0,Tn=h.useCallback(()=>{var re;s&&((re=navigator.clipboard)==null||re.writeText(s))},[s]),mn=h.useCallback(()=>{const re=B.trim(),je=z;if(re){if(!one(re)){A(t("settings:env.invalidKey"));return}w(Ye=>[...Ye,{id:aR(),key:re,value:je,scope:e!=null&&e.isAdmin&&O?"global":"user"}]),F(""),L("")}},[e==null?void 0:e.isAdmin,O,B,z,t]),or=h.useCallback(re=>{w(je=>je.filter(Ye=>Ye.id!==re))},[]),sn=h.useCallback((re,je)=>{w(Ye=>Ye.map(jt=>jt.id===re?{...jt,...je}:jt))},[]),kn=h.useCallback(re=>{T(je=>{const Ye=new Set(je);return Ye.has(re)?Ye.delete(re):Ye.add(re),Ye})},[]),tn=h.useCallback(()=>{const re=_e.trim();if(!re)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(re)){Ct("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(se.map(Ye=>String(Ye||"").trim().toLowerCase())).has(re.toLowerCase())){we("");return}we(""),de([...se,re])},[_e,se,de]),Sn=h.useCallback(re=>{const je=String(re||"").trim().toLowerCase();je&&de(se.filter(Ye=>String(Ye||"").trim().toLowerCase()!==je))},[se,de]),xe=h.useCallback(re=>{const je=re.target.value;ine(je)},[]),Te=re=>{const je=E1(re,r);return je?t("settings:cursor.modelList.fetchedAt",{time:je}):t("settings:cursor.modelList.never")},it=re=>E1(re,r)||String(re||"");return o.jsxs("div",{className:"af-settings-page",children:[o.jsx("header",{className:"af-settings-top",children:o.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[o.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),o.jsx("p",{className:"af-settings-lead",children:t("settings:workspace.description")}),a?o.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,f?o.jsx("p",{className:"af-err af-settings-api-hint",children:f}):null,j?o.jsx("p",{className:"af-err af-settings-api-hint",children:j}):null]}),o.jsxs("div",{className:"af-settings-layout",children:[o.jsxs("div",{className:"af-settings-bento",children:[o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[o.jsxs("div",{className:"af-set-card-inner",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),o.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),o.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Tn,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:o.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),o.jsx("p",{className:"af-set-hint",children:t("settings:workspace.description")})]}),o.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),o.jsx("span",{className:"af-set-badge"+(ot?" af-set-badge--ok":" af-set-badge--muted"),children:t(ot?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:ot?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(ot?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:ot?t("settings:cursor.modelList.count",{count:c.cursor.length})+" · "+Te(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),ot?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:c.cursor.join(`
204
+ `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Qe(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),o.jsx("span",{className:"af-set-badge"+(Qt?" af-set-badge--ok":" af-set-badge--err"),children:t(Qt?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),o.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),o.jsxs("div",{children:[o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),o.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:E,onChange:re=>D(re.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),g?o.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,v?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:v}):null]}),Qt?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+" · "+Te(c.opencodeFetchedAt)}),o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:c.opencode.join(`
205
+ `)})]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Qe(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),o.jsx("span",{className:"af-set-badge"+(rn?" af-set-badge--ok":" af-set-badge--err"),children:t(rn?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:rn?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(rn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:rn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+" · "+Te(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),rn?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:c.claudeCode.join(`
206
+ `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Qe(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),o.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),o.jsx("span",{className:"af-set-env-note",children:C?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[o.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[o.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?o.jsx("span",{children:t("settings:env.scope")}):null,o.jsx("span",{children:t("settings:env.value")}),o.jsx("span",{})]}),k.map(re=>o.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:re.key,onChange:je=>sn(re.id,{key:je.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:re.scope!=="global"?"is-active":"",onClick:()=>sn(re.id,{scope:"user"}),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:re.scope==="global"?"is-active":"",onClick:()=>sn(re.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:M.has(re.id)?"text":"password",value:re.value,onChange:je=>sn(re.id,{value:je.target.value}),placeholder:ane(re.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),o.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>kn(re.id),"aria-label":M.has(re.id)?"Hide value":"Show value",children:o.jsx("span",{className:"material-symbols-outlined",children:M.has(re.id)?"visibility_off":"visibility"})})]}),o.jsx("div",{className:"af-set-env-actions",children:o.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:re.key}),onClick:()=>or(re.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},re.id)),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:B,onChange:re=>F(re.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:O?"":"is-active",onClick:()=>W(!1),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:O?"is-active":"",onClick:()=>W(!0),children:t("settings:env.global")})]})}):null,o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:z,onChange:re=>L(re.target.value),"aria-label":t("settings:env.newValue")})}),o.jsx("div",{className:"af-set-env-actions",children:o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:mn,disabled:!B.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]})]})]}),e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"用户白名单"}),o.jsx("p",{className:"af-set-card-subtitle",children:"只控制 username 是否允许注册或登录,密码由用户首次登录时自行设置。"})]})]}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void le(),disabled:Ee,children:Ee?"刷新中...":"刷新"})]}),et?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:et}):null,ae?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["文件:",o.jsx("code",{children:ae})]}):null,o.jsxs("div",{className:"af-allowlist-grid",children:[o.jsxs("div",{className:"af-allowlist-main",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:"文件白名单"}),o.jsx("span",{children:st?"保存中...":`${se.length} 个用户`})]}),o.jsx("div",{className:"af-allowlist-list",children:se.length>0?se.map(re=>o.jsxs("div",{className:"af-allowlist-row",children:[o.jsx("span",{className:"af-allowlist-name",children:re}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>Sn(re),"aria-label":`删除 ${re}`,disabled:st,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},re)):o.jsx("div",{className:"af-allowlist-empty",children:"未配置文件白名单;如果环境变量也为空,则所有用户可注册。"})}),o.jsxs("div",{className:"af-allowlist-add",children:[o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:_e,onChange:re=>we(re.target.value),onKeyDown:re=>{re.key==="Enter"&&tn()},placeholder:"username",autoComplete:"off"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:tn,disabled:st||!_e.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加"]})]})]}),o.jsxs("div",{className:"af-allowlist-side",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:"环境变量白名单"}),o.jsx("span",{children:"只读"})]}),o.jsx("div",{className:"af-allowlist-env-list",children:fe.length>0?fe.map(re=>o.jsx("code",{children:re},re)):o.jsx("span",{children:"未配置 AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS"})})]})]})]}):null,e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--feedback",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"rate_review"})}),o.jsx("h2",{className:"af-set-h2",children:"意见反馈"})]}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Fn(),disabled:P,children:P?"刷新中...":"刷新"})]}),Z?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Z}):null,o.jsx("div",{className:"af-feedback-list",children:_.length>0?_.map(re=>o.jsxs("article",{className:"af-feedback-item",children:[o.jsxs("header",{className:"af-feedback-item__head",children:[o.jsxs("div",{children:[o.jsx("h3",{children:re.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:re.username||re.userId||"unknown"}),o.jsx("span",{children:it(re.createdAt)})]})]}),re.contact?o.jsx("span",{className:"af-feedback-item__contact",children:re.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:re.content}),re.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:re.pageUrl}):null]},re.id)):o.jsx("div",{className:"af-feedback-empty",children:P?"正在加载反馈...":"暂无反馈"})})]}):null]}),o.jsxs("aside",{className:"af-settings-rail","aria-label":t("settings:title"),children:[o.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[o.jsxs("div",{className:"af-set-rail-inner",children:[o.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),o.jsxs("div",{className:"af-set-health-line",children:[o.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),o.jsx("span",{className:"af-set-health-label",children:t(!a&&!f?"settings:system.normal":"settings:system.abnormal")})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.cursorModels")}),o.jsx("span",{children:c.cursor.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.opencodeModels")}),o.jsx("span",{children:c.opencode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.claudeCodeModels")}),o.jsx("span",{children:c.claudeCode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]})]}),o.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}),o.jsxs("div",{className:"af-set-rail-card",children:[o.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),o.jsxs("div",{className:"af-set-language-selector",children:[o.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:xe,"aria-label":t("settings:language.description"),children:sne.map(re=>o.jsxs("option",{value:re.code,children:[re.flag," ",re.name]},re.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function cne(){const{navigate:e}=ko(),[t,n]=h.useState(""),[r,s]=h.useState(""),[i,a]=h.useState(!1),[l,c]=h.useState(""),[d,f]=h.useState(!1),u=async p=>{if(p.preventDefault(),!i){a(!0),c("");try{const m=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,content:r,pageUrl:window.location.href})}),g=await m.json().catch(()=>({}));if(!m.ok)throw new Error(g.error||"提交失败");f(!0),n(""),s("")}catch(m){c(String(m.message||m))}finally{a(!1)}}};return o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel",children:[o.jsxs("div",{className:"af-feedback-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),o.jsx("h1",{children:"意见反馈"}),o.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在设置页统一查看。"})]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>e("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?o.jsxs("div",{className:"af-feedback-success",role:"status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsxs("div",{children:[o.jsx("strong",{children:"已提交"}),o.jsx("span",{children:"感谢反馈,管理员可以在设置页查看这条记录。"})]})]}):null,o.jsxs("form",{className:"af-feedback-form",onSubmit:u,children:[o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{value:t,onChange:p=>n(p.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"反馈内容"}),o.jsx("textarea",{value:r,onChange:p=>s(p.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),l?o.jsx("p",{className:"af-err af-feedback-error",children:l}):null,o.jsx("div",{className:"af-feedback-actions",children:o.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:i||!t.trim()||!r.trim(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"hourglass_empty":"send"}),i?"提交中...":"提交反馈"]})})]})]})})}function lR(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function _1(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:lR(),key:r,value:String(s??""),private:n.has(r)}))}function P1(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 Xh(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(`
207
+ `),description:String((e==null?void 0:e.description)||t.description||""),envRows:_1(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:_1(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 Sx(){return Xh({name:"",raw:{command:""}})}function une(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 i=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);i.length&&(n.args=i)}const r=P1(e.envRows),s=P1(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(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean)}}function A1(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function I1(e){return e?e.ok?"ok":"error":"unknown"}function T1({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const i=(a,l,c)=>n(t.map(d=>d.id===a?{...d,[l]:c}:d));return o.jsxs("div",{className:"af-mcp-field",children:[o.jsxs("div",{className:"af-mcp-field-head",children:[o.jsx("span",{children:e}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:lR(),key:"",value:"",private:!0}]),children:"添加"})]}),o.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?o.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>o.jsxs("div",{className:"af-mcp-kv-row",children:[o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>i(a.id,"key",l.target.value)}),o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>i(a.id,"value",l.target.value)}),o.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[o.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>i(a.id,"private",l.target.checked)}),o.jsx("span",{children:"个人"})]}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function dne(){var O;const[e,t]=h.useState(""),[n,r]=h.useState([]),[s,i]=h.useState(Sx),[a,l]=h.useState(""),[c,d]=h.useState(!1),[f,u]=h.useState(!1),[p,m]=h.useState(!1),[g,b]=h.useState({}),[v,y]=h.useState(""),[k,w]=h.useState(""),j=h.useMemo(()=>n.find(W=>W.name===a)||null,[a,n]),A=j&&g[j.name]||null,C=h.useCallback(async()=>{d(!0),y("");try{const W=await fetch("/api/mcps"),M=await W.json().catch(()=>({}));if(!W.ok)throw new Error(M.error||"MCP HTTP "+W.status);const T=Array.isArray(M.servers)?M.servers:[];t(String(M.path||"")),r(T),a&&T.some(E=>E.name===a)&&i(Xh(T.find(E=>E.name===a)))}catch(W){y(String(W.message||W))}finally{d(!1)}},[a]);h.useEffect(()=>{C()},[C]);const $=()=>{l(""),i(Sx()),w(""),y("")},B=W=>{l(W.name),i(Xh(W)),w(""),y("")},F=async(W="")=>{m(!0),y(""),w("");try{const M=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W?{name:W}:{})}),T=await M.json().catch(()=>({}));if(!M.ok)throw new Error(T.error||"检测 MCP 失败");const E=Array.isArray(T.results)?T.results:[];b(D=>{const _={...D};for(const R of E)R!=null&&R.name&&(_[R.name]=R);return _}),w(W?`已检测 ${W}。`:"已检测所有 MCP。")}catch(M){y(String(M.message||M))}finally{m(!1)}},z=async()=>{u(!0),y(""),w("");try{const W=une(s);if(!W.nextName)throw new Error("请填写 MCP 名称");const M=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),T=await M.json().catch(()=>({}));if(!M.ok)throw new Error(T.error||"保存 MCP 失败");const E=Array.isArray(T.servers)?T.servers:[];r(E),t(String(T.path||e)),l(W.nextName),i(Xh(E.find(D=>D.name===W.nextName)||null)),b(D=>{const _={...D};return s.originalName&&s.originalName!==W.nextName&&delete _[s.originalName],delete _[W.nextName],_}),w("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(W){y(String(W.message||W))}finally{u(!1)}},L=async W=>{if(W!=null&&W.name&&window.confirm(`删除 MCP "${W.name}"?`)){u(!0),y(""),w("");try{const M=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W.name})}),T=await M.json().catch(()=>({}));if(!M.ok)throw new Error(T.error||"删除 MCP 失败");r(Array.isArray(T.servers)?T.servers:[]),l(""),i(Sx()),b(E=>{const D={...E};return delete D[W.name],D}),w("已删除。")}catch(M){y(String(M.message||M))}finally{u(!1)}}};return o.jsxs("main",{className:"af-settings-page",children:[o.jsxs("header",{className:"af-settings-top",children:[o.jsxs("div",{className:"af-settings-crumb",children:[o.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),o.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),o.jsxs("div",{className:"af-settings-top-right",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:C,disabled:c||f,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>F(),disabled:p||c||f||n.length===0,children:p?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:$,disabled:f,children:"新增 MCP"})]})]}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("section",{className:"af-settings-hero",children:[o.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),o.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 Cursor MCP server。当前配置文件:",o.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),o.jsxs("div",{className:"af-mcp-layout",children:[o.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2",children:"Servers"}),o.jsxs("div",{className:"af-mcp-list-head-actions",children:[o.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),o.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:$,disabled:f,children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?o.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?o.jsxs("div",{className:"af-mcp-empty",children:[o.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:$,disabled:f,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(W=>o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===W.name?" af-mcp-server-item--active":""),onClick:()=>B(W),children:[o.jsx("span",{className:"material-symbols-outlined",children:W.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:W.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${I1(g[W.name])}`,children:A1(g[W.name])})]}),o.jsx("em",{children:W.url||[W.command,...W.args||[]].filter(Boolean).join(" ")})]})]},W.name))})]}),o.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:j?"编辑 MCP":"新增 MCP"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),j?o.jsxs("div",{className:"af-mcp-editor-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>F(j.name),disabled:p||f,children:p?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>L(j),disabled:f,children:"删除"})]}):null]}),v?o.jsx("p",{className:"af-mcp-error",children:v}):null,k?o.jsx("p",{className:"af-mcp-status",children:k}):null,A?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${I1(A)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:A1(A)}),o.jsxs("span",{children:[A.elapsedMs||0,"ms"]})]}),A.error?o.jsx("p",{children:A.error}):null,(O=A.tools)!=null&&O.length?o.jsx("div",{className:"af-mcp-tools-list",children:A.tools.map(W=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:W.name}),W.description?o.jsx("span",{children:W.description}):null]},W.name))}):null]}):null,o.jsxs("div",{className:"af-mcp-form",children:[o.jsxs("label",{className:"af-set-label",children:["MCP 名称",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:W=>i(M=>({...M,name:W.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:W=>i(M=>({...M,type:W.target.value})),children:[o.jsx("option",{value:"url",children:"URL / HTTP"}),o.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:W=>i(M=>({...M,url:W.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-set-label",children:["Command",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:W=>i(M=>({...M,command:W.target.value})),placeholder:"uvx"})]}),o.jsxs("label",{className:"af-set-label",children:["Args,每行一个",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:W=>i(M=>({...M,argsText:W.target.value})),placeholder:`mcp-server-example
208
+ --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:W=>i(M=>({...M,description:W.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(T1,{title:"Headers",rows:s.headerRows,onChange:W=>i(M=>({...M,headerRows:W})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(T1,{title:"Env",rows:s.envRows,onChange:W=>i(M=>({...M,envRows:W})),placeholderKey:"TOKEN",placeholderValue:"..."}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:W=>i(M=>({...M,extraJson:W.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:$,disabled:f,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:z,disabled:f,children:f?"保存中...":"保存 MCP"})]})]})]})]})})]})}function cR(e){return t=>typeof t===e}var fne=cR("function"),pne=e=>e===null,R1=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",L1=e=>!hne(e)&&!pne(e)&&(fne(e)||typeof e=="object"),hne=cR("undefined");function mne(e,t,n){return kne(n,e,t)?!0:(Sne(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?gne(e,t,n):e instanceof Map&&t instanceof Map?wne(e,t,n):e instanceof Set&&t instanceof Set?vne(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?yne(e,t):R1(e)&&R1(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?xne(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():bne(e,t,n))}function lp(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!L1(e)||!t||!L1(t)?!1:mne(e,t,n)}function gne(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!lp(e[s],t[s],n))return!1;return!0}function yne(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 xne(e,t,n){return e.message===t.message&&e.name===t.name&&lp(e.cause,t.cause,n)}function wne(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(!lp(r[1],t.get(r[0]),n))return!1;return!0}function bne(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 i=r[s];if(!(i==="_owner"&&e.$$typeof)&&!lp(e[i],t[i],n))return!1}return!0}function vne(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 kne(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Sne(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function p0(e,t){return lp(e,t,new WeakMap)}function Nx(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Nne(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function jne(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Cne(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Ene(e,t){const n=Cne();h.useEffect(()=>{if(!n)return e()},t)}function uR(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function _ne(e,t){const n=h.useRef(t);return p0(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function Pne(e){h.useEffect(()=>{e()},[])}function Ane(e=0){const[t,n]=h.useState({height:Nx()?window.innerHeight:0,width:Nx()?window.innerWidth:0}),r=h.useRef(0),s=h.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return h.useEffect(()=>{if(!Nx())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),jne(window,"resize",i),()=>{Nne(window,"resize",i)}},[]),t}var Ine=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Tne=["bigint","boolean","null","number","string","symbol","undefined"];function cp(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Rne(t))return t}function Wi(e){return t=>cp(t)===e}function Rne(e){return Ine.includes(e)}function Wu(e){return t=>typeof t===e}function Lne(e){return Tne.includes(e)}var One=["innerHTML","ownerDocument","style","attributes","nodeValue"],up=e=>Array.isArray(e),Mne=e=>cp(e)==="AsyncGeneratorFunction",$ne=Wi("AsyncFunction"),Dne=Wu("bigint"),Fne=e=>e===!0||e===!1,zne=Wi("Date"),Bne=Wi("Error"),nl=Wu("function"),Hne=Wi("GeneratorFunction"),Wne=e=>typeof e=="number"&&Number.isInteger(e),vb=Wi("Map"),dR=e=>Number.isNaN(e),h0=e=>e===null,fR=Wi("Function"),Vne=Wi("Promise"),Une=Wi("RegExp"),kb=Wi("Set"),dp=Wu("string"),Kne=Wu("symbol"),m0=Wu("undefined"),qne=Wi("WeakMap"),Yne=Wi("WeakSet"),g0=e=>h0(e)||m0(e),pR=e=>!m0(e),Gne=e=>Wu("number")(e)&&!dR(e),Xne=e=>dp(e)&&e.trim().length>0,Jne=e=>{if(!dp(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},Wg=e=>!g0(e)&&(nl(e)||typeof e=="object"),hR=e=>{if(cp(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Qne=e=>h0(e)||Lne(typeof e),Zne=e=>cp(e)==="URL",mR=e=>!g0(e)&&nl(e[Symbol.iterator]),ere=e=>mR(e)&&nl(e.next)&&nl(e.throw),tre=e=>nl(e)&&/^class\s/.test(e.toString()),nre=(e,t)=>!up(e)||!nl(t)?!1:e.every(n=>t(n)),rre=e=>Wg(e)&&!hR(e)&&e.nodeType===1&&dp(e.nodeName)&&One.every(t=>t in e),sre=e=>dp(e)&&e.length===0||up(e)&&e.length===0||Wg(e)&&!vb(e)&&!kb(e)&&Object.keys(e).length===0||kb(e)&&e.size===0||vb(e)&&e.size===0,ire=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,ore=(e,t)=>up(e)?e.indexOf(t)>-1:!1,are=(e,t,n)=>{if(!Wg(e)||!t)return!1;const r=e[t];return nl(n)?n(r):pR(r)};function Pt(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(up(e))return"Array";if(fR(e))return"Function";const t=cp(e);return t||"Object"}Pt.array=up;Pt.arrayOf=nre;Pt.asyncGeneratorFunction=Mne;Pt.asyncFunction=$ne;Pt.bigint=Dne;Pt.boolean=Fne;Pt.class=tre;Pt.date=zne;Pt.defined=pR;Pt.domElement=rre;Pt.empty=sre;Pt.error=Bne;Pt.function=nl;Pt.generator=ere;Pt.generatorFunction=Hne;Pt.instanceOf=ire;Pt.integer=Wne;Pt.iterable=mR;Pt.map=vb;Pt.nan=dR;Pt.null=h0;Pt.nullOrUndefined=g0;Pt.nonEmptyString=Xne;Pt.number=Gne;Pt.numericString=Jne;Pt.object=Wg;Pt.oneOf=ore;Pt.plainFunction=fR;Pt.plainObject=hR;Pt.primitive=Qne;Pt.promise=Vne;Pt.propertyOf=are;Pt.regexp=Une;Pt.set=kb;Pt.string=dp;Pt.symbol=Kne;Pt.undefined=m0;Pt.url=Zne;Pt.weakMap=qne;Pt.weakSet=Yne;var Gr=Pt;/* v8 ignore next -- @preserve */var lre=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},cre=function(e,t){return e+Wf(t)},Wf=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(cre,""):lre(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Wf(e.props.children):""};Wf.default=Wf;var ure=Wf;const jx=sl(ure);var gR={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(i){return typeof i=="object"&&i!==null&&!(i instanceof RegExp)&&!(i instanceof Date)}}function r(s){function i(A){return A!=="constructor"&&A!=="prototype"&&A!=="__proto__"}function a(A){let C=0;const $=A.length,B=new Array($);for(C;C<$;++C)B[C]=y(A[C]);return B}function l(A){const C={};if(p&&Object.getPrototypeOf(A)!==t)return p(A);const $=u(A);let B,F,z;for(B=0,F=$.length;B<F;++B)i(z=$[B])&&(C[z]=y(A[z]));return C}function c(A,C){const $=A.length,B=C.length;let F=0;const z=new Array($+B);for(F;F<$;++F)z[F]=y(A[F]);for(F=0;F<B;++F)z[F+$]=y(C[F]);return z}const d=Object.prototype.propertyIsEnumerable;function f(A){const C=Object.keys(A),$=Object.getOwnPropertySymbols(A);for(let B=0,F=$.length;B<F;++B)d.call(A,$[B])&&C.push($[B]);return C}const u=s!=null&&s.symbols?f:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,m=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),g=(s==null?void 0:s.onlyDefinedProperties)===!0;function b(A){return typeof A!="object"||A===null}const v=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:w,getKeys:u,isMergeableObject:m}):c;function y(A){return m(A)?Array.isArray(A)?a(A):l(A):A}function k(A,C){const $={},B=u(A),F=u(C);let z,L,O;for(z=0,L=B.length;z<L;++z)i(O=B[z])&&F.indexOf(O)===-1&&($[O]=y(A[O]));for(z=0,L=F.length;z<L;++z)if(i(O=F[z]))if(O in A)B.indexOf(O)!==-1&&(p&&m(C[O])&&Object.getPrototypeOf(C[O])!==t?$[O]=p(C[O]):$[O]=w(A[O],C[O]));else{if(g&&typeof C[O]>"u")continue;$[O]=y(C[O])}return $}function w(A,C){if(g&&typeof C>"u")return y(A);const $=Array.isArray(C),B=Array.isArray(A);return b(C)?C:m(A)?$&&B?v(A,C):$!==B?y(C):k(A,C):y(C)}function j(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return w(arguments[0],arguments[1])}let A;for(let C=0,$=arguments.length;C<$;++C)A=w(A,arguments[C]);return A}return s!=null&&s.all?j:w}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(gR);var dre=gR.exports;const fre=sl(dre);var pre=new Error("Element already at target scroll position"),hre=new Error("Scroll cancelled"),mre=Math.min,O1=Date.now,gre={left:M1("scrollLeft"),top:M1("scrollTop")};function M1(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=xre);var a=O1(),l=n[e],c=s.ease||yre,d=isNaN(s.duration)?350:+s.duration,f=!1;return l===r?i(pre,n[e]):requestAnimationFrame(p),u;function u(){f=!0}function p(m){if(f)return i(hre,n[e]);var g=O1(),b=mre(1,(g-a)/d),v=c(b);n[e]=v*(r-l)+l,b<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function yre(e){return .5*(1-Math.cos(Math.PI*e))}function xre(){}const wre=sl(gre);var yR={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(of,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})})(yR);var bre=yR.exports;const xR=sl(bre),vre=["top","right","bottom","left"],$1=["start","end"],D1=vre.reduce((e,t)=>e.concat(t,t+"-"+$1[0],t+"-"+$1[1]),[]),Lu=Math.min,Gl=Math.max,tg=Math.round,jh=Math.floor,xo=e=>({x:e,y:e}),kre={left:"right",right:"left",bottom:"top",top:"bottom"};function Sb(e,t,n){return Gl(e,Lu(t,n))}function Vu(e,t){return typeof e=="function"?e(t):e}function ra(e){return e.split("-")[0]}function wo(e){return e.split("-")[1]}function wR(e){return e==="x"?"y":"x"}function y0(e){return e==="y"?"height":"width"}function Da(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function x0(e){return wR(Da(e))}function bR(e,t,n){n===void 0&&(n=!1);const r=wo(e),s=x0(e),i=y0(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=rg(a)),[a,rg(a)]}function Sre(e){const t=rg(e);return[ng(e),t,ng(t)]}function ng(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const F1=["left","right"],z1=["right","left"],Nre=["top","bottom"],jre=["bottom","top"];function Cre(e,t,n){switch(e){case"top":case"bottom":return n?t?z1:F1:t?F1:z1;case"left":case"right":return t?Nre:jre;default:return[]}}function Ere(e,t,n,r){const s=wo(e);let i=Cre(ra(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(ng)))),i}function rg(e){const t=ra(e);return kre[t]+e.slice(t.length)}function _re(e){return{top:0,right:0,bottom:0,left:0,...e}}function vR(e){return typeof e!="number"?_re(e):{top:e,right:e,bottom:e,left:e}}function sg(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 B1(e,t,n){let{reference:r,floating:s}=e;const i=Da(t),a=x0(t),l=y0(a),c=ra(t),d=i==="y",f=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let m;switch(c){case"top":m={x:f,y:r.y-s.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:u};break;case"left":m={x:r.x-s.width,y:u};break;default:m={x:r.x,y:r.y}}switch(wo(t)){case"start":m[a]-=p*(n&&d?-1:1);break;case"end":m[a]+=p*(n&&d?-1:1);break}return m}async function Pre(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:p=!1,padding:m=0}=Vu(t,e),g=vR(m),v=l[p?u==="floating"?"reference":"floating":u],y=sg(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:c})),k=u==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},A=sg(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:w,strategy:c}):k);return{top:(y.top-A.top+g.top)/j.y,bottom:(A.bottom-y.bottom+g.bottom)/j.y,left:(y.left-A.left+g.left)/j.x,right:(A.right-y.right+g.right)/j.x}}const Are=50,Ire=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Pre},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:u}=B1(d,r,c),p=r,m=0;const g={};for(let b=0;b<i.length;b++){const v=i[b];if(!v)continue;const{name:y,fn:k}=v,{x:w,y:j,data:A,reset:C}=await k({x:f,y:u,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});f=w??f,u=j??u,g[y]={...g[y],...A},C&&m<Are&&(m++,typeof C=="object"&&(C.placement&&(p=C.placement),C.rects&&(d=C.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:f,y:u}=B1(d,p,c)),b=-1)}return{x:f,y:u,placement:p,strategy:s,middlewareData:g}},Tre=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:i,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:f=0}=Vu(e,t)||{};if(d==null)return{};const u=vR(f),p={x:n,y:r},m=x0(s),g=y0(m),b=await a.getDimensions(d),v=m==="y",y=v?"top":"left",k=v?"bottom":"right",w=v?"clientHeight":"clientWidth",j=i.reference[g]+i.reference[m]-p[m]-i.floating[g],A=p[m]-i.reference[m],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let $=C?C[w]:0;(!$||!await(a.isElement==null?void 0:a.isElement(C)))&&($=l.floating[w]||i.floating[g]);const B=j/2-A/2,F=$/2-b[g]/2-1,z=Lu(u[y],F),L=Lu(u[k],F),O=z,W=$-b[g]-L,M=$/2-b[g]/2+B,T=Sb(O,M,W),E=!c.arrow&&wo(s)!=null&&M!==T&&i.reference[g]/2-(M<O?z:L)-b[g]/2<0,D=E?M<O?M-O:M-W:0;return{[m]:p[m]+D,data:{[m]:T,centerOffset:M-T-D,...E&&{alignmentOffset:D}},reset:E}}});function Rre(e,t,n){return(e?[...n.filter(s=>wo(s)===e),...n.filter(s=>wo(s)!==e)]:n.filter(s=>ra(s)===s)).filter(s=>e?wo(s)===e||(t?ng(s)!==s:!1):!0)}const Lre=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:i,middlewareData:a,placement:l,platform:c,elements:d}=t,{crossAxis:f=!1,alignment:u,allowedPlacements:p=D1,autoAlignment:m=!0,...g}=Vu(e,t),b=u!==void 0||p===D1?Rre(u||null,m,p):p,v=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,k=b[y];if(k==null)return{};const w=bR(k,i,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==k)return{reset:{placement:b[0]}};const j=[v[ra(k)],v[w[0]],v[w[1]]],A=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:j}],C=b[y+1];if(C)return{data:{index:y+1,overflows:A},reset:{placement:C}};const $=A.map(z=>{const L=wo(z.placement);return[z.placement,L&&f?z.overflows.slice(0,2).reduce((O,W)=>O+W,0):z.overflows[0],z.overflows]}).sort((z,L)=>z[1]-L[1]),F=((s=$.filter(z=>z[2].slice(0,wo(z[0])?2:3).every(L=>L<=0))[0])==null?void 0:s[0])||$[0][0];return F!==l?{data:{index:y+1,overflows:A},reset:{placement:F}}:{}}}},Ore=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:i,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...v}=Vu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=ra(s),k=Da(l),w=ra(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),A=p||(w||!b?[rg(l)]:Sre(l)),C=g!=="none";!p&&C&&A.push(...Ere(l,b,g,j));const $=[l,...A],B=await c.detectOverflow(t,v),F=[];let z=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&F.push(B[y]),u){const M=bR(s,a,j);F.push(B[M[0]],B[M[1]])}if(z=[...z,{placement:s,overflows:F}],!F.every(M=>M<=0)){var L,O;const M=(((L=i.flip)==null?void 0:L.index)||0)+1,T=$[M];if(T&&(!(u==="alignment"?k!==Da(T):!1)||z.every(_=>Da(_.placement)===k?_.overflows[0]>0:!0)))return{data:{index:M,overflows:z},reset:{placement:T}};let E=(O=z.filter(D=>D.overflows[0]<=0).sort((D,_)=>D.overflows[1]-_.overflows[1])[0])==null?void 0:O.placement;if(!E)switch(m){case"bestFit":{var W;const D=(W=z.filter(_=>{if(C){const R=Da(_.placement);return R===k||R==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(R=>R>0).reduce((R,P)=>R+P,0)]).sort((_,R)=>_[1]-R[1])[0])==null?void 0:W[0];D&&(E=D);break}case"initialPlacement":E=l;break}if(s!==E)return{reset:{placement:E}}}return{}}}},Mre=new Set(["left","top"]);async function $re(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=ra(n),l=wo(n),c=Da(n)==="y",d=Mre.has(a)?-1:1,f=i&&c?-1:1,u=Vu(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),c?{x:m*f,y:p*d}:{x:p*d,y:m*f}}const Dre=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:i,placement:a,middlewareData:l}=t,c=await $re(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:a}}}}},Fre=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:k,y:w}=y;return{x:k,y:w}}},...d}=Vu(e,t),f={x:n,y:r},u=await i.detectOverflow(t,d),p=Da(ra(s)),m=wR(p);let g=f[m],b=f[p];if(a){const y=m==="y"?"top":"left",k=m==="y"?"bottom":"right",w=g+u[y],j=g-u[k];g=Sb(w,g,j)}if(l){const y=p==="y"?"top":"left",k=p==="y"?"bottom":"right",w=b+u[y],j=b-u[k];b=Sb(w,b,j)}const v=c.fn({...t,[m]:g,[p]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[m]:a,[p]:l}}}}}};function Vg(){return typeof window<"u"}function Uu(e){return kR(e)?(e.nodeName||"").toLowerCase():"#document"}function Hs(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function No(e){var t;return(t=(kR(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kR(e){return Vg()?e instanceof Node||e instanceof Hs(e).Node:!1}function zi(e){return Vg()?e instanceof Element||e instanceof Hs(e).Element:!1}function oa(e){return Vg()?e instanceof HTMLElement||e instanceof Hs(e).HTMLElement:!1}function H1(e){return!Vg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Hs(e).ShadowRoot}function fp(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Bi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function zre(e){return/^(table|td|th)$/.test(Uu(e))}function Ug(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Bre=/transform|translate|scale|rotate|perspective|filter/,Hre=/paint|layout|strict|content/,Rl=e=>!!e&&e!=="none";let Cx;function w0(e){const t=zi(e)?Bi(e):e;return Rl(t.transform)||Rl(t.translate)||Rl(t.scale)||Rl(t.rotate)||Rl(t.perspective)||!b0()&&(Rl(t.backdropFilter)||Rl(t.filter))||Bre.test(t.willChange||"")||Hre.test(t.contain||"")}function Wre(e){let t=rl(e);for(;oa(t)&&!Ou(t);){if(w0(t))return t;if(Ug(t))return null;t=rl(t)}return null}function b0(){return Cx==null&&(Cx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cx}function Ou(e){return/^(html|body|#document)$/.test(Uu(e))}function Bi(e){return Hs(e).getComputedStyle(e)}function Kg(e){return zi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rl(e){if(Uu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||H1(e)&&e.host||No(e);return H1(t)?t.host:t}function SR(e){const t=rl(e);return Ou(t)?e.ownerDocument?e.ownerDocument.body:e.body:oa(t)&&fp(t)?t:SR(t)}function Vf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=SR(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=Hs(s);if(i){const l=Nb(a);return t.concat(a,a.visualViewport||[],fp(s)?s:[],l&&n?Vf(l):[])}else return t.concat(s,Vf(s,[],n))}function Nb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function NR(e){const t=Bi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=oa(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=tg(n)!==i||tg(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function v0(e){return zi(e)?e:e.contextElement}function hu(e){const t=v0(e);if(!oa(t))return xo(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=NR(t);let a=(i?tg(n.width):n.width)/r,l=(i?tg(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Vre=xo(0);function jR(e){const t=Hs(e);return!b0()||!t.visualViewport?Vre:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ure(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Hs(e)?!1:t}function oc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=v0(e);let a=xo(1);t&&(r?zi(r)&&(a=hu(r)):a=hu(e));const l=Ure(i,n,r)?jR(i):xo(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,f=s.width/a.x,u=s.height/a.y;if(i){const p=Hs(i),m=r&&zi(r)?Hs(r):r;let g=p,b=Nb(g);for(;b&&r&&m!==g;){const v=hu(b),y=b.getBoundingClientRect(),k=Bi(b),w=y.left+(b.clientLeft+parseFloat(k.paddingLeft))*v.x,j=y.top+(b.clientTop+parseFloat(k.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,u*=v.y,c+=w,d+=j,g=Hs(b),b=Nb(g)}}return sg({width:f,height:u,x:c,y:d})}function qg(e,t){const n=Kg(e).scrollLeft;return t?t.left+n:oc(No(e)).left+n}function CR(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-qg(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Kre(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=No(r),l=t?Ug(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=xo(1);const f=xo(0),u=oa(r);if((u||!u&&!i)&&((Uu(r)!=="body"||fp(a))&&(c=Kg(r)),u)){const m=oc(r);d=hu(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const p=a&&!u&&!i?CR(a,c):xo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+p.x,y:n.y*d.y-c.scrollTop*d.y+f.y+p.y}}function qre(e){return Array.from(e.getClientRects())}function Yre(e){const t=No(e),n=Kg(e),r=e.ownerDocument.body,s=Gl(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Gl(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+qg(e);const l=-n.scrollTop;return Bi(r).direction==="rtl"&&(a+=Gl(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const W1=25;function Gre(e,t){const n=Hs(e),r=No(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const f=b0();(!f||f&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=qg(r);if(d<=0){const f=r.ownerDocument,u=f.body,p=getComputedStyle(u),m=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-u.clientWidth-m);g<=W1&&(i-=g)}else d<=W1&&(i+=d);return{width:i,height:a,x:l,y:c}}function Xre(e,t){const n=oc(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=oa(e)?hu(e):xo(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=s*i.x,d=r*i.y;return{width:a,height:l,x:c,y:d}}function V1(e,t,n){let r;if(t==="viewport")r=Gre(e,n);else if(t==="document")r=Yre(No(e));else if(zi(t))r=Xre(t,n);else{const s=jR(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return sg(r)}function ER(e,t){const n=rl(e);return n===t||!zi(n)||Ou(n)?!1:Bi(n).position==="fixed"||ER(n,t)}function Jre(e,t){const n=t.get(e);if(n)return n;let r=Vf(e,[],!1).filter(l=>zi(l)&&Uu(l)!=="body"),s=null;const i=Bi(e).position==="fixed";let a=i?rl(e):e;for(;zi(a)&&!Ou(a);){const l=Bi(a),c=w0(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||fp(a)&&!c&&ER(e,a))?r=r.filter(f=>f!==a):s=l,a=rl(a)}return t.set(e,r),r}function Qre(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Ug(t)?[]:Jre(t,this._c):[].concat(n),r],l=V1(t,a[0],s);let c=l.top,d=l.right,f=l.bottom,u=l.left;for(let p=1;p<a.length;p++){const m=V1(t,a[p],s);c=Gl(m.top,c),d=Lu(m.right,d),f=Lu(m.bottom,f),u=Gl(m.left,u)}return{width:d-u,height:f-c,x:u,y:c}}function Zre(e){const{width:t,height:n}=NR(e);return{width:t,height:n}}function ese(e,t,n){const r=oa(t),s=No(t),i=n==="fixed",a=oc(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=xo(0);function d(){c.x=qg(s)}if(r||!r&&!i)if((Uu(t)!=="body"||fp(s))&&(l=Kg(t)),r){const m=oc(t,!0,i,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else s&&d();i&&!r&&s&&d();const f=s&&!r&&!i?CR(s,l):xo(0),u=a.left+l.scrollLeft-c.x-f.x,p=a.top+l.scrollTop-c.y-f.y;return{x:u,y:p,width:a.width,height:a.height}}function Ex(e){return Bi(e).position==="static"}function U1(e,t){if(!oa(e)||Bi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return No(e)===n&&(n=n.ownerDocument.body),n}function _R(e,t){const n=Hs(e);if(Ug(e))return n;if(!oa(e)){let s=rl(e);for(;s&&!Ou(s);){if(zi(s)&&!Ex(s))return s;s=rl(s)}return n}let r=U1(e,t);for(;r&&zre(r)&&Ex(r);)r=U1(r,t);return r&&Ou(r)&&Ex(r)&&!w0(r)?n:r||Wre(e)||n}const tse=async function(e){const t=this.getOffsetParent||_R,n=this.getDimensions,r=await n(e.floating);return{reference:ese(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function nse(e){return Bi(e).direction==="rtl"}const rse={convertOffsetParentRelativeRectToViewportRelativeRect:Kre,getDocumentElement:No,getClippingRect:Qre,getOffsetParent:_R,getElementRects:tse,getClientRects:qre,getDimensions:Zre,getScale:hu,isElement:zi,isRTL:nse};function PR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function sse(e,t){let n=null,r;const s=No(e);function i(){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),i();const d=e.getBoundingClientRect(),{left:f,top:u,width:p,height:m}=d;if(l||t(),!p||!m)return;const g=jh(u),b=jh(s.clientWidth-(f+p)),v=jh(s.clientHeight-(u+m)),y=jh(f),w={rootMargin:-g+"px "+-b+"px "+-v+"px "+-y+"px",threshold:Gl(0,Lu(1,c))||1};let j=!0;function A(C){const $=C[0].intersectionRatio;if($!==c){if(!j)return a();$?a(!1,$):r=setTimeout(()=>{a(!1,1e-7)},1e3)}$===1&&!PR(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(A,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(A,w)}n.observe(e)}return a(!0),i}function K1(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=v0(e),f=s||i?[...d?Vf(d):[],...t?Vf(t):[]]:[];f.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const u=d&&l?sse(d,n):null;let p=-1,m=null;a&&(m=new ResizeObserver(y=>{let[k]=y;k&&k.target===d&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=m)==null||w.observe(t)})),n()}),d&&!c&&m.observe(d),t&&m.observe(t));let g,b=c?oc(e):null;c&&v();function v(){const y=oc(e);b&&!PR(b,y)&&n(),b=y,g=requestAnimationFrame(v)}return n(),()=>{var y;f.forEach(k=>{s&&k.removeEventListener("scroll",n),i&&k.removeEventListener("resize",n)}),u==null||u(),(y=m)==null||y.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const ise=Dre,ose=Lre,ase=Fre,lse=Ore,q1=Tre,cse=(e,t,n)=>{const r=new Map,s={platform:rse,...n},i={...s.platform,_c:r};return Ire(e,t,{...s,platform:i})};var use=typeof document<"u",dse=function(){},Jh=use?h.useLayoutEffect:dse;function ig(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(!ig(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 i=s[r];if(!(i==="_owner"&&e.$$typeof)&&!ig(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function AR(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Y1(e,t){const n=AR(e);return Math.round(t*n)/n}function _x(e){const t=h.useRef(e);return Jh(()=>{t.current=e}),t}function G1(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[f,u]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);ig(p,r)||m(r);const[g,b]=h.useState(null),[v,y]=h.useState(null),k=h.useCallback(_=>{_!==C.current&&(C.current=_,b(_))},[]),w=h.useCallback(_=>{_!==$.current&&($.current=_,y(_))},[]),j=i||g,A=a||v,C=h.useRef(null),$=h.useRef(null),B=h.useRef(f),F=c!=null,z=_x(c),L=_x(s),O=_x(d),W=h.useCallback(()=>{if(!C.current||!$.current)return;const _={placement:t,strategy:n,middleware:p};L.current&&(_.platform=L.current),cse(C.current,$.current,_).then(R=>{const P={...R,isPositioned:O.current!==!1};M.current&&!ig(B.current,P)&&(B.current=P,Mr.flushSync(()=>{u(P)}))})},[p,t,n,L,O]);Jh(()=>{d===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,u(_=>({..._,isPositioned:!1})))},[d]);const M=h.useRef(!1);Jh(()=>(M.current=!0,()=>{M.current=!1}),[]),Jh(()=>{if(j&&(C.current=j),A&&($.current=A),j&&A){if(z.current)return z.current(j,A,W);W()}},[j,A,W,z,F]);const T=h.useMemo(()=>({reference:C,floating:$,setReference:k,setFloating:w}),[k,w]),E=h.useMemo(()=>({reference:j,floating:A}),[j,A]),D=h.useMemo(()=>{const _={position:n,left:0,top:0};if(!E.floating)return _;const R=Y1(E.floating,f.x),P=Y1(E.floating,f.y);return l?{..._,transform:"translate("+R+"px, "+P+"px)",...AR(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:R,top:P}},[n,l,E.floating,f.x,f.y]);return h.useMemo(()=>({...f,update:W,refs:T,elements:E,floatingStyles:D}),[f,W,T,E,D])}const fse=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?q1({element:r.current,padding:s}).fn(n):{}:r?q1({element:r,padding:s}).fn(n):{}}}},X1=(e,t)=>{const n=ise(e);return{name:n.name,fn:n.fn,options:[e,t]}},pse=(e,t)=>{const n=ase(e);return{name:n.name,fn:n.fn,options:[e,t]}},hse=(e,t)=>{const n=lse(e);return{name:n.name,fn:n.fn,options:[e,t]}},mse=(e,t)=>{const n=ose(e);return{name:n.name,fn:n.fn,options:[e,t]}},gse=(e,t)=>{const n=fse(e);return{name:n.name,fn:n.fn,options:[e,t]}},yse={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},xse={beaconOptions:{offset:-18}},IR={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},wse={isFixed:!1,locale:IR,placement:"bottom"},bse={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},zt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},Ar={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Be={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},lo={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Lt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},vse="react-joyride-portal";function kse(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function nu(...e){return fre({all:!0,isMergeableObject:t=>!(!Gr.plainObject(t)||h.isValidElement(t))})(...e)}function TR(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Vo(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=jx(e);if(i)(i.includes("{current}")||i.includes("{total}"))&&r&&s&&(i=i.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(h.isValidElement(e)&&!Object.values(e.props).length&&TR(e.type)==="function")try{i=Vo(e.type({}),t)}catch{i=jx(n)}else i=jx(n);return i}function Tr(e,t,n,...r){if(!e)return;const s=new Date,i=`${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 ${i}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Sse(e,t){const n=kse(t);return{...e,...n}}function Uf(){}function Nse(e){return Object.keys(e)}function og(e,...t){if(!Gr.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 J1(e,...t){if(!Gr.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 jb(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(TR(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:s}=e.props;if(Gr.string(s)&&s.includes("{current}"))return h.cloneElement(e,{children:r(s)});if(Array.isArray(s))return h.cloneElement(e,{children:s.map(i=>typeof i=="string"?r(i):jb(i,t,n))});if(Gr.function(e.type)&&!Object.values(e.props).length)try{return jb(e.type({}),t,n)}catch{return e}return e}function Q1(e){return Nse(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function k0(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function Z1(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 S0(e){return e?e.getBoundingClientRect():null}function jse(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((i,a)=>i-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 ai(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 Cse(e,t,n){const r=S0(e),s=Ku(e),i=s?!s.isSameNode(bs()):!1,a=n??qu(e);let l=0,c=(r==null?void 0:r.top)??0;return i&&a?c=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!i&&!a&&(c+=l),s.isSameNode(bs())||(c+=bs().scrollTop)),Math.floor(c-t)}function Ku(e,t){if(!e)return bs();const n=xR(e);if(n){if(n.isSameNode(bs()))return t?document:bs();if(!(n.scrollHeight>n.offsetHeight))return bs()}return n}function Ese(e){const t=e.getBoundingClientRect(),n=bs(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function _se(e,t){if(!e)return 0;const n=xR(e)??bs(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=S0(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(RR(e)||Pse(e))){const f=e.getBoundingClientRect(),u=f.top-((s==null?void 0:s.top)??0),p=u+f.height,m=n.clientHeight,g=m*.2;u>=g&&p<=m-g?c=i:c=u+i}const d=Math.floor(c-t-r);return d<0?0:d}function Pse(e){return e.offsetParent!==document.body}function RR(e){if(!e)return!1;const t=Ku(e);return t?!t.isSameNode(bs()):!1}function qu(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?qu(e.parentNode,t):!1}function Ch(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 eC(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==Be.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Ku(s):bs(),l=a?!a.isSameNode(bs()):!1;return(r.isFixed||qu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function bs(){return document.scrollingElement??document.documentElement}function tC(e,t){const{duration:n,element:r}=t;let s=()=>{};const i=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;s=wre.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function Ase(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,i,a)=>s+s+i+i+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 LR={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Eh={...LR,borderRadius:4,padding:8};function Ise(e,t){const{styles:n}=e,r=nu(n??{},t.styles??{});let{width:s}=t;k0()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const i={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return nu({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...LR,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(${Ase(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:{...Eh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Eh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Eh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Eh,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:{...i,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 Tse=["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 N0(e,t){if(!t)return null;const n=nu(wse,J1(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=nu(yse,e.options??{},J1(t,...Tse)),s=Ise(e,{...n,...r}),i=nu(xse,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:nu(IR,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:Rse(r.spotlightPadding),styles:s}}function Rse(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 Lse(e,t,n){const{action:r}=t,s=n&&[zt.PREV,zt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function OR(e,t=!1){return Gr.plainObject(e)?e.target?!0:(Tr(t,"tour","target is missing from the step"),!1):(Tr(t,"tour","step must be an object"),!1)}function MR(e,t=!1){return Gr.array(e)?e.every(n=>OR(n,t)):(Tr(t,"tour","steps must be an array"),!1)}var Ose=class{constructor(e){Xn(this,"beaconPosition",null);Xn(this,"debug");Xn(this,"eventListeners",new Map);Xn(this,"listeners",new Set);Xn(this,"props");Xn(this,"snapshot");Xn(this,"state");Xn(this,"steps");Xn(this,"tooltipPosition",null);Xn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Xn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Xn(this,"getServerSnapshot",()=>this.snapshot);Xn(this,"getSnapshot",()=>this.snapshot);Xn(this,"getEventState",()=>og(this.snapshot,"positioned"));Xn(this,"getState",()=>og(this.snapshot,"positioned"));Xn(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&Tr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Be.BEACON_BEFORE||this.state.lifecycle===Be.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(i=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:i.onPosition;n&&n(t)});Xn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Xn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Xn(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)}});Xn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Xn(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,i=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:i,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,!p0(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=Gr.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,Gr.number(t)&&Tr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Gr.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&Tr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:zt.INIT,controlled:s,index:i,lifecycle:Be.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Lt.READY:Lt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Lt.WAITING&&e.size>0?{...e,status:Lt.RUNNING}:e}getStep(e){return N0(this.props,this.steps[e??this.state.index])}};function Mse(e){return new Ose(e)}function nC(e,t){return Math.min(Math.max(e,0),t)}function $se(e,t,n){const r=h.useRef(t),s=h.useRef(n);return r.current=t,s.current=n,h.useMemo(()=>{const i=()=>e.current.getSnapshot();return{close:(v=null)=>{const{index:y,status:k}=i();k===Lt.RUNNING&&e.current.updateState({action:zt.CLOSE,index:y+1,origin:v,lifecycle:Be.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:v=>{const{controlled:y,size:k,status:w}=i();if(y){Tr(r.current,"tour","go() is not supported in controlled mode");return}w===Lt.RUNNING&&e.current.updateState({action:zt.GO,index:v,lifecycle:Be.COMPLETE,positioned:!1,scrolling:!1,status:v<k?w:Lt.FINISHED,waiting:!1})},info:()=>og(e.current.getSnapshot(),"positioned"),next:v=>{const{index:y,size:k,status:w}=i();w===Lt.RUNNING&&e.current.updateState({action:zt.NEXT,index:nC(y+1,k),lifecycle:Be.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:v}=i();v===Lt.RUNNING&&e.current.updateState({action:zt.UPDATE,lifecycle:Be.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:v=>{const{index:y,size:k,status:w}=i();w===Lt.RUNNING&&e.current.updateState({action:zt.PREV,index:nC(y-1,k),lifecycle:Be.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},reset:(v=!1)=>{const{controlled:y}=i();if(y){Tr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:zt.RESET,index:0,lifecycle:Be.INIT,positioned:!1,scrolling:!1,status:v?Lt.RUNNING:Lt.READY,waiting:!1})},skip:v=>{const{status:y}=i();y===Lt.RUNNING&&e.current.updateState({action:zt.SKIP,lifecycle:Be.COMPLETE,origin:v,positioned:!1,scrolling:!1,status:Lt.SKIPPED,waiting:!1})},start:v=>{const{index:y,size:k}=i();s.current(),e.current.updateState({action:zt.START,index:Gr.number(v)?v:y,lifecycle:Be.INIT,positioned:!1,scrolling:!1,status:k?Lt.RUNNING:Lt.WAITING,waiting:!1},!0)},stop:(v=!1)=>{const{index:y,status:k}=i();[Lt.FINISHED,Lt.SKIPPED].includes(k)||e.current.updateState({action:zt.STOP,index:y+(v?1:0),lifecycle:Be.COMPLETE,positioned:!1,scrolling:!1,status:Lt.PAUSED,waiting:!1})}}},[e])}const Dse=new Set(["origin","positioned"]);function Fse(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return Tr(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const i=n.current;if(n.current=s,!i)return;const a={};let l=!1;for(const c of Object.keys(s))s[c]!==i[c]&&!Dse.has(c)&&(a[c]={from:i[c],to:s[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||Tr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function zse(e,t,n){const r=h.useRef(e),s=h.useRef(t);return r.current=e,s.current=t,h.useCallback((i,a,l)=>{var d;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:i,...l};(d=r.current)==null||d.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Ia(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],i=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(i):s===r&&i!==r},previous:t}}function Bse(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:c}=e,{action:d,index:f,lifecycle:u,positioned:p,scrolling:m,size:g,status:b}=a,v=uR(l)??null,y=h.useRef(null),k=h.useRef(i),w=h.useRef(a),j=h.useRef(s),A=h.useRef(l),C=h.useRef(v),$=h.useRef(n),B=h.useRef(null),F=h.useRef(null),z=h.useRef(null);k.current=i,w.current=a,j.current=s,A.current=l,C.current=v,$.current=n;const L=()=>{B.current&&(clearInterval(B.current),B.current=null),F.current=null,z.current&&(z.current.cancel(),z.current=null)};h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:O}=Ia(w.current,j.current);(O("action",[zt.NEXT,zt.PREV,zt.SKIP,zt.CLOSE])||y.current===zt.CLOSE&&d===zt.START)&&(y.current=d)},[d]),h.useEffect(()=>{if(!j.current)return()=>{L()};const{hasChanged:O}=Ia(w.current,j.current),W=A.current;if(O("index")&&L(),b!==Lt.RUNNING||!W||u!==Be.INIT)return()=>{L()};const{hasChangedTo:M}=Ia(w.current,j.current);M("status",Lt.RUNNING)&&[Lt.IDLE,Lt.READY,Lt.PAUSED].includes(j.current.status)&&r(Ar.TOUR_START,W),c.current.cleanupPositionData();const{debug:T}=k.current;if(W.before&&!z.current){Tr(T,`step:${f}`,"before()",W),z.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(Ar.STEP_BEFORE_HOOK,W,{action:y.current??w.current.action});const E=()=>{z.current=null,c.current.updateState({action:y.current??w.current.action,waiting:!1,lifecycle:Be.READY})},D=new AbortController,_=W.beforeTimeout;z.current={cancel:()=>D.abort()};const R=_?setTimeout(()=>{D.signal.aborted||(Tr(T,`step:${f}`,"before()","timed out",`${_}ms`),D.abort(),t(W,"before_hook"),r(Ar.ERROR,W,{error:new Error("Step before hook timed out")}),E())},_):null;W.before({...c.current.getState(),action:y.current??c.current.getState().action,step:W}).then(()=>{D.signal.aborted||(R&&clearTimeout(R),E())}).catch(P=>{D.signal.aborted||(R&&clearTimeout(R),t(W,"before_hook"),r(Ar.ERROR,W,{error:P instanceof Error?P:new Error(String(P))}),E())})}else if(!z.current){B.current&&F.current!==W.target&&L();const E=ai(W.target);if(E&&Ch(E))L(),c.current.updateState({action:y.current??zt.UPDATE,lifecycle:Be.READY,waiting:!1});else if(W.targetWaitTimeout===0)c.current.updateState({action:y.current??zt.UPDATE,lifecycle:Be.READY,waiting:!1});else if(!B.current){const{targetWaitTimeout:D}=W,_=Date.now();F.current=W.target,Tr(T,`step:${f}`,"polling","started",`${D}ms`),c.current.updateState({waiting:!0}),B.current=setInterval(()=>{const R=ai(W.target),P=Date.now()-_,G=P>=D;(R&&Ch(R)||G)&&(Tr(T,`step:${f}`,"polling",R&&Ch(R)?"found":"timed out",`${P}ms`),L(),c.current.updateState({action:y.current??zt.UPDATE,lifecycle:Be.READY,waiting:!1}))},100)}}return()=>{L()}},[t,r,f,u,b,c]),h.useEffect(()=>{if(!j.current)return;const{hasChanged:O,hasChangedTo:W,previous:M}=Ia(w.current,j.current),T=A.current;if(!T)return;const E=ai(T.target),D=!!E;if(D&&Ch(E)){if(W("lifecycle",Be.READY)&&M.lifecycle===Be.INIT&&r(Ar.STEP_BEFORE,T,{action:y.current??w.current.action}),W("lifecycle",Be.READY)){const _=w.current,R=Lse(T,_,k.current.continuous)?Be.TOOLTIP:Be.BEACON,P=ai(T.scrollTarget??T.spotlightTarget??T.target),G=eC({isFirstStep:_.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:T,target:P,targetLifecycle:R}),Z=R===Be.TOOLTIP?Be.TOOLTIP_BEFORE:Be.BEACON_BEFORE;Tr(k.current.debug,`step:${f}`,"scroll",G?"needed":"skipped"),c.current.updateState({action:zt.UPDATE,lifecycle:Z,scrolling:G})}}else if(w.current.status===Lt.RUNNING&&u!==Be.INIT&&u!==Be.COMPLETE&&O("lifecycle")){Tr(k.current.debug,`step:${f}`,D?"Target not visible":"Target not mounted",T),t(T,"target_not_found"),r(Ar.TARGET_NOT_FOUND,T);const _=w.current;_.controlled||c.current.updateState({action:zt.UPDATE,index:_.index+(_.action===zt.PREV?-1:1),lifecycle:Be.INIT})}},[t,r,f,u,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:O,previous:W}=Ia(w.current,j.current),M=A.current,T=C.current;if(M&&O("lifecycle",Be.TOOLTIP_BEFORE)&&W.lifecycle===Be.BEACON){const _=ai(M.scrollTarget??M.spotlightTarget??M.target);if(eC({isFirstStep:w.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:_,targetLifecycle:Be.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const E=u===Be.BEACON_BEFORE||u===Be.TOOLTIP_BEFORE;if(M&&E&&!m){const _=u===Be.TOOLTIP_BEFORE?Be.TOOLTIP:Be.BEACON;c.current.updateState({action:zt.UPDATE,lifecycle:_})}M&&O("lifecycle",Be.BEACON)&&r(Ar.BEACON,M),M&&O("lifecycle",Be.TOOLTIP)&&r(Ar.TOOLTIP,M);const D=w.current;if((D.status===Lt.RUNNING||D.controlled&&D.status===Lt.PAUSED&&M)&&T&&O("lifecycle",Be.COMPLETE)&&W.lifecycle===Be.TOOLTIP&&(r(Ar.STEP_AFTER,T,{action:y.current??zt.UPDATE,index:W.index??D.index,lifecycle:D.lifecycle}),T.after)){r(Ar.STEP_AFTER_HOOK,T,{action:y.current??zt.UPDATE,index:W.index??D.index,lifecycle:D.lifecycle});try{T.after({...c.current.getState(),action:y.current??zt.UPDATE,index:W.index??D.index,lifecycle:D.lifecycle,step:T})}catch{}}},[r,u,p,m,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:O,previous:W}=Ia(w.current,j.current),M=A.current,T=C.current;g&&!M&&u===Be.INIT&&c.current.updateState({action:zt.UPDATE,lifecycle:Be.COMPLETE,status:Lt.FINISHED}),!w.current.controlled&&b===Lt.RUNNING&&O("lifecycle",Be.COMPLETE)&&f<g&&c.current.updateState({action:zt.UPDATE,lifecycle:Be.INIT}),O("lifecycle",Be.COMPLETE)&&f>=g&&c.current.updateState({action:zt.UPDATE,lifecycle:Be.COMPLETE,status:Lt.FINISHED});const E=M??T??N0(k.current,k.current.steps[f-1]);if(E&&O("status",[Lt.FINISHED,Lt.SKIPPED])){let D;M?D=f:T?D=W.index??f:D=f-1,r(Ar.TOUR_END,E,{index:D}),w.current.controlled||$.current.reset(),y.current=null}M&&O("action",zt.STOP)&&(y.current=null,r(Ar.TOUR_STATUS,M)),M&&O("action",zt.RESET)&&(r(Ar.TOUR_STATUS,M),y.current=null)},[d,r,f,u,g,b,c])}function Hse({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:c,steps:d}=n,f=h.useRef(void 0),u=h.useRef(r),p=h.useRef(e);u.current=r,p.current=e,h.useEffect(()=>{const m=f.current;if(f.current=n,!m||n===m)return;const{hasChanged:g}=Ia(n,m);if(p0(m.steps,d)||(MR(d,i)?s.current.setSteps(d):(Tr(i,"tour","Steps are not valid",d),t(Ar.ERROR,d[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&p.current.start(c??a):p.current.stop();else if(Gr.number(c)&&g("stepIndex")){const b=Gr.number(m.stepIndex)&&m.stepIndex<c?zt.NEXT:zt.PREV;[Lt.FINISHED,Lt.SKIPPED].includes(u.current.status)||s.current.updateState({action:b,index:c,lifecycle:Be.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,d,s])}function Wse(e,t){var l,c,d,f;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:i}=t;if(i.scrollTarget||i.spotlightTarget)return Math.max(0,e);let a=e-i.spotlightPadding.top;if(r===Be.BEACON_BEFORE&&(n!=null&&n.placement)){const u=Vse(n);["bottom"].includes(n.placement)||(a+=Math.floor(u-s))}else if(r===Be.TOOLTIP_BEFORE){const{placement:u}=i;if(u==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,m=(c=i.floatingOptions)!=null&&c.hideArrow?0:i.arrowSize,g=i.offset+i.spotlightPadding.top+m;a-=p+g}else if(u==="left"||u==="right"){const p=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,m=((f=ai(i.target))==null?void 0:f.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+m/2-p/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function Vse(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 Use({emitEvent:e,previousState:t,props:n,state:r,step:s,store:i}){const{index:a,lifecycle:l,positioned:c,scrolling:d,status:f}=r,u=h.useRef(null),p=h.useRef(r),m=h.useRef(t),g=h.useRef(n),b=h.useRef(s);p.current=r,m.current=t,g.current=n,b.current=s,h.useEffect(()=>()=>{var v;(v=u.current)==null||v.call(u)},[]),h.useEffect(()=>{var A;if(!m.current||!b.current)return;const{hasChangedTo:v}=Ia(p.current,m.current),y=b.current,{debug:k}=g.current,{scrollDuration:w}=y,j=l===Be.BEACON_BEFORE||l===Be.TOOLTIP_BEFORE;if(f===Lt.RUNNING&&j&&d&&v("positioned",!0)){const C=ai(y.scrollTarget??y.spotlightTarget??y.target),$=i.current.getPositionData("beacon"),B=Ku(C),F=B?!B.isSameNode(bs()):!1;(A=u.current)==null||A.call(u),(async()=>{if(F&&!qu(B)){const D=bs(),_=Ese(B),R={initial:D.scrollTop,target:_,element:D,duration:w};e(Ar.SCROLL_START,y,{scroll:R});const{cancel:P,promise:G}=tC(_,{element:D,duration:w});u.current=P,await G,e(Ar.SCROLL_END,y,{scroll:R})}const L=Math.floor(_se(C,y.scrollOffset))||0,O=F?L:Wse(L,{beaconPosition:$,lifecycle:l,scrollOffset:y.scrollOffset,step:y});Tr(k,`step:${a}`,"scroll",F?"custom":"document",`${L} → ${O}`);const W=B,M={initial:W.scrollTop,target:O,element:W,duration:w};e(Ar.SCROLL_START,y,{scroll:M});const{cancel:T,promise:E}=tC(O,{element:W,duration:w});u.current=T,await E,e(Ar.SCROLL_END,y,{scroll:M}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,d,f,i])}function Kse(e){const t=_ne(()=>Sse(bse,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=h.useRef(Mse(t)),d=JP.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[f,u]=h.useState([]),p=h.useCallback((A,C)=>{u($=>[...$,{reason:C,step:A}])},[]),m=h.useCallback(()=>{u([])},[]);Fse(c,n);const g=$se(c,n,m),b=zse(s,g,c),{index:v,size:y,status:k}=d,w=uR(d),j=h.useMemo(()=>N0(t,l[v]),[v,t,l]);return Pne(()=>{i&&y&&MR(l,n)&&g.start(a??r)}),Ene(()=>{i&&y&&k===Lt.IDLE&&c.current.updateState({status:Lt.READY})},[i,y,k]),Hse({controls:g,emitEvent:b,props:t,state:d,store:c}),Bse({addFailure:p,controls:g,emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),Use({emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),{controls:g,failures:f,mergedProps:t,state:d,step:j,store:c}}function qse(e){const[t,n]=h.useState(null);return h.useEffect(()=>{let r=null,s=!1;if(e)if(Gr.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=vse,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Yse={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Gse({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Uf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
209
+ @keyframes joyride-loader-spin {
210
+ to { transform: rotate(360deg); }
211
+ }
212
+ `)),document.head.appendChild(c),()=>{const d=document.getElementById("joyride-loader-animation");d!=null&&d.parentNode&&d.parentNode.removeChild(d)}},[r,e]),n===null)return null;const{height:s,width:i,...a}=t.styles.loader;let l;if(n){const c=n;l=at.createElement(c,{step:t})}else l=at.createElement("div",{style:{...Yse,height:s,width:i,borderTopColor:t.primaryColor}});return at.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Xse={height:0,isFixed:!1,left:0,top:0,width:0};function _d(e,t){const n=ai(e);if(!n)return Xse;const r=S0(n),s=qu(n),i=Cse(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:i,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function Jse(e,t,n){const[r,s]=h.useState(()=>_d(e,t)),i=h.useRef(void 0),a=h.useRef(null),l=h.useRef(n),c=h.useRef(null),d=h.useCallback(()=>{clearTimeout(i.current),i.current=window.setTimeout(()=>{s(u=>{const p=_d(e,t);return u.top===p.top&&u.left===p.left&&u.width===p.width&&u.height===p.height&&u.isFixed===p.isFixed?u:p})},100)},[e,t]);h.useEffect(()=>{let u=null;const p=g=>{a.current=Ku(g,!0),a.current&&a.current.addEventListener("scroll",d,{passive:!0}),window.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(d),c.current.observe(g)),s(_d(e,t))},m=ai(e);return m?p(m):(u=new MutationObserver(()=>{const g=ai(e);g&&(u==null||u.disconnect(),u=null,p(g))}),u.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;u==null||u.disconnect(),a.current&&a.current.removeEventListener("scroll",d),window.removeEventListener("scroll",d),window.removeEventListener("resize",d),(g=c.current)==null||g.disconnect(),clearTimeout(i.current)}},[e,t,d]),h.useEffect(()=>{l.current&&!n&&s(_d(e,t)),l.current=n},[n,e,t]);let f=r;return l.current&&!n&&(f=_d(e,t)),f}function Qse(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function rC(e,t,n,r,s){if(n<=0||r<=0)return"";const i=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+i} ${t}`;return a+=`H${e+n-i}`,a+=`A${i} ${i} 0 0 1 ${e+n} ${t+i}`,a+=`V${t+r-i}`,a+=`A${i} ${i} 0 0 1 ${e+n-i} ${t+r}`,a+=`H${e+i}`,a+=`A${i} ${i} 0 0 1 ${e} ${t+r-i}`,a+=`V${t+i}`,a+=`A${i} ${i} 0 0 1 ${e+i} ${t}Z`,a}const Zse=[Be.BEACON_BEFORE,Be.BEACON];function eie(e){var E,D;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:c,scrolling:d,spotlightPadding:f,spotlightRadius:u,spotlightTarget:p,styles:m,target:g,waiting:b}=e,v=Ane(),y=Jse(p??g,f,d||b),k=h.useRef(null),w=(s===Be.TOOLTIP||s===Be.TOOLTIP_BEFORE)&&l!=="center",[j,A]=h.useState(!1),C=c?(E=k.current)==null?void 0:E.offsetParent:null,$=(C==null?void 0:C.clientWidth)??v.width,B=(C==null?void 0:C.clientHeight)??jse()??v.height,F=((D=m.overlay)==null?void 0:D.backgroundColor)??"rgba(0, 0, 0, 0.5)",z=h.useMemo(()=>{const{backgroundColor:_,mixBlendMode:R,...P}=m.overlay;return{height:B,pointerEvents:"none",...P}},[B,m.overlay]),L=w&&!d&&!b;h.useEffect(()=>{L?requestAnimationFrame(()=>A(!0)):A(!1)},[L]);const O=n&&Zse.includes(s),W=!n&&s!==Be.TOOLTIP;if(r||!b&&(O||W))return null;let M="";if(L)if(c&&C){const _=ai(p??g);if(_){const R=Z1(_),P=Z1(C);M=rC(R.left-P.left-f.left,R.top-P.top-f.top,_.offsetWidth+f.left+f.right,_.offsetHeight+f.top+f.bottom,u)}}else M=rC(y.left,y.top,y.width,y.height,u);const T=Qse($,B,M);return at.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:z},at.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:B,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:$}},at.createElement("path",{d:T,fill:F,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&at.createElement("path",{d:M,fill:F,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(m.spotlight).length>0&&at.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...m.spotlight})))}function $R(e){const{children:t,element:n}=e;return n?Mr.createPortal(t,n):null}const tie='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function nie(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return Uf;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(tie)],{shiftKey:l}=i;if(!a.length)return;i.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 i=e.querySelector(t);i&&(s=setTimeout(()=>{i.focus({preventScroll:!0})},100))}return()=>{var i;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(i=n.current)==null||i.focus({preventScroll:!0})}},[e,t])}function Go(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 rie(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...Go(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...Go(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...Go(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...Go(e,t,n)};default:return null}}function sie(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...Go(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...Go(e,r,n)};case"left":return{right:-n,top:t.y??0,...Go(e,r,n)};case"right":return{left:-n,top:t.y??0,...Go(e,r,n)};default:return{}}}function iie({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!Go(r,n,i))return null;c=at.createElement("span",{style:{flexShrink:0}},at.createElement(l,{base:n,placement:r,size:i}))}else{const d=rie(r,n,i);if(!d)return null;c=at.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},at.createElement("polygon",{fill:"currentColor",points:d.points}))}return at.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...sie(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function oie(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:c,size:d,step:f,styles:u}=e,p=h.useRef(null),m=!!t;h.useEffect(()=>{if(m||document.getElementById("joyride-beacon-animation"))return Uf;const v=document.createElement("style");v.id="joyride-beacon-animation",a&&v.setAttribute("nonce",a),v.appendChild(document.createTextNode(`
213
+ @keyframes joyride-beacon-inner {
214
+ 20% {
215
+ opacity: 0.9;
216
+ }
217
+
218
+ 90% {
219
+ opacity: 0.7;
220
+ }
221
+ }
222
+
223
+ @keyframes joyride-beacon-outer {
224
+ 0% {
225
+ transform: scale(1);
226
+ }
227
+
228
+ 45% {
229
+ opacity: 0.7;
230
+ transform: scale(0.75);
231
+ }
232
+
233
+ 100% {
234
+ opacity: 0.9;
235
+ transform: scale(1);
236
+ }
237
+ }
238
+ `)),document.head.appendChild(v);const y=setTimeout(()=>{Gr.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(y);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[m,a,c]);const g=Vo(i.open);let b;if(t){const v=t;b=at.createElement(v,{continuous:n,index:r,isLastStep:s,size:d,step:f})}else b=at.createElement("span",{style:u.beacon},at.createElement("span",{style:u.beaconOuter}),at.createElement("span",{style:u.beaconInner}));return at.createElement("button",{ref:p,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:u.beaconWrapper,title:g,type:"button"},b)}function aie({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return at.createElement("button",{style:i,type:"button",...t},at.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"},at.createElement("g",null,at.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 lie(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:c}=e,{buttons:d,content:f,styles:u,title:p}=l,m={};d.includes("primary")&&(m.primary=at.createElement("button",{"data-testid":"button-primary",style:u.buttonPrimary,type:"button",...i})),d.includes("skip")&&!s&&(m.skip=at.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:u.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(m.back=at.createElement("button",{"data-testid":"button-back",style:u.buttonBack,type:"button",...t})),m.close=d.includes("close")&&at.createElement(aie,{"data-testid":"button-close",styles:u.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Vo(f),"aria-describedby":"joyride-tooltip-content"};return at.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:u.tooltip,...c,...g},at.createElement("div",{style:u.tooltipContainer},p&&at.createElement("h4",{id:"joyride-tooltip-title",style:u.tooltipTitle},p),at.createElement("div",{id:"joyride-tooltip-content",style:u.tooltipContent},f)),d.some(b=>b==="back"||b==="primary"||b==="skip")&&at.createElement("div",{style:u.tooltipFooter},at.createElement("div",{style:u.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function cie(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(lo.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(lo.BUTTON_CLOSE):n.close(lo.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(lo.BUTTON_PRIMARY);return}n.next(lo.BUTTON_PRIMARY)},f=y=>{y.preventDefault(),n.skip(lo.BUTTON_SKIP)},u=()=>{const{back:y,close:k,last:w,next:j,nextWithProgress:A,skip:C}=a.locale,$=Vo(y),B=Vo(k),F=Vo(w),z=Vo(j),L=Vo(C);let O=k,W=B;if(t){if(O=j,W=z,a.showProgress&&!s){const M=Vo(A,{step:r+1,steps:i});O=jb(A,r+1,i),W=M}s&&(O=w,W=F)}return{backProps:{"aria-label":$,children:y,"data-action":"back",onClick:l,role:"button",title:$},closeProps:{"aria-label":B,children:k,"data-action":"close",onClick:c,role:"button",title:B},primaryProps:{"aria-label":W,children:O,"data-action":"primary",onClick:d,role:"button",title:W},skipProps:{"aria-label":L,children:C,"data-action":"skip",onClick:f,role:"button",title:L},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:m,tooltipComponent:g,...b}=a;let v;if(g){const y=g;v=at.createElement(y,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b})}else v=at.createElement(lie,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b});return v}function uie(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function die(e,t,n){var r,s;return e?[mse()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[hse({crossAxis:!1,fallbackPlacements:uie(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function fie(e){var R,P,G,Z,V;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:c,setTooltipRef:d,shouldScroll:f,size:u,step:p,target:m,updateState:g}=e,b=h.useRef(null),v=h.useRef({}),y=h.useRef({}),k=p.placement==="center",w=p.placement==="auto",j=h.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),A=h.useMemo(()=>RR(m)?Ku(m):void 0,[m]),C=h.useMemo(()=>qu(m),[m]),$=h.useMemo(()=>A?{boundary:A,rootBoundary:"viewport"}:{},[A]),B=k||w?"bottom":p.placement,F=k?"fixed":((R=p.floatingOptions)==null?void 0:R.strategy)??(p.isFixed||C?"fixed":"absolute"),z=h.useMemo(()=>{var se,ue,fe,ge;return k?[{name:"center",fn:({rects:ae})=>({x:(window.innerWidth-ae.floating.width)/2,y:(window.innerHeight-ae.floating.height)/2})}]:[X1(({placement:ae})=>{var we;let ve="right";ae.startsWith("top")?ve="top":ae.startsWith("bottom")?ve="bottom":ae.startsWith("left")&&(ve="left");const _e=p.spotlightTarget?0:p.spotlightPadding[ve];return p.offset+_e+((we=p.floatingOptions)!=null&&we.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...die(w,p,B),pse({padding:10,...$,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(fe=p.floatingOptions)!=null&&fe.hideArrow?[]:[gse({element:b,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ge=p.floatingOptions)==null?void 0:ge.middleware)??[]]},[k,p,w,B,$]),L=G1({...k?{elements:{reference:j}}:{},placement:B,strategy:F,middleware:z}),O=G1({strategy:F,placement:p.beaconPlacement??(w||k?"bottom":p.placement),middleware:h.useMemo(()=>{var se,ue;return[X1(((ue=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:ue.offset)??-18)]},[(G=(P=p.floatingOptions)==null?void 0:P.beaconOptions)==null?void 0:G.offset]),whileElementsMounted:K1});y.current=L.middlewareData,v.current=O.middlewareData,h.useEffect(()=>{var fe;const{floating:se,reference:ue}=L.elements;if(!(!ue||!se||s!==Be.TOOLTIP))return K1(ue,se,L.update,(fe=p.floatingOptions)==null?void 0:fe.autoUpdate)},[s,L.update,(Z=p.floatingOptions)==null?void 0:Z.autoUpdate,p.target,L.elements]),h.useEffect(()=>{!k&&m&&L.refs.setReference(m),m&&O.refs.setReference(m)},[O.refs,k,m,L.refs]),h.useEffect(()=>{L.isPositioned&&c("tooltip",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:y.current})},[c,L.isPositioned,L.placement,L.x,L.y]),h.useEffect(()=>{O.isPositioned&&c("beacon",{placement:O.placement,x:O.x??0,y:O.y??0,middlewareData:v.current})},[c,O.isPositioned,O.placement,O.x,O.y]);const W=p.zIndex+100,M=h.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:Be.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),T=h.useCallback(se=>{se&&(L.refs.setFloating(se),d(se))},[L.refs,d]),{arrow:E,floater:D}=p.styles;let _=null;if(s===Be.TOOLTIP||s===Be.TOOLTIP_BEFORE){const se=Q1({...D,...L.floatingStyles,zIndex:W,opacity:a&&L.isPositioned?1:0,...!a&&{transition:"none"}});_=at.createElement("div",{ref:T,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},at.createElement(cie,{continuous:t,controls:n,index:r,isLastStep:r+1===u,size:u,step:p}),!k&&!((V=p.floatingOptions)!=null&&V.hideArrow)&&at.createElement(iie,{arrowComponent:p.arrowComponent,arrowRef:b,base:p.arrowBase,placement:L.placement,position:L.middlewareData.arrow,size:p.arrowSize,styles:E}))}else(s===Be.BEACON||s===Be.BEACON_BEFORE)&&(_=at.createElement("div",{ref:O.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:Q1({...O.floatingStyles,zIndex:W})},at.createElement(oie,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===u,locale:p.locale,nonce:i,onInteract:M,shouldFocus:f,size:u,step:p,styles:p.styles})));return at.createElement($R,{element:l},_)}function pie(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:c,size:d,step:f,updateState:u}=e,[p,m]=h.useState(null);nie(f.disableFocusTrap?null:p,"[data-action=primary]");const g=ai(f.target),b=s===Be.TOOLTIP;return!OR(f)||!Gr.domElement(g)?null:at.createElement(fie,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:b,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:d,step:f,target:g,updateState:u})}function hie({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:d}=t,f=qse(c),{index:u,lifecycle:p,status:m}=n,g=m===Lt.RUNNING,[b,v]=h.useState(!1),y=h.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?k===0?v(!0):y.current=setTimeout(()=>{v(!0)},k):v(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[k,n.waiting]),h.useEffect(()=>{if(!g)return;const A=C=>{!r||p!==Be.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(lo.KEYBOARD):e.close(lo.KEYBOARD))};return document.body.addEventListener("keydown",A,{passive:!0}),()=>{document.body.removeEventListener("keydown",A)}},[e,g,p,r]);const w=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(lo.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(lo.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const j=n.action===zt.START&&!r.skipBeacon&&r.placement!=="center";return at.createElement(at.Fragment,null,p!==Be.INIT&&at.createElement(pie,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:f,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(u!==0||d),step:r,updateState:s.current.updateState}),at.createElement($R,{element:f},at.createElement(at.Fragment,null,b&&at.createElement(Gse,{nonce:l,step:r}),!j&&at.createElement(eie,{...r,continuous:i,lifecycle:p,onClickOverlay:w,portalElement:c?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function mie(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=Kse(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>og(s,"positioned"),[s]),step:i,Tour:k0()?at.createElement(hie,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function gie(e){const{Tour:t}=mie(e);return t}function yie(e){return k0()?at.createElement(gie,e):null}function xie(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 wie(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function bie(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Px="af:onboarding";function vie({page:e,hasNodes:t=!1}){const{t:n}=vn(),[r,s]=h.useState(!1),[i,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?xie(n):t?wie(n):bie(n),[e,t,n]);return h.useEffect(()=>{const d=localStorage.getItem(Px);console.log("[Onboarding] localStorage:",d);const f=d?JSON.parse(d):{};if(console.log("[Onboarding] progress:",f,"page:",e),f.completed||f[e]){console.log("[Onboarding] skipped - already done"),s(!1),a([]);return}console.log("[Onboarding] starting with steps:",c),a(c),s(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const d=f=>{var g;const u=f.target.closest("button");if(!u||!u.closest(".react-joyride__tooltip"))return;const m=(g=u.textContent)==null?void 0:g.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const b=localStorage.getItem(Px)||"{}",v=JSON.parse(b);m===n("onboarding:skip")?(v.projects=!0,v.flow=!0,v.completed=!0):v[e]=!0,localStorage.setItem(Px,JSON.stringify(v)),a([]),s(!1),e==="projects"&&(m===n("onboarding:done")||m===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const y=document.querySelector(".af-create-btn");y&&y.click()},500))}};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[r,e,n]),!r||i.length===0?null:o.jsx(yie,{ref:l,steps:i,run:r,continuous:!0,showSkipButton:!0,showProgress:i.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})}function kie(){const{navigate:e,path:t}=ko(),[n,r]=h.useState([]),[s,i]=h.useState(!1);if(h.useEffect(()=>{let f=!1;const u=async()=>{try{const m=await fetch("/api/pipeline-recent-runs");if(!m.ok)return;const g=await m.json();if(f)return;const b=Array.isArray(g.runs)?g.runs:[];r(b.filter(v=>v&&v.status==="running"))}catch{}};u();const p=window.setInterval(u,3e3);return()=>{f=!0,window.clearInterval(p)}},[]),n.length===0)return null;const a=f=>{const u=new URLSearchParams({flowId:f.flowId,flowSource:f.flowSource||"workspace"});e(`/flow?${u.toString()}`),i(!1)},l=t==="/flow"?new URLSearchParams(window.location.search):null,c=(l==null?void 0:l.get("flowId"))||"",d=n.length===1;return o.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!d&&o.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>i(!1),children:n.map(f=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(f.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(f),title:`${f.flowId} · ${f.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:f.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:f.runId.slice(0,12)})]},`${f.flowId}:${f.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):i(f=>!f),title:d?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[o.jsx("span",{className:"af-run-indicator__pulse"}),o.jsx("span",{className:"af-run-indicator__label",children:d?n[0].flowId:`${n.length} running`})]})]})}class Sie extends h.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,i;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(((i=this.state.info)==null?void 0:i.componentStack)||"");return o.jsx("div",{className:"af-auth-screen",children:o.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"error"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow UI Error"}),o.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),o.jsx("pre",{children:t}),n?o.jsx("pre",{children:n}):null]})})}}function Nie({authUser:e}){const{path:t}=ko();return t==="/projects"||t==="/"?o.jsx(Ac,{authUser:e}):t==="/nodes"?o.jsx(Ac,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(Ac,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(Ac,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(Ac,{authUser:e,resourceKind:"skills"}):t==="/mcps"?o.jsx(dne,{}):t==="/flow"?o.jsx(C7,{}):t==="/workspace"?o.jsx(Hq,{}):t.startsWith("/display")?o.jsx(eR,{}):t==="/settings"?o.jsx(lne,{authUser:e}):t==="/feedback"?o.jsx(cne,{}):o.jsx(Ac,{})}function jie({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=h.useState(""),[i,a]=h.useState(""),[l,c]=h.useState(!1),[d,f]=h.useState(""),u=async()=>{try{const g=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!g.authenticated,user:g.user||null,setupRequired:!!g.setupRequired}),f(g.error?String(g.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),f(String(m.message||m))}};h.useEffect(()=>{u()},[]);const p=async m=>{m.preventDefault(),c(!0),f("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:i})}),b=await g.json().catch(()=>({}));if(!g.ok)throw new Error(b.error||"登录失败");n({loading:!1,authenticated:!0,user:b.user||null,setupRequired:!1})}catch(g){f(String(g.message||g))}finally{c(!1)}};return t.loading?o.jsx("div",{className:"af-auth-screen",children:o.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})}}):o.jsx("div",{className:"af-auth-screen",children:o.jsxs("form",{className:"af-auth-panel",onSubmit:p,children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow"}),o.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"用户名"}),o.jsx("input",{value:r,onChange:m=>s(m.target.value),autoComplete:"username",autoFocus:!0})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"密码"}),o.jsx("input",{type:"password",value:i,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),d?o.jsx("p",{className:"af-auth-error",children:d}):null,o.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||i.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Cie({authUser:e,onLogout:t}){const{path:n}=ko(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(vie,{page:r?"flow":"projects"}):null,r?null:o.jsx(pM,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(Nie,{authUser:e})}),o.jsx(kie,{})]})}function Eie(){return o.jsx(Sie,{children:o.jsx(YO,{children:o.jsx(_ie,{})})})}function _ie(){const{path:e}=ko();return e.startsWith("/display")?o.jsx(eR,{}):o.jsx(jie,{children:({user:t,onLogout:n})=>o.jsx(Cie,{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 sC=document.querySelector('link[rel="icon"]');sC&&(sC.href=b_);Ax.createRoot(document.getElementById("root")).render(o.jsx(at.StrictMode,{children:o.jsx(Eie,{})}));