@fieldwangai/agentflow 0.1.35 → 0.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,214 +0,0 @@
1
- var ZT=Object.defineProperty;var e2=(e,t,n)=>t in e?ZT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Rn=(e,t,n)=>e2(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 ld=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var G1={exports:{}},om={},X1={exports:{}},St={};/**
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 Yd=Symbol.for("react.element"),t2=Symbol.for("react.portal"),n2=Symbol.for("react.fragment"),r2=Symbol.for("react.strict_mode"),s2=Symbol.for("react.profiler"),i2=Symbol.for("react.provider"),o2=Symbol.for("react.context"),a2=Symbol.for("react.forward_ref"),l2=Symbol.for("react.suspense"),c2=Symbol.for("react.memo"),u2=Symbol.for("react.lazy"),K0=Symbol.iterator;function d2(e){return e===null||typeof e!="object"?null:(e=K0&&e[K0]||e["@@iterator"],typeof e=="function"?e:null)}var J1={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Q1=Object.assign,Z1={};function Mc(e,t,n){this.props=e,this.context=t,this.refs=Z1,this.updater=n||J1}Mc.prototype.isReactComponent={};Mc.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")};Mc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function ej(){}ej.prototype=Mc.prototype;function xw(e,t,n){this.props=e,this.context=t,this.refs=Z1,this.updater=n||J1}var ww=xw.prototype=new ej;ww.constructor=xw;Q1(ww,Mc.prototype);ww.isPureReactComponent=!0;var q0=Array.isArray,tj=Object.prototype.hasOwnProperty,vw={current:null},nj={key:!0,ref:!0,__self:!0,__source:!0};function rj(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)tj.call(t,r)&&!nj.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:Yd,type:e,key:i,ref:a,props:s,_owner:vw.current}}function f2(e,t){return{$$typeof:Yd,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function bw(e){return typeof e=="object"&&e!==null&&e.$$typeof===Yd}function p2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Y0=/\/+/g;function dg(e,t){return typeof e=="object"&&e!==null&&e.key!=null?p2(""+e.key):t.toString(36)}function Tp(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 Yd:case t2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+dg(a,0):r,q0(s)?(n="",e!=null&&(n=e.replace(Y0,"$&/")+"/"),Tp(s,t,n,"",function(d){return d})):s!=null&&(bw(s)&&(s=f2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(Y0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",q0(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+dg(i,l);a+=Tp(i,t,n,c,s)}else if(c=d2(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+dg(i,l++),a+=Tp(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 Hf(e,t,n){if(e==null)return e;var r=[],s=0;return Tp(e,r,"","",function(i){return t.call(n,i,s++)}),r}function h2(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 Ur={current:null},Rp={transition:null},m2={ReactCurrentDispatcher:Ur,ReactCurrentBatchConfig:Rp,ReactCurrentOwner:vw};function sj(){throw Error("act(...) is not supported in production builds of React.")}St.Children={map:Hf,forEach:function(e,t,n){Hf(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Hf(e,function(){t++}),t},toArray:function(e){return Hf(e,function(t){return t})||[]},only:function(e){if(!bw(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};St.Component=Mc;St.Fragment=n2;St.Profiler=s2;St.PureComponent=xw;St.StrictMode=r2;St.Suspense=l2;St.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=m2;St.act=sj;St.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=Q1({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=vw.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)tj.call(t,c)&&!nj.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:Yd,type:e.type,key:s,ref:i,props:r,_owner:a}};St.createContext=function(e){return e={$$typeof:o2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:i2,_context:e},e.Consumer=e};St.createElement=rj;St.createFactory=function(e){var t=rj.bind(null,e);return t.type=e,t};St.createRef=function(){return{current:null}};St.forwardRef=function(e){return{$$typeof:a2,render:e}};St.isValidElement=bw;St.lazy=function(e){return{$$typeof:u2,_payload:{_status:-1,_result:e},_init:h2}};St.memo=function(e,t){return{$$typeof:c2,type:e,compare:t===void 0?null:t}};St.startTransition=function(e){var t=Rp.transition;Rp.transition={};try{e()}finally{Rp.transition=t}};St.unstable_act=sj;St.useCallback=function(e,t){return Ur.current.useCallback(e,t)};St.useContext=function(e){return Ur.current.useContext(e)};St.useDebugValue=function(){};St.useDeferredValue=function(e){return Ur.current.useDeferredValue(e)};St.useEffect=function(e,t){return Ur.current.useEffect(e,t)};St.useId=function(){return Ur.current.useId()};St.useImperativeHandle=function(e,t,n){return Ur.current.useImperativeHandle(e,t,n)};St.useInsertionEffect=function(e,t){return Ur.current.useInsertionEffect(e,t)};St.useLayoutEffect=function(e,t){return Ur.current.useLayoutEffect(e,t)};St.useMemo=function(e,t){return Ur.current.useMemo(e,t)};St.useReducer=function(e,t,n){return Ur.current.useReducer(e,t,n)};St.useRef=function(e){return Ur.current.useRef(e)};St.useState=function(e){return Ur.current.useState(e)};St.useSyncExternalStore=function(e,t,n){return Ur.current.useSyncExternalStore(e,t,n)};St.useTransition=function(){return Ur.current.useTransition()};St.version="18.3.1";X1.exports=St;var m=X1.exports;const qe=xa(m);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var g2=m,y2=Symbol.for("react.element"),x2=Symbol.for("react.fragment"),w2=Object.prototype.hasOwnProperty,v2=g2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,b2={key:!0,ref:!0,__self:!0,__source:!0};function ij(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)w2.call(t,r)&&!b2.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:y2,type:e,key:i,ref:a,props:s,_owner:v2.current}}om.Fragment=x2;om.jsx=ij;om.jsxs=ij;G1.exports=om;var o=G1.exports,Ay={},oj={exports:{}},js={},aj={exports:{}},lj={};/**
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(_,T){var C=_.length;_.push(T);e:for(;0<C;){var G=C-1>>>1,Z=_[G];if(0<s(Z,T))_[G]=T,_[C]=Z,C=G;else break e}}function n(_){return _.length===0?null:_[0]}function r(_){if(_.length===0)return null;var T=_[0],C=_.pop();if(C!==T){_[0]=C;e:for(var G=0,Z=_.length,W=Z>>>1;G<W;){var te=2*(G+1)-1,le=_[te],ue=te+1,de=_[ue];if(0>s(le,C))ue<Z&&0>s(de,le)?(_[G]=de,_[ue]=C,G=ue):(_[G]=le,_[te]=C,G=te);else if(ue<Z&&0>s(de,C))_[G]=de,_[ue]=C,G=ue;else break e}}return T}function s(_,T){var C=_.sortIndex-T.sortIndex;return C!==0?C:_.id-T.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=[],u=1,f=null,p=3,h=!1,g=!1,b=!1,S=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=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 T=n(d);T!==null;){if(T.callback===null)r(d);else if(T.startTime<=_)r(d),T.sortIndex=T.expirationTime,t(c,T);else break;T=n(d)}}function j(_){if(b=!1,w(_),!g)if(n(c)!==null)g=!0,A(E);else{var T=n(d);T!==null&&z(j,T.startTime-_)}}function E(_,T){g=!1,b&&(b=!1,y(R),R=-1),h=!0;var C=p;try{for(w(T),f=n(c);f!==null&&(!(f.expirationTime>T)||_&&!D());){var G=f.callback;if(typeof G=="function"){f.callback=null,p=f.priorityLevel;var Z=G(f.expirationTime<=T);T=e.unstable_now(),typeof Z=="function"?f.callback=Z:f===n(c)&&r(c),w(T)}else r(c);f=n(c)}if(f!==null)var W=!0;else{var te=n(d);te!==null&&z(j,te.startTime-T),W=!1}return W}finally{f=null,p=C,h=!1}}var k=!1,I=null,R=-1,$=5,K=-1;function D(){return!(e.unstable_now()-K<$)}function L(){if(I!==null){var _=e.unstable_now();K=_;var T=!0;try{T=I(!0,_)}finally{T?H():(k=!1,I=null)}}else k=!1}var H;if(typeof v=="function")H=function(){v(L)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,O=M.port2;M.port1.onmessage=L,H=function(){O.postMessage(null)}}else H=function(){S(L,0)};function A(_){I=_,k||(k=!0,H())}function z(_,T){R=S(function(){_(e.unstable_now())},T)}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||h||(g=!0,A(E))},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"):$=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 T=3;break;default:T=p}var C=p;p=T;try{return _()}finally{p=C}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,T){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var C=p;p=_;try{return T()}finally{p=C}},e.unstable_scheduleCallback=function(_,T,C){var G=e.unstable_now();switch(typeof C=="object"&&C!==null?(C=C.delay,C=typeof C=="number"&&0<C?G+C:G):C=G,_){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=C+Z,_={id:u++,callback:T,priorityLevel:_,startTime:C,expirationTime:Z,sortIndex:-1},C>G?(_.sortIndex=C,t(d,_),n(c)===null&&_===n(d)&&(b?(y(R),R=-1):b=!0,z(j,C-G))):(_.sortIndex=Z,t(c,_),g||h||(g=!0,A(E))),_},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(_){var T=p;return function(){var C=p;p=T;try{return _.apply(this,arguments)}finally{p=C}}}})(lj);aj.exports=lj;var k2=aj.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 S2=m,Ss=k2;function ke(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 cj=new Set,cd={};function ll(e,t){mc(e,t),mc(e+"Capture",t)}function mc(e,t){for(cd[e]=t,e=0;e<t.length;e++)cj.add(t[e])}var mo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Iy=Object.prototype.hasOwnProperty,N2=/^[: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]*$/,G0={},X0={};function j2(e){return Iy.call(X0,e)?!0:Iy.call(G0,e)?!1:N2.test(e)?X0[e]=!0:(G0[e]=!0,!1)}function C2(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 E2(e,t,n,r){if(t===null||typeof t>"u"||C2(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 Wr(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 Sr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Sr[e]=new Wr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Sr[t]=new Wr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Sr[e]=new Wr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Sr[e]=new Wr(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){Sr[e]=new Wr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Sr[e]=new Wr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Sr[e]=new Wr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Sr[e]=new Wr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Sr[e]=new Wr(e,5,!1,e.toLowerCase(),null,!1,!1)});var kw=/[\-:]([a-z])/g;function Sw(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(kw,Sw);Sr[t]=new Wr(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(kw,Sw);Sr[t]=new Wr(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(kw,Sw);Sr[t]=new Wr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Sr[e]=new Wr(e,1,!1,e.toLowerCase(),null,!1,!1)});Sr.xlinkHref=new Wr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Sr[e]=new Wr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Nw(e,t,n,r){var s=Sr.hasOwnProperty(t)?Sr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(E2(t,n,s,r)&&(n=null),r||s===null?j2(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 ko=S2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Uf=Symbol.for("react.element"),Fl=Symbol.for("react.portal"),zl=Symbol.for("react.fragment"),jw=Symbol.for("react.strict_mode"),Ty=Symbol.for("react.profiler"),uj=Symbol.for("react.provider"),dj=Symbol.for("react.context"),Cw=Symbol.for("react.forward_ref"),Ry=Symbol.for("react.suspense"),Ly=Symbol.for("react.suspense_list"),Ew=Symbol.for("react.memo"),Wo=Symbol.for("react.lazy"),fj=Symbol.for("react.offscreen"),J0=Symbol.iterator;function hu(e){return e===null||typeof e!="object"?null:(e=J0&&e[J0]||e["@@iterator"],typeof e=="function"?e:null)}var En=Object.assign,fg;function Ru(e){if(fg===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);fg=t&&t[1]||""}return`
34
- `+fg+e}var pg=!1;function hg(e,t){if(!e||pg)return"";pg=!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{pg=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Ru(e):""}function _2(e){switch(e.tag){case 5:return Ru(e.type);case 16:return Ru("Lazy");case 13:return Ru("Suspense");case 19:return Ru("SuspenseList");case 0:case 2:case 15:return e=hg(e.type,!1),e;case 11:return e=hg(e.type.render,!1),e;case 1:return e=hg(e.type,!0),e;default:return""}}function Oy(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 zl:return"Fragment";case Fl:return"Portal";case Ty:return"Profiler";case jw:return"StrictMode";case Ry:return"Suspense";case Ly:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case dj:return(e.displayName||"Context")+".Consumer";case uj:return(e._context.displayName||"Context")+".Provider";case Cw:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ew:return t=e.displayName||null,t!==null?t:Oy(e.type)||"Memo";case Wo:t=e._payload,e=e._init;try{return Oy(e(t))}catch{}}return null}function P2(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 Oy(t);case 8:return t===jw?"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 da(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function pj(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function A2(e){var t=pj(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 Wf(e){e._valueTracker||(e._valueTracker=A2(e))}function hj(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=pj(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function nh(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 My(e,t){var n=t.checked;return En({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Q0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=da(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 mj(e,t){t=t.checked,t!=null&&Nw(e,"checked",t,!1)}function $y(e,t){mj(e,t);var n=da(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")?Dy(e,t.type,n):t.hasOwnProperty("defaultValue")&&Dy(e,t.type,da(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Z0(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 Dy(e,t,n){(t!=="number"||nh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Lu=Array.isArray;function sc(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+da(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 Fy(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(ke(91));return En({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function eb(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(ke(92));if(Lu(n)){if(1<n.length)throw Error(ke(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:da(n)}}function gj(e,t){var n=da(t.value),r=da(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 tb(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function yj(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 zy(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?yj(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Vf,xj=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(Vf=Vf||document.createElement("div"),Vf.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Vf.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ud(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Uu={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},I2=["Webkit","ms","Moz","O"];Object.keys(Uu).forEach(function(e){I2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Uu[t]=Uu[e]})});function wj(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Uu.hasOwnProperty(e)&&Uu[e]?(""+t).trim():t+"px"}function vj(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=wj(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var T2=En({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 By(e,t){if(t){if(T2[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ke(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ke(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ke(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ke(62))}}function Hy(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 Uy=null;function _w(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wy=null,ic=null,oc=null;function nb(e){if(e=Jd(e)){if(typeof Wy!="function")throw Error(ke(280));var t=e.stateNode;t&&(t=dm(t),Wy(e.stateNode,e.type,t))}}function bj(e){ic?oc?oc.push(e):oc=[e]:ic=e}function kj(){if(ic){var e=ic,t=oc;if(oc=ic=null,nb(e),t)for(e=0;e<t.length;e++)nb(t[e])}}function Sj(e,t){return e(t)}function Nj(){}var mg=!1;function jj(e,t,n){if(mg)return e(t,n);mg=!0;try{return Sj(e,t,n)}finally{mg=!1,(ic!==null||oc!==null)&&(Nj(),kj())}}function dd(e,t){var n=e.stateNode;if(n===null)return null;var r=dm(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(ke(231,t,typeof n));return n}var Vy=!1;if(mo)try{var mu={};Object.defineProperty(mu,"passive",{get:function(){Vy=!0}}),window.addEventListener("test",mu,mu),window.removeEventListener("test",mu,mu)}catch{Vy=!1}function R2(e,t,n,r,s,i,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(u){this.onError(u)}}var Wu=!1,rh=null,sh=!1,Ky=null,L2={onError:function(e){Wu=!0,rh=e}};function O2(e,t,n,r,s,i,a,l,c){Wu=!1,rh=null,R2.apply(L2,arguments)}function M2(e,t,n,r,s,i,a,l,c){if(O2.apply(this,arguments),Wu){if(Wu){var d=rh;Wu=!1,rh=null}else throw Error(ke(198));sh||(sh=!0,Ky=d)}}function cl(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 Cj(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 rb(e){if(cl(e)!==e)throw Error(ke(188))}function $2(e){var t=e.alternate;if(!t){if(t=cl(e),t===null)throw Error(ke(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 rb(s),e;if(i===r)return rb(s),t;i=i.sibling}throw Error(ke(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(ke(189))}}if(n.alternate!==r)throw Error(ke(190))}if(n.tag!==3)throw Error(ke(188));return n.stateNode.current===n?e:t}function Ej(e){return e=$2(e),e!==null?_j(e):null}function _j(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=_j(e);if(t!==null)return t;e=e.sibling}return null}var Pj=Ss.unstable_scheduleCallback,sb=Ss.unstable_cancelCallback,D2=Ss.unstable_shouldYield,F2=Ss.unstable_requestPaint,Dn=Ss.unstable_now,z2=Ss.unstable_getCurrentPriorityLevel,Pw=Ss.unstable_ImmediatePriority,Aj=Ss.unstable_UserBlockingPriority,ih=Ss.unstable_NormalPriority,B2=Ss.unstable_LowPriority,Ij=Ss.unstable_IdlePriority,am=null,$i=null;function H2(e){if($i&&typeof $i.onCommitFiberRoot=="function")try{$i.onCommitFiberRoot(am,e,void 0,(e.current.flags&128)===128)}catch{}}var di=Math.clz32?Math.clz32:V2,U2=Math.log,W2=Math.LN2;function V2(e){return e>>>=0,e===0?32:31-(U2(e)/W2|0)|0}var Kf=64,qf=4194304;function Ou(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 oh(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=Ou(l):(i&=a,i!==0&&(r=Ou(i)))}else a=n&~s,a!==0?r=Ou(a):i!==0&&(r=Ou(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-di(t),s=1<<n,r|=e[n],t&=~s;return r}function K2(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 q2(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-di(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=K2(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function qy(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Tj(){var e=Kf;return Kf<<=1,!(Kf&4194240)&&(Kf=64),e}function gg(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Gd(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-di(t),e[t]=n}function Y2(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-di(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Aw(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-di(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var Ut=0;function Rj(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Lj,Iw,Oj,Mj,$j,Yy=!1,Yf=[],ea=null,ta=null,na=null,fd=new Map,pd=new Map,qo=[],G2="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 ib(e,t){switch(e){case"focusin":case"focusout":ea=null;break;case"dragenter":case"dragleave":ta=null;break;case"mouseover":case"mouseout":na=null;break;case"pointerover":case"pointerout":fd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":pd.delete(t.pointerId)}}function gu(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=Jd(t),t!==null&&Iw(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function X2(e,t,n,r,s){switch(t){case"focusin":return ea=gu(ea,e,t,n,r,s),!0;case"dragenter":return ta=gu(ta,e,t,n,r,s),!0;case"mouseover":return na=gu(na,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return fd.set(i,gu(fd.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,pd.set(i,gu(pd.get(i)||null,e,t,n,r,s)),!0}return!1}function Dj(e){var t=Ha(e.target);if(t!==null){var n=cl(t);if(n!==null){if(t=n.tag,t===13){if(t=Cj(n),t!==null){e.blockedOn=t,$j(e.priority,function(){Oj(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 Lp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Gy(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Uy=r,n.target.dispatchEvent(r),Uy=null}else return t=Jd(n),t!==null&&Iw(t),e.blockedOn=n,!1;t.shift()}return!0}function ob(e,t,n){Lp(e)&&n.delete(t)}function J2(){Yy=!1,ea!==null&&Lp(ea)&&(ea=null),ta!==null&&Lp(ta)&&(ta=null),na!==null&&Lp(na)&&(na=null),fd.forEach(ob),pd.forEach(ob)}function yu(e,t){e.blockedOn===t&&(e.blockedOn=null,Yy||(Yy=!0,Ss.unstable_scheduleCallback(Ss.unstable_NormalPriority,J2)))}function hd(e){function t(s){return yu(s,e)}if(0<Yf.length){yu(Yf[0],e);for(var n=1;n<Yf.length;n++){var r=Yf[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ea!==null&&yu(ea,e),ta!==null&&yu(ta,e),na!==null&&yu(na,e),fd.forEach(t),pd.forEach(t),n=0;n<qo.length;n++)r=qo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<qo.length&&(n=qo[0],n.blockedOn===null);)Dj(n),n.blockedOn===null&&qo.shift()}var ac=ko.ReactCurrentBatchConfig,ah=!0;function Q2(e,t,n,r){var s=Ut,i=ac.transition;ac.transition=null;try{Ut=1,Tw(e,t,n,r)}finally{Ut=s,ac.transition=i}}function Z2(e,t,n,r){var s=Ut,i=ac.transition;ac.transition=null;try{Ut=4,Tw(e,t,n,r)}finally{Ut=s,ac.transition=i}}function Tw(e,t,n,r){if(ah){var s=Gy(e,t,n,r);if(s===null)Cg(e,t,r,lh,n),ib(e,r);else if(X2(s,e,t,n,r))r.stopPropagation();else if(ib(e,r),t&4&&-1<G2.indexOf(e)){for(;s!==null;){var i=Jd(s);if(i!==null&&Lj(i),i=Gy(e,t,n,r),i===null&&Cg(e,t,r,lh,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else Cg(e,t,r,null,n)}}var lh=null;function Gy(e,t,n,r){if(lh=null,e=_w(r),e=Ha(e),e!==null)if(t=cl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Cj(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 lh=e,null}function Fj(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(z2()){case Pw:return 1;case Aj:return 4;case ih:case B2:return 16;case Ij:return 536870912;default:return 16}default:return 16}}var Xo=null,Rw=null,Op=null;function zj(){if(Op)return Op;var e,t=Rw,n=t.length,r,s="value"in Xo?Xo.value:Xo.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 Op=s.slice(e,1<r?1-r:void 0)}function Mp(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 Gf(){return!0}function ab(){return!1}function Cs(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)?Gf:ab,this.isPropagationStopped=ab,this}return En(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=Gf)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Gf)},persist:function(){},isPersistent:Gf}),t}var $c={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Lw=Cs($c),Xd=En({},$c,{view:0,detail:0}),eR=Cs(Xd),yg,xg,xu,lm=En({},Xd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ow,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!==xu&&(xu&&e.type==="mousemove"?(yg=e.screenX-xu.screenX,xg=e.screenY-xu.screenY):xg=yg=0,xu=e),yg)},movementY:function(e){return"movementY"in e?e.movementY:xg}}),lb=Cs(lm),tR=En({},lm,{dataTransfer:0}),nR=Cs(tR),rR=En({},Xd,{relatedTarget:0}),wg=Cs(rR),sR=En({},$c,{animationName:0,elapsedTime:0,pseudoElement:0}),iR=Cs(sR),oR=En({},$c,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),aR=Cs(oR),lR=En({},$c,{data:0}),cb=Cs(lR),cR={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},uR={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"},dR={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function fR(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=dR[e])?!!t[e]:!1}function Ow(){return fR}var pR=En({},Xd,{key:function(e){if(e.key){var t=cR[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Mp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?uR[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ow,charCode:function(e){return e.type==="keypress"?Mp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Mp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),hR=Cs(pR),mR=En({},lm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ub=Cs(mR),gR=En({},Xd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ow}),yR=Cs(gR),xR=En({},$c,{propertyName:0,elapsedTime:0,pseudoElement:0}),wR=Cs(xR),vR=En({},lm,{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}),bR=Cs(vR),kR=[9,13,27,32],Mw=mo&&"CompositionEvent"in window,Vu=null;mo&&"documentMode"in document&&(Vu=document.documentMode);var SR=mo&&"TextEvent"in window&&!Vu,Bj=mo&&(!Mw||Vu&&8<Vu&&11>=Vu),db=" ",fb=!1;function Hj(e,t){switch(e){case"keyup":return kR.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uj(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bl=!1;function NR(e,t){switch(e){case"compositionend":return Uj(t);case"keypress":return t.which!==32?null:(fb=!0,db);case"textInput":return e=t.data,e===db&&fb?null:e;default:return null}}function jR(e,t){if(Bl)return e==="compositionend"||!Mw&&Hj(e,t)?(e=zj(),Op=Rw=Xo=null,Bl=!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 Bj&&t.locale!=="ko"?null:t.data;default:return null}}var CR={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 pb(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!CR[e.type]:t==="textarea"}function Wj(e,t,n,r){bj(r),t=ch(t,"onChange"),0<t.length&&(n=new Lw("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Ku=null,md=null;function ER(e){tC(e,0)}function cm(e){var t=Wl(e);if(hj(t))return e}function _R(e,t){if(e==="change")return t}var Vj=!1;if(mo){var vg;if(mo){var bg="oninput"in document;if(!bg){var hb=document.createElement("div");hb.setAttribute("oninput","return;"),bg=typeof hb.oninput=="function"}vg=bg}else vg=!1;Vj=vg&&(!document.documentMode||9<document.documentMode)}function mb(){Ku&&(Ku.detachEvent("onpropertychange",Kj),md=Ku=null)}function Kj(e){if(e.propertyName==="value"&&cm(md)){var t=[];Wj(t,md,e,_w(e)),jj(ER,t)}}function PR(e,t,n){e==="focusin"?(mb(),Ku=t,md=n,Ku.attachEvent("onpropertychange",Kj)):e==="focusout"&&mb()}function AR(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return cm(md)}function IR(e,t){if(e==="click")return cm(t)}function TR(e,t){if(e==="input"||e==="change")return cm(t)}function RR(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var pi=typeof Object.is=="function"?Object.is:RR;function gd(e,t){if(pi(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(!Iy.call(t,s)||!pi(e[s],t[s]))return!1}return!0}function gb(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yb(e,t){var n=gb(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=gb(n)}}function qj(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?qj(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Yj(){for(var e=window,t=nh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=nh(e.document)}return t}function $w(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 LR(e){var t=Yj(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&qj(n.ownerDocument.documentElement,n)){if(r!==null&&$w(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=yb(n,i);var a=yb(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 OR=mo&&"documentMode"in document&&11>=document.documentMode,Hl=null,Xy=null,qu=null,Jy=!1;function xb(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Jy||Hl==null||Hl!==nh(r)||(r=Hl,"selectionStart"in r&&$w(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}),qu&&gd(qu,r)||(qu=r,r=ch(Xy,"onSelect"),0<r.length&&(t=new Lw("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Hl)))}function Xf(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Ul={animationend:Xf("Animation","AnimationEnd"),animationiteration:Xf("Animation","AnimationIteration"),animationstart:Xf("Animation","AnimationStart"),transitionend:Xf("Transition","TransitionEnd")},kg={},Gj={};mo&&(Gj=document.createElement("div").style,"AnimationEvent"in window||(delete Ul.animationend.animation,delete Ul.animationiteration.animation,delete Ul.animationstart.animation),"TransitionEvent"in window||delete Ul.transitionend.transition);function um(e){if(kg[e])return kg[e];if(!Ul[e])return e;var t=Ul[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Gj)return kg[e]=t[n];return e}var Xj=um("animationend"),Jj=um("animationiteration"),Qj=um("animationstart"),Zj=um("transitionend"),eC=new Map,wb="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 wa(e,t){eC.set(e,t),ll(t,[e])}for(var Sg=0;Sg<wb.length;Sg++){var Ng=wb[Sg],MR=Ng.toLowerCase(),$R=Ng[0].toUpperCase()+Ng.slice(1);wa(MR,"on"+$R)}wa(Xj,"onAnimationEnd");wa(Jj,"onAnimationIteration");wa(Qj,"onAnimationStart");wa("dblclick","onDoubleClick");wa("focusin","onFocus");wa("focusout","onBlur");wa(Zj,"onTransitionEnd");mc("onMouseEnter",["mouseout","mouseover"]);mc("onMouseLeave",["mouseout","mouseover"]);mc("onPointerEnter",["pointerout","pointerover"]);mc("onPointerLeave",["pointerout","pointerover"]);ll("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));ll("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));ll("onBeforeInput",["compositionend","keypress","textInput","paste"]);ll("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));ll("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));ll("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mu="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(" "),DR=new Set("cancel close invalid load scroll toggle".split(" ").concat(Mu));function vb(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,M2(r,t,void 0,e),e.currentTarget=null}function tC(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;vb(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;vb(s,l,d),i=c}}}if(sh)throw e=Ky,sh=!1,Ky=null,e}function un(e,t){var n=t[nx];n===void 0&&(n=t[nx]=new Set);var r=e+"__bubble";n.has(r)||(nC(t,e,2,!1),n.add(r))}function jg(e,t,n){var r=0;t&&(r|=4),nC(n,e,r,t)}var Jf="_reactListening"+Math.random().toString(36).slice(2);function yd(e){if(!e[Jf]){e[Jf]=!0,cj.forEach(function(n){n!=="selectionchange"&&(DR.has(n)||jg(n,!1,e),jg(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Jf]||(t[Jf]=!0,jg("selectionchange",!1,t))}}function nC(e,t,n,r){switch(Fj(t)){case 1:var s=Q2;break;case 4:s=Z2;break;default:s=Tw}n=s.bind(null,t,n,e),s=void 0,!Vy||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 Cg(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=Ha(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}jj(function(){var d=i,u=_w(n),f=[];e:{var p=eC.get(e);if(p!==void 0){var h=Lw,g=e;switch(e){case"keypress":if(Mp(n)===0)break e;case"keydown":case"keyup":h=hR;break;case"focusin":g="focus",h=wg;break;case"focusout":g="blur",h=wg;break;case"beforeblur":case"afterblur":h=wg;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=lb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=nR;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=yR;break;case Xj:case Jj:case Qj:h=iR;break;case Zj:h=wR;break;case"scroll":h=eR;break;case"wheel":h=bR;break;case"copy":case"cut":case"paste":h=aR;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=ub}var b=(t&4)!==0,S=!b&&e==="scroll",y=b?p!==null?p+"Capture":null:p;b=[];for(var v=d,w;v!==null;){w=v;var j=w.stateNode;if(w.tag===5&&j!==null&&(w=j,y!==null&&(j=dd(v,y),j!=null&&b.push(xd(v,j,w)))),S)break;v=v.return}0<b.length&&(p=new h(p,g,null,n,u),f.push({event:p,listeners:b}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&n!==Uy&&(g=n.relatedTarget||n.fromElement)&&(Ha(g)||g[go]))break e;if((h||p)&&(p=u.window===u?u:(p=u.ownerDocument)?p.defaultView||p.parentWindow:window,h?(g=n.relatedTarget||n.toElement,h=d,g=g?Ha(g):null,g!==null&&(S=cl(g),g!==S||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=d),h!==g)){if(b=lb,j="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(b=ub,j="onPointerLeave",y="onPointerEnter",v="pointer"),S=h==null?p:Wl(h),w=g==null?p:Wl(g),p=new b(j,v+"leave",h,n,u),p.target=S,p.relatedTarget=w,j=null,Ha(u)===d&&(b=new b(y,v+"enter",g,n,u),b.target=w,b.relatedTarget=S,j=b),S=j,h&&g)t:{for(b=h,y=g,v=0,w=b;w;w=_l(w))v++;for(w=0,j=y;j;j=_l(j))w++;for(;0<v-w;)b=_l(b),v--;for(;0<w-v;)y=_l(y),w--;for(;v--;){if(b===y||y!==null&&b===y.alternate)break t;b=_l(b),y=_l(y)}b=null}else b=null;h!==null&&bb(f,p,h,b,!1),g!==null&&S!==null&&bb(f,S,g,b,!0)}}e:{if(p=d?Wl(d):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var E=_R;else if(pb(p))if(Vj)E=TR;else{E=AR;var k=PR}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(E=IR);if(E&&(E=E(e,d))){Wj(f,E,n,u);break e}k&&k(e,p,d),e==="focusout"&&(k=p._wrapperState)&&k.controlled&&p.type==="number"&&Dy(p,"number",p.value)}switch(k=d?Wl(d):window,e){case"focusin":(pb(k)||k.contentEditable==="true")&&(Hl=k,Xy=d,qu=null);break;case"focusout":qu=Xy=Hl=null;break;case"mousedown":Jy=!0;break;case"contextmenu":case"mouseup":case"dragend":Jy=!1,xb(f,n,u);break;case"selectionchange":if(OR)break;case"keydown":case"keyup":xb(f,n,u)}var I;if(Mw)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else Bl?Hj(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(Bj&&n.locale!=="ko"&&(Bl||R!=="onCompositionStart"?R==="onCompositionEnd"&&Bl&&(I=zj()):(Xo=u,Rw="value"in Xo?Xo.value:Xo.textContent,Bl=!0)),k=ch(d,R),0<k.length&&(R=new cb(R,e,null,n,u),f.push({event:R,listeners:k}),I?R.data=I:(I=Uj(n),I!==null&&(R.data=I)))),(I=SR?NR(e,n):jR(e,n))&&(d=ch(d,"onBeforeInput"),0<d.length&&(u=new cb("onBeforeInput","beforeinput",null,n,u),f.push({event:u,listeners:d}),u.data=I))}tC(f,t)})}function xd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ch(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=dd(e,n),i!=null&&r.unshift(xd(e,i,s)),i=dd(e,t),i!=null&&r.push(xd(e,i,s))),e=e.return}return r}function _l(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function bb(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=dd(n,i),c!=null&&a.unshift(xd(n,c,l))):s||(c=dd(n,i),c!=null&&a.push(xd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var FR=/\r\n?/g,zR=/\u0000|\uFFFD/g;function kb(e){return(typeof e=="string"?e:""+e).replace(FR,`
38
- `).replace(zR,"")}function Qf(e,t,n){if(t=kb(t),kb(e)!==t&&n)throw Error(ke(425))}function uh(){}var Qy=null,Zy=null;function ex(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 tx=typeof setTimeout=="function"?setTimeout:void 0,BR=typeof clearTimeout=="function"?clearTimeout:void 0,Sb=typeof Promise=="function"?Promise:void 0,HR=typeof queueMicrotask=="function"?queueMicrotask:typeof Sb<"u"?function(e){return Sb.resolve(null).then(e).catch(UR)}:tx;function UR(e){setTimeout(function(){throw e})}function Eg(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),hd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);hd(t)}function ra(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 Nb(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 Dc=Math.random().toString(36).slice(2),Ri="__reactFiber$"+Dc,wd="__reactProps$"+Dc,go="__reactContainer$"+Dc,nx="__reactEvents$"+Dc,WR="__reactListeners$"+Dc,VR="__reactHandles$"+Dc;function Ha(e){var t=e[Ri];if(t)return t;for(var n=e.parentNode;n;){if(t=n[go]||n[Ri]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Nb(e);e!==null;){if(n=e[Ri])return n;e=Nb(e)}return t}e=n,n=e.parentNode}return null}function Jd(e){return e=e[Ri]||e[go],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Wl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(ke(33))}function dm(e){return e[wd]||null}var rx=[],Vl=-1;function va(e){return{current:e}}function fn(e){0>Vl||(e.current=rx[Vl],rx[Vl]=null,Vl--)}function rn(e,t){Vl++,rx[Vl]=e.current,e.current=t}var fa={},Lr=va(fa),os=va(!1),Qa=fa;function gc(e,t){var n=e.type.contextTypes;if(!n)return fa;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 as(e){return e=e.childContextTypes,e!=null}function dh(){fn(os),fn(Lr)}function jb(e,t,n){if(Lr.current!==fa)throw Error(ke(168));rn(Lr,t),rn(os,n)}function rC(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(ke(108,P2(e)||"Unknown",s));return En({},n,r)}function fh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||fa,Qa=Lr.current,rn(Lr,e),rn(os,os.current),!0}function Cb(e,t,n){var r=e.stateNode;if(!r)throw Error(ke(169));n?(e=rC(e,t,Qa),r.__reactInternalMemoizedMergedChildContext=e,fn(os),fn(Lr),rn(Lr,e)):fn(os),rn(os,n)}var oo=null,fm=!1,_g=!1;function sC(e){oo===null?oo=[e]:oo.push(e)}function KR(e){fm=!0,sC(e)}function ba(){if(!_g&&oo!==null){_g=!0;var e=0,t=Ut;try{var n=oo;for(Ut=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}oo=null,fm=!1}catch(s){throw oo!==null&&(oo=oo.slice(e+1)),Pj(Pw,ba),s}finally{Ut=t,_g=!1}}return null}var Kl=[],ql=0,ph=null,hh=0,Ls=[],Os=0,Za=null,co=1,uo="";function Da(e,t){Kl[ql++]=hh,Kl[ql++]=ph,ph=e,hh=t}function iC(e,t,n){Ls[Os++]=co,Ls[Os++]=uo,Ls[Os++]=Za,Za=e;var r=co;e=uo;var s=32-di(r)-1;r&=~(1<<s),n+=1;var i=32-di(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,co=1<<32-di(t)+s|n<<s|r,uo=i+e}else co=1<<i|n<<s|r,uo=e}function Dw(e){e.return!==null&&(Da(e,1),iC(e,1,0))}function Fw(e){for(;e===ph;)ph=Kl[--ql],Kl[ql]=null,hh=Kl[--ql],Kl[ql]=null;for(;e===Za;)Za=Ls[--Os],Ls[Os]=null,uo=Ls[--Os],Ls[Os]=null,co=Ls[--Os],Ls[Os]=null}var bs=null,ws=null,wn=!1,oi=null;function oC(e,t){var n=Ds(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 Eb(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,bs=e,ws=ra(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,bs=e,ws=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Za!==null?{id:co,overflow:uo}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ds(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,bs=e,ws=null,!0):!1;default:return!1}}function sx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ix(e){if(wn){var t=ws;if(t){var n=t;if(!Eb(e,t)){if(sx(e))throw Error(ke(418));t=ra(n.nextSibling);var r=bs;t&&Eb(e,t)?oC(r,n):(e.flags=e.flags&-4097|2,wn=!1,bs=e)}}else{if(sx(e))throw Error(ke(418));e.flags=e.flags&-4097|2,wn=!1,bs=e}}}function _b(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;bs=e}function Zf(e){if(e!==bs)return!1;if(!wn)return _b(e),wn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!ex(e.type,e.memoizedProps)),t&&(t=ws)){if(sx(e))throw aC(),Error(ke(418));for(;t;)oC(e,t),t=ra(t.nextSibling)}if(_b(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ke(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ws=ra(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ws=null}}else ws=bs?ra(e.stateNode.nextSibling):null;return!0}function aC(){for(var e=ws;e;)e=ra(e.nextSibling)}function yc(){ws=bs=null,wn=!1}function zw(e){oi===null?oi=[e]:oi.push(e)}var qR=ko.ReactCurrentBatchConfig;function wu(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(ke(309));var r=n.stateNode}if(!r)throw Error(ke(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(ke(284));if(!n._owner)throw Error(ke(290,e))}return e}function ep(e,t){throw e=Object.prototype.toString.call(t),Error(ke(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Pb(e){var t=e._init;return t(e._payload)}function lC(e){function t(y,v){if(e){var w=y.deletions;w===null?(y.deletions=[v],y.flags|=16):w.push(v)}}function n(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function s(y,v){return y=aa(y,v),y.index=0,y.sibling=null,y}function i(y,v,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<v?(y.flags|=2,v):w):(y.flags|=2,v)):(y.flags|=1048576,v)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,v,w,j){return v===null||v.tag!==6?(v=Og(w,y.mode,j),v.return=y,v):(v=s(v,w),v.return=y,v)}function c(y,v,w,j){var E=w.type;return E===zl?u(y,v,w.props.children,j,w.key):v!==null&&(v.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Wo&&Pb(E)===v.type)?(j=s(v,w.props),j.ref=wu(y,v,w),j.return=y,j):(j=Up(w.type,w.key,w.props,null,y.mode,j),j.ref=wu(y,v,w),j.return=y,j)}function d(y,v,w,j){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=Mg(w,y.mode,j),v.return=y,v):(v=s(v,w.children||[]),v.return=y,v)}function u(y,v,w,j,E){return v===null||v.tag!==7?(v=qa(w,y.mode,j,E),v.return=y,v):(v=s(v,w),v.return=y,v)}function f(y,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Og(""+v,y.mode,w),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Uf:return w=Up(v.type,v.key,v.props,null,y.mode,w),w.ref=wu(y,null,v),w.return=y,w;case Fl:return v=Mg(v,y.mode,w),v.return=y,v;case Wo:var j=v._init;return f(y,j(v._payload),w)}if(Lu(v)||hu(v))return v=qa(v,y.mode,w,null),v.return=y,v;ep(y,v)}return null}function p(y,v,w,j){var E=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return E!==null?null:l(y,v,""+w,j);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Uf:return w.key===E?c(y,v,w,j):null;case Fl:return w.key===E?d(y,v,w,j):null;case Wo:return E=w._init,p(y,v,E(w._payload),j)}if(Lu(w)||hu(w))return E!==null?null:u(y,v,w,j,null);ep(y,w)}return null}function h(y,v,w,j,E){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(w)||null,l(v,y,""+j,E);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Uf:return y=y.get(j.key===null?w:j.key)||null,c(v,y,j,E);case Fl:return y=y.get(j.key===null?w:j.key)||null,d(v,y,j,E);case Wo:var k=j._init;return h(y,v,w,k(j._payload),E)}if(Lu(j)||hu(j))return y=y.get(w)||null,u(v,y,j,E,null);ep(v,j)}return null}function g(y,v,w,j){for(var E=null,k=null,I=v,R=v=0,$=null;I!==null&&R<w.length;R++){I.index>R?($=I,I=null):$=I.sibling;var K=p(y,I,w[R],j);if(K===null){I===null&&(I=$);break}e&&I&&K.alternate===null&&t(y,I),v=i(K,v,R),k===null?E=K:k.sibling=K,k=K,I=$}if(R===w.length)return n(y,I),wn&&Da(y,R),E;if(I===null){for(;R<w.length;R++)I=f(y,w[R],j),I!==null&&(v=i(I,v,R),k===null?E=I:k.sibling=I,k=I);return wn&&Da(y,R),E}for(I=r(y,I);R<w.length;R++)$=h(I,y,R,w[R],j),$!==null&&(e&&$.alternate!==null&&I.delete($.key===null?R:$.key),v=i($,v,R),k===null?E=$:k.sibling=$,k=$);return e&&I.forEach(function(D){return t(y,D)}),wn&&Da(y,R),E}function b(y,v,w,j){var E=hu(w);if(typeof E!="function")throw Error(ke(150));if(w=E.call(w),w==null)throw Error(ke(151));for(var k=E=null,I=v,R=v=0,$=null,K=w.next();I!==null&&!K.done;R++,K=w.next()){I.index>R?($=I,I=null):$=I.sibling;var D=p(y,I,K.value,j);if(D===null){I===null&&(I=$);break}e&&I&&D.alternate===null&&t(y,I),v=i(D,v,R),k===null?E=D:k.sibling=D,k=D,I=$}if(K.done)return n(y,I),wn&&Da(y,R),E;if(I===null){for(;!K.done;R++,K=w.next())K=f(y,K.value,j),K!==null&&(v=i(K,v,R),k===null?E=K:k.sibling=K,k=K);return wn&&Da(y,R),E}for(I=r(y,I);!K.done;R++,K=w.next())K=h(I,y,R,K.value,j),K!==null&&(e&&K.alternate!==null&&I.delete(K.key===null?R:K.key),v=i(K,v,R),k===null?E=K:k.sibling=K,k=K);return e&&I.forEach(function(L){return t(y,L)}),wn&&Da(y,R),E}function S(y,v,w,j){if(typeof w=="object"&&w!==null&&w.type===zl&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Uf:e:{for(var E=w.key,k=v;k!==null;){if(k.key===E){if(E=w.type,E===zl){if(k.tag===7){n(y,k.sibling),v=s(k,w.props.children),v.return=y,y=v;break e}}else if(k.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Wo&&Pb(E)===k.type){n(y,k.sibling),v=s(k,w.props),v.ref=wu(y,k,w),v.return=y,y=v;break e}n(y,k);break}else t(y,k);k=k.sibling}w.type===zl?(v=qa(w.props.children,y.mode,j,w.key),v.return=y,y=v):(j=Up(w.type,w.key,w.props,null,y.mode,j),j.ref=wu(y,v,w),j.return=y,y=j)}return a(y);case Fl:e:{for(k=w.key;v!==null;){if(v.key===k)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(y,v.sibling),v=s(v,w.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=Mg(w,y.mode,j),v.return=y,y=v}return a(y);case Wo:return k=w._init,S(y,v,k(w._payload),j)}if(Lu(w))return g(y,v,w,j);if(hu(w))return b(y,v,w,j);ep(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(y,v.sibling),v=s(v,w),v.return=y,y=v):(n(y,v),v=Og(w,y.mode,j),v.return=y,y=v),a(y)):n(y,v)}return S}var xc=lC(!0),cC=lC(!1),mh=va(null),gh=null,Yl=null,Bw=null;function Hw(){Bw=Yl=gh=null}function Uw(e){var t=mh.current;fn(mh),e._currentValue=t}function ox(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function lc(e,t){gh=e,Bw=Yl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ts=!0),e.firstContext=null)}function zs(e){var t=e._currentValue;if(Bw!==e)if(e={context:e,memoizedValue:t,next:null},Yl===null){if(gh===null)throw Error(ke(308));Yl=e,gh.dependencies={lanes:0,firstContext:e}}else Yl=Yl.next=e;return t}var Ua=null;function Ww(e){Ua===null?Ua=[e]:Ua.push(e)}function uC(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ww(t)):(n.next=s.next,s.next=n),t.interleaved=n,yo(e,r)}function yo(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 Vo=!1;function Vw(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dC(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 ho(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function sa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,$t&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,yo(e,n)}return s=r.interleaved,s===null?(t.next=t,Ww(r)):(t.next=s.next,s.next=t),r.interleaved=t,yo(e,n)}function $p(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,Aw(e,n)}}function Ab(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 yh(e,t,n,r){var s=e.updateQueue;Vo=!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 u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==a&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;a=0,u=d=c=null,l=i;do{var p=l.lane,h=l.eventTime;if((r&p)===p){u!==null&&(u=u.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,b=l;switch(p=t,h=n,b.tag){case 1:if(g=b.payload,typeof g=="function"){f=g.call(h,f,p);break e}f=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,p=typeof g=="function"?g.call(h,f,p):g,p==null)break e;f=En({},f,p);break e;case 2:Vo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=h,c=f):u=u.next=h,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(u===null&&(c=f),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=u,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);tl|=a,e.lanes=a,e.memoizedState=f}}function Ib(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(ke(191,s));s.call(r)}}}var Qd={},Di=va(Qd),vd=va(Qd),bd=va(Qd);function Wa(e){if(e===Qd)throw Error(ke(174));return e}function Kw(e,t){switch(rn(bd,t),rn(vd,e),rn(Di,Qd),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:zy(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=zy(t,e)}fn(Di),rn(Di,t)}function wc(){fn(Di),fn(vd),fn(bd)}function fC(e){Wa(bd.current);var t=Wa(Di.current),n=zy(t,e.type);t!==n&&(rn(vd,e),rn(Di,n))}function qw(e){vd.current===e&&(fn(Di),fn(vd))}var jn=va(0);function xh(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 Pg=[];function Yw(){for(var e=0;e<Pg.length;e++)Pg[e]._workInProgressVersionPrimary=null;Pg.length=0}var Dp=ko.ReactCurrentDispatcher,Ag=ko.ReactCurrentBatchConfig,el=0,Cn=null,er=null,cr=null,wh=!1,Yu=!1,kd=0,YR=0;function Ar(){throw Error(ke(321))}function Gw(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!pi(e[n],t[n]))return!1;return!0}function Xw(e,t,n,r,s,i){if(el=i,Cn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Dp.current=e===null||e.memoizedState===null?QR:ZR,e=n(r,s),Yu){i=0;do{if(Yu=!1,kd=0,25<=i)throw Error(ke(301));i+=1,cr=er=null,t.updateQueue=null,Dp.current=eL,e=n(r,s)}while(Yu)}if(Dp.current=vh,t=er!==null&&er.next!==null,el=0,cr=er=Cn=null,wh=!1,t)throw Error(ke(300));return e}function Jw(){var e=kd!==0;return kd=0,e}function Pi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cr===null?Cn.memoizedState=cr=e:cr=cr.next=e,cr}function Bs(){if(er===null){var e=Cn.alternate;e=e!==null?e.memoizedState:null}else e=er.next;var t=cr===null?Cn.memoizedState:cr.next;if(t!==null)cr=t,er=e;else{if(e===null)throw Error(ke(310));er=e,e={memoizedState:er.memoizedState,baseState:er.baseState,baseQueue:er.baseQueue,queue:er.queue,next:null},cr===null?Cn.memoizedState=cr=e:cr=cr.next=e}return cr}function Sd(e,t){return typeof t=="function"?t(e):t}function Ig(e){var t=Bs(),n=t.queue;if(n===null)throw Error(ke(311));n.lastRenderedReducer=e;var r=er,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 u=d.lane;if((el&u)===u)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 f={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Cn.lanes|=u,tl|=u}d=d.next}while(d!==null&&d!==i);c===null?a=r:c.next=l,pi(r,t.memoizedState)||(ts=!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,Cn.lanes|=i,tl|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Tg(e){var t=Bs(),n=t.queue;if(n===null)throw Error(ke(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);pi(i,t.memoizedState)||(ts=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function pC(){}function hC(e,t){var n=Cn,r=Bs(),s=t(),i=!pi(r.memoizedState,s);if(i&&(r.memoizedState=s,ts=!0),r=r.queue,Qw(yC.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||cr!==null&&cr.memoizedState.tag&1){if(n.flags|=2048,Nd(9,gC.bind(null,n,r,s,t),void 0,null),dr===null)throw Error(ke(349));el&30||mC(n,t,s)}return s}function mC(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Cn.updateQueue,t===null?(t={lastEffect:null,stores:null},Cn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function gC(e,t,n,r){t.value=n,t.getSnapshot=r,xC(t)&&wC(e)}function yC(e,t,n){return n(function(){xC(t)&&wC(e)})}function xC(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!pi(e,n)}catch{return!0}}function wC(e){var t=yo(e,1);t!==null&&fi(t,e,1,-1)}function Tb(e){var t=Pi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Sd,lastRenderedState:e},t.queue=e,e=e.dispatch=JR.bind(null,Cn,e),[t.memoizedState,e]}function Nd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Cn.updateQueue,t===null?(t={lastEffect:null,stores:null},Cn.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 vC(){return Bs().memoizedState}function Fp(e,t,n,r){var s=Pi();Cn.flags|=e,s.memoizedState=Nd(1|t,n,void 0,r===void 0?null:r)}function pm(e,t,n,r){var s=Bs();r=r===void 0?null:r;var i=void 0;if(er!==null){var a=er.memoizedState;if(i=a.destroy,r!==null&&Gw(r,a.deps)){s.memoizedState=Nd(t,n,i,r);return}}Cn.flags|=e,s.memoizedState=Nd(1|t,n,i,r)}function Rb(e,t){return Fp(8390656,8,e,t)}function Qw(e,t){return pm(2048,8,e,t)}function bC(e,t){return pm(4,2,e,t)}function kC(e,t){return pm(4,4,e,t)}function SC(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 NC(e,t,n){return n=n!=null?n.concat([e]):null,pm(4,4,SC.bind(null,t,e),n)}function Zw(){}function jC(e,t){var n=Bs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Gw(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function CC(e,t){var n=Bs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Gw(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function EC(e,t,n){return el&21?(pi(n,t)||(n=Tj(),Cn.lanes|=n,tl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ts=!0),e.memoizedState=n)}function GR(e,t){var n=Ut;Ut=n!==0&&4>n?n:4,e(!0);var r=Ag.transition;Ag.transition={};try{e(!1),t()}finally{Ut=n,Ag.transition=r}}function _C(){return Bs().memoizedState}function XR(e,t,n){var r=oa(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},PC(e))AC(t,n);else if(n=uC(e,t,n,r),n!==null){var s=Hr();fi(n,e,r,s),IC(n,t,r)}}function JR(e,t,n){var r=oa(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(PC(e))AC(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,pi(l,a)){var c=t.interleaved;c===null?(s.next=s,Ww(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=uC(e,t,s,r),n!==null&&(s=Hr(),fi(n,e,r,s),IC(n,t,r))}}function PC(e){var t=e.alternate;return e===Cn||t!==null&&t===Cn}function AC(e,t){Yu=wh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function IC(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Aw(e,n)}}var vh={readContext:zs,useCallback:Ar,useContext:Ar,useEffect:Ar,useImperativeHandle:Ar,useInsertionEffect:Ar,useLayoutEffect:Ar,useMemo:Ar,useReducer:Ar,useRef:Ar,useState:Ar,useDebugValue:Ar,useDeferredValue:Ar,useTransition:Ar,useMutableSource:Ar,useSyncExternalStore:Ar,useId:Ar,unstable_isNewReconciler:!1},QR={readContext:zs,useCallback:function(e,t){return Pi().memoizedState=[e,t===void 0?null:t],e},useContext:zs,useEffect:Rb,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fp(4194308,4,SC.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fp(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fp(4,2,e,t)},useMemo:function(e,t){var n=Pi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Pi();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=XR.bind(null,Cn,e),[r.memoizedState,e]},useRef:function(e){var t=Pi();return e={current:e},t.memoizedState=e},useState:Tb,useDebugValue:Zw,useDeferredValue:function(e){return Pi().memoizedState=e},useTransition:function(){var e=Tb(!1),t=e[0];return e=GR.bind(null,e[1]),Pi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Cn,s=Pi();if(wn){if(n===void 0)throw Error(ke(407));n=n()}else{if(n=t(),dr===null)throw Error(ke(349));el&30||mC(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Rb(yC.bind(null,r,i,e),[e]),r.flags|=2048,Nd(9,gC.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Pi(),t=dr.identifierPrefix;if(wn){var n=uo,r=co;n=(r&~(1<<32-di(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=kd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=YR++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ZR={readContext:zs,useCallback:jC,useContext:zs,useEffect:Qw,useImperativeHandle:NC,useInsertionEffect:bC,useLayoutEffect:kC,useMemo:CC,useReducer:Ig,useRef:vC,useState:function(){return Ig(Sd)},useDebugValue:Zw,useDeferredValue:function(e){var t=Bs();return EC(t,er.memoizedState,e)},useTransition:function(){var e=Ig(Sd)[0],t=Bs().memoizedState;return[e,t]},useMutableSource:pC,useSyncExternalStore:hC,useId:_C,unstable_isNewReconciler:!1},eL={readContext:zs,useCallback:jC,useContext:zs,useEffect:Qw,useImperativeHandle:NC,useInsertionEffect:bC,useLayoutEffect:kC,useMemo:CC,useReducer:Tg,useRef:vC,useState:function(){return Tg(Sd)},useDebugValue:Zw,useDeferredValue:function(e){var t=Bs();return er===null?t.memoizedState=e:EC(t,er.memoizedState,e)},useTransition:function(){var e=Tg(Sd)[0],t=Bs().memoizedState;return[e,t]},useMutableSource:pC,useSyncExternalStore:hC,useId:_C,unstable_isNewReconciler:!1};function ri(e,t){if(e&&e.defaultProps){t=En({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ax(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:En({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var hm={isMounted:function(e){return(e=e._reactInternals)?cl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Hr(),s=oa(e),i=ho(r,s);i.payload=t,n!=null&&(i.callback=n),t=sa(e,i,s),t!==null&&(fi(t,e,s,r),$p(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Hr(),s=oa(e),i=ho(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=sa(e,i,s),t!==null&&(fi(t,e,s,r),$p(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Hr(),r=oa(e),s=ho(n,r);s.tag=2,t!=null&&(s.callback=t),t=sa(e,s,r),t!==null&&(fi(t,e,r,n),$p(t,e,r))}};function Lb(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?!gd(n,r)||!gd(s,i):!0}function TC(e,t,n){var r=!1,s=fa,i=t.contextType;return typeof i=="object"&&i!==null?i=zs(i):(s=as(t)?Qa:Lr.current,r=t.contextTypes,i=(r=r!=null)?gc(e,s):fa),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=hm,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function Ob(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&&hm.enqueueReplaceState(t,t.state,null)}function lx(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},Vw(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=zs(i):(i=as(t)?Qa:Lr.current,s.context=gc(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(ax(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&&hm.enqueueReplaceState(s,s.state,null),yh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function vc(e,t){try{var n="",r=t;do n+=_2(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 Rg(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function cx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var tL=typeof WeakMap=="function"?WeakMap:Map;function RC(e,t,n){n=ho(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){kh||(kh=!0,wx=r),cx(e,t)},n}function LC(e,t,n){n=ho(-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(){cx(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){cx(e,t),typeof r!="function"&&(ia===null?ia=new Set([this]):ia.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Mb(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new tL;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=mL.bind(null,e,t,n),t.then(e,e))}function $b(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 Db(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=ho(-1,1),t.tag=2,sa(n,t,1))),n.lanes|=1),e)}var nL=ko.ReactCurrentOwner,ts=!1;function zr(e,t,n,r){t.child=e===null?cC(t,null,n,r):xc(t,e.child,n,r)}function Fb(e,t,n,r,s){n=n.render;var i=t.ref;return lc(t,s),r=Xw(e,t,n,r,i,s),n=Jw(),e!==null&&!ts?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,xo(e,t,s)):(wn&&n&&Dw(t),t.flags|=1,zr(e,t,r,s),t.child)}function zb(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!av(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,OC(e,t,i,r,s)):(e=Up(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:gd,n(a,r)&&e.ref===t.ref)return xo(e,t,s)}return t.flags|=1,e=aa(i,r),e.ref=t.ref,e.return=t,t.child=e}function OC(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(gd(i,r)&&e.ref===t.ref)if(ts=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ts=!0);else return t.lanes=e.lanes,xo(e,t,s)}return ux(e,t,n,r,s)}function MC(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},rn(Xl,gs),gs|=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,rn(Xl,gs),gs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,rn(Xl,gs),gs|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,rn(Xl,gs),gs|=r;return zr(e,t,s,n),t.child}function $C(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ux(e,t,n,r,s){var i=as(n)?Qa:Lr.current;return i=gc(t,i),lc(t,s),n=Xw(e,t,n,r,i,s),r=Jw(),e!==null&&!ts?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,xo(e,t,s)):(wn&&r&&Dw(t),t.flags|=1,zr(e,t,n,s),t.child)}function Bb(e,t,n,r,s){if(as(n)){var i=!0;fh(t)}else i=!1;if(lc(t,s),t.stateNode===null)zp(e,t),TC(t,n,r),lx(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=zs(d):(d=as(n)?Qa:Lr.current,d=gc(t,d));var u=n.getDerivedStateFromProps,f=typeof u=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&Ob(t,a,r,d),Vo=!1;var p=t.memoizedState;a.state=p,yh(t,r,a,s),c=t.memoizedState,l!==r||p!==c||os.current||Vo?(typeof u=="function"&&(ax(t,n,u,r),c=t.memoizedState),(l=Vo||Lb(t,n,l,r,p,c,d))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,dC(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:ri(t.type,l),a.props=d,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=zs(c):(c=as(n)?Qa:Lr.current,c=gc(t,c));var h=n.getDerivedStateFromProps;(u=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&Ob(t,a,r,c),Vo=!1,p=t.memoizedState,a.state=p,yh(t,r,a,s);var g=t.memoizedState;l!==f||p!==g||os.current||Vo?(typeof h=="function"&&(ax(t,n,h,r),g=t.memoizedState),(d=Vo||Lb(t,n,d,r,p,g,c)||!1)?(u||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 dx(e,t,n,r,i,s)}function dx(e,t,n,r,s,i){$C(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Cb(t,n,!1),xo(e,t,i);r=t.stateNode,nL.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=xc(t,e.child,null,i),t.child=xc(t,null,l,i)):zr(e,t,l,i),t.memoizedState=r.state,s&&Cb(t,n,!0),t.child}function DC(e){var t=e.stateNode;t.pendingContext?jb(e,t.pendingContext,t.pendingContext!==t.context):t.context&&jb(e,t.context,!1),Kw(e,t.containerInfo)}function Hb(e,t,n,r,s){return yc(),zw(s),t.flags|=256,zr(e,t,n,r),t.child}var fx={dehydrated:null,treeContext:null,retryLane:0};function px(e){return{baseLanes:e,cachePool:null,transitions:null}}function FC(e,t,n){var r=t.pendingProps,s=jn.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),rn(jn,s&1),e===null)return ix(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=ym(a,r,0,null),e=qa(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=px(n),t.memoizedState=fx,e):ev(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return rL(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=aa(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=aa(l,i):(i=qa(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?px(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=fx,r}return i=e.child,e=i.sibling,r=aa(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 ev(e,t){return t=ym({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function tp(e,t,n,r){return r!==null&&zw(r),xc(t,e.child,null,n),e=ev(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function rL(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=Rg(Error(ke(422))),tp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=ym({mode:"visible",children:r.children},s,0,null),i=qa(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&xc(t,e.child,null,a),t.child.memoizedState=px(a),t.memoizedState=fx,i);if(!(t.mode&1))return tp(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(ke(419)),r=Rg(i,r,void 0),tp(e,t,a,r)}if(l=(a&e.childLanes)!==0,ts||l){if(r=dr,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,yo(e,s),fi(r,e,s,-1))}return ov(),r=Rg(Error(ke(421))),tp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=gL.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,ws=ra(s.nextSibling),bs=t,wn=!0,oi=null,e!==null&&(Ls[Os++]=co,Ls[Os++]=uo,Ls[Os++]=Za,co=e.id,uo=e.overflow,Za=t),t=ev(t,r.children),t.flags|=4096,t)}function Ub(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ox(e.return,t,n)}function Lg(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 zC(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(zr(e,t,r.children,n),r=jn.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&&Ub(e,n,t);else if(e.tag===19)Ub(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(rn(jn,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&&xh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Lg(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&&xh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Lg(t,!0,n,null,i);break;case"together":Lg(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function zp(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function xo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),tl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(ke(153));if(t.child!==null){for(e=t.child,n=aa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=aa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function sL(e,t,n){switch(t.tag){case 3:DC(t),yc();break;case 5:fC(t);break;case 1:as(t.type)&&fh(t);break;case 4:Kw(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;rn(mh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(rn(jn,jn.current&1),t.flags|=128,null):n&t.child.childLanes?FC(e,t,n):(rn(jn,jn.current&1),e=xo(e,t,n),e!==null?e.sibling:null);rn(jn,jn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return zC(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),rn(jn,jn.current),r)break;return null;case 22:case 23:return t.lanes=0,MC(e,t,n)}return xo(e,t,n)}var BC,hx,HC,UC;BC=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}};hx=function(){};HC=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Wa(Di.current);var i=null;switch(n){case"input":s=My(e,s),r=My(e,r),i=[];break;case"select":s=En({},s,{value:void 0}),r=En({},r,{value:void 0}),i=[];break;case"textarea":s=Fy(e,s),r=Fy(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=uh)}By(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"&&(cd.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"&&(cd.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&un("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)}};UC=function(e,t,n,r){n!==r&&(t.flags|=4)};function vu(e,t){if(!wn)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 Ir(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 iL(e,t,n){var r=t.pendingProps;switch(Fw(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ir(t),null;case 1:return as(t.type)&&dh(),Ir(t),null;case 3:return r=t.stateNode,wc(),fn(os),fn(Lr),Yw(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Zf(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,oi!==null&&(kx(oi),oi=null))),hx(e,t),Ir(t),null;case 5:qw(t);var s=Wa(bd.current);if(n=t.type,e!==null&&t.stateNode!=null)HC(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(ke(166));return Ir(t),null}if(e=Wa(Di.current),Zf(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[Ri]=t,r[wd]=i,e=(t.mode&1)!==0,n){case"dialog":un("cancel",r),un("close",r);break;case"iframe":case"object":case"embed":un("load",r);break;case"video":case"audio":for(s=0;s<Mu.length;s++)un(Mu[s],r);break;case"source":un("error",r);break;case"img":case"image":case"link":un("error",r),un("load",r);break;case"details":un("toggle",r);break;case"input":Q0(r,i),un("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},un("invalid",r);break;case"textarea":eb(r,i),un("invalid",r)}By(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&&Qf(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Qf(r.textContent,l,e),s=["children",""+l]):cd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&un("scroll",r)}switch(n){case"input":Wf(r),Z0(r,i,!0);break;case"textarea":Wf(r),tb(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=uh)}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=yj(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[Ri]=t,e[wd]=r,BC(e,t,!1,!1),t.stateNode=e;e:{switch(a=Hy(n,r),n){case"dialog":un("cancel",e),un("close",e),s=r;break;case"iframe":case"object":case"embed":un("load",e),s=r;break;case"video":case"audio":for(s=0;s<Mu.length;s++)un(Mu[s],e);s=r;break;case"source":un("error",e),s=r;break;case"img":case"image":case"link":un("error",e),un("load",e),s=r;break;case"details":un("toggle",e),s=r;break;case"input":Q0(e,r),s=My(e,r),un("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=En({},r,{value:void 0}),un("invalid",e);break;case"textarea":eb(e,r),s=Fy(e,r),un("invalid",e);break;default:s=r}By(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?vj(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&xj(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&ud(e,c):typeof c=="number"&&ud(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(cd.hasOwnProperty(i)?c!=null&&i==="onScroll"&&un("scroll",e):c!=null&&Nw(e,i,c,a))}switch(n){case"input":Wf(e),Z0(e,r,!1);break;case"textarea":Wf(e),tb(e);break;case"option":r.value!=null&&e.setAttribute("value",""+da(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?sc(e,!!r.multiple,i,!1):r.defaultValue!=null&&sc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=uh)}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 Ir(t),null;case 6:if(e&&t.stateNode!=null)UC(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(ke(166));if(n=Wa(bd.current),Wa(Di.current),Zf(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ri]=t,(i=r.nodeValue!==n)&&(e=bs,e!==null))switch(e.tag){case 3:Qf(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Qf(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ri]=t,t.stateNode=r}return Ir(t),null;case 13:if(fn(jn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(wn&&ws!==null&&t.mode&1&&!(t.flags&128))aC(),yc(),t.flags|=98560,i=!1;else if(i=Zf(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(ke(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(ke(317));i[Ri]=t}else yc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ir(t),i=!1}else oi!==null&&(kx(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||jn.current&1?nr===0&&(nr=3):ov())),t.updateQueue!==null&&(t.flags|=4),Ir(t),null);case 4:return wc(),hx(e,t),e===null&&yd(t.stateNode.containerInfo),Ir(t),null;case 10:return Uw(t.type._context),Ir(t),null;case 17:return as(t.type)&&dh(),Ir(t),null;case 19:if(fn(jn),i=t.memoizedState,i===null)return Ir(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)vu(i,!1);else{if(nr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=xh(e),a!==null){for(t.flags|=128,vu(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 rn(jn,jn.current&1|2),t.child}e=e.sibling}i.tail!==null&&Dn()>bc&&(t.flags|=128,r=!0,vu(i,!1),t.lanes=4194304)}else{if(!r)if(e=xh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),vu(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!wn)return Ir(t),null}else 2*Dn()-i.renderingStartTime>bc&&n!==1073741824&&(t.flags|=128,r=!0,vu(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=Dn(),t.sibling=null,n=jn.current,rn(jn,r?n&1|2:n&1),t):(Ir(t),null);case 22:case 23:return iv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?gs&1073741824&&(Ir(t),t.subtreeFlags&6&&(t.flags|=8192)):Ir(t),null;case 24:return null;case 25:return null}throw Error(ke(156,t.tag))}function oL(e,t){switch(Fw(t),t.tag){case 1:return as(t.type)&&dh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return wc(),fn(os),fn(Lr),Yw(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return qw(t),null;case 13:if(fn(jn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ke(340));yc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return fn(jn),null;case 4:return wc(),null;case 10:return Uw(t.type._context),null;case 22:case 23:return iv(),null;case 24:return null;default:return null}}var np=!1,Tr=!1,aL=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function Gl(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ln(e,t,r)}else n.current=null}function mx(e,t,n){try{n()}catch(r){Ln(e,t,r)}}var Wb=!1;function lL(e,t){if(Qy=ah,e=Yj(),$w(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,u=0,f=e,p=null;t:for(;;){for(var h;f!==n||s!==0&&f.nodeType!==3||(l=a+s),f!==i||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)p=f,f=h;for(;;){if(f===e)break t;if(p===n&&++d===s&&(l=a),p===i&&++u===r&&(c=a),(h=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Zy={focusedElem:e,selectionRange:n},ah=!1,Oe=t;Oe!==null;)if(t=Oe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Oe=e;else for(;Oe!==null;){t=Oe;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,S=g.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?b:ri(t.type,b),S);y.__reactInternalSnapshotBeforeUpdate=v}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(ke(163))}}catch(j){Ln(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Oe=e;break}Oe=t.return}return g=Wb,Wb=!1,g}function Gu(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&&mx(t,n,i)}s=s.next}while(s!==r)}}function mm(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 gx(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 WC(e){var t=e.alternate;t!==null&&(e.alternate=null,WC(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ri],delete t[wd],delete t[nx],delete t[WR],delete t[VR])),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 VC(e){return e.tag===5||e.tag===3||e.tag===4}function Vb(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||VC(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 yx(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=uh));else if(r!==4&&(e=e.child,e!==null))for(yx(e,t,n),e=e.sibling;e!==null;)yx(e,t,n),e=e.sibling}function xx(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(xx(e,t,n),e=e.sibling;e!==null;)xx(e,t,n),e=e.sibling}var vr=null,si=!1;function Do(e,t,n){for(n=n.child;n!==null;)KC(e,t,n),n=n.sibling}function KC(e,t,n){if($i&&typeof $i.onCommitFiberUnmount=="function")try{$i.onCommitFiberUnmount(am,n)}catch{}switch(n.tag){case 5:Tr||Gl(n,t);case 6:var r=vr,s=si;vr=null,Do(e,t,n),vr=r,si=s,vr!==null&&(si?(e=vr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):vr.removeChild(n.stateNode));break;case 18:vr!==null&&(si?(e=vr,n=n.stateNode,e.nodeType===8?Eg(e.parentNode,n):e.nodeType===1&&Eg(e,n),hd(e)):Eg(vr,n.stateNode));break;case 4:r=vr,s=si,vr=n.stateNode.containerInfo,si=!0,Do(e,t,n),vr=r,si=s;break;case 0:case 11:case 14:case 15:if(!Tr&&(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)&&mx(n,t,a),s=s.next}while(s!==r)}Do(e,t,n);break;case 1:if(!Tr&&(Gl(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Ln(n,t,l)}Do(e,t,n);break;case 21:Do(e,t,n);break;case 22:n.mode&1?(Tr=(r=Tr)||n.memoizedState!==null,Do(e,t,n),Tr=r):Do(e,t,n);break;default:Do(e,t,n)}}function Kb(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new aL),t.forEach(function(r){var s=yL.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ti(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:vr=l.stateNode,si=!1;break e;case 3:vr=l.stateNode.containerInfo,si=!0;break e;case 4:vr=l.stateNode.containerInfo,si=!0;break e}l=l.return}if(vr===null)throw Error(ke(160));KC(i,a,s),vr=null,si=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(d){Ln(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)qC(t,e),t=t.sibling}function qC(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(ti(t,e),_i(e),r&4){try{Gu(3,e,e.return),mm(3,e)}catch(b){Ln(e,e.return,b)}try{Gu(5,e,e.return)}catch(b){Ln(e,e.return,b)}}break;case 1:ti(t,e),_i(e),r&512&&n!==null&&Gl(n,n.return);break;case 5:if(ti(t,e),_i(e),r&512&&n!==null&&Gl(n,n.return),e.flags&32){var s=e.stateNode;try{ud(s,"")}catch(b){Ln(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&&mj(s,i),Hy(l,a);var d=Hy(l,i);for(a=0;a<c.length;a+=2){var u=c[a],f=c[a+1];u==="style"?vj(s,f):u==="dangerouslySetInnerHTML"?xj(s,f):u==="children"?ud(s,f):Nw(s,u,f,d)}switch(l){case"input":$y(s,i);break;case"textarea":gj(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?sc(s,!!i.multiple,h,!1):p!==!!i.multiple&&(i.defaultValue!=null?sc(s,!!i.multiple,i.defaultValue,!0):sc(s,!!i.multiple,i.multiple?[]:"",!1))}s[wd]=i}catch(b){Ln(e,e.return,b)}}break;case 6:if(ti(t,e),_i(e),r&4){if(e.stateNode===null)throw Error(ke(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(b){Ln(e,e.return,b)}}break;case 3:if(ti(t,e),_i(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{hd(t.containerInfo)}catch(b){Ln(e,e.return,b)}break;case 4:ti(t,e),_i(e);break;case 13:ti(t,e),_i(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(rv=Dn())),r&4&&Kb(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(Tr=(d=Tr)||u,ti(t,e),Tr=d):ti(t,e),_i(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(Oe=e,u=e.child;u!==null;){for(f=Oe=u;Oe!==null;){switch(p=Oe,h=p.child,p.tag){case 0:case 11:case 14:case 15:Gu(4,p,p.return);break;case 1:Gl(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){Ln(r,n,b)}}break;case 5:Gl(p,p.return);break;case 22:if(p.memoizedState!==null){Yb(f);continue}}h!==null?(h.return=p,Oe=h):Yb(f)}u=u.sibling}e:for(u=null,f=e;;){if(f.tag===5){if(u===null){u=f;try{s=f.stateNode,d?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=wj("display",a))}catch(b){Ln(e,e.return,b)}}}else if(f.tag===6){if(u===null)try{f.stateNode.nodeValue=d?"":f.memoizedProps}catch(b){Ln(e,e.return,b)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;u===f&&(u=null),f=f.return}u===f&&(u=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:ti(t,e),_i(e),r&4&&Kb(e);break;case 21:break;default:ti(t,e),_i(e)}}function _i(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(VC(n)){var r=n;break e}n=n.return}throw Error(ke(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(ud(s,""),r.flags&=-33);var i=Vb(e);xx(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Vb(e);yx(e,l,a);break;default:throw Error(ke(161))}}catch(c){Ln(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function cL(e,t,n){Oe=e,YC(e)}function YC(e,t,n){for(var r=(e.mode&1)!==0;Oe!==null;){var s=Oe,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||np;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Tr;l=np;var d=Tr;if(np=a,(Tr=c)&&!d)for(Oe=s;Oe!==null;)a=Oe,c=a.child,a.tag===22&&a.memoizedState!==null?Gb(s):c!==null?(c.return=a,Oe=c):Gb(s);for(;i!==null;)Oe=i,YC(i),i=i.sibling;Oe=s,np=l,Tr=d}qb(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,Oe=i):qb(e)}}function qb(e){for(;Oe!==null;){var t=Oe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Tr||mm(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Tr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:ri(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Ib(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}Ib(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 u=d.memoizedState;if(u!==null){var f=u.dehydrated;f!==null&&hd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ke(163))}Tr||t.flags&512&&gx(t)}catch(p){Ln(t,t.return,p)}}if(t===e){Oe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Oe=n;break}Oe=t.return}}function Yb(e){for(;Oe!==null;){var t=Oe;if(t===e){Oe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Oe=n;break}Oe=t.return}}function Gb(e){for(;Oe!==null;){var t=Oe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{mm(4,t)}catch(c){Ln(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Ln(t,s,c)}}var i=t.return;try{gx(t)}catch(c){Ln(t,i,c)}break;case 5:var a=t.return;try{gx(t)}catch(c){Ln(t,a,c)}}}catch(c){Ln(t,t.return,c)}if(t===e){Oe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Oe=l;break}Oe=t.return}}var uL=Math.ceil,bh=ko.ReactCurrentDispatcher,tv=ko.ReactCurrentOwner,Fs=ko.ReactCurrentBatchConfig,$t=0,dr=null,qn=null,br=0,gs=0,Xl=va(0),nr=0,jd=null,tl=0,gm=0,nv=0,Xu=null,Zr=null,rv=0,bc=1/0,io=null,kh=!1,wx=null,ia=null,rp=!1,Jo=null,Sh=0,Ju=0,vx=null,Bp=-1,Hp=0;function Hr(){return $t&6?Dn():Bp!==-1?Bp:Bp=Dn()}function oa(e){return e.mode&1?$t&2&&br!==0?br&-br:qR.transition!==null?(Hp===0&&(Hp=Tj()),Hp):(e=Ut,e!==0||(e=window.event,e=e===void 0?16:Fj(e.type)),e):1}function fi(e,t,n,r){if(50<Ju)throw Ju=0,vx=null,Error(ke(185));Gd(e,n,r),(!($t&2)||e!==dr)&&(e===dr&&(!($t&2)&&(gm|=n),nr===4&&Yo(e,br)),ls(e,r),n===1&&$t===0&&!(t.mode&1)&&(bc=Dn()+500,fm&&ba()))}function ls(e,t){var n=e.callbackNode;q2(e,t);var r=oh(e,e===dr?br:0);if(r===0)n!==null&&sb(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&sb(n),t===1)e.tag===0?KR(Xb.bind(null,e)):sC(Xb.bind(null,e)),HR(function(){!($t&6)&&ba()}),n=null;else{switch(Rj(r)){case 1:n=Pw;break;case 4:n=Aj;break;case 16:n=ih;break;case 536870912:n=Ij;break;default:n=ih}n=nE(n,GC.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function GC(e,t){if(Bp=-1,Hp=0,$t&6)throw Error(ke(327));var n=e.callbackNode;if(cc()&&e.callbackNode!==n)return null;var r=oh(e,e===dr?br:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Nh(e,r);else{t=r;var s=$t;$t|=2;var i=JC();(dr!==e||br!==t)&&(io=null,bc=Dn()+500,Ka(e,t));do try{pL();break}catch(l){XC(e,l)}while(!0);Hw(),bh.current=i,$t=s,qn!==null?t=0:(dr=null,br=0,t=nr)}if(t!==0){if(t===2&&(s=qy(e),s!==0&&(r=s,t=bx(e,s))),t===1)throw n=jd,Ka(e,0),Yo(e,r),ls(e,Dn()),n;if(t===6)Yo(e,r);else{if(s=e.current.alternate,!(r&30)&&!dL(s)&&(t=Nh(e,r),t===2&&(i=qy(e),i!==0&&(r=i,t=bx(e,i))),t===1))throw n=jd,Ka(e,0),Yo(e,r),ls(e,Dn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(ke(345));case 2:Fa(e,Zr,io);break;case 3:if(Yo(e,r),(r&130023424)===r&&(t=rv+500-Dn(),10<t)){if(oh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Hr(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=tx(Fa.bind(null,e,Zr,io),t);break}Fa(e,Zr,io);break;case 4:if(Yo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-di(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=Dn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*uL(r/1960))-r,10<r){e.timeoutHandle=tx(Fa.bind(null,e,Zr,io),r);break}Fa(e,Zr,io);break;case 5:Fa(e,Zr,io);break;default:throw Error(ke(329))}}}return ls(e,Dn()),e.callbackNode===n?GC.bind(null,e):null}function bx(e,t){var n=Xu;return e.current.memoizedState.isDehydrated&&(Ka(e,t).flags|=256),e=Nh(e,t),e!==2&&(t=Zr,Zr=n,t!==null&&kx(t)),e}function kx(e){Zr===null?Zr=e:Zr.push.apply(Zr,e)}function dL(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(!pi(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 Yo(e,t){for(t&=~nv,t&=~gm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-di(t),r=1<<n;e[n]=-1,t&=~r}}function Xb(e){if($t&6)throw Error(ke(327));cc();var t=oh(e,0);if(!(t&1))return ls(e,Dn()),null;var n=Nh(e,t);if(e.tag!==0&&n===2){var r=qy(e);r!==0&&(t=r,n=bx(e,r))}if(n===1)throw n=jd,Ka(e,0),Yo(e,t),ls(e,Dn()),n;if(n===6)throw Error(ke(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Fa(e,Zr,io),ls(e,Dn()),null}function sv(e,t){var n=$t;$t|=1;try{return e(t)}finally{$t=n,$t===0&&(bc=Dn()+500,fm&&ba())}}function nl(e){Jo!==null&&Jo.tag===0&&!($t&6)&&cc();var t=$t;$t|=1;var n=Fs.transition,r=Ut;try{if(Fs.transition=null,Ut=1,e)return e()}finally{Ut=r,Fs.transition=n,$t=t,!($t&6)&&ba()}}function iv(){gs=Xl.current,fn(Xl)}function Ka(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,BR(n)),qn!==null)for(n=qn.return;n!==null;){var r=n;switch(Fw(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&dh();break;case 3:wc(),fn(os),fn(Lr),Yw();break;case 5:qw(r);break;case 4:wc();break;case 13:fn(jn);break;case 19:fn(jn);break;case 10:Uw(r.type._context);break;case 22:case 23:iv()}n=n.return}if(dr=e,qn=e=aa(e.current,null),br=gs=t,nr=0,jd=null,nv=gm=tl=0,Zr=Xu=null,Ua!==null){for(t=0;t<Ua.length;t++)if(n=Ua[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}Ua=null}return e}function XC(e,t){do{var n=qn;try{if(Hw(),Dp.current=vh,wh){for(var r=Cn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}wh=!1}if(el=0,cr=er=Cn=null,Yu=!1,kd=0,tv.current=null,n===null||n.return===null){nr=1,jd=t,qn=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=br,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=l,f=u.tag;if(!(u.mode&1)&&(f===0||f===11||f===15)){var p=u.alternate;p?(u.updateQueue=p.updateQueue,u.memoizedState=p.memoizedState,u.lanes=p.lanes):(u.updateQueue=null,u.memoizedState=null)}var h=$b(a);if(h!==null){h.flags&=-257,Db(h,a,l,i,t),h.mode&1&&Mb(i,d,t),t=h,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)){Mb(i,d,t),ov();break e}c=Error(ke(426))}}else if(wn&&l.mode&1){var S=$b(a);if(S!==null){!(S.flags&65536)&&(S.flags|=256),Db(S,a,l,i,t),zw(vc(c,l));break e}}i=c=vc(c,l),nr!==4&&(nr=2),Xu===null?Xu=[i]:Xu.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=RC(i,c,t);Ab(i,y);break e;case 1:l=c;var v=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(ia===null||!ia.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=LC(i,l,t);Ab(i,j);break e}}i=i.return}while(i!==null)}ZC(n)}catch(E){t=E,qn===n&&n!==null&&(qn=n=n.return);continue}break}while(!0)}function JC(){var e=bh.current;return bh.current=vh,e===null?vh:e}function ov(){(nr===0||nr===3||nr===2)&&(nr=4),dr===null||!(tl&268435455)&&!(gm&268435455)||Yo(dr,br)}function Nh(e,t){var n=$t;$t|=2;var r=JC();(dr!==e||br!==t)&&(io=null,Ka(e,t));do try{fL();break}catch(s){XC(e,s)}while(!0);if(Hw(),$t=n,bh.current=r,qn!==null)throw Error(ke(261));return dr=null,br=0,nr}function fL(){for(;qn!==null;)QC(qn)}function pL(){for(;qn!==null&&!D2();)QC(qn)}function QC(e){var t=tE(e.alternate,e,gs);e.memoizedProps=e.pendingProps,t===null?ZC(e):qn=t,tv.current=null}function ZC(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=oL(n,t),n!==null){n.flags&=32767,qn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{nr=6,qn=null;return}}else if(n=iL(n,t,gs),n!==null){qn=n;return}if(t=t.sibling,t!==null){qn=t;return}qn=t=e}while(t!==null);nr===0&&(nr=5)}function Fa(e,t,n){var r=Ut,s=Fs.transition;try{Fs.transition=null,Ut=1,hL(e,t,n,r)}finally{Fs.transition=s,Ut=r}return null}function hL(e,t,n,r){do cc();while(Jo!==null);if($t&6)throw Error(ke(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(ke(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(Y2(e,i),e===dr&&(qn=dr=null,br=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||rp||(rp=!0,nE(ih,function(){return cc(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=Fs.transition,Fs.transition=null;var a=Ut;Ut=1;var l=$t;$t|=4,tv.current=null,lL(e,n),qC(n,e),LR(Zy),ah=!!Qy,Zy=Qy=null,e.current=n,cL(n),F2(),$t=l,Ut=a,Fs.transition=i}else e.current=n;if(rp&&(rp=!1,Jo=e,Sh=s),i=e.pendingLanes,i===0&&(ia=null),H2(n.stateNode),ls(e,Dn()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(kh)throw kh=!1,e=wx,wx=null,e;return Sh&1&&e.tag!==0&&cc(),i=e.pendingLanes,i&1?e===vx?Ju++:(Ju=0,vx=e):Ju=0,ba(),null}function cc(){if(Jo!==null){var e=Rj(Sh),t=Fs.transition,n=Ut;try{if(Fs.transition=null,Ut=16>e?16:e,Jo===null)var r=!1;else{if(e=Jo,Jo=null,Sh=0,$t&6)throw Error(ke(331));var s=$t;for($t|=4,Oe=e.current;Oe!==null;){var i=Oe,a=i.child;if(Oe.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Oe=d;Oe!==null;){var u=Oe;switch(u.tag){case 0:case 11:case 15:Gu(8,u,i)}var f=u.child;if(f!==null)f.return=u,Oe=f;else for(;Oe!==null;){u=Oe;var p=u.sibling,h=u.return;if(WC(u),u===d){Oe=null;break}if(p!==null){p.return=h,Oe=p;break}Oe=h}}}var g=i.alternate;if(g!==null){var b=g.child;if(b!==null){g.child=null;do{var S=b.sibling;b.sibling=null,b=S}while(b!==null)}}Oe=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Oe=a;else e:for(;Oe!==null;){if(i=Oe,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Gu(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,Oe=y;break e}Oe=i.return}}var v=e.current;for(Oe=v;Oe!==null;){a=Oe;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,Oe=w;else e:for(a=v;Oe!==null;){if(l=Oe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:mm(9,l)}}catch(E){Ln(l,l.return,E)}if(l===a){Oe=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Oe=j;break e}Oe=l.return}}if($t=s,ba(),$i&&typeof $i.onPostCommitFiberRoot=="function")try{$i.onPostCommitFiberRoot(am,e)}catch{}r=!0}return r}finally{Ut=n,Fs.transition=t}}return!1}function Jb(e,t,n){t=vc(n,t),t=RC(e,t,1),e=sa(e,t,1),t=Hr(),e!==null&&(Gd(e,1,t),ls(e,t))}function Ln(e,t,n){if(e.tag===3)Jb(e,e,n);else for(;t!==null;){if(t.tag===3){Jb(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ia===null||!ia.has(r))){e=vc(n,e),e=LC(t,e,1),t=sa(t,e,1),e=Hr(),t!==null&&(Gd(t,1,e),ls(t,e));break}}t=t.return}}function mL(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Hr(),e.pingedLanes|=e.suspendedLanes&n,dr===e&&(br&n)===n&&(nr===4||nr===3&&(br&130023424)===br&&500>Dn()-rv?Ka(e,0):nv|=n),ls(e,t)}function eE(e,t){t===0&&(e.mode&1?(t=qf,qf<<=1,!(qf&130023424)&&(qf=4194304)):t=1);var n=Hr();e=yo(e,t),e!==null&&(Gd(e,t,n),ls(e,n))}function gL(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),eE(e,n)}function yL(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(ke(314))}r!==null&&r.delete(t),eE(e,n)}var tE;tE=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||os.current)ts=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ts=!1,sL(e,t,n);ts=!!(e.flags&131072)}else ts=!1,wn&&t.flags&1048576&&iC(t,hh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;zp(e,t),e=t.pendingProps;var s=gc(t,Lr.current);lc(t,n),s=Xw(null,t,r,e,s,n);var i=Jw();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,as(r)?(i=!0,fh(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Vw(t),s.updater=hm,t.stateNode=s,s._reactInternals=t,lx(t,r,e,n),t=dx(null,t,r,!0,i,n)):(t.tag=0,wn&&i&&Dw(t),zr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(zp(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=wL(r),e=ri(r,e),s){case 0:t=ux(null,t,r,e,n);break e;case 1:t=Bb(null,t,r,e,n);break e;case 11:t=Fb(null,t,r,e,n);break e;case 14:t=zb(null,t,r,ri(r.type,e),n);break e}throw Error(ke(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ri(r,s),ux(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ri(r,s),Bb(e,t,r,s,n);case 3:e:{if(DC(t),e===null)throw Error(ke(387));r=t.pendingProps,i=t.memoizedState,s=i.element,dC(e,t),yh(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=vc(Error(ke(423)),t),t=Hb(e,t,r,n,s);break e}else if(r!==s){s=vc(Error(ke(424)),t),t=Hb(e,t,r,n,s);break e}else for(ws=ra(t.stateNode.containerInfo.firstChild),bs=t,wn=!0,oi=null,n=cC(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yc(),r===s){t=xo(e,t,n);break e}zr(e,t,r,n)}t=t.child}return t;case 5:return fC(t),e===null&&ix(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,ex(r,s)?a=null:i!==null&&ex(r,i)&&(t.flags|=32),$C(e,t),zr(e,t,a,n),t.child;case 6:return e===null&&ix(t),null;case 13:return FC(e,t,n);case 4:return Kw(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=xc(t,null,r,n):zr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ri(r,s),Fb(e,t,r,s,n);case 7:return zr(e,t,t.pendingProps,n),t.child;case 8:return zr(e,t,t.pendingProps.children,n),t.child;case 12:return zr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,rn(mh,r._currentValue),r._currentValue=a,i!==null)if(pi(i.value,a)){if(i.children===s.children&&!os.current){t=xo(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=ho(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),ox(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(ke(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),ox(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}zr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,lc(t,n),s=zs(s),r=r(s),t.flags|=1,zr(e,t,r,n),t.child;case 14:return r=t.type,s=ri(r,t.pendingProps),s=ri(r.type,s),zb(e,t,r,s,n);case 15:return OC(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ri(r,s),zp(e,t),t.tag=1,as(r)?(e=!0,fh(t)):e=!1,lc(t,n),TC(t,r,s),lx(t,r,s,n),dx(null,t,r,!0,e,n);case 19:return zC(e,t,n);case 22:return MC(e,t,n)}throw Error(ke(156,t.tag))};function nE(e,t){return Pj(e,t)}function xL(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 Ds(e,t,n,r){return new xL(e,t,n,r)}function av(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wL(e){if(typeof e=="function")return av(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Cw)return 11;if(e===Ew)return 14}return 2}function aa(e,t){var n=e.alternate;return n===null?(n=Ds(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 Up(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")av(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case zl:return qa(n.children,s,i,t);case jw:a=8,s|=8;break;case Ty:return e=Ds(12,n,t,s|2),e.elementType=Ty,e.lanes=i,e;case Ry:return e=Ds(13,n,t,s),e.elementType=Ry,e.lanes=i,e;case Ly:return e=Ds(19,n,t,s),e.elementType=Ly,e.lanes=i,e;case fj:return ym(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uj:a=10;break e;case dj:a=9;break e;case Cw:a=11;break e;case Ew:a=14;break e;case Wo:a=16,r=null;break e}throw Error(ke(130,e==null?e:typeof e,""))}return t=Ds(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function qa(e,t,n,r){return e=Ds(7,e,r,t),e.lanes=n,e}function ym(e,t,n,r){return e=Ds(22,e,r,t),e.elementType=fj,e.lanes=n,e.stateNode={isHidden:!1},e}function Og(e,t,n){return e=Ds(6,e,null,t),e.lanes=n,e}function Mg(e,t,n){return t=Ds(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function vL(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=gg(0),this.expirationTimes=gg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gg(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function lv(e,t,n,r,s,i,a,l,c){return e=new vL(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ds(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Vw(i),e}function bL(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Fl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function rE(e){if(!e)return fa;e=e._reactInternals;e:{if(cl(e)!==e||e.tag!==1)throw Error(ke(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(as(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(ke(171))}if(e.tag===1){var n=e.type;if(as(n))return rC(e,n,t)}return t}function sE(e,t,n,r,s,i,a,l,c){return e=lv(n,r,!0,e,s,i,a,l,c),e.context=rE(null),n=e.current,r=Hr(),s=oa(n),i=ho(r,s),i.callback=t??null,sa(n,i,s),e.current.lanes=s,Gd(e,s,r),ls(e,r),e}function xm(e,t,n,r){var s=t.current,i=Hr(),a=oa(s);return n=rE(n),t.context===null?t.context=n:t.pendingContext=n,t=ho(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=sa(s,t,a),e!==null&&(fi(e,s,a,i),$p(e,s,a)),a}function jh(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 Qb(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function cv(e,t){Qb(e,t),(e=e.alternate)&&Qb(e,t)}function kL(){return null}var iE=typeof reportError=="function"?reportError:function(e){console.error(e)};function uv(e){this._internalRoot=e}wm.prototype.render=uv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(ke(409));xm(e,t,null,null)};wm.prototype.unmount=uv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;nl(function(){xm(null,e,null,null)}),t[go]=null}};function wm(e){this._internalRoot=e}wm.prototype.unstable_scheduleHydration=function(e){if(e){var t=Mj();e={blockedOn:null,target:e,priority:t};for(var n=0;n<qo.length&&t!==0&&t<qo[n].priority;n++);qo.splice(n,0,e),n===0&&Dj(e)}};function dv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function vm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Zb(){}function SL(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=jh(a);i.call(d)}}var a=sE(t,r,e,0,null,!1,!1,"",Zb);return e._reactRootContainer=a,e[go]=a.current,yd(e.nodeType===8?e.parentNode:e),nl(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=jh(c);l.call(d)}}var c=lv(e,0,!1,null,null,!1,!1,"",Zb);return e._reactRootContainer=c,e[go]=c.current,yd(e.nodeType===8?e.parentNode:e),nl(function(){xm(t,c,n,r)}),c}function bm(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=jh(a);l.call(c)}}xm(t,a,e,s)}else a=SL(n,t,e,s,r);return jh(a)}Lj=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Ou(t.pendingLanes);n!==0&&(Aw(t,n|1),ls(t,Dn()),!($t&6)&&(bc=Dn()+500,ba()))}break;case 13:nl(function(){var r=yo(e,1);if(r!==null){var s=Hr();fi(r,e,1,s)}}),cv(e,1)}};Iw=function(e){if(e.tag===13){var t=yo(e,134217728);if(t!==null){var n=Hr();fi(t,e,134217728,n)}cv(e,134217728)}};Oj=function(e){if(e.tag===13){var t=oa(e),n=yo(e,t);if(n!==null){var r=Hr();fi(n,e,t,r)}cv(e,t)}};Mj=function(){return Ut};$j=function(e,t){var n=Ut;try{return Ut=e,t()}finally{Ut=n}};Wy=function(e,t,n){switch(t){case"input":if($y(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=dm(r);if(!s)throw Error(ke(90));hj(r),$y(r,s)}}}break;case"textarea":gj(e,n);break;case"select":t=n.value,t!=null&&sc(e,!!n.multiple,t,!1)}};Sj=sv;Nj=nl;var NL={usingClientEntryPoint:!1,Events:[Jd,Wl,dm,bj,kj,sv]},bu={findFiberByHostInstance:Ha,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},jL={bundleType:bu.bundleType,version:bu.version,rendererPackageName:bu.rendererPackageName,rendererConfig:bu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ko.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Ej(e),e===null?null:e.stateNode},findFiberByHostInstance:bu.findFiberByHostInstance||kL,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 sp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sp.isDisabled&&sp.supportsFiber)try{am=sp.inject(jL),$i=sp}catch{}}js.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=NL;js.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!dv(t))throw Error(ke(200));return bL(e,t,null,n)};js.createRoot=function(e,t){if(!dv(e))throw Error(ke(299));var n=!1,r="",s=iE;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=lv(e,1,!1,null,null,n,!1,r,s),e[go]=t.current,yd(e.nodeType===8?e.parentNode:e),new uv(t)};js.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(ke(188)):(e=Object.keys(e).join(","),Error(ke(268,e)));return e=Ej(t),e=e===null?null:e.stateNode,e};js.flushSync=function(e){return nl(e)};js.hydrate=function(e,t,n){if(!vm(t))throw Error(ke(200));return bm(null,e,t,!0,n)};js.hydrateRoot=function(e,t,n){if(!dv(e))throw Error(ke(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=iE;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=sE(t,null,e,1,n??null,s,!1,i,a),e[go]=t.current,yd(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 wm(t)};js.render=function(e,t,n){if(!vm(t))throw Error(ke(200));return bm(null,e,t,!1,n)};js.unmountComponentAtNode=function(e){if(!vm(e))throw Error(ke(40));return e._reactRootContainer?(nl(function(){bm(null,null,e,!1,function(){e._reactRootContainer=null,e[go]=null})}),!0):!1};js.unstable_batchedUpdates=sv;js.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!vm(n))throw Error(ke(200));if(e==null||e._reactInternals===void 0)throw Error(ke(38));return bm(e,t,n,!1,r)};js.version="18.3.1-next-f1338f8080-20240426";function oE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(oE)}catch(e){console.error(e)}}oE(),oj.exports=js;var es=oj.exports,ek=es;Ay.createRoot=ek.createRoot,Ay.hydrateRoot=ek.hydrateRoot;const aE=m.createContext(null);function Sx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function CL(){const e=Sx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function EL({children:e}){const[t,n]=m.useState(CL);m.useEffect(()=>{const i=()=>n(Sx(window.location.pathname));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const r=m.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=Sx(l.pathname),d=l.search||"";window.history.pushState({},"",c+d),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(aE.Provider,{value:s,children:e})}function ul(){const e=m.useContext(aE);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function _L(){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 tk={};function Nx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&tk[t[0]]||(typeof t[0]=="string"&&(tk[t[0]]=new Date),_L(...t))}const lE=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function nk(e,t,n){e.loadNamespaces(t,lE(e,n))}function rk(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,lE(e,r))}function PL(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 AL(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Nx("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}}):PL(e,t,n)}const IL=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,TL={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},RL=e=>TL[e],LL=e=>e.replace(IL,RL);let jx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:LL};function OL(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};jx={...jx,...e}}function ML(){return jx}let cE;function $L(e){cE=e}function DL(){return cE}const FL={type:"3rdParty",init(e){OL(e.options.react),$L(e)}},zL=m.createContext();class BL{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const HL=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function on(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(zL)||{},i=n||r||DL();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new BL),!i){Nx("You will need to pass in an i18next instance by using initReactI18next");const w=(E,k)=>typeof k=="string"?k:k&&typeof k=="object"&&typeof k.defaultValue=="string"?k.defaultValue:Array.isArray(E)?E[E.length-1]:E,j=[w,{},!1];return j.t=w,j.i18n={},j.ready=!1,j}i.options.react&&i.options.react.wait!==void 0&&Nx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...ML(),...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 u=(i.isInitialized||i.initializedStoreOnce)&&d.every(w=>AL(w,i,a));function f(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],c)}const[p,h]=m.useState(f);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const b=HL(g),S=m.useRef(!0);m.useEffect(()=>{const{bindI18n:w,bindI18nStore:j}=a;S.current=!0,!u&&!l&&(t.lng?rk(i,t.lng,d,()=>{S.current&&h(f)}):nk(i,d,()=>{S.current&&h(f)})),u&&b&&b!==g&&S.current&&h(f);function E(){S.current&&h(f)}return w&&i&&i.on(w,E),j&&i&&i.store.on(j,E),()=>{S.current=!1,w&&i&&w.split(" ").forEach(k=>i.off(k,E)),j&&i&&j.split(" ").forEach(k=>i.store.off(k,E))}},[i,g]);const y=m.useRef(!0);m.useEffect(()=>{S.current&&!y.current&&h(f),y.current=!1},[i,c]);const v=[p,i,u];if(v.t=p,v.i18n=i,v.ready=u,u||!u&&!l)return v;throw new Promise(w=>{t.lng?rk(i,t.lng,d,()=>w()):nk(i,d,()=>w())})}const uE="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",UL=[{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:"/settings",labelKey:"common:nav.settings",icon:"settings"}],WL=[{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 VL(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function KL({authUser:e,onLogout:t}){const{path:n,navigate:r}=ul(),{t:s}=on(),[i,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),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:uE,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:UL.map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(VL(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)||""}),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&&WL.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 dE="agentflow.pipelineRecent",qL=50,YL=15;function GL(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function fE(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(dE);return e?GL(e).filter(t=>t&&typeof t.flowId=="string"&&(t.flowSource==="user"||t.flowSource==="builtin"||t.flowSource==="workspace")&&t.kind==="opened"&&typeof t.at=="number"):[]}function ip(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=fE(),i=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,qL);try{localStorage.setItem(dE,JSON.stringify(i))}catch{}}function XL(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==="builtin")?"builtin":n[0].source??"user"}function Cx(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 u=Math.floor(a/24);return u<7?t("flow:time.daysAgo",{n:u}):`${l.getMonth()+1}/${l.getDate()}`}function JL(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 QL(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:XL(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,YL)}var ys=Uint8Array,Jl=Uint16Array,ZL=Int32Array,pE=new ys([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]),hE=new ys([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]),eO=new ys([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mE=function(e,t){for(var n=new Jl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new ZL(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}},gE=mE(pE,2),yE=gE.b,tO=gE.r;yE[28]=258,tO[258]=28;var nO=mE(hE,0),rO=nO.b,Ex=new Jl(32768);for(var dn=0;dn<32768;++dn){var Fo=(dn&43690)>>1|(dn&21845)<<1;Fo=(Fo&52428)>>2|(Fo&13107)<<2,Fo=(Fo&61680)>>4|(Fo&3855)<<4,Ex[dn]=((Fo&65280)>>8|(Fo&255)<<8)>>1}var Qu=function(e,t,n){for(var r=e.length,s=0,i=new Jl(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new Jl(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new Jl(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],u=t-e[s],f=a[e[s]-1]++<<u,p=f|(1<<u)-1;f<=p;++f)l[Ex[f]>>c]=d}else for(l=new Jl(r),s=0;s<r;++s)e[s]&&(l[s]=Ex[a[e[s]-1]++]>>15-e[s]);return l},Zd=new ys(288);for(var dn=0;dn<144;++dn)Zd[dn]=8;for(var dn=144;dn<256;++dn)Zd[dn]=9;for(var dn=256;dn<280;++dn)Zd[dn]=7;for(var dn=280;dn<288;++dn)Zd[dn]=8;var xE=new ys(32);for(var dn=0;dn<32;++dn)xE[dn]=5;var sO=Qu(Zd,9,1),iO=Qu(xE,5,1),$g=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ni=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Dg=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},oO=function(e){return(e+7)/8|0},fv=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new ys(e.subarray(t,n))},aO=["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"],Rs=function(e,t,n){var r=new Error(t||aO[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Rs),!n)throw r;return r},lO=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new ys(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new ys(s*3));var d=function(pe){var ae=n.length;if(pe>ae){var ye=new ys(Math.max(ae*2,pe));ye.set(n),n=ye}},u=t.f||0,f=t.p||0,p=t.b||0,h=t.l,g=t.d,b=t.m,S=t.n,y=s*8;do{if(!h){u=ni(e,f,1);var v=ni(e,f+1,3);if(f+=3,v)if(v==1)h=sO,g=iO,b=9,S=5;else if(v==2){var k=ni(e,f,31)+257,I=ni(e,f+10,15)+4,R=k+ni(e,f+5,31)+1;f+=14;for(var $=new ys(R),K=new ys(19),D=0;D<I;++D)K[eO[D]]=ni(e,f+D*3,7);f+=I*3;for(var L=$g(K),H=(1<<L)-1,M=Qu(K,L,1),D=0;D<R;){var O=M[ni(e,f,H)];f+=O&15;var w=O>>4;if(w<16)$[D++]=w;else{var A=0,z=0;for(w==16?(z=3+ni(e,f,3),f+=2,A=$[D-1]):w==17?(z=3+ni(e,f,7),f+=3):w==18&&(z=11+ni(e,f,127),f+=7);z--;)$[D++]=A}}var _=$.subarray(0,k),T=$.subarray(k);b=$g(_),S=$g(T),h=Qu(_,b,1),g=Qu(T,S,1)}else Rs(1);else{var w=oO(f)+4,j=e[w-4]|e[w-3]<<8,E=w+j;if(E>s){c&&Rs(0);break}l&&d(p+j),n.set(e.subarray(w,E),p),t.b=p+=j,t.p=f=E*8,t.f=u;continue}if(f>y){c&&Rs(0);break}}l&&d(p+131072);for(var C=(1<<b)-1,G=(1<<S)-1,Z=f;;Z=f){var A=h[Dg(e,f)&C],W=A>>4;if(f+=A&15,f>y){c&&Rs(0);break}if(A||Rs(2),W<256)n[p++]=W;else if(W==256){Z=f,h=null;break}else{var te=W-254;if(W>264){var D=W-257,le=pE[D];te=ni(e,f,(1<<le)-1)+yE[D],f+=le}var ue=g[Dg(e,f)&G],de=ue>>4;ue||Rs(3),f+=ue&15;var T=rO[de];if(de>3){var le=hE[de];T+=Dg(e,f)&(1<<le)-1,f+=le}if(f>y){c&&Rs(0);break}l&&d(p+131072);var ce=p+te;if(p<T){var fe=i-T,re=Math.min(T,ce);for(fe+p<0&&Rs(3);p<re;++p)n[p]=r[fe+p]}for(;p<ce;++p)n[p]=n[p-T]}}t.l=h,t.p=Z,t.b=p,t.f=u,h&&(u=1,t.m=b,t.d=g,t.n=S)}while(!u);return p!=n.length&&a?fv(n,0,p):n.subarray(0,p)},cO=new ys(0),Li=function(e,t){return e[t]|e[t+1]<<8},ai=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Fg=function(e,t){return ai(e,t)+ai(e,t+4)*4294967296};function uO(e,t){return lO(e,{i:2},t&&t.out,t&&t.dictionary)}var _x=typeof TextDecoder<"u"&&new TextDecoder,dO=0;try{_x.decode(cO,{stream:!0}),dO=1}catch{}var fO=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:fv(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 pO(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(_x)return _x.decode(e);var s=fO(e),i=s.s,n=s.r;return n.length&&Rs(8),i}}var hO=function(e,t){return t+30+Li(e,t+26)+Li(e,t+28)},mO=function(e,t,n){var r=Li(e,t+28),s=pO(e.subarray(t+46,t+46+r),!(Li(e,t+8)&2048)),i=t+46+r,a=ai(e,t+20),l=n&&a==4294967295?gO(e,i):[a,ai(e,t+24),ai(e,t+42)],c=l[0],d=l[1],u=l[2];return[Li(e,t+10),c,d,s,i+Li(e,t+30)+Li(e,t+32),u]},gO=function(e,t){for(;Li(e,t)!=1;t+=4+Li(e,t+2));return[Fg(e,t+12),Fg(e,t+4),Fg(e,t+20)]};function yO(e,t){for(var n={},r=e.length-22;ai(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Rs(13);var s=Li(e,r+8);if(!s)return{};var i=ai(e,r+16),a=i==4294967295||s==65535;if(a){var l=ai(e,r-12);a=ai(e,l)==101075792,a&&(s=ai(e,l+32),i=ai(e,l+48))}for(var c=0;c<s;++c){var d=mO(e,i,a),u=d[0],f=d[1],p=d[2],h=d[3],g=d[4],b=d[5],S=hO(e,b);i=g,u?u==8?n[h]=uO(e.subarray(S,S+f),{out:new ys(p)}):Rs(14,"unknown compression type "+u):n[h]=fv(e,S,S+f)}return n}const xO=8*1024*1024,wO=500;function vO(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 bO(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function kO(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 SO=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function NO(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=yO(t),r=new Map;let s=0,i=0;for(const[c,d]of Object.entries(n)){if(c.endsWith("/"))continue;const u=vO(c);if(!u||bO(u))continue;const f=(d==null?void 0:d.length)??0;if(s+=f,s>xO||(i+=1,i>wO))return null;r.set(u,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const d=kO(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 SO.test(l)?l:null}catch{return null}}const zg=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function jO({file:e,onClose:t,onImported:n}){const{t:r}=on(),s=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[d,u]=m.useState("user"),[f,p]=m.useState(!1),[h,g]=m.useState(""),[b,S]=m.useState(null),y=b??e;m.useEffect(()=>{const E=requestAnimationFrame(()=>{var k;return(k=i.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(E)},[]),m.useEffect(()=>{let E=!1;return(async()=>{const k=y.name||"",I=k.toLowerCase();let R="";if(I.endsWith(".zip")){if(R=await NO(y)||"",!R){const $=k.replace(/\.zip$/i,"");zg.test($)&&(R=$)}}else if(I.endsWith(".yaml")||I.endsWith(".yml")){const $=k.replace(/\.ya?ml$/i,"");zg.test($)&&(R=$)}E||c(R)})(),()=>{E=!0}},[y]);const v=l.trim(),w=v.length>0&&zg.test(v);async function j(E){if(E.preventDefault(),!(!w||f)){p(!0),g("");try{const k=new FormData;k.set("flowId",v),k.set("targetSpace",d),k.set("file",y,y.name);const I=await fetch("/api/flows/import",{method:"POST",body:k}),R=await I.json().catch(()=>({}));if(!I.ok){g(typeof R.error=="string"?R.error:r("project:importModal.importFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(k){g(String((k==null?void 0:k.message)||k))}finally{p(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:E=>{E.target===E.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:E=>E.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:E=>{var I;const k=(I=E.target.files)==null?void 0:I[0];k&&S(k),E.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:E=>c(E.target.value),"aria-invalid":v.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 E;return(E=a.current)==null?void 0:E.click()},children:r("project:importModal.changeFile")})}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const CO=/^[a-zA-Z][a-zA-Z0-9_-]*$/,sk="af:newPipelineGuide";function EO({open:e,onClose:t,onCreated:n}){const{t:r}=on(),s=m.useId(),i=m.useRef(null),[a,l]=m.useState(""),[c,d]=m.useState(""),[u,f]=m.useState("user"),[p,h]=m.useState(!1),[g,b]=m.useState(""),[S,y]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),d(""),f("user"),b(""),h(!1),localStorage.getItem(sk)==="true"&&y(!0);const I=requestAnimationFrame(()=>{var R;return(R=i.current)==null?void 0:R.focus()});return()=>cancelAnimationFrame(I)},[e]);const v=()=>{localStorage.removeItem(sk),y(!1)};if(!e)return null;const w=a.trim(),j=w.length>0&&CO.test(w);async function E(k){if(k.preventDefault(),!(!j||p)){h(!0),b(""),v();try{const I=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:w,description:c.trim(),targetSpace:u})}),R=await I.json().catch(()=>({}));if(!I.ok){b(typeof R.error=="string"?R.error:r("project:newPipelineModal.createFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(I){b(String((I==null?void 0:I.message)||I))}finally{h(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:k=>{k.target===k.currentTarget&&(v(),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:k=>k.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:()=>{v(),t()},"aria-label":r("project:newPipelineModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),S?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:v,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:E,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:k=>l(k.target.value),"aria-invalid":w.length>0&&!j}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(S?"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(S?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:k=>d(k.target.value)}),S?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:()=>{v(),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":S?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const wE="agentflow.pipelineViewPreference";function vE(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function bE(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(wE)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function _O(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(wE,JSON.stringify(e))}catch{}}function Ch(e){return e==="pipeline"?"pipeline":"workspace"}function PO(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function kE(e,t,n,r=!1){if(!e)return;const s=bE();s[vE(e,t,r)]={view:Ch(n),at:Date.now()},_O(s)}function AO(e,t="workspace"){if(!(e!=null&&e.id))return Ch(t);const r=bE()[vE(e.id,e.source??"user",!!e.archived)],s=Ch((r==null?void 0:r.view)||t);return s==="pipeline"&&!PO(e)?"workspace":s}function pv(e,t="workspace"){if(!(e!=null&&e.id))return t==="pipeline"?"/flow":"/workspace";const n=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return e.archived&&n.set(t==="pipeline"?"flowArchived":"archived","1"),`/${Ch(t)==="pipeline"?"flow":"workspace"}?${n.toString()}`}function op(e,t="workspace"){return pv(e,AO(e,t))}function IO({onChanged:e}){const[t,n]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[r,s]=m.useState([]),[i,a]=m.useState(""),[l,c]=m.useState("keyword"),[d,u]=m.useState([]),[f,p]=m.useState(""),[h,g]=m.useState(""),[b,S]=m.useState(""),y=m.useCallback(async()=>{g("");try{const[k,I]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=global&agent=codex")]),R=await k.json().catch(()=>({}));k.ok&&n({available:!!R.available,version:typeof R.version=="string"?R.version:"",loggedIn:!!R.loggedIn,user:typeof R.user=="string"?R.user:"",error:typeof R.error=="string"?R.error:""});const $=await I.json().catch(()=>({}));if(!I.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+I.status);s(Array.isArray($.skills)?$.skills:[])}catch(k){g(String(k.message||k))}},[]);m.useEffect(()=>{y()},[y]);const v=m.useCallback(async()=>{const k=i.trim();if(k){p("search"),g(""),S("");try{const I=await fetch(`/api/skillhub/search?q=${encodeURIComponent(k)}&mode=${encodeURIComponent(l)}`),R=await I.json().catch(()=>({}));if(!I.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+I.status);u(Array.isArray(R.items)?R.items:[])}catch(I){g(String(I.message||I))}finally{p("")}}},[i,l]),w=m.useCallback(async(k,I=!1)=>{const R=k&&typeof k=="object"?k:null,$=String(R?R.slug||R.name||R.collection||R.skillId||R.id:k||"").trim();if($){p(`install:${$}`),g(""),S("");try{const K=R?{slug:R.slug||"",skillId:R.skillId||"",collection:R.collection||"",collectionName:R.collection&&R.name||"",target:"global",agent:"codex",force:I}:{slug:$,target:"global",agent:"codex",force:I},D=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)}),L=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+D.status);S(I?`已更新 ${$}`:`已安装 ${$}`),await y(),typeof e=="function"&&await e()}catch(K){g(String(K.message||K))}finally{p("")}}},[y,e]),j=m.useCallback(async k=>{const I=String(k||"").trim();if(I){p(`uninstall:${I}`),g(""),S("");try{const R=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:I,target:"global",agent:"codex"})}),$=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+R.status);S(`已卸载 ${I}`),await y(),typeof e=="function"&&await e()}catch(R){g(String(R.message||R))}finally{p("")}}},[y,e]),E=m.useCallback(async()=>{p("update-cli"),g(""),S("");try{const k=await fetch("/api/skillhub/update",{method:"POST"}),I=await k.json().catch(()=>({}));if(!k.ok)throw new Error(typeof I.error=="string"?I.error:"HTTP "+k.status);S("SkillHub CLI 已更新"),await y()}catch(k){g(String(k.message||k))}finally{p("")}},[y]);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:y,disabled:!!f,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:E,disabled:!!f,children:f==="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:k=>{c(k.target.value),u([])},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:k=>a(k.target.value),onKeyDown:k=>{k.key==="Enter"&&v()},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:()=>v(),disabled:!i.trim()||f==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),f==="search"?"搜索中…":"搜索"]})]}),h?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:h}):null,b?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:b}):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(k=>o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:k.name}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[k.agent||"codex"," · ",k.kind||"skill"]})]}),o.jsxs("div",{className:"af-set-skillhub-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>w(k.name,!0),disabled:!!f,children:"更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>j(k.name),disabled:!!f,children:"卸载"})]})]},`${k.agent}:${k.path}:${k.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(k=>{const I=k.slug||k.name,R=k.kind==="collection"||k.collection,$=!R&&r.some(K=>K.name===I||K.name===k.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:k.name||I}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[R?`collection:${k.collection}`:I,k.skillId?` · id:${k.skillId}`:"",k.version?` · ${k.version}`:""]}),k.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:k.summary}):null]}),o.jsx("button",{type:"button",className:$?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>w(k,$),disabled:!!f,children:$?"更新":R?"安装合集":"安装"})]},k.id||I)})})]})]})]})}function la(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 TO(e){return{version:1,collections:la({collections:e})}}function pa(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 SE(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 NE(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function jE(e,t,n){const r=pa(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 RO(e,t,n){const r=String(e||"").trim().toLowerCase(),s=la({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return pa(s,t)}function CE(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),i=String(t||"").trim().toLowerCase(),a=la({collections:r}),l=RO(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const d=localStorage.getItem(e);if(d!==null){const u=JSON.parse(d);if(Array.isArray(u)){const f=new Set(s),p=u.map(String).filter(y=>f.has(y));if(s.length>0&&p.length===s.length)return c;const h=new Set(p),g=new Set(l),b=l.length>0&&l.every(y=>h.has(y)),S=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const v=pa(y,n);return v.length>0&&v.every(w=>h.has(w))});return l.length>0&&S&&!b?c:p}}}catch{}return c}function ku(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 LO(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 Px(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function EE(e){const t=e.source??"user";return t==="builtin"?`builtin/pipelines / ${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 OO="project:defaultCardDesc";function _E(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(OO)}function MO(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $n({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(`(${MO(r)})`,"gi"),a=s.split(i);return o.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?o.jsx("mark",{className:"af-search-hit",children:l},c):o.jsx("span",{children:l},c))})}function $O(e,t,n){const r=[String(e.id),_E(e,n),EE(e),Px(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function DO(e,t,n){return t?$O(e,t,n).includes(t):!0}function FO(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 Bg(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function ik(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 ok(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const zO=["all","agent","control","provide","marketplace"],BO=["all","agent","control","provide"];function ap(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function xn(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 Su(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function Pl({resourceKind:e=""}){var ps,Jn,Ks,_r,Es,$r,gr,yr;const{t}=on(),{navigate:n,path:r}=ul(),[s,i]=m.useState(e||"all"),[a,l]=m.useState([]),[c,d]=m.useState([]),[u,f]=m.useState([]),[p,h]=m.useState([]),[g,b]=m.useState([]),[S,y]=m.useState(""),[v,w]=m.useState(!1),[j,E]=m.useState([]),[k,I]=m.useState(""),[R,$]=m.useState(""),[K,D]=m.useState(!1),[L,H]=m.useState(!1),[M,O]=m.useState(!1),[A,z]=m.useState(null),[_,T]=m.useState(!1),[C,G]=m.useState(""),[Z,W]=m.useState(!0),[te,le]=m.useState("all"),[ue,de]=m.useState(""),[ce,fe]=m.useState("overview"),[re,pe]=m.useState({}),[ae,ye]=m.useState(""),[Be,lt]=m.useState({}),[Ge,_t]=m.useState(""),[Pt,Te]=m.useState(""),[an,Fn]=m.useState({}),[qt,_n]=m.useState(""),[jr,fr]=m.useState(""),[ie,xe]=m.useState(""),[Ve,Ze]=m.useState(!1),Xe=m.useRef(0),At=m.useRef(0),On=m.useCallback(async()=>{const q=++At.current;I("");try{const be=await fetch("/api/flows");if(q!==At.current)return;if(!be.ok)throw new Error("HTTP "+be.status);const Ae=await be.json();if(q!==At.current)return;l(Array.isArray(Ae)?Ae:[])}catch(be){if(q!==At.current)return;l([]),I(String(be.message||be))}try{const be=await fetch("/api/pipeline-recent-runs");if(q!==At.current)return;if(be.ok){const Ae=await be.json();if(q!==At.current)return;E(Array.isArray(Ae.runs)?Ae.runs:[])}else E([])}catch{if(q!==At.current)return;E([])}D(!0)},[]),Dt=m.useCallback(async()=>{$(""),H(!1);try{const[q,be,Ae,Ue]=await Promise.all([fetch("/api/nodes"),fetch("/api/skills"),fetch("/api/skill-collections"),fetch("/api/marketplace/flow-snippets")]),yt=await q.json().catch(()=>({})),Bn=await be.json().catch(()=>({})),ct=await Ae.json().catch(()=>({})),wt=await Ue.json().catch(()=>({}));if(!q.ok)throw new Error(yt.error||"Nodes HTTP "+q.status);if(!be.ok)throw new Error(Bn.error||"Skills HTTP "+be.status);if(!Ae.ok)throw new Error(ct.error||"Collections HTTP "+Ae.status);if(!Ue.ok)throw new Error(wt.error||"Flow snippets HTTP "+Ue.status);d(Array.isArray(yt.nodes)?yt.nodes:Array.isArray(yt)?yt:[]),f(Array.isArray(Bn.skills)?Bn.skills:[]),b(la(ct)),h(Array.isArray(wt.snippets)?wt.snippets:[])}catch(q){d([]),f([]),h([]),b([]),$(String(q.message||q))}finally{H(!0)}},[]);m.useEffect(()=>{D(!1),On(),Dt()},[On,Dt]),m.useEffect(()=>{let q=!1;return fetch("/api/ui-context").then(be=>be.json()).then(be=>{q||Ze(!!be.hideCommunityLinks)}).catch(()=>{}),()=>{q=!0}},[]);const Mn=m.useCallback(async q=>{const be=la({collections:q});w(!0),$("");try{const Ae=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(TO(be))}),Ue=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(Ue.error||"Collections HTTP "+Ae.status);b(la(Ue))}catch(Ae){$(String(Ae.message||Ae))}finally{w(!1)}},[]),Yt=m.useCallback(()=>{const q=S.trim();if(!q)return;const be=q.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Ae=new Set(g.map(ct=>ct.id));let Ue=be,yt=2;for(;Ae.has(Ue);)Ue=`${be}-${yt++}`;const Bn=Date.now();Mn([...g,{id:Ue,name:q,skillKeys:[],createdAt:Bn,updatedAt:Bn}]),y(""),le(`collection:${Ue}`)},[S,Mn,g]),Gt=m.useCallback(q=>{const be=g.find(Ue=>Ue.id===q);if(be!=null&&be.builtin)return;const Ae=g.filter(Ue=>Ue.id!==q);te===`collection:${q}`&&le("all"),Mn(Ae)},[te,Mn,g]),rr=m.useCallback((q,be,Ae)=>{const Ue=String(be||"").trim();if(!Ue)return;const yt=Date.now(),Bn=g.map(ct=>{if(ct.id!==q)return ct;const wt=new Set(ct.skillKeys||[]);return Ae?wt.add(Ue):wt.delete(Ue),{...ct,skillKeys:Array.from(wt),updatedAt:yt}});Mn(Bn)},[Mn,g]),he=m.useCallback(async q=>{const be=q==null?void 0:q.packageId,Ae=q==null?void 0:q.version;if(!be||!Ae||!window.confirm(t("project:deleteMyNodeConfirm",{id:be,version:Ae})))return;const Ue=xn(q);fr(Ue),xe(""),$("");try{const yt=new URLSearchParams({id:be,version:Ae}),Bn=await fetch(`/api/marketplace/node?${yt.toString()}`,{method:"DELETE"}),ct=await Bn.json().catch(()=>({}));if(!Bn.ok||(ct==null?void 0:ct.ok)===!1){const wt=Array.isArray(ct==null?void 0:ct.usage)&&ct.usage.length>0?` ${t("project:deleteMyNodeUsedBy",{count:ct.usage.length})}`:"";throw new Error(((ct==null?void 0:ct.error)||"Delete failed")+wt)}xe(t("project:deleteMyNodeSuccess",{id:be,version:Ae})),lt(wt=>{const or={...wt};return delete or[Ue],or}),Fn(wt=>{const or={};for(const[qs,Ys]of Object.entries(wt))qs.startsWith(`${Ue}:`)||(or[qs]=Ys);return or}),de(""),await Dt()}catch(yt){xe(String(yt.message||yt))}finally{fr("")}},[Dt,t]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){i(e),le("all"),de(""),fe("overview");return}i(q=>q==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(r!=="/projects"&&r!=="/")return;const q=new URLSearchParams(window.location.search);let be=!1;if(q.get("tab")==="nodes"){n("/nodes");return}if(q.get("tab")==="my-nodes"){n("/my-nodes");return}if(q.get("tab")==="my-flows"){n("/my-flows");return}if(q.get("tab")==="skills"){n("/skills");return}if(q.get("tab")==="archived"&&(i("archived"),q.delete("tab"),be=!0),q.get("new")==="1"&&(O(!0),q.delete("new"),be=!0),be){const Ae=q.toString();window.history.replaceState({},"",Ae?`/projects?${Ae}`:"/projects")}},[r,n]);const Ee=m.useMemo(()=>QL(j,fE(),a),[j,a,r]),Wt=m.useMemo(()=>Ee.filter(q=>FO(C,q)),[Ee,C]),nt=C.trim().toLowerCase(),hn=m.useMemo(()=>s==="archived"?a.filter(q=>q.archived):a.filter(q=>!q.archived),[a,s]),Us=m.useMemo(()=>hn.filter(q=>DO(q,nt,t)),[hn,nt,t]),Pn=s==="nodes"||s==="my-nodes",Cr=s==="my-nodes",pr=s==="my-flows",fs=m.useMemo(()=>c.filter(q=>Cr&&q.source!=="marketplace"?!1:(te==="all"||(te==="marketplace"?q.source==="marketplace":q.type===te))&&Bg(C,[q.id,q.label,q.displayName,q.description,q.type,q.source,q.packageId,q.version])),[c,Cr,C,te]),xi=m.useMemo(()=>{const q=new Map;for(const be of g)q.set(be.id,new Set(be.skillKeys||[]));return q},[g]),Ws=m.useMemo(()=>[{id:"all",label:"全部"},...g.map(q=>({id:`collection:${q.id}`,label:q.name,count:q.skillKeys.length,collection:q})),{id:"ungrouped",label:"未分组"}],[g]),hr=m.useMemo(()=>u.filter(q=>{var Ue;const be=xn(q);let Ae=te==="all";if(te.startsWith("collection:")){const yt=te.slice(11);Ae=!!((Ue=xi.get(yt))!=null&&Ue.has(be))}else te==="ungrouped"&&(Ae=!Array.from(xi.values()).some(yt=>yt.has(be)));return Ae&&Bg(C,[q.name,q.id,q.description,q.sourceLabel,q.source,q.path])}),[u,C,te,xi]),sr=m.useMemo(()=>p.filter(q=>Bg(C,[q.id,q.name,q.displayName,q.description,q.version,q.packageDir,Array.isArray(q.tags)?q.tags.join(" "):""])),[p,C]),Vs=Pn||pr||s==="skills",Ye=m.useMemo(()=>fs.find(q=>xn(q)===ue)||fs[0]||null,[fs,ue]),Vt=m.useMemo(()=>hr.find(q=>xn(q)===ue)||hr[0]||null,[hr,ue]),ln=m.useMemo(()=>sr.find(q=>Su(q)===ue)||sr[0]||null,[sr,ue]),mr=Vt?re[xn(Vt)]:null,He=Ye?Be[xn(Ye)]:null,Xt=Ye&&Pt?an[`${xn(Ye)}:${Pt}`]:null,_e=t(Pn?"project:searchNodes":pr?"project:searchFlows":s==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(s!=="skills"||!Vt)return;const q=xn(Vt);if(re[q])return;let be=!1;return ye(q),fetch(`/api/skills/detail?key=${encodeURIComponent(q)}`).then(Ae=>Ae.json().then(Ue=>({ok:Ae.ok,json:Ue}))).then(({ok:Ae,json:Ue})=>{be||Ae&&Ue.skill&&pe(yt=>({...yt,[q]:Ue.skill}))}).catch(()=>{}).finally(()=>{be||ye("")}),()=>{be=!0}},[s,Vt,re]),m.useEffect(()=>{if(!Pn||!Ye)return;const q=xn(Ye);if(Be[q])return;let be=!1;return _t(q),fetch(`/api/nodes/detail?id=${encodeURIComponent(Ye.id)}`).then(Ae=>Ae.json().then(Ue=>({ok:Ae.ok,json:Ue}))).then(({ok:Ae,json:Ue})=>{be||Ae&&lt(yt=>({...yt,[q]:Ue}))}).catch(()=>{}).finally(()=>{be||_t("")}),()=>{be=!0}},[Pn,Ye,Be]),m.useEffect(()=>{if(!Pn)return;const q=Array.isArray(He==null?void 0:He.files)?He.files:[];Te(be=>{var Ae;return be&&q.some(Ue=>Ue.path===be)?be:((Ae=q[0])==null?void 0:Ae.path)||""})},[Pn,He]),m.useEffect(()=>{if(!Pn||!Ye||!Pt)return;const q=`${xn(Ye)}:${Pt}`;if(an[q])return;let be=!1;return _n(q),fetch(`/api/nodes/file?id=${encodeURIComponent(Ye.id)}&path=${encodeURIComponent(Pt)}`).then(Ae=>Ae.json().then(Ue=>({ok:Ae.ok,json:Ue}))).then(({ok:Ae,json:Ue})=>{be||Ae&&Fn(yt=>({...yt,[q]:Ue}))}).catch(()=>{}).finally(()=>{be||_n("")}),()=>{be=!0}},[Pn,Ye,Pt,an]),m.useEffect(()=>{xe("")},[ue,s]);const bn=q=>{n(op(q,"workspace"))},Er=q=>{n(op({id:q.flowId,source:q.flowSource,archived:!!q.archived},"workspace"))},ot=m.useCallback(q=>{var be,Ae;q.preventDefault(),q.stopPropagation(),(Ae=(be=q.dataTransfer)==null?void 0:be.types)!=null&&Ae.includes("Files")&&(Xe.current+=1,T(!0))},[]),Xn=m.useCallback(q=>{q.preventDefault(),q.stopPropagation(),Xe.current-=1,Xe.current<=0&&(Xe.current=0,T(!1))},[]),ir=m.useCallback(q=>{q.preventDefault(),q.stopPropagation()},[]),zn=m.useCallback(q=>{var Ue,yt;q.preventDefault(),q.stopPropagation(),Xe.current=0,T(!1);const be=(yt=(Ue=q.dataTransfer)==null?void 0:Ue.files)==null?void 0:yt[0];if(!be)return;const Ae=be.name.toLowerCase();!Ae.endsWith(".yaml")&&!Ae.endsWith(".yml")&&!Ae.endsWith(".zip")||z(be)},[]);return o.jsxs("div",{className:"af-projects"+(_?" af-projects--drop-target":""),onDragEnter:ot,onDragLeave:Xn,onDragOver:ir,onDrop:zn,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:s==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>i("all"),children:t("project:all")}),o.jsx("button",{type:"button",className:s==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>i("archived"),children:t("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"+(C.trim()?" af-search--has-clear":""),type:"search",placeholder:_e,"aria-label":_e,autoComplete:"off",value:C,onChange:q=>G(q.target.value),onKeyDown:q=>{q.key==="Escape"&&(G(""),q.currentTarget.blur())}}),C.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>G(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Vs?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>Dt(),children:t("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(Z?" af-icon-btn--active":""),"aria-label":t("flow:palette.toggleRecentActivity"),"aria-expanded":Z,"aria-controls":"af-recent-activity-panel",onClick:()=>W(q=>!q),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>O(!0),children:t("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:t(s==="my-nodes"?"project:myNodes":s==="my-flows"?"project:myFlows":s==="nodes"?"project:globalNodes":s==="skills"?"project:globalSkills":s==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:nt?t("project:filterResult",{count:s==="nodes"||s==="my-nodes"?fs.length:s==="my-flows"?sr.length:s==="skills"?hr.length:Us.length}):s==="my-nodes"?t("project:myNodesHint",{count:fs.length}):s==="my-flows"?t("project:myFlowsHint",{count:sr.length}):s==="nodes"?t("project:nodesHint",{count:c.length}):s==="skills"?t("project:skillsHint",{count:u.length}):t(s==="archived"?"project:archivedHint":"project:activeHint")}),k?o.jsx("p",{className:"af-err af-projects-api-hint",children:k}):null,R&&Vs?o.jsx("p",{className:"af-err af-projects-api-hint",children:R}):null]}),Vs?o.jsxs("div",{className:"af-resource-toolbar",children:[s==="skills"?o.jsx(IO,{onChanged:Dt}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:pr?"schema":Pn?Cr?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:t(pr?"project:myFlowsPurposeTitle":Cr?"project:myNodesPurposeTitle":Pn?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:t(pr?"project:myFlowsPurposeDesc":Cr?"project:myNodesPurposeDesc":Pn?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),pr?null:o.jsx("div",{className:"af-resource-filter-row",children:(Pn?(Cr?BO:zO).map(q=>({id:q,label:t(`project:resourceFilter.${q}`)})):Ws).map(q=>q.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(te===q.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{le(q.id),de("")},children:[q.label,o.jsx("em",{children:q.count}),q.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),q.collection.builtin?null:o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:v,"aria-label":`删除 ${q.collection.name}`,onClick:()=>Gt(q.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},q.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(te===q.id?" af-resource-filter--active":""),onClick:()=>{le(q.id),de("")},children:q.label},q.id))}),s==="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:S,onChange:q=>y(q.target.value),onKeyDown:q=>{q.key==="Enter"&&Yt()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!S.trim()||v,onClick:()=>Yt(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Pn?o.jsx("div",{className:"af-resource-grid",children:fs.length>0?fs.map(q=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Ye&&xn(q)===xn(Ye)?" af-resource-card--active":""),onClick:()=>de(xn(q)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:ku(q.type==="control"?"secondary":q.type==="provide"?"primary":"muted"),children:o.jsx($n,{query:C,children:q.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx($n,{query:C,children:ik(q.source,t)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx($n,{query:C,children:q.label||q.displayName||q.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx($n,{query:C,children:q.description||t("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx($n,{query:C,children:q.id})}),o.jsx("span",{children:t("project:nodeSlots",{inputs:Object.keys(q.inputs||{}).length,outputs:Object.keys(q.outputs||{}).length})})]}),q.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($n,{query:C,children:`${q.packageId}${q.version?` / ${q.version}`:""}`})})]}):null]},`${q.id}:${q.source||""}:${q.packageId||""}`)):L?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:nt?t("project:noNodeMatch",{query:C.trim()}):t(Cr?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:t("project:loadingResources")})})}):pr?o.jsx("div",{className:"af-resource-grid",children:sr.length>0?sr.map(q=>{const be=q.snippet&&Array.isArray(q.snippet.instances)?q.snippet.instances:[],Ae=q.snippet&&Array.isArray(q.snippet.edges)?q.snippet.edges:[],Ue=Number.isFinite(Number(q.nodeCount))?Number(q.nodeCount):be.length,yt=Number.isFinite(Number(q.edgeCount))?Number(q.edgeCount):Ae.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(ln&&Su(q)===Su(ln)?" af-resource-card--active":""),onClick:()=>de(Su(q)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:ku("primary"),children:o.jsx($n,{query:C,children:q.version?`v${q.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:t("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx($n,{query:C,children:q.displayName||q.name||q.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx($n,{query:C,children:q.description||t("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:t("project:flowSnippetNodes",{nodes:Ue,edges:yt})}),o.jsx("span",{children:o.jsx($n,{query:C,children:q.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($n,{query:C,children:ok(q)})})]})]},Su(q))}):L?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:nt?t("project:noFlowSnippetMatch",{query:C.trim()}):t("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:t("project:loadingResources")})})}):s==="skills"?o.jsx("div",{className:"af-resource-grid",children:hr.length>0?hr.map(q=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Vt&&xn(q)===xn(Vt)?" af-resource-card--active":""),onClick:()=>de(xn(q)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:ku(q.source==="builtin"?"muted":"primary"),children:o.jsx($n,{query:C,children:q.sourceLabel||q.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:t("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx($n,{query:C,children:q.name||q.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx($n,{query:C,children:q.description||t("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($n,{query:C,children:q.path||q.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[g.filter(be=>be.skillKeys.includes(xn(q))).slice(0,3).map(be=>o.jsx("span",{children:be.name},be.id)),g.filter(be=>be.skillKeys.includes(xn(q))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},q.key||`${q.source}:${q.name}`)):L?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:nt?t("project:noSkillMatch",{query:C.trim()}):t("project:noSkills")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:t("project:loadingResources")})})}):o.jsxs("div",{className:"af-project-grid",children:[Us.length>0?Us.map(q=>o.jsx("button",{type:"button",className:"af-project-card",onClick:()=>bn(q),children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:ku(Px(q.source,t).tone),children:o.jsx($n,{query:C,children:Px(q.source,t).label})}),q.archived?o.jsx("span",{className:ku("muted"),children:o.jsx($n,{query:C,children:t("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx($n,{query:C,children:q.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx($n,{query:C,children:_E(q,t)})}),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($n,{query:C,children:EE(q)})})]})]})},`${q.id}:${q.source??"user"}:${q.archived?"a":""}`)):K?hn.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:s==="archived"?t("project:noArchived"):a.length>0?t("project:noActive"):t(k?"project:loadFailed":"project:noPipelines")}),!k&&a.length===0&&s==="all"?o.jsx("p",{className:"af-projects-empty-hint",children:t("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:t("project:noMatch",{query:C.trim()})})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:t("project:loadingPipelines")})}),o.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>O(!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:t("project:newPipeline")})]}),Ve?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"}),t("project:hubCard.eyebrow")]}),o.jsx("h3",{className:"af-hub-card__title",children:t("project:hubCard.title")}),o.jsx("p",{className:"af-hub-card__desc",children:t("project:hubCard.desc")}),o.jsxs("span",{className:"af-hub-card__cta",children:[t("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:t("project:hubCard.cliHint")})]})]})]}),Vs?o.jsx("aside",{className:"af-resource-detail","aria-label":t(Pn?"project:nodeDetail":pr?"project:flowDetail":"project:skillDetail"),children:Pn&&Ye?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:Ye.label||Ye.displayName||Ye.id}),o.jsx("p",{children:Ye.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(q=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(ce===q?" af-resource-detail-tab--active":""),onClick:()=>fe(q),children:t(`project:nodeDetailTabs.${q}`)},q))}),Ge===xn(Ye)?o.jsx("p",{className:"af-resource-detail-desc",children:t("project:loadingResources")}):ce==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:Ye.description||((ps=He==null?void 0:He.node)==null?void 0:ps.description)||t("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailType")}),o.jsx("dd",{children:Ye.type||((Jn=He==null?void 0:He.node)==null?void 0:Jn.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailSource")}),o.jsx("dd",{children:ik(Ye.source,t)})]}),Ye.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailPackage")}),o.jsx("dd",{children:Ye.packageId})]}):null,Ye.version?o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailVersion")}),o.jsx("dd",{children:Ye.version})]}):null,Ye.packageDir||He!=null&&He.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailPath")}),o.jsx("dd",{children:Ye.packageDir||(He==null?void 0:He.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailEditable")}),o.jsx("dd",{children:(He==null?void 0:He.readOnly)===!1?t("project:editable"):t("project:readOnly")})]})]}),Cr&&Ye.source==="marketplace"?o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:t("project:myNodeManagement")}),o.jsx("p",{children:t("project:deleteMyNodeHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:jr===xn(Ye),onClick:()=>he(Ye),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),jr===xn(Ye)?t("project:deletingMyNode"):t("project:deleteMyNode")]}),ie?o.jsx("p",{className:"af-resource-action-message",children:ie}):null]}):null,o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:t("project:resourceMeaning")}),o.jsx("p",{children:t("project:nodesMeaning")})]})]}):ce==="schema"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:t("project:nodeSchema")}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:t("project:nodeInputs")}),ap(((Ks=He==null?void 0:He.node)==null?void 0:Ks.inputs)||Ye.inputs).length>0?ap(((_r=He==null?void 0:He.node)==null?void 0:_r.inputs)||Ye.inputs).map(q=>o.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):o.jsx("em",{children:t("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:t("project:nodeOutputs")}),ap(((Es=He==null?void 0:He.node)==null?void 0:Es.outputs)||Ye.outputs).length>0?ap((($r=He==null?void 0:He.node)==null?void 0:$r.outputs)||Ye.outputs).map(q=>o.jsxs("code",{children:[q.name||q.key,q.type?`: ${q.type}`:""]},q.key)):o.jsx("em",{children:t("project:noSlots")})]})]}):ce==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:t("project:nodeRuntime")}),He!=null&&He.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(He.runtime,null,2)}):o.jsx("p",{children:t("project:noRuntimeManifest")}),He!=null&&He.body?o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"af-resource-detail-subtitle",children:t("project:nodeBody")}),o.jsx("pre",{className:"af-resource-skill-preview",children:He.body})]}):o.jsx("p",{children:t("project:noNodeBody")})]}):ce==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:t("project:nodeFiles")}),Array.isArray(He==null?void 0:He.files)&&He.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:He.files.map(q=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(Pt===q.path?" af-node-file-item--active":""),onClick:()=>Te(q.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:q.path})]},q.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[qt===`${xn(Ye)}:${Pt}`?t("project:loadingResources"):Xt!=null&&Xt.binary?t("project:binaryFile"):(Xt==null?void 0:Xt.content)||t("project:selectNodeFile"),Xt!=null&&Xt.truncated?`
43
-
44
- ${t("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:t("project:noNodeFiles")})]}):o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:t("project:nodeUsage")}),Array.isArray(He==null?void 0:He.usage)&&He.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:He.usage.map(q=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:q.flowId}),o.jsxs("span",{children:[q.flowSource,q.archived?` · ${t("project:archived")}`:""]}),o.jsx("em",{children:q.instances.map(be=>be.label||be.instanceId).join(", ")})]},`${q.flowSource}:${q.flowId}:${q.archived?"a":""}`))}):o.jsx("p",{children:t("project:noNodeUsage")})]})]}):pr&&ln?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:ln.displayName||ln.name||ln.id}),o.jsx("p",{children:ln.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:ln.description||t("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailVersion")}),o.jsx("dd",{children:ln.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailPath")}),o.jsx("dd",{children:ok(ln)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:t("project:flowSnippetScale")}),o.jsx("dd",{children:t("project:flowSnippetNodes",{nodes:Number.isFinite(Number(ln.nodeCount))?Number(ln.nodeCount):Array.isArray((gr=ln.snippet)==null?void 0:gr.instances)?ln.snippet.instances.length:0,edges:Number.isFinite(Number(ln.edgeCount))?Number(ln.edgeCount):Array.isArray((yr=ln.snippet)==null?void 0:yr.edges)?ln.snippet.edges.length:0})})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:t("project:resourceMeaning")}),o.jsx("p",{children:t("project:myFlowsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:t("project:flowSnippetPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(ln.snippet||{},null,2)})]})]}):s==="skills"&&Vt?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:Vt.name||Vt.id}),o.jsx("p",{children:Vt.sourceLabel||Vt.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Vt.description||t("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailSource")}),o.jsx("dd",{children:Vt.sourceLabel||Vt.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:t("project:detailPath")}),o.jsx("dd",{children:Vt.path||Vt.key})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:"Collections"}),g.length===0?o.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):o.jsx("div",{className:"af-skill-detail-collections",children:g.map(q=>{const be=xn(Vt),Ae=q.skillKeys.includes(be);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Ae,disabled:v,onChange:Ue=>rr(q.id,be,Ue.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:q.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[q.skillKeys.length," skills"]})]})]},q.id)})})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:t("project:resourceMeaning")}),o.jsx("p",{children:t("project:skillsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:t("project:skillPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:ae===xn(Vt)?t("project:loadingResources"):(mr==null?void 0:mr.body)||(mr==null?void 0:mr.content)||t("project:skillPreviewEmpty")})]})]}):o.jsx("p",{className:"af-activity-empty",children:t("project:selectResource")})}):o.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(Z?"":" af-activity--hidden"),"aria-hidden":!Z,"aria-label":t("project:recentActivity"),children:[o.jsxs("h2",{className:"af-activity-title",children:[o.jsx("span",{className:"af-activity-bullet"}),t("project:recentActivity")]}),o.jsx("div",{className:"af-activity-list",children:Wt.length===0?o.jsx("p",{className:"af-activity-empty",children:Ee.length===0?t("project:noRecentActivity"):t("project:noMatchRecent")}):Wt.map(q=>o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action",onClick:()=>Er(q),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx($n,{query:C,children:q.flowId})}),o.jsx("span",{className:"af-activity-time",children:Cx(q.at,t)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:LO(q.kind),children:q.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[q.kind==="executed"?t("project:recentRun"):t("project:recentOpen")," · ",Cx(q.at,t)]})]})]},`${q.kind}-${q.flowId}-${q.flowSource}-${q.at}`))})]})]}),o.jsx(EO,{open:M,onClose:()=>O(!1),onCreated:async q=>{O(!1),await On();const be=q.source??"user";n(op({id:q.id,source:be},"workspace"))}}),A?o.jsx(jO,{file:A,onClose:()=>z(null),onImported:async q=>{z(null),await On();const be=q.source??"user";n(op({id:q.id,source:be},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}function Gn(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=Gn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var HO={value:()=>{}};function km(){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 Wp(n)}function Wp(e){this._=e}function UO(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}})}Wp.prototype=km.prototype={constructor:Wp,on:function(e,t){var n=this._,r=UO(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=WO(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]=ak(n[s],e.name,t);else if(t==null)for(s in n)n[s]=ak(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 Wp(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 WO(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function ak(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=HO,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ax="http://www.w3.org/1999/xhtml";const lk={svg:"http://www.w3.org/2000/svg",xhtml:Ax,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Sm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),lk.hasOwnProperty(t)?{space:lk[t],local:e}:e}function VO(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ax&&t.documentElement.namespaceURI===Ax?t.createElement(e):t.createElementNS(n,e)}}function KO(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function PE(e){var t=Sm(e);return(t.local?KO:VO)(t)}function qO(){}function hv(e){return e==null?qO:function(){return this.querySelector(e)}}function YO(e){typeof e!="function"&&(e=hv(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,u=0;u<a;++u)(c=i[u])&&(d=e.call(c,c.__data__,u,i))&&("__data__"in c&&(d.__data__=c.__data__),l[u]=d);return new Ns(r,this._parents)}function GO(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function XO(){return[]}function AE(e){return e==null?XO:function(){return this.querySelectorAll(e)}}function JO(e){return function(){return GO(e.apply(this,arguments))}}function QO(e){typeof e=="function"?e=JO(e):e=AE(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 Ns(r,s)}function IE(e){return function(){return this.matches(e)}}function TE(e){return function(t){return t.matches(e)}}var ZO=Array.prototype.find;function eM(e){return function(){return ZO.call(this.children,e)}}function tM(){return this.firstElementChild}function nM(e){return this.select(e==null?tM:eM(typeof e=="function"?e:TE(e)))}var rM=Array.prototype.filter;function sM(){return Array.from(this.children)}function iM(e){return function(){return rM.call(this.children,e)}}function oM(e){return this.selectAll(e==null?sM:iM(typeof e=="function"?e:TE(e)))}function aM(e){typeof e!="function"&&(e=IE(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 Ns(r,this._parents)}function RE(e){return new Array(e.length)}function lM(){return new Ns(this._enter||this._groups.map(RE),this._parents)}function Eh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Eh.prototype={constructor:Eh,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 cM(e){return function(){return e}}function uM(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 Eh(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function dM(e,t,n,r,s,i,a){var l,c,d=new Map,u=t.length,f=i.length,p=new Array(u),h;for(l=0;l<u;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",d.has(h)?s[l]=c:d.set(h,c));for(l=0;l<f;++l)h=a.call(e,i[l],l,i)+"",(c=d.get(h))?(r[l]=c,c.__data__=i[l],d.delete(h)):n[l]=new Eh(e,i[l]);for(l=0;l<u;++l)(c=t[l])&&d.get(p[l])===c&&(s[l]=c)}function fM(e){return e.__data__}function pM(e,t){if(!arguments.length)return Array.from(this,fM);var n=t?dM:uM,r=this._parents,s=this._groups;typeof e!="function"&&(e=cM(e));for(var i=s.length,a=new Array(i),l=new Array(i),c=new Array(i),d=0;d<i;++d){var u=r[d],f=s[d],p=f.length,h=hM(e.call(u,u&&u.__data__,d,r)),g=h.length,b=l[d]=new Array(g),S=a[d]=new Array(g),y=c[d]=new Array(p);n(u,f,b,S,y,h,t);for(var v=0,w=0,j,E;v<g;++v)if(j=b[v]){for(v>=w&&(w=v+1);!(E=S[w])&&++w<g;);j._next=E||null}}return a=new Ns(a,r),a._enter=l,a._exit=c,a}function hM(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function mM(){return new Ns(this._exit||this._groups.map(RE),this._parents)}function gM(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 yM(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],u=r[c],f=d.length,p=l[c]=new Array(f),h,g=0;g<f;++g)(h=d[g]||u[g])&&(p[g]=h);for(;c<s;++c)l[c]=n[c];return new Ns(l,this._parents)}function xM(){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 wM(e){e||(e=vM);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,c=s[i]=new Array(l),d,u=0;u<l;++u)(d=a[u])&&(c[u]=d);c.sort(t)}return new Ns(s,this._parents).order()}function vM(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function bM(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function kM(){return Array.from(this)}function SM(){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 NM(){let e=0;for(const t of this)++e;return e}function jM(){return!this.node()}function CM(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 EM(e){return function(){this.removeAttribute(e)}}function _M(e){return function(){this.removeAttributeNS(e.space,e.local)}}function PM(e,t){return function(){this.setAttribute(e,t)}}function AM(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function IM(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function TM(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 RM(e,t){var n=Sm(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?_M:EM:typeof t=="function"?n.local?TM:IM:n.local?AM:PM)(n,t))}function LE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function LM(e){return function(){this.style.removeProperty(e)}}function OM(e,t,n){return function(){this.style.setProperty(e,t,n)}}function MM(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function $M(e,t,n){return arguments.length>1?this.each((t==null?LM:typeof t=="function"?MM:OM)(e,t,n??"")):kc(this.node(),e)}function kc(e,t){return e.style.getPropertyValue(t)||LE(e).getComputedStyle(e,null).getPropertyValue(t)}function DM(e){return function(){delete this[e]}}function FM(e,t){return function(){this[e]=t}}function zM(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function BM(e,t){return arguments.length>1?this.each((t==null?DM:typeof t=="function"?zM:FM)(e,t)):this.node()[e]}function OE(e){return e.trim().split(/^|\s+/)}function mv(e){return e.classList||new ME(e)}function ME(e){this._node=e,this._names=OE(e.getAttribute("class")||"")}ME.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 $E(e,t){for(var n=mv(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function DE(e,t){for(var n=mv(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function HM(e){return function(){$E(this,e)}}function UM(e){return function(){DE(this,e)}}function WM(e,t){return function(){(t.apply(this,arguments)?$E:DE)(this,e)}}function VM(e,t){var n=OE(e+"");if(arguments.length<2){for(var r=mv(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?WM:t?HM:UM)(n,t))}function KM(){this.textContent=""}function qM(e){return function(){this.textContent=e}}function YM(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function GM(e){return arguments.length?this.each(e==null?KM:(typeof e=="function"?YM:qM)(e)):this.node().textContent}function XM(){this.innerHTML=""}function JM(e){return function(){this.innerHTML=e}}function QM(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ZM(e){return arguments.length?this.each(e==null?XM:(typeof e=="function"?QM:JM)(e)):this.node().innerHTML}function e$(){this.nextSibling&&this.parentNode.appendChild(this)}function t$(){return this.each(e$)}function n$(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function r$(){return this.each(n$)}function s$(e){var t=typeof e=="function"?e:PE(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function i$(){return null}function o$(e,t){var n=typeof e=="function"?e:PE(e),r=t==null?i$:typeof t=="function"?t:hv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function a$(){var e=this.parentNode;e&&e.removeChild(this)}function l$(){return this.each(a$)}function c$(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function u$(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function d$(e){return this.select(e?u$:c$)}function f$(e){return arguments.length?this.property("__data__",e):this.node().__data__}function p$(e){return function(t){e.call(this,t,this.__data__)}}function h$(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 m$(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 g$(e,t,n){return function(){var r=this.__on,s,i=p$(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 y$(e,t,n){var r=h$(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,d=l.length,u;c<d;++c)for(s=0,u=l[c];s<i;++s)if((a=r[s]).type===u.type&&a.name===u.name)return u.value}return}for(l=t?g$:m$,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function FE(e,t,n){var r=LE(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 x$(e,t){return function(){return FE(this,e,t)}}function w$(e,t){return function(){return FE(this,e,t.apply(this,arguments))}}function v$(e,t){return this.each((typeof t=="function"?w$:x$)(e,t))}function*b$(){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 zE=[null];function Ns(e,t){this._groups=e,this._parents=t}function ef(){return new Ns([[document.documentElement]],zE)}function k$(){return this}Ns.prototype=ef.prototype={constructor:Ns,select:YO,selectAll:QO,selectChild:nM,selectChildren:oM,filter:aM,data:pM,enter:lM,exit:mM,join:gM,merge:yM,selection:k$,order:xM,sort:wM,call:bM,nodes:kM,node:SM,size:NM,empty:jM,each:CM,attr:RM,style:$M,property:BM,classed:VM,text:GM,html:ZM,raise:t$,lower:r$,append:s$,insert:o$,remove:l$,clone:d$,datum:f$,on:y$,dispatch:v$,[Symbol.iterator]:b$};function xs(e){return typeof e=="string"?new Ns([[document.querySelector(e)]],[document.documentElement]):new Ns([[e]],zE)}function S$(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ii(e,t){if(e=S$(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 N$={passive:!1},Cd={capture:!0,passive:!1};function Hg(e){e.stopImmediatePropagation()}function uc(e){e.preventDefault(),e.stopImmediatePropagation()}function BE(e){var t=e.document.documentElement,n=xs(e).on("dragstart.drag",uc,Cd);"onselectstart"in t?n.on("selectstart.drag",uc,Cd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function HE(e,t){var n=e.document.documentElement,r=xs(e).on("dragstart.drag",null);t&&(r.on("click.drag",uc,Cd),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 lp=e=>()=>e;function Ix(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:c,dy:d,dispatch:u}){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:u}})}Ix.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function j$(e){return!e.ctrlKey&&!e.button}function C$(){return this.parentNode}function E$(e,t){return t??{x:e.x,y:e.y}}function _$(){return navigator.maxTouchPoints||"ontouchstart"in this}function UE(){var e=j$,t=C$,n=E$,r=_$,s={},i=km("start","drag","end"),a=0,l,c,d,u,f=0;function p(j){j.on("mousedown.drag",h).filter(r).on("touchstart.drag",S).on("touchmove.drag",y,N$).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(j,E){if(!(u||!e.call(this,j,E))){var k=w(this,t.call(this,j,E),j,E,"mouse");k&&(xs(j.view).on("mousemove.drag",g,Cd).on("mouseup.drag",b,Cd),BE(j.view),Hg(j),d=!1,l=j.clientX,c=j.clientY,k("start",j))}}function g(j){if(uc(j),!d){var E=j.clientX-l,k=j.clientY-c;d=E*E+k*k>f}s.mouse("drag",j)}function b(j){xs(j.view).on("mousemove.drag mouseup.drag",null),HE(j.view,d),uc(j),s.mouse("end",j)}function S(j,E){if(e.call(this,j,E)){var k=j.changedTouches,I=t.call(this,j,E),R=k.length,$,K;for($=0;$<R;++$)(K=w(this,I,j,E,k[$].identifier,k[$]))&&(Hg(j),K("start",j,k[$]))}}function y(j){var E=j.changedTouches,k=E.length,I,R;for(I=0;I<k;++I)(R=s[E[I].identifier])&&(uc(j),R("drag",j,E[I]))}function v(j){var E=j.changedTouches,k=E.length,I,R;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),I=0;I<k;++I)(R=s[E[I].identifier])&&(Hg(j),R("end",j,E[I]))}function w(j,E,k,I,R,$){var K=i.copy(),D=ii($||k,E),L,H,M;if((M=n.call(j,new Ix("beforestart",{sourceEvent:k,target:p,identifier:R,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:K}),I))!=null)return L=M.x-D[0]||0,H=M.y-D[1]||0,function O(A,z,_){var T=D,C;switch(A){case"start":s[R]=O,C=a++;break;case"end":delete s[R],--a;case"drag":D=ii(_||z,E),C=a;break}K.call(A,j,new Ix(A,{sourceEvent:z,subject:M,target:p,identifier:R,active:C,x:D[0]+L,y:D[1]+H,dx:D[0]-T[0],dy:D[1]-T[1],dispatch:K}),I)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:lp(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:lp(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:lp(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:lp(!!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?(f=(j=+j)*j,p):Math.sqrt(f)},p}function gv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function WE(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function tf(){}var Ed=.7,_h=1/Ed,dc="\\s*([+-]?\\d+)\\s*",_d="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",P$=/^#([0-9a-f]{3,8})$/,A$=new RegExp(`^rgb\\(${dc},${dc},${dc}\\)$`),I$=new RegExp(`^rgb\\(${Fi},${Fi},${Fi}\\)$`),T$=new RegExp(`^rgba\\(${dc},${dc},${dc},${_d}\\)$`),R$=new RegExp(`^rgba\\(${Fi},${Fi},${Fi},${_d}\\)$`),L$=new RegExp(`^hsl\\(${_d},${Fi},${Fi}\\)$`),O$=new RegExp(`^hsla\\(${_d},${Fi},${Fi},${_d}\\)$`),ck={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};gv(tf,rl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:uk,formatHex:uk,formatHex8:M$,formatHsl:$$,formatRgb:dk,toString:dk});function uk(){return this.rgb().formatHex()}function M$(){return this.rgb().formatHex8()}function $$(){return VE(this).formatHsl()}function dk(){return this.rgb().formatRgb()}function rl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=P$.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?fk(t):n===3?new ns(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?cp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?cp(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=A$.exec(e))?new ns(t[1],t[2],t[3],1):(t=I$.exec(e))?new ns(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=T$.exec(e))?cp(t[1],t[2],t[3],t[4]):(t=R$.exec(e))?cp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=L$.exec(e))?mk(t[1],t[2]/100,t[3]/100,1):(t=O$.exec(e))?mk(t[1],t[2]/100,t[3]/100,t[4]):ck.hasOwnProperty(e)?fk(ck[e]):e==="transparent"?new ns(NaN,NaN,NaN,0):null}function fk(e){return new ns(e>>16&255,e>>8&255,e&255,1)}function cp(e,t,n,r){return r<=0&&(e=t=n=NaN),new ns(e,t,n,r)}function D$(e){return e instanceof tf||(e=rl(e)),e?(e=e.rgb(),new ns(e.r,e.g,e.b,e.opacity)):new ns}function Tx(e,t,n,r){return arguments.length===1?D$(e):new ns(e,t,n,r??1)}function ns(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gv(ns,Tx,WE(tf,{brighter(e){return e=e==null?_h:Math.pow(_h,e),new ns(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ed:Math.pow(Ed,e),new ns(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ns(Ya(this.r),Ya(this.g),Ya(this.b),Ph(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:pk,formatHex:pk,formatHex8:F$,formatRgb:hk,toString:hk}));function pk(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}`}function F$(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}${Va((isNaN(this.opacity)?1:this.opacity)*255)}`}function hk(){const e=Ph(this.opacity);return`${e===1?"rgb(":"rgba("}${Ya(this.r)}, ${Ya(this.g)}, ${Ya(this.b)}${e===1?")":`, ${e})`}`}function Ph(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ya(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Va(e){return e=Ya(e),(e<16?"0":"")+e.toString(16)}function mk(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new li(e,t,n,r)}function VE(e){if(e instanceof li)return new li(e.h,e.s,e.l,e.opacity);if(e instanceof tf||(e=rl(e)),!e)return new li;if(e instanceof li)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-s,c=(i+s)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?i+s:2-i-s,a*=60):l=c>0&&c<1?0:a,new li(a,l,c,e.opacity)}function z$(e,t,n,r){return arguments.length===1?VE(e):new li(e,t,n,r??1)}function li(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gv(li,z$,WE(tf,{brighter(e){return e=e==null?_h:Math.pow(_h,e),new li(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ed:Math.pow(Ed,e),new li(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new ns(Ug(e>=240?e-240:e+120,s,r),Ug(e,s,r),Ug(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new li(gk(this.h),up(this.s),up(this.l),Ph(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=Ph(this.opacity);return`${e===1?"hsl(":"hsla("}${gk(this.h)}, ${up(this.s)*100}%, ${up(this.l)*100}%${e===1?")":`, ${e})`}`}}));function gk(e){return e=(e||0)%360,e<0?e+360:e}function up(e){return Math.max(0,Math.min(1,e||0))}function Ug(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 yv=e=>()=>e;function B$(e,t){return function(n){return e+n*t}}function H$(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 U$(e){return(e=+e)==1?KE:function(t,n){return n-t?H$(t,n,e):yv(isNaN(t)?n:t)}}function KE(e,t){var n=t-e;return n?B$(e,n):yv(isNaN(e)?t:e)}const Ah=function e(t){var n=U$(t);function r(s,i){var a=n((s=Tx(s)).r,(i=Tx(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),d=KE(s.opacity,i.opacity);return function(u){return s.r=a(u),s.g=l(u),s.b=c(u),s.opacity=d(u),s+""}}return r.gamma=e,r}(1);function W$(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 V$(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function K$(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]=Zu(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 q$(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ii(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Y$(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]=Zu(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Rx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wg=new RegExp(Rx.source,"g");function G$(e){return function(){return e}}function X$(e){return function(t){return e(t)+""}}function qE(e,t){var n=Rx.lastIndex=Wg.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Rx.exec(e))&&(s=Wg.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:Ii(r,s)})),n=Wg.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?X$(c[0].x):G$(t):(t=c.length,function(d){for(var u=0,f;u<t;++u)l[(f=c[u]).i]=f.x(d);return l.join("")})}function Zu(e,t){var n=typeof t,r;return t==null||n==="boolean"?yv(t):(n==="number"?Ii:n==="string"?(r=rl(t))?(t=r,Ah):qE:t instanceof rl?Ah:t instanceof Date?q$:V$(t)?W$:Array.isArray(t)?K$:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Y$:Ii)(e,t)}var yk=180/Math.PI,Lx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function YE(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)*yk,skewX:Math.atan(c)*yk,scaleX:a,scaleY:l}}var dp;function J$(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Lx:YE(t.a,t.b,t.c,t.d,t.e,t.f)}function Q$(e){return e==null||(dp||(dp=document.createElementNS("http://www.w3.org/2000/svg","g")),dp.setAttribute("transform",e),!(e=dp.transform.baseVal.consolidate()))?Lx:(e=e.matrix,YE(e.a,e.b,e.c,e.d,e.e,e.f))}function GE(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function i(d,u,f,p,h,g){if(d!==f||u!==p){var b=h.push("translate(",null,t,null,n);g.push({i:b-4,x:Ii(d,f)},{i:b-2,x:Ii(u,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(d,u,f,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:Ii(d,u)})):u&&f.push(s(f)+"rotate("+u+r)}function l(d,u,f,p){d!==u?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:Ii(d,u)}):u&&f.push(s(f)+"skewX("+u+r)}function c(d,u,f,p,h,g){if(d!==f||u!==p){var b=h.push(s(h)+"scale(",null,",",null,")");g.push({i:b-4,x:Ii(d,f)},{i:b-2,x:Ii(u,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(d,u){var f=[],p=[];return d=e(d),u=e(u),i(d.translateX,d.translateY,u.translateX,u.translateY,f,p),a(d.rotate,u.rotate,f,p),l(d.skewX,u.skewX,f,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,p),d=u=null,function(h){for(var g=-1,b=p.length,S;++g<b;)f[(S=p[g]).i]=S.x(h);return f.join("")}}}var Z$=GE(J$,"px, ","px)","deg)"),eD=GE(Q$,", ",")",")"),tD=1e-12;function xk(e){return((e=Math.exp(e))+1/e)/2}function nD(e){return((e=Math.exp(e))-1/e)/2}function rD(e){return((e=Math.exp(2*e))-1)/(e+1)}const Vp=function e(t,n,r){function s(i,a){var l=i[0],c=i[1],d=i[2],u=a[0],f=a[1],p=a[2],h=u-l,g=f-c,b=h*h+g*g,S,y;if(b<tD)y=Math.log(p/d)/t,S=function(I){return[l+I*h,c+I*g,d*Math.exp(t*I*y)]};else{var v=Math.sqrt(b),w=(p*p-d*d+r*b)/(2*d*n*v),j=(p*p-d*d-r*b)/(2*p*n*v),E=Math.log(Math.sqrt(w*w+1)-w),k=Math.log(Math.sqrt(j*j+1)-j);y=(k-E)/t,S=function(I){var R=I*y,$=xk(E),K=d/(n*v)*($*rD(t*R+E)-nD(E));return[l+K*h,c+K*g,d*$/xk(t*R+E)]}}return S.duration=y*1e3*t/Math.SQRT2,S}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 Sc=0,$u=0,Nu=0,XE=1e3,Ih,Du,Th=0,sl=0,Nm=0,Pd=typeof performance=="object"&&performance.now?performance:Date,JE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function xv(){return sl||(JE(sD),sl=Pd.now()+Nm)}function sD(){sl=0}function Rh(){this._call=this._time=this._next=null}Rh.prototype=QE.prototype={constructor:Rh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?xv():+n)+(t==null?0:+t),!this._next&&Du!==this&&(Du?Du._next=this:Ih=this,Du=this),this._call=e,this._time=n,Ox()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ox())}};function QE(e,t,n){var r=new Rh;return r.restart(e,t,n),r}function iD(){xv(),++Sc;for(var e=Ih,t;e;)(t=sl-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Sc}function wk(){sl=(Th=Pd.now())+Nm,Sc=$u=0;try{iD()}finally{Sc=0,aD(),sl=0}}function oD(){var e=Pd.now(),t=e-Th;t>XE&&(Nm-=t,Th=e)}function aD(){for(var e,t=Ih,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:Ih=n);Du=e,Ox(r)}function Ox(e){if(!Sc){$u&&($u=clearTimeout($u));var t=e-sl;t>24?(e<1/0&&($u=setTimeout(wk,e-Pd.now()-Nm)),Nu&&(Nu=clearInterval(Nu))):(Nu||(Th=Pd.now(),Nu=setInterval(oD,XE)),Sc=1,JE(wk))}}function vk(e,t,n){var r=new Rh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var lD=km("start","end","cancel","interrupt"),cD=[],ZE=0,bk=1,Mx=2,Kp=3,kk=4,$x=5,qp=6;function jm(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;uD(e,n,{name:t,index:r,group:s,on:lD,tween:cD,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ZE})}function wv(e,t){var n=gi(e,t);if(n.state>ZE)throw new Error("too late; already scheduled");return n}function Ki(e,t){var n=gi(e,t);if(n.state>Kp)throw new Error("too late; already running");return n}function gi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function uD(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=QE(i,0,n.time);function i(d){n.state=bk,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var u,f,p,h;if(n.state!==bk)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===Kp)return vk(a);h.state===kk?(h.state=qp,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=qp,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(vk(function(){n.state===Kp&&(n.state=kk,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=Mx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Mx){for(n.state=Kp,s=new Array(p=n.tween.length),u=0,f=-1;u<p;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(c),n.state=$x,1),f=-1,p=s.length;++f<p;)s[f].call(e,u);n.state===$x&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=qp,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Yp(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>Mx&&r.state<$x,r.state=qp,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function dD(e){return this.each(function(){Yp(this,e)})}function fD(e,t){var n,r;return function(){var s=Ki(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 pD(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=Ki(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 hD(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=gi(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?fD:pD)(n,e,t))}function vv(e,t,n){var r=e._id;return e.each(function(){var s=Ki(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return gi(s,r).value[t]}}function e_(e,t){var n;return(typeof t=="number"?Ii:t instanceof rl?Ah:(n=rl(t))?(t=n,Ah):qE)(e,t)}function mD(e){return function(){this.removeAttribute(e)}}function gD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yD(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 xD(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 wD(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 vD(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 bD(e,t){var n=Sm(e),r=n==="transform"?eD:e_;return this.attrTween(e,typeof t=="function"?(n.local?vD:wD)(n,r,vv(this,"attr."+e,t)):t==null?(n.local?gD:mD)(n):(n.local?xD:yD)(n,r,t))}function kD(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function SD(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ND(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&SD(e,i)),n}return s._value=t,s}function jD(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&kD(e,i)),n}return s._value=t,s}function CD(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=Sm(e);return this.tween(n,(r.local?ND:jD)(r,t))}function ED(e,t){return function(){wv(this,e).delay=+t.apply(this,arguments)}}function _D(e,t){return t=+t,function(){wv(this,e).delay=t}}function PD(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ED:_D)(t,e)):gi(this.node(),t).delay}function AD(e,t){return function(){Ki(this,e).duration=+t.apply(this,arguments)}}function ID(e,t){return t=+t,function(){Ki(this,e).duration=t}}function TD(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?AD:ID)(t,e)):gi(this.node(),t).duration}function RD(e,t){if(typeof t!="function")throw new Error;return function(){Ki(this,e).ease=t}}function LD(e){var t=this._id;return arguments.length?this.each(RD(t,e)):gi(this.node(),t).ease}function OD(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ki(this,e).ease=n}}function MD(e){if(typeof e!="function")throw new Error;return this.each(OD(this._id,e))}function $D(e){typeof e!="function"&&(e=IE(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 wo(r,this._parents,this._name,this._id)}function DD(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],u=c.length,f=a[l]=new Array(u),p,h=0;h<u;++h)(p=c[h]||d[h])&&(f[h]=p);for(;l<r;++l)a[l]=t[l];return new wo(a,this._parents,this._name,this._id)}function FD(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 zD(e,t,n){var r,s,i=FD(t)?wv:Ki;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function BD(e,t){var n=this._id;return arguments.length<2?gi(this.node(),n).on.on(e):this.each(zD(n,e,t))}function HD(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function UD(){return this.on("end.remove",HD(this._id))}function WD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=hv(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),u,f,p=0;p<c;++p)(u=l[p])&&(f=e.call(u,u.__data__,p,l))&&("__data__"in u&&(f.__data__=u.__data__),d[p]=f,jm(d[p],t,n,p,d,gi(u,n)));return new wo(i,this._parents,t,n)}function VD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=AE(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var c=r[l],d=c.length,u,f=0;f<d;++f)if(u=c[f]){for(var p=e.call(u,u.__data__,f,c),h,g=gi(u,n),b=0,S=p.length;b<S;++b)(h=p[b])&&jm(h,t,n,b,p,g);i.push(p),a.push(u)}return new wo(i,a,t,n)}var KD=ef.prototype.constructor;function qD(){return new KD(this._groups,this._parents)}function YD(e,t){var n,r,s;return function(){var i=kc(this,e),a=(this.style.removeProperty(e),kc(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function t_(e){return function(){this.style.removeProperty(e)}}function GD(e,t,n){var r,s=n+"",i;return function(){var a=kc(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function XD(e,t,n){var r,s,i;return function(){var a=kc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),kc(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function JD(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=Ki(this,e),d=c.on,u=c.value[i]==null?l||(l=t_(t)):void 0;(d!==n||s!==u)&&(r=(n=d).copy()).on(a,s=u),c.on=r}}function QD(e,t,n){var r=(e+="")=="transform"?Z$:e_;return t==null?this.styleTween(e,YD(e,r)).on("end.style."+e,t_(e)):typeof t=="function"?this.styleTween(e,XD(e,r,vv(this,"style."+e,t))).each(JD(this._id,e)):this.styleTween(e,GD(e,r,t),n).on("end.style."+e,null)}function ZD(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function eF(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&ZD(e,a,n)),r}return i._value=t,i}function tF(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,eF(e,t,n??""))}function nF(e){return function(){this.textContent=e}}function rF(e){return function(){var t=e(this);this.textContent=t??""}}function sF(e){return this.tween("text",typeof e=="function"?rF(vv(this,"text",e)):nF(e==null?"":e+""))}function iF(e){return function(t){this.textContent=e.call(this,t)}}function oF(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&iF(s)),t}return r._value=e,r}function aF(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,oF(e))}function lF(){for(var e=this._name,t=this._id,n=n_(),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 u=gi(c,t);jm(c,e,n,d,a,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new wo(r,this._parents,e,n)}function cF(){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=Ki(this,r),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),d.on=t}),s===0&&i()})}var uF=0;function wo(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function n_(){return++uF}var ro=ef.prototype;wo.prototype={constructor:wo,select:WD,selectAll:VD,selectChild:ro.selectChild,selectChildren:ro.selectChildren,filter:$D,merge:DD,selection:qD,transition:lF,call:ro.call,nodes:ro.nodes,node:ro.node,size:ro.size,empty:ro.empty,each:ro.each,on:BD,attr:bD,attrTween:CD,style:QD,styleTween:tF,text:sF,textTween:aF,remove:UD,tween:hD,delay:PD,duration:TD,ease:LD,easeVarying:MD,end:cF,[Symbol.iterator]:ro[Symbol.iterator]};function dF(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var fF={time:null,delay:0,duration:250,ease:dF};function pF(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 hF(e){var t,n;e instanceof wo?(t=e._id,e=e._name):(t=n_(),(n=fF).time=xv(),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])&&jm(c,e,t,d,a,n||pF(c,t));return new wo(r,this._parents,e,t)}ef.prototype.interrupt=dD;ef.prototype.transition=hF;const fp=e=>()=>e;function mF(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 fo(e,t,n){this.k=e,this.x=t,this.y=n}fo.prototype={constructor:fo,scale:function(e){return e===1?this:new fo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new fo(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 Cm=new fo(1,0,0);r_.prototype=fo.prototype;function r_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Cm;return e.__zoom}function Vg(e){e.stopImmediatePropagation()}function ju(e){e.preventDefault(),e.stopImmediatePropagation()}function gF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function yF(){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 Sk(){return this.__zoom||Cm}function xF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function wF(){return navigator.maxTouchPoints||"ontouchstart"in this}function vF(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 s_(){var e=gF,t=yF,n=vF,r=xF,s=wF,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Vp,d=km("start","zoom","end"),u,f,p,h=500,g=150,b=0,S=10;function y(M){M.property("__zoom",Sk).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",K).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,O,A,z){var _=M.selection?M.selection():M;_.property("__zoom",Sk),M!==_?E(M,O,A,z):_.interrupt().each(function(){k(this,arguments).event(z).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},y.scaleBy=function(M,O,A,z){y.scaleTo(M,function(){var _=this.__zoom.k,T=typeof O=="function"?O.apply(this,arguments):O;return _*T},A,z)},y.scaleTo=function(M,O,A,z){y.transform(M,function(){var _=t.apply(this,arguments),T=this.__zoom,C=A==null?j(_):typeof A=="function"?A.apply(this,arguments):A,G=T.invert(C),Z=typeof O=="function"?O.apply(this,arguments):O;return n(w(v(T,Z),C,G),_,a)},A,z)},y.translateBy=function(M,O,A,z){y.transform(M,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof A=="function"?A.apply(this,arguments):A),t.apply(this,arguments),a)},null,z)},y.translateTo=function(M,O,A,z,_){y.transform(M,function(){var T=t.apply(this,arguments),C=this.__zoom,G=z==null?j(T):typeof z=="function"?z.apply(this,arguments):z;return n(Cm.translate(G[0],G[1]).scale(C.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof A=="function"?-A.apply(this,arguments):-A),T,a)},z,_)};function v(M,O){return O=Math.max(i[0],Math.min(i[1],O)),O===M.k?M:new fo(O,M.x,M.y)}function w(M,O,A){var z=O[0]-A[0]*M.k,_=O[1]-A[1]*M.k;return z===M.x&&_===M.y?M:new fo(M.k,z,_)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function E(M,O,A,z){M.on("start.zoom",function(){k(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(z).end()}).tween("zoom",function(){var _=this,T=arguments,C=k(_,T).event(z),G=t.apply(_,T),Z=A==null?j(G):typeof A=="function"?A.apply(_,T):A,W=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),te=_.__zoom,le=typeof O=="function"?O.apply(_,T):O,ue=c(te.invert(Z).concat(W/te.k),le.invert(Z).concat(W/le.k));return function(de){if(de===1)de=le;else{var ce=ue(de),fe=W/ce[2];de=new fo(fe,Z[0]-ce[0]*fe,Z[1]-ce[1]*fe)}C.zoom(null,de)}})}function k(M,O,A){return!A&&M.__zooming||new I(M,O)}function I(M,O){this.that=M,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,O),this.taps=0}I.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,O){return this.mouse&&M!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var O=xs(this.that).datum();d.call(M,this.that,new mF(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),O)}};function R(M,...O){if(!e.apply(this,arguments))return;var A=k(this,O).event(M),z=this.__zoom,_=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),T=ii(M);if(A.wheel)(A.mouse[0][0]!==T[0]||A.mouse[0][1]!==T[1])&&(A.mouse[1]=z.invert(A.mouse[0]=T)),clearTimeout(A.wheel);else{if(z.k===_)return;A.mouse=[T,z.invert(T)],Yp(this),A.start()}ju(M),A.wheel=setTimeout(C,g),A.zoom("mouse",n(w(v(z,_),A.mouse[0],A.mouse[1]),A.extent,a));function C(){A.wheel=null,A.end()}}function $(M,...O){if(p||!e.apply(this,arguments))return;var A=M.currentTarget,z=k(this,O,!0).event(M),_=xs(M.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",W,!0),T=ii(M,A),C=M.clientX,G=M.clientY;BE(M.view),Vg(M),z.mouse=[T,this.__zoom.invert(T)],Yp(this),z.start();function Z(te){if(ju(te),!z.moved){var le=te.clientX-C,ue=te.clientY-G;z.moved=le*le+ue*ue>b}z.event(te).zoom("mouse",n(w(z.that.__zoom,z.mouse[0]=ii(te,A),z.mouse[1]),z.extent,a))}function W(te){_.on("mousemove.zoom mouseup.zoom",null),HE(te.view,z.moved),ju(te),z.event(te).end()}}function K(M,...O){if(e.apply(this,arguments)){var A=this.__zoom,z=ii(M.changedTouches?M.changedTouches[0]:M,this),_=A.invert(z),T=A.k*(M.shiftKey?.5:2),C=n(w(v(A,T),z,_),t.apply(this,O),a);ju(M),l>0?xs(this).transition().duration(l).call(E,C,z,M):xs(this).call(y.transform,C,z,M)}}function D(M,...O){if(e.apply(this,arguments)){var A=M.touches,z=A.length,_=k(this,O,M.changedTouches.length===z).event(M),T,C,G,Z;for(Vg(M),C=0;C<z;++C)G=A[C],Z=ii(G,this),Z=[Z,this.__zoom.invert(Z),G.identifier],_.touch0?!_.touch1&&_.touch0[2]!==Z[2]&&(_.touch1=Z,_.taps=0):(_.touch0=Z,T=!0,_.taps=1+!!u);u&&(u=clearTimeout(u)),T&&(_.taps<2&&(f=Z[0],u=setTimeout(function(){u=null},h)),Yp(this),_.start())}}function L(M,...O){if(this.__zooming){var A=k(this,O).event(M),z=M.changedTouches,_=z.length,T,C,G,Z;for(ju(M),T=0;T<_;++T)C=z[T],G=ii(C,this),A.touch0&&A.touch0[2]===C.identifier?A.touch0[0]=G:A.touch1&&A.touch1[2]===C.identifier&&(A.touch1[0]=G);if(C=A.that.__zoom,A.touch1){var W=A.touch0[0],te=A.touch0[1],le=A.touch1[0],ue=A.touch1[1],de=(de=le[0]-W[0])*de+(de=le[1]-W[1])*de,ce=(ce=ue[0]-te[0])*ce+(ce=ue[1]-te[1])*ce;C=v(C,Math.sqrt(de/ce)),G=[(W[0]+le[0])/2,(W[1]+le[1])/2],Z=[(te[0]+ue[0])/2,(te[1]+ue[1])/2]}else if(A.touch0)G=A.touch0[0],Z=A.touch0[1];else return;A.zoom("touch",n(w(C,G,Z),A.extent,a))}}function H(M,...O){if(this.__zooming){var A=k(this,O).event(M),z=M.changedTouches,_=z.length,T,C;for(Vg(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),T=0;T<_;++T)C=z[T],A.touch0&&A.touch0[2]===C.identifier?delete A.touch0:A.touch1&&A.touch1[2]===C.identifier&&delete A.touch1;if(A.touch1&&!A.touch0&&(A.touch0=A.touch1,delete A.touch1),A.touch0)A.touch0[1]=this.__zoom.invert(A.touch0[0]);else if(A.end(),A.taps===2&&(C=ii(C,this),Math.hypot(f[0]-C[0],f[1]-C[1])<S)){var G=xs(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:fp(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:fp(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:fp(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:fp([[+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?(S=+M,y):S},y}const Wi={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."},Ad=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],i_=["Enter"," ","Escape"],o_={"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 Nc;(function(e){e.Strict="strict",e.Loose="loose"})(Nc||(Nc={}));var Ga;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ga||(Ga={}));var Id;(function(e){e.Partial="partial",e.Full="full"})(Id||(Id={}));const a_={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Go;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Go||(Go={}));var cs;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(cs||(cs={}));var Fe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Fe||(Fe={}));const Nk={[Fe.Left]:Fe.Right,[Fe.Right]:Fe.Left,[Fe.Top]:Fe.Bottom,[Fe.Bottom]:Fe.Top};function l_(e){return e===null?null:e?"valid":"invalid"}const c_=e=>"id"in e&&"source"in e&&"target"in e,bF=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),bv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),nf=(e,t=[0,0])=>{const{width:n,height:r}=So(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},kF=(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):bv(s)?s:t.nodeLookup.get(s.id));const l=a?Lh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Em(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return _m(n)},rf=(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=Em(n,Lh(s)),r=!0)}),r?_m(n):{x:0,y:0,width:0,height:0}},kv=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...of(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const d of e.values()){const{measured:u,selectable:f=!0,hidden:p=!1}=d;if(a&&!f||p)continue;const h=u.width??d.width??d.initialWidth??null,g=u.height??d.height??d.initialHeight??null,b=Td(l,Cc(d)),S=(h??0)*(g??0),y=i&&b>0;(!d.internals.handleBounds||y||b>=S||d.dragging)&&c.push(d)}return c},SF=(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 NF(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 jF({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=NF(e,a),c=rf(l),d=Sv(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 u_({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},u=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Wi.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(f=[[c,d],[c+h,d+g]])}else l&&Ec(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+d],[a.extent[1][0]+c,a.extent[1][1]+d]]);const p=Ec(f)?il(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Wi.error015())),{position:{x:p.x-c+(a.measured.width??0)*u[0],y:p.y-d+(a.measured.height??0)*u[1]},positionAbsolute:p}}async function CF({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 h=i.has(p.id),g=!h&&p.parentId&&a.find(b=>b.id===p.parentId);(h||g)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),u=SF(a,c);for(const p of c)l.has(p.id)&&!u.find(g=>g.id===p.id)&&u.push(p);if(!s)return{edges:u,nodes:a};const f=await s({nodes:a,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:a}:{edges:[],nodes:[]}:f}const jc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),il=(e={x:0,y:0},t,n)=>({x:jc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:jc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function d_(e,t,n){const{width:r,height:s}=So(n),{x:i,y:a}=n.internals.positionAbsolute;return il(e,[[i,a],[i+r,a+s]],t)}const jk=(e,t,n)=>e<t?jc(Math.abs(e-t),1,t)/t:e>n?-jc(Math.abs(e-n),1,t)/t:0,f_=(e,t,n=15,r=40)=>{const s=jk(e.x,r,t.width-r)*n,i=jk(e.y,r,t.height-r)*n;return[s,i]},Em=(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)}),Dx=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),_m=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Cc=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=bv(e)?e.internals.positionAbsolute:nf(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}},Lh=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=bv(e)?e.internals.positionAbsolute:nf(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)}},p_=(e,t)=>_m(Em(Dx(e),Dx(t))),Td=(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)},Ck=e=>ci(e.width)&&ci(e.height)&&ci(e.x)&&ci(e.y),ci=e=>!isNaN(e)&&isFinite(e),EF=(e,t)=>{},sf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),of=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?sf(l,a):l},Oh=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Al(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 _F(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Al(e,n),s=Al(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Al(e.top??e.y??0,n),s=Al(e.bottom??e.y??0,n),i=Al(e.left??e.x??0,t),a=Al(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 PF(e,t,n,r,s,i){const{x:a,y:l}=Oh(e,[t,n,r]),{x:c,y:d}=Oh({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=s-c,f=i-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(u),bottom:Math.floor(f)}}const Sv=(e,t,n,r,s,i)=>{const a=_F(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,d=Math.min(l,c),u=jc(d,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*u,g=n/2-p*u,b=PF(e,h,g,u,t,n),S={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:h-S.left+S.right,y:g-S.top+S.bottom,zoom:u}},Rd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ec(e){return e!=null&&e!=="parent"}function So(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 h_(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 m_(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 Ek(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function AF(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function IF(e){return{...o_,...e||{}}}function ed(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=ui(e),l=of({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:d}=n?sf(l,t):l;return{xSnapped:c,ySnapped:d,...l}}const Nv=e=>({width:e.offsetWidth,height:e.offsetHeight}),g_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},TF=["INPUT","SELECT","TEXTAREA"];function y_(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:TF.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const x_=e=>"clientX"in e,ui=(e,t)=>{var i,a;const n=x_(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)}},_k=(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,...Nv(a)}})};function w_({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,u=Math.abs(c-e),f=Math.abs(d-t);return[c,d,u,f]}function pp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Pk({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Fe.Left:return[t-pp(t-r,i),n];case Fe.Right:return[t+pp(r-t,i),n];case Fe.Top:return[t,n-pp(n-s,i)];case Fe.Bottom:return[t,n+pp(s-n,i)]}}function v_({sourceX:e,sourceY:t,sourcePosition:n=Fe.Bottom,targetX:r,targetY:s,targetPosition:i=Fe.Top,curvature:a=.25}){const[l,c]=Pk({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,u]=Pk({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,g]=w_({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${e},${t} C${l},${c} ${d},${u} ${r},${s}`,f,p,h,g]}function b_({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 RF({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 LF({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=Em(Lh(e),Lh(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 Td(a,_m(i))>0}const OF=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,MF=(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)),Ld=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||OF;let s;return c_(e)?s={...e}:s={...e,id:r(e)},MF(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function k_({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=b_({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const Ak={[Fe.Left]:{x:-1,y:0},[Fe.Right]:{x:1,y:0},[Fe.Top]:{x:0,y:-1},[Fe.Bottom]:{x:0,y:1}},$F=({source:e,sourcePosition:t=Fe.Bottom,target:n})=>t===Fe.Left||t===Fe.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},Ik=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function DF({source:e,sourcePosition:t=Fe.Bottom,target:n,targetPosition:r=Fe.Top,center:s,offset:i,stepPosition:a}){const l=Ak[t],c=Ak[r],d={x:e.x+l.x*i,y:e.y+l.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=$F({source:d,sourcePosition:t,target:u}),p=f.x!==0?"x":"y",h=f[p];let g=[],b,S;const y={x:0,y:0},v={x:0,y:0},[,,w,j]=b_({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+(u.x-d.x)*a,S=s.y??(d.y+u.y)/2):(b=s.x??(d.x+u.x)/2,S=s.y??d.y+(u.y-d.y)*a);const R=[{x:b,y:d.y},{x:b,y:u.y}],$=[{x:d.x,y:S},{x:u.x,y:S}];l[p]===h?g=p==="x"?R:$:g=p==="x"?$:R}else{const R=[{x:d.x,y:u.y}],$=[{x:u.x,y:d.y}];if(p==="x"?g=l.x===h?$:R:g=l.y===h?R:$,t===r){const M=Math.abs(e[p]-n[p]);if(M<=i){const O=Math.min(i-1,i-M);l[p]===h?y[p]=(d[p]>e[p]?-1:1)*O:v[p]=(u[p]>n[p]?-1:1)*O}}if(t!==r){const M=p==="x"?"y":"x",O=l[p]===c[M],A=d[M]>u[M],z=d[M]<u[M];(l[p]===1&&(!O&&A||O&&z)||l[p]!==1&&(!O&&z||O&&A))&&(g=p==="x"?R:$)}const K={x:d.x+y.x,y:d.y+y.y},D={x:u.x+v.x,y:u.y+v.y},L=Math.max(Math.abs(K.x-g[0].x),Math.abs(D.x-g[0].x)),H=Math.max(Math.abs(K.y-g[0].y),Math.abs(D.y-g[0].y));L>=H?(b=(K.x+D.x)/2,S=g[0].y):(b=g[0].x,S=(K.y+D.y)/2)}const E={x:d.x+y.x,y:d.y+y.y},k={x:u.x+v.x,y:u.y+v.y};return[[e,...E.x!==g[0].x||E.y!==g[0].y?[E]:[],...g,...k.x!==g[g.length-1].x||k.y!==g[g.length-1].y?[k]:[],n],b,S,w,j]}function FF(e,t,n,r){const s=Math.min(Ik(e,t)/2,Ik(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,u=e.y<n.y?1:-1;return`L ${i+s*d},${a}Q ${i},${a} ${i},${a+s*u}`}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 Fx({sourceX:e,sourceY:t,sourcePosition:n=Fe.Bottom,targetX:r,targetY:s,targetPosition:i=Fe.Top,borderRadius:a=5,centerX:l,centerY:c,offset:d=20,stepPosition:u=.5}){const[f,p,h,g,b]=DF({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:c},offset:d,stepPosition:u});let S=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)S+=FF(f[y-1],f[y],f[y+1],a);return S+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[S,p,h,g,b]}function Tk(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zF(e){var f;const{sourceNode:t,targetNode:n}=e;if(!Tk(t)||!Tk(n))return null;const r=t.internals.handleBounds||Rk(t.handles),s=n.internals.handleBounds||Rk(n.handles),i=Lk((r==null?void 0:r.source)??[],e.sourceHandle),a=Lk(e.connectionMode===Nc.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(f=e.onError)==null||f.call(e,"008",Wi.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Fe.Bottom,c=(a==null?void 0:a.position)||Fe.Top,d=ol(t,i,l),u=ol(n,a,c);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:l,targetPosition:c}}function Rk(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 ol(e,t,n=Fe.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??So(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Fe.Top:return{x:s+a/2,y:i};case Fe.Right:return{x:s+a,y:i+l/2};case Fe.Bottom:return{x:s+a/2,y:i+l};case Fe.Left:return{x:s,y:i+l/2}}}function Lk(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function zx(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function BF(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=zx(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 S_=1e3,HF=10,jv={nodeOrigin:[0,0],nodeExtent:Ad,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},UF={...jv,checkEquality:!0};function Cv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function WF(e,t,n){const r=Cv(jv,n);for(const s of e.values())if(s.parentId)_v(s,e,t,r);else{const i=nf(s,r.nodeOrigin),a=Ec(s.extent)?s.extent:r.nodeExtent,l=il(i,a,So(s));s.internals.positionAbsolute=l}}function VF(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 Ev(e){return e==="manual"}function Bx(e,t,n,r={}){var u,f;const s=Cv(UF,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Ev(s.zIndexMode)?S_:0;let c=e.length>0,d=!1;t.clear(),n.clear();for(const p of e){let h=a.get(p.id);if(s.checkEquality&&p===(h==null?void 0:h.internals.userNode))t.set(p.id,h);else{const g=nf(p,s.nodeOrigin),b=Ec(p.extent)?p.extent:s.nodeExtent,S=il(g,b,So(p));h={...s.defaults,...p,measured:{width:(u=p.measured)==null?void 0:u.width,height:(f=p.measured)==null?void 0:f.height},internals:{positionAbsolute:S,handleBounds:VF(p,h),z:N_(p,l,s.zIndexMode),userNode:p}},t.set(p.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),p.parentId&&_v(h,t,n,r,i),d||(d=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:d}}function KF(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 _v(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Cv(jv,r),d=e.parentId,u=t.get(d);if(!u){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}KF(e,n),s&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++s.i,u.internals.z=u.internals.z+s.i*HF),s&&u.internals.rootParentIndex!==void 0&&(s.i=u.internals.rootParentIndex);const f=i&&!Ev(c)?S_:0,{x:p,y:h,z:g}=qF(e,u,a,l,f,c),{positionAbsolute:b}=e.internals,S=p!==b.x||h!==b.y;(S||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:S?{x:p,y:h}:b,z:g}})}function N_(e,t,n){const r=ci(e.zIndex)?e.zIndex:0;return Ev(n)?r:r+(e.selected?t:0)}function qF(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=So(e),d=nf(e,n),u=Ec(e.extent)?il(d,e.extent,c):d;let f=il({x:a+u.x,y:l+u.y},r,c);e.extent==="parent"&&(f=d_(f,c,t));const p=N_(e,s,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Pv(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)??Cc(c),u=p_(d,l.rect);i.set(l.parentId,{expandedRect:u,parent:c})}return i.size>0&&i.forEach(({expandedRect:l,parent:c},d)=>{var w;const u=c.internals.positionAbsolute,f=So(c),p=c.origin??r,h=l.x<u.x?Math.round(Math.abs(u.x-l.x)):0,g=l.y<u.y?Math.round(Math.abs(u.y-l.y)):0,b=Math.max(f.width,Math.round(l.width)),S=Math.max(f.height,Math.round(l.height)),y=(b-f.width)*p[0],v=(S-f.height)*p[1];(h>0||g>0||y||v)&&(s.push({id:d,type:"position",position:{x:c.position.x-h+y,y:c.position.y-g+v}}),(w=n.get(d))==null||w.forEach(j=>{e.some(E=>E.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+h,y:j.position.y+g}})})),(f.width<l.width||f.height<l.height||h||g)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:b+(h?p[0]*h-y:0),height:S+(g?p[1]*g-v:0)}})}),s}function YF(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=[],u=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(u.transform),p=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const b=Nv(h.nodeElement),S=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(S||!g.internals.handleBounds||h.force))){const v=h.nodeElement.getBoundingClientRect(),w=Ec(g.extent)?g.extent:i;let{positionAbsolute:j}=g.internals;g.parentId&&g.extent==="parent"?j=d_(j,b,t.get(g.parentId)):w&&(j=il(j,w,b));const E={...g,measured:b,internals:{...g.internals,positionAbsolute:j,handleBounds:{source:_k("source",h.nodeElement,v,f,g.id),target:_k("target",h.nodeElement,v,f,g.id)}}};t.set(g.id,E),g.parentId&&_v(E,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,S&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&p.push({id:g.id,parentId:g.parentId,rect:Cc(E,s)}))}}if(p.length>0){const h=Pv(p,t,n,s);d.push(...h)}return{changes:d,updatedInternals:c}}async function GF({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 Ok(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 j_(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}`,u=`${i}-${l}--${s}-${a}`;Ok("source",c,u,e,s,a),Ok("target",c,d,e,i,l),t.set(r.id,r)}}function C_(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:C_(n,t):!1}function Mk(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 XF(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!C_(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 Kg({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[d,u]of t){const f=(a=n.get(d))==null?void 0:a.internals.userNode;f&&s.push({...f,position:u.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 JF({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=sf(i,t);return{x:a.x-i.x,y:a.y-i.y}}function QF({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},u=null,f=!1,p=null,h=!1,g=!1,b=null;function S({noDragClassName:v,handleSelector:w,domNode:j,isSelectable:E,nodeId:k,nodeClickDistance:I=0}){p=xs(j);function R({x:L,y:H}){const{nodeLookup:M,nodeExtent:O,snapGrid:A,snapToGrid:z,nodeOrigin:_,onNodeDrag:T,onSelectionDrag:C,onError:G,updateNodePositions:Z}=t();i={x:L,y:H};let W=!1;const te=l.size>1,le=te&&O?Dx(rf(l)):null,ue=te&&z?JF({dragItems:l,snapGrid:A,x:L,y:H}):null;for(const[de,ce]of l){if(!M.has(de))continue;let fe={x:L-ce.distance.x,y:H-ce.distance.y};z&&(fe=ue?{x:Math.round(fe.x+ue.x),y:Math.round(fe.y+ue.y)}:sf(fe,A));let re=null;if(te&&O&&!ce.extent&&le){const{positionAbsolute:ye}=ce.internals,Be=ye.x-le.x+O[0][0],lt=ye.x+ce.measured.width-le.x2+O[1][0],Ge=ye.y-le.y+O[0][1],_t=ye.y+ce.measured.height-le.y2+O[1][1];re=[[Be,Ge],[lt,_t]]}const{position:pe,positionAbsolute:ae}=u_({nodeId:de,nextPosition:fe,nodeLookup:M,nodeExtent:re||O,nodeOrigin:_,onError:G});W=W||ce.position.x!==pe.x||ce.position.y!==pe.y,ce.position=pe,ce.internals.positionAbsolute=ae}if(g=g||W,!!W&&(Z(l,!0),b&&(r||T||!k&&C))){const[de,ce]=Kg({nodeId:k,dragItems:l,nodeLookup:M});r==null||r(b,l,de,ce),T==null||T(b,de,ce),k||C==null||C(b,ce)}}async function $(){if(!u)return;const{transform:L,panBy:H,autoPanSpeed:M,autoPanOnNodeDrag:O}=t();if(!O){c=!1,cancelAnimationFrame(a);return}const[A,z]=f_(d,u,M);(A!==0||z!==0)&&(i.x=(i.x??0)-A/L[2],i.y=(i.y??0)-z/L[2],await H({x:A,y:z})&&R(i)),a=requestAnimationFrame($)}function K(L){var te;const{nodeLookup:H,multiSelectionActive:M,nodesDraggable:O,transform:A,snapGrid:z,snapToGrid:_,selectNodesOnDrag:T,onNodeDragStart:C,onSelectionDragStart:G,unselectNodesAndEdges:Z}=t();f=!0,(!T||!E)&&!M&&k&&((te=H.get(k))!=null&&te.selected||Z()),E&&T&&k&&(e==null||e(k));const W=ed(L.sourceEvent,{transform:A,snapGrid:z,snapToGrid:_,containerBounds:u});if(i=W,l=XF(H,O,W,k),l.size>0&&(n||C||!k&&G)){const[le,ue]=Kg({nodeId:k,dragItems:l,nodeLookup:H});n==null||n(L.sourceEvent,l,le,ue),C==null||C(L.sourceEvent,le,ue),k||G==null||G(L.sourceEvent,ue)}}const D=UE().clickDistance(I).on("start",L=>{const{domNode:H,nodeDragThreshold:M,transform:O,snapGrid:A,snapToGrid:z}=t();u=(H==null?void 0:H.getBoundingClientRect())||null,h=!1,g=!1,b=L.sourceEvent,M===0&&K(L),i=ed(L.sourceEvent,{transform:O,snapGrid:A,snapToGrid:z,containerBounds:u}),d=ui(L.sourceEvent,u)}).on("drag",L=>{const{autoPanOnNodeDrag:H,transform:M,snapGrid:O,snapToGrid:A,nodeDragThreshold:z,nodeLookup:_}=t(),T=ed(L.sourceEvent,{transform:M,snapGrid:O,snapToGrid:A,containerBounds:u});if(b=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||k&&!_.has(k))&&(h=!0),!h){if(!c&&H&&f&&(c=!0,$()),!f){const C=ui(L.sourceEvent,u),G=C.x-d.x,Z=C.y-d.y;Math.sqrt(G*G+Z*Z)>z&&K(L)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&l&&f&&(d=ui(L.sourceEvent,u),R(T))}}).on("end",L=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:H,updateNodePositions:M,onNodeDragStop:O,onSelectionDragStop:A}=t();if(g&&(M(l,!1),g=!1),s||O||!k&&A){const[z,_]=Kg({nodeId:k,dragItems:l,nodeLookup:H,dragging:!1});s==null||s(L.sourceEvent,l,z,_),O==null||O(L.sourceEvent,z,_),k||A==null||A(L.sourceEvent,_)}}}).filter(L=>{const H=L.target;return!L.button&&(!v||!Mk(H,`.${v}`,j))&&(!w||Mk(H,w,j))});p.call(D)}function y(){p==null||p.on(".drag",null)}return{update:S,destroy:y}}function ZF(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())Td(s,Cc(i))>0&&r.push(i);return r}const e3=250;function t3(e,t,n,r){var l,c;let s=[],i=1/0;const a=ZF(e,n,t+e3);for(const d of a){const u=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((c=d.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:h}=ol(d,f,f.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(s=[{...f,x:p,y:h}],i=g):g===i&&s.push({...f,x:p,y:h}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(u=>u.type===d)??s[0]}return s[0]}function E_(e,t,n,r,s,i=!1){var d,u,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((u=a.internals.handleBounds)==null?void 0:u.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&i?{...c,...ol(a,c,c.position,!0)}:c}function __(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function n3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const P_=()=>!0;function r3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:u,flowId:f,panBy:p,cancelConnection:h,onConnectStart:g,onConnect:b,onConnectEnd:S,isValidConnection:y=P_,onReconnectEnd:v,updateConnection:w,getTransform:j,getFromHandle:E,autoPanSpeed:k,dragThreshold:I=1,handleDomNode:R}){const $=g_(e.target);let K=0,D;const{x:L,y:H}=ui(e),M=__(i,R),O=l==null?void 0:l.getBoundingClientRect();let A=!1;if(!O||!M)return;const z=E_(s,M,r,c,t);if(!z)return;let _=ui(e,O),T=!1,C=null,G=!1,Z=null;function W(){if(!u||!O)return;const[pe,ae]=f_(_,O,k);p({x:pe,y:ae}),K=requestAnimationFrame(W)}const te={...z,nodeId:s,type:M,position:z.position},le=c.get(s);let de={inProgress:!0,isValid:null,from:ol(le,te,Fe.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:le,to:_,toHandle:null,toPosition:Nk[te.position],toNode:null,pointer:_};function ce(){A=!0,w(de),g==null||g(e,{nodeId:s,handleId:r,handleType:M})}I===0&&ce();function fe(pe){if(!A){const{x:_t,y:Pt}=ui(pe),Te=_t-L,an=Pt-H;if(!(Te*Te+an*an>I*I))return;ce()}if(!E()||!te){re(pe);return}const ae=j();_=ui(pe,O),D=t3(of(_,ae,!1,[1,1]),n,c,te),T||(W(),T=!0);const ye=A_(pe,{handle:D,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:$,lib:d,flowId:f,nodeLookup:c});Z=ye.handleDomNode,C=ye.connection,G=n3(!!D,ye.isValid);const Be=c.get(s),lt=Be?ol(Be,te,Fe.Left,!0):de.from,Ge={...de,from:lt,isValid:G,to:ye.toHandle&&G?Oh({x:ye.toHandle.x,y:ye.toHandle.y},ae):_,toHandle:ye.toHandle,toPosition:G&&ye.toHandle?ye.toHandle.position:Nk[te.position],toNode:ye.toHandle?c.get(ye.toHandle.nodeId):null,pointer:_};w(Ge),de=Ge}function re(pe){if(!("touches"in pe&&pe.touches.length>0)){if(A){(D||Z)&&C&&G&&(b==null||b(C));const{inProgress:ae,...ye}=de,Be={...ye,toPosition:de.toHandle?de.toPosition:null};S==null||S(pe,Be),i&&(v==null||v(pe,Be))}h(),cancelAnimationFrame(K),T=!1,G=!1,C=null,Z=null,$.removeEventListener("mousemove",fe),$.removeEventListener("mouseup",re),$.removeEventListener("touchmove",fe),$.removeEventListener("touchend",re)}}$.addEventListener("mousemove",fe),$.addEventListener("mouseup",re),$.addEventListener("touchmove",fe),$.addEventListener("touchend",re)}function A_(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:d=P_,nodeLookup:u}){const f=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:h,y:g}=ui(e),b=a.elementFromPoint(h,g),S=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:p,y={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const v=__(void 0,S),w=S.getAttribute("data-nodeid"),j=S.getAttribute("data-handleid"),E=S.classList.contains("connectable"),k=S.classList.contains("connectableend");if(!w||!v)return y;const I={source:f?w:r,sourceHandle:f?j:s,target:f?r:w,targetHandle:f?s:j};y.connection=I;const $=E&&k&&(n===Nc.Strict?f&&v==="source"||!f&&v==="target":w!==r||j!==s);y.isValid=$&&d(I),y.toHandle=E_(w,v,j,u,n,!0)}return y}const Hx={onPointerDown:r3,isValid:A_};function s3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=xs(e);function i({translateExtent:l,width:c,height:d,zoomStep:u=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const g=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const j=n(),E=w.sourceEvent.ctrlKey&&Rd()?10:1,k=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*u,I=j[2]*Math.pow(2,k*E);t.scaleTo(I)};let b=[0,0];const S=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 E=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],k=[E[0]-b[0],E[1]-b[1]];b=E;const I=r()*Math.max(j[2],Math.log(j[2]))*(h?-1:1),R={x:j[0]-k[0]*I,y:j[1]-k[1]*I},$=[[0,0],[c,d]];t.setViewportConstrained({x:R.x,y:R.y,zoom:j[2]},$,l)},v=s_().on("start",S).on("zoom",f?y:null).on("zoom.wheel",p?g:null);s.call(v,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:ii}}const Pm=e=>({x:e.x,y:e.y,zoom:e.k}),qg=({x:e,y:t,zoom:n})=>Cm.translate(e,t).scale(n),Ql=(e,t)=>e.target.closest(`.${t}`),I_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),i3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Yg=(e,t=0,n=i3,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},T_=e=>{const t=e.ctrlKey&&Rd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function o3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return u=>{if(Ql(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&a){const S=ii(u),y=T_(u),v=f*Math.pow(2,y);r.scaleTo(n,v,S,u);return}const p=u.deltaMode===1?20:1;let h=s===Ga.Vertical?0:u.deltaX*p,g=s===Ga.Horizontal?0:u.deltaY*p;!Rd()&&u.shiftKey&&s!==Ga.Vertical&&(h=u.deltaY*p,g=0),r.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const b=Pm(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(u,b),e.panScrollTimeout=setTimeout(()=>{d==null||d(u,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(u,b))}}function a3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=Ql(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function l3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Pm(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 c3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&I_(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,Pm(i.transform)))}}function u3({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&&I_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Pm(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function d3({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:d,connectionInProgress:u}){return f=>{var S;const p=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Ql(f,`${d}-flow__node`)||Ql(f,`${d}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||u&&!g||Ql(f,l)&&g||Ql(f,c)&&(!g||s&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((S=f.touches)==null?void 0:S.length)>1)return f.preventDefault(),!1;if(!p&&!s&&!h&&g||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&b}}function f3({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},u=e.getBoundingClientRect(),f=s_().scaleExtent([t,n]).translateExtent(r),p=xs(e).call(f);v({x:s.x,y:s.y,zoom:jc(s.zoom,t,n)},[[0,0],[u.width,u.height]],r);const h=p.on("wheel.zoom"),g=p.on("dblclick.zoom");f.wheelDelta(T_);function b(D,L){return p?new Promise(H=>{f==null||f.interpolate((L==null?void 0:L.interpolate)==="linear"?Zu:Vp).transform(Yg(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>H(!0)),D)}):Promise.resolve(!1)}function S({noWheelClassName:D,noPanClassName:L,onPaneContextMenu:H,userSelectionActive:M,panOnScroll:O,panOnDrag:A,panOnScrollMode:z,panOnScrollSpeed:_,preventScrolling:T,zoomOnPinch:C,zoomOnScroll:G,zoomOnDoubleClick:Z,zoomActivationKeyPressed:W,lib:te,onTransformChange:le,connectionInProgress:ue,paneClickDistance:de,selectionOnDrag:ce}){M&&!d.isZoomingOrPanning&&y();const fe=O&&!W&&!M;f.clickDistance(ce?1/0:!ci(de)||de<0?0:de);const re=fe?o3({zoomPanValues:d,noWheelClassName:D,d3Selection:p,d3Zoom:f,panOnScrollMode:z,panOnScrollSpeed:_,zoomOnPinch:C,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):a3({noWheelClassName:D,preventScrolling:T,d3ZoomHandler:h});if(p.on("wheel.zoom",re,{passive:!1}),!M){const ae=l3({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:a});f.on("start",ae);const ye=c3({zoomPanValues:d,panOnDrag:A,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:le});f.on("zoom",ye);const Be=u3({zoomPanValues:d,panOnDrag:A,panOnScroll:O,onPaneContextMenu:H,onPanZoomEnd:l,onDraggingChange:c});f.on("end",Be)}const pe=d3({zoomActivationKeyPressed:W,panOnDrag:A,zoomOnScroll:G,panOnScroll:O,zoomOnDoubleClick:Z,zoomOnPinch:C,userSelectionActive:M,noPanClassName:L,noWheelClassName:D,lib:te,connectionInProgress:ue});f.filter(pe),Z?p.on("dblclick.zoom",g):p.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function v(D,L,H){const M=qg(D),O=f==null?void 0:f.constrain()(M,L,H);return O&&await b(O),new Promise(A=>A(O))}async function w(D,L){const H=qg(D);return await b(H,L),new Promise(M=>M(H))}function j(D){if(p){const L=qg(D),H=p.property("__zoom");(H.k!==D.zoom||H.x!==D.x||H.y!==D.y)&&(f==null||f.transform(p,L,null,{sync:!0}))}}function E(){const D=p?r_(p.node()):{x:0,y:0,k:1};return{x:D.x,y:D.y,zoom:D.k}}function k(D,L){return p?new Promise(H=>{f==null||f.interpolate((L==null?void 0:L.interpolate)==="linear"?Zu:Vp).scaleTo(Yg(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>H(!0)),D)}):Promise.resolve(!1)}function I(D,L){return p?new Promise(H=>{f==null||f.interpolate((L==null?void 0:L.interpolate)==="linear"?Zu:Vp).scaleBy(Yg(p,L==null?void 0:L.duration,L==null?void 0:L.ease,()=>H(!0)),D)}):Promise.resolve(!1)}function R(D){f==null||f.scaleExtent(D)}function $(D){f==null||f.translateExtent(D)}function K(D){const L=!ci(D)||D<0?0:D;f==null||f.clickDistance(L)}return{update:S,destroy:y,setViewport:w,setViewportConstrained:v,getViewport:E,scaleTo:k,scaleBy:I,setScaleExtent:R,setTranslateExtent:$,syncViewport:j,setClickDistance:K}}var _c;(function(e){e.Line="line",e.Handle="handle"})(_c||(_c={}));function p3({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 $k(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 zo(e,t){return Math.max(0,t-e)}function Bo(e,t){return Math.max(0,e-t)}function hp(e,t,n){return Math.max(0,t-e,e-n)}function Dk(e,t){return e?!t:t}function h3(e,t,n,r,s,i,a,l){let{affectsX:c,affectsY:d}=t;const{isHorizontal:u,isVertical:f}=t,p=u&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:b,maxWidth:S,minHeight:y,maxHeight:v}=r,{x:w,y:j,width:E,height:k,aspectRatio:I}=e;let R=Math.floor(u?h-e.pointerX:0),$=Math.floor(f?g-e.pointerY:0);const K=E+(c?-R:R),D=k+(d?-$:$),L=-i[0]*E,H=-i[1]*k;let M=hp(K,b,S),O=hp(D,y,v);if(a){let _=0,T=0;c&&R<0?_=zo(w+R+L,a[0][0]):!c&&R>0&&(_=Bo(w+K+L,a[1][0])),d&&$<0?T=zo(j+$+H,a[0][1]):!d&&$>0&&(T=Bo(j+D+H,a[1][1])),M=Math.max(M,_),O=Math.max(O,T)}if(l){let _=0,T=0;c&&R>0?_=Bo(w+R,l[0][0]):!c&&R<0&&(_=zo(w+K,l[1][0])),d&&$>0?T=Bo(j+$,l[0][1]):!d&&$<0&&(T=zo(j+D,l[1][1])),M=Math.max(M,_),O=Math.max(O,T)}if(s){if(u){const _=hp(K/I,y,v)*I;if(M=Math.max(M,_),a){let T=0;!c&&!d||c&&!d&&p?T=Bo(j+H+K/I,a[1][1])*I:T=zo(j+H+(c?R:-R)/I,a[0][1])*I,M=Math.max(M,T)}if(l){let T=0;!c&&!d||c&&!d&&p?T=zo(j+K/I,l[1][1])*I:T=Bo(j+(c?R:-R)/I,l[0][1])*I,M=Math.max(M,T)}}if(f){const _=hp(D*I,b,S)/I;if(O=Math.max(O,_),a){let T=0;!c&&!d||d&&!c&&p?T=Bo(w+D*I+L,a[1][0])/I:T=zo(w+(d?$:-$)*I+L,a[0][0])/I,O=Math.max(O,T)}if(l){let T=0;!c&&!d||d&&!c&&p?T=zo(w+D*I,l[1][0])/I:T=Bo(w+(d?$:-$)*I,l[0][0])/I,O=Math.max(O,T)}}}$=$+($<0?O:-O),R=R+(R<0?M:-M),s&&(p?K>D*I?$=(Dk(c,d)?-R:R)/I:R=(Dk(c,d)?-$:$)*I:u?($=R/I,d=c):(R=$*I,c=d));const A=c?w+R:w,z=d?j+$:j;return{width:E+(c?-R:R),height:k+(d?-$:$),x:i[0]*R*(c?-1:1)+A,y:i[1]*$*(d?-1:1)+z}}const R_={width:0,height:0,x:0,y:0},m3={...R_,pointerX:0,pointerY:0,aspectRatio:1};function g3(e){return[[0,0],[e.measured.width,e.measured.height]]}function y3(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 x3({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=xs(e);let a={controlDirection:$k("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:u,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:g,onResizeEnd:b,shouldResize:S}){let y={...R_},v={...m3};a={boundaries:u,resizeDirection:p,keepAspectRatio:f,controlDirection:$k(d)};let w,j=null,E=[],k,I,R,$=!1;const K=UE().on("start",D=>{const{nodeLookup:L,transform:H,snapGrid:M,snapToGrid:O,nodeOrigin:A,paneDomNode:z}=n();if(w=L.get(t),!w)return;j=(z==null?void 0:z.getBoundingClientRect())??null;const{xSnapped:_,ySnapped:T}=ed(D.sourceEvent,{transform:H,snapGrid:M,snapToGrid:O,containerBounds:j});y={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},v={...y,pointerX:_,pointerY:T,aspectRatio:y.width/y.height},k=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(k=L.get(w.parentId),I=k&&w.extent==="parent"?g3(k):void 0),E=[],R=void 0;for(const[C,G]of L)if(G.parentId===t&&(E.push({id:C,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const Z=y3(G,w,G.origin??A);R?R=[[Math.min(Z[0][0],R[0][0]),Math.min(Z[0][1],R[0][1])],[Math.max(Z[1][0],R[1][0]),Math.max(Z[1][1],R[1][1])]]:R=Z}h==null||h(D,{...y})}).on("drag",D=>{const{transform:L,snapGrid:H,snapToGrid:M,nodeOrigin:O}=n(),A=ed(D.sourceEvent,{transform:L,snapGrid:H,snapToGrid:M,containerBounds:j}),z=[];if(!w)return;const{x:_,y:T,width:C,height:G}=y,Z={},W=w.origin??O,{width:te,height:le,x:ue,y:de}=h3(v,a.controlDirection,A,a.boundaries,a.keepAspectRatio,W,I,R),ce=te!==C,fe=le!==G,re=ue!==_&&ce,pe=de!==T&&fe;if(!re&&!pe&&!ce&&!fe)return;if((re||pe||W[0]===1||W[1]===1)&&(Z.x=re?ue:y.x,Z.y=pe?de:y.y,y.x=Z.x,y.y=Z.y,E.length>0)){const lt=ue-_,Ge=de-T;for(const _t of E)_t.position={x:_t.position.x-lt+W[0]*(te-C),y:_t.position.y-Ge+W[1]*(le-G)},z.push(_t)}if((ce||fe)&&(Z.width=ce&&(!a.resizeDirection||a.resizeDirection==="horizontal")?te:y.width,Z.height=fe&&(!a.resizeDirection||a.resizeDirection==="vertical")?le:y.height,y.width=Z.width,y.height=Z.height),k&&w.expandParent){const lt=W[0]*(Z.width??0);Z.x&&Z.x<lt&&(y.x=lt,v.x=v.x-(Z.x-lt));const Ge=W[1]*(Z.height??0);Z.y&&Z.y<Ge&&(y.y=Ge,v.y=v.y-(Z.y-Ge))}const ae=p3({width:y.width,prevWidth:C,height:y.height,prevHeight:G,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ye={...y,direction:ae};(S==null?void 0:S(D,ye))!==!1&&($=!0,g==null||g(D,ye),r(Z,z))}).on("end",D=>{$&&(b==null||b(D,{...y}),s==null||s({...y}),$=!1)});i.call(K)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var L_={exports:{}},O_={},M_={exports:{}},$_={};/**
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 Pc=m;function w3(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var v3=typeof Object.is=="function"?Object.is:w3,b3=Pc.useState,k3=Pc.useEffect,S3=Pc.useLayoutEffect,N3=Pc.useDebugValue;function j3(e,t){var n=t(),r=b3({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return S3(function(){s.value=n,s.getSnapshot=t,Gg(s)&&i({inst:s})},[e,n,t]),k3(function(){return Gg(s)&&i({inst:s}),e(function(){Gg(s)&&i({inst:s})})},[e]),N3(n),n}function Gg(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!v3(e,n)}catch{return!0}}function C3(e,t){return t()}var E3=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?C3:j3;$_.useSyncExternalStore=Pc.useSyncExternalStore!==void 0?Pc.useSyncExternalStore:E3;M_.exports=$_;var D_=M_.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 Am=m,_3=D_;function P3(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var A3=typeof Object.is=="function"?Object.is:P3,I3=_3.useSyncExternalStore,T3=Am.useRef,R3=Am.useEffect,L3=Am.useMemo,O3=Am.useDebugValue;O_.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=T3(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=L3(function(){function c(h){if(!d){if(d=!0,u=h,h=r(h),s!==void 0&&a.hasValue){var g=a.value;if(s(g,h))return f=g}return f=h}if(g=f,A3(u,h))return g;var b=r(h);return s!==void 0&&s(g,b)?(u=h,g):(u=h,f=b)}var d=!1,u,f,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=I3(e,i[0],i[1]);return R3(function(){a.hasValue=!0,a.value=l},[l]),O3(l),l};L_.exports=O_;var M3=L_.exports;const $3=xa(M3),D3={},Fk=e=>{let t;const n=new Set,r=(u,f)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(D3?"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},F3=e=>e?Fk(e):Fk,{useDebugValue:z3}=qe,{useSyncExternalStoreWithSelector:B3}=$3,H3=e=>e;function F_(e,t=H3,n){const r=B3(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return z3(r),r}const zk=(e,t)=>{const n=F3(e),r=(s,i=t)=>F_(n,s,i);return Object.assign(r,n),r},U3=(e,t)=>e?zk(e,t):zk;function vn(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 Im=m.createContext(null),W3=Im.Provider,z_=Wi.error001();function Lt(e,t){const n=m.useContext(Im);if(n===null)throw new Error(z_);return F_(n,e,t)}function pn(){const e=m.useContext(Im);if(e===null)throw new Error(z_);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Bk={display:"none"},V3={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},B_="react-flow__node-desc",H_="react-flow__edge-desc",K3="react-flow__aria-live",q3=e=>e.ariaLiveMessage,Y3=e=>e.ariaLabelConfig;function G3({rfId:e}){const t=Lt(q3);return o.jsx("div",{id:`${K3}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:V3,children:t})}function X3({rfId:e,disableKeyboardA11y:t}){const n=Lt(Y3);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${B_}-${e}`,style:Bk,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${H_}-${e}`,style:Bk,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(G3,{rfId:e})]})}const Ac=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:Gn(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});Ac.displayName="Panel";function J3({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(Ac,{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 Q3=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}},mp=e=>e.id;function Z3(e,t){return vn(e.selectedNodes.map(mp),t.selectedNodes.map(mp))&&vn(e.selectedEdges.map(mp),t.selectedEdges.map(mp))}function ez({onSelectionChange:e}){const t=pn(),{selectedNodes:n,selectedEdges:r}=Lt(Q3,Z3);return m.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const tz=e=>!!e.onSelectionChangeHandlers;function nz({onSelectionChange:e}){const t=Lt(tz);return e||t?o.jsx(ez,{onSelectionChange:e}):null}const Ux=typeof window<"u"?m.useLayoutEffect:m.useEffect,U_=[0,0],rz={x:0,y:0,zoom:1},sz=["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"],Hk=[...sz,"rfId"],iz=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}),Uk={translateExtent:Ad,nodeOrigin:U_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function oz(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Lt(iz,vn),d=pn();Ux(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Uk,l()}),[]);const u=m.useRef(Uk);return Ux(()=>{for(const f of Hk){const p=e[f],h=u.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?i(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?d.setState({ariaLabelConfig:IF(p)}):f==="fitView"?d.setState({fitViewQueued:p}):f==="fitViewOptions"?d.setState({fitViewOptions:p}):d.setState({[f]:p})))}u.current=e},Hk.map(f=>e[f])),null}function Wk(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function az(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=Wk(),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=Wk())!=null&&r.matches?"dark":"light"}const Vk=typeof document<"u"?document:null;function Od(e=null,t={target:Vk,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),s=m.useRef(!1),i=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),u=d.reduce((f,p)=>f.concat(...p),[]);return[d,u]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??Vk,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=h=>{var S,y;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!d)&&y_(h))return!1;const b=qk(h.code,l);if(i.current.add(h[b]),Kk(a,i.current,!1)){const v=((y=(S=h.composedPath)==null?void 0:S.call(h))==null?void 0:y[0])||h.target,w=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!w)&&h.preventDefault(),r(!0)}},f=h=>{const g=qk(h.code,l);Kk(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function Kk(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function qk(e,t){return t.includes(e)?"code":"key"}const lz=()=>{const e=pn();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,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=Sv(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},u=n.snapGrid??s,f=n.snapToGrid??i;return of(d,r,f,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=Oh(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function W_(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)cz(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 cz(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 Av(e,t){return W_(e,t)}function V_(e,t){return W_(e,t)}function za(e,t){return{id:e,type:"select",selected:t}}function Zl(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(za(i.id,a)))}return r}function Yk({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 Gk(e){return{id:e.id,type:"remove"}}const Xk=e=>bF(e),uz=e=>c_(e);function K_(e){return m.forwardRef(e)}function Jk(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>dz(()=>n(s=>s+BigInt(1))));return Ux(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function dz(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const q_=m.createContext(null);function fz({children:e}){const t=pn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:d,hasDefaultNodes:u,onNodesChange:f,nodeLookup:p,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let b=c;for(const y of l)b=typeof y=="function"?y(b):y;let S=Yk({items:b,lookup:p});for(const y of g.values())S=y(S);u&&d(b),S.length>0?f==null||f(S):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:v,setNodes:w}=t.getState();y&&w(v)})},[]),r=Jk(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:p}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;u?d(h):f&&f(Yk({items:h,lookup:p}))},[]),i=Jk(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(q_.Provider,{value:a,children:e})}function pz(){const e=m.useContext(q_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const hz=e=>!!e.panZoom;function dl(){const e=lz(),t=pn(),n=pz(),r=Lt(hz),s=m.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var y,v;const{nodeLookup:p,nodeOrigin:h}=t.getState(),g=Xk(f)?f:p.get(f.id),b=g.parentId?m_(g.position,g.measured,g.parentId,p,h):g.position,S={...g,position:b,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return Cc(S)},d=(f,p,h={replace:!1})=>{a(g=>g.map(b=>{if(b.id===f){const S=typeof p=="function"?p(b):p;return h.replace&&Xk(S)?S:{...b,...S}}return b}))},u=(f,p,h={replace:!1})=>{l(g=>g.map(b=>{if(b.id===f){const S=typeof p=="function"?p(b):p;return h.replace&&uz(S)?S:{...b,...S}}return b}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var p;return(p=i(f))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(p=>({...p}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const p=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...p])},addEdges:f=>{const p=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...p])},toObject:()=>{const{nodes:f=[],edges:p=[],transform:h}=t.getState(),[g,b,S]=h;return{nodes:f.map(y=>({...y})),edges:p.map(y=>({...y})),viewport:{x:g,y:b,zoom:S}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:h,edges:g,onNodesDelete:b,onEdgesDelete:S,triggerNodeChanges:y,triggerEdgeChanges:v,onDelete:w,onBeforeDelete:j}=t.getState(),{nodes:E,edges:k}=await CF({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:g,onBeforeDelete:j}),I=k.length>0,R=E.length>0;if(I){const $=k.map(Gk);S==null||S(k),v($)}if(R){const $=E.map(Gk);b==null||b(E),y($)}return(R||I)&&(w==null||w({nodes:E,edges:k})),{deletedNodes:E,deletedEdges:k}},getIntersectingNodes:(f,p=!0,h)=>{const g=Ck(f),b=g?f:c(f),S=h!==void 0;return b?(h||t.getState().nodes).filter(y=>{const v=t.getState().nodeLookup.get(y.id);if(v&&!g&&(y.id===f.id||!v.internals.positionAbsolute))return!1;const w=Cc(S?y:v),j=Td(w,b);return p&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const b=Ck(f)?f:c(f);if(!b)return!1;const S=Td(b,p);return h&&S>0||S>=p.width*p.height||S>=b.width*b.height},updateNode:d,updateNodeData:(f,p,h={replace:!1})=>{d(f,g=>{const b=typeof p=="function"?p(g):p;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},updateEdge:u,updateEdgeData:(f,p,h={replace:!1})=>{u(f,g=>{const b=typeof p=="function"?p(g):p;return h.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},h)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:h}=t.getState();return kF(f,{nodeLookup:p,nodeOrigin:h})},getHandleConnections:({type:f,id:p,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${f}${p?`-${p}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:f,handleId:p,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${f?p?`-${f}-${p}`:`-${f}`:""}`))==null?void 0:g.values())??[])},fitView:async f=>{const p=t.getState().fitViewResolver??AF();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:p}),n.nodeQueue.push(h=>[...h]),p.promise}}},[]);return m.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const Qk=e=>e.selected,mz=typeof window<"u"?window:void 0;function gz({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=pn(),{deleteElements:r}=dl(),s=Od(e,{actInsideInputWithModifier:!1}),i=Od(t,{target:mz});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(Qk),edges:a.filter(Qk)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function yz(e){const t=pn();m.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=Nv(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Wi.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 Tm={position:"absolute",width:"100%",height:"100%",top:0,left:0},xz=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function wz({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Ga.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:d,minZoom:u,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:h=!0,children:g,noWheelClassName:b,noPanClassName:S,onViewportChange:y,isControlledViewport:v,paneClickDistance:w,selectionOnDrag:j}){const E=pn(),k=m.useRef(null),{userSelectionActive:I,lib:R,connectionInProgress:$}=Lt(xz,vn),K=Od(p),D=m.useRef();yz(k);const L=m.useCallback(H=>{y==null||y({x:H[0],y:H[1],zoom:H[2]}),v||E.setState({transform:H})},[y,v]);return m.useEffect(()=>{if(k.current){D.current=f3({domNode:k.current,minZoom:u,maxZoom:f,translateExtent:d,viewport:c,onDraggingChange:A=>E.setState(z=>z.paneDragging===A?z:{paneDragging:A}),onPanZoomStart:(A,z)=>{const{onViewportChangeStart:_,onMoveStart:T}=E.getState();T==null||T(A,z),_==null||_(z)},onPanZoom:(A,z)=>{const{onViewportChange:_,onMove:T}=E.getState();T==null||T(A,z),_==null||_(z)},onPanZoomEnd:(A,z)=>{const{onViewportChangeEnd:_,onMoveEnd:T}=E.getState();T==null||T(A,z),_==null||_(z)}});const{x:H,y:M,zoom:O}=D.current.getViewport();return E.setState({panZoom:D.current,transform:[H,M,O],domNode:k.current.closest(".react-flow")}),()=>{var A;(A=D.current)==null||A.destroy()}}},[]),m.useEffect(()=>{var H;(H=D.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:K,preventScrolling:h,noPanClassName:S,userSelectionActive:I,noWheelClassName:b,lib:R,onTransformChange:L,connectionInProgress:$,selectionOnDrag:j,paneClickDistance:w})},[e,t,n,r,s,i,a,l,K,h,S,I,b,R,L,$,j,w]),o.jsx("div",{className:"react-flow__renderer",ref:k,style:Tm,children:g})}const vz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function bz(){const{userSelectionActive:e,userSelectionRect:t}=Lt(vz,vn);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 Xg=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},kz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Sz({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Id.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:g}){const b=pn(),{userSelectionActive:S,elementsSelectable:y,dragging:v,connectionInProgress:w}=Lt(kz,vn),j=y&&(e||S),E=m.useRef(null),k=m.useRef(),I=m.useRef(new Set),R=m.useRef(new Set),$=m.useRef(!1),K=_=>{if($.current||w){$.current=!1;return}c==null||c(_),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},D=_=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){_.preventDefault();return}d==null||d(_)},L=u?_=>u(_):void 0,H=_=>{$.current&&(_.stopPropagation(),$.current=!1)},M=_=>{var le,ue;const{domNode:T}=b.getState();if(k.current=T==null?void 0:T.getBoundingClientRect(),!k.current)return;const C=_.target===E.current;if(!C&&!!_.target.closest(".nokey")||!e||!(i&&C||t)||_.button!==0||!_.isPrimary)return;(ue=(le=_.target)==null?void 0:le.setPointerCapture)==null||ue.call(le,_.pointerId),$.current=!1;const{x:W,y:te}=ui(_.nativeEvent,k.current);b.setState({userSelectionRect:{width:0,height:0,startX:W,startY:te,x:W,y:te}}),C||(_.stopPropagation(),_.preventDefault())},O=_=>{const{userSelectionRect:T,transform:C,nodeLookup:G,edgeLookup:Z,connectionLookup:W,triggerNodeChanges:te,triggerEdgeChanges:le,defaultEdgeOptions:ue,resetSelectedElements:de}=b.getState();if(!k.current||!T)return;const{x:ce,y:fe}=ui(_.nativeEvent,k.current),{startX:re,startY:pe}=T;if(!$.current){const Ge=t?0:s;if(Math.hypot(ce-re,fe-pe)<=Ge)return;de(),a==null||a(_)}$.current=!0;const ae={startX:re,startY:pe,x:ce<re?ce:re,y:fe<pe?fe:pe,width:Math.abs(ce-re),height:Math.abs(fe-pe)},ye=I.current,Be=R.current;I.current=new Set(kv(G,ae,C,n===Id.Partial,!0).map(Ge=>Ge.id)),R.current=new Set;const lt=(ue==null?void 0:ue.selectable)??!0;for(const Ge of I.current){const _t=W.get(Ge);if(_t)for(const{edgeId:Pt}of _t.values()){const Te=Z.get(Pt);Te&&(Te.selectable??lt)&&R.current.add(Pt)}}if(!Ek(ye,I.current)){const Ge=Zl(G,I.current,!0);te(Ge)}if(!Ek(Be,R.current)){const Ge=Zl(Z,R.current);le(Ge)}b.setState({userSelectionRect:ae,userSelectionActive:!0,nodesSelectionActive:!1})},A=_=>{var T,C;_.button===0&&((C=(T=_.target)==null?void 0:T.releasePointerCapture)==null||C.call(T,_.pointerId),!S&&_.target===E.current&&b.getState().userSelectionRect&&(K==null||K(_)),b.setState({userSelectionActive:!1,userSelectionRect:null}),$.current&&(l==null||l(_),b.setState({nodesSelectionActive:I.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:Gn(["react-flow__pane",{draggable:z,dragging:v,selection:e}]),onClick:j?void 0:Xg(K,E),onContextMenu:Xg(D,E),onWheel:Xg(L,E),onPointerEnter:j?void 0:f,onPointerMove:j?O:p,onPointerUp:j?A:void 0,onPointerDownCapture:j?M:void 0,onClickCapture:j?H:void 0,onPointerLeave:h,ref:E,style:Tm,children:[g,o.jsx(bz,{})]})}function Wx({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",Wi.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([e])}function Y_({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=pn(),[c,d]=m.useState(!1),u=m.useRef();return m.useEffect(()=>{u.current=QF({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Wx({id:f,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=u.current)==null||f.destroy()}},[n,r,t,i,e,s,a]),c}const Nz=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function G_(){const e=pn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:d,nodeOrigin:u}=e.getState(),f=new Map,p=Nz(a),h=s?i[0]:5,g=s?i[1]:5,b=n.direction.x*h*n.factor,S=n.direction.y*g*n.factor;for(const[,y]of d){if(!p(y))continue;let v={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+S};s&&(v=sf(v,i));const{position:w,positionAbsolute:j}=u_({nodeId:y.id,nextPosition:v,nodeLookup:d,nodeExtent:r,nodeOrigin:u,onError:l});y.position=w,y.internals.positionAbsolute=j,f.set(y.id,y)}c(f)},[])}const Iv=m.createContext(null),jz=Iv.Provider;Iv.Consumer;const X_=()=>m.useContext(Iv),Cz=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Ez=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:d}=a,u=(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:u,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Nc.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:u&&d}};function _z({type:e="source",position:t=Fe.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:d,onMouseDown:u,onTouchStart:f,...p},h){var O,A;const g=a||null,b=e==="target",S=pn(),y=X_(),{connectOnClick:v,noPanClassName:w,rfId:j}=Lt(Cz,vn),{connectingFrom:E,connectingTo:k,clickConnecting:I,isPossibleEndHandle:R,connectionInProcess:$,clickConnectionInProcess:K,valid:D}=Lt(Ez(y,g,e),vn);y||(A=(O=S.getState()).onError)==null||A.call(O,"010",Wi.error010());const L=z=>{const{defaultEdgeOptions:_,onConnect:T,hasDefaultEdges:C}=S.getState(),G={..._,...z};if(C){const{edges:Z,setEdges:W}=S.getState();W(Ld(G,Z))}T==null||T(G),l==null||l(G)},H=z=>{if(!y)return;const _=x_(z.nativeEvent);if(s&&(_&&z.button===0||!_)){const T=S.getState();Hx.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:b,handleId:g,nodeId:y,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...C)=>{var G,Z;return(Z=(G=S.getState()).onConnectEnd)==null?void 0:Z.call(G,...C)},updateConnection:T.updateConnection,onConnect:L,isValidConnection:n||((...C)=>{var G,Z;return((Z=(G=S.getState()).isValidConnection)==null?void 0:Z.call(G,...C))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}_?u==null||u(z):f==null||f(z)},M=z=>{const{onClickConnectStart:_,onClickConnectEnd:T,connectionClickStartHandle:C,connectionMode:G,isValidConnection:Z,lib:W,rfId:te,nodeLookup:le,connection:ue}=S.getState();if(!y||!C&&!s)return;if(!C){_==null||_(z.nativeEvent,{nodeId:y,handleId:g,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const de=g_(z.target),ce=n||Z,{connection:fe,isValid:re}=Hx.isValid(z.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:G,fromNodeId:C.nodeId,fromHandleId:C.id||null,fromType:C.type,isValidConnection:ce,flowId:te,doc:de,lib:W,nodeLookup:le});re&&fe&&L(fe);const pe=structuredClone(ue);delete pe.inProgress,pe.toPosition=pe.toHandle?pe.toHandle.position:null,T==null||T(z,pe),S.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${j}-${y}-${g}-${e}`,className:Gn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:I,connectingfrom:E,connectingto:k,valid:D,connectionindicator:r&&(!$||R)&&($||K?i:s)}]),onMouseDown:H,onTouchStart:H,onClick:v?M:void 0,ref:h,...p,children:c})}const Hs=m.memo(K_(_z));function Pz({data:e,isConnectable:t,sourcePosition:n=Fe.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Hs,{type:"source",position:n,isConnectable:t})]})}function Az({data:e,isConnectable:t,targetPosition:n=Fe.Top,sourcePosition:r=Fe.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Hs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Hs,{type:"source",position:r,isConnectable:t})]})}function Iz(){return null}function Tz({data:e,isConnectable:t,targetPosition:n=Fe.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Hs,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Mh={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Zk={input:Pz,default:Az,output:Tz,group:Iz};function Rz(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 Lz=e=>{const{width:t,height:n,x:r,y:s}=rf(e.nodeLookup,{filter:i=>!!i.selected});return{width:ci(t)?t:null,height:ci(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 Oz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=pn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Lt(Lz,vn),c=G_(),d=m.useRef(null);m.useEffect(()=>{var h;n||(h=d.current)==null||h.focus({preventScroll:!0})},[n]);const u=!l&&s!==null&&i!==null;if(Y_({nodeRef:d,disabled:!u}),!u)return null;const f=e?h=>{const g=r.getState().nodes.filter(b=>b.selected);e(h,g)}:void 0,p=h=>{Object.prototype.hasOwnProperty.call(Mh,h.key)&&(h.preventDefault(),c({direction:Mh[h.key],factor:h.shiftKey?4:1}))};return o.jsx("div",{className:Gn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const eS=typeof window<"u"?window:void 0,Mz=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function J_({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:d,selectionOnDrag:u,selectionMode:f,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:S,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:I,panOnDrag:R,defaultViewport:$,translateExtent:K,minZoom:D,maxZoom:L,preventScrolling:H,onSelectionContextMenu:M,noWheelClassName:O,noPanClassName:A,disableKeyboardA11y:z,onViewportChange:_,isControlledViewport:T}){const{nodesSelectionActive:C,userSelectionActive:G}=Lt(Mz,vn),Z=Od(d,{target:eS}),W=Od(b,{target:eS}),te=W||R,le=W||j,ue=u&&te!==!0,de=Z||G||ue;return gz({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(wz,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:w,panOnScroll:le,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:I,panOnDrag:!Z&&te,defaultViewport:$,translateExtent:K,minZoom:D,maxZoom:L,zoomActivationKeyCode:S,preventScrolling:H,noWheelClassName:O,noPanClassName:A,onViewportChange:_,isControlledViewport:T,paneClickDistance:l,selectionOnDrag:ue,children:o.jsxs(Sz,{onSelectionStart:p,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:te,isSelecting:!!de,selectionMode:f,selectionKeyPressed:Z,paneClickDistance:l,selectionOnDrag:ue,children:[e,C&&o.jsx(Oz,{onSelectionContextMenu:M,noPanClassName:A,disableKeyboardA11y:z})]})})}J_.displayName="FlowRenderer";const $z=m.memo(J_),Dz=e=>t=>e?kv(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 Fz(e){return Lt(m.useCallback(Dz(e),[e]),vn)}const zz=e=>e.updateNodeInternals;function Bz(){const e=Lt(zz),[t]=m.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 m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Hz({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=pn(),i=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),d=m.useRef(t),u=n&&!!e.internals.handleBounds;return m.useEffect(()=>{i.current&&!e.hidden&&(!u||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[u,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(i.current){const f=d.current!==t,p=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||p||h)&&(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 Uz({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:d,nodesFocusable:u,resizeObserver:f,noDragClassName:p,noPanClassName:h,disableKeyboardA11y:g,rfId:b,nodeTypes:S,nodeClickDistance:y,onError:v}){const{node:w,internals:j,isParent:E}=Lt(ce=>{const fe=ce.nodeLookup.get(e),re=ce.parentLookup.has(e);return{node:fe,internals:fe.internals,isParent:re}},vn);let k=w.type||"default",I=(S==null?void 0:S[k])||Zk[k];I===void 0&&(v==null||v("003",Wi.error003(k)),k="default",I=(S==null?void 0:S.default)||Zk.default);const R=!!(w.draggable||l&&typeof w.draggable>"u"),$=!!(w.selectable||c&&typeof w.selectable>"u"),K=!!(w.connectable||d&&typeof w.connectable>"u"),D=!!(w.focusable||u&&typeof w.focusable>"u"),L=pn(),H=h_(w),M=Hz({node:w,nodeType:k,hasDimensions:H,resizeObserver:f}),O=Y_({nodeRef:M,disabled:w.hidden||!R,noDragClassName:p,handleSelector:w.dragHandle,nodeId:e,isSelectable:$,nodeClickDistance:y}),A=G_();if(w.hidden)return null;const z=So(w),_=Rz(w),T=$||R||t||n||r||s,C=n?ce=>n(ce,{...j.userNode}):void 0,G=r?ce=>r(ce,{...j.userNode}):void 0,Z=s?ce=>s(ce,{...j.userNode}):void 0,W=i?ce=>i(ce,{...j.userNode}):void 0,te=a?ce=>a(ce,{...j.userNode}):void 0,le=ce=>{const{selectNodesOnDrag:fe,nodeDragThreshold:re}=L.getState();$&&(!fe||!R||re>0)&&Wx({id:e,store:L,nodeRef:M}),t&&t(ce,{...j.userNode})},ue=ce=>{if(!(y_(ce.nativeEvent)||g)){if(i_.includes(ce.key)&&$){const fe=ce.key==="Escape";Wx({id:e,store:L,unselect:fe,nodeRef:M})}else if(R&&w.selected&&Object.prototype.hasOwnProperty.call(Mh,ce.key)){ce.preventDefault();const{ariaLabelConfig:fe}=L.getState();L.setState({ariaLiveMessage:fe["node.a11yDescription.ariaLiveMessage"]({direction:ce.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),A({direction:Mh[ce.key],factor:ce.shiftKey?4:1})}}},de=()=>{var Be;if(g||!((Be=M.current)!=null&&Be.matches(":focus-visible")))return;const{transform:ce,width:fe,height:re,autoPanOnNodeFocus:pe,setCenter:ae}=L.getState();if(!pe)return;kv(new Map([[e,w]]),{x:0,y:0,width:fe,height:re},ce,!0).length>0||ae(w.position.x+z.width/2,w.position.y+z.height/2,{zoom:ce[2]})};return o.jsx("div",{className:Gn(["react-flow__node",`react-flow__node-${k}`,{[h]:R},w.className,{selected:w.selected,selectable:$,parent:E,draggable:R,dragging:O}]),ref:M,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:H?"visible":"hidden",...w.style,..._},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:C,onMouseMove:G,onMouseLeave:Z,onContextMenu:W,onClick:le,onDoubleClick:te,onKeyDown:D?ue:void 0,tabIndex:D?0:void 0,onFocus:D?de:void 0,role:w.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${B_}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:o.jsx(jz,{value:e,children:o.jsx(I,{id:e,data:w.data,type:k,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:$,draggable:R,deletable:w.deletable??!0,isConnectable:K,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:O,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...z})})})}var Wz=m.memo(Uz);const Vz=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Q_(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Lt(Vz,vn),a=Fz(e.onlyRenderVisibleElements),l=Bz();return o.jsx("div",{className:"react-flow__nodes",style:Tm,children:a.map(c=>o.jsx(Wz,{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))})}Q_.displayName="NodeRenderer";const Kz=m.memo(Q_);function qz(e){return Lt(m.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&LF({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),vn)}const Yz=({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"})},Gz=({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"})},tS={[cs.Arrow]:Yz,[cs.ArrowClosed]:Gz};function Xz(e){const t=pn();return m.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(tS,e)?tS[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Wi.error009(e)),null)},[e])}const Jz=({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=Xz(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},Z_=({defaultColor:e,rfId:t})=>{const n=Lt(i=>i.edges),r=Lt(i=>i.defaultEdgeOptions),s=m.useMemo(()=>BF(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(Jz,{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};Z_.displayName="MarkerDefinitions";var Qz=m.memo(Z_);function eP({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...u}){const[f,p]=m.useState({x:1,y:0,width:0,height:0}),h=Gn(["react-flow__edge-textwrapper",d]),g=m.useRef(null);return m.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-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...u,children:[s&&o.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}eP.displayName="EdgeText";const Zz=m.memo(eP);function Rm({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:d=20,...u}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...u,d:e,fill:"none",className:Gn(["react-flow__edge-path",u.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&ci(t)&&ci(n)?o.jsx(Zz,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function nS({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Fe.Left||e===Fe.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function tP({sourceX:e,sourceY:t,sourcePosition:n=Fe.Bottom,targetX:r,targetY:s,targetPosition:i=Fe.Top}){const[a,l]=nS({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,d]=nS({pos:i,x1:r,y1:s,x2:e,y2:t}),[u,f,p,h]=w_({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}`,u,f,p,h]}function nP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:S,interactionWidth:y})=>{const[v,w,j]=tP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),E=e.isInternal?void 0:t;return o.jsx(Rm,{id:E,path:v,labelX:w,labelY:j,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:S,interactionWidth:y})})}const e4=nP({isInternal:!1}),rP=nP({isInternal:!0});e4.displayName="SimpleBezierEdge";rP.displayName="SimpleBezierEdgeInternal";function sP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,sourcePosition:h=Fe.Bottom,targetPosition:g=Fe.Top,markerEnd:b,markerStart:S,pathOptions:y,interactionWidth:v})=>{const[w,j,E]=Fx({sourceX:n,sourceY:r,sourcePosition:h,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}),k=e.isInternal?void 0:t;return o.jsx(Rm,{id:k,path:w,labelX:j,labelY:E,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:b,markerStart:S,interactionWidth:v})})}const iP=sP({isInternal:!1}),oP=sP({isInternal:!0});iP.displayName="SmoothStepEdge";oP.displayName="SmoothStepEdgeInternal";function aP(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(iP,{...n,id:r,pathOptions:m.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const t4=aP({isInternal:!1}),lP=aP({isInternal:!0});t4.displayName="StepEdge";lP.displayName="StepEdgeInternal";function cP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:g,interactionWidth:b})=>{const[S,y,v]=k_({sourceX:n,sourceY:r,targetX:s,targetY:i}),w=e.isInternal?void 0:t;return o.jsx(Rm,{id:w,path:S,labelX:y,labelY:v,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:g,interactionWidth:b})})}const n4=cP({isInternal:!1}),uP=cP({isInternal:!0});n4.displayName="StraightEdge";uP.displayName="StraightEdgeInternal";function dP(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Fe.Bottom,targetPosition:l=Fe.Top,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:S,pathOptions:y,interactionWidth:v})=>{const[w,j,E]=v_({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),k=e.isInternal?void 0:t;return o.jsx(Rm,{id:k,path:w,labelX:j,labelY:E,label:c,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:b,markerStart:S,interactionWidth:v})})}const r4=dP({isInternal:!1}),fP=dP({isInternal:!0});r4.displayName="BezierEdge";fP.displayName="BezierEdgeInternal";const rS={default:fP,straight:uP,step:lP,smoothstep:oP,simplebezier:rP},sS={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},s4=(e,t,n)=>n===Fe.Left?e-t:n===Fe.Right?e+t:e,i4=(e,t,n)=>n===Fe.Top?e-t:n===Fe.Bottom?e+t:e,iS="react-flow__edgeupdater";function oS({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:Gn([iS,`${iS}-${l}`]),cx:s4(t,r,e),cy:i4(n,r,e),r,stroke:"transparent",fill:"transparent"})}function o4({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:d,onReconnectStart:u,onReconnectEnd:f,setReconnecting:p,setUpdateHover:h}){const g=pn(),b=(j,E)=>{if(j.button!==0)return;const{autoPanOnConnect:k,domNode:I,connectionMode:R,connectionRadius:$,lib:K,onConnectStart:D,cancelConnection:L,nodeLookup:H,rfId:M,panBy:O,updateConnection:A}=g.getState(),z=E.type==="target",_=(G,Z)=>{p(!1),f==null||f(G,n,E.type,Z)},T=G=>d==null?void 0:d(n,G),C=(G,Z)=>{p(!0),u==null||u(j,n,E.type),D==null||D(G,Z)};Hx.onPointerDown(j.nativeEvent,{autoPanOnConnect:k,connectionMode:R,connectionRadius:$,domNode:I,handleId:E.id,nodeId:E.nodeId,nodeLookup:H,isTarget:z,edgeUpdaterType:E.type,lib:K,flowId:M,cancelConnection:L,panBy:O,isValidConnection:(...G)=>{var Z,W;return((W=(Z=g.getState()).isValidConnection)==null?void 0:W.call(Z,...G))??!0},onConnect:T,onConnectStart:C,onConnectEnd:(...G)=>{var Z,W;return(W=(Z=g.getState()).onConnectEnd)==null?void 0:W.call(Z,...G)},onReconnectEnd:_,updateConnection:A,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},S=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"}),v=()=>h(!0),w=()=>h(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(oS,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:S,onMouseEnter:v,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&o.jsx(oS,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:v,onMouseOut:w,type:"target"})]})}function a4({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,reconnectRadius:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,rfId:g,edgeTypes:b,noPanClassName:S,onError:y,disableKeyboardA11y:v}){let w=Lt(ae=>ae.edgeLookup.get(e));const j=Lt(ae=>ae.defaultEdgeOptions);w=j?{...j,...w}:w;let E=w.type||"default",k=(b==null?void 0:b[E])||rS[E];k===void 0&&(y==null||y("011",Wi.error011(E)),E="default",k=(b==null?void 0:b.default)||rS.default);const I=!!(w.focusable||t&&typeof w.focusable>"u"),R=typeof f<"u"&&(w.reconnectable||n&&typeof w.reconnectable>"u"),$=!!(w.selectable||r&&typeof w.selectable>"u"),K=m.useRef(null),[D,L]=m.useState(!1),[H,M]=m.useState(!1),O=pn(),{zIndex:A,sourceX:z,sourceY:_,targetX:T,targetY:C,sourcePosition:G,targetPosition:Z}=Lt(m.useCallback(ae=>{const ye=ae.nodeLookup.get(w.source),Be=ae.nodeLookup.get(w.target);if(!ye||!Be)return{zIndex:w.zIndex,...sS};const lt=zF({id:e,sourceNode:ye,targetNode:Be,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ae.connectionMode,onError:y});return{zIndex:RF({selected:w.selected,zIndex:w.zIndex,sourceNode:ye,targetNode:Be,elevateOnSelect:ae.elevateEdgesOnSelect,zIndexMode:ae.zIndexMode}),...lt||sS}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),vn),W=m.useMemo(()=>w.markerStart?`url('#${zx(w.markerStart,g)}')`:void 0,[w.markerStart,g]),te=m.useMemo(()=>w.markerEnd?`url('#${zx(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||z===null||_===null||T===null||C===null)return null;const le=ae=>{var Ge;const{addSelectedEdges:ye,unselectNodesAndEdges:Be,multiSelectionActive:lt}=O.getState();$&&(O.setState({nodesSelectionActive:!1}),w.selected&&lt?(Be({nodes:[],edges:[w]}),(Ge=K.current)==null||Ge.blur()):ye([e])),s&&s(ae,w)},ue=i?ae=>{i(ae,{...w})}:void 0,de=a?ae=>{a(ae,{...w})}:void 0,ce=l?ae=>{l(ae,{...w})}:void 0,fe=c?ae=>{c(ae,{...w})}:void 0,re=d?ae=>{d(ae,{...w})}:void 0,pe=ae=>{var ye;if(!v&&i_.includes(ae.key)&&$){const{unselectNodesAndEdges:Be,addSelectedEdges:lt}=O.getState();ae.key==="Escape"?((ye=K.current)==null||ye.blur(),Be({edges:[w]})):lt([e])}};return o.jsx("svg",{style:{zIndex:A},children:o.jsxs("g",{className:Gn(["react-flow__edge",`react-flow__edge-${E}`,w.className,S,{selected:w.selected,animated:w.animated,inactive:!$&&!s,updating:D,selectable:$}]),onClick:le,onDoubleClick:ue,onContextMenu:de,onMouseEnter:ce,onMouseMove:fe,onMouseLeave:re,onKeyDown:I?pe:void 0,tabIndex:I?0:void 0,role:w.ariaRole??(I?"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":I?`${H_}-${g}`:void 0,ref:K,...w.domAttributes,children:[!H&&o.jsx(k,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:$,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:z,sourceY:_,targetX:T,targetY:C,sourcePosition:G,targetPosition:Z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:W,markerEnd:te,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),R&&o.jsx(o4,{edge:w,isReconnectable:R,reconnectRadius:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:z,sourceY:_,targetX:T,targetY:C,sourcePosition:G,targetPosition:Z,setUpdateHover:L,setReconnecting:M})]})})}var l4=m.memo(a4);const c4=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function pP({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:f,onEdgeDoubleClick:p,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:S,edgesReconnectable:y,elementsSelectable:v,onError:w}=Lt(c4,vn),j=qz(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(Qz,{defaultColor:e,rfId:n}),j.map(E=>o.jsx(l4,{id:E,edgesFocusable:S,edgesReconnectable:y,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:d,onClick:u,reconnectRadius:f,onDoubleClick:p,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:w,edgeTypes:r,disableKeyboardA11y:b},E))]})}pP.displayName="EdgeRenderer";const u4=m.memo(pP),d4=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function f4({children:e}){const t=Lt(d4);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function p4(e){const t=dl(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const h4=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function m4(e){const t=Lt(h4),n=pn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function g4(e){return e.connection.inProgress?{...e.connection,to:of(e.connection.to,e.transform)}:{...e.connection}}function y4(e){return g4}function x4(e){const t=y4();return Lt(t,vn)}const w4=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function v4({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Lt(w4,vn);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:Gn(["react-flow__connection",l_(l)]),children:o.jsx(hP,{style:t,type:n,CustomComponent:r,isValid:l})})})}const hP=({style:e,type:t=Go.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:d,toNode:u,toHandle:f,toPosition:p,pointer:h}=x4();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:l_(r),toNode:u,toHandle:f,pointer:h});let g="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case Go.Bezier:[g]=v_(b);break;case Go.SimpleBezier:[g]=tP(b);break;case Go.Step:[g]=Fx({...b,borderRadius:0});break;case Go.SmoothStep:[g]=Fx(b);break;default:[g]=k_(b)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};hP.displayName="ConnectionLine";const b4={};function aS(e=b4){m.useRef(e),pn(),m.useEffect(()=>{},[e])}function k4(){pn(),m.useRef(!1),m.useEffect(()=>{},[])}function mP({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:S,connectionLineContainerStyle:y,selectionKeyCode:v,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:I,deleteKeyCode:R,onlyRenderVisibleElements:$,elementsSelectable:K,defaultViewport:D,translateExtent:L,minZoom:H,maxZoom:M,preventScrolling:O,defaultMarkerColor:A,zoomOnScroll:z,zoomOnPinch:_,panOnScroll:T,panOnScrollSpeed:C,panOnScrollMode:G,zoomOnDoubleClick:Z,panOnDrag:W,onPaneClick:te,onPaneMouseEnter:le,onPaneMouseMove:ue,onPaneMouseLeave:de,onPaneScroll:ce,onPaneContextMenu:fe,paneClickDistance:re,nodeClickDistance:pe,onEdgeContextMenu:ae,onEdgeMouseEnter:ye,onEdgeMouseMove:Be,onEdgeMouseLeave:lt,reconnectRadius:Ge,onReconnect:_t,onReconnectStart:Pt,onReconnectEnd:Te,noDragClassName:an,noWheelClassName:Fn,noPanClassName:qt,disableKeyboardA11y:_n,nodeExtent:jr,rfId:fr,viewport:ie,onViewportChange:xe}){return aS(e),aS(t),k4(),p4(n),m4(ie),o.jsx($z,{onPaneClick:te,onPaneMouseEnter:le,onPaneMouseMove:ue,onPaneMouseLeave:de,onPaneContextMenu:fe,onPaneScroll:ce,paneClickDistance:re,deleteKeyCode:R,selectionKeyCode:v,selectionOnDrag:w,selectionMode:j,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:I,elementsSelectable:K,zoomOnScroll:z,zoomOnPinch:_,zoomOnDoubleClick:Z,panOnScroll:T,panOnScrollSpeed:C,panOnScrollMode:G,panOnDrag:W,defaultViewport:D,translateExtent:L,minZoom:H,maxZoom:M,onSelectionContextMenu:f,preventScrolling:O,noDragClassName:an,noWheelClassName:Fn,noPanClassName:qt,disableKeyboardA11y:_n,onViewportChange:xe,isControlledViewport:!!ie,children:o.jsxs(f4,{children:[o.jsx(u4,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:_t,onReconnectStart:Pt,onReconnectEnd:Te,onlyRenderVisibleElements:$,onEdgeContextMenu:ae,onEdgeMouseEnter:ye,onEdgeMouseMove:Be,onEdgeMouseLeave:lt,reconnectRadius:Ge,defaultMarkerColor:A,noPanClassName:qt,disableKeyboardA11y:_n,rfId:fr}),o.jsx(v4,{style:b,type:g,component:S,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(Kz,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:pe,onlyRenderVisibleElements:$,noPanClassName:qt,noDragClassName:an,disableKeyboardA11y:_n,nodeExtent:jr,rfId:fr}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}mP.displayName="GraphView";const S4=m.memo(mP),lS=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:f,zIndexMode:p="basic"}={})=>{const h=new Map,g=new Map,b=new Map,S=new Map,y=r??t??[],v=n??e??[],w=u??[0,0],j=f??Ad;j_(b,S,y);const{nodesInitialized:E}=Bx(v,h,g,{nodeOrigin:w,nodeExtent:j,zIndexMode:p});let k=[0,0,1];if(a&&s&&i){const I=rf(h,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:R,y:$,zoom:K}=Sv(I,s,i,c,d,(l==null?void 0:l.padding)??.1);k=[R,$,K]}return{rfId:"1",width:s??0,height:i??0,transform:k,nodes:v,nodesInitialized:E,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:S,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:d,translateExtent:Ad,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Nc.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:{...a_},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:EF,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:o_,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},N4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:p})=>U3((h,g)=>{async function b(){const{nodeLookup:S,panZoom:y,fitViewOptions:v,fitViewResolver:w,width:j,height:E,minZoom:k,maxZoom:I}=g();y&&(await jF({nodes:S,width:j,height:E,panZoom:y,minZoom:k,maxZoom:I},v),w==null||w.resolve(!0),h({fitViewResolver:null}))}return{...lS({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:d,nodeOrigin:u,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:S=>{const{nodeLookup:y,parentLookup:v,nodeOrigin:w,elevateNodesOnSelect:j,fitViewQueued:E,zIndexMode:k,nodesSelectionActive:I}=g(),{nodesInitialized:R,hasSelectedNodes:$}=Bx(S,y,v,{nodeOrigin:w,nodeExtent:f,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:k}),K=I&&$;E&&R?(b(),h({nodes:S,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:K})):h({nodes:S,nodesInitialized:R,nodesSelectionActive:K})},setEdges:S=>{const{connectionLookup:y,edgeLookup:v}=g();j_(y,v,S),h({edges:S})},setDefaultNodesAndEdges:(S,y)=>{if(S){const{setNodes:v}=g();v(S),h({hasDefaultNodes:!0})}if(y){const{setEdges:v}=g();v(y),h({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:y,nodeLookup:v,parentLookup:w,domNode:j,nodeOrigin:E,nodeExtent:k,debug:I,fitViewQueued:R,zIndexMode:$}=g(),{changes:K,updatedInternals:D}=YF(S,v,w,j,E,k,$);D&&(WF(v,w,{nodeOrigin:E,nodeExtent:k,zIndexMode:$}),R?(b(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(K==null?void 0:K.length)>0&&(I&&console.log("React Flow: trigger node changes",K),y==null||y(K)))},updateNodePositions:(S,y=!1)=>{const v=[];let w=[];const{nodeLookup:j,triggerNodeChanges:E,connection:k,updateConnection:I,onNodesChangeMiddlewareMap:R}=g();for(const[$,K]of S){const D=j.get($),L=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(K!=null&&K.position)),H={id:$,type:"position",position:L?{x:Math.max(0,K.position.x),y:Math.max(0,K.position.y)}:K.position,dragging:y};if(D&&k.inProgress&&k.fromNode.id===D.id){const M=ol(D,k.fromHandle,Fe.Left,!0);I({...k,from:M})}L&&D.parentId&&v.push({id:$,parentId:D.parentId,rect:{...K.internals.positionAbsolute,width:K.measured.width??0,height:K.measured.height??0}}),w.push(H)}if(v.length>0){const{parentLookup:$,nodeOrigin:K}=g(),D=Pv(v,j,$,K);w.push(...D)}for(const $ of R.values())w=$(w);E(w)},triggerNodeChanges:S=>{const{onNodesChange:y,setNodes:v,nodes:w,hasDefaultNodes:j,debug:E}=g();if(S!=null&&S.length){if(j){const k=Av(S,w);v(k)}E&&console.log("React Flow: trigger node changes",S),y==null||y(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:y,setEdges:v,edges:w,hasDefaultEdges:j,debug:E}=g();if(S!=null&&S.length){if(j){const k=V_(S,w);v(k)}E&&console.log("React Flow: trigger edge changes",S),y==null||y(S)}},addSelectedNodes:S=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:E}=g();if(y){const k=S.map(I=>za(I,!0));j(k);return}j(Zl(w,new Set([...S]),!0)),E(Zl(v))},addSelectedEdges:S=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:E}=g();if(y){const k=S.map(I=>za(I,!0));E(k);return}E(Zl(v,new Set([...S]))),j(Zl(w,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:y}={})=>{const{edges:v,nodes:w,nodeLookup:j,triggerNodeChanges:E,triggerEdgeChanges:k}=g(),I=S||w,R=y||v,$=[];for(const D of I){if(!D.selected)continue;const L=j.get(D.id);L&&(L.selected=!1),$.push(za(D.id,!1))}const K=[];for(const D of R)D.selected&&K.push(za(D.id,!1));E($),k(K)},setMinZoom:S=>{const{panZoom:y,maxZoom:v}=g();y==null||y.setScaleExtent([S,v]),h({minZoom:S})},setMaxZoom:S=>{const{panZoom:y,minZoom:v}=g();y==null||y.setScaleExtent([v,S]),h({maxZoom:S})},setTranslateExtent:S=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(S),h({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:y,triggerNodeChanges:v,triggerEdgeChanges:w,elementsSelectable:j}=g();if(!j)return;const E=y.reduce((I,R)=>R.selected?[...I,za(R.id,!1)]:I,[]),k=S.reduce((I,R)=>R.selected?[...I,za(R.id,!1)]:I,[]);v(E),w(k)},setNodeExtent:S=>{const{nodes:y,nodeLookup:v,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:E,nodeExtent:k,zIndexMode:I}=g();S[0][0]===k[0][0]&&S[0][1]===k[0][1]&&S[1][0]===k[1][0]&&S[1][1]===k[1][1]||(Bx(y,v,w,{nodeOrigin:j,nodeExtent:S,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:I}),h({nodeExtent:S}))},panBy:S=>{const{transform:y,width:v,height:w,panZoom:j,translateExtent:E}=g();return GF({delta:S,panZoom:j,transform:y,translateExtent:E,width:v,height:w})},setCenter:async(S,y,v)=>{const{width:w,height:j,maxZoom:E,panZoom:k}=g();if(!k)return Promise.resolve(!1);const I=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:E;return await k.setViewport({x:w/2-S*I,y:j/2-y*I,zoom:I},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...a_}})},updateConnection:S=>{h({connection:S})},reset:()=>h({...lS()})}},Object.is);function Tv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:d,nodeOrigin:u,nodeExtent:f,zIndexMode:p,children:h}){const[g]=m.useState(()=>N4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:u,nodeExtent:f,zIndexMode:p}));return o.jsx(W3,{value:g,children:o.jsx(fz,{children:h})})}function j4({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:d,maxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:h}){return m.useContext(Im)?o.jsx(o.Fragment,{children:e}):o.jsx(Tv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:h,children:e})}const C4={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function E4({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:d,onMove:u,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:S,onClickConnectEnd:y,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:E,onNodeDoubleClick:k,onNodeDragStart:I,onNodeDrag:R,onNodeDragStop:$,onNodesDelete:K,onEdgesDelete:D,onDelete:L,onSelectionChange:H,onSelectionDragStart:M,onSelectionDrag:O,onSelectionDragStop:A,onSelectionContextMenu:z,onSelectionStart:_,onSelectionEnd:T,onBeforeDelete:C,connectionMode:G,connectionLineType:Z=Go.Bezier,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:le,deleteKeyCode:ue="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:ce=!1,selectionMode:fe=Id.Full,panActivationKeyCode:re="Space",multiSelectionKeyCode:pe=Rd()?"Meta":"Control",zoomActivationKeyCode:ae=Rd()?"Meta":"Control",snapToGrid:ye,snapGrid:Be,onlyRenderVisibleElements:lt=!1,selectNodesOnDrag:Ge,nodesDraggable:_t,autoPanOnNodeFocus:Pt,nodesConnectable:Te,nodesFocusable:an,nodeOrigin:Fn=U_,edgesFocusable:qt,edgesReconnectable:_n,elementsSelectable:jr=!0,defaultViewport:fr=rz,minZoom:ie=.5,maxZoom:xe=2,translateExtent:Ve=Ad,preventScrolling:Ze=!0,nodeExtent:Xe,defaultMarkerColor:At="#b1b1b7",zoomOnScroll:On=!0,zoomOnPinch:Dt=!0,panOnScroll:Mn=!1,panOnScrollSpeed:Yt=.5,panOnScrollMode:Gt=Ga.Free,zoomOnDoubleClick:rr=!0,panOnDrag:he=!0,onPaneClick:Ee,onPaneMouseEnter:Wt,onPaneMouseMove:nt,onPaneMouseLeave:hn,onPaneScroll:Us,onPaneContextMenu:Pn,paneClickDistance:Cr=1,nodeClickDistance:pr=0,children:fs,onReconnect:xi,onReconnectStart:Ws,onReconnectEnd:hr,onEdgeContextMenu:sr,onEdgeDoubleClick:Vs,onEdgeMouseEnter:Ye,onEdgeMouseMove:Vt,onEdgeMouseLeave:ln,reconnectRadius:mr=10,onNodesChange:He,onEdgesChange:Xt,noDragClassName:_e="nodrag",noWheelClassName:bn="nowheel",noPanClassName:Er="nopan",fitView:ot,fitViewOptions:Xn,connectOnClick:ir,attributionPosition:zn,proOptions:ps,defaultEdgeOptions:Jn,elevateNodesOnSelect:Ks=!0,elevateEdgesOnSelect:_r=!1,disableKeyboardA11y:Es=!1,autoPanOnConnect:$r,autoPanOnNodeDrag:gr,autoPanSpeed:yr,connectionRadius:q,isValidConnection:be,onError:Ae,style:Ue,id:yt,nodeDragThreshold:Bn,connectionDragThreshold:ct,viewport:wt,onViewportChange:or,width:qs,height:Ys,colorMode:hs="light",debug:jo,onScroll:_s,ariaLabelConfig:pl,zIndexMode:et="basic",...wi},Pr){const Gs=yt||"1",Co=az(hs),Ps=m.useCallback(Hn=>{Hn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),_s==null||_s(Hn)},[_s]);return o.jsx("div",{"data-testid":"rf__wrapper",...wi,onScroll:Ps,style:{...Ue,...C4},ref:Pr,className:Gn(["react-flow",s,Co]),id:yt,role:"application",children:o.jsxs(j4,{nodes:e,edges:t,width:qs,height:Ys,fitView:ot,fitViewOptions:Xn,minZoom:ie,maxZoom:xe,nodeOrigin:Fn,nodeExtent:Xe,zIndexMode:et,children:[o.jsx(oz,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:b,onClickConnectStart:S,onClickConnectEnd:y,nodesDraggable:_t,autoPanOnNodeFocus:Pt,nodesConnectable:Te,nodesFocusable:an,edgesFocusable:qt,edgesReconnectable:_n,elementsSelectable:jr,elevateNodesOnSelect:Ks,elevateEdgesOnSelect:_r,minZoom:ie,maxZoom:xe,nodeExtent:Xe,onNodesChange:He,onEdgesChange:Xt,snapToGrid:ye,snapGrid:Be,connectionMode:G,translateExtent:Ve,connectOnClick:ir,defaultEdgeOptions:Jn,fitView:ot,fitViewOptions:Xn,onNodesDelete:K,onEdgesDelete:D,onDelete:L,onNodeDragStart:I,onNodeDrag:R,onNodeDragStop:$,onSelectionDrag:O,onSelectionDragStart:M,onSelectionDragStop:A,onMove:u,onMoveStart:f,onMoveEnd:p,noPanClassName:Er,nodeOrigin:Fn,rfId:Gs,autoPanOnConnect:$r,autoPanOnNodeDrag:gr,autoPanSpeed:yr,onError:Ae,connectionRadius:q,isValidConnection:be,selectNodesOnDrag:Ge,nodeDragThreshold:Bn,connectionDragThreshold:ct,onBeforeDelete:C,debug:jo,ariaLabelConfig:pl,zIndexMode:et}),o.jsx(S4,{onInit:d,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:E,onNodeDoubleClick:k,nodeTypes:i,edgeTypes:a,connectionLineType:Z,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:le,selectionKeyCode:de,selectionOnDrag:ce,selectionMode:fe,deleteKeyCode:ue,multiSelectionKeyCode:pe,panActivationKeyCode:re,zoomActivationKeyCode:ae,onlyRenderVisibleElements:lt,defaultViewport:fr,translateExtent:Ve,minZoom:ie,maxZoom:xe,preventScrolling:Ze,zoomOnScroll:On,zoomOnPinch:Dt,zoomOnDoubleClick:rr,panOnScroll:Mn,panOnScrollSpeed:Yt,panOnScrollMode:Gt,panOnDrag:he,onPaneClick:Ee,onPaneMouseEnter:Wt,onPaneMouseMove:nt,onPaneMouseLeave:hn,onPaneScroll:Us,onPaneContextMenu:Pn,paneClickDistance:Cr,nodeClickDistance:pr,onSelectionContextMenu:z,onSelectionStart:_,onSelectionEnd:T,onReconnect:xi,onReconnectStart:Ws,onReconnectEnd:hr,onEdgeContextMenu:sr,onEdgeDoubleClick:Vs,onEdgeMouseEnter:Ye,onEdgeMouseMove:Vt,onEdgeMouseLeave:ln,reconnectRadius:mr,defaultMarkerColor:At,noDragClassName:_e,noWheelClassName:bn,noPanClassName:Er,rfId:Gs,disableKeyboardA11y:Es,nodeExtent:Xe,viewport:wt,onViewportChange:or}),o.jsx(nz,{onSelectionChange:H}),fs,o.jsx(J3,{proOptions:ps,position:zn}),o.jsx(X3,{rfId:Gs,disableKeyboardA11y:Es})]})})}var gP=K_(E4);function yP(){const e=pn();return m.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 xP(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>Av(s,i)),[]);return[t,n,r]}function wP(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>V_(s,i)),[]);return[t,n,r]}function _4({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:Gn(["react-flow__background-pattern",n,r])})}function P4({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:Gn(["react-flow__background-pattern","dots",t])})}var ca;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ca||(ca={}));const A4={[ca.Dots]:1,[ca.Lines]:1,[ca.Cross]:6},I4=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function vP({id:e,variant:t=ca.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:d,patternClassName:u}){const f=m.useRef(null),{transform:p,patternId:h}=Lt(I4,vn),g=r||A4[t],b=t===ca.Dots,S=t===ca.Cross,y=Array.isArray(n)?n:[n,n],v=[y[0]*p[2]||1,y[1]*p[2]||1],w=g*p[2],j=Array.isArray(i)?i:[i,i],E=S?[w,w]:v,k=[j[0]*p[2]||1+E[0]/2,j[1]*p[2]||1+E[1]/2],I=`${h}${e||""}`;return o.jsxs("svg",{className:Gn(["react-flow__background",d]),style:{...c,...Tm,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[o.jsx("pattern",{id:I,x:p[0]%v[0],y:p[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:b?o.jsx(P4,{radius:w/2,className:u}):o.jsx(_4,{dimensions:E,lineWidth:s,variant:t,className:u})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}vP.displayName="Background";const bP=m.memo(vP);function T4(){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 R4(){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 O4(){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 M4(){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 gp({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:Gn(["react-flow__controls-button",t]),...n,children:e})}const $4=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function kP({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:d,children:u,position:f="bottom-left",orientation:p="vertical","aria-label":h}){const g=pn(),{isInteractive:b,minZoomReached:S,maxZoomReached:y,ariaLabelConfig:v}=Lt($4,vn),{zoomIn:w,zoomOut:j,fitView:E}=dl(),k=()=>{w(),i==null||i()},I=()=>{j(),a==null||a()},R=()=>{E(s),l==null||l()},$=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),c==null||c(!b)},K=p==="horizontal"?"horizontal":"vertical";return o.jsxs(Ac,{className:Gn(["react-flow__controls",K,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??v["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(gp,{onClick:k,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(T4,{})}),o.jsx(gp,{onClick:I,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:S,children:o.jsx(R4,{})})]}),n&&o.jsx(gp,{className:"react-flow__controls-fitview",onClick:R,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:o.jsx(L4,{})}),r&&o.jsx(gp,{className:"react-flow__controls-interactive",onClick:$,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:b?o.jsx(M4,{}):o.jsx(O4,{})}),u]})}kP.displayName="Controls";const D4=m.memo(kP);function F4({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:d,borderRadius:u,shapeRendering:f,selected:p,onClick:h}){const{background:g,backgroundColor:b}=i||{},S=a||g||b;return o.jsx("rect",{className:Gn(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:u,ry:u,width:r,height:s,style:{fill:S,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?y=>h(y,e):void 0})}const z4=m.memo(F4),B4=e=>e.nodes.map(t=>t.id),Jg=e=>e instanceof Function?e:()=>e;function H4({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=z4,onClick:a}){const l=Lt(B4,vn),c=Jg(t),d=Jg(e),u=Jg(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(W4,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:f},p))})}function U4({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:d,x:u,y:f,width:p,height:h}=Lt(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const S=b.internals.userNode,{x:y,y:v}=b.internals.positionAbsolute,{width:w,height:j}=So(S);return{node:S,x:y,y:v,width:w,height:j}},vn);return!d||d.hidden||!h_(d)?null:o.jsx(l,{x:u,y:f,width:p,height:h,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 W4=m.memo(U4);var V4=m.memo(H4);const K4=200,q4=150,Y4=e=>!e.hidden,G4=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?p_(rf(e.nodeLookup,{filter:Y4}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},X4="react-flow__minimap-desc";function SP({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:d,maskStrokeColor:u,maskStrokeWidth:f,position:p="bottom-right",onClick:h,onNodeClick:g,pannable:b=!1,zoomable:S=!1,ariaLabel:y,inversePan:v,zoomStep:w=1,offsetScale:j=5}){const E=pn(),k=m.useRef(null),{boundingRect:I,viewBB:R,rfId:$,panZoom:K,translateExtent:D,flowWidth:L,flowHeight:H,ariaLabelConfig:M}=Lt(G4,vn),O=(e==null?void 0:e.width)??K4,A=(e==null?void 0:e.height)??q4,z=I.width/O,_=I.height/A,T=Math.max(z,_),C=T*O,G=T*A,Z=j*T,W=I.x-(C-I.width)/2-Z,te=I.y-(G-I.height)/2-Z,le=C+Z*2,ue=G+Z*2,de=`${X4}-${$}`,ce=m.useRef(0),fe=m.useRef();ce.current=T,m.useEffect(()=>{if(k.current&&K)return fe.current=s3({domNode:k.current,panZoom:K,getTransform:()=>E.getState().transform,getViewScale:()=>ce.current}),()=>{var ye;(ye=fe.current)==null||ye.destroy()}},[K]),m.useEffect(()=>{var ye;(ye=fe.current)==null||ye.update({translateExtent:D,width:L,height:H,inversePan:v,pannable:b,zoomStep:w,zoomable:S})},[b,S,v,w,D,L,H]);const re=h?ye=>{var Ge;const[Be,lt]=((Ge=fe.current)==null?void 0:Ge.pointer(ye))||[0,0];h(ye,{x:Be,y:lt})}:void 0,pe=g?m.useCallback((ye,Be)=>{const lt=E.getState().nodeLookup.get(Be).internals.userNode;g(ye,lt)},[]):void 0,ae=y??M["minimap.ariaLabel"];return o.jsx(Ac,{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 u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*T: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:Gn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:O,height:A,viewBox:`${W} ${te} ${le} ${ue}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:k,onClick:re,children:[ae&&o.jsx("title",{id:de,children:ae}),o.jsx(V4,{onClick:pe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-Z},${te-Z}h${le+Z*2}v${ue+Z*2}h${-le-Z*2}z
66
- M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}SP.displayName="MiniMap";const J4=m.memo(SP),Q4=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Z4={[_c.Line]:"right",[_c.Handle]:"bottom-right"};function eB({nodeId:e,position:t,variant:n=_c.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:h=!0,shouldResize:g,onResizeStart:b,onResize:S,onResizeEnd:y}){const v=X_(),w=typeof e=="string"?e:v,j=pn(),E=m.useRef(null),k=n===_c.Handle,I=Lt(m.useCallback(Q4(k&&h),[k,h]),vn),R=m.useRef(null),$=t??Z4[n];m.useEffect(()=>{if(!(!E.current||!w))return R.current||(R.current=x3({domNode:E.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:D,transform:L,snapGrid:H,snapToGrid:M,nodeOrigin:O,domNode:A}=j.getState();return{nodeLookup:D,transform:L,snapGrid:H,snapToGrid:M,nodeOrigin:O,paneDomNode:A}},onChange:(D,L)=>{const{triggerNodeChanges:H,nodeLookup:M,parentLookup:O,nodeOrigin:A}=j.getState(),z=[],_={x:D.x,y:D.y},T=M.get(w);if(T&&T.expandParent&&T.parentId){const C=T.origin??A,G=D.width??T.measured.width??0,Z=D.height??T.measured.height??0,W={id:T.id,parentId:T.parentId,rect:{width:G,height:Z,...m_({x:D.x??T.position.x,y:D.y??T.position.y},{width:G,height:Z},T.parentId,M,C)}},te=Pv([W],M,O,A);z.push(...te),_.x=D.x?Math.max(C[0]*G,D.x):void 0,_.y=D.y?Math.max(C[1]*Z,D.y):void 0}if(_.x!==void 0&&_.y!==void 0){const C={id:w,type:"position",position:{..._}};z.push(C)}if(D.width!==void 0&&D.height!==void 0){const G={id:w,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};z.push(G)}for(const C of L){const G={...C,type:"position"};z.push(G)}H(z)},onEnd:({width:D,height:L})=>{const H={id:w,type:"dimensions",resizing:!1,dimensions:{width:D,height:L}};j.getState().triggerNodeChanges([H])}})),R.current.update({controlPosition:$,boundaries:{minWidth:l,minHeight:c,maxWidth:d,maxHeight:u},keepAspectRatio:f,resizeDirection:p,onResizeStart:b,onResize:S,onResizeEnd:y,shouldResize:g}),()=>{var D;(D=R.current)==null||D.destroy()}},[$,l,c,d,u,f,b,S,y,g]);const K=$.split("-");return o.jsx("div",{className:Gn(["react-flow__resize-control","nodrag",...K,n,r]),ref:E,style:{...s,scale:I,...a&&{[k?"backgroundColor":"borderColor"]:a}},children:i})}const tB=m.memo(eB);function nB(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const rB=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,sB=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iB={};function cS(e,t){return(iB.jsx?sB:rB).test(e)}const oB=/[ \t\n\f\r]/g;function aB(e){return typeof e=="object"?e.type==="text"?uS(e.value):!1:uS(e)}function uS(e){return e.replace(oB,"")===""}let af=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};af.prototype.normal={};af.prototype.property={};af.prototype.space=void 0;function NP(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new af(n,r,t)}function Vx(e){return e.toLowerCase()}class ds{constructor(t,n){this.attribute=n,this.property=t}}ds.prototype.attribute="";ds.prototype.booleanish=!1;ds.prototype.boolean=!1;ds.prototype.commaOrSpaceSeparated=!1;ds.prototype.commaSeparated=!1;ds.prototype.defined=!1;ds.prototype.mustUseProperty=!1;ds.prototype.number=!1;ds.prototype.overloadedBoolean=!1;ds.prototype.property="";ds.prototype.spaceSeparated=!1;ds.prototype.space=void 0;let lB=0;const mt=fl(),Vn=fl(),Kx=fl(),Se=fl(),nn=fl(),fc=fl(),ms=fl();function fl(){return 2**++lB}const qx=Object.freeze(Object.defineProperty({__proto__:null,boolean:mt,booleanish:Vn,commaOrSpaceSeparated:ms,commaSeparated:fc,number:Se,overloadedBoolean:Kx,spaceSeparated:nn},Symbol.toStringTag,{value:"Module"})),Qg=Object.keys(qx);class Rv extends ds{constructor(t,n,r,s){let i=-1;if(super(t,n),dS(this,"space",s),typeof r=="number")for(;++i<Qg.length;){const a=Qg[i];dS(this,Qg[i],(r&qx[a])===qx[a])}}}Rv.prototype.defined=!0;function dS(e,t,n){n&&(e[t]=n)}function Fc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Rv(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[Vx(r)]=r,n[Vx(i.attribute)]=r}return new af(t,n,e.space)}const jP=Fc({properties:{ariaActiveDescendant:null,ariaAtomic:Vn,ariaAutoComplete:null,ariaBusy:Vn,ariaChecked:Vn,ariaColCount:Se,ariaColIndex:Se,ariaColSpan:Se,ariaControls:nn,ariaCurrent:null,ariaDescribedBy:nn,ariaDetails:null,ariaDisabled:Vn,ariaDropEffect:nn,ariaErrorMessage:null,ariaExpanded:Vn,ariaFlowTo:nn,ariaGrabbed:Vn,ariaHasPopup:null,ariaHidden:Vn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:nn,ariaLevel:Se,ariaLive:null,ariaModal:Vn,ariaMultiLine:Vn,ariaMultiSelectable:Vn,ariaOrientation:null,ariaOwns:nn,ariaPlaceholder:null,ariaPosInSet:Se,ariaPressed:Vn,ariaReadOnly:Vn,ariaRelevant:null,ariaRequired:Vn,ariaRoleDescription:nn,ariaRowCount:Se,ariaRowIndex:Se,ariaRowSpan:Se,ariaSelected:Vn,ariaSetSize:Se,ariaSort:null,ariaValueMax:Se,ariaValueMin:Se,ariaValueNow:Se,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function CP(e,t){return t in e?e[t]:t}function EP(e,t){return CP(e,t.toLowerCase())}const cB=Fc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:fc,acceptCharset:nn,accessKey:nn,action:null,allow:null,allowFullScreen:mt,allowPaymentRequest:mt,allowUserMedia:mt,alt:null,as:null,async:mt,autoCapitalize:null,autoComplete:nn,autoFocus:mt,autoPlay:mt,blocking:nn,capture:null,charSet:null,checked:mt,cite:null,className:nn,cols:Se,colSpan:null,content:null,contentEditable:Vn,controls:mt,controlsList:nn,coords:Se|fc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:mt,defer:mt,dir:null,dirName:null,disabled:mt,download:Kx,draggable:Vn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:mt,formTarget:null,headers:nn,height:Se,hidden:Kx,high:Se,href:null,hrefLang:null,htmlFor:nn,httpEquiv:nn,id:null,imageSizes:null,imageSrcSet:null,inert:mt,inputMode:null,integrity:null,is:null,isMap:mt,itemId:null,itemProp:nn,itemRef:nn,itemScope:mt,itemType:nn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:mt,low:Se,manifest:null,max:null,maxLength:Se,media:null,method:null,min:null,minLength:Se,multiple:mt,muted:mt,name:null,nonce:null,noModule:mt,noValidate:mt,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:mt,optimum:Se,pattern:null,ping:nn,placeholder:null,playsInline:mt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:mt,referrerPolicy:null,rel:nn,required:mt,reversed:mt,rows:Se,rowSpan:Se,sandbox:nn,scope:null,scoped:mt,seamless:mt,selected:mt,shadowRootClonable:mt,shadowRootDelegatesFocus:mt,shadowRootMode:null,shape:null,size:Se,sizes:null,slot:null,span:Se,spellCheck:Vn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Se,step:null,style:null,tabIndex:Se,target:null,title:null,translate:null,type:null,typeMustMatch:mt,useMap:null,value:Vn,width:Se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:nn,axis:null,background:null,bgColor:null,border:Se,borderColor:null,bottomMargin:Se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:mt,declare:mt,event:null,face:null,frame:null,frameBorder:null,hSpace:Se,leftMargin:Se,link:null,longDesc:null,lowSrc:null,marginHeight:Se,marginWidth:Se,noResize:mt,noHref:mt,noShade:mt,noWrap:mt,object:null,profile:null,prompt:null,rev:null,rightMargin:Se,rules:null,scheme:null,scrolling:Vn,standby:null,summary:null,text:null,topMargin:Se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Se,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:mt,disableRemotePlayback:mt,prefix:null,property:null,results:Se,security:null,unselectable:null},space:"html",transform:EP}),uB=Fc({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:ms,accentHeight:Se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Se,amplitude:Se,arabicForm:null,ascent:Se,attributeName:null,attributeType:null,azimuth:Se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Se,by:null,calcMode:null,capHeight:Se,className:nn,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:Se,diffuseConstant:Se,direction:null,display:null,dur:null,divisor:Se,dominantBaseline:null,download:mt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Se,enableBackground:null,end:null,event:null,exponent:Se,externalResourcesRequired:null,fill:null,fillOpacity:Se,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:fc,g2:fc,glyphName:fc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Se,horizOriginX:Se,horizOriginY:Se,id:null,ideographic:Se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Se,k:Se,k1:Se,k2:Se,k3:Se,k4:Se,kernelMatrix:ms,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Se,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:Se,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:Se,overlineThickness:Se,paintOrder:null,panose1:null,path:null,pathLength:Se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:nn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Se,pointsAtY:Se,pointsAtZ:Se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ms,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ms,rev:ms,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ms,requiredFeatures:ms,requiredFonts:ms,requiredFormats:ms,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:Se,specularExponent:Se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Se,strikethroughThickness:Se,string:null,stroke:null,strokeDashArray:ms,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Se,strokeOpacity:Se,strokeWidth:null,style:null,surfaceScale:Se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ms,tabIndex:Se,tableValues:null,target:null,targetX:Se,targetY:Se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ms,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Se,underlineThickness:Se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Se,values:null,vAlphabetic:Se,vMathematical:Se,vectorEffect:null,vHanging:Se,vIdeographic:Se,version:null,vertAdvY:Se,vertOriginX:Se,vertOriginY:Se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:CP}),_P=Fc({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()}}),PP=Fc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:EP}),AP=Fc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),dB={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"},fB=/[A-Z]/g,fS=/-[a-z]/g,pB=/^data[-\w.:]+$/i;function hB(e,t){const n=Vx(t);let r=t,s=ds;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&pB.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(fS,gB);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!fS.test(i)){let a=i.replace(fB,mB);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Rv}return new s(r,t)}function mB(e){return"-"+e.toLowerCase()}function gB(e){return e.charAt(1).toUpperCase()}const yB=NP([jP,cB,_P,PP,AP],"html"),Lv=NP([jP,uB,_P,PP,AP],"svg");function xB(e){return e.join(" ").trim()}var Ov={},pS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,wB=/\n/g,vB=/^\s*/,bB=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,kB=/^:\s*/,SB=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,NB=/^[;\s]*/,jB=/^\s+|\s+$/g,CB=`
67
- `,hS="/",mS="*",Ba="",EB="comment",_B="declaration";function PB(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(wB);b&&(n+=b.length);var S=g.lastIndexOf(CB);r=~S?g.length-S: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 S=b[0];return s(S),e=e.slice(S.length),b}}function d(){c(vB)}function u(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=i();if(!(hS!=e.charAt(0)||mS!=e.charAt(1))){for(var b=2;Ba!=e.charAt(b)&&(mS!=e.charAt(b)||hS!=e.charAt(b+1));)++b;if(b+=2,Ba===e.charAt(b-1))return l("End of comment missing");var S=e.slice(2,b-2);return r+=2,s(S),e=e.slice(b),r+=2,g({type:EB,comment:S})}}function p(){var g=i(),b=c(bB);if(b){if(f(),!c(kB))return l("property missing ':'");var S=c(SB),y=g({type:_B,property:gS(b[0].replace(pS,Ba)),value:S?gS(S[0].replace(pS,Ba)):Ba});return c(NB),y}}function h(){var g=[];u(g);for(var b;b=p();)b!==!1&&(g.push(b),u(g));return g}return d(),h()}function gS(e){return e?e.replace(jB,Ba):Ba}var AB=PB,IB=ld&&ld.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ov,"__esModule",{value:!0});Ov.default=RB;const TB=IB(AB);function RB(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,TB.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 Lm={};Object.defineProperty(Lm,"__esModule",{value:!0});Lm.camelCase=void 0;var LB=/^--[a-zA-Z0-9_-]+$/,OB=/-([a-z])/g,MB=/^[^-]+$/,$B=/^-(webkit|moz|ms|o|khtml)-/,DB=/^-(ms)-/,FB=function(e){return!e||MB.test(e)||LB.test(e)},zB=function(e,t){return t.toUpperCase()},yS=function(e,t){return"".concat(t,"-")},BB=function(e,t){return t===void 0&&(t={}),FB(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(DB,yS):e=e.replace($B,yS),e.replace(OB,zB))};Lm.camelCase=BB;var HB=ld&&ld.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},UB=HB(Ov),WB=Lm;function Yx(e,t){var n={};return!e||typeof e!="string"||(0,UB.default)(e,function(r,s){r&&s&&(n[(0,WB.camelCase)(r,t)]=s)}),n}Yx.default=Yx;var VB=Yx;const KB=xa(VB),IP=TP("end"),Mv=TP("start");function TP(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 qB(e){const t=Mv(e),n=IP(e);if(t&&n)return{start:t,end:n}}function td(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?xS(e.position):"start"in e||"end"in e?xS(e):"line"in e||"column"in e?Gx(e):""}function Gx(e){return wS(e&&e.line)+":"+wS(e&&e.column)}function xS(e){return Gx(e&&e.start)+"-"+Gx(e&&e.end)}function wS(e){return e&&typeof e=="number"?e:1}class Or 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=td(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}}Or.prototype.file="";Or.prototype.name="";Or.prototype.reason="";Or.prototype.message="";Or.prototype.stack="";Or.prototype.column=void 0;Or.prototype.line=void 0;Or.prototype.ancestors=void 0;Or.prototype.cause=void 0;Or.prototype.fatal=void 0;Or.prototype.place=void 0;Or.prototype.ruleId=void 0;Or.prototype.source=void 0;const $v={}.hasOwnProperty,YB=new Map,GB=/[A-Z]/g,XB=new Set(["table","tbody","thead","tfoot","tr"]),JB=new Set(["td","th"]),RP="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function QB(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=o5(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=i5(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"?Lv:yB,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=LP(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function LP(e,t,n){if(t.type==="element")return ZB(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return e5(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return n5(e,t,n);if(t.type==="mdxjsEsm")return t5(e,t);if(t.type==="root")return r5(e,t,n);if(t.type==="text")return s5(e,t)}function ZB(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=Lv,e.schema=s),e.ancestors.push(t);const i=MP(e,t.tagName,!1),a=a5(e,t);let l=Fv(e,t);return XB.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!aB(c):!0})),OP(e,a,i,t),Dv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function e5(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)}Md(e,t.position)}function t5(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Md(e,t.position)}function n5(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=Lv,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:MP(e,t.name,!0),a=l5(e,t),l=Fv(e,t);return OP(e,a,i,t),Dv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function r5(e,t,n){const r={};return Dv(r,Fv(e,t)),e.create(t,e.Fragment,r,n)}function s5(e,t){return t.value}function OP(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Dv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function i5(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 o5(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=Mv(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 a5(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&$v.call(t.properties,s)){const i=c5(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&JB.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 l5(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 Md(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 Md(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function Fv(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:YB;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=LP(e,i,a);l!==void 0&&n.push(l)}return n}function c5(e,t,n){const r=hB(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?nB(n):xB(n)),r.property==="style"){let s=typeof n=="object"?n:u5(e,String(n));return e.stylePropertyNameCase==="css"&&(s=d5(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?dB[r.property]||r.property:r.attribute,n]}}function u5(e,t){try{return KB(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Or("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=RP+"#cannot-parse-style-attribute",s}}function MP(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=cS(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=cS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return $v.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Md(e)}function Md(e,t){const n=new Or("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=RP+"#cannot-handle-mdx-estrees-without-createevaluater",n}function d5(e){const t={};let n;for(n in e)$v.call(e,n)&&(t[f5(n)]=e[n]);return t}function f5(e){let t=e.replace(GB,p5);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function p5(e){return"-"+e.toLowerCase()}const Zg={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"]},h5={};function m5(e,t){const n=h5,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return $P(e,r,s)}function $P(e,t,n){if(g5(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 vS(e.children,t,n)}return Array.isArray(e)?vS(e,t,n):""}function vS(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=$P(e[s],t,n);return r.join("")}function g5(e){return!!(e&&typeof e=="object")}const bS=document.createElement("i");function zv(e){const t="&"+e+";";bS.innerHTML=t;const n=bS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Vi(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 Ms(e,t){return e.length>0?(Vi(e,e.length,0,t),e):t}const kS={}.hasOwnProperty;function y5(e){const t={};let n=-1;for(;++n<e.length;)x5(t,e[n]);return t}function x5(e,t){let n;for(n in t){const s=(kS.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){kS.call(s,a)||(s[a]=[]);const l=i[a];w5(s[a],Array.isArray(l)?l:l?[l]:[])}}}function w5(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Vi(e,0,0,r)}function DP(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function pc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Oi=ka(/[A-Za-z]/),vs=ka(/[\dA-Za-z]/),v5=ka(/[#-'*+\--9=?A-Z^-~]/);function Xx(e){return e!==null&&(e<32||e===127)}const Jx=ka(/\d/),b5=ka(/[\dA-Fa-f]/),k5=ka(/[!-/:-@[-`{-~]/);function tt(e){return e!==null&&e<-2}function us(e){return e!==null&&(e<0||e===32)}function Bt(e){return e===-2||e===-1||e===32}const S5=ka(new RegExp("\\p{P}|\\p{S}","u")),N5=ka(/\s/);function ka(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function zc(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const 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 sn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return Bt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Bt(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const j5={tokenize:C5};function C5(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"),sn(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 tt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const E5={tokenize:_5},SS={tokenize:P5};function _5(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&&v();const j=t.events.length;let E=j,k;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){k=t.events[E][1].end;break}y(r);let I=j;for(;I<t.events.length;)t.events[I][1].end={...k},I++;return Vi(t.events,E+1,0,t.events.slice(j)),t.events.length=I,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(SS,u,f)(w)}function u(w){return s&&v(),y(r),p(w)}function f(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(SS,h,g)(w)}function h(w){return r++,n.push([t.currentConstruct,t.containerState]),p(w)}function g(w){if(w===null){s&&v(),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){S(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return tt(w)?(e.consume(w),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),b)}function S(w,j){const E=t.sliceStream(w);if(j&&E.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(E),t.parser.lazy[w.start.line]){let k=s.events.length;for(;k--;)if(s.events[k][1].start.offset<a&&(!s.events[k][1].end||s.events[k][1].end.offset>a))return;const I=t.events.length;let R=I,$,K;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if($){K=t.events[R][1].end;break}$=!0}for(y(r),k=I;k<t.events.length;)t.events[k][1].end={...K},k++;Vi(t.events,R+1,0,t.events.slice(I)),t.events.length=k}}function y(w){let j=n.length;for(;j-- >w;){const E=n[j];t.containerState=E[1],E[0].exit.call(t,e)}n.length=w}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function P5(e,t,n){return sn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function NS(e){if(e===null||us(e)||N5(e))return 1;if(S5(e))return 2}function Bv(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 Qx={name:"attention",resolveAll:A5,tokenize:I5};function A5(e,t){let n=-1,r,s,i,a,l,c,d,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};jS(f,-c),jS(p,c),a={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},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=Ms(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=Ms(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=Ms(d,Bv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=Ms(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,d=Ms(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,Vi(e,r-1,n-r+3,d),n=r+d.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function I5(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=NS(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"),u=NS(c),f=!u||u===2&&s||n.includes(c),p=!s||s===2&&u||n.includes(r);return d._open=!!(i===42?f:f&&(s||!p)),d._close=!!(i===42?p:p&&(u||!f)),t(c)}}function jS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const T5={name:"autolink",tokenize:R5};function R5(e,t,n){let r=0;return s;function s(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(h){return Oi(h)?(e.consume(h),a):h===64?n(h):d(h)}function a(h){return h===43||h===45||h===46||vs(h)?(r=1,l(h)):d(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||vs(h))&&r++<32?(e.consume(h),l):(r=0,d(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||Xx(h)?n(h):(e.consume(h),c)}function d(h){return h===64?(e.consume(h),u):v5(h)?(e.consume(h),d):n(h)}function u(h){return vs(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,u):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||vs(h))&&r++<63){const g=h===45?p:f;return e.consume(h),g}return n(h)}}const Om={partial:!0,tokenize:L5};function L5(e,t,n){return r;function r(i){return Bt(i)?sn(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||tt(i)?t(i):n(i)}}const FP={continuation:{tokenize:M5},exit:$5,name:"blockQuote",tokenize:O5};function O5(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 Bt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function M5(e,t,n){const r=this;return s;function s(a){return Bt(a)?sn(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(FP,t,n)(a)}}function $5(e){e.exit("blockQuote")}const zP={name:"characterEscape",tokenize:D5};function D5(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 k5(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const BP={name:"characterReference",tokenize:F5};function F5(e,t,n){const r=this;let s=0,i,a;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=vs,u(f))}function d(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=b5,u):(e.enter("characterReferenceValue"),i=7,a=Jx,u(f))}function u(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===vs&&!zv(r.sliceSerialize(p))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&s++<i?(e.consume(f),u):n(f)}}const CS={partial:!0,tokenize:B5},ES={concrete:!0,name:"codeFenced",tokenize:z5};function z5(e,t,n){const r=this,s={partial:!0,tokenize:E};let i=0,a=0,l;return c;function c(k){return d(k)}function d(k){const I=r.events[r.events.length-1];return i=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===l?(a++,e.consume(k),u):a<3?n(k):(e.exit("codeFencedFenceSequence"),Bt(k)?sn(e,f,"whitespace")(k):f(k))}function f(k){return k===null||tt(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(CS,b,j)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(k))}function p(k){return k===null||tt(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(k)):Bt(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),sn(e,h,"whitespace")(k)):k===96&&k===l?n(k):(e.consume(k),p)}function h(k){return k===null||tt(k)?f(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||tt(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(k)):k===96&&k===l?n(k):(e.consume(k),g)}function b(k){return e.attempt(s,j,S)(k)}function S(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),y}function y(k){return i>0&&Bt(k)?sn(e,v,"linePrefix",i+1)(k):v(k)}function v(k){return k===null||tt(k)?e.check(CS,b,j)(k):(e.enter("codeFlowValue"),w(k))}function w(k){return k===null||tt(k)?(e.exit("codeFlowValue"),v(k)):(e.consume(k),w)}function j(k){return e.exit("codeFenced"),t(k)}function E(k,I,R){let $=0;return K;function K(O){return k.enter("lineEnding"),k.consume(O),k.exit("lineEnding"),D}function D(O){return k.enter("codeFencedFence"),Bt(O)?sn(k,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):L(O)}function L(O){return O===l?(k.enter("codeFencedFenceSequence"),H(O)):R(O)}function H(O){return O===l?($++,k.consume(O),H):$>=a?(k.exit("codeFencedFenceSequence"),Bt(O)?sn(k,M,"whitespace")(O):M(O)):R(O)}function M(O){return O===null||tt(O)?(k.exit("codeFencedFence"),I(O)):R(O)}}}function B5(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 ey={name:"codeIndented",tokenize:U5},H5={partial:!0,tokenize:W5};function U5(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),sn(e,i,"linePrefix",5)(d)}function i(d){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?c(d):tt(d)?e.attempt(H5,a,c)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||tt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function c(d){return e.exit("codeIndented"),t(d)}}function W5(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):tt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):sn(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):tt(a)?s(a):n(a)}}const V5={name:"codeText",previous:q5,resolve:K5,tokenize:Y5};function K5(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 q5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Y5(e,t,n){let r=0,s,i;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(i=e.enter("codeTextSequence"),s=0,u(f)):tt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),d(f))}function d(f){return f===null||f===32||f===96||tt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),d)}function u(f){return f===96?(e.consume(f),s++,u):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(i.type="codeTextData",d(f))}}class G5{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&&Cu(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),Cu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Cu(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);Cu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Cu(this.left,n.reverse())}}}function Cu(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 HP(e){const t={};let n=-1,r,s,i,a,l,c,d;const u=new G5(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.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,X5(u,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=u.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(u.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={...u.get(s)[1].start},l=u.slice(s,n),l.unshift(r),u.splice(s,n-s+1,l))}}return Vi(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!d}function X5(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 u,f,p=-1,h=n,g=0,b=0;const S=[b];for(;h;){for(;e.get(++s)[1]!==h;);i.push(s),h._tokenizer||(u=r.sliceStream(h),h.next||u.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(u),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(b=p+1,S.push(b),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const y=l.slice(S[p],S[p+1]),v=i.pop();c.push([v,v+y.length-1]),e.splice(v,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 J5={resolve:Z5,tokenize:eH},Q5={partial:!0,tokenize:tH};function Z5(e){return HP(e),e}function eH(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):tt(l)?e.check(Q5,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 tH(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),sn(e,i,"linePrefix")}function i(a){if(a===null||tt(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 UP(e,t,n,r,s,i,a,l,c){const d=c||Number.POSITIVE_INFINITY;let u=0;return f;function f(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||Xx(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"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(l),p(y)):y===null||y===60||tt(y)?n(y):(e.consume(y),y===92?g:h)}function g(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function b(y){return!u&&(y===null||y===41||us(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):u<d&&y===40?(e.consume(y),u++,b):y===41?(e.consume(y),u--,b):y===null||y===32||y===40||Xx(y)?n(y):(e.consume(y),y===92?S:b)}function S(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function WP(e,t,n,r,s,i){const a=this;let l=0,c;return d;function d(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(i),u}function u(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(i),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):tt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||tt(h)||l++>999?(e.exit("chunkString"),u(h)):(e.consume(h),c||(c=!Bt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function VP(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):tt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),sn(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(p))}function u(p){return p===a||p===null||tt(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?f:u)}function f(p){return p===a||p===92?(e.consume(p),u):u(p)}}function nd(e,t){let n;return r;function r(s){return tt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Bt(s)?sn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const nH={name:"definition",tokenize:sH},rH={partial:!0,tokenize:iH};function sH(e,t,n){const r=this;let s;return i;function i(h){return e.enter("definition"),a(h)}function a(h){return WP.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=pc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return us(h)?nd(e,d)(h):d(h)}function d(h){return UP(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function u(h){return e.attempt(rH,f,f)(h)}function f(h){return Bt(h)?sn(e,p,"whitespace")(h):p(h)}function p(h){return h===null||tt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function iH(e,t,n){return r;function r(l){return us(l)?nd(e,s)(l):n(l)}function s(l){return VP(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Bt(l)?sn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||tt(l)?t(l):n(l)}}const oH={name:"hardBreakEscape",tokenize:aH};function aH(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return tt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const lH={name:"headingAtx",resolve:cH,tokenize:uH};function cH(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"},Vi(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function uH(e,t,n){let r=0;return s;function s(u){return e.enter("atxHeading"),i(u)}function i(u){return e.enter("atxHeadingSequence"),a(u)}function a(u){return u===35&&r++<6?(e.consume(u),a):u===null||us(u)?(e.exit("atxHeadingSequence"),l(u)):n(u)}function l(u){return u===35?(e.enter("atxHeadingSequence"),c(u)):u===null||tt(u)?(e.exit("atxHeading"),t(u)):Bt(u)?sn(e,l,"whitespace")(u):(e.enter("atxHeadingText"),d(u))}function c(u){return u===35?(e.consume(u),c):(e.exit("atxHeadingSequence"),l(u))}function d(u){return u===null||u===35||us(u)?(e.exit("atxHeadingText"),l(u)):(e.consume(u),d)}}const dH=["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"],_S=["pre","script","style","textarea"],fH={concrete:!0,name:"htmlFlow",resolveTo:mH,tokenize:gH},pH={partial:!0,tokenize:xH},hH={partial:!0,tokenize:yH};function mH(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 gH(e,t,n){const r=this;let s,i,a,l,c;return d;function d(W){return u(W)}function u(W){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(W),f}function f(W){return W===33?(e.consume(W),p):W===47?(e.consume(W),i=!0,b):W===63?(e.consume(W),s=3,r.interrupt?t:C):Oi(W)?(e.consume(W),a=String.fromCharCode(W),S):n(W)}function p(W){return W===45?(e.consume(W),s=2,h):W===91?(e.consume(W),s=5,l=0,g):Oi(W)?(e.consume(W),s=4,r.interrupt?t:C):n(W)}function h(W){return W===45?(e.consume(W),r.interrupt?t:C):n(W)}function g(W){const te="CDATA[";return W===te.charCodeAt(l++)?(e.consume(W),l===te.length?r.interrupt?t:L:g):n(W)}function b(W){return Oi(W)?(e.consume(W),a=String.fromCharCode(W),S):n(W)}function S(W){if(W===null||W===47||W===62||us(W)){const te=W===47,le=a.toLowerCase();return!te&&!i&&_S.includes(le)?(s=1,r.interrupt?t(W):L(W)):dH.includes(a.toLowerCase())?(s=6,te?(e.consume(W),y):r.interrupt?t(W):L(W)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(W):i?v(W):w(W))}return W===45||vs(W)?(e.consume(W),a+=String.fromCharCode(W),S):n(W)}function y(W){return W===62?(e.consume(W),r.interrupt?t:L):n(W)}function v(W){return Bt(W)?(e.consume(W),v):K(W)}function w(W){return W===47?(e.consume(W),K):W===58||W===95||Oi(W)?(e.consume(W),j):Bt(W)?(e.consume(W),w):K(W)}function j(W){return W===45||W===46||W===58||W===95||vs(W)?(e.consume(W),j):E(W)}function E(W){return W===61?(e.consume(W),k):Bt(W)?(e.consume(W),E):w(W)}function k(W){return W===null||W===60||W===61||W===62||W===96?n(W):W===34||W===39?(e.consume(W),c=W,I):Bt(W)?(e.consume(W),k):R(W)}function I(W){return W===c?(e.consume(W),c=null,$):W===null||tt(W)?n(W):(e.consume(W),I)}function R(W){return W===null||W===34||W===39||W===47||W===60||W===61||W===62||W===96||us(W)?E(W):(e.consume(W),R)}function $(W){return W===47||W===62||Bt(W)?w(W):n(W)}function K(W){return W===62?(e.consume(W),D):n(W)}function D(W){return W===null||tt(W)?L(W):Bt(W)?(e.consume(W),D):n(W)}function L(W){return W===45&&s===2?(e.consume(W),A):W===60&&s===1?(e.consume(W),z):W===62&&s===4?(e.consume(W),G):W===63&&s===3?(e.consume(W),C):W===93&&s===5?(e.consume(W),T):tt(W)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(pH,Z,H)(W)):W===null||tt(W)?(e.exit("htmlFlowData"),H(W)):(e.consume(W),L)}function H(W){return e.check(hH,M,Z)(W)}function M(W){return e.enter("lineEnding"),e.consume(W),e.exit("lineEnding"),O}function O(W){return W===null||tt(W)?H(W):(e.enter("htmlFlowData"),L(W))}function A(W){return W===45?(e.consume(W),C):L(W)}function z(W){return W===47?(e.consume(W),a="",_):L(W)}function _(W){if(W===62){const te=a.toLowerCase();return _S.includes(te)?(e.consume(W),G):L(W)}return Oi(W)&&a.length<8?(e.consume(W),a+=String.fromCharCode(W),_):L(W)}function T(W){return W===93?(e.consume(W),C):L(W)}function C(W){return W===62?(e.consume(W),G):W===45&&s===2?(e.consume(W),C):L(W)}function G(W){return W===null||tt(W)?(e.exit("htmlFlowData"),Z(W)):(e.consume(W),G)}function Z(W){return e.exit("htmlFlow"),t(W)}}function yH(e,t,n){const r=this;return s;function s(a){return tt(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 xH(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Om,t,n)}}const wH={name:"htmlText",tokenize:vH};function vH(e,t,n){const r=this;let s,i,a;return l;function l(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),c}function c(C){return C===33?(e.consume(C),d):C===47?(e.consume(C),E):C===63?(e.consume(C),w):Oi(C)?(e.consume(C),R):n(C)}function d(C){return C===45?(e.consume(C),u):C===91?(e.consume(C),i=0,g):Oi(C)?(e.consume(C),v):n(C)}function u(C){return C===45?(e.consume(C),h):n(C)}function f(C){return C===null?n(C):C===45?(e.consume(C),p):tt(C)?(a=f,z(C)):(e.consume(C),f)}function p(C){return C===45?(e.consume(C),h):f(C)}function h(C){return C===62?A(C):C===45?p(C):f(C)}function g(C){const G="CDATA[";return C===G.charCodeAt(i++)?(e.consume(C),i===G.length?b:g):n(C)}function b(C){return C===null?n(C):C===93?(e.consume(C),S):tt(C)?(a=b,z(C)):(e.consume(C),b)}function S(C){return C===93?(e.consume(C),y):b(C)}function y(C){return C===62?A(C):C===93?(e.consume(C),y):b(C)}function v(C){return C===null||C===62?A(C):tt(C)?(a=v,z(C)):(e.consume(C),v)}function w(C){return C===null?n(C):C===63?(e.consume(C),j):tt(C)?(a=w,z(C)):(e.consume(C),w)}function j(C){return C===62?A(C):w(C)}function E(C){return Oi(C)?(e.consume(C),k):n(C)}function k(C){return C===45||vs(C)?(e.consume(C),k):I(C)}function I(C){return tt(C)?(a=I,z(C)):Bt(C)?(e.consume(C),I):A(C)}function R(C){return C===45||vs(C)?(e.consume(C),R):C===47||C===62||us(C)?$(C):n(C)}function $(C){return C===47?(e.consume(C),A):C===58||C===95||Oi(C)?(e.consume(C),K):tt(C)?(a=$,z(C)):Bt(C)?(e.consume(C),$):A(C)}function K(C){return C===45||C===46||C===58||C===95||vs(C)?(e.consume(C),K):D(C)}function D(C){return C===61?(e.consume(C),L):tt(C)?(a=D,z(C)):Bt(C)?(e.consume(C),D):$(C)}function L(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),s=C,H):tt(C)?(a=L,z(C)):Bt(C)?(e.consume(C),L):(e.consume(C),M)}function H(C){return C===s?(e.consume(C),s=void 0,O):C===null?n(C):tt(C)?(a=H,z(C)):(e.consume(C),H)}function M(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||us(C)?$(C):(e.consume(C),M)}function O(C){return C===47||C===62||us(C)?$(C):n(C)}function A(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function z(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),_}function _(C){return Bt(C)?sn(e,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):T(C)}function T(C){return e.enter("htmlTextData"),a(C)}}const Hv={name:"labelEnd",resolveAll:NH,resolveTo:jH,tokenize:CH},bH={tokenize:EH},kH={tokenize:_H},SH={tokenize:PH};function NH(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&&Vi(e,0,e.length,n),e}function jH(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}},u={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",d,t]],l=Ms(l,e.slice(i+1,i+r+3)),l=Ms(l,[["enter",u,t]]),l=Ms(l,Bv(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Ms(l,[["exit",u,t],e[a-2],e[a-1],["exit",d,t]]),l=Ms(l,e.slice(a+1)),l=Ms(l,[["exit",c,t]]),Vi(e,i,e.length,l),e}function CH(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?f(p):(a=r.parser.defined.includes(pc(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(bH,u,a?u:f)(p):p===91?e.attempt(kH,u,a?d:f)(p):a?u(p):f(p)}function d(p){return e.attempt(SH,u,f)(p)}function u(p){return t(p)}function f(p){return i._balanced=!0,n(p)}}function EH(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return us(f)?nd(e,i)(f):i(f)}function i(f){return f===41?u(f):UP(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return us(f)?nd(e,c)(f):u(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?VP(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):u(f)}function d(f){return us(f)?nd(e,u)(f):u(f)}function u(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function _H(e,t,n){const r=this;return s;function s(l){return WP.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(pc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function PH(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 AH={name:"labelStartImage",resolveAll:Hv.resolveAll,tokenize:IH};function IH(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 TH={name:"labelStartLink",resolveAll:Hv.resolveAll,tokenize:RH};function RH(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 ty={name:"lineEnding",tokenize:LH};function LH(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),sn(e,t,"linePrefix")}}const Gp={name:"thematicBreak",tokenize:OH};function OH(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||tt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function c(d){return d===s?(e.consume(d),r++,c):(e.exit("thematicBreakSequence"),Bt(d)?sn(e,l,"whitespace")(d):l(d))}}const Qr={continuation:{tokenize:FH},exit:BH,name:"list",tokenize:DH},MH={partial:!0,tokenize:HH},$H={partial:!0,tokenize:zH};function DH(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(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Jx(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Gp,n,d)(h):d(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return Jx(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),d(h)):n(h)}function d(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Om,r.interrupt?n:u,e.attempt(MH,p,f))}function u(h){return r.containerState.initialBlankLine=!0,i++,p(h)}function f(h){return Bt(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function FH(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Om,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,sn(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!Bt(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($H,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,sn(e,e.attempt(Qr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function zH(e,t,n){const r=this;return sn(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 BH(e){e.exit(this.containerState.type)}function HH(e,t,n){const r=this;return sn(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!Bt(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const PS={name:"setextUnderline",resolveTo:UH,tokenize:WH};function UH(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 WH(e,t,n){const r=this;let s;return i;function i(d){let u=r.events.length,f;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){f=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(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"),Bt(d)?sn(e,c,"lineSuffix")(d):c(d))}function c(d){return d===null||tt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const VH={tokenize:KH};function KH(e){const t=this,n=e.attempt(Om,r,e.attempt(this.parser.constructs.flowInitial,s,sn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(J5,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 qH={resolveAll:qP()},YH=KP("string"),GH=KP("text");function KP(e){return{resolveAll:qP(e==="text"?XH: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(u){return d(u)?i(u):l(u)}function l(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),c}function c(u){return d(u)?(n.exit("data"),i(u)):(n.consume(u),c)}function d(u){if(u===null)return!0;const f=s[u];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function qP(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 XH(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 JH={42:Qr,43:Qr,45:Qr,48:Qr,49:Qr,50:Qr,51:Qr,52:Qr,53:Qr,54:Qr,55:Qr,56:Qr,57:Qr,62:FP},QH={91:nH},ZH={[-2]:ey,[-1]:ey,32:ey},e6={35:lH,42:Gp,45:[PS,Gp],60:fH,61:PS,95:Gp,96:ES,126:ES},t6={38:BP,92:zP},n6={[-5]:ty,[-4]:ty,[-3]:ty,33:AH,38:BP,42:Qx,60:[T5,wH],91:TH,92:[oH,zP],93:Hv,95:Qx,96:V5},r6={null:[Qx,qH]},s6={null:[42,95]},i6={null:[]},o6=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:s6,contentInitial:QH,disable:i6,document:JH,flow:e6,flowInitial:ZH,insideSpan:r6,string:t6,text:n6},Symbol.toStringTag,{value:"Module"}));function a6(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:I(E),check:I(k),consume:v,enter:w,exit:j,interrupt:I(k,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let u=t.tokenize.call(d,c);return t.resolveAll&&i.push(t),d;function f(D){return a=Ms(a,D),S(),a[a.length-1]!==null?[]:(R(t,0),d.events=Bv(i,d.events,d),d.events)}function p(D,L){return c6(h(D),L)}function h(D){return l6(a,D)}function g(){const{_bufferIndex:D,_index:L,line:H,column:M,offset:O}=r;return{_bufferIndex:D,_index:L,line:H,column:M,offset:O}}function b(D){s[D.line]=D.column,K()}function S(){let D;for(;r._index<a.length;){const L=a[r._index];if(typeof L=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<L.length;)y(L.charCodeAt(r._bufferIndex));else y(L)}}function y(D){u=u(D)}function v(D){tt(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,K()):D!==-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=D}function w(D,L){const H=L||{};return H.type=D,H.start=g(),d.events.push(["enter",H,d]),l.push(H),H}function j(D){const L=l.pop();return L.end=g(),d.events.push(["exit",L,d]),L}function E(D,L){R(D,L.from)}function k(D,L){L.restore()}function I(D,L){return H;function H(M,O,A){let z,_,T,C;return Array.isArray(M)?Z(M):"tokenize"in M?Z([M]):G(M);function G(ue){return de;function de(ce){const fe=ce!==null&&ue[ce],re=ce!==null&&ue.null,pe=[...Array.isArray(fe)?fe:fe?[fe]:[],...Array.isArray(re)?re:re?[re]:[]];return Z(pe)(ce)}}function Z(ue){return z=ue,_=0,ue.length===0?A:W(ue[_])}function W(ue){return de;function de(ce){return C=$(),T=ue,ue.partial||(d.currentConstruct=ue),ue.name&&d.parser.constructs.disable.null.includes(ue.name)?le():ue.tokenize.call(L?Object.assign(Object.create(d),L):d,c,te,le)(ce)}}function te(ue){return D(T,C),O}function le(ue){return C.restore(),++_<z.length?W(z[_]):A}}}function R(D,L){D.resolveAll&&!i.includes(D)&&i.push(D),D.resolve&&Vi(d.events,L,d.events.length-L,D.resolve(d.events.slice(L),d)),D.resolveTo&&(d.events=D.resolveTo(d.events,d))}function $(){const D=g(),L=d.previous,H=d.currentConstruct,M=d.events.length,O=Array.from(l);return{from:M,restore:A};function A(){r=D,d.previous=L,d.currentConstruct=H,d.events.length=M,l=O,K()}}function K(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function l6(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 c6(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 u6(e){const r={constructs:y5([o6,...(e||{}).extensions||[]]),content:s(j5),defined:[],document:s(E5),flow:s(VH),lazy:{},string:s(YH),text:s(GH)};return r;function s(i){return a;function a(l){return a6(r,i,l)}}}function d6(e){for(;!HP(e););return e}const AS=/[\0\t\n\r]/g;function f6(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let d,u,f,p,h;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),f=0,t="",n&&(i.charCodeAt(0)===65279&&f++,n=void 0);f<i.length;){if(AS.lastIndex=f,d=AS.exec(i),p=d&&d.index!==void 0?d.index:i.length,h=i.charCodeAt(p),!d){t=i.slice(f);break}if(h===10&&f===p&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<p&&(c.push(i.slice(f,p)),e+=p-f),h){case 0:{c.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,c.push(-2);e++<u;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const p6=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function h6(e){return e.replace(p6,m6)}function m6(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return DP(n.slice(i?2:1),i?16:10)}return zv(n)||e}const YP={}.hasOwnProperty;function g6(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),y6(n)(d6(u6(n).document().write(f6()(e,t,!0))))}function y6(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Te),autolinkProtocol:$,autolinkEmail:$,atxHeading:i(lt),blockQuote:i(re),characterEscape:$,characterReference:$,codeFenced:i(pe),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(pe,a),codeText:i(ae,a),codeTextData:$,data:$,codeFlowValue:$,definition:i(ye),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(Be),hardBreakEscape:i(Ge),hardBreakTrailing:i(Ge),htmlFlow:i(_t,a),htmlFlowData:$,htmlText:i(_t,a),htmlTextData:$,image:i(Pt),label:a,link:i(Te),listItem:i(Fn),listItemValue:p,listOrdered:i(an,f),listUnordered:i(an),paragraph:i(qt),reference:W,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(lt),strong:i(_n),thematicBreak:i(fr)},exit:{atxHeading:c(),atxHeadingSequence:E,autolink:c(),autolinkEmail:fe,autolinkProtocol:ce,blockQuote:c(),characterEscapeValue:K,characterReferenceMarkerHexadecimal:le,characterReferenceMarkerNumeric:le,characterReferenceValue:ue,characterReference:de,codeFenced:c(S),codeFencedFence:b,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:K,codeIndented:c(y),codeText:c(O),codeTextData:K,data:K,definition:c(),definitionDestinationString:j,definitionLabelString:v,definitionTitleString:w,emphasis:c(),hardBreakEscape:c(L),hardBreakTrailing:c(L),htmlFlow:c(H),htmlFlowData:K,htmlText:c(M),htmlTextData:K,image:c(z),label:T,labelText:_,lineEnding:D,link:c(A),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:te,resourceDestinationString:C,resourceTitleString:G,resource:Z,setextHeading:c(R),setextHeadingLineSequence:I,setextHeadingText:k,strong:c(),thematicBreak:c()}};GP(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){let xe={type:"root",children:[]};const Ve={stack:[xe],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:u,data:n},Ze=[];let Xe=-1;for(;++Xe<ie.length;)if(ie[Xe][1].type==="listOrdered"||ie[Xe][1].type==="listUnordered")if(ie[Xe][0]==="enter")Ze.push(Xe);else{const At=Ze.pop();Xe=s(ie,At,Xe)}for(Xe=-1;++Xe<ie.length;){const At=t[ie[Xe][0]];YP.call(At,ie[Xe][1].type)&&At[ie[Xe][1].type].call(Object.assign({sliceSerialize:ie[Xe][2].sliceSerialize},Ve),ie[Xe][1])}if(Ve.tokenStack.length>0){const At=Ve.tokenStack[Ve.tokenStack.length-1];(At[1]||IS).call(Ve,void 0,At[0])}for(xe.position={start:Ho(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:Ho(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe<t.transforms.length;)xe=t.transforms[Xe](xe)||xe;return xe}function s(ie,xe,Ve){let Ze=xe-1,Xe=-1,At=!1,On,Dt,Mn,Yt;for(;++Ze<=Ve;){const Gt=ie[Ze];switch(Gt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Gt[0]==="enter"?Xe++:Xe--,Yt=void 0;break}case"lineEndingBlank":{Gt[0]==="enter"&&(On&&!Yt&&!Xe&&!Mn&&(Mn=Ze),Yt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Yt=void 0}if(!Xe&&Gt[0]==="enter"&&Gt[1].type==="listItemPrefix"||Xe===-1&&Gt[0]==="exit"&&(Gt[1].type==="listUnordered"||Gt[1].type==="listOrdered")){if(On){let rr=Ze;for(Dt=void 0;rr--;){const he=ie[rr];if(he[1].type==="lineEnding"||he[1].type==="lineEndingBlank"){if(he[0]==="exit")continue;Dt&&(ie[Dt][1].type="lineEndingBlank",At=!0),he[1].type="lineEnding",Dt=rr}else if(!(he[1].type==="linePrefix"||he[1].type==="blockQuotePrefix"||he[1].type==="blockQuotePrefixWhitespace"||he[1].type==="blockQuoteMarker"||he[1].type==="listItemIndent"))break}Mn&&(!Dt||Mn<Dt)&&(On._spread=!0),On.end=Object.assign({},Dt?ie[Dt][1].start:Gt[1].end),ie.splice(Dt||Ze,0,["exit",On,Gt[2]]),Ze++,Ve++}if(Gt[1].type==="listItemPrefix"){const rr={type:"listItem",_spread:!1,start:Object.assign({},Gt[1].start),end:void 0};On=rr,ie.splice(Ze,0,["enter",rr,Gt[2]]),Ze++,Ve++,Mn=void 0,Yt=!0}}}return ie[xe][1]._spread=At,Ve}function i(ie,xe){return Ve;function Ve(Ze){l.call(this,ie(Ze),Ze),xe&&xe.call(this,Ze)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ie,xe,Ve){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([xe,Ve||void 0]),ie.position={start:Ho(xe.start),end:void 0}}function c(ie){return xe;function xe(Ve){ie&&ie.call(this,Ve),d.call(this,Ve)}}function d(ie,xe){const Ve=this.stack.pop(),Ze=this.tokenStack.pop();if(Ze)Ze[0].type!==ie.type&&(xe?xe.call(this,ie,Ze[0]):(Ze[1]||IS).call(this,ie,Ze[0]));else throw new Error("Cannot close `"+ie.type+"` ("+td({start:ie.start,end:ie.end})+"): it’s not open");Ve.position.end=Ho(ie.end)}function u(){return m5(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(ie){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=ie}function g(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=ie}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie.replace(/(\r?\n|\r)$/g,"")}function v(ie){const xe=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=xe,Ve.identifier=pc(this.sliceSerialize(ie)).toLowerCase()}function w(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ie}function j(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ie}function E(ie){const xe=this.stack[this.stack.length-1];if(!xe.depth){const Ve=this.sliceSerialize(ie).length;xe.depth=Ve}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function I(ie){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function $(ie){const Ve=this.stack[this.stack.length-1].children;let Ze=Ve[Ve.length-1];(!Ze||Ze.type!=="text")&&(Ze=jr(),Ze.position={start:Ho(ie.start),end:void 0},Ve.push(Ze)),this.stack.push(Ze)}function K(ie){const xe=this.stack.pop();xe.value+=this.sliceSerialize(ie),xe.position.end=Ho(ie.end)}function D(ie){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ve=xe.children[xe.children.length-1];Ve.position.end=Ho(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&($.call(this,ie),K.call(this,ie))}function L(){this.data.atHardBreak=!0}function H(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie}function M(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie}function O(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ie}function A(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=xe,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function z(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=xe,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function _(ie){const xe=this.sliceSerialize(ie),Ve=this.stack[this.stack.length-2];Ve.label=h6(xe),Ve.identifier=pc(xe).toLowerCase()}function T(){const ie=this.stack[this.stack.length-1],xe=this.resume(),Ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ve.type==="link"){const Ze=ie.children;Ve.children=Ze}else Ve.alt=xe}function C(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ie}function G(){const ie=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ie}function Z(){this.data.inReference=void 0}function W(){this.data.referenceType="collapsed"}function te(ie){const xe=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=xe,Ve.identifier=pc(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function le(ie){this.data.characterReferenceType=ie.type}function ue(ie){const xe=this.sliceSerialize(ie),Ve=this.data.characterReferenceType;let Ze;Ve?(Ze=DP(xe,Ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ze=zv(xe);const Xe=this.stack[this.stack.length-1];Xe.value+=Ze}function de(ie){const xe=this.stack.pop();xe.position.end=Ho(ie.end)}function ce(ie){K.call(this,ie);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(ie)}function fe(ie){K.call(this,ie);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(ie)}function re(){return{type:"blockquote",children:[]}}function pe(){return{type:"code",lang:null,meta:null,value:""}}function ae(){return{type:"inlineCode",value:""}}function ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Be(){return{type:"emphasis",children:[]}}function lt(){return{type:"heading",depth:0,children:[]}}function Ge(){return{type:"break"}}function _t(){return{type:"html",value:""}}function Pt(){return{type:"image",title:null,url:"",alt:null}}function Te(){return{type:"link",title:null,url:"",children:[]}}function an(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function Fn(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function qt(){return{type:"paragraph",children:[]}}function _n(){return{type:"strong",children:[]}}function jr(){return{type:"text",value:""}}function fr(){return{type:"thematicBreak"}}}function Ho(e){return{line:e.line,column:e.column,offset:e.offset}}function GP(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?GP(e,r):x6(e,r)}}function x6(e,t){let n;for(n in t)if(YP.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 IS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+td({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+td({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+td({start:t.start,end:t.end})+") is still open")}function w6(e){const t=this;t.parser=n;function n(r){return g6(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function v6(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 b6(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function k6(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 S6(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function N6(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function j6(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=zc(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 C6(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 E6(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function XP(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 _6(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return XP(e,t);const s={src:zc(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 P6(e,t){const n={src:zc(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function A6(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 I6(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return XP(e,t);const s={href:zc(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 T6(e,t){const n={href:zc(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function R6(e,t,n){const r=e.all(t),s=n?L6(n):JP(t),i={},a=[];if(typeof t.checked=="boolean"){const u=r[0];let f;u&&u.type==="element"&&u.tagName==="p"?f=u:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const u=r[l];(s||l!==0||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),u.type==="element"&&u.tagName==="p"&&!s?a.push(...u.children):a.push(u)}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 L6(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=JP(n[r])}return t}function JP(e){const t=e.spread;return t??e.children.length>1}function O6(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 M6(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $6(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function D6(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function F6(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=Mv(t.children[1]),c=IP(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 z6(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 f=t.children[c],p={},h=a?a[c]:void 0;h&&(p.align=h);let g={type:"element",tagName:i,properties:p,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),d.push(g)}const u={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,u),e.applyData(t,u)}function B6(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const TS=9,RS=32;function H6(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(LS(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(LS(t.slice(s),s>0,!1)),i.join("")}function LS(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===TS||i===RS;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===TS||i===RS;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function U6(e,t){const n={type:"text",value:H6(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function W6(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const V6={blockquote:v6,break:b6,code:k6,delete:S6,emphasis:N6,footnoteReference:j6,heading:C6,html:E6,imageReference:_6,image:P6,inlineCode:A6,linkReference:I6,link:T6,listItem:R6,list:O6,paragraph:M6,root:$6,strong:D6,table:F6,tableCell:B6,tableRow:z6,text:U6,thematicBreak:W6,toml:yp,yaml:yp,definition:yp,footnoteDefinition:yp};function yp(){}const QP=-1,Mm=0,rd=1,$h=2,Uv=3,Wv=4,Vv=5,Kv=6,ZP=7,eA=8,OS=typeof self=="object"?self:globalThis,K6=(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 Mm:case QP:return n(a,s);case rd:{const l=n([],s);for(const c of a)l.push(r(c));return l}case $h:{const l=n({},s);for(const[c,d]of a)l[r(c)]=r(d);return l}case Uv:return n(new Date(a),s);case Wv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case Vv:{const l=n(new Map,s);for(const[c,d]of a)l.set(r(c),r(d));return l}case Kv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case ZP:{const{name:l,message:c}=a;return n(new OS[l](c),s)}case eA: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 OS[i](a),s)};return r},MS=e=>K6(new Map,e)(0),Il="",{toString:q6}={},{keys:Y6}=Object,Eu=e=>{const t=typeof e;if(t!=="object"||!e)return[Mm,t];const n=q6.call(e).slice(8,-1);switch(n){case"Array":return[rd,Il];case"Object":return[$h,Il];case"Date":return[Uv,Il];case"RegExp":return[Wv,Il];case"Map":return[Vv,Il];case"Set":return[Kv,Il];case"DataView":return[rd,n]}return n.includes("Array")?[rd,n]:n.includes("Error")?[ZP,n]:[$h,n]},xp=([e,t])=>e===Mm&&(t==="function"||t==="symbol"),G6=(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]=Eu(a);switch(l){case Mm:{let u=a;switch(c){case"bigint":l=eA,u=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);u=null;break;case"undefined":return s([QP],a)}return s([l,u],a)}case rd:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const u=[],f=s([l,u],a);for(const p of a)u.push(i(p));return f}case $h:{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 u=[],f=s([l,u],a);for(const p of Y6(a))(e||!xp(Eu(a[p])))&&u.push([i(p),i(a[p])]);return f}case Uv:return s([l,a.toISOString()],a);case Wv:{const{source:u,flags:f}=a;return s([l,{source:u,flags:f}],a)}case Vv:{const u=[],f=s([l,u],a);for(const[p,h]of a)(e||!(xp(Eu(p))||xp(Eu(h))))&&u.push([i(p),i(h)]);return f}case Kv:{const u=[],f=s([l,u],a);for(const p of a)(e||!xp(Eu(p)))&&u.push(i(p));return f}}const{message:d}=a;return s([l,{name:c,message:d}],a)};return i},$S=(e,{json:t,lossy:n}={})=>{const r=[];return G6(!(t||n),!!t,new Map,r)(e),r},Dh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?MS($S(e,t)):structuredClone(e):(e,t)=>MS($S(e,t));function X6(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 J6(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Q6(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||X6,r=e.options.footnoteBackLabel||J6,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 u=e.all(d),f=String(d.identifier).toUpperCase(),p=zc(f.toLowerCase());let h=0;const g=[],b=e.footnoteCounts.get(f);for(;b!==void 0&&++h<=b;){g.length>0&&g.push({type:"text",value:" "});let v=typeof n=="string"?n:n(c,h);typeof v=="string"&&(v={type:"text",value:v}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const S=u[u.length-1];if(S&&S.type==="element"&&S.tagName==="p"){const v=S.children[S.children.length-1];v&&v.type==="text"?v.value+=" ":S.children.push({type:"text",value:" "}),S.children.push(...g)}else u.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(u,!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:{...Dh(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 tA=function(e){if(e==null)return n8;if(typeof e=="function")return $m(e);if(typeof e=="object")return Array.isArray(e)?Z6(e):e8(e);if(typeof e=="string")return t8(e);throw new Error("Expected function, string, or object as test")};function Z6(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=tA(e[n]);return $m(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function e8(e){const t=e;return $m(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function t8(e){return $m(t);function t(n){return n&&n.type===e}}function $m(e){return t;function t(n,r,s){return!!(r8(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function n8(){return!0}function r8(e){return e!==null&&typeof e=="object"&&"type"in e}const nA=[],s8=!0,DS=!1,i8="skip";function o8(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=tA(s),a=r?-1:1;l(e,void 0,[])();function l(c,d,u){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=nA,g,b,S;if((!t||i(c,d,u[u.length-1]||void 0))&&(h=a8(n(c,u)),h[0]===DS))return h;if("children"in c&&c.children){const y=c;if(y.children&&h[0]!==i8)for(b=(r?y.children.length:-1)+a,S=u.concat(y);b>-1&&b<y.children.length;){const v=y.children[b];if(g=l(v,b,S)(),g[0]===DS)return g;b=typeof g[1]=="number"?g[1]:b+a}}return h}}}function a8(e){return Array.isArray(e)?e:typeof e=="number"?[s8,e]:e==null?nA:[e]}function rA(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),o8(e,i,l,s);function l(c,d){const u=d[d.length-1],f=u?u.children.indexOf(c):void 0;return a(c,f,u)}}const Zx={}.hasOwnProperty,l8={};function c8(e,t){const n=t||l8,r=new Map,s=new Map,i=new Map,a={...V6,...n.handlers},l={all:d,applyData:d8,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:u8,wrap:p8};return rA(e,function(u){if(u.type==="definition"||u.type==="footnoteDefinition"){const f=u.type==="definition"?r:s,p=String(u.identifier).toUpperCase();f.has(p)||f.set(p,u)}}),l;function c(u,f){const p=u.type,h=l.handlers[p];if(Zx.call(l.handlers,p)&&h)return h(l,u,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in u){const{children:b,...S}=u,y=Dh(S);return y.children=l.all(u),y}return Dh(u)}return(l.options.unknownHandler||f8)(l,u,f)}function d(u){const f=[];if("children"in u){const p=u.children;let h=-1;for(;++h<p.length;){const g=l.one(p[h],u);if(g){if(h&&p[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=FS(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=FS(b.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function u8(e,t){e.position&&(t.position=qB(e))}function d8(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,Dh(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function f8(e,t){const n=t.data||{},r="value"in t&&!(Zx.call(n,"hProperties")||Zx.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 p8(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 FS(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function zS(e,t){const n=c8(e,t),r=n.one(e,void 0),s=Q6(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 h8(e,t){return e&&"run"in e?async function(n,r){const s=zS(n,{file:r,...t});await e.run(s,r)}:function(n,r){return zS(n,{file:r,...e||t})}}function BS(e){if(e)throw e}var Xp=Object.prototype.hasOwnProperty,sA=Object.prototype.toString,HS=Object.defineProperty,US=Object.getOwnPropertyDescriptor,WS=function(t){return typeof Array.isArray=="function"?Array.isArray(t):sA.call(t)==="[object Array]"},VS=function(t){if(!t||sA.call(t)!=="[object Object]")return!1;var n=Xp.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Xp.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||Xp.call(t,s)},KS=function(t,n){HS&&n.name==="__proto__"?HS(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},qS=function(t,n){if(n==="__proto__")if(Xp.call(t,n)){if(US)return US(t,n).value}else return;return t[n]},m8=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,d=arguments.length,u=!1;for(typeof l=="boolean"&&(u=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=qS(l,n),s=qS(t,n),l!==s&&(u&&s&&(VS(s)||(i=WS(s)))?(i?(i=!1,a=r&&WS(r)?r:[]):a=r&&VS(r)?r:{},KS(l,{name:n,newValue:e(u,a,s)})):typeof s<"u"&&KS(l,{name:n,newValue:s}));return l};const ny=xa(m8);function ew(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 g8(){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 u=e[++i];let f=-1;if(c){a(c);return}for(;++f<s.length;)(d[f]===null||d[f]===void 0)&&(d[f]=s[f]);s=d,u?y8(u,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 y8(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 u=d;if(l&&n)throw u;return s(u)}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 Ai={basename:x8,dirname:w8,extname:v8,join:b8,sep:"/"};function x8(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');lf(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 w8(e){if(lf(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 v8(e){lf(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 b8(...e){let t=-1,n;for(;++t<e.length;)lf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":k8(n)}function k8(e){lf(e);const t=e.codePointAt(0)===47;let n=S8(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function S8(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 lf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const N8={cwd:j8};function j8(){return"/"}function tw(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function C8(e){if(typeof e=="string")e=new URL(e);else if(!tw(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 E8(e)}function E8(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 ry=["history","path","basename","stem","extname","dirname"];class iA{constructor(t){let n;t?tw(t)?n={path:t}:typeof t=="string"||_8(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":N8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<ry.length;){const i=ry[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)ry.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?Ai.basename(this.path):void 0}set basename(t){iy(t,"basename"),sy(t,"basename"),this.path=Ai.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ai.dirname(this.path):void 0}set dirname(t){YS(this.basename,"dirname"),this.path=Ai.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ai.extname(this.path):void 0}set extname(t){if(sy(t,"extname"),YS(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=Ai.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){tw(t)&&(t=C8(t)),iy(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ai.basename(this.path,this.extname):void 0}set stem(t){iy(t,"stem"),sy(t,"stem"),this.path=Ai.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 Or(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 sy(e,t){if(e&&e.includes(Ai.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ai.sep+"`")}function iy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function YS(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function _8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const P8=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},A8={}.hasOwnProperty;class qv extends P8{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=g8()}copy(){const t=new qv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ny(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(ly("data",this.frozen),this.namespace[t]=n,this):A8.call(this.namespace,t)&&this.namespace[t]||void 0:t?(ly("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const s=n.call(t,...r);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=wp(t),r=this.parser||this.Parser;return oy("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),oy("process",this.parser||this.Parser),ay("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=wp(t),c=r.parse(l);r.run(c,l,function(u,f,p){if(u||!f||!p)return d(u);const h=f,g=r.stringify(h,p);R8(g)?p.value=g:p.result=g,d(u,p)});function d(u,f){u||!f?a(u):i?i(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),oy("processSync",this.parser||this.Parser),ay("processSync",this.compiler||this.Compiler),this.process(t,s),XS("processSync","process",n),r;function s(i,a){n=!0,BS(i),r=a}}run(t,n,r){GS(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=wp(n);s.run(t,c,d);function d(u,f,p){const h=f||t;u?l(u):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),XS("runSync","run",r),s;function i(a,l){BS(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=wp(n),s=this.compiler||this.Compiler;return ay("stringify",s),GS(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(ly("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[u,...f]=d;c(u,f)}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=ny(!0,s.settings,d.settings))}function l(d){let u=-1;if(d!=null)if(Array.isArray(d))for(;++u<d.length;){const f=d[u];i(f)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function c(d,u){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===d){p=f;break}if(p===-1)r.push([d,...u]);else if(u.length>0){let[h,...g]=u;const b=r[p][1];ew(b)&&ew(h)&&(h=ny(!0,b,h)),r[p]=[d,h,...g]}}}}const I8=new qv().freeze();function oy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ay(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ly(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 GS(e){if(!ew(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function XS(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function wp(e){return T8(e)?e:new iA(e)}function T8(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function R8(e){return typeof e=="string"||L8(e)}function L8(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const O8="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",JS=[],QS={allowDangerousHtml:!0},M8=/^(https?|ircs?|mailto|xmpp)$/i,$8=[{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 cf(e){const t=D8(e),n=F8(e);return z8(t.runSync(t.parse(n),n),e)}function D8(e){const t=e.rehypePlugins||JS,n=e.remarkPlugins||JS,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...QS}:QS;return I8().use(w6).use(n).use(h8,r).use(t)}function F8(e){const t=e.children||"",n=new iA;return typeof t=="string"&&(n.value=t),n}function z8(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||B8;for(const u of $8)Object.hasOwn(t,u.from)&&(""+u.from+(u.to?"use `"+u.to+"` instead":"remove it")+O8+u.id,void 0);return rA(e,d),QB(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(u,f,p){if(u.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:u.value},f;if(u.type==="element"){let h;for(h in Zg)if(Object.hasOwn(Zg,h)&&Object.hasOwn(u.properties,h)){const g=u.properties[h],b=Zg[h];(b===null||b.includes(u.tagName))&&(u.properties[h]=c(String(g||""),h,u))}}if(u.type==="element"){let h=n?!n.includes(u.tagName):i?i.includes(u.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(u,f,p)),h&&p&&typeof f=="number")return l&&u.children?p.children.splice(f,1,...u.children):p.children.splice(f,1),f}}}function B8(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||M8.test(e.slice(0,t))?e:""}function H8(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Fh(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Fh(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Fh(t[r])}`).join(",")}}`}function ZS(e){return Fh({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 $d(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function eN(e){return Fh({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 tN(e,t){return!H8(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function nN(e,t=!1){const n=new Map;for(const r of e){const s=$d(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function U8(e,t,n,r){const s=new Map(e.map(v=>[v.id,v])),i=new Set(n.map(v=>v.id)),a=new Set,l=[],c=[],d=n.map(v=>{const w=s.get(v.id);return w?ZS(w)===ZS(v)?(a.add(v.id),w):(c.push(v.id),tN(v,w)):(l.push(v.id),v)}),u=nN(t),f=nN(r,!0),p=new Set,h=[],g=[],b=r.map(v=>{const w=$d(v),j=u.get(w);return j?eN(j)===eN(v)?(p.add(w),j):(g.push(w),tN(v,j)):(h.push(w),v)}),S=e.filter(v=>!i.has(v.id)).map(v=>v.id),y=t.map(v=>$d(v)).filter(v=>!f.has(v));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:c,removedNodeIds:S,addedEdgeKeys:h,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:S.length,nodeReused:a.size,edgeAdded:h.length,edgeRemoved:y.length,edgeReused:p.size,nextEdgeCount:f.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function oA(e){return typeof e>"u"||e===null}function W8(e){return typeof e=="object"&&e!==null}function V8(e){return Array.isArray(e)?e:oA(e)?[]:[e]}function K8(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 q8(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function Y8(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var G8=oA,X8=W8,J8=V8,Q8=q8,Z8=Y8,e9=K8,tr={isNothing:G8,isObject:X8,toArray:J8,repeat:Q8,isNegativeZero:Z8,extend:e9};function aA(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 Dd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=aA(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Dd.prototype=Object.create(Error.prototype);Dd.prototype.constructor=Dd;Dd.prototype.toString=function(t){return this.name+": "+aA(this,t)};var Br=Dd;function cy(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 uy(e,t){return tr.repeat(" ",t-e.length)+e}function t9(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,u=Math.min(e.line+t.linesAfter,s.length).toString().length,f=t.maxLength-(t.indent+u+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)d=cy(e.buffer,r[a-c],s[a-c],e.position-(r[a]-r[a-c]),f),l=tr.repeat(" ",t.indent)+uy((e.line-c+1).toString(),u)+" | "+d.str+`
82
- `+l;for(d=cy(e.buffer,r[a],s[a],e.position,f),l+=tr.repeat(" ",t.indent)+uy((e.line+1).toString(),u)+" | "+d.str+`
83
- `,l+=tr.repeat("-",t.indent+u+3+d.pos)+`^
84
- `,c=1;c<=t.linesAfter&&!(a+c>=s.length);c++)d=cy(e.buffer,r[a+c],s[a+c],e.position-(r[a]-r[a+c]),f),l+=tr.repeat(" ",t.indent)+uy((e.line+c+1).toString(),u)+" | "+d.str+`
85
- `;return l.replace(/\n$/,"")}var n9=t9,r9=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],s9=["scalar","sequence","mapping"];function i9(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function o9(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(r9.indexOf(n)===-1)throw new Br('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=i9(t.styleAliases||null),s9.indexOf(this.kind)===-1)throw new Br('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var kr=o9;function rN(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 a9(){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 nw(e){return this.extend(e)}nw.prototype.extend=function(t){var n=[],r=[];if(t instanceof kr)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 Br("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof kr))throw new Br("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new Br("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 Br("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 kr))throw new Br("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(nw.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=rN(s,"implicit"),s.compiledExplicit=rN(s,"explicit"),s.compiledTypeMap=a9(s.compiledImplicit,s.compiledExplicit),s};var lA=nw,cA=new kr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),uA=new kr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),dA=new kr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),fA=new lA({explicit:[cA,uA,dA]});function l9(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function c9(){return null}function u9(e){return e===null}var pA=new kr("tag:yaml.org,2002:null",{kind:"scalar",resolve:l9,construct:c9,predicate:u9,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function d9(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 f9(e){return e==="true"||e==="True"||e==="TRUE"}function p9(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var hA=new kr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:d9,construct:f9,predicate:p9,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 h9(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function m9(e){return 48<=e&&e<=55}function g9(e){return 48<=e&&e<=57}function y9(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(!h9(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!m9(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!g9(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function x9(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 w9(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!tr.isNegativeZero(e)}var mA=new kr("tag:yaml.org,2002:int",{kind:"scalar",resolve:y9,construct:x9,predicate:w9,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"]}}),v9=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function b9(e){return!(e===null||!v9.test(e)||e[e.length-1]==="_")}function k9(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 S9=/^[-+]?[0-9]+e/;function N9(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(tr.isNegativeZero(e))return"-0.0";return n=e.toString(10),S9.test(n)?n.replace("e",".e"):n}function j9(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||tr.isNegativeZero(e))}var gA=new kr("tag:yaml.org,2002:float",{kind:"scalar",resolve:b9,construct:k9,predicate:j9,represent:N9,defaultStyle:"lowercase"}),yA=fA.extend({implicit:[pA,hA,mA,gA]}),xA=yA,wA=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),vA=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 C9(e){return e===null?!1:wA.exec(e)!==null||vA.exec(e)!==null}function E9(e){var t,n,r,s,i,a,l,c=0,d=null,u,f,p;if(t=wA.exec(e),t===null&&(t=vA.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]&&(u=+t[10],f=+(t[11]||0),d=(u*60+f)*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 _9(e){return e.toISOString()}var bA=new kr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:C9,construct:E9,instanceOf:Date,represent:_9});function P9(e){return e==="<<"||e===null}var kA=new kr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:P9}),Yv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
- \r`;function A9(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=Yv;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 I9(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=Yv,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 T9(e){var t="",n=0,r,s,i=e.length,a=Yv;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 R9(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var SA=new kr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:A9,construct:I9,predicate:R9,represent:T9}),L9=Object.prototype.hasOwnProperty,O9=Object.prototype.toString;function M9(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,O9.call(s)!=="[object Object]")return!1;for(i in s)if(L9.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 $9(e){return e!==null?e:[]}var NA=new kr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:M9,construct:$9}),D9=Object.prototype.toString;function F9(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],D9.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function z9(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 jA=new kr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:F9,construct:z9}),B9=Object.prototype.hasOwnProperty;function H9(e){if(e===null)return!0;var t,n=e;for(t in n)if(B9.call(n,t)&&n[t]!==null)return!1;return!0}function U9(e){return e!==null?e:{}}var CA=new kr("tag:yaml.org,2002:set",{kind:"mapping",resolve:H9,construct:U9}),Gv=xA.extend({implicit:[bA,kA],explicit:[SA,NA,jA,CA]}),ha=Object.prototype.hasOwnProperty,zh=1,EA=2,_A=3,Bh=4,dy=1,W9=2,sN=3,V9=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,K9=/[\x85\u2028\u2029]/,q9=/[,\[\]\{\}]/,PA=/^(?:!|!!|![a-z\-]+!)$/i,AA=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function iN(e){return Object.prototype.toString.call(e)}function zi(e){return e===10||e===13}function Xa(e){return e===9||e===32}function rs(e){return e===9||e===32||e===10||e===13}function ec(e){return e===44||e===91||e===93||e===123||e===125}function Y9(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function G9(e){return e===120?2:e===117?4:e===85?8:0}function X9(e){return 48<=e&&e<=57?e-48:-1}function oN(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 J9(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function IA(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var TA=new Array(256),RA=new Array(256);for(var Tl=0;Tl<256;Tl++)TA[Tl]=oN(Tl)?1:0,RA[Tl]=oN(Tl);function Q9(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Gv,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 LA(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=n9(n),new Br(t,n)}function We(e,t){throw LA(e,t)}function Hh(e,t){e.onWarning&&e.onWarning.call(null,LA(e,t))}var aN={YAML:function(t,n,r){var s,i,a;t.version!==null&&We(t,"duplication of %YAML directive"),r.length!==1&&We(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&We(t,"ill-formed argument of the YAML directive"),i=parseInt(s[1],10),a=parseInt(s[2],10),i!==1&&We(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&Hh(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,i;r.length!==2&&We(t,"TAG directive accepts exactly two arguments"),s=r[0],i=r[1],PA.test(s)||We(t,"ill-formed tag handle (first argument) of the TAG directive"),ha.call(t.tagMap,s)&&We(t,'there is a previously declared suffix for "'+s+'" tag handle'),AA.test(i)||We(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{We(t,"tag prefix is malformed: "+i)}t.tagMap[s]=i}};function ua(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||We(e,"expected valid JSON character");else V9.test(l)&&We(e,"the stream contains non-printable characters");e.result+=l}}function lN(e,t,n,r){var s,i,a,l;for(tr.isObject(n)||We(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],ha.call(t,i)||(IA(t,i,n[i]),r[i]=!0)}function tc(e,t,n,r,s,i,a,l,c){var d,u;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,u=s.length;d<u;d+=1)Array.isArray(s[d])&&We(e,"nested arrays are not supported inside keys"),typeof s=="object"&&iN(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&iN(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,u=i.length;d<u;d+=1)lN(e,t,i[d],n);else lN(e,t,i,n);else!e.json&&!ha.call(n,s)&&ha.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,We(e,"duplicated mapping key")),IA(t,s,i),delete n[s];return t}function Xv(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++):We(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function Yn(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;Xa(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(zi(s))for(Xv(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&&Hh(e,"deficient indentation"),r}function Dm(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||rs(n)))}function Jv(e,t){t===1?e.result+=" ":t>1&&(e.result+=tr.repeat(`
88
- `,t-1))}function Z9(e,t,n){var r,s,i,a,l,c,d,u,f=e.kind,p=e.result,h;if(h=e.input.charCodeAt(e.position),rs(h)||ec(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96||(h===63||h===45)&&(s=e.input.charCodeAt(e.position+1),rs(s)||n&&ec(s)))return!1;for(e.kind="scalar",e.result="",i=a=e.position,l=!1;h!==0;){if(h===58){if(s=e.input.charCodeAt(e.position+1),rs(s)||n&&ec(s))break}else if(h===35){if(r=e.input.charCodeAt(e.position-1),rs(r))break}else{if(e.position===e.lineStart&&Dm(e)||n&&ec(h))break;if(zi(h))if(c=e.line,d=e.lineStart,u=e.lineIndent,Yn(e,!1,-1),e.lineIndent>=t){l=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=c,e.lineStart=d,e.lineIndent=u;break}}l&&(ua(e,i,a,!1),Jv(e,e.line-c),i=a=e.position,l=!1),Xa(h)||(a=e.position+1),h=e.input.charCodeAt(++e.position)}return ua(e,i,a,!1),e.result?!0:(e.kind=f,e.result=p,!1)}function eU(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(ua(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 zi(n)?(ua(e,r,s,!0),Jv(e,Yn(e,!1,t)),r=s=e.position):e.position===e.lineStart&&Dm(e)?We(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);We(e,"unexpected end of the stream within a single quoted scalar")}function tU(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 ua(e,n,e.position,!0),e.position++,!0;if(l===92){if(ua(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),zi(l))Yn(e,!1,t);else if(l<256&&TA[l])e.result+=RA[l],e.position++;else if((a=G9(l))>0){for(s=a,i=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=Y9(l))>=0?i=(i<<4)+a:We(e,"expected hexadecimal character");e.result+=J9(i),e.position++}else We(e,"unknown escape sequence");n=r=e.position}else zi(l)?(ua(e,n,r,!0),Jv(e,Yn(e,!1,t)),n=r=e.position):e.position===e.lineStart&&Dm(e)?We(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}We(e,"unexpected end of the stream within a double quoted scalar")}function nU(e,t){var n=!0,r,s,i,a=e.tag,l,c=e.anchor,d,u,f,p,h,g=Object.create(null),b,S,y,v;if(v=e.input.charCodeAt(e.position),v===91)u=93,h=!1,l=[];else if(v===123)u=125,h=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),v=e.input.charCodeAt(++e.position);v!==0;){if(Yn(e,!0,t),v=e.input.charCodeAt(e.position),v===u)return e.position++,e.tag=a,e.anchor=c,e.kind=h?"mapping":"sequence",e.result=l,!0;n?v===44&&We(e,"expected the node content, but found ','"):We(e,"missed comma between flow collection entries"),S=b=y=null,f=p=!1,v===63&&(d=e.input.charCodeAt(e.position+1),rs(d)&&(f=p=!0,e.position++,Yn(e,!0,t))),r=e.line,s=e.lineStart,i=e.position,Ic(e,t,zh,!1,!0),S=e.tag,b=e.result,Yn(e,!0,t),v=e.input.charCodeAt(e.position),(p||e.line===r)&&v===58&&(f=!0,v=e.input.charCodeAt(++e.position),Yn(e,!0,t),Ic(e,t,zh,!1,!0),y=e.result),h?tc(e,l,g,S,b,y,r,s,i):f?l.push(tc(e,null,g,S,b,y,r,s,i)):l.push(b),Yn(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}We(e,"unexpected end of the stream within a flow collection")}function rU(e,t){var n,r,s=dy,i=!1,a=!1,l=t,c=0,d=!1,u,f;if(f=e.input.charCodeAt(e.position),f===124)r=!1;else if(f===62)r=!0;else return!1;for(e.kind="scalar",e.result="";f!==0;)if(f=e.input.charCodeAt(++e.position),f===43||f===45)dy===s?s=f===43?sN:W9:We(e,"repeat of a chomping mode identifier");else if((u=X9(f))>=0)u===0?We(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?We(e,"repeat of an indentation width identifier"):(l=t+u-1,a=!0);else break;if(Xa(f)){do f=e.input.charCodeAt(++e.position);while(Xa(f));if(f===35)do f=e.input.charCodeAt(++e.position);while(!zi(f)&&f!==0)}for(;f!==0;){for(Xv(e),e.lineIndent=0,f=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&f===32;)e.lineIndent++,f=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),zi(f)){c++;continue}if(e.lineIndent<l){s===sN?e.result+=tr.repeat(`
89
- `,i?1+c:c):s===dy&&i&&(e.result+=`
90
- `);break}for(r?Xa(f)?(d=!0,e.result+=tr.repeat(`
91
- `,i?1+c:c)):d?(d=!1,e.result+=tr.repeat(`
92
- `,c+1)):c===0?i&&(e.result+=" "):e.result+=tr.repeat(`
93
- `,c):e.result+=tr.repeat(`
94
- `,i?1+c:c),i=!0,a=!0,c=0,n=e.position;!zi(f)&&f!==0;)f=e.input.charCodeAt(++e.position);ua(e,n,e.position,!1)}return!0}function cN(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,We(e,"tab characters must not be used in indentation")),!(c!==45||(a=e.input.charCodeAt(e.position+1),!rs(a))));){if(l=!0,e.position++,Yn(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,Ic(e,t,_A,!1,!0),i.push(e.result),Yn(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)We(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 sU(e,t,n){var r,s,i,a,l,c,d=e.tag,u=e.anchor,f={},p=Object.create(null),h=null,g=null,b=null,S=!1,y=!1,v;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=f),v=e.input.charCodeAt(e.position);v!==0;){if(!S&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,We(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),i=e.line,(v===63||v===58)&&rs(r))v===63?(S&&(tc(e,f,p,h,g,null,a,l,c),h=g=b=null),y=!0,S=!0,s=!0):S?(S=!1,s=!0):We(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,v=r;else{if(a=e.line,l=e.lineStart,c=e.position,!Ic(e,n,EA,!1,!0))break;if(e.line===i){for(v=e.input.charCodeAt(e.position);Xa(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),rs(v)||We(e,"a whitespace character is expected after the key-value separator within a block mapping"),S&&(tc(e,f,p,h,g,null,a,l,c),h=g=b=null),y=!0,S=!1,s=!1,h=e.tag,g=e.result;else if(y)We(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=u,!0}else if(y)We(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=u,!0}if((e.line===i||e.lineIndent>t)&&(S&&(a=e.line,l=e.lineStart,c=e.position),Ic(e,t,Bh,!0,s)&&(S?g=e.result:b=e.result),S||(tc(e,f,p,h,g,b,a,l,c),h=g=b=null),Yn(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&v!==0)We(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return S&&tc(e,f,p,h,g,null,a,l,c),y&&(e.tag=d,e.anchor=u,e.kind="mapping",e.result=f),y}function iU(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&&We(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)):We(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!rs(a);)a===33&&(r?We(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),PA.test(s)||We(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),q9.test(i)&&We(e,"tag suffix cannot contain flow indicator characters")}i&&!AA.test(i)&&We(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{We(e,"tag name is malformed: "+i)}return n?e.tag=i:ha.call(e.tagMap,s)?e.tag=e.tagMap[s]+i:s==="!"?e.tag="!"+i:s==="!!"?e.tag="tag:yaml.org,2002:"+i:We(e,'undeclared tag handle "'+s+'"'),!0}function oU(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&We(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!rs(n)&&!ec(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&We(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function aU(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&&!rs(r)&&!ec(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&We(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),ha.call(e.anchorMap,n)||We(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],Yn(e,!0,-1),!0}function Ic(e,t,n,r,s){var i,a,l,c=1,d=!1,u=!1,f,p,h,g,b,S;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=a=l=Bh===n||_A===n,r&&Yn(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;iU(e)||oU(e);)Yn(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||Bh===n)&&(zh===n||EA===n?b=t:b=t+1,S=e.position-e.lineStart,c===1?l&&(cN(e,S)||sU(e,S,b))||nU(e,b)?u=!0:(a&&rU(e,b)||eU(e,b)||tU(e,b)?u=!0:aU(e)?(u=!0,(e.tag!==null||e.anchor!==null)&&We(e,"alias node should not have any properties")):Z9(e,b,zh===n)&&(u=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(u=l&&cN(e,S))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&We(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),f=0,p=e.implicitTypes.length;f<p;f+=1)if(g=e.implicitTypes[f],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(ha.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,h=e.typeMap.multi[e.kind||"fallback"],f=0,p=h.length;f<p;f+=1)if(e.tag.slice(0,h[f].tag.length)===h[f].tag){g=h[f];break}g||We(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&We(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)):We(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||u}function lU(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&&(Yn(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&&!rs(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&We(e,"directive name must not be less than one character in length");a!==0;){for(;Xa(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!zi(a));break}if(zi(a))break;for(n=e.position;a!==0&&!rs(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&Xv(e),ha.call(aN,r)?aN[r](e,r,s):Hh(e,'unknown document directive "'+r+'"')}if(Yn(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,Yn(e,!0,-1)):i&&We(e,"directives end mark is expected"),Ic(e,e.lineIndent-1,Bh,!1,!0),Yn(e,!0,-1),e.checkLineBreaks&&K9.test(e.input.slice(t,e.position))&&Hh(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Dm(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,Yn(e,!0,-1));return}if(e.position<e.length-1)We(e,"end of the stream or a document separator is expected");else return}function OA(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 Q9(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,We(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;)lU(n);return n.documents}function cU(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=OA(e,n);if(typeof t!="function")return r;for(var s=0,i=r.length;s<i;s+=1)t(r[s])}function uU(e,t){var n=OA(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new Br("expected a single document in the stream, but found more")}}var dU=cU,fU=uU,MA={loadAll:dU,load:fU},$A=Object.prototype.toString,DA=Object.prototype.hasOwnProperty,Qv=65279,pU=9,Fd=10,hU=13,mU=32,gU=33,yU=34,rw=35,xU=37,wU=38,vU=39,bU=42,FA=44,kU=45,Uh=58,SU=61,NU=62,jU=63,CU=64,zA=91,BA=93,EU=96,HA=123,_U=124,UA=125,Mr={};Mr[0]="\\0";Mr[7]="\\a";Mr[8]="\\b";Mr[9]="\\t";Mr[10]="\\n";Mr[11]="\\v";Mr[12]="\\f";Mr[13]="\\r";Mr[27]="\\e";Mr[34]='\\"';Mr[92]="\\\\";Mr[133]="\\N";Mr[160]="\\_";Mr[8232]="\\L";Mr[8233]="\\P";var PU=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],AU=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function IU(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&&DA.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[a]=l;return n}function TU(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 Br("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+tr.repeat("0",r-t.length)+t}var RU=1,zd=2;function LU(e){this.schema=e.schema||Gv,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=tr.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=IU(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==='"'?zd:RU,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 uN(e,t){for(var n=tr.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 sw(e,t){return`
98
- `+tr.repeat(" ",e.indent*t)}function OU(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 Wh(e){return e===mU||e===pU}function Bd(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Qv||65536<=e&&e<=1114111}function dN(e){return Bd(e)&&e!==Qv&&e!==hU&&e!==Fd}function fN(e,t,n){var r=dN(e),s=r&&!Wh(e);return(n?r:r&&e!==FA&&e!==zA&&e!==BA&&e!==HA&&e!==UA)&&e!==rw&&!(t===Uh&&!s)||dN(t)&&!Wh(t)&&e===rw||t===Uh&&s}function MU(e){return Bd(e)&&e!==Qv&&!Wh(e)&&e!==kU&&e!==jU&&e!==Uh&&e!==FA&&e!==zA&&e!==BA&&e!==HA&&e!==UA&&e!==rw&&e!==wU&&e!==bU&&e!==gU&&e!==_U&&e!==SU&&e!==NU&&e!==vU&&e!==yU&&e!==xU&&e!==CU&&e!==EU}function $U(e){return!Wh(e)&&e!==Uh}function Fu(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 WA(e){var t=/^\n* /;return t.test(e)}var VA=1,iw=2,KA=3,qA=4,$l=5;function DU(e,t,n,r,s,i,a,l){var c,d=0,u=null,f=!1,p=!1,h=r!==-1,g=-1,b=MU(Fu(e,0))&&$U(Fu(e,e.length-1));if(t||a)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Fu(e,c),!Bd(d))return $l;b=b&&fN(d,u,l),u=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=Fu(e,c),d===Fd)f=!0,h&&(p=p||c-g-1>r&&e[g+1]!==" ",g=c);else if(!Bd(d))return $l;b=b&&fN(d,u,l),u=d}p=p||h&&c-g-1>r&&e[g+1]!==" "}return!f&&!p?b&&!a&&!s(e)?VA:i===zd?$l:iw:n>9&&WA(e)?$l:a?i===zd?$l:iw:p?qA:KA}function FU(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===zd?'""':"''";if(!e.noCompatMode&&(PU.indexOf(t)!==-1||AU.test(t)))return e.quotingType===zd?'"'+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 OU(e,d)}switch(DU(t,l,e.indent,a,c,e.quotingType,e.forceQuotes&&!r,s)){case VA:return t;case iw:return"'"+t.replace(/'/g,"''")+"'";case KA:return"|"+pN(t,e.indent)+hN(uN(t,i));case qA:return">"+pN(t,e.indent)+hN(uN(zU(t,a),i));case $l:return'"'+BU(t)+'"';default:throw new Br("impossible error: invalid scalar style")}}()}function pN(e,t){var n=WA(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 hN(e){return e[e.length-1]===`
103
- `?e.slice(0,-1):e}function zU(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,mN(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
- `:"")+mN(c,t),s=i}return r}function mN(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 BU(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Fu(e,s),r=Mr[n],!r&&Bd(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||TU(n);return t}function HU(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)),(vo(e,t,l,!1,!1)||typeof l>"u"&&vo(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function gN(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)),(vo(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&vo(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=sw(e,t)),e.dump&&Fd===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=i,e.dump=s||"[]"}function UU(e,t,n){var r="",s=e.tag,i=Object.keys(n),a,l,c,d,u;for(a=0,l=i.length;a<l;a+=1)u="",r!==""&&(u+=", "),e.condenseFlow&&(u+='"'),c=i[a],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),vo(e,t,c,!1,!1)&&(e.dump.length>1024&&(u+="? "),u+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),vo(e,t,d,!1,!1)&&(u+=e.dump,r+=u));e.tag=s,e.dump="{"+r+"}"}function WU(e,t,n,r){var s="",i=e.tag,a=Object.keys(n),l,c,d,u,f,p;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new Br("sortKeys must be a boolean or a function");for(l=0,c=a.length;l<c;l+=1)p="",(!r||s!=="")&&(p+=sw(e,t)),d=a[l],u=n[d],e.replacer&&(u=e.replacer.call(n,d,u)),vo(e,t+1,d,!0,!0,!0)&&(f=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,f&&(e.dump&&Fd===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,f&&(p+=sw(e,t)),vo(e,t+1,u,!0,f)&&(e.dump&&Fd===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=i,e.dump=s||"{}"}function yN(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,$A.call(l.represent)==="[object Function]")r=l.represent(t,c);else if(DA.call(l.represent,c))r=l.represent[c](t,c);else throw new Br("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function vo(e,t,n,r,s,i,a){e.tag=null,e.dump=n,yN(e,n,!1)||yN(e,n,!0);var l=$A.call(e.dump),c=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var u=l==="[object Object]"||l==="[object Array]",f,p;if(u&&(f=e.duplicates.indexOf(n),p=f!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(s=!1),p&&e.usedDuplicates[f])e.dump="*ref_"+f;else{if(u&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(WU(e,t,e.dump,s),p&&(e.dump="&ref_"+f+e.dump)):(UU(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?gN(e,t-1,e.dump,s):gN(e,t,e.dump,s),p&&(e.dump="&ref_"+f+e.dump)):(HU(e,t,e.dump),p&&(e.dump="&ref_"+f+" "+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 Br("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 VU(e,t){var n=[],r=[],s,i;for(ow(e,n,r),s=0,i=r.length;s<i;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(i)}function ow(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)ow(e[s],t,n);else for(r=Object.keys(e),s=0,i=r.length;s<i;s+=1)ow(e[r[s]],t,n)}function KU(e,t){t=t||{};var n=new LU(t);n.noRefs||VU(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),vo(n,0,r,!0,!0)?n.dump+`
110
- `:""}var qU=KU,YU={dump:qU};function Zv(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 GU=kr,XU=lA,JU=fA,QU=yA,ZU=xA,eW=Gv,tW=MA.load,nW=MA.loadAll,rW=YU.dump,sW=Br,iW={binary:SA,float:gA,map:dA,null:pA,pairs:jA,set:CA,timestamp:bA,bool:hA,int:mA,merge:kA,omap:NA,seq:uA,str:cA},oW=Zv("safeLoad","load"),aW=Zv("safeLoadAll","loadAll"),lW=Zv("safeDump","dump"),YA={Type:GU,Schema:XU,FAILSAFE_SCHEMA:JU,JSON_SCHEMA:QU,CORE_SCHEMA:ZU,DEFAULT_SCHEMA:eW,load:tW,loadAll:nW,dump:rW,YAMLException:sW,types:iW,safeLoad:oW,safeLoadAll:aW,safeDump:lW};const ma=["requirement","planning","code","test","normal"],aw={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},cW=["agent","control","provide","condition","jump","condition_jump","start","end"];function uW(e){return cW.includes(e)?e:"agent"}function dW(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function fW(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=YA.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=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,d=new Set(Object.keys(s));for(const p of i)p!=null&&p.source&&d.add(String(p.source)),p!=null&&p.target&&d.add(String(p.target));const u=Array.from(d).map(p=>{const h=s[p],g=l[p]&&typeof l[p].x=="number"&&typeof l[p].y=="number"?{x:l[p].x,y:l[p].y}:{x:0,y:0},b=(h==null?void 0:h.definitionId)??p,S=dW(b),y=(h==null?void 0:h.label)!=null?String(h.label):p,v=(h==null?void 0:h.role)!=null?String(h.role).trim():"",w=aw[v]||v,j=ma.includes(w)?w:"normal",E=(h==null?void 0:h.model)!=null?String(h.model).trim():void 0,k=(h==null?void 0:h.body)!=null?String(h.body):"",I=(h==null?void 0:h.script)!=null?String(h.script):"",R=Array.isArray(h==null?void 0:h.images)?h.images:[];return{id:p,type:uW(S),position:g,data:{label:y,definitionId:b,schemaType:S,role:j,model:E||void 0,body:k,images:R,...I.trim()!==""?{script:I}:{}}}}),f=i.filter(p=>(p==null?void 0:p.source)&&(p==null?void 0:p.target)).map((p,h)=>({id:`e-${p.source}-${p.target}-${h}`,source:String(p.source),target:String(p.target),sourceHandle:p.sourceHandle??void 0,targetHandle:p.targetHandle??void 0,markerEnd:{type:cs.ArrowClosed}}));return{nodes:u,edges:f,instances:s,description:c}}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 uf(e,t){var s,i,a,l,c,d,u,f,p;const n=h=>{const g={type:(h==null?void 0:h.type)??"node",name:(h==null?void 0:h.name)??"",value:(h==null?void 0:h.value)??(h==null?void 0:h.default)??""};return(h==null?void 0:h.required)===!0&&(g.required=!0),(h==null?void 0:h.showOnNode)!=null&&(g.showOnNode=!!h.showOnNode),g},r={};for(const h of e){const g=t[h.id]&&typeof t[h.id]=="object"?{...t[h.id]}:{},b=((s=h.data)==null?void 0:s.definitionId)||h.id,S=((i=h.data)==null?void 0:i.inputs)??[],y=((a=h.data)==null?void 0:a.outputs)??[],v=((l=h.data)==null?void 0:l.role)!=null?String(h.data.role).trim():"",w=g.role!=null?String(g.role).trim():"",j=aw[v]||v,E=aw[w]||w,k=ma.includes(j)?j:ma.includes(E)?E:"normal",I=Array.isArray(S)?S.map(n):Array.isArray(g.input)?g.input.map(z=>n(z)):[],R=Array.isArray(y)?y.map(n):Array.isArray(g.output)?g.output.map(z=>n(z)):[],$=((c=h.data)==null?void 0:c.label)!=null?String(h.data.label):g.label!=null?String(g.label):h.id,K=(d=h.data)==null?void 0:d.body,D=K!=null?String(K):g.body!=null?String(g.body):"";let L=((u=h.data)==null?void 0:u.model)!=null&&String(h.data.model).trim()!==""?String(h.data.model).trim():g.model!=null&&String(g.model).trim()!==""?String(g.model).trim():void 0;(L===""||L==="default")&&(L=void 0);const H={...g,definitionId:b,label:$,role:k,model:L,input:I,output:R};b.startsWith("provide_")||D.trim()===""?delete H.body:H.body=D;const M=Array.isArray((f=h.data)==null?void 0:f.images)?h.data.images:Array.isArray(g.images)?g.images:[];M.length>0?H.images=M:delete H.images;const O=(p=h.data)==null?void 0:p.script,A=O!=null?String(O):g.script!=null?String(g.script):"";A.trim()===""?delete H.script:H.script=A,delete H.temperature,delete H.maxTokens,delete H.description,r[h.id]=H}return r}function sd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function pW(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 GA(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=>sd(a)),edges:i.map(a=>sd(a)),instances:uf(r,n||{})}}function XA(e,t,n,r,s={}){var f;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,pW(p.id,a));const c=e.nodes.map(p=>{var g,b;const h=l.get(p.id);return{...sd(p),id:h,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,h)=>{const g=l.get(p.source),b=l.get(p.target);return{...sd(p),id:`e-${g}-${b}-${Date.now()}-${h}`,source:g,target:b,selected:!1}}),u={...r||{}};for(const[p,h]of l.entries()){const g=(f=e.instances)==null?void 0:f[p];g&&(u[h]={...sd(g),label:g.label!=null?String(g.label):h})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...c],edges:[...(n||[]).map(p=>({...p,selected:!1})),...d],instances:u,pastedNodeIds:c.map(p=>p.id)}}function xN(e,t,n,r){const s=uf(e,n),i=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),a={};for(const d of e){const u=d.position??{x:0,y:0};a[d.id]={x:u.x,y:u.y}}const l={nodePositions:a};(r==null?void 0:r.description)!=null&&String(r.description).trim()!==""&&(l.description=String(r.description).trim());const c={instances:s,edges:i,ui:l};return YA.dump(c,{lineWidth:-1})}function hW(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 mW(e,t,n){var c,d,u;const r=new Set(e.map(f=>f.id)),s={};for(const f of e)s[f.id]=hW(f);const i=new Map,a=new Map;for(const f of t)f.target&&r.has(f.target)&&(i.has(f.target)||i.set(f.target,new Set),f.targetHandle&&i.get(f.target).add(f.targetHandle)),f.source&&r.has(f.source)&&(a.has(f.source)||a.set(f.source,new Set),f.sourceHandle&&a.get(f.source).add(f.sourceHandle));const l=[];for(const f of e){const p=((c=f.data)==null?void 0:c.definitionId)!=null?String(f.data.definitionId):"",h=s[f.id]||{inputNames:[],outputNames:[]},g=h.inputNames.length,b=h.outputNames.length;if(!(p==="control_start"||p.startsWith("provide_"))&&g>0)for(let v=0;v<g;v++){const w=`input-${v}`;if(!((d=i.get(f.id))==null?void 0:d.has(w))){const E=h.inputNames[v]||w;l.push({nodeId:f.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:E,handle:w}),key:`${f.id}-${w}-in`})}}if(!(p==="control_end")&&b>0)for(let v=0;v<b;v++){const w=`output-${v}`;if(!((u=a.get(f.id))==null?void 0:u.has(w))){const E=h.outputNames[v]||w;l.push({nodeId:f.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:E,handle:w}),key:`${f.id}-${w}-out`})}}}return l}const Vh=/\[image\s+(\d+)\]/gi;function ss(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 gW(e){return`image ${ss(e).length+1}`}function yW(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function xW(e,t){const n=ss(e),r=String(t||""),s=new Set;Vh.lastIndex=0;let i;for(;i=Vh.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function wW(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 JA(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 Kh(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 QA({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=ss(n);for(const a of r){const l=await wW(a),c=gW(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=yW(s,c)}return{body:s,images:i}}function lw(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 vW={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_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"]};function bW(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(vW[e]||[]).includes(s)?r:s}const kW={tool_git_checkout:new Set(["targetDir","pullIfExists","includeSubmodules","workspaceContext","commit","changed"]),control_load_skills:new Set(["mergeMode","workspaceContext","skillsContext","loadedCount","summary"]),agent_subAgent:new Set(["workspaceContext","skillsContext"])},SW={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"])};function wN(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,u;const i=n[s],l=n.find(f=>(f==null?void 0:f.name)&&f.name===r.name)||i;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((d=kW[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"}:{},...(u=SW[e])!=null&&u.has(r.name)?{showOnNode:!1}:{}}})}function ZA(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=lw(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 Hd(e,t,n,r,s){var A,z,_,T,C,G,Z,W,te,le,ue,de,ce,fe,re,pe;const i=((A=e.data)==null?void 0:A.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(ae=>ae.id===i),l=t[e.id];let c=[],d=[],u=((z=e.data)==null?void 0:z.label)??e.id,f,p,h,g,b;const S=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(lw)),Array.isArray(l.output)&&(d=l.output.map(lw)),l.label&&(u=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(b=String(l.script)));const y=f??(typeof((_=e.data)==null?void 0:_.role)=="string"?e.data.role:"普通"),v=p??((T=e.data)==null?void 0:T.model)??void 0,w=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=w!==""?w:void 0,E=h??((C=e.data)==null?void 0:C.body)??"",k=Array.isArray(g)?g:Array.isArray((G=e.data)==null?void 0:G.images)?e.data.images:[],I=b!==void 0?b:((Z=e.data)==null?void 0:Z.script)!=null?String(e.data.script):"",R=String(e.id),$=(W=r==null?void 0:r[s])==null?void 0:W[R],K=(te=$==null?void 0:$.label)==null?void 0:te.label,D=$==null?void 0:$.body,L=$==null?void 0:$.description;S||(c.length===0&&((le=a==null?void 0:a.inputs)!=null&&le.length)&&(c=a.inputs.map(ae=>({...ae}))),d.length===0&&((ue=a==null?void 0:a.outputs)!=null&&ue.length)&&(d=a.outputs.map(ae=>({...ae}))));const H=(a==null?void 0:a.id)??i;if(H==="agent_subAgent"&&!d.some(ae=>(ae==null?void 0:ae.name)==="result")){const ae=(de=a==null?void 0:a.outputs)==null?void 0:de.find(ye=>(ye==null?void 0:ye.name)==="result");d=[...d,ae?{...ae}:{type:"text",name:"result",default:""}]}if((H==="display_markdown"||H==="display_mermaid"||H==="display_ascii")&&!d.some(ae=>(ae==null?void 0:ae.name)==="next")){const ae=(ce=a==null?void 0:a.outputs)==null?void 0:ce.find(ye=>(ye==null?void 0:ye.name)==="next");d=[...d,ae?{...ae}:{type:"node",name:"next",default:""}]}if(H==="workspace_run"){if(!c.some(ae=>(ae==null?void 0:ae.name)==="prev")){const ae=(fe=a==null?void 0:a.inputs)==null?void 0:fe.find(ye=>(ye==null?void 0:ye.name)==="prev");c=[ae?{...ae}:{type:"node",name:"prev",default:""},...c]}if(!d.some(ae=>(ae==null?void 0:ae.name)==="next")){const ae=(re=a==null?void 0:a.outputs)==null?void 0:re.find(ye=>(ye==null?void 0:ye.name)==="next");d=[...d,ae?{...ae}:{type:"node",name:"next",default:""}]}}c=wN(H,c,a==null?void 0:a.inputs),d=wN(H,d,a==null?void 0:a.outputs),H.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(E).trim()!==""&&(d=d.map((ae,ye)=>ye===0?{...ae,default:E,value:E}:ae));const M=bW(H,K||u,a),O=H==="tool_nodejs"||String(I).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:K||u,displayLabel:M,definitionDisplayName:a==null?void 0:a.displayName,definitionId:H,schemaType:((pe=e.data)==null?void 0:pe.schemaType)??e.type??"agent",role:y,model:v,body:D||E,images:k,script:I,inputs:c,outputs:d,description:L||j,originalLabel:u,originalBody:E,...O?{script:I}:{}}}}function eI(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var u,f,p,h;const s=n.get(r.source),i=n.get(r.target),a=((f=(u=s==null?void 0:s.data)==null?void 0:u.outputs)==null?void 0:f.length)??0,l=((h=(p=i==null?void 0:i.data)==null?void 0:p.inputs)==null?void 0:h.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 vN(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 bN(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function qh(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=vN(t==null?void 0:t.sourceHandle,"output"),i=vN(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var d,u,f,p;if(c.id===n){const h=bN((d=c.data)==null?void 0:d.outputs,s);if(h!==((u=c.data)==null?void 0:u.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=bN((f=c.data)==null?void 0:f.inputs,i);if(h!==((p=c.data)==null?void 0:p.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function Kn(e){switch(Yh(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Yh(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 NW(e,t){const n=Yh(e),r=Yh(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const jW=new Set(["workspaceContext","skillsContext"]);function cw(e){const t=Yh(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&jW.has(n)?`${t}+${n}`:t}function tI(e){return cw(e)}function Tc(e,t){if(!e||!t||!NW(e.type,t.type))return!1;const n=cw(e),r=cw(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function CW(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 Rc(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=CW(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 so(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function EW(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 _W(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function PW(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Wn(e){e.stopPropagation()}function AW(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function IW(e,t){const n=`\\[${AW(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
- `).replace(/\n{3,}/g,`
125
-
126
- `).trimEnd()}function fy(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TW(e){const t=String(e||"");let n="",r=0;Vh.lastIndex=0;let s;for(;s=Vh.exec(t);)n+=fy(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${fy(s[0])}</span>`,r=s.index+s[0].length;return n+=fy(t.slice(r)),n||" "}function nI({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var Gt,rr;const{t:u}=on(),f=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],h=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=EW(e),b=_W(g),S=(e==null?void 0:e.isRunMode)??!1,y=(e==null?void 0:e.isExecuting)??!1,v=(e==null?void 0:e.isDim)??!1,w=(e==null?void 0:e.nodeStatus)??null,j=(e==null?void 0:e.nodeElapsed)??null,E=(e==null?void 0:e.definitionId)||"",k=E.startsWith("provide_"),I=E==="provide_bool",R=E==="provide_str",$=E==="provide_file",K=E==="agent_subAgent",D=K&&!S,L=I?PW(p[0]):!1,H=k?String(((Gt=p[0])==null?void 0:Gt.value)??((rr=p[0])==null?void 0:rr.default)??(e==null?void 0:e.body)??""):"",M=String((e==null?void 0:e.body)||""),O=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||u("flow:node.fallbackLabel"),A=!k&&!D&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",z=ss(e==null?void 0:e.images),_=m.useRef(!1),T=m.useRef(!1),C=m.useRef(null),G=m.useRef(null),[Z,W]=m.useState(H),[te,le]=m.useState(M);m.useEffect(()=>{_.current||W(H)},[n,H]),m.useEffect(()=>{T.current||le(M)},[n,M]),m.useEffect(()=>{const he=C.current;if(!he)return;const Ee=Math.min(Math.max(he.scrollHeight,76),220),Wt=he.getBoundingClientRect().height||0;(!he.style.height||Wt<Ee-1)&&(he.style.height=`${Ee}px`)},[te]);const ue=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],de=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],ce=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],fe=((e==null?void 0:e.model)??"").trim(),re=h==="agent"&&!E.startsWith("tool_nodejs"),pe=new Set(ue.map(so)),ae=new Set(de.map(so)),ye=new Set(ce.map(so)),Be=fe?fe.startsWith("cursor:")||fe.startsWith("opencode:")||fe.startsWith("claude-code:")?fe:ye.has(fe)?`claude-code:${fe}`:ae.has(fe)?`opencode:${fe}`:pe.has(fe)?`cursor:${fe}`:fe:"",lt=fe&&!Be.startsWith("cursor:")&&!Be.startsWith("opencode:")&&!Be.startsWith("claude-code:")&&!pe.has(fe)&&!ae.has(fe)&&!ye.has(fe),Ge=fe.startsWith("cursor:")?fe.slice(7):fe.startsWith("opencode:")?fe.slice(9):fe.startsWith("claude-code:")?fe.slice(12):fe,_t=he=>{const Ee=he.target.value;d&&d(n,Ee)},Pt=he=>{he.stopPropagation(),r&&r(n)},Te=he=>{he.stopPropagation(),s&&s()},an=he=>{he.stopPropagation(),i==null||i(n,he.target.value==="true"?"true":"false")},Fn=he=>{he.stopPropagation();const Ee=he.target.value;W(Ee),_.current||i==null||i(n,Ee)},qt=he=>{he.stopPropagation(),_.current=!0},_n=he=>{he.stopPropagation(),_.current=!1;const Ee=he.currentTarget.value;W(Ee),i==null||i(n,Ee)},jr=()=>{i==null||i(n,Z)},fr=he=>{he.stopPropagation();const Ee=window.prompt("文件路径",Z);Ee!=null&&(W(Ee),i==null||i(n,Ee))},ie=he=>{if(le(he),a==null||a(n,he),l){const Ee=xW(z,he);(Ee.length!==z.length||Ee.some((Wt,nt)=>{var hn;return Wt.id!==((hn=z[nt])==null?void 0:hn.id)}))&&l(n,Ee)}},xe=he=>{he.stopPropagation();const Ee=he.target.value;T.current?le(Ee):ie(Ee)},Ve=he=>{he.stopPropagation(),T.current=!0},Ze=he=>{he.stopPropagation(),T.current=!1;const Ee=he.currentTarget.value;ie(Ee)},Xe=()=>{ie(te)},At=async he=>{const Ee=await QA({files:he,body:te,images:z});Ee&&(le(Ee.body),a==null||a(n,Ee.body),l==null||l(n,Ee.images))},On=(he,Ee)=>{he.stopPropagation();const Wt=z.filter(hn=>hn.id!==Ee.id),nt=IW(te,Ee.label);le(nt),a==null||a(n,nt),l==null||l(n,Wt)},Dt=he=>{const Ee=JA(he);Ee.length!==0&&(he.preventDefault(),he.stopPropagation(),At(Ee).catch(()=>{}))},Mn=he=>{const Ee=Kh(he);Ee.length!==0&&(he.preventDefault(),he.stopPropagation(),At(Ee).catch(()=>{}))},Yt=()=>{const he=C.current,Ee=G.current;!he||!Ee||(Ee.scrollTop=he.scrollTop,Ee.scrollLeft=he.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(y?" af-flow-node--executing":"")+(w==="success"?" af-flow-node--done":"")+(w==="failed"?" af-flow-node--failed":"")+(w==="running"&&!y?" af-flow-node--running-disk":"")+(v?" af-flow-node--dim":"")+" af-flow-node--"+h.replace(/[^a-z0-9_-]/g,""),"data-schema":h,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:b}),!S&&re&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:Be,onChange:_t,onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,"aria-label":u("flow:node.model"),title:Ge||u("flow:node.defaultModel"),children:[o.jsx("option",{value:"",children:u("flow:node.defaultModel")}),lt&&o.jsx("option",{value:fe,children:fe}),ue.length>0&&o.jsx("optgroup",{label:"Cursor",children:ue.map(he=>o.jsx("option",{value:`cursor:${so(he)}`,children:so(he)},`c-${he}`))}),de.length>0&&o.jsx("optgroup",{label:"OpenCode",children:de.map(he=>o.jsx("option",{value:`opencode:${so(he)}`,children:so(he)},`o-${he}`))}),ce.length>0&&o.jsx("optgroup",{label:"Claude Code",children:ce.map(he=>o.jsx("option",{value:`claude-code:${so(he)}`,children:so(he)},`cc-${he}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),y&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),w==="running"&&!y&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:u("flow:node.diskRunning"),children:"RUNNING"}),w==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:j!=null&&String(j).trim()!==""?j:"--"}),w==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!S&&k&&!I&&!R&&!$&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Te,"aria-label":u("flow:node.expandProvide"),title:u("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!S&&o.jsx("button",{type:"button",className:"af-flow-node__delete",onClick:Pt,"aria-label":u("flow:node.deleteNode"),title:u("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:f.map((he,Ee)=>{if(he.showOnNode===!1)return null;const Wt=u("flow:node.inputTooltip",{name:he.name||`#${Ee}`,type:he.type})+(he.default!=null&&he.default!==""?u("flow:node.defaultSuffix",{value:he.default}):""),nt=he.name||`#${Ee+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:Wt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[nt,he.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Hs,{type:"target",position:Fe.Left,id:`input-${Ee}`,className:"af-flow-node__handle",style:{background:Kn(he.type)},title:Wt})]},`in-${Ee}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:O}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,I?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(L?" af-flow-node__bool-select--true":""),value:L?"true":"false",onChange:an,onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,"aria-label":"Boolean value",title:L?"true":"false",children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):R?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:Z,onChange:Fn,onCompositionStart:qt,onCompositionEnd:_n,onBlur:jr,onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,placeholder:"输入文本",rows:2}):$?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:Z,onChange:Fn,onCompositionStart:qt,onCompositionEnd:_n,onBlur:jr,placeholder:"选择或输入文件路径",title:Z||"选择或输入文件路径"}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",onClick:fr,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):K&&!S?o.jsxs("div",{className:"af-flow-node__prompt-stack nodrag",onPointerDown:Wn,onMouseDown:Wn,onClick:Wn,children:[o.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:TW(te)+`
127
- `}}),o.jsx("textarea",{ref:C,className:"af-flow-node__prompt-editor nodrag",value:te,onChange:xe,onCompositionStart:Ve,onCompositionEnd:Ze,onBlur:Xe,onPaste:Dt,onDrop:Mn,onScroll:Yt,onDragOver:he=>{Kh(he).length>0&&he.preventDefault()},placeholder:"输入 prompt",rows:2})]}):null,K&&z.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:z.map((he,Ee)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:he.name,children:[o.jsx("img",{src:he.dataUrl,alt:""}),o.jsxs("span",{children:["[",he.label||`image ${Ee+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",onClick:Wt=>On(Wt,he),onPointerDown:Wn,onMouseDown:Wn,"aria-label":`删除 ${he.label||`image ${Ee+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},he.id||Ee))}):null,A?o.jsx("span",{className:"af-flow-node__prompt-preview",title:A,children:A}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((he,Ee)=>{if(he.showOnNode===!1)return null;const Wt=u("flow:node.outputTooltip",{name:he.name||`#${Ee}`,type:he.type})+(he.default!=null&&he.default!==""?u("flow:node.defaultSuffix",{value:he.default}):""),nt=he.name||`#${Ee+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:Wt,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[nt,he.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Hs,{type:"source",position:Fe.Right,id:`output-${Ee}`,className:"af-flow-node__handle",style:{background:Kn(he.type)},title:Wt})]},`out-${Ee}`)})})]})]})}const df="flowNode";function rI(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 Gh(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function RW(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function LW({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=on(),a=m.useId(),l=m.useRef(null),[c,d]=m.useState(""),[u,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),h(""),f(!1);const y=requestAnimationFrame(()=>{var v;return(v=l.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),b=g===n;async function S(y){if(y.preventDefault(),!(!b||u)){f(!0),h("");try{const v=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await v.json().catch(()=>({}));if(!v.ok){h(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(v){h(String((v==null?void 0:v.message)||v))}finally{f(!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:S,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:u,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||u,children:i(u?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function kN({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:u}){const{t:f}=on(),p=m.useId(),h=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=h.current)==null?void 0:w.focus()});function v(w){w.key==="Escape"&&u(),w.key==="Enter"&&d()}return window.addEventListener("keydown",v),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",v)}},[e,u,d]),!e)return null;const g=r??f("common:common.confirm","确定"),b=s??f("common:common.cancel","取消"),S=t??f("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&u()},children:o.jsxs("div",{ref:h,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:S}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:u,"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:u,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 OW({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=on(),l=m.useId(),c=m.useRef(null),[d,u]=m.useState(""),[f,p]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),g(""),p(!1);const v=requestAnimationFrame(()=>{var w;return(w=c.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(v)},[e,n]),!e)return null;const b=d.trim(),S=b===n;async function y(v){if(v.preventDefault(),!S||f)return;p(!0),g("");let w=null;try{const j=new AbortController;w=setTimeout(()=>j.abort(),15e3);const E=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}),k=await E.json().catch(()=>({}));if(!E.ok){g(typeof k.error=="string"?k.error:a("project:deleteModal.deleteFailed"));return}try{for(let I=localStorage.length-1;I>=0;I--){const R=localStorage.key(I);R&&(R.startsWith(`af:composer-sessions:${n}:${r}`)||R.startsWith(`af:composer-active-session:${n}:${r}`)||R.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(R)}}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:v=>{v.target===v.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:v=>v.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:v=>u(v.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!S})]}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!S||f,children:a(f?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function MW({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Uo({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(MW,{children:t})]},n))})}function sI({open:e,onClose:t}){const{t:n}=on(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=RW()?"⌘":"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(Uo,{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(Uo,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Uo,{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(Uo,{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(Uo,{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(Uo,{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(Uo,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(Uo,{keys:[i,"A"]})]})]})]})]})]})})}function $W(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 DW({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=on(),[i,a]=m.useState(""),[l,c]=m.useState(0),d=m.useRef(null),u=m.useRef(null);m.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 f=m.useMemo(()=>{const g=(r||[]).map(y=>{var v,w,j;return{id:y.id,label:((v=y.data)==null?void 0:v.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),b=i.trim(),S=g.map(y=>({e:y,s:$W(y,b)})).filter(y=>y.s>0);return S.sort((y,v)=>v.s-y.s||y.e.id.localeCompare(v.e.id)),S.slice(0,50).map(y=>y.e)},[r,i]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var b;const g=(b=u.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const b=f[g];b&&(n(b.id),t())},h=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(b=>Math.min(f.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:h,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:u,className:"af-jump-panel__list",role:"listbox",children:f.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:S=>{S.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 FW({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=on(),u=m.useId(),f=m.useRef(null),p=m.useRef(null),[h,g]=m.useState(""),[b,S]=m.useState(""),[y,v]=m.useState(!1),[w,j]=m.useState(!1),[E,k]=m.useState(!1),[I,R]=m.useState(""),[$,K]=m.useState("");if(m.useEffect(()=>{if(!e||!i)return;g(""),S(""),R(""),K(""),v(!0),j(!1),k(!1);const A=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const _=await fetch(`/api/pipeline-file-content?${A}`),T=await _.json();if(!_.ok)throw new Error(T.error||"HTTP "+_.status);g(T.content||""),S(T.content||"")}catch(_){R(_.message||String(_))}finally{v(!1)}})();const z=requestAnimationFrame(()=>{var _;return(_=f.current)==null?void 0:_.focus()});return()=>cancelAnimationFrame(z)},[e,i,n,r,s]),!e)return null;const D=h!==b;async function L(A){if(A.preventDefault(),!w){j(!0),R(""),K("");try{const z=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),_=await fetch(`/api/pipeline-file-save?${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:h})}),T=await _.json();if(!_.ok)throw new Error(T.error||"HTTP "+_.status);S(h),K(d("flow:fileEdit.saved")),l&&l()}catch(z){R(z.message||String(z))}finally{j(!1)}}}async function H(){if(!(!c||E||!h)){k(!0),R("");try{const A=await c(h);typeof A=="string"&&A&&g(A)}catch(A){R(A.message||String(A))}finally{k(!1)}}}function M(){g(b),R(""),K("")}const O=h.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:A=>{A.target===A.currentTarget&&t()},children:o.jsxs("div",{ref:f,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:A=>A.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:u,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")}):I&&!h?o.jsx("div",{className:"af-file-edit-error",children:I}):o.jsxs(o.Fragment,{children:[O&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:h,onChange:A=>g(A.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(I||$)&&!y&&o.jsx("div",{className:`af-file-edit-status${$?" af-file-edit-status--success":""}`,children:$||I}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:M,disabled:!D||w||E,children:d("flow:fileEdit.reset")}),c&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:H,disabled:E||w||!h,children:d(E?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:L,disabled:!D||w||E,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const iI=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),zW=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function BW(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 HW(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 SN(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 oI(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(iI.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 aI(e){return{inputNames:SN(e==null?void 0:e.inputs),outputNames:SN(e==null?void 0:e.outputs)}}function UW(e,t,n){const r=aI(t),s=HW(e),i=[];for(const a of s)if(!oI(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 WW(e,t){const n=aI(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=oI(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 VW(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function KW(e){return e.map(t=>{const n=VW(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 qW(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 zW)iI.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function YW(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 GW(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 vp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:u}=on(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[g,b]=m.useState(0),[S,y]=m.useState(0),[v,w]=m.useState(null),j=m.useMemo(()=>ss(c),[c]),E=m.useMemo(()=>UW(e,a,u),[e,a,u]),k=E.length>0,I=m.useMemo(()=>WW(e,a),[e,a]),R=m.useMemo(()=>KW(I),[I]),$=m.useMemo(()=>n?null:BW(e,g),[e,g,n]),K=m.useMemo(()=>{if(!$)return[];const A=qW(a,u);return YW(A,$.query)},[$,a,u]);m.useEffect(()=>{y(A=>{const z=Math.max(0,K.length-1);return Math.min(Math.max(0,A),z)})},[K.length]);const D=m.useCallback(()=>{const A=p.current;if(!A||!$||K.length===0){w(null);return}const z=GW(A,g);if(!z){w(null);return}const _=4,T=44,C=13.5*16,G=Math.min(K.length*T+8,C);let Z=z.bottom+_;Z+G>window.innerHeight-8&&(Z=Math.max(8,z.top-G-_));const W=288;let te=z.left;te=Math.max(8,Math.min(te,window.innerWidth-W-8)),w({top:Z,left:te})},[$,K.length,g]);m.useLayoutEffect(()=>{if(!$||K.length===0){w(null);return}const A=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(A)},[$,K.length,g,e,D]),m.useEffect(()=>{if(!$||K.length===0)return;const A=()=>D();return window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[$,K.length,D]);const L=m.useCallback(A=>{if(!$)return;const{atIndex:z}=$,_=e.slice(0,z)+"${"+A+"}"+e.slice(g);t(_);const T=z+A.length+3;queueMicrotask(()=>{const C=p.current;C&&(C.focus(),C.setSelectionRange(T,T)),b(T)})},[$,e,g,t]),H=m.useCallback(()=>{const A=p.current,z=h.current;!A||!z||(z.scrollTop=A.scrollTop,z.scrollLeft=A.scrollLeft,$&&K.length>0&&queueMicrotask(()=>D()))},[$,K.length,D]),M=m.useCallback(A=>{if(!n&&$&&K.length>0&&(A.key==="ArrowDown"||A.key==="ArrowUp"||A.key==="Enter")){if(A.key==="ArrowDown")A.preventDefault(),y(z=>(z+1)%K.length);else if(A.key==="ArrowUp")A.preventDefault(),y(z=>(z-1+K.length)%K.length);else if(A.key==="Enter"&&!A.shiftKey){A.preventDefault();const z=K[S];z&&L(z.insert)}}},[n,$,K,S,L]),O=m.useCallback(async A=>{if(n||typeof d!="function")return!1;const z=await QA({files:A,body:e,images:j});return z?(t(z.body),d(z.images),queueMicrotask(()=>{const _=p.current;if(!_)return;_.focus();const T=z.body.length;_.setSelectionRange(T,T),b(T)}),!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((A,z)=>o.jsxs("span",{className:"af-body-image-chip",title:A.name,children:[o.jsx("img",{src:A.dataUrl,alt:""}),o.jsxs("span",{children:["[",A.label||`image ${z+1}`,"]"]})]},A.id||z))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
128
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":k,"aria-describedby":k?f:void 0,onChange:A=>{t(A.target.value),b(A.target.selectionStart??A.target.value.length)},onSelect:A=>{const z=A.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onClick:A=>{const z=A.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onKeyUp:A=>{const z=A.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??z.value.length)},onKeyDown:M,onPaste:A=>{const z=JA(A);z.length!==0&&(A.preventDefault(),O(z).catch(()=>{}))},onDragOver:A=>{Kh(A).length>0&&A.preventDefault()},onDrop:A=>{const z=Kh(A);z.length!==0&&(A.preventDefault(),O(z).catch(()=>{}))},onScroll:H})]}),$&&K.length>0&&v?es.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":u("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:K.map((A,z)=>o.jsx("li",{role:"option","aria-selected":z===S,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===S?" af-composer-mention-item--active":""),onMouseDown:_=>_.preventDefault(),onMouseEnter:()=>y(z),onClick:()=>L(A.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${A.insert}}`}),A.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:A.subtitle}):null]})},`${A.section}-${A.insert}`))}),document.body):null,k?o.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:E.map(A=>A.message).join(" · ")}):null]})}const lI=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function bp(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function NN({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=on(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),d=(f,p,h)=>{const g=n.map((b,S)=>{if(S!==f)return b;const y={...b,[p]:h};return p==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},u=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:u})}),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((f,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${u}-${p}`,children:[u,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>d(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>d(p,"name",h.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:f.default,onChange:h=>d(p,"default",h.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:!!f.required,onChange:h=>{i||d(p,"required",h.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:f.showOnNode!==!1,onChange:h=>d(p,"showOnNode",h.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"})})]},`${u}-${p}`))]}):null]})}function cI({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:u,ioSlots:f}){const{t:p}=on(),[h,g]=m.useState(!1),[b,S]=m.useState(!1),[y,v]=m.useState({status:"idle",message:""}),w=m.useCallback(L=>{t(H=>H&&{...H,...L})},[t]),{cursorList:j,opencodeList:E,claudeCodeList:k,currentNotInLists:I}=m.useMemo(()=>{const L=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],H=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],M=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],O=new Set([...L,...H,...M].map(bp)),A=((e==null?void 0:e.model)??"").trim(),z=A.startsWith("cursor:")?A.slice(7):A.startsWith("opencode:")?A.slice(9):A.startsWith("claude-code:")?A.slice(12):A,_=A&&!O.has(z)?A:"";return{cursorList:L,opencodeList:H,claudeCodeList:M,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const R=String(e.script??""),$=n==="tool_nodejs"||R.trim()!=="",K=typeof c=="function"&&!i&&(e==null?void 0:e.newId),D=async()=>{if(K){v({status:"running",message:p("flow:nodeProps.publishRunning")});try{const L=await c(e,n);v({status:"success",message:L!=null&&L.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(L){v({status:"error",message:String((L==null?void 0:L.message)||L)})}}};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:D,disabled:!K||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:[u?o.jsx("p",{className:"af-err af-node-props-err",children:u}):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:L=>w({newId:L.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:L=>w({label:L.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:ma.includes(e.role)?e.role:p("flow:roles.normal"),onChange:L=>w({role:L.target.value}),disabled:i,children:ma.map(L=>o.jsx("option",{value:L,children:L},L))})]}),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 L=(e.model||"").trim();return L?I||L:""})(),onChange:L=>w({model:L.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),I?o.jsxs("option",{value:I,children:[I,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?o.jsx("optgroup",{label:"Cursor",children:j.map(L=>o.jsx("option",{value:bp(L),children:L},`c-${L}`))}):null,E.length>0?o.jsx("optgroup",{label:"OpenCode",children:E.map(L=>o.jsx("option",{value:bp(L),children:L},`o-${L}`))}):null,k.length>0?o.jsx("optgroup",{label:"Claude Code",children:k.map(L=>o.jsx("option",{value:`claude-code:${bp(L)}`,children:L},`cc-${L}`))}):null]})]}),o.jsx(NN,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>w({inputs:L}),disabled:i,requiredReadonly:!d}),o.jsx(NN,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>w({outputs:L}),disabled:i,requiredReadonly:!d}),$?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:()=>S(!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(vp,{value:R,onChange:L=>w({script:L}),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:f,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(vp,{value:e.body,onChange:L=>w({body:L}),images:e.images,onImagesChange:L=>w({images:L}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,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:L=>{L.target===L.currentTarget&&S(!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:()=>S(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(vp,{value:R,onChange:L=>w({script:L}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&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(vp,{value:e.body,onChange:L=>w({body:L}),images:e.images,onImagesChange:L=>w({images:L}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function e0(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 XW(e){const t=e0(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 uI(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function jN({text:e}){const{t}=on(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(cf,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function CN({o:e}){var r;const{t}=on(),n=e0(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:uI(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(cf,{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 EN(e){return XW(e)}function _N(e){var r;if(!e)return null;const t=e0(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"?uI(String(n)):String(n)}function PN({text:e,title:t,copiedLabel:n}){const[r,s]=m.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 AN=2e4,dI="af:run-node-ctx-width";function Jp(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Qo(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):Qo(Jp())}function JW(){try{const e=localStorage.getItem(dI);if(e==null)return Qo(Jp());const t=parseInt(e,10);return Number.isFinite(t)?Qo(t):Qo(Jp())}catch{return Qo(Jp())}}async function IN(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 QW(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function ZW({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=on(),[a,l]=m.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=m.useState(JW),u=m.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[f,p]=m.useState(!0),[h,g]=m.useState(""),[b,S]=m.useState([]),[y,v]=m.useState(null),[w,j]=m.useState(null),E=m.useRef(null),k=m.useRef(null),I=m.useRef(0),R=m.useRef(0);m.useLayoutEffect(()=>{const _=window.matchMedia("(max-width: 960px)"),T=()=>l(_.matches);return _.addEventListener("change",T),()=>_.removeEventListener("change",T)},[]),m.useEffect(()=>{function _(){d(T=>Qo(T))}return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[]);const $=m.useCallback(()=>{d(_=>{const T=Qo(_);try{localStorage.setItem(dI,String(T))}catch{}return T})},[]),K=m.useCallback(_=>{if(a||_.button!==0)return;_.preventDefault();const T=_.currentTarget;u.current={active:!0,pointerId:_.pointerId,startX:_.clientX,startW:c},T.setPointerCapture(_.pointerId)},[a,c]),D=m.useCallback(_=>{const T=u.current;if(!T.active||_.pointerId!==T.pointerId)return;const C=T.startX-_.clientX;d(Qo(T.startW+C))},[]),L=m.useCallback(_=>{const T=u.current;if(!(!T.active||_.pointerId!==T.pointerId)){T.active=!1;try{_.currentTarget.releasePointerCapture(_.pointerId)}catch{}$()}},[$]),H=m.useCallback(()=>{const _=u.current;_.active&&(_.active=!1,$())},[$]),M=m.useCallback(_=>{const T=Array.isArray(_)?_:[];S(T),v(C=>C&&T.some(G=>G.execId===C)?C:T.length>0?T[T.length-1].execId:null)},[]),O=m.useCallback(()=>{if(!e||!t)return;const _=++I.current,T=new AbortController,C=window.setTimeout(()=>T.abort(),AN);(async()=>{try{const G=await IN(t,e,n,T.signal);if(_!==I.current)return;M(Array.isArray(G.rounds)?G.rounds:[])}catch{}finally{window.clearTimeout(C)}})()},[e,t,n,M]);m.useEffect(()=>{if(!e||!t){p(!1),g(""),S([]);return}const _=++R.current;p(!0),g(""),S([]),v(null);const T=new AbortController,C=window.setTimeout(()=>T.abort(),AN);return(async()=>{try{const G=await IN(t,e,n,T.signal);if(_!==R.current)return;M(Array.isArray(G.rounds)?G.rounds:[])}catch(G){if(_!==R.current)return;const Z=(G==null?void 0:G.name)==="AbortError"?"requestTimeout":G.message||String(G);g(Z)}finally{window.clearTimeout(C),_===R.current&&p(!1)}})(),()=>{T.abort(),R.current++,I.current++}},[e,t,n,M]),m.useEffect(()=>{r&&O()},[r,O]),m.useEffect(()=>{clearInterval(k.current);const _=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(_&&_.status==="running"))&&e&&t&&(k.current=setInterval(()=>O(),2e3)),()=>clearInterval(k.current)},[b,e,t,n,r,O]),m.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[y]);const A=b.find(_=>_.execId===y),z=a?void 0:{width:`${c}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:z,"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:K,onPointerMove:D,onPointerUp:L,onPointerCancel:L,onLostPointerCapture:H}),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"})})]}),f&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),h&&o.jsx("div",{className:"af-run-ctx-error",children:QW(i,h)}),!f&&!h&&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--"+tV((A==null?void 0:A.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 T=_.target.value;v(T==="latest"?"latest":Number(T))},children:[...b].reverse().map(_=>{const T=_.execId==="latest"?i("flow:runContext.latest"):`#${_.execId}`,C=nV(i,_.status),G=_.finishedAt?` · ${eV(_.finishedAt)}`:"";return o.jsx("option",{value:String(_.execId),children:`${T} · ${C}${G}`},_.execId)})})]}),A&&o.jsxs("div",{className:"af-run-ctx-body",ref:E,children:[A.inputs&&A.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"]}),A.inputs.map((_,T)=>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}-${T}`))]}),A.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(jN,{text:A.prompt})]}),A.outputs&&A.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"})})]}),A.outputs.map((_,T)=>{const C=EN(_),G=_N(_);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}),C?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:C}):null,o.jsx(PN,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(CN,{o:_})]},`${_.slot}-${T}`)})]}),!A.prompt&&(!A.outputs||A.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&A&&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"&&A.prompt!=null&&o.jsx(jN,{text:A.prompt}),w==="output"&&A.outputs&&A.outputs.map((_,T)=>{const C=EN(_),G=_N(_);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}),C?o.jsx("span",{className:"af-run-ctx-format-badge",children:C}):null,o.jsx(PN,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(CN,{o:_})]},`${_.slot}-${T}`)})]})]})})]})}function eV(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 tV(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 nV(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 rV({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=on(),[d,u]=m.useState({}),[f,p]=m.useState(null),[h,g]=m.useState({}),[b,S]=m.useState(!0),[y,v]=m.useState(!1),[w,j]=m.useState(""),[E,k]=m.useState(!1),[I,R]=m.useState(null),$=m.useRef(null),K=m.useRef(!0),D=m.useRef({});m.useMemo(()=>{var C,G,Z;const T={};for(const W of r){const te=(Z=(G=(C=W.data)==null?void 0:C.outputs)==null?void 0:G[0])==null?void 0:Z.default;te!=null&&te!==""&&(T[W.id]=String(te))}return D.current=T,T},[r]);const L=m.useMemo(()=>{var C;const T={};for(const G of i){if(!((C=G.data)!=null&&C.inputs))continue;const Z=G.data.inputs;for(let W=0;W<Z.length;W++){const te=Z[W];if(!(te!=null&&te.name))continue;const le=s.find(de=>de.target===G.id&&de.targetHandle===`input-${W}`);if(!(le!=null&&le.source))continue;r.find(de=>de.id===le.source)&&(T[le.source]=te.name)}}return T},[i,s,r]);m.useEffect(()=>(K.current=!0,()=>{K.current=!1}),[]),m.useEffect(()=>{if(!e){S(!1);return}S(!0);const T=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&T.set("archived","1"),fetch(`/api/flow/run-config?${T.toString()}`).then(C=>{if(!C.ok)throw new Error(`HTTP ${C.status}`);return C.json()}).then(C=>{var Z;if(!K.current)return;u(C.presets||{}),p(C.activePreset||null);const G=C.activePreset&&((Z=C.presets)!=null&&Z[C.activePreset])?C.presets[C.activePreset]:{};g({...D.current,...G}),S(!1)}).catch(()=>{K.current&&(g(D.current),S(!1))})},[e,t,n]),m.useEffect(()=>{var C;if(!a)return;const T={};for(const[G,Z]of Object.entries(h)){const W=L[G];if(!W)continue;const te=r.find(ue=>ue.id===G);if(!te)continue;(((C=te.data)==null?void 0:C.definitionId)||"").startsWith("provide_file")?T[W]={type:"file",path:Z}:T[W]={type:"str",value:Z}}a(T)},[h,L,r,a]);const H=m.useCallback((T,C)=>{g(G=>({...G,[T]:C}))},[]),M=m.useCallback(T=>{T!==f&&(p(T),T&&d[T]?g({...D.current,...d[T]}):g(D.current))},[f,d]),O=m.useCallback(async()=>{if(w.trim()){v(!0);try{const T={...d,[w.trim()]:h},C={flowId:e,flowSource:t,archived:n,presets:T,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)})).ok&&(u(T),p(w.trim()),j(""),k(!1))}finally{v(!1)}}},[e,t,n,d,h,w]),A=m.useCallback(async()=>{if(f){v(!0);try{const T={...d};delete T[f];const C=Object.keys(T)[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:T,activePreset:C})})).ok&&(u(T),p(C),C&&T[C]?g({...D.current,...T[C]}):g(D.current))}finally{v(!1)}}},[e,t,n,d,f]),z=m.useCallback(async()=>{if(f){v(!0);try{const T={...d,[f]:h};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:T,activePreset:f})})).ok&&u(T)}finally{v(!1)}}},[e,t,n,d,f,h]),_=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:f||"",onChange:T=>M(T.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:c("flow:runConfig.default")}),_.map(T=>o.jsx("option",{value:T,children:T},T))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>k(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),f&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:z,disabled:y,title:c("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),f&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:A,disabled:y,title:c("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),E&&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:T=>j(T.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:O,disabled:y||!w.trim(),children:c(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{k(!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(T=>{var de,ce;const C=((de=T.data)==null?void 0:de.definitionId)||"",G=C.startsWith("provide_file"),Z=C==="provide_bool",W=((ce=T.data)==null?void 0:ce.label)||T.id,te=T.id,le=h[te]||"",ue=["true","1","yes","on"].includes(String(le).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(G?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:G?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:W}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>R({instanceId:te,label:W,content:le}),"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:te}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ue?" af-run-config-bool-toggle--true":""),onClick:()=>H(te,ue?"false":"true"),"aria-pressed":ue,children:ue?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:le,onChange:fe=>H(te,fe.target.value),placeholder:c(G?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},te)})})]}),I&&es.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:I.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>R(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:$,className:"af-provide-edit-modal__textarea",defaultValue:I.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:()=>{!I||!$.current||(H(I.instanceId,$.current.value),R(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:()=>R(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const fI={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"]},sV={"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 iV(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function oV(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 aV(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 TN(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(fI))if(r.includes(e))return n;return"other"}function lV({event:e,defaultExpanded:t}){const[n,r]=m.useState(!!t),s=sV[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=m.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(h=>h!=="text"&&h!=="meta").slice(0,3).map(h=>{const g=i[h];return g==null?`${h}:null`:typeof g=="object"?`${h}:{…}`:`${h}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),u=m.useCallback(f=>{f.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(f=>!f),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:oV(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:u,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 cV({open:e,onClose:t,flowId:n}){var R;const[r,s]=m.useState([]),[i,a]=m.useState(!1),[l,c]=m.useState(null),[d,u]=m.useState(null),[f,p]=m.useState(!1),[h,g]=m.useState(!0),[b,S]=m.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,v]=m.useState(""),w=m.useRef(null),j=m.useCallback(async()=>{a(!0);try{const $=h&&n?`?flowId=${encodeURIComponent(n)}`:"",D=await(await fetch(`/api/composer-logs${$}`)).json();s(Array.isArray(D.sessions)?D.sessions:[])}catch{s([])}finally{a(!1)}},[n,h]),E=m.useCallback(async $=>{if(!$){u(null);return}p(!0);try{const D=await(await fetch(`/api/composer-logs/${encodeURIComponent($)}`)).json();u(D)}catch{u(null)}finally{p(!1)}},[]);m.useEffect(()=>{e&&j()},[e,j]),m.useEffect(()=>{if(!(!e||!l))return E(l),w.current=setInterval(()=>E(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,E]);const k=m.useMemo(()=>{const $=(d==null?void 0:d.events)||[],K=y.trim().toLowerCase();return $.filter(D=>{const L=TN(D.tag,D.payload);return!b[L]&&L!=="other"?!1:K?[D.tag,JSON.stringify(D.payload||"")].join(" ").toLowerCase().includes(K):!0})},[d,b,y]),I=m.useMemo(()=>{const $=(d==null?void 0:d.events)||[],K={};for(const D of $){const L=TN(D.tag,D.payload);K[L]=(K[L]||0)+1}return K},[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:h,onChange:$=>g($.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:h&&n?"no sessions for this flow":"no sessions"}),r.map($=>{const K=l===$.sessionId;return o.jsxs("div",{onClick:()=>c($.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:K?"rgba(124,77,255,0.18)":"transparent",borderLeft:K?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:aV($.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:$.flowId||"(no flow)"}),$.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:$.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[iV($.size)," · ",$.model||"default"]})]},$.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(fI).map($=>o.jsxs("button",{type:"button",onClick:()=>S(K=>({...K,[$]:!K[$]})),style:{background:b[$]?"rgba(124,77,255,0.25)":"transparent",color:b[$]?"#e8deff":"#6a6a6a",border:`1px solid ${b[$]?"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:[$," ",I[$]!=null?`(${I[$]})`:""]},$)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:$=>v($.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"}),f&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&k.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((R=d.events)==null?void 0:R.length)||0," total)"]}),k.map(($,K)=>o.jsx(lV,{event:$,defaultExpanded:$.tag==="error"},`${$.ts}_${K}`))]})]})]})]}):null}const uV="0.1.35";function RN(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 py(e,t){return t==="running"?RN(e):e==null||!Number.isFinite(e)||e<=0?"--":RN(e)}const pI=m.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function dV(e){const{setNodes:t}=dl(),{modelLists:n,onModelChange:r}=m.useContext(pI),s=m.useCallback(d=>{t(u=>u.filter(f=>f.id!==d))},[t]),i=m.useCallback(()=>{var p,h,g,b,S,y,v,w;const d=((p=e.data)==null?void 0:p.definitionId)||"",u=((h=e.data)==null?void 0:h.label)||e.id,f=((S=(b=(g=e.data)==null?void 0:g.outputs)==null?void 0:b[0])==null?void 0:S.value)||((w=(v=(y=e.data)==null?void 0:y.outputs)==null?void 0:v[0])==null?void 0:w.default)||"";window.__provideEditContent={instanceId:e.id,label:u,definitionId:d,content:f},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),a=m.useCallback((d,u)=>{t(f=>f.map(p=>{var g;if(p.id!==d)return p;const h=Array.isArray((g=p.data)==null?void 0:g.outputs)&&p.data.outputs.length?p.data.outputs.map((b,S)=>S===0?{...b,default:u,value:u}:b):[{type:"bool",name:"value",default:u,value:u}];return{...p,data:{...p.data,body:"",outputs:h}}}))},[t]),l=m.useCallback((d,u)=>{t(f=>f.map(p=>p.id===d?{...p,data:{...p.data,body:u}}:p))},[t]),c=m.useCallback((d,u)=>{t(f=>f.map(p=>p.id===d?{...p,data:{...p.data,images:ss(u)}}:p))},[t]);return o.jsx(nI,{...e,deleteNode:s,onProvideExpand:i,onProvideValueChange:a,onNodeBodyChange:l,onNodeImagesChange:c,modelLists:n,onModelChange:r})}const fV={[df]:dV},zu=["CONTROL","TOOL","PROVIDE","AGENT"],pV=1200,LN="af-flow-node--sync-flash",ON="af-flow-edge--sync-flash";function MN(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function $N(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function t0(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 hV(e){const t=t0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function kp(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 hI(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function mI(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function hy(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 DN(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 FN(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 mV(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function gV(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 gI(e,t,n,r,s){const i=hV(e),a={id:t,type:df,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 Hd(a,r,s)}function zN(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=Rc(i,e.sourceHandle||"output-0","source"),c=Rc(a,e.targetHandle||"input-0","target");return!l||!c?!1:Tc(l,c)}function yV(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=Rc(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:tI(a)}:null}function xV(e,t,n){var a;const r=gI(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"?Tc(n.slot,c):Tc(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function wV(e,t){return t?e.map((n,r)=>{const s=xV(n,e,t);if(!s)return null;const i=t0(n);return{def:n,order:r,category:i,categoryRank:zu.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:hI(s.hydrated.data||n),description:mI(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 vV=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function bV(e){const t=new Set,n=[];let r;const s=new RegExp(vV.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function BN(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 ao(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function Sp(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(ao),d=a.map(ao);return l.map(ao).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function kV(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function my(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 SV({steps:e}){const{t}=on();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:kV(s)}):null]}):null})]},n.index)})})}function NV(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 jV(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 CV(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 EV(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 HN({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=on(),a=m.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return m.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(UN,{segments:c.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(UN,{segments:t,running:n})})]})}function UN({segments:e,running:t=!1}){const{t:n}=on(),r=e.filter(f=>f.kind==="assistant").map(f=>f.text).join(""),s=e.filter(f=>f.kind==="result").map(f=>f.text).join(""),i=NV(r,s),a=e.filter(f=>f.kind==="error").map(f=>f.text).join(`
131
- `),l=e.filter(f=>f.kind!=="error"),c=i?l.filter(f=>f.kind!=="result"):l,d=jV(c),u=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((f,p)=>o.jsxs("section",{className:EV(f.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:CV(f.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:f.text})]},`${f.kind}-${p}`)),t&&!u?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 _V({fitViewEpoch:e}){const{fitView:t}=dl(),n=m.useRef(t);return n.current=t,m.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function PV({onReady:e}){const t=yP();return m.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function WN(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}const Qp=1500,VN=500,AV=262144,IV=2e3;function gy(e){return typeof e!="string"?"":e.length<=IV?e:`[log line truncated, ${e.length} chars]`}const TV=Qp;function RV(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:gy(s)}}catch{return{ts:n,type:"info",text:gy(s)}}return{ts:n,type:"log",text:gy(`[${r}] ${s}`)}}function KN(e){if(!e)return[];const t=[],n=e.split(`
132
- `);for(let r=n.length-1;r>=0&&t.length<TV;r--){const s=n[r];if(!s)continue;const i=RV(s);i&&t.push(i)}return t.reverse(),t}function LV(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 OV(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 MV({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:c,isValidConnection:d,onNodesDelete:u,onNodeClick:f,onNodeDoubleClick:p,onEdgeClick:h,onFlowInit:g,onDrop:b,onDragOver:S,hideMinimapAndControls:y,bottomSlot:v}){const{t:w}=on(),j=!s,E=j||t==="pan"?!0:[1,2],k=j?!1:t==="select",I="af-flow-canvas"+(j?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),R=m.useCallback(()=>{},[]),$=m.useMemo(()=>{const K=new Map(n.map(O=>[O.id,O])),D=new Set(n.filter(O=>O.selected).map(O=>O.id)),L=D.size>0,H=(O,A)=>{const z=/^#([0-9a-f]{6})$/i.exec(O);if(!z)return O;const _=parseInt(z[1],16);return`rgba(${_>>16&255}, ${_>>8&255}, ${_&255}, ${A})`},M="#ff5169";return r.map(O=>{var pe,ae,ye,Be;const A=K.get(O.source),z=K.get(O.target),_=/^output-(\d+)$/.exec(O.sourceHandle||""),T=/^input-(\d+)$/.exec(O.targetHandle||""),C=A&&_?(ae=(pe=A.data)==null?void 0:pe.outputs)==null?void 0:ae[parseInt(_[1],10)]:null,G=z&&T?(Be=(ye=z.data)==null?void 0:ye.inputs)==null?void 0:Be[parseInt(T[1],10)]:null,Z=C!=null&&C.type?Kn(C.type):null,W=G!=null&&G.type?Kn(G.type):null,te=Z&&W&&Z!==W,le=L&&(D.has(O.source)||D.has(O.target)),ue=O.style||{};if(te){const lt=O.selected?.95:le?.85:.78,Ge=H(M,lt);return{...O,className:((O.className||"")+" af-flow-edge--type-mismatch"+(le?" af-flow-edge--adjacent":"")).trim(),style:{...ue,stroke:Ge,strokeWidth:le?2.75:2.5,strokeDasharray:"6 4"},markerEnd:O.markerEnd&&typeof O.markerEnd=="object"?{...O.markerEnd,color:Ge}:{type:cs.ArrowClosed,color:Ge}}}const de=Z||W;if(!de)return le?{...O,className:((O.className||"")+" af-flow-edge--adjacent").trim(),style:{...ue,strokeWidth:2.5}}:O;const ce=le||O.selected?.7:.38,fe=H(de,ce),re=le?2.5:ue.strokeWidth??2;return{...O,className:((O.className||"")+(le?" af-flow-edge--adjacent":"")).trim(),style:{...ue,stroke:fe,strokeWidth:re},markerEnd:O.markerEnd&&typeof O.markerEnd=="object"?{...O.markerEnd,color:fe}:{type:cs.ArrowClosed,color:fe}}})},[n,r]);return o.jsxs(gP,{className:I,nodes:n,edges:$,onNodesChange:s||R,onEdgesChange:i||R,onConnect:j?void 0:a,onConnectStart:j?void 0:l,onConnectEnd:j?void 0:c,isValidConnection:j?void 0:d,onNodesDelete:j?void 0:u,onNodeClick:f,onNodeDoubleClick:j?void 0:p,onEdgeClick:j?void 0:h,onInit:g,onDrop:j?void 0:b,onDragOver:j?void 0:S,nodeTypes:fV,selectionOnDrag:k,panOnDrag:E,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(bP,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx(Ac,{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:K=>{var L;const D=(((L=K.data)==null?void 0:L.schemaType)??"agent").toLowerCase();return D==="control"?"rgba(237, 108, 2, 0.85)":D==="provide"?"rgba(0, 228, 117, 0.35)":D==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:v}),y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(D4,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&o.jsx(Ac,{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:K,color:D})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:D}}),o.jsx("span",{className:"af-pin-legend__label",children:K})]},K))}),o.jsx(_V,{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 qN(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 $V(e){return e==="builtin"?"workspace":e??"user"}function Rl(e,t){return t(e==="builtin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}const yI="af:run-console-height",id=230,_u={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Np={};function Zp(e){if(!Number.isFinite(e))return id;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function DV(){try{const e=localStorage.getItem(yI);if(e==null)return id;const t=parseInt(e,10);return Number.isFinite(t)?Zp(t):id}catch{return id}}function FV(){var U0,W0;const{t:e,i18n:t}=on(),{navigate:n,path:r}=ul(),s=m.useRef(null),i=m.useCallback(x=>{s.current=typeof x=="function"?x:null},[]),[a,l]=m.useState([]),[c,d]=m.useState(""),[u,f]=m.useState(null),[p,h]=m.useState(0),[g,b]=m.useState(""),[S,y]=m.useState(""),[v,w]=m.useState(""),[j,E]=m.useState(""),[k,I]=m.useState(!1),[R,$]=m.useState(""),[K,D]=m.useState(!1),[L,H]=m.useState(""),[M,O]=m.useState(!1),[A,z]=m.useState(!1),[_,T]=m.useState(!1),[C,G]=m.useState(null),[Z,W]=m.useState(!1),[te,le]=m.useState(!1),ue=m.useRef(!1),[de,ce]=m.useState([]),[fe,re]=m.useState(""),[pe,ae]=m.useState("nodes"),ye=m.useRef(null),[Be,lt]=m.useState([]),[Ge,_t]=m.useState(!1),[Pt,Te]=m.useState(""),[an,Fn]=m.useState(!1),[qt,_n]=m.useState({name:"",id:"",description:""}),[jr,fr]=m.useState(!1),[ie,xe]=m.useState(""),[Ve,Ze]=m.useState(""),Xe=m.useRef(null),[At,On]=m.useState([]),[Dt,Mn]=m.useState(!1),[Yt,Gt]=m.useState(""),[rr,he]=m.useState(""),[Ee,Wt]=m.useState(null),[nt,hn]=m.useState(null),[Us,Pn]=m.useState([]),[Cr,pr]=m.useState(""),[fs,xi]=m.useState(!1),Ws=m.useCallback(x=>{Xe.current&&window.clearTimeout(Xe.current),Ze(x),Xe.current=window.setTimeout(()=>{Ze(""),Xe.current=null},3800)},[]),hr=m.useCallback(x=>{const N=String(x||"").trim();N&&window.requestAnimationFrame(()=>{var F;(F=s.current)==null||F.call(s,N)})},[]);m.useEffect(()=>()=>{Xe.current&&window.clearTimeout(Xe.current)},[]);const[sr,Vs]=m.useState(!1),[Ye,Vt]=m.useState({files:[]}),[ln,mr]=m.useState(!1),[He,Xt]=m.useState(!0);m.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/flows",{method:"HEAD"}).then(U=>{x||Xt(U.ok)}).catch(()=>{x||Xt(!1)})};N();const F=window.setInterval(N,5e3);return()=>{x=!0,window.clearInterval(F)}},[]),m.useEffect(()=>{let x=!1;return fetch("/api/dev-info").then(N=>N.json()).then(N=>{x||be(!!(N!=null&&N.isDev))}).catch(()=>{}),()=>{x=!0}},[]),m.useEffect(()=>{u!=null&&u.id&&kE(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[_e,bn]=m.useState("edit"),[Er,ot]=m.useState([]),Xn=m.useRef(0),[ir,zn]=m.useState(new Set),[ps,Jn]=m.useState({}),[Ks,_r]=m.useState(null),[Es,$r]=m.useState(0),[gr,yr]=m.useState(!1),[q,be]=m.useState(!1),[Ae,Ue]=m.useState(!1),[yt,Bn]=m.useState(DV),ct=m.useRef({active:!1,pointerId:-1,startY:0,startH:id}),[wt,or]=m.useState(null),[qs,Ys]=m.useState(null),[hs,jo]=m.useState({}),_s=m.useRef(hs);m.useEffect(()=>{_s.current=hs},[hs]);const[pl,et]=m.useState(!1),[wi,Pr]=m.useState(!1),[Gs,Co]=m.useState({}),[Ps,Hn]=m.useState({}),[Yi,xr]=m.useState(null),[mn,Sa]=m.useState(_u),[Kc,qc]=m.useState(!1),[Vr,Yc]=m.useState(!1),[Na,Eo]=m.useState(""),[Gi,ja]=m.useState(""),[Ft,hl]=m.useState(Np),[gn,Ca]=m.useState(null),dt=m.useRef(0),As=m.useRef(null),ml=m.useRef(null),Ea=m.useRef(!0),Xs=m.useRef(!1),[An,gl]=m.useState(null),[_a,_o]=m.useState(null),[Pa,kn]=m.useState(!1),[Xi,yl]=m.useState(""),[Aa,Ji]=m.useState(!1),yf=m.useRef(null),[Is,Qi]=m.useState(null),[xf,Ia]=m.useState(!1),[Gc,Zi]=m.useState(null),[xl,eo]=m.useState(!1),[Js,Kr]=m.useState(null),Xc=m.useRef(null),[qr,Ta]=m.useState(""),[wl,Ra]=m.useState(0),[Po,Ao]=m.useState(0),[Vm,Jc]=m.useState("pan"),[vl,vi]=m.useState(!1),[Qc,wf]=m.useState(!1),Zc=m.useRef(null),bl=m.useRef(null),Io=m.useRef(null),[Km,vf]=m.useState(0),[Ke,eu]=m.useState(null),[bf,kl]=m.useState(""),[rt,kf]=m.useState({cursor:[],opencode:[],claudeCode:[]}),[P,B]=m.useState(""),[X,Q]=m.useState(""),[ee,oe]=m.useState([]),[ge,Ne]=m.useState([]),[Ie,ze]=m.useState(!1),[zt,Ht]=m.useState([]),[Nt,In]=m.useState(!1),[Tn,ar]=m.useState(()=>new Set),[Qn,vt]=m.useState(!1),It=m.useRef(null),jt=m.useRef(null),[$e,we]=m.useState({}),at=m.useCallback(x=>{if(!x)return null;const N=x.id,F=x.source??"user",U=x.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${N}:${F}${U?":"+U:""}`,activeKey:`af:composer-active-session:${N}:${F}${U?":"+U:""}`}},[]),xt=m.useCallback(x=>{if(!x)return"";const N=x.id,F=x.source??"user",U=x.archived?"archived":"";return`af:composer-skills:pipeline:${N}:${F}${U?":"+U:""}`},[]),ut=m.useCallback(x=>{const N=at(x);if(!N)return{sessions:[],activeSessionId:null};try{const F=localStorage.getItem(N.sessionsKey);if(!F)return{sessions:[],activeSessionId:null};const U=JSON.parse(F);if(!Array.isArray(U))return{sessions:[],activeSessionId:null};const V=U.filter(J=>J&&typeof J.id=="string").map(J=>({...J,running:!1,statusLine:J.running?e("flow:composer.pageRefreshReset"):J.statusLine,steps:[]}));let Y=null;try{Y=localStorage.getItem(N.activeKey),Y&&!V.some(J=>J.id===Y)&&(Y=null)}catch{Y=null}return{sessions:V,activeSessionId:Y}}catch{return{sessions:[],activeSessionId:null}}},[at]),De=m.useCallback((x,N,F)=>{const U=at(x);if(U)try{localStorage.setItem(U.sessionsKey,JSON.stringify(N)),F?localStorage.setItem(U.activeKey,F):localStorage.removeItem(U.activeKey)}catch{}},[at]),bt=m.useRef(0),Jt=m.useRef({sessions:[],activeSessionId:null,flowKey:null}),[ft,Tt]=m.useState([]),[Ct,Zt]=m.useState(null),Un=m.useMemo(()=>xt(u),[xt,u]),[To,to]=m.useState(""),bi=m.useMemo(()=>{if(!u)return null;const x=u.id,N=u.source??"user",F=u.archived?"archived":"";return`${x}:${N}${F?":"+F:""}`},[u]),Qs=m.useRef(!1);m.useEffect(()=>{if(!bi){Tt([]),Zt(null),Jt.current={sessions:[],activeSessionId:null,flowKey:null};return}const x=Jt.current;if(x.flowKey===bi)return;x.flowKey=bi,Qs.current&&x.sessions.length>0&&De(u,x.sessions,x.activeSessionId);const{sessions:N,activeSessionId:F}=ut(u);if(N.length===0){const U=`session-1-${Date.now()}`,V={id:U,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};x.sessions=[V],x.activeSessionId=U,Tt([V]),Zt(U)}else{const U=N[N.length-1];if(U&&(!U.thread||U.thread.length===0))bt.current=my(N),x.sessions=N,x.activeSessionId=U.id,Tt(N),Zt(U.id);else{const Y=my(N)+1;bt.current=Y;const J=`session-${Y}-${Date.now()}`,ne={id:J,label:e("flow:composer.conversationLabel",{n:Y}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},me=[...N,ne];x.sessions=me,x.activeSessionId=J,Tt(me),Zt(J)}}Qs.current=!0},[bi,u,ut,De]);const Sn=m.useMemo(()=>ft.find(x=>x.id===Ct)||null,[ft,Ct]),yn=(Sn==null?void 0:Sn.running)??!1,tu=(Sn==null?void 0:Sn.statusLine)??"",nu=(Sn==null?void 0:Sn.segments)??[],ru=(Sn==null?void 0:Sn.thread)??[],m0=(Sn==null?void 0:Sn.steps)??[];Sn==null||Sn.outputDismissed;const pt=(Sn==null?void 0:Sn.phaseContext)??null,g0=m.useRef([]),[qm,Sf]=m.useState(!1),Nf=m.useRef(null),y0=m.useRef(null);m.useEffect(()=>{const x=y0.current;x&&requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight})},[ru,nu]);const Ym=m.useRef(null),Gm=m.useRef(!1),oT=m.useRef(null),x0=m.useCallback(x=>{const N=++bt.current,F=`session-${N}-${Date.now()}`,U={id:F,label:x||e("flow:composer.conversationLabel",{n:N}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return Tt(V=>[...V,U]),Zt(F),F},[]);m.useEffect(()=>{!u||!Qs.current||(Jt.current.sessions=ft,Jt.current.activeSessionId=Ct,De(u,ft,Ct))},[ft,Ct,u,De]),m.useEffect(()=>{bt.current=Math.max(bt.current,my(ft))},[ft]);const w0=m.useCallback(x=>{var N;Ym.current===x&&((N=Nf.current)==null||N.abort()),Tt(F=>{const U=F.filter(Y=>Y.id!==x);if(F.some((Y,J)=>Y.id===x&&F.findIndex(ne=>ne.id===Ct)===J)||Ct===x){const Y=U;Y.length>0?Zt(Y[Y.length-1].id):setTimeout(()=>{bt.current=0;const J=++bt.current,ne=`session-${J}-${Date.now()}`,me={id:ne,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};Tt(je=>[...je,me]),Zt(ne)},0)}return U})},[Ct]),Yr=m.useCallback(x=>{Tt(N=>{const F=N.findIndex(Y=>Y.id===Ct);if(F<0)return N;const U={...N[F]};x(U);const V=[...N];return V[F]=U,V})},[Ct]),v0=m.useCallback(x=>{Yr(N=>{N.running=x})},[Yr]),ki=m.useCallback(x=>{Yr(N=>{N.statusLine=x})},[Yr]),Si=m.useCallback(x=>{Yr(N=>{typeof x=="function"?N.segments=x(N.segments):N.segments=x})},[Yr]),b0=m.useCallback(x=>{Yr(N=>{typeof x=="function"?N.thread=x(N.thread):N.thread=x})},[Yr]),su=m.useCallback(x=>{Yr(N=>{typeof x=="function"?N.steps=x(N.steps):N.steps=x})},[Yr]),k0=m.useCallback(x=>{Yr(N=>{N.outputDismissed=x})},[Yr]),iu=m.useCallback(x=>{Yr(N=>{N.phaseContext=typeof x=="function"?x(N.phaseContext):x})},[Yr]),S0=m.useCallback(x=>{Zt(x),Tt(N=>{const F=N.findIndex(V=>V.id===x);if(F<0||!N[F].outputDismissed)return N;const U=[...N];return U[F]={...N[F],outputDismissed:!1},U})},[]);m.useEffect(()=>{g0.current=nu},[nu]);const Dr=m.useRef({}),N0=m.useRef(!1),La=m.useRef(null),Ro=m.useRef(null),ou=m.useRef(!1),Xm=m.useRef(0),jf=m.useRef(""),[Rt,ht,aT]=xP([]),[Nn,cn,lT]=wP([]),Ni=m.useRef(Rt),Sl=m.useRef(Nn),j0=m.useRef(null),Jm=m.useRef(null),C0=m.useRef(null),Cf=m.useRef(null),[Gr,Lo]=m.useState(null),Zs=m.useMemo(()=>Rt.filter(x=>{var N;return(((N=x.data)==null?void 0:N.definitionId)||"").startsWith("provide_")}),[Rt]),Nl=m.useMemo(()=>{var N;const x={};for(const F of Rt){if(!((N=F.data)!=null&&N.inputs))continue;const U=F.data.inputs;for(let V=0;V<U.length;V++){const Y=U[V];if(!(Y!=null&&Y.name))continue;const J=Nn.find(me=>me.target===F.id&&me.targetHandle===`input-${V}`);if(!(J!=null&&J.source))continue;Zs.find(me=>me.id===J.source)&&(x[J.source]=Y.name)}}return x},[Rt,Nn,Zs]),au=m.useMemo(()=>{if(_e==="edit"||ir.size===0)return null;const x=new Set(ir);for(const N of Nn)ir.has(N.source)&&x.add(N.target),ir.has(N.target)&&x.add(N.source);return x},[_e,ir,Nn]),cT=m.useMemo(()=>_e==="edit"?Rt:Rt.map(x=>{var N,F;return{...x,draggable:!1,connectable:!1,data:{...x.data,isRunMode:!0,isExecuting:ir.has(x.id),nodeStatus:((N=ps[x.id])==null?void 0:N.status)??null,nodeElapsed:((F=ps[x.id])==null?void 0:F.elapsed)??null,isDim:au?!au.has(x.id):!1}}}),[_e,Rt,ir,ps,au]),uT=m.useMemo(()=>au?Nn.map(x=>{const N=ir.has(x.source)||ir.has(x.target),F=x.className?x.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",U=N?"af-flow-edge--focus":"af-flow-edge--dim";return{...x,className:(F?F+" ":"")+U}}):Nn,[Nn,ir,au]);m.useEffect(()=>{if(!u){Hn({}),xr(null),Sa(_u),hl(Np),Ca(null),Eo(""),ja("");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=>{Hn(N.presets||{}),xr(N.activePreset||null)}).catch(()=>{Hn({}),xr(null)})},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived]);const Oo=m.useCallback(x=>{dt.current+=1,Sa(x)},[]),Mo=m.useCallback(async(x,N={})=>{if(!x)return;const F=!!N.quiet,U=!!N.force,V=dt.current;F||(qc(!0),Eo(""),ja(""));const Y=new URLSearchParams({flowId:x.id,flowSource:x.source||"user"});x.archived&&Y.set("archived","1");try{const J=await fetch(`/api/flow/schedule?${Y.toString()}`),ne=await J.json().catch(()=>({}));if(!J.ok)throw new Error(ne.error||`HTTP ${J.status}`);if(!U&&dt.current!==V)return;Sa({..._u,...ne.schedule||{}}),hl(ne.state&&typeof ne.state=="object"?ne.state:Np),Ca(ne.status||null)}catch(J){if(!U&&dt.current!==V)return;Sa(_u),hl(Np),Ca(null),Eo(String(J.message||J))}finally{qc(!1)}},[]);m.useEffect(()=>{if(!u)return;let x=!1;return(async()=>{await Mo(u)})(),()=>{x=!0}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Mo]),m.useEffect(()=>{var F,U,V,Y;if(!Yi||!Ps[Yi]||Zs.length===0)return;const x=Ps[Yi],N={};for(const J of Zs){const ne=Nl[J.id];if(!ne)continue;const me=((F=J.data)==null?void 0:F.definitionId)||"",je=x[J.id]??((Y=(V=(U=J.data)==null?void 0:U.outputs)==null?void 0:V[0])==null?void 0:Y.default)??"";me.startsWith("provide_file")?N[ne]={type:"file",path:je}:N[ne]={type:"str",value:je}}Object.keys(N).length>0&&jo(N)},[Yi,Ps,Zs,Nl]);const dT=m.useCallback(()=>{if(!Js||!Xc.current)return;const x=Xc.current.value;ht(N=>N.map(F=>{var U,V;return F.id!==Js.instanceId?F:{...F,data:{...F.data,outputs:((V=(U=F.data)==null?void 0:U.outputs)==null?void 0:V.map((Y,J)=>J===0?{...Y,default:x}:Y))||[{type:"text",name:"value",default:x}]}}})),Kr(null)},[Js,ht]),Je=m.useMemo(()=>{const x=Rt.filter(N=>N.selected);return x.length===1?x[0]:null},[Rt]),ji=m.useMemo(()=>u?mW(Rt,Nn,e):[],[u,Rt,Nn,e]),fT=m.useMemo(()=>ji.map(x=>x.key).join("|"),[ji]),E0=m.useMemo(()=>ji.some(x=>String((x==null?void 0:x.level)||"warning").toLowerCase()==="error"),[ji]);m.useLayoutEffect(()=>{W(ji.length>0&&!E0)},[fT,u==null?void 0:u.id,u==null?void 0:u.source,ji.length,E0]),Io.current=Je,m.useEffect(()=>{Ni.current=Rt},[Rt]),m.useEffect(()=>{Sl.current=Nn},[Nn]),m.useEffect(()=>{C0.current=Gr},[Gr]),m.useEffect(()=>{if(!Gr)return;const x=F=>{F.key==="Escape"&&Lo(null)},N=F=>{var U,V;(V=(U=F.target)==null?void 0:U.closest)!=null&&V.call(U,".af-connect-node-menu")||Lo(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",N)}},[Gr]),m.useEffect(()=>()=>{Ro.current!=null&&(clearTimeout(Ro.current),Ro.current=null)},[]);const Qm=m.useMemo(()=>{var N;if(!Je)return null;const x=(N=Je.data)==null?void 0:N.definitionId;return de.find(F=>F.id===x)??null},[Je,de]),Zm=m.useMemo(()=>{const x={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const N of de){const F=t0(N);x[F].push(N)}for(const N of zu)x[N].sort((F,U)=>F.id.localeCompare(U.id));return x},[de]),Ef=m.useMemo(()=>{const x=fe.trim().toLowerCase();if(!x)return Zm;const N={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const F of zu)N[F]=Zm[F].filter(U=>gV(U,x));return N},[Zm,fe]),pT=m.useMemo(()=>zu.reduce((x,N)=>x+Ef[N].length,0),[Ef]),_f=m.useMemo(()=>de.filter(x=>{const N=String(x.id??""),F=String(x.source??"");return N.startsWith("marketplace:")||F==="marketplace"||F==="collection"}),[de]),_0=m.useMemo(()=>{const x=new Set;for(const N of _f){const F=String(N.id??"");if(F&&(x.add(F),F.startsWith("marketplace:"))){const U=F.slice(12),[V]=U.split("@");V&&x.add(`marketplace:${V}`)}}return x},[_f]),Pf=m.useCallback(async()=>{d("");try{const x=await fetch("/api/flows");if(!x.ok)throw new Error("HTTP "+x.status);l(await x.json())}catch(x){d(String(x.message||x))}},[]);m.useEffect(()=>{Pf()},[Pf]),m.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]),m.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/model-lists").then(U=>U.json()).then(U=>{x||kf({cursor:Array.isArray(U.cursor)?U.cursor.map(String):[],opencode:Array.isArray(U.opencode)?U.opencode.map(String):[],claudeCode:Array.isArray(U.claudeCode)?U.claudeCode.map(String):[]})}).catch(()=>{})};N();const F=setTimeout(N,4e3);return()=>{x=!0,clearTimeout(F)}},[]),m.useEffect(()=>{let x=!1;return fetch("/api/skills").then(N=>N.json()).then(N=>{if(x)return;const F=Array.isArray(N.skills)?N.skills.filter(U=>U&&typeof U.key=="string"&&U.key.trim()).map(U=>({key:String(U.key),name:String(U.name||U.id||U.key),description:U.description?String(U.description):"",sourceLabel:U.sourceLabel?String(U.sourceLabel):""})):[];oe(F),ze(!0)}).catch(()=>{}),()=>{x=!0}},[]),m.useEffect(()=>{let x=!1;return fetch("/api/skill-collections").then(N=>N.json()).then(N=>{x||(Ht(la(N)),In(!0))}).catch(()=>{}),()=>{x=!0}},[]),m.useEffect(()=>{if(to(""),!(!Ie||!Nt)){if(!Un){Ne([]);return}Ne(CE(Un,"pipeline",ee,zt)),to(Un)}},[zt,Nt,ee,Ie,Un]),m.useEffect(()=>{if(!(To!==Un||!Un))try{localStorage.setItem(Un,JSON.stringify(ge))}catch{}},[ge,Un,To]);const P0=m.useCallback(async x=>{const N=x.source??"user",F=!!x.archived,U=new URLSearchParams({flowId:x.id,flowSource:N});F&&U.set("archived","1");const V=new URLSearchParams({flowId:x.id,flowSource:N});F&&V.set("archived","1"),V.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[Y,J]=await Promise.all([fetch("/api/flow?"+U.toString()),fetch("/api/nodes?"+V.toString())]),ne=await Y.json();if(!Y.ok||ne.error)throw new Error(ne.error||e("flow:nodePropsError.loadFlowFailed"));const me=await J.json();if(!J.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const je=Array.isArray(me)?me:Array.isArray(me==null?void 0:me.nodes)?me.nodes:[],Re=!Array.isArray(me)&&(me==null?void 0:me.pipelineTranslations)||{},se=fW(ne.flowYaml||"");if(se.error)throw new Error(se.error);const Ce={...se.instances||{}},ve=se.nodes.map(en=>Hd(en,Ce,je,Re,x.id)),Qe=eI(se.edges,ve);return{flowSource:N,paletteList:je,instances:Ce,flowDescriptionText:se.description??"",nodes:ve,edges:Qe}},[t.language,e]),Ts=m.useCallback(async(x,N={})=>{const F=!!N.preserveComposer,U=F&&!!N.incrementalSync;ou.current=!1,Xm.current+=1,f(x),y(""),F||(w(""),re(""),hn(null),b(""),$(""),H(""),Ta(""),b0([]),Si([]),su([]),k0(!1),iu(null),Jc("pan")),U||(Dr.current={},ht([]),cn([])),qN(x);try{const V=await P0(x);if(ce(V.paletteList),Dr.current=V.instances,b(V.flowDescriptionText),$(x.id||""),U){const Y=Ni.current,J=Sl.current;try{const ne=U8(Y,J,V.nodes,V.edges),me=new Set([...ne.changes.addedNodeIds,...ne.changes.updatedNodeIds]),je=new Set([...ne.changes.addedEdgeKeys,...ne.changes.updatedEdgeKeys]),Re=me.size>0?ne.nodes.map(Ce=>me.has(Ce.id)?{...Ce,className:MN(Ce.className,LN)}:Ce):ne.nodes,se=je.size>0?ne.edges.map(Ce=>je.has($d(Ce))?{...Ce,className:MN(Ce.className,ON)}:Ce):ne.edges;ht(Re),cn(se),Ro.current!=null&&(clearTimeout(Ro.current),Ro.current=null),(me.size>0||je.size>0)&&(Ro.current=window.setTimeout(()=>{Ro.current=null,me.size>0&&ht(Ce=>Ce.map(ve=>{if(!me.has(ve.id))return ve;const Qe=$N(ve.className,LN);return Qe===String(ve.className||"")?ve:{...ve,className:Qe}})),je.size>0&&cn(Ce=>Ce.map(ve=>{if(!je.has($d(ve)))return ve;const Qe=$N(ve.className,ON);return Qe===String(ve.className||"")?ve:{...ve,className:Qe}}))},pV))}catch{ht(V.nodes),cn(V.edges)}}else ht(V.nodes),cn(V.edges),h(Y=>Y+1);ip(x.id,V.flowSource),vf(Y=>Y+1);try{jf.current=xN(V.nodes,V.edges,V.instances,{description:V.flowDescriptionText})}catch{jf.current=""}ou.current=!0}catch(V){y(String(V.message||V))}},[P0,ht,cn]),Af=m.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 F=await fetch("/api/nodes?"+N.toString()),U=await F.json();if(!F.ok)throw new Error((U==null?void 0:U.error)||e("flow:nodePropsError.loadNodesFailed"));const V=Array.isArray(U)?U:Array.isArray(U==null?void 0:U.nodes)?U.nodes:[];ce(V)},[u,e,t.language]),eg=m.useCallback(async()=>{Mn(!0),Gt("");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");On(Array.isArray(N==null?void 0:N.nodes)?N.nodes:[])}catch(x){Gt(String(x.message||x)),On([])}finally{Mn(!1)}},[]),If=m.useCallback(async()=>{_t(!0),Te("");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");lt(Array.isArray(N==null?void 0:N.snippets)?N.snippets:[])}catch(x){Te(String(x.message||x)),lt([])}finally{_t(!1)}},[]);m.useEffect(()=>{u&&(eg(),If())},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,eg,If]);const hT=m.useCallback(async x=>{if(!u||!x)return;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`;if(N){he(N),Gt("");try{const F=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})}),U=await F.json().catch(()=>({}));if(!F.ok||(U==null?void 0:U.ok)===!1)throw new Error((U==null?void 0:U.error)||"Failed to install marketplace node");await Af()}catch(F){Gt(String(F.message||F))}finally{he("")}}},[u,Af]),mT=m.useCallback(async(x,N)=>{const F={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"},U=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),V=await U.json();if(!U.ok||(V==null?void 0:V.ok)===!1)throw new Error((V==null?void 0:V.error)||"Publish failed");return await Af(),V},[Af,u]),A0=m.useCallback(async()=>{var U;if(!u||ue.current)return;const x=u.id,N=u.source??"user",F=((U=Io.current)==null?void 0:U.id)??null;ue.current=!0,le(!0);try{await Ts({id:x,source:N,archived:u.archived},{preserveComposer:!0,incrementalSync:!0}),F&&ht(V=>V.map(Y=>({...Y,selected:Y.id===F})))}finally{ue.current=!1,le(!1)}},[u,u==null?void 0:u.archived,Ts,ht]);m.useEffect(()=>{if(N0.current||a.length===0)return;const x=new URLSearchParams(window.location.search),N=x.get("flowId");if(!N)return;const F=x.get("flowSource")??"user",U=x.get("flowArchived")==="1",V=a.find(Y=>Y.id===N&&(Y.source??"user")===F&&!!Y.archived===U);V&&(N0.current=!0,Ts(V))},[a,Ts]);const Tf=m.useRef(0);m.useEffect(()=>{if(!u)return;const x=u.id,N=u.source??"user",F=!!u.archived;Tf.current=0;let U=!1;const V=async()=>{var ne;if(U)return;const J=new URLSearchParams({flowId:x,flowSource:N,v:String(Tf.current)});F&&J.set("archived","1");try{const me=await fetch("/api/flow-editor-sync-poll?"+J.toString());if(!me.ok||U)return;const je=await me.json();if(U)return;if(je.changed){Tf.current=je.version;const Re=((ne=Io.current)==null?void 0:ne.id)??null;await Ts({id:x,source:N,archived:F},{preserveComposer:!0,incrementalSync:!0}),await Mo({id:x,source:N,archived:F},{quiet:!0,force:!0}),Re&&ht(se=>se.map(Ce=>({...Ce,selected:Ce.id===Re})))}else Tf.current=je.version}catch{}},Y=window.setInterval(V,2e3);return V(),()=>{U=!0,window.clearInterval(Y)}},[u==null?void 0:u.id,u==null?void 0:u.source,u==null?void 0:u.archived,Ts,Mo,ht]);const gT=m.useMemo(()=>v?v.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":v===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[v]);m.useEffect(()=>{if(!v)return;v===e("flow:status.saved")||v.startsWith(e("flow:status.runInTerminal"));const x=v.startsWith(e("flow:status.runInTerminal"))?5200:2800,N=window.setTimeout(()=>w(""),x);return()=>clearTimeout(N)},[v,e]),m.useEffect(()=>{E("")},[u==null?void 0:u.id,u==null?void 0:u.source]),m.useEffect(()=>{const x=()=>{window.__provideEditContent&&(Kr(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",x),()=>window.removeEventListener("provide-expand",x)},[]),m.useEffect(()=>{var ne,me,je,Re,se,Ce,ve;if(!Je){eu(null);return}const x=Dr.current[Je.id]||{},{inputs:N,outputs:F}=ZA(Je),U=String(((ne=Je.data)==null?void 0:ne.definitionId)??Je.id??""),V=((me=Je.data)==null?void 0:me.script)!=null?String(Je.data.script):void 0,Y=x.script!=null?String(x.script):void 0,J=U==="tool_nodejs"||V&&V.trim()!==""||Y&&Y.trim()!==""?String(V??Y??""):"";eu({id:Je.id,newId:Je.id,label:String(((je=Je.data)==null?void 0:je.label)??Je.id),role:((Re=Je.data)==null?void 0:Re.role)??"普通",model:String(((se=Je.data)==null?void 0:se.model)??x.model??""),body:String(((Ce=Je.data)==null?void 0:Ce.body)??x.body??""),images:ss(((ve=Je.data)==null?void 0:ve.images)??x.images),script:J,inputs:N,outputs:F})},[Je==null?void 0:Je.id,Km]),m.useEffect(()=>{u&&(Je||(bl.current=null,hn(x=>x==="node"?null:x)))},[u,Je==null?void 0:Je.id]);const Rf=m.useCallback(()=>{bl.current=null,hn(x=>x==="settings"||x==="history"?x:"node")},[]),yT=m.useCallback((x,N)=>{x.metaKey||x.ctrlKey||x.shiftKey||_e!=="edit"&&Ys((N==null?void 0:N.id)??null)},[_e]),xT=m.useCallback((x,N)=>{_e==="edit"&&(x.preventDefault(),ht(F=>F.map(U=>({...U,selected:U.id===N.id}))),cn(F=>F.map(U=>({...U,selected:!1}))),Rf())},[Rf,_e,cn,ht]),wT=m.useCallback((x,N)=>{if(_e!=="edit")return;const F=x.metaKey||x.ctrlKey||x.shiftKey;cn(U=>U.map(V=>V.id===N.id?{...V,selected:!V.selected||!F}:F?V:{...V,selected:!1})),F||ht(U=>U.map(V=>({...V,selected:!1})))},[_e,cn,ht]),vT=m.useCallback(x=>zN(x,Ni.current),[]),bT=m.useCallback(x=>{if(!zN(x,Ni.current)){w("端口类型不匹配,已取消连线");return}Lo(null),ht(N=>qh(N,x)),cn(N=>{const F=N.filter(U=>!(U.target===x.target&&U.targetHandle===x.targetHandle));return Ld({...x,markerEnd:{type:cs.ArrowClosed}},F)})},[cn,ht]),kT=m.useCallback((x,N)=>{Jm.current=yV(N,Ni.current),Lo(null)},[]),ST=m.useCallback((x,N)=>{var ve,Qe,en,Kt;const F=Jm.current;if(Jm.current=null,!u||!F||N!=null&&N.toNode)return;const U=wV(de,F);if(U.length===0){w(`没有匹配 ${F.slotType} 端口的节点`);return}const V=((Qe=(ve=x==null?void 0:x.changedTouches)==null?void 0:ve[0])==null?void 0:Qe.clientX)??(x==null?void 0:x.clientX),Y=((Kt=(en=x==null?void 0:x.changedTouches)==null?void 0:en[0])==null?void 0:Kt.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(V)||!Number.isFinite(Y))return;const J=La.current,ne=document.querySelector(".af-pipeline-flow .react-flow");if(!J||!ne)return;const me=ne.getBoundingClientRect(),je=320,Re=Math.min(440,104+U.length*58),se=Math.max(12,Math.min(V-me.left,me.width-je-12)),Ce=Math.max(12,Math.min(Y-me.top,me.height-Re-12));Lo({left:se,top:Ce,flowPosition:J.screenToFlowPosition({x:V,y:Y}),draft:F,candidates:U,query:""})},[de,u]),NT=m.useCallback(x=>{for(const N of x)delete Dr.current[N.id]},[]),jT=m.useCallback(x=>{La.current=x},[]),CT=m.useCallback(x=>{ht(F=>F.map(U=>({...U,selected:U.id===x}))),cn(F=>F.map(U=>({...U,selected:!1}))),Rf();const N=()=>{var me,je,Re;const F=La.current;if(!(F!=null&&F.getNode))return;const U=F.getNode(x);if(!U)return;const V=(me=F.getInternalNode)==null?void 0:me.call(F,x),Y=((je=V==null?void 0:V.measured)==null?void 0:je.width)??(V==null?void 0:V.width)??U.width??200,J=((Re=V==null?void 0:V.measured)==null?void 0:Re.height)??(V==null?void 0:V.height)??U.height??88,{zoom:ne}=F.getViewport();F.setCenter(U.position.x+Y/2,U.position.y+J/2,{zoom:WN(ne),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(N))},[ht,cn,Rf]),ET=m.useCallback(x=>{ht(F=>F.map(U=>({...U,selected:U.id===x}))),cn(F=>F.map(U=>({...U,selected:!1})));const N=()=>{var je,Re,se;const F=La.current;if(!(F!=null&&F.getNode))return;const U=F.getNode(x);if(!U)return;const V=(je=F.getInternalNode)==null?void 0:je.call(F,x),Y=((Re=V==null?void 0:V.measured)==null?void 0:Re.width)??(V==null?void 0:V.width)??U.width??200,J=((se=V==null?void 0:V.measured)==null?void 0:se.height)??(V==null?void 0:V.height)??U.height??88,{zoom:ne}=F.getViewport(),me=WN(ne);F.setCenter(U.position.x+Y/2,U.position.y+J/2,{zoom:me,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(N))},[ht,cn]),jl=m.useCallback((x,N)=>{const F=`node-${Date.now()}`;return gI(x,F,N,Dr.current,de)},[de]),I0=m.useCallback(x=>{if(!u||!x)return;let N={x:180,y:160};const F=La.current,U=document.querySelector(".af-pipeline-flow .react-flow");if(F&&U){const V=U.getBoundingClientRect();N=F.screenToFlowPosition({x:V.left+V.width*.45,y:V.top+V.height*.38})}ht(V=>[...V,jl(x,N)])},[u,ht,jl]),_T=m.useCallback(x=>{const N=C0.current;if(!u||!N||!(x!=null&&x.def))return;const F=jl(x.def,N.flowPosition),U=N.draft.handleType==="source"?{source:N.draft.nodeId,sourceHandle:N.draft.handleId,target:F.id,targetHandle:`input-${x.slotIndex}`}:{source:F.id,sourceHandle:`output-${x.slotIndex}`,target:N.draft.nodeId,targetHandle:N.draft.handleId};ht(V=>qh([...V,F],U)),cn(V=>{const Y=V.filter(J=>!(J.target===U.target&&J.targetHandle===U.targetHandle));return Ld({...U,markerEnd:{type:cs.ArrowClosed}},Y)}),Lo(null)},[u,jl,ht,cn]),PT=m.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),AT=m.useCallback(x=>{var J;if(x.preventDefault(),!u)return;const N=La.current;if(!N)return;const F=N.screenToFlowPosition({x:x.clientX,y:x.clientY}),U=x.dataTransfer.getData("application/agentflow-snippet");if(U){const ne=Be.find(me=>`${me.id}@${me.version}`===U);ne&&((J=Cf.current)==null||J.call(Cf,ne,F));return}const V=x.dataTransfer.getData("application/agentflow-node");if(!V)return;const Y=de.find(ne=>ne.id===V);Y&&ht(ne=>[...ne,jl(Y,F)])},[u,de,Be,ht,jl]),Ci=m.useCallback(async(x,N)=>{if(!u)return;const F=xN(x,N,Dr.current,{description:g});if(F!==jf.current){w(e("flow:status.saving"));try{const U=$V(u.source),V=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,flowSource:U,flowYaml:F,...u.archived?{flowArchived:!0}:{}})}),Y=await V.json();if(!V.ok||!Y.success)throw new Error(Y.error||e("flow:status.saveFailed"));if(jf.current=F,w(e("flow:status.saved")),u.source==="builtin"&&U==="workspace"){const J={id:u.id,source:"workspace",path:void 0};f(J),qN(J),ip(u.id,"workspace")}}catch(U){w(e("flow:status.saveFailed")+": "+(U.message||U))}}},[u,g]);m.useEffect(()=>{if(!u||!ou.current||_e!=="edit"||u.archived)return;const x=Xm.current,N=setTimeout(()=>{x===Xm.current&&ou.current&&Ci(Ni.current,Sl.current)},400);return()=>clearTimeout(N)},[Rt,Nn,g,_e,u,Ci]);const Lf=m.useCallback(async x=>{if(!u||u.archived)return;const N=u.source??"user";if(!(N!=="user"&&N!=="workspace")&&N!==x){I(!0),E("");try{const F=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:u.id,fromSource:N,toSource:x})}),U=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof U.error=="string"?U.error:e("flow:composer.requestFailed"));const V=U.flowSource==="workspace"||U.flowSource==="user"?U.flowSource:x;let Y={id:u.id,source:V,archived:u.archived};try{const J=await fetch("/api/flows");if(J.ok){const ne=await J.json(),me=Array.isArray(ne)?ne.find(je=>je.id===u.id&&(je.source??"user")===V&&!!je.archived==!!u.archived):null;me&&(Y=me)}}catch{}await Ts(Y,{preserveComposer:!0}),ip(u.id,V)}catch(F){E(String(F.message||F))}finally{I(!1)}}},[u,Ts]),tg=m.useCallback(async()=>{if(u){Yc(!0),Eo(""),ja("");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:mn})}),N=await x.json().catch(()=>({}));if(!x.ok||!N.success)throw new Error(N.error||"Failed to save schedule");Sa({..._u,...N.schedule||{}}),ja(e("flow:schedule.saved")),await Mo(u,{quiet:!0,force:!0})}catch(x){Eo(String(x.message||x))}finally{Yc(!1)}}},[u,mn,Mo,e]),IT=m.useCallback(async()=>{u&&(await Ci(Ni.current,Sl.current),!u.archived&&u.source!=="builtin"&&await tg())},[u,Ci,tg]),Of=m.useCallback(async()=>{if(!u||!R.trim())return;const x=R.trim();if(x===u.id){H("");return}D(!0),H("");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})}),F=await N.json().catch(()=>({}));if(!N.ok)throw new Error(typeof F.error=="string"?F.error:e("flow:composer.requestFailed"));let U={id:F.flowId,source:F.flowSource??u.source,archived:u.archived};try{const V=await fetch("/api/flows");if(V.ok){const Y=await V.json(),J=Array.isArray(Y)?Y.find(ne=>ne.id===F.flowId&&(ne.source??"user")===(F.flowSource??u.source)):null;J&&(U=J)}}catch{}await Ts(U,{preserveComposer:!0}),ip(F.flowId,F.flowSource??u.source)}catch(N){H(String(N.message||N))}finally{D(!1)}},[u,R,Ts]),T0=m.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{O(!0),setTimeout(()=>O(!1),2e3)}).catch(()=>{})},[]),ng=m.useCallback(()=>{Ci(Rt,Nn)},[Ci,Rt,Nn]),TT=m.useCallback((x,N)=>{const F=N.trim()===""||N==="default"?void 0:N.trim(),U=Rt.map(V=>V.id===x?{...V,data:{...V.data,model:F}}:V);ht(U),Ci(U,Nn)},[Rt,Nn,ht,Ci]),Mf=m.useCallback(()=>{var Qe,en;if(!Ke||!u||!Je)return!1;const x=Je.id,N=Ke.newId.trim();if(kl(""),!lI.test(N))return kl(e("flow:nodePropsError.invalidInstanceId")),!1;if(Rt.some(Kt=>Kt.id===N&&Kt.id!==x))return kl(e("flow:nodePropsError.duplicateInstanceId")),!1;const F=Ke.role.trim(),U=ma.includes(F)?F:"普通",V=Ke.model.trim(),Y=Kt=>(Array.isArray(Kt)?Kt:[]).map(Ot=>({type:String((Ot==null?void 0:Ot.type)??"节点").trim()||"节点",name:String((Ot==null?void 0:Ot.name)??""),default:String((Ot==null?void 0:Ot.default)??""),required:!!(Ot!=null&&Ot.required),showOnNode:(Ot==null?void 0:Ot.showOnNode)!=null?Ot.showOnNode!==!1:!!(Ot!=null&&Ot.required)||String((Ot==null?void 0:Ot.type)??"节点").trim().toLowerCase()==="node"})),J=Y(Ke.inputs),ne=Y(Ke.outputs),me=String(((Qe=Je.data)==null?void 0:Qe.definitionId)??N),je=me.startsWith("provide_"),Re={...Je.data,label:Ke.label.trim()||N,role:U,model:V===""||V==="default"?void 0:V,body:je?"":Ke.body,images:je?[]:ss(Ke.images),inputs:J,outputs:je&&Array.isArray((en=Je.data)==null?void 0:en.outputs)?Je.data.outputs:ne},se=String(Ke.script??"").trim();me==="tool_nodejs"||se!==""?Re.script=String(Ke.script??""):delete Re.script;let Ce,ve=Nn;if(N!==x){const Kt={...Dr.current},Ot={...Kt[x]||{}};delete Kt[x],Kt[N]=Ot,Dr.current=Kt,Ce=Rt.map(st=>st.id!==x?st:{...st,id:N,selected:!0,data:Re}),ve=Nn.map((st,Pe)=>({...st,source:st.source===x?N:st.source,target:st.target===x?N:st.target,id:`e-${st.source===x?N:st.source}-${st.target===x?N:st.target}-${Pe}`}))}else Ce=Rt.map(Kt=>Kt.id===x?{...Kt,data:Re}:Kt);return ht(Ce),cn(ve),hr(N),Ci(Ce,ve),!0},[Ke,u,Je,Rt,Nn,ht,cn,hr,Ci]),rg=m.useCallback(()=>{var en,Kt;if(!Ke||!u||!Je)return!1;const x=Je.id,N=Ke.role.trim(),F=ma.includes(N)?N:"普通",U=Ke.model.trim(),V=Ot=>(Array.isArray(Ot)?Ot:[]).map(st=>({type:String((st==null?void 0:st.type)??"节点").trim()||"节点",name:String((st==null?void 0:st.name)??""),default:String((st==null?void 0:st.default)??""),required:!!(st!=null&&st.required),showOnNode:(st==null?void 0:st.showOnNode)!=null?st.showOnNode!==!1:!!(st!=null&&st.required)||String((st==null?void 0:st.type)??"节点").trim().toLowerCase()==="node"})),Y=V(Ke.inputs),J=V(Ke.outputs),ne=String(((en=Je.data)==null?void 0:en.definitionId)??x),me=ne.startsWith("provide_"),je=Ke.label.trim()||x,Re=U===""||U==="default"?void 0:U,se={...Je.data,label:je,role:F,model:Re,body:me?"":Ke.body,images:me?[]:ss(Ke.images),inputs:Y,outputs:me&&Array.isArray((Kt=Je.data)==null?void 0:Kt.outputs)?Je.data.outputs:J},Ce=String(Ke.script??"").trim();ne==="tool_nodejs"||Ce!==""?se.script=String(Ke.script??""):delete se.script;const ve=Je.data||{};return(ve.label!==se.label||ve.role!==se.role||ve.model!==se.model||ve.body!==se.body||JSON.stringify(ss(ve.images))!==JSON.stringify(se.images)||(ve.script??void 0)!==(se.script??void 0)||JSON.stringify(ve.inputs||[])!==JSON.stringify(Y)||JSON.stringify(ve.outputs||[])!==JSON.stringify(J))&&(ht(Ot=>Ot.map(st=>st.id===x?{...st,data:se}:st)),hr(x)),!0},[Ke,u,Je,ht,hr]),R0=m.useRef(rg);m.useEffect(()=>{R0.current=rg},[rg]),m.useEffect(()=>{if(!Ke||!u||!ou.current||_e!=="edit")return;const x=setTimeout(()=>{R0.current()},400);return()=>clearTimeout(x)},[Ke,u,_e]);const RT=m.useCallback(()=>{if(!(!Ke||!Je)){if(Ke.newId.trim()===Je.id){kl("");return}Mf()}},[Ke,Je,Mf]);m.useEffect(()=>{const x=N=>{var U,V,Y;if(_e!=="edit")return;const F=rI(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){if(nt==="node"&&Je&&Ke){N.preventDefault(),N.stopPropagation(),Mf()||ng();return}if(F)return;N.preventDefault(),N.stopPropagation(),ng();return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),wf(J=>!J);return}if(!Qc){if(vl){if(N.key==="Escape"){N.preventDefault(),vi(!1);return}if(Gh(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),vi(!1);return}(N.key==="v"||N.key==="V"||N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey&&N.preventDefault();return}if(!F){if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="c"){const J=GA(Ni.current,Sl.current,Dr.current);J&&(N.preventDefault(),N.stopPropagation(),j0.current=J,w(`Copied ${J.nodes.length} node${J.nodes.length>1?"s":""}`));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="v"){const J=XA(j0.current,Ni.current,Sl.current,Dr.current);J&&(N.preventDefault(),N.stopPropagation(),Dr.current=J.instances,ht(J.nodes),cn(J.edges),w(`Pasted ${J.pastedNodeIds.length} node${J.pastedNodeIds.length>1?"s":""}`));return}if((N.key==="a"||N.key==="A")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),(U=ye.current)==null||U.focus(),(Y=(V=ye.current)==null?void 0:V.select)==null||Y.call(V);return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="a"){N.preventDefault(),N.stopPropagation(),ht(J=>J.map(ne=>({...ne,selected:!0}))),cn(J=>J.map(ne=>({...ne,selected:!1})));return}if(Gh(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),vi(J=>!J);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Jc("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),Jc("pan");return}}}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[ng,vl,Qc,nt,Je,Ke,Mf,_e]),m.useEffect(()=>{if(_e!=="running"||Ks==null)return;let x=Math.floor((Date.now()-Ks)/1e3);const N=setInterval(()=>{const F=Date.now()-Ks,U=Math.floor(F/1e3);U!==x&&(x=U,$r(F))},500);return()=>clearInterval(N)},[_e,Ks]),m.useEffect(()=>{const x=ml.current;!x||!x.parentElement||Ea.current&&(Xs.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Xs.current=!1}))},[Er]),m.useEffect(()=>{const x=ml.current;if(!x)return;const N=x.parentElement;if(!N)return;const F=()=>{if(Xs.current)return;const U=N.scrollHeight-N.scrollTop-N.clientHeight;Ea.current=U<40};return N.addEventListener("scroll",F,{passive:!0}),()=>N.removeEventListener("scroll",F)},[gr,_e]),m.useEffect(()=>{if(_e==="edit"||!gr)return;Ea.current=!0;const x=ml.current;x&&(Xs.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{Xs.current=!1}))},[_e,gr]),m.useEffect(()=>{Er.length>Qp+VN&&ot(x=>x.length>Qp+VN?x.slice(-Qp):x)},[Er]);const LT=m.useCallback(x=>{if(x.button!==0)return;x.preventDefault();const N=x.currentTarget;ct.current={active:!0,pointerId:x.pointerId,startY:x.clientY,startH:yt},N.setPointerCapture(x.pointerId)},[yt]),OT=m.useCallback(x=>{const N=ct.current;if(!N.active||x.pointerId!==N.pointerId)return;const F=N.startY-x.clientY;Bn(Zp(N.startH+F))},[]),$f=m.useCallback(()=>{Bn(x=>{const N=Zp(x);try{localStorage.setItem(yI,String(N))}catch{}return N})},[]),L0=m.useCallback(x=>{const N=ct.current;if(!(!N.active||x.pointerId!==N.pointerId)){N.active=!1;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}$f()}},[$f]),MT=m.useCallback(()=>{const x=ct.current;x.active&&(x.active=!1,$f())},[$f]);m.useEffect(()=>{function x(){Bn(N=>Zp(N))}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const Ei=m.useCallback(async(x={})=>{if(!u)return;const N=x.runUuid!=null&&String(x.runUuid).trim()?String(x.runUuid).trim():null,F=x.cliInputsOverride??_s.current,U=!!x.prepareOnly;if(bn(U?"ready":"running"),ot(U?[]:[{ts:new Date().toISOString(),type:"info",text:N?e("flow:run.connectingApiResume",{uuid:N}):e("flow:run.connectingApi")}]),zn(new Set),Jn({}),yr(!U),hn(null),N||or(null),U)return;if(!N){const Y=Date.now();_r(Y),$r(0)}const V=new AbortController;As.current=V;try{const Y=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:F}),signal:V.signal});if(!Y.ok){const se=await Y.json().catch(()=>({error:e("flow:composer.requestFailed")}));ot(Ce=>[...Ce,{ts:new Date().toISOString(),type:"error",text:se.error||e("flow:composer.requestFailed")}]),bn("error");return}if(ot(se=>[...se,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!Y.body){ot(se=>[...se,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),bn("error");return}const J=Y.body.getReader(),ne=new TextDecoder;let me="";const je=se=>{const Ce=se.ts||new Date().toISOString();if(se.type==="event")if(se.event==="node-start")zn(ve=>new Set(ve).add(se.instanceId)),Jn(ve=>({...ve,[se.instanceId]:{status:"running",startMs:Date.now()}})),ot(ve=>[...ve,{ts:Ce,type:"node-start",text:se.label?e("flow:run.nodeStartWithLabel",{instanceId:se.instanceId,label:se.label}):e("flow:run.nodeStart",{instanceId:se.instanceId})}]);else if(se.event==="node-done"){zn(Qe=>{const en=new Set(Qe);return en.delete(se.instanceId),en});const ve=se.elapsed??null;Jn(Qe=>({...Qe,[se.instanceId]:{status:"success",elapsed:ve}})),ot(Qe=>[...Qe,{ts:Ce,type:"node-done",text:ve?e("flow:run.nodeDoneWithElapsed",{instanceId:se.instanceId,elapsed:ve}):e("flow:run.nodeDone",{instanceId:se.instanceId})}])}else if(se.event==="node-failed")zn(ve=>{const Qe=new Set(ve);return Qe.delete(se.instanceId),Qe}),Jn(ve=>({...ve,[se.instanceId]:{status:"failed",elapsed:se.elapsed??null}})),ot(ve=>[...ve,{ts:Ce,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:se.instanceId})}]);else if(se.event==="apply-start"){if(se.uuid&&or(String(se.uuid)),typeof se.runStartTime=="number"&&se.runStartTime>0)_r(se.runStartTime),$r(Math.max(0,Date.now()-se.runStartTime));else if(typeof se.totalExecutedMs=="number"&&se.totalExecutedMs>0){const ve=Date.now()-se.totalExecutedMs;_r(ve),$r(se.totalExecutedMs)}ot(ve=>[...ve,{ts:Ce,type:"info",text:e("flow:run.pipelineStart",{uuid:se.uuid||"?"})}])}else se.event==="apply-done"?ot(ve=>[...ve,{ts:Ce,type:"info",text:se.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:se.totalElapsed}):e("flow:run.pipelineDone")}]):se.event==="apply-paused"?ot(ve=>[...ve,{ts:Ce,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(se.pendingNodes||[]).join(", ")})}]):ot(ve=>[...ve,{ts:Ce,type:"event",text:`[${se.event}] ${JSON.stringify(se)}`}]);else se.type==="user-check-content"?(gl({instanceId:se.instanceId,execId:se.execId??1,inputPath:se.inputPath,outputPath:se.outputPath,content:se.content||""}),_o(se.content||""),kn(!1),yl(""),Ji(!1),ot(ve=>[...ve,{ts:Ce,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:se.instanceId})}])):se.type==="user-ask-prompt"?(Qi({instanceId:se.instanceId,execId:se.execId??1,question:se.question||"",options:Array.isArray(se.options)?se.options:[]}),Ia(!1),ot(ve=>[...ve,{ts:Ce,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:se.instanceId,defaultValue:`等待用户选择 (${se.instanceId})`})}])):se.type==="tool-print-content"?(Zi({instanceId:se.instanceId,execId:se.execId??1,content:se.content||"",createdAt:Date.now()}),eo(!1)):se.type==="log"?ot(ve=>[...ve,{ts:Ce,type:"log",text:se.text!=null?String(se.text):""}]):se.type==="error"?ot(ve=>[...ve,{ts:Ce,type:"error",text:se.message||e("flow:run.unknownError")}]):se.type==="done"?ot(ve=>[...ve,{ts:Ce,type:"done",text:e("flow:run.executionEnd",{exitCode:se.exitCode??"?"})}]):ot(ve=>[...ve,{ts:Ce,type:"log",text:JSON.stringify(se)}])},Re=se=>{if(se.trim())try{je(JSON.parse(se))}catch{ot(Ce=>[...Ce,{ts:new Date().toISOString(),type:"log",text:se}])}};for(;;){const{done:se,value:Ce}=await J.read();me+=ne.decode(Ce??new Uint8Array,{stream:!se});const ve=me.split(`
133
- `);me=ve.pop()??"";for(const Qe of ve)Re(Qe);if(se)break}me.trim()&&Re(me),bn("done")}catch(Y){Y.name==="AbortError"?(ot(J=>[...J,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),bn("stopped")):(ot(J=>[...J,{ts:new Date().toISOString(),type:"error",text:Y.message||e("flow:run.unknownError")}]),bn("error"))}finally{As.current=null,zn(new Set)}},[u]),[$T,sg]=m.useState(!1),DT=m.useCallback(()=>{sg(!0)},[]),FT=m.useCallback(async()=>{if(sg(!1),As.current&&(As.current.abort(),As.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{}bn("stopped"),zn(new Set)},[u]),Oa=m.useCallback(()=>{bn("edit"),zn(new Set),Jn({}),Ys(null),or(null)},[]),[zT,Df]=m.useState(!1),BT=m.useCallback(async()=>{if(Df(!1),As.current&&(As.current.abort(),As.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{}Oa()},[u,Oa]),HT=m.useCallback(()=>{Df(!1),n("/projects")},[n]),UT=m.useCallback(x=>{const N=x.runId!=null&&String(x.runId).trim()?String(x.runId).trim():null,F=x.flowId!=null&&String(x.flowId).trim()?String(x.flowId).trim():(u==null?void 0:u.id)!=null?String(u.id):null;or(N);const U=x.status||"unknown";let V="stopped";U==="success"?V="done":U==="failed"?V="error":U==="running"?V="running":V="stopped",bn(V);const Y=typeof x.at=="number"?x.at:null;if(V==="running"&&Y!=null?(_r(Y),$r(Math.max(0,Date.now()-Y))):Y!=null&&typeof x.endedAt=="number"&&x.endedAt>Y?(_r(null),$r(x.endedAt-Y)):(_r(null),$r(Math.max(0,x.durationMs??0))),ot([]),zn(new Set),Jn({}),Ys(null),hn(null),yr(!1),N&&F){const J=new URLSearchParams({flowId:F,runId:N});fetch(`/api/run-node-statuses?${J}`).then(ne=>ne.json()).then(ne=>{const me=ne.statuses&&typeof ne.statuses=="object"?ne.statuses:{},je={};for(const[Re,se]of Object.entries(me))se&&typeof se=="object"&&typeof se.status=="string"&&(je[Re]={status:se.status,...se.elapsed!=null&&String(se.elapsed).trim()!==""?{elapsed:String(se.elapsed)}:{}});Jn(je)}).catch(()=>{})}},[u==null?void 0:u.id]);m.useEffect(()=>{if(!(u!=null&&u.id)||_e!=="edit")return;let x=!1;return(async()=>{try{const N=await fetch("/api/pipeline-recent-runs"),F=await N.json();if(x||!N.ok)return;const V=(Array.isArray(F.runs)?F.runs:[]).find(ne=>ne.flowId===u.id&&ne.status==="running");if(!V||x)return;const Y=V.runId||null;or(Y),bn("running"),yr(!0),_r(V.at||Date.now()),Xn.current=0;const J=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${Y},已恢复运行视图`}];if(Y){const ne=new URLSearchParams({flowId:u.id,runId:Y}),je=await(await fetch(`/api/run-node-statuses?${ne}`)).json();if(x)return;const Re=je.statuses&&typeof je.statuses=="object"?je.statuses:{},se={},Ce=new Set;for(const[ve,Qe]of Object.entries(Re))Qe&&typeof Qe=="object"&&typeof Qe.status=="string"&&(se[ve]={status:Qe.status,...Qe.elapsed!=null&&String(Qe.elapsed).trim()!==""?{elapsed:String(Qe.elapsed)}:{}},Qe.status==="running"&&Ce.add(ve));Jn(se),zn(Ce);try{const ve=new URLSearchParams({flowId:u.id,runId:Y,sinceBytes:"0",tailBytes:"262144"}),Qe=await fetch(`/api/run-log?${ve}`);if(Qe.ok){const en=await Qe.json();if(!x){Xn.current=Number(en.bytes||0);const Kt=KN(typeof en.text=="string"?en.text:"");ot([...Kt,...J]);return}}}catch{}}ot(J)}catch{}})(),()=>{x=!0}},[u==null?void 0:u.id]),m.useEffect(()=>{if(_e==="edit"||!(u!=null&&u.id)||!wt)return;let x=!1,N=null;const F=async()=>{try{const U=new URLSearchParams({flowId:u.id,runId:wt}),V=await fetch(`/api/run-node-statuses?${U}`);if(!V.ok)return;const Y=await V.json();if(x)return;const J=Y.statuses&&typeof Y.statuses=="object"?Y.statuses:{},ne={},me=new Set;for(const[je,Re]of Object.entries(J))Re&&typeof Re=="object"&&typeof Re.status=="string"&&(ne[je]={status:Re.status,...Re.elapsed!=null&&String(Re.elapsed).trim()!==""?{elapsed:String(Re.elapsed)}:{}},Re.status==="running"&&me.add(je));Jn(je=>LV(je,ne)?je:ne),zn(je=>OV(je,me)?je:me);try{const je=new URLSearchParams({flowId:u.id,runId:wt,sinceBytes:String(Xn.current||0),tailBytes:String(AV)}),Re=await fetch(`/api/run-log?${je}`);if(Re.ok){const se=await Re.json();if(x)return;const Ce=Number(se.bytes||0),ve=typeof se.text=="string"?se.text:"";if(ve){const Qe=KN(ve);Qe.length>0&&ot(en=>[...en,...Qe])}Xn.current=Ce}}catch{}try{const je=await fetch("/api/pipeline-recent-runs");if(!je.ok)return;const Re=await je.json();if(x)return;const Ce=(Array.isArray(Re.runs)?Re.runs:[]).find(ve=>ve.flowId===u.id&&ve.runId===wt);if(Ce&&Ce.status){const ve=Ce.status;ve==="running"?bn(Qe=>Qe==="running"?Qe:"running"):ve==="success"?bn("done"):ve==="failed"?bn("error"):(ve==="stopped"||ve==="interrupted")&&bn("stopped")}}catch{}}catch{}};return F(),N=window.setInterval(F,2500),()=>{x=!0,N&&window.clearInterval(N)}},[_e,u==null?void 0:u.id,wt]),m.useEffect(()=>{if(nt!=="history"||!u)return;let x=!1;return(async()=>{xi(!0),pr("");try{const N=await fetch("/api/pipeline-recent-runs"),F=await N.json();if(!N.ok)throw new Error(F.error||"HTTP "+N.status);x||Pn(Array.isArray(F.runs)?F.runs:[])}catch(N){x||(pr(String(N.message||N)),Pn([]))}finally{x||xi(!1)}})(),()=>{x=!0}},[nt,u]),m.useEffect(()=>{if(!u){Vt({files:[]});return}let x=!1;return(async()=>{mr(!0);try{const N=new URLSearchParams({flowId:u.id,flowSource:u.source||"user",archived:u.archived?"1":"0"}),F=await fetch(`/api/pipeline-files?${N}`),U=await F.json();if(!F.ok)throw new Error(U.error||"HTTP "+F.status);x||Vt({files:Array.isArray(U.files)?U.files:[],path:U.path,error:U.error})}catch(N){x||Vt({files:[],error:N.message||String(N)})}finally{x||mr(!1)}})(),()=>{x=!0}},[u]);const lu=m.useMemo(()=>u?Us.filter(x=>x&&x.flowId===u.id).sort((x,N)=>N.at-x.at):[],[Us,u]),Fr=m.useMemo(()=>{let x=0,N=0,F=0,U=0,V=0;for(const Y of lu){const J=Y.status||"unknown";J==="success"?x+=1:J==="failed"?N+=1:J==="running"?F+=1:J==="stopped"?U+=1:J==="interrupted"&&(V+=1)}return{success:x,failed:N,running:F,stopped:U,interrupted:V}},[lu]),cu=m.useMemo(()=>u?BN(qr,wl):null,[u,qr,wl]),ei=m.useMemo(()=>{if(!cu||!u)return[];const x=cu.query.toLowerCase(),N=V=>x?V.some(Y=>Y&&String(Y).toLowerCase().includes(x)):!0,F=Rt.map(V=>{var je,Re;const Y=V.id,J=String(((je=V.data)==null?void 0:je.label)??Y),ne=(Re=V.data)!=null&&Re.definitionId?String(V.data.definitionId):"",me=[J!==Y?J:"",ne&&ne!==Y?ne:""].filter(Boolean);return{id:Y,label:J,defId:ne,subs:me}}).filter(({id:V,label:Y,defId:J})=>N([V,Y,J])).sort((V,Y)=>V.id.localeCompare(Y.id)).slice(0,18).map(({id:V,label:Y,defId:J})=>{const ne=[Y!==V?Y:null,J||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:V,title:V,subtitle:ne}}),U=de.filter(V=>V&&V.id&&N([V.id,V.label,V.description])).sort((V,Y)=>V.id.localeCompare(Y.id)).slice(0,22).map(V=>({kind:"definition",id:V.id,title:V.id,subtitle:V.label&&V.label!==V.id?String(V.label):String(V.type||"")}));return[...F,...U]},[cu,Rt,de,u]),uu=m.useMemo(()=>{const x=ei.filter(F=>F.kind==="instance"),N=ei.filter(F=>F.kind==="definition");return{instances:x,definitions:N}},[ei]);m.useEffect(()=>{Ao(x=>{const N=Math.max(0,ei.length-1);return Math.min(Math.max(0,x),N)})},[ei]);const O0=m.useMemo(()=>bV(qr),[qr]),wr=m.useMemo(()=>Rt.filter(x=>x.selected),[Rt]),ig=m.useMemo(()=>new Set(wr.map(x=>x.id)),[wr]),Ff=m.useMemo(()=>Nn.filter(x=>ig.has(x.source)&&ig.has(x.target)),[Nn,ig]),M0=m.useMemo(()=>{const x=fe.trim().toLowerCase();return x?Be.filter(N=>[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].filter(Boolean).some(F=>String(F).toLowerCase().includes(x))):Be},[Be,fe]),$0=m.useCallback((x,N)=>{const F=String(x||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",U=Date.now().toString(36);let V=`${F}-${U}`,Y=2;for(;N.has(V);)V=`${F}-${U}-${Y}`,Y+=1;return N.add(V),V},[]),D0=m.useCallback((x,N)=>{var st;if(!u||!x)return;const F=x.snippet&&typeof x.snippet=="object"?x.snippet:{},U=F.instances&&typeof F.instances=="object"?F.instances:{},V=Object.keys(U);if(V.length===0)return;const Y=new Set(Ni.current.map(Pe=>Pe.id)),J={};for(const Pe of V)J[Pe]=$0(Pe,Y);const ne=(st=F.ui)!=null&&st.nodePositions&&typeof F.ui.nodePositions=="object"?F.ui.nodePositions:{},me=V.map(Pe=>{const Mt=ne[Pe];return{id:Pe,x:typeof(Mt==null?void 0:Mt.x)=="number"?Mt.x:0,y:typeof(Mt==null?void 0:Mt.y)=="number"?Mt.y:0}}),je=Math.min(...me.map(Pe=>Pe.x)),Re=Math.min(...me.map(Pe=>Pe.y));let se=N||{x:180,y:160};const Ce=La.current,ve=document.querySelector(".af-pipeline-flow .react-flow");if(!N&&Ce&&ve){const Pe=ve.getBoundingClientRect();se=Ce.screenToFlowPosition({x:Pe.left+Pe.width*.48,y:Pe.top+Pe.height*.32})}const Qe={};for(const Pe of V)Qe[J[Pe]]={...U[Pe]||{}};Dr.current={...Dr.current,...Qe};const en=V.map(Pe=>{const Mt=U[Pe]||{},Zn=me.find(no=>no.id===Pe)||{x:0,y:0},$o={id:J[Pe],type:"flowNode",selected:!0,position:{x:se.x+(Zn.x-je),y:se.y+(Zn.y-Re)},data:{label:Mt.label||J[Pe],definitionId:Mt.definitionId||Pe,role:Mt.role||"normal",body:Mt.body||"",script:Mt.script||""}};return Hd($o,Dr.current,de,{},u.id)}),Kt=new Set(V),Ot=(Array.isArray(F.edges)?F.edges:[]).filter(Pe=>Kt.has(Pe==null?void 0:Pe.source)&&Kt.has(Pe==null?void 0:Pe.target)).map((Pe,Mt)=>({id:`e-${J[Pe.source]}-${J[Pe.target]}-${Date.now()}-${Mt}`,source:J[Pe.source],target:J[Pe.target],sourceHandle:Pe.sourceHandle??void 0,targetHandle:Pe.targetHandle??void 0,markerEnd:{type:cs.ArrowClosed}}));ht(Pe=>[...Pe.map(Mt=>({...Mt,selected:!1})),...en]),cn(Pe=>[...Pe.map(Mt=>({...Mt,selected:!1})),...Ot]),w(`已添加流程片段:${x.displayName||x.id}`)},[$0,de,u,cn,ht]);Cf.current=D0;const WT=m.useCallback(()=>{var F,U;if(wr.length<2){Te("请先在画布上选择至少两个节点。"),ae("flows");return}const x=wr[0],N=wr.length===2?`${((F=x.data)==null?void 0:F.label)||x.id} 片段`:`${((U=x.data)==null?void 0:U.label)||x.id} 等 ${wr.length} 个节点`;_n({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),xe(""),Fn(!0),ae("flows")},[wr]),VT=m.useCallback(async()=>{var V,Y;if(!u||wr.length<2)return;const x=qt.name.trim();if(!x){xe("请填写片段名称。");return}const N=uf(wr,Dr.current),F={};for(const J of wr)F[J.id]={x:((V=J.position)==null?void 0:V.x)||0,y:((Y=J.position)==null?void 0:Y.y)||0};const U=Ff.map(J=>({source:J.source,target:J.target,sourceHandle:J.sourceHandle??null,targetHandle:J.targetHandle??null}));fr(!0),xe("");try{const J=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:qt.id,name:x,displayName:x,version:"1.0.0",description:qt.description,snippet:{instances:N,edges:U,ui:{nodePositions:F}}})}),ne=await J.json().catch(()=>({}));if(!J.ok||(ne==null?void 0:ne.ok)===!1)throw new Error((ne==null?void 0:ne.error)||"Publish failed");Fn(!1),w(`流程片段已发布:${ne.id||x}`),Ws(`流程片段已发布:${ne.id||x}`),await If(),ae("flows")}catch(J){xe(String(J.message||J))}finally{fr(!1)}},[u,wr,Ff,qt,If,Ws]),zf=m.useMemo(()=>{const x=[],N=new Set;for(const V of wr)N.add(V.id),x.push({node:V,kind:"canvas"});const F=new Map(Rt.map(V=>[V.id,V])),U=new Map(de.map(V=>[V.id,V]));for(const V of O0){if(N.has(V))continue;const Y=F.get(V);if(Y){N.add(V),x.push({node:Y,kind:"mention"});continue}const J=U.get(V);J&&(N.add(V),x.push({definition:J,kind:"definition"}))}return x},[wr,O0,Rt,de]),Xr=m.useMemo(()=>{const x=Array.isArray(rt==null?void 0:rt.cursor)?rt.cursor:[],N=Array.isArray(rt==null?void 0:rt.opencode)?rt.opencode:[],F=Array.isArray(rt==null?void 0:rt.claudeCode)?rt.claudeCode:[],U=N.map(je=>`opencode:${ao(je)}`),V=F.map(je=>`claude-code:${ao(je)}`),Y=new Set([...x,...N,...F].map(ao).concat(U).concat(V)),J=(P||"").trim(),ne=Sp(P,x,N,F),me=ne&&!Y.has(ne)&&!Y.has(J)?J:"";return{cursorList:x,opencodeList:N,claudeCodeList:F,currentNotInLists:me}},[rt,P]),og=m.useMemo(()=>new Set(ge),[ge]),ag=ge.length,Bf=m.useMemo(()=>{const x=new Map(ee.map(Y=>[Y.key,Y])),N=new Set,F=new Set,U=zt.map(Y=>{const J=pa(Y,ee).map(ne=>x.get(ne)).filter(Boolean);for(const ne of J)N.add(ne.key),F.add(String(ne.name||ne.id||ne.key||"").trim());return{...Y,skills:J}}).filter(Y=>Y.skills.length>0),V=ee.filter(Y=>{const J=String(Y.name||Y.id||Y.key||"").trim();return!N.has(Y.key)&&!F.has(J)});return{groups:U,ungrouped:V}},[zt,ee]),Cl=m.useCallback(()=>{const x=It.current;if(!x)return;const N=x.getBoundingClientRect(),F=Math.min(400,Math.max(300,window.innerWidth-24)),U=Math.min(Math.max(12,N.right-F),window.innerWidth-F-12),V=Math.max(140,N.top-22),Y=Math.min(360,V);we({position:"fixed",left:`${U}px`,top:`${Math.max(12,N.top-Y-10)}px`,width:`${F}px`,maxHeight:`${Y}px`})},[]);m.useEffect(()=>{const x=Array.isArray(rt==null?void 0:rt.cursor)?rt.cursor:[],N=Array.isArray(rt==null?void 0:rt.opencode)?rt.opencode:[],F=Array.isArray(rt==null?void 0:rt.claudeCode)?rt.claudeCode:[];B(U=>{const V=Sp(U,x,N,F);return V===U?U:V})},[rt.cursor,rt.opencode,rt.claudeCode]),m.useEffect(()=>{if(!Qn)return;Cl();const x=F=>{var V,Y;const U=F.target;(V=It.current)!=null&&V.contains(U)||(Y=jt.current)!=null&&Y.contains(U)||vt(!1)},N=F=>{F.key==="Escape"&&vt(!1)};return window.addEventListener("resize",Cl),window.addEventListener("scroll",Cl,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",N),()=>{window.removeEventListener("resize",Cl),window.removeEventListener("scroll",Cl,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",N)}},[Qn,Cl]);const Ma=m.useCallback(async(x,N={})=>{var st;if(!u||Gm.current)return;const F=N.phaseContextSnapshot,U=(typeof x=="string"?x:qr).trim();if(!U)return;const V=g0.current;Gm.current=!0,v0(!0),ki(e("flow:composer.connecting")),hn(Pe=>Pe!=="composer"?"composer":Pe);const Y=[...ru];if(V.length>0&&Y.push({type:"assistant",segments:[...V]}),b0([...Y,{type:"user",text:U}]),Y.filter(Pe=>Pe.type==="user").length===0){const Pe=U.replace(/\s+/g," ").slice(0,30)+(U.length>30?"…":"");Tt(Mt=>Mt.map(Zn=>Zn.id===Ct?{...Zn,label:Pe}:Zn))}const J=Y.map(Pe=>Pe.type==="user"?{role:"user",text:Pe.text}:{role:"assistant",text:(Pe.segments||[]).filter(Zn=>Zn.kind==="assistant"||Zn.kind==="result").map(Zn=>Zn.text).join(`
134
- `)}).filter(Pe=>Pe.text),ne=F??pt;Ta(""),Si([]),su([]),k0(!1);const me=new AbortController;Nf.current=me,Ym.current=Ct;let je=null;const Re=Array.isArray(rt==null?void 0:rt.cursor)?rt.cursor:[],se=Array.isArray(rt==null?void 0:rt.opencode)?rt.opencode:[],Ce=Array.isArray(rt==null?void 0:rt.claudeCode)?rt.claudeCode:[],ve=Sp(P,Re,se,Ce),Qe=zf.filter(Pe=>Pe.kind!=="definition"&&Pe.node).map(Pe=>Pe.node.id),en=u;let Kt=!1,Ot=!1;try{je=setTimeout(()=>me.abort(),12e4);const Pe={prompt:U,model:ve,flowId:u.id,flowSource:u.source??"user",...u.archived?{flowArchived:!0}:{},contextInstanceIds:Qe,thread:J,selectedSkills:ge};ne&&ne.nextPhase&&!ne.isLastPhase&&(Pe.phaseContext={phaseIndex:ne.nextPhase.index,phases:ne.phases,userPromptOriginal:ne.userPromptOriginal||U}),X&&(Pe.phaseRole=X);const Mt=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe),signal:me.signal});if(je&&(clearTimeout(je),je=null),!Mt.ok){let fu=Mt.statusText||e("flow:composer.requestFailed");try{const pu=await Mt.json();pu&&pu.error&&(fu=String(pu.error))}catch{}ki(fu),Si([{kind:"error",text:fu}]);return}const Zn=(st=Mt.body)==null?void 0:st.getReader();if(!Zn){ki(e("flow:composer.cannotReadStream"));return}const $o=new TextDecoder;let no="";for(;;){const{done:fu,value:pu}=await Zn.read();if(fu)break;for(no+=$o.decode(pu,{stream:!0});;){const ug=no.indexOf(`
135
- `);if(ug<0)break;const V0=no.slice(0,ug).trim();if(no=no.slice(ug+1),!V0)continue;let Me;try{Me=JSON.parse(V0)}catch{continue}if(Me.type==="status"&&typeof Me.line=="string"&&ki(Me.line),Me.type==="natural"&&typeof Me.text=="string"&&Me.text){const tn=typeof Me.kind=="string"&&Me.kind?Me.kind:"assistant";Si(Qt=>[...Qt,{kind:tn,text:Me.text}])}if(Me.type==="error"&&Me.message){Ot=!0;const tn=Me.code?` [${Me.code}]`:"",Qt=String(Me.message)+tn;ki(Qt),Si(Jr=>[...Jr,{kind:"error",text:Qt}])}if(Me.type==="plan"&&Array.isArray(Me.steps)){su(Me.steps.map(Qt=>({...Qt,status:"pending"})));const tn=Me.steps.map((Qt,Jr)=>`${Jr+1}. ${Qt.description||Qt.type}`).join(`
136
- `);Si(Qt=>[...Qt,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Me.steps.length,summary:tn})}])}if(Me.type==="step-start"){const tn=Me.index??0,Qt=Me.total??0,Jr=Me.tier?` [${Me.tier}]`:"",JT=Me.model?` (${Me.model})`:"";ki(e("flow:composer.step",{current:tn+1,total:Qt,description:(Me.description||"")+Jr+JT})),su(QT=>QT.map(El=>El.index===tn?{...El,status:"running",model:Me.model,tier:Me.tier,nodeRole:Me.nodeRole??El.nodeRole,instanceId:Me.instanceId??El.instanceId,instanceLabel:Me.instanceLabel??El.instanceLabel}:El))}if(Me.type==="step-progress"){const tn=Me.index??0,Qt=Me.total??0;ki(e("flow:composer.step",{current:tn+1,total:Qt,description:Me.description||""}))}if(Me.type==="step-done"){const tn=Me.index??0;su(Qt=>Qt.map(Jr=>Jr.index===tn?{...Jr,status:Me.success?"done":"error"}:Jr))}if(Me.type==="phase-plan"&&Array.isArray(Me.phases)){iu(Qt=>({...Qt||{},phases:Me.phases,currentPhase:Me.currentPhase??0,phaseTotal:Me.phaseTotal??Me.phases.length,phaseName:Me.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(Qt==null?void 0:Qt.userPromptOriginal)||U}));const tn=Me.phases.map((Qt,Jr)=>`${Jr+1}. ${Qt.label}`).join(" → ");Si(Qt=>[...Qt,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Me.phases.length,labels:tn,current:Me.phaseName||""})}])}Me.type==="phase-complete"&&(iu(tn=>{var Jr;return{...tn||{},phases:Me.phases||(tn==null?void 0:tn.phases)||[],currentPhase:Me.phaseIndex??0,phaseTotal:Me.phaseTotal??((Jr=Me.phases)==null?void 0:Jr.length)??0,phaseName:Me.phaseName||"",isLastPhase:!!Me.isLastPhase,nextPhase:Me.nextPhase||null,userPromptOriginal:Me.userPromptOriginal||(tn==null?void 0:tn.userPromptOriginal)||U}}),!Me.isLastPhase&&Me.nextPhase&&Si(tn=>[...tn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Me.phaseName||e("flow:composer.nextPhase"),nextPhase:Me.nextPhase.label})}])),Me.type==="done"&&(Kt=!0,ki(tn=>tn||e("flow:composer.done")))}}}catch(Pe){const Mt=Pe;if(Mt.name==="AbortError"){const Zn=e(je?"flow:composer.connectTimeout":"flow:composer.aborted");ki(Zn),Si($o=>[...$o,{kind:"error",text:Zn}])}else{const Zn=Mt.code||Mt.name||"UNKNOWN",$o=`${Mt.message||String(Pe)} [${Zn}]`;ki($o),Si(no=>[...no,{kind:"error",text:$o}])}}finally{if(Gm.current=!1,v0(!1),Nf.current=null,Ym.current=null,je&&clearTimeout(je),Kt&&en){const Pe={id:en.id,source:en.source??"user",archived:en.archived};(async()=>(await Ts(Pe,{preserveComposer:!0,incrementalSync:!0}),await Mo(Pe,{quiet:!0,force:!0})))()}}},[u,qr,P,rt,zf,Ts,Mo,ru,Ct,pt,X,ge]);oT.current=Ma;const F0=m.useCallback(()=>{!pt||pt.isLastPhase||(iu(null),Ma(e("flow:composer.skipRemainingPhases")))},[pt,Ma]),z0=m.useCallback(()=>{if(!pt||pt.isLastPhase||!pt.nextPhase)return;const x=String(pt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Ma(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:pt})},[pt,Ma]);m.useEffect(()=>{if(!qm)return;const x=N=>{N.key==="Escape"&&Sf(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[qm]),m.useEffect(()=>{_e!=="edit"&&Sf(!1)},[_e]),m.useLayoutEffect(()=>{const x=Zc.current;if(!x)return;if(!u){x.style.height="";return}x.style.height="0px";const N=getComputedStyle(x),F=parseFloat(N.lineHeight),U=(parseFloat(N.paddingTop)||0)+(parseFloat(N.paddingBottom)||0),V=Number.isFinite(F)&&F>0?F:13*1.45,Y=U+V*2,J=U+V*10,ne=Math.min(Math.max(x.scrollHeight,Y),J);x.style.height=`${ne}px`},[qr,u]);const lg=m.useCallback(x=>{const N=qr,F=wl,U=BN(N,F);if(!U)return;const V=N.slice(0,U.atIndex)+`@${x} `+N.slice(F);Ta(V);const Y=U.atIndex+x.length+2;queueMicrotask(()=>{const J=Zc.current;J&&(J.focus(),J.setSelectionRange(Y,Y)),Ra(Y)})},[qr,wl]),cg=m.useCallback(x=>{Ta(N=>{const F=`@${x}`,U=N.indexOf(F);return U<0?N:N.slice(0,U)+N.slice(U+F.length)})},[]),B0=m.useCallback(x=>{x.kind==="canvas"?ht(N=>N.map(F=>F.id===x.node.id?{...F,selected:!1}:F)):x.kind==="mention"?cg(x.node.id):cg(x.definition.id)},[ht,cg]),KT=m.useCallback(()=>{hn(x=>x==="history"?null:"history")},[]),qT=m.useCallback(()=>{hn(x=>x==="settings"?null:"settings")},[]),YT=m.useCallback(()=>{hn(x=>x==="composer"?null:"composer")},[]),du=m.useCallback(()=>{hn(x=>(x==="node"&&Io.current&&(bl.current=Io.current.id),null))},[]),H0=m.useCallback(()=>{vi(x=>!x)},[]),GT=()=>{if(!u)return null;const x=Vr||u.archived||u.source==="builtin",N=gn!=null&&gn.running?e("flow:schedule.running"):mn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),F=gn!=null&&gn.running?"running":mn.enabled?"waiting":"disabled",U=At.slice(0,12),V=u.archived||u.source==="builtin";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:du,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:R,onChange:Y=>{$(Y.target.value),H("")},onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),Of())},onBlur:()=>{R.trim()&&R.trim()!==u.id&&Of()},placeholder:u.id,disabled:K,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Rl(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Rl(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]}),L?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:L}):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:g,onChange:Y=>b(Y.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:()=>T0(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:M?"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:k,onClick:()=>Lf("workspace"),children:e(k?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:k,onClick:()=>Lf("user"),children:e(k?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),j?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:j}):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:[At.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:eg,disabled:Dt,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(Dt?"common:common.loading":"common:common.refresh")]})]}),Yt?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Yt}):null,Dt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):U.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:U.map(Y=>{const J=Y.definitionId||`marketplace:${Y.id}${Y.version?`@${Y.version}`:""}`,ne=_0.has(J)||_0.has(`marketplace:${Y.id}`),me=_f.find(Ce=>String(Ce.id)===J||String(Ce.id)===`marketplace:${Y.id}`),je=rr===J,Re=kp(Y.inputs||Y.input),se=kp(Y.outputs||Y.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ne?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:Y.displayName||Y.label||Y.id}),o.jsx("span",{children:Y.version?`v${Y.version}`:J})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:Y.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:Re.length>0?Re.map(Ce=>o.jsx("span",{className:"af-pipeline-market-chip",children:Ce},`in-${J}-${Ce}`)):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:se.length>0?se.map(Ce=>o.jsx("span",{className:"af-pipeline-market-chip",children:Ce},`out-${J}-${Ce}`)):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:()=>Wt(Y),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:ne?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:V||je,onClick:()=>{ne&&me?(I0(me),hn(null)):hT(Y)},children:e(je?"flow:settings.installingNode":ne?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},J)})}):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")})]}),Kc?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:!!mn.enabled,disabled:x,onChange:Y=>Oo(J=>({...J,enabled:Y.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:mn.cron||"",disabled:x,onChange:Y=>Oo(J=>({...J,cron:Y.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:mn.timezone||"",disabled:x,onChange:Y=>Oo(J=>({...J,timezone:Y.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:mn.preset||"",disabled:x,onChange:Y=>Oo(J=>({...J,preset:Y.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Ps).map(Y=>o.jsx("option",{value:Y,children:Y},Y))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${F}`}),o.jsx("span",{children:mn.nextRunAt?e("flow:schedule.nextRun",{time:new Date(mn.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:[Ft.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Ft.lastTriggeredAt).toLocaleString()})]}):null,Ft.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Ft.lastSkippedAt).toLocaleString(),Ft.lastSkipReason?` · ${Ft.lastSkipReason}`:""]})]}):null,Ft.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Ft.lastRunUuid})]}):null,Ft.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Ft.lastExitCode)})]}):null,Ft.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Ft.lastFinishedAt).toLocaleString()})]}):null]}),gn!=null&&gn.lastError||Ft.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(gn==null?void 0:gn.lastError)||Ft.lastError}):null,u.archived||u.source==="builtin"?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Na?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Na}):null,Gi?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Gi}):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:[Rt.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:_f.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Rl(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--${F}`,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:Rt.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:Rl(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 IT(),disabled:Vr,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(Vr?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:du,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")})]})]})]})},XT=()=>{const x=Ee;if(!x)return null;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,F=x.displayName||x.label||x.id,U=kp(x.inputs||x.input),V=kp(x.outputs||x.output);return es.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:Y=>{Y.target===Y.currentTarget&&Wt(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:F})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Wt(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:(U.length>0?U:[""]).slice(0,4).map((Y,J)=>o.jsx("span",{title:Y},`preview-in-${J}`))}),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:F}),o.jsx("span",{children:N})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(V.length>0?V:[""]).slice(0,4).map((Y,J)=>o.jsx("span",{title:Y},`preview-out-${J}`))})]})}),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:U.length>0?U.map(Y=>o.jsx("span",{className:"af-pipeline-market-chip",children:Y},`preview-input-${Y}`)):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:V.length>0?V.map(Y=>o.jsx("span",{className:"af-pipeline-market-chip",children:Y},`preview-output-${Y}`)):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(Y=>Y.to||Y).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(Tv,{children:[o.jsx(PV,{onReady:i}),o.jsxs(pI.Provider,{value:{modelLists:rt,onModelChange:TT},children:[o.jsxs("div",{className:"af-pipeline-page"+(_e!=="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:()=>{_e==="running"?Df(!0):_e!=="edit"?Oa():n("/projects")},"aria-label":e(_e!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(_e!=="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",uV,"-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(pv(u,"workspace")),children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[q&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Ae?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Ue(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),_e==="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:py(Es,"running")})]}),_e==="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:py(Es,"stopped")})]}),(_e==="done"||_e==="error")&&o.jsxs("div",{className:"af-run-timer"+(_e==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:_e==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:py(Es,_e)})]}),_e!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(gr?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>yr(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),_e==="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:KT,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:qT,"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":"")+(yn?" af-composer-topbar-btn--running":""),onClick:YT,"aria-label":"AI Composer",title:"AI Composer",disabled:!u,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(vl?" af-icon-btn--active":""),onClick:H0,"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||u.source==="builtin"||u.source!=="user"&&u.source!=="workspace",onClick:()=>T(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!u||u.source==="builtin"||u.archived||u.source!=="user"&&u.source!=="workspace",onClick:()=>z(!0),children:"Archive"})]}),_e==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:DT,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):_e==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void Ei(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Oa,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):_e==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void Ei({runUuid:wt}),title:wt?e("flow:topbar.resumeTitle",{uuid:wt}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Oa,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):_e==="done"||_e==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!u,onClick:()=>void Ei(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Oa,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 Ei(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!u,onClick:()=>et(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":pl,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),pl&&u&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var N,F,U,V,Y;et(!1);const x={};for(const J of Zs){const ne=Nl[J.id];ne&&(x[ne]=((N=hs[ne])==null?void 0:N.value)??((F=hs[ne])==null?void 0:F.path)??((Y=(V=(U=J.data)==null?void 0:U.outputs)==null?void 0:V[0])==null?void 0:Y.default)??"")}Co(x),Pr(!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:()=>{et(!1),Ei({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:()=>{et(!1),Ei()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(Ps).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var U;et(!1);const N=Ps[x]||{},F={};for(const V of Zs){const Y=Nl[V.id];if(!Y)continue;const J=((U=V.data)==null?void 0:U.definitionId)||"",ne=N[V.id]??"";J.startsWith("provide_file")?F[Y]={type:"file",path:ne}:F[Y]={type:"str",value:ne}}Ei({cliInputsOverride:F})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),Ve?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:Ve}),o.jsx("button",{type:"button",onClick:()=>Ze(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(_e!=="edit"?" af-pipeline-body--run-mode":""),children:[_e==="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${sr?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Vs(x=>!x),"aria-expanded":sr,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:sr?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:u&&(u.path||Ye.path)||"",children:u?u.id:e("flow:palette2.noPipelineSelected")}),sr&&o.jsx("div",{className:"af-palette-workspace-tree",children:ln?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):Ye.error?o.jsx("div",{className:"af-palette-workspace-empty",children:Ye.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:["(",Ye.files.length,")"]})]}),Ye.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:Ye.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:()=>G({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))}):Ye.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),Ye.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"?()=>G({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:ye,type:"search",className:"af-palette-search-input",value:fe,onChange:x=>re(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:()=>ae("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:()=>ae("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),c?o.jsx("p",{className:"af-err af-palette-list-err",children:c}):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:WT,disabled:!u||wr.length<2,title:wr.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:["已选 ",wr.length," 节点 / ",Ff.length," 连线"]})]})}),Pt?o.jsx("p",{className:"af-err af-palette-list-err",children:Pt}):null,Ge?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):M0.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:M0.map(x=>{const N=`${x.id}@${x.version}`,F=x.displayName||x.name||x.id,U=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>D0(x),draggable:!!u,onDragStart:V=>{V.dataTransfer.setData("application/agentflow-snippet",N),V.dataTransfer.effectAllowed="move"},disabled:!u,title:U,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:F}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),U?o.jsx("span",{className:"af-palette-card-desc",children:U}):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:fe.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[zu.filter(x=>Ef[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:Ef[x].map(N=>{const F=FN(N.inputs,"input"),U=FN(N.outputs,"output"),Y=N.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":mI(N),J=hI(N);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>I0(N),draggable:!!u,onDragStart:ne=>{ne.dataTransfer.setData("application/agentflow-node",N.id),ne.dataTransfer.effectAllowed="move"},disabled:!u,title:Y||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:mV(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:J}),J!==N.id?o.jsx("span",{className:"af-palette-card-id",children:N.id}):null]})]}),Y?o.jsx("span",{className:"af-palette-card-desc",children:Y}):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:[F.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[F.shown.map((ne,me)=>o.jsxs("span",{className:"af-palette-card-port",title:DN("input",ne,me),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Kn(ne==null?void 0:ne.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:hy(ne,me)})]},`in-${me}`)),F.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",F.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:[U.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[U.shown.map((ne,me)=>o.jsxs("span",{className:"af-palette-card-port",title:DN("output",ne,me),children:[o.jsx("span",{className:"af-palette-card-port-name",children:hy(ne,me)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Kn(ne==null?void 0:ne.type)}})]},`out-${me}`)),U.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",U.hidden]}):null]})]})]})]},N.id)})})]},x)),u&&de.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,u&&de.length>0&&fe.trim()&&pT===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"+(He?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(He?"common:engine.online":"common:engine.offline")})]}),v?o.jsx("div",{className:"af-palette-tip"+gT,role:"status","aria-live":"polite",children:v}):null]})]}):_e!=="edit"&&u?o.jsx(rV,{flowId:u.id,flowSource:u.source||"user",flowArchived:u.archived,provideNodes:Zs,edges:Nn,nodes:Rt,onCliInputsChange:jo,onBackToEdit:Oa}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[S?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:S}):null,u&&ji.length>0&&!Z?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:te,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void A0(),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:()=>W(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:ji.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(),CT(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,u&&ji.length>0&&Z?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:ji.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:H0,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:()=>W(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:te,onClick:()=>void A0(),children:e("common:common.refresh")})]})]}):null,nt==="settings"&&u&&_e==="edit"?GT():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:u?o.jsxs(o.Fragment,{children:[o.jsx(MV,{fitViewEpoch:p,canvasTool:Vm,nodes:cT,edges:uT,onNodesChange:_e!=="edit"?void 0:aT,onEdgesChange:_e!=="edit"?void 0:lT,onConnect:_e!=="edit"?void 0:bT,onConnectStart:_e!=="edit"?void 0:kT,onConnectEnd:_e!=="edit"?void 0:ST,isValidConnection:_e!=="edit"?void 0:vT,onNodesDelete:_e!=="edit"?void 0:NT,onNodeClick:yT,onNodeDoubleClick:xT,onEdgeClick:wT,onFlowInit:jT,onDrop:AT,onDragOver:PT,hideMinimapAndControls:!!(u&&nt),bottomSlot:_e==="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:zf.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):zf.map((x,N)=>{var me,je;if(x.kind==="definition"){const Re=x.definition,se=String(Re.label??Re.id),Ce=[Re.id,Re.description?String(Re.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:Ce,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:se}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>B0(x),"aria-label":e("flow:composer.removeFromInput",{id:Re.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${Re.id}`)}const F=x.node,U=x.kind,V=String(((me=F.data)==null?void 0:me.label)??F.id),Y=(je=F.data)!=null&&je.definitionId?String(F.data.definitionId):"",J=Y&&Y!==V?`${V} · ${F.id} · ${Y}`:`${V} · ${F.id}`,ne=U==="canvas"?e("flow:composer.deselectNode",{id:F.id}):e("flow:composer.removeFromInput",{id:F.id});return o.jsxs("div",{className:"af-composer-node-chip"+(U==="mention"?" af-composer-node-chip--mention":""),title:J,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:V}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>B0(x),"aria-label":ne,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},F.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:Zc,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!u,value:qr,rows:2,onChange:x=>{Ta(x.target.value),Ra(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Ra(N.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),Ma();return}if(cu&&ei.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),Ao(N=>(N+1)%ei.length);else if(x.key==="ArrowUp")x.preventDefault(),Ao(N=>(N-1+ei.length)%ei.length);else if(x.key==="Enter"){x.preventDefault();const N=ei[Po];N&&lg(N.id)}}},onKeyUp:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Ra(N.selectionStart??N.value.length)},onClick:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Ra(N.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),cu&&u&&ei.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[uu.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,uu.instances.map((x,N)=>{const F=N;return o.jsx("li",{role:"option","aria-selected":F===Po,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===Po?" af-composer-mention-item--active":""),onMouseDown:U=>U.preventDefault(),onMouseEnter:()=>Ao(F),onClick:()=>lg(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}`)}),uu.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,uu.definitions.map((x,N)=>{const F=uu.instances.length+N;return o.jsx("li",{role:"option","aria-selected":F===Po,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===Po?" af-composer-mention-item--active":""),onMouseDown:U=>U.preventDefault(),onMouseEnter:()=>Ao(F),onClick:()=>lg(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:[ft.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:Ct||"",onChange:x=>{x.target.value==="__new__"?x0():S0(x.target.value)},disabled:yn,"aria-label":e("flow:composer.switchConversation"),children:[ft.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:It,type:"button",className:"af-composer-skills-button"+(ag>0?" af-composer-skills-button--active":""),disabled:!u||yn,"aria-haspopup":"listbox","aria-expanded":Qn,onClick:()=>vt(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:ag>0?`Skills ${ag}`:"Skills"})]}),Qn&&!yn?es.createPortal(o.jsx("div",{ref:jt,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:$e,children:ee.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Bf.groups.map(x=>{const N=pa(x,ee),F=jE(x,og,ee),U=Tn.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(U?" 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:F==="all",disabled:N.length===0,onChange:V=>{const Y=V.target.checked;Ne(J=>Y?SE(J,N):NE(J,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,F==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":U?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{ar(V=>{const Y=new Set(V);return Y.has(x.id)?Y.delete(x.id):Y.add(x.id),Y})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:U?"expand_more":"expand_less"})]})]}),U?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(V=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:og.has(V.key),onChange:Y=>{const J=Y.target.checked;Ne(ne=>J?ne.includes(V.key)?ne:[...ne,V.key]:ne.filter(me=>me!==V.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:V.name}),V.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:V.description}):null]})]},`${x.id}:${V.key}`))})]},x.id)}),Bf.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:Bf.ungrouped.length})]}),Bf.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:og.has(x.key),onChange:N=>{const F=N.target.checked;Ne(U=>F?U.includes(x.key)?U:[...U,x.key]:U.filter(V=>V!==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:(P||"").trim()?Xr.currentNotInLists?Xr.currentNotInLists:Sp(P,Xr.cursorList,Xr.opencodeList,Xr.claudeCodeList):"",onChange:x=>B(x.target.value),disabled:!u||yn,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),Xr.currentNotInLists?o.jsxs("option",{value:Xr.currentNotInLists,children:[Xr.currentNotInLists,e("flow:composer.modelNotInList")]}):null,Xr.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:Xr.cursorList.map(x=>o.jsx("option",{value:ao(x),children:x},`composer-c-${x}`))}):null,Xr.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:Xr.opencodeList.map(x=>o.jsx("option",{value:`opencode:${ao(x)}`,children:x},`composer-o-${x}`))}):null,Xr.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:Xr.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${ao(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(u&&qr.trim()&&!yn?" af-composer-send--active":"")+(yn?" af-composer-send--stop":""),disabled:!u||!yn&&!qr.trim(),"aria-label":e(yn?"flow:composer.stopGeneration":"flow:composer.send"),title:yn?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(yn){(x=Nf.current)==null||x.abort();return}Ma()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:yn?"stop":"arrow_upward"})})]})]}),qm?es.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&&Sf(!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"+(yn?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:tu||void 0,children:yn&&!tu?e("flow:composer.executing"):tu||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Sf(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),m0.length>1&&!(pt&&Array.isArray(pt.phases)&&pt.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(SV,{steps:m0})}):null,pt&&Array.isArray(pt.phases)&&pt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:pt.phases.map((x,N)=>{const F=x.status||(N<(pt.currentPhase??0)?"done":N===(pt.currentPhase??0)?yn?"running":pt.nextPhase||pt.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(F==="done"?" af-composer-phase-item--done":"")+(F==="running"?" af-composer-phase-item--running":"")+(F==="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:F==="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(HN,{thread:ru,liveSegments:nu,running:yn})}),pt&&!pt.isLastPhase&&pt.nextPhase&&!yn?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:pt.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:z0,children:e("flow:composer.phaseReviewContinue",{label:pt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:F0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),Gr&&_e==="edit"?(()=>{var U;const x=String(Gr.query||"").trim().toLowerCase(),N=x?Gr.candidates.filter(V=>{var Y,J,ne;return[(Y=V.def)==null?void 0:Y.id,V.displayLabel,V.description,(J=V.slot)==null?void 0:J.name,(ne=V.slot)==null?void 0:ne.type].filter(Boolean).some(me=>String(me).toLowerCase().includes(x))}):Gr.candidates,F=Gr.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:Gr.left,top:Gr.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:Kn((U=Gr.draft.slot)==null?void 0:U.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",Gr.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>Lo(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:Gr.query,onChange:V=>Lo(Y=>Y&&{...Y,query:V.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[N.map(V=>{var ne,me;const Y=V.displayLabel||((ne=V.def)==null?void 0:ne.id),J=hy(V.slot,V.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>_T(V),title:V.description||V.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:Y}),Y!==V.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:V.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:F}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Kn((me=V.slot)==null?void 0:me.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:J})]})]},`${V.def.id}-${V.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")})})]}),_e!=="edit"&&gr&&o.jsxs("div",{className:"af-run-console",style:{height:yt},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:LT,onPointerMove:OT,onPointerUp:L0,onPointerCancel:L0,onLostPointerCapture:MT}),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:[_e==="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:()=>yr(!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:[Er.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:ml})]})]})]}),_e!=="edit"&&qs&&u?o.jsx(ZW,{instanceId:qs,flowId:u.id,runId:wt,nodeStatus:((U0=ps[qs])==null?void 0:U0.status)??null,onClose:()=>Ys(null)}):null,nt&&nt!=="settings"&&u&&_e==="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:du,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),ft.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[ft.map(x=>o.jsxs("button",{type:"button",ref:N=>{N&&x.id===Ct&&N.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===Ct?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>S0(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(),w0(x.id)},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),w0(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:()=>x0(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(yn?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:yn&&!tu?e("flow:composer.executing"):tu||e("flow:composer.ready")}),pt&&Array.isArray(pt.phases)&&pt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:pt.phases.map((x,N)=>{const F=x.status||(N<(pt.currentPhase??0)?"done":N===(pt.currentPhase??0)?yn?"running":pt.isLastPhase&&N===pt.phases.length-1||pt.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(F==="done"?" af-composer-phase-item--done":"")+(F==="running"?" af-composer-phase-item--running":"")+(F==="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:F==="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:y0,children:o.jsx(HN,{thread:ru,liveSegments:nu,running:yn})}),pt&&!pt.isLastPhase&&pt.nextPhase&&!yn?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:pt.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:z0,children:e("flow:composer.phaseReviewContinue",{label:pt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:F0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):nt==="node"&&Je?Ke?o.jsx(cI,{draft:Ke,setDraft:eu,definitionId:String(((W0=Je.data)==null?void 0:W0.definitionId)??Je.id),systemPromptReadonly:String((Qm==null?void 0:Qm.description)??""),modelLists:rt,disabled:!u,onIdBlur:RT,onClose:du,onPublishToMarketplace:mT,error:bf,ioSlots:{inputs:Array.isArray(Ke==null?void 0:Ke.inputs)?Ke.inputs:[],outputs:Array.isArray(Ke==null?void 0:Ke.outputs)?Ke.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:du,"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:R,onChange:x=>{$(x.target.value),H("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Of())},onBlur:()=>{R.trim()&&R.trim()!==u.id&&Of()},placeholder:u.id,disabled:K,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Rl(u.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[u.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Rl(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]}),L?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:L}):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:()=>T0(u.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:M?"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:k,onClick:()=>Lf("workspace"),children:e(k?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:k,onClick:()=>Lf("user"),children:e(k?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),j?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:j}):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:g,onChange:x=>b(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")}),Kc?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:!!mn.enabled,disabled:Vr||u.archived||u.source==="builtin",onChange:x=>Oo(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:mn.cron||"",disabled:Vr||u.archived||u.source==="builtin",onChange:x=>Oo(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:mn.timezone||"",disabled:Vr||u.archived||u.source==="builtin",onChange:x=>Oo(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:mn.preset||"",disabled:Vr||u.archived||u.source==="builtin",onChange:x=>Oo(N=>({...N,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(Ps).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")})}),mn.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(mn.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:gn!=null&&gn.running?e("flow:schedule.running"):mn.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Ft.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Ft.lastTriggeredAt).toLocaleString()})]}):null,Ft.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Ft.lastSkippedAt).toLocaleString(),Ft.lastSkipReason?` · ${Ft.lastSkipReason}`:""]})]}):null,Ft.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Ft.lastRunUuid})]}):null,Ft.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Ft.lastExitCode)})]}):null,Ft.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Ft.lastFinishedAt).toLocaleString()})]}):null]}),gn!=null&&gn.lastError||Ft.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(gn==null?void 0:gn.lastError)||Ft.lastError}):null,u.archived||u.source==="builtin"?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,Na?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Na}):null,Gi?o.jsx("p",{className:"af-pipeline-drawer-muted",children:Gi}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:Vr||u.archived||u.source==="builtin",onClick:tg,children:e(Vr?"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:[Rt.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})]}),fs?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):Cr?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:Cr}):lu.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[Fr.success+Fr.failed+Fr.running+Fr.stopped+Fr.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[Fr.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:Fr.success})}):null,Fr.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:Fr.failed})}):null,Fr.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:Fr.stopped})}):null,Fr.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:Fr.interrupted})}):null,Fr.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:Fr.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:lu.map((x,N)=>{const F=x.status||"unknown",U=F==="success"?"af-exec-history-card--success":F==="failed"?"af-exec-history-card--failed":F==="stopped"?"af-exec-history-card--stopped":F==="interrupted"?"af-exec-history-card--interrupted":F==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",V=e(F==="success"?"flow:history.success":F==="failed"?"flow:history.failed":F==="stopped"?"flow:history.stopped":F==="interrupted"?"flow:history.interrupted":F==="running"?"flow:history.running":"flow:history.unknown"),Y=F==="success"?"check_circle":F==="failed"?"error":F==="stopped"?"stop_circle":F==="interrupted"?"sync_disabled":F==="running"?"progress_activity":"help",J=x.runId||`${x.at}-${N}`,ne=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:lu.length-N});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${U}`,onClick:()=>UT(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:ne}),o.jsx("span",{className:"af-exec-history-card-time",children:Cx(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:Y}),V]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),JL(x.durationMs,e)]})]})]})},`${u.id}-${J}`)})})]})]})})]})}):null]}),o.jsx(kN,{open:$T,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:FT,onCancel:()=>sg(!1)}),o.jsx(kN,{open:zT,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:HT,onSecondary:BT,onCancel:()=>Df(!1)}),o.jsx(sI,{open:vl,onClose:()=>vi(!1)}),XT(),o.jsx(DW,{open:Qc,onClose:()=>wf(!1),onJump:ET,nodes:Rt}),o.jsx(cV,{open:Ae,onClose:()=>Ue(!1),flowId:(u==null?void 0:u.id)??""}),o.jsx(LW,{open:A,onClose:()=>z(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",onArchived:async()=>{z(!1),await Pf(),n("/projects?tab=archived")}}),o.jsx(OW,{open:_&&!!(u!=null&&u.id),onClose:()=>T(!1),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),onDeleted:async()=>{T(!1),f(null),ht([]),cn([]),iu(null),await Pf(),n("/projects")}}),an&&es.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:()=>Fn(!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:qt.name,onChange:x=>{const N=x.target.value;_n(F=>({...F,name:N,id:F.id?F.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:qt.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:qt.description,onChange:x=>_n(N=>({...N,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",wr.length," 个节点和 ",Ff.length," 条内部连线。"]}),ie?o.jsx("div",{className:"af-flow-snippet-error",children:ie}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Fn(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:jr||!qt.name.trim(),onClick:()=>void VT(),children:jr?"发布中…":"发布"})]})]})}),document.body),o.jsx(FW,{open:!!C,onClose:()=>G(null),flowId:(u==null?void 0:u.id)??"",flowSource:(u==null?void 0:u.source)??"user",flowArchived:!!(u!=null&&u.archived),filePath:(C==null?void 0:C.filePath)??"",fileName:(C==null?void 0:C.fileName)??"",onSaved:()=>{Vt(x=>({...x}))}})]}),An&&_e!=="edit"&&es.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:An.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:Pa?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(!An||!u||!wt)return;const x=_a||An.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:wt,instanceId:An.instanceId,content:x})})).ok?(gl(F=>F&&{...F,content:x}),kn(!1),ot(F=>[...F,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):ot(F=>[...F,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{ot(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:()=>{_o(An.content),kn(!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:()=>kn(!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:()=>gl(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:Pa?o.jsx("textarea",{ref:yf,className:"af-user-check-modal__textarea",value:_a||An.content,onChange:x=>_o(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:_a||An.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:Xi,onChange:x=>yl(x.target.value),disabled:Aa}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:Aa||!Xi.trim(),onClick:()=>{!An||!u||!wt||!Xi.trim()||(Ji(!0),ot(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:wt,instanceId:An.instanceId,content:_a||An.content,prompt:Xi})}).then(x=>x.json()).then(x=>{Ji(!1),x.ok&&x.content?(_o(x.content),kn(!0),yl(""),ot(N=>[...N,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):ot(N=>[...N,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{Ji(!1),ot(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[Aa?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(!An||!u||!wt)return;const x=_a||An.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:wt,instanceId:An.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:wt,instanceId:An.instanceId,execId:An.execId})}),gl(null),yl(""),Ei({runUuid:wt})):ot(F=>[...F,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{ot(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),Is&&_e!=="edit"&&es.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:Is.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Qi(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:[Is.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:Is.question})}):null,Is.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:Is.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:xf,onClick:async()=>{if(!(!Is||!u||!wt)){Ia(!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:wt,instanceId:Is.instanceId,execId:Is.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Qi(null),Ia(!1),Ei({runUuid:wt})):(Ia(!1),ot(F=>[...F,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{Ia(!1),ot(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(xf?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),Gc&&_e!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(xl?" 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:Gc.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>eo(x=>!x),"aria-label":e(xl?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(xl?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:xl?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Zi(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(cf,{children:Gc.content})})})]}),Js&&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:Js.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>Kr(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:Xc,className:"af-provide-edit-modal__textarea",defaultValue:Js.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:dT,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:()=>Kr(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),wi&&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:()=>Pr(!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:Zs.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:Zs.map(x=>{var me,je;const N=Nl[x.id];if(!N)return null;const F=((me=x.data)==null?void 0:me.definitionId)||"",U=F.startsWith("provide_file"),V=F==="provide_bool",Y=((je=x.data)==null?void 0:je.label)||x.id,J=Gs[N]??"",ne=["true","1","yes","on"].includes(String(J).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"+(U?" af-run-params-item__icon--file":""),children:U?"description":V?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:Y}),o.jsx("span",{className:"af-run-params-item__slot",children:N})]}),V?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ne?" af-run-config-bool-toggle--true":""),onClick:()=>Co(Re=>({...Re,[N]:ne?"false":"true"})),"aria-pressed":ne,children:ne?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:J,onChange:Re=>Co(se=>({...se,[N]:Re.target.value})),placeholder:e(U?"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 F of Zs){const U=Nl[F.id];if(!U)continue;const V=((N=F.data)==null?void 0:N.definitionId)||"",Y=Gs[U]??"";V.startsWith("provide_file")?x[U]={type:"file",path:Y}:x[U]={type:"str",value:Y}}Pr(!1),et(!1),Ei({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:()=>Pr(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const zV="af:workspace-graph:v2",Dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],BV=new Set(["control_start","control_end","control_load_skills"]),HV={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:""}]},UV={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:""}]},WV="0.1.35";function VV(){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 jp(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 KV(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:workspace-composer:${t}:${n}${e!=null&&e.archived?":archived":""}`}function qV(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 YV(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function GV(e){const t=String(e||"").trim();return!t||/^思考中/.test(t)||/^生成回复中/.test(t)||/^完成$/.test(t)||/^事件:\s*(system|user)$/i.test(t)||/^工具\s+\w+ToolCall\s+\((started|completed)\)$/i.test(t)||/^Started\s+\S+/.test(t)||/^Completed\s+\S+/.test(t)||/^Run started:/.test(t)||/^Run finished/.test(t)||/^Run paused/.test(t)||/^Workspace run paused/.test(t)||/^Paused at/.test(t)}function XV(e){const t=String(e||"").trim();return GV(t)||/^Run started:/.test(t)||/^Run finished/.test(t)||/^Run paused/.test(t)||/^Workspace run paused/.test(t)||/^Started\s+\S+/.test(t)||/^Completed\s+\S+/.test(t)}function JV(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 YN(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 GN(e){return(Array.isArray(e)?e:[]).filter(t=>t&&(t.role==="user"||t.role==="assistant")&&typeof t.text=="string").filter(t=>!(t.role==="assistant"&&XV(t.text))).map(t=>({role:t.role,text:t.text,...t.error?{error:!0}:{},...typeof t.at=="number"?{at:t.at}:{}})).slice(-80)}function xI(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 Bu(e){const t=String((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 XN(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function n0(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Hu(e){return n0(e)}function uw(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function yy(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 JN(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 QN(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 ZN(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=Rc(s.get(n),e.sourceHandle||"output-0","source"),a=Rc(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Tc(i,a))}function QV(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=Rc(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:tI(a)}:null}function ZV(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"?Tc(t.slot,a):Tc(a,t.slot)))continue;const c=Bu(n);return{def:n,order:r,category:c,categoryRank:Dl.indexOf(c),slot:a,slotIndex:i,displayLabel:Hu(n),description:uw(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 e7(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function t7(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 n7(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Cp(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:n7(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 xy(e,t){var u,f;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=Array.isArray(e==null?void 0:e.edges)?e.edges:[],s=(u=e==null?void 0:e.ui)!=null&&u.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},i=(f=e==null?void 0:e.ui)!=null&&f.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},a=new Set(Object.keys(n));for(const p of r)p!=null&&p.source&&a.add(String(p.source)),p!=null&&p.target&&a.add(String(p.target));const c=Array.from(a).map(p=>{const h=n[p]||{},g=h.definitionId||p,b=t.find(w=>w.id===g),S=s[p]&&typeof s[p].x=="number"&&typeof s[p].y=="number"?s[p]:{x:320+a.size*20,y:180+a.size*12},y=i[p]&&typeof i[p].width=="number"&&typeof i[p].height=="number"?{width:i[p].width,height:i[p].height}:null,v=!!Bi(g);return{id:p,type:df,position:S,...v&&y?{width:y.width,height:y.height}:{},data:{label:h.label||n0(b)||p,definitionId:g,schemaType:xI(g,b),role:h.role||"normal",model:h.model||void 0,body:h.body||"",script:h.script||"",...v&&y?{displaySize:y}:{}}}}).map(p=>Hd(p,n,t)),d=r.filter(p=>(p==null?void 0:p.source)&&(p==null?void 0:p.target)).map((p,h)=>({id:p.id||`we-${p.source}-${p.target}-${h}`,source:String(p.source),target:String(p.target),sourceHandle:p.sourceHandle??void 0,targetHandle:p.targetHandle??void 0,markerEnd:{type:cs.ArrowClosed}}));return{nodes:c,edges:eI(d,c),instances:n}}function wy(e,t,n){var l,c,d,u,f,p,h,g,b;const r=uf(e,n||{}),s=t.map(S=>({source:S.source,target:S.target,sourceHandle:S.sourceHandle??null,targetHandle:S.targetHandle??null})),i={},a={};for(const S of e)if(i[S.id]={x:((l=S.position)==null?void 0:l.x)||0,y:((c=S.position)==null?void 0:c.y)||0},Bi((d=S.data)==null?void 0:d.definitionId)){const y=Number(((f=(u=S.data)==null?void 0:u.displaySize)==null?void 0:f.width)||S.width||((p=S.measured)==null?void 0:p.width)||0),v=Number(((g=(h=S.data)==null?void 0:h.displaySize)==null?void 0:g.height)||S.height||((b=S.measured)==null?void 0:b.height)||0);y>0&&v>0&&(a[S.id]={width:y,height:v})}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function Bi(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":""}function od(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Bi(e==null?void 0:e.definitionId)==="image"?"src":"content",s=t.find(i=>(i==null?void 0:i.name)===r&&String((i==null?void 0:i.default)||"").trim())||t.find(i=>(i==null?void 0:i.name)==="filePath"&&String((i==null?void 0:i.default)||"").trim())||t.find(i=>(i==null?void 0:i.type)==="text"&&String((i==null?void 0:i.default)||"").trim());return String((e==null?void 0:e.body)||(s==null?void 0:s.default)||"")}function wI(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 r7(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.default)||(e==null?void 0:e.label)||"Image preview")}function s7(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":"article"}function nc(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 i7(e){const t=nc(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function o7(e){return nc(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function a7(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&&nc(l).length>1&&i7(t[a+1])){i();const c=nc(l),d=o7(t[a+1]),u=[];for(a+=2;a<t.length&&t[a].trim()&&nc(t[a]).length>1;)u.push(nc(t[a])),a++;n.push({type:"table",headers:c,align:d,rows:u});continue}r.push(l),a++}return i(),n}function e1({children:e}){return o.jsx(cf,{components:{p:({children:t})=>o.jsx(o.Fragment,{children:t})},children:String(e||"")})}function l7({content:e}){const t=m.useMemo(()=>a7(e),[e]);return o.jsx(o.Fragment,{children:t.map((n,r)=>n.type!=="table"?o.jsx(cf,{children:n.text},`md-${r}`):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:n.headers.map((s,i)=>o.jsx("th",{style:{textAlign:n.align[i]||"left"},children:o.jsx(e1,{children:s})},i))})}),o.jsx("tbody",{children:n.rows.map((s,i)=>o.jsx("tr",{children:n.headers.map((a,l)=>o.jsx("td",{style:{textAlign:n.align[l]||"left"},children:o.jsx(e1,{children:s[l]||""})},l))},i))})]})},`table-${r}`))})}function c7(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 u7({code:e}){const t=m.useMemo(()=>c7(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((u,f)=>{l.set(u.id,{x:24+(n?f*(r+i):f%3*(r+i)),y:24+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(360,...Array.from(l.values()).map(u=>u.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(u=>u.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((u,f)=>{const p=l.get(u.from),h=l.get(u.to);if(!p||!h)return null;const g=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+h.x+r)/2} ${p.y+s/2}, ${(p.x+h.x+r)/2} ${h.y+s/2}, ${h.x} ${h.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return o.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${u.from}-${u.to}-${f}`)}),t.nodes.map(u=>{const f=l.get(u.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-work-node__mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-work-node__mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:u.label.slice(0,22)})]},u.id)})]})})}function Ll({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[s,i]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const u=n.current;if(!u)return;const f=Math.max(1,u.scrollHeight),p=Math.max(1,u.clientHeight),h=f>p+1,g=h?Math.max(12,p/f*100):100,b=Math.max(0,100-g),S=h?Math.min(b,u.scrollTop/Math.max(1,f-p)*b):0;i({visible:h,top:S,height:g})},[]);m.useEffect(()=>{const u=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(u);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(u),p.disconnect()}},[t,a]);const l=m.useCallback(u=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,u))*p,a()},[a]),c=m.useCallback((u,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),g=s.height/100*h.height,b=Math.max(1,h.height-g);return(u-h.top-f)/b},[s.height]),d=m.useCallback(u=>{var j,E;if(!s.visible)return;u.preventDefault(),u.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,g=s.height/100*p.height,S=u.clientY>=p.top+h&&u.clientY<=p.top+h+g?u.clientY-p.top-h:g/2;l(c(u.clientY,S));const y=u.pointerId;(E=(j=u.currentTarget).setPointerCapture)==null||E.call(j,y);const v=k=>{k.preventDefault(),l(c(k.clientY,S))},w=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)};window.addEventListener("pointermove",v),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 d7({data:e,htmlFrameRef:t,htmlFrameVersion:n=0}){const r=Bi(e==null?void 0:e.definitionId);if(!r)return null;const s=od(e),i=r==="html"?wI(s):s;return i.trim()?r==="html"?o.jsx(Ll,{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:t,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||"HTML preview",sandbox:"",srcDoc:i},n)}):r==="image"?o.jsx(Ll,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:i,alt:r7(e),loading:"lazy"})}):r==="markdown"?o.jsx(Ll,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(l7,{content:i})}):r==="mermaid"?o.jsxs(Ll,{className:"af-work-display-body",children:[o.jsx(u7,{code:i}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:i})]}):o.jsx(Ll,{className:"af-work-display-body",children:o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:i})}):o.jsx(Ll,{className:"af-work-display-empty",children:"No display content"})}function f7({value:e,onChange:t}){return o.jsx("div",{className:"af-work-display-editor nodrag nopan",onClick:n=>n.stopPropagation(),children:o.jsx("textarea",{className:"af-work-display-editor__textarea",value:e,onChange:n=>t==null?void 0:t(n.target.value),onKeyDown:n=>{n.key==="Escape"&&n.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1})})}function p7({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=(t==null?void 0:t.nodeChat)||{},s=Array.isArray(r.messages)?r.messages:[],i=String(r.draft||""),a=String(r.candidateContent||""),l=!!r.running,c=String(r.error||"");return n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:d=>d.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 d;return(d=t==null?void 0:t.onCloseNodeChat)==null?void 0:d.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.length>0||l||c||a.trim()?o.jsxs("div",{className:"af-work-node-chat__messages",children:[s.slice(-4).map((d,u)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${d.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:d.role==="assistant"?"AI":"你"}),o.jsx("p",{children:d.text})]},`${d.at||u}-${u}`)),l?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,c?o.jsx("div",{className:"af-work-node-chat__error",children:c}):null]}):null,o.jsxs("div",{className:"af-work-node-chat__composer",children:[o.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:l,"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:i,disabled:l,placeholder:"描述你想怎么调整这个展示",onChange:d=>{var u;return(u=t==null?void 0:t.onUpdateNodeChatDraft)==null?void 0:u.call(t,e,d.target.value)},onKeyDown:d=>{var u;(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&(d.preventDefault(),(u=t==null?void 0:t.onSendNodeChat)==null||u.call(t,e))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:l||!i.trim(),onClick:()=>{var d;return(d=t==null?void 0:t.onSendNodeChat)==null?void 0:d.call(t,e)},"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:l||!a.trim(),onClick:()=>{var d;return(d=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:d.call(t,e,"replace")},children:"替换当前内容"}),o.jsx("button",{type:"button",disabled:l||!a.trim(),onClick:()=>{var d;return(d=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:d.call(t,e,"append")},children:"追加"})]})]}):o.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:d=>{var u;d.stopPropagation(),(u=t==null?void 0:t.onToggleNodeChat)==null||u.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 h7(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":"md"}function m7(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function g7(e,t){const n=Bi(t==null?void 0:t.definitionId)||"markdown";return`outputs/${m7((t==null?void 0:t.label)||e||n)}.${h7(n)}`}function y7({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((v,w)=>({slot:v,idx:w})).sort((v,w)=>{var R,$,K,D;const j=String(((R=v.slot)==null?void 0:R.name)||"").trim(),E=String((($=w.slot)==null?void 0:$.name)||"").trim();if(j==="next"&&E!=="next")return-1;if(E==="next"&&j!=="next")return 1;const k=String(((K=v.slot)==null?void 0:K.type)||"").trim(),I=String(((D=w.slot)==null?void 0:D.type)||"").trim();return k==="node"&&I!=="node"?-1:I==="node"&&k!=="node"?1:v.idx-w.idx}),l=Bi(t==null?void 0:t.definitionId),c=m.useRef(null),[d,u]=m.useState(0),[f,p]=m.useState(!1),[h,g]=m.useState(""),b=l==="markdown"?od(t):"";m.useEffect(()=>{f||g(String(b||""))},[b,f]);const S=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="image"?"Image":"Markdown"),y=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;return o.jsxs("div",{className:"af-work-display-card"+(y?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(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:y?{width:y.width,height:y.height}:void 0,children:[o.jsx(tB,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,maxWidth:1200,maxHeight:1e3,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((v,w)=>{if(v.showOnNode===!1)return null;const j=`${4.15+w*1.75}rem`,E=v.name||`#${w+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:j},children:E}),o.jsx(Hs,{type:"target",position:Fe.Left,id:`input-${w}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:j,background:Kn(v.type)},title:`${E} · ${v.type}`})]},`in-${w}`)}),a.map(({slot:v,idx:w},j)=>{if(v.showOnNode===!1)return null;const E=`${4.15+j*1.75}rem`,k=v.name||`#${w+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:E},children:k}),o.jsx(Hs,{type:"source",position:Fe.Right,id:`output-${w}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:E,background:Kn(v.type)},title:`${k} · ${v.type}`})]},`out-${w}`)}),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:s7(l)}),o.jsx("strong",{children:S}),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:v=>v.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var v,w,j,E;try{(E=(j=(w=(v=c.current)==null?void 0:v.contentWindow)==null?void 0:w.history)==null?void 0:j.back)==null||E.call(j)}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 v,w,j,E;try{(E=(j=(w=(v=c.current)==null?void 0:v.contentWindow)==null?void 0:w.history)==null?void 0:j.forward)==null||E.call(j)}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:()=>u(v=>v+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}):null,l==="markdown"?f?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:v=>v.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var v;(v=t==null?void 0:t.onSetDisplayNodeContent)==null||v.call(t,e,h,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),p(!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:()=>{g(String(b||"")),p(!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",onClick:v=>{v.stopPropagation(),g(String(b||"")),p(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:()=>{var v;return(v=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:v.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",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&f?o.jsx(f7,{value:h,onChange:g}):o.jsx(d7,{data:t,htmlFrameRef:c,htmlFrameVersion:d}),o.jsx(p7,{nodeId:e,data:t})]})}function x7({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;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":""),children:[s.map((l,c)=>{if(l.showOnNode===!1)return null;const d=`${2.25+c*1.75}rem`,u=l.name||`#${c+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:d},children:u}),o.jsx(Hs,{type:"target",position:Fe.Left,id:`input-${c}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:d,background:Kn(l.type)},title:`${u} · ${l.type}`})]},`in-${c}`)}),i.map((l,c)=>{if(l.showOnNode===!1)return null;const d=`${2.25+c*1.75}rem`,u=l.name||`#${c+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:d},children:u}),o.jsx(Hs,{type:"source",position:Fe.Right,id:`output-${c}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:d,background:Kn(l.type)},title:`${u} · ${l.type}`})]},`out-${c}`)}),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",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",disabled:a,onClick:l=>{var c;l.stopPropagation(),(c=t==null?void 0:t.onRunWorkspaceNode)==null||c.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined"+(a?" af-spin":""),children:a?"sync":"play_arrow"}),o.jsx("span",{children:a?"Running":"Run line"})]})]})}function w7(e){var d,u,f,p,h,g,b,S;const{setEdges:t,setNodes:n}=dl(),r=(d=e.data)==null?void 0:d.onSyncNodePropDraft,s=m.useCallback(y=>{n(v=>v.filter(w=>w.id!==y)),t(v=>v.filter(w=>w.source!==y&&w.target!==y))},[t,n]),i=m.useCallback((y,v)=>{n(w=>w.map(j=>j.id===y?{...j,data:{...j.data,model:v}}:j)),r==null||r(y,{model:v})},[n,r]),a=m.useCallback((y,v)=>{n(w=>w.map(j=>{var k;if(j.id!==y)return j;const E=Array.isArray((k=j.data)==null?void 0:k.outputs)&&j.data.outputs.length?j.data.outputs.map((I,R)=>R===0?{...I,default:v,value:v}:I):[{type:"bool",name:"value",default:v,value:v}];return{...j,data:{...j.data,body:"",outputs:E}}})),r==null||r(y,w=>({body:"",outputs:Array.isArray(w==null?void 0:w.outputs)&&w.outputs.length?w.outputs.map((E,k)=>k===0?{...E,default:v,value:v}:E):[{type:"bool",name:"value",default:v,value:v}]}))},[n,r]),l=m.useCallback((y,v)=>{n(w=>w.map(j=>j.id===y?{...j,data:{...j.data,body:v}}:j)),r==null||r(y,{body:v})},[n,r]),c=m.useCallback((y,v)=>{const w=ss(v);n(j=>j.map(E=>E.id===y?{...E,data:{...E.data,images:w}}:E)),r==null||r(y,{images:w})},[n,r]);return Bi((u=e.data)==null?void 0:u.definitionId)?o.jsx(y7,{...e,deleteNode:s}):((f=e.data)==null?void 0:f.definitionId)==="workspace_run"?o.jsx(x7,{...e,deleteNode:s}):((p=e.data)==null?void 0:p.definitionId)==="control_load_skills"?o.jsx(N7,{...e,deleteNode:s,skills:(h=e.data)==null?void 0:h.skills,skillCollections:(g=e.data)==null?void 0:g.skillCollections,onChangeSkillKeys:(b=e.data)==null?void 0:b.onChangeLoadSkillKeys}):o.jsx("div",{className:"af-work-flow-node",children:o.jsx(nI,{...e,deleteNode:s,modelLists:(S=e.data)==null?void 0:S.modelLists,onModelChange:i,onProvideValueChange:a,onNodeBodyChange:l,onNodeImagesChange:c})})}const v7={[df]:w7};function vI(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&vI(n.children,t);return t}function bI(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&bI(n.children,t));return t}function kI({items:e,onOpen:t,collapsedDirs:n,onToggleDir:r,onCreateFile:s,onCreateFolder:i,onDelete:a,onFileDragStart:l}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(c=>{var f;const d=c.type==="directory",u=d&&(n==null?void 0:n.has(c.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--"+c.type,draggable:!d,onDragStart:p=>{d||l==null||l(p,c)},onClick:()=>d?r==null?void 0:r(c.path):t(c),title:c.path,children:[d?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:c.icon||e7(c.name,d)}),o.jsx("span",{children:c.name})]}),d?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>s==null?void 0:s(c.path),title:"新增文件","aria-label":`在 ${c.name} 新增文件`,children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>i==null?void 0:i(c.path),title:"新增文件夹","aria-label":`在 ${c.name} 新增文件夹`,children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})})]}):null,o.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:()=>a==null?void 0:a(c),title:"删除","aria-label":`删除 ${c.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]}),d&&!u&&((f=c.children)!=null&&f.length)?o.jsx(kI,{items:c.children,onOpen:t,collapsedDirs:n,onToggleDir:r,onCreateFile:s,onCreateFolder:i,onDelete:a,onFileDragStart:l}):null]},c.path)})})}function b7({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 t1(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 k7(e){const t=t1((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 t1((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function S7(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function N7({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:[],u=Array.isArray(i)?i:[],[f,p]=m.useState(!1),[h,g]=m.useState(""),[b,S]=m.useState(()=>new Set),y=m.useRef(null),v=m.useRef(null),[w,j]=m.useState({visible:!1,top:0,height:100}),E=m.useMemo(()=>new Set(k7(t)),[t]),k=m.useMemo(()=>new Map(d.map(O=>[O.key,O])),[d]),I=m.useMemo(()=>{const O=new Set,A=u.map(_=>{const T=pa(_,d).map(C=>k.get(C)).filter(Boolean);for(const C of T)O.add(C.key);return{..._,skills:T}}).filter(_=>_.skills.length>0),z=d.filter(_=>!O.has(_.key));return{collectionGroups:A,ungrouped:z}},[k,u,d]),R=m.useMemo(()=>{const O=h.trim().toLowerCase();if(!O)return I;const A=_=>[_==null?void 0:_.key,_==null?void 0:_.name,_==null?void 0:_.description].map(C=>String(C||"").toLowerCase()).join(" ").includes(O);return{collectionGroups:I.collectionGroups.map(_=>{const C=[_==null?void 0:_.id,_==null?void 0:_.name,_==null?void 0:_.description].map(G=>String(G||"").toLowerCase()).join(" ").includes(O)?_.skills:_.skills.filter(A);return{..._,skills:C}}).filter(_=>_.skills.length>0),ungrouped:I.ungrouped.filter(A)}},[I,h]),$=m.useCallback((O,A)=>{const z=new Set(E);for(const _ of O)A?z.add(_):z.delete(_);a==null||a(e,Array.from(z))},[e,E,a]),K=m.useCallback(O=>{S(A=>{const z=new Set(A);return z.has(O)?z.delete(O):z.add(O),z})},[]),D=m.useCallback(()=>{const O=y.current;if(!O)return;const A=Math.max(1,O.scrollHeight),z=Math.max(1,O.clientHeight),_=A>z+1,T=_?Math.max(12,z/A*100):100,C=Math.max(0,100-T),G=_?Math.min(C,O.scrollTop/Math.max(1,A-z)*C):0;j({visible:_,top:G,height:T})},[]);m.useEffect(()=>{if(!f)return;const O=requestAnimationFrame(D);return()=>cancelAnimationFrame(O)},[b,R,E.size,f,D]);const L=m.useCallback(O=>{const A=y.current;if(!A)return;const z=Math.max(0,A.scrollHeight-A.clientHeight);A.scrollTop=Math.min(1,Math.max(0,O))*z,D()},[D]),H=m.useCallback((O,A=0)=>{const z=v.current;if(!z)return 0;const _=z.getBoundingClientRect(),T=w.height/100*_.height,C=Math.max(1,_.height-T);return(O-_.top-A)/C},[w.height]),M=m.useCallback(O=>{var le,ue;if(!w.visible)return;O.preventDefault(),O.stopPropagation();const A=v.current;if(!A)return;const z=A.getBoundingClientRect(),_=w.top/100*z.height,T=w.height/100*z.height,G=O.clientY>=z.top+_&&O.clientY<=z.top+_+T?O.clientY-z.top-_:T/2;L(H(O.clientY,G));const Z=O.pointerId;(ue=(le=O.currentTarget).setPointerCapture)==null||ue.call(le,Z);const W=de=>{de.preventDefault(),L(H(de.clientY,G))},te=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",te)};window.addEventListener("pointermove",W),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",te)},[H,L,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((O,A)=>{if(O.showOnNode===!1)return null;const z=`${2.6+A*1.7}rem`,_=O.name||`#${A+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:z},children:_}),o.jsx(Hs,{type:"target",position:Fe.Left,id:`input-${A}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:z,background:Kn(O.type)},title:`${_} · ${O.type}`})]},`in-${A}`)}),c.map((O,A)=>{if(O.showOnNode===!1)return null;const z=`${2.6+A*1.7}rem`,_=O.name||`#${A+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:z},children:_}),o.jsx(Hs,{type:"source",position:Fe.Right,id:`output-${A}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:z,background:Kn(O.type)},title:`${_} · ${O.type}`})]},`out-${A}`)}),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:O=>{var A;O.stopPropagation(),f||(A=t==null?void 0:t.onRefreshSkills)==null||A.call(t),p(z=>!z)},children:[o.jsx("span",{children:E.size>0?`${E.size} skills selected`:"选择 Skills"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:O=>O.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:h,onChange:O=>g(O.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?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:D,children:[R.collectionGroups.map(O=>{const A=O.skills.map(C=>C.key),z=A.filter(C=>E.has(C)).length,_=A.length>0&&z===A.length,T=b.has(O.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(T?" 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:C=>$(A,C.target.checked),"aria-label":`选择 ${O.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>K(O.id),"aria-expanded":!T,children:o.jsx("span",{children:O.name})}),o.jsxs("small",{children:[z,"/",A.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>K(O.id),"aria-label":T?`展开 ${O.name}`:`收起 ${O.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:T?"chevron_right":"expand_more"})})]}),T?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:O.skills.map(C=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:E.has(C.key),onChange:G=>$([C.key],G.target.checked)}),o.jsx("span",{children:C.name})]},`${O.id}:${C.key}`))})]},O.id)}),R.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:R.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:R.ungrouped.map(O=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:E.has(O.key),onChange:A=>$([O.key],A.target.checked)}),o.jsx("span",{children:O.name})]},`ungrouped:${O.key}`))})]}):null,R.collectionGroups.length===0&&R.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:v,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 j7(){var rt,kf;const{i18n:e}=on(),{navigate:t}=ul(),n=dl(),r=yP(),s=m.useMemo(VV,[]),[i,a]=xP([]),[l,c,d]=wP([]),u=m.useRef([]),f=m.useRef([]),p=m.useRef(null),h=m.useRef(null),g=m.useRef(null),[b,S]=m.useState(null),[y,v]=m.useState({}),w=m.useRef({}),j=m.useRef(!1),E=m.useRef(null),[k,I]=m.useState([]),[R,$]=m.useState(""),[K,D]=m.useState("nodes"),[L,H]=m.useState([]),[M,O]=m.useState(!1),[A,z]=m.useState(""),[_,T]=m.useState(!1),[C,G]=m.useState({name:"",id:"",description:""}),[Z,W]=m.useState(!1),[te,le]=m.useState(""),[ue,de]=m.useState(""),ce=m.useRef(null),[fe,re]=m.useState(!1),[pe,ae]=m.useState("nodes"),[ye,Be]=m.useState(""),[lt,Ge]=m.useState(0),[_t,Pt]=m.useState(""),[Te,an]=m.useState(null),[Fn,qt]=m.useState(""),[_n,jr]=m.useState([]),[fr,ie]=m.useState(""),[xe,Ve]=m.useState(""),[Ze,Xe]=m.useState(()=>new Set),[At,On]=m.useState({cursor:[],opencode:[],claudeCode:[]}),[Dt,Mn]=m.useState(""),[Yt,Gt]=m.useState([]),[rr,he]=m.useState(!1),[Ee,Wt]=m.useState([]),[nt,hn]=m.useState([]),[Us,Pn]=m.useState(!1),Cr=m.useCallback(P=>{ce.current&&window.clearTimeout(ce.current),de(P),ce.current=window.setTimeout(()=>{de(""),ce.current=null},3800)},[]),pr=m.useCallback(P=>{const B=String(P||"").trim();B&&window.requestAnimationFrame(()=>{r(B)})},[r]);m.useEffect(()=>()=>{ce.current&&window.clearTimeout(ce.current)},[]);const[fs,xi]=m.useState(()=>new Set),[Ws,hr]=m.useState(!1),sr=m.useRef(null),Vs=m.useRef(null),Ye=m.useRef(null),[Vt,ln]=m.useState({}),[mr,He]=m.useState(""),[Xt,_e]=m.useState(!1),[bn,Er]=m.useState([]),[ot,Xn]=m.useState([]),[ir,zn]=m.useState("workspace"),[ps,Jn]=m.useState(!1),[Ks,_r]=m.useState(!1),[Es,$r]=m.useState(""),[gr,yr]=m.useState({}),[q,be]=m.useState(!1),[Ae,Ue]=m.useState(!1),[yt,Bn]=m.useState("pan"),[ct,wt]=m.useState(null),[or,qs]=m.useState(""),[Ys,hs]=m.useState(()=>new Set),[jo,_s]=m.useState({}),[pl,et]=m.useState(""),wi=m.useMemo(()=>KV(s),[s]),Pr=m.useMemo(()=>qV(s),[s]),Gs=m.useRef(!1),[Co,Ps]=m.useState("");m.useEffect(()=>{s.flowId&&kE(s.flowId,s.flowSource||"user","workspace",!!s.archived)},[s]),m.useEffect(()=>{if(Gs.current=!1,Xn([]),zn("workspace"),!wi){Er([]),Gs.current=!0;return}try{const P=localStorage.getItem(wi);Er(P?GN(JSON.parse(P)):[])}catch{Er([])}finally{Gs.current=!0}},[wi]),m.useEffect(()=>{if(!(!Gs.current||!wi))try{localStorage.setItem(wi,JSON.stringify(GN(bn)))}catch{}},[bn,wi]);const Hn=m.useCallback(async()=>{const P=jp(s),B=await fetch(`/api/workspace/files?${P.toString()}`),X=await B.json();if(!B.ok)throw new Error(X.error||"读取 workspace 失败");const Q=X.files||[];jr(Q),Xe(new Set(bI(Q))),ie(X.root||"")},[s]),Yi=m.useCallback(async()=>{O(!0),z("");try{const P=await fetch("/api/marketplace/flow-snippets"),B=await P.json().catch(()=>({}));if(!P.ok)throw new Error(B.error||"读取流程片段失败");H(Array.isArray(B.snippets)?B.snippets:[])}catch(P){z(String(P.message||P)),H([])}finally{O(!1)}},[]),xr=m.useCallback(async(P=i,B=l)=>{var oe;if(!j.current)return;const X=wy(P,B,w.current),Q=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,graph:X})}),ee=await Q.json();if(!Q.ok)throw new Error(ee.error||"保存 workspace graph 失败");w.current=((oe=ee.graph)==null?void 0:oe.instances)||X.instances,v(w.current),et("Workspace graph saved")},[l,s,i]),mn=m.useCallback(async()=>{j.current=!1;const P=jp(s),B=jp(s);B.set("lang",String(e.language||"zh").startsWith("zh")?"zh":"en");const[X,Q]=await Promise.all([fetch(`/api/nodes?${B.toString()}`),fetch(`/api/workspace/graph?${P.toString()}`),Hn()]),ee=await X.json(),oe=await Q.json();if(!X.ok)throw new Error(ee.error||"读取节点定义失败");if(!Q.ok)throw new Error(oe.error||"读取 workspace graph 失败");const ge=[...(Array.isArray(ee)?ee:ee.nodes||[]).filter(ze=>!BV.has(ze.id)),UV,HV];I(ge);const Ne=oe.graph||JSON.parse(localStorage.getItem(zV)||"null")||{},Ie=xy(Ne,ge);w.current=Ie.instances,v(Ie.instances),a(Ie.nodes),c(Ie.edges),et(oe.writable?"Workspace ready":"Readonly workspace"),j.current=!0},[s,e.language,Hn,c,a]),Sa=m.useCallback(async(P,B)=>{const X={packageId:(P==null?void 0:P.newId)||(P==null?void 0:P.id)||(P==null?void 0:P.label),label:(P==null?void 0:P.label)||(P==null?void 0:P.newId)||(P==null?void 0:P.id),version:"1.0.0",definitionId:B,body:(P==null?void 0:P.body)||"",script:(P==null?void 0:P.script)||"",inputs:Array.isArray(P==null?void 0:P.inputs)?P.inputs:[],outputs:Array.isArray(P==null?void 0:P.outputs)?P.outputs:[],flowId:s.flowId,flowSource:s.flowSource||"user",archived:!!s.archived},Q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X)}),ee=await Q.json().catch(()=>({}));if(!Q.ok||(ee==null?void 0:ee.ok)===!1)throw new Error((ee==null?void 0:ee.error)||"Publish failed");return await mn(),et(`Published node ${ee.definitionId||ee.id||X.packageId}`),ee},[s,mn]),Kc=m.useCallback((P="workspace")=>{Jn(!0),_r(!1),an(null),zn(P||"workspace")},[]),qc=m.useCallback(async P=>{if(!P||or)return;const B=wy(i,l,w.current),X=`run-${Date.now()}-${String(P).replace(/[^a-z0-9_-]+/gi,"_")}`,Q=`Run ${P}`;qs(P),hs(new Set([P])),_s({[P]:{status:"running"}}),et(`Running ${P}...`),zn(X),Xn(ee=>[...ee.slice(-7),{id:X,label:Q,runNodeId:P,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await xr(i,l);const ee=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({...s,graph:B,runNodeId:P,model:Dt,selectedSkills:Ee,stream:!0})});if(!ee.ok){const we=await ee.json().catch(()=>({}));throw new Error(we.error||"Workspace run failed")}if(!ee.body)throw new Error("Workspace run stream unavailable");const oe=ee.body.getReader(),ge=new TextDecoder;let Ne="",Ie=[],ze=[],zt=P;const Ht=(we,at)=>{var bt,Jt;const xt=i.find(ft=>ft.id===we),ut=String(((bt=xt==null?void 0:xt.data)==null?void 0:bt.label)||we||"").trim(),De=String(at||((Jt=xt==null?void 0:xt.data)==null?void 0:Jt.definitionId)||"").trim();return De&&De!==ut?`${ut} (${De})`:ut},Nt=(we,at,xt)=>{const ut=String(we||"").trim();ut&&Xn(De=>De.map(bt=>{if(bt.id!==X)return bt;const ft=[...Array.isArray(bt.steps)?bt.steps:[]],Tt=ft.findIndex(Qs=>Qs.id===ut),Ct={id:ut,label:Ht(ut,at),status:xt};Tt>=0?ft[Tt]={...ft[Tt],...Ct}:ft.push(Ct);const Zt=ft.map((Qs,Sn)=>{const yn=Qs.status==="done"?"[done]":Qs.status==="failed"?"[failed]":"[running]";return`${Sn+1}. ${yn} ${Qs.label}`}).join(`
140
- `),Un=Array.isArray(bt.messages)?bt.messages:[],To=Un.findIndex(Qs=>Qs.kind==="run-summary"),to={role:"assistant",kind:"run-summary",text:Zt||"准备运行...",at:Date.now()},bi=[...Un];return To>=0?bi[To]=to:bi.unshift(to),{...bt,steps:ft,messages:bi.slice(-160)}}))},In=we=>{const at=String(we||"").trim();if(!at)return;const xt=zt;zt=at,hs(new Set([at])),_s(ut=>{var De;return{...ut,...xt&&xt!==at&&((De=ut[xt])==null?void 0:De.status)==="running"?{[xt]:{status:"success"}}:{},[at]:{status:"running"}}})},Tn=we=>{const at=String(we||"").trim();at&&(hs(xt=>{const ut=new Set(xt);return ut.delete(at),ut}),_s(xt=>({...xt,[at]:{status:"success"}})))},ar=(we,at)=>{const xt=String(at||"");if(!xt.trim())return;const ut=["assistant","thinking","result","error","prompt"].includes(we)?we:"assistant";Xn(De=>De.map(bt=>{if(bt.id!==X)return bt;let Jt=Array.isArray(bt.messages)?bt.messages:[];if(ut==="result"){const Ct=[...Jt].reverse().find(Zt=>Zt.kind==="assistant");if(String((Ct==null?void 0:Ct.text)||"").trim()===xt.trim())return bt}if(ut==="assistant"){const Ct=Jt.findIndex(Zt=>Zt.kind==="result"&&String(Zt.text||"").trim()===xt.trim());Ct>=0&&(Jt=Jt.filter((Zt,Un)=>Un!==Ct))}const ft=[...Jt],Tt=ft[ft.length-1];return Tt&&Tt.kind===ut&&!Tt.error?ft[ft.length-1]={...Tt,text:`${Tt.text||""}${Tt.text?`
141
- `:""}${xt}`}:ft.push({role:"assistant",kind:ut,text:xt,...ut==="error"?{error:!0}:{},at:Date.now()}),{...bt,messages:ft.slice(-160)}}))},Qn=we=>{const at=String(we||"");at.trim()&&Xn(xt=>xt.map(ut=>{var ft;if(ut.id!==X)return ut;const De=Array.isArray(ut.messages)?ut.messages:[],bt=De.findIndex(Tt=>Tt.kind==="thinking"),Jt=[...De];if(bt>=0){const Tt=String(((ft=Jt[bt])==null?void 0:ft.text)||"");Jt[bt]={...Jt[bt],text:`${Tt}${Tt&&!Tt.endsWith(`
142
- `),""}${at}`,at:Date.now()}}else{const Tt=Jt.findIndex(Ct=>Ct.kind==="activity");Jt.splice(Tt>=0?Tt+1:Jt.length,0,{role:"assistant",kind:"thinking",text:at,at:Date.now()})}return{...ut,messages:Jt.slice(-160)}}))},vt=we=>{const at=JV(we);at&&Xn(xt=>xt.map(ut=>{if(ut.id!==X)return ut;const De=Array.isArray(ut.activities)?ut.activities:[],bt=De[De.length-1]===at?De:[...De,at].slice(-8),Jt=Array.isArray(ut.messages)?ut.messages:[],ft=Jt.findIndex(Zt=>Zt.kind==="activity"),Tt={role:"assistant",kind:"activity",text:bt.map((Zt,Un)=>`${Un+1}. ${Zt}`).join(`
143
- `),at:Date.now()},Ct=[...Jt];if(ft>=0)Ct[ft]=Tt;else{const Zt=Ct.findIndex(Un=>Un.kind==="run-summary");Ct.splice(Zt>=0?Zt+1:0,0,Tt)}return{...ut,activities:bt,messages:Ct.slice(-160)}}))},It=we=>{const at=String((we==null?void 0:we.source)||"runner"),xt=String((we==null?void 0:we.stream)||""),ut=String((we==null?void 0:we.eventType)||"event"),De=String((we==null?void 0:we.text)||"").trim();if(!De)return;const bt=`[${at}${xt?`:${xt}`:""}] ${ut}
144
- ${De}`;Xn(Jt=>Jt.map(ft=>{if(ft.id!==X)return ft;const Ct=[...Array.isArray(ft.rawTrace)?ft.rawTrace:[],bt].slice(-80),Zt=Array.isArray(ft.messages)?ft.messages:[],Un=Zt.findIndex(bi=>bi.kind==="raw"),To={role:"assistant",kind:"raw",text:Ct.join(`
145
-
146
- ---
147
-
148
- `),at:Date.now()},to=[...Zt];return Un>=0?to[Un]=To:to.push(To),{...ft,rawTrace:Ct,messages:to.slice(-160)}}))},jt=we=>{Xn(at=>at.map(xt=>xt.id===X?{...xt,status:we,endedAt:Date.now()}:xt))},$e=we=>{const at=xy(we||B,k);w.current=at.instances,v(at.instances),a(at.nodes),c(at.edges)};for(;;){const{value:we,done:at}=await oe.read();if(at)break;Ne+=ge.decode(we,{stream:!0});const xt=Ne.split(`
149
- `);Ne=xt.pop()||"";for(const ut of xt){if(!ut.trim())continue;const De=JSON.parse(ut);if(De.type==="error")throw new Error(De.error||"Workspace run failed");if(De.type==="node-start"&&(et(`Running ${De.nodeId}...`),In(De.nodeId),Nt(De.nodeId,De.definitionId,"running")),De.type==="node-done"&&(Tn(De.nodeId),Nt(De.nodeId,De.definitionId,"done")),De.type==="status"&&vt(De.line||De.message||""),De.type==="paused"&&(ze=Array.isArray(De.nodeIds)?De.nodeIds:[]),De.type==="natural"&&(De.kind==="thinking"?Qn(De.text||""):ar(De.kind,De.text||"")),De.type==="raw"){const bt=YN(De);bt&&Qn(bt),It(De)}De.type==="graph"&&De.graph&&$e(De.graph),De.type==="done"&&(De.graph&&$e(De.graph),Ie=Array.isArray(De.order)?De.order:[],ze=Array.isArray(De.pauseNodeIds)?De.pauseNodeIds:ze)}}if(Ne.trim()){const we=JSON.parse(Ne);if(we.type==="error")throw new Error(we.error||"Workspace run failed");if(we.type==="node-start"&&(et(`Running ${we.nodeId}...`),In(we.nodeId),Nt(we.nodeId,we.definitionId,"running")),we.type==="node-done"&&(Tn(we.nodeId),Nt(we.nodeId,we.definitionId,"done")),we.type==="status"&&vt(we.line||we.message||""),we.type==="paused"&&(ze=Array.isArray(we.nodeIds)?we.nodeIds:[]),we.type==="natural"&&(we.kind==="thinking"?Qn(we.text||""):ar(we.kind,we.text||"")),we.type==="raw"){const at=YN(we);at&&Qn(at),It(we)}we.type==="graph"&&we.graph&&$e(we.graph),we.type==="done"&&(we.graph&&$e(we.graph),Ie=Array.isArray(we.order)?we.order:[],ze=Array.isArray(we.pauseNodeIds)?we.pauseNodeIds:ze)}et(ze.length?`Workspace run paused at ${ze.join(", ")}`:`Workspace run done: ${Ie.length?Ie.join(" -> "):P}`),jt(ze.length?"paused":"done"),await Hn()}catch(ee){hs(new Set),_s(oe=>{var Ne;const ge=(Ne=Object.entries(oe).find(([,Ie])=>(Ie==null?void 0:Ie.status)==="running"))==null?void 0:Ne[0];return ge?{...oe,[ge]:{status:"failed"}}:oe}),et(String(ee.message||ee)),Xn(oe=>oe.map(ge=>ge.id===X?{...ge,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(ge.messages)?ge.messages:[],{role:"assistant",error:!0,text:String(ee.message||ee),at:Date.now()}].slice(-160)}:ge))}finally{qs(""),hs(new Set)}},[Dt,l,s,Hn,i,k,or,xr,Ee,c,a]),Vr=m.useCallback(async()=>{try{const B=await(await fetch("/api/skills")).json().catch(()=>({})),X=Array.isArray(B.skills)?B.skills.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):""})):[];Gt(X),he(!0)}catch{he(!0)}},[]);m.useEffect(()=>{mn().catch(P=>et(String(P.message||P))),Yi(),fetch("/api/model-lists").then(P=>P.json()).then(P=>On({cursor:Array.isArray(P.cursor)?P.cursor.map(String):[],opencode:Array.isArray(P.opencode)?P.opencode.map(String):[],claudeCode:Array.isArray(P.claudeCode)?P.claudeCode.map(String):[]})).catch(()=>{}),Vr(),fetch("/api/skill-collections").then(P=>P.json()).then(P=>{hn(la(P)),Pn(!0)}).catch(()=>{}),fetch("/api/auth/me").then(P=>P.json()).then(P=>wt(P.user||null)).catch(()=>wt(null))},[mn,Yi,Vr,Pr]),m.useEffect(()=>{if(Ps(""),!(!rr||!Us)){if(!Pr){Wt([]);return}Wt(CE(Pr,"workspace",Yt,nt)),Ps(Pr)}},[nt,Us,Yt,rr,Pr]),m.useEffect(()=>{if(!(Co!==Pr||!Pr))try{localStorage.setItem(Pr,JSON.stringify(Ee))}catch{}},[Ee,Pr,Co]),m.useEffect(()=>{w.current=y},[y]),m.useEffect(()=>{u.current=i},[i]),m.useEffect(()=>{f.current=l},[l]),m.useEffect(()=>{g.current=b},[b]),m.useEffect(()=>{if(!b)return;const P=X=>{X.key==="Escape"&&S(null)},B=X=>{var Q,ee;(ee=(Q=X.target)==null?void 0:Q.closest)!=null&&ee.call(Q,".af-connect-node-menu")||S(null)};return document.addEventListener("keydown",P),document.addEventListener("pointerdown",B),()=>{document.removeEventListener("keydown",P),document.removeEventListener("pointerdown",B)}},[b]),m.useEffect(()=>{if(j.current)return E.current&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{xr().catch(P=>et(String(P.message||P)))},650),()=>{E.current&&window.clearTimeout(E.current)}},[i,l,xr]);const Yc=m.useCallback((P,B)=>{const X=S7(B),Q=Ie=>Array.isArray(Ie)?Ie.map(ze=>(ze==null?void 0:ze.name)!=="skillKeys"&&(ze==null?void 0:ze.name)!=="skillsContext"&&(ze==null?void 0:ze.type)!=="text"?ze:{...ze,default:X,value:X}):[],ee=i.map(Ie=>{var ze;return Ie.id!==P?Ie:{...Ie,data:{...Ie.data,body:X,inputs:Q((ze=Ie.data)==null?void 0:ze.inputs)}}}),oe=w.current||{},ge=oe[P]&&typeof oe[P]=="object"?oe[P]:{},Ne={...oe,[P]:{...ge,body:X,input:Q(ge.input)}};w.current=Ne,a(ee),v(Ne),xr(ee,l).catch(Ie=>et(String(Ie.message||Ie)))},[l,i,xr,a]),Na=m.useCallback(P=>{const B=String(P||"").trim();B&&($r(X=>X===B?"":B),yr(X=>({...X,[B]:X[B]||{sessionId:`nodechat_${Date.now()}_${B.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),Eo=m.useCallback((P,B)=>{const X=String(P||"").trim();X&&yr(Q=>({...Q,[X]:{...Q[X]||{sessionId:`nodechat_${Date.now()}_${X.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(B||""),error:""}}))},[]),Gi=m.useCallback((P,B,X="replace",Q={})=>{var Qn;const ee=String(P||"").trim();if(!ee)return;const oe=u.current.find(vt=>vt.id===ee),ge=Bi((Qn=oe==null?void 0:oe.data)==null?void 0:Qn.definitionId),Ne=ge==="html"?wI(B):String(B||""),Ie=oe?od(oe.data):"",ze=X==="append"&&String(Ie||"").trim()?`${String(Ie).replace(/\s+$/g,"")}
150
-
151
- ${Ne.trim()}`:Ne,zt=ge==="image"?"src":"content",Ht=vt=>{let It=!1;return(Array.isArray(vt)?vt:[]).map($e=>{const we=String(($e==null?void 0:$e.name)||""),at=String(($e==null?void 0:$e.type)||"");return!It&&(we===zt||we==="filePath"||at==="text")?(It=!0,{...$e,default:ze,value:ze}):$e})},Nt=u.current.map(vt=>{var It,jt;return vt.id!==ee?vt:{...vt,data:{...vt.data,body:ze,inputs:Ht((It=vt.data)==null?void 0:It.inputs),outputs:Ht((jt=vt.data)==null?void 0:jt.outputs)}}}),In=w.current||{},Tn=In[ee]&&typeof In[ee]=="object"?In[ee]:{},ar={...In,[ee]:{...Tn,body:ze,input:Ht(Tn.input),output:Ht(Tn.output)}};w.current=ar,a(Nt),v(ar),an(vt=>(vt==null?void 0:vt.id)===ee?{...vt,body:ze}:vt),(Q==null?void 0:Q.logChat)!==!1&&yr(vt=>{var It;return{...vt,[ee]:{...vt[ee]||{},candidateContent:"",messages:[...(It=vt[ee])!=null&&It.messages&&Array.isArray(vt[ee].messages)?vt[ee].messages:[],{role:"assistant",text:X==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),xr(Nt,f.current).catch(vt=>et(String(vt.message||vt))),et(String((Q==null?void 0:Q.statusMessage)||"")||(X==="append"?"已追加节点内容":"已替换节点内容"))},[xr,a]),ja=m.useCallback((P,B="replace")=>{var ee;const X=String(P||"").trim(),Q=String(((ee=gr[X])==null?void 0:ee.candidateContent)||"").trim();!X||!Q||Gi(X,Q,B)},[gr,Gi]),Ft=m.useCallback(async P=>{var Ie,ze,zt;const B=String(P||"").trim();if(!B)return;const X=gr[B]||{},Q=String(X.draft||"").trim();if(!Q||X.running)return;const ee=u.current.find(Ht=>Ht.id===B);if(!ee)return;const oe={role:"user",text:Q,at:Date.now()},ge=Array.isArray(X.messages)?X.messages:[],Ne=X.sessionId||`nodechat_${Date.now()}_${B.replace(/[^a-z0-9_-]+/gi,"_")}`;yr(Ht=>({...Ht,[B]:{...X,sessionId:Ne,messages:[...ge,oe],draft:"",running:!0,error:""}}));try{const Ht=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,sessionId:Ne,node:{id:B,label:((Ie=ee.data)==null?void 0:Ie.label)||B,definitionId:((ze=ee.data)==null?void 0:ze.definitionId)||""},nodeKind:Bi((zt=ee.data)==null?void 0:zt.definitionId)||"markdown",currentContent:od(ee.data),messages:ge,message:Q,model:Dt})}),Nt=await Ht.json().catch(()=>({}));if(!Ht.ok)throw new Error(Nt.error||"节点微调失败");const In=String(Nt.candidateContent||Nt.reply||"").trim();yr(Tn=>{var ar;return{...Tn,[B]:{...Tn[B]||{},sessionId:String(Nt.sessionId||Ne),running:!1,candidateContent:In,messages:[...(ar=Tn[B])!=null&&ar.messages&&Array.isArray(Tn[B].messages)?Tn[B].messages:[...ge,oe],{role:"assistant",text:In||"已生成候选内容。",at:Date.now()}]}}})}catch(Ht){const Nt=String(Ht.message||Ht);yr(In=>({...In,[B]:{...In[B]||{},running:!1,error:Nt}})),et(Nt)}},[Dt,s,gr]),hl=m.useCallback(async(P,B)=>{const X=od(B);if(!String(X||"").trim()){et("展示节点没有可保存内容");return}const Q=g7(P,B),ee=window.prompt("保存到 workspace 相对路径",Q);if(ee)try{const oe=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:ee,content:X})}),ge=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(ge.error||"保存文件失败");et(`已保存 ${ge.path||ee}`),await Hn()}catch(oe){et(String(oe.message||oe))}},[s,Hn]),gn=m.useCallback((P,B)=>{const X=String(P||"");X&&an(Q=>{if(!Q||Q.id!==X)return Q;const ee=typeof B=="function"?B(Q):B;return!ee||typeof ee!="object"?Q:{...Q,...ee}})},[]),Ca=m.useMemo(()=>i.map(P=>{var B,X;return{...P,data:{...P.data,modelLists:At,showBodyPreview:!0,isExecuting:Ys.has(P.id),nodeStatus:((B=jo[P.id])==null?void 0:B.status)??null,nodeElapsed:((X=jo[P.id])==null?void 0:X.elapsed)??null,onRunWorkspaceNode:qc,runningRunNodeId:or,skills:Yt,skillCollections:nt,onChangeLoadSkillKeys:Yc,onRefreshSkills:Vr,onSaveDisplayNodeToFile:hl,nodeChatActive:Es===P.id,nodeChat:gr[P.id]||null,onSetDisplayNodeContent:Gi,onToggleNodeChat:Na,onCloseNodeChat:()=>$r(""),onUpdateNodeChatDraft:Eo,onSendNodeChat:Ft,onApplyNodeChatCandidate:ja,onSyncNodePropDraft:gn}}}),[Es,ja,Yc,At,gr,i,Vr,qc,or,hl,Ft,Gi,nt,Yt,gn,Na,Eo,Ys,jo]),dt=m.useMemo(()=>i.find(P=>P.id===_t)||null,[i,_t]);m.useEffect(()=>{var X,Q,ee,oe,ge,Ne;if(!dt){an(null),qt("");return}const{inputs:P,outputs:B}=ZA(dt);an({id:dt.id,newId:dt.id,label:String(((X=dt.data)==null?void 0:X.label)??dt.id),role:String(((Q=dt.data)==null?void 0:Q.role)??"normal"),model:String(((ee=dt.data)==null?void 0:ee.model)??""),body:String(((oe=dt.data)==null?void 0:oe.body)??""),images:ss((ge=dt.data)==null?void 0:ge.images),script:String(((Ne=dt.data)==null?void 0:Ne.script)??""),inputs:P,outputs:B}),qt("")},[dt==null?void 0:dt.id]);const As=m.useCallback((P=!1)=>{var Qn,vt;if(!Te||!dt)return!1;const B=dt.id,X=String(Te.newId||"").trim(),Q=P?X:B;if(qt(""),P){if(!lI.test(Q))return qt("Invalid instance id"),!1;if(i.some(It=>It.id===Q&&It.id!==B))return qt("Duplicate instance id"),!1}const ee=String(Te.role||"").trim(),oe=ma.includes(ee)?ee:"normal",ge=String(Te.model||"").trim(),Ne=It=>(Array.isArray(It)?It:[]).map(jt=>({type:String((jt==null?void 0:jt.type)??"node").trim()||"node",name:String((jt==null?void 0:jt.name)??""),default:String((jt==null?void 0:jt.default)??""),required:!!(jt!=null&&jt.required),showOnNode:(jt==null?void 0:jt.showOnNode)!=null?jt.showOnNode!==!1:!!(jt!=null&&jt.required)||String((jt==null?void 0:jt.type)??"node").trim().toLowerCase()==="node"})),Ie=String(((Qn=dt.data)==null?void 0:Qn.definitionId)??Q),ze=Ie.startsWith("provide_"),zt={...dt.data,label:String(Te.label||"").trim()||Q,role:oe,model:ge===""||ge==="default"?void 0:ge,body:ze?"":String(Te.body??""),images:ze?[]:ss(Te.images),inputs:Ne(Te.inputs),outputs:ze&&Array.isArray((vt=dt.data)==null?void 0:vt.outputs)?dt.data.outputs:Ne(Te.outputs)},Ht=String(Te.script??"").trim();Ie==="tool_nodejs"||Ht!==""?zt.script=String(Te.script??""):delete zt.script;const Nt=dt.data||{};if(!(Q!==B||Nt.label!==zt.label||Nt.role!==zt.role||Nt.model!==zt.model||Nt.body!==zt.body||JSON.stringify(ss(Nt.images))!==JSON.stringify(zt.images)||(Nt.script??void 0)!==(zt.script??void 0)||JSON.stringify(Nt.inputs||[])!==JSON.stringify(zt.inputs||[])||JSON.stringify(Nt.outputs||[])!==JSON.stringify(zt.outputs||[])))return!0;let Tn=i.map(It=>It.id===B?{...It,id:Q,selected:!0,data:zt}:It),ar=l;if(Q!==B){const It={...w.current},jt={...It[B]||{}};delete It[B],It[Q]=jt,w.current=It,v(It),ar=l.map(($e,we)=>({...$e,source:$e.source===B?Q:$e.source,target:$e.target===B?Q:$e.target,id:`we-${$e.source===B?Q:$e.source}-${$e.target===B?Q:$e.target}-${we}`})),Pt(Q)}return a(Tn),c(ar),pr(Q),!0},[l,Te,i,dt,c,a,pr]);m.useEffect(()=>{if(!Te||!dt)return;const P=window.setTimeout(()=>{As(!1)},350);return()=>window.clearTimeout(P)},[Te==null?void 0:Te.label,Te==null?void 0:Te.role,Te==null?void 0:Te.model,Te==null?void 0:Te.body,JSON.stringify((Te==null?void 0:Te.images)||[]),Te==null?void 0:Te.script,JSON.stringify((Te==null?void 0:Te.inputs)||[]),JSON.stringify((Te==null?void 0:Te.outputs)||[]),As,dt==null?void 0:dt.id]);const ml=m.useMemo(()=>{const P=new Map(Ca.map(B=>[B.id,B]));return l.map(B=>{var ze,zt,Ht,Nt;const X=P.get(B.source),Q=P.get(B.target),ee=/^output-(\d+)$/.exec(B.sourceHandle||""),oe=/^input-(\d+)$/.exec(B.targetHandle||""),ge=X&&ee?(zt=(ze=X.data)==null?void 0:ze.outputs)==null?void 0:zt[parseInt(ee[1],10)]:null,Ne=Q&&oe?(Nt=(Ht=Q.data)==null?void 0:Ht.inputs)==null?void 0:Nt[parseInt(oe[1],10)]:null,Ie=ge!=null&&ge.type?Kn(ge.type):Ne!=null&&Ne.type?Kn(Ne.type):"";return Ie?{...B,style:{...B.style||{},stroke:Ie,strokeWidth:2},markerEnd:{type:cs.ArrowClosed,color:Ie}}:B})},[l,Ca]),Ea=m.useMemo(()=>{const P=R.trim().toLowerCase(),B={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const X of k)P&&![X.id,X.label,X.displayName,X.description].some(Q=>String(Q||"").toLowerCase().includes(P))||B[Bu(X)].push(X);for(const X of Dl)B[X].sort((Q,ee)=>Q.id.localeCompare(ee.id));return B},[k,R]),Xs=m.useMemo(()=>{const P=ye.trim().toLowerCase();return k.filter(B=>!P||[B.id,B.label,B.displayName,B.description].some(X=>String(X||"").toLowerCase().includes(P))).sort((B,X)=>{const Q=Dl.indexOf(Bu(B)),ee=Dl.indexOf(Bu(X));return Q!==ee?Q-ee:Hu(B).localeCompare(Hu(X))}).slice(0,30)},[k,ye]),An=m.useMemo(()=>{const P=ye.trim().toLowerCase();return L.filter(B=>!P||[B.id,B.version,B.displayName,B.name,B.description,...Array.isArray(B.tags)?B.tags:[]].some(X=>String(X||"").toLowerCase().includes(P))).sort((B,X)=>String(B.displayName||B.name||B.id).localeCompare(String(X.displayName||X.name||X.id))).slice(0,30)},[L,ye]);m.useEffect(()=>{Ge(0)},[ye,fe,pe]),m.useEffect(()=>{if(!fe)return;const P=window.setTimeout(()=>{var B;return(B=Ye.current)==null?void 0:B.focus()},0);return()=>window.clearTimeout(P)},[fe]);const gl=m.useMemo(()=>{const P=xe.trim().toLowerCase();return P?vI(_n).filter(B=>B.path.toLowerCase().includes(P)):_n},[xe,_n]),_a=[...(At.cursor||[]).map(P=>({label:`Cursor · ${P.split(" - ")[0]}`,value:`cursor:${P.split(" - ")[0]}`})),...(At.opencode||[]).map(P=>({label:`OpenCode · ${P.split(" - ")[0]}`,value:`opencode:${P.split(" - ")[0]}`})),...(At.claudeCode||[]).map(P=>({label:`Claude · ${P.split(" - ")[0]}`,value:`claude-code:${P.split(" - ")[0]}`}))],_o=m.useMemo(()=>new Set(Ee),[Ee]),Pa=m.useMemo(()=>{const P=new Map(Yt.map(oe=>[oe.key,oe])),B=new Set,X=new Set,Q=nt.map(oe=>{const ge=pa(oe,Yt).map(Ne=>P.get(Ne)).filter(Boolean);for(const Ne of ge)B.add(Ne.key),X.add(String(Ne.name||Ne.id||Ne.key||"").trim());return{...oe,skills:ge}}).filter(oe=>oe.skills.length>0),ee=Yt.filter(oe=>{const ge=String(oe.name||oe.id||oe.key||"").trim();return!B.has(oe.key)&&!X.has(ge)});return{groups:Q,ungrouped:ee}},[nt,Yt]),kn=m.useMemo(()=>{const P=i.filter(B=>B.selected);return P.length>0?P:_t?i.filter(B=>B.id===_t):[]},[i,_t]),Xi=m.useMemo(()=>kn.map(P=>P.id),[kn]),yl=m.useMemo(()=>{const P=String((ct==null?void 0:ct.username)||(ct==null?void 0:ct.userId)||"").trim();return P?P.slice(0,1).toUpperCase():"?"},[ct]),Aa=m.useMemo(()=>new Set(Xi),[Xi]),Ji=m.useMemo(()=>l.filter(P=>Aa.has(P.source)&&Aa.has(P.target)),[l,Aa]),yf=m.useMemo(()=>{const P=R.trim().toLowerCase();return P?L.filter(B=>[B.id,B.version,B.displayName,B.name,B.description,...Array.isArray(B.tags)?B.tags:[]].filter(Boolean).some(X=>String(X).toLowerCase().includes(P))):L},[L,R]),Is=m.useCallback((P,B)=>{const X=String(P||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let Q=`${X}_${Date.now().toString(36)}`,ee=2;for(;B.has(Q);)Q=`${X}_${Date.now().toString(36)}_${ee}`,ee+=1;return B.add(Q),Q},[]),Qi=m.useCallback((P,B)=>{var It,jt;const X=P!=null&&P.snippet&&typeof P.snippet=="object"?P.snippet:{},Q=X.instances&&typeof X.instances=="object"?X.instances:{},ee=Object.keys(Q);if(ee.length===0)return;const oe=new Set(u.current.map($e=>$e.id)),ge={};for(const $e of ee)ge[$e]=Is($e,oe);const Ne=(It=X.ui)!=null&&It.nodePositions&&typeof X.ui.nodePositions=="object"?X.ui.nodePositions:{},Ie=ee.map($e=>{const we=Ne[$e];return{id:$e,x:typeof(we==null?void 0:we.x)=="number"?we.x:0,y:typeof(we==null?void 0:we.y)=="number"?we.y:0}}),ze=Math.min(...Ie.map($e=>$e.x)),zt=Math.min(...Ie.map($e=>$e.y));let Ht=B||{x:360+u.current.length*24,y:180+u.current.length*18};if(!B){const $e=document.querySelector(".af-workspace-canvas .react-flow");if($e){const we=$e.getBoundingClientRect();Ht=n.screenToFlowPosition({x:we.left+we.width*.48,y:we.top+we.height*.32})}}const Nt={},In={};for(const $e of Ie){const we=ge[$e.id];Nt[we]={...Q[$e.id]||{}},In[we]={x:Ht.x+($e.x-ze),y:Ht.y+($e.y-zt)}}const Tn=new Set(ee),ar=(Array.isArray(X.edges)?X.edges:[]).filter($e=>Tn.has($e==null?void 0:$e.source)&&Tn.has($e==null?void 0:$e.target)).map($e=>({source:ge[$e.source],target:ge[$e.target],sourceHandle:$e.sourceHandle??null,targetHandle:$e.targetHandle??null})),Qn=xy({instances:Nt,edges:ar,ui:{nodePositions:In}},k),vt=Qn.nodes.map($e=>({...$e,selected:!0}));w.current={...w.current,...Qn.instances},v(w.current),a($e=>[...$e.map(we=>({...we,selected:!1})),...vt]),c($e=>[...$e.map(we=>({...we,selected:!1})),...Qn.edges]),Pt(((jt=vt[0])==null?void 0:jt.id)||""),et(`已添加流程片段:${P.displayName||P.id}`)},[Is,k,n,c,a]),xf=m.useCallback(()=>{var X,Q;if(kn.length<2){z("请先在 workspace 画布上选择至少两个节点。"),D("flows");return}const P=kn[0],B=kn.length===2?`${((X=P.data)==null?void 0:X.label)||P.id} 片段`:`${((Q=P.data)==null?void 0:Q.label)||P.id} 等 ${kn.length} 个节点`;G({name:B,id:B.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),le(""),T(!0),D("flows")},[kn]),Ia=m.useCallback(async()=>{var Q,ee;if(kn.length<2)return;const P=C.name.trim();if(!P){le("请填写片段名称。");return}const B={};for(const oe of kn)B[oe.id]={x:((Q=oe.position)==null?void 0:Q.x)||0,y:((ee=oe.position)==null?void 0:ee.y)||0};const X=Ji.map(oe=>({source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle??null,targetHandle:oe.targetHandle??null}));W(!0),le("");try{const oe=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:C.id,name:P,displayName:P,version:"1.0.0",description:C.description,snippet:{instances:uf(kn,w.current),edges:X,ui:{nodePositions:B}}})}),ge=await oe.json().catch(()=>({}));if(!oe.ok||ge.ok===!1)throw new Error(ge.error||"发布流程片段失败");T(!1),et(`流程片段已发布:${ge.id||P}`),Cr(`流程片段已发布:${ge.id||P}`),await Yi(),D("flows")}catch(oe){le(String(oe.message||oe))}finally{W(!1)}},[Yi,C,Ji,kn,Cr]),Gc=m.useCallback(P=>{a(B=>B.map(X=>X.id===P?{...X,selected:!1}:X)),Pt(B=>B===P?"":B)},[a]),Zi=m.useCallback(()=>{const P=sr.current;if(!P)return;const B=P.getBoundingClientRect(),X=Math.min(420,Math.max(320,B.width+160)),Q=12,ee=Math.max(180,B.top-Q*2),oe=Math.min(560,ee);ln({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-X-12,B.left)),top:Math.max(Q,B.top-oe-Q),width:X,maxHeight:oe,zIndex:1e4})},[]);m.useEffect(()=>{if(!Ws)return;Zi();const P=X=>{var ee,oe;const Q=X.target;(ee=sr.current)!=null&&ee.contains(Q)||(oe=Vs.current)!=null&&oe.contains(Q)||hr(!1)},B=X=>{X.key==="Escape"&&hr(!1)};return window.addEventListener("pointerdown",P),window.addEventListener("keydown",B),window.addEventListener("resize",Zi),window.addEventListener("scroll",Zi,!0),()=>{window.removeEventListener("pointerdown",P),window.removeEventListener("keydown",B),window.removeEventListener("resize",Zi),window.removeEventListener("scroll",Zi,!0)}},[Ws,Zi]);const xl=m.useCallback(P=>{var X,Q;const B=new Map;for(const ee of P||[])(ee==null?void 0:ee.type)==="dimensions"&&((X=ee.dimensions)!=null&&X.width)&&((Q=ee.dimensions)!=null&&Q.height)&&B.set(ee.id,{width:Math.round(Number(ee.dimensions.width)),height:Math.round(Number(ee.dimensions.height))});a(ee=>Av(P,ee).map(oe=>{var Ne;const ge=B.get(oe.id);return!ge||!Bi((Ne=oe.data)==null?void 0:Ne.definitionId)?oe:{...oe,data:{...oe.data,displaySize:ge}}}))},[a]),eo=m.useCallback(()=>{const P=document.querySelector(".af-workspace-canvas .react-flow");if(P){const B=P.getBoundingClientRect();return n.screenToFlowPosition({x:B.left+B.width*.48,y:B.top+B.height*.32})}return{x:360+i.length*36,y:180+i.length*28}},[i.length,n]),Js=m.useCallback(()=>{var P,B,X;if(dt){const Q=Number(((P=dt.measured)==null?void 0:P.width)||dt.width||260);return{x:Number(((B=dt.position)==null?void 0:B.x)||0)+Q+140,y:Number(((X=dt.position)==null?void 0:X.y)||0)}}return eo()},[eo,dt]),Kr=m.useCallback((P,B={})=>{if(!P)return null;const X=B.id||t7(P.id,i),Q=Cp(P.inputs),ee=Cp(P.outputs),oe={definitionId:P.id,label:B.label||n0(P),role:"normal",body:B.body||"",input:B.inputs||Q,output:B.outputs||ee},ge={id:X,type:df,position:B.position||eo(),data:{label:oe.label,definitionId:P.id,schemaType:xI(P.id,P),role:"normal",body:oe.body,inputs:oe.input,outputs:oe.output}},Ne={...Hd(ge,{...w.current,[X]:oe},k),selected:!0};return a(Ie=>[...Ie.map(ze=>({...ze,selected:!1})),Ne]),Pt(X),X},[eo,i,k,a]),Xc=m.useCallback(P=>ZN(P,u.current),[]),qr=m.useCallback(P=>{if(!ZN(P,u.current)){et("端口类型不匹配,已取消连线");return}S(null),a(B=>qh(B,P)),c(B=>{const X=B.filter(Q=>!(Q.target===P.target&&Q.targetHandle===P.targetHandle));return Ld({...P,markerEnd:{type:cs.ArrowClosed}},X)})},[c,a]),Ta=m.useCallback((P,B)=>{h.current=QV(B,u.current),S(null)},[]),wl=m.useCallback((P,B)=>{var Nt,In,Tn,ar;const X=h.current;if(h.current=null,!X||B!=null&&B.toNode)return;const Q=ZV(k,X);if(Q.length===0){et(`没有匹配 ${X.slotType} 端口的节点`);return}const ee=((In=(Nt=P==null?void 0:P.changedTouches)==null?void 0:Nt[0])==null?void 0:In.clientX)??(P==null?void 0:P.clientX),oe=((ar=(Tn=P==null?void 0:P.changedTouches)==null?void 0:Tn[0])==null?void 0:ar.clientY)??(P==null?void 0:P.clientY);if(!Number.isFinite(ee)||!Number.isFinite(oe))return;const ge=document.querySelector(".af-workspace-canvas .react-flow");if(!ge)return;const Ne=ge.getBoundingClientRect(),Ie=320,ze=Math.min(440,104+Q.length*58),zt=Math.max(12,Math.min(ee-Ne.left,Ne.width-Ie-12)),Ht=Math.max(12,Math.min(oe-Ne.top,Ne.height-ze-12));S({left:zt,top:Ht,flowPosition:n.screenToFlowPosition({x:ee,y:oe}),draft:X,candidates:Q,query:""})},[k,n]),Ra=m.useCallback(P=>{const B=g.current;if(!B||!(P!=null&&P.def))return;const X=Kr(P.def,{position:B.flowPosition});if(!X)return;const Q=B.draft.handleType==="source"?{source:B.draft.nodeId,sourceHandle:B.draft.handleId,target:X,targetHandle:`input-${P.slotIndex}`}:{source:X,sourceHandle:`output-${P.slotIndex}`,target:B.draft.nodeId,targetHandle:B.draft.handleId};a(ee=>qh(ee,Q)),c(ee=>{const oe=ee.filter(ge=>!(ge.target===Q.target&&ge.targetHandle===Q.targetHandle));return Ld({...Q,markerEnd:{type:cs.ArrowClosed}},oe)}),S(null)},[Kr,c]),Po=m.useCallback(P=>{P&&(Kr(P,{position:Js()}),re(!1),Be(""))},[Kr,Js]),Ao=m.useCallback(P=>{P&&(Qi(P,Js()),re(!1),Be(""))},[Qi,Js]);m.useEffect(()=>{const P=B=>{if(B.defaultPrevented)return;const X=rI(B.target)||YV(B.target);if((B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="s"){B.preventDefault(),xr().catch(Q=>et(String(Q.message||Q)));return}if(Ae){(B.key==="Escape"||Gh(B))&&(B.preventDefault(),Ue(!1));return}if(!X){if((B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="c"){const Q=GA(u.current,f.current,w.current);Q&&(B.preventDefault(),B.stopPropagation(),p.current=Q,et(`Copied ${Q.nodes.length} node${Q.nodes.length>1?"s":""}`));return}if((B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="v"){const Q=XA(p.current,u.current,f.current,w.current);Q&&(B.preventDefault(),B.stopPropagation(),w.current=Q.instances,v(Q.instances),a(Q.nodes),c(Q.edges),Pt(Q.pastedNodeIds[0]||""),et(`Pasted ${Q.pastedNodeIds.length} node${Q.pastedNodeIds.length>1?"s":""}`));return}if(Gh(B)&&!B.metaKey&&!B.ctrlKey&&!B.altKey){B.preventDefault(),Ue(!0);return}if(B.key==="a"||B.key==="A"){if(B.metaKey||B.ctrlKey){B.preventDefault(),a(Q=>Q.map(ee=>({...ee,selected:!0}))),c(Q=>Q.map(ee=>({...ee,selected:!1})));return}if(B.altKey)return;B.preventDefault(),re(!0);return}if((B.key==="v"||B.key==="V")&&!B.metaKey&&!B.ctrlKey&&!B.altKey){B.preventDefault(),Bn("select");return}(B.key==="h"||B.key==="H")&&!B.metaKey&&!B.ctrlKey&&!B.altKey&&(B.preventDefault(),Bn("pan"))}};return window.addEventListener("keydown",P,!0),()=>window.removeEventListener("keydown",P,!0)},[xr,Ae,c,a]);const Vm=m.useCallback(P=>{Xe(B=>{const X=new Set(B);return X.has(P)?X.delete(P):X.add(P),X})},[]),Jc=m.useCallback((P,B)=>{P.dataTransfer.effectAllowed="copy",P.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:B.path,name:B.name,type:B.type})),P.dataTransfer.setData("text/plain",B.path)},[]),vl=m.useCallback((P,B)=>{P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("application/agentflow-node",B.id),P.dataTransfer.setData("text/plain",B.id)},[]),vi=m.useCallback(async(P,B)=>{const X=k.find(ze=>ze.id==="display_markdown");if(!X){et("Markdown Display 节点不可用");return}const Q=jp(s);Q.set("path",P.path);const ee=await fetch(`/api/workspace/file?${Q.toString()}`),oe=await ee.json();if(!ee.ok)throw new Error(oe.error||"读取文件失败");const ge=String(oe.content||""),Ne=Cp(X.inputs).map(ze=>ze.name==="content"?{...ze,default:ge}:ze),Ie=Cp(X.outputs).map(ze=>ze.name==="content"?{...ze,default:ge}:ze);Kr(X,{label:P.name||"Markdown",body:ge,inputs:Ne,outputs:Ie,position:B}),et(`已创建 Markdown 展示:${P.path}`)},[Kr,s,k]),Qc=m.useCallback(P=>{vi(P,eo()).catch(B=>et(String(B.message||B)))},[vi,eo]),wf=m.useCallback(P=>{const B=P.dataTransfer.getData("application/x-agentflow-workspace-file");if(B){P.preventDefault();let ge;try{ge=JSON.parse(B)}catch{return}if(!(ge!=null&&ge.path))return;const Ne=n.screenToFlowPosition({x:P.clientX,y:P.clientY});vi(ge,Ne).catch(Ie=>et(String(Ie.message||Ie)));return}const X=P.dataTransfer.getData("application/agentflow-snippet");if(X){const ge=L.find(Ie=>`${Ie.id}@${Ie.version}`===X);if(!ge)return;P.preventDefault();const Ne=n.screenToFlowPosition({x:P.clientX,y:P.clientY});Qi(ge,Ne);return}const Q=P.dataTransfer.getData("application/agentflow-node");if(!Q)return;const ee=k.find(ge=>ge.id===Q);if(!ee)return;P.preventDefault();const oe=n.screenToFlowPosition({x:P.clientX,y:P.clientY});Kr(ee,{position:oe})},[vi,Kr,L,Qi,k,n]),Zc=m.useCallback(P=>{const B=Array.from(P.dataTransfer.types||[]);!B.includes("application/x-agentflow-workspace-file")&&!B.includes("application/agentflow-node")&&!B.includes("application/agentflow-snippet")||(P.preventDefault(),P.dataTransfer.dropEffect=B.includes("application/agentflow-node")||B.includes("application/agentflow-snippet")?"move":"copy")},[]),bl=m.useCallback(async(P="")=>{const B=window.prompt("新文件名",P?`${P}/notes.md`:"notes.md");if(!B)return;const X=P&&!B.includes("/")?`${P}/${B}`:B;try{const Q=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:X,content:""})}),ee=await Q.json();if(!Q.ok)throw new Error(ee.error||"创建文件失败");et(`已创建 ${ee.path}`),await Hn()}catch(Q){et(String(Q.message||Q))}},[s,Hn]),Io=m.useCallback(async(P="")=>{const B=window.prompt("新文件夹名",P?`${P}/docs`:"docs");if(!B)return;const X=P&&!B.includes("/")?`${P}/${B}`:B;try{const Q=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:X})}),ee=await Q.json();if(!Q.ok)throw new Error(ee.error||"创建文件夹失败");Xe(oe=>{const ge=new Set(oe);return P&&ge.delete(P),ge}),et(`已创建 ${ee.path}`),await Hn()}catch(Q){et(String(Q.message||Q))}},[s,Hn]),Km=m.useCallback(async P=>{if(!(!(P!=null&&P.path)||!window.confirm(`删除 ${P.path}?`)))try{const B=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,path:P.path})}),X=await B.json();if(!B.ok)throw new Error(X.error||"删除失败");et(`已删除 ${X.path}`),await Hn()}catch(B){et(String(B.message||B))}},[s,Hn]),vf=m.useCallback(async()=>{const P=mr.trim();if(!P||Xt)return;const B=wy(i,l,w.current);He(""),_e(!0),Kc("workspace"),Er(X=>[...X,{role:"user",text:P,at:Date.now()}]);try{await xr(i,l);const X=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...s,prompt:P,outputKind:"markdown",workspaceGraph:B,allowFlowYaml:!1,model:Dt,selectedSkills:Ee,selectedNodeIds:Xi})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"生成失败");const ee=String(Q.content||"").trim();Er(oe=>[...oe,{role:"assistant",text:ee,at:Date.now()}]),await mn(),et("AI 生成完成")}catch(X){const Q=String(X.message||X);Er(ee=>[...ee,{role:"assistant",text:Q,error:!0,at:Date.now()}]),et(Q)}finally{_e(!1)}},[Dt,Xt,mr,l,s,mn,i,Kc,xr,Xi,Ee]),Ke=ot.find(P=>P.id===ir)||null,eu=Ke?Array.isArray(Ke.messages)?Ke.messages:[]:bn,bf=Ke?Ke.status==="running":Xt,kl=Ke?Ke.status==="running"?`${Ke.label} running`:Ke.status==="paused"?`${Ke.label} paused`:Ke.status==="failed"?`${Ke.label} failed`:`${Ke.label} done`:Xt?"Workspace agent running":bn.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} · ${fr}`:fr||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",WV,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{t(pv({id:s.flowId,source:s.flowSource||"user",archived:!!s.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Workspace"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:pl}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Ue(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(ps?" af-composer-topbar-btn--active":"")+(Xt?" af-composer-topbar-btn--running":""),onClick:()=>Jn(P=>!P),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",onClick:()=>xr().catch(P=>et(String(P.message||P))),children:"Save"})]})]}),ue?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:ue}),o.jsx("button",{type:"button",onClick:()=>de(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(ps||Te?" af-workspace-body--drawer":"")+(q?" af-workspace-body--sidebar-collapsed":""),children:[q?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:()=>re(!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:()=>be(!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:()=>be(!1),"aria-label":"展开侧边栏",title:(ct==null?void 0:ct.username)||(ct==null?void 0:ct.userId)||"展开侧边栏",children:yl})]})}):null,o.jsxs("aside",{className:"af-workspace-sidebar","aria-hidden":q,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:()=>be(!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",onClick:()=>bl(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Io(""),"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 Hn(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:xe,onChange:P=>Ve(P.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(kI,{items:gl,onOpen:Qc,collapsedDirs:Ze,onToggleDir:Vm,onCreateFile:bl,onCreateFolder:Io,onDelete:Km,onFileDragStart:Jc})})]}),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:K==="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:R,onChange:P=>$(P.target.value),placeholder:K==="flows"?"搜索流程片段...":"搜索节点...","aria-label":K==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":K==="nodes",className:"af-palette-tab"+(K==="nodes"?" af-palette-tab--active":""),onClick:()=>D("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":K==="flows",className:"af-palette-tab"+(K==="flows"?" af-palette-tab--active":""),onClick:()=>D("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:K==="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:xf,disabled:kn.length<2,title:kn.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:["已选 ",kn.length," 节点 / ",Ji.length," 连线"]})]})}),A?o.jsx("p",{className:"af-err af-palette-list-err",children:A}):null,M?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):yf.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:yf.map(P=>{const B=`${P.id}@${P.version}`,X=P.displayName||P.name||P.id,Q=P.description||`${P.nodeCount||0} 个节点,${P.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:ee=>{ee.dataTransfer.effectAllowed="move",ee.dataTransfer.setData("application/agentflow-snippet",B),ee.dataTransfer.setData("text/plain",B)},onClick:()=>Qi(P),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:X}),o.jsxs("span",{className:"af-palette-card-id",children:[P.id,"@",P.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:[P.nodeCount||0," nodes"]}),o.jsxs("span",{children:[P.edgeCount||0," edges"]})]})]},B)})})]}):o.jsx("p",{className:"af-palette-empty",children:R.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Dl.map(P=>{var B;return(B=Ea[P])!=null&&B.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${P}`,children:[o.jsx("h3",{className:"af-palette-cat",children:P}),o.jsx("div",{className:"af-palette-cards",children:Ea[P].map(X=>{const Q=QN(X.inputs,"input"),ee=QN(X.outputs,"output"),oe=uw(X),ge=Hu(X);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:Ne=>vl(Ne,X),onClick:()=>Kr(X),title:oe||X.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:XN(P)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:ge}),ge!==X.id?o.jsx("span",{className:"af-palette-card-id",children:X.id}):null]})]}),oe?o.jsx("span",{className:"af-palette-card-desc",children:oe}):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:[Q.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((Ne,Ie)=>o.jsxs("span",{className:"af-palette-card-port",title:JN("input",Ne,Ie),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Kn(Ne==null?void 0:Ne.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:yy(Ne,Ie)})]},`in-${Ie}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.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:[ee.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[ee.shown.map((Ne,Ie)=>o.jsxs("span",{className:"af-palette-card-port",title:JN("output",Ne,Ie),children:[o.jsx("span",{className:"af-palette-card-port-name",children:yy(Ne,Ie)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:Kn(Ne==null?void 0:Ne.type)}})]},`out-${Ie}`)),ee.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",ee.hidden]}):null]})]})]})]},X.id)})})]},P):null}),k.length>0&&R.trim()&&Dl.every(P=>{var B;return!((B=Ea[P])!=null&&B.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(gP,{className:"af-flow-canvas af-workspace-flow"+(yt==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),nodes:Ca,edges:ml,nodeTypes:v7,onNodesChange:xl,onEdgesChange:d,onConnect:qr,onConnectStart:Ta,onConnectEnd:wl,isValidConnection:Xc,onNodeClick:(P,B)=>{_t&&Pt(B.id)},onNodeDoubleClick:(P,B)=>{P.preventDefault(),Jn(!1),a(X=>X.map(Q=>({...Q,selected:Q.id===B.id}))),c(X=>X.map(Q=>({...Q,selected:!1}))),Pt(B.id)},onPaneClick:()=>Pt(""),onDrop:wf,onDragOver:Zc,selectionOnDrag:yt==="select",panOnDrag:yt==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(bP,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),b?(()=>{var Q;const P=String(b.query||"").trim().toLowerCase(),B=P?b.candidates.filter(ee=>{var oe,ge,Ne;return[(oe=ee.def)==null?void 0:oe.id,ee.displayLabel,ee.description,(ge=ee.slot)==null?void 0:ge.name,(Ne=ee.slot)==null?void 0:Ne.type].filter(Boolean).some(Ie=>String(Ie).toLowerCase().includes(P))}):b.candidates,X=b.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:b.left,top:b.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:Kn((Q=b.draft.slot)==null?void 0:Q.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",b.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>S(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:b.query,onChange:ee=>S(oe=>oe&&{...oe,query:ee.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[B.map(ee=>{var Ne,Ie;const oe=ee.displayLabel||((Ne=ee.def)==null?void 0:Ne.id),ge=yy(ee.slot,ee.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>Ra(ee),title:ee.description||ee.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:oe}),oe!==ee.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:ee.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:X}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Kn((Ie=ee.slot)==null?void 0:Ie.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:ge})]})]},`${ee.def.id}-${ee.slotIndex}`)}),B.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,Ks?o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>_r(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):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:()=>_r(!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:kn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):kn.map(P=>{var ee,oe;const B=String(((ee=P.data)==null?void 0:ee.label)??P.id),X=(oe=P.data)!=null&&oe.definitionId?String(P.data.definitionId):"",Q=X&&X!==B?`${B} · ${P.id} · ${X}`:`${B} · ${P.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:Q,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:X||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:B}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Gc(P.id),"aria-label":`取消选择 ${P.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},P.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:mr,rows:2,onChange:P=>He(P.target.value),onKeyDown:P=>{(P.metaKey||P.ctrlKey)&&P.key==="Enter"&&(P.preventDefault(),vf())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:sr,type:"button",className:"af-composer-skills-button"+(Ee.length>0?" af-composer-skills-button--active":""),disabled:Xt,"aria-haspopup":"listbox","aria-expanded":Ws,onClick:()=>hr(P=>!P),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:Ee.length>0?`Skills ${Ee.length}`:"Skills"})]}),Ws&&!Xt?es.createPortal(o.jsx("div",{ref:Vs,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:Vt,children:Yt.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Pa.groups.map(P=>{const B=pa(P,Yt),X=jE(P,_o,Yt),Q=fs.has(P.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:X==="all",disabled:B.length===0,onChange:ee=>{const oe=ee.target.checked;Wt(ge=>oe?SE(ge,B):NE(ge,B))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:P.name}),P.builtin?o.jsx("em",{children:"built-in"}):null,X==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":Q?`展开 ${P.name}`:`收起 ${P.name}`,onClick:()=>{xi(ee=>{const oe=new Set(ee);return oe.has(P.id)?oe.delete(P.id):oe.add(P.id),oe})},children:[o.jsx("span",{children:P.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:P.skills.map(ee=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:_o.has(ee.key),onChange:oe=>{const ge=oe.target.checked;Wt(Ne=>ge?Ne.includes(ee.key)?Ne:[...Ne,ee.key]:Ne.filter(Ie=>Ie!==ee.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:ee.name}),ee.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:ee.description}):null]})]},`${P.id}:${ee.key}`))})]},P.id)}),Pa.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:Pa.ungrouped.length})]}),Pa.ungrouped.map(P=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:_o.has(P.key),onChange:B=>{const X=B.target.checked;Wt(Q=>X?Q.includes(P.key)?Q:[...Q,P.key]:Q.filter(ee=>ee!==P.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:P.name}),P.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:P.description}):null]})]},`ungrouped:${P.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:Dt,onChange:P=>Mn(P.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),_a.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(mr.trim()&&!Xt?" af-composer-send--active":"")+(Xt?" af-composer-send--stop":""),disabled:Xt||!mr.trim(),"aria-label":Xt?"Running":"Send",onClick:()=>void vf(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Xt?"sync":"arrow_upward"})})]})]})]})})]}),ps?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:()=>Jn(!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"+(ir==="workspace"?" af-composer-session-tab--active":""),onClick:()=>zn("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),ot.map(P=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(ir===P.id?" af-composer-session-tab--active":"")+(P.status==="running"?" af-composer-session-tab--running":""),onClick:()=>zn(P.id),title:P.runNodeId||P.label,children:o.jsx("span",{className:"af-composer-session-label",children:P.label})},P.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(bf?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:kl}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(b7,{messages:eu,running:bf,showRunningIndicator:!Ke})})]})}):Te&&dt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(cI,{draft:Te,setDraft:an,definitionId:String(((rt=dt.data)==null?void 0:rt.definitionId)||dt.id),systemPromptReadonly:String(((kf=dt.data)==null?void 0:kf.description)||""),modelLists:At,disabled:!1,onIdBlur:()=>As(!0),onClose:()=>Pt(""),onPublishToMarketplace:Sa,error:Fn,ioSlots:{inputs:Array.isArray(Te==null?void 0:Te.inputs)?Te.inputs:[],outputs:Array.isArray(Te==null?void 0:Te.outputs)?Te.outputs:[]}})}):null,o.jsx(sI,{open:Ae,onClose:()=>Ue(!1)}),_?es.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:()=>T(!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:C.name,onChange:P=>{const B=P.target.value;G(X=>({...X,name:B,id:X.id?X.id:B.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:C.id,onChange:P=>G(B=>({...B,id:P.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:C.description,onChange:P=>G(B=>({...B,description:P.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",kn.length," 个节点和 ",Ji.length," 条内部连线。"]}),te?o.jsx("div",{className:"af-flow-snippet-error",children:te}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>T(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Z||!C.name.trim(),onClick:()=>void Ia(),children:Z?"发布中...":"发布"})]})]})}),document.body):null,fe?es.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>re(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:P=>P.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":pe==="nodes",className:"af-workspace-quick-add__tab"+(pe==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>ae("nodes"),children:"节点"}),o.jsx("button",{type:"button",role:"tab","aria-selected":pe==="flows",className:"af-workspace-quick-add__tab"+(pe==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>ae("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:Ye,value:ye,onChange:P=>Be(P.target.value),onKeyDown:P=>{if(P.key==="Escape")P.preventDefault(),re(!1);else if(P.key==="ArrowDown"){P.preventDefault();const B=pe==="flows"?An.length:Xs.length;Ge(X=>Math.min(Math.max(0,B-1),X+1))}else P.key==="ArrowUp"?(P.preventDefault(),Ge(B=>Math.max(0,B-1))):P.key==="Tab"?(P.preventDefault(),ae(B=>B==="nodes"?"flows":"nodes")):P.key==="Enter"&&(P.preventDefault(),pe==="flows"?Ao(An[lt]||An[0]):Po(Xs[lt]||Xs[0]))},placeholder:pe==="flows"?"搜索流程片段...":"搜索节点...","aria-label":pe==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:pe==="flows"?An.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:M?"正在加载流程片段...":A||"没有匹配的流程片段"}):An.map((P,B)=>{const X=P.displayName||P.name||P.id,Q=P.snippet&&typeof P.snippet=="object"?P.snippet.instances:null,ee=P.snippet&&typeof P.snippet=="object"?P.snippet.edges:null,oe=Number.isFinite(Number(P.nodeCount))?Number(P.nodeCount):Object.keys(Q||{}).length,ge=Number.isFinite(Number(P.edgeCount))?Number(P.edgeCount):Array.isArray(ee)?ee.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(B===lt?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ge(B),onClick:()=>Ao(P),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:X}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[P.id,P.version?` · v${P.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:P.description||`${oe} 节点 / ${ge} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${P.id}@${P.version}`)}):Xs.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Xs.map((P,B)=>{const X=Bu(P),Q=Hu(P),ee=uw(P);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(B===lt?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>Ge(B),onClick:()=>Po(P),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:XN(X)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:Q}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:P.id}),ee?o.jsx("span",{className:"af-workspace-quick-add__desc",children:ee}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:X})]},P.id)})})]})}),document.body):null]})]})}function C7(){return o.jsx(Tv,{children:o.jsx(j7,{})})}const it=e=>typeof e=="string",Pu=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},n1=e=>e==null?"":""+e,E7=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},_7=/###/g,r1=e=>e&&e.indexOf("###")>-1?e.replace(_7,"."):e,s1=e=>!e||it(e),ad=(e,t,n)=>{const r=it(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(s1(e))return{};const i=r1(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return s1(e)?{}:{obj:e,k:r1(r[s])}},i1=(e,t,n)=>{const{obj:r,k:s}=ad(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=ad(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=ad(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},P7=(e,t,n,r)=>{const{obj:s,k:i}=ad(e,t,Object);s[i]=s[i]||[],s[i].push(n)},Xh=(e,t)=>{const{obj:n,k:r}=ad(e,t);if(n)return n[r]},A7=(e,t,n)=>{const r=Xh(e,n);return r!==void 0?r:Xh(t,n)},SI=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?it(e[r])||e[r]instanceof String||it(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):SI(e[r],t[r],n):e[r]=t[r]);return e},Ol=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var I7={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const T7=e=>it(e)?e.replace(/[&<>"'\/]/g,t=>I7[t]):e;class R7{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 L7=[" ",",","?","!",";"],O7=new R7(20),M7=(e,t,n)=>{t=t||"",n=n||"";const r=L7.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=O7.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},dw=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},Jh=e=>e&&e.replace("_","-"),$7={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 Qh{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||$7,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:(it(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Qh(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Qh(this.logger,t)}}var Mi=new Qh;class Fm{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 o1 extends Fm{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):it(r)&&i?l.push(...r.split(i)):l.push(r)));const c=Xh(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!it(r)?c:dw(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),i1(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)(it(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=Xh(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?SI(c,r,i):c={...c,...r},i1(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 NI={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 a1={};class Zh extends Fm{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),E7(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Mi.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&&!M7(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:it(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:it(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,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(u){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 f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||a,g=f&&f.exactUsedKey||a,b=Object.prototype.toString.apply(p),S=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!it(p)&&typeof p!="boolean"&&typeof p!="number";if(v&&p&&w&&S.indexOf(b)<0&&!(it(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(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=j,f.usedParams=this.getUsedParamsDetails(n),f):j}if(i){const j=Array.isArray(p),E=j?[]:{},k=j?g:h;for(const I in p)if(Object.prototype.hasOwnProperty.call(p,I)){const R=`${k}${i}${I}`;E[I]=this.translate(R,{...n,joinArrays:!1,ns:l}),E[I]===R&&(E[I]=p[I])}p=E}}else if(v&&it(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,E=!1;const k=n.count!==void 0&&!it(n.count),I=Zh.hasDefaultValue(n),R=k?this.pluralResolver.getSuffix(d,n.count,n):"",$=n.ordinal&&k?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",K=k&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),D=K&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${R}`]||n[`defaultValue${$}`]||n.defaultValue;!this.isValidLookup(p)&&I&&(j=!0,p=D),this.isValidLookup(p)||(E=!0,p=a);const H=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&E?void 0:p,M=I&&D!==p&&this.options.updateMissing;if(E||j||M){if(this.logger.log(M?"updateKey":"missingKey",d,c,a,M?D: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 O=[];const A=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&A&&A[0])for(let _=0;_<A.length;_++)O.push(A[_]);else this.options.saveMissingTo==="all"?O=this.languageUtils.toResolveHierarchy(n.lng||this.language):O.push(n.lng||this.language);const z=(_,T,C)=>{const G=I&&C!==p?C:H;this.options.missingKeyHandler?this.options.missingKeyHandler(_,c,T,G,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(_,c,T,G,M,n),this.emit("missingKey",_,c,T,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&k?O.forEach(_=>{const T=this.pluralResolver.getSuffixes(_,n);K&&n[`defaultValue${this.options.pluralSeparator}zero`]&&T.indexOf(`${this.options.pluralSeparator}zero`)<0&&T.push(`${this.options.pluralSeparator}zero`),T.forEach(C=>{z([_],a+C,n[`defaultValue${C}`]||D)})}):z(O,a,D))}p=this.extendTranslation(p,t,n,f,r),E&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(E||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,j?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,s,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=it(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(d){const p=t.match(this.interpolator.nestingRegexp);u=p&&p.length}let f=r.replace&&!it(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;u<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return i&&i[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=it(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=NI.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 it(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(c,n),u=d.key;s=u;let f=d.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!it(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(it(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(S=>{this.isValidLookup(r)||(l=S,!a1[`${b[0]}-${S}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(a1[`${b[0]}-${S}`]=!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 v=[u];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(v,u,y,S,n);else{let j;p&&(j=this.pluralResolver.getSuffix(y,n.count,n));const E=`${this.options.pluralSeparator}zero`,k=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(v.push(u+j),n.ordinal&&j.indexOf(k)===0&&v.push(u+j.replace(k,this.options.pluralSeparator)),h&&v.push(u+E)),g){const I=`${u}${this.options.contextSeparator}${n.context}`;v.push(I),p&&(v.push(I+j),n.ordinal&&j.indexOf(k)===0&&v.push(I+j.replace(k,this.options.pluralSeparator)),h&&v.push(I+E))}}let w;for(;w=v.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,S,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&&!it(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 vy=e=>e.charAt(0).toUpperCase()+e.slice(1);class l1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Mi.create("languageUtils")}getScriptPartFromCode(t){if(t=Jh(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=Jh(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(it(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]=vy(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]=vy(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=vy(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)),it(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 it(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))):it(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let D7=[{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}],F7={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 z7=["v1","v2","v3"],B7=["v4"],c1={zero:0,one:1,two:2,few:3,many:4,other:5},H7=()=>{const e={};return D7.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:F7[t.fc]}})}),e};class U7{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Mi.create("pluralResolver"),(!this.options.compatibilityJSON||B7.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=H7(),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=Jh(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)=>c1[s]-c1[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!z7.includes(this.options.compatibilityJSON)}}const u1=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=A7(e,t,n);return!i&&s&&it(n)&&(i=dw(e,n,r),i===void 0&&(i=dw(t,n,r))),i},by=e=>e.replace(/\$/g,"$$$$");class W7{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Mi.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:u,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:S,maxReplaces:y,alwaysFormat:v}=t.interpolation;this.escape=n!==void 0?n:T7,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?Ol(i):a||"{{",this.suffix=l?Ol(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=u?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=p?Ol(p):h||Ol("$t("),this.nestingSuffix=g?Ol(g):b||Ol(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=y||1e3,this.alwaysFormat=v!==void 0?v:!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=h=>{if(h.indexOf(this.formatSeparator)<0){const y=u1(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:h}):y}const g=h.split(this.formatSeparator),b=g.shift().trim(),S=g.join(this.formatSeparator).trim();return this.format(u1(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const u=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>by(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?by(this.escape(h)):by(h)}].forEach(h=>{for(l=0;i=h.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof u=="function"){const S=u(t,i,s);a=it(S)?S:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(f){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!it(a)&&!this.useRawValueToEscape&&(a=n1(a));const b=h.safeValue(a);if(t=t.replace(i[0],b),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=i[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(c,d)=>{const u=this.nestingOptionsSeparator;if(c.indexOf(u)<0)return c;const f=c.split(new RegExp(`${u}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const h=p.match(/'/g),g=p.match(/"/g);(h&&h.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}${u}${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&&!it(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 u=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=u.shift(),c=u,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!it(i))return i;it(i)||(i=n1(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=c.reduce((u,f)=>this.format(u,f,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const V7=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,""),u=l.trim();n[u]||(n[u]=d),d==="false"&&(n[u]=!1),d==="true"&&(n[u]=!0),isNaN(d)||(n[u]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},Ml=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(Jh(r),s),t[a]=l),l(n)}};class K7{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Mi.create("formatter"),this.options=t,this.formats={number:Ml((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:Ml((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:Ml((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:Ml((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:Ml((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()]=Ml(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:u}=V7(c);if(this.formats[d]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[d](l,h,{...u,...s,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const q7=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class Y7 extends Fm{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=Mi.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 u=!0;n.forEach(f=>{const p=`${d}|${f}`;!r.reload&&this.store.hasResourceBundle(d,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,u=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),c[f]===void 0&&(c[f]=!0)))}),u||(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=>{P7(c.loaded,[i],a),q7(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const u=c.loaded[d];u.length&&u.forEach(f=>{l[d][f]===void 0&&(l[d][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,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,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(d&&u&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,u)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const d=c(t,n);d&&typeof d.then=="function"?d.then(u=>l(null,u)).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();it(t)&&(t=this.languageUtils.toResolveHierarchy(t)),it(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 u;d.length===5?u=d(t,n,r,s,c):u=d(t,n,r,s),u&&typeof u.then=="function"?u.then(f=>l(null,f)).catch(l):l(null,u)}catch(u){l(u)}else d(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const d1=()=>({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]),it(e[1])&&(t.defaultValue=e[1]),it(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}}),f1=e=>(it(e.ns)&&(e.ns=[e.ns]),it(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),it(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Ep=()=>{},G7=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Ud extends Fm{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=f1(t),this.services={},this.logger=Mi,this.modules={external:[]},G7(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&&(it(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=d1();this.options={...s,...this.options,...f1(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=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?Mi.init(i(this.modules.logger),this.options):Mi.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=K7);const f=new l1(this.options);this.store=new o1(this.options.resources,this.options);const p=this.services;p.logger=Mi,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new U7(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(u),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new W7(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new Y7(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var g=arguments.length,b=new Array(g>1?g-1:0),S=1;S<g;S++)b[S-1]=arguments[S];t.emit(h,...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 Zh(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,b=new Array(g>1?g-1:0),S=1;S<g;S++)b[S-1]=arguments[S];t.emit(h,...b)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Ep),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=function(){return t.store[u](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=function(){return t.store[u](...arguments),t}});const c=Pu(),d=()=>{const u=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};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]:Ep;const s=it(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=Pu();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=Ep),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"&&NI.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=Pu();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=it(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,u=>{a(u,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,u=new Array(d>2?d-2:0),f=2;f<d;f++)u[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(u))}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 h;return c.keyPrefix&&Array.isArray(a)?h=a.map(g=>`${c.keyPrefix}${p}${g}`):h=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(h,c)};return it(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=Pu();return this.options.ns?(it(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=Pu();it(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 l1(d1());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 Ud(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ep;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new Ud(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 o1(this.store.data,s),i.services.resourceStore=i.store),i.translator=new Zh(i.services,s),i.translator.on("*",function(l){for(var c=arguments.length,d=new Array(c>1?c-1:0),u=1;u<c;u++)d[u-1]=arguments[u];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 Nr=Ud.createInstance();Nr.createInstance=Ud.createInstance;Nr.createInstance;Nr.dir;Nr.init;Nr.loadResources;Nr.reloadResources;Nr.use;Nr.changeLanguage;Nr.getFixedT;Nr.t;Nr.exists;Nr.setDefaultNamespace;Nr.hasLoadedNamespace;Nr.loadNamespaces;Nr.loadLanguages;function X7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wd(e){"@babel/helpers - typeof";return Wd=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},Wd(e)}function J7(e,t){if(Wd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Wd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Q7(e){var t=J7(e,"string");return Wd(t)=="symbol"?t:t+""}function Z7(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,Q7(r.key),r)}}function eK(e,t,n){return t&&Z7(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var jI=[],tK=jI.forEach,nK=jI.slice;function rK(e){return tK.call(nK.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]+$/,sK=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},h1={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=sK(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)}},iK={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=h1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&h1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},oK={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}},Au=null,m1=function(){if(Au!==null)return Au;try{Au=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Au=!1}return Au},aK={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&m1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&m1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Iu=null,g1=function(){if(Iu!==null)return Iu;try{Iu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Iu=!1}return Iu},lK={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&g1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&g1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},cK={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}},uK={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}},dK={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}},fK={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]}},CI=!1;try{document.cookie,CI=!0}catch{}var EI=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];CI||EI.splice(1,1);function pK(){return{order:EI,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var _I=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};X7(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return eK(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=rK(r,this.options||{},pK()),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(iK),this.addDetector(oK),this.addDetector(aK),this.addDetector(lK),this.addDetector(cK),this.addDetector(uK),this.addDetector(dK),this.addDetector(fK)}},{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)}))}}])}();_I.type="languageDetector";const hK={name:"AgentFlow",tagline:"AI Workflow Orchestration"},mK={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},gK={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"},yK={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},xK={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},wK={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},vK={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},bK={app:hK,nav:mK,common:gK,status:yK,nodeTypes:xK,engine:wK,links:vK},kK="Flow Editor",SK="Nodes",NK="Edges",jK="Properties",CK={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"},EK={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}}"},_K={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},PK={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},AK={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"},IK={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)"},TK={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},RK={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},LK={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},OK={node:"Node",text:"Text",file:"File",bool:"Boolean"},MK={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"},$K={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",selectAll:"Select all nodes"},DK={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},FK={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."},zK={mainNav:"Main Navigation"},BK={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'},HK={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):
152
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
153
- 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}}"},UK={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"},WK={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},VK={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}}"},KK={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"},qK={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"},YK={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"},GK={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"},XK={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"},JK={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},QK={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},ZK={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"},eq={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."},tq={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},nq={save:"Save",cancel:"Cancel"},rq={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},sq={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},iq={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"},oq={title:kK,nodes:SK,edges:NK,properties:jK,node:CK,nodeProps:EK,actions:_K,panel:PK,palette:AK,pipeline:IK,status:TK,roles:RK,phases:LK,types:OK,runContext:MK,shortcuts:$K,jumpPalette:DK,emptyCanvas:FK,sidebar:zK,validation:BK,composer:HK,topbar:UK,palette2:WK,run:VK,fileEdit:KK,settings:qK,schedule:YK,history:GK,nodePropsError:XK,placeholder:JK,time:QK,userCheck:ZK,userAsk:eq,toolPrint:tq,provideEdit:nq,runParams:rq,runPreset:sq,runConfig:iq},aq="Settings",lq={engine:"Engine Settings",preferences:"Global Preferences"},cq={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)."},uq={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..."}},dq={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."},fq={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."},pq={title:"Environment Variables",note:"Private to the current signed-in user; overrides service-level env at runtime",saving:"Saving...",key:"Key",value:"Value",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)"},hq={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},mq={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},gq={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},yq={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."},xq={title:aq,crumb:lq,workspace:cq,cursor:uq,opencode:dq,claudeCode:fq,env:pq,system:hq,shortcuts:mq,language:gq,onboarding:yq},wq={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},vq={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)"},bq={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},kq={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},Sq={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},Nq={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},jq={aiLabels:wq,placeholders:vq,actions:bq,labels:kq,tooltips:Sq,rightPanel:Nq},Cq="Projects",Eq="All",_q="Archived",Pq="Nodes",Aq="My Nodes",Iq="My Flows",Tq="Skills",Rq="Active Projects",Lq="Archived Pipelines",Oq="Global Nodes",Mq="Manage node versions published to the current workspace marketplace, {{count}} total.",$q="Manage flow snippets published to the current workspace marketplace, {{count}} total.",Dq="Global Skills",Fq="Create New Project",zq="New Pipeline",Bq="SEARCH PIPELINES...",Hq="SEARCH NODES...",Uq="SEARCH FLOW SNIPPETS...",Wq="SEARCH SKILLS...",Vq="Refresh Resources",Kq="Loading pipelines...",qq="Loading global resources...",Yq="Filter result: {{count}} items (matching title, description, path and tags)",Gq="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",Xq="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",Jq="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",Qq="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",Zq="Executable building blocks for pipeline runtime",eY="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.",tY="Published local node packages",nY="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",rY="Published flow snippets",sY="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",iY="Operating guides for Composer and agents",oY="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",aY="No archived projects.",lY="No active pipelines; archived items are in the Archived tab.",cY="No global nodes available.",uY="No marketplace nodes have been published.",dY="No flow snippets have been published. Select multiple canvas nodes and publish them first.",fY="No skills available.",pY="No description.",hY='No node matches "{{query}}".',mY='No flow snippet matches "{{query}}".',gY='No skill matches "{{query}}".',yY="{{inputs}} in / {{outputs}} out",xY="Flow Snippet",wY="{{nodes}} nodes / {{edges}} edges",vY="Skill",bY="Node detail",kY="Flow snippet detail",SY="Skill detail",NY="Type",jY="Source",CY="Package",EY="Version",_Y="Path",PY="Editable",AY="Read only",IY="Editable",TY="Schema",RY="Inputs",LY="Outputs",OY="Runtime",MY="Node Body",$Y="Files",DY="Usage",FY="No runtime manifest.",zY="No node body or README.",BY="No previewable files.",HY="Select a file to preview.",UY="Binary file preview is not supported.",WY="Large file; showing the first 256KB only.",VY="No pipelines using this node were found.",KY="Node Management",qY="Delete Node Version",YY="Deleting...",GY="AgentFlow checks all flow references before deleting; installed or used versions are kept.",XY="Delete {{id}}@{{version}}? This cannot be undone.",JY="Deleted {{id}}@{{version}}.",QY="{{count}} flow(s) still use it.",ZY="No slots",eG="Purpose",tG="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",nG="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.",rG="Scale",sG="Snippet JSON",iG="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",oG="SKILL.md Preview",aG="No preview content available.",lG="Select a resource to inspect details.",cG="Failed to load pipeline list.",uG="No pipelines in current workspace.",dG="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.",fG='No pipelines found matching "{{query}}". Try different keywords or clear the search.',pG="Recent Activity",hG="No recent activity",mG="No recent activity matching the keyword",gG="Recent Run",yG="Recent Open",xG={builtin:"Built-in",workspace:"Workspace",user:"User"},wG={flow:"Flow",global:"Global",marketplace:"Marketplace"},vG={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},bG={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},kG="Open to edit this pipeline in the node canvas.",SG={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>"},NG={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"},jG={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"},CG={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"},EG={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"},_G={title:Cq,all:Eq,archived:_q,nodes:Pq,myNodes:Aq,myFlows:Iq,skills:Tq,activeProjects:Rq,archivedPipelines:Lq,globalNodes:Oq,myNodesHint:Mq,myFlowsHint:$q,globalSkills:Dq,createNew:Fq,newPipeline:zq,searchPipelines:Bq,searchNodes:Hq,searchFlows:Uq,searchSkills:Wq,refreshResources:Vq,loadingPipelines:Kq,loadingResources:qq,filterResult:Yq,archivedHint:Gq,activeHint:Xq,nodesHint:Jq,skillsHint:Qq,nodesPurposeTitle:Zq,nodesPurposeDesc:eY,myNodesPurposeTitle:tY,myNodesPurposeDesc:nY,myFlowsPurposeTitle:rY,myFlowsPurposeDesc:sY,skillsPurposeTitle:iY,skillsPurposeDesc:oY,noArchived:aY,noActive:lY,noNodes:cY,noMyNodes:uY,noMyFlows:dY,noSkills:fY,noDescription:pY,noNodeMatch:hY,noFlowSnippetMatch:mY,noSkillMatch:gY,nodeSlots:yY,flowSnippet:xY,flowSnippetNodes:wY,skill:vY,nodeDetail:bY,flowDetail:kY,skillDetail:SY,detailType:NY,detailSource:jY,detailPackage:CY,detailVersion:EY,detailPath:_Y,detailEditable:PY,readOnly:AY,editable:IY,nodeSchema:TY,nodeInputs:RY,nodeOutputs:LY,nodeRuntime:OY,nodeBody:MY,nodeFiles:$Y,nodeUsage:DY,noRuntimeManifest:FY,noNodeBody:zY,noNodeFiles:BY,selectNodeFile:HY,binaryFile:UY,fileTruncated:WY,noNodeUsage:VY,myNodeManagement:KY,deleteMyNode:qY,deletingMyNode:YY,deleteMyNodeHint:GY,deleteMyNodeConfirm:XY,deleteMyNodeSuccess:JY,deleteMyNodeUsedBy:QY,noSlots:ZY,resourceMeaning:eG,nodesMeaning:tG,myFlowsMeaning:nG,flowSnippetScale:rG,flowSnippetPreview:sG,skillsMeaning:iG,skillPreview:oG,skillPreviewEmpty:aG,selectResource:lG,loadFailed:cG,noPipelines:uG,emptyHint:dG,noMatch:fG,recentActivity:pG,noRecentActivity:hG,noMatchRecent:mG,recentRun:gG,recentOpen:yG,sourceBadge:xG,resourceSource:wG,resourceFilter:vG,nodeDetailTabs:bG,defaultCardDesc:kG,hubCard:SG,newPipelineModal:NG,importModal:jG,deleteModal:CG,archiveModal:EG},PG="Back",AG="Next",IG="Skip",TG="Done",RG="Start Creating",LG={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
154
-
155
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
156
-
157
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},OG={intro:`Now you're in the flow editor.
158
-
159
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
160
-
161
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
162
-
163
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
164
-
165
- The left node panel allows you to freely drag, delete, and adjust connections.`},MG={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"},$G={back:PG,next:AG,skip:IG,done:TG,startCreate:RG,projects:LG,flow:OG,newPipeline:MG},DG={name:"AgentFlow",tagline:"AI 工作流编排"},FG={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",flowEditor:"流程编辑器",settings:"设置",back:"返回"},zG={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},BG={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},HG={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},UG={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},WG={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},VG={app:DG,nav:FG,common:zG,status:BG,nodeTypes:HG,engine:UG,links:WG},KG="流程编辑器",qG="节点",YG="连线",GG="属性",XG={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:"编辑内容"},JG={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}}"},QG={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},ZG={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},eX={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},tX={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},nX={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},rX={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},sX={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},iX={node:"节点",text:"文本",file:"文件",bool:"布尔"},oX={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:"等待"},aX={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",selectAll:"全选所有节点"},lX={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},cX={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},uX={mainNav:"主导航"},dX={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},fX={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}} 步):
166
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
167
- 当前:{{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}}"},pX={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},hX={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},mX={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}} 的分支"},gX={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},yX={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:"已复制"},xX={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:"定时配置已保存"},wX={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},vX={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},bX={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},kX={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},SX={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},NX={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},jX={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},CX={save:"保存",cancel:"取消"},EX={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},_X={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},PX={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},AX={title:KG,nodes:qG,edges:YG,properties:GG,node:XG,nodeProps:JG,actions:QG,panel:ZG,palette:eX,pipeline:tX,status:nX,roles:rX,phases:sX,types:iX,runContext:oX,shortcuts:aX,jumpPalette:lX,emptyCanvas:cX,sidebar:uX,validation:dX,composer:fX,topbar:pX,palette2:hX,run:mX,fileEdit:gX,settings:yX,schedule:xX,history:wX,nodePropsError:vX,placeholder:bX,time:kX,userCheck:SX,userAsk:NX,toolPrint:jX,provideEdit:CX,runParams:EX,runPreset:_X,runConfig:PX},IX="设置",TX={engine:"引擎设置",preferences:"全局首选项"},RX={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},LX={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},OX={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},MX={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},$X={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",saving:"正在保存...",key:"键",value:"值",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},DX={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},FX={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},zX={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},BX={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},HX={title:IX,crumb:TX,workspace:RX,cursor:LX,opencode:OX,claudeCode:MX,env:$X,system:DX,shortcuts:FX,language:zX,onboarding:BX},UX={thinking:"思考",result:"结果",reply:"回复",error:"错误"},WX={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},VX={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},KX={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},qX={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},YX={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},GX={aiLabels:UX,placeholders:WX,actions:VX,labels:KX,tooltips:qX,rightPanel:YX},XX="项目",JX="全部",QX="已归档",ZX="Nodes",eJ="我的 Nodes",tJ="我的流程",nJ="Skills",rJ="活跃项目",sJ="已归档流水线",iJ="全局 Nodes",oJ="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",aJ="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",lJ="全局 Skills",cJ="创建新项目",uJ="新建流水线",dJ="搜索流水线…",fJ="搜索 nodes…",pJ="搜索流程片段…",hJ="搜索 skills…",mJ="刷新资源",gJ="加载流水线列表…",yJ="加载全局资源…",xJ="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",wJ="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",vJ="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",bJ="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",kJ="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",SJ="流程运行时的可执行积木",NJ="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",jJ="已发布的本地节点包",CJ="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",EJ="已发布的流程片段",_J="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",PJ="Composer/Agent 的操作指南",AJ="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",IJ="暂无归档项目。",TJ="暂无未归档流水线;已归档项在 Archived 标签中查看。",RJ="暂无可用全局 nodes。",LJ="暂无已发布的 marketplace nodes。",OJ="暂无已发布的流程片段。可在画布中选中多个节点后发布。",MJ="暂无可用 skills。",$J="暂无描述。",DJ="未找到与「{{query}}」匹配的 node。",FJ="未找到与「{{query}}」匹配的流程片段。",zJ="未找到与「{{query}}」匹配的 skill。",BJ="{{inputs}} in / {{outputs}} out",HJ="流程片段",UJ="{{nodes}} 节点 / {{edges}} 连线",WJ="Skill",VJ="Node 详情",KJ="流程片段详情",qJ="Skill 详情",YJ="类型",GJ="来源",XJ="包",JJ="版本",QJ="路径",ZJ="可编辑",eQ="只读",tQ="可编辑",nQ="Schema",rQ="输入",sQ="输出",iQ="Runtime",oQ="节点内容",aQ="Files",lQ="Usage",cQ="暂无 runtime manifest。",uQ="暂无节点正文或 README。",dQ="暂无可预览文件。",fQ="请选择文件查看内容。",pQ="二进制文件暂不支持预览。",hQ="文件较大,仅显示前 256KB。",mQ="暂未发现使用此 node 的流水线。",gQ="节点管理",yQ="删除节点版本",xQ="删除中…",wQ="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",vQ="确定删除 {{id}}@{{version}}?此操作不可撤销。",bQ="已删除 {{id}}@{{version}}。",kQ="仍有 {{count}} 个 Flow 使用它。",SQ="无槽位",NQ="作用",jQ="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",CQ="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",EQ="规模",_Q="片段 JSON",PQ="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",AQ="SKILL.md 预览",IQ="暂无可预览内容。",TQ="请选择一个资源查看详情。",RQ="未能加载流水线列表。",LQ="当前工作区暂无流水线。",OQ="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",MQ="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",$Q="最近打开或最近运行",DQ="暂无打开或运行记录",FQ="暂无与关键词匹配的最近记录",zQ="最近运行",BQ="最近打开",HQ={builtin:"内置",workspace:"工作区",user:"用户"},UQ={flow:"Flow",global:"Global",marketplace:"Marketplace"},WQ={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},VQ={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},KQ="打开以在节点画布中编辑此流水线。",qQ={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},YQ={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:"关闭"},GQ={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},XQ={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},JQ={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},QQ={title:XX,all:JX,archived:QX,nodes:ZX,myNodes:eJ,myFlows:tJ,skills:nJ,activeProjects:rJ,archivedPipelines:sJ,globalNodes:iJ,myNodesHint:oJ,myFlowsHint:aJ,globalSkills:lJ,createNew:cJ,newPipeline:uJ,searchPipelines:dJ,searchNodes:fJ,searchFlows:pJ,searchSkills:hJ,refreshResources:mJ,loadingPipelines:gJ,loadingResources:yJ,filterResult:xJ,archivedHint:wJ,activeHint:vJ,nodesHint:bJ,skillsHint:kJ,nodesPurposeTitle:SJ,nodesPurposeDesc:NJ,myNodesPurposeTitle:jJ,myNodesPurposeDesc:CJ,myFlowsPurposeTitle:EJ,myFlowsPurposeDesc:_J,skillsPurposeTitle:PJ,skillsPurposeDesc:AJ,noArchived:IJ,noActive:TJ,noNodes:RJ,noMyNodes:LJ,noMyFlows:OJ,noSkills:MJ,noDescription:$J,noNodeMatch:DJ,noFlowSnippetMatch:FJ,noSkillMatch:zJ,nodeSlots:BJ,flowSnippet:HJ,flowSnippetNodes:UJ,skill:WJ,nodeDetail:VJ,flowDetail:KJ,skillDetail:qJ,detailType:YJ,detailSource:GJ,detailPackage:XJ,detailVersion:JJ,detailPath:QJ,detailEditable:ZJ,readOnly:eQ,editable:tQ,nodeSchema:nQ,nodeInputs:rQ,nodeOutputs:sQ,nodeRuntime:iQ,nodeBody:oQ,nodeFiles:aQ,nodeUsage:lQ,noRuntimeManifest:cQ,noNodeBody:uQ,noNodeFiles:dQ,selectNodeFile:fQ,binaryFile:pQ,fileTruncated:hQ,noNodeUsage:mQ,myNodeManagement:gQ,deleteMyNode:yQ,deletingMyNode:xQ,deleteMyNodeHint:wQ,deleteMyNodeConfirm:vQ,deleteMyNodeSuccess:bQ,deleteMyNodeUsedBy:kQ,noSlots:SQ,resourceMeaning:NQ,nodesMeaning:jQ,myFlowsMeaning:CQ,flowSnippetScale:EQ,flowSnippetPreview:_Q,skillsMeaning:PQ,skillPreview:AQ,skillPreviewEmpty:IQ,selectResource:TQ,loadFailed:RQ,noPipelines:LQ,emptyHint:OQ,noMatch:MQ,recentActivity:$Q,noRecentActivity:DQ,noMatchRecent:FQ,recentRun:zQ,recentOpen:BQ,sourceBadge:HQ,resourceSource:UQ,resourceFilter:WQ,nodeDetailTabs:VQ,defaultCardDesc:KQ,hubCard:qQ,newPipelineModal:YQ,importModal:GQ,deleteModal:XQ,archiveModal:JQ},ZQ="返回",eZ="下一步",tZ="跳过",nZ="完成",rZ="开始创建",sZ={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
168
-
169
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
170
-
171
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},iZ={intro:`现在进入流程编辑器。
172
-
173
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
174
-
175
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
176
-
177
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
178
-
179
- 左侧节点面板可以自由拖拽、删除和调整连接。`},oZ={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},aZ={back:ZQ,next:eZ,skip:tZ,done:nZ,startCreate:rZ,projects:sZ,flow:iZ,newPipeline:oZ},lZ={en:{common:bK,flow:oq,settings:xq,composer:jq,project:_G,onboarding:$G},zh:{common:VG,flow:AX,settings:HX,composer:GX,project:QQ,onboarding:aZ}};Nr.use(_I).use(FL).init({resources:lZ,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 cZ=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function uZ(e){return Nr.changeLanguage(e)}const fw="agentflow-settings-opencode-plan-v1";function ky(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 PI(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function dZ(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function _p(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=String(n.key??"").trim(),s=String(n.value??""),i=String(n.id??"").trim()||PI();!r&&!s||t.push({id:i,key:r,value:s})}return t}function y1(){try{return localStorage.getItem(fw)??""}catch{return""}}function fZ(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function pZ(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 hZ(){const{t:e,i18n:t}=on(["common","settings"]),n=t.language||"zh",[r,s]=m.useState(""),[i,a]=m.useState(""),[l,c]=m.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[d,u]=m.useState(""),[f,p]=m.useState(!1),[h,g]=m.useState(!1),[b,S]=m.useState(""),[y,v]=m.useState([]),[w,j]=m.useState(""),[E,k]=m.useState(!1),[I,R]=m.useState(""),[$,K]=m.useState(""),[D,L]=m.useState(""),H=m.useRef(null),M=m.useRef(!1),O=m.useRef(!1),A=m.useRef(""),z=m.useCallback(async()=>{a("");try{const re=await fetch("/api/ui-context");if(!re.ok)throw new Error("HTTP "+re.status);const pe=await re.json();s(typeof pe.workspaceRoot=="string"?pe.workspaceRoot:"")}catch(re){a(String(re.message||re)),s("")}},[]),_=m.useCallback(async()=>{u(""),p(!0);try{const re=await fetch("/api/model-lists");if(!re.ok)throw new Error("HTTP "+re.status);const pe=await re.json();c(ky(pe))}catch(re){u(String(re.message||re))}finally{p(!1)}},[]),T=m.useCallback(async()=>{j("");try{const re=await fetch("/api/user-env"),pe=await re.json().catch(()=>({}));if(!re.ok)throw new Error(typeof pe.error=="string"?pe.error:"HTTP "+re.status);const ae=_p(Array.isArray(pe.env)?pe.env:[]);A.current=JSON.stringify(ae),v(ae)}catch(re){v([]),j(String(re.message||re))}finally{O.current=!0}},[]),C=m.useCallback(async re=>{const pe=_p(re);k(!0),j("");try{const ae=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:pe})}),ye=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ye.error=="string"?ye.error:"HTTP "+ae.status);const Be=_p(Array.isArray(ye.env)?ye.env:[]);A.current=JSON.stringify(Be),v(Be)}catch(ae){j(String(ae.message||ae))}finally{k(!1)}},[]),G=m.useCallback(async()=>{u(""),p(!0);try{const re=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:D.trim()})}),pe=await re.json().catch(()=>({}));if(!re.ok)throw new Error(typeof pe.error=="string"?pe.error:"HTTP "+re.status);c(ky(pe.modelLists))}catch(re){u(String(re.message||re))}finally{p(!1)}},[D]);m.useEffect(()=>{z(),_(),T(),(async()=>{try{const re=await fetch("/api/agentflow-config");if(re.ok){const pe=await re.json(),ae=typeof pe.opencodeProvider=="string"?pe.opencodeProvider:"";L(ae),H.current=ae;try{localStorage.setItem(fw,ae)}catch{}}else{const pe=y1();L(pe),H.current=pe}}catch{const re=y1();L(re),H.current=re}finally{M.current=!0}})()},[z,_,T]),m.useEffect(()=>{if(!O.current||JSON.stringify(_p(y))===A.current)return;const pe=setTimeout(()=>{C(y)},350);return()=>clearTimeout(pe)},[y,C]),m.useEffect(()=>{if(!M.current)return;const re=D.trim();if(re===H.current)return;const pe=setTimeout(()=>{(async()=>{g(!0),S("");try{const ae=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:re})}),ye=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(typeof ye.error=="string"?ye.error:"HTTP "+ae.status);H.current=re;try{localStorage.setItem(fw,re)}catch{}ye.modelLists&&c(ky(ye.modelLists))}catch(ae){S(String(ae.message||ae))}finally{g(!1)}})()},450);return()=>clearTimeout(pe)},[D]);const Z=l.cursor.length>0,W=l.opencode.length>0,te=l.claudeCode.length>0,le=m.useCallback(()=>{var re;r&&((re=navigator.clipboard)==null||re.writeText(r))},[r]),ue=m.useCallback(()=>{const re=I.trim(),pe=$;if(re){if(!dZ(re)){j(e("settings:env.invalidKey"));return}v(ae=>[...ae,{id:PI(),key:re,value:pe}]),R(""),K("")}},[I,$,e]),de=m.useCallback(re=>{v(pe=>pe.filter(ae=>ae.id!==re))},[]),ce=m.useCallback(re=>{const pe=re.target.value;uZ(pe)},[]),fe=re=>{const pe=pZ(re,n);return pe?e("settings:cursor.modelList.fetchedAt",{time:pe}):e("settings:cursor.modelList.never")};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":e("settings:title"),children:[o.jsx("span",{className:"af-settings-crumb-muted",children:e("settings:crumb.engine")}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:e("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:[e("common:app.name")," ",e("settings:title")]}),o.jsx("p",{className:"af-settings-lead",children:e("settings:workspace.description")}),i?o.jsx("p",{className:"af-err af-settings-api-hint",children:i}):null,d?o.jsx("p",{className:"af-err af-settings-api-hint",children:d}):null,w?o.jsx("p",{className:"af-err af-settings-api-hint",children:w}):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:e("settings:workspace.title")})]}),o.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:e("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:r,placeholder:e("common:loading")}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:le,"aria-label":e("settings:workspace.copyPath"),disabled:!r,children:o.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),o.jsx("p",{className:"af-set-hint",children:e("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"+(Z?" af-set-badge--ok":" af-set-badge--muted"),children:e(Z?"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:Z?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:e(Z?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:Z?e("settings:cursor.modelList.count",{count:l.cursor.length})+" · "+fe(l.cursorFetchedAt):e("settings:cursor.modelList.refresh")})]})]}),Z?o.jsx("pre",{className:"af-set-model-preview","aria-label":e("settings:cursor.modelPreviewLabel"),children:l.cursor.join(`
180
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>G(),disabled:f,children:e(f?"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"+(W?" af-set-badge--ok":" af-set-badge--err"),children:e(W?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),o.jsx("p",{className:"af-set-p",children:e("settings:opencode.description")}),o.jsxs("div",{children:[o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:e("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:D,onChange:re=>L(re.target.value),placeholder:e("settings:opencode.providerPlaceholder"),autoComplete:"off"}),h?o.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:e("settings:opencode.saving")}):null,b?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:b}):null]}),W?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:e("settings:cursor.modelList.count",{count:l.opencode.length})+" · "+fe(l.opencodeFetchedAt)}),o.jsx("pre",{className:"af-set-model-preview","aria-label":e("settings:opencode.modelPreviewLabel"),children:l.opencode.join(`
181
- `)})]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>G(),disabled:f,children:e(f?"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:e("settings:claudeCode.title")}),o.jsx("span",{className:"af-set-badge"+(te?" af-set-badge--ok":" af-set-badge--err"),children:e(te?"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:te?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:e(te?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:te?e("settings:cursor.modelList.count",{count:l.claudeCode.length})+" · "+fe(l.claudeCodeFetchedAt):e("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:e("settings:claudeCode.description")}),te?o.jsx("pre",{className:"af-set-model-preview","aria-label":e("settings:claudeCode.modelPreviewLabel"),children:l.claudeCode.join(`
182
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>G(),disabled:f,children:e(f?"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:e("settings:env.title")})]}),o.jsx("span",{className:"af-set-env-note",children:e(E?"settings:env.saving":"settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows",children:[y.map(re=>o.jsxs("div",{className:"af-set-env-row",children:[o.jsxs("div",{className:"af-set-env-cell",children:[o.jsx("span",{className:"af-set-env-k",children:e("settings:env.key")}),o.jsx("code",{className:"af-set-code-key",children:re.key||"—"})]}),o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow",children:[o.jsx("span",{className:"af-set-env-k",children:e("settings:env.value")}),o.jsx("code",{className:"af-set-code-val",children:fZ(re.value)})]}),o.jsx("div",{className:"af-set-env-actions",children:o.jsx("button",{type:"button",className:"af-set-env-del","aria-label":e("settings:env.delete",{key:re.key}),onClick:()=>de(re.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},re.id)),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft",children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-input af-set-input--dashed af-set-input--mono",placeholder:"KEY_NAME",value:I,onChange:re=>R(re.target.value),"aria-label":e("settings:env.newKey")})}),o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow",children:o.jsx("input",{className:"af-set-input af-set-input--dashed af-set-input--mono",type:"password",placeholder:e("settings:env.newValue"),value:$,onChange:re=>K(re.target.value),"aria-label":e("settings:env.newValue")})}),o.jsx("div",{className:"af-set-env-actions",children:o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:ue,disabled:!I.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),e("settings:env.add")]})})]})]})]})]}),o.jsxs("aside",{className:"af-settings-rail","aria-label":e("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:e("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:e(!i&&!d?"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:e("settings:system.cursorModels")}),o.jsx("span",{children:l.cursor.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,l.cursor.length>0?12+l.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:e("settings:system.opencodeModels")}),o.jsx("span",{children:l.opencode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,l.opencode.length>0?12+l.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:e("settings:system.claudeCodeModels")}),o.jsx("span",{children:l.claudeCode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,l.claudeCode.length>0?12+l.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:e("settings:language.title")}),o.jsxs("div",{className:"af-set-language-selector",children:[o.jsx("select",{className:"af-set-input af-set-input--sm",value:n,onChange:ce,"aria-label":e("settings:language.description"),children:cZ.map(re=>o.jsxs("option",{value:re.code,children:[re.flag," ",re.name]},re.code))}),o.jsx("p",{className:"af-set-hint",children:e("settings:language.description")})]})]})]})]})]})})]})}function AI(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function x1(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:AI(),key:r,value:String(s??""),private:n.has(r)}))}function w1(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 eh(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(`
183
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:x1(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:x1(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"].includes(r))),null,2)}}function Sy(){return eh({name:"",raw:{command:""}})}function mZ(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=w1(e.envRows),s=w1(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 v1(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function b1(e){return e?e.ok?"ok":"error":"unknown"}function k1({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:AI(),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 gZ(){var L;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,i]=m.useState(Sy),[a,l]=m.useState(""),[c,d]=m.useState(!1),[u,f]=m.useState(!1),[p,h]=m.useState(!1),[g,b]=m.useState({}),[S,y]=m.useState(""),[v,w]=m.useState(""),j=m.useMemo(()=>n.find(H=>H.name===a)||null,[a,n]),E=j&&g[j.name]||null,k=m.useCallback(async()=>{d(!0),y("");try{const H=await fetch("/api/mcps"),M=await H.json().catch(()=>({}));if(!H.ok)throw new Error(M.error||"MCP HTTP "+H.status);const O=Array.isArray(M.servers)?M.servers:[];t(String(M.path||"")),r(O),a&&O.some(A=>A.name===a)&&i(eh(O.find(A=>A.name===a)))}catch(H){y(String(H.message||H))}finally{d(!1)}},[a]);m.useEffect(()=>{k()},[k]);const I=()=>{l(""),i(Sy()),w(""),y("")},R=H=>{l(H.name),i(eh(H)),w(""),y("")},$=async(H="")=>{h(!0),y(""),w("");try{const M=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H?{name:H}:{})}),O=await M.json().catch(()=>({}));if(!M.ok)throw new Error(O.error||"检测 MCP 失败");const A=Array.isArray(O.results)?O.results:[];b(z=>{const _={...z};for(const T of A)T!=null&&T.name&&(_[T.name]=T);return _}),w(H?`已检测 ${H}。`:"已检测所有 MCP。")}catch(M){y(String(M.message||M))}finally{h(!1)}},K=async()=>{f(!0),y(""),w("");try{const H=mZ(s);if(!H.nextName)throw new Error("请填写 MCP 名称");const M=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),O=await M.json().catch(()=>({}));if(!M.ok)throw new Error(O.error||"保存 MCP 失败");const A=Array.isArray(O.servers)?O.servers:[];r(A),t(String(O.path||e)),l(H.nextName),i(eh(A.find(z=>z.name===H.nextName)||null)),b(z=>{const _={...z};return s.originalName&&s.originalName!==H.nextName&&delete _[s.originalName],delete _[H.nextName],_}),w("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(H){y(String(H.message||H))}finally{f(!1)}},D=async H=>{if(H!=null&&H.name&&window.confirm(`删除 MCP "${H.name}"?`)){f(!0),y(""),w("");try{const M=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:H.name})}),O=await M.json().catch(()=>({}));if(!M.ok)throw new Error(O.error||"删除 MCP 失败");r(Array.isArray(O.servers)?O.servers:[]),l(""),i(Sy()),b(A=>{const z={...A};return delete z[H.name],z}),w("已删除。")}catch(M){y(String(M.message||M))}finally{f(!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:k,disabled:c||u,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>$(),disabled:p||c||u||n.length===0,children:p?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:I,disabled:u,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:I,disabled:u,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:I,disabled:u,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(H=>o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===H.name?" af-mcp-server-item--active":""),onClick:()=>R(H),children:[o.jsx("span",{className:"material-symbols-outlined",children:H.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:H.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${b1(g[H.name])}`,children:v1(g[H.name])})]}),o.jsx("em",{children:H.url||[H.command,...H.args||[]].filter(Boolean).join(" ")})]})]},H.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:()=>$(j.name),disabled:p||u,children:p?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>D(j),disabled:u,children:"删除"})]}):null]}),S?o.jsx("p",{className:"af-mcp-error",children:S}):null,v?o.jsx("p",{className:"af-mcp-status",children:v}):null,E?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${b1(E)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:v1(E)}),o.jsxs("span",{children:[E.elapsedMs||0,"ms"]})]}),E.error?o.jsx("p",{children:E.error}):null,(L=E.tools)!=null&&L.length?o.jsx("div",{className:"af-mcp-tools-list",children:E.tools.map(H=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:H.name}),H.description?o.jsx("span",{children:H.description}):null]},H.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:H=>i(M=>({...M,name:H.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:H=>i(M=>({...M,type:H.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:H=>i(M=>({...M,url:H.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:H=>i(M=>({...M,command:H.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:H=>i(M=>({...M,argsText:H.target.value})),placeholder:`mcp-server-example
184
- --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:H=>i(M=>({...M,description:H.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(k1,{title:"Headers",rows:s.headerRows,onChange:H=>i(M=>({...M,headerRows:H})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(k1,{title:"Env",rows:s.envRows,onChange:H=>i(M=>({...M,envRows:H})),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:H=>i(M=>({...M,extraJson:H.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:I,disabled:u,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:K,disabled:u,children:u?"保存中...":"保存 MCP"})]})]})]})]})})]})}function II(e){return t=>typeof t===e}var yZ=II("function"),xZ=e=>e===null,S1=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",N1=e=>!wZ(e)&&!xZ(e)&&(yZ(e)||typeof e=="object"),wZ=II("undefined");function vZ(e,t,n){return EZ(n,e,t)?!0:(_Z(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?bZ(e,t,n):e instanceof Map&&t instanceof Map?NZ(e,t,n):e instanceof Set&&t instanceof Set?CZ(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?kZ(e,t):S1(e)&&S1(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?SZ(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():jZ(e,t,n))}function ff(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!N1(e)||!t||!N1(t)?!1:vZ(e,t,n)}function bZ(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!ff(e[s],t[s],n))return!1;return!0}function kZ(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 SZ(e,t,n){return e.message===t.message&&e.name===t.name&&ff(e.cause,t.cause,n)}function NZ(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(!ff(r[1],t.get(r[0]),n))return!1;return!0}function jZ(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)&&!ff(e[i],t[i],n))return!1}return!0}function CZ(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 EZ(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function _Z(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function r0(e,t){return ff(e,t,new WeakMap)}function Ny(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function PZ(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function AZ(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function IZ(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function TZ(e,t){const n=IZ();m.useEffect(()=>{if(!n)return e()},t)}function TI(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function RZ(e,t){const n=m.useRef(t);return r0(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function LZ(e){m.useEffect(()=>{e()},[])}function OZ(e=0){const[t,n]=m.useState({height:Ny()?window.innerHeight:0,width:Ny()?window.innerWidth:0}),r=m.useRef(0),s=m.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return m.useEffect(()=>{if(!Ny())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),AZ(window,"resize",i),()=>{PZ(window,"resize",i)}},[]),t}var MZ=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],$Z=["bigint","boolean","null","number","string","symbol","undefined"];function pf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(DZ(t))return t}function yi(e){return t=>pf(t)===e}function DZ(e){return MZ.includes(e)}function Bc(e){return t=>typeof t===e}function FZ(e){return $Z.includes(e)}var zZ=["innerHTML","ownerDocument","style","attributes","nodeValue"],hf=e=>Array.isArray(e),BZ=e=>pf(e)==="AsyncGeneratorFunction",HZ=yi("AsyncFunction"),UZ=Bc("bigint"),WZ=e=>e===!0||e===!1,VZ=yi("Date"),KZ=yi("Error"),ga=Bc("function"),qZ=yi("GeneratorFunction"),YZ=e=>typeof e=="number"&&Number.isInteger(e),pw=yi("Map"),RI=e=>Number.isNaN(e),s0=e=>e===null,LI=yi("Function"),GZ=yi("Promise"),XZ=yi("RegExp"),hw=yi("Set"),mf=Bc("string"),JZ=Bc("symbol"),i0=Bc("undefined"),QZ=yi("WeakMap"),ZZ=yi("WeakSet"),o0=e=>s0(e)||i0(e),OI=e=>!i0(e),eee=e=>Bc("number")(e)&&!RI(e),tee=e=>mf(e)&&e.trim().length>0,nee=e=>{if(!mf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},zm=e=>!o0(e)&&(ga(e)||typeof e=="object"),MI=e=>{if(pf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},ree=e=>s0(e)||FZ(typeof e),see=e=>pf(e)==="URL",$I=e=>!o0(e)&&ga(e[Symbol.iterator]),iee=e=>$I(e)&&ga(e.next)&&ga(e.throw),oee=e=>ga(e)&&/^class\s/.test(e.toString()),aee=(e,t)=>!hf(e)||!ga(t)?!1:e.every(n=>t(n)),lee=e=>zm(e)&&!MI(e)&&e.nodeType===1&&mf(e.nodeName)&&zZ.every(t=>t in e),cee=e=>mf(e)&&e.length===0||hf(e)&&e.length===0||zm(e)&&!pw(e)&&!hw(e)&&Object.keys(e).length===0||hw(e)&&e.size===0||pw(e)&&e.size===0,uee=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,dee=(e,t)=>hf(e)?e.indexOf(t)>-1:!1,fee=(e,t,n)=>{if(!zm(e)||!t)return!1;const r=e[t];return ga(n)?n(r):OI(r)};function gt(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(hf(e))return"Array";if(LI(e))return"Function";const t=pf(e);return t||"Object"}gt.array=hf;gt.arrayOf=aee;gt.asyncGeneratorFunction=BZ;gt.asyncFunction=HZ;gt.bigint=UZ;gt.boolean=WZ;gt.class=oee;gt.date=VZ;gt.defined=OI;gt.domElement=lee;gt.empty=cee;gt.error=KZ;gt.function=ga;gt.generator=iee;gt.generatorFunction=qZ;gt.instanceOf=uee;gt.integer=YZ;gt.iterable=$I;gt.map=pw;gt.nan=RI;gt.null=s0;gt.nullOrUndefined=o0;gt.nonEmptyString=tee;gt.number=eee;gt.numericString=nee;gt.object=zm;gt.oneOf=dee;gt.plainFunction=LI;gt.plainObject=MI;gt.primitive=ree;gt.promise=GZ;gt.propertyOf=fee;gt.regexp=XZ;gt.set=hw;gt.string=mf;gt.symbol=JZ;gt.undefined=i0;gt.url=see;gt.weakMap=QZ;gt.weakSet=ZZ;var Rr=gt;/* v8 ignore next -- @preserve */var pee=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},hee=function(e,t){return e+Vd(t)},Vd=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(hee,""):pee(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Vd(e.props.children):""};Vd.default=Vd;var mee=Vd;const jy=xa(mee);var DI={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(E){return E!=="constructor"&&E!=="prototype"&&E!=="__proto__"}function a(E){let k=0;const I=E.length,R=new Array(I);for(k;k<I;++k)R[k]=y(E[k]);return R}function l(E){const k={};if(p&&Object.getPrototypeOf(E)!==t)return p(E);const I=f(E);let R,$,K;for(R=0,$=I.length;R<$;++R)i(K=I[R])&&(k[K]=y(E[K]));return k}function c(E,k){const I=E.length,R=k.length;let $=0;const K=new Array(I+R);for($;$<I;++$)K[$]=y(E[$]);for($=0;$<R;++$)K[$+I]=y(k[$]);return K}const d=Object.prototype.propertyIsEnumerable;function u(E){const k=Object.keys(E),I=Object.getOwnPropertySymbols(E);for(let R=0,$=I.length;R<$;++R)d.call(E,I[R])&&k.push(I[R]);return k}const f=s!=null&&s.symbols?u:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),g=(s==null?void 0:s.onlyDefinedProperties)===!0;function b(E){return typeof E!="object"||E===null}const S=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:w,getKeys:f,isMergeableObject:h}):c;function y(E){return h(E)?Array.isArray(E)?a(E):l(E):E}function v(E,k){const I={},R=f(E),$=f(k);let K,D,L;for(K=0,D=R.length;K<D;++K)i(L=R[K])&&$.indexOf(L)===-1&&(I[L]=y(E[L]));for(K=0,D=$.length;K<D;++K)if(i(L=$[K]))if(L in E)R.indexOf(L)!==-1&&(p&&h(k[L])&&Object.getPrototypeOf(k[L])!==t?I[L]=p(k[L]):I[L]=w(E[L],k[L]));else{if(g&&typeof k[L]>"u")continue;I[L]=y(k[L])}return I}function w(E,k){if(g&&typeof k>"u")return y(E);const I=Array.isArray(k),R=Array.isArray(E);return b(k)?k:h(E)?I&&R?S(E,k):I!==R?y(k):v(E,k):y(k)}function j(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return w(arguments[0],arguments[1])}let E;for(let k=0,I=arguments.length;k<I;++k)E=w(E,arguments[k]);return E}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})})(DI);var gee=DI.exports;const yee=xa(gee);var xee=new Error("Element already at target scroll position"),wee=new Error("Scroll cancelled"),vee=Math.min,j1=Date.now,bee={left:C1("scrollLeft"),top:C1("scrollTop")};function C1(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=See);var a=j1(),l=n[e],c=s.ease||kee,d=isNaN(s.duration)?350:+s.duration,u=!1;return l===r?i(xee,n[e]):requestAnimationFrame(p),f;function f(){u=!0}function p(h){if(u)return i(wee,n[e]);var g=j1(),b=vee(1,(g-a)/d),S=c(b);n[e]=S*(r-l)+l,b<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function kee(e){return .5*(1-Math.cos(Math.PI*e))}function See(){}const Nee=xa(bee);var FI={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(ld,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})})(FI);var jee=FI.exports;const zI=xa(jee),Cee=["top","right","bottom","left"],E1=["start","end"],_1=Cee.reduce((e,t)=>e.concat(t,t+"-"+E1[0],t+"-"+E1[1]),[]),Lc=Math.min,Ja=Math.max,em=Math.round,Pp=Math.floor,Hi=e=>({x:e,y:e}),Eee={left:"right",right:"left",bottom:"top",top:"bottom"};function mw(e,t,n){return Ja(e,Lc(t,n))}function Hc(e,t){return typeof e=="function"?e(t):e}function bo(e){return e.split("-")[0]}function Ui(e){return e.split("-")[1]}function BI(e){return e==="x"?"y":"x"}function a0(e){return e==="y"?"height":"width"}function Zo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function l0(e){return BI(Zo(e))}function HI(e,t,n){n===void 0&&(n=!1);const r=Ui(e),s=l0(e),i=a0(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=nm(a)),[a,nm(a)]}function _ee(e){const t=nm(e);return[tm(e),t,tm(t)]}function tm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const P1=["left","right"],A1=["right","left"],Pee=["top","bottom"],Aee=["bottom","top"];function Iee(e,t,n){switch(e){case"top":case"bottom":return n?t?A1:P1:t?P1:A1;case"left":case"right":return t?Pee:Aee;default:return[]}}function Tee(e,t,n,r){const s=Ui(e);let i=Iee(bo(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(tm)))),i}function nm(e){const t=bo(e);return Eee[t]+e.slice(t.length)}function Ree(e){return{top:0,right:0,bottom:0,left:0,...e}}function UI(e){return typeof e!="number"?Ree(e):{top:e,right:e,bottom:e,left:e}}function rm(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 I1(e,t,n){let{reference:r,floating:s}=e;const i=Zo(t),a=l0(t),l=a0(a),c=bo(t),d=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Ui(t)){case"start":h[a]-=p*(n&&d?-1:1);break;case"end":h[a]+=p*(n&&d?-1:1);break}return h}async function Lee(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:u="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=Hc(t,e),g=UI(h),S=l[p?f==="floating"?"reference":"floating":f],y=rm(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(S)))==null||n?S:S.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),v=f==="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},E=rm(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:w,strategy:c}):v);return{top:(y.top-E.top+g.top)/j.y,bottom:(E.bottom-y.bottom+g.bottom)/j.y,left:(y.left-E.left+g.left)/j.x,right:(E.right-y.right+g.right)/j.x}}const Oee=50,Mee=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Lee},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:u,y:f}=I1(d,r,c),p=r,h=0;const g={};for(let b=0;b<i.length;b++){const S=i[b];if(!S)continue;const{name:y,fn:v}=S,{x:w,y:j,data:E,reset:k}=await v({x:u,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});u=w??u,f=j??f,g[y]={...g[y],...E},k&&h<Oee&&(h++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(d=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):k.rects),{x:u,y:f}=I1(d,p,c)),b=-1)}return{x:u,y:f,placement:p,strategy:s,middlewareData:g}},$ee=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:u=0}=Hc(e,t)||{};if(d==null)return{};const f=UI(u),p={x:n,y:r},h=l0(s),g=a0(h),b=await a.getDimensions(d),S=h==="y",y=S?"top":"left",v=S?"bottom":"right",w=S?"clientHeight":"clientWidth",j=i.reference[g]+i.reference[h]-p[h]-i.floating[g],E=p[h]-i.reference[h],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let I=k?k[w]:0;(!I||!await(a.isElement==null?void 0:a.isElement(k)))&&(I=l.floating[w]||i.floating[g]);const R=j/2-E/2,$=I/2-b[g]/2-1,K=Lc(f[y],$),D=Lc(f[v],$),L=K,H=I-b[g]-D,M=I/2-b[g]/2+R,O=mw(L,M,H),A=!c.arrow&&Ui(s)!=null&&M!==O&&i.reference[g]/2-(M<L?K:D)-b[g]/2<0,z=A?M<L?M-L:M-H:0;return{[h]:p[h]+z,data:{[h]:O,centerOffset:M-O-z,...A&&{alignmentOffset:z}},reset:A}}});function Dee(e,t,n){return(e?[...n.filter(s=>Ui(s)===e),...n.filter(s=>Ui(s)!==e)]:n.filter(s=>bo(s)===s)).filter(s=>e?Ui(s)===e||(t?tm(s)!==s:!1):!0)}const Fee=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:u=!1,alignment:f,allowedPlacements:p=_1,autoAlignment:h=!0,...g}=Hc(e,t),b=f!==void 0||p===_1?Dee(f||null,h,p):p,S=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,v=b[y];if(v==null)return{};const w=HI(v,i,await(c.isRTL==null?void 0:c.isRTL(d.floating)));if(l!==v)return{reset:{placement:b[0]}};const j=[S[bo(v)],S[w[0]],S[w[1]]],E=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:v,overflows:j}],k=b[y+1];if(k)return{data:{index:y+1,overflows:E},reset:{placement:k}};const I=E.map(K=>{const D=Ui(K.placement);return[K.placement,D&&u?K.overflows.slice(0,2).reduce((L,H)=>L+H,0):K.overflows[0],K.overflows]}).sort((K,D)=>K[1]-D[1]),$=((s=I.filter(K=>K[2].slice(0,Ui(K[0])?2:3).every(D=>D<=0))[0])==null?void 0:s[0])||I[0][0];return $!==l?{data:{index:y+1,overflows:E},reset:{placement:$}}:{}}}},zee=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:u=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...S}=Hc(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=bo(s),v=Zo(l),w=bo(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(d.floating)),E=p||(w||!b?[nm(l)]:_ee(l)),k=g!=="none";!p&&k&&E.push(...Tee(l,b,g,j));const I=[l,...E],R=await c.detectOverflow(t,S),$=[];let K=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&$.push(R[y]),f){const M=HI(s,a,j);$.push(R[M[0]],R[M[1]])}if(K=[...K,{placement:s,overflows:$}],!$.every(M=>M<=0)){var D,L;const M=(((D=i.flip)==null?void 0:D.index)||0)+1,O=I[M];if(O&&(!(f==="alignment"?v!==Zo(O):!1)||K.every(_=>Zo(_.placement)===v?_.overflows[0]>0:!0)))return{data:{index:M,overflows:K},reset:{placement:O}};let A=(L=K.filter(z=>z.overflows[0]<=0).sort((z,_)=>z.overflows[1]-_.overflows[1])[0])==null?void 0:L.placement;if(!A)switch(h){case"bestFit":{var H;const z=(H=K.filter(_=>{if(k){const T=Zo(_.placement);return T===v||T==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(T=>T>0).reduce((T,C)=>T+C,0)]).sort((_,T)=>_[1]-T[1])[0])==null?void 0:H[0];z&&(A=z);break}case"initialPlacement":A=l;break}if(s!==A)return{reset:{placement:A}}}return{}}}},Bee=new Set(["left","top"]);async function Hee(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=bo(n),l=Ui(n),c=Zo(n)==="y",d=Bee.has(a)?-1:1,u=i&&c?-1:1,f=Hc(t,e);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(h=l==="end"?g*-1:g),c?{x:h*u,y:p*d}:{x:p*d,y:h*u}}const Uee=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 Hee(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}}}}},Wee=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:v,y:w}=y;return{x:v,y:w}}},...d}=Hc(e,t),u={x:n,y:r},f=await i.detectOverflow(t,d),p=Zo(bo(s)),h=BI(p);let g=u[h],b=u[p];if(a){const y=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=g+f[y],j=g-f[v];g=mw(w,g,j)}if(l){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",w=b+f[y],j=b-f[v];b=mw(w,b,j)}const S=c.fn({...t,[h]:g,[p]:b});return{...S,data:{x:S.x-n,y:S.y-r,enabled:{[h]:a,[p]:l}}}}}};function Bm(){return typeof window<"u"}function Uc(e){return WI(e)?(e.nodeName||"").toLowerCase():"#document"}function ks(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qi(e){var t;return(t=(WI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function WI(e){return Bm()?e instanceof Node||e instanceof ks(e).Node:!1}function hi(e){return Bm()?e instanceof Element||e instanceof ks(e).Element:!1}function No(e){return Bm()?e instanceof HTMLElement||e instanceof ks(e).HTMLElement:!1}function T1(e){return!Bm()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ks(e).ShadowRoot}function gf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=mi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Vee(e){return/^(table|td|th)$/.test(Uc(e))}function Hm(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Kee=/transform|translate|scale|rotate|perspective|filter/,qee=/paint|layout|strict|content/,$a=e=>!!e&&e!=="none";let Cy;function c0(e){const t=hi(e)?mi(e):e;return $a(t.transform)||$a(t.translate)||$a(t.scale)||$a(t.rotate)||$a(t.perspective)||!u0()&&($a(t.backdropFilter)||$a(t.filter))||Kee.test(t.willChange||"")||qee.test(t.contain||"")}function Yee(e){let t=ya(e);for(;No(t)&&!Oc(t);){if(c0(t))return t;if(Hm(t))return null;t=ya(t)}return null}function u0(){return Cy==null&&(Cy=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cy}function Oc(e){return/^(html|body|#document)$/.test(Uc(e))}function mi(e){return ks(e).getComputedStyle(e)}function Um(e){return hi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ya(e){if(Uc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||T1(e)&&e.host||qi(e);return T1(t)?t.host:t}function VI(e){const t=ya(e);return Oc(t)?e.ownerDocument?e.ownerDocument.body:e.body:No(t)&&gf(t)?t:VI(t)}function Kd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=VI(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=ks(s);if(i){const l=gw(a);return t.concat(a,a.visualViewport||[],gf(s)?s:[],l&&n?Kd(l):[])}else return t.concat(s,Kd(s,[],n))}function gw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function KI(e){const t=mi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=No(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=em(n)!==i||em(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function d0(e){return hi(e)?e:e.contextElement}function hc(e){const t=d0(e);if(!No(t))return Hi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=KI(t);let a=(i?em(n.width):n.width)/r,l=(i?em(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Gee=Hi(0);function qI(e){const t=ks(e);return!u0()||!t.visualViewport?Gee:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xee(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ks(e)?!1:t}function al(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=d0(e);let a=Hi(1);t&&(r?hi(r)&&(a=hc(r)):a=hc(e));const l=Xee(i,n,r)?qI(i):Hi(0);let c=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,u=s.width/a.x,f=s.height/a.y;if(i){const p=ks(i),h=r&&hi(r)?ks(r):r;let g=p,b=gw(g);for(;b&&r&&h!==g;){const S=hc(b),y=b.getBoundingClientRect(),v=mi(b),w=y.left+(b.clientLeft+parseFloat(v.paddingLeft))*S.x,j=y.top+(b.clientTop+parseFloat(v.paddingTop))*S.y;c*=S.x,d*=S.y,u*=S.x,f*=S.y,c+=w,d+=j,g=ks(b),b=gw(g)}}return rm({width:u,height:f,x:c,y:d})}function Wm(e,t){const n=Um(e).scrollLeft;return t?t.left+n:al(qi(e)).left+n}function YI(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Wm(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Jee(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=qi(r),l=t?Hm(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},d=Hi(1);const u=Hi(0),f=No(r);if((f||!f&&!i)&&((Uc(r)!=="body"||gf(a))&&(c=Um(r)),f)){const h=al(r);d=hc(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const p=a&&!f&&!i?YI(a,c):Hi(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+p.x,y:n.y*d.y-c.scrollTop*d.y+u.y+p.y}}function Qee(e){return Array.from(e.getClientRects())}function Zee(e){const t=qi(e),n=Um(e),r=e.ownerDocument.body,s=Ja(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Ja(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Wm(e);const l=-n.scrollTop;return mi(r).direction==="rtl"&&(a+=Ja(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const R1=25;function ete(e,t){const n=ks(e),r=qi(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const u=u0();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const d=Wm(r);if(d<=0){const u=r.ownerDocument,f=u.body,p=getComputedStyle(f),h=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-h);g<=R1&&(i-=g)}else d<=R1&&(i+=d);return{width:i,height:a,x:l,y:c}}function tte(e,t){const n=al(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=No(e)?hc(e):Hi(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 L1(e,t,n){let r;if(t==="viewport")r=ete(e,n);else if(t==="document")r=Zee(qi(e));else if(hi(t))r=tte(t,n);else{const s=qI(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return rm(r)}function GI(e,t){const n=ya(e);return n===t||!hi(n)||Oc(n)?!1:mi(n).position==="fixed"||GI(n,t)}function nte(e,t){const n=t.get(e);if(n)return n;let r=Kd(e,[],!1).filter(l=>hi(l)&&Uc(l)!=="body"),s=null;const i=mi(e).position==="fixed";let a=i?ya(e):e;for(;hi(a)&&!Oc(a);){const l=mi(a),c=c0(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||gf(a)&&!c&&GI(e,a))?r=r.filter(u=>u!==a):s=l,a=ya(a)}return t.set(e,r),r}function rte(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?Hm(t)?[]:nte(t,this._c):[].concat(n),r],l=L1(t,a[0],s);let c=l.top,d=l.right,u=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const h=L1(t,a[p],s);c=Ja(h.top,c),d=Lc(h.right,d),u=Lc(h.bottom,u),f=Ja(h.left,f)}return{width:d-f,height:u-c,x:f,y:c}}function ste(e){const{width:t,height:n}=KI(e);return{width:t,height:n}}function ite(e,t,n){const r=No(t),s=qi(t),i=n==="fixed",a=al(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Hi(0);function d(){c.x=Wm(s)}if(r||!r&&!i)if((Uc(t)!=="body"||gf(s))&&(l=Um(t)),r){const h=al(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&d();i&&!r&&s&&d();const u=s&&!r&&!i?YI(s,l):Hi(0),f=a.left+l.scrollLeft-c.x-u.x,p=a.top+l.scrollTop-c.y-u.y;return{x:f,y:p,width:a.width,height:a.height}}function Ey(e){return mi(e).position==="static"}function O1(e,t){if(!No(e)||mi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return qi(e)===n&&(n=n.ownerDocument.body),n}function XI(e,t){const n=ks(e);if(Hm(e))return n;if(!No(e)){let s=ya(e);for(;s&&!Oc(s);){if(hi(s)&&!Ey(s))return s;s=ya(s)}return n}let r=O1(e,t);for(;r&&Vee(r)&&Ey(r);)r=O1(r,t);return r&&Oc(r)&&Ey(r)&&!c0(r)?n:r||Yee(e)||n}const ote=async function(e){const t=this.getOffsetParent||XI,n=this.getDimensions,r=await n(e.floating);return{reference:ite(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ate(e){return mi(e).direction==="rtl"}const lte={convertOffsetParentRelativeRectToViewportRelativeRect:Jee,getDocumentElement:qi,getClippingRect:rte,getOffsetParent:XI,getElementRects:ote,getClientRects:Qee,getDimensions:ste,getScale:hc,isElement:hi,isRTL:ate};function JI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cte(e,t){let n=null,r;const s=qi(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:u,top:f,width:p,height:h}=d;if(l||t(),!p||!h)return;const g=Pp(f),b=Pp(s.clientWidth-(u+p)),S=Pp(s.clientHeight-(f+h)),y=Pp(u),w={rootMargin:-g+"px "+-b+"px "+-S+"px "+-y+"px",threshold:Ja(0,Lc(1,c))||1};let j=!0;function E(k){const I=k[0].intersectionRatio;if(I!==c){if(!j)return a();I?a(!1,I):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!JI(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(E,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(E,w)}n.observe(e)}return a(!0),i}function M1(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=d0(e),u=s||i?[...d?Kd(d):[],...t?Kd(t):[]]:[];u.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const f=d&&l?cte(d,n):null;let p=-1,h=null;a&&(h=new ResizeObserver(y=>{let[v]=y;v&&v.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=h)==null||w.observe(t)})),n()}),d&&!c&&h.observe(d),t&&h.observe(t));let g,b=c?al(e):null;c&&S();function S(){const y=al(e);b&&!JI(b,y)&&n(),b=y,g=requestAnimationFrame(S)}return n(),()=>{var y;u.forEach(v=>{s&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),f==null||f(),(y=h)==null||y.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const ute=Uee,dte=Fee,fte=Wee,pte=zee,$1=$ee,hte=(e,t,n)=>{const r=new Map,s={platform:lte,...n},i={...s.platform,_c:r};return Mee(e,t,{...s,platform:i})};var mte=typeof document<"u",gte=function(){},th=mte?m.useLayoutEffect:gte;function sm(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(!sm(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)&&!sm(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function QI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function D1(e,t){const n=QI(e);return Math.round(t*n)/n}function _y(e){const t=m.useRef(e);return th(()=>{t.current=e}),t}function F1(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,[u,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);sm(p,r)||h(r);const[g,b]=m.useState(null),[S,y]=m.useState(null),v=m.useCallback(_=>{_!==k.current&&(k.current=_,b(_))},[]),w=m.useCallback(_=>{_!==I.current&&(I.current=_,y(_))},[]),j=i||g,E=a||S,k=m.useRef(null),I=m.useRef(null),R=m.useRef(u),$=c!=null,K=_y(c),D=_y(s),L=_y(d),H=m.useCallback(()=>{if(!k.current||!I.current)return;const _={placement:t,strategy:n,middleware:p};D.current&&(_.platform=D.current),hte(k.current,I.current,_).then(T=>{const C={...T,isPositioned:L.current!==!1};M.current&&!sm(R.current,C)&&(R.current=C,es.flushSync(()=>{f(C)}))})},[p,t,n,D,L]);th(()=>{d===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f(_=>({..._,isPositioned:!1})))},[d]);const M=m.useRef(!1);th(()=>(M.current=!0,()=>{M.current=!1}),[]),th(()=>{if(j&&(k.current=j),E&&(I.current=E),j&&E){if(K.current)return K.current(j,E,H);H()}},[j,E,H,K,$]);const O=m.useMemo(()=>({reference:k,floating:I,setReference:v,setFloating:w}),[v,w]),A=m.useMemo(()=>({reference:j,floating:E}),[j,E]),z=m.useMemo(()=>{const _={position:n,left:0,top:0};if(!A.floating)return _;const T=D1(A.floating,u.x),C=D1(A.floating,u.y);return l?{..._,transform:"translate("+T+"px, "+C+"px)",...QI(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:C}},[n,l,A.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:H,refs:O,elements:A,floatingStyles:z}),[u,H,O,A,z])}const yte=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?$1({element:r.current,padding:s}).fn(n):{}:r?$1({element:r,padding:s}).fn(n):{}}}},z1=(e,t)=>{const n=ute(e);return{name:n.name,fn:n.fn,options:[e,t]}},xte=(e,t)=>{const n=fte(e);return{name:n.name,fn:n.fn,options:[e,t]}},wte=(e,t)=>{const n=pte(e);return{name:n.name,fn:n.fn,options:[e,t]}},vte=(e,t)=>{const n=dte(e);return{name:n.name,fn:n.fn,options:[e,t]}},bte=(e,t)=>{const n=yte(e);return{name:n.name,fn:n.fn,options:[e,t]}},kte={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},Ste={beaconOptions:{offset:-18}},ZI={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Nte={isFixed:!1,locale:ZI,placement:"bottom"},jte={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Et={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},lr={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"},Le={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Ti={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},kt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Cte="react-joyride-portal";function Ete(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function rc(...e){return yee({all:!0,isMergeableObject:t=>!(!Rr.plainObject(t)||m.isValidElement(t))})(...e)}function eT(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function lo(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=jy(e);if(i)(i.includes("{current}")||i.includes("{total}"))&&r&&s&&(i=i.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&eT(e.type)==="function")try{i=lo(e.type({}),t)}catch{i=jy(n)}else i=jy(n);return i}function ur(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 _te(e,t){const n=Ete(t);return{...e,...n}}function qd(){}function Pte(e){return Object.keys(e)}function im(e,...t){if(!Rr.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 B1(e,...t){if(!Rr.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 yw(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(eT(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Rr.string(s)&&s.includes("{current}"))return m.cloneElement(e,{children:r(s)});if(Array.isArray(s))return m.cloneElement(e,{children:s.map(i=>typeof i=="string"?r(i):yw(i,t,n))});if(Rr.function(e.type)&&!Object.values(e.props).length)try{return yw(e.type({}),t,n)}catch{return e}return e}function H1(e){return Pte(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function f0(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function U1(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 p0(e){return e?e.getBoundingClientRect():null}function Ate(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 $s(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 Ite(e,t,n){const r=p0(e),s=Wc(e),i=s?!s.isSameNode(is()):!1,a=n??Vc(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(is())||(c+=is().scrollTop)),Math.floor(c-t)}function Wc(e,t){if(!e)return is();const n=zI(e);if(n){if(n.isSameNode(is()))return t?document:is();if(!(n.scrollHeight>n.offsetHeight))return is()}return n}function Tte(e){const t=e.getBoundingClientRect(),n=is(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Rte(e,t){if(!e)return 0;const n=zI(e)??is(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=p0(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(tT(e)||Lte(e))){const u=e.getBoundingClientRect(),f=u.top-((s==null?void 0:s.top)??0),p=f+u.height,h=n.clientHeight,g=h*.2;f>=g&&p<=h-g?c=i:c=f+i}const d=Math.floor(c-t-r);return d<0?0:d}function Lte(e){return e.offsetParent!==document.body}function tT(e){if(!e)return!1;const t=Wc(e);return t?!t.isSameNode(is()):!1}function Vc(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?Vc(e.parentNode,t):!1}function Ap(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 W1(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==Le.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Wc(s):is(),l=a?!a.isSameNode(is()):!1;return(r.isFixed||Vc(s))&&!l?!1:a.scrollHeight>a.clientHeight}function is(){return document.scrollingElement??document.documentElement}function V1(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=Nee.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function Ote(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 nT={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Ip={...nT,borderRadius:4,padding:8};function Mte(e,t){const{styles:n}=e,r=rc(n??{},t.styles??{});let{width:s}=t;f0()&&(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 rc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...nT,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(${Ote(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:{...Ip,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Ip,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Ip,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Ip,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 $te=["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 h0(e,t){if(!t)return null;const n=rc(Nte,B1(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=rc(kte,e.options??{},B1(t,...$te)),s=Mte(e,{...n,...r}),i=rc(Ste,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:rc(ZI,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:Dte(r.spotlightPadding),styles:s}}function Dte(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 Fte(e,t,n){const{action:r}=t,s=n&&[Et.PREV,Et.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function rT(e,t=!1){return Rr.plainObject(e)?e.target?!0:(ur(t,"tour","target is missing from the step"),!1):(ur(t,"tour","step must be an object"),!1)}function sT(e,t=!1){return Rr.array(e)?e.every(n=>rT(n,t)):(ur(t,"tour","steps must be an array"),!1)}var zte=class{constructor(e){Rn(this,"beaconPosition",null);Rn(this,"debug");Rn(this,"eventListeners",new Map);Rn(this,"listeners",new Set);Rn(this,"props");Rn(this,"snapshot");Rn(this,"state");Rn(this,"steps");Rn(this,"tooltipPosition",null);Rn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Rn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Rn(this,"getServerSnapshot",()=>this.snapshot);Rn(this,"getSnapshot",()=>this.snapshot);Rn(this,"getEventState",()=>im(this.snapshot,"positioned"));Rn(this,"getState",()=>im(this.snapshot,"positioned"));Rn(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&ur(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Le.BEACON_BEFORE||this.state.lifecycle===Le.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)});Rn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Rn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Rn(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)}});Rn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Rn(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,!r0(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=Rr.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,Rr.number(t)&&ur(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Rr.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&ur(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Et.INIT,controlled:s,index:i,lifecycle:Le.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?kt.READY:kt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===kt.WAITING&&e.size>0?{...e,status:kt.RUNNING}:e}getStep(e){return h0(this.props,this.steps[e??this.state.index])}};function Bte(e){return new zte(e)}function K1(e,t){return Math.min(Math.max(e,0),t)}function Hte(e,t,n){const r=m.useRef(t),s=m.useRef(n);return r.current=t,s.current=n,m.useMemo(()=>{const i=()=>e.current.getSnapshot();return{close:(S=null)=>{const{index:y,status:v}=i();v===kt.RUNNING&&e.current.updateState({action:Et.CLOSE,index:y+1,origin:S,lifecycle:Le.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:S=>{const{controlled:y,size:v,status:w}=i();if(y){ur(r.current,"tour","go() is not supported in controlled mode");return}w===kt.RUNNING&&e.current.updateState({action:Et.GO,index:S,lifecycle:Le.COMPLETE,positioned:!1,scrolling:!1,status:S<v?w:kt.FINISHED,waiting:!1})},info:()=>im(e.current.getSnapshot(),"positioned"),next:S=>{const{index:y,size:v,status:w}=i();w===kt.RUNNING&&e.current.updateState({action:Et.NEXT,index:K1(y+1,v),lifecycle:Le.COMPLETE,origin:S,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:S}=i();S===kt.RUNNING&&e.current.updateState({action:Et.UPDATE,lifecycle:Le.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:S=>{const{index:y,size:v,status:w}=i();w===kt.RUNNING&&e.current.updateState({action:Et.PREV,index:K1(y-1,v),lifecycle:Le.COMPLETE,origin:S,positioned:!1,scrolling:!1,waiting:!1})},reset:(S=!1)=>{const{controlled:y}=i();if(y){ur(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Et.RESET,index:0,lifecycle:Le.INIT,positioned:!1,scrolling:!1,status:S?kt.RUNNING:kt.READY,waiting:!1})},skip:S=>{const{status:y}=i();y===kt.RUNNING&&e.current.updateState({action:Et.SKIP,lifecycle:Le.COMPLETE,origin:S,positioned:!1,scrolling:!1,status:kt.SKIPPED,waiting:!1})},start:S=>{const{index:y,size:v}=i();s.current(),e.current.updateState({action:Et.START,index:Rr.number(S)?S:y,lifecycle:Le.INIT,positioned:!1,scrolling:!1,status:v?kt.RUNNING:kt.WAITING,waiting:!1},!0)},stop:(S=!1)=>{const{index:y,status:v}=i();[kt.FINISHED,kt.SKIPPED].includes(v)||e.current.updateState({action:Et.STOP,index:y+(S?1:0),lifecycle:Le.COMPLETE,positioned:!1,scrolling:!1,status:kt.PAUSED,waiting:!1})}}},[e])}const Ute=new Set(["origin","positioned"]);function Wte(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return ur(!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]&&!Ute.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||ur(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Vte(e,t,n){const r=m.useRef(e),s=m.useRef(t);return r.current=e,s.current=t,m.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 Ko(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 Kte(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:c}=e,{action:d,index:u,lifecycle:f,positioned:p,scrolling:h,size:g,status:b}=a,S=TI(l)??null,y=m.useRef(null),v=m.useRef(i),w=m.useRef(a),j=m.useRef(s),E=m.useRef(l),k=m.useRef(S),I=m.useRef(n),R=m.useRef(null),$=m.useRef(null),K=m.useRef(null);v.current=i,w.current=a,j.current=s,E.current=l,k.current=S,I.current=n;const D=()=>{R.current&&(clearInterval(R.current),R.current=null),$.current=null,K.current&&(K.current.cancel(),K.current=null)};m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:L}=Ko(w.current,j.current);(L("action",[Et.NEXT,Et.PREV,Et.SKIP,Et.CLOSE])||y.current===Et.CLOSE&&d===Et.START)&&(y.current=d)},[d]),m.useEffect(()=>{if(!j.current)return()=>{D()};const{hasChanged:L}=Ko(w.current,j.current),H=E.current;if(L("index")&&D(),b!==kt.RUNNING||!H||f!==Le.INIT)return()=>{D()};const{hasChangedTo:M}=Ko(w.current,j.current);M("status",kt.RUNNING)&&[kt.IDLE,kt.READY,kt.PAUSED].includes(j.current.status)&&r(lr.TOUR_START,H),c.current.cleanupPositionData();const{debug:O}=v.current;if(H.before&&!K.current){ur(O,`step:${u}`,"before()",H),K.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(lr.STEP_BEFORE_HOOK,H,{action:y.current??w.current.action});const A=()=>{K.current=null,c.current.updateState({action:y.current??w.current.action,waiting:!1,lifecycle:Le.READY})},z=new AbortController,_=H.beforeTimeout;K.current={cancel:()=>z.abort()};const T=_?setTimeout(()=>{z.signal.aborted||(ur(O,`step:${u}`,"before()","timed out",`${_}ms`),z.abort(),t(H,"before_hook"),r(lr.ERROR,H,{error:new Error("Step before hook timed out")}),A())},_):null;H.before({...c.current.getState(),action:y.current??c.current.getState().action,step:H}).then(()=>{z.signal.aborted||(T&&clearTimeout(T),A())}).catch(C=>{z.signal.aborted||(T&&clearTimeout(T),t(H,"before_hook"),r(lr.ERROR,H,{error:C instanceof Error?C:new Error(String(C))}),A())})}else if(!K.current){R.current&&$.current!==H.target&&D();const A=$s(H.target);if(A&&Ap(A))D(),c.current.updateState({action:y.current??Et.UPDATE,lifecycle:Le.READY,waiting:!1});else if(H.targetWaitTimeout===0)c.current.updateState({action:y.current??Et.UPDATE,lifecycle:Le.READY,waiting:!1});else if(!R.current){const{targetWaitTimeout:z}=H,_=Date.now();$.current=H.target,ur(O,`step:${u}`,"polling","started",`${z}ms`),c.current.updateState({waiting:!0}),R.current=setInterval(()=>{const T=$s(H.target),C=Date.now()-_,G=C>=z;(T&&Ap(T)||G)&&(ur(O,`step:${u}`,"polling",T&&Ap(T)?"found":"timed out",`${C}ms`),D(),c.current.updateState({action:y.current??Et.UPDATE,lifecycle:Le.READY,waiting:!1}))},100)}}return()=>{D()}},[t,r,u,f,b,c]),m.useEffect(()=>{if(!j.current)return;const{hasChanged:L,hasChangedTo:H,previous:M}=Ko(w.current,j.current),O=E.current;if(!O)return;const A=$s(O.target),z=!!A;if(z&&Ap(A)){if(H("lifecycle",Le.READY)&&M.lifecycle===Le.INIT&&r(lr.STEP_BEFORE,O,{action:y.current??w.current.action}),H("lifecycle",Le.READY)){const _=w.current,T=Fte(O,_,v.current.continuous)?Le.TOOLTIP:Le.BEACON,C=$s(O.scrollTarget??O.spotlightTarget??O.target),G=W1({isFirstStep:_.index===0,scrollToFirstStep:v.current.scrollToFirstStep,step:O,target:C,targetLifecycle:T}),Z=T===Le.TOOLTIP?Le.TOOLTIP_BEFORE:Le.BEACON_BEFORE;ur(v.current.debug,`step:${u}`,"scroll",G?"needed":"skipped"),c.current.updateState({action:Et.UPDATE,lifecycle:Z,scrolling:G})}}else if(w.current.status===kt.RUNNING&&f!==Le.INIT&&f!==Le.COMPLETE&&L("lifecycle")){ur(v.current.debug,`step:${u}`,z?"Target not visible":"Target not mounted",O),t(O,"target_not_found"),r(lr.TARGET_NOT_FOUND,O);const _=w.current;_.controlled||c.current.updateState({action:Et.UPDATE,index:_.index+(_.action===Et.PREV?-1:1),lifecycle:Le.INIT})}},[t,r,u,f,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:L,previous:H}=Ko(w.current,j.current),M=E.current,O=k.current;if(M&&L("lifecycle",Le.TOOLTIP_BEFORE)&&H.lifecycle===Le.BEACON){const _=$s(M.scrollTarget??M.spotlightTarget??M.target);if(W1({isFirstStep:w.current.index===0,scrollToFirstStep:v.current.scrollToFirstStep,step:M,target:_,targetLifecycle:Le.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const A=f===Le.BEACON_BEFORE||f===Le.TOOLTIP_BEFORE;if(M&&A&&!h){const _=f===Le.TOOLTIP_BEFORE?Le.TOOLTIP:Le.BEACON;c.current.updateState({action:Et.UPDATE,lifecycle:_})}M&&L("lifecycle",Le.BEACON)&&r(lr.BEACON,M),M&&L("lifecycle",Le.TOOLTIP)&&r(lr.TOOLTIP,M);const z=w.current;if((z.status===kt.RUNNING||z.controlled&&z.status===kt.PAUSED&&M)&&O&&L("lifecycle",Le.COMPLETE)&&H.lifecycle===Le.TOOLTIP&&(r(lr.STEP_AFTER,O,{action:y.current??Et.UPDATE,index:H.index??z.index,lifecycle:z.lifecycle}),O.after)){r(lr.STEP_AFTER_HOOK,O,{action:y.current??Et.UPDATE,index:H.index??z.index,lifecycle:z.lifecycle});try{O.after({...c.current.getState(),action:y.current??Et.UPDATE,index:H.index??z.index,lifecycle:z.lifecycle,step:O})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:L,previous:H}=Ko(w.current,j.current),M=E.current,O=k.current;g&&!M&&f===Le.INIT&&c.current.updateState({action:Et.UPDATE,lifecycle:Le.COMPLETE,status:kt.FINISHED}),!w.current.controlled&&b===kt.RUNNING&&L("lifecycle",Le.COMPLETE)&&u<g&&c.current.updateState({action:Et.UPDATE,lifecycle:Le.INIT}),L("lifecycle",Le.COMPLETE)&&u>=g&&c.current.updateState({action:Et.UPDATE,lifecycle:Le.COMPLETE,status:kt.FINISHED});const A=M??O??h0(v.current,v.current.steps[u-1]);if(A&&L("status",[kt.FINISHED,kt.SKIPPED])){let z;M?z=u:O?z=H.index??u:z=u-1,r(lr.TOUR_END,A,{index:z}),w.current.controlled||I.current.reset(),y.current=null}M&&L("action",Et.STOP)&&(y.current=null,r(lr.TOUR_STATUS,M)),M&&L("action",Et.RESET)&&(r(lr.TOUR_STATUS,M),y.current=null)},[d,r,u,f,g,b,c])}function qte({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:c,steps:d}=n,u=m.useRef(void 0),f=m.useRef(r),p=m.useRef(e);f.current=r,p.current=e,m.useEffect(()=>{const h=u.current;if(u.current=n,!h||n===h)return;const{hasChanged:g}=Ko(n,h);if(r0(h.steps,d)||(sT(d,i)?s.current.setSteps(d):(ur(i,"tour","Steps are not valid",d),t(lr.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(Rr.number(c)&&g("stepIndex")){const b=Rr.number(h.stepIndex)&&h.stepIndex<c?Et.NEXT:Et.PREV;[kt.FINISHED,kt.SKIPPED].includes(f.current.status)||s.current.updateState({action:b,index:c,lifecycle:Le.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,d,s])}function Yte(e,t){var l,c,d,u;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===Le.BEACON_BEFORE&&(n!=null&&n.placement)){const f=Gte(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Le.TOOLTIP_BEFORE){const{placement:f}=i;if(f==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=i.floatingOptions)!=null&&c.hideArrow?0:i.arrowSize,g=i.offset+i.spotlightPadding.top+h;a-=p+g}else if(f==="left"||f==="right"){const p=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,h=((u=$s(i.target))==null?void 0:u.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+h/2-p/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function Gte(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 Xte({emitEvent:e,previousState:t,props:n,state:r,step:s,store:i}){const{index:a,lifecycle:l,positioned:c,scrolling:d,status:u}=r,f=m.useRef(null),p=m.useRef(r),h=m.useRef(t),g=m.useRef(n),b=m.useRef(s);p.current=r,h.current=t,g.current=n,b.current=s,m.useEffect(()=>()=>{var S;(S=f.current)==null||S.call(f)},[]),m.useEffect(()=>{var E;if(!h.current||!b.current)return;const{hasChangedTo:S}=Ko(p.current,h.current),y=b.current,{debug:v}=g.current,{scrollDuration:w}=y,j=l===Le.BEACON_BEFORE||l===Le.TOOLTIP_BEFORE;if(u===kt.RUNNING&&j&&d&&S("positioned",!0)){const k=$s(y.scrollTarget??y.spotlightTarget??y.target),I=i.current.getPositionData("beacon"),R=Wc(k),$=R?!R.isSameNode(is()):!1;(E=f.current)==null||E.call(f),(async()=>{if($&&!Vc(R)){const z=is(),_=Tte(R),T={initial:z.scrollTop,target:_,element:z,duration:w};e(lr.SCROLL_START,y,{scroll:T});const{cancel:C,promise:G}=V1(_,{element:z,duration:w});f.current=C,await G,e(lr.SCROLL_END,y,{scroll:T})}const D=Math.floor(Rte(k,y.scrollOffset))||0,L=$?D:Yte(D,{beaconPosition:I,lifecycle:l,scrollOffset:y.scrollOffset,step:y});ur(v,`step:${a}`,"scroll",$?"custom":"document",`${D} → ${L}`);const H=R,M={initial:H.scrollTop,target:L,element:H,duration:w};e(lr.SCROLL_START,y,{scroll:M});const{cancel:O,promise:A}=V1(L,{element:H,duration:w});f.current=O,await A,e(lr.SCROLL_END,y,{scroll:M}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,d,u,i])}function Jte(e){const t=RZ(()=>_te(jte,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=m.useRef(Bte(t)),d=D_.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[u,f]=m.useState([]),p=m.useCallback((E,k)=>{f(I=>[...I,{reason:k,step:E}])},[]),h=m.useCallback(()=>{f([])},[]);Wte(c,n);const g=Hte(c,n,h),b=Vte(s,g,c),{index:S,size:y,status:v}=d,w=TI(d),j=m.useMemo(()=>h0(t,l[S]),[S,t,l]);return LZ(()=>{i&&y&&sT(l,n)&&g.start(a??r)}),TZ(()=>{i&&y&&v===kt.IDLE&&c.current.updateState({status:kt.READY})},[i,y,v]),qte({controls:g,emitEvent:b,props:t,state:d,store:c}),Kte({addFailure:p,controls:g,emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),Xte({emitEvent:b,previousState:w,props:t,state:d,step:j,store:c}),{controls:g,failures:u,mergedProps:t,state:d,step:j,store:c}}function Qte(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Rr.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=Cte,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Zte={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function ene({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return qd;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
185
- @keyframes joyride-loader-spin {
186
- to { transform: rotate(360deg); }
187
- }
188
- `)),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=qe.createElement(c,{step:t})}else l=qe.createElement("div",{style:{...Zte,height:s,width:i,borderTopColor:t.primaryColor}});return qe.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const tne={height:0,isFixed:!1,left:0,top:0,width:0};function Tu(e,t){const n=$s(e);if(!n)return tne;const r=p0(n),s=Vc(n),i=Ite(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 nne(e,t,n){const[r,s]=m.useState(()=>Tu(e,t)),i=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),d=m.useCallback(()=>{clearTimeout(i.current),i.current=window.setTimeout(()=>{s(f=>{const p=Tu(e,t);return f.top===p.top&&f.left===p.left&&f.width===p.width&&f.height===p.height&&f.isFixed===p.isFixed?f:p})},100)},[e,t]);m.useEffect(()=>{let f=null;const p=g=>{a.current=Wc(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(Tu(e,t))},h=$s(e);return h?p(h):(f=new MutationObserver(()=>{const g=$s(e);g&&(f==null||f.disconnect(),f=null,p(g))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;f==null||f.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]),m.useEffect(()=>{l.current&&!n&&s(Tu(e,t)),l.current=n},[n,e,t]);let u=r;return l.current&&!n&&(u=Tu(e,t)),u}function rne(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function q1(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 sne=[Le.BEACON_BEFORE,Le.BEACON];function ine(e){var A,z;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:c,scrolling:d,spotlightPadding:u,spotlightRadius:f,spotlightTarget:p,styles:h,target:g,waiting:b}=e,S=OZ(),y=nne(p??g,u,d||b),v=m.useRef(null),w=(s===Le.TOOLTIP||s===Le.TOOLTIP_BEFORE)&&l!=="center",[j,E]=m.useState(!1),k=c?(A=v.current)==null?void 0:A.offsetParent:null,I=(k==null?void 0:k.clientWidth)??S.width,R=(k==null?void 0:k.clientHeight)??Ate()??S.height,$=((z=h.overlay)==null?void 0:z.backgroundColor)??"rgba(0, 0, 0, 0.5)",K=m.useMemo(()=>{const{backgroundColor:_,mixBlendMode:T,...C}=h.overlay;return{height:R,pointerEvents:"none",...C}},[R,h.overlay]),D=w&&!d&&!b;m.useEffect(()=>{D?requestAnimationFrame(()=>E(!0)):E(!1)},[D]);const L=n&&sne.includes(s),H=!n&&s!==Le.TOOLTIP;if(r||!b&&(L||H))return null;let M="";if(D)if(c&&k){const _=$s(p??g);if(_){const T=U1(_),C=U1(k);M=q1(T.left-C.left-u.left,T.top-C.top-u.top,_.offsetWidth+u.left+u.right,_.offsetHeight+u.top+u.bottom,f)}}else M=q1(y.left,y.top,y.width,y.height,f);const O=rne(I,R,M);return qe.createElement("div",{ref:v,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:K},qe.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:R,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:I}},qe.createElement("path",{d:O,fill:$,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&qe.createElement("path",{d:M,fill:$,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&qe.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function iT(e){const{children:t,element:n}=e;return n?es.createPortal(t,n):null}const one='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function ane(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return qd;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(one)],{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 po(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 lne(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...po(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...po(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...po(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...po(e,t,n)};default:return null}}function cne(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...po(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...po(e,r,n)};case"left":return{right:-n,top:t.y??0,...po(e,r,n)};case"right":return{left:-n,top:t.y??0,...po(e,r,n)};default:return{}}}function une({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!po(r,n,i))return null;c=qe.createElement("span",{style:{flexShrink:0}},qe.createElement(l,{base:n,placement:r,size:i}))}else{const d=lne(r,n,i);if(!d)return null;c=qe.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},qe.createElement("polygon",{fill:"currentColor",points:d.points}))}return qe.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...cne(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function dne(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:c,size:d,step:u,styles:f}=e,p=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return qd;const S=document.createElement("style");S.id="joyride-beacon-animation",a&&S.setAttribute("nonce",a),S.appendChild(document.createTextNode(`
189
- @keyframes joyride-beacon-inner {
190
- 20% {
191
- opacity: 0.9;
192
- }
193
-
194
- 90% {
195
- opacity: 0.7;
196
- }
197
- }
198
-
199
- @keyframes joyride-beacon-outer {
200
- 0% {
201
- transform: scale(1);
202
- }
203
-
204
- 45% {
205
- opacity: 0.7;
206
- transform: scale(0.75);
207
- }
208
-
209
- 100% {
210
- opacity: 0.9;
211
- transform: scale(1);
212
- }
213
- }
214
- `)),document.head.appendChild(S);const y=setTimeout(()=>{Rr.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(y);const v=document.getElementById("joyride-beacon-animation");v!=null&&v.parentNode&&v.parentNode.removeChild(v)}},[h,a,c]);const g=lo(i.open);let b;if(t){const S=t;b=qe.createElement(S,{continuous:n,index:r,isLastStep:s,size:d,step:u})}else b=qe.createElement("span",{style:f.beacon},qe.createElement("span",{style:f.beaconOuter}),qe.createElement("span",{style:f.beaconInner}));return qe.createElement("button",{ref:p,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:g,type:"button"},b)}function fne({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return qe.createElement("button",{style:i,type:"button",...t},qe.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"},qe.createElement("g",null,qe.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 pne(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:c}=e,{buttons:d,content:u,styles:f,title:p}=l,h={};d.includes("primary")&&(h.primary=qe.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...i})),d.includes("skip")&&!s&&(h.skip=qe.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(h.back=qe.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=d.includes("close")&&qe.createElement(fne,{"data-testid":"button-close",styles:f.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":lo(u),"aria-describedby":"joyride-tooltip-content"};return qe.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...g},qe.createElement("div",{style:f.tooltipContainer},p&&qe.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),qe.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},u)),d.some(b=>b==="back"||b==="primary"||b==="skip")&&qe.createElement("div",{style:f.tooltipFooter},qe.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function hne(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(Ti.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(Ti.BUTTON_CLOSE):n.close(Ti.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(Ti.BUTTON_PRIMARY);return}n.next(Ti.BUTTON_PRIMARY)},u=y=>{y.preventDefault(),n.skip(Ti.BUTTON_SKIP)},f=()=>{const{back:y,close:v,last:w,next:j,nextWithProgress:E,skip:k}=a.locale,I=lo(y),R=lo(v),$=lo(w),K=lo(j),D=lo(k);let L=v,H=R;if(t){if(L=j,H=K,a.showProgress&&!s){const M=lo(E,{step:r+1,steps:i});L=yw(E,r+1,i),H=M}s&&(L=w,H=$)}return{backProps:{"aria-label":I,children:y,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":R,children:v,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":H,children:L,"data-action":"primary",onClick:d,role:"button",title:H},skipProps:{"aria-label":D,children:k,"data-action":"skip",onClick:u,role:"button",title:D},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:g,...b}=a;let S;if(g){const y=g;S=qe.createElement(y,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b})}else S=qe.createElement(pne,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b});return S}function mne(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function gne(e,t,n){var r,s;return e?[vte()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[wte({crossAxis:!1,fallbackPlacements:mne(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function yne(e){var T,C,G,Z,W;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:c,setTooltipRef:d,shouldScroll:u,size:f,step:p,target:h,updateState:g}=e,b=m.useRef(null),S=m.useRef({}),y=m.useRef({}),v=p.placement==="center",w=p.placement==="auto",j=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),E=m.useMemo(()=>tT(h)?Wc(h):void 0,[h]),k=m.useMemo(()=>Vc(h),[h]),I=m.useMemo(()=>E?{boundary:E,rootBoundary:"viewport"}:{},[E]),R=v||w?"bottom":p.placement,$=v?"fixed":((T=p.floatingOptions)==null?void 0:T.strategy)??(p.isFixed||k?"fixed":"absolute"),K=m.useMemo(()=>{var te,le,ue,de;return v?[{name:"center",fn:({rects:ce})=>({x:(window.innerWidth-ce.floating.width)/2,y:(window.innerHeight-ce.floating.height)/2})}]:[z1(({placement:ce})=>{var pe;let fe="right";ce.startsWith("top")?fe="top":ce.startsWith("bottom")?fe="bottom":ce.startsWith("left")&&(fe="left");const re=p.spotlightTarget?0:p.spotlightPadding[fe];return p.offset+re+((pe=p.floatingOptions)!=null&&pe.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(te=p.floatingOptions)==null?void 0:te.hideArrow]),...gne(w,p,R),xte({padding:10,...I,...(le=p.floatingOptions)==null?void 0:le.shiftOptions}),...(ue=p.floatingOptions)!=null&&ue.hideArrow?[]:[bte({element:b,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((de=p.floatingOptions)==null?void 0:de.middleware)??[]]},[v,p,w,R,I]),D=F1({...v?{elements:{reference:j}}:{},placement:R,strategy:$,middleware:K}),L=F1({strategy:$,placement:p.beaconPlacement??(w||v?"bottom":p.placement),middleware:m.useMemo(()=>{var te,le;return[z1(((le=(te=p.floatingOptions)==null?void 0:te.beaconOptions)==null?void 0:le.offset)??-18)]},[(G=(C=p.floatingOptions)==null?void 0:C.beaconOptions)==null?void 0:G.offset]),whileElementsMounted:M1});y.current=D.middlewareData,S.current=L.middlewareData,m.useEffect(()=>{var ue;const{floating:te,reference:le}=D.elements;if(!(!le||!te||s!==Le.TOOLTIP))return M1(le,te,D.update,(ue=p.floatingOptions)==null?void 0:ue.autoUpdate)},[s,D.update,(Z=p.floatingOptions)==null?void 0:Z.autoUpdate,p.target,D.elements]),m.useEffect(()=>{!v&&h&&D.refs.setReference(h),h&&L.refs.setReference(h)},[L.refs,v,h,D.refs]),m.useEffect(()=>{D.isPositioned&&c("tooltip",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:y.current})},[c,D.isPositioned,D.placement,D.x,D.y]),m.useEffect(()=>{L.isPositioned&&c("beacon",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:S.current})},[c,L.isPositioned,L.placement,L.x,L.y]);const H=p.zIndex+100,M=m.useCallback(te=>{te.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:Le.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),O=m.useCallback(te=>{te&&(D.refs.setFloating(te),d(te))},[D.refs,d]),{arrow:A,floater:z}=p.styles;let _=null;if(s===Le.TOOLTIP||s===Le.TOOLTIP_BEFORE){const te=H1({...z,...D.floatingStyles,zIndex:H,opacity:a&&D.isPositioned?1:0,...!a&&{transition:"none"}});_=qe.createElement("div",{ref:O,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:te},qe.createElement(hne,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!v&&!((W=p.floatingOptions)!=null&&W.hideArrow)&&qe.createElement(une,{arrowComponent:p.arrowComponent,arrowRef:b,base:p.arrowBase,placement:D.placement,position:D.middlewareData.arrow,size:p.arrowSize,styles:A}))}else(s===Le.BEACON||s===Le.BEACON_BEFORE)&&(_=qe.createElement("div",{ref:L.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:H1({...L.floatingStyles,zIndex:H})},qe.createElement(dne,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:i,onInteract:M,shouldFocus:u,size:f,step:p,styles:p.styles})));return qe.createElement(iT,{element:l},_)}function xne(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:c,size:d,step:u,updateState:f}=e,[p,h]=m.useState(null);ane(u.disableFocusTrap?null:p,"[data-action=primary]");const g=$s(u.target),b=s===Le.TOOLTIP;return!rT(u)||!Rr.domElement(g)?null:qe.createElement(yne,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:b,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:d,step:u,target:g,updateState:f})}function wne({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:d}=t,u=Qte(c),{index:f,lifecycle:p,status:h}=n,g=h===kt.RUNNING,[b,S]=m.useState(!1),y=m.useRef(null),v=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?v===0?S(!0):y.current=setTimeout(()=>{S(!0)},v):S(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[v,n.waiting]),m.useEffect(()=>{if(!g)return;const E=k=>{!r||p!==Le.TOOLTIP||k.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Ti.KEYBOARD):e.close(Ti.KEYBOARD))};return document.body.addEventListener("keydown",E,{passive:!0}),()=>{document.body.removeEventListener("keydown",E)}},[e,g,p,r]);const w=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Ti.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Ti.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const j=n.action===Et.START&&!r.skipBeacon&&r.placement!=="center";return qe.createElement(qe.Fragment,null,p!==Le.INIT&&qe.createElement(xne,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:u,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||d),step:r,updateState:s.current.updateState}),qe.createElement(iT,{element:u},qe.createElement(qe.Fragment,null,b&&qe.createElement(ene,{nonce:l,step:r}),!j&&qe.createElement(ine,{...r,continuous:i,lifecycle:p,onClickOverlay:w,portalElement:c?u:null,scrolling:n.scrolling,waiting:n.waiting}))))}function vne(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=Jte(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>im(s,"positioned"),[s]),step:i,Tour:f0()?qe.createElement(wne,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function bne(e){const{Tour:t}=vne(e);return t}function kne(e){return f0()?qe.createElement(bne,e):null}function Sne(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 Nne(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function jne(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Py="af:onboarding";function Cne({page:e,hasNodes:t=!1}){const{t:n}=on(),[r,s]=m.useState(!1),[i,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?Sne(n):t?Nne(n):jne(n),[e,t,n]);return m.useEffect(()=>{const d=localStorage.getItem(Py);console.log("[Onboarding] localStorage:",d);const u=d?JSON.parse(d):{};if(console.log("[Onboarding] progress:",u,"page:",e),u.completed||u[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]),m.useEffect(()=>{if(!r)return;const d=u=>{var g;const f=u.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(g=f.textContent)==null?void 0:g.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const b=localStorage.getItem(Py)||"{}",S=JSON.parse(b);h===n("onboarding:skip")?(S.projects=!0,S.flow=!0,S.completed=!0):S[e]=!0,localStorage.setItem(Py,JSON.stringify(S)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===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(kne,{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 Ene(){const{navigate:e,path:t}=ul(),[n,r]=m.useState([]),[s,i]=m.useState(!1);if(m.useEffect(()=>{let u=!1;const f=async()=>{try{const h=await fetch("/api/pipeline-recent-runs");if(!h.ok)return;const g=await h.json();if(u)return;const b=Array.isArray(g.runs)?g.runs:[];r(b.filter(S=>S&&S.status==="running"))}catch{}};f();const p=window.setInterval(f,3e3);return()=>{u=!0,window.clearInterval(p)}},[]),n.length===0)return null;const a=u=>{const f=new URLSearchParams({flowId:u.flowId,flowSource:u.flowSource||"workspace"});e(`/flow?${f.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(u=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(u.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(u),title:`${u.flowId} · ${u.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:u.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:u.runId.slice(0,12)})]},`${u.flowId}:${u.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):i(u=>!u),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 _ne extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,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 Pne(){const{path:e}=ul();return e==="/projects"||e==="/"?o.jsx(Pl,{}):e==="/nodes"?o.jsx(Pl,{resourceKind:"nodes"}):e==="/my-nodes"?o.jsx(Pl,{resourceKind:"my-nodes"}):e==="/my-flows"?o.jsx(Pl,{resourceKind:"my-flows"}):e==="/skills"?o.jsx(Pl,{resourceKind:"skills"}):e==="/mcps"?o.jsx(gZ,{}):e==="/flow"?o.jsx(FV,{}):e==="/workspace"?o.jsx(C7,{}):e==="/settings"?o.jsx(hZ,{}):o.jsx(Pl,{})}function Ane({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[i,a]=m.useState(""),[l,c]=m.useState(!1),[d,u]=m.useState(""),f=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})}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),u(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),u("");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){u(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:h=>s(h.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:h=>a(h.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 Ine({authUser:e,onLogout:t}){const{path:n}=ul(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(Cne,{page:r?"flow":"projects"}):null,r?null:o.jsx(KL,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(Pne,{})}),o.jsx(Ene,{})]})}function Tne(){return o.jsx(_ne,{children:o.jsx(EL,{children:o.jsx(Ane,{children:({user:e,onLogout:t})=>o.jsx(Ine,{authUser:e,onLogout:t})})})})}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 Y1=document.querySelector('link[rel="icon"]');Y1&&(Y1.href=uE);Ay.createRoot(document.getElementById("root")).render(o.jsx(qe.StrictMode,{children:o.jsx(Tne,{})}));