@fieldwangai/agentflow 0.1.51 → 0.1.53

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 xR=Object.defineProperty;var wR=(e,t,n)=>t in e?xR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var er=(e,t,n)=>wR(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 df=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function il(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pC={exports:{}},dg={},hC={exports:{}},Mt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Jf=Symbol.for("react.element"),bR=Symbol.for("react.portal"),vR=Symbol.for("react.fragment"),kR=Symbol.for("react.strict_mode"),SR=Symbol.for("react.profiler"),NR=Symbol.for("react.provider"),jR=Symbol.for("react.context"),CR=Symbol.for("react.forward_ref"),ER=Symbol.for("react.suspense"),_R=Symbol.for("react.memo"),PR=Symbol.for("react.lazy"),G0=Symbol.iterator;function AR(e){return e===null||typeof e!="object"?null:(e=G0&&e[G0]||e["@@iterator"],typeof e=="function"?e:null)}var mC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},gC=Object.assign,yC={};function Du(e,t,n){this.props=e,this.context=t,this.refs=yC,this.updater=n||mC}Du.prototype.isReactComponent={};Du.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")};Du.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function xC(){}xC.prototype=Du.prototype;function Tb(e,t,n){this.props=e,this.context=t,this.refs=yC,this.updater=n||mC}var Rb=Tb.prototype=new xC;Rb.constructor=Tb;gC(Rb,Du.prototype);Rb.isPureReactComponent=!0;var X0=Array.isArray,wC=Object.prototype.hasOwnProperty,Lb={current:null},bC={key:!0,ref:!0,__self:!0,__source:!0};function vC(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)wC.call(t,r)&&!bC.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:Jf,type:e,key:i,ref:a,props:s,_owner:Lb.current}}function IR(e,t){return{$$typeof:Jf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ob(e){return typeof e=="object"&&e!==null&&e.$$typeof===Jf}function TR(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var J0=/\/+/g;function my(e,t){return typeof e=="object"&&e!==null&&e.key!=null?TR(""+e.key):t.toString(36)}function Ih(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 Jf:case bR:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+my(a,0):r,X0(s)?(n="",e!=null&&(n=e.replace(J0,"$&/")+"/"),Ih(s,t,n,"",function(d){return d})):s!=null&&(Ob(s)&&(s=IR(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(J0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",X0(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+my(i,l);a+=Ih(i,t,n,c,s)}else if(c=AR(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+my(i,l++),a+=Ih(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 zp(e,t,n){if(e==null)return e;var r=[],s=0;return Ih(e,r,"","",function(i){return t.call(n,i,s++)}),r}function RR(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 ls={current:null},Th={transition:null},LR={ReactCurrentDispatcher:ls,ReactCurrentBatchConfig:Th,ReactCurrentOwner:Lb};function kC(){throw Error("act(...) is not supported in production builds of React.")}Mt.Children={map:zp,forEach:function(e,t,n){zp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return zp(e,function(){t++}),t},toArray:function(e){return zp(e,function(t){return t})||[]},only:function(e){if(!Ob(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Mt.Component=Du;Mt.Fragment=vR;Mt.Profiler=SR;Mt.PureComponent=Tb;Mt.StrictMode=kR;Mt.Suspense=ER;Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=LR;Mt.act=kC;Mt.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=gC({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Lb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)wC.call(t,c)&&!bC.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:Jf,type:e.type,key:s,ref:i,props:r,_owner:a}};Mt.createContext=function(e){return e={$$typeof:jR,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:NR,_context:e},e.Consumer=e};Mt.createElement=vC;Mt.createFactory=function(e){var t=vC.bind(null,e);return t.type=e,t};Mt.createRef=function(){return{current:null}};Mt.forwardRef=function(e){return{$$typeof:CR,render:e}};Mt.isValidElement=Ob;Mt.lazy=function(e){return{$$typeof:PR,_payload:{_status:-1,_result:e},_init:RR}};Mt.memo=function(e,t){return{$$typeof:_R,type:e,compare:t===void 0?null:t}};Mt.startTransition=function(e){var t=Th.transition;Th.transition={};try{e()}finally{Th.transition=t}};Mt.unstable_act=kC;Mt.useCallback=function(e,t){return ls.current.useCallback(e,t)};Mt.useContext=function(e){return ls.current.useContext(e)};Mt.useDebugValue=function(){};Mt.useDeferredValue=function(e){return ls.current.useDeferredValue(e)};Mt.useEffect=function(e,t){return ls.current.useEffect(e,t)};Mt.useId=function(){return ls.current.useId()};Mt.useImperativeHandle=function(e,t,n){return ls.current.useImperativeHandle(e,t,n)};Mt.useInsertionEffect=function(e,t){return ls.current.useInsertionEffect(e,t)};Mt.useLayoutEffect=function(e,t){return ls.current.useLayoutEffect(e,t)};Mt.useMemo=function(e,t){return ls.current.useMemo(e,t)};Mt.useReducer=function(e,t,n){return ls.current.useReducer(e,t,n)};Mt.useRef=function(e){return ls.current.useRef(e)};Mt.useState=function(e){return ls.current.useState(e)};Mt.useSyncExternalStore=function(e,t,n){return ls.current.useSyncExternalStore(e,t,n)};Mt.useTransition=function(){return ls.current.useTransition()};Mt.version="18.3.1";hC.exports=Mt;var h=hC.exports;const at=il(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 OR=h,MR=Symbol.for("react.element"),$R=Symbol.for("react.fragment"),DR=Object.prototype.hasOwnProperty,FR=OR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,zR={key:!0,ref:!0,__self:!0,__source:!0};function SC(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)DR.call(t,r)&&!zR.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:MR,type:e,key:i,ref:a,props:s,_owner:FR.current}}dg.Fragment=$R;dg.jsx=SC;dg.jsxs=SC;pC.exports=dg;var o=pC.exports,Mx={},NC={exports:{}},Gs={},jC={exports:{}},CC={};/**
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 X=P-1>>>1,Z=_[X];if(0<s(Z,R))_[X]=R,_[P]=Z,P=X;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 X=0,Z=_.length,V=Z>>>1;X<V;){var ne=2*(X+1)-1,ue=_[ne],pe=ne+1,ge=_[pe];if(0>s(ue,P))pe<Z&&0>s(ge,ue)?(_[X]=ge,_[pe]=P,X=pe):(_[X]=ue,_[ne]=P,X=ne);else if(pe<Z&&0>s(ge,P))_[X]=ge,_[pe]=P,X=pe;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 X=u.callback;if(typeof X=="function"){u.callback=null,p=u.priorityLevel;var Z=X(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 ne=n(d);ne!==null&&D(j,ne.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 X=e.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?X+P:X):P=X,_){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>X?(_.sortIndex=P,t(d,_),n(c)===null&&_===n(d)&&(b?(y(B),B=-1):b=!0,D(j,P-X))):(_.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}}}})(CC);jC.exports=CC;var BR=jC.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 HR=h,qs=BR;function je(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 EC=new Set,ff={};function ic(e,t){yu(e,t),yu(e+"Capture",t)}function yu(e,t){for(ff[e]=t,e=0;e<t.length;e++)EC.add(t[e])}var Qo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$x=Object.prototype.hasOwnProperty,WR=/^[: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]*$/,Q0={},Z0={};function VR(e){return $x.call(Z0,e)?!0:$x.call(Q0,e)?!1:WR.test(e)?Z0[e]=!0:(Q0[e]=!0,!1)}function UR(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 KR(e,t,n,r){if(t===null||typeof t>"u"||UR(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 cs(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 zr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){zr[e]=new cs(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];zr[t]=new cs(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){zr[e]=new cs(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){zr[e]=new cs(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){zr[e]=new cs(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){zr[e]=new cs(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){zr[e]=new cs(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){zr[e]=new cs(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){zr[e]=new cs(e,5,!1,e.toLowerCase(),null,!1,!1)});var Mb=/[\-:]([a-z])/g;function $b(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(Mb,$b);zr[t]=new cs(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(Mb,$b);zr[t]=new cs(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(Mb,$b);zr[t]=new cs(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){zr[e]=new cs(e,1,!1,e.toLowerCase(),null,!1,!1)});zr.xlinkHref=new cs("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){zr[e]=new cs(e,1,!1,e.toLowerCase(),null,!0,!0)});function Db(e,t,n,r){var s=zr.hasOwnProperty(t)?zr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(KR(t,n,s,r)&&(n=null),r||s===null?VR(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 ia=HR.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Bp=Symbol.for("react.element"),Bc=Symbol.for("react.portal"),Hc=Symbol.for("react.fragment"),Fb=Symbol.for("react.strict_mode"),Dx=Symbol.for("react.profiler"),_C=Symbol.for("react.provider"),PC=Symbol.for("react.context"),zb=Symbol.for("react.forward_ref"),Fx=Symbol.for("react.suspense"),zx=Symbol.for("react.suspense_list"),Bb=Symbol.for("react.memo"),Pa=Symbol.for("react.lazy"),AC=Symbol.for("react.offscreen"),ek=Symbol.iterator;function yd(e){return e===null||typeof e!="object"?null:(e=ek&&e[ek]||e["@@iterator"],typeof e=="function"?e:null)}var Jn=Object.assign,gy;function Od(e){if(gy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);gy=t&&t[1]||""}return`
34
+ `+gy+e}var yy=!1;function xy(e,t){if(!e||yy)return"";yy=!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{yy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Od(e):""}function qR(e){switch(e.tag){case 5:return Od(e.type);case 16:return Od("Lazy");case 13:return Od("Suspense");case 19:return Od("SuspenseList");case 0:case 2:case 15:return e=xy(e.type,!1),e;case 11:return e=xy(e.type.render,!1),e;case 1:return e=xy(e.type,!0),e;default:return""}}function Bx(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 Hc:return"Fragment";case Bc:return"Portal";case Dx:return"Profiler";case Fb:return"StrictMode";case Fx:return"Suspense";case zx:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case PC:return(e.displayName||"Context")+".Consumer";case _C:return(e._context.displayName||"Context")+".Provider";case zb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Bb:return t=e.displayName||null,t!==null?t:Bx(e.type)||"Memo";case Pa:t=e._payload,e=e._init;try{return Bx(e(t))}catch{}}return null}function YR(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 Bx(t);case 8:return t===Fb?"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 Qa(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function IC(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function GR(e){var t=IC(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 Hp(e){e._valueTracker||(e._valueTracker=GR(e))}function TC(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=IC(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function tm(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 Hx(e,t){var n=t.checked;return Jn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function tk(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Qa(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 RC(e,t){t=t.checked,t!=null&&Db(e,"checked",t,!1)}function Wx(e,t){RC(e,t);var n=Qa(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")?Vx(e,t.type,n):t.hasOwnProperty("defaultValue")&&Vx(e,t.type,Qa(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function nk(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 Vx(e,t,n){(t!=="number"||tm(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Md=Array.isArray;function iu(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=""+Qa(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 Ux(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(je(91));return Jn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function rk(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(je(92));if(Md(n)){if(1<n.length)throw Error(je(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Qa(n)}}function LC(e,t){var n=Qa(t.value),r=Qa(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 sk(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function OC(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 Kx(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?OC(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Wp,MC=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(Wp=Wp||document.createElement("div"),Wp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Wp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function pf(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kd={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},XR=["Webkit","ms","Moz","O"];Object.keys(Kd).forEach(function(e){XR.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kd[t]=Kd[e]})});function $C(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kd.hasOwnProperty(e)&&Kd[e]?(""+t).trim():t+"px"}function DC(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=$C(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var JR=Jn({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 qx(e,t){if(t){if(JR[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(je(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(je(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(je(61))}if(t.style!=null&&typeof t.style!="object")throw Error(je(62))}}function Yx(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 Gx=null;function Hb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xx=null,ou=null,au=null;function ik(e){if(e=ep(e)){if(typeof Xx!="function")throw Error(je(280));var t=e.stateNode;t&&(t=gg(t),Xx(e.stateNode,e.type,t))}}function FC(e){ou?au?au.push(e):au=[e]:ou=e}function zC(){if(ou){var e=ou,t=au;if(au=ou=null,ik(e),t)for(e=0;e<t.length;e++)ik(t[e])}}function BC(e,t){return e(t)}function HC(){}var wy=!1;function WC(e,t,n){if(wy)return e(t,n);wy=!0;try{return BC(e,t,n)}finally{wy=!1,(ou!==null||au!==null)&&(HC(),zC())}}function hf(e,t){var n=e.stateNode;if(n===null)return null;var r=gg(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(je(231,t,typeof n));return n}var Jx=!1;if(Qo)try{var xd={};Object.defineProperty(xd,"passive",{get:function(){Jx=!0}}),window.addEventListener("test",xd,xd),window.removeEventListener("test",xd,xd)}catch{Jx=!1}function QR(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 qd=!1,nm=null,rm=!1,Qx=null,ZR={onError:function(e){qd=!0,nm=e}};function eL(e,t,n,r,s,i,a,l,c){qd=!1,nm=null,QR.apply(ZR,arguments)}function tL(e,t,n,r,s,i,a,l,c){if(eL.apply(this,arguments),qd){if(qd){var d=nm;qd=!1,nm=null}else throw Error(je(198));rm||(rm=!0,Qx=d)}}function oc(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 VC(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 ok(e){if(oc(e)!==e)throw Error(je(188))}function nL(e){var t=e.alternate;if(!t){if(t=oc(e),t===null)throw Error(je(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 ok(s),e;if(i===r)return ok(s),t;i=i.sibling}throw Error(je(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(je(189))}}if(n.alternate!==r)throw Error(je(190))}if(n.tag!==3)throw Error(je(188));return n.stateNode.current===n?e:t}function UC(e){return e=nL(e),e!==null?KC(e):null}function KC(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=KC(e);if(t!==null)return t;e=e.sibling}return null}var qC=qs.unstable_scheduleCallback,ak=qs.unstable_cancelCallback,rL=qs.unstable_shouldYield,sL=qs.unstable_requestPaint,ir=qs.unstable_now,iL=qs.unstable_getCurrentPriorityLevel,Wb=qs.unstable_ImmediatePriority,YC=qs.unstable_UserBlockingPriority,sm=qs.unstable_NormalPriority,oL=qs.unstable_LowPriority,GC=qs.unstable_IdlePriority,fg=null,xo=null;function aL(e){if(xo&&typeof xo.onCommitFiberRoot=="function")try{xo.onCommitFiberRoot(fg,e,void 0,(e.current.flags&128)===128)}catch{}}var zi=Math.clz32?Math.clz32:uL,lL=Math.log,cL=Math.LN2;function uL(e){return e>>>=0,e===0?32:31-(lL(e)/cL|0)|0}var Vp=64,Up=4194304;function $d(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 im(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=$d(l):(i&=a,i!==0&&(r=$d(i)))}else a=n&~s,a!==0?r=$d(a):i!==0&&(r=$d(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-zi(t),s=1<<n,r|=e[n],t&=~s;return r}function dL(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 fL(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-zi(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=dL(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function Zx(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function XC(){var e=Vp;return Vp<<=1,!(Vp&4194240)&&(Vp=64),e}function by(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-zi(t),e[t]=n}function pL(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-zi(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Vb(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-zi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var un=0;function JC(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var QC,Ub,ZC,eE,tE,ew=!1,Kp=[],za=null,Ba=null,Ha=null,mf=new Map,gf=new Map,Ra=[],hL="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 lk(e,t){switch(e){case"focusin":case"focusout":za=null;break;case"dragenter":case"dragleave":Ba=null;break;case"mouseover":case"mouseout":Ha=null;break;case"pointerover":case"pointerout":mf.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":gf.delete(t.pointerId)}}function wd(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=ep(t),t!==null&&Ub(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function mL(e,t,n,r,s){switch(t){case"focusin":return za=wd(za,e,t,n,r,s),!0;case"dragenter":return Ba=wd(Ba,e,t,n,r,s),!0;case"mouseover":return Ha=wd(Ha,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return mf.set(i,wd(mf.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,gf.set(i,wd(gf.get(i)||null,e,t,n,r,s)),!0}return!1}function nE(e){var t=$l(e.target);if(t!==null){var n=oc(t);if(n!==null){if(t=n.tag,t===13){if(t=VC(n),t!==null){e.blockedOn=t,tE(e.priority,function(){ZC(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 Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=tw(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Gx=r,n.target.dispatchEvent(r),Gx=null}else return t=ep(n),t!==null&&Ub(t),e.blockedOn=n,!1;t.shift()}return!0}function ck(e,t,n){Rh(e)&&n.delete(t)}function gL(){ew=!1,za!==null&&Rh(za)&&(za=null),Ba!==null&&Rh(Ba)&&(Ba=null),Ha!==null&&Rh(Ha)&&(Ha=null),mf.forEach(ck),gf.forEach(ck)}function bd(e,t){e.blockedOn===t&&(e.blockedOn=null,ew||(ew=!0,qs.unstable_scheduleCallback(qs.unstable_NormalPriority,gL)))}function yf(e){function t(s){return bd(s,e)}if(0<Kp.length){bd(Kp[0],e);for(var n=1;n<Kp.length;n++){var r=Kp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(za!==null&&bd(za,e),Ba!==null&&bd(Ba,e),Ha!==null&&bd(Ha,e),mf.forEach(t),gf.forEach(t),n=0;n<Ra.length;n++)r=Ra[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ra.length&&(n=Ra[0],n.blockedOn===null);)nE(n),n.blockedOn===null&&Ra.shift()}var lu=ia.ReactCurrentBatchConfig,om=!0;function yL(e,t,n,r){var s=un,i=lu.transition;lu.transition=null;try{un=1,Kb(e,t,n,r)}finally{un=s,lu.transition=i}}function xL(e,t,n,r){var s=un,i=lu.transition;lu.transition=null;try{un=4,Kb(e,t,n,r)}finally{un=s,lu.transition=i}}function Kb(e,t,n,r){if(om){var s=tw(e,t,n,r);if(s===null)Ay(e,t,r,am,n),lk(e,r);else if(mL(s,e,t,n,r))r.stopPropagation();else if(lk(e,r),t&4&&-1<hL.indexOf(e)){for(;s!==null;){var i=ep(s);if(i!==null&&QC(i),i=tw(e,t,n,r),i===null&&Ay(e,t,r,am,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else Ay(e,t,r,null,n)}}var am=null;function tw(e,t,n,r){if(am=null,e=Hb(r),e=$l(e),e!==null)if(t=oc(e),t===null)e=null;else if(n=t.tag,n===13){if(e=VC(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 am=e,null}function rE(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(iL()){case Wb:return 1;case YC:return 4;case sm:case oL:return 16;case GC:return 536870912;default:return 16}default:return 16}}var Ma=null,qb=null,Lh=null;function sE(){if(Lh)return Lh;var e,t=qb,n=t.length,r,s="value"in Ma?Ma.value:Ma.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 Lh=s.slice(e,1<r?1-r:void 0)}function Oh(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 qp(){return!0}function uk(){return!1}function Xs(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)?qp:uk,this.isPropagationStopped=uk,this}return Jn(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=qp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=qp)},persist:function(){},isPersistent:qp}),t}var Fu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yb=Xs(Fu),Zf=Jn({},Fu,{view:0,detail:0}),wL=Xs(Zf),vy,ky,vd,pg=Jn({},Zf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Gb,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!==vd&&(vd&&e.type==="mousemove"?(vy=e.screenX-vd.screenX,ky=e.screenY-vd.screenY):ky=vy=0,vd=e),vy)},movementY:function(e){return"movementY"in e?e.movementY:ky}}),dk=Xs(pg),bL=Jn({},pg,{dataTransfer:0}),vL=Xs(bL),kL=Jn({},Zf,{relatedTarget:0}),Sy=Xs(kL),SL=Jn({},Fu,{animationName:0,elapsedTime:0,pseudoElement:0}),NL=Xs(SL),jL=Jn({},Fu,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),CL=Xs(jL),EL=Jn({},Fu,{data:0}),fk=Xs(EL),_L={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},PL={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"},AL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function IL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=AL[e])?!!t[e]:!1}function Gb(){return IL}var TL=Jn({},Zf,{key:function(e){if(e.key){var t=_L[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Oh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?PL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Gb,charCode:function(e){return e.type==="keypress"?Oh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Oh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),RL=Xs(TL),LL=Jn({},pg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),pk=Xs(LL),OL=Jn({},Zf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Gb}),ML=Xs(OL),$L=Jn({},Fu,{propertyName:0,elapsedTime:0,pseudoElement:0}),DL=Xs($L),FL=Jn({},pg,{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}),zL=Xs(FL),BL=[9,13,27,32],Xb=Qo&&"CompositionEvent"in window,Yd=null;Qo&&"documentMode"in document&&(Yd=document.documentMode);var HL=Qo&&"TextEvent"in window&&!Yd,iE=Qo&&(!Xb||Yd&&8<Yd&&11>=Yd),hk=" ",mk=!1;function oE(e,t){switch(e){case"keyup":return BL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function aE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wc=!1;function WL(e,t){switch(e){case"compositionend":return aE(t);case"keypress":return t.which!==32?null:(mk=!0,hk);case"textInput":return e=t.data,e===hk&&mk?null:e;default:return null}}function VL(e,t){if(Wc)return e==="compositionend"||!Xb&&oE(e,t)?(e=sE(),Lh=qb=Ma=null,Wc=!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 iE&&t.locale!=="ko"?null:t.data;default:return null}}var UL={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 gk(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!UL[e.type]:t==="textarea"}function lE(e,t,n,r){FC(r),t=lm(t,"onChange"),0<t.length&&(n=new Yb("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Gd=null,xf=null;function KL(e){wE(e,0)}function hg(e){var t=Kc(e);if(TC(t))return e}function qL(e,t){if(e==="change")return t}var cE=!1;if(Qo){var Ny;if(Qo){var jy="oninput"in document;if(!jy){var yk=document.createElement("div");yk.setAttribute("oninput","return;"),jy=typeof yk.oninput=="function"}Ny=jy}else Ny=!1;cE=Ny&&(!document.documentMode||9<document.documentMode)}function xk(){Gd&&(Gd.detachEvent("onpropertychange",uE),xf=Gd=null)}function uE(e){if(e.propertyName==="value"&&hg(xf)){var t=[];lE(t,xf,e,Hb(e)),WC(KL,t)}}function YL(e,t,n){e==="focusin"?(xk(),Gd=t,xf=n,Gd.attachEvent("onpropertychange",uE)):e==="focusout"&&xk()}function GL(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return hg(xf)}function XL(e,t){if(e==="click")return hg(t)}function JL(e,t){if(e==="input"||e==="change")return hg(t)}function QL(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Hi=typeof Object.is=="function"?Object.is:QL;function wf(e,t){if(Hi(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(!$x.call(t,s)||!Hi(e[s],t[s]))return!1}return!0}function wk(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function bk(e,t){var n=wk(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=wk(n)}}function dE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?dE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function fE(){for(var e=window,t=tm();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=tm(e.document)}return t}function Jb(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 ZL(e){var t=fE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&dE(n.ownerDocument.documentElement,n)){if(r!==null&&Jb(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=bk(n,i);var a=bk(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 eO=Qo&&"documentMode"in document&&11>=document.documentMode,Vc=null,nw=null,Xd=null,rw=!1;function vk(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;rw||Vc==null||Vc!==tm(r)||(r=Vc,"selectionStart"in r&&Jb(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}),Xd&&wf(Xd,r)||(Xd=r,r=lm(nw,"onSelect"),0<r.length&&(t=new Yb("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Vc)))}function Yp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Uc={animationend:Yp("Animation","AnimationEnd"),animationiteration:Yp("Animation","AnimationIteration"),animationstart:Yp("Animation","AnimationStart"),transitionend:Yp("Transition","TransitionEnd")},Cy={},pE={};Qo&&(pE=document.createElement("div").style,"AnimationEvent"in window||(delete Uc.animationend.animation,delete Uc.animationiteration.animation,delete Uc.animationstart.animation),"TransitionEvent"in window||delete Uc.transitionend.transition);function mg(e){if(Cy[e])return Cy[e];if(!Uc[e])return e;var t=Uc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in pE)return Cy[e]=t[n];return e}var hE=mg("animationend"),mE=mg("animationiteration"),gE=mg("animationstart"),yE=mg("transitionend"),xE=new Map,kk="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 ol(e,t){xE.set(e,t),ic(t,[e])}for(var Ey=0;Ey<kk.length;Ey++){var _y=kk[Ey],tO=_y.toLowerCase(),nO=_y[0].toUpperCase()+_y.slice(1);ol(tO,"on"+nO)}ol(hE,"onAnimationEnd");ol(mE,"onAnimationIteration");ol(gE,"onAnimationStart");ol("dblclick","onDoubleClick");ol("focusin","onFocus");ol("focusout","onBlur");ol(yE,"onTransitionEnd");yu("onMouseEnter",["mouseout","mouseover"]);yu("onMouseLeave",["mouseout","mouseover"]);yu("onPointerEnter",["pointerout","pointerover"]);yu("onPointerLeave",["pointerout","pointerover"]);ic("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ic("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ic("onBeforeInput",["compositionend","keypress","textInput","paste"]);ic("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ic("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ic("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dd="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(" "),rO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dd));function Sk(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,tL(r,t,void 0,e),e.currentTarget=null}function wE(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;Sk(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;Sk(s,l,d),i=c}}}if(rm)throw e=Qx,rm=!1,Qx=null,e}function Tn(e,t){var n=t[lw];n===void 0&&(n=t[lw]=new Set);var r=e+"__bubble";n.has(r)||(bE(t,e,2,!1),n.add(r))}function Py(e,t,n){var r=0;t&&(r|=4),bE(n,e,r,t)}var Gp="_reactListening"+Math.random().toString(36).slice(2);function bf(e){if(!e[Gp]){e[Gp]=!0,EC.forEach(function(n){n!=="selectionchange"&&(rO.has(n)||Py(n,!1,e),Py(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Gp]||(t[Gp]=!0,Py("selectionchange",!1,t))}}function bE(e,t,n,r){switch(rE(t)){case 1:var s=yL;break;case 4:s=xL;break;default:s=Kb}n=s.bind(null,t,n,e),s=void 0,!Jx||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 Ay(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=$l(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}WC(function(){var d=i,f=Hb(n),u=[];e:{var p=xE.get(e);if(p!==void 0){var m=Yb,g=e;switch(e){case"keypress":if(Oh(n)===0)break e;case"keydown":case"keyup":m=RL;break;case"focusin":g="focus",m=Sy;break;case"focusout":g="blur",m=Sy;break;case"beforeblur":case"afterblur":m=Sy;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=dk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=vL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=ML;break;case hE:case mE:case gE:m=NL;break;case yE:m=DL;break;case"scroll":m=wL;break;case"wheel":m=zL;break;case"copy":case"cut":case"paste":m=CL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=pk}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=hf(k,y),j!=null&&b.push(vf(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!==Gx&&(g=n.relatedTarget||n.fromElement)&&($l(g)||g[Zo]))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?$l(g):null,g!==null&&(v=oc(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=d),m!==g)){if(b=dk,j="onMouseLeave",y="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(b=pk,j="onPointerLeave",y="onPointerEnter",k="pointer"),v=m==null?p:Kc(m),w=g==null?p:Kc(g),p=new b(j,k+"leave",m,n,f),p.target=v,p.relatedTarget=w,j=null,$l(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=Ac(w))k++;for(w=0,j=y;j;j=Ac(j))w++;for(;0<k-w;)b=Ac(b),k--;for(;0<w-k;)y=Ac(y),w--;for(;k--;){if(b===y||y!==null&&b===y.alternate)break t;b=Ac(b),y=Ac(y)}b=null}else b=null;m!==null&&Nk(u,p,m,b,!1),g!==null&&v!==null&&Nk(u,v,g,b,!0)}}e:{if(p=d?Kc(d):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var A=qL;else if(gk(p))if(cE)A=JL;else{A=GL;var C=YL}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(A=XL);if(A&&(A=A(e,d))){lE(u,A,n,f);break e}C&&C(e,p,d),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Vx(p,"number",p.value)}switch(C=d?Kc(d):window,e){case"focusin":(gk(C)||C.contentEditable==="true")&&(Vc=C,nw=d,Xd=null);break;case"focusout":Xd=nw=Vc=null;break;case"mousedown":rw=!0;break;case"contextmenu":case"mouseup":case"dragend":rw=!1,vk(u,n,f);break;case"selectionchange":if(eO)break;case"keydown":case"keyup":vk(u,n,f)}var $;if(Xb)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 Wc?oE(e,n)&&(B="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(B="onCompositionStart");B&&(iE&&n.locale!=="ko"&&(Wc||B!=="onCompositionStart"?B==="onCompositionEnd"&&Wc&&($=sE()):(Ma=f,qb="value"in Ma?Ma.value:Ma.textContent,Wc=!0)),C=lm(d,B),0<C.length&&(B=new fk(B,e,null,n,f),u.push({event:B,listeners:C}),$?B.data=$:($=aE(n),$!==null&&(B.data=$)))),($=HL?WL(e,n):VL(e,n))&&(d=lm(d,"onBeforeInput"),0<d.length&&(f=new fk("onBeforeInput","beforeinput",null,n,f),u.push({event:f,listeners:d}),f.data=$))}wE(u,t)})}function vf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function lm(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=hf(e,n),i!=null&&r.unshift(vf(e,i,s)),i=hf(e,t),i!=null&&r.push(vf(e,i,s))),e=e.return}return r}function Ac(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Nk(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=hf(n,i),c!=null&&a.unshift(vf(n,c,l))):s||(c=hf(n,i),c!=null&&a.push(vf(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var sO=/\r\n?/g,iO=/\u0000|\uFFFD/g;function jk(e){return(typeof e=="string"?e:""+e).replace(sO,`
38
+ `).replace(iO,"")}function Xp(e,t,n){if(t=jk(t),jk(e)!==t&&n)throw Error(je(425))}function cm(){}var sw=null,iw=null;function ow(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 aw=typeof setTimeout=="function"?setTimeout:void 0,oO=typeof clearTimeout=="function"?clearTimeout:void 0,Ck=typeof Promise=="function"?Promise:void 0,aO=typeof queueMicrotask=="function"?queueMicrotask:typeof Ck<"u"?function(e){return Ck.resolve(null).then(e).catch(lO)}:aw;function lO(e){setTimeout(function(){throw e})}function Iy(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),yf(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);yf(t)}function Wa(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 Ek(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 zu=Math.random().toString(36).slice(2),ho="__reactFiber$"+zu,kf="__reactProps$"+zu,Zo="__reactContainer$"+zu,lw="__reactEvents$"+zu,cO="__reactListeners$"+zu,uO="__reactHandles$"+zu;function $l(e){var t=e[ho];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Zo]||n[ho]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ek(e);e!==null;){if(n=e[ho])return n;e=Ek(e)}return t}e=n,n=e.parentNode}return null}function ep(e){return e=e[ho]||e[Zo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Kc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(je(33))}function gg(e){return e[kf]||null}var cw=[],qc=-1;function al(e){return{current:e}}function Ln(e){0>qc||(e.current=cw[qc],cw[qc]=null,qc--)}function En(e,t){qc++,cw[qc]=e.current,e.current=t}var Za={},Jr=al(Za),Ns=al(!1),Yl=Za;function xu(e,t){var n=e.type.contextTypes;if(!n)return Za;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 js(e){return e=e.childContextTypes,e!=null}function um(){Ln(Ns),Ln(Jr)}function _k(e,t,n){if(Jr.current!==Za)throw Error(je(168));En(Jr,t),En(Ns,n)}function vE(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(je(108,YR(e)||"Unknown",s));return Jn({},n,r)}function dm(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Za,Yl=Jr.current,En(Jr,e),En(Ns,Ns.current),!0}function Pk(e,t,n){var r=e.stateNode;if(!r)throw Error(je(169));n?(e=vE(e,t,Yl),r.__reactInternalMemoizedMergedChildContext=e,Ln(Ns),Ln(Jr),En(Jr,e)):Ln(Ns),En(Ns,n)}var Wo=null,yg=!1,Ty=!1;function kE(e){Wo===null?Wo=[e]:Wo.push(e)}function dO(e){yg=!0,kE(e)}function ll(){if(!Ty&&Wo!==null){Ty=!0;var e=0,t=un;try{var n=Wo;for(un=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Wo=null,yg=!1}catch(s){throw Wo!==null&&(Wo=Wo.slice(e+1)),qC(Wb,ll),s}finally{un=t,Ty=!1}}return null}var Yc=[],Gc=0,fm=null,pm=0,ui=[],di=0,Gl=null,Ko=1,qo="";function Tl(e,t){Yc[Gc++]=pm,Yc[Gc++]=fm,fm=e,pm=t}function SE(e,t,n){ui[di++]=Ko,ui[di++]=qo,ui[di++]=Gl,Gl=e;var r=Ko;e=qo;var s=32-zi(r)-1;r&=~(1<<s),n+=1;var i=32-zi(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Ko=1<<32-zi(t)+s|n<<s|r,qo=i+e}else Ko=1<<i|n<<s|r,qo=e}function Qb(e){e.return!==null&&(Tl(e,1),SE(e,1,0))}function Zb(e){for(;e===fm;)fm=Yc[--Gc],Yc[Gc]=null,pm=Yc[--Gc],Yc[Gc]=null;for(;e===Gl;)Gl=ui[--di],ui[di]=null,qo=ui[--di],ui[di]=null,Ko=ui[--di],ui[di]=null}var Us=null,Ws=null,Bn=!1,Oi=null;function NE(e,t){var n=hi(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 Ak(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Us=e,Ws=Wa(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Us=e,Ws=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Gl!==null?{id:Ko,overflow:qo}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=hi(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Us=e,Ws=null,!0):!1;default:return!1}}function uw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function dw(e){if(Bn){var t=Ws;if(t){var n=t;if(!Ak(e,t)){if(uw(e))throw Error(je(418));t=Wa(n.nextSibling);var r=Us;t&&Ak(e,t)?NE(r,n):(e.flags=e.flags&-4097|2,Bn=!1,Us=e)}}else{if(uw(e))throw Error(je(418));e.flags=e.flags&-4097|2,Bn=!1,Us=e}}}function Ik(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Us=e}function Jp(e){if(e!==Us)return!1;if(!Bn)return Ik(e),Bn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ow(e.type,e.memoizedProps)),t&&(t=Ws)){if(uw(e))throw jE(),Error(je(418));for(;t;)NE(e,t),t=Wa(t.nextSibling)}if(Ik(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(je(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Ws=Wa(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Ws=null}}else Ws=Us?Wa(e.stateNode.nextSibling):null;return!0}function jE(){for(var e=Ws;e;)e=Wa(e.nextSibling)}function wu(){Ws=Us=null,Bn=!1}function ev(e){Oi===null?Oi=[e]:Oi.push(e)}var fO=ia.ReactCurrentBatchConfig;function kd(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(je(309));var r=n.stateNode}if(!r)throw Error(je(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(je(284));if(!n._owner)throw Error(je(290,e))}return e}function Qp(e,t){throw e=Object.prototype.toString.call(t),Error(je(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Tk(e){var t=e._init;return t(e._payload)}function CE(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=qa(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=Fy(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===Hc?f(y,k,w.props.children,j,w.key):k!==null&&(k.elementType===A||typeof A=="object"&&A!==null&&A.$$typeof===Pa&&Tk(A)===k.type)?(j=s(k,w.props),j.ref=kd(y,k,w),j.return=y,j):(j=Hh(w.type,w.key,w.props,null,y.mode,j),j.ref=kd(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=zy(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=Hl(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=Fy(""+k,y.mode,w),k.return=y,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case Bp:return w=Hh(k.type,k.key,k.props,null,y.mode,w),w.ref=kd(y,null,k),w.return=y,w;case Bc:return k=zy(k,y.mode,w),k.return=y,k;case Pa:var j=k._init;return u(y,j(k._payload),w)}if(Md(k)||yd(k))return k=Hl(k,y.mode,w,null),k.return=y,k;Qp(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 Bp:return w.key===A?c(y,k,w,j):null;case Bc:return w.key===A?d(y,k,w,j):null;case Pa:return A=w._init,p(y,k,A(w._payload),j)}if(Md(w)||yd(w))return A!==null?null:f(y,k,w,j,null);Qp(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 Bp:return y=y.get(j.key===null?w:j.key)||null,c(k,y,j,A);case Bc:return y=y.get(j.key===null?w:j.key)||null,d(k,y,j,A);case Pa:var C=j._init;return m(y,k,w,C(j._payload),A)}if(Md(j)||yd(j))return y=y.get(w)||null,f(k,y,j,A,null);Qp(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,$),Bn&&Tl(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 Bn&&Tl(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)}),Bn&&Tl(y,B),A}function b(y,k,w,j){var A=yd(w);if(typeof A!="function")throw Error(je(150));if(w=A.call(w),w==null)throw Error(je(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,$),Bn&&Tl(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 Bn&&Tl(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)}),Bn&&Tl(y,B),A}function v(y,k,w,j){if(typeof w=="object"&&w!==null&&w.type===Hc&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Bp:e:{for(var A=w.key,C=k;C!==null;){if(C.key===A){if(A=w.type,A===Hc){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===Pa&&Tk(A)===C.type){n(y,C.sibling),k=s(C,w.props),k.ref=kd(y,C,w),k.return=y,y=k;break e}n(y,C);break}else t(y,C);C=C.sibling}w.type===Hc?(k=Hl(w.props.children,y.mode,j,w.key),k.return=y,y=k):(j=Hh(w.type,w.key,w.props,null,y.mode,j),j.ref=kd(y,k,w),j.return=y,y=j)}return a(y);case Bc: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=zy(w,y.mode,j),k.return=y,y=k}return a(y);case Pa:return C=w._init,v(y,k,C(w._payload),j)}if(Md(w))return g(y,k,w,j);if(yd(w))return b(y,k,w,j);Qp(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=Fy(w,y.mode,j),k.return=y,y=k),a(y)):n(y,k)}return v}var bu=CE(!0),EE=CE(!1),hm=al(null),mm=null,Xc=null,tv=null;function nv(){tv=Xc=mm=null}function rv(e){var t=hm.current;Ln(hm),e._currentValue=t}function fw(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 cu(e,t){mm=e,tv=Xc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ws=!0),e.firstContext=null)}function gi(e){var t=e._currentValue;if(tv!==e)if(e={context:e,memoizedValue:t,next:null},Xc===null){if(mm===null)throw Error(je(308));Xc=e,mm.dependencies={lanes:0,firstContext:e}}else Xc=Xc.next=e;return t}var Dl=null;function sv(e){Dl===null?Dl=[e]:Dl.push(e)}function _E(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,sv(t)):(n.next=s.next,s.next=n),t.interleaved=n,ea(e,r)}function ea(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 Aa=!1;function iv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function PE(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 Jo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Va(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,ea(e,n)}return s=r.interleaved,s===null?(t.next=t,sv(r)):(t.next=s.next,s.next=t),r.interleaved=t,ea(e,n)}function Mh(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,Vb(e,n)}}function Rk(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 gm(e,t,n,r){var s=e.updateQueue;Aa=!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=Jn({},u,p);break e;case 2:Aa=!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);Jl|=a,e.lanes=a,e.memoizedState=u}}function Lk(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(je(191,s));s.call(r)}}}var tp={},wo=al(tp),Sf=al(tp),Nf=al(tp);function Fl(e){if(e===tp)throw Error(je(174));return e}function ov(e,t){switch(En(Nf,t),En(Sf,e),En(wo,tp),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Kx(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Kx(t,e)}Ln(wo),En(wo,t)}function vu(){Ln(wo),Ln(Sf),Ln(Nf)}function AE(e){Fl(Nf.current);var t=Fl(wo.current),n=Kx(t,e.type);t!==n&&(En(Sf,e),En(wo,n))}function av(e){Sf.current===e&&(Ln(wo),Ln(Sf))}var Gn=al(0);function ym(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 Ry=[];function lv(){for(var e=0;e<Ry.length;e++)Ry[e]._workInProgressVersionPrimary=null;Ry.length=0}var $h=ia.ReactCurrentDispatcher,Ly=ia.ReactCurrentBatchConfig,Xl=0,Xn=null,br=null,Pr=null,xm=!1,Jd=!1,jf=0,pO=0;function qr(){throw Error(je(321))}function cv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Hi(e[n],t[n]))return!1;return!0}function uv(e,t,n,r,s,i){if(Xl=i,Xn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,$h.current=e===null||e.memoizedState===null?yO:xO,e=n(r,s),Jd){i=0;do{if(Jd=!1,jf=0,25<=i)throw Error(je(301));i+=1,Pr=br=null,t.updateQueue=null,$h.current=wO,e=n(r,s)}while(Jd)}if($h.current=wm,t=br!==null&&br.next!==null,Xl=0,Pr=br=Xn=null,xm=!1,t)throw Error(je(300));return e}function dv(){var e=jf!==0;return jf=0,e}function co(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pr===null?Xn.memoizedState=Pr=e:Pr=Pr.next=e,Pr}function yi(){if(br===null){var e=Xn.alternate;e=e!==null?e.memoizedState:null}else e=br.next;var t=Pr===null?Xn.memoizedState:Pr.next;if(t!==null)Pr=t,br=e;else{if(e===null)throw Error(je(310));br=e,e={memoizedState:br.memoizedState,baseState:br.baseState,baseQueue:br.baseQueue,queue:br.queue,next:null},Pr===null?Xn.memoizedState=Pr=e:Pr=Pr.next=e}return Pr}function Cf(e,t){return typeof t=="function"?t(e):t}function Oy(e){var t=yi(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=br,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((Xl&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,Xn.lanes|=f,Jl|=f}d=d.next}while(d!==null&&d!==i);c===null?a=r:c.next=l,Hi(r,t.memoizedState)||(ws=!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,Xn.lanes|=i,Jl|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function My(e){var t=yi(),n=t.queue;if(n===null)throw Error(je(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);Hi(i,t.memoizedState)||(ws=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function IE(){}function TE(e,t){var n=Xn,r=yi(),s=t(),i=!Hi(r.memoizedState,s);if(i&&(r.memoizedState=s,ws=!0),r=r.queue,fv(OE.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Pr!==null&&Pr.memoizedState.tag&1){if(n.flags|=2048,Ef(9,LE.bind(null,n,r,s,t),void 0,null),Ir===null)throw Error(je(349));Xl&30||RE(n,t,s)}return s}function RE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Xn.updateQueue,t===null?(t={lastEffect:null,stores:null},Xn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function LE(e,t,n,r){t.value=n,t.getSnapshot=r,ME(t)&&$E(e)}function OE(e,t,n){return n(function(){ME(t)&&$E(e)})}function ME(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Hi(e,n)}catch{return!0}}function $E(e){var t=ea(e,1);t!==null&&Bi(t,e,1,-1)}function Ok(e){var t=co();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Cf,lastRenderedState:e},t.queue=e,e=e.dispatch=gO.bind(null,Xn,e),[t.memoizedState,e]}function Ef(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Xn.updateQueue,t===null?(t={lastEffect:null,stores:null},Xn.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 DE(){return yi().memoizedState}function Dh(e,t,n,r){var s=co();Xn.flags|=e,s.memoizedState=Ef(1|t,n,void 0,r===void 0?null:r)}function xg(e,t,n,r){var s=yi();r=r===void 0?null:r;var i=void 0;if(br!==null){var a=br.memoizedState;if(i=a.destroy,r!==null&&cv(r,a.deps)){s.memoizedState=Ef(t,n,i,r);return}}Xn.flags|=e,s.memoizedState=Ef(1|t,n,i,r)}function Mk(e,t){return Dh(8390656,8,e,t)}function fv(e,t){return xg(2048,8,e,t)}function FE(e,t){return xg(4,2,e,t)}function zE(e,t){return xg(4,4,e,t)}function BE(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 HE(e,t,n){return n=n!=null?n.concat([e]):null,xg(4,4,BE.bind(null,t,e),n)}function pv(){}function WE(e,t){var n=yi();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&cv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function VE(e,t){var n=yi();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&cv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function UE(e,t,n){return Xl&21?(Hi(n,t)||(n=XC(),Xn.lanes|=n,Jl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ws=!0),e.memoizedState=n)}function hO(e,t){var n=un;un=n!==0&&4>n?n:4,e(!0);var r=Ly.transition;Ly.transition={};try{e(!1),t()}finally{un=n,Ly.transition=r}}function KE(){return yi().memoizedState}function mO(e,t,n){var r=Ka(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},qE(e))YE(t,n);else if(n=_E(e,t,n,r),n!==null){var s=as();Bi(n,e,r,s),GE(n,t,r)}}function gO(e,t,n){var r=Ka(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(qE(e))YE(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,Hi(l,a)){var c=t.interleaved;c===null?(s.next=s,sv(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=_E(e,t,s,r),n!==null&&(s=as(),Bi(n,e,r,s),GE(n,t,r))}}function qE(e){var t=e.alternate;return e===Xn||t!==null&&t===Xn}function YE(e,t){Jd=xm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function GE(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Vb(e,n)}}var wm={readContext:gi,useCallback:qr,useContext:qr,useEffect:qr,useImperativeHandle:qr,useInsertionEffect:qr,useLayoutEffect:qr,useMemo:qr,useReducer:qr,useRef:qr,useState:qr,useDebugValue:qr,useDeferredValue:qr,useTransition:qr,useMutableSource:qr,useSyncExternalStore:qr,useId:qr,unstable_isNewReconciler:!1},yO={readContext:gi,useCallback:function(e,t){return co().memoizedState=[e,t===void 0?null:t],e},useContext:gi,useEffect:Mk,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Dh(4194308,4,BE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Dh(4194308,4,e,t)},useInsertionEffect:function(e,t){return Dh(4,2,e,t)},useMemo:function(e,t){var n=co();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=co();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=mO.bind(null,Xn,e),[r.memoizedState,e]},useRef:function(e){var t=co();return e={current:e},t.memoizedState=e},useState:Ok,useDebugValue:pv,useDeferredValue:function(e){return co().memoizedState=e},useTransition:function(){var e=Ok(!1),t=e[0];return e=hO.bind(null,e[1]),co().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Xn,s=co();if(Bn){if(n===void 0)throw Error(je(407));n=n()}else{if(n=t(),Ir===null)throw Error(je(349));Xl&30||RE(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Mk(OE.bind(null,r,i,e),[e]),r.flags|=2048,Ef(9,LE.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=co(),t=Ir.identifierPrefix;if(Bn){var n=qo,r=Ko;n=(r&~(1<<32-zi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=jf++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=pO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},xO={readContext:gi,useCallback:WE,useContext:gi,useEffect:fv,useImperativeHandle:HE,useInsertionEffect:FE,useLayoutEffect:zE,useMemo:VE,useReducer:Oy,useRef:DE,useState:function(){return Oy(Cf)},useDebugValue:pv,useDeferredValue:function(e){var t=yi();return UE(t,br.memoizedState,e)},useTransition:function(){var e=Oy(Cf)[0],t=yi().memoizedState;return[e,t]},useMutableSource:IE,useSyncExternalStore:TE,useId:KE,unstable_isNewReconciler:!1},wO={readContext:gi,useCallback:WE,useContext:gi,useEffect:fv,useImperativeHandle:HE,useInsertionEffect:FE,useLayoutEffect:zE,useMemo:VE,useReducer:My,useRef:DE,useState:function(){return My(Cf)},useDebugValue:pv,useDeferredValue:function(e){var t=yi();return br===null?t.memoizedState=e:UE(t,br.memoizedState,e)},useTransition:function(){var e=My(Cf)[0],t=yi().memoizedState;return[e,t]},useMutableSource:IE,useSyncExternalStore:TE,useId:KE,unstable_isNewReconciler:!1};function Ti(e,t){if(e&&e.defaultProps){t=Jn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function pw(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Jn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var wg={isMounted:function(e){return(e=e._reactInternals)?oc(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=as(),s=Ka(e),i=Jo(r,s);i.payload=t,n!=null&&(i.callback=n),t=Va(e,i,s),t!==null&&(Bi(t,e,s,r),Mh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=as(),s=Ka(e),i=Jo(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Va(e,i,s),t!==null&&(Bi(t,e,s,r),Mh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=as(),r=Ka(e),s=Jo(n,r);s.tag=2,t!=null&&(s.callback=t),t=Va(e,s,r),t!==null&&(Bi(t,e,r,n),Mh(t,e,r))}};function $k(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?!wf(n,r)||!wf(s,i):!0}function XE(e,t,n){var r=!1,s=Za,i=t.contextType;return typeof i=="object"&&i!==null?i=gi(i):(s=js(t)?Yl:Jr.current,r=t.contextTypes,i=(r=r!=null)?xu(e,s):Za),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=wg,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Dk(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&&wg.enqueueReplaceState(t,t.state,null)}function hw(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},iv(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=gi(i):(i=js(t)?Yl:Jr.current,s.context=xu(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(pw(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&&wg.enqueueReplaceState(s,s.state,null),gm(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ku(e,t){try{var n="",r=t;do n+=qR(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 $y(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function mw(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var bO=typeof WeakMap=="function"?WeakMap:Map;function JE(e,t,n){n=Jo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){vm||(vm=!0,jw=r),mw(e,t)},n}function QE(e,t,n){n=Jo(-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(){mw(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){mw(e,t),typeof r!="function"&&(Ua===null?Ua=new Set([this]):Ua.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Fk(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new bO;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=LO.bind(null,e,t,n),t.then(e,e))}function zk(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 Bk(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=Jo(-1,1),t.tag=2,Va(n,t,1))),n.lanes|=1),e)}var vO=ia.ReactCurrentOwner,ws=!1;function is(e,t,n,r){t.child=e===null?EE(t,null,n,r):bu(t,e.child,n,r)}function Hk(e,t,n,r,s){n=n.render;var i=t.ref;return cu(t,s),r=uv(e,t,n,r,i,s),n=dv(),e!==null&&!ws?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ta(e,t,s)):(Bn&&n&&Qb(t),t.flags|=1,is(e,t,r,s),t.child)}function Wk(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!vv(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,ZE(e,t,i,r,s)):(e=Hh(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:wf,n(a,r)&&e.ref===t.ref)return ta(e,t,s)}return t.flags|=1,e=qa(i,r),e.ref=t.ref,e.return=t,t.child=e}function ZE(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(wf(i,r)&&e.ref===t.ref)if(ws=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ws=!0);else return t.lanes=e.lanes,ta(e,t,s)}return gw(e,t,n,r,s)}function e_(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},En(Qc,zs),zs|=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,En(Qc,zs),zs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,En(Qc,zs),zs|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,En(Qc,zs),zs|=r;return is(e,t,s,n),t.child}function t_(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function gw(e,t,n,r,s){var i=js(n)?Yl:Jr.current;return i=xu(t,i),cu(t,s),n=uv(e,t,n,r,i,s),r=dv(),e!==null&&!ws?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ta(e,t,s)):(Bn&&r&&Qb(t),t.flags|=1,is(e,t,n,s),t.child)}function Vk(e,t,n,r,s){if(js(n)){var i=!0;dm(t)}else i=!1;if(cu(t,s),t.stateNode===null)Fh(e,t),XE(t,n,r),hw(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=gi(d):(d=js(n)?Yl:Jr.current,d=xu(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)&&Dk(t,a,r,d),Aa=!1;var p=t.memoizedState;a.state=p,gm(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Ns.current||Aa?(typeof f=="function"&&(pw(t,n,f,r),c=t.memoizedState),(l=Aa||$k(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,PE(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Ti(t.type,l),a.props=d,u=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=gi(c):(c=js(n)?Yl:Jr.current,c=xu(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)&&Dk(t,a,r,c),Aa=!1,p=t.memoizedState,a.state=p,gm(t,r,a,s);var g=t.memoizedState;l!==u||p!==g||Ns.current||Aa?(typeof m=="function"&&(pw(t,n,m,r),g=t.memoizedState),(d=Aa||$k(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 yw(e,t,n,r,i,s)}function yw(e,t,n,r,s,i){t_(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Pk(t,n,!1),ta(e,t,i);r=t.stateNode,vO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=bu(t,e.child,null,i),t.child=bu(t,null,l,i)):is(e,t,l,i),t.memoizedState=r.state,s&&Pk(t,n,!0),t.child}function n_(e){var t=e.stateNode;t.pendingContext?_k(e,t.pendingContext,t.pendingContext!==t.context):t.context&&_k(e,t.context,!1),ov(e,t.containerInfo)}function Uk(e,t,n,r,s){return wu(),ev(s),t.flags|=256,is(e,t,n,r),t.child}var xw={dehydrated:null,treeContext:null,retryLane:0};function ww(e){return{baseLanes:e,cachePool:null,transitions:null}}function r_(e,t,n){var r=t.pendingProps,s=Gn.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),En(Gn,s&1),e===null)return dw(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=kg(a,r,0,null),e=Hl(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=ww(n),t.memoizedState=xw,e):hv(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return kO(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=qa(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=qa(l,i):(i=Hl(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?ww(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=xw,r}return i=e.child,e=i.sibling,r=qa(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 hv(e,t){return t=kg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Zp(e,t,n,r){return r!==null&&ev(r),bu(t,e.child,null,n),e=hv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function kO(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=$y(Error(je(422))),Zp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=kg({mode:"visible",children:r.children},s,0,null),i=Hl(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&bu(t,e.child,null,a),t.child.memoizedState=ww(a),t.memoizedState=xw,i);if(!(t.mode&1))return Zp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(je(419)),r=$y(i,r,void 0),Zp(e,t,a,r)}if(l=(a&e.childLanes)!==0,ws||l){if(r=Ir,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,ea(e,s),Bi(r,e,s,-1))}return bv(),r=$y(Error(je(421))),Zp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=OO.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Ws=Wa(s.nextSibling),Us=t,Bn=!0,Oi=null,e!==null&&(ui[di++]=Ko,ui[di++]=qo,ui[di++]=Gl,Ko=e.id,qo=e.overflow,Gl=t),t=hv(t,r.children),t.flags|=4096,t)}function Kk(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),fw(e.return,t,n)}function Dy(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 s_(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(is(e,t,r.children,n),r=Gn.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&&Kk(e,n,t);else if(e.tag===19)Kk(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(En(Gn,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&&ym(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Dy(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&&ym(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Dy(t,!0,n,null,i);break;case"together":Dy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Fh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ta(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Jl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(je(153));if(t.child!==null){for(e=t.child,n=qa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=qa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function SO(e,t,n){switch(t.tag){case 3:n_(t),wu();break;case 5:AE(t);break;case 1:js(t.type)&&dm(t);break;case 4:ov(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;En(hm,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(En(Gn,Gn.current&1),t.flags|=128,null):n&t.child.childLanes?r_(e,t,n):(En(Gn,Gn.current&1),e=ta(e,t,n),e!==null?e.sibling:null);En(Gn,Gn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return s_(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),En(Gn,Gn.current),r)break;return null;case 22:case 23:return t.lanes=0,e_(e,t,n)}return ta(e,t,n)}var i_,bw,o_,a_;i_=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}};bw=function(){};o_=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Fl(wo.current);var i=null;switch(n){case"input":s=Hx(e,s),r=Hx(e,r),i=[];break;case"select":s=Jn({},s,{value:void 0}),r=Jn({},r,{value:void 0}),i=[];break;case"textarea":s=Ux(e,s),r=Ux(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=cm)}qx(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"&&(ff.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"&&(ff.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Tn("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)}};a_=function(e,t,n,r){n!==r&&(t.flags|=4)};function Sd(e,t){if(!Bn)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 Yr(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 NO(e,t,n){var r=t.pendingProps;switch(Zb(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yr(t),null;case 1:return js(t.type)&&um(),Yr(t),null;case 3:return r=t.stateNode,vu(),Ln(Ns),Ln(Jr),lv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Jp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Oi!==null&&(_w(Oi),Oi=null))),bw(e,t),Yr(t),null;case 5:av(t);var s=Fl(Nf.current);if(n=t.type,e!==null&&t.stateNode!=null)o_(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(je(166));return Yr(t),null}if(e=Fl(wo.current),Jp(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[ho]=t,r[kf]=i,e=(t.mode&1)!==0,n){case"dialog":Tn("cancel",r),Tn("close",r);break;case"iframe":case"object":case"embed":Tn("load",r);break;case"video":case"audio":for(s=0;s<Dd.length;s++)Tn(Dd[s],r);break;case"source":Tn("error",r);break;case"img":case"image":case"link":Tn("error",r),Tn("load",r);break;case"details":Tn("toggle",r);break;case"input":tk(r,i),Tn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Tn("invalid",r);break;case"textarea":rk(r,i),Tn("invalid",r)}qx(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&&Xp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Xp(r.textContent,l,e),s=["children",""+l]):ff.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Tn("scroll",r)}switch(n){case"input":Hp(r),nk(r,i,!0);break;case"textarea":Hp(r),sk(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=cm)}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=OC(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[ho]=t,e[kf]=r,i_(e,t,!1,!1),t.stateNode=e;e:{switch(a=Yx(n,r),n){case"dialog":Tn("cancel",e),Tn("close",e),s=r;break;case"iframe":case"object":case"embed":Tn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Dd.length;s++)Tn(Dd[s],e);s=r;break;case"source":Tn("error",e),s=r;break;case"img":case"image":case"link":Tn("error",e),Tn("load",e),s=r;break;case"details":Tn("toggle",e),s=r;break;case"input":tk(e,r),s=Hx(e,r),Tn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Jn({},r,{value:void 0}),Tn("invalid",e);break;case"textarea":rk(e,r),s=Ux(e,r),Tn("invalid",e);break;default:s=r}qx(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?DC(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&MC(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&pf(e,c):typeof c=="number"&&pf(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ff.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Tn("scroll",e):c!=null&&Db(e,i,c,a))}switch(n){case"input":Hp(e),nk(e,r,!1);break;case"textarea":Hp(e),sk(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Qa(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?iu(e,!!r.multiple,i,!1):r.defaultValue!=null&&iu(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=cm)}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 Yr(t),null;case 6:if(e&&t.stateNode!=null)a_(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(je(166));if(n=Fl(Nf.current),Fl(wo.current),Jp(t)){if(r=t.stateNode,n=t.memoizedProps,r[ho]=t,(i=r.nodeValue!==n)&&(e=Us,e!==null))switch(e.tag){case 3:Xp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Xp(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[ho]=t,t.stateNode=r}return Yr(t),null;case 13:if(Ln(Gn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Bn&&Ws!==null&&t.mode&1&&!(t.flags&128))jE(),wu(),t.flags|=98560,i=!1;else if(i=Jp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(je(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(je(317));i[ho]=t}else wu(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yr(t),i=!1}else Oi!==null&&(_w(Oi),Oi=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||Gn.current&1?kr===0&&(kr=3):bv())),t.updateQueue!==null&&(t.flags|=4),Yr(t),null);case 4:return vu(),bw(e,t),e===null&&bf(t.stateNode.containerInfo),Yr(t),null;case 10:return rv(t.type._context),Yr(t),null;case 17:return js(t.type)&&um(),Yr(t),null;case 19:if(Ln(Gn),i=t.memoizedState,i===null)return Yr(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Sd(i,!1);else{if(kr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ym(e),a!==null){for(t.flags|=128,Sd(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 En(Gn,Gn.current&1|2),t.child}e=e.sibling}i.tail!==null&&ir()>Su&&(t.flags|=128,r=!0,Sd(i,!1),t.lanes=4194304)}else{if(!r)if(e=ym(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Sd(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Bn)return Yr(t),null}else 2*ir()-i.renderingStartTime>Su&&n!==1073741824&&(t.flags|=128,r=!0,Sd(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=Gn.current,En(Gn,r?n&1|2:n&1),t):(Yr(t),null);case 22:case 23:return wv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?zs&1073741824&&(Yr(t),t.subtreeFlags&6&&(t.flags|=8192)):Yr(t),null;case 24:return null;case 25:return null}throw Error(je(156,t.tag))}function jO(e,t){switch(Zb(t),t.tag){case 1:return js(t.type)&&um(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vu(),Ln(Ns),Ln(Jr),lv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return av(t),null;case 13:if(Ln(Gn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(je(340));wu()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ln(Gn),null;case 4:return vu(),null;case 10:return rv(t.type._context),null;case 22:case 23:return wv(),null;case 24:return null;default:return null}}var eh=!1,Gr=!1,CO=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function Jc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){tr(e,t,r)}else n.current=null}function vw(e,t,n){try{n()}catch(r){tr(e,t,r)}}var qk=!1;function EO(e,t){if(sw=om,e=fE(),Jb(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(iw={focusedElem:e,selectionRange:n},om=!1,Ve=t;Ve!==null;)if(t=Ve,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ve=e;else for(;Ve!==null;){t=Ve;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:Ti(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(je(163))}}catch(j){tr(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Ve=e;break}Ve=t.return}return g=qk,qk=!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&&vw(t,n,i)}s=s.next}while(s!==r)}}function bg(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 kw(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 l_(e){var t=e.alternate;t!==null&&(e.alternate=null,l_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ho],delete t[kf],delete t[lw],delete t[cO],delete t[uO])),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 c_(e){return e.tag===5||e.tag===3||e.tag===4}function Yk(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||c_(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 Sw(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=cm));else if(r!==4&&(e=e.child,e!==null))for(Sw(e,t,n),e=e.sibling;e!==null;)Sw(e,t,n),e=e.sibling}function Nw(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(Nw(e,t,n),e=e.sibling;e!==null;)Nw(e,t,n),e=e.sibling}var Mr=null,Ri=!1;function ka(e,t,n){for(n=n.child;n!==null;)u_(e,t,n),n=n.sibling}function u_(e,t,n){if(xo&&typeof xo.onCommitFiberUnmount=="function")try{xo.onCommitFiberUnmount(fg,n)}catch{}switch(n.tag){case 5:Gr||Jc(n,t);case 6:var r=Mr,s=Ri;Mr=null,ka(e,t,n),Mr=r,Ri=s,Mr!==null&&(Ri?(e=Mr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Mr.removeChild(n.stateNode));break;case 18:Mr!==null&&(Ri?(e=Mr,n=n.stateNode,e.nodeType===8?Iy(e.parentNode,n):e.nodeType===1&&Iy(e,n),yf(e)):Iy(Mr,n.stateNode));break;case 4:r=Mr,s=Ri,Mr=n.stateNode.containerInfo,Ri=!0,ka(e,t,n),Mr=r,Ri=s;break;case 0:case 11:case 14:case 15:if(!Gr&&(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)&&vw(n,t,a),s=s.next}while(s!==r)}ka(e,t,n);break;case 1:if(!Gr&&(Jc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){tr(n,t,l)}ka(e,t,n);break;case 21:ka(e,t,n);break;case 22:n.mode&1?(Gr=(r=Gr)||n.memoizedState!==null,ka(e,t,n),Gr=r):ka(e,t,n);break;default:ka(e,t,n)}}function Gk(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new CO),t.forEach(function(r){var s=MO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Pi(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:Mr=l.stateNode,Ri=!1;break e;case 3:Mr=l.stateNode.containerInfo,Ri=!0;break e;case 4:Mr=l.stateNode.containerInfo,Ri=!0;break e}l=l.return}if(Mr===null)throw Error(je(160));u_(i,a,s),Mr=null,Ri=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){tr(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)d_(t,e),t=t.sibling}function d_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Pi(t,e),ao(e),r&4){try{Qd(3,e,e.return),bg(3,e)}catch(b){tr(e,e.return,b)}try{Qd(5,e,e.return)}catch(b){tr(e,e.return,b)}}break;case 1:Pi(t,e),ao(e),r&512&&n!==null&&Jc(n,n.return);break;case 5:if(Pi(t,e),ao(e),r&512&&n!==null&&Jc(n,n.return),e.flags&32){var s=e.stateNode;try{pf(s,"")}catch(b){tr(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&&RC(s,i),Yx(l,a);var d=Yx(l,i);for(a=0;a<c.length;a+=2){var f=c[a],u=c[a+1];f==="style"?DC(s,u):f==="dangerouslySetInnerHTML"?MC(s,u):f==="children"?pf(s,u):Db(s,f,u,d)}switch(l){case"input":Wx(s,i);break;case"textarea":LC(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?iu(s,!!i.multiple,m,!1):p!==!!i.multiple&&(i.defaultValue!=null?iu(s,!!i.multiple,i.defaultValue,!0):iu(s,!!i.multiple,i.multiple?[]:"",!1))}s[kf]=i}catch(b){tr(e,e.return,b)}}break;case 6:if(Pi(t,e),ao(e),r&4){if(e.stateNode===null)throw Error(je(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(b){tr(e,e.return,b)}}break;case 3:if(Pi(t,e),ao(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{yf(t.containerInfo)}catch(b){tr(e,e.return,b)}break;case 4:Pi(t,e),ao(e);break;case 13:Pi(t,e),ao(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(yv=ir())),r&4&&Gk(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Gr=(d=Gr)||f,Pi(t,e),Gr=d):Pi(t,e),ao(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(Ve=e,f=e.child;f!==null;){for(u=Ve=f;Ve!==null;){switch(p=Ve,m=p.child,p.tag){case 0:case 11:case 14:case 15:Qd(4,p,p.return);break;case 1:Jc(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){tr(r,n,b)}}break;case 5:Jc(p,p.return);break;case 22:if(p.memoizedState!==null){Jk(u);continue}}m!==null?(m.return=p,Ve=m):Jk(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=$C("display",a))}catch(b){tr(e,e.return,b)}}}else if(u.tag===6){if(f===null)try{u.stateNode.nodeValue=d?"":u.memoizedProps}catch(b){tr(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:Pi(t,e),ao(e),r&4&&Gk(e);break;case 21:break;default:Pi(t,e),ao(e)}}function ao(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(c_(n)){var r=n;break e}n=n.return}throw Error(je(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(pf(s,""),r.flags&=-33);var i=Yk(e);Nw(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Yk(e);Sw(e,l,a);break;default:throw Error(je(161))}}catch(c){tr(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function _O(e,t,n){Ve=e,f_(e)}function f_(e,t,n){for(var r=(e.mode&1)!==0;Ve!==null;){var s=Ve,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||eh;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Gr;l=eh;var d=Gr;if(eh=a,(Gr=c)&&!d)for(Ve=s;Ve!==null;)a=Ve,c=a.child,a.tag===22&&a.memoizedState!==null?Qk(s):c!==null?(c.return=a,Ve=c):Qk(s);for(;i!==null;)Ve=i,f_(i),i=i.sibling;Ve=s,eh=l,Gr=d}Xk(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,Ve=i):Xk(e)}}function Xk(e){for(;Ve!==null;){var t=Ve;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Gr||bg(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Gr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Ti(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Lk(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}Lk(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&&yf(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(je(163))}Gr||t.flags&512&&kw(t)}catch(p){tr(t,t.return,p)}}if(t===e){Ve=null;break}if(n=t.sibling,n!==null){n.return=t.return,Ve=n;break}Ve=t.return}}function Jk(e){for(;Ve!==null;){var t=Ve;if(t===e){Ve=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Ve=n;break}Ve=t.return}}function Qk(e){for(;Ve!==null;){var t=Ve;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{bg(4,t)}catch(c){tr(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){tr(t,s,c)}}var i=t.return;try{kw(t)}catch(c){tr(t,i,c)}break;case 5:var a=t.return;try{kw(t)}catch(c){tr(t,a,c)}}}catch(c){tr(t,t.return,c)}if(t===e){Ve=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Ve=l;break}Ve=t.return}}var PO=Math.ceil,bm=ia.ReactCurrentDispatcher,mv=ia.ReactCurrentOwner,mi=ia.ReactCurrentBatchConfig,qt=0,Ir=null,ur=null,Dr=0,zs=0,Qc=al(0),kr=0,_f=null,Jl=0,vg=0,gv=0,Zd=null,xs=null,yv=0,Su=1/0,Ho=null,vm=!1,jw=null,Ua=null,th=!1,$a=null,km=0,ef=0,Cw=null,zh=-1,Bh=0;function as(){return qt&6?ir():zh!==-1?zh:zh=ir()}function Ka(e){return e.mode&1?qt&2&&Dr!==0?Dr&-Dr:fO.transition!==null?(Bh===0&&(Bh=XC()),Bh):(e=un,e!==0||(e=window.event,e=e===void 0?16:rE(e.type)),e):1}function Bi(e,t,n,r){if(50<ef)throw ef=0,Cw=null,Error(je(185));Qf(e,n,r),(!(qt&2)||e!==Ir)&&(e===Ir&&(!(qt&2)&&(vg|=n),kr===4&&La(e,Dr)),Cs(e,r),n===1&&qt===0&&!(t.mode&1)&&(Su=ir()+500,yg&&ll()))}function Cs(e,t){var n=e.callbackNode;fL(e,t);var r=im(e,e===Ir?Dr:0);if(r===0)n!==null&&ak(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&ak(n),t===1)e.tag===0?dO(Zk.bind(null,e)):kE(Zk.bind(null,e)),aO(function(){!(qt&6)&&ll()}),n=null;else{switch(JC(r)){case 1:n=Wb;break;case 4:n=YC;break;case 16:n=sm;break;case 536870912:n=GC;break;default:n=sm}n=b_(n,p_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function p_(e,t){if(zh=-1,Bh=0,qt&6)throw Error(je(327));var n=e.callbackNode;if(uu()&&e.callbackNode!==n)return null;var r=im(e,e===Ir?Dr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Sm(e,r);else{t=r;var s=qt;qt|=2;var i=m_();(Ir!==e||Dr!==t)&&(Ho=null,Su=ir()+500,Bl(e,t));do try{TO();break}catch(l){h_(e,l)}while(!0);nv(),bm.current=i,qt=s,ur!==null?t=0:(Ir=null,Dr=0,t=kr)}if(t!==0){if(t===2&&(s=Zx(e),s!==0&&(r=s,t=Ew(e,s))),t===1)throw n=_f,Bl(e,0),La(e,r),Cs(e,ir()),n;if(t===6)La(e,r);else{if(s=e.current.alternate,!(r&30)&&!AO(s)&&(t=Sm(e,r),t===2&&(i=Zx(e),i!==0&&(r=i,t=Ew(e,i))),t===1))throw n=_f,Bl(e,0),La(e,r),Cs(e,ir()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(je(345));case 2:Rl(e,xs,Ho);break;case 3:if(La(e,r),(r&130023424)===r&&(t=yv+500-ir(),10<t)){if(im(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){as(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=aw(Rl.bind(null,e,xs,Ho),t);break}Rl(e,xs,Ho);break;case 4:if(La(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-zi(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*PO(r/1960))-r,10<r){e.timeoutHandle=aw(Rl.bind(null,e,xs,Ho),r);break}Rl(e,xs,Ho);break;case 5:Rl(e,xs,Ho);break;default:throw Error(je(329))}}}return Cs(e,ir()),e.callbackNode===n?p_.bind(null,e):null}function Ew(e,t){var n=Zd;return e.current.memoizedState.isDehydrated&&(Bl(e,t).flags|=256),e=Sm(e,t),e!==2&&(t=xs,xs=n,t!==null&&_w(t)),e}function _w(e){xs===null?xs=e:xs.push.apply(xs,e)}function AO(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(!Hi(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 La(e,t){for(t&=~gv,t&=~vg,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-zi(t),r=1<<n;e[n]=-1,t&=~r}}function Zk(e){if(qt&6)throw Error(je(327));uu();var t=im(e,0);if(!(t&1))return Cs(e,ir()),null;var n=Sm(e,t);if(e.tag!==0&&n===2){var r=Zx(e);r!==0&&(t=r,n=Ew(e,r))}if(n===1)throw n=_f,Bl(e,0),La(e,t),Cs(e,ir()),n;if(n===6)throw Error(je(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Rl(e,xs,Ho),Cs(e,ir()),null}function xv(e,t){var n=qt;qt|=1;try{return e(t)}finally{qt=n,qt===0&&(Su=ir()+500,yg&&ll())}}function Ql(e){$a!==null&&$a.tag===0&&!(qt&6)&&uu();var t=qt;qt|=1;var n=mi.transition,r=un;try{if(mi.transition=null,un=1,e)return e()}finally{un=r,mi.transition=n,qt=t,!(qt&6)&&ll()}}function wv(){zs=Qc.current,Ln(Qc)}function Bl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,oO(n)),ur!==null)for(n=ur.return;n!==null;){var r=n;switch(Zb(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&um();break;case 3:vu(),Ln(Ns),Ln(Jr),lv();break;case 5:av(r);break;case 4:vu();break;case 13:Ln(Gn);break;case 19:Ln(Gn);break;case 10:rv(r.type._context);break;case 22:case 23:wv()}n=n.return}if(Ir=e,ur=e=qa(e.current,null),Dr=zs=t,kr=0,_f=null,gv=vg=Jl=0,xs=Zd=null,Dl!==null){for(t=0;t<Dl.length;t++)if(n=Dl[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}Dl=null}return e}function h_(e,t){do{var n=ur;try{if(nv(),$h.current=wm,xm){for(var r=Xn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}xm=!1}if(Xl=0,Pr=br=Xn=null,Jd=!1,jf=0,mv.current=null,n===null||n.return===null){kr=1,_f=t,ur=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=Dr,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=zk(a);if(m!==null){m.flags&=-257,Bk(m,a,l,i,t),m.mode&1&&Fk(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)){Fk(i,d,t),bv();break e}c=Error(je(426))}}else if(Bn&&l.mode&1){var v=zk(a);if(v!==null){!(v.flags&65536)&&(v.flags|=256),Bk(v,a,l,i,t),ev(ku(c,l));break e}}i=c=ku(c,l),kr!==4&&(kr=2),Zd===null?Zd=[i]:Zd.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=JE(i,c,t);Rk(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"&&(Ua===null||!Ua.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=QE(i,l,t);Rk(i,j);break e}}i=i.return}while(i!==null)}y_(n)}catch(A){t=A,ur===n&&n!==null&&(ur=n=n.return);continue}break}while(!0)}function m_(){var e=bm.current;return bm.current=wm,e===null?wm:e}function bv(){(kr===0||kr===3||kr===2)&&(kr=4),Ir===null||!(Jl&268435455)&&!(vg&268435455)||La(Ir,Dr)}function Sm(e,t){var n=qt;qt|=2;var r=m_();(Ir!==e||Dr!==t)&&(Ho=null,Bl(e,t));do try{IO();break}catch(s){h_(e,s)}while(!0);if(nv(),qt=n,bm.current=r,ur!==null)throw Error(je(261));return Ir=null,Dr=0,kr}function IO(){for(;ur!==null;)g_(ur)}function TO(){for(;ur!==null&&!rL();)g_(ur)}function g_(e){var t=w_(e.alternate,e,zs);e.memoizedProps=e.pendingProps,t===null?y_(e):ur=t,mv.current=null}function y_(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=jO(n,t),n!==null){n.flags&=32767,ur=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{kr=6,ur=null;return}}else if(n=NO(n,t,zs),n!==null){ur=n;return}if(t=t.sibling,t!==null){ur=t;return}ur=t=e}while(t!==null);kr===0&&(kr=5)}function Rl(e,t,n){var r=un,s=mi.transition;try{mi.transition=null,un=1,RO(e,t,n,r)}finally{mi.transition=s,un=r}return null}function RO(e,t,n,r){do uu();while($a!==null);if(qt&6)throw Error(je(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(je(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(pL(e,i),e===Ir&&(ur=Ir=null,Dr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||th||(th=!0,b_(sm,function(){return uu(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=mi.transition,mi.transition=null;var a=un;un=1;var l=qt;qt|=4,mv.current=null,EO(e,n),d_(n,e),ZL(iw),om=!!sw,iw=sw=null,e.current=n,_O(n),sL(),qt=l,un=a,mi.transition=i}else e.current=n;if(th&&(th=!1,$a=e,km=s),i=e.pendingLanes,i===0&&(Ua=null),aL(n.stateNode),Cs(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(vm)throw vm=!1,e=jw,jw=null,e;return km&1&&e.tag!==0&&uu(),i=e.pendingLanes,i&1?e===Cw?ef++:(ef=0,Cw=e):ef=0,ll(),null}function uu(){if($a!==null){var e=JC(km),t=mi.transition,n=un;try{if(mi.transition=null,un=16>e?16:e,$a===null)var r=!1;else{if(e=$a,$a=null,km=0,qt&6)throw Error(je(331));var s=qt;for(qt|=4,Ve=e.current;Ve!==null;){var i=Ve,a=i.child;if(Ve.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Ve=d;Ve!==null;){var f=Ve;switch(f.tag){case 0:case 11:case 15:Qd(8,f,i)}var u=f.child;if(u!==null)u.return=f,Ve=u;else for(;Ve!==null;){f=Ve;var p=f.sibling,m=f.return;if(l_(f),f===d){Ve=null;break}if(p!==null){p.return=m,Ve=p;break}Ve=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)}}Ve=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Ve=a;else e:for(;Ve!==null;){if(i=Ve,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,Ve=y;break e}Ve=i.return}}var k=e.current;for(Ve=k;Ve!==null;){a=Ve;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,Ve=w;else e:for(a=k;Ve!==null;){if(l=Ve,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:bg(9,l)}}catch(A){tr(l,l.return,A)}if(l===a){Ve=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Ve=j;break e}Ve=l.return}}if(qt=s,ll(),xo&&typeof xo.onPostCommitFiberRoot=="function")try{xo.onPostCommitFiberRoot(fg,e)}catch{}r=!0}return r}finally{un=n,mi.transition=t}}return!1}function eS(e,t,n){t=ku(n,t),t=JE(e,t,1),e=Va(e,t,1),t=as(),e!==null&&(Qf(e,1,t),Cs(e,t))}function tr(e,t,n){if(e.tag===3)eS(e,e,n);else for(;t!==null;){if(t.tag===3){eS(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Ua===null||!Ua.has(r))){e=ku(n,e),e=QE(t,e,1),t=Va(t,e,1),e=as(),t!==null&&(Qf(t,1,e),Cs(t,e));break}}t=t.return}}function LO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=as(),e.pingedLanes|=e.suspendedLanes&n,Ir===e&&(Dr&n)===n&&(kr===4||kr===3&&(Dr&130023424)===Dr&&500>ir()-yv?Bl(e,0):gv|=n),Cs(e,t)}function x_(e,t){t===0&&(e.mode&1?(t=Up,Up<<=1,!(Up&130023424)&&(Up=4194304)):t=1);var n=as();e=ea(e,t),e!==null&&(Qf(e,t,n),Cs(e,n))}function OO(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),x_(e,n)}function MO(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(je(314))}r!==null&&r.delete(t),x_(e,n)}var w_;w_=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ns.current)ws=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ws=!1,SO(e,t,n);ws=!!(e.flags&131072)}else ws=!1,Bn&&t.flags&1048576&&SE(t,pm,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Fh(e,t),e=t.pendingProps;var s=xu(t,Jr.current);cu(t,n),s=uv(null,t,r,e,s,n);var i=dv();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,js(r)?(i=!0,dm(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,iv(t),s.updater=wg,t.stateNode=s,s._reactInternals=t,hw(t,r,e,n),t=yw(null,t,r,!0,i,n)):(t.tag=0,Bn&&i&&Qb(t),is(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Fh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=DO(r),e=Ti(r,e),s){case 0:t=gw(null,t,r,e,n);break e;case 1:t=Vk(null,t,r,e,n);break e;case 11:t=Hk(null,t,r,e,n);break e;case 14:t=Wk(null,t,r,Ti(r.type,e),n);break e}throw Error(je(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ti(r,s),gw(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ti(r,s),Vk(e,t,r,s,n);case 3:e:{if(n_(t),e===null)throw Error(je(387));r=t.pendingProps,i=t.memoizedState,s=i.element,PE(e,t),gm(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=ku(Error(je(423)),t),t=Uk(e,t,r,n,s);break e}else if(r!==s){s=ku(Error(je(424)),t),t=Uk(e,t,r,n,s);break e}else for(Ws=Wa(t.stateNode.containerInfo.firstChild),Us=t,Bn=!0,Oi=null,n=EE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(wu(),r===s){t=ta(e,t,n);break e}is(e,t,r,n)}t=t.child}return t;case 5:return AE(t),e===null&&dw(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,ow(r,s)?a=null:i!==null&&ow(r,i)&&(t.flags|=32),t_(e,t),is(e,t,a,n),t.child;case 6:return e===null&&dw(t),null;case 13:return r_(e,t,n);case 4:return ov(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=bu(t,null,r,n):is(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ti(r,s),Hk(e,t,r,s,n);case 7:return is(e,t,t.pendingProps,n),t.child;case 8:return is(e,t,t.pendingProps.children,n),t.child;case 12:return is(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,En(hm,r._currentValue),r._currentValue=a,i!==null)if(Hi(i.value,a)){if(i.children===s.children&&!Ns.current){t=ta(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=Jo(-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),fw(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(je(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),fw(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}is(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,cu(t,n),s=gi(s),r=r(s),t.flags|=1,is(e,t,r,n),t.child;case 14:return r=t.type,s=Ti(r,t.pendingProps),s=Ti(r.type,s),Wk(e,t,r,s,n);case 15:return ZE(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ti(r,s),Fh(e,t),t.tag=1,js(r)?(e=!0,dm(t)):e=!1,cu(t,n),XE(t,r,s),hw(t,r,s,n),yw(null,t,r,!0,e,n);case 19:return s_(e,t,n);case 22:return e_(e,t,n)}throw Error(je(156,t.tag))};function b_(e,t){return qC(e,t)}function $O(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 hi(e,t,n,r){return new $O(e,t,n,r)}function vv(e){return e=e.prototype,!(!e||!e.isReactComponent)}function DO(e){if(typeof e=="function")return vv(e)?1:0;if(e!=null){if(e=e.$$typeof,e===zb)return 11;if(e===Bb)return 14}return 2}function qa(e,t){var n=e.alternate;return n===null?(n=hi(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 Hh(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")vv(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Hc:return Hl(n.children,s,i,t);case Fb:a=8,s|=8;break;case Dx:return e=hi(12,n,t,s|2),e.elementType=Dx,e.lanes=i,e;case Fx:return e=hi(13,n,t,s),e.elementType=Fx,e.lanes=i,e;case zx:return e=hi(19,n,t,s),e.elementType=zx,e.lanes=i,e;case AC:return kg(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case _C:a=10;break e;case PC:a=9;break e;case zb:a=11;break e;case Bb:a=14;break e;case Pa:a=16,r=null;break e}throw Error(je(130,e==null?e:typeof e,""))}return t=hi(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Hl(e,t,n,r){return e=hi(7,e,r,t),e.lanes=n,e}function kg(e,t,n,r){return e=hi(22,e,r,t),e.elementType=AC,e.lanes=n,e.stateNode={isHidden:!1},e}function Fy(e,t,n){return e=hi(6,e,null,t),e.lanes=n,e}function zy(e,t,n){return t=hi(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function FO(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=by(0),this.expirationTimes=by(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=by(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function kv(e,t,n,r,s,i,a,l,c){return e=new FO(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=hi(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},iv(i),e}function zO(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Bc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function v_(e){if(!e)return Za;e=e._reactInternals;e:{if(oc(e)!==e||e.tag!==1)throw Error(je(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(js(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(je(171))}if(e.tag===1){var n=e.type;if(js(n))return vE(e,n,t)}return t}function k_(e,t,n,r,s,i,a,l,c){return e=kv(n,r,!0,e,s,i,a,l,c),e.context=v_(null),n=e.current,r=as(),s=Ka(n),i=Jo(r,s),i.callback=t??null,Va(n,i,s),e.current.lanes=s,Qf(e,s,r),Cs(e,r),e}function Sg(e,t,n,r){var s=t.current,i=as(),a=Ka(s);return n=v_(n),t.context===null?t.context=n:t.pendingContext=n,t=Jo(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Va(s,t,a),e!==null&&(Bi(e,s,a,i),Mh(e,s,a)),a}function Nm(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 tS(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Sv(e,t){tS(e,t),(e=e.alternate)&&tS(e,t)}function BO(){return null}var S_=typeof reportError=="function"?reportError:function(e){console.error(e)};function Nv(e){this._internalRoot=e}Ng.prototype.render=Nv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(je(409));Sg(e,t,null,null)};Ng.prototype.unmount=Nv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ql(function(){Sg(null,e,null,null)}),t[Zo]=null}};function Ng(e){this._internalRoot=e}Ng.prototype.unstable_scheduleHydration=function(e){if(e){var t=eE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ra.length&&t!==0&&t<Ra[n].priority;n++);Ra.splice(n,0,e),n===0&&nE(e)}};function jv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function jg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function nS(){}function HO(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=Nm(a);i.call(d)}}var a=k_(t,r,e,0,null,!1,!1,"",nS);return e._reactRootContainer=a,e[Zo]=a.current,bf(e.nodeType===8?e.parentNode:e),Ql(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=Nm(c);l.call(d)}}var c=kv(e,0,!1,null,null,!1,!1,"",nS);return e._reactRootContainer=c,e[Zo]=c.current,bf(e.nodeType===8?e.parentNode:e),Ql(function(){Sg(t,c,n,r)}),c}function Cg(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=Nm(a);l.call(c)}}Sg(t,a,e,s)}else a=HO(n,t,e,s,r);return Nm(a)}QC=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=$d(t.pendingLanes);n!==0&&(Vb(t,n|1),Cs(t,ir()),!(qt&6)&&(Su=ir()+500,ll()))}break;case 13:Ql(function(){var r=ea(e,1);if(r!==null){var s=as();Bi(r,e,1,s)}}),Sv(e,1)}};Ub=function(e){if(e.tag===13){var t=ea(e,134217728);if(t!==null){var n=as();Bi(t,e,134217728,n)}Sv(e,134217728)}};ZC=function(e){if(e.tag===13){var t=Ka(e),n=ea(e,t);if(n!==null){var r=as();Bi(n,e,t,r)}Sv(e,t)}};eE=function(){return un};tE=function(e,t){var n=un;try{return un=e,t()}finally{un=n}};Xx=function(e,t,n){switch(t){case"input":if(Wx(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=gg(r);if(!s)throw Error(je(90));TC(r),Wx(r,s)}}}break;case"textarea":LC(e,n);break;case"select":t=n.value,t!=null&&iu(e,!!n.multiple,t,!1)}};BC=xv;HC=Ql;var WO={usingClientEntryPoint:!1,Events:[ep,Kc,gg,FC,zC,xv]},Nd={findFiberByHostInstance:$l,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},VO={bundleType:Nd.bundleType,version:Nd.version,rendererPackageName:Nd.rendererPackageName,rendererConfig:Nd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ia.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=UC(e),e===null?null:e.stateNode},findFiberByHostInstance:Nd.findFiberByHostInstance||BO,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 nh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nh.isDisabled&&nh.supportsFiber)try{fg=nh.inject(VO),xo=nh}catch{}}Gs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=WO;Gs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!jv(t))throw Error(je(200));return zO(e,t,null,n)};Gs.createRoot=function(e,t){if(!jv(e))throw Error(je(299));var n=!1,r="",s=S_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=kv(e,1,!1,null,null,n,!1,r,s),e[Zo]=t.current,bf(e.nodeType===8?e.parentNode:e),new Nv(t)};Gs.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(je(188)):(e=Object.keys(e).join(","),Error(je(268,e)));return e=UC(t),e=e===null?null:e.stateNode,e};Gs.flushSync=function(e){return Ql(e)};Gs.hydrate=function(e,t,n){if(!jg(t))throw Error(je(200));return Cg(null,e,t,!0,n)};Gs.hydrateRoot=function(e,t,n){if(!jv(e))throw Error(je(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=S_;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=k_(t,null,e,1,n??null,s,!1,i,a),e[Zo]=t.current,bf(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 Ng(t)};Gs.render=function(e,t,n){if(!jg(t))throw Error(je(200));return Cg(null,e,t,!1,n)};Gs.unmountComponentAtNode=function(e){if(!jg(e))throw Error(je(40));return e._reactRootContainer?(Ql(function(){Cg(null,null,e,!1,function(){e._reactRootContainer=null,e[Zo]=null})}),!0):!1};Gs.unstable_batchedUpdates=xv;Gs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!jg(n))throw Error(je(200));if(e==null||e._reactInternals===void 0)throw Error(je(38));return Cg(e,t,n,!1,r)};Gs.version="18.3.1-next-f1338f8080-20240426";function N_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(N_)}catch(e){console.error(e)}}N_(),NC.exports=Gs;var $r=NC.exports,rS=$r;Mx.createRoot=rS.createRoot,Mx.hydrateRoot=rS.hydrateRoot;const j_=h.createContext(null);function Pw(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function UO(){const e=Pw(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function KO({children:e}){const[t,n]=h.useState(UO);h.useEffect(()=>{const i=()=>n(Pw(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=Pw(l.pathname),d=l.search||"";window.history.pushState({},"",c+d),n(c)},[]),s=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(j_.Provider,{value:s,children:e})}function Co(){const e=h.useContext(j_);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function qO(){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 sS={};function Aw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&sS[t[0]]||(typeof t[0]=="string"&&(sS[t[0]]=new Date),qO(...t))}const C_=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function iS(e,t,n){e.loadNamespaces(t,C_(e,n))}function oS(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,C_(e,r))}function YO(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 GO(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Aw("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}}):YO(e,t,n)}const XO=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,JO={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},QO=e=>JO[e],ZO=e=>e.replace(XO,QO);let Iw={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:ZO};function eM(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Iw={...Iw,...e}}function tM(){return Iw}let E_;function nM(e){E_=e}function rM(){return E_}const sM={type:"3rdParty",init(e){eM(e.options.react),nM(e)}},iM=h.createContext();class oM{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const aM=(e,t)=>{const n=h.useRef();return h.useEffect(()=>{n.current=e},[e,t]),n.current};function Pn(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=h.useContext(iM)||{},i=n||r||rM();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new oM),!i){Aw("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&&Aw("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...tM(),...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=>GO(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=aM(g),v=h.useRef(!0);h.useEffect(()=>{const{bindI18n:w,bindI18nStore:j}=a;v.current=!0,!f&&!l&&(t.lng?oS(i,t.lng,d,()=>{v.current&&m(u)}):iS(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?oS(i,t.lng,d,()=>w()):iS(i,d,()=>w())})}const __="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",lM=[{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"}],cM=[{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 uM(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function dM({authUser:e,onLogout:t}){const{path:n,navigate:r}=Co(),{t:s}=Pn(),[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:__,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:lM.map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(uM(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&&cM.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 P_="agentflow.pipelineRecent",fM=50,pM=15;function hM(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function A_(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(P_);return e?hM(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 rh(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=A_(),i=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,fM);try{localStorage.setItem(P_,JSON.stringify(i))}catch{}}function mM(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 Tw(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 gM(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 yM(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:mM(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,pM)}var Bs=Uint8Array,Zc=Uint16Array,xM=Int32Array,I_=new Bs([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]),T_=new Bs([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]),wM=new Bs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),R_=function(e,t){for(var n=new Zc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new xM(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}},L_=R_(I_,2),O_=L_.b,bM=L_.r;O_[28]=258,bM[258]=28;var vM=R_(T_,0),kM=vM.b,Rw=new Zc(32768);for(var Rn=0;Rn<32768;++Rn){var Sa=(Rn&43690)>>1|(Rn&21845)<<1;Sa=(Sa&52428)>>2|(Sa&13107)<<2,Sa=(Sa&61680)>>4|(Sa&3855)<<4,Rw[Rn]=((Sa&65280)>>8|(Sa&255)<<8)>>1}var tf=function(e,t,n){for(var r=e.length,s=0,i=new Zc(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new Zc(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new Zc(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[Rw[u]>>c]=d}else for(l=new Zc(r),s=0;s<r;++s)e[s]&&(l[s]=Rw[a[e[s]-1]++]>>15-e[s]);return l},np=new Bs(288);for(var Rn=0;Rn<144;++Rn)np[Rn]=8;for(var Rn=144;Rn<256;++Rn)np[Rn]=9;for(var Rn=256;Rn<280;++Rn)np[Rn]=7;for(var Rn=280;Rn<288;++Rn)np[Rn]=8;var M_=new Bs(32);for(var Rn=0;Rn<32;++Rn)M_[Rn]=5;var SM=tf(np,9,1),NM=tf(M_,5,1),By=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ai=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Hy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},jM=function(e){return(e+7)/8|0},Cv=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Bs(e.subarray(t,n))},CM=["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"],ci=function(e,t,n){var r=new Error(t||CM[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,ci),!n)throw r;return r},EM=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new Bs(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new Bs(s*3));var d=function(we){var Pe=n.length;if(we>Pe){var Te=new Bs(Math.max(Pe*2,we));Te.set(n),n=Te}},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=Ai(e,u,1);var k=Ai(e,u+1,3);if(u+=3,k)if(k==1)m=SM,g=NM,b=9,v=5;else if(k==2){var C=Ai(e,u,31)+257,$=Ai(e,u+10,15)+4,B=C+Ai(e,u+5,31)+1;u+=14;for(var F=new Bs(B),z=new Bs(19),L=0;L<$;++L)z[wM[L]]=Ai(e,u+L*3,7);u+=$*3;for(var O=By(z),W=(1<<O)-1,M=tf(z,O,1),L=0;L<B;){var T=M[Ai(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+Ai(e,u,3),u+=2,E=F[L-1]):w==17?(D=3+Ai(e,u,7),u+=3):w==18&&(D=11+Ai(e,u,127),u+=7);D--;)F[L++]=E}}var _=F.subarray(0,C),R=F.subarray(C);b=By(_),v=By(R),m=tf(_,b,1),g=tf(R,v,1)}else ci(1);else{var w=jM(u)+4,j=e[w-4]|e[w-3]<<8,A=w+j;if(A>s){c&&ci(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&&ci(0);break}}l&&d(p+131072);for(var P=(1<<b)-1,X=(1<<v)-1,Z=u;;Z=u){var E=m[Hy(e,u)&P],V=E>>4;if(u+=E&15,u>y){c&&ci(0);break}if(E||ci(2),V<256)n[p++]=V;else if(V==256){Z=u,m=null;break}else{var ne=V-254;if(V>264){var L=V-257,ue=I_[L];ne=Ai(e,u,(1<<ue)-1)+O_[L],u+=ue}var pe=g[Hy(e,u)&X],ge=pe>>4;pe||ci(3),u+=pe&15;var R=kM[ge];if(ge>3){var ue=T_[ge];R+=Hy(e,u)&(1<<ue)-1,u+=ue}if(u>y){c&&ci(0);break}l&&d(p+131072);var ae=p+ne;if(p<R){var be=i-R,Ae=Math.min(R,ae);for(be+p<0&&ci(3);p<Ae;++p)n[p]=r[be+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?Cv(n,0,p):n.subarray(0,p)},_M=new Bs(0),mo=function(e,t){return e[t]|e[t+1]<<8},Mi=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Wy=function(e,t){return Mi(e,t)+Mi(e,t+4)*4294967296};function PM(e,t){return EM(e,{i:2},t&&t.out,t&&t.dictionary)}var Lw=typeof TextDecoder<"u"&&new TextDecoder,AM=0;try{Lw.decode(_M,{stream:!0}),AM=1}catch{}var IM=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:Cv(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 TM(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(Lw)return Lw.decode(e);var s=IM(e),i=s.s,n=s.r;return n.length&&ci(8),i}}var RM=function(e,t){return t+30+mo(e,t+26)+mo(e,t+28)},LM=function(e,t,n){var r=mo(e,t+28),s=TM(e.subarray(t+46,t+46+r),!(mo(e,t+8)&2048)),i=t+46+r,a=Mi(e,t+20),l=n&&a==4294967295?OM(e,i):[a,Mi(e,t+24),Mi(e,t+42)],c=l[0],d=l[1],f=l[2];return[mo(e,t+10),c,d,s,i+mo(e,t+30)+mo(e,t+32),f]},OM=function(e,t){for(;mo(e,t)!=1;t+=4+mo(e,t+2));return[Wy(e,t+12),Wy(e,t+4),Wy(e,t+20)]};function MM(e,t){for(var n={},r=e.length-22;Mi(e,r)!=101010256;--r)(!r||e.length-r>65558)&&ci(13);var s=mo(e,r+8);if(!s)return{};var i=Mi(e,r+16),a=i==4294967295||s==65535;if(a){var l=Mi(e,r-12);a=Mi(e,l)==101075792,a&&(s=Mi(e,l+32),i=Mi(e,l+48))}for(var c=0;c<s;++c){var d=LM(e,i,a),f=d[0],u=d[1],p=d[2],m=d[3],g=d[4],b=d[5],v=RM(e,b);i=g,f?f==8?n[m]=PM(e.subarray(v,v+u),{out:new Bs(p)}):ci(14,"unknown compression type "+f):n[m]=Cv(e,v,v+u)}return n}const $M=8*1024*1024,DM=500;function FM(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 zM(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function BM(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 HM=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function WM(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=MM(t),r=new Map;let s=0,i=0;for(const[c,d]of Object.entries(n)){if(c.endsWith("/"))continue;const f=FM(c);if(!f||zM(f))continue;const u=(d==null?void 0:d.length)??0;if(s+=u,s>$M||(i+=1,i>DM))return null;r.set(f,u)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const d=BM(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 HM.test(l)?l:null}catch{return null}}const Vy=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function VM({file:e,onClose:t,onImported:n}){const{t:r}=Pn(),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 WM(y)||"",!B){const F=C.replace(/\.zip$/i,"");Vy.test(F)&&(B=F)}}else if($.endsWith(".yaml")||$.endsWith(".yml")){const F=C.replace(/\.ya?ml$/i,"");Vy.test(F)&&(B=F)}A||c(B)})(),()=>{A=!0}},[y]);const k=l.trim(),w=k.length>0&&Vy.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 UM=/^[a-zA-Z][a-zA-Z0-9_-]*$/,aS="af:newPipelineGuide";function KM({open:e,onClose:t,onCreated:n}){const{t:r}=Pn(),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(aS)==="true"&&y(!0);const $=requestAnimationFrame(()=>{var B;return(B=i.current)==null?void 0:B.focus()});return()=>cancelAnimationFrame($)},[e]);const k=()=>{localStorage.removeItem(aS),y(!1)};if(!e)return null;const w=a.trim(),j=w.length>0&&UM.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 $_="agentflow.pipelineViewPreference";function D_(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function F_(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem($_)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function qM(e){if(!(typeof localStorage>"u"))try{localStorage.setItem($_,JSON.stringify(e))}catch{}}function jm(e){return e==="display"?"display":e==="pipeline"?"pipeline":"workspace"}function YM(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function z_(e,t,n,r=!1){if(!e)return;const s=F_();s[D_(e,t,r)]={view:jm(n),at:Date.now()},qM(s)}function GM(e,t="workspace"){if(!(e!=null&&e.id))return jm(t);const r=F_()[D_(e.id,e.source??"user",!!e.archived)],s=jm((r==null?void 0:r.view)||t);return s==="pipeline"&&!YM(e)?"workspace":s}function Cm(e,t="workspace"){const n=jm(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 sh(e,t="workspace"){return Cm(e,GM(e,t))}function XM(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 Ow(e){return String((e==null?void 0:e.version)||"").trim()}function JM(e){const t=Ow(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 QM({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(X=>X.slug===W||X.name===W||X.id===W)||E[0],_=Ow(O),R=String((D==null?void 0:D.version)||"").trim();let P="unknown";return D?_&&R?P=XM(_,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:Ow(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:JM(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 Ya(e){return(Array.isArray(e==null?void 0:e.collections)?e.collections:[]).filter(n=>n&&typeof n=="object").map(n=>({id:String(n.id||n.name||"").trim(),name:String(n.name||n.id||"").trim(),skillKeys:Array.from(new Set((Array.isArray(n.skillKeys)?n.skillKeys:[]).map(r=>String(r||"").trim()).filter(Boolean))),builtin:!!n.builtin,createdAt:Number.isFinite(n.createdAt)?Number(n.createdAt):Date.now(),updatedAt:Number.isFinite(n.updatedAt)?Number(n.updatedAt):Date.now()})).filter(n=>n.id&&n.name)}function ZM(e){return{version:1,collections:Ya({collections:e})}}function el(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 B_(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 H_(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function W_(e,t,n){const r=el(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 e$(e,t,n){const r=String(e||"").trim().toLowerCase(),s=Ya({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return el(s,t)}function V_(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),i=String(t||"").trim().toLowerCase(),a=Ya({collections:r}),l=e$(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=el(y,n);return k.length>0&&k.every(w=>m.has(w))});return l.length>0&&v&&!b?c:p}}}catch{}return c}function jd(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 t$(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 Mw(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 U_(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 n$="project:defaultCardDesc";function K_(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(n$)}function r$(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(`(${r$(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 s$(e,t,n){const r=[String(e.id),K_(e,n),U_(e),Mw(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
+ `).toLowerCase()}function i$(e,t,n){return t?s$(e,t,n).includes(t):!0}function o$(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 Uy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
+ `).toLowerCase().includes(n):!0}function lS(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 cS(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const a$=["all","agent","control","provide","marketplace"],l$=["all","agent","control","provide"],q_="agentflow.projects.activityPanelOpen",$w="agentflow.projects.activitySelected";function c$(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(q_);return e!=="0"}function uS(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function u$(){return typeof localStorage>"u"?"":localStorage.getItem($w)||""}function ih(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function zn(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 Na(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function Y_(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 G_(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 Dw(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 dS(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Dw(e,t))}function d$(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function fS(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 f$(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 Ky(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function p$(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 h$(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 m$(e){var b,v,y,k;const t=Y_(e),n=G_(e),r=new Map(t.map((w,j)=>[Dw(w,j),dS(w,j)])),s=t.map((w,j)=>({id:Dw(w,j),title:dS(w,j),meta:d$(w)})),i=n.map((w,j)=>{const A=fS(w,"source"),C=fS(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:f$(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=h$(s,i),d=s.map(w=>{const j=p$(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 Ic({resourceKind:e="",authUser:t=null}){var xi,dn,Qs,wi,Zs,Rs;const{t:n}=Pn(),{navigate:r,path:s}=Co(),[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),[X,Z]=h.useState(""),[V,ne]=h.useState(c$),[ue,pe]=h.useState(u$),[ge,ae]=h.useState("all"),[be,Ae]=h.useState(""),[we,Pe]=h.useState("overview"),[Te,it]=h.useState({}),[ct,tt]=h.useState(""),[jt,Ye]=h.useState({}),[kt,nn]=h.useState(""),[vn,Mn]=h.useState(""),[Ht,$n]=h.useState({}),[Wn,le]=h.useState(""),[de,He]=h.useState(""),[Ze,ot]=h.useState(""),[Xt,rn]=h.useState(""),[sn,An]=h.useState(""),[Sr,Jt]=h.useState(!1),[mn,Vn]=h.useState(""),[or,ye]=h.useState({hiddenBuiltins:[],promoted:[]}),Ie=h.useRef(0),nt=h.useRef(0),Ct=h.useCallback(async()=>{var he,Me;const K=++nt.current;B("");try{const Re=await fetch("/api/flows");if(K!==nt.current)return;if(!Re.ok)throw new Error("HTTP "+Re.status);const Qe=await Re.json();if(K!==nt.current)return;c(Array.isArray(Qe)?Qe:[])}catch(Re){if(K!==nt.current)return;c([]),B(String(Re.message||Re))}try{const Re=await fetch("/api/pipeline-recent-runs");if(K!==nt.current)return;if(Re.ok){const Qe=await Re.json();if(K!==nt.current)return;C(Array.isArray(Qe.runs)?Qe.runs:[])}else C([])}catch{if(K!==nt.current)return;C([])}if(t!=null&&t.isAdmin)try{const Re=await fetch("/api/admin/builtin-flows");if(K!==nt.current)return;const Qe=await Re.json().catch(()=>({}));Re.ok&&ye({hiddenBuiltins:Array.isArray((he=Qe==null?void 0:Qe.config)==null?void 0:he.hiddenBuiltins)?Qe.config.hiddenBuiltins:[],promoted:Array.isArray((Me=Qe==null?void 0:Qe.config)==null?void 0:Me.promoted)?Qe.config.promoted:[]})}catch{if(K!==nt.current)return;ye({hiddenBuiltins:[],promoted:[]})}else ye({hiddenBuiltins:[],promoted:[]});O(!0)},[t==null?void 0:t.isAdmin]),ie=h.useCallback(async(K,he)=>{if(!(t!=null&&t.isAdmin)||!(K!=null&&K.id))return;const Me=`${he}:${K.source}:${K.id}`;Vn(Me),B("");try{const Re=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:he,flowId:K.id,ownerUserId:K.ownerUserId||t.userId})}),Qe=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(Qe.error||"更新内置配置失败");await Ct()}catch(Re){B(String(Re.message||Re))}finally{Vn("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,Ct]),_e=h.useCallback(async()=>{z(""),M(!1);try{const[K,he,Me,Re]=await Promise.all([fetch("/api/nodes"),fetch("/api/skills"),fetch("/api/skill-collections"),fetch("/api/marketplace/flow-snippets")]),Qe=await K.json().catch(()=>({})),Dt=await he.json().catch(()=>({})),Ot=await Me.json().catch(()=>({})),Un=await Re.json().catch(()=>({}));if(!K.ok)throw new Error(Qe.error||"Nodes HTTP "+K.status);if(!he.ok)throw new Error(Dt.error||"Skills HTTP "+he.status);if(!Me.ok)throw new Error(Ot.error||"Collections HTTP "+Me.status);if(!Re.ok)throw new Error(Un.error||"Flow snippets HTTP "+Re.status);f(Array.isArray(Qe.nodes)?Qe.nodes:Array.isArray(Qe)?Qe:[]),p(Array.isArray(Dt.skills)?Dt.skills:[]),v(Ya(Ot)),g(Array.isArray(Un.snippets)?Un.snippets:[])}catch(K){f([]),p([]),g([]),v([]),z(String(K.message||K))}finally{M(!0)}},[]);h.useEffect(()=>{O(!1),Ct(),_e()},[Ct,_e]),h.useEffect(()=>{try{localStorage.setItem(q_,V?"1":"0")}catch{}},[V]),h.useEffect(()=>{try{ue?localStorage.setItem($w,ue):localStorage.removeItem($w)}catch{}},[ue]),h.useEffect(()=>{let K=!1;return fetch("/api/ui-context").then(he=>he.json()).then(he=>{K||Jt(!!he.hideCommunityLinks)}).catch(()=>{}),()=>{K=!0}},[]);const et=h.useCallback(async K=>{const he=Ya({collections:K});j(!0),z("");try{const Me=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ZM(he))}),Re=await Me.json().catch(()=>({}));if(!Me.ok)throw new Error(Re.error||"Collections HTTP "+Me.status);v(Ya(Re))}catch(Me){z(String(Me.message||Me))}finally{j(!1)}},[]),$t=h.useCallback(()=>{const K=y.trim();if(!K)return;const he=K.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Me=new Set(b.map(Ot=>Ot.id));let Re=he,Qe=2;for(;Me.has(Re);)Re=`${he}-${Qe++}`;const Dt=Date.now();et([...b,{id:Re,name:K,skillKeys:[],createdAt:Dt,updatedAt:Dt}]),k(""),ae(`collection:${Re}`)},[y,et,b]),Qt=h.useCallback(K=>{const he=b.find(Re=>Re.id===K);if(he!=null&&he.builtin)return;const Me=b.filter(Re=>Re.id!==K);ge===`collection:${K}`&&ae("all"),et(Me)},[ge,et,b]),ar=h.useCallback((K,he,Me)=>{const Re=String(he||"").trim();if(!Re)return;const Qe=Date.now(),Dt=b.map(Ot=>{if(Ot.id!==K)return Ot;const Un=new Set(Ot.skillKeys||[]);return Me?Un.add(Re):Un.delete(Re),{...Ot,skillKeys:Array.from(Un),updatedAt:Qe}});et(Dt)},[et,b]),ut=h.useCallback(async K=>{const he=K==null?void 0:K.packageId,Me=K==null?void 0:K.version;if(!he||!Me||!window.confirm(n("project:deleteMyNodeConfirm",{id:he,version:Me})))return;const Re=zn(K);He(Re),ot(""),z("");try{const Qe=new URLSearchParams({id:he,version:Me}),Dt=await fetch(`/api/marketplace/node?${Qe.toString()}`,{method:"DELETE"}),Ot=await Dt.json().catch(()=>({}));if(!Dt.ok||(Ot==null?void 0:Ot.ok)===!1){const Un=Array.isArray(Ot==null?void 0:Ot.usage)&&Ot.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Ot.usage.length})}`:"";throw new Error(((Ot==null?void 0:Ot.error)||"Delete failed")+Un)}ot(n("project:deleteMyNodeSuccess",{id:he,version:Me})),Ye(Un=>{const mr={...Un};return delete mr[Re],mr}),$n(Un=>{const mr={};for(const[To,ua]of Object.entries(Un))To.startsWith(`${Re}:`)||(mr[To]=ua);return mr}),Ae(""),await _e()}catch(Qe){ot(String(Qe.message||Qe))}finally{He("")}},[_e,n]),Nr=h.useCallback(async K=>{const he=K==null?void 0:K.id,Me=(K==null?void 0:K.version)||"1.0.0";if(!he||!Me||!window.confirm(n("project:deleteMyFlowConfirm",{id:he,version:Me})))return;const Re=Na(K);rn(Re),An(""),z("");try{const Qe=new URLSearchParams({id:he,version:Me}),Dt=await fetch(`/api/marketplace/flow-snippet?${Qe.toString()}`,{method:"DELETE"}),Ot=await Dt.json().catch(()=>({}));if(!Dt.ok||(Ot==null?void 0:Ot.ok)===!1)throw new Error((Ot==null?void 0:Ot.error)||"Delete failed");An(n("project:deleteMyFlowSuccess",{id:he,version:Me})),Ae(""),await _e()}catch(Qe){An(String(Qe.message||Qe))}finally{rn("")}},[_e,n]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){a(e),ae("all"),Ae(""),Pe("overview");return}a(K=>K==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const K=new URLSearchParams(window.location.search);let he=!1;if(K.get("tab")==="nodes"){r("/nodes");return}if(K.get("tab")==="my-nodes"){r("/my-nodes");return}if(K.get("tab")==="my-flows"){r("/my-flows");return}if(K.get("tab")==="skills"){r("/skills");return}if(K.get("tab")==="archived"&&(a("archived"),K.delete("tab"),he=!0),K.get("new")==="1"&&(E(!0),K.delete("new"),he=!0),he){const Me=K.toString();window.history.replaceState({},"",Me?`/projects?${Me}`:"/projects")}},[s,r]);const Hr=h.useMemo(()=>yM(A,A_(),l),[A,l,s]),Js=h.useMemo(()=>Hr.filter(K=>o$(X,K)),[Hr,X]),Dn=X.trim().toLowerCase(),us=h.useMemo(()=>i==="archived"?l.filter(K=>K.archived):l.filter(K=>!K.archived),[l,i]),qi=h.useMemo(()=>us.filter(K=>i$(K,Dn,n)),[us,Dn,n]),Po=h.useMemo(()=>new Set((or.promoted||[]).map(K=>String((K==null?void 0:K.id)||"").trim()).filter(Boolean)),[or.promoted]),Ao=h.useMemo(()=>(or.hiddenBuiltins||[]).map(K=>String(K||"").trim()).filter(Boolean),[or.hiddenBuiltins]),Ee=i==="nodes"||i==="my-nodes",Oe=i==="my-nodes",Zt=i==="my-flows",Tr=h.useMemo(()=>d.filter(K=>Oe&&K.source!=="marketplace"?!1:(ge==="all"||(ge==="marketplace"?K.source==="marketplace":K.type===ge))&&Uy(X,[K.id,K.label,K.displayName,K.description,K.type,K.source,K.packageId,K.version])),[d,Oe,X,ge]),xt=h.useMemo(()=>{const K=new Map;for(const he of b)K.set(he.id,new Set(he.skillKeys||[]));return K},[b]),es=h.useMemo(()=>[{id:"all",label:"全部"},...b.map(K=>({id:`collection:${K.id}`,label:K.name,count:K.skillKeys.length,collection:K})),{id:"ungrouped",label:"未分组"}],[b]),Qn=h.useMemo(()=>u.filter(K=>{var Re;const he=zn(K);let Me=ge==="all";if(ge.startsWith("collection:")){const Qe=ge.slice(11);Me=!!((Re=xt.get(Qe))!=null&&Re.has(he))}else ge==="ungrouped"&&(Me=!Array.from(xt.values()).some(Qe=>Qe.has(he)));return Me&&Uy(X,[K.name,K.id,K.description,K.sourceLabel,K.source,K.path])}),[u,X,ge,xt]),Fn=h.useMemo(()=>m.filter(K=>Uy(X,[K.id,K.name,K.displayName,K.description,K.version,K.packageDir,Array.isArray(K.tags)?K.tags.join(" "):""])),[m,X]),Is=Ee||Zt||i==="skills",lt=h.useMemo(()=>Tr.find(K=>zn(K)===be)||Tr[0]||null,[Tr,be]),on=h.useMemo(()=>Qn.find(K=>zn(K)===be)||Qn[0]||null,[Qn,be]),Lt=h.useMemo(()=>Fn.find(K=>Na(K)===be)||Fn[0]||null,[Fn,be]),ds=on?Te[zn(on)]:null,Be=lt?jt[zn(lt)]:null,pr=lt&&vn?Ht[`${zn(lt)}:${vn}`]:null,Zn=n(Ee?"project:searchNodes":Zt?"project:searchFlows":i==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(i!=="skills"||!on)return;const K=zn(on);if(Te[K])return;let he=!1;return tt(K),fetch(`/api/skills/detail?key=${encodeURIComponent(K)}`).then(Me=>Me.json().then(Re=>({ok:Me.ok,json:Re}))).then(({ok:Me,json:Re})=>{he||Me&&Re.skill&&it(Qe=>({...Qe,[K]:Re.skill}))}).catch(()=>{}).finally(()=>{he||tt("")}),()=>{he=!0}},[i,on,Te]),h.useEffect(()=>{if(!Ee||!lt)return;const K=zn(lt);if(jt[K])return;let he=!1;return nn(K),fetch(`/api/nodes/detail?id=${encodeURIComponent(lt.id)}`).then(Me=>Me.json().then(Re=>({ok:Me.ok,json:Re}))).then(({ok:Me,json:Re})=>{he||Me&&Ye(Qe=>({...Qe,[K]:Re}))}).catch(()=>{}).finally(()=>{he||nn("")}),()=>{he=!0}},[Ee,lt,jt]),h.useEffect(()=>{if(!Ee)return;const K=Array.isArray(Be==null?void 0:Be.files)?Be.files:[];Mn(he=>{var Me;return he&&K.some(Re=>Re.path===he)?he:((Me=K[0])==null?void 0:Me.path)||""})},[Ee,Be]),h.useEffect(()=>{if(!Ee||!lt||!vn)return;const K=`${zn(lt)}:${vn}`;if(Ht[K])return;let he=!1;return le(K),fetch(`/api/nodes/file?id=${encodeURIComponent(lt.id)}&path=${encodeURIComponent(vn)}`).then(Me=>Me.json().then(Re=>({ok:Me.ok,json:Re}))).then(({ok:Me,json:Re})=>{he||Me&&$n(Qe=>({...Qe,[K]:Re}))}).catch(()=>{}).finally(()=>{he||le("")}),()=>{he=!0}},[Ee,lt,vn,Ht]),h.useEffect(()=>{ot("")},[be,i]);const la=K=>{r(sh(K,"workspace"))},ca=K=>{pe(uS(K)),r(sh({id:K.flowId,source:K.flowSource,archived:!!K.archived},"workspace"))},Io=h.useCallback(K=>{var he,Me;K.preventDefault(),K.stopPropagation(),(Me=(he=K.dataTransfer)==null?void 0:he.types)!=null&&Me.includes("Files")&&(Ie.current+=1,P(!0))},[]),hr=h.useCallback(K=>{K.preventDefault(),K.stopPropagation(),Ie.current-=1,Ie.current<=0&&(Ie.current=0,P(!1))},[]),Ts=h.useCallback(K=>{K.preventDefault(),K.stopPropagation()},[]),fs=h.useCallback(K=>{var Re,Qe;K.preventDefault(),K.stopPropagation(),Ie.current=0,P(!1);const he=(Qe=(Re=K.dataTransfer)==null?void 0:Re.files)==null?void 0:Qe[0];if(!he)return;const Me=he.name.toLowerCase();!Me.endsWith(".yaml")&&!Me.endsWith(".yml")&&!Me.endsWith(".zip")||_(he)},[]);return o.jsxs("div",{className:"af-projects"+(R?" af-projects--drop-target":""),onDragEnter:Io,onDragLeave:hr,onDragOver:Ts,onDrop:fs,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"+(X.trim()?" af-search--has-clear":""),type:"search",placeholder:Zn,"aria-label":Zn,autoComplete:"off",value:X,onChange:K=>Z(K.target.value),onKeyDown:K=>{K.key==="Escape"&&(Z(""),K.currentTarget.blur())}}),X.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]}),Is?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>_e(),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:()=>ne(K=>!K),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:Dn?n("project:filterResult",{count:i==="nodes"||i==="my-nodes"?Tr.length:i==="my-flows"?Fn.length:i==="skills"?Qn.length:qi.length}):i==="my-nodes"?n("project:myNodesHint",{count:Tr.length}):i==="my-flows"?n("project:myFlowsHint",{count:Fn.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&&Is?o.jsx("p",{className:"af-err af-projects-api-hint",children:F}):null]}),Is?o.jsxs("div",{className:"af-resource-toolbar",children:[i==="skills"?o.jsx(QM,{onChanged:_e}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:Zt?"schema":Ee?Oe?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(Zt?"project:myFlowsPurposeTitle":Oe?"project:myNodesPurposeTitle":Ee?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(Zt?"project:myFlowsPurposeDesc":Oe?"project:myNodesPurposeDesc":Ee?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),Zt?null:o.jsx("div",{className:"af-resource-filter-row",children:(Ee?(Oe?l$:a$).map(K=>({id:K,label:n(`project:resourceFilter.${K}`)})):es).map(K=>K.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(ge===K.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ae(K.id),Ae("")},children:[K.label,o.jsx("em",{children:K.count}),K.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),K.collection.builtin?null:o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:w,"aria-label":`删除 ${K.collection.name}`,onClick:()=>Qt(K.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},K.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(ge===K.id?" af-resource-filter--active":""),onClick:()=>{ae(K.id),Ae("")},children:K.label},K.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:K=>k(K.target.value),onKeyDown:K=>{K.key==="Enter"&&$t()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!y.trim()||w,onClick:()=>$t(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Ee?o.jsx("div",{className:"af-resource-grid",children:Tr.length>0?Tr.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(lt&&zn(K)===zn(lt)?" af-resource-card--active":""),onClick:()=>Ae(zn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:jd(K.type==="control"?"secondary":K.type==="provide"?"primary":"muted"),children:o.jsx(sr,{query:X,children:K.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(sr,{query:X,children:lS(K.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(sr,{query:X,children:K.label||K.displayName||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:X,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(sr,{query:X,children:K.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(K.inputs||{}).length,outputs:Object.keys(K.outputs||{}).length})})]}),K.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:X,children:`${K.packageId}${K.version?` / ${K.version}`:""}`})})]}):null]},`${K.id}:${K.source||""}:${K.packageId||""}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:Dn?n("project:noNodeMatch",{query:X.trim()}):n(Oe?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):Zt?o.jsx("div",{className:"af-resource-grid",children:Fn.length>0?Fn.map(K=>{const he=Y_(K),Me=G_(K),Re=Number.isFinite(Number(K.nodeCount))?Number(K.nodeCount):he.length,Qe=Number.isFinite(Number(K.edgeCount))?Number(K.edgeCount):Me.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(Lt&&Na(K)===Na(Lt)?" af-resource-card--active":""),onClick:()=>Ae(Na(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:jd("primary"),children:o.jsx(sr,{query:X,children:K.version?`v${K.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:X,children:K.displayName||K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:X,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Re,edges:Qe})}),o.jsx("span",{children:o.jsx(sr,{query:X,children:K.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:X,children:cS(K)})})]})]},Na(K))}):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:Dn?n("project:noFlowSnippetMatch",{query:X.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:Qn.length>0?Qn.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(on&&zn(K)===zn(on)?" af-resource-card--active":""),onClick:()=>Ae(zn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:jd(K.source==="builtin"?"muted":"primary"),children:o.jsx(sr,{query:X,children:K.sourceLabel||K.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:X,children:K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:X,children:K.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:X,children:K.path||K.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[b.filter(he=>he.skillKeys.includes(zn(K))).slice(0,3).map(he=>o.jsx("span",{children:he.name},he.id)),b.filter(he=>he.skillKeys.includes(zn(K))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},K.key||`${K.source}:${K.name}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:Dn?n("project:noSkillMatch",{query:X.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"&&Ao.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:Ao.map(K=>{const he=mn===`show-builtin:builtin:${K}`;return o.jsxs("button",{type:"button",disabled:he,onClick:()=>ie({id:K,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:K}),o.jsx("em",{children:he?"恢复中":"恢复"})]},K)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[qi.length>0?qi.map(K=>{const he=(t==null?void 0:t.isAdmin)&&K.source==="user"&&!K.archived&&!Po.has(K.id),Me=(t==null?void 0:t.isAdmin)&&K.source==="admin",Re=(t==null?void 0:t.isAdmin)&&K.source==="builtin",Qe=mn.endsWith(`:${K.source}:${K.id}`);return o.jsx("div",{className:"af-project-card",role:"button",tabIndex:0,onClick:()=>la(K),onKeyDown:Dt=>{(Dt.key==="Enter"||Dt.key===" ")&&(Dt.preventDefault(),la(K))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:jd(Mw(K.source,n).tone),children:o.jsx(sr,{query:X,children:Mw(K.source,n).label})}),K.archived?o.jsx("span",{className:jd("muted"),children:o.jsx(sr,{query:X,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(sr,{query:X,children:K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(sr,{query:X,children:K_(K,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:X,children:U_(K)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Dt=>Dt.stopPropagation(),onKeyDown:Dt=>Dt.stopPropagation(),children:[he?o.jsx("button",{type:"button",disabled:Qe,onClick:()=>ie(K,"promote"),children:"设为内置"}):null,Me?o.jsx("button",{type:"button",disabled:Qe,onClick:()=>ie(K,"unpromote"),children:"取消内置"}):null,Re?o.jsx("button",{type:"button",disabled:Qe,onClick:()=>ie(K,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${K.id}:${K.source??"user"}:${K.archived?"a":""}`)}):L?us.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:X.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")})]}),Sr?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")})]})]})]})]}),Is?o.jsx("aside",{className:"af-resource-detail","aria-label":n(Ee?"project:nodeDetail":Zt?"project:flowDetail":"project:skillDetail"),children:Ee&&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(K=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(we===K?" af-resource-detail-tab--active":""),onClick:()=>Pe(K),children:n(`project:nodeDetailTabs.${K}`)},K))}),kt===zn(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||((xi=Be==null?void 0:Be.node)==null?void 0:xi.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||((dn=Be==null?void 0:Be.node)==null?void 0:dn.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:lS(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||Be!=null&&Be.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:lt.packageDir||(Be==null?void 0:Be.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(Be==null?void 0:Be.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),Oe&&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===zn(lt),onClick:()=>ut(lt),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),de===zn(lt)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),Ze?o.jsx("p",{className:"af-resource-action-message",children:Ze}):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")}),ih(((Qs=Be==null?void 0:Be.node)==null?void 0:Qs.inputs)||lt.inputs).length>0?ih(((wi=Be==null?void 0:Be.node)==null?void 0:wi.inputs)||lt.inputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),ih(((Zs=Be==null?void 0:Be.node)==null?void 0:Zs.outputs)||lt.outputs).length>0?ih(((Rs=Be==null?void 0:Be.node)==null?void 0:Rs.outputs)||lt.outputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.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")}),Be!=null&&Be.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Be.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),Be!=null&&Be.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:Be.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(Be==null?void 0:Be.files)&&Be.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:Be.files.map(K=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(vn===K.path?" af-node-file-item--active":""),onClick:()=>Mn(K.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:K.path})]},K.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[Wn===`${zn(lt)}:${vn}`?n("project:loadingResources"):pr!=null&&pr.binary?n("project:binaryFile"):(pr==null?void 0:pr.content)||n("project:selectNodeFile"),pr!=null&&pr.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(Be==null?void 0:Be.usage)&&Be.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:Be.usage.map(K=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:K.flowId}),o.jsxs("span",{children:[K.flowSource,K.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:K.instances.map(he=>he.label||he.instanceId).join(", ")})]},`${K.flowSource}:${K.flowId}:${K.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):Zt&&Lt?(()=>{const K=m$(Lt);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:Lt.displayName||Lt.name||Lt.id}),o.jsx("p",{children:Lt.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Lt.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:Lt.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:cS(Lt)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Lt.nodeCount))?Number(Lt.nodeCount):K.nodes.length,edges:Number.isFinite(Number(Lt.edgeCount))?Number(Lt.edgeCount):K.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:Xt===Na(Lt),onClick:()=>Nr(Lt),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),Xt===Na(Lt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),sn?o.jsx("p",{className:"af-resource-action-message",children:sn}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),K.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:K.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:K.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:Ky(he.label,18)}):null]},he.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:K.diagram.nodes.map((he,Me)=>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:Me+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:he.height/2-3,children:Ky(he.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:he.height/2+16,children:Ky(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(Lt.snippet||{},null,2)})]})]})]})})():i==="skills"&&on?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:on.name||on.id}),o.jsx("p",{children:on.sourceLabel||on.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:on.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:on.sourceLabel||on.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:on.path||on.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(K=>{const he=zn(on),Me=K.skillKeys.includes(he);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Me,disabled:w,onChange:Re=>ar(K.id,he,Re.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:K.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[K.skillKeys.length," skills"]})]})]},K.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:ct===zn(on)?n("project:loadingResources"):(ds==null?void 0:ds.body)||(ds==null?void 0:ds.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:Js.length===0?o.jsx("p",{className:"af-activity-empty",children:Hr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Js.map(K=>{const he=ue===uS(K);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:()=>ca(K),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(sr,{query:X,children:K.flowId})}),o.jsx("span",{className:"af-activity-time",children:Tw(K.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:t$(K.kind),children:K.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[K.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",Tw(K.at,n)]})]})]},`${K.kind}-${K.flowId}-${K.flowSource}-${K.at}`)})})]})]}),o.jsx(KM,{open:T,onClose:()=>E(!1),onCreated:async K=>{E(!1),await Ct();const he=K.source??"user";r(sh({id:K.id,source:he},"workspace"))}}),D?o.jsx(VM,{file:D,onClose:()=>_(null),onImported:async K=>{_(null),await Ct();const he=K.source??"user";r(sh({id:K.id,source:he},"workspace"))}},`${D.name}-${D.size}-${D.lastModified}`):null]})}function fr(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=fr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var g$={value:()=>{}};function Eg(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Wh(n)}function Wh(e){this._=e}function y$(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Wh.prototype=Eg.prototype={constructor:Wh,on:function(e,t){var n=this._,r=y$(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=x$(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]=pS(n[s],e.name,t);else if(t==null)for(s in n)n[s]=pS(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Wh(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,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 x$(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function pS(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=g$,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Fw="http://www.w3.org/1999/xhtml";const hS={svg:"http://www.w3.org/2000/svg",xhtml:Fw,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _g(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),hS.hasOwnProperty(t)?{space:hS[t],local:e}:e}function w$(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fw&&t.documentElement.namespaceURI===Fw?t.createElement(e):t.createElementNS(n,e)}}function b$(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function X_(e){var t=_g(e);return(t.local?b$:w$)(t)}function v$(){}function Ev(e){return e==null?v$:function(){return this.querySelector(e)}}function k$(e){typeof e!="function"&&(e=Ev(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 Ys(r,this._parents)}function S$(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function N$(){return[]}function J_(e){return e==null?N$:function(){return this.querySelectorAll(e)}}function j$(e){return function(){return S$(e.apply(this,arguments))}}function C$(e){typeof e=="function"?e=j$(e):e=J_(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 Ys(r,s)}function Q_(e){return function(){return this.matches(e)}}function Z_(e){return function(t){return t.matches(e)}}var E$=Array.prototype.find;function _$(e){return function(){return E$.call(this.children,e)}}function P$(){return this.firstElementChild}function A$(e){return this.select(e==null?P$:_$(typeof e=="function"?e:Z_(e)))}var I$=Array.prototype.filter;function T$(){return Array.from(this.children)}function R$(e){return function(){return I$.call(this.children,e)}}function L$(e){return this.selectAll(e==null?T$:R$(typeof e=="function"?e:Z_(e)))}function O$(e){typeof e!="function"&&(e=Q_(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 Ys(r,this._parents)}function eP(e){return new Array(e.length)}function M$(){return new Ys(this._enter||this._groups.map(eP),this._parents)}function Em(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Em.prototype={constructor:Em,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 $$(e){return function(){return e}}function D$(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 Em(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function F$(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 Em(e,i[l]);for(l=0;l<f;++l)(c=t[l])&&d.get(p[l])===c&&(s[l]=c)}function z$(e){return e.__data__}function B$(e,t){if(!arguments.length)return Array.from(this,z$);var n=t?F$:D$,r=this._parents,s=this._groups;typeof e!="function"&&(e=$$(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=H$(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 Ys(a,r),a._enter=l,a._exit=c,a}function H$(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function W$(){return new Ys(this._exit||this._groups.map(eP),this._parents)}function V$(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 U$(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 Ys(l,this._parents)}function K$(){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 q$(e){e||(e=Y$);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 Ys(s,this._parents).order()}function Y$(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function G$(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function X$(){return Array.from(this)}function J$(){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 Q$(){let e=0;for(const t of this)++e;return e}function Z$(){return!this.node()}function eD(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 tD(e){return function(){this.removeAttribute(e)}}function nD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rD(e,t){return function(){this.setAttribute(e,t)}}function sD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function iD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function oD(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 aD(e,t){var n=_g(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?nD:tD:typeof t=="function"?n.local?oD:iD:n.local?sD:rD)(n,t))}function tP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lD(e){return function(){this.style.removeProperty(e)}}function cD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function uD(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function dD(e,t,n){return arguments.length>1?this.each((t==null?lD:typeof t=="function"?uD:cD)(e,t,n??"")):Nu(this.node(),e)}function Nu(e,t){return e.style.getPropertyValue(t)||tP(e).getComputedStyle(e,null).getPropertyValue(t)}function fD(e){return function(){delete this[e]}}function pD(e,t){return function(){this[e]=t}}function hD(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function mD(e,t){return arguments.length>1?this.each((t==null?fD:typeof t=="function"?hD:pD)(e,t)):this.node()[e]}function nP(e){return e.trim().split(/^|\s+/)}function _v(e){return e.classList||new rP(e)}function rP(e){this._node=e,this._names=nP(e.getAttribute("class")||"")}rP.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 sP(e,t){for(var n=_v(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function iP(e,t){for(var n=_v(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function gD(e){return function(){sP(this,e)}}function yD(e){return function(){iP(this,e)}}function xD(e,t){return function(){(t.apply(this,arguments)?sP:iP)(this,e)}}function wD(e,t){var n=nP(e+"");if(arguments.length<2){for(var r=_v(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?xD:t?gD:yD)(n,t))}function bD(){this.textContent=""}function vD(e){return function(){this.textContent=e}}function kD(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function SD(e){return arguments.length?this.each(e==null?bD:(typeof e=="function"?kD:vD)(e)):this.node().textContent}function ND(){this.innerHTML=""}function jD(e){return function(){this.innerHTML=e}}function CD(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ED(e){return arguments.length?this.each(e==null?ND:(typeof e=="function"?CD:jD)(e)):this.node().innerHTML}function _D(){this.nextSibling&&this.parentNode.appendChild(this)}function PD(){return this.each(_D)}function AD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ID(){return this.each(AD)}function TD(e){var t=typeof e=="function"?e:X_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function RD(){return null}function LD(e,t){var n=typeof e=="function"?e:X_(e),r=t==null?RD:typeof t=="function"?t:Ev(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function OD(){var e=this.parentNode;e&&e.removeChild(this)}function MD(){return this.each(OD)}function $D(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function DD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function FD(e){return this.select(e?DD:$D)}function zD(e){return arguments.length?this.property("__data__",e):this.node().__data__}function BD(e){return function(t){e.call(this,t,this.__data__)}}function HD(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 WD(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 VD(e,t,n){return function(){var r=this.__on,s,i=BD(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 UD(e,t,n){var r=HD(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?VD:WD,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function oP(e,t,n){var r=tP(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 KD(e,t){return function(){return oP(this,e,t)}}function qD(e,t){return function(){return oP(this,e,t.apply(this,arguments))}}function YD(e,t){return this.each((typeof t=="function"?qD:KD)(e,t))}function*GD(){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 aP=[null];function Ys(e,t){this._groups=e,this._parents=t}function rp(){return new Ys([[document.documentElement]],aP)}function XD(){return this}Ys.prototype=rp.prototype={constructor:Ys,select:k$,selectAll:C$,selectChild:A$,selectChildren:L$,filter:O$,data:B$,enter:M$,exit:W$,join:V$,merge:U$,selection:XD,order:K$,sort:q$,call:G$,nodes:X$,node:J$,size:Q$,empty:Z$,each:eD,attr:aD,style:dD,property:mD,classed:wD,text:SD,html:ED,raise:PD,lower:ID,append:TD,insert:LD,remove:MD,clone:FD,datum:zD,on:UD,dispatch:YD,[Symbol.iterator]:GD};function Hs(e){return typeof e=="string"?new Ys([[document.querySelector(e)]],[document.documentElement]):new Ys([[e]],aP)}function JD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Li(e,t){if(e=JD(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 QD={passive:!1},Pf={capture:!0,passive:!1};function qy(e){e.stopImmediatePropagation()}function du(e){e.preventDefault(),e.stopImmediatePropagation()}function lP(e){var t=e.document.documentElement,n=Hs(e).on("dragstart.drag",du,Pf);"onselectstart"in t?n.on("selectstart.drag",du,Pf):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function cP(e,t){var n=e.document.documentElement,r=Hs(e).on("dragstart.drag",null);t&&(r.on("click.drag",du,Pf),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 oh=e=>()=>e;function zw(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}})}zw.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ZD(e){return!e.ctrlKey&&!e.button}function eF(){return this.parentNode}function tF(e,t){return t??{x:e.x,y:e.y}}function nF(){return navigator.maxTouchPoints||"ontouchstart"in this}function uP(){var e=ZD,t=eF,n=tF,r=nF,s={},i=Eg("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,QD).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&&(Hs(j.view).on("mousemove.drag",g,Pf).on("mouseup.drag",b,Pf),lP(j.view),qy(j),d=!1,l=j.clientX,c=j.clientY,C("start",j))}}function g(j){if(du(j),!d){var A=j.clientX-l,C=j.clientY-c;d=A*A+C*C>u}s.mouse("drag",j)}function b(j){Hs(j.view).on("mousemove.drag mouseup.drag",null),cP(j.view,d),du(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]))&&(qy(j),z("start",j,C[F]))}}function y(j){var A=j.changedTouches,C=A.length,$,B;for($=0;$<C;++$)(B=s[A[$].identifier])&&(du(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])&&(qy(j),B("end",j,A[$]))}function w(j,A,C,$,B,F){var z=i.copy(),L=Li(F||C,A),O,W,M;if((M=n.call(j,new zw("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=Li(_||D,A),P=a;break}z.call(E,j,new zw(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:oh(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:oh(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:oh(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:oh(!!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 Pv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function dP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function sp(){}var Af=.7,_m=1/Af,fu="\\s*([+-]?\\d+)\\s*",If="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",bo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",rF=/^#([0-9a-f]{3,8})$/,sF=new RegExp(`^rgb\\(${fu},${fu},${fu}\\)$`),iF=new RegExp(`^rgb\\(${bo},${bo},${bo}\\)$`),oF=new RegExp(`^rgba\\(${fu},${fu},${fu},${If}\\)$`),aF=new RegExp(`^rgba\\(${bo},${bo},${bo},${If}\\)$`),lF=new RegExp(`^hsl\\(${If},${bo},${bo}\\)$`),cF=new RegExp(`^hsla\\(${If},${bo},${bo},${If}\\)$`),mS={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};Pv(sp,Zl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:gS,formatHex:gS,formatHex8:uF,formatHsl:dF,formatRgb:yS,toString:yS});function gS(){return this.rgb().formatHex()}function uF(){return this.rgb().formatHex8()}function dF(){return fP(this).formatHsl()}function yS(){return this.rgb().formatRgb()}function Zl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=rF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?xS(t):n===3?new bs(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ah(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ah(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=sF.exec(e))?new bs(t[1],t[2],t[3],1):(t=iF.exec(e))?new bs(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oF.exec(e))?ah(t[1],t[2],t[3],t[4]):(t=aF.exec(e))?ah(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=lF.exec(e))?vS(t[1],t[2]/100,t[3]/100,1):(t=cF.exec(e))?vS(t[1],t[2]/100,t[3]/100,t[4]):mS.hasOwnProperty(e)?xS(mS[e]):e==="transparent"?new bs(NaN,NaN,NaN,0):null}function xS(e){return new bs(e>>16&255,e>>8&255,e&255,1)}function ah(e,t,n,r){return r<=0&&(e=t=n=NaN),new bs(e,t,n,r)}function fF(e){return e instanceof sp||(e=Zl(e)),e?(e=e.rgb(),new bs(e.r,e.g,e.b,e.opacity)):new bs}function Bw(e,t,n,r){return arguments.length===1?fF(e):new bs(e,t,n,r??1)}function bs(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Pv(bs,Bw,dP(sp,{brighter(e){return e=e==null?_m:Math.pow(_m,e),new bs(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Af:Math.pow(Af,e),new bs(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bs(Wl(this.r),Wl(this.g),Wl(this.b),Pm(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:wS,formatHex:wS,formatHex8:pF,formatRgb:bS,toString:bS}));function wS(){return`#${zl(this.r)}${zl(this.g)}${zl(this.b)}`}function pF(){return`#${zl(this.r)}${zl(this.g)}${zl(this.b)}${zl((isNaN(this.opacity)?1:this.opacity)*255)}`}function bS(){const e=Pm(this.opacity);return`${e===1?"rgb(":"rgba("}${Wl(this.r)}, ${Wl(this.g)}, ${Wl(this.b)}${e===1?")":`, ${e})`}`}function Pm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Wl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function zl(e){return e=Wl(e),(e<16?"0":"")+e.toString(16)}function vS(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new $i(e,t,n,r)}function fP(e){if(e instanceof $i)return new $i(e.h,e.s,e.l,e.opacity);if(e instanceof sp||(e=Zl(e)),!e)return new $i;if(e instanceof $i)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 $i(a,l,c,e.opacity)}function hF(e,t,n,r){return arguments.length===1?fP(e):new $i(e,t,n,r??1)}function $i(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Pv($i,hF,dP(sp,{brighter(e){return e=e==null?_m:Math.pow(_m,e),new $i(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Af:Math.pow(Af,e),new $i(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 bs(Yy(e>=240?e-240:e+120,s,r),Yy(e,s,r),Yy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new $i(kS(this.h),lh(this.s),lh(this.l),Pm(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=Pm(this.opacity);return`${e===1?"hsl(":"hsla("}${kS(this.h)}, ${lh(this.s)*100}%, ${lh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function kS(e){return e=(e||0)%360,e<0?e+360:e}function lh(e){return Math.max(0,Math.min(1,e||0))}function Yy(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 Av=e=>()=>e;function mF(e,t){return function(n){return e+n*t}}function gF(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 yF(e){return(e=+e)==1?pP:function(t,n){return n-t?gF(t,n,e):Av(isNaN(t)?n:t)}}function pP(e,t){var n=t-e;return n?mF(e,n):Av(isNaN(e)?t:e)}const Am=function e(t){var n=yF(t);function r(s,i){var a=n((s=Bw(s)).r,(i=Bw(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),d=pP(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 xF(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 wF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function bF(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]=nf(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 vF(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function fo(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function kF(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]=nf(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Hw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Gy=new RegExp(Hw.source,"g");function SF(e){return function(){return e}}function NF(e){return function(t){return e(t)+""}}function hP(e,t){var n=Hw.lastIndex=Gy.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Hw.exec(e))&&(s=Gy.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:fo(r,s)})),n=Gy.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?NF(c[0].x):SF(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 nf(e,t){var n=typeof t,r;return t==null||n==="boolean"?Av(t):(n==="number"?fo:n==="string"?(r=Zl(t))?(t=r,Am):hP:t instanceof Zl?Am:t instanceof Date?vF:wF(t)?xF:Array.isArray(t)?bF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?kF:fo)(e,t)}var SS=180/Math.PI,Ww={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function mP(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)*SS,skewX:Math.atan(c)*SS,scaleX:a,scaleY:l}}var ch;function jF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ww:mP(t.a,t.b,t.c,t.d,t.e,t.f)}function CF(e){return e==null||(ch||(ch=document.createElementNS("http://www.w3.org/2000/svg","g")),ch.setAttribute("transform",e),!(e=ch.transform.baseVal.consolidate()))?Ww:(e=e.matrix,mP(e.a,e.b,e.c,e.d,e.e,e.f))}function gP(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:fo(d,u)},{i:b-2,x:fo(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:fo(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:fo(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:fo(d,u)},{i:b-2,x:fo(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 EF=gP(jF,"px, ","px)","deg)"),_F=gP(CF,", ",")",")"),PF=1e-12;function NS(e){return((e=Math.exp(e))+1/e)/2}function AF(e){return((e=Math.exp(e))-1/e)/2}function IF(e){return((e=Math.exp(2*e))-1)/(e+1)}const Vh=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<PF)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=NS(A),z=d/(n*k)*(F*IF(t*B+A)-AF(A));return[l+z*m,c+z*g,d*F/NS(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 ju=0,Fd=0,Cd=0,yP=1e3,Im,zd,Tm=0,ec=0,Pg=0,Tf=typeof performance=="object"&&performance.now?performance:Date,xP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Iv(){return ec||(xP(TF),ec=Tf.now()+Pg)}function TF(){ec=0}function Rm(){this._call=this._time=this._next=null}Rm.prototype=wP.prototype={constructor:Rm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Iv():+n)+(t==null?0:+t),!this._next&&zd!==this&&(zd?zd._next=this:Im=this,zd=this),this._call=e,this._time=n,Vw()},stop:function(){this._call&&(this._call=null,this._time=1/0,Vw())}};function wP(e,t,n){var r=new Rm;return r.restart(e,t,n),r}function RF(){Iv(),++ju;for(var e=Im,t;e;)(t=ec-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ju}function jS(){ec=(Tm=Tf.now())+Pg,ju=Fd=0;try{RF()}finally{ju=0,OF(),ec=0}}function LF(){var e=Tf.now(),t=e-Tm;t>yP&&(Pg-=t,Tm=e)}function OF(){for(var e,t=Im,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:Im=n);zd=e,Vw(r)}function Vw(e){if(!ju){Fd&&(Fd=clearTimeout(Fd));var t=e-ec;t>24?(e<1/0&&(Fd=setTimeout(jS,e-Tf.now()-Pg)),Cd&&(Cd=clearInterval(Cd))):(Cd||(Tm=Tf.now(),Cd=setInterval(LF,yP)),ju=1,xP(jS))}}function CS(e,t,n){var r=new Rm;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var MF=Eg("start","end","cancel","interrupt"),$F=[],bP=0,ES=1,Uw=2,Uh=3,_S=4,Kw=5,Kh=6;function Ag(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;DF(e,n,{name:t,index:r,group:s,on:MF,tween:$F,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:bP})}function Tv(e,t){var n=Ui(e,t);if(n.state>bP)throw new Error("too late; already scheduled");return n}function Eo(e,t){var n=Ui(e,t);if(n.state>Uh)throw new Error("too late; already running");return n}function Ui(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function DF(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=wP(i,0,n.time);function i(d){n.state=ES,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!==ES)return c();for(f in r)if(m=r[f],m.name===n.name){if(m.state===Uh)return CS(a);m.state===_S?(m.state=Kh,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=Kh,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(CS(function(){n.state===Uh&&(n.state=_S,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=Uw,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Uw){for(n.state=Uh,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=Kw,1),u=-1,p=s.length;++u<p;)s[u].call(e,f);n.state===Kw&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Kh,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function qh(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>Uw&&r.state<Kw,r.state=Kh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function FF(e){return this.each(function(){qh(this,e)})}function zF(e,t){var n,r;return function(){var s=Eo(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 BF(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=Eo(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 HF(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ui(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?zF:BF)(n,e,t))}function Rv(e,t,n){var r=e._id;return e.each(function(){var s=Eo(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ui(s,r).value[t]}}function vP(e,t){var n;return(typeof t=="number"?fo:t instanceof Zl?Am:(n=Zl(t))?(t=n,Am):hP)(e,t)}function WF(e){return function(){this.removeAttribute(e)}}function VF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function UF(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 KF(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 qF(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 YF(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 GF(e,t){var n=_g(e),r=n==="transform"?_F:vP;return this.attrTween(e,typeof t=="function"?(n.local?YF:qF)(n,r,Rv(this,"attr."+e,t)):t==null?(n.local?VF:WF)(n):(n.local?KF:UF)(n,r,t))}function XF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function JF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function QF(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&JF(e,i)),n}return s._value=t,s}function ZF(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&XF(e,i)),n}return s._value=t,s}function ez(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=_g(e);return this.tween(n,(r.local?QF:ZF)(r,t))}function tz(e,t){return function(){Tv(this,e).delay=+t.apply(this,arguments)}}function nz(e,t){return t=+t,function(){Tv(this,e).delay=t}}function rz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?tz:nz)(t,e)):Ui(this.node(),t).delay}function sz(e,t){return function(){Eo(this,e).duration=+t.apply(this,arguments)}}function iz(e,t){return t=+t,function(){Eo(this,e).duration=t}}function oz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sz:iz)(t,e)):Ui(this.node(),t).duration}function az(e,t){if(typeof t!="function")throw new Error;return function(){Eo(this,e).ease=t}}function lz(e){var t=this._id;return arguments.length?this.each(az(t,e)):Ui(this.node(),t).ease}function cz(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Eo(this,e).ease=n}}function uz(e){if(typeof e!="function")throw new Error;return this.each(cz(this._id,e))}function dz(e){typeof e!="function"&&(e=Q_(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 na(r,this._parents,this._name,this._id)}function fz(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 na(a,this._parents,this._name,this._id)}function pz(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 hz(e,t,n){var r,s,i=pz(t)?Tv:Eo;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function mz(e,t){var n=this._id;return arguments.length<2?Ui(this.node(),n).on.on(e):this.each(hz(n,e,t))}function gz(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function yz(){return this.on("end.remove",gz(this._id))}function xz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ev(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,Ag(d[p],t,n,p,d,Ui(f,n)));return new na(i,this._parents,t,n)}function wz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=J_(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=Ui(f,n),b=0,v=p.length;b<v;++b)(m=p[b])&&Ag(m,t,n,b,p,g);i.push(p),a.push(f)}return new na(i,a,t,n)}var bz=rp.prototype.constructor;function vz(){return new bz(this._groups,this._parents)}function kz(e,t){var n,r,s;return function(){var i=Nu(this,e),a=(this.style.removeProperty(e),Nu(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function kP(e){return function(){this.style.removeProperty(e)}}function Sz(e,t,n){var r,s=n+"",i;return function(){var a=Nu(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function Nz(e,t,n){var r,s,i;return function(){var a=Nu(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Nu(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function jz(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=Eo(this,e),d=c.on,f=c.value[i]==null?l||(l=kP(t)):void 0;(d!==n||s!==f)&&(r=(n=d).copy()).on(a,s=f),c.on=r}}function Cz(e,t,n){var r=(e+="")=="transform"?EF:vP;return t==null?this.styleTween(e,kz(e,r)).on("end.style."+e,kP(e)):typeof t=="function"?this.styleTween(e,Nz(e,r,Rv(this,"style."+e,t))).each(jz(this._id,e)):this.styleTween(e,Sz(e,r,t),n).on("end.style."+e,null)}function Ez(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function _z(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&Ez(e,a,n)),r}return i._value=t,i}function Pz(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,_z(e,t,n??""))}function Az(e){return function(){this.textContent=e}}function Iz(e){return function(){var t=e(this);this.textContent=t??""}}function Tz(e){return this.tween("text",typeof e=="function"?Iz(Rv(this,"text",e)):Az(e==null?"":e+""))}function Rz(e){return function(t){this.textContent=e.call(this,t)}}function Lz(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Rz(s)),t}return r._value=e,r}function Oz(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,Lz(e))}function Mz(){for(var e=this._name,t=this._id,n=SP(),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=Ui(c,t);Ag(c,e,n,d,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new na(r,this._parents,e,n)}function $z(){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=Eo(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 Dz=0;function na(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function SP(){return++Dz}var zo=rp.prototype;na.prototype={constructor:na,select:xz,selectAll:wz,selectChild:zo.selectChild,selectChildren:zo.selectChildren,filter:dz,merge:fz,selection:vz,transition:Mz,call:zo.call,nodes:zo.nodes,node:zo.node,size:zo.size,empty:zo.empty,each:zo.each,on:mz,attr:GF,attrTween:ez,style:Cz,styleTween:Pz,text:Tz,textTween:Oz,remove:yz,tween:HF,delay:rz,duration:oz,ease:lz,easeVarying:uz,end:$z,[Symbol.iterator]:zo[Symbol.iterator]};function Fz(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zz={time:null,delay:0,duration:250,ease:Fz};function Bz(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 Hz(e){var t,n;e instanceof na?(t=e._id,e=e._name):(t=SP(),(n=zz).time=Iv(),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])&&Ag(c,e,t,d,a,n||Bz(c,t));return new na(r,this._parents,e,t)}rp.prototype.interrupt=FF;rp.prototype.transition=Hz;const uh=e=>()=>e;function Wz(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 Yo(e,t,n){this.k=e,this.x=t,this.y=n}Yo.prototype={constructor:Yo,scale:function(e){return e===1?this:new Yo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Yo(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 Ig=new Yo(1,0,0);NP.prototype=Yo.prototype;function NP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ig;return e.__zoom}function Xy(e){e.stopImmediatePropagation()}function Ed(e){e.preventDefault(),e.stopImmediatePropagation()}function Vz(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Uz(){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 PS(){return this.__zoom||Ig}function Kz(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function qz(){return navigator.maxTouchPoints||"ontouchstart"in this}function Yz(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 jP(){var e=Vz,t=Uz,n=Yz,r=Kz,s=qz,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Vh,d=Eg("start","zoom","end"),f,u,p,m=500,g=150,b=0,v=10;function y(M){M.property("__zoom",PS).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",PS),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,X=R.invert(P),Z=typeof T=="function"?T.apply(this,arguments):T;return n(w(k(R,Z),P,X),_,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,X=D==null?j(R):typeof D=="function"?D.apply(this,arguments):D;return n(Ig.translate(X[0],X[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 Yo(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 Yo(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),X=t.apply(_,R),Z=E==null?j(X):typeof E=="function"?E.apply(_,R):E,V=Math.max(X[1][0]-X[0][0],X[1][1]-X[0][1]),ne=_.__zoom,ue=typeof T=="function"?T.apply(_,R):T,pe=c(ne.invert(Z).concat(V/ne.k),ue.invert(Z).concat(V/ue.k));return function(ge){if(ge===1)ge=ue;else{var ae=pe(ge),be=V/ae[2];ge=new Yo(be,Z[0]-ae[0]*be,Z[1]-ae[1]*be)}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=Hs(this.that).datum();d.call(M,this.that,new Wz(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=Li(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)],qh(this),E.start()}Ed(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),_=Hs(M.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",V,!0),R=Li(M,E),P=M.clientX,X=M.clientY;lP(M.view),Xy(M),D.mouse=[R,this.__zoom.invert(R)],qh(this),D.start();function Z(ne){if(Ed(ne),!D.moved){var ue=ne.clientX-P,pe=ne.clientY-X;D.moved=ue*ue+pe*pe>b}D.event(ne).zoom("mouse",n(w(D.that.__zoom,D.mouse[0]=Li(ne,E),D.mouse[1]),D.extent,a))}function V(ne){_.on("mousemove.zoom mouseup.zoom",null),cP(ne.view,D.moved),Ed(ne),D.event(ne).end()}}function z(M,...T){if(e.apply(this,arguments)){var E=this.__zoom,D=Li(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);Ed(M),l>0?Hs(this).transition().duration(l).call(A,P,D,M):Hs(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,X,Z;for(Xy(M),P=0;P<D;++P)X=E[P],Z=Li(X,this),Z=[Z,this.__zoom.invert(Z),X.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)),qh(this),_.start())}}function O(M,...T){if(this.__zooming){var E=C(this,T).event(M),D=M.changedTouches,_=D.length,R,P,X,Z;for(Ed(M),R=0;R<_;++R)P=D[R],X=Li(P,this),E.touch0&&E.touch0[2]===P.identifier?E.touch0[0]=X:E.touch1&&E.touch1[2]===P.identifier&&(E.touch1[0]=X);if(P=E.that.__zoom,E.touch1){var V=E.touch0[0],ne=E.touch0[1],ue=E.touch1[0],pe=E.touch1[1],ge=(ge=ue[0]-V[0])*ge+(ge=ue[1]-V[1])*ge,ae=(ae=pe[0]-ne[0])*ae+(ae=pe[1]-ne[1])*ae;P=k(P,Math.sqrt(ge/ae)),X=[(V[0]+ue[0])/2,(V[1]+ue[1])/2],Z=[(ne[0]+pe[0])/2,(ne[1]+pe[1])/2]}else if(E.touch0)X=E.touch0[0],Z=E.touch0[1];else return;E.zoom("touch",n(w(P,X,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(Xy(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=Li(P,this),Math.hypot(u[0]-P[0],u[1]-P[1])<v)){var X=Hs(this).on("dblclick.zoom");X&&X.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:uh(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:uh(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:uh(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:uh([[+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 No={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."},Rf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],CP=["Enter"," ","Escape"],EP={"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 Cu;(function(e){e.Strict="strict",e.Loose="loose"})(Cu||(Cu={}));var Vl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Vl||(Vl={}));var Lf;(function(e){e.Partial="partial",e.Full="full"})(Lf||(Lf={}));const _P={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Oa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Oa||(Oa={}));var Es;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Es||(Es={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const AS={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top};function PP(e){return e===null?null:e?"valid":"invalid"}const AP=e=>"id"in e&&"source"in e&&"target"in e,Gz=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Lv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ip=(e,t=[0,0])=>{const{width:n,height:r}=oa(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},Xz=(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):Lv(s)?s:t.nodeLookup.get(s.id));const l=a?Lm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Tg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Rg(n)},op=(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=Tg(n,Lm(s)),r=!0)}),r?Rg(n):{x:0,y:0,width:0,height:0}},Ov=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...lp(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=Of(l,_u(d)),v=(m??0)*(g??0),y=i&&b>0;(!d.internals.handleBounds||y||b>=v||d.dragging)&&c.push(d)}return c},Jz=(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 Qz(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 Zz({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=Qz(e,a),c=op(l),d=Mv(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 IP({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",No.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(u=[[c,d],[c+m,d+g]])}else l&&Pu(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=Pu(u)?tc(t,u,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",No.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 e3({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=Jz(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 Eu=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),tc=(e={x:0,y:0},t,n)=>({x:Eu(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Eu(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function TP(e,t,n){const{width:r,height:s}=oa(n),{x:i,y:a}=n.internals.positionAbsolute;return tc(e,[[i,a],[i+r,a+s]],t)}const IS=(e,t,n)=>e<t?Eu(Math.abs(e-t),1,t)/t:e>n?-Eu(Math.abs(e-n),1,t)/t:0,RP=(e,t,n=15,r=40)=>{const s=IS(e.x,r,t.width-r)*n,i=IS(e.y,r,t.height-r)*n;return[s,i]},Tg=(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)}),qw=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Rg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_u=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Lv(e)?e.internals.positionAbsolute:ip(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}},Lm=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Lv(e)?e.internals.positionAbsolute:ip(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)}},LP=(e,t)=>Rg(Tg(qw(e),qw(t))),Of=(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)},TS=e=>Di(e.width)&&Di(e.height)&&Di(e.x)&&Di(e.y),Di=e=>!isNaN(e)&&isFinite(e),t3=(e,t)=>{},ap=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),lp=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?ap(l,a):l},Om=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Tc(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 n3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Tc(e,n),s=Tc(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Tc(e.top??e.y??0,n),s=Tc(e.bottom??e.y??0,n),i=Tc(e.left??e.x??0,t),a=Tc(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 r3(e,t,n,r,s,i){const{x:a,y:l}=Om(e,[t,n,r]),{x:c,y:d}=Om({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 Mv=(e,t,n,r,s,i)=>{const a=n3(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,d=Math.min(l,c),f=Eu(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=r3(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}},Mf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Pu(e){return e!=null&&e!=="parent"}function oa(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 OP(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 MP(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 RS(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function s3(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function i3(e){return{...EP,...e||{}}}function rf(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Fi(e),l=lp({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:d}=n?ap(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const $v=e=>({width:e.offsetWidth,height:e.offsetHeight}),$P=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},o3=["INPUT","SELECT","TEXTAREA"];function DP(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:o3.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const FP=e=>"clientX"in e,Fi=(e,t)=>{var i,a;const n=FP(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)}},LS=(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,...$v(a)}})};function zP({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 dh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function OS({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Je.Left:return[t-dh(t-r,i),n];case Je.Right:return[t+dh(r-t,i),n];case Je.Top:return[t,n-dh(n-s,i)];case Je.Bottom:return[t,n+dh(s-n,i)]}}function BP({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:i=Je.Top,curvature:a=.25}){const[l,c]=OS({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,f]=OS({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[u,p,m,g]=zP({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 HP({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 a3({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 l3({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=Tg(Lm(e),Lm(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 Of(a,Rg(i))>0}const c3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,u3=(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)),$f=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||c3;let s;return AP(e)?s={...e}:s={...e,id:r(e)},u3(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function WP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=HP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const MS={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},d3=({source:e,sourcePosition:t=Je.Bottom,target:n})=>t===Je.Left||t===Je.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},$S=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function f3({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:r=Je.Top,center:s,offset:i,stepPosition:a}){const l=MS[t],c=MS[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=d3({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]=HP({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 p3(e,t,n,r){const s=Math.min($S(e,t)/2,$S(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 Yw({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:i=Je.Top,borderRadius:a=5,centerX:l,centerY:c,offset:d=20,stepPosition:f=.5}){const[u,p,m,g,b]=f3({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+=p3(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 DS(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function h3(e){var u;const{sourceNode:t,targetNode:n}=e;if(!DS(t)||!DS(n))return null;const r=t.internals.handleBounds||FS(t.handles),s=n.internals.handleBounds||FS(n.handles),i=zS((r==null?void 0:r.source)??[],e.sourceHandle),a=zS(e.connectionMode===Cu.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",No.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Je.Bottom,c=(a==null?void 0:a.position)||Je.Top,d=nc(t,i,l),f=nc(n,a,c);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function FS(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 nc(e,t,n=Je.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??oa(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:s+a/2,y:i};case Je.Right:return{x:s+a,y:i+l/2};case Je.Bottom:return{x:s+a/2,y:i+l};case Je.Left:return{x:s,y:i+l/2}}}function zS(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Gw(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function m3(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=Gw(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 VP=1e3,g3=10,Dv={nodeOrigin:[0,0],nodeExtent:Rf,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},y3={...Dv,checkEquality:!0};function Fv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function x3(e,t,n){const r=Fv(Dv,n);for(const s of e.values())if(s.parentId)Bv(s,e,t,r);else{const i=ip(s,r.nodeOrigin),a=Pu(s.extent)?s.extent:r.nodeExtent,l=tc(i,a,oa(s));s.internals.positionAbsolute=l}}function w3(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 zv(e){return e==="manual"}function Xw(e,t,n,r={}){var f,u;const s=Fv(y3,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!zv(s.zIndexMode)?VP: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=ip(p,s.nodeOrigin),b=Pu(p.extent)?p.extent:s.nodeExtent,v=tc(g,b,oa(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:w3(p,m),z:UP(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&&Bv(m,t,n,r,i),d||(d=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:d}}function b3(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 Bv(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Fv(Dv,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}b3(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*g3),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const u=i&&!zv(c)?VP:0,{x:p,y:m,z:g}=v3(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 UP(e,t,n){const r=Di(e.zIndex)?e.zIndex:0;return zv(n)?r:r+(e.selected?t:0)}function v3(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=oa(e),d=ip(e,n),f=Pu(e.extent)?tc(d,e.extent,c):d;let u=tc({x:a+f.x,y:l+f.y},r,c);e.extent==="parent"&&(u=TP(u,c,t));const p=UP(e,s,i),m=t.internals.z??0;return{x:u.x,y:u.y,z:m>=p?m+1:p}}function Hv(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)??_u(c),f=LP(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=oa(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 k3(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=$v(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=Pu(g.extent)?g.extent:i;let{positionAbsolute:j}=g.internals;g.parentId&&g.extent==="parent"?j=TP(j,b,t.get(g.parentId)):w&&(j=tc(j,w,b));const A={...g,measured:b,internals:{...g.internals,positionAbsolute:j,handleBounds:{source:LS("source",m.nodeElement,k,u,g.id),target:LS("target",m.nodeElement,k,u,g.id)}}};t.set(g.id,A),g.parentId&&Bv(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:_u(A,s)}))}}if(p.length>0){const m=Hv(p,t,n,s);d.push(...m)}return{changes:d,updatedInternals:c}}async function S3({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 BS(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 KP(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}`;BS("source",c,f,e,s,a),BS("target",c,d,e,i,l),t.set(r.id,r)}}function qP(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:qP(n,t):!1}function HS(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 N3(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!qP(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 Jy({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 j3({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=ap(i,t);return{x:a.x-i.x,y:a.y-i.y}}function C3({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=Hs(j);function B({x:O,y:W}){const{nodeLookup:M,nodeExtent:T,snapGrid:E,snapToGrid:D,nodeOrigin:_,onNodeDrag:R,onSelectionDrag:P,onError:X,updateNodePositions:Z}=t();i={x:O,y:W};let V=!1;const ne=l.size>1,ue=ne&&T?qw(op(l)):null,pe=ne&&D?j3({dragItems:l,snapGrid:E,x:O,y:W}):null;for(const[ge,ae]of l){if(!M.has(ge))continue;let be={x:O-ae.distance.x,y:W-ae.distance.y};D&&(be=pe?{x:Math.round(be.x+pe.x),y:Math.round(be.y+pe.y)}:ap(be,E));let Ae=null;if(ne&&T&&!ae.extent&&ue){const{positionAbsolute:Te}=ae.internals,it=Te.x-ue.x+T[0][0],ct=Te.x+ae.measured.width-ue.x2+T[1][0],tt=Te.y-ue.y+T[0][1],jt=Te.y+ae.measured.height-ue.y2+T[1][1];Ae=[[it,tt],[ct,jt]]}const{position:we,positionAbsolute:Pe}=IP({nodeId:ge,nextPosition:be,nodeLookup:M,nodeExtent:Ae||T,nodeOrigin:_,onError:X});V=V||ae.position.x!==we.x||ae.position.y!==we.y,ae.position=we,ae.internals.positionAbsolute=Pe}if(g=g||V,!!V&&(Z(l,!0),b&&(r||R||!C&&P))){const[ge,ae]=Jy({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]=RP(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 ne;const{nodeLookup:W,multiSelectionActive:M,nodesDraggable:T,transform:E,snapGrid:D,snapToGrid:_,selectNodesOnDrag:R,onNodeDragStart:P,onSelectionDragStart:X,unselectNodesAndEdges:Z}=t();u=!0,(!R||!A)&&!M&&C&&((ne=W.get(C))!=null&&ne.selected||Z()),A&&R&&C&&(e==null||e(C));const V=rf(O.sourceEvent,{transform:E,snapGrid:D,snapToGrid:_,containerBounds:f});if(i=V,l=N3(W,T,V,C),l.size>0&&(n||P||!C&&X)){const[ue,pe]=Jy({nodeId:C,dragItems:l,nodeLookup:W});n==null||n(O.sourceEvent,l,ue,pe),P==null||P(O.sourceEvent,ue,pe),C||X==null||X(O.sourceEvent,pe)}}const L=uP().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=rf(O.sourceEvent,{transform:T,snapGrid:E,snapToGrid:D,containerBounds:f}),d=Fi(O.sourceEvent,f)}).on("drag",O=>{const{autoPanOnNodeDrag:W,transform:M,snapGrid:T,snapToGrid:E,nodeDragThreshold:D,nodeLookup:_}=t(),R=rf(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=Fi(O.sourceEvent,f),X=P.x-d.x,Z=P.y-d.y;Math.sqrt(X*X+Z*Z)>D&&z(O)}(i.x!==R.xSnapped||i.y!==R.ySnapped)&&l&&u&&(d=Fi(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,_]=Jy({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||!HS(W,`.${k}`,j))&&(!w||HS(W,w,j))});p.call(L)}function y(){p==null||p.on(".drag",null)}return{update:v,destroy:y}}function E3(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())Of(s,_u(i))>0&&r.push(i);return r}const _3=250;function P3(e,t,n,r){var l,c;let s=[],i=1/0;const a=E3(e,n,t+_3);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}=nc(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 YP(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,...nc(a,c,c.position,!0)}:c}function GP(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function A3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const XP=()=>!0;function I3(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=XP,onReconnectEnd:k,updateConnection:w,getTransform:j,getFromHandle:A,autoPanSpeed:C,dragThreshold:$=1,handleDomNode:B}){const F=$P(e.target);let z=0,L;const{x:O,y:W}=Fi(e),M=GP(i,B),T=l==null?void 0:l.getBoundingClientRect();let E=!1;if(!T||!M)return;const D=YP(s,M,r,c,t);if(!D)return;let _=Fi(e,T),R=!1,P=null,X=!1,Z=null;function V(){if(!f||!T)return;const[we,Pe]=RP(_,T,C);p({x:we,y:Pe}),z=requestAnimationFrame(V)}const ne={...D,nodeId:s,type:M,position:D.position},ue=c.get(s);let ge={inProgress:!0,isValid:null,from:nc(ue,ne,Je.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:ue,to:_,toHandle:null,toPosition:AS[ne.position],toNode:null,pointer:_};function ae(){E=!0,w(ge),g==null||g(e,{nodeId:s,handleId:r,handleType:M})}$===0&&ae();function be(we){if(!E){const{x:jt,y:Ye}=Fi(we),kt=jt-O,nn=Ye-W;if(!(kt*kt+nn*nn>$*$))return;ae()}if(!A()||!ne){Ae(we);return}const Pe=j();_=Fi(we,T),L=P3(lp(_,Pe,!1,[1,1]),n,c,ne),R||(V(),R=!0);const Te=JP(we,{handle:L,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:F,lib:d,flowId:u,nodeLookup:c});Z=Te.handleDomNode,P=Te.connection,X=A3(!!L,Te.isValid);const it=c.get(s),ct=it?nc(it,ne,Je.Left,!0):ge.from,tt={...ge,from:ct,isValid:X,to:Te.toHandle&&X?Om({x:Te.toHandle.x,y:Te.toHandle.y},Pe):_,toHandle:Te.toHandle,toPosition:X&&Te.toHandle?Te.toHandle.position:AS[ne.position],toNode:Te.toHandle?c.get(Te.toHandle.nodeId):null,pointer:_};w(tt),ge=tt}function Ae(we){if(!("touches"in we&&we.touches.length>0)){if(E){(L||Z)&&P&&X&&(b==null||b(P));const{inProgress:Pe,...Te}=ge,it={...Te,toPosition:ge.toHandle?ge.toPosition:null};v==null||v(we,it),i&&(k==null||k(we,it))}m(),cancelAnimationFrame(z),R=!1,X=!1,P=null,Z=null,F.removeEventListener("mousemove",be),F.removeEventListener("mouseup",Ae),F.removeEventListener("touchmove",be),F.removeEventListener("touchend",Ae)}}F.addEventListener("mousemove",be),F.addEventListener("mouseup",Ae),F.addEventListener("touchmove",be),F.addEventListener("touchend",Ae)}function JP(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:d=XP,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}=Fi(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=GP(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===Cu.Strict?u&&k==="source"||!u&&k==="target":w!==r||j!==s);y.isValid=F&&d($),y.toHandle=YP(w,k,j,f,n,!0)}return y}const Jw={onPointerDown:I3,isValid:JP};function T3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Hs(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&&Mf()?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=jP().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:Li}}const Lg=e=>({x:e.x,y:e.y,zoom:e.k}),Qy=({x:e,y:t,zoom:n})=>Ig.translate(e,t).scale(n),eu=(e,t)=>e.target.closest(`.${t}`),QP=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),R3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Zy=(e,t=0,n=R3,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},ZP=e=>{const t=e.ctrlKey&&Mf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function L3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return f=>{if(eu(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=Li(f),y=ZP(f),k=u*Math.pow(2,y);r.scaleTo(n,k,v,f);return}const p=f.deltaMode===1?20:1;let m=s===Vl.Vertical?0:f.deltaX*p,g=s===Vl.Horizontal?0:f.deltaY*p;!Mf()&&f.shiftKey&&s!==Vl.Vertical&&(m=f.deltaY*p,g=0),r.translateBy(n,-(m/u)*i,-(g/u)*i,{internal:!0});const b=Lg(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 O3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=eu(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function M3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Lg(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 $3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&QP(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,Lg(i.transform)))}}function D3({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&&QP(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Lg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function F3({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"&&(eu(u,`${d}-flow__node`)||eu(u,`${d}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||f&&!g||eu(u,l)&&g||eu(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 z3({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=jP().scaleExtent([t,n]).translateExtent(r),p=Hs(e).call(u);k({x:s.x,y:s.y,zoom:Eu(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=p.on("wheel.zoom"),g=p.on("dblclick.zoom");u.wheelDelta(ZP);function b(L,O){return p?new Promise(W=>{u==null||u.interpolate((O==null?void 0:O.interpolate)==="linear"?nf:Vh).transform(Zy(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:X,zoomOnDoubleClick:Z,zoomActivationKeyPressed:V,lib:ne,onTransformChange:ue,connectionInProgress:pe,paneClickDistance:ge,selectionOnDrag:ae}){M&&!d.isZoomingOrPanning&&y();const be=T&&!V&&!M;u.clickDistance(ae?1/0:!Di(ge)||ge<0?0:ge);const Ae=be?L3({zoomPanValues:d,noWheelClassName:L,d3Selection:p,d3Zoom:u,panOnScrollMode:D,panOnScrollSpeed:_,zoomOnPinch:P,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):O3({noWheelClassName:L,preventScrolling:R,d3ZoomHandler:m});if(p.on("wheel.zoom",Ae,{passive:!1}),!M){const Pe=M3({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:a});u.on("start",Pe);const Te=$3({zoomPanValues:d,panOnDrag:E,onPaneContextMenu:!!W,onPanZoom:i,onTransformChange:ue});u.on("zoom",Te);const it=D3({zoomPanValues:d,panOnDrag:E,panOnScroll:T,onPaneContextMenu:W,onPanZoomEnd:l,onDraggingChange:c});u.on("end",it)}const we=F3({zoomActivationKeyPressed:V,panOnDrag:E,zoomOnScroll:X,panOnScroll:T,zoomOnDoubleClick:Z,zoomOnPinch:P,userSelectionActive:M,noPanClassName:O,noWheelClassName:L,lib:ne,connectionInProgress:pe});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=Qy(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=Qy(L);return await b(W,O),new Promise(M=>M(W))}function j(L){if(p){const O=Qy(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?NP(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"?nf:Vh).scaleTo(Zy(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"?nf:Vh).scaleBy(Zy(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=!Di(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 Au;(function(e){e.Line="line",e.Handle="handle"})(Au||(Au={}));function B3({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 WS(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 ja(e,t){return Math.max(0,t-e)}function Ca(e,t){return Math.max(0,e-t)}function fh(e,t,n){return Math.max(0,t-e,e-n)}function VS(e,t){return e?!t:t}function H3(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=fh(z,b,v),T=fh(L,y,k);if(a){let _=0,R=0;c&&B<0?_=ja(w+B+O,a[0][0]):!c&&B>0&&(_=Ca(w+z+O,a[1][0])),d&&F<0?R=ja(j+F+W,a[0][1]):!d&&F>0&&(R=Ca(j+L+W,a[1][1])),M=Math.max(M,_),T=Math.max(T,R)}if(l){let _=0,R=0;c&&B>0?_=Ca(w+B,l[0][0]):!c&&B<0&&(_=ja(w+z,l[1][0])),d&&F>0?R=Ca(j+F,l[0][1]):!d&&F<0&&(R=ja(j+L,l[1][1])),M=Math.max(M,_),T=Math.max(T,R)}if(s){if(f){const _=fh(z/$,y,k)*$;if(M=Math.max(M,_),a){let R=0;!c&&!d||c&&!d&&p?R=Ca(j+W+z/$,a[1][1])*$:R=ja(j+W+(c?B:-B)/$,a[0][1])*$,M=Math.max(M,R)}if(l){let R=0;!c&&!d||c&&!d&&p?R=ja(j+z/$,l[1][1])*$:R=Ca(j+(c?B:-B)/$,l[0][1])*$,M=Math.max(M,R)}}if(u){const _=fh(L*$,b,v)/$;if(T=Math.max(T,_),a){let R=0;!c&&!d||d&&!c&&p?R=Ca(w+L*$+O,a[1][0])/$:R=ja(w+(d?F:-F)*$+O,a[0][0])/$,T=Math.max(T,R)}if(l){let R=0;!c&&!d||d&&!c&&p?R=ja(w+L*$,l[1][0])/$:R=Ca(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=(VS(c,d)?-B:B)/$:B=(VS(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 eA={width:0,height:0,x:0,y:0},W3={...eA,pointerX:0,pointerY:0,aspectRatio:1};function V3(e){return[[0,0],[e.measured.width,e.measured.height]]}function U3(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 K3({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Hs(e);let a={controlDirection:WS("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={...eA},k={...W3};a={boundaries:f,resizeDirection:p,keepAspectRatio:u,controlDirection:WS(d)};let w,j=null,A=[],C,$,B,F=!1;const z=uP().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}=rf(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"?V3(C):void 0),A=[],B=void 0;for(const[P,X]of O)if(X.parentId===t&&(A.push({id:P,position:{...X.position},extent:X.extent}),X.extent==="parent"||X.expandParent)){const Z=U3(X,w,X.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=rf(L.sourceEvent,{transform:O,snapGrid:W,snapToGrid:M,containerBounds:j}),D=[];if(!w)return;const{x:_,y:R,width:P,height:X}=y,Z={},V=w.origin??T,{width:ne,height:ue,x:pe,y:ge}=H3(k,a.controlDirection,E,a.boundaries,a.keepAspectRatio,V,$,B),ae=ne!==P,be=ue!==X,Ae=pe!==_&&ae,we=ge!==R&&be;if(!Ae&&!we&&!ae&&!be)return;if((Ae||we||V[0]===1||V[1]===1)&&(Z.x=Ae?pe:y.x,Z.y=we?ge:y.y,y.x=Z.x,y.y=Z.y,A.length>0)){const ct=pe-_,tt=ge-R;for(const jt of A)jt.position={x:jt.position.x-ct+V[0]*(ne-P),y:jt.position.y-tt+V[1]*(ue-X)},D.push(jt)}if((ae||be)&&(Z.width=ae&&(!a.resizeDirection||a.resizeDirection==="horizontal")?ne:y.width,Z.height=be&&(!a.resizeDirection||a.resizeDirection==="vertical")?ue:y.height,y.width=Z.width,y.height=Z.height),C&&w.expandParent){const ct=V[0]*(Z.width??0);Z.x&&Z.x<ct&&(y.x=ct,k.x=k.x-(Z.x-ct));const tt=V[1]*(Z.height??0);Z.y&&Z.y<tt&&(y.y=tt,k.y=k.y-(Z.y-tt))}const Pe=B3({width:y.width,prevWidth:P,height:y.height,prevHeight:X,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Te={...y,direction:Pe};(v==null?void 0:v(L,Te))!==!1&&(F=!0,g==null||g(L,Te),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 tA={exports:{}},nA={},rA={exports:{}},sA={};/**
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 Iu=h;function q3(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Y3=typeof Object.is=="function"?Object.is:q3,G3=Iu.useState,X3=Iu.useEffect,J3=Iu.useLayoutEffect,Q3=Iu.useDebugValue;function Z3(e,t){var n=t(),r=G3({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return J3(function(){s.value=n,s.getSnapshot=t,ex(s)&&i({inst:s})},[e,n,t]),X3(function(){return ex(s)&&i({inst:s}),e(function(){ex(s)&&i({inst:s})})},[e]),Q3(n),n}function ex(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Y3(e,n)}catch{return!0}}function e5(e,t){return t()}var t5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?e5:Z3;sA.useSyncExternalStore=Iu.useSyncExternalStore!==void 0?Iu.useSyncExternalStore:t5;rA.exports=sA;var iA=rA.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 Og=h,n5=iA;function r5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var s5=typeof Object.is=="function"?Object.is:r5,i5=n5.useSyncExternalStore,o5=Og.useRef,a5=Og.useEffect,l5=Og.useMemo,c5=Og.useDebugValue;nA.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=o5(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=l5(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,s5(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=i5(e,i[0],i[1]);return a5(function(){a.hasValue=!0,a.value=l},[l]),c5(l),l};tA.exports=nA;var u5=tA.exports;const d5=il(u5),f5={},US=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:()=>{(f5?"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},p5=e=>e?US(e):US,{useDebugValue:h5}=at,{useSyncExternalStoreWithSelector:m5}=d5,g5=e=>e;function oA(e,t=g5,n){const r=m5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return h5(r),r}const KS=(e,t)=>{const n=p5(e),r=(s,i=t)=>oA(n,s,i);return Object.assign(r,n),r},y5=(e,t)=>e?KS(e,t):KS;function Hn(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 Mg=h.createContext(null),x5=Mg.Provider,aA=No.error001();function Ut(e,t){const n=h.useContext(Mg);if(n===null)throw new Error(aA);return oA(n,e,t)}function On(){const e=h.useContext(Mg);if(e===null)throw new Error(aA);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const qS={display:"none"},w5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},lA="react-flow__node-desc",cA="react-flow__edge-desc",b5="react-flow__aria-live",v5=e=>e.ariaLiveMessage,k5=e=>e.ariaLabelConfig;function S5({rfId:e}){const t=Ut(v5);return o.jsx("div",{id:`${b5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:w5,children:t})}function N5({rfId:e,disableKeyboardA11y:t}){const n=Ut(k5);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${lA}-${e}`,style:qS,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${cA}-${e}`,style:qS,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(S5,{rfId:e})]})}const Tu=h.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:fr(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});Tu.displayName="Panel";function j5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(Tu,{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 C5=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}},ph=e=>e.id;function E5(e,t){return Hn(e.selectedNodes.map(ph),t.selectedNodes.map(ph))&&Hn(e.selectedEdges.map(ph),t.selectedEdges.map(ph))}function _5({onSelectionChange:e}){const t=On(),{selectedNodes:n,selectedEdges:r}=Ut(C5,E5);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 P5=e=>!!e.onSelectionChangeHandlers;function A5({onSelectionChange:e}){const t=Ut(P5);return e||t?o.jsx(_5,{onSelectionChange:e}):null}const Qw=typeof window<"u"?h.useLayoutEffect:h.useEffect,uA=[0,0],I5={x:0,y:0,zoom:1},T5=["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"],YS=[...T5,"rfId"],R5=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}),GS={translateExtent:Rf,nodeOrigin:uA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function L5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Ut(R5,Hn),d=On();Qw(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=GS,l()}),[]);const f=h.useRef(GS);return Qw(()=>{for(const u of YS){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:i3(p)}):u==="fitView"?d.setState({fitViewQueued:p}):u==="fitViewOptions"?d.setState({fitViewOptions:p}):d.setState({[u]:p})))}f.current=e},YS.map(u=>e[u])),null}function XS(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function O5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const s=XS(),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=XS())!=null&&r.matches?"dark":"light"}const JS=typeof document<"u"?document:null;function Df(e=null,t={target:JS,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)??JS,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)&&DP(m))return!1;const b=ZS(m.code,l);if(i.current.add(m[b]),QS(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=ZS(m.code,l);QS(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 QS(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function ZS(e,t){return t.includes(e)?"code":"key"}const M5=()=>{const e=On();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=Mv(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 lp(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=Om(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function dA(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)$5(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 $5(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 Mm(e,t){return dA(e,t)}function Wv(e,t){return dA(e,t)}function Ll(e,t){return{id:e,type:"select",selected:t}}function tu(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(Ll(i.id,a)))}return r}function eN({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 tN(e){return{id:e.id,type:"remove"}}const nN=e=>Gz(e),D5=e=>AP(e);function fA(e){return h.forwardRef(e)}function rN(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>F5(()=>n(s=>s+BigInt(1))));return Qw(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function F5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const pA=h.createContext(null);function z5({children:e}){const t=On(),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=eN({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=rN(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(eN({items:m,lookup:p}))},[]),i=rN(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(pA.Provider,{value:a,children:e})}function B5(){const e=h.useContext(pA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const H5=e=>!!e.panZoom;function ac(){const e=M5(),t=On(),n=B5(),r=Ut(H5),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=nN(u)?u:p.get(u.id),b=g.parentId?MP(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 _u(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&&nN(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&&D5(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 e3({nodesToRemove:u,edgesToRemove:p,nodes:m,edges:g,onBeforeDelete:j}),$=C.length>0,B=A.length>0;if($){const F=C.map(tN);v==null||v(C),k(F)}if(B){const F=A.map(tN);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=TS(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=_u(v?y:k),j=Of(w,b);return p&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(u,p,m=!0)=>{const b=TS(u)?u:c(u);if(!b)return!1;const v=Of(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 Xz(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??s3();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 sN=e=>e.selected,W5=typeof window<"u"?window:void 0;function V5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=On(),{deleteElements:r}=ac(),s=Df(e,{actInsideInputWithModifier:!1}),i=Df(t,{target:W5});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(sN),edges:a.filter(sN)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function U5(e){const t=On();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=$v(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",No.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 $g={position:"absolute",width:"100%",height:"100%",top:0,left:0},K5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function q5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Vl.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=On(),C=h.useRef(null),{userSelectionActive:$,lib:B,connectionInProgress:F}=Ut(K5,Hn),z=Df(p),L=h.useRef();U5(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=z3({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:$g,children:g})}const Y5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function G5(){const{userSelectionActive:e,userSelectionRect:t}=Ut(Y5,Hn);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 tx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},X5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function J5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Lf.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=On(),{userSelectionActive:v,elementsSelectable:y,dragging:k,connectionInProgress:w}=Ut(X5,Hn),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,pe;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;(pe=(ue=_.target)==null?void 0:ue.setPointerCapture)==null||pe.call(ue,_.pointerId),F.current=!1;const{x:V,y:ne}=Fi(_.nativeEvent,C.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:ne,x:V,y:ne}}),P||(_.stopPropagation(),_.preventDefault())},T=_=>{const{userSelectionRect:R,transform:P,nodeLookup:X,edgeLookup:Z,connectionLookup:V,triggerNodeChanges:ne,triggerEdgeChanges:ue,defaultEdgeOptions:pe,resetSelectedElements:ge}=b.getState();if(!C.current||!R)return;const{x:ae,y:be}=Fi(_.nativeEvent,C.current),{startX:Ae,startY:we}=R;if(!F.current){const tt=t?0:s;if(Math.hypot(ae-Ae,be-we)<=tt)return;ge(),a==null||a(_)}F.current=!0;const Pe={startX:Ae,startY:we,x:ae<Ae?ae:Ae,y:be<we?be:we,width:Math.abs(ae-Ae),height:Math.abs(be-we)},Te=$.current,it=B.current;$.current=new Set(Ov(X,Pe,P,n===Lf.Partial,!0).map(tt=>tt.id)),B.current=new Set;const ct=(pe==null?void 0:pe.selectable)??!0;for(const tt of $.current){const jt=V.get(tt);if(jt)for(const{edgeId:Ye}of jt.values()){const kt=Z.get(Ye);kt&&(kt.selectable??ct)&&B.current.add(Ye)}}if(!RS(Te,$.current)){const tt=tu(X,$.current,!0);ne(tt)}if(!RS(it,B.current)){const tt=tu(Z,B.current);ue(tt)}b.setState({userSelectionRect:Pe,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:fr(["react-flow__pane",{draggable:D,dragging:k,selection:e}]),onClick:j?void 0:tx(z,A),onContextMenu:tx(L,A),onWheel:tx(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:$g,children:[g,o.jsx(G5,{})]})}function Zw({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",No.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 hA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=On(),[c,d]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=C3({getStoreItems:()=>l.getState(),onNodeMouseDown:u=>{Zw({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 Q5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function mA(){const e=On();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=Q5(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=ap(k,i));const{position:w,positionAbsolute:j}=IP({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 Vv=h.createContext(null),Z5=Vv.Provider;Vv.Consumer;const gA=()=>h.useContext(Vv),eB=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),tB=(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===Cu.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 nB({type:e="source",position:t=Je.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=On(),y=gA(),{connectOnClick:k,noPanClassName:w,rfId:j}=Ut(eB,Hn),{connectingFrom:A,connectingTo:C,clickConnecting:$,isPossibleEndHandle:B,connectionInProcess:F,clickConnectionInProcess:z,valid:L}=Ut(tB(y,g,e),Hn);y||(E=(T=v.getState()).onError)==null||E.call(T,"010",No.error010());const O=D=>{const{defaultEdgeOptions:_,onConnect:R,hasDefaultEdges:P}=v.getState(),X={..._,...D};if(P){const{edges:Z,setEdges:V}=v.getState();V($f(X,Z))}R==null||R(X),l==null||l(X)},W=D=>{if(!y)return;const _=FP(D.nativeEvent);if(s&&(_&&D.button===0||!_)){const R=v.getState();Jw.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 X,Z;return(Z=(X=v.getState()).onConnectEnd)==null?void 0:Z.call(X,...P)},updateConnection:R.updateConnection,onConnect:O,isValidConnection:n||((...P)=>{var X,Z;return((Z=(X=v.getState()).isValidConnection)==null?void 0:Z.call(X,...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:X,isValidConnection:Z,lib:V,rfId:ne,nodeLookup:ue,connection:pe}=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=$P(D.target),ae=n||Z,{connection:be,isValid:Ae}=Jw.isValid(D.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:X,fromNodeId:P.nodeId,fromHandleId:P.id||null,fromType:P.type,isValidConnection:ae,flowId:ne,doc:ge,lib:V,nodeLookup:ue});Ae&&be&&O(be);const we=structuredClone(pe);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:fr(["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 Ps=h.memo(fA(nB));function rB({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Ps,{type:"source",position:n,isConnectable:t})]})}function sB({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:r=Je.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Ps,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Ps,{type:"source",position:r,isConnectable:t})]})}function iB(){return null}function oB({data:e,isConnectable:t,targetPosition:n=Je.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Ps,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const $m={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},iN={input:rB,default:sB,output:oB,group:iB};function aB(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 lB=e=>{const{width:t,height:n,x:r,y:s}=op(e.nodeLookup,{filter:i=>!!i.selected});return{width:Di(t)?t:null,height:Di(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 cB({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=On(),{width:s,height:i,transformString:a,userSelectionActive:l}=Ut(lB,Hn),c=mA(),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(hA({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($m,m.key)&&(m.preventDefault(),c({direction:$m[m.key],factor:m.shiftKey?4:1}))};return o.jsx("div",{className:fr(["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 oN=typeof window<"u"?window:void 0,uB=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function yA({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:X}=Ut(uB,Hn),Z=Df(d,{target:oN}),V=Df(b,{target:oN}),ne=V||B,ue=V||j,pe=f&&ne!==!0,ge=Z||X||pe;return V5({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(q5,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:k,zoomOnPinch:w,panOnScroll:ue,panOnScrollSpeed:A,panOnScrollMode:C,zoomOnDoubleClick:$,panOnDrag:!Z&&ne,defaultViewport:F,translateExtent:z,minZoom:L,maxZoom:O,zoomActivationKeyCode:v,preventScrolling:W,noWheelClassName:T,noPanClassName:E,onViewportChange:_,isControlledViewport:R,paneClickDistance:l,selectionOnDrag:pe,children:o.jsxs(J5,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:ne,isSelecting:!!ge,selectionMode:u,selectionKeyPressed:Z,paneClickDistance:l,selectionOnDrag:pe,children:[e,P&&o.jsx(cB,{onSelectionContextMenu:M,noPanClassName:E,disableKeyboardA11y:D})]})})}yA.displayName="FlowRenderer";const dB=h.memo(yA),fB=e=>t=>e?Ov(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 pB(e){return Ut(h.useCallback(fB(e),[e]),Hn)}const hB=e=>e.updateNodeInternals;function mB(){const e=Ut(hB),[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 gB({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=On(),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 yB({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}=Ut(ae=>{const be=ae.nodeLookup.get(e),Ae=ae.parentLookup.has(e);return{node:be,internals:be.internals,isParent:Ae}},Hn);let C=w.type||"default",$=(v==null?void 0:v[C])||iN[C];$===void 0&&(k==null||k("003",No.error003(C)),C="default",$=(v==null?void 0:v.default)||iN.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=On(),W=OP(w),M=gB({node:w,nodeType:C,hasDimensions:W,resizeObserver:u}),T=hA({nodeRef:M,disabled:w.hidden||!B,noDragClassName:p,handleSelector:w.dragHandle,nodeId:e,isSelectable:F,nodeClickDistance:y}),E=mA();if(w.hidden)return null;const D=oa(w),_=aB(w),R=F||B||t||n||r||s,P=n?ae=>n(ae,{...j.userNode}):void 0,X=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,ne=a?ae=>a(ae,{...j.userNode}):void 0,ue=ae=>{const{selectNodesOnDrag:be,nodeDragThreshold:Ae}=O.getState();F&&(!be||!B||Ae>0)&&Zw({id:e,store:O,nodeRef:M}),t&&t(ae,{...j.userNode})},pe=ae=>{if(!(DP(ae.nativeEvent)||g)){if(CP.includes(ae.key)&&F){const be=ae.key==="Escape";Zw({id:e,store:O,unselect:be,nodeRef:M})}else if(B&&w.selected&&Object.prototype.hasOwnProperty.call($m,ae.key)){ae.preventDefault();const{ariaLabelConfig:be}=O.getState();O.setState({ariaLiveMessage:be["node.a11yDescription.ariaLiveMessage"]({direction:ae.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),E({direction:$m[ae.key],factor:ae.shiftKey?4:1})}}},ge=()=>{var it;if(g||!((it=M.current)!=null&&it.matches(":focus-visible")))return;const{transform:ae,width:be,height:Ae,autoPanOnNodeFocus:we,setCenter:Pe}=O.getState();if(!we)return;Ov(new Map([[e,w]]),{x:0,y:0,width:be,height:Ae},ae,!0).length>0||Pe(w.position.x+D.width/2,w.position.y+D.height/2,{zoom:ae[2]})};return o.jsx("div",{className:fr(["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:X,onMouseLeave:Z,onContextMenu:V,onClick:ue,onDoubleClick:ne,onKeyDown:L?pe: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:`${lA}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:o.jsx(Z5,{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 xB=h.memo(yB);const wB=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function xA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Ut(wB,Hn),a=pB(e.onlyRenderVisibleElements),l=mB();return o.jsx("div",{className:"react-flow__nodes",style:$g,children:a.map(c=>o.jsx(xB,{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))})}xA.displayName="NodeRenderer";const bB=h.memo(xA);function vB(e){return Ut(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&&l3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Hn)}const kB=({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"})},SB=({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"})},aN={[Es.Arrow]:kB,[Es.ArrowClosed]:SB};function NB(e){const t=On();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(aN,e)?aN[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",No.error009(e)),null)},[e])}const jB=({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=NB(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},wA=({defaultColor:e,rfId:t})=>{const n=Ut(i=>i.edges),r=Ut(i=>i.defaultEdgeOptions),s=h.useMemo(()=>m3(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(jB,{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};wA.displayName="MarkerDefinitions";var CB=h.memo(wA);function bA({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=fr(["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}bA.displayName="EdgeText";const EB=h.memo(bA);function Dg({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:fr(["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&&Di(t)&&Di(n)?o.jsx(EB,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function lN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Je.Left||e===Je.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function vA({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:s,targetPosition:i=Je.Top}){const[a,l]=lN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=lN({pos:i,x1:r,y1:s,x2:e,y2:t}),[f,u,p,m]=zP({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 kA(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]=vA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),A=e.isInternal?void 0:t;return o.jsx(Dg,{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 _B=kA({isInternal:!1}),SA=kA({isInternal:!0});_B.displayName="SimpleBezierEdge";SA.displayName="SimpleBezierEdgeInternal";function NA(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=Je.Bottom,targetPosition:g=Je.Top,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:k})=>{const[w,j,A]=Yw({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(Dg,{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 jA=NA({isInternal:!1}),CA=NA({isInternal:!0});jA.displayName="SmoothStepEdge";CA.displayName="SmoothStepEdgeInternal";function EA(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(jA,{...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 PB=EA({isInternal:!1}),_A=EA({isInternal:!0});PB.displayName="StepEdge";_A.displayName="StepEdgeInternal";function PA(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]=WP({sourceX:n,sourceY:r,targetX:s,targetY:i}),w=e.isInternal?void 0:t;return o.jsx(Dg,{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 AB=PA({isInternal:!1}),AA=PA({isInternal:!0});AB.displayName="StraightEdge";AA.displayName="StraightEdgeInternal";function IA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Je.Bottom,targetPosition:l=Je.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]=BP({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(Dg,{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 IB=IA({isInternal:!1}),TA=IA({isInternal:!0});IB.displayName="BezierEdge";TA.displayName="BezierEdgeInternal";const cN={default:TA,straight:AA,step:_A,smoothstep:CA,simplebezier:SA},uN={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},TB=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,RB=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,dN="react-flow__edgeupdater";function fN({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:fr([dN,`${dN}-${l}`]),cx:TB(t,r,e),cy:RB(n,r,e),r,stroke:"transparent",fill:"transparent"})}function LB({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=On(),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",_=(X,Z)=>{p(!1),u==null||u(X,n,A.type,Z)},R=X=>d==null?void 0:d(n,X),P=(X,Z)=>{p(!0),f==null||f(j,n,A.type),L==null||L(X,Z)};Jw.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:(...X)=>{var Z,V;return((V=(Z=g.getState()).isValidConnection)==null?void 0:V.call(Z,...X))??!0},onConnect:R,onConnectStart:P,onConnectEnd:(...X)=>{var Z,V;return(V=(Z=g.getState()).onConnectEnd)==null?void 0:V.call(Z,...X)},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(fN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:v,onMouseEnter:k,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&o.jsx(fN,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:k,onMouseOut:w,type:"target"})]})}function OB({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=Ut(Pe=>Pe.edgeLookup.get(e));const j=Ut(Pe=>Pe.defaultEdgeOptions);w=j?{...j,...w}:w;let A=w.type||"default",C=(b==null?void 0:b[A])||cN[A];C===void 0&&(y==null||y("011",No.error011(A)),A="default",C=(b==null?void 0:b.default)||cN.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=On(),{zIndex:E,sourceX:D,sourceY:_,targetX:R,targetY:P,sourcePosition:X,targetPosition:Z}=Ut(h.useCallback(Pe=>{const Te=Pe.nodeLookup.get(w.source),it=Pe.nodeLookup.get(w.target);if(!Te||!it)return{zIndex:w.zIndex,...uN};const ct=h3({id:e,sourceNode:Te,targetNode:it,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:Pe.connectionMode,onError:y});return{zIndex:a3({selected:w.selected,zIndex:w.zIndex,sourceNode:Te,targetNode:it,elevateOnSelect:Pe.elevateEdgesOnSelect,zIndexMode:Pe.zIndexMode}),...ct||uN}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),Hn),V=h.useMemo(()=>w.markerStart?`url('#${Gw(w.markerStart,g)}')`:void 0,[w.markerStart,g]),ne=h.useMemo(()=>w.markerEnd?`url('#${Gw(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||D===null||_===null||R===null||P===null)return null;const ue=Pe=>{var tt;const{addSelectedEdges:Te,unselectNodesAndEdges:it,multiSelectionActive:ct}=T.getState();F&&(T.setState({nodesSelectionActive:!1}),w.selected&&ct?(it({nodes:[],edges:[w]}),(tt=z.current)==null||tt.blur()):Te([e])),s&&s(Pe,w)},pe=i?Pe=>{i(Pe,{...w})}:void 0,ge=a?Pe=>{a(Pe,{...w})}:void 0,ae=l?Pe=>{l(Pe,{...w})}:void 0,be=c?Pe=>{c(Pe,{...w})}:void 0,Ae=d?Pe=>{d(Pe,{...w})}:void 0,we=Pe=>{var Te;if(!k&&CP.includes(Pe.key)&&F){const{unselectNodesAndEdges:it,addSelectedEdges:ct}=T.getState();Pe.key==="Escape"?((Te=z.current)==null||Te.blur(),it({edges:[w]})):ct([e])}};return o.jsx("svg",{style:{zIndex:E},children:o.jsxs("g",{className:fr(["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:pe,onContextMenu:ge,onMouseEnter:ae,onMouseMove:be,onMouseLeave:Ae,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":$?`${cA}-${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:X,targetPosition:Z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:V,markerEnd:ne,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),B&&o.jsx(LB,{edge:w,isReconnectable:B,reconnectRadius:f,onReconnect:u,onReconnectStart:p,onReconnectEnd:m,sourceX:D,sourceY:_,targetX:R,targetY:P,sourcePosition:X,targetPosition:Z,setUpdateHover:O,setReconnecting:M})]})})}var MB=h.memo(OB);const $B=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function RA({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}=Ut($B,Hn),j=vB(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(CB,{defaultColor:e,rfId:n}),j.map(A=>o.jsx(MB,{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))]})}RA.displayName="EdgeRenderer";const DB=h.memo(RA),FB=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function zB({children:e}){const t=Ut(FB);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function BB(e){const t=ac(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const HB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function WB(e){const t=Ut(HB),n=On();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function VB(e){return e.connection.inProgress?{...e.connection,to:lp(e.connection.to,e.transform)}:{...e.connection}}function UB(e){return VB}function KB(e){const t=UB();return Ut(t,Hn)}const qB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function YB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Ut(qB,Hn);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:fr(["react-flow__connection",PP(l)]),children:o.jsx(LA,{style:t,type:n,CustomComponent:r,isValid:l})})})}const LA=({style:e,type:t=Oa.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}=KB();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:PP(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 Oa.Bezier:[g]=BP(b);break;case Oa.SimpleBezier:[g]=vA(b);break;case Oa.Step:[g]=Yw({...b,borderRadius:0});break;case Oa.SmoothStep:[g]=Yw(b);break;default:[g]=WP(b)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};LA.displayName="ConnectionLine";const GB={};function pN(e=GB){h.useRef(e),On(),h.useEffect(()=>{},[e])}function XB(){On(),h.useRef(!1),h.useEffect(()=>{},[])}function OA({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:X,zoomOnDoubleClick:Z,panOnDrag:V,onPaneClick:ne,onPaneMouseEnter:ue,onPaneMouseMove:pe,onPaneMouseLeave:ge,onPaneScroll:ae,onPaneContextMenu:be,paneClickDistance:Ae,nodeClickDistance:we,onEdgeContextMenu:Pe,onEdgeMouseEnter:Te,onEdgeMouseMove:it,onEdgeMouseLeave:ct,reconnectRadius:tt,onReconnect:jt,onReconnectStart:Ye,onReconnectEnd:kt,noDragClassName:nn,noWheelClassName:vn,noPanClassName:Mn,disableKeyboardA11y:Ht,nodeExtent:$n,rfId:Wn,viewport:le,onViewportChange:de}){return pN(e),pN(t),XB(),BB(n),WB(le),o.jsx(dB,{onPaneClick:ne,onPaneMouseEnter:ue,onPaneMouseMove:pe,onPaneMouseLeave:ge,onPaneContextMenu:be,onPaneScroll:ae,paneClickDistance:Ae,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:X,panOnDrag:V,defaultViewport:L,translateExtent:O,minZoom:W,maxZoom:M,onSelectionContextMenu:u,preventScrolling:T,noDragClassName:nn,noWheelClassName:vn,noPanClassName:Mn,disableKeyboardA11y:Ht,onViewportChange:de,isControlledViewport:!!le,children:o.jsxs(zB,{children:[o.jsx(DB,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:jt,onReconnectStart:Ye,onReconnectEnd:kt,onlyRenderVisibleElements:F,onEdgeContextMenu:Pe,onEdgeMouseEnter:Te,onEdgeMouseMove:it,onEdgeMouseLeave:ct,reconnectRadius:tt,defaultMarkerColor:E,noPanClassName:Mn,disableKeyboardA11y:Ht,rfId:Wn}),o.jsx(YB,{style:b,type:g,component:v,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(bB,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:we,onlyRenderVisibleElements:F,noPanClassName:Mn,noDragClassName:nn,disableKeyboardA11y:Ht,nodeExtent:$n,rfId:Wn}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}OA.displayName="GraphView";const JB=h.memo(OA),hN=({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??Rf;KP(b,v,y);const{nodesInitialized:A}=Xw(k,m,g,{nodeOrigin:w,nodeExtent:j,zIndexMode:p});let C=[0,0,1];if(a&&s&&i){const $=op(m,{filter:L=>!!((L.width||L.initialWidth)&&(L.height||L.initialHeight))}),{x:B,y:F,zoom:z}=Mv($,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:Rf,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Cu.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:{..._P},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:t3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:EP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QB=({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})=>y5((m,g)=>{async function b(){const{nodeLookup:v,panZoom:y,fitViewOptions:k,fitViewResolver:w,width:j,height:A,minZoom:C,maxZoom:$}=g();y&&(await Zz({nodes:v,width:j,height:A,panZoom:y,minZoom:C,maxZoom:$},k),w==null||w.resolve(!0),m({fitViewResolver:null}))}return{...hN({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}=Xw(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();KP(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}=k3(v,k,w,j,A,C,F);L&&(x3(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=nc(L,C.fromHandle,Je.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=Hv(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=Mm(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=Wv(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($=>Ll($,!0));j(C);return}j(tu(w,new Set([...v]),!0)),A(tu(k))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:k,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:A}=g();if(y){const C=v.map($=>Ll($,!0));A(C);return}A(tu(k,new Set([...v]))),j(tu(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(Ll(L.id,!1))}const z=[];for(const L of B)L.selected&&z.push(Ll(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?[...$,Ll(B.id,!1)]:$,[]),C=v.reduce(($,B)=>B.selected?[...$,Ll(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]||(Xw(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 S3({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:{..._P}})},updateConnection:v=>{m({connection:v})},reset:()=>m({...hN()})}},Object.is);function Fg({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(()=>QB({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(x5,{value:g,children:o.jsx(z5,{children:m})})}function ZB({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(Mg)?o.jsx(o.Fragment,{children:e}):o.jsx(Fg,{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 e4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function t4({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:X,connectionLineType:Z=Oa.Bezier,connectionLineStyle:V,connectionLineComponent:ne,connectionLineContainerStyle:ue,deleteKeyCode:pe="Backspace",selectionKeyCode:ge="Shift",selectionOnDrag:ae=!1,selectionMode:be=Lf.Full,panActivationKeyCode:Ae="Space",multiSelectionKeyCode:we=Mf()?"Meta":"Control",zoomActivationKeyCode:Pe=Mf()?"Meta":"Control",snapToGrid:Te,snapGrid:it,onlyRenderVisibleElements:ct=!1,selectNodesOnDrag:tt,nodesDraggable:jt,autoPanOnNodeFocus:Ye,nodesConnectable:kt,nodesFocusable:nn,nodeOrigin:vn=uA,edgesFocusable:Mn,edgesReconnectable:Ht,elementsSelectable:$n=!0,defaultViewport:Wn=I5,minZoom:le=.5,maxZoom:de=2,translateExtent:He=Rf,preventScrolling:Ze=!0,nodeExtent:ot,defaultMarkerColor:Xt="#b1b1b7",zoomOnScroll:rn=!0,zoomOnPinch:sn=!0,panOnScroll:An=!1,panOnScrollSpeed:Sr=.5,panOnScrollMode:Jt=Vl.Free,zoomOnDoubleClick:mn=!0,panOnDrag:Vn=!0,onPaneClick:or,onPaneMouseEnter:ye,onPaneMouseMove:Ie,onPaneMouseLeave:nt,onPaneScroll:Ct,onPaneContextMenu:ie,paneClickDistance:_e=1,nodeClickDistance:et=0,children:$t,onReconnect:Qt,onReconnectStart:ar,onReconnectEnd:ut,onEdgeContextMenu:Nr,onEdgeDoubleClick:Hr,onEdgeMouseEnter:Js,onEdgeMouseMove:Dn,onEdgeMouseLeave:us,reconnectRadius:qi=10,onNodesChange:Po,onEdgesChange:Ao,noDragClassName:Ee="nodrag",noWheelClassName:Oe="nowheel",noPanClassName:Zt="nopan",fitView:Tr,fitViewOptions:xt,connectOnClick:es,attributionPosition:Qn,proOptions:Fn,defaultEdgeOptions:Is,elevateNodesOnSelect:lt=!0,elevateEdgesOnSelect:on=!1,disableKeyboardA11y:Lt=!1,autoPanOnConnect:ds,autoPanOnNodeDrag:Be,autoPanSpeed:pr,connectionRadius:Zn,isValidConnection:la,onError:ca,style:Io,id:hr,nodeDragThreshold:Ts,connectionDragThreshold:fs,viewport:xi,onViewportChange:dn,width:Qs,height:wi,colorMode:Zs="light",debug:Rs,onScroll:K,ariaLabelConfig:he,zIndexMode:Me="basic",...Re},Qe){const Dt=hr||"1",Ot=O5(Zs),Un=h.useCallback(mr=>{mr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),K==null||K(mr)},[K]);return o.jsx("div",{"data-testid":"rf__wrapper",...Re,onScroll:Un,style:{...Io,...e4},ref:Qe,className:fr(["react-flow",s,Ot]),id:hr,role:"application",children:o.jsxs(ZB,{nodes:e,edges:t,width:Qs,height:wi,fitView:Tr,fitViewOptions:xt,minZoom:le,maxZoom:de,nodeOrigin:vn,nodeExtent:ot,zIndexMode:Me,children:[o.jsx(L5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:jt,autoPanOnNodeFocus:Ye,nodesConnectable:kt,nodesFocusable:nn,edgesFocusable:Mn,edgesReconnectable:Ht,elementsSelectable:$n,elevateNodesOnSelect:lt,elevateEdgesOnSelect:on,minZoom:le,maxZoom:de,nodeExtent:ot,onNodesChange:Po,onEdgesChange:Ao,snapToGrid:Te,snapGrid:it,connectionMode:X,translateExtent:He,connectOnClick:es,defaultEdgeOptions:Is,fitView:Tr,fitViewOptions:xt,onNodesDelete:z,onEdgesDelete:L,onDelete:O,onNodeDragStart:$,onNodeDrag:B,onNodeDragStop:F,onSelectionDrag:T,onSelectionDragStart:M,onSelectionDragStop:E,onMove:f,onMoveStart:u,onMoveEnd:p,noPanClassName:Zt,nodeOrigin:vn,rfId:Dt,autoPanOnConnect:ds,autoPanOnNodeDrag:Be,autoPanSpeed:pr,onError:ca,connectionRadius:Zn,isValidConnection:la,selectNodesOnDrag:tt,nodeDragThreshold:Ts,connectionDragThreshold:fs,onBeforeDelete:P,debug:Rs,ariaLabelConfig:he,zIndexMode:Me}),o.jsx(JB,{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:ne,connectionLineContainerStyle:ue,selectionKeyCode:ge,selectionOnDrag:ae,selectionMode:be,deleteKeyCode:pe,multiSelectionKeyCode:we,panActivationKeyCode:Ae,zoomActivationKeyCode:Pe,onlyRenderVisibleElements:ct,defaultViewport:Wn,translateExtent:He,minZoom:le,maxZoom:de,preventScrolling:Ze,zoomOnScroll:rn,zoomOnPinch:sn,zoomOnDoubleClick:mn,panOnScroll:An,panOnScrollSpeed:Sr,panOnScrollMode:Jt,panOnDrag:Vn,onPaneClick:or,onPaneMouseEnter:ye,onPaneMouseMove:Ie,onPaneMouseLeave:nt,onPaneScroll:Ct,onPaneContextMenu:ie,paneClickDistance:_e,nodeClickDistance:et,onSelectionContextMenu:D,onSelectionStart:_,onSelectionEnd:R,onReconnect:Qt,onReconnectStart:ar,onReconnectEnd:ut,onEdgeContextMenu:Nr,onEdgeDoubleClick:Hr,onEdgeMouseEnter:Js,onEdgeMouseMove:Dn,onEdgeMouseLeave:us,reconnectRadius:qi,defaultMarkerColor:Xt,noDragClassName:Ee,noWheelClassName:Oe,noPanClassName:Zt,rfId:Dt,disableKeyboardA11y:Lt,nodeExtent:ot,viewport:xi,onViewportChange:dn}),o.jsx(A5,{onSelectionChange:W}),$t,o.jsx(j5,{proOptions:Fn,position:Qn}),o.jsx(N5,{rfId:Dt,disableKeyboardA11y:Lt})]})})}var Uv=fA(t4);function Kv(){const e=On();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 MA(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>Mm(s,i)),[]);return[t,n,r]}function $A(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>Wv(s,i)),[]);return[t,n,r]}function n4({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:fr(["react-flow__background-pattern",n,r])})}function r4({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:fr(["react-flow__background-pattern","dots",t])})}var Ga;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ga||(Ga={}));const s4={[Ga.Dots]:1,[Ga.Lines]:1,[Ga.Cross]:6},i4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function DA({id:e,variant:t=Ga.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}=Ut(i4,Hn),g=r||s4[t],b=t===Ga.Dots,v=t===Ga.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:fr(["react-flow__background",d]),style:{...c,...$g,"--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(r4,{radius:w/2,className:f}):o.jsx(n4,{dimensions:A,lineWidth:s,variant:t,className:f})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${$})`})]})}DA.displayName="Background";const qv=h.memo(DA);function o4(){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 a4(){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 l4(){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 c4(){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 u4(){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 hh({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:fr(["react-flow__controls-button",t]),...n,children:e})}const d4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function FA({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=On(),{isInteractive:b,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:k}=Ut(d4,Hn),{zoomIn:w,zoomOut:j,fitView:A}=ac(),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(Tu,{className:fr(["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(hh,{onClick:C,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(o4,{})}),o.jsx(hh,{onClick:$,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:v,children:o.jsx(a4,{})})]}),n&&o.jsx(hh,{className:"react-flow__controls-fitview",onClick:B,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:o.jsx(l4,{})}),r&&o.jsx(hh,{className:"react-flow__controls-interactive",onClick:F,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:b?o.jsx(u4,{}):o.jsx(c4,{})}),f]})}FA.displayName="Controls";const f4=h.memo(FA);function p4({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:fr(["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 h4=h.memo(p4),m4=e=>e.nodes.map(t=>t.id),nx=e=>e instanceof Function?e:()=>e;function g4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=h4,onClick:a}){const l=Ut(m4,Hn),c=nx(t),d=nx(e),f=nx(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(x4,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:u},p))})}function y4({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}=Ut(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}=oa(v);return{node:v,x:y,y:k,width:w,height:j}},Hn);return!d||d.hidden||!OP(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 x4=h.memo(y4);var w4=h.memo(g4);const b4=200,v4=150,k4=e=>!e.hidden,S4=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?LP(op(e.nodeLookup,{filter:k4}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},N4="react-flow__minimap-desc";function zA({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=On(),C=h.useRef(null),{boundingRect:$,viewBB:B,rfId:F,panZoom:z,translateExtent:L,flowWidth:O,flowHeight:W,ariaLabelConfig:M}=Ut(S4,Hn),T=(e==null?void 0:e.width)??b4,E=(e==null?void 0:e.height)??v4,D=$.width/T,_=$.height/E,R=Math.max(D,_),P=R*T,X=R*E,Z=j*R,V=$.x-(P-$.width)/2-Z,ne=$.y-(X-$.height)/2-Z,ue=P+Z*2,pe=X+Z*2,ge=`${N4}-${F}`,ae=h.useRef(0),be=h.useRef();ae.current=R,h.useEffect(()=>{if(C.current&&z)return be.current=T3({domNode:C.current,panZoom:z,getTransform:()=>A.getState().transform,getViewScale:()=>ae.current}),()=>{var Te;(Te=be.current)==null||Te.destroy()}},[z]),h.useEffect(()=>{var Te;(Te=be.current)==null||Te.update({translateExtent:L,width:O,height:W,inversePan:k,pannable:b,zoomStep:w,zoomable:v})},[b,v,k,w,L,O,W]);const Ae=m?Te=>{var tt;const[it,ct]=((tt=be.current)==null?void 0:tt.pointer(Te))||[0,0];m(Te,{x:it,y:ct})}:void 0,we=g?h.useCallback((Te,it)=>{const ct=A.getState().nodeLookup.get(it).internals.userNode;g(Te,ct)},[]):void 0,Pe=y??M["minimap.ariaLabel"];return o.jsx(Tu,{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:fr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:T,height:E,viewBox:`${V} ${ne} ${ue} ${pe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ge,ref:C,onClick:Ae,children:[Pe&&o.jsx("title",{id:ge,children:Pe}),o.jsx(w4,{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},${ne-Z}h${ue+Z*2}v${pe+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"})]})})}zA.displayName="MiniMap";const j4=h.memo(zA),C4=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,E4={[Au.Line]:"right",[Au.Handle]:"bottom-right"};function _4({nodeId:e,position:t,variant:n=Au.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=gA(),w=typeof e=="string"?e:k,j=On(),A=h.useRef(null),C=n===Au.Handle,$=Ut(h.useCallback(C4(C&&m),[C,m]),Hn),B=h.useRef(null),F=t??E4[n];h.useEffect(()=>{if(!(!A.current||!w))return B.current||(B.current=K3({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,X=L.width??R.measured.width??0,Z=L.height??R.measured.height??0,V={id:R.id,parentId:R.parentId,rect:{width:X,height:Z,...MP({x:L.x??R.position.x,y:L.y??R.position.y},{width:X,height:Z},R.parentId,M,P)}},ne=Hv([V],M,T,E);D.push(...ne),_.x=L.x?Math.max(P[0]*X,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 X={id:w,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:L.width,height:L.height}};D.push(X)}for(const P of O){const X={...P,type:"position"};D.push(X)}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:fr(["react-flow__resize-control","nodrag",...z,n,r]),ref:A,style:{...s,scale:$,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:i})}const BA=h.memo(_4);function P4(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const A4=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,I4=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,T4={};function mN(e,t){return(T4.jsx?I4:A4).test(e)}const R4=/[ \t\n\f\r]/g;function L4(e){return typeof e=="object"?e.type==="text"?gN(e.value):!1:gN(e)}function gN(e){return e.replace(R4,"")===""}let cp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};cp.prototype.normal={};cp.prototype.property={};cp.prototype.space=void 0;function HA(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new cp(n,r,t)}function eb(e){return e.toLowerCase()}class As{constructor(t,n){this.attribute=n,this.property=t}}As.prototype.attribute="";As.prototype.booleanish=!1;As.prototype.boolean=!1;As.prototype.commaOrSpaceSeparated=!1;As.prototype.commaSeparated=!1;As.prototype.defined=!1;As.prototype.mustUseProperty=!1;As.prototype.number=!1;As.prototype.overloadedBoolean=!1;As.prototype.property="";As.prototype.spaceSeparated=!1;As.prototype.space=void 0;let O4=0;const Pt=lc(),cr=lc(),tb=lc(),Ce=lc(),Cn=lc(),pu=lc(),Fs=lc();function lc(){return 2**++O4}const nb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Pt,booleanish:cr,commaOrSpaceSeparated:Fs,commaSeparated:pu,number:Ce,overloadedBoolean:tb,spaceSeparated:Cn},Symbol.toStringTag,{value:"Module"})),rx=Object.keys(nb);class Yv extends As{constructor(t,n,r,s){let i=-1;if(super(t,n),yN(this,"space",s),typeof r=="number")for(;++i<rx.length;){const a=rx[i];yN(this,rx[i],(r&nb[a])===nb[a])}}}Yv.prototype.defined=!0;function yN(e,t,n){n&&(e[t]=n)}function Bu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Yv(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[eb(r)]=r,n[eb(i.attribute)]=r}return new cp(t,n,e.space)}const WA=Bu({properties:{ariaActiveDescendant:null,ariaAtomic:cr,ariaAutoComplete:null,ariaBusy:cr,ariaChecked:cr,ariaColCount:Ce,ariaColIndex:Ce,ariaColSpan:Ce,ariaControls:Cn,ariaCurrent:null,ariaDescribedBy:Cn,ariaDetails:null,ariaDisabled:cr,ariaDropEffect:Cn,ariaErrorMessage:null,ariaExpanded:cr,ariaFlowTo:Cn,ariaGrabbed:cr,ariaHasPopup:null,ariaHidden:cr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Cn,ariaLevel:Ce,ariaLive:null,ariaModal:cr,ariaMultiLine:cr,ariaMultiSelectable:cr,ariaOrientation:null,ariaOwns:Cn,ariaPlaceholder:null,ariaPosInSet:Ce,ariaPressed:cr,ariaReadOnly:cr,ariaRelevant:null,ariaRequired:cr,ariaRoleDescription:Cn,ariaRowCount:Ce,ariaRowIndex:Ce,ariaRowSpan:Ce,ariaSelected:cr,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 VA(e,t){return t in e?e[t]:t}function UA(e,t){return VA(e,t.toLowerCase())}const M4=Bu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:pu,acceptCharset:Cn,accessKey:Cn,action:null,allow:null,allowFullScreen:Pt,allowPaymentRequest:Pt,allowUserMedia:Pt,alt:null,as:null,async:Pt,autoCapitalize:null,autoComplete:Cn,autoFocus:Pt,autoPlay:Pt,blocking:Cn,capture:null,charSet:null,checked:Pt,cite:null,className:Cn,cols:Ce,colSpan:null,content:null,contentEditable:cr,controls:Pt,controlsList:Cn,coords:Ce|pu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Pt,defer:Pt,dir:null,dirName:null,disabled:Pt,download:tb,draggable:cr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Pt,formTarget:null,headers:Cn,height:Ce,hidden:tb,high:Ce,href:null,hrefLang:null,htmlFor:Cn,httpEquiv:Cn,id:null,imageSizes:null,imageSrcSet:null,inert:Pt,inputMode:null,integrity:null,is:null,isMap:Pt,itemId:null,itemProp:Cn,itemRef:Cn,itemScope:Pt,itemType:Cn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Pt,low:Ce,manifest:null,max:null,maxLength:Ce,media:null,method:null,min:null,minLength:Ce,multiple:Pt,muted:Pt,name:null,nonce:null,noModule:Pt,noValidate:Pt,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:Pt,optimum:Ce,pattern:null,ping:Cn,placeholder:null,playsInline:Pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Pt,referrerPolicy:null,rel:Cn,required:Pt,reversed:Pt,rows:Ce,rowSpan:Ce,sandbox:Cn,scope:null,scoped:Pt,seamless:Pt,selected:Pt,shadowRootClonable:Pt,shadowRootDelegatesFocus:Pt,shadowRootMode:null,shape:null,size:Ce,sizes:null,slot:null,span:Ce,spellCheck:cr,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:Pt,useMap:null,value:cr,width:Ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Cn,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:Pt,declare:Pt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ce,leftMargin:Ce,link:null,longDesc:null,lowSrc:null,marginHeight:Ce,marginWidth:Ce,noResize:Pt,noHref:Pt,noShade:Pt,noWrap:Pt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ce,rules:null,scheme:null,scrolling:cr,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:Pt,disableRemotePlayback:Pt,prefix:null,property:null,results:Ce,security:null,unselectable:null},space:"html",transform:UA}),$4=Bu({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:Fs,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:Cn,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:Pt,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:pu,g2:pu,glyphName:pu,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:Fs,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:Cn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ce,pointsAtY:Ce,pointsAtZ:Ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Fs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Fs,rev:Fs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Fs,requiredFeatures:Fs,requiredFonts:Fs,requiredFormats:Fs,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:Fs,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:Fs,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:Fs,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:VA}),KA=Bu({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()}}),qA=Bu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:UA}),YA=Bu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),D4={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"},F4=/[A-Z]/g,xN=/-[a-z]/g,z4=/^data[-\w.:]+$/i;function B4(e,t){const n=eb(t);let r=t,s=As;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&z4.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(xN,W4);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!xN.test(i)){let a=i.replace(F4,H4);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Yv}return new s(r,t)}function H4(e){return"-"+e.toLowerCase()}function W4(e){return e.charAt(1).toUpperCase()}const V4=HA([WA,M4,KA,qA,YA],"html"),Gv=HA([WA,$4,KA,qA,YA],"svg");function U4(e){return e.join(" ").trim()}var Xv={},wN=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,K4=/\n/g,q4=/^\s*/,Y4=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,G4=/^:\s*/,X4=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,J4=/^[;\s]*/,Q4=/^\s+|\s+$/g,Z4=`
67
+ `,bN="/",vN="*",Ml="",eH="comment",tH="declaration";function nH(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(K4);b&&(n+=b.length);var v=g.lastIndexOf(Z4);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(q4)}function f(g){var b;for(g=g||[];b=u();)b!==!1&&g.push(b);return g}function u(){var g=i();if(!(bN!=e.charAt(0)||vN!=e.charAt(1))){for(var b=2;Ml!=e.charAt(b)&&(vN!=e.charAt(b)||bN!=e.charAt(b+1));)++b;if(b+=2,Ml===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:eH,comment:v})}}function p(){var g=i(),b=c(Y4);if(b){if(u(),!c(G4))return l("property missing ':'");var v=c(X4),y=g({type:tH,property:kN(b[0].replace(wN,Ml)),value:v?kN(v[0].replace(wN,Ml)):Ml});return c(J4),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 kN(e){return e?e.replace(Q4,Ml):Ml}var rH=nH,sH=df&&df.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Xv,"__esModule",{value:!0});Xv.default=oH;const iH=sH(rH);function oH(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,iH.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 zg={};Object.defineProperty(zg,"__esModule",{value:!0});zg.camelCase=void 0;var aH=/^--[a-zA-Z0-9_-]+$/,lH=/-([a-z])/g,cH=/^[^-]+$/,uH=/^-(webkit|moz|ms|o|khtml)-/,dH=/^-(ms)-/,fH=function(e){return!e||cH.test(e)||aH.test(e)},pH=function(e,t){return t.toUpperCase()},SN=function(e,t){return"".concat(t,"-")},hH=function(e,t){return t===void 0&&(t={}),fH(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(dH,SN):e=e.replace(uH,SN),e.replace(lH,pH))};zg.camelCase=hH;var mH=df&&df.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},gH=mH(Xv),yH=zg;function rb(e,t){var n={};return!e||typeof e!="string"||(0,gH.default)(e,function(r,s){r&&s&&(n[(0,yH.camelCase)(r,t)]=s)}),n}rb.default=rb;var xH=rb;const wH=il(xH),GA=XA("end"),Jv=XA("start");function XA(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 bH(e){const t=Jv(e),n=GA(e);if(t&&n)return{start:t,end:n}}function sf(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?NN(e.position):"start"in e||"end"in e?NN(e):"line"in e||"column"in e?sb(e):""}function sb(e){return jN(e&&e.line)+":"+jN(e&&e.column)}function NN(e){return sb(e&&e.start)+"-"+sb(e&&e.end)}function jN(e){return e&&typeof e=="number"?e:1}class Qr 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=sf(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}}Qr.prototype.file="";Qr.prototype.name="";Qr.prototype.reason="";Qr.prototype.message="";Qr.prototype.stack="";Qr.prototype.column=void 0;Qr.prototype.line=void 0;Qr.prototype.ancestors=void 0;Qr.prototype.cause=void 0;Qr.prototype.fatal=void 0;Qr.prototype.place=void 0;Qr.prototype.ruleId=void 0;Qr.prototype.source=void 0;const Qv={}.hasOwnProperty,vH=new Map,kH=/[A-Z]/g,SH=new Set(["table","tbody","thead","tfoot","tr"]),NH=new Set(["td","th"]),JA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function jH(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=RH(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=TH(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"?Gv:V4,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=QA(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function QA(e,t,n){if(t.type==="element")return CH(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return EH(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return PH(e,t,n);if(t.type==="mdxjsEsm")return _H(e,t);if(t.type==="root")return AH(e,t,n);if(t.type==="text")return IH(e,t)}function CH(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Gv,e.schema=s),e.ancestors.push(t);const i=eI(e,t.tagName,!1),a=LH(e,t);let l=e0(e,t);return SH.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!L4(c):!0})),ZA(e,a,i,t),Zv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function EH(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)}Ff(e,t.position)}function _H(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ff(e,t.position)}function PH(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Gv,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:eI(e,t.name,!0),a=OH(e,t),l=e0(e,t);return ZA(e,a,i,t),Zv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function AH(e,t,n){const r={};return Zv(r,e0(e,t)),e.create(t,e.Fragment,r,n)}function IH(e,t){return t.value}function ZA(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Zv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function TH(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 RH(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=Jv(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 LH(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Qv.call(t.properties,s)){const i=MH(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&NH.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 OH(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 Ff(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 Ff(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function e0(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:vH;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=QA(e,i,a);l!==void 0&&n.push(l)}return n}function MH(e,t,n){const r=B4(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?P4(n):U4(n)),r.property==="style"){let s=typeof n=="object"?n:$H(e,String(n));return e.stylePropertyNameCase==="css"&&(s=DH(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?D4[r.property]||r.property:r.attribute,n]}}function $H(e,t){try{return wH(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Qr("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=JA+"#cannot-parse-style-attribute",s}}function eI(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=mN(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=mN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Qv.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ff(e)}function Ff(e,t){const n=new Qr("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=JA+"#cannot-handle-mdx-estrees-without-createevaluater",n}function DH(e){const t={};let n;for(n in e)Qv.call(e,n)&&(t[FH(n)]=e[n]);return t}function FH(e){let t=e.replace(kH,zH);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function zH(e){return"-"+e.toLowerCase()}const sx={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"]},BH={};function HH(e,t){const n=BH,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return tI(e,r,s)}function tI(e,t,n){if(WH(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 CN(e.children,t,n)}return Array.isArray(e)?CN(e,t,n):""}function CN(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=tI(e[s],t,n);return r.join("")}function WH(e){return!!(e&&typeof e=="object")}const EN=document.createElement("i");function t0(e){const t="&"+e+";";EN.innerHTML=t;const n=EN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function jo(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 fi(e,t){return e.length>0?(jo(e,e.length,0,t),e):t}const _N={}.hasOwnProperty;function VH(e){const t={};let n=-1;for(;++n<e.length;)UH(t,e[n]);return t}function UH(e,t){let n;for(n in t){const s=(_N.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){_N.call(s,a)||(s[a]=[]);const l=i[a];KH(s[a],Array.isArray(l)?l:l?[l]:[])}}}function KH(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);jo(e,0,0,r)}function nI(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 hu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const go=cl(/[A-Za-z]/),Vs=cl(/[\dA-Za-z]/),qH=cl(/[#-'*+\--9=?A-Z^-~]/);function ib(e){return e!==null&&(e<32||e===127)}const ob=cl(/\d/),YH=cl(/[\dA-Fa-f]/),GH=cl(/[!-/:-@[-`{-~]/);function yt(e){return e!==null&&e<-2}function _s(e){return e!==null&&(e<0||e===32)}function en(e){return e===-2||e===-1||e===32}const XH=cl(new RegExp("\\p{P}|\\p{S}","u")),JH=cl(/\s/);function cl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Hu(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Vs(e.charCodeAt(n+1))&&Vs(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 _n(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 QH={tokenize:ZH};function ZH(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"),_n(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 yt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const e6={tokenize:t6},PN={tokenize:n6};function t6(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 jo(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(PN,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(PN,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 yt(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++;jo(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 n6(e,t,n){return _n(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function AN(e){if(e===null||_s(e)||JH(e))return 1;if(XH(e))return 2}function n0(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 ab={name:"attention",resolveAll:r6,tokenize:s6};function r6(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};IN(u,-c),IN(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=fi(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=fi(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=fi(d,n0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=fi(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=fi(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,jo(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 s6(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=AN(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=AN(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 IN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const i6={name:"autolink",tokenize:o6};function o6(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 go(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||Vs(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||Vs(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||ib(m)?n(m):(e.consume(m),c)}function d(m){return m===64?(e.consume(m),f):qH(m)?(e.consume(m),d):n(m)}function f(m){return Vs(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||Vs(m))&&r++<63){const g=m===45?p:u;return e.consume(m),g}return n(m)}}const Bg={partial:!0,tokenize:a6};function a6(e,t,n){return r;function r(i){return en(i)?_n(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||yt(i)?t(i):n(i)}}const rI={continuation:{tokenize:c6},exit:u6,name:"blockQuote",tokenize:l6};function l6(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 c6(e,t,n){const r=this;return s;function s(a){return en(a)?_n(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(rI,t,n)(a)}}function u6(e){e.exit("blockQuote")}const sI={name:"characterEscape",tokenize:d6};function d6(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 GH(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const iI={name:"characterReference",tokenize:f6};function f6(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=Vs,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=YH,f):(e.enter("characterReferenceValue"),i=7,a=ob,f(u))}function f(u){if(u===59&&s){const p=e.exit("characterReferenceValue");return a===Vs&&!t0(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 TN={partial:!0,tokenize:h6},RN={concrete:!0,name:"codeFenced",tokenize:p6};function p6(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)?_n(e,u,"whitespace")(C):u(C))}function u(C){return C===null||yt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(TN,b,j)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||yt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),u(C)):en(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),_n(e,m,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function m(C){return C===null||yt(C)?u(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(C))}function g(C){return C===null||yt(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)?_n(e,k,"linePrefix",i+1)(C):k(C)}function k(C){return C===null||yt(C)?e.check(TN,b,j)(C):(e.enter("codeFlowValue"),w(C))}function w(C){return C===null||yt(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)?_n(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)?_n(C,M,"whitespace")(T):M(T)):B(T)}function M(T){return T===null||yt(T)?(C.exit("codeFencedFence"),$(T)):B(T)}}}function h6(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 ix={name:"codeIndented",tokenize:g6},m6={partial:!0,tokenize:y6};function g6(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),_n(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):yt(d)?e.attempt(m6,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||yt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function y6(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):yt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):_n(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):yt(a)?s(a):n(a)}}const x6={name:"codeText",previous:b6,resolve:w6,tokenize:v6};function w6(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 b6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function v6(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)):yt(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||yt(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 k6{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&&_d(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),_d(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),_d(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);_d(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);_d(this.left,n.reverse())}}}function _d(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 oI(e){const t={};let n=-1,r,s,i,a,l,c,d;const f=new k6(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,S6(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 jo(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function S6(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 N6={resolve:C6,tokenize:E6},j6={partial:!0,tokenize:_6};function C6(e){return oI(e),e}function E6(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):yt(l)?e.check(j6,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 _6(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),_n(e,i,"linePrefix")}function i(a){if(a===null||yt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function aI(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||ib(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||yt(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||_s(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||ib(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 lI(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):yt(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||yt(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 cI(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):yt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),_n(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||yt(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 of(e,t){let n;return r;function r(s){return yt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):en(s)?_n(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const P6={name:"definition",tokenize:I6},A6={partial:!0,tokenize:T6};function I6(e,t,n){const r=this;let s;return i;function i(m){return e.enter("definition"),a(m)}function a(m){return lI.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=hu(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 _s(m)?of(e,d)(m):d(m)}function d(m){return aI(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(A6,u,u)(m)}function u(m){return en(m)?_n(e,p,"whitespace")(m):p(m)}function p(m){return m===null||yt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function T6(e,t,n){return r;function r(l){return _s(l)?of(e,s)(l):n(l)}function s(l){return cI(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return en(l)?_n(e,a,"whitespace")(l):a(l)}function a(l){return l===null||yt(l)?t(l):n(l)}}const R6={name:"hardBreakEscape",tokenize:L6};function L6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return yt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const O6={name:"headingAtx",resolve:M6,tokenize:$6};function M6(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"},jo(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function $6(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||_s(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||yt(f)?(e.exit("atxHeading"),t(f)):en(f)?_n(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||_s(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),d)}}const D6=["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"],LN=["pre","script","style","textarea"],F6={concrete:!0,name:"htmlFlow",resolveTo:H6,tokenize:W6},z6={partial:!0,tokenize:U6},B6={partial:!0,tokenize:V6};function H6(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 W6(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):go(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):go(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 ne="CDATA[";return V===ne.charCodeAt(l++)?(e.consume(V),l===ne.length?r.interrupt?t:O:g):n(V)}function b(V){return go(V)?(e.consume(V),a=String.fromCharCode(V),v):n(V)}function v(V){if(V===null||V===47||V===62||_s(V)){const ne=V===47,ue=a.toLowerCase();return!ne&&!i&&LN.includes(ue)?(s=1,r.interrupt?t(V):O(V)):D6.includes(a.toLowerCase())?(s=6,ne?(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||Vs(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||go(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||Vs(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||yt(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||_s(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||yt(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),X):V===63&&s===3?(e.consume(V),P):V===93&&s===5?(e.consume(V),R):yt(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(z6,Z,W)(V)):V===null||yt(V)?(e.exit("htmlFlowData"),W(V)):(e.consume(V),O)}function W(V){return e.check(B6,M,Z)(V)}function M(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),T}function T(V){return V===null||yt(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 ne=a.toLowerCase();return LN.includes(ne)?(e.consume(V),X):O(V)}return go(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),X):V===45&&s===2?(e.consume(V),P):O(V)}function X(V){return V===null||yt(V)?(e.exit("htmlFlowData"),Z(V)):(e.consume(V),X)}function Z(V){return e.exit("htmlFlow"),t(V)}}function V6(e,t,n){const r=this;return s;function s(a){return yt(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 U6(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Bg,t,n)}}const K6={name:"htmlText",tokenize:q6};function q6(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):go(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):go(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):yt(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 X="CDATA[";return P===X.charCodeAt(i++)?(e.consume(P),i===X.length?b:g):n(P)}function b(P){return P===null?n(P):P===93?(e.consume(P),v):yt(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):yt(P)?(a=k,D(P)):(e.consume(P),k)}function w(P){return P===null?n(P):P===63?(e.consume(P),j):yt(P)?(a=w,D(P)):(e.consume(P),w)}function j(P){return P===62?E(P):w(P)}function A(P){return go(P)?(e.consume(P),C):n(P)}function C(P){return P===45||Vs(P)?(e.consume(P),C):$(P)}function $(P){return yt(P)?(a=$,D(P)):en(P)?(e.consume(P),$):E(P)}function B(P){return P===45||Vs(P)?(e.consume(P),B):P===47||P===62||_s(P)?F(P):n(P)}function F(P){return P===47?(e.consume(P),E):P===58||P===95||go(P)?(e.consume(P),z):yt(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||Vs(P)?(e.consume(P),z):L(P)}function L(P){return P===61?(e.consume(P),O):yt(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):yt(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):yt(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||_s(P)?F(P):(e.consume(P),M)}function T(P){return P===47||P===62||_s(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)?_n(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 r0={name:"labelEnd",resolveAll:J6,resolveTo:Q6,tokenize:Z6},Y6={tokenize:e8},G6={tokenize:t8},X6={tokenize:n8};function J6(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&&jo(e,0,e.length,n),e}function Q6(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=fi(l,e.slice(i+1,i+r+3)),l=fi(l,[["enter",f,t]]),l=fi(l,n0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=fi(l,[["exit",f,t],e[a-2],e[a-1],["exit",d,t]]),l=fi(l,e.slice(a+1)),l=fi(l,[["exit",c,t]]),jo(e,i,e.length,l),e}function Z6(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(hu(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(Y6,f,a?f:u)(p):p===91?e.attempt(G6,f,a?d:u)(p):a?f(p):u(p)}function d(p){return e.attempt(X6,f,u)(p)}function f(p){return t(p)}function u(p){return i._balanced=!0,n(p)}}function e8(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 _s(u)?of(e,i)(u):i(u)}function i(u){return u===41?f(u):aI(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function a(u){return _s(u)?of(e,c)(u):f(u)}function l(u){return n(u)}function c(u){return u===34||u===39||u===40?cI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):f(u)}function d(u){return _s(u)?of(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 t8(e,t,n){const r=this;return s;function s(l){return lI.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(hu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function n8(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 r8={name:"labelStartImage",resolveAll:r0.resolveAll,tokenize:s8};function s8(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 i8={name:"labelStartLink",resolveAll:r0.resolveAll,tokenize:o8};function o8(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 ox={name:"lineEnding",tokenize:a8};function a8(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),_n(e,t,"linePrefix")}}const Yh={name:"thematicBreak",tokenize:l8};function l8(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||yt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),en(d)?_n(e,l,"whitespace")(d):l(d))}}const ys={continuation:{tokenize:f8},exit:h8,name:"list",tokenize:d8},c8={partial:!0,tokenize:m8},u8={partial:!0,tokenize:p8};function d8(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:ob(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(Yh,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 ob(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(Bg,r.interrupt?n:f,e.attempt(c8,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 f8(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Bg,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,_n(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(u8,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,_n(e,e.attempt(ys,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function p8(e,t,n){const r=this;return _n(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 h8(e){e.exit(this.containerState.type)}function m8(e,t,n){const r=this;return _n(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 ON={name:"setextUnderline",resolveTo:g8,tokenize:y8};function g8(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 y8(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)?_n(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||yt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const x8={tokenize:w8};function w8(e){const t=this,n=e.attempt(Bg,r,e.attempt(this.parser.constructs.flowInitial,s,_n(e,e.attempt(this.parser.constructs.flow,s,e.attempt(N6,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 b8={resolveAll:dI()},v8=uI("string"),k8=uI("text");function uI(e){return{resolveAll:dI(e==="text"?S8: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 dI(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 S8(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 N8={42:ys,43:ys,45:ys,48:ys,49:ys,50:ys,51:ys,52:ys,53:ys,54:ys,55:ys,56:ys,57:ys,62:rI},j8={91:P6},C8={[-2]:ix,[-1]:ix,32:ix},E8={35:O6,42:Yh,45:[ON,Yh],60:F6,61:ON,95:Yh,96:RN,126:RN},_8={38:iI,92:sI},P8={[-5]:ox,[-4]:ox,[-3]:ox,33:r8,38:iI,42:ab,60:[i6,K6],91:i8,92:[R6,sI],93:r0,95:ab,96:x6},A8={null:[ab,b8]},I8={null:[42,95]},T8={null:[]},R8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:I8,contentInitial:j8,disable:T8,document:N8,flow:E8,flowInitial:C8,insideSpan:A8,string:_8,text:P8},Symbol.toStringTag,{value:"Module"}));function L8(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=fi(a,L),v(),a[a.length-1]!==null?[]:(B(t,0),d.events=n0(i,d.events,d),d.events)}function p(L,O){return M8(m(L),O)}function m(L){return O8(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){yt(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]):X(M);function X(pe){return ge;function ge(ae){const be=ae!==null&&pe[ae],Ae=ae!==null&&pe.null,we=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return Z(we)(ae)}}function Z(pe){return D=pe,_=0,pe.length===0?E:V(pe[_])}function V(pe){return ge;function ge(ae){return P=F(),R=pe,pe.partial||(d.currentConstruct=pe),pe.name&&d.parser.constructs.disable.null.includes(pe.name)?ue():pe.tokenize.call(O?Object.assign(Object.create(d),O):d,c,ne,ue)(ae)}}function ne(pe){return L(R,P),T}function ue(pe){return P.restore(),++_<D.length?V(D[_]):E}}}function B(L,O){L.resolveAll&&!i.includes(L)&&i.push(L),L.resolve&&jo(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 O8(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 M8(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 $8(e){const r={constructs:VH([R8,...(e||{}).extensions||[]]),content:s(QH),defined:[],document:s(e6),flow:s(x8),lazy:{},string:s(v8),text:s(k8)};return r;function s(i){return a;function a(l){return L8(r,i,l)}}}function D8(e){for(;!oI(e););return e}const MN=/[\0\t\n\r]/g;function F8(){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(MN.lastIndex=u,d=MN.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 z8=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function B8(e){return e.replace(z8,H8)}function H8(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return nI(n.slice(i?2:1),i?16:10)}return t0(n)||e}const fI={}.hasOwnProperty;function W8(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),V8(n)(D8($8(n).document().write(F8()(e,t,!0))))}function V8(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(kt),autolinkProtocol:F,autolinkEmail:F,atxHeading:i(ct),blockQuote:i(Ae),characterEscape:F,characterReference:F,codeFenced:i(we),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(we,a),codeText:i(Pe,a),codeTextData:F,data:F,codeFlowValue:F,definition:i(Te),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(it),hardBreakEscape:i(tt),hardBreakTrailing:i(tt),htmlFlow:i(jt,a),htmlFlowData:F,htmlText:i(jt,a),htmlTextData:F,image:i(Ye),label:a,link:i(kt),listItem:i(vn),listItemValue:p,listOrdered:i(nn,u),listUnordered:i(nn),paragraph:i(Mn),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ct),strong:i(Ht),thematicBreak:i(Wn)},exit:{atxHeading:c(),atxHeadingSequence:A,autolink:c(),autolinkEmail:be,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:z,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:pe,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:ne,resourceDestinationString:P,resourceTitleString:X,resource:Z,setextHeading:c(B),setextHeadingLineSequence:$,setextHeadingText:C,strong:c(),thematicBreak:c()}};pI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(le){let de={type:"root",children:[]};const He={stack:[de],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:f,data:n},Ze=[];let ot=-1;for(;++ot<le.length;)if(le[ot][1].type==="listOrdered"||le[ot][1].type==="listUnordered")if(le[ot][0]==="enter")Ze.push(ot);else{const Xt=Ze.pop();ot=s(le,Xt,ot)}for(ot=-1;++ot<le.length;){const Xt=t[le[ot][0]];fI.call(Xt,le[ot][1].type)&&Xt[le[ot][1].type].call(Object.assign({sliceSerialize:le[ot][2].sliceSerialize},He),le[ot][1])}if(He.tokenStack.length>0){const Xt=He.tokenStack[He.tokenStack.length-1];(Xt[1]||$N).call(He,void 0,Xt[0])}for(de.position={start:Ea(le.length>0?le[0][1].start:{line:1,column:1,offset:0}),end:Ea(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,He){let Ze=de-1,ot=-1,Xt=!1,rn,sn,An,Sr;for(;++Ze<=He;){const Jt=le[Ze];switch(Jt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Jt[0]==="enter"?ot++:ot--,Sr=void 0;break}case"lineEndingBlank":{Jt[0]==="enter"&&(rn&&!Sr&&!ot&&!An&&(An=Ze),Sr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Sr=void 0}if(!ot&&Jt[0]==="enter"&&Jt[1].type==="listItemPrefix"||ot===-1&&Jt[0]==="exit"&&(Jt[1].type==="listUnordered"||Jt[1].type==="listOrdered")){if(rn){let mn=Ze;for(sn=void 0;mn--;){const Vn=le[mn];if(Vn[1].type==="lineEnding"||Vn[1].type==="lineEndingBlank"){if(Vn[0]==="exit")continue;sn&&(le[sn][1].type="lineEndingBlank",Xt=!0),Vn[1].type="lineEnding",sn=mn}else if(!(Vn[1].type==="linePrefix"||Vn[1].type==="blockQuotePrefix"||Vn[1].type==="blockQuotePrefixWhitespace"||Vn[1].type==="blockQuoteMarker"||Vn[1].type==="listItemIndent"))break}An&&(!sn||An<sn)&&(rn._spread=!0),rn.end=Object.assign({},sn?le[sn][1].start:Jt[1].end),le.splice(sn||Ze,0,["exit",rn,Jt[2]]),Ze++,He++}if(Jt[1].type==="listItemPrefix"){const mn={type:"listItem",_spread:!1,start:Object.assign({},Jt[1].start),end:void 0};rn=mn,le.splice(Ze,0,["enter",mn,Jt[2]]),Ze++,He++,An=void 0,Sr=!0}}}return le[de][1]._spread=Xt,He}function i(le,de){return He;function He(Ze){l.call(this,le(Ze),Ze),de&&de.call(this,Ze)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(le,de,He){this.stack[this.stack.length-1].children.push(le),this.stack.push(le),this.tokenStack.push([de,He||void 0]),le.position={start:Ea(de.start),end:void 0}}function c(le){return de;function de(He){le&&le.call(this,He),d.call(this,He)}}function d(le,de){const He=this.stack.pop(),Ze=this.tokenStack.pop();if(Ze)Ze[0].type!==le.type&&(de?de.call(this,le,Ze[0]):(Ze[1]||$N).call(this,le,Ze[0]));else throw new Error("Cannot close `"+le.type+"` ("+sf({start:le.start,end:le.end})+"): it’s not open");He.position.end=Ea(le.end)}function f(){return HH(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(),He=this.stack[this.stack.length-1];He.label=de,He.identifier=hu(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 He=this.sliceSerialize(le).length;de.depth=He}}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 He=this.stack[this.stack.length-1].children;let Ze=He[He.length-1];(!Ze||Ze.type!=="text")&&(Ze=$n(),Ze.position={start:Ea(le.start),end:void 0},He.push(Ze)),this.stack.push(Ze)}function z(le){const de=this.stack.pop();de.value+=this.sliceSerialize(le),de.position.end=Ea(le.end)}function L(le){const de=this.stack[this.stack.length-1];if(this.data.atHardBreak){const He=de.children[de.children.length-1];He.position.end=Ea(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),He=this.stack[this.stack.length-2];He.label=B8(de),He.identifier=hu(de).toLowerCase()}function R(){const le=this.stack[this.stack.length-1],de=this.resume(),He=this.stack[this.stack.length-1];if(this.data.inReference=!0,He.type==="link"){const Ze=le.children;He.children=Ze}else He.alt=de}function P(){const le=this.resume(),de=this.stack[this.stack.length-1];de.url=le}function X(){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 ne(le){const de=this.resume(),He=this.stack[this.stack.length-1];He.label=de,He.identifier=hu(this.sliceSerialize(le)).toLowerCase(),this.data.referenceType="full"}function ue(le){this.data.characterReferenceType=le.type}function pe(le){const de=this.sliceSerialize(le),He=this.data.characterReferenceType;let Ze;He?(Ze=nI(de,He==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ze=t0(de);const ot=this.stack[this.stack.length-1];ot.value+=Ze}function ge(le){const de=this.stack.pop();de.position.end=Ea(le.end)}function ae(le){z.call(this,le);const de=this.stack[this.stack.length-1];de.url=this.sliceSerialize(le)}function be(le){z.call(this,le);const de=this.stack[this.stack.length-1];de.url="mailto:"+this.sliceSerialize(le)}function Ae(){return{type:"blockquote",children:[]}}function we(){return{type:"code",lang:null,meta:null,value:""}}function Pe(){return{type:"inlineCode",value:""}}function Te(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function it(){return{type:"emphasis",children:[]}}function ct(){return{type:"heading",depth:0,children:[]}}function tt(){return{type:"break"}}function jt(){return{type:"html",value:""}}function Ye(){return{type:"image",title:null,url:"",alt:null}}function kt(){return{type:"link",title:null,url:"",children:[]}}function nn(le){return{type:"list",ordered:le.type==="listOrdered",start:null,spread:le._spread,children:[]}}function vn(le){return{type:"listItem",spread:le._spread,checked:null,children:[]}}function Mn(){return{type:"paragraph",children:[]}}function Ht(){return{type:"strong",children:[]}}function $n(){return{type:"text",value:""}}function Wn(){return{type:"thematicBreak"}}}function Ea(e){return{line:e.line,column:e.column,offset:e.offset}}function pI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?pI(e,r):U8(e,r)}}function U8(e,t){let n;for(n in t)if(fI.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 $N(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+sf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+sf({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+sf({start:t.start,end:t.end})+") is still open")}function K8(e){const t=this;t.parser=n;function n(r){return W8(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function q8(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 Y8(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
+ `}]}function G8(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 X8(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function J8(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Q8(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Hu(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 Z8(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 e9(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function hI(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 t9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return hI(e,t);const s={src:Hu(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 n9(e,t){const n={src:Hu(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 r9(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 s9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return hI(e,t);const s={href:Hu(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 i9(e,t){const n={href:Hu(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 o9(e,t,n){const r=e.all(t),s=n?a9(n):mI(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 a9(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=mI(n[r])}return t}function mI(e){const t=e.spread;return t??e.children.length>1}function l9(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 c9(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function u9(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function d9(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function f9(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=Jv(t.children[1]),c=GA(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 p9(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 h9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const DN=9,FN=32;function m9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(zN(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(zN(t.slice(s),s>0,!1)),i.join("")}function zN(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===DN||i===FN;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===DN||i===FN;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function g9(e,t){const n={type:"text",value:m9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function y9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const x9={blockquote:q8,break:Y8,code:G8,delete:X8,emphasis:J8,footnoteReference:Q8,heading:Z8,html:e9,imageReference:t9,image:n9,inlineCode:r9,linkReference:s9,link:i9,listItem:o9,list:l9,paragraph:c9,root:u9,strong:d9,table:f9,tableCell:h9,tableRow:p9,text:g9,thematicBreak:y9,toml:mh,yaml:mh,definition:mh,footnoteDefinition:mh};function mh(){}const gI=-1,Hg=0,af=1,Dm=2,s0=3,i0=4,o0=5,a0=6,yI=7,xI=8,BN=typeof self=="object"?self:globalThis,w9=(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 Hg:case gI:return n(a,s);case af:{const l=n([],s);for(const c of a)l.push(r(c));return l}case Dm:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case s0:return n(new Date(a),s);case i0:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case o0:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case a0:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case yI:{const{name:l,message:c}=a;return n(new BN[l](c),s)}case xI: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 BN[i](a),s)};return r},HN=e=>w9(new Map,e)(0),Rc="",{toString:b9}={},{keys:v9}=Object,Pd=e=>{const t=typeof e;if(t!=="object"||!e)return[Hg,t];const n=b9.call(e).slice(8,-1);switch(n){case"Array":return[af,Rc];case"Object":return[Dm,Rc];case"Date":return[s0,Rc];case"RegExp":return[i0,Rc];case"Map":return[o0,Rc];case"Set":return[a0,Rc];case"DataView":return[af,n]}return n.includes("Array")?[af,n]:n.includes("Error")?[yI,n]:[Dm,n]},gh=([e,t])=>e===Hg&&(t==="function"||t==="symbol"),k9=(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]=Pd(a);switch(l){case Hg:{let f=a;switch(c){case"bigint":l=xI,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return s([gI],a)}return s([l,f],a)}case af:{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 Dm:{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 v9(a))(e||!gh(Pd(a[p])))&&f.push([i(p),i(a[p])]);return u}case s0:return s([l,a.toISOString()],a);case i0:{const{source:f,flags:u}=a;return s([l,{source:f,flags:u}],a)}case o0:{const f=[],u=s([l,f],a);for(const[p,m]of a)(e||!(gh(Pd(p))||gh(Pd(m))))&&f.push([i(p),i(m)]);return u}case a0:{const f=[],u=s([l,f],a);for(const p of a)(e||!gh(Pd(p)))&&f.push(i(p));return u}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return i},WN=(e,{json:t,lossy:n}={})=>{const r=[];return k9(!(t||n),!!t,new Map,r)(e),r},Fm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?HN(WN(e,t)):structuredClone(e):(e,t)=>HN(WN(e,t));function S9(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 N9(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function j9(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||S9,r=e.options.footnoteBackLabel||N9,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=Hu(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:{...Fm(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 wI=function(e){if(e==null)return P9;if(typeof e=="function")return Wg(e);if(typeof e=="object")return Array.isArray(e)?C9(e):E9(e);if(typeof e=="string")return _9(e);throw new Error("Expected function, string, or object as test")};function C9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=wI(e[n]);return Wg(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function E9(e){const t=e;return Wg(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function _9(e){return Wg(t);function t(n){return n&&n.type===e}}function Wg(e){return t;function t(n,r,s){return!!(A9(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function P9(){return!0}function A9(e){return e!==null&&typeof e=="object"&&"type"in e}const bI=[],I9=!0,VN=!1,T9="skip";function R9(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=wI(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=bI,g,b,v;if((!t||i(c,d,f[f.length-1]||void 0))&&(m=L9(n(c,f)),m[0]===VN))return m;if("children"in c&&c.children){const y=c;if(y.children&&m[0]!==T9)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]===VN)return g;b=typeof g[1]=="number"?g[1]:b+a}}return m}}}function L9(e){return Array.isArray(e)?e:typeof e=="number"?[I9,e]:e==null?bI:[e]}function vI(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),R9(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 lb={}.hasOwnProperty,O9={};function M9(e,t){const n=t||O9,r=new Map,s=new Map,i=new Map,a={...x9,...n.handlers},l={all:d,applyData:D9,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:$9,wrap:z9};return vI(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(lb.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=Fm(v);return y.children=l.all(f),y}return Fm(f)}return(l.options.unknownHandler||F9)(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=UN(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=UN(b.value))}Array.isArray(g)?u.push(...g):u.push(g)}}}return u}}function $9(e,t){e.position&&(t.position=bH(e))}function D9(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,Fm(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function F9(e,t){const n=t.data||{},r="value"in t&&!(lb.call(n,"hProperties")||lb.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 z9(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 UN(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function KN(e,t){const n=M9(e,t),r=n.one(e,void 0),s=j9(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 B9(e,t){return e&&"run"in e?async function(n,r){const s=KN(n,{file:r,...t});await e.run(s,r)}:function(n,r){return KN(n,{file:r,...e||t})}}function qN(e){if(e)throw e}var Gh=Object.prototype.hasOwnProperty,kI=Object.prototype.toString,YN=Object.defineProperty,GN=Object.getOwnPropertyDescriptor,XN=function(t){return typeof Array.isArray=="function"?Array.isArray(t):kI.call(t)==="[object Array]"},JN=function(t){if(!t||kI.call(t)!=="[object Object]")return!1;var n=Gh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Gh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Gh.call(t,s)},QN=function(t,n){YN&&n.name==="__proto__"?YN(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},ZN=function(t,n){if(n==="__proto__")if(Gh.call(t,n)){if(GN)return GN(t,n).value}else return;return t[n]},H9=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=ZN(l,n),s=ZN(t,n),l!==s&&(f&&s&&(JN(s)||(i=XN(s)))?(i?(i=!1,a=r&&XN(r)?r:[]):a=r&&JN(r)?r:{},QN(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&QN(l,{name:n,newValue:s}));return l};const ax=il(H9);function cb(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 W9(){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?V9(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 V9(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 uo={basename:U9,dirname:K9,extname:q9,join:Y9,sep:"/"};function U9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');up(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 K9(e){if(up(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 q9(e){up(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 Y9(...e){let t=-1,n;for(;++t<e.length;)up(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":G9(n)}function G9(e){up(e);const t=e.codePointAt(0)===47;let n=X9(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function X9(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 up(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const J9={cwd:Q9};function Q9(){return"/"}function ub(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Z9(e){if(typeof e=="string")e=new URL(e);else if(!ub(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 eW(e)}function eW(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 lx=["history","path","basename","stem","extname","dirname"];class SI{constructor(t){let n;t?ub(t)?n={path:t}:typeof t=="string"||tW(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":J9.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<lx.length;){const i=lx[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)lx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?uo.basename(this.path):void 0}set basename(t){ux(t,"basename"),cx(t,"basename"),this.path=uo.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?uo.dirname(this.path):void 0}set dirname(t){ej(this.basename,"dirname"),this.path=uo.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?uo.extname(this.path):void 0}set extname(t){if(cx(t,"extname"),ej(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=uo.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){ub(t)&&(t=Z9(t)),ux(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?uo.basename(this.path,this.extname):void 0}set stem(t){ux(t,"stem"),cx(t,"stem"),this.path=uo.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 Qr(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 cx(e,t){if(e&&e.includes(uo.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+uo.sep+"`")}function ux(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ej(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function tW(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const nW=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},rW={}.hasOwnProperty;class l0 extends nW{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=W9()}copy(){const t=new l0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ax(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(px("data",this.frozen),this.namespace[t]=n,this):rW.call(this.namespace,t)&&this.namespace[t]||void 0:t?(px("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=yh(t),r=this.parser||this.Parser;return dx("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),dx("process",this.parser||this.Parser),fx("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=yh(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);oW(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(),dx("processSync",this.parser||this.Parser),fx("processSync",this.compiler||this.Compiler),this.process(t,s),nj("processSync","process",n),r;function s(i,a){n=!0,qN(i),r=a}}run(t,n,r){tj(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=yh(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),nj("runSync","run",r),s;function i(a,l){qN(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=yh(n),s=this.compiler||this.Compiler;return fx("stringify",s),tj(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(px("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=ax(!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];cb(b)&&cb(m)&&(m=ax(!0,b,m)),r[p]=[d,m,...g]}}}}const sW=new l0().freeze();function dx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function fx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function px(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 tj(e){if(!cb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function nj(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function yh(e){return iW(e)?e:new SI(e)}function iW(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function oW(e){return typeof e=="string"||aW(e)}function aW(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const lW="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",rj=[],sj={allowDangerousHtml:!0},cW=/^(https?|ircs?|mailto|xmpp)$/i,uW=[{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 dp(e){const t=dW(e),n=fW(e);return pW(t.runSync(t.parse(n),n),e)}function dW(e){const t=e.rehypePlugins||rj,n=e.remarkPlugins||rj,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sj}:sj;return sW().use(K8).use(n).use(B9,r).use(t)}function fW(e){const t=e.children||"",n=new SI;return typeof t=="string"&&(n.value=t),n}function pW(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||hW;for(const f of uW)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+lW+f.id,void 0);return vI(e,d),jH(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 sx)if(Object.hasOwn(sx,m)&&Object.hasOwn(f.properties,m)){const g=f.properties[m],b=sx[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 hW(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||cW.test(e.slice(0,t))?e:""}function mW(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function zm(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>zm(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${zm(t[r])}`).join(",")}}`}function ij(e){return zm({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 zf(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function oj(e){return zm({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 aj(e,t){return!mW(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function lj(e,t=!1){const n=new Map;for(const r of e){const s=zf(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function gW(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?ij(w)===ij(k)?(a.add(k.id),w):(c.push(k.id),aj(k,w)):(l.push(k.id),k)}),f=lj(t),u=lj(r,!0),p=new Set,m=[],g=[],b=r.map(k=>{const w=zf(k),j=f.get(w);return j?oj(j)===oj(k)?(p.add(w),j):(g.push(w),aj(k,j)):(m.push(w),k)}),v=e.filter(k=>!i.has(k.id)).map(k=>k.id),y=t.map(k=>zf(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 NI(e){return typeof e>"u"||e===null}function yW(e){return typeof e=="object"&&e!==null}function xW(e){return Array.isArray(e)?e:NI(e)?[]:[e]}function wW(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 bW(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function vW(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var kW=NI,SW=yW,NW=xW,jW=bW,CW=vW,EW=wW,vr={isNothing:kW,isObject:SW,toArray:NW,repeat:jW,isNegativeZero:CW,extend:EW};function jI(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 Bf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=jI(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Bf.prototype=Object.create(Error.prototype);Bf.prototype.constructor=Bf;Bf.prototype.toString=function(t){return this.name+": "+jI(this,t)};var os=Bf;function hx(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 mx(e,t){return vr.repeat(" ",t-e.length)+e}function _W(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=hx(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),u),l=vr.repeat(" ",t.indent)+mx((e.line-c+1).toString(),f)+" | "+d.str+`
82
+ `+l;for(d=hx(e.buffer,r[a],s[a],e.position,u),l+=vr.repeat(" ",t.indent)+mx((e.line+1).toString(),f)+" | "+d.str+`
83
+ `,l+=vr.repeat("-",t.indent+f+3+d.pos)+`^
84
+ `,c=1;c<=t.linesAfter&&!(a+c>=s.length);c++)d=hx(e.buffer,r[a+c],s[a+c],e.position-(r[a]-r[a+c]),u),l+=vr.repeat(" ",t.indent)+mx((e.line+c+1).toString(),f)+" | "+d.str+`
85
+ `;return l.replace(/\n$/,"")}var PW=_W,AW=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],IW=["scalar","sequence","mapping"];function TW(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function RW(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(AW.indexOf(n)===-1)throw new os('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=TW(t.styleAliases||null),IW.indexOf(this.kind)===-1)throw new os('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Fr=RW;function cj(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 LW(){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 db(e){return this.extend(e)}db.prototype.extend=function(t){var n=[],r=[];if(t instanceof Fr)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 os("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof Fr))throw new os("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new os("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 os("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 Fr))throw new os("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(db.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=cj(s,"implicit"),s.compiledExplicit=cj(s,"explicit"),s.compiledTypeMap=LW(s.compiledImplicit,s.compiledExplicit),s};var CI=db,EI=new Fr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),_I=new Fr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),PI=new Fr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),AI=new CI({explicit:[EI,_I,PI]});function OW(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function MW(){return null}function $W(e){return e===null}var II=new Fr("tag:yaml.org,2002:null",{kind:"scalar",resolve:OW,construct:MW,predicate:$W,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function DW(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 FW(e){return e==="true"||e==="True"||e==="TRUE"}function zW(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var TI=new Fr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:DW,construct:FW,predicate:zW,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 BW(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function HW(e){return 48<=e&&e<=55}function WW(e){return 48<=e&&e<=57}function VW(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(!BW(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!HW(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!WW(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function UW(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 KW(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!vr.isNegativeZero(e)}var RI=new Fr("tag:yaml.org,2002:int",{kind:"scalar",resolve:VW,construct:UW,predicate:KW,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"]}}),qW=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function YW(e){return!(e===null||!qW.test(e)||e[e.length-1]==="_")}function GW(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 XW=/^[-+]?[0-9]+e/;function JW(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(vr.isNegativeZero(e))return"-0.0";return n=e.toString(10),XW.test(n)?n.replace("e",".e"):n}function QW(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||vr.isNegativeZero(e))}var LI=new Fr("tag:yaml.org,2002:float",{kind:"scalar",resolve:YW,construct:GW,predicate:QW,represent:JW,defaultStyle:"lowercase"}),OI=AI.extend({implicit:[II,TI,RI,LI]}),MI=OI,$I=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),DI=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 ZW(e){return e===null?!1:$I.exec(e)!==null||DI.exec(e)!==null}function eV(e){var t,n,r,s,i,a,l,c=0,d=null,f,u,p;if(t=$I.exec(e),t===null&&(t=DI.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 tV(e){return e.toISOString()}var FI=new Fr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:ZW,construct:eV,instanceOf:Date,represent:tV});function nV(e){return e==="<<"||e===null}var zI=new Fr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:nV}),c0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
+ \r`;function rV(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=c0;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 sV(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=c0,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 iV(e){var t="",n=0,r,s,i=e.length,a=c0;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 oV(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var BI=new Fr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:rV,construct:sV,predicate:oV,represent:iV}),aV=Object.prototype.hasOwnProperty,lV=Object.prototype.toString;function cV(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,lV.call(s)!=="[object Object]")return!1;for(i in s)if(aV.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 uV(e){return e!==null?e:[]}var HI=new Fr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:cV,construct:uV}),dV=Object.prototype.toString;function fV(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],dV.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function pV(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 WI=new Fr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:fV,construct:pV}),hV=Object.prototype.hasOwnProperty;function mV(e){if(e===null)return!0;var t,n=e;for(t in n)if(hV.call(n,t)&&n[t]!==null)return!1;return!0}function gV(e){return e!==null?e:{}}var VI=new Fr("tag:yaml.org,2002:set",{kind:"mapping",resolve:mV,construct:gV}),u0=MI.extend({implicit:[FI,zI],explicit:[BI,HI,WI,VI]}),tl=Object.prototype.hasOwnProperty,Bm=1,UI=2,KI=3,Hm=4,gx=1,yV=2,uj=3,xV=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,wV=/[\x85\u2028\u2029]/,bV=/[,\[\]\{\}]/,qI=/^(?:!|!!|![a-z\-]+!)$/i,YI=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function dj(e){return Object.prototype.toString.call(e)}function vo(e){return e===10||e===13}function Ul(e){return e===9||e===32}function vs(e){return e===9||e===32||e===10||e===13}function nu(e){return e===44||e===91||e===93||e===123||e===125}function vV(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function kV(e){return e===120?2:e===117?4:e===85?8:0}function SV(e){return 48<=e&&e<=57?e-48:-1}function fj(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 NV(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function GI(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var XI=new Array(256),JI=new Array(256);for(var Lc=0;Lc<256;Lc++)XI[Lc]=fj(Lc)?1:0,JI[Lc]=fj(Lc);function jV(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||u0,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 QI(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=PW(n),new os(t,n)}function st(e,t){throw QI(e,t)}function Wm(e,t){e.onWarning&&e.onWarning.call(null,QI(e,t))}var pj={YAML:function(t,n,r){var s,i,a;t.version!==null&&st(t,"duplication of %YAML directive"),r.length!==1&&st(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&st(t,"ill-formed argument of the YAML directive"),i=parseInt(s[1],10),a=parseInt(s[2],10),i!==1&&st(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&Wm(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,i;r.length!==2&&st(t,"TAG directive accepts exactly two arguments"),s=r[0],i=r[1],qI.test(s)||st(t,"ill-formed tag handle (first argument) of the TAG directive"),tl.call(t.tagMap,s)&&st(t,'there is a previously declared suffix for "'+s+'" tag handle'),YI.test(i)||st(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{st(t,"tag prefix is malformed: "+i)}t.tagMap[s]=i}};function Xa(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||st(e,"expected valid JSON character");else xV.test(l)&&st(e,"the stream contains non-printable characters");e.result+=l}}function hj(e,t,n,r){var s,i,a,l;for(vr.isObject(n)||st(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],tl.call(t,i)||(GI(t,i,n[i]),r[i]=!0)}function ru(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])&&st(e,"nested arrays are not supported inside keys"),typeof s=="object"&&dj(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&dj(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)hj(e,t,i[d],n);else hj(e,t,i,n);else!e.json&&!tl.call(n,s)&&tl.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,st(e,"duplicated mapping key")),GI(t,s,i),delete n[s];return t}function d0(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++):st(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function dr(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;Ul(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(vo(s))for(d0(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&&Wm(e,"deficient indentation"),r}function Vg(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||vs(n)))}function f0(e,t){t===1?e.result+=" ":t>1&&(e.result+=vr.repeat(`
88
+ `,t-1))}function CV(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),vs(m)||nu(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),vs(s)||n&&nu(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),vs(s)||n&&nu(s))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),vs(r))break}else{if(e.position===e.lineStart&&Vg(e)||n&&nu(m))break;if(vo(m))if(c=e.line,d=e.lineStart,f=e.lineIndent,dr(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&&(Xa(e,i,a,!1),f0(e,e.line-c),i=a=e.position,l=!1),Ul(m)||(a=e.position+1),m=e.input.charCodeAt(++e.position)}return Xa(e,i,a,!1),e.result?!0:(e.kind=u,e.result=p,!1)}function EV(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(Xa(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 vo(n)?(Xa(e,r,s,!0),f0(e,dr(e,!1,t)),r=s=e.position):e.position===e.lineStart&&Vg(e)?st(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);st(e,"unexpected end of the stream within a single quoted scalar")}function _V(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 Xa(e,n,e.position,!0),e.position++,!0;if(l===92){if(Xa(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),vo(l))dr(e,!1,t);else if(l<256&&XI[l])e.result+=JI[l],e.position++;else if((a=kV(l))>0){for(s=a,i=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=vV(l))>=0?i=(i<<4)+a:st(e,"expected hexadecimal character");e.result+=NV(i),e.position++}else st(e,"unknown escape sequence");n=r=e.position}else vo(l)?(Xa(e,n,r,!0),f0(e,dr(e,!1,t)),n=r=e.position):e.position===e.lineStart&&Vg(e)?st(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}st(e,"unexpected end of the stream within a double quoted scalar")}function PV(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(dr(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&&st(e,"expected the node content, but found ','"):st(e,"missed comma between flow collection entries"),v=b=y=null,u=p=!1,k===63&&(d=e.input.charCodeAt(e.position+1),vs(d)&&(u=p=!0,e.position++,dr(e,!0,t))),r=e.line,s=e.lineStart,i=e.position,Ru(e,t,Bm,!1,!0),v=e.tag,b=e.result,dr(e,!0,t),k=e.input.charCodeAt(e.position),(p||e.line===r)&&k===58&&(u=!0,k=e.input.charCodeAt(++e.position),dr(e,!0,t),Ru(e,t,Bm,!1,!0),y=e.result),m?ru(e,l,g,v,b,y,r,s,i):u?l.push(ru(e,null,g,v,b,y,r,s,i)):l.push(b),dr(e,!0,t),k=e.input.charCodeAt(e.position),k===44?(n=!0,k=e.input.charCodeAt(++e.position)):n=!1}st(e,"unexpected end of the stream within a flow collection")}function AV(e,t){var n,r,s=gx,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)gx===s?s=u===43?uj:yV:st(e,"repeat of a chomping mode identifier");else if((f=SV(u))>=0)f===0?st(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?st(e,"repeat of an indentation width identifier"):(l=t+f-1,a=!0);else break;if(Ul(u)){do u=e.input.charCodeAt(++e.position);while(Ul(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!vo(u)&&u!==0)}for(;u!==0;){for(d0(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),vo(u)){c++;continue}if(e.lineIndent<l){s===uj?e.result+=vr.repeat(`
89
+ `,i?1+c:c):s===gx&&i&&(e.result+=`
90
+ `);break}for(r?Ul(u)?(d=!0,e.result+=vr.repeat(`
91
+ `,i?1+c:c)):d?(d=!1,e.result+=vr.repeat(`
92
+ `,c+1)):c===0?i&&(e.result+=" "):e.result+=vr.repeat(`
93
+ `,c):e.result+=vr.repeat(`
94
+ `,i?1+c:c),i=!0,a=!0,c=0,n=e.position;!vo(u)&&u!==0;)u=e.input.charCodeAt(++e.position);Xa(e,n,e.position,!1)}return!0}function mj(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,st(e,"tab characters must not be used in indentation")),!(c!==45||(a=e.input.charCodeAt(e.position+1),!vs(a))));){if(l=!0,e.position++,dr(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Ru(e,t,KI,!1,!0),i.push(e.result),dr(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)st(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 IV(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,st(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),i=e.line,(k===63||k===58)&&vs(r))k===63?(v&&(ru(e,u,p,m,g,null,a,l,c),m=g=b=null),y=!0,v=!0,s=!0):v?(v=!1,s=!0):st(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,!Ru(e,n,UI,!1,!0))break;if(e.line===i){for(k=e.input.charCodeAt(e.position);Ul(k);)k=e.input.charCodeAt(++e.position);if(k===58)k=e.input.charCodeAt(++e.position),vs(k)||st(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(ru(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)st(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(y)st(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),Ru(e,t,Hm,!0,s)&&(v?g=e.result:b=e.result),v||(ru(e,u,p,m,g,b,a,l,c),m=g=b=null),dr(e,!0,-1),k=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&k!==0)st(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return v&&ru(e,u,p,m,g,null,a,l,c),y&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=u),y}function TV(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&&st(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)):st(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!vs(a);)a===33&&(r?st(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),qI.test(s)||st(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),bV.test(i)&&st(e,"tag suffix cannot contain flow indicator characters")}i&&!YI.test(i)&&st(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{st(e,"tag name is malformed: "+i)}return n?e.tag=i:tl.call(e.tagMap,s)?e.tag=e.tagMap[s]+i:s==="!"?e.tag="!"+i:s==="!!"?e.tag="tag:yaml.org,2002:"+i:st(e,'undeclared tag handle "'+s+'"'),!0}function RV(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&st(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!vs(n)&&!nu(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&st(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function LV(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&&!vs(r)&&!nu(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&st(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),tl.call(e.anchorMap,n)||st(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],dr(e,!0,-1),!0}function Ru(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=Hm===n||KI===n,r&&dr(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;TV(e)||RV(e);)dr(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||Hm===n)&&(Bm===n||UI===n?b=t:b=t+1,v=e.position-e.lineStart,c===1?l&&(mj(e,v)||IV(e,v,b))||PV(e,b)?f=!0:(a&&AV(e,b)||EV(e,b)||_V(e,b)?f=!0:LV(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&st(e,"alias node should not have any properties")):CV(e,b,Bm===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&mj(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"&&st(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(tl.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||st(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&st(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)):st(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 OV(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&&(dr(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&&!vs(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&st(e,"directive name must not be less than one character in length");a!==0;){for(;Ul(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!vo(a));break}if(vo(a))break;for(n=e.position;a!==0&&!vs(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&d0(e),tl.call(pj,r)?pj[r](e,r,s):Wm(e,'unknown document directive "'+r+'"')}if(dr(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,dr(e,!0,-1)):i&&st(e,"directives end mark is expected"),Ru(e,e.lineIndent-1,Hm,!1,!0),dr(e,!0,-1),e.checkLineBreaks&&wV.test(e.input.slice(t,e.position))&&Wm(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Vg(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,dr(e,!0,-1));return}if(e.position<e.length-1)st(e,"end of the stream or a document separator is expected");else return}function ZI(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 jV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,st(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;)OV(n);return n.documents}function MV(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=ZI(e,n);if(typeof t!="function")return r;for(var s=0,i=r.length;s<i;s+=1)t(r[s])}function $V(e,t){var n=ZI(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new os("expected a single document in the stream, but found more")}}var DV=MV,FV=$V,eT={loadAll:DV,load:FV},tT=Object.prototype.toString,nT=Object.prototype.hasOwnProperty,p0=65279,zV=9,Hf=10,BV=13,HV=32,WV=33,VV=34,fb=35,UV=37,KV=38,qV=39,YV=42,rT=44,GV=45,Vm=58,XV=61,JV=62,QV=63,ZV=64,sT=91,iT=93,eU=96,oT=123,tU=124,aT=125,Zr={};Zr[0]="\\0";Zr[7]="\\a";Zr[8]="\\b";Zr[9]="\\t";Zr[10]="\\n";Zr[11]="\\v";Zr[12]="\\f";Zr[13]="\\r";Zr[27]="\\e";Zr[34]='\\"';Zr[92]="\\\\";Zr[133]="\\N";Zr[160]="\\_";Zr[8232]="\\L";Zr[8233]="\\P";var nU=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],rU=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function sU(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&&nT.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}function iU(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 os("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+vr.repeat("0",r-t.length)+t}var oU=1,Wf=2;function aU(e){this.schema=e.schema||u0,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=vr.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=sU(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==='"'?Wf:oU,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 gj(e,t){for(var n=vr.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 pb(e,t){return`
98
+ `+vr.repeat(" ",e.indent*t)}function lU(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 Um(e){return e===HV||e===zV}function Vf(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==p0||65536<=e&&e<=1114111}function yj(e){return Vf(e)&&e!==p0&&e!==BV&&e!==Hf}function xj(e,t,n){var r=yj(e),s=r&&!Um(e);return(n?r:r&&e!==rT&&e!==sT&&e!==iT&&e!==oT&&e!==aT)&&e!==fb&&!(t===Vm&&!s)||yj(t)&&!Um(t)&&e===fb||t===Vm&&s}function cU(e){return Vf(e)&&e!==p0&&!Um(e)&&e!==GV&&e!==QV&&e!==Vm&&e!==rT&&e!==sT&&e!==iT&&e!==oT&&e!==aT&&e!==fb&&e!==KV&&e!==YV&&e!==WV&&e!==tU&&e!==XV&&e!==JV&&e!==qV&&e!==VV&&e!==UV&&e!==ZV&&e!==eU}function uU(e){return!Um(e)&&e!==Vm}function Bd(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 lT(e){var t=/^\n* /;return t.test(e)}var cT=1,hb=2,uT=3,dT=4,Dc=5;function dU(e,t,n,r,s,i,a,l){var c,d=0,f=null,u=!1,p=!1,m=r!==-1,g=-1,b=cU(Bd(e,0))&&uU(Bd(e,e.length-1));if(t||a)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Bd(e,c),!Vf(d))return Dc;b=b&&xj(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Bd(e,c),d===Hf)u=!0,m&&(p=p||c-g-1>r&&e[g+1]!==" ",g=c);else if(!Vf(d))return Dc;b=b&&xj(d,f,l),f=d}p=p||m&&c-g-1>r&&e[g+1]!==" "}return!u&&!p?b&&!a&&!s(e)?cT:i===Wf?Dc:hb:n>9&&lT(e)?Dc:a?i===Wf?Dc:hb:p?dT:uT}function fU(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===Wf?'""':"''";if(!e.noCompatMode&&(nU.indexOf(t)!==-1||rU.test(t)))return e.quotingType===Wf?'"'+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 lU(e,d)}switch(dU(t,l,e.indent,a,c,e.quotingType,e.forceQuotes&&!r,s)){case cT:return t;case hb:return"'"+t.replace(/'/g,"''")+"'";case uT:return"|"+wj(t,e.indent)+bj(gj(t,i));case dT:return">"+wj(t,e.indent)+bj(gj(pU(t,a),i));case Dc:return'"'+hU(t)+'"';default:throw new os("impossible error: invalid scalar style")}}()}function wj(e,t){var n=lT(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 bj(e){return e[e.length-1]===`
103
+ `?e.slice(0,-1):e}function pU(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,vj(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
+ `:"")+vj(c,t),s=i}return r}function vj(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 hU(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Bd(e,s),r=Zr[n],!r&&Vf(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||iU(n);return t}function mU(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)),(ra(e,t,l,!1,!1)||typeof l>"u"&&ra(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function kj(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)),(ra(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&ra(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=pb(e,t)),e.dump&&Hf===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=i,e.dump=s||"[]"}function gU(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)),ra(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ra(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=s,e.dump="{"+r+"}"}function yU(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 os("sortKeys must be a boolean or a function");for(l=0,c=a.length;l<c;l+=1)p="",(!r||s!=="")&&(p+=pb(e,t)),d=a[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),ra(e,t+1,d,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&Hf===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,u&&(p+=pb(e,t)),ra(e,t+1,f,!0,u)&&(e.dump&&Hf===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=i,e.dump=s||"{}"}function Sj(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,tT.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(nT.call(l.represent,c))r=l.represent[c](t,c);else throw new os("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function ra(e,t,n,r,s,i,a){e.tag=null,e.dump=n,Sj(e,n,!1)||Sj(e,n,!0);var l=tT.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?(yU(e,t,e.dump,s),p&&(e.dump="&ref_"+u+e.dump)):(gU(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?kj(e,t-1,e.dump,s):kj(e,t,e.dump,s),p&&(e.dump="&ref_"+u+e.dump)):(mU(e,t,e.dump),p&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&fU(e,e.dump,t,i,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new os("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 xU(e,t){var n=[],r=[],s,i;for(mb(e,n,r),s=0,i=r.length;s<i;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(i)}function mb(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)mb(e[s],t,n);else for(r=Object.keys(e),s=0,i=r.length;s<i;s+=1)mb(e[r[s]],t,n)}function wU(e,t){t=t||{};var n=new aU(t);n.noRefs||xU(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),ra(n,0,r,!0,!0)?n.dump+`
110
+ `:""}var bU=wU,vU={dump:bU};function h0(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 kU=Fr,SU=CI,NU=AI,jU=OI,CU=MI,EU=u0,_U=eT.load,PU=eT.loadAll,AU=vU.dump,IU=os,TU={binary:BI,float:LI,map:PI,null:II,pairs:WI,set:VI,timestamp:FI,bool:TI,int:RI,merge:zI,omap:HI,seq:_I,str:EI},RU=h0("safeLoad","load"),LU=h0("safeLoadAll","loadAll"),OU=h0("safeDump","dump"),fT={Type:kU,Schema:SU,FAILSAFE_SCHEMA:NU,JSON_SCHEMA:jU,CORE_SCHEMA:CU,DEFAULT_SCHEMA:EU,load:_U,loadAll:PU,dump:AU,YAMLException:IU,types:TU,safeLoad:RU,safeLoadAll:LU,safeDump:OU};const nl=["requirement","planning","code","test","normal"],gb={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},MU=["agent","control","provide","condition","jump","condition_jump","start","end"];function $U(e){return MU.includes(e)?e:"agent"}function DU(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function FU(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=fT.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=DU(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():"",$=gb[C]||C,B=nl.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:$U(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:Es.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 fp(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():"",$=gb[A]||A,B=gb[C]||C,F=nl.includes($)?$:nl.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 X=(b=v.data)==null?void 0:b.script,Z=X!=null?String(X):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 lf(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function zU(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 pT(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=>lf(a)),edges:i.map(a=>lf(a)),instances:fp(r,n||{})}}function hT(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,zU(p.id,a));const c=e.nodes.map(p=>{var g,b;const m=l.get(p.id);return{...lf(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{...lf(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]={...lf(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 Nj(e,t,n,r){var f,u,p,m;const s=fp(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 fT.dump(d,{lineWidth:-1})}function BU(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 HU(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]=BU(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 Km=/\[image\s+(\d+)\]/gi;function ks(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 WU(e){return`image ${ks(e).length+1}`}function VU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function UU(e,t){const n=ks(e),r=String(t||""),s=new Set;Km.lastIndex=0;let i;for(;i=Km.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function KU(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 mT(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 qm(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 gT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=ks(n);for(const a of r){const l=await KU(a),c=WU(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=VU(s,c)}return{body:s,images:i}}function yb(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 qU={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 YU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(qU[e]||[]).includes(s)?r:s}const GU={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"])},XU={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"])},JU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_image","display_chart","display_table"]);function QU(e,t){if(!JU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function ZU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function eK(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 jj(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=GU[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&&QU(e,r)?{showOnNode:!0}:{},...(f=XU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function yT(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=yb(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 Uf(e,t,n,r,s){var D,_,R,P,X,Z,V,ne,ue,pe,ge,ae,be,Ae,we,Pe,Te,it,ct,tt,jt;const i=((D=e.data)==null?void 0:D.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Ye=>Ye.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(yb)),Array.isArray(l.output)&&(d=l.output.map(yb)),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??((X=e.data)==null?void 0:X.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=(ne=r==null?void 0:r[s])==null?void 0:ne[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&&((pe=a==null?void 0:a.inputs)!=null&&pe.length)&&(c=a.inputs.map(Ye=>({...Ye}))),d.length===0&&((ge=a==null?void 0:a.outputs)!=null&&ge.length)&&(d=a.outputs.map(Ye=>({...Ye}))));const W=eK(a,(a==null?void 0:a.id)??i),M=(l==null?void 0:l.marketplaceRef)||((ae=e.data)==null?void 0:ae.marketplaceRef)||ZU(a);if(W==="agent_subAgent"&&!d.some(Ye=>(Ye==null?void 0:Ye.name)==="result")){const Ye=(be=a==null?void 0:a.outputs)==null?void 0:be.find(kt=>(kt==null?void 0:kt.name)==="result");d=[...d,Ye?{...Ye}:{type:"text",name:"result",default:""}]}if((W==="display_markdown"||W==="display_mermaid"||W==="display_ascii"||W==="display_chart"||W==="display_table")&&!d.some(Ye=>(Ye==null?void 0:Ye.name)==="next")){const Ye=(Ae=a==null?void 0:a.outputs)==null?void 0:Ae.find(kt=>(kt==null?void 0:kt.name)==="next");d=[...d,Ye?{...Ye}:{type:"node",name:"next",default:""}]}if(W==="workspace_run"){if(!c.some(Ye=>(Ye==null?void 0:Ye.name)==="prev")){const Ye=(we=a==null?void 0:a.inputs)==null?void 0:we.find(kt=>(kt==null?void 0:kt.name)==="prev");c=[Ye?{...Ye}:{type:"node",name:"prev",default:""},...c]}if(!d.some(Ye=>(Ye==null?void 0:Ye.name)==="next")){const Ye=(Pe=a==null?void 0:a.outputs)==null?void 0:Pe.find(kt=>(kt==null?void 0:kt.name)==="next");d=[...d,Ye?{...Ye}:{type:"node",name:"next",default:""}]}}c=jj(W,c,a==null?void 0:a.inputs),d=jj(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((Ye,kt)=>kt===0?{...Ye,default:A,value:A}:Ye));const T=YU(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||(Te=e.data)!=null&&Te.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((it=e.data)==null?void 0:it.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(ct=e.data)!=null&&ct.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((tt=e.data)==null?void 0:tt.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((jt=e.data)==null?void 0:jt.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 xT(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 Cj(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 Ej(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function Ym(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=Cj(t==null?void 0:t.sourceHandle,"output"),i=Cj(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=Ej((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=Ej((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 _j=80,tK=220;function nK(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 rK(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function xh(e,t,n){const r={nodes:Array.isArray(e)?e.map(nK):[],edges:Array.isArray(t)?t.map(rK):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function yx(e,t){const n=[...e,t];return n.length>_j?n.slice(n.length-_j):n}function wT({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=yx(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=xh(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||xh(e,t,n),C=l.current.pop();return C?(c.current=yx(c.current,A),k(C),!0):(g(),!1)},[g,t,n,v,e,k]),j=h.useCallback(()=>{v();const A=d.current||xh(e,t,n),C=c.current.pop();return C?(l.current=yx(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=xh(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()},tK))},[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 nr(e){switch(Gm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Gm(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 sK(e,t){const n=Gm(e),r=Gm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const iK=new Set(["workspaceContext","skillsContext","mcpContext"]);function xb(e){const t=Gm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&iK.has(n)?`${t}+${n}`:t}function bT(e){return xb(e)}function Lu(e,t){if(!e||!t||!sK(e.type,t.type))return!1;const n=xb(e),r=xb(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function oK(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 Ou(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=oK(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 Bo(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function aK(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 lK(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function cK(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Or(e){e.stopPropagation()}function uK(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dK(e,t){const n=`\\[${uK(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
+ `).replace(/\n{3,}/g,`
125
+
126
+ `).trimEnd()}function xx(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fK(e){const t=String(e||"");let n="",r=0;Km.lastIndex=0;let s;for(;s=Km.exec(t);)n+=xx(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${xx(s[0])}</span>`,r=s.index+s[0].length;return n+=xx(t.slice(r)),n||" "}function pK(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 vT({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var Vn,or;const{t:f}=Pn(),u=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=aK(e),b=lK(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?cK(p[0]):!1,M=$?String(((Vn=p[0])==null?void 0:Vn.value)??((or=p[0])==null?void 0:or.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():"",_=ks(e==null?void 0:e.images),R=h.useRef(!1),P=h.useRef(!1),X=h.useRef(null),Z=h.useRef(null),V=h.useRef(null),[ne,ue]=h.useState(M),[pe,ge]=h.useState(T);h.useEffect(()=>{R.current||ue(M)},[n,M]),h.useEffect(()=>{P.current||ge(T)},[n,T]),h.useEffect(()=>{const ye=Z.current;if(!ye)return;const Ie=pK(ye,pe);ye.style.minHeight=`${Ie}px`,ye.style.height="",V.current&&(V.current.style.minHeight=`${Ie}px`,V.current.style.height="")},[pe]),h.useEffect(()=>{const ye=X.current,Ie=e==null?void 0:e.onNodeContentResize;if(!O||!ye||!Ie||typeof ResizeObserver>"u")return;let nt=0;const Ct=()=>{window.cancelAnimationFrame(nt),nt=window.requestAnimationFrame(()=>Ie(n))},ie=new ResizeObserver(Ct);return ie.observe(ye),Ct(),()=>{window.cancelAnimationFrame(nt),ie.disconnect()}},[e==null?void 0:e.onNodeContentResize,O,n]);const ae=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],be=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],Ae=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],we=((e==null?void 0:e.model)??"").trim(),Pe=m==="agent"&&!C.startsWith("tool_nodejs"),Te=new Set(ae.map(Bo)),it=new Set(be.map(Bo)),ct=new Set(Ae.map(Bo)),tt=we?we.startsWith("cursor:")||we.startsWith("opencode:")||we.startsWith("claude-code:")?we:ct.has(we)?`claude-code:${we}`:it.has(we)?`opencode:${we}`:Te.has(we)?`cursor:${we}`:we:"",jt=we&&!tt.startsWith("cursor:")&&!tt.startsWith("opencode:")&&!tt.startsWith("claude-code:")&&!Te.has(we)&&!it.has(we)&&!ct.has(we),Ye=we.startsWith("cursor:")?we.slice(7):we.startsWith("opencode:")?we.slice(9):we.startsWith("claude-code:")?we.slice(12):we,kt=ye=>{if(y)return;const Ie=ye.target.value;d&&d(n,Ie)},nn=ye=>{ye.stopPropagation(),!y&&r&&r(n)},vn=ye=>{ye.stopPropagation(),s&&s()},Mn=ye=>{ye.stopPropagation(),!y&&(i==null||i(n,ye.target.value==="true"?"true":"false"))},Ht=ye=>{if(ye.stopPropagation(),y)return;const Ie=ye.target.value;ue(Ie),R.current||i==null||i(n,Ie)},$n=ye=>{ye.stopPropagation(),R.current=!0},Wn=ye=>{if(ye.stopPropagation(),y)return;R.current=!1;const Ie=ye.currentTarget.value;ue(Ie),i==null||i(n,Ie)},le=()=>{y||i==null||i(n,ne)},de=ye=>{if(ye.stopPropagation(),y)return;const Ie=window.prompt("文件路径",ne);Ie!=null&&(ue(Ie),i==null||i(n,Ie))},He=ye=>{if(ge(ye),a==null||a(n,ye),l){const Ie=UU(_,ye);(Ie.length!==_.length||Ie.some((nt,Ct)=>{var ie;return nt.id!==((ie=_[Ct])==null?void 0:ie.id)}))&&l(n,Ie)}},Ze=ye=>{if(ye.stopPropagation(),y)return;const Ie=ye.target.value;P.current?ge(Ie):He(Ie)},ot=ye=>{ye.stopPropagation(),!y&&(P.current=!0)},Xt=ye=>{if(ye.stopPropagation(),y)return;P.current=!1;const Ie=ye.currentTarget.value;He(Ie)},rn=()=>{y||He(pe)},sn=async ye=>{if(y)return;const Ie=await gT({files:ye,body:pe,images:_});Ie&&(ge(Ie.body),a==null||a(n,Ie.body),l==null||l(n,Ie.images))},An=(ye,Ie)=>{if(ye.stopPropagation(),y)return;const nt=_.filter(ie=>ie.id!==Ie.id),Ct=dK(pe,Ie.label);ge(Ct),a==null||a(n,Ct),l==null||l(n,nt)},Sr=ye=>{if(y)return;const Ie=mT(ye);Ie.length!==0&&(ye.preventDefault(),ye.stopPropagation(),sn(Ie).catch(()=>{}))},Jt=ye=>{if(y)return;const Ie=qm(ye);Ie.length!==0&&(ye.preventDefault(),ye.stopPropagation(),sn(Ie).catch(()=>{}))},mn=()=>{const ye=Z.current,Ie=V.current;!ye||!Ie||(Ie.scrollTop=ye.scrollTop,Ie.scrollLeft=ye.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&&Pe&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Or,onMouseDown:Or,onClick:Or,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:tt,onChange:kt,onPointerDown:Or,onMouseDown:Or,onClick:Or,"aria-label":f("flow:node.model"),title:Ye||f("flow:node.defaultModel"),disabled:y,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),jt&&o.jsx("option",{value:we,children:we}),ae.length>0&&o.jsx("optgroup",{label:"Cursor",children:ae.map(ye=>o.jsx("option",{value:`cursor:${Bo(ye)}`,children:Bo(ye)},`c-${ye}`))}),be.length>0&&o.jsx("optgroup",{label:"OpenCode",children:be.map(ye=>o.jsx("option",{value:`opencode:${Bo(ye)}`,children:Bo(ye)},`o-${ye}`))}),Ae.length>0&&o.jsx("optgroup",{label:"Claude Code",children:Ae.map(ye=>o.jsx("option",{value:`claude-code:${Bo(ye)}`,children:Bo(ye)},`cc-${ye}`))})]}),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:vn,"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((ye,Ie)=>{if(ye.showOnNode===!1)return null;const nt=f("flow:node.inputTooltip",{name:ye.name||`#${Ie}`,type:ye.type})+(ye.default!=null&&ye.default!==""?f("flow:node.defaultSuffix",{value:ye.default}):""),Ct=ye.name||`#${Ie+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:nt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Ct,ye.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ps,{type:"target",position:Je.Left,id:`input-${Ie}`,className:"af-flow-node__handle",style:{background:nr(ye.type)},title:nt})]},`in-${Ie}`)})}),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:Mn,onPointerDown:Or,onMouseDown:Or,onClick:Or,"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:ne,onChange:Ht,onCompositionStart:$n,onCompositionEnd:Wn,onBlur:le,onPointerDown:Or,onMouseDown:Or,onClick:Or,placeholder:"输入文本",rows:2,readOnly:y}):z?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Or,onMouseDown:Or,onClick:Or,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:ne,onChange:Ht,onCompositionStart:$n,onCompositionEnd:Wn,onBlur:le,placeholder:"选择或输入文件路径",title:ne||"选择或输入文件路径",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:X,className:"af-flow-node__prompt-stack nodrag",children:[o.jsx("pre",{ref:V,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:fK(pe)+`
127
+ `}}),o.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:pe,onChange:Ze,onCompositionStart:ot,onCompositionEnd:Xt,onBlur:rn,onPaste:Sr,onDrop:Jt,onScroll:mn,onDragOver:ye=>{qm(ye).length>0&&ye.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,L&&_.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:_.map((ye,Ie)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:ye.name,children:[o.jsx("img",{src:ye.dataUrl,alt:""}),o.jsxs("span",{children:["[",ye.label||`image ${Ie+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:nt=>An(nt,ye),onPointerDown:Or,onMouseDown:Or,"aria-label":`删除 ${ye.label||`image ${Ie+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ye.id||Ie))}):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((ye,Ie)=>{if(ye.showOnNode===!1)return null;const nt=f("flow:node.outputTooltip",{name:ye.name||`#${Ie}`,type:ye.type})+(ye.default!=null&&ye.default!==""?f("flow:node.defaultSuffix",{value:ye.default}):""),Ct=ye.name||`#${Ie+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:nt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Ct,ye.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ps,{type:"source",position:Je.Right,id:`output-${Ie}`,className:"af-flow-node__handle",style:{background:nr(ye.type)},title:nt})]},`out-${Ie}`)})})]})]})}const pp="flowNode";function kT(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 Xm(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function hK(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function mK({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Pn(),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 Pj({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}=Pn(),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 gK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Pn(),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 yK({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Ii({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(yK,{children:t})]},n))})}function ST({open:e,onClose:t}){const{t:n}=Pn(),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=hK()?"⌘":"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(Ii,{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(Ii,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Ii,{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(Ii,{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(Ii,{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(Ii,{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(Ii,{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(Ii,{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(Ii,{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(Ii,{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(Ii,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function xK(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 NT({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Pn(),[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:xK(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 wK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=Pn(),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 jT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),bK=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function vK(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 kK(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 Aj(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 CT(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(jT.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 ET(e){return{inputNames:Aj(e==null?void 0:e.inputs),outputNames:Aj(e==null?void 0:e.outputs)}}function SK(e,t,n){const r=ET(t),s=kK(e),i=[];for(const a of s)if(!CT(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 NK(e,t){const n=ET(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=CT(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 jK(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function CK(e){return e.map(t=>{const n=jK(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 EK(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 bK)jT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function _K(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 PK(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 wh({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}=Pn(),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(()=>ks(c),[c]),A=h.useMemo(()=>SK(e,a,f),[e,a,f]),C=A.length>0,$=h.useMemo(()=>NK(e,a),[e,a]),B=h.useMemo(()=>CK($),[$]),F=h.useMemo(()=>n?null:vK(e,g),[e,g,n]),z=h.useMemo(()=>{if(!F)return[];const E=EK(a,f);return _K(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=PK(E,g);if(!D){w(null);return}const _=4,R=44,P=13.5*16,X=Math.min(z.length*R+8,P);let Z=D.bottom+_;Z+X>window.innerHeight-8&&(Z=Math.max(8,D.top-X-_));const V=288;let ne=D.left;ne=Math.max(8,Math.min(ne,window.innerWidth-V-8)),w({top:Z,left:ne})},[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 gT({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=mT(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onDragOver:E=>{qm(E).length>0&&E.preventDefault()},onDrop:E=>{const D=qm(E);D.length!==0&&(E.preventDefault(),T(D).catch(()=>{}))},onScroll:W})]}),F&&z.length>0&&k?$r.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 _T=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function bh(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Ij({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Pn(),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 PT({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}=Pn(),[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(bh)),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:nl.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>w({role:O.target.value}),disabled:i,children:nl.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:bh(O),children:O},`c-${O}`))}):null,A.length>0?o.jsx("optgroup",{label:"OpenCode",children:A.map(O=>o.jsx("option",{value:bh(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:${bh(O)}`,children:O},`cc-${O}`))}):null]})]}),o.jsx(Ij,{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(Ij,{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(wh,{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(wh,{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(wh,{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(wh,{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 m0(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 AK(e){const t=m0(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 AT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Tj({text:e}){const{t}=Pn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(dp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Rj({o:e}){var r;const{t}=Pn(),n=m0(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:AT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(dp,{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 Lj(e){return AK(e)}function Oj(e){var r;if(!e)return null;const t=m0(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"?AT(String(n)):String(n)}function Mj({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 $j=2e4,IT="af:run-node-ctx-width";function Xh(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Da(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):Da(Xh())}function IK(){try{const e=localStorage.getItem(IT);if(e==null)return Da(Xh());const t=parseInt(e,10);return Number.isFinite(t)?Da(t):Da(Xh())}catch{return Da(Xh())}}async function Dj(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 TK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function RK({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Pn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(IK),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=>Da(R))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const F=h.useCallback(()=>{d(_=>{const R=Da(_);try{localStorage.setItem(IT,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(Da(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(X=>X.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(),$j);(async()=>{try{const X=await Dj(t,e,n,R.signal);if(_!==$.current)return;M(Array.isArray(X.rounds)?X.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(),$j);return(async()=>{try{const X=await Dj(t,e,n,R.signal);if(_!==B.current)return;M(Array.isArray(X.rounds)?X.rounds:[])}catch(X){if(_!==B.current)return;const Z=(X==null?void 0:X.name)==="AbortError"?"requestTimeout":X.message||String(X);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:TK(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--"+OK((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=MK(i,_.status),X=_.finishedAt?` · ${LK(_.finishedAt)}`:"";return o.jsx("option",{value:String(_.execId),children:`${R} · ${P}${X}`},_.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(Tj,{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=Lj(_),X=Oj(_);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(Mj,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Rj,{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(Tj,{text:E.prompt}),w==="output"&&E.outputs&&E.outputs.map((_,R)=>{const P=Lj(_),X=Oj(_);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(Mj,{text:X,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Rj,{o:_})]},`${_.slot}-${R}`)})]})]})})]})}function LK(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 OK(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 MK(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 $K({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Pn(),[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,X,Z;const R={};for(const V of r){const ne=(Z=(X=(P=V.data)==null?void 0:P.outputs)==null?void 0:X[0])==null?void 0:Z.default;ne!=null&&ne!==""&&(R[V.id]=String(ne))}return L.current=R,R},[r]);const O=h.useMemo(()=>{var P;const R={};for(const X of i){if(!((P=X.data)!=null&&P.inputs))continue;const Z=X.data.inputs;for(let V=0;V<Z.length;V++){const ne=Z[V];if(!(ne!=null&&ne.name))continue;const ue=s.find(ge=>ge.target===X.id&&ge.targetHandle===`input-${V}`);if(!(ue!=null&&ue.source))continue;r.find(ge=>ge.id===ue.source)&&(R[ue.source]=ne.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 X=P.activePreset&&((Z=P.presets)!=null&&Z[P.activePreset])?P.presets[P.activePreset]:{};g({...L.current,...X}),v(!1)}).catch(()=>{z.current&&(g(L.current),v(!1))})},[e,t,n]),h.useEffect(()=>{var P;if(!a)return;const R={};for(const[X,Z]of Object.entries(m)){const V=O[X];if(!V)continue;const ne=r.find(pe=>pe.id===X);if(!ne)continue;(((P=ne.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(X=>({...X,[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)||"",X=P.startsWith("provide_file"),Z=P==="provide_bool",V=((ae=R.data)==null?void 0:ae.label)||R.id,ne=R.id,ue=m[ne]||"",pe=["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"+(X?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:X?"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:ne,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:ne}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(pe?" af-run-config-bool-toggle--true":""),onClick:()=>W(ne,pe?"false":"true"),"aria-pressed":pe,children:pe?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:be=>W(ne,be.target.value),placeholder:c(X?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},ne)})})]}),$&&$r.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 TT={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"]},DK={"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 FK(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function zK(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 BK(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 Fj(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(TT))if(r.includes(e))return n;return"other"}function HK({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=DK[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:zK(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 WK({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=Fj(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=Fj(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:BK(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:[FK(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(TT).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(HK,{event:F,defaultExpanded:F.tag==="error"},`${F.ts}_${z}`))]})]})]})]}):null}const VK="0.1.53";function zj(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 wx(e,t){return t==="running"?zj(e):e==null||!Number.isFinite(e)||e<=0?"--":zj(e)}const RT=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function UK(e){var k,w,j,A,C,$,B,F,z,L,O;const{setNodes:t}=ac(),n=Kv(),{modelLists:r,onModelChange:s}=h.useContext(RT),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=Yj(M);T&&(t(E=>E.map(D=>{var P,X,Z,V,ne,ue;if(D.id!==W)return D;const _=Number(((X=(P=D.data)==null?void 0:P.displaySize)==null?void 0:X.width)||D.width||((Z=D.measured)==null?void 0:Z.width)||0),R=Number(((ne=(V=D.data)==null?void 0:V.displaySize)==null?void 0:ne.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 ne,ue,pe,ge,ae,be;if(!c)return;W.preventDefault(),W.stopPropagation();const M=i.current,T=M==null?void 0:M.getBoundingClientRect(),E=Number(((ue=(ne=e.data)==null?void 0:ne.displaySize)==null?void 0:ue.width)||e.width||((pe=e.measured)==null?void 0:pe.width)||(T==null?void 0:T.width)||$T),D=Number(((ae=(ge=e.data)==null?void 0:ge.displaySize)==null?void 0:ae.height)||e.height||((be=e.measured)==null?void 0:be.height)||(T==null?void 0:T.height)||wb),_=W.clientX,R=W.clientY,P=e.id;let X=0;const Z=Ae=>{const we=Yj({width:E+Ae.clientX-_,height:D+Ae.clientY-R});we&&(window.cancelAnimationFrame(X),X=window.requestAnimationFrame(()=>f(P,we)))},V=()=>{window.cancelAnimationFrame(X),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,X,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=(X=e.data)==null?void 0:X.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:ks(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(vT,{...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 KK={[pp]:UK},Hd=["CONTROL","TOOL","PROVIDE","AGENT"],qK=1200,Bj="af-flow-node--sync-flash",Hj="af-flow-edge--sync-flash";function Wj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function Vj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function g0(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 YK(e){const t=g0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function vh(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 LT(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function OT(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function bx(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 Uj(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 Kj(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 GK(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function XK(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 MT(e,t,n,r,s){const i=YK(e),a={id:t,type:pp,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 Uf(a,r,s)}const $T=320,JK=220,QK=1600,wb=104,ZK=900;function qj(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Yj(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:qj(t,JK,QK)||$T,height:qj(n,wb,ZK)||wb}}function e7(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 Gj(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=Ou(i,e.sourceHandle||"output-0","source"),c=Ou(a,e.targetHandle||"input-0","target");return!l||!c?!1:Lu(l,c)}function t7(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=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:bT(a)}:null}function n7(e,t,n){var a;const r=MT(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"?Lu(n.slot,c):Lu(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function r7(e,t){return t?e.map((n,r)=>{const s=n7(n,e,t);if(!s)return null;const i=g0(n);return{def:n,order:r,category:i,categoryRank:Hd.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:LT(s.hydrated.data||n),description:OT(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 s7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function i7(e){const t=new Set,n=[];let r;const s=new RegExp(s7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function Xj(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 Vo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function kh(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(Vo),d=a.map(Vo);return l.map(Vo).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function o7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function vx(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 a7({steps:e}){const{t}=Pn();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:o7(s)}):null]}):null})]},n.index)})})}function l7(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 c7(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 u7(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 d7(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 Jj({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=Pn(),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(Qj,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(Qj,{segments:t,running:n})})]})}function Qj({segments:e,running:t=!1}){const{t:n}=Pn(),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=l7(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=c7(c),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((u,p)=>o.jsxs("section",{className:d7(u.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:u7(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 f7({fitViewEpoch:e}){const{fitView:t}=ac(),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 p7({onReady:e}){const t=Kv();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function Zj(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function e1(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 Jh=1500,t1=500,h7=262144,m7=2e3;function kx(e){return typeof e!="string"?"":e.length<=m7?e:`[log line truncated, ${e.length} chars]`}const g7=Jh;function y7(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:kx(s)}}catch{return{ts:n,type:"info",text:kx(s)}}return{ts:n,type:"log",text:kx(`[${r}] ${s}`)}}function n1(e){if(!e)return[];const t=[],n=e.split(`
132
+ `);for(let r=n.length-1;r>=0&&t.length<g7;r--){const s=n[r];if(!s)continue;const i=y7(s);i&&t.push(i)}return t.reverse(),t}function x7(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 w7(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 b7({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}=Pn(),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,Pe,Te,it;const E=z.get(T.source),D=z.get(T.target),_=/^output-(\d+)$/.exec(T.sourceHandle||""),R=/^input-(\d+)$/.exec(T.targetHandle||""),P=E&&_?(Pe=(we=E.data)==null?void 0:we.outputs)==null?void 0:Pe[parseInt(_[1],10)]:null,X=D&&R?(it=(Te=D.data)==null?void 0:Te.inputs)==null?void 0:it[parseInt(R[1],10)]:null,Z=P!=null&&P.type?nr(P.type):null,V=X!=null&&X.type?nr(X.type):null,ne=Z&&V&&Z!==V,ue=O&&(L.has(T.source)||L.has(T.target)),pe=T.style||{};if(ne){const ct=T.selected?.95:ue?.85:.78,tt=W(M,ct);return{...T,className:((T.className||"")+" af-flow-edge--type-mismatch"+(ue?" af-flow-edge--adjacent":"")).trim(),style:{...pe,stroke:tt,strokeWidth:ue?2.75:2.5,strokeDasharray:"6 4"},markerEnd:T.markerEnd&&typeof T.markerEnd=="object"?{...T.markerEnd,color:tt}:{type:Es.ArrowClosed,color:tt}}}const ge=Z||V;if(!ge)return ue?{...T,className:((T.className||"")+" af-flow-edge--adjacent").trim(),style:{...pe,strokeWidth:2.5}}:T;const ae=ue||T.selected?.7:.38,be=W(ge,ae),Ae=ue?2.5:pe.strokeWidth??2;return{...T,className:((T.className||"")+(ue?" af-flow-edge--adjacent":"")).trim(),style:{...pe,stroke:be,strokeWidth:Ae},markerEnd:T.markerEnd&&typeof T.markerEnd=="object"?{...T.markerEnd,color:be}:{type:Es.ArrowClosed,color:be}}})},[n,r]);return o.jsxs(Uv,{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:KK,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(qv,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx(Tu,{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(j4,{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(f4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&o.jsx(Tu,{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(f7,{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 r1(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 v7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function li(e){return e==="builtin"||e==="admin"}function Oc(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function k7(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 DT="af:run-console-height",cf=230,Ad={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Sh={};function Qh(e){if(!Number.isFinite(e))return cf;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function S7(){try{const e=localStorage.getItem(DT);if(e==null)return cf;const t=parseInt(e,10);return Number.isFinite(t)?Qh(t):cf}catch{return cf}}function N7(){var K0,q0;const{t:e,i18n:t}=Pn(),{navigate:n,path:r}=Co(),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),[X,Z]=h.useState(null),[V,ne]=h.useState(!1),[ue,pe]=h.useState(!1),ge=h.useRef(!1),[ae,be]=h.useState([]),[Ae,we]=h.useState(""),[Pe,Te]=h.useState("nodes"),it=h.useRef(null),[ct,tt]=h.useState([]),[jt,Ye]=h.useState(!1),[kt,nn]=h.useState(""),[vn,Mn]=h.useState(!1),[Ht,$n]=h.useState({name:"",id:"",description:""}),[Wn,le]=h.useState(!1),[de,He]=h.useState(""),[Ze,ot]=h.useState(""),Xt=h.useRef(null),[rn,sn]=h.useState([]),[An,Sr]=h.useState(!1),[Jt,mn]=h.useState(""),[Vn,or]=h.useState(""),[ye,Ie]=h.useState(null),[nt,Ct]=h.useState(null),[ie,_e]=h.useState([]),[et,$t]=h.useState(""),[Qt,ar]=h.useState(!1),ut=h.useCallback(x=>{Xt.current&&window.clearTimeout(Xt.current),ot(x),Xt.current=window.setTimeout(()=>{ot(""),Xt.current=null},3800)},[]),Nr=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(()=>()=>{Xt.current&&window.clearTimeout(Xt.current)},[]);const[Hr,Js]=h.useState(!1),[Dn,us]=h.useState({files:[]}),[qi,Po]=h.useState(!1),[Ao,Ee]=h.useState(!0);h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/flows",{method:"HEAD"}).then(q=>{x||Ee(q.ok)}).catch(()=>{x||Ee(!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||ca(!!(N!=null&&N.isDev))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{u!=null&&u.id&&z_(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[Oe,Zt]=h.useState("edit"),[Tr,xt]=h.useState([]),es=h.useRef(0),[Qn,Fn]=h.useState(new Set),[Is,lt]=h.useState({}),[on,Lt]=h.useState(null),[ds,Be]=h.useState(0),[pr,Zn]=h.useState(!1),[la,ca]=h.useState(!1),[Io,hr]=h.useState(!1),[Ts,fs]=h.useState(S7),xi=h.useRef({active:!1,pointerId:-1,startY:0,startH:cf}),[dn,Qs]=h.useState(null),[wi,Zs]=h.useState(null),[Rs,K]=h.useState({}),he=h.useRef(Rs);h.useEffect(()=>{he.current=Rs},[Rs]);const[Me,Re]=h.useState(!1),[Qe,Dt]=h.useState(!1),[Ot,Un]=h.useState({}),[mr,To]=h.useState({}),[ua,Gu]=h.useState(null),[Kn,da]=h.useState(Ad),[ts,Xu]=h.useState(!1),[ei,ul]=h.useState(!1),[dl,Rr]=h.useState(""),[fa,Yi]=h.useState(""),[Yt,pa]=h.useState(Sh),[qn,fl]=h.useState(null),pl=h.useRef(0),bi=h.useRef(null),vi=h.useRef(null),Gi=h.useRef(!0),Ro=h.useRef(!1),[lr,ha]=h.useState(null),[Xi,ma]=h.useState(null),[Ju,Lo]=h.useState(!1),[hl,jr]=h.useState(""),[cc,ki]=h.useState(!1),Qu=h.useRef(null),[Wr,Ls]=h.useState(null),[Zu,ps]=h.useState(!1),[ml,Ji]=h.useState(null),[uc,Le]=h.useState(!1),[Vr,gl]=h.useState(null),dc=h.useRef(null),[fn,Qi]=h.useState(""),[kn,yl]=h.useState(0),[xl,wl]=h.useState(0),[wp,fc]=h.useState("pan"),[bl,ti]=h.useState(!1),[ed,td]=h.useState(!1),pc=h.useRef(null),hc=h.useRef(null),Zi=h.useRef(null),[mc,bp]=h.useState(0),[St,gc]=h.useState(null),[vp,Si]=h.useState(""),[ht,kp]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[eo,nd]=h.useState(""),[yc,Qg]=h.useState(""),[rr,Sp]=h.useState([]),[Os,ni]=h.useState([]),[ft,tn]=h.useState(!1),[ga,Zg]=h.useState([]),[xc,ey]=h.useState(!1),[ty,ny]=h.useState(()=>new Set),[wc,rd]=h.useState(!1),bc=h.useRef(null),vc=h.useRef(null),[vl,kl]=h.useState({}),kc=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:""}`}},[]),Np=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:""}`},[]),Sc=h.useCallback(x=>{const N=kc(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}}},[kc]),Ni=h.useCallback((x,N,H)=>{const q=kc(x);if(q)try{localStorage.setItem(q.sessionsKey,JSON.stringify(N)),H?localStorage.setItem(q.activeKey,H):localStorage.removeItem(q.activeKey)}catch{}},[kc]),gn=h.useRef(0),Oo=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[Ur,hs]=h.useState([]),[Cr,ri]=h.useState(null),Ms=h.useMemo(()=>Np(u),[Np,u]),[sd,id]=h.useState(""),Sl=h.useMemo(()=>{if(!u)return null;const x=u.id,N=u.source??"user",H=u.archived?"archived":"";return`${x}:${N}${H?":"+H:""}`},[u]),Nc=h.useRef(!1);h.useEffect(()=>{if(!Sl){hs([]),ri(null),Oo.current={sessions:[],activeSessionId:null,flowKey:null};return}const x=Oo.current;if(x.flowKey===Sl)return;x.flowKey=Sl,Nc.current&&x.sessions.length>0&&Ni(u,x.sessions,x.activeSessionId);const{sessions:N,activeSessionId:H}=Sc(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,hs([Y]),ri(q)}else{const q=N[N.length-1];if(q&&(!q.thread||q.thread.length===0))gn.current=vx(N),x.sessions=N,x.activeSessionId=q.id,hs(N),ri(q.id);else{const J=vx(N)+1;gn.current=J;const ee=`session-${J}-${Date.now()}`,te={id:ee,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},me=[...N,te];x.sessions=me,x.activeSessionId=ee,hs(me),ri(ee)}}Nc.current=!0},[Sl,u,Sc,Ni]);const Sn=h.useMemo(()=>Ur.find(x=>x.id===Cr)||null,[Ur,Cr]),In=(Sn==null?void 0:Sn.running)??!1,Nl=(Sn==null?void 0:Sn.statusLine)??"",ya=(Sn==null?void 0:Sn.segments)??[],xa=(Sn==null?void 0:Sn.thread)??[],wa=(Sn==null?void 0:Sn.steps)??[];Sn==null||Sn.outputDismissed;const Nt=(Sn==null?void 0:Sn.phaseContext)??null,jp=h.useRef([]),[od,jc]=h.useState(!1),jl=h.useRef(null),ad=h.useRef(null);h.useEffect(()=>{const x=ad.current;x&&requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight})},[xa,ya]);const ld=h.useRef(null),to=h.useRef(!1),ry=h.useRef(null),Cp=h.useCallback(x=>{const N=++gn.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 hs(Y=>[...Y,q]),ri(H),H},[]);h.useEffect(()=>{!u||!Nc.current||(Oo.current.sessions=Ur,Oo.current.activeSessionId=Cr,Ni(u,Ur,Cr))},[Ur,Cr,u,Ni]),h.useEffect(()=>{gn.current=Math.max(gn.current,vx(Ur))},[Ur]);const Mo=h.useCallback(x=>{var N;ld.current===x&&((N=jl.current)==null||N.abort()),hs(H=>{const q=H.filter(J=>J.id!==x);if(H.some((J,ee)=>J.id===x&&H.findIndex(te=>te.id===Cr)===ee)||Cr===x){const J=q;J.length>0?ri(J[J.length-1].id):setTimeout(()=>{gn.current=0;const ee=++gn.current,te=`session-${ee}-${Date.now()}`,me={id:te,label:e("flow:composer.conversationLabel",{n:ee}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};hs(xe=>[...xe,me]),ri(te)},0)}return q})},[Cr]),gr=h.useCallback(x=>{hs(N=>{const H=N.findIndex(J=>J.id===Cr);if(H<0)return N;const q={...N[H]};x(q);const Y=[...N];return Y[H]=q,Y})},[Cr]),si=h.useCallback(x=>{gr(N=>{N.running=x})},[gr]),ii=h.useCallback(x=>{gr(N=>{N.statusLine=x})},[gr]),oi=h.useCallback(x=>{gr(N=>{typeof x=="function"?N.segments=x(N.segments):N.segments=x})},[gr]),Ep=h.useCallback(x=>{gr(N=>{typeof x=="function"?N.thread=x(N.thread):N.thread=x})},[gr]),Cl=h.useCallback(x=>{gr(N=>{typeof x=="function"?N.steps=x(N.steps):N.steps=x})},[gr]),_p=h.useCallback(x=>{gr(N=>{N.outputDismissed=x})},[gr]),ba=h.useCallback(x=>{gr(N=>{N.phaseContext=typeof x=="function"?x(N.phaseContext):x})},[gr]),cd=h.useCallback(x=>{ri(x),hs(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(()=>{jp.current=ya},[ya]);const yr=h.useRef({}),Pp=h.useRef(!1),ji=h.useRef(null),$o=h.useRef(null),no=h.useRef(null),va=h.useRef(!1),ud=h.useRef(0),El=h.useRef(""),[Et,wt,Ap]=MA([]),[It,an,Ip]=$A([]),$s=h.useRef(Et),ro=h.useRef(It),dd=h.useRef(null),S=h.useRef(null),I=h.useRef(null),U=h.useRef(null),[G,Q]=h.useState(null),re=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:{},wt(Array.isArray(x==null?void 0:x.nodes)?x.nodes:[]),an(Array.isArray(x==null?void 0:x.edges)?x.edges:[]),Q(null)},[an,wt]),se=h.useMemo(()=>({instances:yr.current}),[It,Et]),{resetHistory:oe,undo:fe,redo:Se}=wT({nodes:Et,edges:It,extra:se,enabled:!!u&&va.current&&Oe==="edit",onRestore:re}),Ne=h.useMemo(()=>Et.filter(x=>{var N;return(((N=x.data)==null?void 0:N.definitionId)||"").startsWith("provide_")}),[Et]),Fe=h.useMemo(()=>{var N;const x={};for(const H of Et){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=It.find(me=>me.target===H.id&&me.targetHandle===`input-${Y}`);if(!(ee!=null&&ee.source))continue;Ne.find(me=>me.id===ee.source)&&(x[ee.source]=J.name)}}return x},[Et,It,Ne]),rt=h.useMemo(()=>{if(Oe==="edit"||Qn.size===0)return null;const x=new Set(Qn);for(const N of It)Qn.has(N.source)&&x.add(N.target),Qn.has(N.target)&&x.add(N.source);return x},[Oe,Qn,It]),Ge=h.useMemo(()=>Oe==="edit"?Et:Et.map(x=>{var N,H;return{...x,draggable:!1,connectable:!1,data:{...x.data,isRunMode:!0,isExecuting:Qn.has(x.id),nodeStatus:((N=Is[x.id])==null?void 0:N.status)??null,nodeElapsed:((H=Is[x.id])==null?void 0:H.elapsed)??null,isDim:rt?!rt.has(x.id):!1}}}),[Oe,Et,Qn,Is,rt]),zt=h.useMemo(()=>rt?It.map(x=>{const N=Qn.has(x.source)||Qn.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}}):It,[It,Qn,rt]);h.useEffect(()=>{if(!u){To({}),Gu(null),da(Ad),pa(Sh),fl(null),Rr(""),Yi("");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=>{To(N.presets||{}),Gu(N.activePreset||null)}).catch(()=>{To({}),Gu(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const ln=h.useCallback(x=>{pl.current+=1,da(x)},[]),xr=h.useCallback(async(x,N={})=>{if(!x)return;const H=!!N.quiet,q=!!N.force,Y=pl.current;H||(Xu(!0),Rr(""),Yi(""));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()}`),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||`HTTP ${ee.status}`);if(!q&&pl.current!==Y)return;da({...Ad,...te.schedule||{}}),pa(te.state&&typeof te.state=="object"?te.state:Sh),fl(te.status||null)}catch(ee){if(!q&&pl.current!==Y)return;da(Ad),pa(Sh),fl(null),Rr(String(ee.message||ee))}finally{Xu(!1)}},[]);h.useEffect(()=>{if(!u)return;let x=!1;return(async()=>{await xr(u)})(),()=>{x=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,xr]),h.useEffect(()=>{var H,q,Y,J;if(!ua||!mr[ua]||Ne.length===0)return;const x=mr[ua],N={};for(const ee of Ne){const te=Fe[ee.id];if(!te)continue;const me=((H=ee.data)==null?void 0:H.definitionId)||"",xe=x[ee.id]??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"";me.startsWith("provide_file")?N[te]={type:"file",path:xe}:N[te]={type:"str",value:xe}}Object.keys(N).length>0&&K(N)},[ua,mr,Ne,Fe]);const Bt=h.useCallback(()=>{if(!Vr||!dc.current)return;const x=dc.current.value;wt(N=>N.map(H=>{var q,Y;return H.id!==Vr.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}]}}})),gl(null)},[Vr,wt]),Ue=h.useMemo(()=>{const x=Et.filter(N=>N.selected);return x.length===1?x[0]:null},[Et]),wr=h.useMemo(()=>u?HU(Et,It,e):[],[u,Et,It,e]),Kr=h.useMemo(()=>wr.map(x=>x.key).join("|"),[wr]),Ds=h.useMemo(()=>wr.some(x=>String((x==null?void 0:x.level)||"warning").toLowerCase()==="error"),[wr]);h.useLayoutEffect(()=>{ne(wr.length>0&&!Ds)},[Kr,u==null?void 0:u.id,u==null?void 0:u.source,wr.length,Ds]),Zi.current=Ue,h.useEffect(()=>{$s.current=Et},[Et]),h.useEffect(()=>{const x=i.current,N=new Map,H=[];for(const ee of Et){const te=e7(ee);N.set(ee.id,te),x.get(ee.id)!==te&&H.push(ee.id)}if(i.current=N,H.length===0)return;const q=()=>H.forEach(ee=>{var te;return(te=s.current)==null?void 0:te.call(s,ee)}),Y=window.requestAnimationFrame(q),J=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Y),window.clearTimeout(J)}},[Et]),h.useEffect(()=>{ro.current=It},[It]),h.useEffect(()=>{I.current=G},[G]),h.useEffect(()=>{if(!G)return;const x=H=>{H.key==="Escape"&&Q(null)},N=H=>{var q,Y;(Y=(q=H.target)==null?void 0:q.closest)!=null&&Y.call(q,".af-connect-node-menu")||Q(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",N)}},[G]),h.useEffect(()=>()=>{no.current!=null&&(clearTimeout(no.current),no.current=null)},[]);const gt=h.useMemo(()=>{var N;if(!Ue)return null;const x=(N=Ue.data)==null?void 0:N.definitionId;return ae.find(H=>H.id===x)??null},[Ue,ae]),pn=h.useMemo(()=>{const x={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const N of ae){const H=g0(N);x[H].push(N)}for(const N of Hd)x[N].sort((H,q)=>H.id.localeCompare(q.id));return x},[ae]),ns=h.useMemo(()=>{const x=Ae.trim().toLowerCase();if(!x)return pn;const N={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const H of Hd)N[H]=pn[H].filter(q=>XK(q,x));return N},[pn,Ae]),Cc=h.useMemo(()=>Hd.reduce((x,N)=>x+ns[N].length,0),[ns]),Do=h.useMemo(()=>ae.filter(x=>{const N=String(x.id??""),H=String(x.source??"");return N.startsWith("marketplace:")||H==="marketplace"||H==="collection"}),[ae]),ve=h.useMemo(()=>{const x=new Set;for(const N of Do){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},[Do]),dt=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(()=>{dt()},[dt]),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||kp({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):""})):[];Sp(H),tn(!0)}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skill-collections").then(N=>N.json()).then(N=>{x||(Zg(Ya(N)),ey(!0))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{if(id(""),!(!ft||!xc)){if(!Ms){ni([]);return}ni(V_(Ms,"pipeline",rr,ga)),id(Ms)}},[ga,xc,rr,ft,Ms]),h.useEffect(()=>{if(!(sd!==Ms||!Ms))try{localStorage.setItem(Ms,JSON.stringify(Os))}catch{}},[Os,Ms,sd]);const pt=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())]),te=await J.json();if(!J.ok||te.error)throw new Error(te.error||e("flow:nodePropsError.loadFlowFailed"));const me=await ee.json();if(!ee.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const xe=Array.isArray(me)?me:Array.isArray(me==null?void 0:me.nodes)?me.nodes:[],ze=!Array.isArray(me)&&(me==null?void 0:me.pipelineTranslations)||{},ce=FU(te.flowYaml||"");if(ce.error)throw new Error(ce.error);const De={...ce.instances||{}},ke=ce.nodes.map(yn=>Uf(yn,De,xe,ze,x.id)),mt=xT(ce.edges,ke);return{flowSource:N,paletteList:xe,instances:De,flowDescriptionText:ce.description??"",viewport:e1(ce.viewport),nodes:ke,edges:mt}},[t.language,e]),Xe=h.useCallback(async(x,N={})=>{const H=!!N.preserveComposer,q=H&&!!N.incrementalSync;va.current=!1,ud.current+=1,p(x),k(""),H||(j(""),we(""),Ct(null),v(""),z(""),M(""),Qi(""),Ep([]),oi([]),Cl([]),_p(!1),ba(null),fc("pan")),q||(yr.current={},wt([]),an([])),r1(x);try{const Y=await pt(x);if(be(Y.paletteList),yr.current=Y.instances,v(Y.flowDescriptionText),z(x.id||""),q){const J=$s.current,ee=ro.current;try{const te=gW(J,ee,Y.nodes,Y.edges),me=new Set([...te.changes.addedNodeIds,...te.changes.updatedNodeIds]),xe=new Set([...te.changes.addedEdgeKeys,...te.changes.updatedEdgeKeys]),ze=me.size>0?te.nodes.map(De=>me.has(De.id)?{...De,className:Wj(De.className,Bj)}:De):te.nodes,ce=xe.size>0?te.edges.map(De=>xe.has(zf(De))?{...De,className:Wj(De.className,Hj)}:De):te.edges;wt(ze),an(ce),no.current!=null&&(clearTimeout(no.current),no.current=null),(me.size>0||xe.size>0)&&(no.current=window.setTimeout(()=>{no.current=null,me.size>0&&wt(De=>De.map(ke=>{if(!me.has(ke.id))return ke;const mt=Vj(ke.className,Bj);return mt===String(ke.className||"")?ke:{...ke,className:mt}})),xe.size>0&&an(De=>De.map(ke=>{if(!xe.has(zf(ke)))return ke;const mt=Vj(ke.className,Hj);return mt===String(ke.className||"")?ke:{...ke,className:mt}}))},qK))}catch{wt(Y.nodes),an(Y.edges)}}else if(wt(Y.nodes),an(Y.edges),$o.current=Y.viewport||null,Y.viewport){const J=()=>{var ee;try{(ee=ji.current)==null||ee.setViewport(Y.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else g(J=>J+1);rh(x.id,Y.flowSource),bp(J=>J+1),oe(Y.nodes,Y.edges,{instances:Y.instances});try{El.current=Nj(Y.nodes,Y.edges,Y.instances,{description:Y.flowDescriptionText,viewport:$o.current})}catch{El.current=""}va.current=!0}catch(Y){k(String(Y.message||Y))}},[pt,oe,wt,an]),$e=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:[];be(Y)},[u,e,t.language]),Tt=h.useCallback(async()=>{Sr(!0),mn("");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");sn(Array.isArray(N==null?void 0:N.nodes)?N.nodes:[])}catch(x){mn(String(x.message||x)),sn([])}finally{Sr(!1)}},[]),Wt=h.useCallback(async()=>{Ye(!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");tt(Array.isArray(N==null?void 0:N.snippets)?N.snippets:[])}catch(x){nn(String(x.message||x)),tt([])}finally{Ye(!1)}},[]);h.useEffect(()=>{u&&(Tt(),Wt())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Tt,Wt]);const Kt=h.useCallback(async x=>{if(!u||!x)return;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`;if(N){or(N),mn("");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 $e()}catch(H){mn(String(H.message||H))}finally{or("")}}},[u,$e]),Nn=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 $e(),Y},[$e,u]),hn=h.useCallback(async()=>{var q;if(!u||ge.current)return;const x=u.id,N=u.source??"user",H=((q=Zi.current)==null?void 0:q.id)??null;ge.current=!0,pe(!0);try{await Xe({id:x,source:N,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),H&&wt(Y=>Y.map(J=>({...J,selected:J.id===H})))}finally{ge.current=!1,pe(!1)}},[u,u==null?void 0:u.archived,Xe,wt]);h.useEffect(()=>{if(Pp.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&&(Pp.current=!0,Xe(Y))},[l,Xe]);const _t=h.useRef(0);h.useEffect(()=>{if(!u)return;const x=u.id,N=u.source??"user",H=!!u.archived;_t.current=0;let q=!1;const Y=async()=>{var te;if(q)return;const ee=new URLSearchParams({flowId:x,flowSource:N,v:String(_t.current)});H&&ee.set("archived","1");try{const me=await fetch("/api/flow-editor-sync-poll?"+ee.toString());if(!me.ok||q)return;const xe=await me.json();if(q)return;if(xe.changed){_t.current=xe.version;const ze=((te=Zi.current)==null?void 0:te.id)??null;await Xe({id:x,source:N,archived:H},{preserveComposer:!0,incrementalSync:!0}),await xr({id:x,source:N,archived:H},{quiet:!0,force:!0}),ze&&wt(ce=>ce.map(De=>({...De,selected:De.id===ze})))}else _t.current=xe.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,Xe,xr,wt]);const cn=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&&(gl(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",x),()=>window.removeEventListener("provide-expand",x)},[]),h.useEffect(()=>{var te,me,xe,ze,ce,De,ke;if(!Ue){gc(null);return}const x=yr.current[Ue.id]||{},{inputs:N,outputs:H}=yT(Ue),q=String(((te=Ue.data)==null?void 0:te.definitionId)??Ue.id??""),Y=((me=Ue.data)==null?void 0:me.script)!=null?String(Ue.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??""):"";gc({id:Ue.id,newId:Ue.id,label:String(((xe=Ue.data)==null?void 0:xe.label)??Ue.id),role:((ze=Ue.data)==null?void 0:ze.role)??"普通",model:String(((ce=Ue.data)==null?void 0:ce.model)??x.model??""),body:String(((De=Ue.data)==null?void 0:De.body)??x.body??""),images:ks(((ke=Ue.data)==null?void 0:ke.images)??x.images),script:ee,inputs:N,outputs:H})},[Ue==null?void 0:Ue.id,mc]),h.useEffect(()=>{u&&(Ue||(hc.current=null,Ct(x=>x==="node"?null:x)))},[u,Ue==null?void 0:Ue.id]);const Er=h.useCallback(()=>{hc.current=null,Ct(x=>x==="settings"||x==="history"?x:"node")},[]),Ci=h.useCallback((x,N)=>{x.metaKey||x.ctrlKey||x.shiftKey||Oe!=="edit"&&Zs((N==null?void 0:N.id)??null)},[Oe]),so=h.useCallback((x,N)=>{Oe==="edit"&&(x.preventDefault(),wt(H=>H.map(q=>({...q,selected:q.id===N.id}))),an(H=>H.map(q=>({...q,selected:!1}))),Er())},[Er,Oe,an,wt]),Fo=h.useCallback((x,N)=>{if(Oe!=="edit")return;const H=x.metaKey||x.ctrlKey||x.shiftKey;an(q=>q.map(Y=>Y.id===N.id?{...Y,selected:!Y.selected||!H}:H?Y:{...Y,selected:!1})),H||wt(q=>q.map(Y=>({...Y,selected:!1})))},[Oe,an,wt]),sy=h.useCallback(x=>Gj(x,$s.current),[]),iy=h.useCallback(x=>{if(!Gj(x,$s.current)){j("端口类型不匹配,已取消连线");return}Q(null),wt(N=>Ym(N,x)),an(N=>{const H=N.filter(q=>!(q.target===x.target&&q.targetHandle===x.targetHandle));return $f({...x,markerEnd:{type:Es.ArrowClosed}},H)})},[an,wt]),B2=h.useCallback((x,N)=>{S.current=t7(N,$s.current),Q(null)},[]),H2=h.useCallback((x,N)=>{var ke,mt,yn,xn;const H=S.current;if(S.current=null,!u||!H||N!=null&&N.toNode)return;const q=r7(ae,H);if(q.length===0){j(`没有匹配 ${H.slotType} 端口的节点`);return}const Y=((mt=(ke=x==null?void 0:x.changedTouches)==null?void 0:ke[0])==null?void 0:mt.clientX)??(x==null?void 0:x.clientX),J=((xn=(yn=x==null?void 0:x.changedTouches)==null?void 0:yn[0])==null?void 0:xn.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(Y)||!Number.isFinite(J))return;const ee=ji.current,te=document.querySelector(".af-pipeline-flow .react-flow");if(!ee||!te)return;const me=te.getBoundingClientRect(),xe=320,ze=Math.min(440,104+q.length*58),ce=Math.max(12,Math.min(Y-me.left,me.width-xe-12)),De=Math.max(12,Math.min(J-me.top,me.height-ze-12));Q({left:ce,top:De,flowPosition:ee.screenToFlowPosition({x:Y,y:J}),draft:H,candidates:q,query:""})},[ae,u]),W2=h.useCallback(x=>{for(const N of x)delete yr.current[N.id]},[]),V2=h.useCallback(x=>{ji.current=x},[]),U2=h.useCallback(x=>{wt(H=>H.map(q=>({...q,selected:q.id===x}))),an(H=>H.map(q=>({...q,selected:!1}))),Er();const N=()=>{var me,xe,ze;const H=ji.current;if(!(H!=null&&H.getNode))return;const q=H.getNode(x);if(!q)return;const Y=(me=H.getInternalNode)==null?void 0:me.call(H,x),J=((xe=Y==null?void 0:Y.measured)==null?void 0:xe.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((ze=Y==null?void 0:Y.measured)==null?void 0:ze.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:te}=H.getViewport();H.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:Zj(te),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(N))},[wt,an,Er]),K2=h.useCallback(x=>{wt(H=>H.map(q=>({...q,selected:q.id===x}))),an(H=>H.map(q=>({...q,selected:!1})));const N=()=>{var xe,ze,ce;const H=ji.current;if(!(H!=null&&H.getNode))return;const q=H.getNode(x);if(!q)return;const Y=(xe=H.getInternalNode)==null?void 0:xe.call(H,x),J=((ze=Y==null?void 0:Y.measured)==null?void 0:ze.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:te}=H.getViewport(),me=Zj(te);H.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:me,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(N))},[wt,an]),Ec=h.useCallback((x,N)=>{const H=`node-${Date.now()}`;return MT(x,H,N,yr.current,ae)},[ae]),R0=h.useCallback(x=>{if(!u||!x)return;let N={x:180,y:160};const H=ji.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})}wt(Y=>[...Y,Ec(x,N)])},[u,wt,Ec]),q2=h.useCallback(x=>{const N=I.current;if(!u||!N||!(x!=null&&x.def))return;const H=Ec(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};wt(Y=>Ym([...Y,H],q)),an(Y=>{const J=Y.filter(ee=>!(ee.target===q.target&&ee.targetHandle===q.targetHandle));return $f({...q,markerEnd:{type:Es.ArrowClosed}},J)}),Q(null)},[u,Ec,wt,an]),Y2=h.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),G2=h.useCallback(x=>{var ee;if(x.preventDefault(),!u)return;const N=ji.current;if(!N)return;const H=N.screenToFlowPosition({x:x.clientX,y:x.clientY}),q=x.dataTransfer.getData("application/agentflow-snippet");if(q){const te=ct.find(me=>`${me.id}@${me.version}`===q);te&&((ee=U.current)==null||ee.call(U,te,H));return}const Y=x.dataTransfer.getData("application/agentflow-node");if(!Y)return;const J=ae.find(te=>te.id===Y);J&&wt(te=>[...te,Ec(J,H)])},[u,ae,ct,wt,Ec]),ai=h.useCallback(async(x,N)=>{if(!u)return;const H=Nj(x,N,yr.current,{description:b,viewport:$o.current});if(H!==El.current){j(e("flow:status.saving"));try{const q=v7(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(El.current=H,j(e("flow:status.saved")),li(u.source)&&q==="workspace"){const ee={id:u.id,source:"workspace",path:void 0};p(ee),r1(ee),rh(u.id,"workspace")}}catch(q){j(e("flow:status.saveFailed")+": "+(q.message||q))}}},[u,b]);h.useEffect(()=>{if(!u||!va.current||Oe!=="edit"||u.archived)return;const x=ud.current,N=setTimeout(()=>{x===ud.current&&va.current&&ai($s.current,ro.current)},400);return()=>clearTimeout(N)},[Et,It,b,Oe,u,ai]);const Tp=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 te=await ee.json(),me=Array.isArray(te)?te.find(xe=>xe.id===u.id&&(xe.source??"user")===Y&&!!xe.archived==!!u.archived):null;me&&(J=me)}}catch{}await Xe(J,{preserveComposer:!0}),rh(u.id,Y)}catch(H){C(String(H.message||H))}finally{B(!1)}}},[u,Xe]),oy=h.useCallback(async()=>{if(u){ul(!0),Rr(""),Yi("");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:Kn})}),N=await x.json().catch(()=>({}));if(!x.ok||!N.success)throw new Error(N.error||"Failed to save schedule");da({...Ad,...N.schedule||{}}),Yi(e("flow:schedule.saved")),await xr(u,{quiet:!0,force:!0})}catch(x){Rr(String(x.message||x))}finally{ul(!1)}}},[u,Kn,xr,e]),X2=h.useCallback(async()=>{u&&(await ai($s.current,ro.current),!u.archived&&u.source!=="builtin"&&await oy())},[u,ai,oy]),Rp=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(te=>te.id===H.flowId&&(te.source??"user")===(H.flowSource??u.source)):null;ee&&(q=ee)}}catch{}await Xe(q,{preserveComposer:!0}),rh(H.flowId,H.flowSource??u.source)}catch(N){M(String(N.message||N))}finally{O(!1)}},[u,F,Xe]),L0=h.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{E(!0),setTimeout(()=>E(!1),2e3)}).catch(()=>{})},[]),ay=h.useCallback(()=>{ai(Et,It)},[ai,Et,It]),O0=h.useCallback(()=>{var N,H;if(!u)return;const x=e1((H=(N=ji.current)==null?void 0:N.getViewport)==null?void 0:H.call(N));x&&($o.current=x,j("已固定 Pipeline 进入视角"),ai($s.current,ro.current))},[ai,u]),J2=h.useCallback((x,N)=>{const H=N.trim()===""||N==="default"?void 0:N.trim(),q=Et.map(Y=>Y.id===x?{...Y,data:{...Y.data,model:H}}:Y);wt(q),ai(q,It)},[Et,It,wt,ai]),Lp=h.useCallback(()=>{var mt,yn;if(!St||!u||!Ue)return!1;const x=Ue.id,N=St.newId.trim();if(Si(""),!_T.test(N))return Si(e("flow:nodePropsError.invalidInstanceId")),!1;if(Et.some(xn=>xn.id===N&&xn.id!==x))return Si(e("flow:nodePropsError.duplicateInstanceId")),!1;const H=St.role.trim(),q=nl.includes(H)?H:"普通",Y=St.model.trim(),J=xn=>(Array.isArray(xn)?xn:[]).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"})),ee=J(St.inputs),te=J(St.outputs),me=String(((mt=Ue.data)==null?void 0:mt.definitionId)??N),xe=me.startsWith("provide_"),ze={...Ue.data,label:St.label.trim()||N,role:q,model:Y===""||Y==="default"?void 0:Y,body:xe?"":St.body,images:xe?[]:ks(St.images),inputs:ee,outputs:xe&&Array.isArray((yn=Ue.data)==null?void 0:yn.outputs)?Ue.data.outputs:te},ce=String(St.script??"").trim();me==="tool_nodejs"||ce!==""?ze.script=String(St.script??""):delete ze.script;let De,ke=It;if(N!==x){const xn={...yr.current},Vt={...xn[x]||{}};delete xn[x],xn[N]=Vt,yr.current=xn,De=Et.map(bt=>bt.id!==x?bt:{...bt,id:N,selected:!0,data:ze}),ke=It.map((bt,Gt)=>({...bt,source:bt.source===x?N:bt.source,target:bt.target===x?N:bt.target,id:`e-${bt.source===x?N:bt.source}-${bt.target===x?N:bt.target}-${Gt}`}))}else De=Et.map(xn=>xn.id===x?{...xn,data:ze}:xn);return wt(De),an(ke),Nr(N),ai(De,ke),!0},[St,u,Ue,Et,It,wt,an,Nr,ai]),ly=h.useCallback(()=>{var yn,xn;if(!St||!u||!Ue)return!1;const x=Ue.id,N=St.role.trim(),H=nl.includes(N)?N:"普通",q=St.model.trim(),Y=Vt=>(Array.isArray(Vt)?Vt:[]).map(bt=>({type:String((bt==null?void 0:bt.type)??"节点").trim()||"节点",name:String((bt==null?void 0:bt.name)??""),default:String((bt==null?void 0:bt.default)??""),required:!!(bt!=null&&bt.required),showOnNode:(bt==null?void 0:bt.showOnNode)!=null?bt.showOnNode!==!1:!!(bt!=null&&bt.required)||String((bt==null?void 0:bt.type)??"节点").trim().toLowerCase()==="node"})),J=Y(St.inputs),ee=Y(St.outputs),te=String(((yn=Ue.data)==null?void 0:yn.definitionId)??x),me=te.startsWith("provide_"),xe=St.label.trim()||x,ze=q===""||q==="default"?void 0:q,ce={...Ue.data,label:xe,role:H,model:ze,body:me?"":St.body,images:me?[]:ks(St.images),inputs:J,outputs:me&&Array.isArray((xn=Ue.data)==null?void 0:xn.outputs)?Ue.data.outputs:ee},De=String(St.script??"").trim();te==="tool_nodejs"||De!==""?ce.script=String(St.script??""):delete ce.script;const ke=Ue.data||{};return(ke.label!==ce.label||ke.role!==ce.role||ke.model!==ce.model||ke.body!==ce.body||JSON.stringify(ks(ke.images))!==JSON.stringify(ce.images)||(ke.script??void 0)!==(ce.script??void 0)||JSON.stringify(ke.inputs||[])!==JSON.stringify(J)||JSON.stringify(ke.outputs||[])!==JSON.stringify(ee))&&(wt(Vt=>Vt.map(bt=>bt.id===x?{...bt,data:ce}:bt)),Nr(x)),!0},[St,u,Ue,wt,Nr]),M0=h.useRef(ly);h.useEffect(()=>{M0.current=ly},[ly]),h.useEffect(()=>{if(!St||!u||!va.current||Oe!=="edit")return;const x=setTimeout(()=>{M0.current()},400);return()=>clearTimeout(x)},[St,u,Oe]);const Q2=h.useCallback(()=>{if(!(!St||!Ue)){if(St.newId.trim()===Ue.id){Si("");return}Lp()}},[St,Ue,Lp]);h.useEffect(()=>{const x=N=>{var ee,te,me;if(Oe!=="edit")return;const H=kT(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){if(nt==="node"&&Ue&&St){N.preventDefault(),N.stopPropagation(),Lp()||ay();return}if(H)return;N.preventDefault(),N.stopPropagation(),ay();return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),td(xe=>!xe);return}if(ed)return;if(bl){if(N.key==="Escape"){N.preventDefault(),ti(!1);return}if(Xm(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ti(!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 xe=Y?fe():Se();j(xe?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 xe=pT($s.current,ro.current,yr.current);xe&&(N.preventDefault(),N.stopPropagation(),dd.current=xe,j(`Copied ${xe.nodes.length} node${xe.nodes.length>1?"s":""}`));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="v"){const xe=hT(dd.current,$s.current,ro.current,yr.current);xe&&(N.preventDefault(),N.stopPropagation(),yr.current=xe.instances,wt(xe.nodes),an(xe.edges),j(`Pasted ${xe.pastedNodeIds.length} node${xe.pastedNodeIds.length>1?"s":""}`));return}if((N.key==="a"||N.key==="A")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),(ee=it.current)==null||ee.focus(),(me=(te=it.current)==null?void 0:te.select)==null||me.call(te);return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="a"){N.preventDefault(),N.stopPropagation(),wt(xe=>xe.map(ze=>({...ze,selected:!0}))),an(xe=>xe.map(ze=>({...ze,selected:!1})));return}if(Xm(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ti(xe=>!xe);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),fc("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),fc("pan");return}if((N.key==="f"||N.key==="F")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),O0();return}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[ay,O0,bl,ed,nt,Ue,St,Lp,Oe,fe,Se]),h.useEffect(()=>{if(Oe!=="running"||on==null)return;let x=Math.floor((Date.now()-on)/1e3);const N=setInterval(()=>{const H=Date.now()-on,q=Math.floor(H/1e3);q!==x&&(x=q,Be(H))},500);return()=>clearInterval(N)},[Oe,on]),h.useEffect(()=>{const x=vi.current;!x||!x.parentElement||Gi.current&&(Ro.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Ro.current=!1}))},[Tr]),h.useEffect(()=>{const x=vi.current;if(!x)return;const N=x.parentElement;if(!N)return;const H=()=>{if(Ro.current)return;const q=N.scrollHeight-N.scrollTop-N.clientHeight;Gi.current=q<40};return N.addEventListener("scroll",H,{passive:!0}),()=>N.removeEventListener("scroll",H)},[pr,Oe]),h.useEffect(()=>{if(Oe==="edit"||!pr)return;Gi.current=!0;const x=vi.current;x&&(Ro.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Ro.current=!1}))},[Oe,pr]),h.useEffect(()=>{Tr.length>Jh+t1&&xt(x=>x.length>Jh+t1?x.slice(-Jh):x)},[Tr]);const Z2=h.useCallback(x=>{if(x.button!==0)return;x.preventDefault();const N=x.currentTarget;xi.current={active:!0,pointerId:x.pointerId,startY:x.clientY,startH:Ts},N.setPointerCapture(x.pointerId)},[Ts]),eR=h.useCallback(x=>{const N=xi.current;if(!N.active||x.pointerId!==N.pointerId)return;const H=N.startY-x.clientY;fs(Qh(N.startH+H))},[]),Op=h.useCallback(()=>{fs(x=>{const N=Qh(x);try{localStorage.setItem(DT,String(N))}catch{}return N})},[]),$0=h.useCallback(x=>{const N=xi.current;if(!(!N.active||x.pointerId!==N.pointerId)){N.active=!1;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}Op()}},[Op]),tR=h.useCallback(()=>{const x=xi.current;x.active&&(x.active=!1,Op())},[Op]);h.useEffect(()=>{function x(){fs(N=>Qh(N))}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const io=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(Zt(q?"ready":"running"),xt(q?[]:[{ts:new Date().toISOString(),type:"info",text:N?e("flow:run.connectingApiResume",{uuid:N}):e("flow:run.connectingApi")}]),Fn(new Set),lt({}),Zn(!q),Ct(null),N||Qs(null),q)return;if(!N){const J=Date.now();Lt(J),Be(0)}const Y=new AbortController;bi.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")}));xt(De=>[...De,{ts:new Date().toISOString(),type:"error",text:ce.error||e("flow:composer.requestFailed")}]),Zt("error");return}if(xt(ce=>[...ce,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){xt(ce=>[...ce,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),Zt("error");return}const ee=J.body.getReader(),te=new TextDecoder;let me="";const xe=ce=>{const De=ce.ts||new Date().toISOString();if(ce.type==="event")if(ce.event==="node-start")Fn(ke=>new Set(ke).add(ce.instanceId)),lt(ke=>({...ke,[ce.instanceId]:{status:"running",startMs:Date.now()}})),xt(ke=>[...ke,{ts:De,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"){Fn(mt=>{const yn=new Set(mt);return yn.delete(ce.instanceId),yn});const ke=ce.elapsed??null;lt(mt=>({...mt,[ce.instanceId]:{status:"success",elapsed:ke}})),xt(mt=>[...mt,{ts:De,type:"node-done",text:ke?e("flow:run.nodeDoneWithElapsed",{instanceId:ce.instanceId,elapsed:ke}):e("flow:run.nodeDone",{instanceId:ce.instanceId})}])}else if(ce.event==="node-failed")Fn(ke=>{const mt=new Set(ke);return mt.delete(ce.instanceId),mt}),lt(ke=>({...ke,[ce.instanceId]:{status:"failed",elapsed:ce.elapsed??null}})),xt(ke=>[...ke,{ts:De,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:ce.instanceId})}]);else if(ce.event==="apply-start"){if(ce.uuid&&Qs(String(ce.uuid)),typeof ce.runStartTime=="number"&&ce.runStartTime>0)Lt(ce.runStartTime),Be(Math.max(0,Date.now()-ce.runStartTime));else if(typeof ce.totalExecutedMs=="number"&&ce.totalExecutedMs>0){const ke=Date.now()-ce.totalExecutedMs;Lt(ke),Be(ce.totalExecutedMs)}xt(ke=>[...ke,{ts:De,type:"info",text:e("flow:run.pipelineStart",{uuid:ce.uuid||"?"})}])}else ce.event==="apply-done"?xt(ke=>[...ke,{ts:De,type:"info",text:ce.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:ce.totalElapsed}):e("flow:run.pipelineDone")}]):ce.event==="apply-paused"?xt(ke=>[...ke,{ts:De,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(ce.pendingNodes||[]).join(", ")})}]):xt(ke=>[...ke,{ts:De,type:"event",text:`[${ce.event}] ${JSON.stringify(ce)}`}]);else ce.type==="user-check-content"?(ha({instanceId:ce.instanceId,execId:ce.execId??1,inputPath:ce.inputPath,outputPath:ce.outputPath,content:ce.content||""}),ma(ce.content||""),Lo(!1),jr(""),ki(!1),xt(ke=>[...ke,{ts:De,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:ce.instanceId})}])):ce.type==="user-ask-prompt"?(Ls({instanceId:ce.instanceId,execId:ce.execId??1,question:ce.question||"",options:Array.isArray(ce.options)?ce.options:[]}),ps(!1),xt(ke=>[...ke,{ts:De,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:ce.instanceId,defaultValue:`等待用户选择 (${ce.instanceId})`})}])):ce.type==="tool-print-content"?(Ji({instanceId:ce.instanceId,execId:ce.execId??1,content:ce.content||"",createdAt:Date.now()}),Le(!1)):ce.type==="log"?xt(ke=>[...ke,{ts:De,type:"log",text:ce.text!=null?String(ce.text):""}]):ce.type==="error"?xt(ke=>[...ke,{ts:De,type:"error",text:ce.message||e("flow:run.unknownError")}]):ce.type==="done"?xt(ke=>[...ke,{ts:De,type:"done",text:e("flow:run.executionEnd",{exitCode:ce.exitCode??"?"})}]):xt(ke=>[...ke,{ts:De,type:"log",text:JSON.stringify(ce)}])},ze=ce=>{if(ce.trim())try{xe(JSON.parse(ce))}catch{xt(De=>[...De,{ts:new Date().toISOString(),type:"log",text:ce}])}};for(;;){const{done:ce,value:De}=await ee.read();me+=te.decode(De??new Uint8Array,{stream:!ce});const ke=me.split(`
133
+ `);me=ke.pop()??"";for(const mt of ke)ze(mt);if(ce)break}me.trim()&&ze(me),Zt("done")}catch(J){J.name==="AbortError"?(xt(ee=>[...ee,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),Zt("stopped")):(xt(ee=>[...ee,{ts:new Date().toISOString(),type:"error",text:J.message||e("flow:run.unknownError")}]),Zt("error"))}finally{bi.current=null,Fn(new Set)}},[u]),[nR,cy]=h.useState(!1),rR=h.useCallback(()=>{cy(!0)},[]),sR=h.useCallback(async()=>{if(cy(!1),bi.current&&(bi.current.abort(),bi.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{}Zt("stopped"),Fn(new Set)},[u]),_l=h.useCallback(()=>{Zt("edit"),Fn(new Set),lt({}),Zs(null),Qs(null)},[]),[iR,Mp]=h.useState(!1),oR=h.useCallback(async()=>{if(Mp(!1),bi.current&&(bi.current.abort(),bi.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{}_l()},[u,_l]),aR=h.useCallback(()=>{Mp(!1),n("/projects")},[n]),lR=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;Qs(N);const q=x.status||"unknown";let Y="stopped";q==="success"?Y="done":q==="failed"?Y="error":q==="running"?Y="running":Y="stopped",Zt(Y);const J=typeof x.at=="number"?x.at:null;if(Y==="running"&&J!=null?(Lt(J),Be(Math.max(0,Date.now()-J))):J!=null&&typeof x.endedAt=="number"&&x.endedAt>J?(Lt(null),Be(x.endedAt-J)):(Lt(null),Be(Math.max(0,x.durationMs??0))),xt([]),Fn(new Set),lt({}),Zs(null),Ct(null),Zn(!1),N&&H){const ee=new URLSearchParams({flowId:H,runId:N});fetch(`/api/run-node-statuses?${ee}`).then(te=>te.json()).then(te=>{const me=te.statuses&&typeof te.statuses=="object"?te.statuses:{},xe={};for(const[ze,ce]of Object.entries(me))ce&&typeof ce=="object"&&typeof ce.status=="string"&&(xe[ze]={status:ce.status,...ce.elapsed!=null&&String(ce.elapsed).trim()!==""?{elapsed:String(ce.elapsed)}:{}});lt(xe)}).catch(()=>{})}},[u==null?void 0:u.id]);h.useEffect(()=>{if(!(u!=null&&u.id)||Oe!=="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(te=>te.flowId===u.id&&te.status==="running");if(!Y||x)return;const J=Y.runId||null;Qs(J),Zt("running"),Zn(!0),Lt(Y.at||Date.now()),es.current=0;const ee=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${J},已恢复运行视图`}];if(J){const te=new URLSearchParams({flowId:u.id,runId:J}),xe=await(await fetch(`/api/run-node-statuses?${te}`)).json();if(x)return;const ze=xe.statuses&&typeof xe.statuses=="object"?xe.statuses:{},ce={},De=new Set;for(const[ke,mt]of Object.entries(ze))mt&&typeof mt=="object"&&typeof mt.status=="string"&&(ce[ke]={status:mt.status,...mt.elapsed!=null&&String(mt.elapsed).trim()!==""?{elapsed:String(mt.elapsed)}:{}},mt.status==="running"&&De.add(ke));lt(ce),Fn(De);try{const ke=new URLSearchParams({flowId:u.id,runId:J,sinceBytes:"0",tailBytes:"262144"}),mt=await fetch(`/api/run-log?${ke}`);if(mt.ok){const yn=await mt.json();if(!x){es.current=Number(yn.bytes||0);const xn=n1(typeof yn.text=="string"?yn.text:"");xt([...xn,...ee]);return}}}catch{}}xt(ee)}catch{}})(),()=>{x=!0}},[u==null?void 0:u.id]),h.useEffect(()=>{if(Oe==="edit"||!(u!=null&&u.id)||!dn)return;let x=!1,N=null;const H=async()=>{try{const q=new URLSearchParams({flowId:u.id,runId:dn}),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:{},te={},me=new Set;for(const[xe,ze]of Object.entries(ee))ze&&typeof ze=="object"&&typeof ze.status=="string"&&(te[xe]={status:ze.status,...ze.elapsed!=null&&String(ze.elapsed).trim()!==""?{elapsed:String(ze.elapsed)}:{}},ze.status==="running"&&me.add(xe));lt(xe=>x7(xe,te)?xe:te),Fn(xe=>w7(xe,me)?xe:me);try{const xe=new URLSearchParams({flowId:u.id,runId:dn,sinceBytes:String(es.current||0),tailBytes:String(h7)}),ze=await fetch(`/api/run-log?${xe}`);if(ze.ok){const ce=await ze.json();if(x)return;const De=Number(ce.bytes||0),ke=typeof ce.text=="string"?ce.text:"";if(ke){const mt=n1(ke);mt.length>0&&xt(yn=>[...yn,...mt])}es.current=De}}catch{}try{const xe=await fetch("/api/pipeline-recent-runs");if(!xe.ok)return;const ze=await xe.json();if(x)return;const De=(Array.isArray(ze.runs)?ze.runs:[]).find(ke=>ke.flowId===u.id&&ke.runId===dn);if(De&&De.status){const ke=De.status;ke==="running"?Zt(mt=>mt==="running"?mt:"running"):ke==="success"?Zt("done"):ke==="failed"?Zt("error"):(ke==="stopped"||ke==="interrupted")&&Zt("stopped")}}catch{}}catch{}};return H(),N=window.setInterval(H,2500),()=>{x=!0,N&&window.clearInterval(N)}},[Oe,u==null?void 0:u.id,dn]),h.useEffect(()=>{if(nt!=="history"||!u)return;let x=!1;return(async()=>{ar(!0),$t("");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||_e(Array.isArray(H.runs)?H.runs:[])}catch(N){x||($t(String(N.message||N)),_e([]))}finally{x||ar(!1)}})(),()=>{x=!0}},[nt,u]),h.useEffect(()=>{if(!u){us({files:[]});return}let x=!1;return(async()=>{Po(!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||us({files:Array.isArray(q.files)?q.files:[],path:q.path,error:q.error})}catch(N){x||us({files:[],error:N.message||String(N)})}finally{x||Po(!1)}})(),()=>{x=!0}},[u]);const fd=h.useMemo(()=>u?ie.filter(x=>x&&x.flowId===u.id).sort((x,N)=>N.at-x.at):[],[ie,u]),rs=h.useMemo(()=>{let x=0,N=0,H=0,q=0,Y=0;for(const J of fd){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}},[fd]),pd=h.useMemo(()=>u?Xj(fn,kn):null,[u,fn,kn]),Ei=h.useMemo(()=>{if(!pd||!u)return[];const x=pd.query.toLowerCase(),N=Y=>x?Y.some(J=>J&&String(J).toLowerCase().includes(x)):!0,H=Et.map(Y=>{var xe,ze;const J=Y.id,ee=String(((xe=Y.data)==null?void 0:xe.label)??J),te=(ze=Y.data)!=null&&ze.definitionId?String(Y.data.definitionId):"",me=[ee!==J?ee:"",te&&te!==J?te:""].filter(Boolean);return{id:J,label:ee,defId:te,subs:me}}).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 te=[J!==Y?J:null,ee||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:Y,title:Y,subtitle:te}}),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]},[pd,Et,ae,u]),hd=h.useMemo(()=>{const x=Ei.filter(H=>H.kind==="instance"),N=Ei.filter(H=>H.kind==="definition");return{instances:x,definitions:N}},[Ei]);h.useEffect(()=>{wl(x=>{const N=Math.max(0,Ei.length-1);return Math.min(Math.max(0,x),N)})},[Ei]);const D0=h.useMemo(()=>i7(fn),[fn]),Lr=h.useMemo(()=>Et.filter(x=>x.selected),[Et]),uy=h.useMemo(()=>new Set(Lr.map(x=>x.id)),[Lr]),$p=h.useMemo(()=>It.filter(x=>uy.has(x.source)&&uy.has(x.target)),[It,uy]),F0=h.useMemo(()=>{const x=Ae.trim().toLowerCase();return x?ct.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))):ct},[ct,Ae]),z0=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},[]),B0=h.useCallback((x,N)=>{var Gt,ss;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($s.current.map(Ke=>Ke.id)),ee={};for(const Ke of Y)ee[Ke]=z0(Ke,J);const te=(Gt=H.ui)!=null&&Gt.nodePositions&&typeof H.ui.nodePositions=="object"?H.ui.nodePositions:{},me=(ss=H.ui)!=null&&ss.nodeSizes&&typeof H.ui.nodeSizes=="object"?H.ui.nodeSizes:{},xe=Y.map(Ke=>{const wn=te[Ke];return{id:Ke,x:typeof(wn==null?void 0:wn.x)=="number"?wn.x:0,y:typeof(wn==null?void 0:wn.y)=="number"?wn.y:0}}),ze=Math.min(...xe.map(Ke=>Ke.x)),ce=Math.min(...xe.map(Ke=>Ke.y));let De=N||{x:180,y:160};const ke=ji.current,mt=document.querySelector(".af-pipeline-flow .react-flow");if(!N&&ke&&mt){const Ke=mt.getBoundingClientRect();De=ke.screenToFlowPosition({x:Ke.left+Ke.width*.48,y:Ke.top+Ke.height*.32})}const yn={};for(const Ke of Y)yn[ee[Ke]]={...q[Ke]||{}};yr.current={...yr.current,...yn};const xn=Y.map(Ke=>{const wn=q[Ke]||{},oo=xe.find(gd=>gd.id===Ke)||{x:0,y:0},_i=me[Ke]&&typeof me[Ke].width=="number"&&typeof me[Ke].height=="number"?{width:me[Ke].width,height:me[Ke].height}:null,Al={id:ee[Ke],type:"flowNode",selected:!0,position:{x:De.x+(oo.x-ze),y:De.y+(oo.y-ce)},..._i?{width:_i.width,height:_i.height}:{},data:{label:wn.label||ee[Ke],definitionId:wn.definitionId||Ke,role:wn.role||"normal",body:wn.body||"",script:wn.script||"",..._i?{displaySize:_i}:{}}};return Uf(Al,yr.current,ae,{},u.id)}),Vt=new Set(Y),bt=(Array.isArray(H.edges)?H.edges:[]).filter(Ke=>Vt.has(Ke==null?void 0:Ke.source)&&Vt.has(Ke==null?void 0:Ke.target)).map((Ke,wn)=>({id:`e-${ee[Ke.source]}-${ee[Ke.target]}-${Date.now()}-${wn}`,source:ee[Ke.source],target:ee[Ke.target],sourceHandle:Ke.sourceHandle??void 0,targetHandle:Ke.targetHandle??void 0,markerEnd:{type:Es.ArrowClosed}}));wt(Ke=>[...Ke.map(wn=>({...wn,selected:!1})),...xn]),an(Ke=>[...Ke.map(wn=>({...wn,selected:!1})),...bt]),j(`已添加流程片段:${x.displayName||x.id}`)},[z0,ae,u,an,wt]);U.current=B0;const cR=h.useCallback(()=>{var H,q;if(Lr.length<2){nn("请先在画布上选择至少两个节点。"),Te("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} 个节点`;$n({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),He(""),Mn(!0),Te("flows")},[Lr]),uR=h.useCallback(async()=>{var J,ee;if(!u||Lr.length<2)return;const x=Ht.name.trim();if(!x){He("请填写片段名称。");return}const N=fp(Lr,yr.current),H={},q={};for(const te of Lr){H[te.id]={x:((J=te.position)==null?void 0:J.x)||0,y:((ee=te.position)==null?void 0:ee.y)||0};const me=k7(te);me&&(q[te.id]=me)}const Y=$p.map(te=>({source:te.source,target:te.target,sourceHandle:te.sourceHandle??null,targetHandle:te.targetHandle??null}));le(!0),He("");try{const te=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Ht.id,name:x,displayName:x,version:"1.0.0",description:Ht.description,snippet:{instances:N,edges:Y,ui:{nodePositions:H,nodeSizes:q}}})}),me=await te.json().catch(()=>({}));if(!te.ok||(me==null?void 0:me.ok)===!1)throw new Error((me==null?void 0:me.error)||"Publish failed");Mn(!1),j(`流程片段已发布:${me.id||x}`),ut(`流程片段已发布:${me.id||x}`),await Wt(),Te("flows")}catch(te){He(String(te.message||te))}finally{le(!1)}},[u,Lr,$p,Ht,Wt,ut]),Dp=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(Et.map(Y=>[Y.id,Y])),q=new Map(ae.map(Y=>[Y.id,Y]));for(const Y of D0){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,D0,Et,ae]),ms=h.useMemo(()=>{const x=Array.isArray(ht==null?void 0:ht.cursor)?ht.cursor:[],N=Array.isArray(ht==null?void 0:ht.opencode)?ht.opencode:[],H=Array.isArray(ht==null?void 0:ht.claudeCode)?ht.claudeCode:[],q=N.map(xe=>`opencode:${Vo(xe)}`),Y=H.map(xe=>`claude-code:${Vo(xe)}`),J=new Set([...x,...N,...H].map(Vo).concat(q).concat(Y)),ee=(eo||"").trim(),te=kh(eo,x,N,H),me=te&&!J.has(te)&&!J.has(ee)?ee:"";return{cursorList:x,opencodeList:N,claudeCodeList:H,currentNotInLists:me}},[ht,eo]),dy=h.useMemo(()=>new Set(Os),[Os]),fy=Os.length,Fp=h.useMemo(()=>{const x=new Map(rr.map(J=>[J.key,J])),N=new Set,H=new Set,q=ga.map(J=>{const ee=el(J,rr).map(te=>x.get(te)).filter(Boolean);for(const te of ee)N.add(te.key),H.add(String(te.name||te.id||te.key||"").trim());return{...J,skills:ee}}).filter(J=>J.skills.length>0),Y=rr.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}},[ga,rr]),_c=h.useCallback(()=>{const x=bc.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);kl({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(ht==null?void 0:ht.cursor)?ht.cursor:[],N=Array.isArray(ht==null?void 0:ht.opencode)?ht.opencode:[],H=Array.isArray(ht==null?void 0:ht.claudeCode)?ht.claudeCode:[];nd(q=>{const Y=kh(q,x,N,H);return Y===q?q:Y})},[ht.cursor,ht.opencode,ht.claudeCode]),h.useEffect(()=>{if(!wc)return;_c();const x=H=>{var Y,J;const q=H.target;(Y=bc.current)!=null&&Y.contains(q)||(J=vc.current)!=null&&J.contains(q)||rd(!1)},N=H=>{H.key==="Escape"&&rd(!1)};return window.addEventListener("resize",_c),window.addEventListener("scroll",_c,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",N),()=>{window.removeEventListener("resize",_c),window.removeEventListener("scroll",_c,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",N)}},[wc,_c]);const Pl=h.useCallback(async(x,N={})=>{var bt;if(!u||to.current)return;const H=N.phaseContextSnapshot,q=(typeof x=="string"?x:fn).trim();if(!q)return;const Y=jp.current;to.current=!0,si(!0),ii(e("flow:composer.connecting")),Ct(Gt=>Gt!=="composer"?"composer":Gt);const J=[...xa];if(Y.length>0&&J.push({type:"assistant",segments:[...Y]}),Ep([...J,{type:"user",text:q}]),J.filter(Gt=>Gt.type==="user").length===0){const Gt=q.replace(/\s+/g," ").slice(0,30)+(q.length>30?"…":"");hs(ss=>ss.map(Ke=>Ke.id===Cr?{...Ke,label:Gt}:Ke))}const ee=J.map(Gt=>Gt.type==="user"?{role:"user",text:Gt.text}:{role:"assistant",text:(Gt.segments||[]).filter(Ke=>Ke.kind==="assistant"||Ke.kind==="result").map(Ke=>Ke.text).join(`
134
+ `)}).filter(Gt=>Gt.text),te=H??Nt;Qi(""),oi([]),Cl([]),_p(!1);const me=new AbortController;jl.current=me,ld.current=Cr;let xe=null;const ze=Array.isArray(ht==null?void 0:ht.cursor)?ht.cursor:[],ce=Array.isArray(ht==null?void 0:ht.opencode)?ht.opencode:[],De=Array.isArray(ht==null?void 0:ht.claudeCode)?ht.claudeCode:[],ke=kh(eo,ze,ce,De),mt=Dp.filter(Gt=>Gt.kind!=="definition"&&Gt.node).map(Gt=>Gt.node.id),yn=u;let xn=!1,Vt=!1;try{xe=setTimeout(()=>me.abort(),12e4);const Gt={prompt:q,model:ke,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:mt,thread:ee,selectedSkills:Os};te&&te.nextPhase&&!te.isLastPhase&&(Gt.phaseContext={phaseIndex:te.nextPhase.index,phases:te.phases,userPromptOriginal:te.userPromptOriginal||q}),yc&&(Gt.phaseRole=yc);const ss=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Gt),signal:me.signal});if(xe&&(clearTimeout(xe),xe=null),!ss.ok){let _i=ss.statusText||e("flow:composer.requestFailed");try{const Al=await ss.json();Al&&Al.error&&(_i=String(Al.error))}catch{}ii(_i),oi([{kind:"error",text:_i}]);return}const Ke=(bt=ss.body)==null?void 0:bt.getReader();if(!Ke){ii(e("flow:composer.cannotReadStream"));return}const wn=new TextDecoder;let oo="";for(;;){const{done:_i,value:Al}=await Ke.read();if(_i)break;for(oo+=wn.decode(Al,{stream:!0});;){const gd=oo.indexOf(`
135
+ `);if(gd<0)break;const Y0=oo.slice(0,gd).trim();if(oo=oo.slice(gd+1),!Y0)continue;let qe;try{qe=JSON.parse(Y0)}catch{continue}if(qe.type==="status"&&typeof qe.line=="string"&&ii(qe.line),qe.type==="natural"&&typeof qe.text=="string"&&qe.text){const jn=typeof qe.kind=="string"&&qe.kind?qe.kind:"assistant";oi(bn=>[...bn,{kind:jn,text:qe.text}])}if(qe.type==="error"&&qe.message){Vt=!0;const jn=qe.code?` [${qe.code}]`:"",bn=String(qe.message)+jn;ii(bn),oi(gs=>[...gs,{kind:"error",text:bn}])}if(qe.type==="plan"&&Array.isArray(qe.steps)){Cl(qe.steps.map(bn=>({...bn,status:"pending"})));const jn=qe.steps.map((bn,gs)=>`${gs+1}. ${bn.description||bn.type}`).join(`
136
+ `);oi(bn=>[...bn,{kind:"assistant",text:e("flow:composer.taskPlan",{count:qe.steps.length,summary:jn})}])}if(qe.type==="step-start"){const jn=qe.index??0,bn=qe.total??0,gs=qe.tier?` [${qe.tier}]`:"",gR=qe.model?` (${qe.model})`:"";ii(e("flow:composer.step",{current:jn+1,total:bn,description:(qe.description||"")+gs+gR})),Cl(yR=>yR.map(Pc=>Pc.index===jn?{...Pc,status:"running",model:qe.model,tier:qe.tier,nodeRole:qe.nodeRole??Pc.nodeRole,instanceId:qe.instanceId??Pc.instanceId,instanceLabel:qe.instanceLabel??Pc.instanceLabel}:Pc))}if(qe.type==="step-progress"){const jn=qe.index??0,bn=qe.total??0;ii(e("flow:composer.step",{current:jn+1,total:bn,description:qe.description||""}))}if(qe.type==="step-done"){const jn=qe.index??0;Cl(bn=>bn.map(gs=>gs.index===jn?{...gs,status:qe.success?"done":"error"}:gs))}if(qe.type==="phase-plan"&&Array.isArray(qe.phases)){ba(bn=>({...bn||{},phases:qe.phases,currentPhase:qe.currentPhase??0,phaseTotal:qe.phaseTotal??qe.phases.length,phaseName:qe.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(bn==null?void 0:bn.userPromptOriginal)||q}));const jn=qe.phases.map((bn,gs)=>`${gs+1}. ${bn.label}`).join(" → ");oi(bn=>[...bn,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:qe.phases.length,labels:jn,current:qe.phaseName||""})}])}qe.type==="phase-complete"&&(ba(jn=>{var gs;return{...jn||{},phases:qe.phases||(jn==null?void 0:jn.phases)||[],currentPhase:qe.phaseIndex??0,phaseTotal:qe.phaseTotal??((gs=qe.phases)==null?void 0:gs.length)??0,phaseName:qe.phaseName||"",isLastPhase:!!qe.isLastPhase,nextPhase:qe.nextPhase||null,userPromptOriginal:qe.userPromptOriginal||(jn==null?void 0:jn.userPromptOriginal)||q}}),!qe.isLastPhase&&qe.nextPhase&&oi(jn=>[...jn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:qe.phaseName||e("flow:composer.nextPhase"),nextPhase:qe.nextPhase.label})}])),qe.type==="done"&&(xn=!0,ii(jn=>jn||e("flow:composer.done")))}}}catch(Gt){const ss=Gt;if(ss.name==="AbortError"){const Ke=e(xe?"flow:composer.connectTimeout":"flow:composer.aborted");ii(Ke),oi(wn=>[...wn,{kind:"error",text:Ke}])}else{const Ke=ss.code||ss.name||"UNKNOWN",wn=`${ss.message||String(Gt)} [${Ke}]`;ii(wn),oi(oo=>[...oo,{kind:"error",text:wn}])}}finally{if(to.current=!1,si(!1),jl.current=null,ld.current=null,xe&&clearTimeout(xe),xn&&yn){const Gt={id:yn.id,source:yn.source??"user",archived:yn.archived};(async()=>(await Xe(Gt,{preserveComposer:!0,incrementalSync:!0}),await xr(Gt,{quiet:!0,force:!0})))()}}},[u,fn,eo,ht,Dp,Xe,xr,xa,Cr,Nt,yc,Os]);ry.current=Pl;const H0=h.useCallback(()=>{!Nt||Nt.isLastPhase||(ba(null),Pl(e("flow:composer.skipRemainingPhases")))},[Nt,Pl]),W0=h.useCallback(()=>{if(!Nt||Nt.isLastPhase||!Nt.nextPhase)return;const x=String(Nt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Pl(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:Nt})},[Nt,Pl]);h.useEffect(()=>{if(!od)return;const x=N=>{N.key==="Escape"&&jc(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[od]),h.useEffect(()=>{Oe!=="edit"&&jc(!1)},[Oe]),h.useLayoutEffect(()=>{const x=pc.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,te=Math.min(Math.max(x.scrollHeight,J),ee);x.style.height=`${te}px`},[fn,u]);const py=h.useCallback(x=>{const N=fn,H=kn,q=Xj(N,H);if(!q)return;const Y=N.slice(0,q.atIndex)+`@${x} `+N.slice(H);Qi(Y);const J=q.atIndex+x.length+2;queueMicrotask(()=>{const ee=pc.current;ee&&(ee.focus(),ee.setSelectionRange(J,J)),yl(J)})},[fn,kn]),hy=h.useCallback(x=>{Qi(N=>{const H=`@${x}`,q=N.indexOf(H);return q<0?N:N.slice(0,q)+N.slice(q+H.length)})},[]),V0=h.useCallback(x=>{x.kind==="canvas"?wt(N=>N.map(H=>H.id===x.node.id?{...H,selected:!1}:H)):x.kind==="mention"?hy(x.node.id):hy(x.definition.id)},[wt,hy]),dR=h.useCallback(()=>{Ct(x=>x==="history"?null:"history")},[]),fR=h.useCallback(()=>{Ct(x=>x==="settings"?null:"settings")},[]),pR=h.useCallback(()=>{Ct(x=>x==="composer"?null:"composer")},[]),md=h.useCallback(()=>{Ct(x=>(x==="node"&&Zi.current&&(hc.current=Zi.current.id),null))},[]),U0=h.useCallback(()=>{ti(x=>!x)},[]),hR=()=>{if(!u)return null;const x=ei||u.archived||li(u.source),N=qn!=null&&qn.running?e("flow:schedule.running"):Kn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),H=qn!=null&&qn.running?"running":Kn.enabled?"waiting":"disabled",q=rn.slice(0,12),Y=u.archived||li(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:md,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(),Rp())},onBlur:()=>{F.trim()&&F.trim()!==u.id&&Rp()},placeholder:u.id,disabled:L,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(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:()=>L0(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:()=>Tp("workspace"),children:e($?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:$,onClick:()=>Tp("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:Tt,disabled:An,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(An?"common:common.loading":"common:common.refresh")]})]}),Jt?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Jt}):null,An?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}`:""}`,te=ve.has(ee)||ve.has(`marketplace:${J.id}`),me=Do.find(De=>String(De.id)===ee||String(De.id)===`marketplace:${J.id}`),xe=Vn===ee,ze=vh(J.inputs||J.input),ce=vh(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:te?"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:ze.length>0?ze.map(De=>o.jsx("span",{className:"af-pipeline-market-chip",children:De},`in-${ee}-${De}`)):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(De=>o.jsx("span",{className:"af-pipeline-market-chip",children:De},`out-${ee}-${De}`)):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:()=>Ie(J),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:te?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:Y||xe,onClick:()=>{te&&me?(R0(me),Ct(null)):Kt(J)},children:e(xe?"flow:settings.installingNode":te?"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")})]}),ts?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:!!Kn.enabled,disabled:x,onChange:J=>ln(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:Kn.cron||"",disabled:x,onChange:J=>ln(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:Kn.timezone||"",disabled:x,onChange:J=>ln(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:Kn.preset||"",disabled:x,onChange:J=>ln(ee=>({...ee,preset:J.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(mr).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:Kn.nextRunAt?e("flow:schedule.nextRun",{time:new Date(Kn.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:[Yt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Yt.lastTriggeredAt).toLocaleString()})]}):null,Yt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Yt.lastSkippedAt).toLocaleString(),Yt.lastSkipReason?` · ${Yt.lastSkipReason}`:""]})]}):null,Yt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Yt.lastRunUuid})]}):null,Yt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Yt.lastExitCode)})]}):null,Yt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Yt.lastFinishedAt).toLocaleString()})]}):null]}),qn!=null&&qn.lastError||Yt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(qn==null?void 0:qn.lastError)||Yt.lastError}):null,u.archived||li(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,dl?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:dl}):null,fa?o.jsx("p",{className:"af-pipeline-drawer-muted",children:fa}):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:[Et.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:Do.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Oc(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:Et.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:Oc(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 X2(),disabled:ei,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(ei?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:md,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")})]})]})]})},mR=()=>{const x=ye;if(!x)return null;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,H=x.displayName||x.label||x.id,q=vh(x.inputs||x.input),Y=vh(x.outputs||x.output);return $r.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&&Ie(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:()=>Ie(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(Fg,{children:[o.jsx(p7,{onReady:a}),o.jsxs(RT.Provider,{value:{modelLists:ht,onModelChange:J2},children:[o.jsxs("div",{className:"af-pipeline-page"+(Oe!=="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:()=>{Oe==="running"?Mp(!0):Oe!=="edit"?_l():n("/projects")},"aria-label":e(Oe!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Oe!=="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",VK,"-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(Cm(u,"workspace")),children:"Workspace"}),o.jsx("button",{type:"button",onClick:()=>n(Cm(u,"display")),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[la&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Io?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>hr(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Oe==="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:wx(ds,"running")})]}),Oe==="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:wx(ds,"stopped")})]}),(Oe==="done"||Oe==="error")&&o.jsxs("div",{className:"af-run-timer"+(Oe==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:Oe==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:wx(ds,Oe)})]}),Oe!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(pr?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>Zn(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Oe==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(nt==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!u,onClick:dR,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(nt==="settings"?" af-icon-btn--active":""),onClick:fR,"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"+(nt==="composer"?" af-composer-topbar-btn--active":"")+(In?" af-composer-topbar-btn--running":""),onClick:pR,"aria-label":"AI Composer",title:"AI Composer",disabled:!u,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(bl?" af-icon-btn--active":""),onClick:U0,"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||li(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||li(u.source)||u.archived||u.source!=="user"&&u.source!=="workspace",onClick:()=>_(!0),children:"Archive"})]}),Oe==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:rR,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Oe==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void io(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:_l,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Oe==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void io({runUuid:dn}),title:dn?e("flow:topbar.resumeTitle",{uuid:dn}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:_l,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Oe==="done"||Oe==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void io(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:_l,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 io(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!u,onClick:()=>Re(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":Me,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),Me&&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;Re(!1);const x={};for(const ee of Ne){const te=Fe[ee.id];te&&(x[te]=((N=Rs[te])==null?void 0:N.value)??((H=Rs[te])==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)??"")}Un(x),Dt(!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:()=>{Re(!1),io({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:()=>{Re(!1),io()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(mr).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var q;Re(!1);const N=mr[x]||{},H={};for(const Y of Ne){const J=Fe[Y.id];if(!J)continue;const ee=((q=Y.data)==null?void 0:q.definitionId)||"",te=N[Y.id]??"";ee.startsWith("provide_file")?H[J]={type:"file",path:te}:H[J]={type:"str",value:te}}io({cliInputsOverride:H})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),Ze?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:Ze}),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"+(Oe!=="edit"?" af-pipeline-body--run-mode":""),children:[Oe==="edit"&&nt!=="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${Hr?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Js(x=>!x),"aria-expanded":Hr,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:Hr?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:u&&(u.path||Dn.path)||"",children:u?u.id:e("flow:palette2.noPipelineSelected")}),Hr&&o.jsx("div",{className:"af-palette-workspace-tree",children:qi?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Dn.error?o.jsx("div",{className:"af-palette-workspace-empty",children:Dn.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:["(",Dn.files.length,")"]})]}),Dn.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:Dn.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))}):Dn.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Dn.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:Pe==="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:it,type:"search",className:"af-palette-search-input",value:Ae,onChange:x=>we(x.target.value),placeholder:(Pe==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Pe==="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":Pe==="nodes",className:"af-palette-tab"+(Pe==="nodes"?" af-palette-tab--active":""),onClick:()=>Te("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Pe==="flows",className:"af-palette-tab"+(Pe==="flows"?" af-palette-tab--active":""),onClick:()=>Te("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:Pe==="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:cR,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," 节点 / ",$p.length," 连线"]})]})}),kt?o.jsx("p",{className:"af-err af-palette-list-err",children:kt}):null,jt?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):F0.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:F0.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:()=>B0(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:Ae.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Hd.filter(x=>ns[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:ns[x].map(N=>{const H=Kj(N.inputs,"input"),q=Kj(N.outputs,"output"),J=N.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":OT(N),ee=LT(N);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>R0(N),draggable:!!u,onDragStart:te=>{te.dataTransfer.setData("application/agentflow-node",N.id),te.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:GK(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((te,me)=>o.jsxs("span",{className:"af-palette-card-port",title:Uj("input",te,me),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(te==null?void 0:te.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:bx(te,me)})]},`in-${me}`)),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((te,me)=>o.jsxs("span",{className:"af-palette-card-port",title:Uj("output",te,me),children:[o.jsx("span",{className:"af-palette-card-port-name",children:bx(te,me)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(te==null?void 0:te.type)}})]},`out-${me}`)),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&&Ae.trim()&&Cc===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"+(Ao?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(Ao?"common:engine.online":"common:engine.offline")})]}),w?o.jsx("div",{className:"af-palette-tip"+cn,role:"status","aria-live":"polite",children:w}):null]})]}):Oe!=="edit"&&u?o.jsx($K,{flowId:u.id,flowSource:u.source||"user",flowArchived:u.archived,provideNodes:Ne,edges:It,nodes:Et,onCliInputsChange:K,onBackToEdit:_l}):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&&wr.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 hn(),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:()=>ne(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:wr.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(),U2(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,u&&wr.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:wr.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:U0,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:()=>ne(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:ue,onClick:()=>void hn(),children:e("common:common.refresh")})]})]}):null,nt==="settings"&&u&&Oe==="edit"?hR():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:u?o.jsxs(o.Fragment,{children:[o.jsx(b7,{fitViewEpoch:m,canvasTool:wp,nodes:Ge,edges:zt,onNodesChange:Oe!=="edit"?void 0:Ap,onEdgesChange:Oe!=="edit"?void 0:Ip,onConnect:Oe!=="edit"?void 0:iy,onConnectStart:Oe!=="edit"?void 0:B2,onConnectEnd:Oe!=="edit"?void 0:H2,isValidConnection:Oe!=="edit"?void 0:sy,onNodesDelete:Oe!=="edit"?void 0:W2,onNodeClick:Ci,onNodeDoubleClick:so,onEdgeClick:Fo,onFlowInit:V2,onDrop:G2,onDragOver:Y2,hideMinimapAndControls:!!(u&&nt),bottomSlot:Oe==="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:Dp.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Dp.map((x,N)=>{var me,xe;if(x.kind==="definition"){const ze=x.definition,ce=String(ze.label??ze.id),De=[ze.id,ze.description?String(ze.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:De,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:ce}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>V0(x),"aria-label":e("flow:composer.removeFromInput",{id:ze.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${ze.id}`)}const H=x.node,q=x.kind,Y=String(((me=H.data)==null?void 0:me.label)??H.id),J=(xe=H.data)!=null&&xe.definitionId?String(H.data.definitionId):"",ee=J&&J!==Y?`${Y} · ${H.id} · ${J}`:`${Y} · ${H.id}`,te=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:()=>V0(x),"aria-label":te,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:pc,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!u,value:fn,rows:2,onChange:x=>{Qi(x.target.value),yl(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&yl(N.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),Pl();return}if(pd&&Ei.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),wl(N=>(N+1)%Ei.length);else if(x.key==="ArrowUp")x.preventDefault(),wl(N=>(N-1+Ei.length)%Ei.length);else if(x.key==="Enter"){x.preventDefault();const N=Ei[xl];N&&py(N.id)}}},onKeyUp:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&yl(N.selectionStart??N.value.length)},onClick:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&yl(N.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),pd&&u&&Ei.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[hd.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,hd.instances.map((x,N)=>{const H=N;return o.jsx("li",{role:"option","aria-selected":H===xl,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===xl?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>wl(H),onClick:()=>py(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}`)}),hd.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,hd.definitions.map((x,N)=>{const H=hd.instances.length+N;return o.jsx("li",{role:"option","aria-selected":H===xl,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===xl?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>wl(H),onClick:()=>py(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:[Ur.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:Cr||"",onChange:x=>{x.target.value==="__new__"?Cp():cd(x.target.value)},disabled:In,"aria-label":e("flow:composer.switchConversation"),children:[Ur.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:bc,type:"button",className:"af-composer-skills-button"+(fy>0?" af-composer-skills-button--active":""),disabled:!u||In,"aria-haspopup":"listbox","aria-expanded":wc,onClick:()=>rd(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:fy>0?`Skills ${fy}`:"Skills"})]}),wc&&!In?$r.createPortal(o.jsx("div",{ref:vc,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:vl,children:rr.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Fp.groups.map(x=>{const N=el(x,rr),H=W_(x,dy,rr),q=ty.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;ni(ee=>J?B_(ee,N):H_(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:()=>{ny(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:dy.has(Y.key),onChange:J=>{const ee=J.target.checked;ni(te=>ee?te.includes(Y.key)?te:[...te,Y.key]:te.filter(me=>me!==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)}),Fp.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:Fp.ungrouped.length})]}),Fp.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:dy.has(x.key),onChange:N=>{const H=N.target.checked;ni(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:(eo||"").trim()?ms.currentNotInLists?ms.currentNotInLists:kh(eo,ms.cursorList,ms.opencodeList,ms.claudeCodeList):"",onChange:x=>nd(x.target.value),disabled:!u||In,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),ms.currentNotInLists?o.jsxs("option",{value:ms.currentNotInLists,children:[ms.currentNotInLists,e("flow:composer.modelNotInList")]}):null,ms.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:ms.cursorList.map(x=>o.jsx("option",{value:Vo(x),children:x},`composer-c-${x}`))}):null,ms.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:ms.opencodeList.map(x=>o.jsx("option",{value:`opencode:${Vo(x)}`,children:x},`composer-o-${x}`))}):null,ms.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:ms.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${Vo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(u&&fn.trim()&&!In?" af-composer-send--active":"")+(In?" af-composer-send--stop":""),disabled:!u||!In&&!fn.trim(),"aria-label":e(In?"flow:composer.stopGeneration":"flow:composer.send"),title:In?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(In){(x=jl.current)==null||x.abort();return}Pl()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:In?"stop":"arrow_upward"})})]})]}),od?$r.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&&jc(!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"+(In?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:Nl||void 0,children:In&&!Nl?e("flow:composer.executing"):Nl||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>jc(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),wa.length>1&&!(Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(a7,{steps:wa})}):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)?In?"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(Jj,{thread:xa,liveSegments:ya,running:In})}),Nt&&!Nt.isLastPhase&&Nt.nextPhase&&!In?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:W0,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:H0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),G&&Oe==="edit"?(()=>{var q;const x=String(G.query||"").trim().toLowerCase(),N=x?G.candidates.filter(Y=>{var J,ee,te;return[(J=Y.def)==null?void 0:J.id,Y.displayLabel,Y.description,(ee=Y.slot)==null?void 0:ee.name,(te=Y.slot)==null?void 0:te.type].filter(Boolean).some(me=>String(me).toLowerCase().includes(x))}):G.candidates,H=G.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:G.left,top:G.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:nr((q=G.draft.slot)==null?void 0:q.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",G.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>Q(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:G.query,onChange:Y=>Q(J=>J&&{...J,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[N.map(Y=>{var te,me;const J=Y.displayLabel||((te=Y.def)==null?void 0:te.id),ee=bx(Y.slot,Y.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>q2(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:nr((me=Y.slot)==null?void 0:me.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")})})]}),Oe!=="edit"&&pr&&o.jsxs("div",{className:"af-run-console",style:{height:Ts},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:Z2,onPointerMove:eR,onPointerUp:$0,onPointerCancel:$0,onLostPointerCapture:tR}),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:[Oe==="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:()=>Zn(!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:[Tr.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:vi})]})]})]}),Oe!=="edit"&&wi&&u?o.jsx(RK,{instanceId:wi,flowId:u.id,runId:dn,nodeStatus:((K0=Is[wi])==null?void 0:K0.status)??null,onClose:()=>Zs(null)}):null,nt&&nt!=="settings"&&u&&Oe==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(nt==="node"?" af-pipeline-drawer--wide":"")+(nt==="composer"?" af-pipeline-drawer--wide":""),"aria-label":nt==="settings"?e("flow:settings.title"):nt==="history"?e("flow:history.title"):nt==="composer"?"AI Composer":e("flow:nodeProps.title"),children:nt==="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:md,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),Ur.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[Ur.map(x=>o.jsxs("button",{type:"button",ref:N=>{N&&x.id===Cr&&N.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===Cr?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>cd(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(),Mo(x.id)},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),Mo(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:()=>Cp(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(In?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:In&&!Nl?e("flow:composer.executing"):Nl||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)?In?"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:ad,children:o.jsx(Jj,{thread:xa,liveSegments:ya,running:In})}),Nt&&!Nt.isLastPhase&&Nt.nextPhase&&!In?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:W0,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:H0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):nt==="node"&&Ue?St?o.jsx(PT,{draft:St,setDraft:gc,definitionId:String(((q0=Ue.data)==null?void 0:q0.definitionId)??Ue.id),systemPromptReadonly:String((gt==null?void 0:gt.description)??""),modelLists:ht,disabled:!u,onIdBlur:Q2,onClose:md,onPublishToMarketplace:Nn,error:vp,ioSlots:{inputs:Array.isArray(St==null?void 0:St.inputs)?St.inputs:[],outputs:Array.isArray(St==null?void 0:St.outputs)?St.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(nt==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:md,"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:nt==="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(),Rp())},onBlur:()=>{F.trim()&&F.trim()!==u.id&&Rp()},placeholder:u.id,disabled:L,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(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:()=>L0(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:()=>Tp("workspace"),children:e($?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:$,onClick:()=>Tp("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")}),ts?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:!!Kn.enabled,disabled:ei||u.archived||li(u.source),onChange:x=>ln(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:Kn.cron||"",disabled:ei||u.archived||li(u.source),onChange:x=>ln(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:Kn.timezone||"",disabled:ei||u.archived||li(u.source),onChange:x=>ln(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:Kn.preset||"",disabled:ei||u.archived||li(u.source),onChange:x=>ln(N=>({...N,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(mr).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")})}),Kn.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(Kn.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:qn!=null&&qn.running?e("flow:schedule.running"):Kn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Yt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Yt.lastTriggeredAt).toLocaleString()})]}):null,Yt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Yt.lastSkippedAt).toLocaleString(),Yt.lastSkipReason?` · ${Yt.lastSkipReason}`:""]})]}):null,Yt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Yt.lastRunUuid})]}):null,Yt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Yt.lastExitCode)})]}):null,Yt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Yt.lastFinishedAt).toLocaleString()})]}):null]}),qn!=null&&qn.lastError||Yt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(qn==null?void 0:qn.lastError)||Yt.lastError}):null,u.archived||li(u.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,dl?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:dl}):null,fa?o.jsx("p",{className:"af-pipeline-drawer-muted",children:fa}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:ei||u.archived||li(u.source),onClick:oy,children:e(ei?"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:[Et.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})]}),Qt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):et?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:et}):fd.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[rs.success+rs.failed+rs.running+rs.stopped+rs.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[rs.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:rs.success})}):null,rs.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:rs.failed})}):null,rs.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:rs.stopped})}):null,rs.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:rs.interrupted})}):null,rs.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:rs.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:fd.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}`,te=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:fd.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:()=>lR(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:te}),o.jsx("span",{className:"af-exec-history-card-time",children:Tw(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"}),gM(x.durationMs,e)]})]})]})},`${u.id}-${ee}`)})})]})]})})]})}):null]}),o.jsx(Pj,{open:nR,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:sR,onCancel:()=>cy(!1)}),o.jsx(Pj,{open:iR,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:aR,onSecondary:oR,onCancel:()=>Mp(!1)}),o.jsx(ST,{open:bl,onClose:()=>ti(!1)}),mR(),o.jsx(NT,{open:ed,onClose:()=>td(!1),onJump:K2,nodes:Et}),o.jsx(WK,{open:Io,onClose:()=>hr(!1),flowId:(u==null?void 0:u.id)??""}),o.jsx(mK,{open:D,onClose:()=>_(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",onArchived:async()=>{_(!1),await dt(),n("/projects?tab=archived")}}),o.jsx(gK,{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),wt([]),an([]),ba(null),await dt(),n("/projects")}}),vn&&$r.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:()=>Mn(!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:Ht.name,onChange:x=>{const N=x.target.value;$n(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:Ht.id,onChange:x=>$n(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:Ht.description,onChange:x=>$n(N=>({...N,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Lr.length," 个节点和 ",$p.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:()=>Mn(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Wn||!Ht.name.trim(),onClick:()=>void uR(),children:Wn?"发布中…":"发布"})]})]})}),document.body),o.jsx(wK,{open:!!X,onClose:()=>Z(null),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),filePath:(X==null?void 0:X.filePath)??"",fileName:(X==null?void 0:X.fileName)??"",onSaved:()=>{us(x=>({...x}))}})]}),lr&&Oe!=="edit"&&$r.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:lr.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:Ju?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(!lr||!u||!dn)return;const x=Xi||lr.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:dn,instanceId:lr.instanceId,content:x})})).ok?(ha(H=>H&&{...H,content:x}),Lo(!1),xt(H=>[...H,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):xt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{xt(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:()=>{ma(lr.content),Lo(!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:()=>Lo(!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:()=>ha(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:Ju?o.jsx("textarea",{ref:Qu,className:"af-user-check-modal__textarea",value:Xi||lr.content,onChange:x=>ma(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:Xi||lr.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:hl,onChange:x=>jr(x.target.value),disabled:cc}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:cc||!hl.trim(),onClick:()=>{!lr||!u||!dn||!hl.trim()||(ki(!0),xt(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:dn,instanceId:lr.instanceId,content:Xi||lr.content,prompt:hl})}).then(x=>x.json()).then(x=>{ki(!1),x.ok&&x.content?(ma(x.content),Lo(!0),jr(""),xt(N=>[...N,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):xt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{ki(!1),xt(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[cc?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(!lr||!u||!dn)return;const x=Xi||lr.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:dn,instanceId:lr.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:dn,instanceId:lr.instanceId,execId:lr.execId})}),ha(null),jr(""),io({runUuid:dn})):xt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{xt(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),Wr&&Oe!=="edit"&&$r.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:Wr.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Ls(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:[Wr.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:Wr.question})}):null,Wr.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:Wr.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:Zu,onClick:async()=>{if(!(!Wr||!u||!dn)){ps(!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:dn,instanceId:Wr.instanceId,execId:Wr.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Ls(null),ps(!1),io({runUuid:dn})):(ps(!1),xt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{ps(!1),xt(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(Zu?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),ml&&Oe!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(uc?" 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:ml.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Le(x=>!x),"aria-label":e(uc?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(uc?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:uc?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Ji(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(dp,{children:ml.content})})})]}),Vr&&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:Vr.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>gl(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:dc,className:"af-provide-edit-modal__textarea",defaultValue:Vr.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:Bt,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:()=>gl(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Qe&&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:()=>Dt(!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:Ne.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:Ne.map(x=>{var me,xe;const N=Fe[x.id];if(!N)return null;const H=((me=x.data)==null?void 0:me.definitionId)||"",q=H.startsWith("provide_file"),Y=H==="provide_bool",J=((xe=x.data)==null?void 0:xe.label)||x.id,ee=Ot[N]??"",te=["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"+(te?" af-run-config-bool-toggle--true":""),onClick:()=>Un(ze=>({...ze,[N]:te?"false":"true"})),"aria-pressed":te,children:te?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:ee,onChange:ze=>Un(ce=>({...ce,[N]:ze.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 Ne){const q=Fe[H.id];if(!q)continue;const Y=((N=H.data)==null?void 0:N.definitionId)||"",J=Ot[q]??"";Y.startsWith("provide_file")?x[q]={type:"file",path:J}:x[q]={type:"str",value:J}}Dt(!1),Re(!1),io({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:()=>Dt(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const j7="modulepreload",C7=function(e){return"/"+e},s1={},E7=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=C7(c),c in s1)return;s1[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":j7,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)})},_7=new Set(["echarts"]),P7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),A7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),I7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Ja(e){return e&&typeof e=="object"&&!Array.isArray(e)}function rc(e,t){if(!Ja(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Ja(n[r])&&Ja(s)&&(n[r]=rc(n[r],s));return n}function Ug(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Ja(n)?rc(n,t):n):Ja(e)?rc(e,t):e}function T7(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 bb(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)=>bb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||A7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);bb(r,`${t}.${n}`)}}}function R7(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!P7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function L7(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:rc(e,t)}function O7(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(!Ja(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return rc(i,n)}):Ja(e)?rc(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function M7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Ug(e,n)}function i1(e,t="rgba(255, 255, 255, 0.62)"){return Ug(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 $7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Ug(e,n)}function D7(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:Ug(e,t)}function F7(e,t,n){const r=O7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Ja(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??I7,textStyle:rc(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:L7(e.tooltip),legend:M7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?$7(e.grid,s||i):e.grid,xAxis:i1(e.xAxis),yAxis:i1(e.yAxis),radar:D7(e.radar),series:t}}function z7(e){const t=T7(e);if(!t)return{ok:!1,error:"No chart content"};try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("ChartSpec must be a JSON object");if(n.type!=="chart")throw new Error('type must be "chart"');if(n.version!=="1.0")throw new Error('version must be "1.0"');if(!_7.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");bb(n);const r=R7(n.option.series),s=n.title==null?"":String(n.title),i=F7(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)}}}function Go(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 FT(e){const t=Go(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function zT(e){return Go(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function B7(e){const t=String(e||"").replace(/\r\n/g,`
137
+ `).split(`
138
+ `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
+ `)}),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&&Go(l).length>1&&FT(t[a+1])){i();const c=Go(l),d=zT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Go(t[a]).length>1;)f.push(Go(t[a])),a++;n.push({type:"table",headers:c,align:d,rows:f});continue}r.push(l),a++}return i(),n}function BT(e,t=!1){return{...t?{p:({children:n})=>o.jsx(o.Fragment,{children:n})}:{},img:({src:n,alt:r})=>o.jsx("img",{src:e?e(n):n||"",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,resolveSrc:t}){return o.jsx(dp,{components:BT(t,!0),children:String(e||"")})}function y0({content:e,resolveSrc:t}){const n=h.useMemo(()=>B7(e),[e]),r=h.useMemo(()=>BT(t),[t]);return o.jsx(o.Fragment,{children:n.map((s,i)=>s.type!=="table"?o.jsx(dp,{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,{resolveSrc: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,{resolveSrc:t,children:a[d]||""})},d))},l))})]})},`table-${i}`))})}function H7(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
140
+ `);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===`
141
+ `?(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 lo(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 W7(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=>lo(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>lo(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)=>lo(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:lo(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:lo(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>lo(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>lo(s[a])):s&&typeof s=="object"?r.map(i=>lo(s[i.key])):r.map((i,a)=>a===0?lo(s):""))}}function V7(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=W7(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
142
+ `).split(`
143
+ `).filter(l=>l.trim());if(s.length>=2&&Go(s[0]).length>1&&FT(s[1])){const l=Go(s[0]),c=zT(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:c[f]||"left"})),rows:s.slice(2).map(d=>Go(d)),error:""}}const i=r.includes(" ")?" ":",",a=H7(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 x0({content:e}){const t=h.useMemo(()=>V7(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:lo(n[i])},`${s.key}-${i}`))},r))})]})})}function w0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>z7(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:""}),E7(()=>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]})}const U7="af:workspace-graph:v2",Fc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],K7=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),q7={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:""}]},Y7={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}]},G7={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}]},X7=new Set(["png","jpg","jpeg","gif","webp","svg"]),J7=320,HT=180,WT=960,vb=96,VT=900,kb="display-ref:",Q7="0.1.53";function Z7(){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 Ia(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 Jm(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 X7.has(n)}function Qm(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=Ia(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function eq(e,t){const n=String(e||"").trim();if(!n)return"";const r=Ia(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function tq(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 nq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function rq(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function sq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!rq(e)}function iq(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 a1(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 UT(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 KT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function b0(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 Wd(e){const t=String(b0(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 l1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Zm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Vd(e){return Zm(e)}function Sb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Sx(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 c1(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 u1(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 d1(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=Ou(s.get(n),e.sourceHandle||"output-0","source"),a=Ou(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Lu(i,a))}function oq(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=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:bT(a)}:null}function aq(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"?Lu(t.slot,a):Lu(a,t.slot)))continue;const c=Wd(n);return{def:n,order:r,category:c,categoryRank:Fc.indexOf(c),slot:a,slotIndex:i,displayLabel:Vd(n),description:Sb(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 Ud(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 lq(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 cq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Nh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:cq(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 qT(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 uq(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[qT(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 Nx(e,t){var u,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=GT(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=b0(v)||b,k=t.find(B=>B.id===y)||v,w=g.marketplaceRef||KT(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=!!Yn(y),C=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,$=mu(C,{display:A});return{id:m,type:pp,position:j,...$?{width:$.width,height:$.height}:{},data:{label:g.label||Zm(v)||Zm(k)||m,definitionId:y,...w?{marketplaceRef:w}:{},...v!=null&&v.packageId?{marketplacePackageId:v.packageId}:{},...v!=null&&v.version?{marketplaceVersion:v.version}:{},schemaType:UT(y,k||v),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...$?{nodeSize:$}:{},...A&&$?{displaySize:$}:{}}}}).map(m=>Uf(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:Es.ArrowClosed}}));return{nodes:d,edges:xT(f,d),instances:r}}function f1(e){return`${kb}${e}`}function jx(e){const t=String(e||"");return t.startsWith(kb)?t.slice(kb.length):t}function YT(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 Nb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var p;return Yn((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=mu(d[u],{display:!0});p&&(c[u]=p)});const f=YT(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function dq(e,t=[]){return Nb(e,t)}function fq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function pq(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function p1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function mu(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:p1(n,HT,WT)||J7,height:p1(r,vb,VT)||vb}}function zc(e){var s,i,a,l,c,d,f,u,p,m,g;const t=!!Yn((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 mu({width:n,height:r},{display:t})}function jh(e,t,n){var l,c;const r=GT(fp(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=zc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function GT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Yn(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 Yn(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 Kl(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Yn(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 Wu(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 XT(e){const t=Wu(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 hq(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 mq(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function h1(e,t){const n=URL.createObjectURL(e);try{mq(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function gq(e){const t=Wu(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(`
144
+ `),i=n.body?Array.from(n.body.childNodes).map(a=>r.serializeToString(a)).join(""):t;return`
145
+ <style>
146
+ * { box-sizing: border-box; }
147
+ html, body { margin: 0; min-height: 100%; background: transparent; }
148
+ .af-html-snapshot-root { width: 100%; min-height: 100%; overflow: hidden; }
149
+ </style>
150
+ ${s}
151
+ <div xmlns="http://www.w3.org/1999/xhtml" class="af-html-snapshot-root">${i}</div>
152
+ `}async function yq({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"?>
153
+ <svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${i}" viewBox="0 0 ${s} ${i}">
154
+ <foreignObject width="100%" height="100%">
155
+ <div xmlns="http://www.w3.org/1999/xhtml" style="width:${s}px;height:${i}px;overflow:hidden;background:#ffffff;">
156
+ ${gq(e)}
157
+ </div>
158
+ </foreignObject>
159
+ </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");h1(p,r)}catch(d){throw h1(l,r.replace(/\.png$/i,".svg")),d}finally{URL.revokeObjectURL(c)}}function xq(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 wq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function bq(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 JT({code:e}){const t=h.useMemo(()=>bq(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 _a({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 vq({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Yn(e==null?void 0:e.definitionId);if(!s)return null;const i=Kl(e),a=s==="html"?Wu(i):i;if(!a.trim())return o.jsx(_a,{className:"af-work-display-empty",children:"No display content"});if(s==="html")return o.jsx(_a,{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:XT(a)},r)});if(s==="image"){const l=Qm(a,t);return o.jsx(_a,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:l,alt:xq(e),loading:"lazy"})})}return s==="markdown"?o.jsx(_a,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(y0,{content:a,resolveSrc:l=>Qm(l,t)})}):s==="chart"?o.jsx(_a,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(w0,{content:a})}):s==="table"?o.jsx(_a,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(x0,{content:a})}):s==="mermaid"?o.jsxs(_a,{className:"af-work-display-body",children:[o.jsx(JT,{code:a}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:a})]}):o.jsx(_a,{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 kq({node:e}){var s,i,a,l;const t=Yn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Kl(e==null?void 0:e.data),r=t==="html"?Wu(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:XT(r)}):t==="image"?o.jsx("img",{src:Qm(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(y0,{content:r,resolveSrc:c=>{var d;return Qm(c,(d=e==null?void 0:e.data)==null?void 0:d.flowParams)}})}):t==="chart"?o.jsx(w0,{content:r}):t==="table"?o.jsx(x0,{content:r}):t==="mermaid"?o.jsxs("div",{className:"af-display-picker-preview__diagram",children:[o.jsx(JT,{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 Sq({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(Jm);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 Nq({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 jq(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function Cq(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function Eq(e,t){const n=Yn(t==null?void 0:t.definitionId)||"markdown";return`outputs/${Cq((t==null?void 0:t.label)||e||n)}.${jq(n)}`}function _q({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,ne,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(((ne=E.slot)==null?void 0:ne.type)||"").trim(),X=String(((ue=D.slot)==null?void 0:ue.type)||"").trim();return P==="node"&&X!=="node"?-1:X==="node"&&P!=="node"?1:E.idx-D.idx}),l=Yn(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"?Kl(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,X;if(l!=="html"||u)return;const E=Wu(Kl(t));if(!E.trim())return;const D=(X=(P=c.current)==null?void 0:P.getBoundingClientRect)==null?void 0:X.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 yq({content:E,width:_,height:R,filename:hq((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(Jm)||Array.from(((P=E.dataTransfer)==null?void 0:P.items)||[]).some(X=>String((X==null?void 0:X.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(Jm);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(BA,{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(Ps,{type:"target",position:Je.Left,id:`input-${D}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:_,background:nr(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(Ps,{type:"source",position:Je.Right,id:`output-${D}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:R,background:nr(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:wq(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(Sq,{value:y,onChange:k,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:$}):o.jsx(vq,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:c,htmlFrameVersion:d}),o.jsx(Nq,{nodeId:e,data:t})]})}function Pq({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(Ps,{type:"target",position:Je.Left,id:`input-${f}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:u,background:nr(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(Ps,{type:"source",position:Je.Right,id:`output-${f}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:u,background:nr(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 Aq(e){var m,g,b,v,y,k,w,j,A,C,$,B,F;const{setEdges:t,setNodes:n}=ac(),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=ks(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 Yn((v=e.data)==null?void 0:v.definitionId)?o.jsx(_q,{...e,deleteNode:c}):((y=e.data)==null?void 0:y.definitionId)==="workspace_run"?o.jsx(Pq,{...e,deleteNode:c}):((k=e.data)==null?void 0:k.definitionId)==="control_load_skills"?o.jsx(Hq,{...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(Wq,{...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(BA,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:HT,minHeight:vb,maxWidth:WT,maxHeight:VT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),o.jsx(vT,{...e,deleteNode:c,modelLists:(F=e.data)==null?void 0:F.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:u,onNodeImagesChange:p})]})}const Iq={[pp]:Aq};function QT(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&QT(n.children,t);return t}function ZT(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&ZT(n.children,t));return t}function Ch(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 Tq(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function Rq(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:Ud(c),size:n}:{...m,type:"directory",name:c,path:d,icon:Ud(c,!0),children:s(m.children||[],a+1,d)}));return u||p.push(f?{type:"file",name:c,path:d,icon:Ud(c),size:n}:{type:"directory",name:c,path:d,icon:Ud(c,!0),children:s([],a+1,d)}),Tq(p)};return s(e||[],0,"")}function e2({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||Ud(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:eq(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(e2,{items:d.children,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:c}):null]},d.path)})})}function Lq({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 eg(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 Oq(e){const t=eg((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 eg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Mq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function $q(e){const t=eg((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 eg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Dq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function m1(e){var r,s,i,a,l,c;if(!e)return null;const{inputs:t,outputs:n}=yT(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:ks((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),inputs:t,outputs:n}}function g1(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 Fq(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=nl.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?[]:ks(t==null?void 0:t.images),inputs:g1(t==null?void 0:t.inputs),outputs:s&&Array.isArray((u=e.data)==null?void 0:u.outputs)?e.data.outputs:g1(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 y1({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(!_T.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=Fq(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(ks(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 zq(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function Bq(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"])zq(e[s],t[s])&&(r[s]=n[s]);return r}function Hq({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(Oq(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=el(_,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(X=>String(X||"").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),X=_?Math.min(P,T.scrollTop/Math.max(1,E-D)*P):0;j({visible:_,top:X,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,pe;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,X=T.clientY>=D.top+_&&T.clientY<=D.top+_+R?T.clientY-D.top-_:R/2;O(W(T.clientY,X));const Z=T.pointerId;(pe=(ue=T.currentTarget).setPointerCapture)==null||pe.call(ue,Z);const V=ge=>{ge.preventDefault(),O(W(ge.clientY,X))},ne=()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",ne),window.removeEventListener("pointercancel",ne)};window.addEventListener("pointermove",V),window.addEventListener("pointerup",ne),window.addEventListener("pointercancel",ne)},[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(Ps,{type:"target",position:Je.Left,id:`input-${E}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:nr(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(Ps,{type:"source",position:Je.Right,id:`output-${E}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:nr(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:X=>F([P.key],X.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 Wq({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($q(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(Ps,{type:"target",position:Je.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:nr(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(Ps,{type:"source",position:Je.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:nr(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 Vq(){var ro,dd;const{i18n:e}=Pn(),{navigate:t}=Co(),n=ac(),r=Kv(),s=h.useMemo(Z7,[]),[i,a]=h.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[l,c]=MA([]),[d,f,u]=$A([]),p=h.useRef([]),m=h.useRef([]),[g,b]=h.useState(()=>Nb(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,X]=h.useState(""),[Z,V]=h.useState("nodes"),[ne,ue]=h.useState([]),[pe,ge]=h.useState(!1),[ae,be]=h.useState(""),[Ae,we]=h.useState(!1),[Pe,Te]=h.useState({name:"",id:"",description:""}),[it,ct]=h.useState(!1),[tt,jt]=h.useState(""),[Ye,kt]=h.useState(""),nn=h.useRef(null),[vn,Mn]=h.useState(!1),[Ht,$n]=h.useState(!1),[Wn,le]=h.useState(""),[de,He]=h.useState(null),[Ze,ot]=h.useState({title:"",layout:"gallery",nodeIds:[]}),[Xt,rn]=h.useState(!1),[sn,An]=h.useState(""),[Sr,Jt]=h.useState(!1),[mn,Vn]=h.useState(""),[or,ye]=h.useState(!1),[Ie,nt]=h.useState("nodes"),[Ct,ie]=h.useState(""),[_e,et]=h.useState(0),[$t,Qt]=h.useState(""),ar=h.useRef(""),[ut,Nr]=h.useState(null),Hr=h.useRef(null),[Js,Dn]=h.useState(""),[us,qi]=h.useState([]),[Po,Ao]=h.useState(""),[Ee,Oe]=h.useState(!0),[Zt,Tr]=h.useState(""),[xt,es]=h.useState(()=>new Set),Qn=h.useRef(null),[Fn,Is]=h.useState(()=>{try{const S=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(S)&&S>=160)return S}catch{}return 360}),[lt,on]=h.useState(!1),[Lt,ds]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[Be,pr]=h.useState(""),[Zn,la]=h.useState([]),[ca,Io]=h.useState(!1),[hr,Ts]=h.useState([]),[fs,xi]=h.useState([]),[dn,Qs]=h.useState(!1),[wi,Zs]=h.useState([]),Rs=h.useCallback(S=>{nn.current&&window.clearTimeout(nn.current),kt(S),nn.current=window.setTimeout(()=>{kt(""),nn.current=null},3800)},[]),K=h.useCallback(S=>{const I=String(S||"").trim();if(!I)return;const U=()=>r(I);window.requestAnimationFrame(U),window.setTimeout(U,80)},[r]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Fn)))}catch{}},[Fn]);const he=h.useCallback(S=>{const I=Qn.current;if(!I)return;const U=I.getBoundingClientRect(),G=16,Q=150,re=230,se=U.top+G,oe=U.bottom-G,fe=Math.max(Q,oe-se-re),Se=Math.min(Math.max(S-se,Q),fe);Is(Se)},[]),Me=h.useCallback(S=>{S.preventDefault(),S.stopPropagation(),on(!0),he(S.clientY);const I=G=>{G.preventDefault(),he(G.clientY)},U=()=>{on(!1),window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",U,!0),window.removeEventListener("pointercancel",U,!0)};window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",U,!0),window.addEventListener("pointercancel",U,!0)},[he]);h.useEffect(()=>()=>{nn.current&&window.clearTimeout(nn.current)},[]);const[Re,Qe]=h.useState(()=>new Set),[Dt,Ot]=h.useState(!1),Un=h.useRef(null),mr=h.useRef(null),To=h.useRef(null),[ua,Gu]=h.useState({}),[Kn,da]=h.useState(""),[ts,Xu]=h.useState(!1),[ei,ul]=h.useState([]),[dl,Rr]=h.useState([]),[fa,Yi]=h.useState("workspace"),[Yt,pa]=h.useState(!1),[qn,fl]=h.useState(!0),[pl,bi]=h.useState(""),[vi,Gi]=h.useState({}),[Ro,lr]=h.useState(!1),[ha,Xi]=h.useState(!1),[ma,Ju]=h.useState(!1),[Lo,hl]=h.useState("pan"),[jr,cc]=h.useState(null),[ki,Qu]=h.useState(""),Wr=h.useRef(null),Ls=h.useRef(!1),[Zu,ps]=h.useState(()=>new Set),[ml,Ji]=h.useState({}),[uc,Le]=h.useState(""),Vr=h.useMemo(()=>tq(s),[s]),[gl,dc]=h.useState("");h.useEffect(()=>{s.flowId&&z_(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(()=>{ul([]),Rr([]),Yi("workspace"),fl(!0)},[s]);const fn=h.useCallback(async()=>{const S=Ia(s),I=await fetch(`/api/workspace/files?${S.toString()}`),U=await I.json();if(!I.ok)throw new Error(U.error||"读取 workspace 失败");const G=U.files||[];qi(G),es(new Set(ZT(G))),Ao(U.root||"")},[s]),Qi=h.useCallback(async()=>{ge(!0),be("");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){be(String(S.message||S)),ue([])}finally{ge(!1)}},[]),kn=h.useCallback(async(S=l,I=d)=>{var re;if(!E.current)return;if(!Ee)throw Le("Readonly workspace"),new Error("Readonly workspace");const U=jh(S,I,T.current);U.ui={...U.ui||{},...w.current?{viewport:w.current}:{},displayPage:dq(v.current,S)};const G=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,graph:U})}),Q=await G.json();if(!G.ok)throw new Error(Q.error||"保存 workspace graph 失败");T.current=((re=Q.graph)==null?void 0:re.instances)||U.instances,M(T.current),Le("Workspace graph saved")},[d,s,l,Ee]),yl=h.useCallback(S=>{var U;const I=(U=S==null?void 0:S.extra)!=null&&U.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:[]),Qt(""),O(null)},[f,c]),xl=h.useMemo(()=>({instances:W}),[W]),wl=wT({nodes:l,edges:d,extra:xl,enabled:E.current,onRestore:yl}),{resetHistory:wp,undo:fc,redo:bl}=wl,ti=h.useCallback(async()=>{var rt,Ge;E.current=!1;const S=Ia(s),I=Ia(s);I.set("lang",String(e.language||"zh").startsWith("zh")?"zh":"en");const[U,G]=await Promise.all([fetch(`/api/nodes?${I.toString()}`),fetch(`/api/workspace/graph?${S.toString()}`),fn()]),Q=await U.json(),re=await G.json();if(!U.ok)throw new Error(Q.error||"读取节点定义失败");if(!G.ok)throw new Error(re.error||"读取 workspace graph 失败");const se=[...(Array.isArray(Q)?Q:Q.nodes||[]).filter(zt=>!K7.has(zt.id)),Y7,G7,q7];R(se);const oe=re.graph||JSON.parse(localStorage.getItem(U7)||"null")||{},fe=Nx(oe,se),Se=Nb((rt=oe==null?void 0:oe.ui)==null?void 0:rt.displayPage,fe.nodes),Ne=YT((Ge=oe==null?void 0:oe.ui)==null?void 0:Ge.viewport);T.current=fe.instances,M(fe.instances),c(fe.nodes),f(fe.edges),b(Se),v.current=Se,k(Ne),w.current=Ne,A([]),wp(fe.nodes,fe.edges,{instances:fe.instances});const Fe=re.writable!==!1;Oe(Fe),Le(Fe?"Workspace ready":"Readonly workspace"),E.current=!0},[s,e.language,fn,wp,f,c]),ed=h.useCallback(async(S,I)=>{const U={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},G=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)}),Q=await G.json().catch(()=>({}));if(!G.ok||(Q==null?void 0:Q.ok)===!1)throw new Error((Q==null?void 0:Q.error)||"Publish failed");return await ti(),Le(`Published node ${Q.definitionId||Q.id||U.packageId}`),Q},[s,ti]),td=h.useCallback((S="workspace")=>{pa(!0),Nr(null),Yi(S||"workspace")},[]),pc=h.useCallback(async(S="")=>{const I=String(S||ki||"").trim();if(I){Ls.current=!0,Wr.current&&(Wr.current.abort(),Wr.current=null),Qu(""),ps(new Set),Ji(U=>{const G={...U};for(const[Q,re]of Object.entries(G))(re==null?void 0:re.status)==="running"&&(G[Q]={status:"stopped"});return G[I]={status:"stopped"},G}),Le(`Workspace run stopped: ${I}`),Rr(U=>U.map(G=>G.runNodeId===I&&G.status==="running"?{...G,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(G.messages)?G.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:G));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,runNodeId:I})})}catch{}}},[s,ki]),hc=h.useCallback(async S=>{if(!Ee){Le("Readonly workspace");return}if(!S||ki)return;let I=l,U=d,G=T.current;const Q=Hr.current;if(Q!=null&&Q.id){const Se=I.find(Fe=>Fe.id===Q.id),Ne=y1({nodes:I,edges:U,instances:G,selectedNode:Se,draft:Q,allowRename:!1});if(Ne!=null&&Ne.error){Dn(Ne.error),Le(Ne.error);return}Ne!=null&&Ne.ok&&Ne.changed&&(I=Ne.nodes,U=Ne.edges,G=Ne.instances,T.current=G,M(G),c(I),f(U),K(Ne.nextId||Q.id))}const re=jh(I,U,G),se=`run-${Date.now()}-${String(S).replace(/[^a-z0-9_-]+/gi,"_")}`,oe=`Run ${S}`,fe=new AbortController;Wr.current=fe,Ls.current=!1,Qu(S),ps(new Set([S])),Ji({[S]:{status:"running"}}),Le(`Running ${S}...`),Yi(se),Rr(Se=>[...Se.slice(-7),{id:se,label:oe,runNodeId:S,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await kn(I,U);const Se=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:fe.signal,body:JSON.stringify({...s,graph:re,runNodeId:S,model:Be,selectedSkills:hr,stream:!0})});if(!Se.ok){const ve=await Se.json().catch(()=>({}));throw new Error(ve.error||"Workspace run failed")}if(!Se.body)throw new Error("Workspace run stream unavailable");const Ne=Se.body.getReader(),Fe=new TextDecoder;let rt="",Ge=[],zt=[],ln=S;const xr=(ve,dt)=>{var Tt,Wt;const pt=l.find(Kt=>Kt.id===ve),Xe=String(((Tt=pt==null?void 0:pt.data)==null?void 0:Tt.label)||ve||"").trim(),$e=String(dt||((Wt=pt==null?void 0:pt.data)==null?void 0:Wt.definitionId)||"").trim();return $e&&$e!==Xe?`${Xe} (${$e})`:Xe},Bt=(ve,dt,pt)=>{const Xe=String(ve||"").trim();Xe&&Rr($e=>$e.map(Tt=>{if(Tt.id!==se)return Tt;const Kt=[...Array.isArray(Tt.steps)?Tt.steps:[]],Nn=Kt.findIndex(Fo=>Fo.id===Xe),hn={id:Xe,label:xr(Xe,dt),status:pt};Nn>=0?Kt[Nn]={...Kt[Nn],...hn}:Kt.push(hn);const _t=Kt.map((Fo,sy)=>{const iy=Fo.status==="done"?"[done]":Fo.status==="failed"?"[failed]":"[running]";return`${sy+1}. ${iy} ${Fo.label}`}).join(`
164
+ `),cn=Array.isArray(Tt.messages)?Tt.messages:[],Er=cn.findIndex(Fo=>Fo.kind==="run-summary"),Ci={role:"assistant",kind:"run-summary",text:_t||"准备运行...",at:Date.now()},so=[...cn];return Er>=0?so[Er]=Ci:so.unshift(Ci),{...Tt,steps:Kt,messages:so.slice(-160)}}))},Ue=ve=>{const dt=String(ve||"").trim();if(!dt)return;const pt=ln;ln=dt,ps(new Set([dt])),Ji(Xe=>{var $e;return{...Xe,...pt&&pt!==dt&&(($e=Xe[pt])==null?void 0:$e.status)==="running"?{[pt]:{status:"success"}}:{},[dt]:{status:"running"}}})},wr=ve=>{const dt=String(ve||"").trim();dt&&(ps(pt=>{const Xe=new Set(pt);return Xe.delete(dt),Xe}),Ji(pt=>({...pt,[dt]:{status:"success"}})))},Kr=(ve,dt)=>{const pt=String(dt||"");if(!pt.trim())return;const Xe=["assistant","thinking","result","error","prompt"].includes(ve)?ve:"assistant";Rr($e=>$e.map(Tt=>{if(Tt.id!==se)return Tt;let Wt=Array.isArray(Tt.messages)?Tt.messages:[];if(Xe==="result"){const hn=[...Wt].reverse().find(_t=>_t.kind==="assistant");if(String((hn==null?void 0:hn.text)||"").trim()===pt.trim())return Tt}if(Xe==="assistant"){const hn=Wt.findIndex(_t=>_t.kind==="result"&&String(_t.text||"").trim()===pt.trim());hn>=0&&(Wt=Wt.filter((_t,cn)=>cn!==hn))}const Kt=[...Wt],Nn=Kt[Kt.length-1];return Nn&&Nn.kind===Xe&&!Nn.error?Kt[Kt.length-1]={...Nn,text:`${Nn.text||""}${Nn.text?`
165
+ `:""}${pt}`}:Kt.push({role:"assistant",kind:Xe,text:pt,...Xe==="error"?{error:!0}:{},at:Date.now()}),{...Tt,messages:Kt.slice(-160)}}))},Ds=ve=>{const dt=String(ve||"");dt.trim()&&Rr(pt=>pt.map(Xe=>{var Kt;if(Xe.id!==se)return Xe;const $e=Array.isArray(Xe.messages)?Xe.messages:[],Tt=$e.findIndex(Nn=>Nn.kind==="thinking"),Wt=[...$e];if(Tt>=0){const Nn=String(((Kt=Wt[Tt])==null?void 0:Kt.text)||"");Wt[Tt]={...Wt[Tt],text:`${Nn}${Nn&&!Nn.endsWith(`
166
+ `),""}${dt}`,at:Date.now()}}else{const Nn=Wt.findIndex(hn=>hn.kind==="activity");Wt.splice(Nn>=0?Nn+1:Wt.length,0,{role:"assistant",kind:"thinking",text:dt,at:Date.now()})}return{...Xe,messages:Wt.slice(-160)}}))},gt=ve=>{const dt=iq(ve);dt&&Rr(pt=>pt.map(Xe=>{if(Xe.id!==se)return Xe;const $e=Array.isArray(Xe.activities)?Xe.activities:[],Tt=$e[$e.length-1]===dt?$e:[...$e,dt].slice(-8),Wt=Array.isArray(Xe.messages)?Xe.messages:[],Kt=Wt.findIndex(_t=>_t.kind==="activity"),Nn={role:"assistant",kind:"activity",text:Tt.map((_t,cn)=>`${cn+1}. ${_t}`).join(`
167
+ `),at:Date.now()},hn=[...Wt];if(Kt>=0)hn[Kt]=Nn;else{const _t=hn.findIndex(cn=>cn.kind==="run-summary");hn.splice(_t>=0?_t+1:0,0,Nn)}return{...Xe,activities:Tt,messages:hn.slice(-160)}}))},pn=ve=>{const dt=String((ve==null?void 0:ve.source)||"runner"),pt=String((ve==null?void 0:ve.stream)||""),Xe=String((ve==null?void 0:ve.eventType)||"event"),$e=String((ve==null?void 0:ve.text)||"").trim();if(!$e)return;const Tt=`[${dt}${pt?`:${pt}`:""}] ${Xe}
168
+ ${$e}`;Rr(Wt=>Wt.map(Kt=>{if(Kt.id!==se)return Kt;const hn=[...Array.isArray(Kt.rawTrace)?Kt.rawTrace:[],Tt].slice(-80),_t=Array.isArray(Kt.messages)?Kt.messages:[],cn=_t.findIndex(so=>so.kind==="raw"),Er={role:"assistant",kind:"raw",text:hn.join(`
169
+
170
+ ---
171
+
172
+ `),at:Date.now()},Ci=[..._t];return cn>=0?Ci[cn]=Er:Ci.push(Er),{...Kt,rawTrace:hn,messages:Ci.slice(-160)}}))},ns=ve=>{Rr(dt=>dt.map(pt=>pt.id===se?{...pt,status:ve,endedAt:Date.now()}:pt))},Cc=ve=>{const dt=new Set,pt=String((ve==null?void 0:ve.nodeId)||"").trim();pt&&dt.add(pt);for(const Xe of Array.isArray(ve==null?void 0:ve.displayNodeIds)?ve.displayNodeIds:[]){const $e=String(Xe||"").trim();$e&&dt.add($e)}for(const Xe of Array.isArray(ve==null?void 0:ve.touchedNodeIds)?ve.touchedNodeIds:[]){const $e=String(Xe||"").trim();$e&&dt.add($e)}if(dt.size===0)for(const Xe of Array.isArray(ve==null?void 0:ve.order)?ve.order:[]){const $e=String(Xe||"").trim();$e&&dt.add($e)}return dt},Do=(ve,dt=null)=>{const pt=Nx(ve||re,_),Xe=new Map(pt.nodes.map(Wt=>[Wt.id,Wt])),$e=pt.instances||{},Tt=dt instanceof Set?dt:null;c(Wt=>{const Kt=new Set(Wt.map(_t=>_t.id)),hn={...jh(Wt,m.current,T.current).instances||{}};for(const[_t,cn]of Object.entries($e)){if(Tt&&!Tt.has(_t)||!Kt.has(_t))continue;const Er=hn[_t];Yn((cn==null?void 0:cn.definitionId)||(Er==null?void 0:Er.definitionId))?hn[_t]=cn:Array.isArray(cn==null?void 0:cn.output)&&(hn[_t]={...Er||cn,output:cn.output})}return T.current=hn,M(hn),Wt.map(_t=>{var Er,Ci,so;if(Tt&&!Tt.has(_t.id))return _t;const cn=Xe.get(_t.id);return cn?Yn(((Er=cn.data)==null?void 0:Er.definitionId)||((Ci=_t.data)==null?void 0:Ci.definitionId))?{..._t,data:{..._t.data,...cn.data}}:Array.isArray((so=cn.data)==null?void 0:so.outputs)?{..._t,data:{..._t.data,outputs:cn.data.outputs}}:_t:_t})})};for(;;){const{value:ve,done:dt}=await Ne.read();if(dt)break;rt+=Fe.decode(ve,{stream:!0});const pt=rt.split(`
173
+ `);rt=pt.pop()||"";for(const Xe of pt){if(!Xe.trim())continue;const $e=JSON.parse(Xe);if($e.type==="error")throw new Error($e.error||"Workspace run failed");if($e.type==="stopped"){Ls.current=!0,Ge=Array.isArray($e.order)?$e.order:Ge;continue}if($e.type==="node-start"&&(Le(`Running ${$e.nodeId}...`),Ue($e.nodeId),Bt($e.nodeId,$e.definitionId,"running")),$e.type==="node-done"&&(wr($e.nodeId),Bt($e.nodeId,$e.definitionId,"done")),$e.type==="status"&&gt($e.line||$e.message||""),$e.type==="paused"&&(zt=Array.isArray($e.nodeIds)?$e.nodeIds:[]),$e.type==="natural"&&($e.kind==="thinking"?Ds($e.text||""):Kr($e.kind,$e.text||"")),$e.type==="raw"){const Tt=a1($e);Tt&&Ds(Tt),pn($e)}$e.type==="graph"&&$e.graph&&Do($e.graph,Cc($e)),$e.type==="done"&&($e.graph&&Do($e.graph,Cc($e)),Ge=Array.isArray($e.order)?$e.order:[],zt=Array.isArray($e.pauseNodeIds)?$e.pauseNodeIds:zt)}}if(rt.trim()){const ve=JSON.parse(rt);if(ve.type==="error")throw new Error(ve.error||"Workspace run failed");if(ve.type==="stopped"&&(Ls.current=!0),ve.type==="node-start"&&(Le(`Running ${ve.nodeId}...`),Ue(ve.nodeId),Bt(ve.nodeId,ve.definitionId,"running")),ve.type==="node-done"&&(wr(ve.nodeId),Bt(ve.nodeId,ve.definitionId,"done")),ve.type==="status"&&gt(ve.line||ve.message||""),ve.type==="paused"&&(zt=Array.isArray(ve.nodeIds)?ve.nodeIds:[]),ve.type==="natural"&&(ve.kind==="thinking"?Ds(ve.text||""):Kr(ve.kind,ve.text||"")),ve.type==="raw"){const dt=a1(ve);dt&&Ds(dt),pn(ve)}ve.type==="graph"&&ve.graph&&Do(ve.graph,Cc(ve)),ve.type==="done"&&(ve.graph&&Do(ve.graph,Cc(ve)),Ge=Array.isArray(ve.order)?ve.order:[],zt=Array.isArray(ve.pauseNodeIds)?ve.pauseNodeIds:zt)}Ls.current&&(ps(new Set),Ji(ve=>{var pt;const dt=((pt=Object.entries(ve).find(([,Xe])=>(Xe==null?void 0:Xe.status)==="running"))==null?void 0:pt[0])||S;return dt?{...ve,[dt]:{status:"stopped"}}:ve})),Le(Ls.current?`Workspace run stopped: ${S}`:zt.length?`Workspace run paused at ${zt.join(", ")}`:`Workspace run done: ${Ge.length?Ge.join(" -> "):S}`),ns(Ls.current?"stopped":zt.length?"paused":"done"),Ls.current||await fn()}catch(Se){if(Ls.current||(Se==null?void 0:Se.name)==="AbortError"){ps(new Set),Ji(Ne=>{var rt;const Fe=((rt=Object.entries(Ne).find(([,Ge])=>(Ge==null?void 0:Ge.status)==="running"))==null?void 0:rt[0])||S;return Fe?{...Ne,[Fe]:{status:"stopped"}}:Ne}),Le(`Workspace run stopped: ${S}`),Rr(Ne=>Ne.map(Fe=>Fe.id===se?{...Fe,status:"stopped",endedAt:Date.now()}:Fe));return}ps(new Set),Ji(Ne=>{var rt;const Fe=(rt=Object.entries(Ne).find(([,Ge])=>(Ge==null?void 0:Ge.status)==="running"))==null?void 0:rt[0];return Fe?{...Ne,[Fe]:{status:"failed"}}:Ne}),Le(String(Se.message||Se)),Rr(Ne=>Ne.map(Fe=>Fe.id===se?{...Fe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Fe.messages)?Fe.messages:[],{role:"assistant",error:!0,text:String(Se.message||Se),at:Date.now()}].slice(-160)}:Fe))}finally{Wr.current===fe&&(Wr.current=null),Qu(""),ps(new Set)}},[Be,d,s,fn,l,_,K,ki,kn,hr,f,c,Ee]),Zi=h.useCallback(async()=>{try{const I=await(await fetch("/api/skills")).json().catch(()=>({})),U=Array.isArray(I.skills)?I.skills.map(G=>({key:String(G.key),name:String(G.name||G.id||G.key),description:G.description?String(G.description):"",sourceLabel:G.sourceLabel?String(G.sourceLabel):""})):[];la(U),Io(!0)}catch{Io(!0)}},[]),mc=h.useCallback(async()=>{try{const I=await(await fetch("/api/mcps")).json().catch(()=>({})),U=Array.isArray(I.servers)?I.servers.map(G=>({name:String((G==null?void 0:G.name)||""),type:String((G==null?void 0:G.type)||""),url:String((G==null?void 0:G.url)||""),command:String((G==null?void 0:G.command)||""),args:Array.isArray(G==null?void 0:G.args)?G.args.map(String):[],description:String((G==null?void 0:G.description)||"")})).filter(G=>G.name):[];Zs(U)}catch{Zs([])}},[]);h.useEffect(()=>{ti().catch(S=>Le(String(S.message||S))),Qi(),fetch("/api/model-lists").then(S=>S.json()).then(S=>ds({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(()=>{}),Zi(),mc(),fetch("/api/skill-collections").then(S=>S.json()).then(S=>{xi(Ya(S)),Qs(!0)}).catch(()=>{}),fetch("/api/auth/me").then(S=>S.json()).then(S=>cc(S.user||null)).catch(()=>cc(null))},[ti,Qi,mc,Zi,Vr]),h.useEffect(()=>{if(dc(""),!(!ca||!dn)){if(!Vr){Ts([]);return}Ts(V_(Vr,"workspace",Zn,fs)),dc(Vr)}},[fs,dn,Zn,ca,Vr]),h.useEffect(()=>{if(!(gl!==Vr||!Vr))try{localStorage.setItem(Vr,JSON.stringify(hr))}catch{}},[hr,Vr,gl]),h.useEffect(()=>{T.current=W},[W]),h.useEffect(()=>{p.current=l},[l]),h.useEffect(()=>{const S=C.current,I=new Map,U=[];for(const se of l){const oe=qT(se);I.set(se.id,oe),S.get(se.id)!==oe&&U.push(se.id)}if(C.current=I,U.length===0)return;const G=()=>U.forEach(se=>r(se)),Q=window.requestAnimationFrame(G),re=window.setTimeout(G,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(re)}},[l,r]),h.useEffect(()=>{m.current=d},[d]),h.useEffect(()=>{v.current=g},[g]),h.useEffect(()=>{w.current=y},[y]),h.useEffect(()=>{Hr.current=ut},[ut]),h.useEffect(()=>{ar.current=$t},[$t]),h.useEffect(()=>{z.current=L},[L]),h.useEffect(()=>{if(!L)return;const S=U=>{U.key==="Escape"&&O(null)},I=U=>{var G,Q;(Q=(G=U.target)==null?void 0:G.closest)!=null&&Q.call(G,".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&&Ee)return D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{kn().catch(S=>Le(String(S.message||S)))},650),()=>{D.current&&window.clearTimeout(D.current)}},[l,d,g,kn,Ee]);const bp=h.useCallback((S,I)=>{if(!Ee){Le("Readonly workspace");return}const U=Mq(I),G=fe=>Array.isArray(fe)?fe.map(Se=>(Se==null?void 0:Se.name)!=="skillKeys"&&(Se==null?void 0:Se.name)!=="skillsContext"&&(Se==null?void 0:Se.type)!=="text"?Se:{...Se,default:U,value:U}):[],Q=l.map(fe=>{var Se;return fe.id!==S?fe:{...fe,data:{...fe.data,body:U,inputs:G((Se=fe.data)==null?void 0:Se.inputs)}}}),re=T.current||{},se=re[S]&&typeof re[S]=="object"?re[S]:{},oe={...re,[S]:{...se,body:U,input:G(se.input)}};T.current=oe,c(Q),M(oe),Nr(fe=>!fe||fe.id!==S?fe:{...fe,body:U,inputs:G(fe.inputs)}),kn(Q,d).catch(fe=>Le(String(fe.message||fe)))},[d,l,kn,c,Ee]),St=h.useCallback((S,I)=>{if(!Ee){Le("Readonly workspace");return}const U=Dq(I),G=fe=>Array.isArray(fe)?fe.map(Se=>(Se==null?void 0:Se.name)!=="serverNames"&&(Se==null?void 0:Se.name)!=="mcpContext"&&(Se==null?void 0:Se.type)!=="text"?Se:{...Se,default:U,value:U}):[],Q=l.map(fe=>{var Se;return fe.id!==S?fe:{...fe,data:{...fe.data,body:U,inputs:G((Se=fe.data)==null?void 0:Se.inputs)}}}),re=T.current||{},se=re[S]&&typeof re[S]=="object"?re[S]:{},oe={...re,[S]:{...se,body:U,input:G(se.input)}};T.current=oe,c(Q),M(oe),Nr(fe=>!fe||fe.id!==S?fe:{...fe,body:U,inputs:G(fe.inputs)}),kn(Q,d).catch(fe=>Le(String(fe.message||fe)))},[d,l,kn,c,Ee]),gc=h.useCallback(S=>{const I=String(S||"").trim();I&&(bi(U=>U===I?"":I),Gi(U=>({...U,[I]:U[I]||{sessionId:`nodechat_${Date.now()}_${I.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),vp=h.useCallback((S,I)=>{const U=String(S||"").trim();U&&Gi(G=>({...G,[U]:{...G[U]||{sessionId:`nodechat_${Date.now()}_${U.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(I||""),error:""}}))},[]),Si=h.useCallback((S,I,U="replace",G={})=>{var xr;if(!Ee){Le("Readonly workspace");return}const Q=String(S||"").trim();if(!Q)return;const re=p.current.find(Bt=>Bt.id===Q),se=Yn((xr=re==null?void 0:re.data)==null?void 0:xr.definitionId),oe=se==="html"?Wu(I):String(I||""),fe=re?Kl(re.data):"",Se=U==="append"&&String(fe||"").trim()?`${String(fe).replace(/\s+$/g,"")}
174
+
175
+ ${oe.trim()}`:oe,Ne=se==="image"?"src":"content",Fe=Bt=>{let Ue=!1;return(Array.isArray(Bt)?Bt:[]).map(Kr=>{const Ds=String((Kr==null?void 0:Kr.name)||""),gt=String((Kr==null?void 0:Kr.type)||"");return!Ue&&(Ds===Ne||Ds==="filePath"||gt==="text")?(Ue=!0,{...Kr,default:Se,value:Se}):Kr})},rt=p.current.map(Bt=>{var Ue,wr;return Bt.id!==Q?Bt:{...Bt,data:{...Bt.data,body:Se,inputs:Fe((Ue=Bt.data)==null?void 0:Ue.inputs),outputs:Fe((wr=Bt.data)==null?void 0:wr.outputs)}}}),Ge=T.current||{},zt=Ge[Q]&&typeof Ge[Q]=="object"?Ge[Q]:{},ln={...Ge,[Q]:{...zt,body:Se,input:Fe(zt.input),output:Fe(zt.output)}};T.current=ln,c(rt),M(ln),Nr(Bt=>(Bt==null?void 0:Bt.id)===Q?{...Bt,body:Se}:Bt),(G==null?void 0:G.logChat)!==!1&&Gi(Bt=>{var Ue;return{...Bt,[Q]:{...Bt[Q]||{},candidateContent:"",messages:[...(Ue=Bt[Q])!=null&&Ue.messages&&Array.isArray(Bt[Q].messages)?Bt[Q].messages:[],{role:"assistant",text:U==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),kn(rt,m.current).catch(Bt=>Le(String(Bt.message||Bt))),Le(String((G==null?void 0:G.statusMessage)||"")||(U==="append"?"已追加节点内容":"已替换节点内容"))},[kn,c,Ee]),ht=h.useCallback(async S=>{if(!Ee)return Le("Readonly workspace"),"";if(!Jm(S))return Le("请选择图片文件"),"";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 U=await fetch("/api/workspace/upload",{method:"POST",body:I}),G=await U.json().catch(()=>({}));if(!U.ok)throw new Error(G.error||"上传图片失败");const Q=String(G.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await fn(),es(re=>{const se=new Set(re);for(const oe of Ch(Q))se.delete(oe);return se}),Le(`已上传图片 ${Q}`),Q}catch(I){return Le(String(I.message||I)),""}},[s,fn,Ee]),kp=h.useCallback(async(S,I)=>{const U=String(S||"").trim();if(!U)return;const G=await ht(I);G&&Si(U,G,"replace",{logChat:!1,statusMessage:`已上传图片 ${G}`})},[Si,ht]),eo=h.useCallback((S,I="replace")=>{var Q;const U=String(S||"").trim(),G=String(((Q=vi[U])==null?void 0:Q.candidateContent)||"").trim();!U||!G||Si(U,G,I)},[vi,Si]),nd=h.useCallback(async(S,I=void 0)=>{var Se,Ne,Fe;if(!Ee){Le("Readonly workspace");return}const U=String(S||"").trim();if(!U)return;const G=vi[U]||{},Q=String(I!==void 0?I:G.draft||"").trim();if(!Q||G.running)return;const re=p.current.find(rt=>rt.id===U);if(!re)return;const se={role:"user",text:Q,at:Date.now()},oe=Array.isArray(G.messages)?G.messages:[],fe=G.sessionId||`nodechat_${Date.now()}_${U.replace(/[^a-z0-9_-]+/gi,"_")}`;Gi(rt=>({...rt,[U]:{...G,sessionId:fe,messages:[...oe,se],draft:"",running:!0,error:""}}));try{const rt=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,sessionId:fe,node:{id:U,label:((Se=re.data)==null?void 0:Se.label)||U,definitionId:((Ne=re.data)==null?void 0:Ne.definitionId)||""},nodeKind:Yn((Fe=re.data)==null?void 0:Fe.definitionId)||"markdown",currentContent:Kl(re.data),messages:oe,message:Q,model:Be})}),Ge=await rt.json().catch(()=>({}));if(!rt.ok)throw new Error(Ge.error||"节点微调失败");const zt=String(Ge.candidateContent||Ge.reply||"").trim();Gi(ln=>{var xr;return{...ln,[U]:{...ln[U]||{},sessionId:String(Ge.sessionId||fe),running:!1,candidateContent:zt,messages:[...(xr=ln[U])!=null&&xr.messages&&Array.isArray(ln[U].messages)?ln[U].messages:[...oe,se],{role:"assistant",text:zt||"已生成候选内容。",at:Date.now()}]}}})}catch(rt){const Ge=String(rt.message||rt);Gi(zt=>({...zt,[U]:{...zt[U]||{},running:!1,error:Ge}})),Le(Ge)}},[Be,s,vi,Ee]),yc=h.useCallback(async(S,I)=>{if(!Ee){Le("Readonly workspace");return}const U=Kl(I);if(!String(U||"").trim()){Le("展示节点没有可保存内容");return}const G=Eq(S,I),Q=window.prompt("保存到 workspace 相对路径",G);if(Q)try{const re=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:Q,content:U})}),se=await re.json().catch(()=>({}));if(!re.ok)throw new Error(se.error||"保存文件失败");const oe=se.path||Q,fe=Ia(s);fe.set("path",oe);const Se=await fetch(`/api/workspace/file?${fe.toString()}`);if(!Se.ok){const Ne=await Se.json().catch(()=>({}));throw new Error(Ne.error||`保存后读取失败:${oe}`)}await fn(),qi(Ne=>Rq(Ne,oe,String(U||"").length)),es(Ne=>{const Fe=new Set(Ne);for(const rt of Ch(oe))Fe.delete(rt);return Fe}),Le(`已保存 ${oe}`)}catch(re){Le(String(re.message||re))}},[s,fn,Ee]),Qg=h.useCallback((S,I)=>{const U=String(S||"");U&&Nr(G=>{if(!G||G.id!==U)return G;const Q=typeof I=="function"?I(G):I;return!Q||typeof Q!="object"?G:{...G,...Q}})},[]),rr=h.useMemo(()=>l.map(S=>{var I,U;return{...S,data:{...S.data,selected:S.selected===!0,modelLists:Lt,showBodyPreview:!0,isExecuting:Zu.has(S.id),nodeStatus:((I=ml[S.id])==null?void 0:I.status)??null,nodeElapsed:((U=ml[S.id])==null?void 0:U.elapsed)??null,flowParams:s,readOnly:!Ee,onRunWorkspaceNode:hc,onStopWorkspaceNode:pc,runningRunNodeId:ki,skills:Zn,skillCollections:fs,onChangeLoadSkillKeys:bp,onRefreshSkills:Zi,mcpServers:wi,onChangeLoadMcpNames:St,onRefreshMcps:mc,onSaveDisplayNodeToFile:yc,onUploadWorkspaceImage:ht,onUploadImageToDisplayNode:kp,nodeChatActive:pl===S.id,nodeChat:vi[S.id]||null,onSetDisplayNodeContent:Si,onToggleNodeChat:gc,onCloseNodeChat:()=>bi(""),onUpdateNodeChatDraft:vp,onSendNodeChat:nd,onApplyNodeChatCandidate:eo,onSyncNodePropDraft:Qg}}}),[pl,eo,St,bp,s,wi,Lt,vi,l,mc,Zi,hc,ki,yc,nd,Si,fs,Zn,pc,Qg,gc,vp,kp,ht,Zu,ml,Ee]),Sp=h.useMemo(()=>new Map(rr.map(S=>[S.id,S])),[rr]),Os=h.useMemo(()=>{const S=new Set(j);return g.nodeIds.map((I,U)=>{var oe;const G=Sp.get(I);if(!G||!Yn((oe=G.data)==null?void 0:oe.definitionId))return null;const Q=zc(G)||{width:520,height:320},re=mu(g.nodeSizes[I]||Q,{display:!0})||Q,se=g.nodePositions[I]||{x:180+U*36,y:120+U*28};return{...G,id:f1(I),position:se,selected:S.has(I),width:re.width,height:re.height,data:{...G.data,sourceNodeId:I,displayPageMode:!0,readOnly:!0,selected:S.has(I),displaySize:re,nodeSize:re}}}).filter(Boolean)},[g,Sp,j]),ni=h.useMemo(()=>rr.filter(S=>{var I;return Yn((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}),[rr]),ft=i==="display";h.useEffect(()=>{if(!ft||!g.viewport)return;const S=g.viewport,I=()=>{try{n.setViewport(S,{duration:0})}catch{}},U=window.requestAnimationFrame(()=>window.requestAnimationFrame(I));return()=>window.cancelAnimationFrame(U)},[g.viewport,ft,n]),h.useEffect(()=>{if(ft||!y)return;const S=y,I=()=>{try{n.setViewport(S,{duration:0})}catch{}},U=window.requestAnimationFrame(()=>window.requestAnimationFrame(I));return()=>window.cancelAnimationFrame(U)},[ft,n,y]),h.useEffect(()=>{const S=$.current,I=new Map,U=[];for(const se of[...rr,...Os]){const oe=uq(se);I.set(se.id,oe),S.get(se.id)!==oe&&U.push(se.id)}if($.current=I,U.length===0)return;const G=()=>U.forEach(se=>r(se)),Q=window.requestAnimationFrame(G),re=window.setTimeout(G,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(re)}},[Os,rr,r]);const tn=h.useMemo(()=>l.find(S=>S.id===$t)||null,[l,$t]),ga=h.useRef({id:"",draft:null}),Zg=h.useMemo(()=>{const S=m1(tn);return S?JSON.stringify(S):""},[tn]);h.useEffect(()=>{if(!tn){ga.current={id:"",draft:null},Nr(null),Dn("");return}const S=m1(tn),I=ga.current;ga.current={id:tn.id,draft:S},Nr(U=>!U||U.id!==tn.id||I.id!==tn.id||!I.draft?S:Bq(U,I.draft,S)),Dn("")},[tn==null?void 0:tn.id,Zg]);const xc=h.useCallback((S=!1)=>{if(!ut||!tn)return!1;if(!Ee)return Dn("Readonly workspace"),Le("Readonly workspace"),!1;Dn("");const I=y1({nodes:l,edges:d,instances:T.current,selectedNode:tn,draft:ut,allowRename:S});return I!=null&&I.error?(Dn(I.error),!1):(!(I!=null&&I.ok)||!I.changed||(T.current=I.instances,M(I.instances),c(I.nodes),f(I.edges),I.nextId!==tn.id&&Qt(I.nextId),K(I.nextId)),!0)},[d,ut,l,tn,f,c,K,Ee]);h.useEffect(()=>{if(!Ee||!ut||!tn)return;const S=window.setTimeout(()=>{xc(!1)},350);return()=>window.clearTimeout(S)},[ut==null?void 0:ut.label,ut==null?void 0:ut.role,ut==null?void 0:ut.model,ut==null?void 0:ut.body,JSON.stringify((ut==null?void 0:ut.images)||[]),ut==null?void 0:ut.script,JSON.stringify((ut==null?void 0:ut.inputs)||[]),JSON.stringify((ut==null?void 0:ut.outputs)||[]),xc,tn==null?void 0:tn.id,Ee]);const ey=h.useMemo(()=>{const S=new Map(rr.map(I=>[I.id,I]));return d.map(I=>{var Se,Ne,Fe,rt;const U=S.get(I.source),G=S.get(I.target),Q=/^output-(\d+)$/.exec(I.sourceHandle||""),re=/^input-(\d+)$/.exec(I.targetHandle||""),se=U&&Q?(Ne=(Se=U.data)==null?void 0:Se.outputs)==null?void 0:Ne[parseInt(Q[1],10)]:null,oe=G&&re?(rt=(Fe=G.data)==null?void 0:Fe.inputs)==null?void 0:rt[parseInt(re[1],10)]:null,fe=se!=null&&se.type?nr(se.type):oe!=null&&oe.type?nr(oe.type):"";return fe?{...I,style:{...I.style||{},stroke:fe,strokeWidth:2},markerEnd:{type:Es.ArrowClosed,color:fe}}:I})},[d,rr]),ty=ft?Os:rr,ny=ft?[]:ey,wc=h.useMemo(()=>ft?Os.map(S=>({...S,id:jx(S.id)})):rr,[Os,rr,ft]),rd=h.useCallback(S=>{const I=String(S||"").trim();if(!I)return;const U=ft?f1(I):I;ft?A([I]):(c(Q=>Q.map(re=>({...re,selected:re.id===U}))),f(Q=>Q.map(re=>({...re,selected:!1}))),Qt(U));const G=()=>{var Se,Ne,Fe;const Q=n.getNode(U);if(!Q)return;const re=(Se=n.getInternalNode)==null?void 0:Se.call(n,U),se=((Ne=re==null?void 0:re.measured)==null?void 0:Ne.width)??(re==null?void 0:re.width)??Q.width??260,oe=((Fe=re==null?void 0:re.measured)==null?void 0:Fe.height)??(re==null?void 0:re.height)??Q.height??120,{zoom:fe}=n.getViewport();n.setCenter(Q.position.x+se/2,Q.position.y+oe/2,{zoom:fq(fe),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(G))},[ft,n,f,c]),bc=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(ft){const U={...v.current,viewport:I};v.current=U,b(U),Le("已固定 Display 进入视角")}else w.current=I,k(I),Le("已固定 Workspace 进入视角");kn(p.current,m.current).catch(U=>Le(String(U.message||U)))},[ft,n,kn]),vc=h.useMemo(()=>{const S=P.trim().toLowerCase(),I={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const U of _)S&&![U.id,U.label,U.displayName,U.description].some(G=>String(G||"").toLowerCase().includes(S))||I[Wd(U)].push(U);for(const U of Fc)I[U].sort((G,Q)=>G.id.localeCompare(Q.id));return I},[_,P]),vl=h.useMemo(()=>{const S=Ct.trim().toLowerCase();return _.filter(I=>!S||[I.id,I.label,I.displayName,I.description].some(U=>String(U||"").toLowerCase().includes(S))).sort((I,U)=>{const G=Fc.indexOf(Wd(I)),Q=Fc.indexOf(Wd(U));return G!==Q?G-Q:Vd(I).localeCompare(Vd(U))}).slice(0,30)},[_,Ct]),kl=h.useMemo(()=>{const S=Ct.trim().toLowerCase();return ne.filter(I=>!S||[I.id,I.version,I.displayName,I.name,I.description,...Array.isArray(I.tags)?I.tags:[]].some(U=>String(U||"").toLowerCase().includes(S))).sort((I,U)=>String(I.displayName||I.name||I.id).localeCompare(String(U.displayName||U.name||U.id))).slice(0,30)},[ne,Ct]);h.useEffect(()=>{et(0)},[Ct,or,Ie]),h.useEffect(()=>{if(!or)return;const S=window.setTimeout(()=>{var I;return(I=To.current)==null?void 0:I.focus()},0);return()=>window.clearTimeout(S)},[or]);const kc=h.useMemo(()=>{const S=Zt.trim().toLowerCase();return S?QT(us).filter(I=>I.path.toLowerCase().includes(S)):us},[Zt,us]),Np=[...(Lt.cursor||[]).map(S=>({label:`Cursor · ${S.split(" - ")[0]}`,value:`cursor:${S.split(" - ")[0]}`})),...(Lt.opencode||[]).map(S=>({label:`OpenCode · ${S.split(" - ")[0]}`,value:`opencode:${S.split(" - ")[0]}`})),...(Lt.claudeCode||[]).map(S=>({label:`Claude · ${S.split(" - ")[0]}`,value:`claude-code:${S.split(" - ")[0]}`}))],Sc=h.useMemo(()=>new Set(hr),[hr]),Ni=h.useMemo(()=>{const S=new Map(Zn.map(re=>[re.key,re])),I=new Set,U=new Set,G=fs.map(re=>{const se=el(re,Zn).map(oe=>S.get(oe)).filter(Boolean);for(const oe of se)I.add(oe.key),U.add(String(oe.name||oe.id||oe.key||"").trim());return{...re,skills:se}}).filter(re=>re.skills.length>0),Q=Zn.filter(re=>{const se=String(re.name||re.id||re.key||"").trim();return!I.has(re.key)&&!U.has(se)});return{groups:G,ungrouped:Q}},[fs,Zn]);h.useEffect(()=>{Qe(S=>{let I=!1;const U=new Set(S);for(const G of Ni.groups)U.has(G.id)||(U.add(G.id),I=!0);return I?U:S})},[Ni.groups]);const gn=h.useMemo(()=>{const S=l.filter(I=>I.selected);return S.length>0?S:$t?l.filter(I=>I.id===$t):[]},[l,$t]),Oo=h.useMemo(()=>gn.map(S=>S.id),[gn]),Ur=h.useMemo(()=>l.filter(S=>{var I;return Yn((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}),[l]),hs=h.useMemo(()=>gn.filter(S=>{var I;return Yn((I=S==null?void 0:S.data)==null?void 0:I.definitionId)}).map(S=>S.id),[gn]),Cr=h.useMemo(()=>{const S=String((jr==null?void 0:jr.username)||(jr==null?void 0:jr.userId)||"").trim();return S?S.slice(0,1).toUpperCase():"?"},[jr]),ri=h.useMemo(()=>new Set(Oo),[Oo]),Ms=h.useMemo(()=>d.filter(S=>ri.has(S.source)&&ri.has(S.target)),[d,ri]),sd=h.useCallback(S=>{const I=S==="display"?"display":"workspace";a(I),Qt(""),A([]),O(null),ye(!1),Jt(!1);const U=Ia(s);I==="display"&&U.set("view","display");const G=`/workspace${U.toString()?`?${U.toString()}`:""}`;window.history.pushState({},"",G)},[s]),id=h.useCallback(S=>{var G;const I=String(S||"").trim();if(!I)return;const U=p.current.find(Q=>Q.id===I);if(!U||!Yn((G=U.data)==null?void 0:G.definitionId)){Le("展示节点不可用");return}b(Q=>{if(Q.nodeIds.includes(I))return Q;const re=Q.nodeIds.length,se=zc(U);return{nodeIds:[...Q.nodeIds,I],nodePositions:{...Q.nodePositions,[I]:{x:180+re*36,y:120+re*28}},nodeSizes:{...Q.nodeSizes,...se?{[I]:se}:{}}}}),A([I])},[]),Sl=h.useCallback(S=>{const I=String(S||"").trim();I&&(b(U=>{const G=U.nodeIds.filter(se=>se!==I),Q={...U.nodePositions},re={...U.nodeSizes};return delete Q[I],delete re[I],{nodeIds:G,nodePositions:Q,nodeSizes:re}}),A(U=>U.filter(G=>G!==I)))},[]),Nc=h.useCallback(S=>{const I=String(S||"").trim();I&&(v.current.nodeIds.includes(I)?Sl(I):id(I))},[id,Sl]),Sn=h.useMemo(()=>{const S=mn.trim().toLowerCase();return S?ni.filter(I=>{var U,G;return[I.id,(U=I.data)==null?void 0:U.label,(G=I.data)==null?void 0:G.definitionId].filter(Boolean).some(Q=>String(Q).toLowerCase().includes(S))}):ni},[ni,mn]),In=h.useMemo(()=>{const S=Sn.length,I=S<=1?1:S<=4?2:3,U=Array.from({length:I},()=>({height:0,nodes:[]}));for(const G of Sn){const Q=zc(G)||{width:420,height:260},re=Math.max(1,Number(Q.width)||420),se=Math.max(1,Number(Q.height)||260),oe=Math.min(26,Math.max(5.5,se/re*16))+3.2;let fe=U[0];for(const Se of U)Se.height<fe.height&&(fe=Se);fe.nodes.push(G),fe.height+=oe}return U.map(G=>G.nodes)},[Sn]),Nl=h.useCallback(S=>{var re,se;const I=g.nodeIds.includes(S.id),U=zc(S)||{width:420,height:260},G=Math.max(1,Math.round(Number(U.width)||420)),Q=Math.max(1,Math.round(Number(U.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":`${G} / ${Q}`},onClick:()=>Nc(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(kq,{node:S})}),o.jsxs("span",{className:"af-display-picker-card__meta",children:[o.jsx("strong",{children:((re=S.data)==null?void 0:re.label)||S.id}),o.jsxs("small",{children:[Yn((se=S.data)==null?void 0:se.definitionId)," · ",S.id]})]})]},S.id)},[g.nodeIds,Nc]),ya=h.useMemo(()=>{const S=P.trim().toLowerCase();return S?ne.filter(I=>[I.id,I.version,I.displayName,I.name,I.description,...Array.isArray(I.tags)?I.tags:[]].filter(Boolean).some(U=>String(U).toLowerCase().includes(S))):ne},[ne,P]),xa=h.useCallback((S,I)=>{const U=String(S||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let G=`${U}_${Date.now().toString(36)}`,Q=2;for(;I.has(G);)G=`${U}_${Date.now().toString(36)}_${Q}`,Q+=1;return I.add(G),G},[]),wa=h.useCallback((S,I)=>{var Kr,Ds;if(!Ee){Le("Readonly workspace");return}const U=S!=null&&S.snippet&&typeof S.snippet=="object"?S.snippet:{},G=U.instances&&typeof U.instances=="object"?U.instances:{},Q=Object.keys(G);if(Q.length===0)return;const re=new Set(p.current.map(gt=>gt.id)),se={};for(const gt of Q)se[gt]=xa(gt,re);const oe=(Kr=U.ui)!=null&&Kr.nodePositions&&typeof U.ui.nodePositions=="object"?U.ui.nodePositions:{},fe=(Ds=U.ui)!=null&&Ds.nodeSizes&&typeof U.ui.nodeSizes=="object"?U.ui.nodeSizes:{},Se=Q.map(gt=>{const pn=oe[gt];return{id:gt,x:typeof(pn==null?void 0:pn.x)=="number"?pn.x:0,y:typeof(pn==null?void 0:pn.y)=="number"?pn.y:0}}),Ne=Math.min(...Se.map(gt=>gt.x)),Fe=Math.min(...Se.map(gt=>gt.y));let rt=I||{x:360+p.current.length*24,y:180+p.current.length*18};if(!I){const gt=document.querySelector(".af-workspace-canvas .react-flow");if(gt){const pn=gt.getBoundingClientRect();rt=n.screenToFlowPosition({x:pn.left+pn.width*.48,y:pn.top+pn.height*.32})}}const Ge={},zt={},ln={};for(const gt of Se){const pn=se[gt.id];Ge[pn]={...G[gt.id]||{}},zt[pn]={x:rt.x+(gt.x-Ne),y:rt.y+(gt.y-Fe)};const ns=fe[gt.id];typeof(ns==null?void 0:ns.width)=="number"&&typeof(ns==null?void 0:ns.height)=="number"&&(ln[pn]={width:ns.width,height:ns.height})}const xr=new Set(Q),Bt=(Array.isArray(U.edges)?U.edges:[]).filter(gt=>xr.has(gt==null?void 0:gt.source)&&xr.has(gt==null?void 0:gt.target)).map(gt=>({source:se[gt.source],target:se[gt.target],sourceHandle:gt.sourceHandle??null,targetHandle:gt.targetHandle??null})),Ue=Nx({instances:Ge,edges:Bt,ui:{nodePositions:zt,nodeSizes:ln}},_),wr=Ue.nodes.map(gt=>({...gt,selected:!0}));T.current={...T.current,...Ue.instances},M(T.current),c(gt=>[...gt.map(pn=>({...pn,selected:!1})),...wr]),f(gt=>[...gt.map(pn=>({...pn,selected:!1})),...Ue.edges]),Le(`已添加流程片段:${S.displayName||S.id}`)},[xa,_,n,f,c,Ee]),Nt=h.useCallback(()=>{var U,G;if(gn.length<2){be("请先在 workspace 画布上选择至少两个节点。"),V("flows");return}const S=gn[0],I=gn.length===2?`${((U=S.data)==null?void 0:U.label)||S.id} 片段`:`${((G=S.data)==null?void 0:G.label)||S.id} 等 ${gn.length} 个节点`;Te({name:I,id:I.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),jt(""),we(!0),V("flows")},[gn]),jp=h.useCallback(async()=>{var Q,re;if(gn.length<2)return;const S=Pe.name.trim();if(!S){jt("请填写片段名称。");return}const I={},U={};for(const se of gn){I[se.id]={x:((Q=se.position)==null?void 0:Q.x)||0,y:((re=se.position)==null?void 0:re.y)||0};const oe=zc(se);oe&&(U[se.id]=oe)}const G=Ms.map(se=>({source:se.source,target:se.target,sourceHandle:se.sourceHandle??null,targetHandle:se.targetHandle??null}));ct(!0),jt("");try{const se=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:Pe.id,name:S,displayName:S,version:"1.0.0",description:Pe.description,snippet:{instances:fp(gn,T.current),edges:G,ui:{nodePositions:I,nodeSizes:U}}})}),oe=await se.json().catch(()=>({}));if(!se.ok||oe.ok===!1)throw new Error(oe.error||"发布流程片段失败");we(!1),Le(`流程片段已发布:${oe.id||S}`),Rs(`流程片段已发布:${oe.id||S}`),await Qi(),V("flows")}catch(se){jt(String(se.message||se))}finally{ct(!1)}},[Qi,Pe,Ms,gn,Rs]);h.useCallback(()=>{if(Ur.length===0){Le("当前 workspace 没有 display 节点");return}const S=hs.length>0?hs:Ur.map(U=>U.id),I=s.flowId?`${s.flowId} 展示页`:"AgentFlow Display";ot({title:I,layout:"gallery",nodeIds:S}),le(""),He(null),Mn(!0)},[s.flowId,hs,Ur]);const od=h.useCallback(S=>{ot(I=>{const U=Array.isArray(I.nodeIds)?I.nodeIds:[];return U.includes(S)?{...I,nodeIds:U.filter(G=>G!==S)}:{...I,nodeIds:[...U,S]}})},[]),jc=h.useCallback(async()=>{var U;const S=Ze.title.trim(),I=Array.isArray(Ze.nodeIds)?Ze.nodeIds:[];if(I.length===0){le("请选择至少一个 display 节点。");return}$n(!0),le(""),He(null);try{await kn(l,d);const G=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,title:S,layout:Ze.layout,nodeIds:I})}),Q=await G.json().catch(()=>({}));if(!G.ok||Q.ok===!1)throw new Error(Q.error||"发布展示页失败");const re=new URL(Q.url||`/display/${((U=Q.share)==null?void 0:U.id)||""}`,window.location.origin).href;He({...Q,absoluteUrl:re}),Le("展示页已生成")}catch(G){le(String(G.message||G))}finally{$n(!1)}},[Ze,d,s,l,kn]),jl=h.useCallback(async()=>{var I;const S=Array.isArray(g.nodeIds)?g.nodeIds:[];if(S.length===0){le("请先添加至少一个展示节点。"),Le("请先添加至少一个展示节点"),Jt(!0);return}$n(!0),le("");try{await kn(l,d);const U=s.flowId?`${s.flowId} 展示页`:"AgentFlow Display",G=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,title:U,layout:"canvas",nodeIds:S})}),Q=await G.json().catch(()=>({}));if(!G.ok||Q.ok===!1)throw new Error(Q.error||"生成展示链接失败");const re=new URL(Q.url||`/display/${((I=Q.share)==null?void 0:I.id)||""}`,window.location.origin).href;He({...Q,absoluteUrl:re}),rn(!0),Le("展示链接已生成")}catch(U){const G=String(U.message||U);le(G),Le(G)}finally{$n(!1)}},[g.nodeIds,d,s,l,kn]),ad=h.useCallback(async()=>{const S=de==null?void 0:de.absoluteUrl;if(!S)return;const I=await pq(S);An(I?"copied":"failed"),window.setTimeout(()=>An(""),1600)},[de==null?void 0:de.absoluteUrl]),ld=h.useCallback(S=>{c(I=>I.map(U=>U.id===S?{...U,selected:!1}:U)),Qt(I=>I===S?"":I)},[c]),to=h.useCallback(()=>{const S=Un.current;if(!S)return;const I=S.getBoundingClientRect(),U=Math.min(420,Math.max(320,I.width+160)),G=12,Q=Math.max(180,I.top-G*2),re=Math.min(560,Q);Gu({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-U-12,I.left)),top:Math.max(G,I.top-re-G),width:U,maxHeight:re,zIndex:1e4})},[]);h.useEffect(()=>{if(!Dt)return;to();const S=U=>{var Q,re;const G=U.target;(Q=Un.current)!=null&&Q.contains(G)||(re=mr.current)!=null&&re.contains(G)||Ot(!1)},I=U=>{U.key==="Escape"&&Ot(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",I),window.addEventListener("resize",to),window.addEventListener("scroll",to,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",I),window.removeEventListener("resize",to),window.removeEventListener("scroll",to,!0)}},[Dt,to]);const ry=h.useCallback(S=>{var G,Q,re;if(i==="display"){const se=[];let oe=!1;b(fe=>{var Fe,rt;const Se={...fe.nodePositions},Ne={...fe.nodeSizes};for(const Ge of S||[]){const zt=jx(Ge==null?void 0:Ge.id);if(!(!zt||!fe.nodeIds.includes(zt))){if(Ge.type==="select"){Ge.selected&&se.push(zt);continue}if(Ge.type==="position"&&Ge.position){Se[zt]={x:Ge.position.x,y:Ge.position.y},oe=!0;continue}if(Ge.type==="dimensions"&&((Fe=Ge.dimensions)!=null&&Fe.width)&&((rt=Ge.dimensions)!=null&&rt.height)){const ln=mu({width:Math.round(Number(Ge.dimensions.width)),height:Math.round(Number(Ge.dimensions.height))},{display:!0});ln&&(Ne[zt]=ln,oe=!0)}}}return oe?{...fe,nodePositions:Se,nodeSizes:Ne}:fe}),(S||[]).some(fe=>(fe==null?void 0:fe.type)==="select")&&A(se);return}if(!Ee){const se=(S||[]).filter(oe=>(oe==null?void 0:oe.type)==="select");se.length>0&&c(oe=>Mm(se,oe));return}const I=new Map;for(const se of S||[])if((se==null?void 0:se.type)==="dimensions"&&((G=se.dimensions)!=null&&G.width)&&((Q=se.dimensions)!=null&&Q.height)){const oe=l.find(Ne=>Ne.id===se.id),fe=!!Yn((re=oe==null?void 0:oe.data)==null?void 0:re.definitionId),Se=mu({width:Math.round(Number(se.dimensions.width)),height:Math.round(Number(se.dimensions.height))},{display:fe});Se&&I.set(se.id,Se)}const U=Array.from(I.keys());if(c(se=>Mm(S,se).map(oe=>{var Se;const fe=I.get(oe.id);return fe?Yn((Se=oe.data)==null?void 0:Se.definitionId)?{...oe,width:fe.width,height:fe.height,data:{...oe.data,nodeSize:fe,displaySize:fe}}:{...oe,width:fe.width,height:fe.height,data:{...oe.data,nodeSize:fe}}:oe})),U.length>0){const se=()=>U.forEach(oe=>r(oe));window.requestAnimationFrame(se),window.setTimeout(se,80)}},[l,c,r,i,Ee]),Cp=h.useCallback(S=>{if(i!=="display"){if(!Ee){const I=(S||[]).filter(U=>(U==null?void 0:U.type)==="select");I.length>0&&f(U=>Wv(I,U));return}u(S)}},[u,f,i,Ee]),Mo=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]),gr=h.useCallback(()=>{var S,I,U;if(tn){const G=Number(((S=tn.measured)==null?void 0:S.width)||tn.width||260);return{x:Number(((I=tn.position)==null?void 0:I.x)||0)+G+140,y:Number(((U=tn.position)==null?void 0:U.y)||0)}}return Mo()},[Mo,tn]),si=h.useCallback((S,I={})=>{if(!Ee)return Le("Readonly workspace"),null;if(!S)return null;const U=b0(S)||S.id,G=KT(S),Q=I.id||lq(U,l),re=Nh(S.inputs),se=Nh(S.outputs),oe={definitionId:U,...G?{marketplaceRef:G}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},label:I.label||Zm(S),role:"normal",body:I.body||"",input:I.inputs||re,output:I.outputs||se},fe={id:Q,type:pp,position:I.position||Mo(),data:{label:oe.label,definitionId:U,...G?{marketplaceRef:G}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},schemaType:UT(U,S),role:"normal",body:oe.body,inputs:oe.input,outputs:oe.output}},Se={...Uf(fe,{...T.current,[Q]:oe},_),selected:!0};return c(Ne=>[...Ne.map(Fe=>({...Fe,selected:!1})),Se]),I.openProperties&&Qt(Q),Q},[Mo,l,_,c,Ee]),ii=h.useCallback(S=>d1(S,p.current),[]),oi=h.useCallback(S=>{if(!Ee){Le("Readonly workspace");return}if(!d1(S,p.current)){Le("端口类型不匹配,已取消连线");return}O(null),c(I=>Ym(I,S)),f(I=>{const U=I.filter(G=>!(G.target===S.target&&G.targetHandle===S.targetHandle));return $f({...S,markerEnd:{type:Es.ArrowClosed}},U)})},[f,c,Ee]),Ep=h.useCallback((S,I)=>{Ee&&(F.current=oq(I,p.current),O(null))},[Ee]),Cl=h.useCallback((S,I)=>{var rt,Ge,zt,ln;if(!Ee)return;const U=F.current;if(F.current=null,!U||I!=null&&I.toNode)return;const G=aq(_,U);if(G.length===0){Le(`没有匹配 ${U.slotType} 端口的节点`);return}const Q=((Ge=(rt=S==null?void 0:S.changedTouches)==null?void 0:rt[0])==null?void 0:Ge.clientX)??(S==null?void 0:S.clientX),re=((ln=(zt=S==null?void 0:S.changedTouches)==null?void 0:zt[0])==null?void 0:ln.clientY)??(S==null?void 0:S.clientY);if(!Number.isFinite(Q)||!Number.isFinite(re))return;const se=document.querySelector(".af-workspace-canvas .react-flow");if(!se)return;const oe=se.getBoundingClientRect(),fe=320,Se=Math.min(440,104+G.length*58),Ne=Math.max(12,Math.min(Q-oe.left,oe.width-fe-12)),Fe=Math.max(12,Math.min(re-oe.top,oe.height-Se-12));O({left:Ne,top:Fe,flowPosition:n.screenToFlowPosition({x:Q,y:re}),draft:U,candidates:G,query:""})},[_,n,Ee]),_p=h.useCallback(S=>{if(!Ee){Le("Readonly workspace"),O(null);return}const I=z.current;if(!I||!(S!=null&&S.def))return;const U=si(S.def,{position:I.flowPosition});if(!U)return;const G=I.draft.handleType==="source"?{source:I.draft.nodeId,sourceHandle:I.draft.handleId,target:U,targetHandle:`input-${S.slotIndex}`}:{source:U,sourceHandle:`output-${S.slotIndex}`,target:I.draft.nodeId,targetHandle:I.draft.handleId};c(Q=>Ym(Q,G)),f(Q=>{const re=Q.filter(se=>!(se.target===G.target&&se.targetHandle===G.targetHandle));return $f({...G,markerEnd:{type:Es.ArrowClosed}},re)}),O(null)},[si,f,Ee]),ba=h.useCallback(S=>{S&&(si(S,{position:gr()}),ye(!1),ie(""))},[si,gr]),cd=h.useCallback(S=>{S&&(wa(S,gr()),ye(!1),ie(""))},[wa,gr]);h.useEffect(()=>{const S=I=>{var Se;if(I.defaultPrevented)return;const U=kT(I.target)||nq(I.target);if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="s"){I.preventDefault(),kn().catch(Ne=>Le(String(Ne.message||Ne)));return}if((I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="k"){I.preventDefault(),I.stopPropagation(),Ju(Ne=>!Ne);return}if(ma)return;if(ha){(I.key==="Escape"||Xm(I))&&(I.preventDefault(),Xi(!1));return}const G=I.key.toLowerCase(),Q=(I.metaKey||I.ctrlKey)&&G==="c",re=(I.metaKey||I.ctrlKey)&&G==="v",se=U&&Q&&sq(I.target);if(U&&!se)return;const oe=(I.metaKey||I.ctrlKey)&&!I.shiftKey&&G==="z",fe=(I.metaKey||I.ctrlKey)&&(I.shiftKey&&G==="z"||G==="y");if(oe||fe){if(ft){I.preventDefault(),I.stopPropagation(),Le("展示页布局会自动保存");return}if(!Ee){I.preventDefault(),Le("Readonly workspace");return}I.preventDefault(),I.stopPropagation();const Ne=oe?fc():bl();Le(Ne?oe?"Undo canvas change":"Redo canvas change":oe?"Nothing to undo":"Nothing to redo");return}if(Q){if(ft)return;const Ne=ar.current,Fe=(p.current||[]).some(Ge=>Ge==null?void 0:Ge.selected)?p.current:(p.current||[]).map(Ge=>Ne&&Ge.id===Ne?{...Ge,selected:!0}:Ge),rt=pT(Fe,m.current,T.current);rt&&(I.preventDefault(),I.stopPropagation(),B.current=rt,se&&typeof((Se=I.target)==null?void 0:Se.blur)=="function"&&I.target.blur(),Le(`Copied ${rt.nodes.length} node${rt.nodes.length>1?"s":""}`));return}if(re){if(ft){I.preventDefault(),I.stopPropagation();return}if(!Ee){I.preventDefault(),Le("Readonly workspace");return}const Ne=hT(B.current,p.current,m.current,T.current);Ne&&(I.preventDefault(),I.stopPropagation(),T.current=Ne.instances,M(Ne.instances),c(Ne.nodes),f(Ne.edges),Le(`Pasted ${Ne.pastedNodeIds.length} node${Ne.pastedNodeIds.length>1?"s":""}`));return}if(Xm(I)&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),Xi(!0);return}if(I.key==="a"||I.key==="A"){if(I.metaKey||I.ctrlKey){I.preventDefault(),ft?A(v.current.nodeIds):(c(Ne=>Ne.map(Fe=>({...Fe,selected:!0}))),f(Ne=>Ne.map(Fe=>({...Fe,selected:!1}))));return}if(I.altKey)return;if(ft){I.preventDefault(),Jt(!0);return}if(!Ee){I.preventDefault(),Le("Readonly workspace");return}I.preventDefault(),ye(!0);return}if((I.key==="v"||I.key==="V")&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),hl("select");return}if((I.key==="h"||I.key==="H")&&!I.metaKey&&!I.ctrlKey&&!I.altKey){I.preventDefault(),hl("pan");return}(I.key==="f"||I.key==="F")&&!I.metaKey&&!I.ctrlKey&&!I.altKey&&(I.preventDefault(),bc())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[ft,ma,bc,bl,kn,ha,f,c,fc,Ee]);const yr=h.useCallback(S=>{es(I=>{const U=new Set(I);return U.has(S)?U.delete(S):U.add(S),U})},[]),Pp=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)},[]),ji=h.useCallback((S,I)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("application/agentflow-node",I.id),S.dataTransfer.setData("text/plain",I.id)},[]),$o=h.useCallback(async(S,I)=>{const U=String((S==null?void 0:S.name)||(S==null?void 0:S.path)||"").toLowerCase(),G=U.split(".").pop(),Q=G==="html"?"display_html":G==="csv"||G==="tsv"||G==="json"&&/\b(table|data|rows|report)\b/i.test(U)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(G)?"display_image":"display_markdown",re=_.find(Fe=>Fe.id===Q);if(!re){Le("展示节点不可用");return}const se=Q==="display_image";let oe=String(S.path||"");if(!se){const Fe=Ia(s);Fe.set("path",S.path);const rt=await fetch(`/api/workspace/file?${Fe.toString()}`),Ge=await rt.json();if(!rt.ok)throw new Error(Ge.error||"读取文件失败");oe=String(Ge.content||"")}const fe=Q==="display_image"?"src":"content",Se=Nh(re.inputs).map(Fe=>Fe.name===fe?{...Fe,default:oe,value:oe}:Fe),Ne=Nh(re.outputs).map(Fe=>Fe.name===fe?{...Fe,default:oe,value:oe}:Fe);si(re,{label:S.name||"Display",body:oe,inputs:Se,outputs:Ne,position:I}),Le(`已创建展示:${S.path}`)},[si,s,_]),no=h.useCallback(S=>{if(!Ee){Le("Readonly workspace");return}$o(S,Mo()).catch(I=>Le(String(I.message||I)))},[$o,Mo,Ee]),va=h.useCallback(S=>{if(!Ee){S.preventDefault(),Le("Readonly workspace");return}const I=S.dataTransfer.getData("application/x-agentflow-workspace-file");if(I){S.preventDefault();let se;try{se=JSON.parse(I)}catch{return}if(!(se!=null&&se.path))return;const oe=n.screenToFlowPosition({x:S.clientX,y:S.clientY});$o(se,oe).catch(fe=>Le(String(fe.message||fe)));return}const U=S.dataTransfer.getData("application/agentflow-snippet");if(U){const se=ne.find(fe=>`${fe.id}@${fe.version}`===U);if(!se)return;S.preventDefault();const oe=n.screenToFlowPosition({x:S.clientX,y:S.clientY});wa(se,oe);return}const G=S.dataTransfer.getData("application/agentflow-node");if(!G)return;const Q=_.find(se=>se.id===G);if(!Q)return;S.preventDefault();const re=n.screenToFlowPosition({x:S.clientX,y:S.clientY});si(Q,{position:re})},[$o,si,ne,wa,_,n,Ee]),ud=h.useCallback(S=>{if(!Ee)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")},[Ee]),El=h.useCallback(async(S="")=>{if(!Ee){Le("Readonly workspace");return}const I=window.prompt("新文件名",S?`${S}/notes.md`:"notes.md");if(!I)return;const U=S&&!I.includes("/")?`${S}/${I}`:I;try{const G=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:U,content:""})}),Q=await G.json();if(!G.ok)throw new Error(Q.error||"创建文件失败");await fn(),es(re=>{const se=new Set(re);for(const oe of Ch(Q.path||U))se.delete(oe);return se}),Le(`已创建 ${Q.path}`)}catch(G){Le(String(G.message||G))}},[s,fn,Ee]),Et=h.useCallback(async(S="")=>{if(!Ee){Le("Readonly workspace");return}const I=window.prompt("新文件夹名",S?`${S}/docs`:"docs");if(!I)return;const U=S&&!I.includes("/")?`${S}/${I}`:I;try{const G=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:U})}),Q=await G.json();if(!G.ok)throw new Error(Q.error||"创建文件夹失败");await fn(),es(re=>{const se=new Set(re);for(const oe of Ch(Q.path||U))se.delete(oe);return Q.path&&se.delete(Q.path),se}),Le(`已创建 ${Q.path}`)}catch(G){Le(String(G.message||G))}},[s,fn,Ee]),wt=h.useCallback(async S=>{if(!Ee){Le("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})}),U=await I.json();if(!I.ok)throw new Error(U.error||"删除失败");Le(`已删除 ${U.path}`),await fn()}catch(I){Le(String(I.message||I))}},[s,fn,Ee]),Ap=h.useCallback(async()=>{if(!Ee){Le("Readonly workspace");return}const S=Kn.trim();if(!S||ts)return;const I=jh(l,d,T.current);da(""),Xu(!0),td("workspace"),ul(U=>[...U,{role:"user",text:S,at:Date.now()}]);try{await kn(l,d);const U=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:Be,selectedSkills:hr,selectedNodeIds:Oo})}),G=await U.json();if(!U.ok)throw new Error(G.error||"生成失败");const Q=String(G.content||"").trim();ul(re=>[...re,{role:"assistant",text:Q,at:Date.now()}]),await ti(),Le("AI 生成完成")}catch(U){const G=String(U.message||U);ul(Q=>[...Q,{role:"assistant",text:G,error:!0,at:Date.now()}]),Le(G)}finally{Xu(!1)}},[Be,ts,Kn,d,s,ti,l,td,kn,Oo,hr,Ee]),It=dl.find(S=>S.id===fa)||null,an=It?Array.isArray(It.messages)?It.messages:[]:ei,Ip=It?It.status==="running":ts,$s=It?It.status==="running"?`${It.label} running`:It.status==="paused"?`${It.label} paused`:It.status==="failed"?`${It.label} failed`:`${It.label} done`:ts?"Workspace agent running":ei.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} · ${Po}`:Po||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",Q7,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{t(Cm({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:()=>sd("workspace"),children:"Workspace"}),o.jsx("button",{type:"button",className:i==="display"?"af-view-switch__active":"",onClick:()=>sd("display"),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:uc}),ft?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Ht||!(de!=null&&de.absoluteUrl)&&g.nodeIds.length===0,onClick:()=>{An(""),de!=null&&de.absoluteUrl?rn(!0):jl()},title:de!=null&&de.absoluteUrl?"查看展示链接":g.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ht?"hourglass_empty":"ios_share"}),Ht?"生成中":de!=null&&de.absoluteUrl?"展示链接":"生成链接"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:ni.length===0,onClick:()=>Jt(!0),title:ni.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:()=>Xi(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Yt?" af-composer-topbar-btn--active":"")+(ts?" af-composer-topbar-btn--running":""),disabled:ft,onClick:()=>pa(S=>!S),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Ee,onClick:()=>kn().catch(S=>Le(String(S.message||S))),children:"Save"})]})]}),Ye?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:Ye}),o.jsx("button",{type:"button",onClick:()=>kt(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(!ft&&(Yt||ut)?" af-workspace-body--drawer":"")+(!ft&&Ro?" af-workspace-body--sidebar-collapsed":"")+(ft?" af-workspace-body--display-mode":""),children:[!ft&&Ro?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:()=>ye(!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:()=>lr(!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:()=>lr(!1),"aria-label":"展开侧边栏",title:(jr==null?void 0:jr.username)||(jr==null?void 0:jr.userId)||"展开侧边栏",children:Cr})]})}):null,ft?null:o.jsxs("aside",{ref:Qn,className:"af-workspace-sidebar"+(lt?" af-workspace-sidebar--resizing":""),"aria-hidden":Ro,style:{"--af-work-files-pane-height":`${Math.round(Fn)}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:()=>lr(!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:!Ee,onClick:()=>El(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Ee,onClick:()=>Et(""),"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 fn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:Zt,onChange:S=>Tr(S.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(e2,{items:kc,flowParams:s,onOpen:no,collapsedDirs:xt,onToggleDir:yr,onCreateFile:El,onCreateFolder:Et,onDelete:wt,onFileDragStart:Pp})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:Me,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=>X(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:Nt,disabled:gn.length<2,title:gn.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:["已选 ",gn.length," 节点 / ",Ms.length," 连线"]})]})}),ae?o.jsx("p",{className:"af-err af-palette-list-err",children:ae}):null,pe?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):ya.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:ya.map(S=>{const I=`${S.id}@${S.version}`,U=S.displayName||S.name||S.id,G=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:()=>wa(S),title:G,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:U}),o.jsxs("span",{className:"af-palette-card-id",children:[S.id,"@",S.version]})]})]}),G?o.jsx("span",{className:"af-palette-card-desc",children:G}):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:[Fc.map(S=>{var I;return(I=vc[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:vc[S].map(U=>{const G=u1(U.inputs,"input"),Q=u1(U.outputs,"output"),re=Sb(U),se=Vd(U);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:oe=>ji(oe,U),onClick:()=>si(U),title:re||U.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:l1(S)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:se}),se!==U.id?o.jsx("span",{className:"af-palette-card-id",children:U.id}):null]})]}),re?o.jsx("span",{className:"af-palette-card-desc",children:re}):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:[G.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[G.shown.map((oe,fe)=>o.jsxs("span",{className:"af-palette-card-port",title:c1("input",oe,fe),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(oe==null?void 0:oe.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Sx(oe,fe)})]},`in-${fe}`)),G.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",G.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,fe)=>o.jsxs("span",{className:"af-palette-card-port",title:c1("output",oe,fe),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Sx(oe,fe)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(oe==null?void 0:oe.type)}})]},`out-${fe}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},U.id)})})]},S):null}),_.length>0&&P.trim()&&Fc.every(S=>{var I;return!((I=vc[S])!=null&&I.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(Uv,{className:"af-flow-canvas af-workspace-flow"+(Lo==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ft?" af-workspace-flow--display-mode":""),nodes:ty,edges:ny,nodeTypes:Iq,onNodesChange:ry,onEdgesChange:Cp,onConnect:ft?void 0:oi,onConnectStart:ft?void 0:Ep,onConnectEnd:ft?void 0:Cl,isValidConnection:ft?void 0:ii,onNodeClick:(S,I)=>{if(ft){A([jx(I.id)]);return}$t&&Qt(I.id)},onNodeDoubleClick:(S,I)=>{S.preventDefault(),!ft&&(pa(!1),c(U=>U.map(G=>({...G,selected:G.id===I.id}))),f(U=>U.map(G=>({...G,selected:!1}))),Qt(I.id))},onPaneClick:()=>{ft?A([]):Qt("")},onDrop:ft?void 0:va,onDragOver:ft?void 0:ud,nodesDraggable:ft?!0:Ee,nodesConnectable:ft?!1:Ee,edgesReconnectable:ft?!1:Ee,deleteKeyCode:ft?null:Ee?["Backspace","Delete"]:null,selectionOnDrag:Lo==="select",panOnDrag:Lo==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(qv,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ft&&L?(()=>{var G;const S=String(L.query||"").trim().toLowerCase(),I=S?L.candidates.filter(Q=>{var re,se,oe;return[(re=Q.def)==null?void 0:re.id,Q.displayLabel,Q.description,(se=Q.slot)==null?void 0:se.name,(oe=Q.slot)==null?void 0:oe.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(S))}):L.candidates,U=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:nr((G=L.draft.slot)==null?void 0:G.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(re=>re&&{...re,query:Q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[I.map(Q=>{var oe,fe;const re=Q.displayLabel||((oe=Q.def)==null?void 0:oe.id),se=Sx(Q.slot,Q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>_p(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:re}),re!==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:U}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:nr((fe=Q.slot)==null?void 0:fe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:se})]})]},`${Q.def.id}-${Q.slotIndex}`)}),I.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ft&&!qn?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:()=>fl(!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:gn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):gn.map(S=>{var Q,re;const I=String(((Q=S.data)==null?void 0:Q.label)??S.id),U=(re=S.data)!=null&&re.definitionId?String(S.data.definitionId):"",G=U&&U!==I?`${I} · ${S.id} · ${U}`:`${I} · ${S.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:G,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:U||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:I}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>ld(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:Kn,rows:2,onChange:S=>da(S.target.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),Ap())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Ee})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:Un,type:"button",className:"af-composer-skills-button"+(hr.length>0?" af-composer-skills-button--active":""),disabled:ts||!Ee,"aria-haspopup":"listbox","aria-expanded":Dt,onClick:()=>Ot(S=>!S),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:hr.length>0?`Skills ${hr.length}`:"Skills"})]}),Dt&&!ts?$r.createPortal(o.jsx("div",{ref:mr,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:ua,children:Zn.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Ni.groups.map(S=>{const I=el(S,Zn),U=W_(S,Sc,Zn),G=Re.has(S.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(G?" 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:U==="all",disabled:I.length===0,onChange:Q=>{const re=Q.target.checked;Ts(se=>re?B_(se,I):H_(se,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,U==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":G?`展开 ${S.name}`:`收起 ${S.name}`,onClick:()=>{Qe(Q=>{const re=new Set(Q);return re.has(S.id)?re.delete(S.id):re.add(S.id),re})},children:[o.jsx("span",{children:S.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:G?"expand_more":"expand_less"})]})]}),G?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:Sc.has(Q.key),onChange:re=>{const se=re.target.checked;Ts(oe=>se?oe.includes(Q.key)?oe:[...oe,Q.key]:oe.filter(fe=>fe!==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)}),Ni.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:Ni.ungrouped.length})]}),Ni.ungrouped.map(S=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Sc.has(S.key),onChange:I=>{const U=I.target.checked;Ts(G=>U?G.includes(S.key)?G:[...G,S.key]:G.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:Be,onChange:S=>pr(S.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),Np.map(S=>o.jsx("option",{value:S.value,children:S.label},S.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(Kn.trim()&&!ts?" af-composer-send--active":"")+(ts?" af-composer-send--stop":""),disabled:ts||!Kn.trim()||!Ee,"aria-label":ts?"Running":"Send",onClick:()=>void Ap(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ts?"sync":"arrow_upward"})})]})]})]})}):ft?null:o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>fl(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!ft&&Yt?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:()=>pa(!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"+(fa==="workspace"?" af-composer-session-tab--active":""),onClick:()=>Yi("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),dl.map(S=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(fa===S.id?" af-composer-session-tab--active":"")+(S.status==="running"?" af-composer-session-tab--running":""),onClick:()=>Yi(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"+(Ip?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:$s}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(Lq,{messages:an,running:Ip,showRunningIndicator:!It})})]})}):!ft&&ut&&tn?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(PT,{draft:ut,setDraft:Nr,definitionId:String(((ro=tn.data)==null?void 0:ro.definitionId)||tn.id),systemPromptReadonly:String(((dd=tn.data)==null?void 0:dd.description)||""),modelLists:Lt,disabled:!Ee,onIdBlur:()=>xc(!0),onClose:()=>Qt(""),onPublishToMarketplace:ed,error:Js,ioSlots:{inputs:Array.isArray(ut==null?void 0:ut.inputs)?ut.inputs:[],outputs:Array.isArray(ut==null?void 0:ut.outputs)?ut.outputs:[]}})}):null,o.jsx(ST,{open:ha,onClose:()=>Xi(!1)}),o.jsx(NT,{open:ma,onClose:()=>Ju(!1),onJump:rd,nodes:wc}),Ae?$r.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:Pe.name,onChange:S=>{const I=S.target.value;Te(U=>({...U,name:I,id:U.id?U.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:Pe.id,onChange:S=>Te(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:Pe.description,onChange:S=>Te(I=>({...I,description:S.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",gn.length," 个节点和 ",Ms.length," 条内部连线。"]}),tt?o.jsx("div",{className:"af-flow-snippet-error",children:tt}):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:it||!Pe.name.trim(),onClick:()=>void jp(),children:it?"发布中...":"发布"})]})]})}),document.body):null,vn?$r.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:()=>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-flow-snippet-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{type:"text",value:Ze.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:Ze.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:Ur.map(S=>{var U,G;const I=Array.isArray(Ze.nodeIds)&&Ze.nodeIds.includes(S.id);return o.jsxs("label",{className:"af-display-share-node-row",children:[o.jsx("input",{type:"checkbox",checked:I,onChange:()=>od(S.id)}),o.jsxs("span",{className:"af-display-share-node-row__main",children:[o.jsx("strong",{children:((U=S.data)==null?void 0:U.label)||S.id}),o.jsxs("small",{children:[Yn((G=S.data)==null?void 0:G.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:()=>void ad(),children:sn==="copied"?"已复制":sn==="failed"?"复制失败":"复制"})]}):null,Wn?o.jsx("div",{className:"af-flow-snippet-error",children:Wn}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Mn(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Ht||!Array.isArray(Ze.nodeIds)||Ze.nodeIds.length===0,onClick:()=>void jc(),children:Ht?"生成中...":"生成链接"})]})]})}),document.body):null,Xt?$r.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:()=>{An(""),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:()=>void ad(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:sn==="copied"?"check":"content_copy"}),sn==="copied"?"已复制":sn==="failed"?"复制失败":"复制"]})]}):o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),Wn?o.jsx("div",{className:"af-flow-snippet-error",children:Wn}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{An(""),rn(!1)},children:"关闭"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Ht||g.nodeIds.length===0,onClick:()=>void jl(),children:Ht?"生成中...":de!=null&&de.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,Sr?$r.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:()=>Jt(!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:mn,onChange:S=>Vn(S.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),o.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":In.length||1},children:Sn.length>0?In.map((S,I)=>o.jsx("div",{className:"af-display-picker-column",children:S.map(Nl)},`display-picker-column-${I}`)):o.jsx("div",{className:"af-display-picker-empty",children:ni.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:()=>Jt(!1),children:"完成"})})]})}),document.body):null,!ft&&or?$r.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>ye(!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":Ie==="nodes",className:"af-workspace-quick-add__tab"+(Ie==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>nt("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":Ie==="flows",className:"af-workspace-quick-add__tab"+(Ie==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>nt("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:To,value:Ct,onChange:S=>ie(S.target.value),onKeyDown:S=>{if(S.key==="Escape")S.preventDefault(),ye(!1);else if(S.key==="ArrowDown"){S.preventDefault();const I=Ie==="flows"?kl.length:vl.length;et(U=>Math.min(Math.max(0,I-1),U+1))}else S.key==="ArrowUp"?(S.preventDefault(),et(I=>Math.max(0,I-1))):S.key==="Tab"?(S.preventDefault(),nt(I=>I==="nodes"?"flows":"nodes")):S.key==="Enter"&&(S.preventDefault(),Ie==="flows"?cd(kl[_e]||kl[0]):ba(vl[_e]||vl[0]))},placeholder:Ie==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ie==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:Ie==="flows"?kl.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:pe?"正在加载流程片段...":ae||"没有匹配的流程片段"}):kl.map((S,I)=>{const U=S.displayName||S.name||S.id,G=S.snippet&&typeof S.snippet=="object"?S.snippet.instances:null,Q=S.snippet&&typeof S.snippet=="object"?S.snippet.edges:null,re=Number.isFinite(Number(S.nodeCount))?Number(S.nodeCount):Object.keys(G||{}).length,se=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===_e?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>et(I),onClick:()=>cd(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:U}),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||`${re} 节点 / ${se} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${S.id}@${S.version}`)}):vl.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):vl.map((S,I)=>{const U=Wd(S),G=Vd(S),Q=Sb(S);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(I===_e?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>et(I),onClick:()=>ba(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:l1(U)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:G}),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:U})]},S.id)})})]})}),document.body):null]})]})}function Uq(){return o.jsx(Fg,{children:o.jsx(Vq,{})})}function Kq(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 qq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function t2(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 Yq(e){const t=t2(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 n2(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 Gq(e,t){const n=String(e||"").trim();return n?n2(n,t):""}function Xq({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 Jq({node:e,shareId:t,style:n}){const r=Kq(e),s=e.kind==="html"?t2(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:qq(e.kind)}),o.jsx("strong",{children:e.label||e.id}),o.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),o.jsx(Xq,{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:Yq(s)}):null,e.kind==="image"?o.jsx("img",{src:n2(s,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?o.jsx("div",{className:"af-public-display-markdown",children:o.jsx(y0,{content:s,resolveSrc:a=>Gq(a,t)})}):null,e.kind==="chart"?o.jsx(w0,{content:s}):null,e.kind==="table"?o.jsx(x0,{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 Qq({data:e}){return o.jsx(Jq,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const Zq={publicDisplay:Qq};function eY(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 r2(){var a;const{path:e}=Co(),t=h.useMemo(()=>eY(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(Fg,{children:o.jsx(Uv,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:Zq,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(qv,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const vt=e=>typeof e=="string",Id=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},x1=e=>e==null?"":""+e,tY=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},nY=/###/g,w1=e=>e&&e.indexOf("###")>-1?e.replace(nY,"."):e,b1=e=>!e||vt(e),uf=(e,t,n)=>{const r=vt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(b1(e))return{};const i=w1(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return b1(e)?{}:{obj:e,k:w1(r[s])}},v1=(e,t,n)=>{const{obj:r,k:s}=uf(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=uf(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=uf(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},rY=(e,t,n,r)=>{const{obj:s,k:i}=uf(e,t,Object);s[i]=s[i]||[],s[i].push(n)},tg=(e,t)=>{const{obj:n,k:r}=uf(e,t);if(n)return n[r]},sY=(e,t,n)=>{const r=tg(e,n);return r!==void 0?r:tg(t,n)},s2=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?vt(e[r])||e[r]instanceof String||vt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):s2(e[r],t[r],n):e[r]=t[r]);return e},Mc=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var iY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const oY=e=>vt(e)?e.replace(/[&<>"'\/]/g,t=>iY[t]):e;class aY{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 lY=[" ",",","?","!",";"],cY=new aY(20),uY=(e,t,n)=>{t=t||"",n=n||"";const r=lY.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=cY.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},jb=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},ng=e=>e&&e.replace("_","-"),dY={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 rg{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||dY,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:(vt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new rg(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new rg(this.logger,t)}}var yo=new rg;class Kg{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 k1 extends Kg{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):vt(r)&&i?l.push(...r.split(i)):l.push(r)));const c=tg(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!vt(r)?c:jb(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),v1(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)(vt(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=tg(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?s2(c,r,i):c={...c,...r},v1(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 i2={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 S1={};class sg extends Kg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),tY(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=yo.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&&!uY(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:vt(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:vt(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=!vt(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&w&&v.indexOf(b)<0&&!(vt(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&&vt(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&&!vt(n.count),$=sg.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 X=$&&P!==p?P:W;this.options.missingKeyHandler?this.options.missingKeyHandler(_,c,R,X,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,c,R,X,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=vt(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&&!vt(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=vt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=i2.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 vt(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&&!vt(n.count),m=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(vt(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,!S1[`${b[0]}-${v}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(S1[`${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&&!vt(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 Cx=e=>e.charAt(0).toUpperCase()+e.slice(1);class N1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=yo.create("languageUtils")}getScriptPartFromCode(t){if(t=ng(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=ng(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(vt(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]=Cx(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]=Cx(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Cx(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)),vt(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 vt(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))):vt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let fY=[{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}],pY={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 hY=["v1","v2","v3"],mY=["v4"],j1={zero:0,one:1,two:2,few:3,many:4,other:5},gY=()=>{const e={};return fY.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:pY[t.fc]}})}),e};class yY{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=yo.create("pluralResolver"),(!this.options.compatibilityJSON||mY.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=gY(),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=ng(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)=>j1[s]-j1[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!hY.includes(this.options.compatibilityJSON)}}const C1=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=sY(e,t,n);return!i&&s&&vt(n)&&(i=jb(e,n,r),i===void 0&&(i=jb(t,n,r))),i},Ex=e=>e.replace(/\$/g,"$$$$");class xY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=yo.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:oY,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?Mc(i):a||"{{",this.suffix=l?Mc(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?Mc(p):m||Mc("$t("),this.nestingSuffix=g?Mc(g):b||Mc(")"),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=C1(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(C1(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=>Ex(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?Ex(this.escape(m)):Ex(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=vt(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!vt(a)&&!this.useRawValueToEscape&&(a=x1(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&&!vt(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&&!vt(i))return i;vt(i)||(i=x1(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 wY=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}},$c=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(ng(r),s),t[a]=l),l(n)}};class bY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=yo.create("formatter"),this.options=t,this.formats={number:$c((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:$c((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:$c((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:$c((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:$c((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()]=$c(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}=wY(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 vY=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class kY extends Kg{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=yo.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=>{rY(c.loaded,[i],a),vY(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();vt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),vt(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 E1=()=>({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]),vt(e[1])&&(t.defaultValue=e[1]),vt(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}}),_1=e=>(vt(e.ns)&&(e.ns=[e.ns]),vt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),vt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Eh=()=>{},SY=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Kf extends Kg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=_1(t),this.services={},this.logger=yo,this.modules={external:[]},SY(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&&(vt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=E1();this.options={...s,...this.options,..._1(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?yo.init(i(this.modules.logger),this.options):yo.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=bY);const u=new N1(this.options);this.store=new k1(this.options.resources,this.options);const p=this.services;p.logger=yo,p.resourceStore=this.store,p.languageUtils=u,p.pluralResolver=new yY(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 xY(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new kY(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 sg(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=Eh),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=Id(),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]:Eh;const s=vt(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=Id();return typeof t=="function"&&(r=t,t=void 0),typeof n=="function"&&(r=n,n=void 0),t||(t=this.languages),n||(n=this.options.ns),r||(r=Eh),this.services.backendConnector.reload(t,n,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"&&i2.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=Id();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=vt(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 vt(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=Id();return this.options.ns?(vt(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=Id();vt(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 N1(E1());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 Kf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Eh;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new Kf(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 k1(this.store.data,s),i.services.resourceStore=i.store),i.translator=new sg(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 Br=Kf.createInstance();Br.createInstance=Kf.createInstance;Br.createInstance;Br.dir;Br.init;Br.loadResources;Br.reloadResources;Br.use;Br.changeLanguage;Br.getFixedT;Br.t;Br.exists;Br.setDefaultNamespace;Br.hasLoadedNamespace;Br.loadNamespaces;Br.loadLanguages;function NY(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qf(e){"@babel/helpers - typeof";return qf=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},qf(e)}function jY(e,t){if(qf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(qf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function CY(e){var t=jY(e,"string");return qf(t)=="symbol"?t:t+""}function EY(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,CY(r.key),r)}}function _Y(e,t,n){return t&&EY(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var o2=[],PY=o2.forEach,AY=o2.slice;function IY(e){return PY.call(AY.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var P1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,TY=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(!P1.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!P1.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},A1={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=TY(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)}},RY={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=A1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&A1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},LY={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}},Td=null,I1=function(){if(Td!==null)return Td;try{Td=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Td=!1}return Td},OY={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&I1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&I1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Rd=null,T1=function(){if(Rd!==null)return Rd;try{Rd=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Rd=!1}return Rd},MY={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&T1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&T1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},$Y={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}},DY={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}},FY={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}},zY={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]}},a2=!1;try{document.cookie,a2=!0}catch{}var l2=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];a2||l2.splice(1,1);function BY(){return{order:l2,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var c2=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};NY(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return _Y(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=IY(r,this.options||{},BY()),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(RY),this.addDetector(LY),this.addDetector(OY),this.addDetector(MY),this.addDetector($Y),this.addDetector(DY),this.addDetector(FY),this.addDetector(zY)}},{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)}))}}])}();c2.type="languageDetector";const HY={name:"AgentFlow",tagline:"AI Workflow Orchestration"},WY={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},VY={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"},UY={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},KY={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},qY={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},YY={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},GY={app:HY,nav:WY,common:VY,status:UY,nodeTypes:KY,engine:qY,links:YY},XY="Flow Editor",JY="Nodes",QY="Edges",ZY="Properties",eG={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"},tG={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}}"},nG={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},rG={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},sG={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"},iG={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)"},oG={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},aG={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},lG={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},cG={node:"Node",text:"Text",file:"File",bool:"Boolean"},uG={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"},dG={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"},fG={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},pG={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."},hG={mainNav:"Main Navigation"},mG={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'},gG={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}}"},yG={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"},xG={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},wG={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}}"},bG={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"},vG={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"},kG={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"},SG={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"},NG={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"},jG={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},CG={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},EG={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"},_G={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."},PG={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},AG={save:"Save",cancel:"Cancel"},IG={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},TG={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},RG={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"},LG={title:XY,nodes:JY,edges:QY,properties:ZY,node:eG,nodeProps:tG,actions:nG,panel:rG,palette:sG,pipeline:iG,status:oG,roles:aG,phases:lG,types:cG,runContext:uG,shortcuts:dG,jumpPalette:fG,emptyCanvas:pG,sidebar:hG,validation:mG,composer:gG,topbar:yG,palette2:xG,run:wG,fileEdit:bG,settings:vG,schedule:kG,history:SG,nodePropsError:NG,placeholder:jG,time:CG,userCheck:EG,userAsk:_G,toolPrint:PG,provideEdit:AG,runParams:IG,runPreset:TG,runConfig:RG},OG="Settings",MG={engine:"Engine Settings",preferences:"Global Preferences"},$G={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)."},DG={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..."}},FG={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."},zG={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."},BG={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)"},HG={title:"User Allowlist",description:"Only controls which usernames may register or sign in. Users set their own password on first sign-in.",enabled:"Allowlist enabled",open:"Open registration",refreshing:"Refreshing...",saving:"Saving...",file:"File",fileList:"File allowlist",envList:"Environment allowlist",readonly:"Read-only",userCount:"{{count}} users",remove:"Remove {{username}}",emptyFile:"No file allowlist configured. If env allowlist is also empty, every username can register.",emptyEnv:"AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS is not configured",unionHint:"The file allowlist and env allowlist are combined. This only stores usernames, never passwords.",add:"Add"},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:OG,crumb:MG,workspace:$G,cursor:DG,opencode:FG,claudeCode:zG,env:BG,allowlist: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:"用户白名单",description:"只控制 username 是否允许注册或登录,密码由用户首次登录时自行设置。",enabled:"白名单已启用",open:"开放注册",refreshing:"刷新中...",saving:"保存中...",file:"文件",fileList:"文件白名单",envList:"环境变量白名单",readonly:"只读",userCount:"{{count}} 个用户",remove:"删除 {{username}}",emptyFile:"未配置文件白名单;如果环境变量也为空,则所有用户可注册。",emptyEnv:"未配置 AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS",unionHint:"文件白名单与环境变量白名单取并集;这里只会保存用户名,不保存密码。",add:"添加"},NZ={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},jZ={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},CZ={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},EZ={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},_Z={title:gZ,crumb:yZ,workspace:xZ,cursor:wZ,opencode:bZ,claudeCode:vZ,env:kZ,allowlist:SZ,system:NZ,shortcuts:jZ,language:CZ,onboarding:EZ},PZ={thinking:"思考",result:"结果",reply:"回复",error:"错误"},AZ={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},IZ={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},TZ={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},RZ={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},LZ={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},OZ={aiLabels:PZ,placeholders:AZ,actions:IZ,labels:TZ,tooltips:RZ,rightPanel:LZ},MZ="项目",$Z="全部",DZ="已归档",FZ="Nodes",zZ="我的 Nodes",BZ="我的流程",HZ="Skills",WZ="活跃项目",VZ="已归档流水线",UZ="全局 Nodes",KZ="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",qZ="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",YZ="全局 Skills",GZ="创建新项目",XZ="新建流水线",JZ="搜索流水线…",QZ="搜索 nodes…",ZZ="搜索流程片段…",eee="搜索 skills…",tee="刷新资源",nee="加载流水线列表…",ree="加载全局资源…",see="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",iee="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",oee="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",aee="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",lee="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",cee="流程运行时的可执行积木",uee="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",dee="已发布的本地节点包",fee="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",pee="已发布的流程片段",hee="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",mee="Composer/Agent 的操作指南",gee="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",yee="暂无归档项目。",xee="暂无未归档流水线;已归档项在 Archived 标签中查看。",wee="暂无可用全局 nodes。",bee="暂无已发布的 marketplace nodes。",vee="暂无已发布的流程片段。可在画布中选中多个节点后发布。",kee="暂无可用 skills。",See="暂无描述。",Nee="未找到与「{{query}}」匹配的 node。",jee="未找到与「{{query}}」匹配的流程片段。",Cee="未找到与「{{query}}」匹配的 skill。",Eee="{{inputs}} in / {{outputs}} out",_ee="流程片段",Pee="{{nodes}} 节点 / {{edges}} 连线",Aee="Skill",Iee="Node 详情",Tee="流程片段详情",Ree="Skill 详情",Lee="类型",Oee="来源",Mee="包",$ee="版本",Dee="路径",Fee="可编辑",zee="只读",Bee="可编辑",Hee="Schema",Wee="输入",Vee="输出",Uee="Runtime",Kee="节点内容",qee="Files",Yee="Usage",Gee="暂无 runtime manifest。",Xee="暂无节点正文或 README。",Jee="暂无可预览文件。",Qee="请选择文件查看内容。",Zee="二进制文件暂不支持预览。",ete="文件较大,仅显示前 256KB。",tte="暂未发现使用此 node 的流水线。",nte="节点管理",rte="删除节点版本",ste="删除中…",ite="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",ote="确定删除 {{id}}@{{version}}?此操作不可撤销。",ate="已删除 {{id}}@{{version}}。",lte="仍有 {{count}} 个 Flow 使用它。",cte="流程片段管理",ute="删除流程片段",dte="删除中…",fte="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",pte="确定删除 {{id}}@{{version}}?此操作不可撤销。",hte="已删除 {{id}}@{{version}}。",mte="无槽位",gte="作用",yte="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",xte="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",wte="规模",bte="流程预览",vte="连线",kte="片段 JSON",Ste="还有 {{count}} 条连线",Nte="暂无可预览节点。",jte="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Cte="SKILL.md 预览",Ete="暂无可预览内容。",_te="请选择一个资源查看详情。",Pte="未能加载流水线列表。",Ate="当前工作区暂无流水线。",Ite="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Tte="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Rte="最近打开或最近运行",Lte="暂无打开或运行记录",Ote="暂无与关键词匹配的最近记录",Mte="最近运行",$te="最近打开",Dte={builtin:"内置",workspace:"工作区",user:"用户"},Fte={flow:"Flow",global:"Global",marketplace:"Marketplace"},zte={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Bte={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Hte="打开以在节点画布中编辑此流水线。",Wte={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Vte={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:"关闭"},Ute={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Kte={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},qte={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Yte={title:MZ,all:$Z,archived:DZ,nodes:FZ,myNodes:zZ,myFlows:BZ,skills:HZ,activeProjects:WZ,archivedPipelines:VZ,globalNodes:UZ,myNodesHint:KZ,myFlowsHint:qZ,globalSkills:YZ,createNew:GZ,newPipeline:XZ,searchPipelines:JZ,searchNodes:QZ,searchFlows:ZZ,searchSkills:eee,refreshResources:tee,loadingPipelines:nee,loadingResources:ree,filterResult:see,archivedHint:iee,activeHint:oee,nodesHint:aee,skillsHint:lee,nodesPurposeTitle:cee,nodesPurposeDesc:uee,myNodesPurposeTitle:dee,myNodesPurposeDesc:fee,myFlowsPurposeTitle:pee,myFlowsPurposeDesc:hee,skillsPurposeTitle:mee,skillsPurposeDesc:gee,noArchived:yee,noActive:xee,noNodes:wee,noMyNodes:bee,noMyFlows:vee,noSkills:kee,noDescription:See,noNodeMatch:Nee,noFlowSnippetMatch:jee,noSkillMatch:Cee,nodeSlots:Eee,flowSnippet:_ee,flowSnippetNodes:Pee,skill:Aee,nodeDetail:Iee,flowDetail:Tee,skillDetail:Ree,detailType:Lee,detailSource:Oee,detailPackage:Mee,detailVersion:$ee,detailPath:Dee,detailEditable:Fee,readOnly:zee,editable:Bee,nodeSchema:Hee,nodeInputs:Wee,nodeOutputs:Vee,nodeRuntime:Uee,nodeBody:Kee,nodeFiles:qee,nodeUsage:Yee,noRuntimeManifest:Gee,noNodeBody:Xee,noNodeFiles:Jee,selectNodeFile:Qee,binaryFile:Zee,fileTruncated:ete,noNodeUsage:tte,myNodeManagement:nte,deleteMyNode:rte,deletingMyNode:ste,deleteMyNodeHint:ite,deleteMyNodeConfirm:ote,deleteMyNodeSuccess:ate,deleteMyNodeUsedBy:lte,myFlowManagement:cte,deleteMyFlow:ute,deletingMyFlow:dte,deleteMyFlowHint:fte,deleteMyFlowConfirm:pte,deleteMyFlowSuccess:hte,noSlots:mte,resourceMeaning:gte,nodesMeaning:yte,myFlowsMeaning:xte,flowSnippetScale:wte,flowSnippetPreview:bte,flowSnippetEdges:vte,flowSnippetJson:kte,flowSnippetMoreEdges:Ste,noFlowSnippetPreview:Nte,skillsMeaning:jte,skillPreview:Cte,skillPreviewEmpty:Ete,selectResource:_te,loadFailed:Pte,noPipelines:Ate,emptyHint:Ite,noMatch:Tte,recentActivity:Rte,noRecentActivity:Lte,noMatchRecent:Ote,recentRun:Mte,recentOpen:$te,sourceBadge:Dte,resourceSource:Fte,resourceFilter:zte,nodeDetailTabs:Bte,defaultCardDesc:Hte,hubCard:Wte,newPipelineModal:Vte,importModal:Ute,deleteModal:Kte,archiveModal:qte},Gte="返回",Xte="下一步",Jte="跳过",Qte="完成",Zte="开始创建",ene={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
192
+
193
+ 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
194
+
195
+ 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},tne={intro:`现在进入流程编辑器。
196
+
197
+ 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
198
+
199
+ 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
200
+
201
+ 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
202
+
203
+ 左侧节点面板可以自由拖拽、删除和调整连接。`},nne={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},rne={back:Gte,next:Xte,skip:Jte,done:Qte,startCreate:Zte,projects:ene,flow:tne,newPipeline:nne},sne={en:{common:GY,flow:LG,settings:qG,composer:eX,project:pQ,onboarding:kQ},zh:{common:AQ,flow:mZ,settings:_Z,composer:OZ,project:Yte,onboarding:rne}};Br.use(c2).use(sM).init({resources:sne,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 ine=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function one(e){return Br.changeLanguage(e)}const Cb="agentflow-settings-opencode-plan-v1";function _x(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 u2(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function ane(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ol(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()||u2(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!i||n.push({id:a,key:s,value:i,scope:c})}return n}function R1(e){return Ol(e).map(({key:t,value:n})=>({key:t,value:n}))}function L1(){try{return localStorage.getItem(Cb)??""}catch{return""}}function lne(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function O1(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 cne({authUser:e}){const{t,i18n:n}=Pn(["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,X]=h.useState(!1),[Z,V]=h.useState(""),[ne,ue]=h.useState([]),[pe,ge]=h.useState([]),[ae,be]=h.useState(""),[Ae,we]=h.useState(""),[Pe,Te]=h.useState(!1),[it,ct]=h.useState(!1),[tt,jt]=h.useState(""),Ye=h.useRef(null),kt=h.useRef(!1),nn=h.useRef(!1),vn=h.useRef(""),Mn=h.useCallback(async()=>{l("");try{const ie=await fetch("/api/ui-context");if(!ie.ok)throw new Error("HTTP "+ie.status);const _e=await ie.json();i(typeof _e.workspaceRoot=="string"?_e.workspaceRoot:"")}catch(ie){l(String(ie.message||ie)),i("")}},[]),Ht=h.useCallback(async()=>{u(""),m(!0);try{const ie=await fetch("/api/model-lists");if(!ie.ok)throw new Error("HTTP "+ie.status);const _e=await ie.json();d(_x(_e))}catch(ie){u(String(ie.message||ie))}finally{m(!1)}},[]),$n=h.useCallback(async()=>{A("");try{const ie=await fetch("/api/user-env"),_e=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof _e.error=="string"?_e.error:"HTTP "+ie.status);const et=Ol(Array.isArray(_e.env)?_e.env:[],"user").map(ar=>({...ar,scope:"user"})),Qt=[...e!=null&&e.isAdmin?Ol(Array.isArray(_e.globalEnv)?_e.globalEnv:[],"global").map(ar=>({...ar,scope:"global"})):[],...et];vn.current=JSON.stringify(Qt),w(Qt)}catch(ie){w([]),A(String(ie.message||ie))}finally{nn.current=!0}},[e==null?void 0:e.isAdmin]),Wn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){X(!0),V("");try{const ie=await fetch("/api/feedback"),_e=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof _e.error=="string"?_e.error:"HTTP "+ie.status);R(Array.isArray(_e.feedback)?_e.feedback:[])}catch(ie){V(String(ie.message||ie))}finally{X(!1)}}},[e==null?void 0:e.isAdmin]),le=h.useCallback(async()=>{if(e!=null&&e.isAdmin){Te(!0),jt("");try{const ie=await fetch("/api/admin/user-allowlist"),_e=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof _e.error=="string"?_e.error:"HTTP "+ie.status);const et=_e.allowlist&&typeof _e.allowlist=="object"?_e.allowlist:{};ue(Array.isArray(et.fileUsers)?et.fileUsers.map(String):[]),ge(Array.isArray(et.envUsers)?et.envUsers.map(String):[]),be(typeof et.path=="string"?et.path:"")}catch(ie){jt(String(ie.message||ie))}finally{Te(!1)}}},[e==null?void 0:e.isAdmin]),de=h.useCallback(async ie=>{if(e!=null&&e.isAdmin){ct(!0),jt("");try{const _e=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ie})}),et=await _e.json().catch(()=>({}));if(!_e.ok)throw new Error(typeof et.error=="string"?et.error:"HTTP "+_e.status);const $t=et.allowlist&&typeof et.allowlist=="object"?et.allowlist:{};ue(Array.isArray($t.fileUsers)?$t.fileUsers.map(String):[]),ge(Array.isArray($t.envUsers)?$t.envUsers.map(String):[]),be(typeof $t.path=="string"?$t.path:"")}catch(_e){jt(String(_e.message||_e))}finally{ct(!1)}}},[e==null?void 0:e.isAdmin]),He=h.useCallback(async ie=>{const _e=Ol(ie),et=_e.filter(Qt=>Qt.scope!=="global"),$t=_e.filter(Qt=>Qt.scope==="global");$(!0),A("");try{const Qt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:R1(et),...e!=null&&e.isAdmin?{globalEnv:R1($t)}:{}})}),ar=await Qt.json().catch(()=>({}));if(!Qt.ok)throw new Error(typeof ar.error=="string"?ar.error:"HTTP "+Qt.status);const ut=Ol(Array.isArray(ar.env)?ar.env:[],"user").map(Js=>({...Js,scope:"user"})),Hr=[...e!=null&&e.isAdmin?Ol(Array.isArray(ar.globalEnv)?ar.globalEnv:[],"global").map(Js=>({...Js,scope:"global"})):[],...ut];vn.current=JSON.stringify(Hr),w(Hr)}catch(Qt){A(String(Qt.message||Qt))}finally{$(!1)}},[e==null?void 0:e.isAdmin]),Ze=h.useCallback(async()=>{u(""),m(!0);try{const ie=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:E.trim()})}),_e=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof _e.error=="string"?_e.error:"HTTP "+ie.status);d(_x(_e.modelLists))}catch(ie){u(String(ie.message||ie))}finally{m(!1)}},[E]);h.useEffect(()=>{Mn(),Ht(),$n(),e!=null&&e.isAdmin&&(Wn(),le()),(async()=>{try{const ie=await fetch("/api/agentflow-config");if(ie.ok){const _e=await ie.json(),et=typeof _e.opencodeProvider=="string"?_e.opencodeProvider:"";D(et),Ye.current=et;try{localStorage.setItem(Cb,et)}catch{}}else{const _e=L1();D(_e),Ye.current=_e}}catch{const ie=L1();D(ie),Ye.current=ie}finally{kt.current=!0}})()},[e==null?void 0:e.isAdmin,Mn,Wn,Ht,le,$n]),h.useEffect(()=>{if(!nn.current||JSON.stringify(Ol(k))===vn.current)return;const _e=setTimeout(()=>{He(k)},350);return()=>clearTimeout(_e)},[k,He]),h.useEffect(()=>{if(!kt.current)return;const ie=E.trim();if(ie===Ye.current)return;const _e=setTimeout(()=>{(async()=>{b(!0),y("");try{const et=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ie})}),$t=await et.json().catch(()=>({}));if(!et.ok)throw new Error(typeof $t.error=="string"?$t.error:"HTTP "+et.status);Ye.current=ie;try{localStorage.setItem(Cb,ie)}catch{}$t.modelLists&&d(_x($t.modelLists))}catch(et){y(String(et.message||et))}finally{b(!1)}})()},450);return()=>clearTimeout(_e)},[E]);const ot=c.cursor.length>0,Xt=c.opencode.length>0,rn=c.claudeCode.length>0,sn=ne.length>0||pe.length>0,An=h.useCallback(()=>{var ie;s&&((ie=navigator.clipboard)==null||ie.writeText(s))},[s]),Sr=h.useCallback(()=>{const ie=B.trim(),_e=z;if(ie){if(!ane(ie)){A(t("settings:env.invalidKey"));return}w(et=>[...et,{id:u2(),key:ie,value:_e,scope:e!=null&&e.isAdmin&&O?"global":"user"}]),F(""),L("")}},[e==null?void 0:e.isAdmin,O,B,z,t]),Jt=h.useCallback(ie=>{w(_e=>_e.filter(et=>et.id!==ie))},[]),mn=h.useCallback((ie,_e)=>{w(et=>et.map($t=>$t.id===ie?{...$t,..._e}:$t))},[]),Vn=h.useCallback(ie=>{T(_e=>{const et=new Set(_e);return et.has(ie)?et.delete(ie):et.add(ie),et})},[]),or=h.useCallback(()=>{const ie=Ae.trim();if(!ie)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ie)){jt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(ne.map(et=>String(et||"").trim().toLowerCase())).has(ie.toLowerCase())){we("");return}we(""),de([...ne,ie])},[Ae,ne,de]),ye=h.useCallback(ie=>{const _e=String(ie||"").trim().toLowerCase();_e&&de(ne.filter(et=>String(et||"").trim().toLowerCase()!==_e))},[ne,de]),Ie=h.useCallback(ie=>{const _e=ie.target.value;one(_e)},[]),nt=ie=>{const _e=O1(ie,r);return _e?t("settings:cursor.modelList.fetchedAt",{time:_e}):t("settings:cursor.modelList.never")},Ct=ie=>O1(ie,r)||String(ie||"");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:An,"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})+" · "+nt(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:()=>Ze(),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"+(Xt?" af-set-badge--ok":" af-set-badge--err"),children:t(Xt?"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:ie=>D(ie.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]}),Xt?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})+" · "+nt(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:()=>Ze(),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})+" · "+nt(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:()=>Ze(),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(ie=>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:ie.key,onChange:_e=>mn(ie.id,{key:_e.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:ie.scope!=="global"?"is-active":"",onClick:()=>mn(ie.id,{scope:"user"}),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:ie.scope==="global"?"is-active":"",onClick:()=>mn(ie.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(ie.id)?"text":"password",value:ie.value,onChange:_e=>mn(ie.id,{value:_e.target.value}),placeholder:lne(ie.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),o.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>Vn(ie.id),"aria-label":M.has(ie.id)?"Hide value":"Show value",children:o.jsx("span",{className:"material-symbols-outlined",children:M.has(ie.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:ie.key}),onClick:()=>Jt(ie.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ie.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:ie=>F(ie.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:ie=>L(ie.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:Sr,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:t("settings:allowlist.title")}),o.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),o.jsx("span",{className:"af-set-badge"+(sn?" af-set-badge--ok":" af-set-badge--muted"),children:t(sn?"settings:allowlist.enabled":"settings:allowlist.open")}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void le(),disabled:Pe,children:t(Pe?"settings:allowlist.refreshing":"common:common.refresh")})]}),tt?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:tt}):null,ae?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",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:t("settings:allowlist.fileList")}),o.jsx("span",{children:it?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:ne.length})})]}),o.jsx("div",{className:"af-allowlist-list",children:ne.length>0?ne.map(ie=>o.jsxs("div",{className:"af-allowlist-row",children:[o.jsx("span",{className:"af-allowlist-name",children:ie}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>ye(ie),"aria-label":t("settings:allowlist.remove",{username:ie}),disabled:it,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie)):o.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),o.jsxs("div",{className:"af-allowlist-add",children:[o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:Ae,onChange:ie=>we(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&or()},placeholder:"username",autoComplete:"off"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:or,disabled:it||!Ae.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),o.jsxs("div",{className:"af-allowlist-side",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.envList")}),o.jsx("span",{children:t("settings:allowlist.readonly")})]}),o.jsx("div",{className:"af-allowlist-env-list",children:pe.length>0?pe.map(ie=>o.jsx("code",{children:ie},ie)):o.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):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 Wn(),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(ie=>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:ie.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:ie.username||ie.userId||"unknown"}),o.jsx("span",{children:Ct(ie.createdAt)})]})]}),ie.contact?o.jsx("span",{className:"af-feedback-item__contact",children:ie.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:ie.content}),ie.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:ie.pageUrl}):null]},ie.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:Ie,"aria-label":t("settings:language.description"),children:ine.map(ie=>o.jsxs("option",{value:ie.code,children:[ie.flag," ",ie.name]},ie.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function une(){const{navigate:e}=Co(),[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 d2(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function M1(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:d2(),key:r,value:String(s??""),private:n.has(r)}))}function $1(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 Zh(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:M1(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:M1(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 Px(){return Zh({name:"",raw:{command:""}})}function dne(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=$1(e.envRows),s=$1(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 D1(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function F1(e){return e?e.ok?"ok":"error":"unknown"}function z1({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:d2(),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 fne(){var O;const[e,t]=h.useState(""),[n,r]=h.useState([]),[s,i]=h.useState(Px),[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(Zh(T.find(E=>E.name===a)))}catch(W){y(String(W.message||W))}finally{d(!1)}},[a]);h.useEffect(()=>{C()},[C]);const $=()=>{l(""),i(Px()),w(""),y("")},B=W=>{l(W.name),i(Zh(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=dne(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(Zh(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(Px()),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--${F1(g[W.name])}`,children:D1(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--${F1(A)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:D1(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(z1,{title:"Headers",rows:s.headerRows,onChange:W=>i(M=>({...M,headerRows:W})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(z1,{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 f2(e){return t=>typeof t===e}var pne=f2("function"),hne=e=>e===null,B1=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",H1=e=>!mne(e)&&!hne(e)&&(pne(e)||typeof e=="object"),mne=f2("undefined");function gne(e,t,n){return Sne(n,e,t)?!0:(Nne(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?yne(e,t,n):e instanceof Map&&t instanceof Map?bne(e,t,n):e instanceof Set&&t instanceof Set?kne(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?xne(e,t):B1(e)&&B1(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?wne(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():vne(e,t,n))}function hp(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!H1(e)||!t||!H1(t)?!1:gne(e,t,n)}function yne(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!hp(e[s],t[s],n))return!1;return!0}function xne(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 wne(e,t,n){return e.message===t.message&&e.name===t.name&&hp(e.cause,t.cause,n)}function bne(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(!hp(r[1],t.get(r[0]),n))return!1;return!0}function vne(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)&&!hp(e[i],t[i],n))return!1}return!0}function kne(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 Sne(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Nne(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function v0(e,t){return hp(e,t,new WeakMap)}function Ax(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function jne(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Cne(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Ene(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function _ne(e,t){const n=Ene();h.useEffect(()=>{if(!n)return e()},t)}function p2(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function Pne(e,t){const n=h.useRef(t);return v0(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function Ane(e){h.useEffect(()=>{e()},[])}function Ine(e=0){const[t,n]=h.useState({height:Ax()?window.innerHeight:0,width:Ax()?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(!Ax())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Cne(window,"resize",i),()=>{jne(window,"resize",i)}},[]),t}var Tne=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Rne=["bigint","boolean","null","number","string","symbol","undefined"];function mp(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Lne(t))return t}function Ki(e){return t=>mp(t)===e}function Lne(e){return Tne.includes(e)}function Vu(e){return t=>typeof t===e}function One(e){return Rne.includes(e)}var Mne=["innerHTML","ownerDocument","style","attributes","nodeValue"],gp=e=>Array.isArray(e),$ne=e=>mp(e)==="AsyncGeneratorFunction",Dne=Ki("AsyncFunction"),Fne=Vu("bigint"),zne=e=>e===!0||e===!1,Bne=Ki("Date"),Hne=Ki("Error"),rl=Vu("function"),Wne=Ki("GeneratorFunction"),Vne=e=>typeof e=="number"&&Number.isInteger(e),Eb=Ki("Map"),h2=e=>Number.isNaN(e),k0=e=>e===null,m2=Ki("Function"),Une=Ki("Promise"),Kne=Ki("RegExp"),_b=Ki("Set"),yp=Vu("string"),qne=Vu("symbol"),S0=Vu("undefined"),Yne=Ki("WeakMap"),Gne=Ki("WeakSet"),N0=e=>k0(e)||S0(e),g2=e=>!S0(e),Xne=e=>Vu("number")(e)&&!h2(e),Jne=e=>yp(e)&&e.trim().length>0,Qne=e=>{if(!yp(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},qg=e=>!N0(e)&&(rl(e)||typeof e=="object"),y2=e=>{if(mp(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Zne=e=>k0(e)||One(typeof e),ere=e=>mp(e)==="URL",x2=e=>!N0(e)&&rl(e[Symbol.iterator]),tre=e=>x2(e)&&rl(e.next)&&rl(e.throw),nre=e=>rl(e)&&/^class\s/.test(e.toString()),rre=(e,t)=>!gp(e)||!rl(t)?!1:e.every(n=>t(n)),sre=e=>qg(e)&&!y2(e)&&e.nodeType===1&&yp(e.nodeName)&&Mne.every(t=>t in e),ire=e=>yp(e)&&e.length===0||gp(e)&&e.length===0||qg(e)&&!Eb(e)&&!_b(e)&&Object.keys(e).length===0||_b(e)&&e.size===0||Eb(e)&&e.size===0,ore=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,are=(e,t)=>gp(e)?e.indexOf(t)>-1:!1,lre=(e,t,n)=>{if(!qg(e)||!t)return!1;const r=e[t];return rl(n)?n(r):g2(r)};function At(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(gp(e))return"Array";if(m2(e))return"Function";const t=mp(e);return t||"Object"}At.array=gp;At.arrayOf=rre;At.asyncGeneratorFunction=$ne;At.asyncFunction=Dne;At.bigint=Fne;At.boolean=zne;At.class=nre;At.date=Bne;At.defined=g2;At.domElement=sre;At.empty=ire;At.error=Hne;At.function=rl;At.generator=tre;At.generatorFunction=Wne;At.instanceOf=ore;At.integer=Vne;At.iterable=x2;At.map=Eb;At.nan=h2;At.null=k0;At.nullOrUndefined=N0;At.nonEmptyString=Jne;At.number=Xne;At.numericString=Qne;At.object=qg;At.oneOf=are;At.plainFunction=m2;At.plainObject=y2;At.primitive=Zne;At.promise=Une;At.propertyOf=lre;At.regexp=Kne;At.set=_b;At.string=yp;At.symbol=qne;At.undefined=S0;At.url=ere;At.weakMap=Yne;At.weakSet=Gne;var Xr=At;/* v8 ignore next -- @preserve */var cre=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},ure=function(e,t){return e+Yf(t)},Yf=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(ure,""):cre(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Yf(e.props.children):""};Yf.default=Yf;var dre=Yf;const Ix=il(dre);var w2={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})})(w2);var fre=w2.exports;const pre=il(fre);var hre=new Error("Element already at target scroll position"),mre=new Error("Scroll cancelled"),gre=Math.min,W1=Date.now,yre={left:V1("scrollLeft"),top:V1("scrollTop")};function V1(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=wre);var a=W1(),l=n[e],c=s.ease||xre,d=isNaN(s.duration)?350:+s.duration,f=!1;return l===r?i(hre,n[e]):requestAnimationFrame(p),u;function u(){f=!0}function p(m){if(f)return i(mre,n[e]);var g=W1(),b=gre(1,(g-a)/d),v=c(b);n[e]=v*(r-l)+l,b<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function xre(e){return .5*(1-Math.cos(Math.PI*e))}function wre(){}const bre=il(yre);var b2={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(df,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})})(b2);var vre=b2.exports;const v2=il(vre),kre=["top","right","bottom","left"],U1=["start","end"],K1=kre.reduce((e,t)=>e.concat(t,t+"-"+U1[0],t+"-"+U1[1]),[]),Mu=Math.min,ql=Math.max,ig=Math.round,_h=Math.floor,ko=e=>({x:e,y:e}),Sre={left:"right",right:"left",bottom:"top",top:"bottom"};function Pb(e,t,n){return ql(e,Mu(t,n))}function Uu(e,t){return typeof e=="function"?e(t):e}function sa(e){return e.split("-")[0]}function So(e){return e.split("-")[1]}function k2(e){return e==="x"?"y":"x"}function j0(e){return e==="y"?"height":"width"}function Fa(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function C0(e){return k2(Fa(e))}function S2(e,t,n){n===void 0&&(n=!1);const r=So(e),s=C0(e),i=j0(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=ag(a)),[a,ag(a)]}function Nre(e){const t=ag(e);return[og(e),t,og(t)]}function og(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const q1=["left","right"],Y1=["right","left"],jre=["top","bottom"],Cre=["bottom","top"];function Ere(e,t,n){switch(e){case"top":case"bottom":return n?t?Y1:q1:t?q1:Y1;case"left":case"right":return t?jre:Cre;default:return[]}}function _re(e,t,n,r){const s=So(e);let i=Ere(sa(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(og)))),i}function ag(e){const t=sa(e);return Sre[t]+e.slice(t.length)}function Pre(e){return{top:0,right:0,bottom:0,left:0,...e}}function N2(e){return typeof e!="number"?Pre(e):{top:e,right:e,bottom:e,left:e}}function lg(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 G1(e,t,n){let{reference:r,floating:s}=e;const i=Fa(t),a=C0(t),l=j0(a),c=sa(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(So(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 Are(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}=Uu(t,e),g=N2(m),v=l[p?u==="floating"?"reference":"floating":u],y=lg(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=lg(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 Ire=50,Tre=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Are},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}=G1(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<Ire&&(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}=G1(d,p,c)),b=-1)}return{x:f,y:u,placement:p,strategy:s,middlewareData:g}},Rre=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}=Uu(e,t)||{};if(d==null)return{};const u=N2(f),p={x:n,y:r},m=C0(s),g=j0(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=Mu(u[y],F),L=Mu(u[k],F),O=z,W=$-b[g]-L,M=$/2-b[g]/2+B,T=Pb(O,M,W),E=!c.arrow&&So(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 Lre(e,t,n){return(e?[...n.filter(s=>So(s)===e),...n.filter(s=>So(s)!==e)]:n.filter(s=>sa(s)===s)).filter(s=>e?So(s)===e||(t?og(s)!==s:!1):!0)}const Ore=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=K1,autoAlignment:m=!0,...g}=Uu(e,t),b=u!==void 0||p===K1?Lre(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=S2(k,i,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==k)return{reset:{placement:b[0]}};const j=[v[sa(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=So(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,So(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}}:{}}}},Mre=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}=Uu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=sa(s),k=Fa(l),w=sa(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),A=p||(w||!b?[ag(l)]:Nre(l)),C=g!=="none";!p&&C&&A.push(..._re(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=S2(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!==Fa(T):!1)||z.every(_=>Fa(_.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=Fa(_.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{}}}},$re=new Set(["left","top"]);async function Dre(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=sa(n),l=So(n),c=Fa(n)==="y",d=$re.has(a)?-1:1,f=i&&c?-1:1,u=Uu(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 Fre=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 Dre(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}}}}},zre=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}=Uu(e,t),f={x:n,y:r},u=await i.detectOverflow(t,d),p=Fa(sa(s)),m=k2(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=Pb(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=Pb(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 Yg(){return typeof window<"u"}function Ku(e){return j2(e)?(e.nodeName||"").toLowerCase():"#document"}function Ks(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _o(e){var t;return(t=(j2(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function j2(e){return Yg()?e instanceof Node||e instanceof Ks(e).Node:!1}function Wi(e){return Yg()?e instanceof Element||e instanceof Ks(e).Element:!1}function aa(e){return Yg()?e instanceof HTMLElement||e instanceof Ks(e).HTMLElement:!1}function X1(e){return!Yg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ks(e).ShadowRoot}function xp(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Vi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Bre(e){return/^(table|td|th)$/.test(Ku(e))}function Gg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Hre=/transform|translate|scale|rotate|perspective|filter/,Wre=/paint|layout|strict|content/,Il=e=>!!e&&e!=="none";let Tx;function E0(e){const t=Wi(e)?Vi(e):e;return Il(t.transform)||Il(t.translate)||Il(t.scale)||Il(t.rotate)||Il(t.perspective)||!_0()&&(Il(t.backdropFilter)||Il(t.filter))||Hre.test(t.willChange||"")||Wre.test(t.contain||"")}function Vre(e){let t=sl(e);for(;aa(t)&&!$u(t);){if(E0(t))return t;if(Gg(t))return null;t=sl(t)}return null}function _0(){return Tx==null&&(Tx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Tx}function $u(e){return/^(html|body|#document)$/.test(Ku(e))}function Vi(e){return Ks(e).getComputedStyle(e)}function Xg(e){return Wi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sl(e){if(Ku(e)==="html")return e;const t=e.assignedSlot||e.parentNode||X1(e)&&e.host||_o(e);return X1(t)?t.host:t}function C2(e){const t=sl(e);return $u(t)?e.ownerDocument?e.ownerDocument.body:e.body:aa(t)&&xp(t)?t:C2(t)}function Gf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=C2(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=Ks(s);if(i){const l=Ab(a);return t.concat(a,a.visualViewport||[],xp(s)?s:[],l&&n?Gf(l):[])}else return t.concat(s,Gf(s,[],n))}function Ab(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function E2(e){const t=Vi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=aa(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=ig(n)!==i||ig(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function P0(e){return Wi(e)?e:e.contextElement}function gu(e){const t=P0(e);if(!aa(t))return ko(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=E2(t);let a=(i?ig(n.width):n.width)/r,l=(i?ig(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Ure=ko(0);function _2(e){const t=Ks(e);return!_0()||!t.visualViewport?Ure:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Kre(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ks(e)?!1:t}function sc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=P0(e);let a=ko(1);t&&(r?Wi(r)&&(a=gu(r)):a=gu(e));const l=Kre(i,n,r)?_2(i):ko(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=Ks(i),m=r&&Wi(r)?Ks(r):r;let g=p,b=Ab(g);for(;b&&r&&m!==g;){const v=gu(b),y=b.getBoundingClientRect(),k=Vi(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=Ks(b),b=Ab(g)}}return lg({width:f,height:u,x:c,y:d})}function Jg(e,t){const n=Xg(e).scrollLeft;return t?t.left+n:sc(_o(e)).left+n}function P2(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Jg(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function qre(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=_o(r),l=t?Gg(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=ko(1);const f=ko(0),u=aa(r);if((u||!u&&!i)&&((Ku(r)!=="body"||xp(a))&&(c=Xg(r)),u)){const m=sc(r);d=gu(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const p=a&&!u&&!i?P2(a,c):ko(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 Yre(e){return Array.from(e.getClientRects())}function Gre(e){const t=_o(e),n=Xg(e),r=e.ownerDocument.body,s=ql(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=ql(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Jg(e);const l=-n.scrollTop;return Vi(r).direction==="rtl"&&(a+=ql(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const J1=25;function Xre(e,t){const n=Ks(e),r=_o(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=_0();(!f||f&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=Jg(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<=J1&&(i-=g)}else d<=J1&&(i+=d);return{width:i,height:a,x:l,y:c}}function Jre(e,t){const n=sc(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=aa(e)?gu(e):ko(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 Q1(e,t,n){let r;if(t==="viewport")r=Xre(e,n);else if(t==="document")r=Gre(_o(e));else if(Wi(t))r=Jre(t,n);else{const s=_2(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return lg(r)}function A2(e,t){const n=sl(e);return n===t||!Wi(n)||$u(n)?!1:Vi(n).position==="fixed"||A2(n,t)}function Qre(e,t){const n=t.get(e);if(n)return n;let r=Gf(e,[],!1).filter(l=>Wi(l)&&Ku(l)!=="body"),s=null;const i=Vi(e).position==="fixed";let a=i?sl(e):e;for(;Wi(a)&&!$u(a);){const l=Vi(a),c=E0(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||xp(a)&&!c&&A2(e,a))?r=r.filter(f=>f!==a):s=l,a=sl(a)}return t.set(e,r),r}function Zre(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Gg(t)?[]:Qre(t,this._c):[].concat(n),r],l=Q1(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=Q1(t,a[p],s);c=ql(m.top,c),d=Mu(m.right,d),f=Mu(m.bottom,f),u=ql(m.left,u)}return{width:d-u,height:f-c,x:u,y:c}}function ese(e){const{width:t,height:n}=E2(e);return{width:t,height:n}}function tse(e,t,n){const r=aa(t),s=_o(t),i=n==="fixed",a=sc(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=ko(0);function d(){c.x=Jg(s)}if(r||!r&&!i)if((Ku(t)!=="body"||xp(s))&&(l=Xg(t)),r){const m=sc(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?P2(s,l):ko(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 Rx(e){return Vi(e).position==="static"}function Z1(e,t){if(!aa(e)||Vi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _o(e)===n&&(n=n.ownerDocument.body),n}function I2(e,t){const n=Ks(e);if(Gg(e))return n;if(!aa(e)){let s=sl(e);for(;s&&!$u(s);){if(Wi(s)&&!Rx(s))return s;s=sl(s)}return n}let r=Z1(e,t);for(;r&&Bre(r)&&Rx(r);)r=Z1(r,t);return r&&$u(r)&&Rx(r)&&!E0(r)?n:r||Vre(e)||n}const nse=async function(e){const t=this.getOffsetParent||I2,n=this.getDimensions,r=await n(e.floating);return{reference:tse(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function rse(e){return Vi(e).direction==="rtl"}const sse={convertOffsetParentRelativeRectToViewportRelativeRect:qre,getDocumentElement:_o,getClippingRect:Zre,getOffsetParent:I2,getElementRects:nse,getClientRects:Yre,getDimensions:ese,getScale:gu,isElement:Wi,isRTL:rse};function T2(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ise(e,t){let n=null,r;const s=_o(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=_h(u),b=_h(s.clientWidth-(f+p)),v=_h(s.clientHeight-(u+m)),y=_h(f),w={rootMargin:-g+"px "+-b+"px "+-v+"px "+-y+"px",threshold:ql(0,Mu(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&&!T2(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 eC(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=P0(e),f=s||i?[...d?Gf(d):[],...t?Gf(t):[]]:[];f.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const u=d&&l?ise(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?sc(e):null;c&&v();function v(){const y=sc(e);b&&!T2(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 ose=Fre,ase=Ore,lse=zre,cse=Mre,tC=Rre,use=(e,t,n)=>{const r=new Map,s={platform:sse,...n},i={...s.platform,_c:r};return Tre(e,t,{...s,platform:i})};var dse=typeof document<"u",fse=function(){},em=dse?h.useLayoutEffect:fse;function cg(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(!cg(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)&&!cg(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function R2(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function nC(e,t){const n=R2(e);return Math.round(t*n)/n}function Lx(e){const t=h.useRef(e);return em(()=>{t.current=e}),t}function rC(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);cg(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=Lx(c),L=Lx(s),O=Lx(d),W=h.useCallback(()=>{if(!C.current||!$.current)return;const _={placement:t,strategy:n,middleware:p};L.current&&(_.platform=L.current),use(C.current,$.current,_).then(R=>{const P={...R,isPositioned:O.current!==!1};M.current&&!cg(B.current,P)&&(B.current=P,$r.flushSync(()=>{u(P)}))})},[p,t,n,L,O]);em(()=>{d===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,u(_=>({..._,isPositioned:!1})))},[d]);const M=h.useRef(!1);em(()=>(M.current=!0,()=>{M.current=!1}),[]),em(()=>{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=nC(E.floating,f.x),P=nC(E.floating,f.y);return l?{..._,transform:"translate("+R+"px, "+P+"px)",...R2(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 pse=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?tC({element:r.current,padding:s}).fn(n):{}:r?tC({element:r,padding:s}).fn(n):{}}}},sC=(e,t)=>{const n=ose(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=cse(e);return{name:n.name,fn:n.fn,options:[e,t]}},gse=(e,t)=>{const n=ase(e);return{name:n.name,fn:n.fn,options:[e,t]}},yse=(e,t)=>{const n=pse(e);return{name:n.name,fn:n.fn,options:[e,t]}},xse={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},wse={beaconOptions:{offset:-18}},L2={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},bse={isFixed:!1,locale:L2,placement:"bottom"},vse={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Ft={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},_r={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"},We={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},po={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Rt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},kse="react-joyride-portal";function Sse(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function su(...e){return pre({all:!0,isMergeableObject:t=>!(!Xr.plainObject(t)||h.isValidElement(t))})(...e)}function O2(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Uo(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=Ix(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&&O2(e.type)==="function")try{i=Uo(e.type({}),t)}catch{i=Ix(n)}else i=Ix(n);return i}function Ar(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 Nse(e,t){const n=Sse(t);return{...e,...n}}function Xf(){}function jse(e){return Object.keys(e)}function ug(e,...t){if(!Xr.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 iC(e,...t){if(!Xr.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 Ib(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(O2(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:s}=e.props;if(Xr.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):Ib(i,t,n))});if(Xr.function(e.type)&&!Object.values(e.props).length)try{return Ib(e.type({}),t,n)}catch{return e}return e}function oC(e){return jse(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function A0(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function aC(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 I0(e){return e?e.getBoundingClientRect():null}function Cse(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 pi(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 Ese(e,t,n){const r=I0(e),s=qu(e),i=s?!s.isSameNode(Ss()):!1,a=n??Yu(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(Ss())||(c+=Ss().scrollTop)),Math.floor(c-t)}function qu(e,t){if(!e)return Ss();const n=v2(e);if(n){if(n.isSameNode(Ss()))return t?document:Ss();if(!(n.scrollHeight>n.offsetHeight))return Ss()}return n}function _se(e){const t=e.getBoundingClientRect(),n=Ss(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Pse(e,t){if(!e)return 0;const n=v2(e)??Ss(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=I0(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(M2(e)||Ase(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 Ase(e){return e.offsetParent!==document.body}function M2(e){if(!e)return!1;const t=qu(e);return t?!t.isSameNode(Ss()):!1}function Yu(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?Yu(e.parentNode,t):!1}function Ph(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 lC(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==We.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?qu(s):Ss(),l=a?!a.isSameNode(Ss()):!1;return(r.isFixed||Yu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Ss(){return document.scrollingElement??document.documentElement}function cC(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=bre.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function Ise(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 $2={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Ah={...$2,borderRadius:4,padding:8};function Tse(e,t){const{styles:n}=e,r=su(n??{},t.styles??{});let{width:s}=t;A0()&&(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 su({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...$2,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(${Ise(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:{...Ah,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Ah,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Ah,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Ah,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 Rse=["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 T0(e,t){if(!t)return null;const n=su(bse,iC(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=su(xse,e.options??{},iC(t,...Rse)),s=Tse(e,{...n,...r}),i=su(wse,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:su(L2,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:Lse(r.spotlightPadding),styles:s}}function Lse(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 Ose(e,t,n){const{action:r}=t,s=n&&[Ft.PREV,Ft.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function D2(e,t=!1){return Xr.plainObject(e)?e.target?!0:(Ar(t,"tour","target is missing from the step"),!1):(Ar(t,"tour","step must be an object"),!1)}function F2(e,t=!1){return Xr.array(e)?e.every(n=>D2(n,t)):(Ar(t,"tour","steps must be an array"),!1)}var Mse=class{constructor(e){er(this,"beaconPosition",null);er(this,"debug");er(this,"eventListeners",new Map);er(this,"listeners",new Set);er(this,"props");er(this,"snapshot");er(this,"state");er(this,"steps");er(this,"tooltipPosition",null);er(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});er(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);er(this,"getServerSnapshot",()=>this.snapshot);er(this,"getSnapshot",()=>this.snapshot);er(this,"getEventState",()=>ug(this.snapshot,"positioned"));er(this,"getState",()=>ug(this.snapshot,"positioned"));er(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&Ar(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===We.BEACON_BEFORE||this.state.lifecycle===We.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)});er(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});er(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});er(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)}});er(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));er(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,!v0(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=Xr.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,Xr.number(t)&&Ar(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Xr.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&Ar(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Ft.INIT,controlled:s,index:i,lifecycle:We.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Rt.READY:Rt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Rt.WAITING&&e.size>0?{...e,status:Rt.RUNNING}:e}getStep(e){return T0(this.props,this.steps[e??this.state.index])}};function $se(e){return new Mse(e)}function uC(e,t){return Math.min(Math.max(e,0),t)}function Dse(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===Rt.RUNNING&&e.current.updateState({action:Ft.CLOSE,index:y+1,origin:v,lifecycle:We.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:v=>{const{controlled:y,size:k,status:w}=i();if(y){Ar(r.current,"tour","go() is not supported in controlled mode");return}w===Rt.RUNNING&&e.current.updateState({action:Ft.GO,index:v,lifecycle:We.COMPLETE,positioned:!1,scrolling:!1,status:v<k?w:Rt.FINISHED,waiting:!1})},info:()=>ug(e.current.getSnapshot(),"positioned"),next:v=>{const{index:y,size:k,status:w}=i();w===Rt.RUNNING&&e.current.updateState({action:Ft.NEXT,index:uC(y+1,k),lifecycle:We.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:v}=i();v===Rt.RUNNING&&e.current.updateState({action:Ft.UPDATE,lifecycle:We.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:v=>{const{index:y,size:k,status:w}=i();w===Rt.RUNNING&&e.current.updateState({action:Ft.PREV,index:uC(y-1,k),lifecycle:We.COMPLETE,origin:v,positioned:!1,scrolling:!1,waiting:!1})},reset:(v=!1)=>{const{controlled:y}=i();if(y){Ar(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Ft.RESET,index:0,lifecycle:We.INIT,positioned:!1,scrolling:!1,status:v?Rt.RUNNING:Rt.READY,waiting:!1})},skip:v=>{const{status:y}=i();y===Rt.RUNNING&&e.current.updateState({action:Ft.SKIP,lifecycle:We.COMPLETE,origin:v,positioned:!1,scrolling:!1,status:Rt.SKIPPED,waiting:!1})},start:v=>{const{index:y,size:k}=i();s.current(),e.current.updateState({action:Ft.START,index:Xr.number(v)?v:y,lifecycle:We.INIT,positioned:!1,scrolling:!1,status:k?Rt.RUNNING:Rt.WAITING,waiting:!1},!0)},stop:(v=!1)=>{const{index:y,status:k}=i();[Rt.FINISHED,Rt.SKIPPED].includes(k)||e.current.updateState({action:Ft.STOP,index:y+(v?1:0),lifecycle:We.COMPLETE,positioned:!1,scrolling:!1,status:Rt.PAUSED,waiting:!1})}}},[e])}const Fse=new Set(["origin","positioned"]);function zse(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return Ar(!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]&&!Fse.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||Ar(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Bse(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 Ta(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 Hse(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=p2(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}=Ta(w.current,j.current);(O("action",[Ft.NEXT,Ft.PREV,Ft.SKIP,Ft.CLOSE])||y.current===Ft.CLOSE&&d===Ft.START)&&(y.current=d)},[d]),h.useEffect(()=>{if(!j.current)return()=>{L()};const{hasChanged:O}=Ta(w.current,j.current),W=A.current;if(O("index")&&L(),b!==Rt.RUNNING||!W||u!==We.INIT)return()=>{L()};const{hasChangedTo:M}=Ta(w.current,j.current);M("status",Rt.RUNNING)&&[Rt.IDLE,Rt.READY,Rt.PAUSED].includes(j.current.status)&&r(_r.TOUR_START,W),c.current.cleanupPositionData();const{debug:T}=k.current;if(W.before&&!z.current){Ar(T,`step:${f}`,"before()",W),z.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(_r.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:We.READY})},D=new AbortController,_=W.beforeTimeout;z.current={cancel:()=>D.abort()};const R=_?setTimeout(()=>{D.signal.aborted||(Ar(T,`step:${f}`,"before()","timed out",`${_}ms`),D.abort(),t(W,"before_hook"),r(_r.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(_r.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=pi(W.target);if(E&&Ph(E))L(),c.current.updateState({action:y.current??Ft.UPDATE,lifecycle:We.READY,waiting:!1});else if(W.targetWaitTimeout===0)c.current.updateState({action:y.current??Ft.UPDATE,lifecycle:We.READY,waiting:!1});else if(!B.current){const{targetWaitTimeout:D}=W,_=Date.now();F.current=W.target,Ar(T,`step:${f}`,"polling","started",`${D}ms`),c.current.updateState({waiting:!0}),B.current=setInterval(()=>{const R=pi(W.target),P=Date.now()-_,X=P>=D;(R&&Ph(R)||X)&&(Ar(T,`step:${f}`,"polling",R&&Ph(R)?"found":"timed out",`${P}ms`),L(),c.current.updateState({action:y.current??Ft.UPDATE,lifecycle:We.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}=Ta(w.current,j.current),T=A.current;if(!T)return;const E=pi(T.target),D=!!E;if(D&&Ph(E)){if(W("lifecycle",We.READY)&&M.lifecycle===We.INIT&&r(_r.STEP_BEFORE,T,{action:y.current??w.current.action}),W("lifecycle",We.READY)){const _=w.current,R=Ose(T,_,k.current.continuous)?We.TOOLTIP:We.BEACON,P=pi(T.scrollTarget??T.spotlightTarget??T.target),X=lC({isFirstStep:_.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:T,target:P,targetLifecycle:R}),Z=R===We.TOOLTIP?We.TOOLTIP_BEFORE:We.BEACON_BEFORE;Ar(k.current.debug,`step:${f}`,"scroll",X?"needed":"skipped"),c.current.updateState({action:Ft.UPDATE,lifecycle:Z,scrolling:X})}}else if(w.current.status===Rt.RUNNING&&u!==We.INIT&&u!==We.COMPLETE&&O("lifecycle")){Ar(k.current.debug,`step:${f}`,D?"Target not visible":"Target not mounted",T),t(T,"target_not_found"),r(_r.TARGET_NOT_FOUND,T);const _=w.current;_.controlled||c.current.updateState({action:Ft.UPDATE,index:_.index+(_.action===Ft.PREV?-1:1),lifecycle:We.INIT})}},[t,r,f,u,c]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:O,previous:W}=Ta(w.current,j.current),M=A.current,T=C.current;if(M&&O("lifecycle",We.TOOLTIP_BEFORE)&&W.lifecycle===We.BEACON){const _=pi(M.scrollTarget??M.spotlightTarget??M.target);if(lC({isFirstStep:w.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:_,targetLifecycle:We.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const E=u===We.BEACON_BEFORE||u===We.TOOLTIP_BEFORE;if(M&&E&&!m){const _=u===We.TOOLTIP_BEFORE?We.TOOLTIP:We.BEACON;c.current.updateState({action:Ft.UPDATE,lifecycle:_})}M&&O("lifecycle",We.BEACON)&&r(_r.BEACON,M),M&&O("lifecycle",We.TOOLTIP)&&r(_r.TOOLTIP,M);const D=w.current;if((D.status===Rt.RUNNING||D.controlled&&D.status===Rt.PAUSED&&M)&&T&&O("lifecycle",We.COMPLETE)&&W.lifecycle===We.TOOLTIP&&(r(_r.STEP_AFTER,T,{action:y.current??Ft.UPDATE,index:W.index??D.index,lifecycle:D.lifecycle}),T.after)){r(_r.STEP_AFTER_HOOK,T,{action:y.current??Ft.UPDATE,index:W.index??D.index,lifecycle:D.lifecycle});try{T.after({...c.current.getState(),action:y.current??Ft.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}=Ta(w.current,j.current),M=A.current,T=C.current;g&&!M&&u===We.INIT&&c.current.updateState({action:Ft.UPDATE,lifecycle:We.COMPLETE,status:Rt.FINISHED}),!w.current.controlled&&b===Rt.RUNNING&&O("lifecycle",We.COMPLETE)&&f<g&&c.current.updateState({action:Ft.UPDATE,lifecycle:We.INIT}),O("lifecycle",We.COMPLETE)&&f>=g&&c.current.updateState({action:Ft.UPDATE,lifecycle:We.COMPLETE,status:Rt.FINISHED});const E=M??T??T0(k.current,k.current.steps[f-1]);if(E&&O("status",[Rt.FINISHED,Rt.SKIPPED])){let D;M?D=f:T?D=W.index??f:D=f-1,r(_r.TOUR_END,E,{index:D}),w.current.controlled||$.current.reset(),y.current=null}M&&O("action",Ft.STOP)&&(y.current=null,r(_r.TOUR_STATUS,M)),M&&O("action",Ft.RESET)&&(r(_r.TOUR_STATUS,M),y.current=null)},[d,r,f,u,g,b,c])}function Wse({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}=Ta(n,m);if(v0(m.steps,d)||(F2(d,i)?s.current.setSteps(d):(Ar(i,"tour","Steps are not valid",d),t(_r.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(Xr.number(c)&&g("stepIndex")){const b=Xr.number(m.stepIndex)&&m.stepIndex<c?Ft.NEXT:Ft.PREV;[Rt.FINISHED,Rt.SKIPPED].includes(u.current.status)||s.current.updateState({action:b,index:c,lifecycle:We.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,d,s])}function Vse(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===We.BEACON_BEFORE&&(n!=null&&n.placement)){const u=Use(n);["bottom"].includes(n.placement)||(a+=Math.floor(u-s))}else if(r===We.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=pi(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 Use(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 Kse({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}=Ta(p.current,m.current),y=b.current,{debug:k}=g.current,{scrollDuration:w}=y,j=l===We.BEACON_BEFORE||l===We.TOOLTIP_BEFORE;if(f===Rt.RUNNING&&j&&d&&v("positioned",!0)){const C=pi(y.scrollTarget??y.spotlightTarget??y.target),$=i.current.getPositionData("beacon"),B=qu(C),F=B?!B.isSameNode(Ss()):!1;(A=u.current)==null||A.call(u),(async()=>{if(F&&!Yu(B)){const D=Ss(),_=_se(B),R={initial:D.scrollTop,target:_,element:D,duration:w};e(_r.SCROLL_START,y,{scroll:R});const{cancel:P,promise:X}=cC(_,{element:D,duration:w});u.current=P,await X,e(_r.SCROLL_END,y,{scroll:R})}const L=Math.floor(Pse(C,y.scrollOffset))||0,O=F?L:Vse(L,{beaconPosition:$,lifecycle:l,scrollOffset:y.scrollOffset,step:y});Ar(k,`step:${a}`,"scroll",F?"custom":"document",`${L} → ${O}`);const W=B,M={initial:W.scrollTop,target:O,element:W,duration:w};e(_r.SCROLL_START,y,{scroll:M});const{cancel:T,promise:E}=cC(O,{element:W,duration:w});u.current=T,await E,e(_r.SCROLL_END,y,{scroll:M}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,d,f,i])}function qse(e){const t=Pne(()=>Nse(vse,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=h.useRef($se(t)),d=iA.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([])},[]);zse(c,n);const g=Dse(c,n,m),b=Bse(s,g,c),{index:v,size:y,status:k}=d,w=p2(d),j=h.useMemo(()=>T0(t,l[v]),[v,t,l]);return Ane(()=>{i&&y&&F2(l,n)&&g.start(a??r)}),_ne(()=>{i&&y&&k===Rt.IDLE&&c.current.updateState({status:Rt.READY})},[i,y,k]),Wse({controls:g,emitEvent:b,props:t,state:d,store:c}),Hse({addFailure:p,controls:g,emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),Kse({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 Yse(e){const[t,n]=h.useState(null);return h.useEffect(()=>{let r=null,s=!1;if(e)if(Xr.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=kse,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Gse={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Xse({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Xf;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:{...Gse,height:s,width:i,borderTopColor:t.primaryColor}});return at.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Jse={height:0,isFixed:!1,left:0,top:0,width:0};function Ld(e,t){const n=pi(e);if(!n)return Jse;const r=I0(n),s=Yu(n),i=Ese(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 Qse(e,t,n){const[r,s]=h.useState(()=>Ld(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=Ld(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=qu(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(Ld(e,t))},m=pi(e);return m?p(m):(u=new MutationObserver(()=>{const g=pi(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(Ld(e,t)),l.current=n},[n,e,t]);let f=r;return l.current&&!n&&(f=Ld(e,t)),f}function Zse(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function dC(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 eie=[We.BEACON_BEFORE,We.BEACON];function tie(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=Ine(),y=Qse(p??g,f,d||b),k=h.useRef(null),w=(s===We.TOOLTIP||s===We.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)??Cse()??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&&eie.includes(s),W=!n&&s!==We.TOOLTIP;if(r||!b&&(O||W))return null;let M="";if(L)if(c&&C){const _=pi(p??g);if(_){const R=aC(_),P=aC(C);M=dC(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=dC(y.left,y.top,y.width,y.height,u);const T=Zse($,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 z2(e){const{children:t,element:n}=e;return n?$r.createPortal(t,n):null}const nie='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function rie(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return Xf;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(nie)],{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 Xo(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 sie(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...Xo(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...Xo(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...Xo(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...Xo(e,t,n)};default:return null}}function iie(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...Xo(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...Xo(e,r,n)};case"left":return{right:-n,top:t.y??0,...Xo(e,r,n)};case"right":return{left:-n,top:t.y??0,...Xo(e,r,n)};default:return{}}}function oie({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!Xo(r,n,i))return null;c=at.createElement("span",{style:{flexShrink:0}},at.createElement(l,{base:n,placement:r,size:i}))}else{const d=sie(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,...iie(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function aie(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 Xf;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(()=>{Xr.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=Uo(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 lie({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 cie(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(lie,{"data-testid":"button-close",styles:u.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Uo(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 uie(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(po.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(po.BUTTON_CLOSE):n.close(po.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(po.BUTTON_PRIMARY);return}n.next(po.BUTTON_PRIMARY)},f=y=>{y.preventDefault(),n.skip(po.BUTTON_SKIP)},u=()=>{const{back:y,close:k,last:w,next:j,nextWithProgress:A,skip:C}=a.locale,$=Uo(y),B=Uo(k),F=Uo(w),z=Uo(j),L=Uo(C);let O=k,W=B;if(t){if(O=j,W=z,a.showProgress&&!s){const M=Uo(A,{step:r+1,steps:i});O=Ib(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(cie,{...u(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b});return v}function die(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function fie(e,t,n){var r,s;return e?[gse()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[mse({crossAxis:!1,fallbackPlacements:die(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function pie(e){var R,P,X,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(()=>M2(m)?qu(m):void 0,[m]),C=h.useMemo(()=>Yu(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 ne,ue,pe,ge;return k?[{name:"center",fn:({rects:ae})=>({x:(window.innerWidth-ae.floating.width)/2,y:(window.innerHeight-ae.floating.height)/2})}]:[sC(({placement:ae})=>{var we;let be="right";ae.startsWith("top")?be="top":ae.startsWith("bottom")?be="bottom":ae.startsWith("left")&&(be="left");const Ae=p.spotlightTarget?0:p.spotlightPadding[be];return p.offset+Ae+((we=p.floatingOptions)!=null&&we.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(ne=p.floatingOptions)==null?void 0:ne.hideArrow]),...fie(w,p,B),hse({padding:10,...$,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(pe=p.floatingOptions)!=null&&pe.hideArrow?[]:[yse({element:b,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ge=p.floatingOptions)==null?void 0:ge.middleware)??[]]},[k,p,w,B,$]),L=rC({...k?{elements:{reference:j}}:{},placement:B,strategy:F,middleware:z}),O=rC({strategy:F,placement:p.beaconPlacement??(w||k?"bottom":p.placement),middleware:h.useMemo(()=>{var ne,ue;return[sC(((ue=(ne=p.floatingOptions)==null?void 0:ne.beaconOptions)==null?void 0:ue.offset)??-18)]},[(X=(P=p.floatingOptions)==null?void 0:P.beaconOptions)==null?void 0:X.offset]),whileElementsMounted:eC});y.current=L.middlewareData,v.current=O.middlewareData,h.useEffect(()=>{var pe;const{floating:ne,reference:ue}=L.elements;if(!(!ue||!ne||s!==We.TOOLTIP))return eC(ue,ne,L.update,(pe=p.floatingOptions)==null?void 0:pe.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(ne=>{ne.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:We.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),T=h.useCallback(ne=>{ne&&(L.refs.setFloating(ne),d(ne))},[L.refs,d]),{arrow:E,floater:D}=p.styles;let _=null;if(s===We.TOOLTIP||s===We.TOOLTIP_BEFORE){const ne=oC({...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:ne},at.createElement(uie,{continuous:t,controls:n,index:r,isLastStep:r+1===u,size:u,step:p}),!k&&!((V=p.floatingOptions)!=null&&V.hideArrow)&&at.createElement(oie,{arrowComponent:p.arrowComponent,arrowRef:b,base:p.arrowBase,placement:L.placement,position:L.middlewareData.arrow,size:p.arrowSize,styles:E}))}else(s===We.BEACON||s===We.BEACON_BEFORE)&&(_=at.createElement("div",{ref:O.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:oC({...O.floatingStyles,zIndex:W})},at.createElement(aie,{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(z2,{element:l},_)}function hie(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);rie(f.disableFocusTrap?null:p,"[data-action=primary]");const g=pi(f.target),b=s===We.TOOLTIP;return!D2(f)||!Xr.domElement(g)?null:at.createElement(pie,{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 mie({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:d}=t,f=Yse(c),{index:u,lifecycle:p,status:m}=n,g=m===Rt.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!==We.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(po.KEYBOARD):e.close(po.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(po.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(po.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const j=n.action===Ft.START&&!r.skipBeacon&&r.placement!=="center";return at.createElement(at.Fragment,null,p!==We.INIT&&at.createElement(hie,{...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(z2,{element:f},at.createElement(at.Fragment,null,b&&at.createElement(Xse,{nonce:l,step:r}),!j&&at.createElement(tie,{...r,continuous:i,lifecycle:p,onClickOverlay:w,portalElement:c?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function gie(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=qse(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>ug(s,"positioned"),[s]),step:i,Tour:A0()?at.createElement(mie,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function yie(e){const{Tour:t}=gie(e);return t}function xie(e){return A0()?at.createElement(yie,e):null}function wie(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 bie(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function vie(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Ox="af:onboarding";function kie({page:e,hasNodes:t=!1}){const{t:n}=Pn(),[r,s]=h.useState(!1),[i,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?wie(n):t?bie(n):vie(n),[e,t,n]);return h.useEffect(()=>{const d=localStorage.getItem(Ox);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(Ox)||"{}",v=JSON.parse(b);m===n("onboarding:skip")?(v.projects=!0,v.flow=!0,v.completed=!0):v[e]=!0,localStorage.setItem(Ox,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(xie,{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 Sie(){const{navigate:e,path:t}=Co(),[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 Nie 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 jie({authUser:e}){const{path:t}=Co();return t==="/projects"||t==="/"?o.jsx(Ic,{authUser:e}):t==="/nodes"?o.jsx(Ic,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(Ic,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(Ic,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(Ic,{authUser:e,resourceKind:"skills"}):t==="/mcps"?o.jsx(fne,{}):t==="/flow"?o.jsx(N7,{}):t==="/workspace"?o.jsx(Uq,{}):t.startsWith("/display")?o.jsx(r2,{}):t==="/settings"?o.jsx(cne,{authUser:e}):t==="/feedback"?o.jsx(une,{}):o.jsx(Ic,{})}function Cie({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 Eie({authUser:e,onLogout:t}){const{path:n}=Co(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(kie,{page:r?"flow":"projects"}):null,r?null:o.jsx(dM,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(jie,{authUser:e})}),o.jsx(Sie,{})]})}function _ie(){return o.jsx(Nie,{children:o.jsx(KO,{children:o.jsx(Pie,{})})})}function Pie(){const{path:e}=Co();return e.startsWith("/display")?o.jsx(r2,{}):o.jsx(Cie,{children:({user:t,onLogout:n})=>o.jsx(Eie,{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 fC=document.querySelector('link[rel="icon"]');fC&&(fC.href=__);Mx.createRoot(document.getElementById("root")).render(o.jsx(at.StrictMode,{children:o.jsx(_ie,{})}));