@fieldwangai/agentflow 0.1.108 → 0.1.110

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,348 +0,0 @@
1
- var _2=Object.defineProperty;var E2=(e,t,n)=>t in e?_2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $n=(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 ud=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ra(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var V_={exports:{}},vm={},K_={exports:{}},Rt={};/**
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 Xd=Symbol.for("react.element"),A2=Symbol.for("react.portal"),P2=Symbol.for("react.fragment"),I2=Symbol.for("react.strict_mode"),R2=Symbol.for("react.profiler"),T2=Symbol.for("react.provider"),M2=Symbol.for("react.context"),$2=Symbol.for("react.forward_ref"),L2=Symbol.for("react.suspense"),O2=Symbol.for("react.memo"),D2=Symbol.for("react.lazy"),I0=Symbol.iterator;function F2(e){return e===null||typeof e!="object"?null:(e=I0&&e[I0]||e["@@iterator"],typeof e=="function"?e:null)}var q_={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},U_=Object.assign,Y_={};function Mc(e,t,n){this.props=e,this.context=t,this.refs=Y_,this.updater=n||q_}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 G_(){}G_.prototype=Mc.prototype;function xb(e,t,n){this.props=e,this.context=t,this.refs=Y_,this.updater=n||q_}var bb=xb.prototype=new G_;bb.constructor=xb;U_(bb,Mc.prototype);bb.isPureReactComponent=!0;var R0=Array.isArray,J_=Object.prototype.hasOwnProperty,kb={current:null},X_={key:!0,ref:!0,__self:!0,__source:!0};function Q_(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)J_.call(t,r)&&!X_.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:Xd,type:e,key:i,ref:a,props:s,_owner:kb.current}}function z2(e,t){return{$$typeof:Xd,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function vb(e){return typeof e=="object"&&e!==null&&e.$$typeof===Xd}function B2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var T0=/\/+/g;function Gg(e,t){return typeof e=="object"&&e!==null&&e.key!=null?B2(""+e.key):t.toString(36)}function Bp(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 Xd:case A2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+Gg(a,0):r,R0(s)?(n="",e!=null&&(n=e.replace(T0,"$&/")+"/"),Bp(s,t,n,"",function(u){return u})):s!=null&&(vb(s)&&(s=z2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(T0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",R0(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+Gg(i,l);a+=Bp(i,t,n,c,s)}else if(c=F2(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+Gg(i,l++),a+=Bp(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 Uf(e,t,n){if(e==null)return e;var r=[],s=0;return Bp(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 Lr={current:null},Hp={transition:null},W2={ReactCurrentDispatcher:Lr,ReactCurrentBatchConfig:Hp,ReactCurrentOwner:kb};function Z_(){throw Error("act(...) is not supported in production builds of React.")}Rt.Children={map:Uf,forEach:function(e,t,n){Uf(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Uf(e,function(){t++}),t},toArray:function(e){return Uf(e,function(t){return t})||[]},only:function(e){if(!vb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Rt.Component=Mc;Rt.Fragment=P2;Rt.Profiler=R2;Rt.PureComponent=xb;Rt.StrictMode=I2;Rt.Suspense=L2;Rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W2;Rt.act=Z_;Rt.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=U_({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=kb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)J_.call(t,c)&&!X_.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:Xd,type:e.type,key:s,ref:i,props:r,_owner:a}};Rt.createContext=function(e){return e={$$typeof:M2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:T2,_context:e},e.Consumer=e};Rt.createElement=Q_;Rt.createFactory=function(e){var t=Q_.bind(null,e);return t.type=e,t};Rt.createRef=function(){return{current:null}};Rt.forwardRef=function(e){return{$$typeof:$2,render:e}};Rt.isValidElement=vb;Rt.lazy=function(e){return{$$typeof:D2,_payload:{_status:-1,_result:e},_init:H2}};Rt.memo=function(e,t){return{$$typeof:O2,type:e,compare:t===void 0?null:t}};Rt.startTransition=function(e){var t=Hp.transition;Hp.transition={};try{e()}finally{Hp.transition=t}};Rt.unstable_act=Z_;Rt.useCallback=function(e,t){return Lr.current.useCallback(e,t)};Rt.useContext=function(e){return Lr.current.useContext(e)};Rt.useDebugValue=function(){};Rt.useDeferredValue=function(e){return Lr.current.useDeferredValue(e)};Rt.useEffect=function(e,t){return Lr.current.useEffect(e,t)};Rt.useId=function(){return Lr.current.useId()};Rt.useImperativeHandle=function(e,t,n){return Lr.current.useImperativeHandle(e,t,n)};Rt.useInsertionEffect=function(e,t){return Lr.current.useInsertionEffect(e,t)};Rt.useLayoutEffect=function(e,t){return Lr.current.useLayoutEffect(e,t)};Rt.useMemo=function(e,t){return Lr.current.useMemo(e,t)};Rt.useReducer=function(e,t,n){return Lr.current.useReducer(e,t,n)};Rt.useRef=function(e){return Lr.current.useRef(e)};Rt.useState=function(e){return Lr.current.useState(e)};Rt.useSyncExternalStore=function(e,t,n){return Lr.current.useSyncExternalStore(e,t,n)};Rt.useTransition=function(){return Lr.current.useTransition()};Rt.version="18.3.1";K_.exports=Rt;var m=K_.exports;const ut=ra(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 V2=m,K2=Symbol.for("react.element"),q2=Symbol.for("react.fragment"),U2=Object.prototype.hasOwnProperty,Y2=V2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,G2={key:!0,ref:!0,__self:!0,__source:!0};function eE(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)U2.call(t,r)&&!G2.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:K2,type:e,key:i,ref:a,props:s,_owner:Y2.current}}vm.Fragment=q2;vm.jsx=eE;vm.jsxs=eE;V_.exports=vm;var o=V_.exports,ww={},tE={exports:{}},hs={},nE={exports:{}},rE={};/**
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,W){var E=T.length;T.push(W);e:for(;0<E;){var Q=E-1>>>1,V=T[Q];if(0<s(V,W))T[Q]=W,T[E]=V,E=Q;else break e}}function n(T){return T.length===0?null:T[0]}function r(T){if(T.length===0)return null;var W=T[0],E=T.pop();if(E!==W){T[0]=E;e:for(var Q=0,V=T.length,F=V>>>1;Q<F;){var se=2*(Q+1)-1,ce=T[se],J=se+1,ne=T[J];if(0>s(ce,E))J<V&&0>s(ne,ce)?(T[Q]=ne,T[J]=E,Q=J):(T[Q]=ce,T[se]=E,Q=se);else if(J<V&&0>s(ne,E))T[Q]=ne,T[J]=E,Q=J;else break e}}return W}function s(T,W){var E=T.sortIndex-W.sortIndex;return E!==0?E:T.id-W.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=[],u=[],d=1,f=null,p=3,h=!1,g=!1,k=!1,b=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 x(T){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=T)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(u)}}function C(T){if(k=!1,x(T),!g)if(n(c)!==null)g=!0,D(N);else{var W=n(u);W!==null&&L(C,W.startTime-T)}}function N(T,W){g=!1,k&&(k=!1,y(I),I=-1),h=!0;var E=p;try{for(x(W),f=n(c);f!==null&&(!(f.expirationTime>W)||T&&!B());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,p=f.priorityLevel;var V=Q(f.expirationTime<=W);W=e.unstable_now(),typeof V=="function"?f.callback=V:f===n(c)&&r(c),x(W)}else r(c);f=n(c)}if(f!==null)var F=!0;else{var se=n(u);se!==null&&L(C,se.startTime-W),F=!1}return F}finally{f=null,p=E,h=!1}}var j=!1,A=null,I=-1,O=5,H=-1;function B(){return!(e.unstable_now()-H<O)}function z(){if(A!==null){var T=e.unstable_now();H=T;var W=!0;try{W=A(!0,T)}finally{W?$():(j=!1,A=null)}}else j=!1}var $;if(typeof v=="function")$=function(){v(z)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,q=M.port2;M.port1.onmessage=z,$=function(){q.postMessage(null)}}else $=function(){b(z,0)};function D(T){A=T,j||(j=!0,$())}function L(T,W){I=b(function(){T(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_continueExecution=function(){g||h||(g=!0,D(N))},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(T){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var E=p;p=W;try{return T()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(T,W){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var E=p;p=T;try{return W()}finally{p=E}},e.unstable_scheduleCallback=function(T,W,E){var Q=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?Q+E:Q):E=Q,T){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=E+V,T={id:d++,callback:W,priorityLevel:T,startTime:E,expirationTime:V,sortIndex:-1},E>Q?(T.sortIndex=E,t(u,T),n(c)===null&&T===n(u)&&(k?(y(I),I=-1):k=!0,L(C,E-Q))):(T.sortIndex=V,t(c,T),g||h||(g=!0,D(N))),T},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(T){var W=p;return function(){var E=p;p=W;try{return T.apply(this,arguments)}finally{p=E}}}})(rE);nE.exports=rE;var J2=nE.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 X2=m,fs=J2;function _e(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 sE=new Set,dd={};function rl(e,t){gc(e,t),gc(e+"Capture",t)}function gc(e,t){for(dd[e]=t,e=0;e<t.length;e++)sE.add(t[e])}var no=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xw=Object.prototype.hasOwnProperty,Q2=/^[: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]*$/,M0={},$0={};function Z2(e){return xw.call($0,e)?!0:xw.call(M0,e)?!1:Q2.test(e)?$0[e]=!0:(M0[e]=!0,!1)}function eL(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 tL(e,t,n,r){if(t===null||typeof t>"u"||eL(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 Or(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 gr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){gr[e]=new Or(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];gr[t]=new Or(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){gr[e]=new Or(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){gr[e]=new Or(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){gr[e]=new Or(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){gr[e]=new Or(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){gr[e]=new Or(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){gr[e]=new Or(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){gr[e]=new Or(e,5,!1,e.toLowerCase(),null,!1,!1)});var Sb=/[\-:]([a-z])/g;function Nb(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(Sb,Nb);gr[t]=new Or(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(Sb,Nb);gr[t]=new Or(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(Sb,Nb);gr[t]=new Or(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){gr[e]=new Or(e,1,!1,e.toLowerCase(),null,!1,!1)});gr.xlinkHref=new Or("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){gr[e]=new Or(e,1,!1,e.toLowerCase(),null,!0,!0)});function jb(e,t,n,r){var s=gr.hasOwnProperty(t)?gr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(tL(t,n,s,r)&&(n=null),r||s===null?Z2(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 co=X2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Yf=Symbol.for("react.element"),Fl=Symbol.for("react.portal"),zl=Symbol.for("react.fragment"),Cb=Symbol.for("react.strict_mode"),bw=Symbol.for("react.profiler"),iE=Symbol.for("react.provider"),oE=Symbol.for("react.context"),_b=Symbol.for("react.forward_ref"),kw=Symbol.for("react.suspense"),vw=Symbol.for("react.suspense_list"),Eb=Symbol.for("react.memo"),Eo=Symbol.for("react.lazy"),aE=Symbol.for("react.offscreen"),L0=Symbol.iterator;function mu(e){return e===null||typeof e!="object"?null:(e=L0&&e[L0]||e["@@iterator"],typeof e=="function"?e:null)}var Tn=Object.assign,Jg;function Mu(e){if(Jg===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Jg=t&&t[1]||""}return`
34
- `+Jg+e}var Xg=!1;function Qg(e,t){if(!e||Xg)return"";Xg=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(`
35
- `),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{Xg=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Mu(e):""}function nL(e){switch(e.tag){case 5:return Mu(e.type);case 16:return Mu("Lazy");case 13:return Mu("Suspense");case 19:return Mu("SuspenseList");case 0:case 2:case 15:return e=Qg(e.type,!1),e;case 11:return e=Qg(e.type.render,!1),e;case 1:return e=Qg(e.type,!0),e;default:return""}}function Sw(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 bw:return"Profiler";case Cb:return"StrictMode";case kw:return"Suspense";case vw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case oE:return(e.displayName||"Context")+".Consumer";case iE:return(e._context.displayName||"Context")+".Provider";case _b:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Eb:return t=e.displayName||null,t!==null?t:Sw(e.type)||"Memo";case Eo:t=e._payload,e=e._init;try{return Sw(e(t))}catch{}}return null}function rL(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 Sw(t);case 8:return t===Cb?"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 Go(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function lE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function sL(e){var t=lE(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 Gf(e){e._valueTracker||(e._valueTracker=sL(e))}function cE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=lE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function hh(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 Nw(e,t){var n=t.checked;return Tn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function O0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Go(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 uE(e,t){t=t.checked,t!=null&&jb(e,"checked",t,!1)}function jw(e,t){uE(e,t);var n=Go(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")?Cw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Cw(e,t.type,Go(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function D0(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 Cw(e,t,n){(t!=="number"||hh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var $u=Array.isArray;function nc(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=""+Go(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 _w(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(_e(91));return Tn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function F0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(_e(92));if($u(n)){if(1<n.length)throw Error(_e(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Go(n)}}function dE(e,t){var n=Go(t.value),r=Go(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 z0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function fE(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 Ew(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?fE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Jf,pE=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(Jf=Jf||document.createElement("div"),Jf.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Jf.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function fd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var qu={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},iL=["Webkit","ms","Moz","O"];Object.keys(qu).forEach(function(e){iL.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),qu[t]=qu[e]})});function hE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||qu.hasOwnProperty(e)&&qu[e]?(""+t).trim():t+"px"}function mE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=hE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var oL=Tn({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 Aw(e,t){if(t){if(oL[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(_e(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(_e(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(_e(61))}if(t.style!=null&&typeof t.style!="object")throw Error(_e(62))}}function Pw(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 Iw=null;function Ab(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rw=null,rc=null,sc=null;function B0(e){if(e=ef(e)){if(typeof Rw!="function")throw Error(_e(280));var t=e.stateNode;t&&(t=_m(t),Rw(e.stateNode,e.type,t))}}function gE(e){rc?sc?sc.push(e):sc=[e]:rc=e}function yE(){if(rc){var e=rc,t=sc;if(sc=rc=null,B0(e),t)for(e=0;e<t.length;e++)B0(t[e])}}function wE(e,t){return e(t)}function xE(){}var Zg=!1;function bE(e,t,n){if(Zg)return e(t,n);Zg=!0;try{return wE(e,t,n)}finally{Zg=!1,(rc!==null||sc!==null)&&(xE(),yE())}}function pd(e,t){var n=e.stateNode;if(n===null)return null;var r=_m(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(_e(231,t,typeof n));return n}var Tw=!1;if(no)try{var gu={};Object.defineProperty(gu,"passive",{get:function(){Tw=!0}}),window.addEventListener("test",gu,gu),window.removeEventListener("test",gu,gu)}catch{Tw=!1}function aL(e,t,n,r,s,i,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var Uu=!1,mh=null,gh=!1,Mw=null,lL={onError:function(e){Uu=!0,mh=e}};function cL(e,t,n,r,s,i,a,l,c){Uu=!1,mh=null,aL.apply(lL,arguments)}function uL(e,t,n,r,s,i,a,l,c){if(cL.apply(this,arguments),Uu){if(Uu){var u=mh;Uu=!1,mh=null}else throw Error(_e(198));gh||(gh=!0,Mw=u)}}function sl(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 kE(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 H0(e){if(sl(e)!==e)throw Error(_e(188))}function dL(e){var t=e.alternate;if(!t){if(t=sl(e),t===null)throw Error(_e(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 H0(s),e;if(i===r)return H0(s),t;i=i.sibling}throw Error(_e(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(_e(189))}}if(n.alternate!==r)throw Error(_e(190))}if(n.tag!==3)throw Error(_e(188));return n.stateNode.current===n?e:t}function vE(e){return e=dL(e),e!==null?SE(e):null}function SE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=SE(e);if(t!==null)return t;e=e.sibling}return null}var NE=fs.unstable_scheduleCallback,W0=fs.unstable_cancelCallback,fL=fs.unstable_shouldYield,pL=fs.unstable_requestPaint,Hn=fs.unstable_now,hL=fs.unstable_getCurrentPriorityLevel,Pb=fs.unstable_ImmediatePriority,jE=fs.unstable_UserBlockingPriority,yh=fs.unstable_NormalPriority,mL=fs.unstable_LowPriority,CE=fs.unstable_IdlePriority,Sm=null,Si=null;function gL(e){if(Si&&typeof Si.onCommitFiberRoot=="function")try{Si.onCommitFiberRoot(Sm,e,void 0,(e.current.flags&128)===128)}catch{}}var Qs=Math.clz32?Math.clz32:xL,yL=Math.log,wL=Math.LN2;function xL(e){return e>>>=0,e===0?32:31-(yL(e)/wL|0)|0}var Xf=64,Qf=4194304;function Lu(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 wh(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=Lu(l):(i&=a,i!==0&&(r=Lu(i)))}else a=n&~s,a!==0?r=Lu(a):i!==0&&(r=Lu(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-Qs(t),s=1<<n,r|=e[n],t&=~s;return r}function bL(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 kL(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Qs(i),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=bL(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function $w(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function _E(){var e=Xf;return Xf<<=1,!(Xf&4194240)&&(Xf=64),e}function ey(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Qd(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Qs(t),e[t]=n}function vL(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-Qs(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Ib(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Qs(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var en=0;function EE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var AE,Rb,PE,IE,RE,Lw=!1,Zf=[],Fo=null,zo=null,Bo=null,hd=new Map,md=new Map,Io=[],SL="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 V0(e,t){switch(e){case"focusin":case"focusout":Fo=null;break;case"dragenter":case"dragleave":zo=null;break;case"mouseover":case"mouseout":Bo=null;break;case"pointerover":case"pointerout":hd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":md.delete(t.pointerId)}}function yu(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=ef(t),t!==null&&Rb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function NL(e,t,n,r,s){switch(t){case"focusin":return Fo=yu(Fo,e,t,n,r,s),!0;case"dragenter":return zo=yu(zo,e,t,n,r,s),!0;case"mouseover":return Bo=yu(Bo,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return hd.set(i,yu(hd.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,md.set(i,yu(md.get(i)||null,e,t,n,r,s)),!0}return!1}function TE(e){var t=Ea(e.target);if(t!==null){var n=sl(t);if(n!==null){if(t=n.tag,t===13){if(t=kE(n),t!==null){e.blockedOn=t,RE(e.priority,function(){PE(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 Wp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ow(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Iw=r,n.target.dispatchEvent(r),Iw=null}else return t=ef(n),t!==null&&Rb(t),e.blockedOn=n,!1;t.shift()}return!0}function K0(e,t,n){Wp(e)&&n.delete(t)}function jL(){Lw=!1,Fo!==null&&Wp(Fo)&&(Fo=null),zo!==null&&Wp(zo)&&(zo=null),Bo!==null&&Wp(Bo)&&(Bo=null),hd.forEach(K0),md.forEach(K0)}function wu(e,t){e.blockedOn===t&&(e.blockedOn=null,Lw||(Lw=!0,fs.unstable_scheduleCallback(fs.unstable_NormalPriority,jL)))}function gd(e){function t(s){return wu(s,e)}if(0<Zf.length){wu(Zf[0],e);for(var n=1;n<Zf.length;n++){var r=Zf[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Fo!==null&&wu(Fo,e),zo!==null&&wu(zo,e),Bo!==null&&wu(Bo,e),hd.forEach(t),md.forEach(t),n=0;n<Io.length;n++)r=Io[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Io.length&&(n=Io[0],n.blockedOn===null);)TE(n),n.blockedOn===null&&Io.shift()}var ic=co.ReactCurrentBatchConfig,xh=!0;function CL(e,t,n,r){var s=en,i=ic.transition;ic.transition=null;try{en=1,Tb(e,t,n,r)}finally{en=s,ic.transition=i}}function _L(e,t,n,r){var s=en,i=ic.transition;ic.transition=null;try{en=4,Tb(e,t,n,r)}finally{en=s,ic.transition=i}}function Tb(e,t,n,r){if(xh){var s=Ow(e,t,n,r);if(s===null)uy(e,t,r,bh,n),V0(e,r);else if(NL(s,e,t,n,r))r.stopPropagation();else if(V0(e,r),t&4&&-1<SL.indexOf(e)){for(;s!==null;){var i=ef(s);if(i!==null&&AE(i),i=Ow(e,t,n,r),i===null&&uy(e,t,r,bh,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else uy(e,t,r,null,n)}}var bh=null;function Ow(e,t,n,r){if(bh=null,e=Ab(r),e=Ea(e),e!==null)if(t=sl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=kE(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 bh=e,null}function ME(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(hL()){case Pb:return 1;case jE:return 4;case yh:case mL:return 16;case CE:return 536870912;default:return 16}default:return 16}}var $o=null,Mb=null,Vp=null;function $E(){if(Vp)return Vp;var e,t=Mb,n=t.length,r,s="value"in $o?$o.value:$o.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 Vp=s.slice(e,1<r?1-r:void 0)}function Kp(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 ep(){return!0}function q0(){return!1}function ms(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)?ep:q0,this.isPropagationStopped=q0,this}return Tn(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=ep)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ep)},persist:function(){},isPersistent:ep}),t}var $c={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},$b=ms($c),Zd=Tn({},$c,{view:0,detail:0}),EL=ms(Zd),ty,ny,xu,Nm=Tn({},Zd,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lb,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"?(ty=e.screenX-xu.screenX,ny=e.screenY-xu.screenY):ny=ty=0,xu=e),ty)},movementY:function(e){return"movementY"in e?e.movementY:ny}}),U0=ms(Nm),AL=Tn({},Nm,{dataTransfer:0}),PL=ms(AL),IL=Tn({},Zd,{relatedTarget:0}),ry=ms(IL),RL=Tn({},$c,{animationName:0,elapsedTime:0,pseudoElement:0}),TL=ms(RL),ML=Tn({},$c,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),$L=ms(ML),LL=Tn({},$c,{data:0}),Y0=ms(LL),OL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},DL={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"},FL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zL(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=FL[e])?!!t[e]:!1}function Lb(){return zL}var BL=Tn({},Zd,{key:function(e){if(e.key){var t=OL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Kp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?DL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lb,charCode:function(e){return e.type==="keypress"?Kp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Kp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),HL=ms(BL),WL=Tn({},Nm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),G0=ms(WL),VL=Tn({},Zd,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lb}),KL=ms(VL),qL=Tn({},$c,{propertyName:0,elapsedTime:0,pseudoElement:0}),UL=ms(qL),YL=Tn({},Nm,{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}),GL=ms(YL),JL=[9,13,27,32],Ob=no&&"CompositionEvent"in window,Yu=null;no&&"documentMode"in document&&(Yu=document.documentMode);var XL=no&&"TextEvent"in window&&!Yu,LE=no&&(!Ob||Yu&&8<Yu&&11>=Yu),J0=" ",X0=!1;function OE(e,t){switch(e){case"keyup":return JL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function DE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Bl=!1;function QL(e,t){switch(e){case"compositionend":return DE(t);case"keypress":return t.which!==32?null:(X0=!0,J0);case"textInput":return e=t.data,e===J0&&X0?null:e;default:return null}}function ZL(e,t){if(Bl)return e==="compositionend"||!Ob&&OE(e,t)?(e=$E(),Vp=Mb=$o=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 LE&&t.locale!=="ko"?null:t.data;default:return null}}var eO={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 Q0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!eO[e.type]:t==="textarea"}function FE(e,t,n,r){gE(r),t=kh(t,"onChange"),0<t.length&&(n=new $b("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Gu=null,yd=null;function tO(e){JE(e,0)}function jm(e){var t=Vl(e);if(cE(t))return e}function nO(e,t){if(e==="change")return t}var zE=!1;if(no){var sy;if(no){var iy="oninput"in document;if(!iy){var Z0=document.createElement("div");Z0.setAttribute("oninput","return;"),iy=typeof Z0.oninput=="function"}sy=iy}else sy=!1;zE=sy&&(!document.documentMode||9<document.documentMode)}function eN(){Gu&&(Gu.detachEvent("onpropertychange",BE),yd=Gu=null)}function BE(e){if(e.propertyName==="value"&&jm(yd)){var t=[];FE(t,yd,e,Ab(e)),bE(tO,t)}}function rO(e,t,n){e==="focusin"?(eN(),Gu=t,yd=n,Gu.attachEvent("onpropertychange",BE)):e==="focusout"&&eN()}function sO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return jm(yd)}function iO(e,t){if(e==="click")return jm(t)}function oO(e,t){if(e==="input"||e==="change")return jm(t)}function aO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ti=typeof Object.is=="function"?Object.is:aO;function wd(e,t){if(ti(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(!xw.call(t,s)||!ti(e[s],t[s]))return!1}return!0}function tN(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function nN(e,t){var n=tN(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=tN(n)}}function HE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?HE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function WE(){for(var e=window,t=hh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=hh(e.document)}return t}function Db(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 lO(e){var t=WE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&HE(n.ownerDocument.documentElement,n)){if(r!==null&&Db(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=nN(n,i);var a=nN(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 cO=no&&"documentMode"in document&&11>=document.documentMode,Hl=null,Dw=null,Ju=null,Fw=!1;function rN(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fw||Hl==null||Hl!==hh(r)||(r=Hl,"selectionStart"in r&&Db(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}),Ju&&wd(Ju,r)||(Ju=r,r=kh(Dw,"onSelect"),0<r.length&&(t=new $b("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Hl)))}function tp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Wl={animationend:tp("Animation","AnimationEnd"),animationiteration:tp("Animation","AnimationIteration"),animationstart:tp("Animation","AnimationStart"),transitionend:tp("Transition","TransitionEnd")},oy={},VE={};no&&(VE=document.createElement("div").style,"AnimationEvent"in window||(delete Wl.animationend.animation,delete Wl.animationiteration.animation,delete Wl.animationstart.animation),"TransitionEvent"in window||delete Wl.transitionend.transition);function Cm(e){if(oy[e])return oy[e];if(!Wl[e])return e;var t=Wl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in VE)return oy[e]=t[n];return e}var KE=Cm("animationend"),qE=Cm("animationiteration"),UE=Cm("animationstart"),YE=Cm("transitionend"),GE=new Map,sN="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 sa(e,t){GE.set(e,t),rl(t,[e])}for(var ay=0;ay<sN.length;ay++){var ly=sN[ay],uO=ly.toLowerCase(),dO=ly[0].toUpperCase()+ly.slice(1);sa(uO,"on"+dO)}sa(KE,"onAnimationEnd");sa(qE,"onAnimationIteration");sa(UE,"onAnimationStart");sa("dblclick","onDoubleClick");sa("focusin","onFocus");sa("focusout","onBlur");sa(YE,"onTransitionEnd");gc("onMouseEnter",["mouseout","mouseover"]);gc("onMouseLeave",["mouseout","mouseover"]);gc("onPointerEnter",["pointerout","pointerover"]);gc("onPointerLeave",["pointerout","pointerover"]);rl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));rl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));rl("onBeforeInput",["compositionend","keypress","textInput","paste"]);rl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));rl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));rl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ou="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(" "),fO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ou));function iN(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,uL(r,t,void 0,e),e.currentTarget=null}function JE(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,u=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;iN(s,l,u),i=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;iN(s,l,u),i=c}}}if(gh)throw e=Mw,gh=!1,Mw=null,e}function yn(e,t){var n=t[Vw];n===void 0&&(n=t[Vw]=new Set);var r=e+"__bubble";n.has(r)||(XE(t,e,2,!1),n.add(r))}function cy(e,t,n){var r=0;t&&(r|=4),XE(n,e,r,t)}var np="_reactListening"+Math.random().toString(36).slice(2);function xd(e){if(!e[np]){e[np]=!0,sE.forEach(function(n){n!=="selectionchange"&&(fO.has(n)||cy(n,!1,e),cy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[np]||(t[np]=!0,cy("selectionchange",!1,t))}}function XE(e,t,n,r){switch(ME(t)){case 1:var s=CL;break;case 4:s=_L;break;default:s=Tb}n=s.bind(null,t,n,e),s=void 0,!Tw||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 uy(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=Ea(l),a===null)return;if(c=a.tag,c===5||c===6){r=i=a;continue e}l=l.parentNode}}r=r.return}bE(function(){var u=i,d=Ab(n),f=[];e:{var p=GE.get(e);if(p!==void 0){var h=$b,g=e;switch(e){case"keypress":if(Kp(n)===0)break e;case"keydown":case"keyup":h=HL;break;case"focusin":g="focus",h=ry;break;case"focusout":g="blur",h=ry;break;case"beforeblur":case"afterblur":h=ry;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=U0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=PL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=KL;break;case KE:case qE:case UE:h=TL;break;case YE:h=UL;break;case"scroll":h=EL;break;case"wheel":h=GL;break;case"copy":case"cut":case"paste":h=$L;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=G0}var k=(t&4)!==0,b=!k&&e==="scroll",y=k?p!==null?p+"Capture":null:p;k=[];for(var v=u,x;v!==null;){x=v;var C=x.stateNode;if(x.tag===5&&C!==null&&(x=C,y!==null&&(C=pd(v,y),C!=null&&k.push(bd(v,C,x)))),b)break;v=v.return}0<k.length&&(p=new h(p,g,null,n,d),f.push({event:p,listeners:k}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&n!==Iw&&(g=n.relatedTarget||n.fromElement)&&(Ea(g)||g[ro]))break e;if((h||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,h?(g=n.relatedTarget||n.toElement,h=u,g=g?Ea(g):null,g!==null&&(b=sl(g),g!==b||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=u),h!==g)){if(k=U0,C="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(k=G0,C="onPointerLeave",y="onPointerEnter",v="pointer"),b=h==null?p:Vl(h),x=g==null?p:Vl(g),p=new k(C,v+"leave",h,n,d),p.target=b,p.relatedTarget=x,C=null,Ea(d)===u&&(k=new k(y,v+"enter",g,n,d),k.target=x,k.relatedTarget=b,C=k),b=C,h&&g)t:{for(k=h,y=g,v=0,x=k;x;x=_l(x))v++;for(x=0,C=y;C;C=_l(C))x++;for(;0<v-x;)k=_l(k),v--;for(;0<x-v;)y=_l(y),x--;for(;v--;){if(k===y||y!==null&&k===y.alternate)break t;k=_l(k),y=_l(y)}k=null}else k=null;h!==null&&oN(f,p,h,k,!1),g!==null&&b!==null&&oN(f,b,g,k,!0)}}e:{if(p=u?Vl(u):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var N=nO;else if(Q0(p))if(zE)N=oO;else{N=sO;var j=rO}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(N=iO);if(N&&(N=N(e,u))){FE(f,N,n,d);break e}j&&j(e,p,u),e==="focusout"&&(j=p._wrapperState)&&j.controlled&&p.type==="number"&&Cw(p,"number",p.value)}switch(j=u?Vl(u):window,e){case"focusin":(Q0(j)||j.contentEditable==="true")&&(Hl=j,Dw=u,Ju=null);break;case"focusout":Ju=Dw=Hl=null;break;case"mousedown":Fw=!0;break;case"contextmenu":case"mouseup":case"dragend":Fw=!1,rN(f,n,d);break;case"selectionchange":if(cO)break;case"keydown":case"keyup":rN(f,n,d)}var A;if(Ob)e:{switch(e){case"compositionstart":var I="onCompositionStart";break e;case"compositionend":I="onCompositionEnd";break e;case"compositionupdate":I="onCompositionUpdate";break e}I=void 0}else Bl?OE(e,n)&&(I="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(I="onCompositionStart");I&&(LE&&n.locale!=="ko"&&(Bl||I!=="onCompositionStart"?I==="onCompositionEnd"&&Bl&&(A=$E()):($o=d,Mb="value"in $o?$o.value:$o.textContent,Bl=!0)),j=kh(u,I),0<j.length&&(I=new Y0(I,e,null,n,d),f.push({event:I,listeners:j}),A?I.data=A:(A=DE(n),A!==null&&(I.data=A)))),(A=XL?QL(e,n):ZL(e,n))&&(u=kh(u,"onBeforeInput"),0<u.length&&(d=new Y0("onBeforeInput","beforeinput",null,n,d),f.push({event:d,listeners:u}),d.data=A))}JE(f,t)})}function bd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function kh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=pd(e,n),i!=null&&r.unshift(bd(e,i,s)),i=pd(e,t),i!=null&&r.push(bd(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 oN(e,t,n,r,s){for(var i=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,s?(c=pd(n,i),c!=null&&a.unshift(bd(n,c,l))):s||(c=pd(n,i),c!=null&&a.push(bd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var pO=/\r\n?/g,hO=/\u0000|\uFFFD/g;function aN(e){return(typeof e=="string"?e:""+e).replace(pO,`
38
- `).replace(hO,"")}function rp(e,t,n){if(t=aN(t),aN(e)!==t&&n)throw Error(_e(425))}function vh(){}var zw=null,Bw=null;function Hw(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 Ww=typeof setTimeout=="function"?setTimeout:void 0,mO=typeof clearTimeout=="function"?clearTimeout:void 0,lN=typeof Promise=="function"?Promise:void 0,gO=typeof queueMicrotask=="function"?queueMicrotask:typeof lN<"u"?function(e){return lN.resolve(null).then(e).catch(yO)}:Ww;function yO(e){setTimeout(function(){throw e})}function dy(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),gd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);gd(t)}function Ho(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 cN(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 Lc=Math.random().toString(36).slice(2),yi="__reactFiber$"+Lc,kd="__reactProps$"+Lc,ro="__reactContainer$"+Lc,Vw="__reactEvents$"+Lc,wO="__reactListeners$"+Lc,xO="__reactHandles$"+Lc;function Ea(e){var t=e[yi];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ro]||n[yi]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=cN(e);e!==null;){if(n=e[yi])return n;e=cN(e)}return t}e=n,n=e.parentNode}return null}function ef(e){return e=e[yi]||e[ro],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Vl(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(_e(33))}function _m(e){return e[kd]||null}var Kw=[],Kl=-1;function ia(e){return{current:e}}function xn(e){0>Kl||(e.current=Kw[Kl],Kw[Kl]=null,Kl--)}function fn(e,t){Kl++,Kw[Kl]=e.current,e.current=t}var Jo={},Ar=ia(Jo),Jr=ia(!1),Ba=Jo;function yc(e,t){var n=e.type.contextTypes;if(!n)return Jo;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 Xr(e){return e=e.childContextTypes,e!=null}function Sh(){xn(Jr),xn(Ar)}function uN(e,t,n){if(Ar.current!==Jo)throw Error(_e(168));fn(Ar,t),fn(Jr,n)}function QE(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(_e(108,rL(e)||"Unknown",s));return Tn({},n,r)}function Nh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Jo,Ba=Ar.current,fn(Ar,e),fn(Jr,Jr.current),!0}function dN(e,t,n){var r=e.stateNode;if(!r)throw Error(_e(169));n?(e=QE(e,t,Ba),r.__reactInternalMemoizedMergedChildContext=e,xn(Jr),xn(Ar),fn(Ar,e)):xn(Jr),fn(Jr,n)}var Ki=null,Em=!1,fy=!1;function ZE(e){Ki===null?Ki=[e]:Ki.push(e)}function bO(e){Em=!0,ZE(e)}function oa(){if(!fy&&Ki!==null){fy=!0;var e=0,t=en;try{var n=Ki;for(en=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ki=null,Em=!1}catch(s){throw Ki!==null&&(Ki=Ki.slice(e+1)),NE(Pb,oa),s}finally{en=t,fy=!1}}return null}var ql=[],Ul=0,jh=null,Ch=0,Ns=[],js=0,Ha=null,Ui=1,Yi="";function ka(e,t){ql[Ul++]=Ch,ql[Ul++]=jh,jh=e,Ch=t}function eA(e,t,n){Ns[js++]=Ui,Ns[js++]=Yi,Ns[js++]=Ha,Ha=e;var r=Ui;e=Yi;var s=32-Qs(r)-1;r&=~(1<<s),n+=1;var i=32-Qs(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Ui=1<<32-Qs(t)+s|n<<s|r,Yi=i+e}else Ui=1<<i|n<<s|r,Yi=e}function Fb(e){e.return!==null&&(ka(e,1),eA(e,1,0))}function zb(e){for(;e===jh;)jh=ql[--Ul],ql[Ul]=null,Ch=ql[--Ul],ql[Ul]=null;for(;e===Ha;)Ha=Ns[--js],Ns[js]=null,Yi=Ns[--js],Ns[js]=null,Ui=Ns[--js],Ns[js]=null}var us=null,ls=null,jn=!1,Us=null;function tA(e,t){var n=Es(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 fN(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,us=e,ls=Ho(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,us=e,ls=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Ha!==null?{id:Ui,overflow:Yi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Es(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,us=e,ls=null,!0):!1;default:return!1}}function qw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Uw(e){if(jn){var t=ls;if(t){var n=t;if(!fN(e,t)){if(qw(e))throw Error(_e(418));t=Ho(n.nextSibling);var r=us;t&&fN(e,t)?tA(r,n):(e.flags=e.flags&-4097|2,jn=!1,us=e)}}else{if(qw(e))throw Error(_e(418));e.flags=e.flags&-4097|2,jn=!1,us=e}}}function pN(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;us=e}function sp(e){if(e!==us)return!1;if(!jn)return pN(e),jn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Hw(e.type,e.memoizedProps)),t&&(t=ls)){if(qw(e))throw nA(),Error(_e(418));for(;t;)tA(e,t),t=Ho(t.nextSibling)}if(pN(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(_e(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ls=Ho(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ls=null}}else ls=us?Ho(e.stateNode.nextSibling):null;return!0}function nA(){for(var e=ls;e;)e=Ho(e.nextSibling)}function wc(){ls=us=null,jn=!1}function Bb(e){Us===null?Us=[e]:Us.push(e)}var kO=co.ReactCurrentBatchConfig;function bu(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(_e(309));var r=n.stateNode}if(!r)throw Error(_e(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(_e(284));if(!n._owner)throw Error(_e(290,e))}return e}function ip(e,t){throw e=Object.prototype.toString.call(t),Error(_e(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function hN(e){var t=e._init;return t(e._payload)}function rA(e){function t(y,v){if(e){var x=y.deletions;x===null?(y.deletions=[v],y.flags|=16):x.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=qo(y,v),y.index=0,y.sibling=null,y}function i(y,v,x){return y.index=x,e?(x=y.alternate,x!==null?(x=x.index,x<v?(y.flags|=2,v):x):(y.flags|=2,v)):(y.flags|=1048576,v)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,v,x,C){return v===null||v.tag!==6?(v=xy(x,y.mode,C),v.return=y,v):(v=s(v,x),v.return=y,v)}function c(y,v,x,C){var N=x.type;return N===zl?d(y,v,x.props.children,C,x.key):v!==null&&(v.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Eo&&hN(N)===v.type)?(C=s(v,x.props),C.ref=bu(y,v,x),C.return=y,C):(C=Qp(x.type,x.key,x.props,null,y.mode,C),C.ref=bu(y,v,x),C.return=y,C)}function u(y,v,x,C){return v===null||v.tag!==4||v.stateNode.containerInfo!==x.containerInfo||v.stateNode.implementation!==x.implementation?(v=by(x,y.mode,C),v.return=y,v):(v=s(v,x.children||[]),v.return=y,v)}function d(y,v,x,C,N){return v===null||v.tag!==7?(v=$a(x,y.mode,C,N),v.return=y,v):(v=s(v,x),v.return=y,v)}function f(y,v,x){if(typeof v=="string"&&v!==""||typeof v=="number")return v=xy(""+v,y.mode,x),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Yf:return x=Qp(v.type,v.key,v.props,null,y.mode,x),x.ref=bu(y,null,v),x.return=y,x;case Fl:return v=by(v,y.mode,x),v.return=y,v;case Eo:var C=v._init;return f(y,C(v._payload),x)}if($u(v)||mu(v))return v=$a(v,y.mode,x,null),v.return=y,v;ip(y,v)}return null}function p(y,v,x,C){var N=v!==null?v.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return N!==null?null:l(y,v,""+x,C);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Yf:return x.key===N?c(y,v,x,C):null;case Fl:return x.key===N?u(y,v,x,C):null;case Eo:return N=x._init,p(y,v,N(x._payload),C)}if($u(x)||mu(x))return N!==null?null:d(y,v,x,C,null);ip(y,x)}return null}function h(y,v,x,C,N){if(typeof C=="string"&&C!==""||typeof C=="number")return y=y.get(x)||null,l(v,y,""+C,N);if(typeof C=="object"&&C!==null){switch(C.$$typeof){case Yf:return y=y.get(C.key===null?x:C.key)||null,c(v,y,C,N);case Fl:return y=y.get(C.key===null?x:C.key)||null,u(v,y,C,N);case Eo:var j=C._init;return h(y,v,x,j(C._payload),N)}if($u(C)||mu(C))return y=y.get(x)||null,d(v,y,C,N,null);ip(v,C)}return null}function g(y,v,x,C){for(var N=null,j=null,A=v,I=v=0,O=null;A!==null&&I<x.length;I++){A.index>I?(O=A,A=null):O=A.sibling;var H=p(y,A,x[I],C);if(H===null){A===null&&(A=O);break}e&&A&&H.alternate===null&&t(y,A),v=i(H,v,I),j===null?N=H:j.sibling=H,j=H,A=O}if(I===x.length)return n(y,A),jn&&ka(y,I),N;if(A===null){for(;I<x.length;I++)A=f(y,x[I],C),A!==null&&(v=i(A,v,I),j===null?N=A:j.sibling=A,j=A);return jn&&ka(y,I),N}for(A=r(y,A);I<x.length;I++)O=h(A,y,I,x[I],C),O!==null&&(e&&O.alternate!==null&&A.delete(O.key===null?I:O.key),v=i(O,v,I),j===null?N=O:j.sibling=O,j=O);return e&&A.forEach(function(B){return t(y,B)}),jn&&ka(y,I),N}function k(y,v,x,C){var N=mu(x);if(typeof N!="function")throw Error(_e(150));if(x=N.call(x),x==null)throw Error(_e(151));for(var j=N=null,A=v,I=v=0,O=null,H=x.next();A!==null&&!H.done;I++,H=x.next()){A.index>I?(O=A,A=null):O=A.sibling;var B=p(y,A,H.value,C);if(B===null){A===null&&(A=O);break}e&&A&&B.alternate===null&&t(y,A),v=i(B,v,I),j===null?N=B:j.sibling=B,j=B,A=O}if(H.done)return n(y,A),jn&&ka(y,I),N;if(A===null){for(;!H.done;I++,H=x.next())H=f(y,H.value,C),H!==null&&(v=i(H,v,I),j===null?N=H:j.sibling=H,j=H);return jn&&ka(y,I),N}for(A=r(y,A);!H.done;I++,H=x.next())H=h(A,y,I,H.value,C),H!==null&&(e&&H.alternate!==null&&A.delete(H.key===null?I:H.key),v=i(H,v,I),j===null?N=H:j.sibling=H,j=H);return e&&A.forEach(function(z){return t(y,z)}),jn&&ka(y,I),N}function b(y,v,x,C){if(typeof x=="object"&&x!==null&&x.type===zl&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Yf:e:{for(var N=x.key,j=v;j!==null;){if(j.key===N){if(N=x.type,N===zl){if(j.tag===7){n(y,j.sibling),v=s(j,x.props.children),v.return=y,y=v;break e}}else if(j.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Eo&&hN(N)===j.type){n(y,j.sibling),v=s(j,x.props),v.ref=bu(y,j,x),v.return=y,y=v;break e}n(y,j);break}else t(y,j);j=j.sibling}x.type===zl?(v=$a(x.props.children,y.mode,C,x.key),v.return=y,y=v):(C=Qp(x.type,x.key,x.props,null,y.mode,C),C.ref=bu(y,v,x),C.return=y,y=C)}return a(y);case Fl:e:{for(j=x.key;v!==null;){if(v.key===j)if(v.tag===4&&v.stateNode.containerInfo===x.containerInfo&&v.stateNode.implementation===x.implementation){n(y,v.sibling),v=s(v,x.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=by(x,y.mode,C),v.return=y,y=v}return a(y);case Eo:return j=x._init,b(y,v,j(x._payload),C)}if($u(x))return g(y,v,x,C);if(mu(x))return k(y,v,x,C);ip(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,v!==null&&v.tag===6?(n(y,v.sibling),v=s(v,x),v.return=y,y=v):(n(y,v),v=xy(x,y.mode,C),v.return=y,y=v),a(y)):n(y,v)}return b}var xc=rA(!0),sA=rA(!1),_h=ia(null),Eh=null,Yl=null,Hb=null;function Wb(){Hb=Yl=Eh=null}function Vb(e){var t=_h.current;xn(_h),e._currentValue=t}function Yw(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 oc(e,t){Eh=e,Hb=Yl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ur=!0),e.firstContext=null)}function Ps(e){var t=e._currentValue;if(Hb!==e)if(e={context:e,memoizedValue:t,next:null},Yl===null){if(Eh===null)throw Error(_e(308));Yl=e,Eh.dependencies={lanes:0,firstContext:e}}else Yl=Yl.next=e;return t}var Aa=null;function Kb(e){Aa===null?Aa=[e]:Aa.push(e)}function iA(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Kb(t)):(n.next=s.next,s.next=n),t.interleaved=n,so(e,r)}function so(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 Ao=!1;function qb(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function oA(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 Qi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Wo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Wt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,so(e,n)}return s=r.interleaved,s===null?(t.next=t,Kb(r)):(t.next=s.next,s.next=t),r.interleaved=t,so(e,n)}function qp(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,Ib(e,n)}}function mN(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 Ah(e,t,n,r){var s=e.updateQueue;Ao=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?i=u:a.next=u,a=c;var d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==a&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;a=0,d=u=c=null,l=i;do{var p=l.lane,h=l.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,k=l;switch(p=t,h=n,k.tag){case 1:if(g=k.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=k.payload,p=typeof g=="function"?g.call(h,f,p):g,p==null)break e;f=Tn({},f,p);break e;case 2:Ao=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=h,c=f):d=d.next=h,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);Va|=a,e.lanes=a,e.memoizedState=f}}function gN(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(_e(191,s));s.call(r)}}}var tf={},Ni=ia(tf),vd=ia(tf),Sd=ia(tf);function Pa(e){if(e===tf)throw Error(_e(174));return e}function Ub(e,t){switch(fn(Sd,t),fn(vd,e),fn(Ni,tf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Ew(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Ew(t,e)}xn(Ni),fn(Ni,t)}function bc(){xn(Ni),xn(vd),xn(Sd)}function aA(e){Pa(Sd.current);var t=Pa(Ni.current),n=Ew(t,e.type);t!==n&&(fn(vd,e),fn(Ni,n))}function Yb(e){vd.current===e&&(xn(Ni),xn(vd))}var Pn=ia(0);function Ph(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 py=[];function Gb(){for(var e=0;e<py.length;e++)py[e]._workInProgressVersionPrimary=null;py.length=0}var Up=co.ReactCurrentDispatcher,hy=co.ReactCurrentBatchConfig,Wa=0,Rn=null,Zn=null,ar=null,Ih=!1,Xu=!1,Nd=0,vO=0;function Nr(){throw Error(_e(321))}function Jb(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ti(e[n],t[n]))return!1;return!0}function Xb(e,t,n,r,s,i){if(Wa=i,Rn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Up.current=e===null||e.memoizedState===null?CO:_O,e=n(r,s),Xu){i=0;do{if(Xu=!1,Nd=0,25<=i)throw Error(_e(301));i+=1,ar=Zn=null,t.updateQueue=null,Up.current=EO,e=n(r,s)}while(Xu)}if(Up.current=Rh,t=Zn!==null&&Zn.next!==null,Wa=0,ar=Zn=Rn=null,Ih=!1,t)throw Error(_e(300));return e}function Qb(){var e=Nd!==0;return Nd=0,e}function pi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ar===null?Rn.memoizedState=ar=e:ar=ar.next=e,ar}function Is(){if(Zn===null){var e=Rn.alternate;e=e!==null?e.memoizedState:null}else e=Zn.next;var t=ar===null?Rn.memoizedState:ar.next;if(t!==null)ar=t,Zn=e;else{if(e===null)throw Error(_e(310));Zn=e,e={memoizedState:Zn.memoizedState,baseState:Zn.baseState,baseQueue:Zn.baseQueue,queue:Zn.queue,next:null},ar===null?Rn.memoizedState=ar=e:ar=ar.next=e}return ar}function jd(e,t){return typeof t=="function"?t(e):t}function my(e){var t=Is(),n=t.queue;if(n===null)throw Error(_e(311));n.lastRenderedReducer=e;var r=Zn,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,u=i;do{var d=u.lane;if((Wa&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var f={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Rn.lanes|=d,Va|=d}u=u.next}while(u!==null&&u!==i);c===null?a=r:c.next=l,ti(r,t.memoizedState)||(Ur=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Rn.lanes|=i,Va|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function gy(e){var t=Is(),n=t.queue;if(n===null)throw Error(_e(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);ti(i,t.memoizedState)||(Ur=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function lA(){}function cA(e,t){var n=Rn,r=Is(),s=t(),i=!ti(r.memoizedState,s);if(i&&(r.memoizedState=s,Ur=!0),r=r.queue,Zb(fA.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||ar!==null&&ar.memoizedState.tag&1){if(n.flags|=2048,Cd(9,dA.bind(null,n,r,s,t),void 0,null),cr===null)throw Error(_e(349));Wa&30||uA(n,t,s)}return s}function uA(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Rn.updateQueue,t===null?(t={lastEffect:null,stores:null},Rn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function dA(e,t,n,r){t.value=n,t.getSnapshot=r,pA(t)&&hA(e)}function fA(e,t,n){return n(function(){pA(t)&&hA(e)})}function pA(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ti(e,n)}catch{return!0}}function hA(e){var t=so(e,1);t!==null&&Zs(t,e,1,-1)}function yN(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:jd,lastRenderedState:e},t.queue=e,e=e.dispatch=jO.bind(null,Rn,e),[t.memoizedState,e]}function Cd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Rn.updateQueue,t===null?(t={lastEffect:null,stores:null},Rn.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 mA(){return Is().memoizedState}function Yp(e,t,n,r){var s=pi();Rn.flags|=e,s.memoizedState=Cd(1|t,n,void 0,r===void 0?null:r)}function Am(e,t,n,r){var s=Is();r=r===void 0?null:r;var i=void 0;if(Zn!==null){var a=Zn.memoizedState;if(i=a.destroy,r!==null&&Jb(r,a.deps)){s.memoizedState=Cd(t,n,i,r);return}}Rn.flags|=e,s.memoizedState=Cd(1|t,n,i,r)}function wN(e,t){return Yp(8390656,8,e,t)}function Zb(e,t){return Am(2048,8,e,t)}function gA(e,t){return Am(4,2,e,t)}function yA(e,t){return Am(4,4,e,t)}function wA(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 xA(e,t,n){return n=n!=null?n.concat([e]):null,Am(4,4,wA.bind(null,t,e),n)}function ek(){}function bA(e,t){var n=Is();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Jb(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function kA(e,t){var n=Is();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Jb(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function vA(e,t,n){return Wa&21?(ti(n,t)||(n=_E(),Rn.lanes|=n,Va|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ur=!0),e.memoizedState=n)}function SO(e,t){var n=en;en=n!==0&&4>n?n:4,e(!0);var r=hy.transition;hy.transition={};try{e(!1),t()}finally{en=n,hy.transition=r}}function SA(){return Is().memoizedState}function NO(e,t,n){var r=Ko(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},NA(e))jA(t,n);else if(n=iA(e,t,n,r),n!==null){var s=$r();Zs(n,e,r,s),CA(n,t,r)}}function jO(e,t,n){var r=Ko(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(NA(e))jA(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,ti(l,a)){var c=t.interleaved;c===null?(s.next=s,Kb(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=iA(e,t,s,r),n!==null&&(s=$r(),Zs(n,e,r,s),CA(n,t,r))}}function NA(e){var t=e.alternate;return e===Rn||t!==null&&t===Rn}function jA(e,t){Xu=Ih=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function CA(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ib(e,n)}}var Rh={readContext:Ps,useCallback:Nr,useContext:Nr,useEffect:Nr,useImperativeHandle:Nr,useInsertionEffect:Nr,useLayoutEffect:Nr,useMemo:Nr,useReducer:Nr,useRef:Nr,useState:Nr,useDebugValue:Nr,useDeferredValue:Nr,useTransition:Nr,useMutableSource:Nr,useSyncExternalStore:Nr,useId:Nr,unstable_isNewReconciler:!1},CO={readContext:Ps,useCallback:function(e,t){return pi().memoizedState=[e,t===void 0?null:t],e},useContext:Ps,useEffect:wN,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Yp(4194308,4,wA.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Yp(4194308,4,e,t)},useInsertionEffect:function(e,t){return Yp(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=NO.bind(null,Rn,e),[r.memoizedState,e]},useRef:function(e){var t=pi();return e={current:e},t.memoizedState=e},useState:yN,useDebugValue:ek,useDeferredValue:function(e){return pi().memoizedState=e},useTransition:function(){var e=yN(!1),t=e[0];return e=SO.bind(null,e[1]),pi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Rn,s=pi();if(jn){if(n===void 0)throw Error(_e(407));n=n()}else{if(n=t(),cr===null)throw Error(_e(349));Wa&30||uA(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,wN(fA.bind(null,r,i,e),[e]),r.flags|=2048,Cd(9,dA.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=pi(),t=cr.identifierPrefix;if(jn){var n=Yi,r=Ui;n=(r&~(1<<32-Qs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Nd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=vO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},_O={readContext:Ps,useCallback:bA,useContext:Ps,useEffect:Zb,useImperativeHandle:xA,useInsertionEffect:gA,useLayoutEffect:yA,useMemo:kA,useReducer:my,useRef:mA,useState:function(){return my(jd)},useDebugValue:ek,useDeferredValue:function(e){var t=Is();return vA(t,Zn.memoizedState,e)},useTransition:function(){var e=my(jd)[0],t=Is().memoizedState;return[e,t]},useMutableSource:lA,useSyncExternalStore:cA,useId:SA,unstable_isNewReconciler:!1},EO={readContext:Ps,useCallback:bA,useContext:Ps,useEffect:Zb,useImperativeHandle:xA,useInsertionEffect:gA,useLayoutEffect:yA,useMemo:kA,useReducer:gy,useRef:mA,useState:function(){return gy(jd)},useDebugValue:ek,useDeferredValue:function(e){var t=Is();return Zn===null?t.memoizedState=e:vA(t,Zn.memoizedState,e)},useTransition:function(){var e=gy(jd)[0],t=Is().memoizedState;return[e,t]},useMutableSource:lA,useSyncExternalStore:cA,useId:SA,unstable_isNewReconciler:!1};function Vs(e,t){if(e&&e.defaultProps){t=Tn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Gw(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Tn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Pm={isMounted:function(e){return(e=e._reactInternals)?sl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=$r(),s=Ko(e),i=Qi(r,s);i.payload=t,n!=null&&(i.callback=n),t=Wo(e,i,s),t!==null&&(Zs(t,e,s,r),qp(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=$r(),s=Ko(e),i=Qi(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Wo(e,i,s),t!==null&&(Zs(t,e,s,r),qp(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=$r(),r=Ko(e),s=Qi(n,r);s.tag=2,t!=null&&(s.callback=t),t=Wo(e,s,r),t!==null&&(Zs(t,e,r,n),qp(t,e,r))}};function xN(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?!wd(n,r)||!wd(s,i):!0}function _A(e,t,n){var r=!1,s=Jo,i=t.contextType;return typeof i=="object"&&i!==null?i=Ps(i):(s=Xr(t)?Ba:Ar.current,r=t.contextTypes,i=(r=r!=null)?yc(e,s):Jo),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Pm,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function bN(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&&Pm.enqueueReplaceState(t,t.state,null)}function Jw(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},qb(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=Ps(i):(i=Xr(t)?Ba:Ar.current,s.context=yc(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Gw(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&&Pm.enqueueReplaceState(s,s.state,null),Ah(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function kc(e,t){try{var n="",r=t;do n+=nL(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 yy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Xw(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var AO=typeof WeakMap=="function"?WeakMap:Map;function EA(e,t,n){n=Qi(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Mh||(Mh=!0,ax=r),Xw(e,t)},n}function AA(e,t,n){n=Qi(-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(){Xw(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Xw(e,t),typeof r!="function"&&(Vo===null?Vo=new Set([this]):Vo.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function kN(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new AO;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=WO.bind(null,e,t,n),t.then(e,e))}function vN(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 SN(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=Qi(-1,1),t.tag=2,Wo(n,t,1))),n.lanes|=1),e)}var PO=co.ReactCurrentOwner,Ur=!1;function Mr(e,t,n,r){t.child=e===null?sA(t,null,n,r):xc(t,e.child,n,r)}function NN(e,t,n,r,s){n=n.render;var i=t.ref;return oc(t,s),r=Xb(e,t,n,r,i,s),n=Qb(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,io(e,t,s)):(jn&&n&&Fb(t),t.flags|=1,Mr(e,t,r,s),t.child)}function jN(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!lk(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,PA(e,t,i,r,s)):(e=Qp(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:wd,n(a,r)&&e.ref===t.ref)return io(e,t,s)}return t.flags|=1,e=qo(i,r),e.ref=t.ref,e.return=t,t.child=e}function PA(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(wd(i,r)&&e.ref===t.ref)if(Ur=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(Ur=!0);else return t.lanes=e.lanes,io(e,t,s)}return Qw(e,t,n,r,s)}function IA(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},fn(Jl,is),is|=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,fn(Jl,is),is|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,fn(Jl,is),is|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,fn(Jl,is),is|=r;return Mr(e,t,s,n),t.child}function RA(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Qw(e,t,n,r,s){var i=Xr(n)?Ba:Ar.current;return i=yc(t,i),oc(t,s),n=Xb(e,t,n,r,i,s),r=Qb(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,io(e,t,s)):(jn&&r&&Fb(t),t.flags|=1,Mr(e,t,n,s),t.child)}function CN(e,t,n,r,s){if(Xr(n)){var i=!0;Nh(t)}else i=!1;if(oc(t,s),t.stateNode===null)Gp(e,t),_A(t,n,r),Jw(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=n.contextType;typeof u=="object"&&u!==null?u=Ps(u):(u=Xr(n)?Ba:Ar.current,u=yc(t,u));var d=n.getDerivedStateFromProps,f=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&bN(t,a,r,u),Ao=!1;var p=t.memoizedState;a.state=p,Ah(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Jr.current||Ao?(typeof d=="function"&&(Gw(t,n,d,r),c=t.memoizedState),(l=Ao||xN(t,n,l,r,p,c,u))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,oA(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Vs(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ps(c):(c=Xr(n)?Ba:Ar.current,c=yc(t,c));var h=n.getDerivedStateFromProps;(d=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||p!==c)&&bN(t,a,r,c),Ao=!1,p=t.memoizedState,a.state=p,Ah(t,r,a,s);var g=t.memoizedState;l!==f||p!==g||Jr.current||Ao?(typeof h=="function"&&(Gw(t,n,h,r),g=t.memoizedState),(u=Ao||xN(t,n,u,r,p,g,c)||!1)?(d||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=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return Zw(e,t,n,r,i,s)}function Zw(e,t,n,r,s,i){RA(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&dN(t,n,!1),io(e,t,i);r=t.stateNode,PO.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)):Mr(e,t,l,i),t.memoizedState=r.state,s&&dN(t,n,!0),t.child}function TA(e){var t=e.stateNode;t.pendingContext?uN(e,t.pendingContext,t.pendingContext!==t.context):t.context&&uN(e,t.context,!1),Ub(e,t.containerInfo)}function _N(e,t,n,r,s){return wc(),Bb(s),t.flags|=256,Mr(e,t,n,r),t.child}var ex={dehydrated:null,treeContext:null,retryLane:0};function tx(e){return{baseLanes:e,cachePool:null,transitions:null}}function MA(e,t,n){var r=t.pendingProps,s=Pn.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),fn(Pn,s&1),e===null)return Uw(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=Tm(a,r,0,null),e=$a(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=tx(n),t.memoizedState=ex,e):tk(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return IO(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=qo(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=qo(l,i):(i=$a(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?tx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=ex,r}return i=e.child,e=i.sibling,r=qo(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 tk(e,t){return t=Tm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function op(e,t,n,r){return r!==null&&Bb(r),xc(t,e.child,null,n),e=tk(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function IO(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=yy(Error(_e(422))),op(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Tm({mode:"visible",children:r.children},s,0,null),i=$a(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=tx(a),t.memoizedState=ex,i);if(!(t.mode&1))return op(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(_e(419)),r=yy(i,r,void 0),op(e,t,a,r)}if(l=(a&e.childLanes)!==0,Ur||l){if(r=cr,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,so(e,s),Zs(r,e,s,-1))}return ak(),r=yy(Error(_e(421))),op(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=VO.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,ls=Ho(s.nextSibling),us=t,jn=!0,Us=null,e!==null&&(Ns[js++]=Ui,Ns[js++]=Yi,Ns[js++]=Ha,Ui=e.id,Yi=e.overflow,Ha=t),t=tk(t,r.children),t.flags|=4096,t)}function EN(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Yw(e.return,t,n)}function wy(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 $A(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(Mr(e,t,r.children,n),r=Pn.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&&EN(e,n,t);else if(e.tag===19)EN(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(fn(Pn,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&&Ph(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),wy(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&&Ph(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}wy(t,!0,n,null,i);break;case"together":wy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Gp(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function io(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Va|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(_e(153));if(t.child!==null){for(e=t.child,n=qo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=qo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function RO(e,t,n){switch(t.tag){case 3:TA(t),wc();break;case 5:aA(t);break;case 1:Xr(t.type)&&Nh(t);break;case 4:Ub(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;fn(_h,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(fn(Pn,Pn.current&1),t.flags|=128,null):n&t.child.childLanes?MA(e,t,n):(fn(Pn,Pn.current&1),e=io(e,t,n),e!==null?e.sibling:null);fn(Pn,Pn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return $A(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),fn(Pn,Pn.current),r)break;return null;case 22:case 23:return t.lanes=0,IA(e,t,n)}return io(e,t,n)}var LA,nx,OA,DA;LA=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}};nx=function(){};OA=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Pa(Ni.current);var i=null;switch(n){case"input":s=Nw(e,s),r=Nw(e,r),i=[];break;case"select":s=Tn({},s,{value:void 0}),r=Tn({},r,{value:void 0}),i=[];break;case"textarea":s=_w(e,s),r=_w(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=vh)}Aw(n,r);var a;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var l=s[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(dd.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var c=r[u];if(l=s!=null?s[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(i||(i=[]),i.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(dd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&yn("scroll",e),i||l===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};DA=function(e,t,n,r){n!==r&&(t.flags|=4)};function ku(e,t){if(!jn)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function jr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function TO(e,t,n){var r=t.pendingProps;switch(zb(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(t),null;case 1:return Xr(t.type)&&Sh(),jr(t),null;case 3:return r=t.stateNode,bc(),xn(Jr),xn(Ar),Gb(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(sp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Us!==null&&(ux(Us),Us=null))),nx(e,t),jr(t),null;case 5:Yb(t);var s=Pa(Sd.current);if(n=t.type,e!==null&&t.stateNode!=null)OA(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(_e(166));return jr(t),null}if(e=Pa(Ni.current),sp(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[yi]=t,r[kd]=i,e=(t.mode&1)!==0,n){case"dialog":yn("cancel",r),yn("close",r);break;case"iframe":case"object":case"embed":yn("load",r);break;case"video":case"audio":for(s=0;s<Ou.length;s++)yn(Ou[s],r);break;case"source":yn("error",r);break;case"img":case"image":case"link":yn("error",r),yn("load",r);break;case"details":yn("toggle",r);break;case"input":O0(r,i),yn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},yn("invalid",r);break;case"textarea":F0(r,i),yn("invalid",r)}Aw(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&&rp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&rp(r.textContent,l,e),s=["children",""+l]):dd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&yn("scroll",r)}switch(n){case"input":Gf(r),D0(r,i,!0);break;case"textarea":Gf(r),z0(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=vh)}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=fE(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[yi]=t,e[kd]=r,LA(e,t,!1,!1),t.stateNode=e;e:{switch(a=Pw(n,r),n){case"dialog":yn("cancel",e),yn("close",e),s=r;break;case"iframe":case"object":case"embed":yn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Ou.length;s++)yn(Ou[s],e);s=r;break;case"source":yn("error",e),s=r;break;case"img":case"image":case"link":yn("error",e),yn("load",e),s=r;break;case"details":yn("toggle",e),s=r;break;case"input":O0(e,r),s=Nw(e,r),yn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Tn({},r,{value:void 0}),yn("invalid",e);break;case"textarea":F0(e,r),s=_w(e,r),yn("invalid",e);break;default:s=r}Aw(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?mE(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&pE(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&fd(e,c):typeof c=="number"&&fd(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(dd.hasOwnProperty(i)?c!=null&&i==="onScroll"&&yn("scroll",e):c!=null&&jb(e,i,c,a))}switch(n){case"input":Gf(e),D0(e,r,!1);break;case"textarea":Gf(e),z0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Go(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?nc(e,!!r.multiple,i,!1):r.defaultValue!=null&&nc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=vh)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return jr(t),null;case 6:if(e&&t.stateNode!=null)DA(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(_e(166));if(n=Pa(Sd.current),Pa(Ni.current),sp(t)){if(r=t.stateNode,n=t.memoizedProps,r[yi]=t,(i=r.nodeValue!==n)&&(e=us,e!==null))switch(e.tag){case 3:rp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&rp(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[yi]=t,t.stateNode=r}return jr(t),null;case 13:if(xn(Pn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(jn&&ls!==null&&t.mode&1&&!(t.flags&128))nA(),wc(),t.flags|=98560,i=!1;else if(i=sp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(_e(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(_e(317));i[yi]=t}else wc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jr(t),i=!1}else Us!==null&&(ux(Us),Us=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||Pn.current&1?er===0&&(er=3):ak())),t.updateQueue!==null&&(t.flags|=4),jr(t),null);case 4:return bc(),nx(e,t),e===null&&xd(t.stateNode.containerInfo),jr(t),null;case 10:return Vb(t.type._context),jr(t),null;case 17:return Xr(t.type)&&Sh(),jr(t),null;case 19:if(xn(Pn),i=t.memoizedState,i===null)return jr(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)ku(i,!1);else{if(er!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Ph(e),a!==null){for(t.flags|=128,ku(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 fn(Pn,Pn.current&1|2),t.child}e=e.sibling}i.tail!==null&&Hn()>vc&&(t.flags|=128,r=!0,ku(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ph(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ku(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!jn)return jr(t),null}else 2*Hn()-i.renderingStartTime>vc&&n!==1073741824&&(t.flags|=128,r=!0,ku(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=Hn(),t.sibling=null,n=Pn.current,fn(Pn,r?n&1|2:n&1),t):(jr(t),null);case 22:case 23:return ok(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?is&1073741824&&(jr(t),t.subtreeFlags&6&&(t.flags|=8192)):jr(t),null;case 24:return null;case 25:return null}throw Error(_e(156,t.tag))}function MO(e,t){switch(zb(t),t.tag){case 1:return Xr(t.type)&&Sh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return bc(),xn(Jr),xn(Ar),Gb(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Yb(t),null;case 13:if(xn(Pn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(_e(340));wc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return xn(Pn),null;case 4:return bc(),null;case 10:return Vb(t.type._context),null;case 22:case 23:return ok(),null;case 24:return null;default:return null}}var ap=!1,Cr=!1,$O=typeof WeakSet=="function"?WeakSet:Set,Xe=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 rx(e,t,n){try{n()}catch(r){Ln(e,t,r)}}var AN=!1;function LO(e,t){if(zw=xh,e=WE(),Db(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,u=0,d=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&&++u===s&&(l=a),p===i&&++d===r&&(c=a),(h=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Bw={focusedElem:e,selectionRange:n},xh=!1,Xe=t;Xe!==null;)if(t=Xe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Xe=e;else for(;Xe!==null;){t=Xe;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var k=g.memoizedProps,b=g.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?k:Vs(t.type,k),b);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(_e(163))}}catch(C){Ln(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,Xe=e;break}Xe=t.return}return g=AN,AN=!1,g}function Qu(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&&rx(t,n,i)}s=s.next}while(s!==r)}}function Im(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 sx(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 FA(e){var t=e.alternate;t!==null&&(e.alternate=null,FA(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[yi],delete t[kd],delete t[Vw],delete t[wO],delete t[xO])),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 zA(e){return e.tag===5||e.tag===3||e.tag===4}function PN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||zA(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 ix(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=vh));else if(r!==4&&(e=e.child,e!==null))for(ix(e,t,n),e=e.sibling;e!==null;)ix(e,t,n),e=e.sibling}function ox(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(ox(e,t,n),e=e.sibling;e!==null;)ox(e,t,n),e=e.sibling}var pr=null,Ks=!1;function vo(e,t,n){for(n=n.child;n!==null;)BA(e,t,n),n=n.sibling}function BA(e,t,n){if(Si&&typeof Si.onCommitFiberUnmount=="function")try{Si.onCommitFiberUnmount(Sm,n)}catch{}switch(n.tag){case 5:Cr||Gl(n,t);case 6:var r=pr,s=Ks;pr=null,vo(e,t,n),pr=r,Ks=s,pr!==null&&(Ks?(e=pr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):pr.removeChild(n.stateNode));break;case 18:pr!==null&&(Ks?(e=pr,n=n.stateNode,e.nodeType===8?dy(e.parentNode,n):e.nodeType===1&&dy(e,n),gd(e)):dy(pr,n.stateNode));break;case 4:r=pr,s=Ks,pr=n.stateNode.containerInfo,Ks=!0,vo(e,t,n),pr=r,Ks=s;break;case 0:case 11:case 14:case 15:if(!Cr&&(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)&&rx(n,t,a),s=s.next}while(s!==r)}vo(e,t,n);break;case 1:if(!Cr&&(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)}vo(e,t,n);break;case 21:vo(e,t,n);break;case 22:n.mode&1?(Cr=(r=Cr)||n.memoizedState!==null,vo(e,t,n),Cr=r):vo(e,t,n);break;default:vo(e,t,n)}}function IN(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new $O),t.forEach(function(r){var s=KO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Bs(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:pr=l.stateNode,Ks=!1;break e;case 3:pr=l.stateNode.containerInfo,Ks=!0;break e;case 4:pr=l.stateNode.containerInfo,Ks=!0;break e}l=l.return}if(pr===null)throw Error(_e(160));BA(i,a,s),pr=null,Ks=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){Ln(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)HA(t,e),t=t.sibling}function HA(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Bs(t,e),ui(e),r&4){try{Qu(3,e,e.return),Im(3,e)}catch(k){Ln(e,e.return,k)}try{Qu(5,e,e.return)}catch(k){Ln(e,e.return,k)}}break;case 1:Bs(t,e),ui(e),r&512&&n!==null&&Gl(n,n.return);break;case 5:if(Bs(t,e),ui(e),r&512&&n!==null&&Gl(n,n.return),e.flags&32){var s=e.stateNode;try{fd(s,"")}catch(k){Ln(e,e.return,k)}}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&&uE(s,i),Pw(l,a);var u=Pw(l,i);for(a=0;a<c.length;a+=2){var d=c[a],f=c[a+1];d==="style"?mE(s,f):d==="dangerouslySetInnerHTML"?pE(s,f):d==="children"?fd(s,f):jb(s,d,f,u)}switch(l){case"input":jw(s,i);break;case"textarea":dE(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?nc(s,!!i.multiple,h,!1):p!==!!i.multiple&&(i.defaultValue!=null?nc(s,!!i.multiple,i.defaultValue,!0):nc(s,!!i.multiple,i.multiple?[]:"",!1))}s[kd]=i}catch(k){Ln(e,e.return,k)}}break;case 6:if(Bs(t,e),ui(e),r&4){if(e.stateNode===null)throw Error(_e(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(k){Ln(e,e.return,k)}}break;case 3:if(Bs(t,e),ui(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{gd(t.containerInfo)}catch(k){Ln(e,e.return,k)}break;case 4:Bs(t,e),ui(e);break;case 13:Bs(t,e),ui(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(sk=Hn())),r&4&&IN(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Cr=(u=Cr)||d,Bs(t,e),Cr=u):Bs(t,e),ui(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(Xe=e,d=e.child;d!==null;){for(f=Xe=d;Xe!==null;){switch(p=Xe,h=p.child,p.tag){case 0:case 11:case 14:case 15:Qu(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(k){Ln(r,n,k)}}break;case 5:Gl(p,p.return);break;case 22:if(p.memoizedState!==null){TN(f);continue}}h!==null?(h.return=p,Xe=h):TN(f)}d=d.sibling}e:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{s=f.stateNode,u?(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=hE("display",a))}catch(k){Ln(e,e.return,k)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(k){Ln(e,e.return,k)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Bs(t,e),ui(e),r&4&&IN(e);break;case 21:break;default:Bs(t,e),ui(e)}}function ui(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(zA(n)){var r=n;break e}n=n.return}throw Error(_e(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(fd(s,""),r.flags&=-33);var i=PN(e);ox(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=PN(e);ix(e,l,a);break;default:throw Error(_e(161))}}catch(c){Ln(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function OO(e,t,n){Xe=e,WA(e)}function WA(e,t,n){for(var r=(e.mode&1)!==0;Xe!==null;){var s=Xe,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||ap;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Cr;l=ap;var u=Cr;if(ap=a,(Cr=c)&&!u)for(Xe=s;Xe!==null;)a=Xe,c=a.child,a.tag===22&&a.memoizedState!==null?MN(s):c!==null?(c.return=a,Xe=c):MN(s);for(;i!==null;)Xe=i,WA(i),i=i.sibling;Xe=s,ap=l,Cr=u}RN(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,Xe=i):RN(e)}}function RN(e){for(;Xe!==null;){var t=Xe;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Cr||Im(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Cr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Vs(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&gN(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}gN(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&gd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(_e(163))}Cr||t.flags&512&&sx(t)}catch(p){Ln(t,t.return,p)}}if(t===e){Xe=null;break}if(n=t.sibling,n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function TN(e){for(;Xe!==null;){var t=Xe;if(t===e){Xe=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Xe=n;break}Xe=t.return}}function MN(e){for(;Xe!==null;){var t=Xe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Im(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{sx(t)}catch(c){Ln(t,i,c)}break;case 5:var a=t.return;try{sx(t)}catch(c){Ln(t,a,c)}}}catch(c){Ln(t,t.return,c)}if(t===e){Xe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Xe=l;break}Xe=t.return}}var DO=Math.ceil,Th=co.ReactCurrentDispatcher,nk=co.ReactCurrentOwner,As=co.ReactCurrentBatchConfig,Wt=0,cr=null,Un=null,mr=0,is=0,Jl=ia(0),er=0,_d=null,Va=0,Rm=0,rk=0,Zu=null,Kr=null,sk=0,vc=1/0,Vi=null,Mh=!1,ax=null,Vo=null,lp=!1,Lo=null,$h=0,ed=0,lx=null,Jp=-1,Xp=0;function $r(){return Wt&6?Hn():Jp!==-1?Jp:Jp=Hn()}function Ko(e){return e.mode&1?Wt&2&&mr!==0?mr&-mr:kO.transition!==null?(Xp===0&&(Xp=_E()),Xp):(e=en,e!==0||(e=window.event,e=e===void 0?16:ME(e.type)),e):1}function Zs(e,t,n,r){if(50<ed)throw ed=0,lx=null,Error(_e(185));Qd(e,n,r),(!(Wt&2)||e!==cr)&&(e===cr&&(!(Wt&2)&&(Rm|=n),er===4&&Ro(e,mr)),Qr(e,r),n===1&&Wt===0&&!(t.mode&1)&&(vc=Hn()+500,Em&&oa()))}function Qr(e,t){var n=e.callbackNode;kL(e,t);var r=wh(e,e===cr?mr:0);if(r===0)n!==null&&W0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&W0(n),t===1)e.tag===0?bO($N.bind(null,e)):ZE($N.bind(null,e)),gO(function(){!(Wt&6)&&oa()}),n=null;else{switch(EE(r)){case 1:n=Pb;break;case 4:n=jE;break;case 16:n=yh;break;case 536870912:n=CE;break;default:n=yh}n=XA(n,VA.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function VA(e,t){if(Jp=-1,Xp=0,Wt&6)throw Error(_e(327));var n=e.callbackNode;if(ac()&&e.callbackNode!==n)return null;var r=wh(e,e===cr?mr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Lh(e,r);else{t=r;var s=Wt;Wt|=2;var i=qA();(cr!==e||mr!==t)&&(Vi=null,vc=Hn()+500,Ma(e,t));do try{BO();break}catch(l){KA(e,l)}while(!0);Wb(),Th.current=i,Wt=s,Un!==null?t=0:(cr=null,mr=0,t=er)}if(t!==0){if(t===2&&(s=$w(e),s!==0&&(r=s,t=cx(e,s))),t===1)throw n=_d,Ma(e,0),Ro(e,r),Qr(e,Hn()),n;if(t===6)Ro(e,r);else{if(s=e.current.alternate,!(r&30)&&!FO(s)&&(t=Lh(e,r),t===2&&(i=$w(e),i!==0&&(r=i,t=cx(e,i))),t===1))throw n=_d,Ma(e,0),Ro(e,r),Qr(e,Hn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(_e(345));case 2:va(e,Kr,Vi);break;case 3:if(Ro(e,r),(r&130023424)===r&&(t=sk+500-Hn(),10<t)){if(wh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){$r(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Ww(va.bind(null,e,Kr,Vi),t);break}va(e,Kr,Vi);break;case 4:if(Ro(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Qs(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=Hn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*DO(r/1960))-r,10<r){e.timeoutHandle=Ww(va.bind(null,e,Kr,Vi),r);break}va(e,Kr,Vi);break;case 5:va(e,Kr,Vi);break;default:throw Error(_e(329))}}}return Qr(e,Hn()),e.callbackNode===n?VA.bind(null,e):null}function cx(e,t){var n=Zu;return e.current.memoizedState.isDehydrated&&(Ma(e,t).flags|=256),e=Lh(e,t),e!==2&&(t=Kr,Kr=n,t!==null&&ux(t)),e}function ux(e){Kr===null?Kr=e:Kr.push.apply(Kr,e)}function FO(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(!ti(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 Ro(e,t){for(t&=~rk,t&=~Rm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Qs(t),r=1<<n;e[n]=-1,t&=~r}}function $N(e){if(Wt&6)throw Error(_e(327));ac();var t=wh(e,0);if(!(t&1))return Qr(e,Hn()),null;var n=Lh(e,t);if(e.tag!==0&&n===2){var r=$w(e);r!==0&&(t=r,n=cx(e,r))}if(n===1)throw n=_d,Ma(e,0),Ro(e,t),Qr(e,Hn()),n;if(n===6)throw Error(_e(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,va(e,Kr,Vi),Qr(e,Hn()),null}function ik(e,t){var n=Wt;Wt|=1;try{return e(t)}finally{Wt=n,Wt===0&&(vc=Hn()+500,Em&&oa())}}function Ka(e){Lo!==null&&Lo.tag===0&&!(Wt&6)&&ac();var t=Wt;Wt|=1;var n=As.transition,r=en;try{if(As.transition=null,en=1,e)return e()}finally{en=r,As.transition=n,Wt=t,!(Wt&6)&&oa()}}function ok(){is=Jl.current,xn(Jl)}function Ma(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,mO(n)),Un!==null)for(n=Un.return;n!==null;){var r=n;switch(zb(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Sh();break;case 3:bc(),xn(Jr),xn(Ar),Gb();break;case 5:Yb(r);break;case 4:bc();break;case 13:xn(Pn);break;case 19:xn(Pn);break;case 10:Vb(r.type._context);break;case 22:case 23:ok()}n=n.return}if(cr=e,Un=e=qo(e.current,null),mr=is=t,er=0,_d=null,rk=Rm=Va=0,Kr=Zu=null,Aa!==null){for(t=0;t<Aa.length;t++)if(n=Aa[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}Aa=null}return e}function KA(e,t){do{var n=Un;try{if(Wb(),Up.current=Rh,Ih){for(var r=Rn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Ih=!1}if(Wa=0,ar=Zn=Rn=null,Xu=!1,Nd=0,nk.current=null,n===null||n.return===null){er=1,_d=t,Un=null;break}e:{var i=e,a=n.return,l=n,c=t;if(t=mr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var h=vN(a);if(h!==null){h.flags&=-257,SN(h,a,l,i,t),h.mode&1&&kN(i,u,t),t=h,c=u;var g=t.updateQueue;if(g===null){var k=new Set;k.add(c),t.updateQueue=k}else g.add(c);break e}else{if(!(t&1)){kN(i,u,t),ak();break e}c=Error(_e(426))}}else if(jn&&l.mode&1){var b=vN(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),SN(b,a,l,i,t),Bb(kc(c,l));break e}}i=c=kc(c,l),er!==4&&(er=2),Zu===null?Zu=[i]:Zu.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=EA(i,c,t);mN(i,y);break e;case 1:l=c;var v=i.type,x=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Vo===null||!Vo.has(x)))){i.flags|=65536,t&=-t,i.lanes|=t;var C=AA(i,l,t);mN(i,C);break e}}i=i.return}while(i!==null)}YA(n)}catch(N){t=N,Un===n&&n!==null&&(Un=n=n.return);continue}break}while(!0)}function qA(){var e=Th.current;return Th.current=Rh,e===null?Rh:e}function ak(){(er===0||er===3||er===2)&&(er=4),cr===null||!(Va&268435455)&&!(Rm&268435455)||Ro(cr,mr)}function Lh(e,t){var n=Wt;Wt|=2;var r=qA();(cr!==e||mr!==t)&&(Vi=null,Ma(e,t));do try{zO();break}catch(s){KA(e,s)}while(!0);if(Wb(),Wt=n,Th.current=r,Un!==null)throw Error(_e(261));return cr=null,mr=0,er}function zO(){for(;Un!==null;)UA(Un)}function BO(){for(;Un!==null&&!fL();)UA(Un)}function UA(e){var t=JA(e.alternate,e,is);e.memoizedProps=e.pendingProps,t===null?YA(e):Un=t,nk.current=null}function YA(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=MO(n,t),n!==null){n.flags&=32767,Un=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{er=6,Un=null;return}}else if(n=TO(n,t,is),n!==null){Un=n;return}if(t=t.sibling,t!==null){Un=t;return}Un=t=e}while(t!==null);er===0&&(er=5)}function va(e,t,n){var r=en,s=As.transition;try{As.transition=null,en=1,HO(e,t,n,r)}finally{As.transition=s,en=r}return null}function HO(e,t,n,r){do ac();while(Lo!==null);if(Wt&6)throw Error(_e(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(_e(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(vL(e,i),e===cr&&(Un=cr=null,mr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||lp||(lp=!0,XA(yh,function(){return ac(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=As.transition,As.transition=null;var a=en;en=1;var l=Wt;Wt|=4,nk.current=null,LO(e,n),HA(n,e),lO(Bw),xh=!!zw,Bw=zw=null,e.current=n,OO(n),pL(),Wt=l,en=a,As.transition=i}else e.current=n;if(lp&&(lp=!1,Lo=e,$h=s),i=e.pendingLanes,i===0&&(Vo=null),gL(n.stateNode),Qr(e,Hn()),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(Mh)throw Mh=!1,e=ax,ax=null,e;return $h&1&&e.tag!==0&&ac(),i=e.pendingLanes,i&1?e===lx?ed++:(ed=0,lx=e):ed=0,oa(),null}function ac(){if(Lo!==null){var e=EE($h),t=As.transition,n=en;try{if(As.transition=null,en=16>e?16:e,Lo===null)var r=!1;else{if(e=Lo,Lo=null,$h=0,Wt&6)throw Error(_e(331));var s=Wt;for(Wt|=4,Xe=e.current;Xe!==null;){var i=Xe,a=i.child;if(Xe.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(Xe=u;Xe!==null;){var d=Xe;switch(d.tag){case 0:case 11:case 15:Qu(8,d,i)}var f=d.child;if(f!==null)f.return=d,Xe=f;else for(;Xe!==null;){d=Xe;var p=d.sibling,h=d.return;if(FA(d),d===u){Xe=null;break}if(p!==null){p.return=h,Xe=p;break}Xe=h}}}var g=i.alternate;if(g!==null){var k=g.child;if(k!==null){g.child=null;do{var b=k.sibling;k.sibling=null,k=b}while(k!==null)}}Xe=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,Xe=a;else e:for(;Xe!==null;){if(i=Xe,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Qu(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,Xe=y;break e}Xe=i.return}}var v=e.current;for(Xe=v;Xe!==null;){a=Xe;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,Xe=x;else e:for(a=v;Xe!==null;){if(l=Xe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Im(9,l)}}catch(N){Ln(l,l.return,N)}if(l===a){Xe=null;break e}var C=l.sibling;if(C!==null){C.return=l.return,Xe=C;break e}Xe=l.return}}if(Wt=s,oa(),Si&&typeof Si.onPostCommitFiberRoot=="function")try{Si.onPostCommitFiberRoot(Sm,e)}catch{}r=!0}return r}finally{en=n,As.transition=t}}return!1}function LN(e,t,n){t=kc(n,t),t=EA(e,t,1),e=Wo(e,t,1),t=$r(),e!==null&&(Qd(e,1,t),Qr(e,t))}function Ln(e,t,n){if(e.tag===3)LN(e,e,n);else for(;t!==null;){if(t.tag===3){LN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Vo===null||!Vo.has(r))){e=kc(n,e),e=AA(t,e,1),t=Wo(t,e,1),e=$r(),t!==null&&(Qd(t,1,e),Qr(t,e));break}}t=t.return}}function WO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=$r(),e.pingedLanes|=e.suspendedLanes&n,cr===e&&(mr&n)===n&&(er===4||er===3&&(mr&130023424)===mr&&500>Hn()-sk?Ma(e,0):rk|=n),Qr(e,t)}function GA(e,t){t===0&&(e.mode&1?(t=Qf,Qf<<=1,!(Qf&130023424)&&(Qf=4194304)):t=1);var n=$r();e=so(e,t),e!==null&&(Qd(e,t,n),Qr(e,n))}function VO(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),GA(e,n)}function KO(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(_e(314))}r!==null&&r.delete(t),GA(e,n)}var JA;JA=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Jr.current)Ur=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ur=!1,RO(e,t,n);Ur=!!(e.flags&131072)}else Ur=!1,jn&&t.flags&1048576&&eA(t,Ch,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Gp(e,t),e=t.pendingProps;var s=yc(t,Ar.current);oc(t,n),s=Xb(null,t,r,e,s,n);var i=Qb();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Xr(r)?(i=!0,Nh(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,qb(t),s.updater=Pm,t.stateNode=s,s._reactInternals=t,Jw(t,r,e,n),t=Zw(null,t,r,!0,i,n)):(t.tag=0,jn&&i&&Fb(t),Mr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Gp(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=UO(r),e=Vs(r,e),s){case 0:t=Qw(null,t,r,e,n);break e;case 1:t=CN(null,t,r,e,n);break e;case 11:t=NN(null,t,r,e,n);break e;case 14:t=jN(null,t,r,Vs(r.type,e),n);break e}throw Error(_e(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),Qw(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),CN(e,t,r,s,n);case 3:e:{if(TA(t),e===null)throw Error(_e(387));r=t.pendingProps,i=t.memoizedState,s=i.element,oA(e,t),Ah(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=kc(Error(_e(423)),t),t=_N(e,t,r,n,s);break e}else if(r!==s){s=kc(Error(_e(424)),t),t=_N(e,t,r,n,s);break e}else for(ls=Ho(t.stateNode.containerInfo.firstChild),us=t,jn=!0,Us=null,n=sA(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(wc(),r===s){t=io(e,t,n);break e}Mr(e,t,r,n)}t=t.child}return t;case 5:return aA(t),e===null&&Uw(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,Hw(r,s)?a=null:i!==null&&Hw(r,i)&&(t.flags|=32),RA(e,t),Mr(e,t,a,n),t.child;case 6:return e===null&&Uw(t),null;case 13:return MA(e,t,n);case 4:return Ub(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=xc(t,null,r,n):Mr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),NN(e,t,r,s,n);case 7:return Mr(e,t,t.pendingProps,n),t.child;case 8:return Mr(e,t,t.pendingProps.children,n),t.child;case 12:return Mr(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,fn(_h,r._currentValue),r._currentValue=a,i!==null)if(ti(i.value,a)){if(i.children===s.children&&!Jr.current){t=io(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=Qi(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),Yw(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(_e(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),Yw(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}Mr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,oc(t,n),s=Ps(s),r=r(s),t.flags|=1,Mr(e,t,r,n),t.child;case 14:return r=t.type,s=Vs(r,t.pendingProps),s=Vs(r.type,s),jN(e,t,r,s,n);case 15:return PA(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Vs(r,s),Gp(e,t),t.tag=1,Xr(r)?(e=!0,Nh(t)):e=!1,oc(t,n),_A(t,r,s),Jw(t,r,s,n),Zw(null,t,r,!0,e,n);case 19:return $A(e,t,n);case 22:return IA(e,t,n)}throw Error(_e(156,t.tag))};function XA(e,t){return NE(e,t)}function qO(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 Es(e,t,n,r){return new qO(e,t,n,r)}function lk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function UO(e){if(typeof e=="function")return lk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===_b)return 11;if(e===Eb)return 14}return 2}function qo(e,t){var n=e.alternate;return n===null?(n=Es(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 Qp(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")lk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case zl:return $a(n.children,s,i,t);case Cb:a=8,s|=8;break;case bw:return e=Es(12,n,t,s|2),e.elementType=bw,e.lanes=i,e;case kw:return e=Es(13,n,t,s),e.elementType=kw,e.lanes=i,e;case vw:return e=Es(19,n,t,s),e.elementType=vw,e.lanes=i,e;case aE:return Tm(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case iE:a=10;break e;case oE:a=9;break e;case _b:a=11;break e;case Eb:a=14;break e;case Eo:a=16,r=null;break e}throw Error(_e(130,e==null?e:typeof e,""))}return t=Es(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function $a(e,t,n,r){return e=Es(7,e,r,t),e.lanes=n,e}function Tm(e,t,n,r){return e=Es(22,e,r,t),e.elementType=aE,e.lanes=n,e.stateNode={isHidden:!1},e}function xy(e,t,n){return e=Es(6,e,null,t),e.lanes=n,e}function by(e,t,n){return t=Es(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function YO(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=ey(0),this.expirationTimes=ey(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ey(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function ck(e,t,n,r,s,i,a,l,c){return e=new YO(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Es(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},qb(i),e}function GO(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 QA(e){if(!e)return Jo;e=e._reactInternals;e:{if(sl(e)!==e||e.tag!==1)throw Error(_e(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Xr(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(_e(171))}if(e.tag===1){var n=e.type;if(Xr(n))return QE(e,n,t)}return t}function ZA(e,t,n,r,s,i,a,l,c){return e=ck(n,r,!0,e,s,i,a,l,c),e.context=QA(null),n=e.current,r=$r(),s=Ko(n),i=Qi(r,s),i.callback=t??null,Wo(n,i,s),e.current.lanes=s,Qd(e,s,r),Qr(e,r),e}function Mm(e,t,n,r){var s=t.current,i=$r(),a=Ko(s);return n=QA(n),t.context===null?t.context=n:t.pendingContext=n,t=Qi(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Wo(s,t,a),e!==null&&(Zs(e,s,a,i),qp(e,s,a)),a}function Oh(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 ON(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function uk(e,t){ON(e,t),(e=e.alternate)&&ON(e,t)}function JO(){return null}var eP=typeof reportError=="function"?reportError:function(e){console.error(e)};function dk(e){this._internalRoot=e}$m.prototype.render=dk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(_e(409));Mm(e,t,null,null)};$m.prototype.unmount=dk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ka(function(){Mm(null,e,null,null)}),t[ro]=null}};function $m(e){this._internalRoot=e}$m.prototype.unstable_scheduleHydration=function(e){if(e){var t=IE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Io.length&&t!==0&&t<Io[n].priority;n++);Io.splice(n,0,e),n===0&&TE(e)}};function fk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Lm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function DN(){}function XO(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=Oh(a);i.call(u)}}var a=ZA(t,r,e,0,null,!1,!1,"",DN);return e._reactRootContainer=a,e[ro]=a.current,xd(e.nodeType===8?e.parentNode:e),Ka(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=Oh(c);l.call(u)}}var c=ck(e,0,!1,null,null,!1,!1,"",DN);return e._reactRootContainer=c,e[ro]=c.current,xd(e.nodeType===8?e.parentNode:e),Ka(function(){Mm(t,c,n,r)}),c}function Om(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=Oh(a);l.call(c)}}Mm(t,a,e,s)}else a=XO(n,t,e,s,r);return Oh(a)}AE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Lu(t.pendingLanes);n!==0&&(Ib(t,n|1),Qr(t,Hn()),!(Wt&6)&&(vc=Hn()+500,oa()))}break;case 13:Ka(function(){var r=so(e,1);if(r!==null){var s=$r();Zs(r,e,1,s)}}),uk(e,1)}};Rb=function(e){if(e.tag===13){var t=so(e,134217728);if(t!==null){var n=$r();Zs(t,e,134217728,n)}uk(e,134217728)}};PE=function(e){if(e.tag===13){var t=Ko(e),n=so(e,t);if(n!==null){var r=$r();Zs(n,e,t,r)}uk(e,t)}};IE=function(){return en};RE=function(e,t){var n=en;try{return en=e,t()}finally{en=n}};Rw=function(e,t,n){switch(t){case"input":if(jw(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=_m(r);if(!s)throw Error(_e(90));cE(r),jw(r,s)}}}break;case"textarea":dE(e,n);break;case"select":t=n.value,t!=null&&nc(e,!!n.multiple,t,!1)}};wE=ik;xE=Ka;var QO={usingClientEntryPoint:!1,Events:[ef,Vl,_m,gE,yE,ik]},vu={findFiberByHostInstance:Ea,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ZO={bundleType:vu.bundleType,version:vu.version,rendererPackageName:vu.rendererPackageName,rendererConfig:vu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:co.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=vE(e),e===null?null:e.stateNode},findFiberByHostInstance:vu.findFiberByHostInstance||JO,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 cp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!cp.isDisabled&&cp.supportsFiber)try{Sm=cp.inject(ZO),Si=cp}catch{}}hs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=QO;hs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!fk(t))throw Error(_e(200));return GO(e,t,null,n)};hs.createRoot=function(e,t){if(!fk(e))throw Error(_e(299));var n=!1,r="",s=eP;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=ck(e,1,!1,null,null,n,!1,r,s),e[ro]=t.current,xd(e.nodeType===8?e.parentNode:e),new dk(t)};hs.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(_e(188)):(e=Object.keys(e).join(","),Error(_e(268,e)));return e=vE(t),e=e===null?null:e.stateNode,e};hs.flushSync=function(e){return Ka(e)};hs.hydrate=function(e,t,n){if(!Lm(t))throw Error(_e(200));return Om(null,e,t,!0,n)};hs.hydrateRoot=function(e,t,n){if(!fk(e))throw Error(_e(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=eP;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=ZA(t,null,e,1,n??null,s,!1,i,a),e[ro]=t.current,xd(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 $m(t)};hs.render=function(e,t,n){if(!Lm(t))throw Error(_e(200));return Om(null,e,t,!1,n)};hs.unmountComponentAtNode=function(e){if(!Lm(e))throw Error(_e(40));return e._reactRootContainer?(Ka(function(){Om(null,null,e,!1,function(){e._reactRootContainer=null,e[ro]=null})}),!0):!1};hs.unstable_batchedUpdates=ik;hs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Lm(n))throw Error(_e(200));if(e==null||e._reactInternals===void 0)throw Error(_e(38));return Om(e,t,n,!1,r)};hs.version="18.3.1-next-f1338f8080-20240426";function tP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(tP)}catch(e){console.error(e)}}tP(),tE.exports=hs;var or=tE.exports,FN=or;ww.createRoot=FN.createRoot,ww.hydrateRoot=FN.hydrateRoot;const nP=m.createContext(null);function dx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function eD(){const e=dx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function tD({children:e}){const[t,n]=m.useState(eD);m.useEffect(()=>{const i=()=>n(dx(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=dx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(nP.Provider,{value:s,children:e})}function si(){const e=m.useContext(nP);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function nD(){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 zN={};function fx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&zN[t[0]]||(typeof t[0]=="string"&&(zN[t[0]]=new Date),nD(...t))}const rP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function BN(e,t,n){e.loadNamespaces(t,rP(e,n))}function HN(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,rP(e,r))}function rD(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 u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(i,e)))}function sD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(fx("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}}):rD(e,t,n)}const iD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,oD={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},aD=e=>oD[e],lD=e=>e.replace(iD,aD);let px={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:lD};function cD(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};px={...px,...e}}function uD(){return px}let sP;function dD(e){sP=e}function fD(){return sP}const pD={type:"3rdParty",init(e){cD(e.options.react),dD(e)}},hD=m.createContext();class mD{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const gD=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function Dr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(hD)||{},i=n||r||fD();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new mD),!i){fx("You will need to pass in an i18next instance by using initReactI18next");const x=(N,j)=>typeof j=="string"?j:j&&typeof j=="object"&&typeof j.defaultValue=="string"?j.defaultValue:Array.isArray(N)?N[N.length-1]:N,C=[x,{},!1];return C.t=x,C.i18n={},C.ready=!1,C}i.options.react&&i.options.react.wait!==void 0&&fx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...uD(),...i.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||s||i.options&&i.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(u);const d=(i.isInitialized||i.initializedStoreOnce)&&u.every(x=>sD(x,i,a));function f(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[p,h]=m.useState(f);let g=u.join();t.lng&&(g=`${t.lng}${g}`);const k=gD(g),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:C}=a;b.current=!0,!d&&!l&&(t.lng?HN(i,t.lng,u,()=>{b.current&&h(f)}):BN(i,u,()=>{b.current&&h(f)})),d&&k&&k!==g&&b.current&&h(f);function N(){b.current&&h(f)}return x&&i&&i.on(x,N),C&&i&&i.store.on(C,N),()=>{b.current=!1,x&&i&&x.split(" ").forEach(j=>i.off(j,N)),C&&i&&C.split(" ").forEach(j=>i.store.off(j,N))}},[i,g]);const y=m.useRef(!0);m.useEffect(()=>{b.current&&!y.current&&h(f),y.current=!1},[i,c]);const v=[p,i,d];if(v.t=p,v.i18n=i,v.ready=d,d||!d&&!l)return v;throw new Promise(x=>{t.lng?HN(i,t.lng,u,()=>x()):BN(i,u,()=>x())})}const iP="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",yD=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/workspaces",label:"知识库",icon:"folder_managed"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/node-studio",label:"节点编辑器",icon:"draw"},{to:"/schedules",label:"定时任务",icon:"event_busy"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],wD=[{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 xD(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function bD({authUser:e,onLogout:t}){const{path:n,navigate:r}=si(),{t:s}=Dr(),[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:iP,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:yD.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(xD(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:l.label||s(l.labelKey)})]},l.to))}),o.jsxs("div",{className:"af-sidebar-footer",children:[o.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[o.jsx("span",{className:"material-symbols-outlined",children:"person"}),o.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?o.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,o.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:o.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!i&&wD.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 kD="agentflow.pipelineRecent",vD=15;function SD(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function ND(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(kD);return e?SD(e).filter(t=>t&&typeof t.flowId=="string"&&(t.flowSource==="user"||t.flowSource==="builtin"||t.flowSource==="admin"||t.flowSource==="workspace")&&t.kind==="opened"&&typeof t.at=="number"):[]}function jD(e,t){const n=e.filter(r=>r.id===t);return n.length===0||n.some(r=>(r.source??"user")==="user")?"user":n.some(r=>r.source==="workspace")?"workspace":n.some(r=>r.source==="admin")?"admin":n.some(r=>r.source==="builtin")?"builtin":n[0].source??"user"}function WN(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,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const d=Math.floor(a/24);return d<7?t("flow:time.daysAgo",{n:d}):`${l.getMonth()+1}/${l.getDate()}`}function CD(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:jD(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,vD)}var os=Uint8Array,Xl=Uint16Array,_D=Int32Array,oP=new os([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),aP=new os([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ED=new os([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lP=function(e,t){for(var n=new Xl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new _D(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}},cP=lP(oP,2),uP=cP.b,AD=cP.r;uP[28]=258,AD[258]=28;var PD=lP(aP,0),ID=PD.b,hx=new Xl(32768);for(var wn=0;wn<32768;++wn){var So=(wn&43690)>>1|(wn&21845)<<1;So=(So&52428)>>2|(So&13107)<<2,So=(So&61680)>>4|(So&3855)<<4,hx[wn]=((So&65280)>>8|(So&255)<<8)>>1}var td=function(e,t,n){for(var r=e.length,s=0,i=new Xl(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new Xl(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new Xl(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],d=t-e[s],f=a[e[s]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)l[hx[f]>>c]=u}else for(l=new Xl(r),s=0;s<r;++s)e[s]&&(l[s]=hx[a[e[s]-1]++]>>15-e[s]);return l},nf=new os(288);for(var wn=0;wn<144;++wn)nf[wn]=8;for(var wn=144;wn<256;++wn)nf[wn]=9;for(var wn=256;wn<280;++wn)nf[wn]=7;for(var wn=280;wn<288;++wn)nf[wn]=8;var dP=new os(32);for(var wn=0;wn<32;++wn)dP[wn]=5;var RD=td(nf,9,1),TD=td(dP,5,1),ky=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Hs=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},vy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},MD=function(e){return(e+7)/8|0},pk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new os(e.subarray(t,n))},$D=["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"],Ss=function(e,t,n){var r=new Error(t||$D[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ss),!n)throw r;return r},LD=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new os(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new os(s*3));var u=function(le){var de=n.length;if(le>de){var we=new os(Math.max(de*2,le));we.set(n),n=we}},d=t.f||0,f=t.p||0,p=t.b||0,h=t.l,g=t.d,k=t.m,b=t.n,y=s*8;do{if(!h){d=Hs(e,f,1);var v=Hs(e,f+1,3);if(f+=3,v)if(v==1)h=RD,g=TD,k=9,b=5;else if(v==2){var j=Hs(e,f,31)+257,A=Hs(e,f+10,15)+4,I=j+Hs(e,f+5,31)+1;f+=14;for(var O=new os(I),H=new os(19),B=0;B<A;++B)H[ED[B]]=Hs(e,f+B*3,7);f+=A*3;for(var z=ky(H),$=(1<<z)-1,M=td(H,z,1),B=0;B<I;){var q=M[Hs(e,f,$)];f+=q&15;var x=q>>4;if(x<16)O[B++]=x;else{var D=0,L=0;for(x==16?(L=3+Hs(e,f,3),f+=2,D=O[B-1]):x==17?(L=3+Hs(e,f,7),f+=3):x==18&&(L=11+Hs(e,f,127),f+=7);L--;)O[B++]=D}}var T=O.subarray(0,j),W=O.subarray(j);k=ky(T),b=ky(W),h=td(T,k,1),g=td(W,b,1)}else Ss(1);else{var x=MD(f)+4,C=e[x-4]|e[x-3]<<8,N=x+C;if(N>s){c&&Ss(0);break}l&&u(p+C),n.set(e.subarray(x,N),p),t.b=p+=C,t.p=f=N*8,t.f=d;continue}if(f>y){c&&Ss(0);break}}l&&u(p+131072);for(var E=(1<<k)-1,Q=(1<<b)-1,V=f;;V=f){var D=h[vy(e,f)&E],F=D>>4;if(f+=D&15,f>y){c&&Ss(0);break}if(D||Ss(2),F<256)n[p++]=F;else if(F==256){V=f,h=null;break}else{var se=F-254;if(F>264){var B=F-257,ce=oP[B];se=Hs(e,f,(1<<ce)-1)+uP[B],f+=ce}var J=g[vy(e,f)&Q],ne=J>>4;J||Ss(3),f+=J&15;var W=ID[ne];if(ne>3){var ce=aP[ne];W+=vy(e,f)&(1<<ce)-1,f+=ce}if(f>y){c&&Ss(0);break}l&&u(p+131072);var ee=p+se;if(p<W){var re=i-W,Z=Math.min(W,ee);for(re+p<0&&Ss(3);p<Z;++p)n[p]=r[re+p]}for(;p<ee;++p)n[p]=n[p-W]}}t.l=h,t.p=V,t.b=p,t.f=d,h&&(d=1,t.m=k,t.d=g,t.n=b)}while(!d);return p!=n.length&&a?pk(n,0,p):n.subarray(0,p)},OD=new os(0),wi=function(e,t){return e[t]|e[t+1]<<8},Ys=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Sy=function(e,t){return Ys(e,t)+Ys(e,t+4)*4294967296};function DD(e,t){return LD(e,{i:2},t&&t.out,t&&t.dictionary)}var mx=typeof TextDecoder<"u"&&new TextDecoder,FD=0;try{mx.decode(OD,{stream:!0}),FD=1}catch{}var zD=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:pk(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 BD(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(mx)return mx.decode(e);var s=zD(e),i=s.s,n=s.r;return n.length&&Ss(8),i}}var HD=function(e,t){return t+30+wi(e,t+26)+wi(e,t+28)},WD=function(e,t,n){var r=wi(e,t+28),s=BD(e.subarray(t+46,t+46+r),!(wi(e,t+8)&2048)),i=t+46+r,a=Ys(e,t+20),l=n&&a==4294967295?VD(e,i):[a,Ys(e,t+24),Ys(e,t+42)],c=l[0],u=l[1],d=l[2];return[wi(e,t+10),c,u,s,i+wi(e,t+30)+wi(e,t+32),d]},VD=function(e,t){for(;wi(e,t)!=1;t+=4+wi(e,t+2));return[Sy(e,t+12),Sy(e,t+4),Sy(e,t+20)]};function KD(e,t){for(var n={},r=e.length-22;Ys(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Ss(13);var s=wi(e,r+8);if(!s)return{};var i=Ys(e,r+16),a=i==4294967295||s==65535;if(a){var l=Ys(e,r-12);a=Ys(e,l)==101075792,a&&(s=Ys(e,l+32),i=Ys(e,l+48))}for(var c=0;c<s;++c){var u=WD(e,i,a),d=u[0],f=u[1],p=u[2],h=u[3],g=u[4],k=u[5],b=HD(e,k);i=g,d?d==8?n[h]=DD(e.subarray(b,b+f),{out:new os(p)}):Ss(14,"unknown compression type "+d):n[h]=pk(e,b,b+f)}return n}const qD=8*1024*1024,UD=500;function YD(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 GD(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function JD(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 XD=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function QD(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=KD(t),r=new Map;let s=0,i=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const d=YD(c);if(!d||GD(d))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>qD||(i+=1,i>UD))return null;r.set(d,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=JD(c);u!==null&&a.add(u)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const c of r.keys())if(!(c===l||c.startsWith(`${l}/`)))return null;return XD.test(l)?l:null}catch{return null}}const Ny=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function ZD({file:e,onClose:t,onImported:n}){const{t:r}=Dr(),s=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,d]=m.useState("user"),[f,p]=m.useState(!1),[h,g]=m.useState(""),[k,b]=m.useState(null),y=k??e;m.useEffect(()=>{const N=requestAnimationFrame(()=>{var j;return(j=i.current)==null?void 0:j.focus()});return()=>cancelAnimationFrame(N)},[]),m.useEffect(()=>{let N=!1;return(async()=>{const j=y.name||"",A=j.toLowerCase();let I="";if(A.endsWith(".zip")){if(I=await QD(y)||"",!I){const O=j.replace(/\.zip$/i,"");Ny.test(O)&&(I=O)}}else if(A.endsWith(".yaml")||A.endsWith(".yml")){const O=j.replace(/\.ya?ml$/i,"");Ny.test(O)&&(I=O)}N||c(I)})(),()=>{N=!0}},[y]);const v=l.trim(),x=v.length>0&&Ny.test(v);async function C(N){if(N.preventDefault(),!(!x||f)){p(!0),g("");try{const j=new FormData;j.set("flowId",v),j.set("targetSpace",u),j.set("file",y,y.name);const A=await fetch("/api/flows/import",{method:"POST",body:j}),I=await A.json().catch(()=>({}));if(!A.ok){g(typeof I.error=="string"?I.error:r("project:importModal.importFailed"));return}n({id:I.flowId,source:I.flowSource??"user"})}catch(j){g(String((j==null?void 0:j.message)||j))}finally{p(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.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:N=>N.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:C,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:N=>{var A;const j=(A=N.target.files)==null?void 0:A[0];j&&b(j),N.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:N=>c(N.target.value),"aria-invalid":v.length>0&&!x}),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 N;return(N=a.current)==null?void 0:N.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:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const eF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,VN="af:newPipelineGuide";function tF({open:e,onClose:t,onCreated:n}){const{t:r}=Dr(),s=m.useId(),i=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("user"),[p,h]=m.useState(!1),[g,k]=m.useState(""),[b,y]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),k(""),h(!1),localStorage.getItem(VN)==="true"&&y(!0);const A=requestAnimationFrame(()=>{var I;return(I=i.current)==null?void 0:I.focus()});return()=>cancelAnimationFrame(A)},[e]);const v=()=>{localStorage.removeItem(VN),y(!1)};if(!e)return null;const x=a.trim(),C=x.length>0&&eF.test(x);async function N(j){if(j.preventDefault(),!(!C||p)){h(!0),k(""),v();try{const A=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:d})}),I=await A.json().catch(()=>({}));if(!A.ok){k(typeof I.error=="string"?I.error:r("project:newPipelineModal.createFailed"));return}n({id:I.flowId,source:I.flowSource??"user"})}catch(A){k(String((A==null?void 0:A.message)||A))}finally{h(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.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:j=>j.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"})})]}),b?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:N,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:j=>l(j.target.value),"aria-invalid":x.length>0&&!C}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(b?"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(b?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:j=>u(j.target.value)}),b?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:!C||p,children:r(p?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const fP="agentflow.pipelineViewPreference";function pP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function hP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(fP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function nF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(fP,JSON.stringify(e))}catch{}}function hk(e){return e==="display"?"display":"workspace"}function rF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function mP(e,t){const n=hk(t);return n==="pipeline"&&rF(e==null?void 0:e.source)?"workspace":n}function sF(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function iF(e,t,n,r=!1){if(!e)return;const s=hP();s[pP(e,t,r)]={view:hk(n),at:Date.now()},nF(s)}function oF(e,t="workspace"){if(!(e!=null&&e.id))return hk(t);const r=hP()[pP(e.id,e.source??"user",!!e.archived)],s=mP(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!sF(e)?"workspace":s}function aF(e,t="workspace"){var s;const n=mP(e,t);if(!(e!=null&&e.id))return n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return(s=e.collaboration)!=null&&s.id&&r.set("workspaceId",e.collaboration.id),e.archived&&r.set("archived","1"),n==="display"&&r.set("view","display"),`/workspace?${r.toString()}`}function up(e,t="workspace"){return aF(e,oF(e,t))}function lF(e,t){const n=String(e||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),r=String(t||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),s=Math.max(n.length,r.length);for(let i=0;i<s;i+=1){const a=Number.isFinite(n[i])?n[i]:0,l=Number.isFinite(r[i])?r[i]:0;if(a!==l)return a>l?1:-1}return 0}function gx(e){return String((e==null?void 0:e.version)||"").trim()}function cF(e){const t=gx(e),n=[(e==null?void 0:e.agent)||"codex",(e==null?void 0:e.kind)||"skill"];return t&&n.push(`v${t}`),n.join(" · ")}function uF({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[s,i]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState("keyword"),[p,h]=m.useState([]),[g,k]=m.useState({}),[b,y]=m.useState(""),[v,x]=m.useState(""),[C,N]=m.useState(""),j=m.useCallback(async()=>{x("");try{const[z,$]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),M=await z.json().catch(()=>({}));z.ok&&r({available:!!M.available,version:typeof M.version=="string"?M.version:"",loggedIn:!!M.loggedIn,user:typeof M.user=="string"?M.user:"",error:typeof M.error=="string"?M.error:""});const q=await $.json().catch(()=>({}));if(!$.ok)throw new Error(typeof q.error=="string"?q.error:"HTTP "+$.status);i(Array.isArray(q.skills)?q.skills:[]),l(typeof q.skillsRoot=="string"?q.skillsRoot:""),k({})}catch(z){x(String(z.message||z))}},[]);m.useEffect(()=>{j()},[j]);const A=m.useCallback(async()=>{const z=c.trim();if(z){y("search"),x(""),N("");try{const $=await fetch(`/api/skillhub/search?q=${encodeURIComponent(z)}&mode=${encodeURIComponent(d)}`),M=await $.json().catch(()=>({}));if(!$.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+$.status);h(Array.isArray(M.items)?M.items:[])}catch($){x(String($.message||$))}finally{y("")}}},[c,d]),I=m.useCallback(async(z,$=!1)=>{if(!t)return;const M=z&&typeof z=="object"?z:null,q=String(M?M.slug||M.name||M.collection||M.skillId||M.id:z||"").trim();if(q){y(`install:${q}`),x(""),N("");try{const D=M?{slug:M.slug||"",skillId:M.skillId||"",collection:M.collection||"",collectionName:M.collection&&M.name||"",target:"agentflow",agent:"codex",force:$}:{slug:q,target:"agentflow",agent:"codex",force:$},L=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)}),T=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+L.status);N($?`已更新 ${q}`:`已安装 ${q}`),await j(),typeof e=="function"&&await e()}catch(D){x(String(D.message||D))}finally{y("")}}},[t,j,e]),O=m.useCallback(async()=>{if(t&&s.length!==0){y("check-updates"),x(""),N("");try{const z=await Promise.all(s.map(async q=>{const D=String(q.name||"").trim();if(!D)return null;try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=keyword`),T=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof T.error=="string"?T.error:"HTTP "+L.status);const W=Array.isArray(T.items)?T.items:[],E=W.find(se=>se.slug===D||se.name===D||se.id===D)||W[0],Q=gx(q),V=String((E==null?void 0:E.version)||"").trim();let F="unknown";return E?Q&&V?F=lF(Q,V)<0?"update":"current":V&&(F="remote-only"):F="missing",[D,{state:F,latestVersion:V,installedVersion:Q,summary:(E==null?void 0:E.summary)||""}]}catch(L){return[D,{state:"error",error:String(L.message||L),installedVersion:gx(q)}]}})),$={};for(const q of z)q&&($[q[0]]=q[1]);k($);const M=Object.values($).filter(q=>q.state==="update").length;N(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{y("")}}},[t,s]),H=m.useCallback(async z=>{if(!t)return;const $=String(z||"").trim();if($){y(`uninstall:${$}`),x(""),N("");try{const M=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:$,target:"agentflow",agent:"codex"})}),q=await M.json().catch(()=>({}));if(!M.ok)throw new Error(typeof q.error=="string"?q.error:"HTTP "+M.status);N(`已卸载 ${$}`),await j(),typeof e=="function"&&await e()}catch(M){x(String(M.message||M))}finally{y("")}}},[t,j,e]),B=m.useCallback(async()=>{if(t){y("update-cli"),x(""),N("");try{const z=await fetch("/api/skillhub/update",{method:"POST"}),$=await z.json().catch(()=>({}));if(!z.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+z.status);N("SkillHub CLI 已更新"),await j()}catch(z){x(String(z.message||z))}finally{y("")}}},[t,j]);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:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",o.jsx("code",{children:a})]}):null]}),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:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),o.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),o.jsxs("div",{className:"af-set-skillhub-toolbar",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:j,disabled:!!b,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:!t||!!b||s.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:!t||!!b,children:b==="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:d,onChange:z=>{f(z.target.value),h([])},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:c,onChange:z=>u(z.target.value),onKeyDown:z=>{z.key==="Enter"&&A()},placeholder:d==="collectionId"?"输入 collection id,例如 1":d==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>A(),disabled:!c.trim()||b==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),b==="search"?"搜索中…":"搜索"]})]}),v?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:v}):null,C?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:C}):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:s.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:s.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):s.map(z=>{const $=g[z.name],M=!$||$.state==="update"||$.state==="remote-only"||$.state==="unknown"||$.state==="error",q=b===`install:${z.name}`?"更新中…":($==null?void 0:$.state)==="current"?"已最新":($==null?void 0:$.state)==="update"&&$.latestVersion?`更新到 v${$.latestVersion}`:($==null?void 0:$.state)==="remote-only"&&$.latestVersion?`安装 v${$.latestVersion}`:"重装";return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:z.displayName||z.name}),o.jsx("div",{className:"af-set-skillhub-meta",children:cF(z)}),o.jsx("div",{className:"af-set-skillhub-version-row",children:$?$.state==="update"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",$.installedVersion?`v${$.installedVersion} -> `:"","v",$.latestVersion]}):$.state==="current"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",$.latestVersion||$.installedVersion]}):$.state==="remote-only"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",$.latestVersion,",本地版本未知"]}):$.state==="missing"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):$.state==="error"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),o.jsxs("div",{className:"af-set-skillhub-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>I(z.name,!0),disabled:!t||!!b||!M,children:q}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>H(z.name),disabled:!t||!!b,children:"卸载"})]})]},`${z.agent}:${z.path}:${z.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:p.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:p.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):p.map(z=>{const $=z.slug||z.name,M=z.kind==="collection"||z.collection,q=!M&&s.some(D=>D.name===$||D.name===z.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:z.name||$}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${z.collection}`:$,z.skillId?` · id:${z.skillId}`:"",z.version?` · ${z.version}`:""]}),z.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:z.summary}):null]}),o.jsx("button",{type:"button",className:q?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>I(z,q),disabled:!t||!!b,children:q?"更新":M?"安装合集":"安装"})]},z.id||$)})})]})]})]})}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 dF(e){return{version:1,collections:La({collections:e})}}function fF(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function gP(e){const t=new Map,n=new Map;for(const r of Array.isArray(e)?e:[])r!=null&&r.key&&t.set(r.key,r.key),r!=null&&r.name&&(r!=null&&r.key)&&!n.has(r.name)&&n.set(r.name,r.key);return r=>{const s=String(r||"").trim();return s&&(t.get(s)||n.get(fF(s)))||""}}function Xo(e,t){const n=gP(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function pF(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 hF(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function mF(e,t,n){const r=Xo(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 gF(e,t,n){const r=String(e).trim().toLowerCase(),s=La({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return Xo(s,t)}function yF(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),i=String(t).trim().toLowerCase(),a=La({collections:r}),l=gF(t,n,r),c=l.length>0?l:s;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const d=JSON.parse(u);if(Array.isArray(d)){const f=gP(n),p=Array.from(new Set(d.map(f).filter(Boolean)));if(s.length>0&&p.length===s.length)return c;const h=new Set(p),g=new Set(l),k=l.length>0&&l.every(y=>h.has(y)),b=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const v=Xo(y,n);return v.length>0&&v.every(x=>h.has(x))});return l.length>0&&b&&!k?c:p}}}catch{}return c}function El(e){return e==="builtin"?"af-proj-badge af-proj-badge--builtin":e==="secondary"?"af-proj-badge af-proj-badge--secondary":e==="primary"?"af-proj-badge af-proj-badge--primary":e==="muted"?"af-proj-badge af-proj-badge--muted":"af-proj-badge"}function wF(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function xF(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 yx(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function yP(e){var n;if((n=e.collaboration)!=null&&n.role&&e.collaboration.role!=="owner")return`共享 Project / ${e.collaboration.ownerUsername||e.collaboration.ownerId} / ${e.id}`;const t=e.source??"user";return t==="builtin"?`builtin/pipelines / ${e.id}`:t==="admin"?`admin builtin / ${e.ownerUserId||"-"} / ${e.id}`:t==="workspace"?e.archived?`.workspace/agentflow/pipelines/_archived / ${e.id}`:`.workspace/agentflow/pipelines / ${e.id}`:e.archived?`~/agentflow/pipelines/_archived / ${e.id}`:`~/agentflow/pipelines / ${e.id}`}const bF="project:defaultCardDesc";function wP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(bF)}function kF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function zn({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(`(${kF(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 vF(e,t,n){const r=[String(e.id),wP(e,n),yP(e),yx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function SF(e,t,n){return t?vF(e,t,n).includes(t):!0}function NF(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 jy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function KN(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 qN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const jF=["all","agent","control","provide","marketplace"],CF=["all","agent","control","provide"],xP="agentflow.projects.activityPanelOpen",wx="agentflow.projects.activitySelected";function _F(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(xP);return e!=="0"}function UN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function EF(){return typeof localStorage>"u"?"":localStorage.getItem(wx)||""}function dp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Bn(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 AF(e,t){if((e==null?void 0:e.source)!=="marketplace")return!1;const n=String((e==null?void 0:e.ownerUserId)||(e==null?void 0:e.createdBy)||"").trim();return n?new Set([String((t==null?void 0:t.userId)||"").trim(),String((t==null?void 0:t.username)||"").trim()].filter(Boolean)).has(n):!0}function No(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function bP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.instances;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):t&&typeof t=="object"?Object.entries(t).map(([r,s])=>({...s&&typeof s=="object"?s:{},instanceId:(s==null?void 0:s.instanceId)||r})):[]}function kP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.edges;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):[]}function xx(e,t){return String((e==null?void 0:e.instanceId)||(e==null?void 0:e.id)||(e==null?void 0:e.nodeId)||`node_${t+1}`)}function YN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||xx(e,t))}function PF(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function GN(e,t){return String(t==="source"?(e==null?void 0:e.source)||(e==null?void 0:e.from)||(e==null?void 0:e.sourceId)||(e==null?void 0:e.fromNode)||(e==null?void 0:e.fromInstanceId)||"":(e==null?void 0:e.target)||(e==null?void 0:e.to)||(e==null?void 0:e.targetId)||(e==null?void 0:e.toNode)||(e==null?void 0:e.toInstanceId)||"")}function IF(e){const t=(e==null?void 0:e.sourceHandle)||(e==null?void 0:e.fromHandle)||(e==null?void 0:e.output)||(e==null?void 0:e.outputName),n=(e==null?void 0:e.targetHandle)||(e==null?void 0:e.toHandle)||(e==null?void 0:e.input)||(e==null?void 0:e.inputName);return t&&n?`${t} -> ${n}`:String(t||n||"")}function Cy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function RF(e){const t=Number(e==null?void 0:e.x),n=Number(e==null?void 0:e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}function TF(e,t){const n=e.map(d=>d.id),r=new Set(n),s=new Map(n.map(d=>[d,0])),i=new Map(n.map(d=>[d,[]]));t.forEach(d=>{var f;!r.has(d.sourceId)||!r.has(d.targetId)||(s.set(d.targetId,(s.get(d.targetId)||0)+1),(f=i.get(d.sourceId))==null||f.push(d.targetId))});const a=new Map,l=n.filter(d=>(s.get(d)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(d=>a.set(d,0));for(let d=0;d<l.length;d+=1){const f=l[d],p=(a.get(f)||0)+1;for(const h of i.get(f)||[])(!a.has(h)||p>a.get(h))&&(a.set(h,p),l.push(h))}n.forEach((d,f)=>{a.has(d)||a.set(d,f%3)});const c=new Map,u=new Map;return n.forEach(d=>{const f=a.get(d)||0,p=c.get(f)||0;c.set(f,p+1),u.set(d,{x:f*190,y:p*86})}),u}function MF(e){var k,b,y,v;const t=bP(e),n=kP(e),r=new Map(t.map((x,C)=>[xx(x,C),YN(x,C)])),s=t.map((x,C)=>({id:xx(x,C),title:YN(x,C),meta:PF(x)})),i=n.map((x,C)=>{const N=GN(x,"source"),j=GN(x,"target");return{key:(x==null?void 0:x.id)||`${N}-${j}-${C}`,sourceId:N,targetId:j,source:r.get(N)||N||"?",target:r.get(j)||j||"?",label:IF(x)}}),a=(b=(k=e==null?void 0:e.snippet)==null?void 0:k.ui)!=null&&b.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(v=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&v.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=TF(s,i),u=s.map(x=>{const C=RF(a[x.id])||c.get(x.id)||{x:0,y:0},N=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},j=Number(N.width),A=Number(N.height),I=Math.max(132,Math.min(210,Number.isFinite(j)?j*.62:150)),O=Math.max(48,Math.min(76,Number.isFinite(A)?A*.46:54));return{...x,x:C.x,y:C.y,width:I,height:O}}),d=new Map(u.map(x=>[x.id,x])),f=i.map(x=>{const C=d.get(x.sourceId),N=d.get(x.targetId);if(!C||!N)return null;const j=C.x+C.width,A=C.y+C.height/2,I=N.x,O=N.y+N.height/2,H=Math.max(48,Math.abs(I-j)*.45);return{...x,path:`M ${j} ${A} C ${j+H} ${A}, ${I-H} ${O}, ${I} ${O}`,labelX:(j+I)/2,labelY:(A+O)/2}}).filter(Boolean),p=u.reduce((x,C)=>({minX:Math.min(x.minX,C.x),minY:Math.min(x.minY,C.y),maxX:Math.max(x.maxX,C.x+C.width),maxY:Math.max(x.maxY,C.y+C.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,g=`${p.minX-h} ${p.minY-h} ${Math.max(360,p.maxX-p.minX+h*2)} ${Math.max(180,p.maxY-p.minY+h*2)}`;return{nodes:s,edges:i,diagram:{nodes:u,edges:f,viewBox:g}}}function Al({resourceKind:e="",authUser:t=null}){var Ee,wt,Ot,Vt,Dn,Mn;const{t:n}=Dr(),{navigate:r,path:s}=si(),i=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[d,f]=m.useState([]),[p,h]=m.useState([]),[g,k]=m.useState([]),[b,y]=m.useState([]),[v,x]=m.useState(""),[C,N]=m.useState(!1),[j,A]=m.useState([]),[I,O]=m.useState(""),[H,B]=m.useState(""),[z,$]=m.useState(!1),[M,q]=m.useState(!1),[D,L]=m.useState(!1),[T,W]=m.useState(null),[E,Q]=m.useState(!1),[V,F]=m.useState(""),[se,ce]=m.useState(_F),[J,ne]=m.useState(EF),[ee,re]=m.useState("all"),[Z,le]=m.useState(""),[de,we]=m.useState("overview"),[De,Qe]=m.useState({}),[Oe,st]=m.useState(""),[mt,kt]=m.useState({}),[Pe,dt]=m.useState(""),[gt,xe]=m.useState(""),[Fe,Me]=m.useState({}),[ue,ve]=m.useState(""),[Ve,qe]=m.useState(""),[be,Tt]=m.useState(""),[ln,_t]=m.useState(""),[hn,tn]=m.useState(""),[te,Ie]=m.useState(!1),[Ue,Ze]=m.useState(""),[Mt,At]=m.useState({hiddenBuiltins:[],promoted:[]}),tr=m.useRef(0),kn=m.useRef(0),nr=m.useRef(0),vn=m.useCallback(async()=>{var pe,$e;const K=++kn.current;O("");try{const Ce=await fetch("/api/flows");if(K!==kn.current)return;if(!Ce.ok)throw new Error("HTTP "+Ce.status);const et=await Ce.json();if(K!==kn.current)return;u(Array.isArray(et)?et:[])}catch(Ce){if(K!==kn.current)return;u([]),O(String(Ce.message||Ce))}try{const Ce=await fetch("/api/pipeline-recent-runs");if(K!==kn.current)return;if(Ce.ok){const et=await Ce.json();if(K!==kn.current)return;A(Array.isArray(et.runs)?et.runs:[])}else A([])}catch{if(K!==kn.current)return;A([])}if(t!=null&&t.isAdmin)try{const Ce=await fetch("/api/admin/builtin-flows");if(K!==kn.current)return;const et=await Ce.json().catch(()=>({}));Ce.ok&&At({hiddenBuiltins:Array.isArray((pe=et==null?void 0:et.config)==null?void 0:pe.hiddenBuiltins)?et.config.hiddenBuiltins:[],promoted:Array.isArray(($e=et==null?void 0:et.config)==null?void 0:$e.promoted)?et.config.promoted:[]})}catch{if(K!==kn.current)return;At({hiddenBuiltins:[],promoted:[]})}else At({hiddenBuiltins:[],promoted:[]});$(!0)},[t==null?void 0:t.isAdmin]),Jn=m.useCallback(async(K,pe)=>{if(!(t!=null&&t.isAdmin)||!(K!=null&&K.id))return;const $e=`${pe}:${K.source}:${K.id}`;Ze($e),O("");try{const Ce=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:pe,flowId:K.id,ownerUserId:K.ownerUserId||t.userId})}),et=await Ce.json().catch(()=>({}));if(!Ce.ok)throw new Error(et.error||"更新内置配置失败");await vn()}catch(Ce){O(String(Ce.message||Ce))}finally{Ze("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,vn]),Wn=m.useCallback(async()=>{const K=++nr.current;B(""),q(!1);const pe="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),k([]),le("");try{const[Ce,et,Sn,St]=await Promise.all([fetch(pe),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),Kt=await Ce.json().catch(()=>({})),Nn=await et.json().catch(()=>({})),mo=await Sn.json().catch(()=>({})),ot=await St.json().catch(()=>({}));if(!Ce.ok)throw new Error(Kt.error||"Nodes HTTP "+Ce.status);if(!et.ok)throw new Error(Nn.error||"Skills HTTP "+et.status);if(!Sn.ok)throw new Error(mo.error||"Collections HTTP "+Sn.status);if(!St.ok)throw new Error(ot.error||"Flow snippets HTTP "+St.status);if(K!==nr.current)return;f(Array.isArray(Kt.nodes)?Kt.nodes:Array.isArray(Kt)?Kt:[]),h(Array.isArray(Nn.skills)?Nn.skills:[]),y(La(mo)),k(Array.isArray(ot.snippets)?ot.snippets:[])}catch(Ce){if(K!==nr.current)return;f([]),h([]),k([]),y([]),B(String(Ce.message||Ce))}finally{if(K!==nr.current)return;q(!0)}},[e]);m.useEffect(()=>{$(!1),vn(),Wn()},[vn,Wn]),m.useEffect(()=>{try{localStorage.setItem(xP,se?"1":"0")}catch{}},[se]),m.useEffect(()=>{try{J?localStorage.setItem(wx,J):localStorage.removeItem(wx)}catch{}},[J]),m.useEffect(()=>{let K=!1;return fetch("/api/ui-context").then(pe=>pe.json()).then(pe=>{K||Ie(!!pe.hideCommunityLinks)}).catch(()=>{}),()=>{K=!0}},[]);const ur=m.useCallback(async K=>{if(!i)return;const pe=La({collections:K});N(!0),B("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(dF(pe))}),Ce=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ce.error||"Collections HTTP "+$e.status);y(La(Ce))}catch($e){B(String($e.message||$e))}finally{N(!1)}},[i]),gs=m.useCallback(()=>{if(!i)return;const K=v.trim();if(!K)return;const pe=K.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(b.map(St=>St.id));let Ce=pe,et=2;for(;$e.has(Ce);)Ce=`${pe}-${et++}`;const Sn=Date.now();ur([...b,{id:Ce,name:K,skillKeys:[],createdAt:Sn,updatedAt:Sn}]),x(""),re(`collection:${Ce}`)},[i,v,ur,b]),wr=m.useCallback(K=>{if(!i)return;const pe=b.find(Ce=>Ce.id===K);if(pe!=null&&pe.builtin)return;const $e=b.filter(Ce=>Ce.id!==K);ee===`collection:${K}`&&re("all"),ur($e)},[i,ee,ur,b]),Rs=m.useCallback((K,pe,$e)=>{if(!i)return;const Ce=String(pe||"").trim();if(!Ce)return;const et=Date.now(),Sn=b.map(St=>{if(St.id!==K)return St;const Kt=new Set(St.skillKeys||[]);return $e?Kt.add(Ce):Kt.delete(Ce),{...St,skillKeys:Array.from(Kt),updatedAt:et}});ur(Sn)},[i,ur,b]),Fr=m.useCallback(async K=>{const pe=K==null?void 0:K.packageId,$e=K==null?void 0:K.version;if(!pe||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:pe,version:$e})))return;const Ce=Bn(K);qe(Ce),Tt(""),B("");try{const et=new URLSearchParams({id:pe,version:$e}),Sn=await fetch(`/api/marketplace/node?${et.toString()}`,{method:"DELETE"}),St=await Sn.json().catch(()=>({}));if(!Sn.ok||(St==null?void 0:St.ok)===!1){const Kt=Array.isArray(St==null?void 0:St.usage)&&St.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:St.usage.length})}`:"";throw new Error(((St==null?void 0:St.error)||"Delete failed")+Kt)}Tt(n("project:deleteMyNodeSuccess",{id:pe,version:$e})),kt(Kt=>{const Nn={...Kt};return delete Nn[Ce],Nn}),Me(Kt=>{const Nn={};for(const[mo,ot]of Object.entries(Kt))mo.startsWith(`${Ce}:`)||(Nn[mo]=ot);return Nn}),le(""),await Wn()}catch(et){Tt(String(et.message||et))}finally{qe("")}},[Wn,n]),on=m.useCallback(async K=>{const pe=K==null?void 0:K.id,$e=(K==null?void 0:K.version)||"1.0.0";if(!pe||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:pe,version:$e})))return;const Ce=No(K);_t(Ce),tn(""),B("");try{const et=new URLSearchParams({id:pe,version:$e}),Sn=await fetch(`/api/marketplace/flow-snippet?${et.toString()}`,{method:"DELETE"}),St=await Sn.json().catch(()=>({}));if(!Sn.ok||(St==null?void 0:St.ok)===!1)throw new Error((St==null?void 0:St.error)||"Delete failed");tn(n("project:deleteMyFlowSuccess",{id:pe,version:$e})),le(""),await Wn()}catch(et){tn(String(et.message||et))}finally{_t("")}},[Wn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),re("all"),le(""),we("overview");return}l(K=>K==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const K=new URLSearchParams(window.location.search),pe=K.get("tab");let $e=!1;if(pe==="nodes"){r("/nodes");return}if(pe==="my-nodes"){r("/my-nodes");return}if(pe==="my-flows"){r("/my-flows");return}if(pe==="skills"){r("/skills");return}if(pe==="archived"?(l("archived"),K.delete("tab"),$e=!0):pe&&(l("all"),K.delete("tab"),$e=!0),K.get("new")==="1"&&(L(!0),K.delete("new"),$e=!0),$e){const Ce=K.toString();window.history.replaceState({},"",Ce?`/projects?${Ce}`:"/projects")}},[s,r]);const xr=m.useMemo(()=>CD(j,ND(),c),[j,c,s]),br=m.useMemo(()=>xr.filter(K=>NF(V,K)),[xr,V]),mn=V.trim().toLowerCase(),Vn=m.useMemo(()=>a==="archived"?c.filter(K=>K.archived):c.filter(K=>!K.archived),[c,a]),kr=m.useMemo(()=>Vn.filter(K=>SF(K,mn,n)),[Vn,mn,n]),dr=m.useMemo(()=>new Set((Mt.promoted||[]).map(K=>String((K==null?void 0:K.id)||"").trim()).filter(Boolean)),[Mt.promoted]),vt=m.useMemo(()=>(Mt.hiddenBuiltins||[]).map(K=>String(K||"").trim()).filter(Boolean),[Mt.hiddenBuiltins]),Ut=a==="nodes"||a==="my-nodes",ae=a==="my-nodes",ke=a==="my-flows",it=m.useMemo(()=>d.filter(K=>ae&&!AF(K,t)?!1:(ee==="all"||(ee==="marketplace"?K.source==="marketplace":K.type===ee))&&jy(V,[K.id,K.label,K.displayName,K.description,K.type,K.source,K.packageId,K.version])),[t,d,ae,V,ee]),bt=m.useMemo(()=>{const K=new Map;for(const pe of b)K.set(pe.id,new Set(Xo(pe,p)));return K},[p,b]),cn=m.useMemo(()=>[{id:"all",label:"全部"},...b.map(K=>{var pe;return{id:`collection:${K.id}`,label:K.name,count:((pe=bt.get(K.id))==null?void 0:pe.size)||0,collection:K}}),{id:"ungrouped",label:"未分组"}],[bt,b]),On=m.useMemo(()=>p.filter(K=>{var Ce;const pe=Bn(K);let $e=ee==="all";if(ee.startsWith("collection:")){const et=ee.slice(11);$e=!!((Ce=bt.get(et))!=null&&Ce.has(pe))}else ee==="ungrouped"&&($e=!Array.from(bt.values()).some(et=>et.has(pe)));return $e&&jy(V,[K.name,K.id,K.description,K.sourceLabel,K.source,K.path])}),[p,V,ee,bt]),nn=m.useMemo(()=>g.filter(K=>jy(V,[K.id,K.name,K.displayName,K.description,K.version,K.packageDir,Array.isArray(K.tags)?K.tags.join(" "):""])),[g,V]),vr=Ut||ke||a==="skills",ft=m.useMemo(()=>it.find(K=>Bn(K)===Z)||it[0]||null,[it,Z]),Yt=m.useMemo(()=>On.find(K=>Bn(K)===Z)||On[0]||null,[On,Z]),Gt=m.useMemo(()=>nn.find(K=>No(K)===Z)||nn[0]||null,[nn,Z]),Sr=Yt?De[Bn(Yt)]:null,tt=ft?mt[Bn(ft)]:null,Xn=ft&&gt?Fe[`${Bn(ft)}:${gt}`]:null,Mi=n(Ut?"project:searchNodes":ke?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!Yt)return;const K=Bn(Yt);if(De[K])return;let pe=!1;return st(K),fetch(`/api/skills/detail?key=${encodeURIComponent(K)}`).then($e=>$e.json().then(Ce=>({ok:$e.ok,json:Ce}))).then(({ok:$e,json:Ce})=>{pe||$e&&Ce.skill&&Qe(et=>({...et,[K]:Ce.skill}))}).catch(()=>{}).finally(()=>{pe||st("")}),()=>{pe=!0}},[a,Yt,De]),m.useEffect(()=>{if(!Ut||!ft)return;const K=Bn(ft);if(mt[K])return;let pe=!1;return dt(K),fetch(`/api/nodes/detail?id=${encodeURIComponent(ft.id)}`).then($e=>$e.json().then(Ce=>({ok:$e.ok,json:Ce}))).then(({ok:$e,json:Ce})=>{pe||$e&&kt(et=>({...et,[K]:Ce}))}).catch(()=>{}).finally(()=>{pe||dt("")}),()=>{pe=!0}},[Ut,ft,mt]),m.useEffect(()=>{if(!Ut)return;const K=Array.isArray(tt==null?void 0:tt.files)?tt.files:[];xe(pe=>{var $e;return pe&&K.some(Ce=>Ce.path===pe)?pe:(($e=K[0])==null?void 0:$e.path)||""})},[Ut,tt]),m.useEffect(()=>{if(!Ut||!ft||!gt)return;const K=`${Bn(ft)}:${gt}`;if(Fe[K])return;let pe=!1;return ve(K),fetch(`/api/nodes/file?id=${encodeURIComponent(ft.id)}&path=${encodeURIComponent(gt)}`).then($e=>$e.json().then(Ce=>({ok:$e.ok,json:Ce}))).then(({ok:$e,json:Ce})=>{pe||$e&&Me(et=>({...et,[K]:Ce}))}).catch(()=>{}).finally(()=>{pe||ve("")}),()=>{pe=!0}},[Ut,ft,gt,Fe]),m.useEffect(()=>{Tt("")},[Z,a]);const zr=K=>{r(up(K,"workspace"))},ho=K=>{ne(UN(K)),r(up({id:K.flowId,source:K.flowSource,archived:!!K.archived},"workspace"))},ai=m.useCallback(K=>{var pe,$e;K.preventDefault(),K.stopPropagation(),($e=(pe=K.dataTransfer)==null?void 0:pe.types)!=null&&$e.includes("Files")&&(tr.current+=1,Q(!0))},[]),Ts=m.useCallback(K=>{K.preventDefault(),K.stopPropagation(),tr.current-=1,tr.current<=0&&(tr.current=0,Q(!1))},[]),ie=m.useCallback(K=>{K.preventDefault(),K.stopPropagation()},[]),Se=m.useCallback(K=>{var Ce,et;K.preventDefault(),K.stopPropagation(),tr.current=0,Q(!1);const pe=(et=(Ce=K.dataTransfer)==null?void 0:Ce.files)==null?void 0:et[0];if(!pe)return;const $e=pe.name.toLowerCase();!$e.endsWith(".yaml")&&!$e.endsWith(".yml")&&!$e.endsWith(".zip")||W(pe)},[]);return o.jsxs("div",{className:"af-projects"+(E?" af-projects--drop-target":""),onDragEnter:ai,onDragLeave:Ts,onDragOver:ie,onDrop:Se,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:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),o.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),o.jsxs("div",{className:"af-projects-top-right",children:[o.jsxs("div",{className:"af-search-wrap",children:[o.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),o.jsx("input",{className:"af-search"+(V.trim()?" af-search--has-clear":""),type:"search",placeholder:Mi,"aria-label":Mi,autoComplete:"off",value:V,onChange:K=>F(K.target.value),onKeyDown:K=>{K.key==="Escape"&&(F(""),K.currentTarget.blur())}}),V.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>F(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),vr?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>Wn(),children:n("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(se?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":se,"aria-controls":"af-recent-activity-panel",onClick:()=>ce(K=>!K),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>L(!0),children:n("project:createNew")})]})]})]}),o.jsxs("div",{className:"af-projects-body",children:[o.jsxs("section",{className:"af-projects-main",children:[o.jsxs("header",{className:"af-projects-section-head",children:[o.jsx("h2",{className:"af-projects-h2",children:n(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:nodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:mn?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?it.length:a==="my-flows"?nn.length:a==="skills"?On.length:kr.length}):a==="my-nodes"?n("project:myNodesHint",{count:it.length}):a==="my-flows"?n("project:myFlowsHint",{count:nn.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:p.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),I?o.jsx("p",{className:"af-err af-projects-api-hint",children:I}):null,H&&vr?o.jsx("p",{className:"af-err af-projects-api-hint",children:H}):null]}),vr?o.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?o.jsx(uF,{onChanged:Wn,canManage:!!(t!=null&&t.isAdmin)}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:ke?"schema":Ut?ae?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(ke?"project:myFlowsPurposeTitle":ae?"project:myNodesPurposeTitle":Ut?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(ke?"project:myFlowsPurposeDesc":ae?"project:myNodesPurposeDesc":Ut?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),ke?null:o.jsxs(o.Fragment,{children:[Ut?o.jsxs("div",{className:"af-resource-filter-row",children:[o.jsx("button",{type:"button",className:"af-resource-filter"+(ae?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),re("all"),le("")},children:n("project:nodeScopeAll")}),o.jsx("button",{type:"button",className:"af-resource-filter"+(ae?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),re("all"),le("")},children:n("project:nodeScopeMine")})]}):null,o.jsx("div",{className:"af-resource-filter-row",children:(Ut?(ae?CF:jF).map(K=>({id:K,label:n(`project:resourceFilter.${K}`)})):cn).map(K=>K.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(ee===K.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{re(K.id),le("")},children:[K.label,o.jsx("em",{children:K.count}),K.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),i&&!K.collection.builtin?o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:C,"aria-label":`删除 ${K.collection.name}`,onClick:()=>wr(K.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},K.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(ee===K.id?" af-resource-filter--active":""),onClick:()=>{re(K.id),le("")},children:K.label},K.id))})]}),a==="skills"&&i?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:v,onChange:K=>x(K.target.value),onKeyDown:K=>{K.key==="Enter"&&gs()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!v.trim()||C,onClick:()=>gs(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Ut?o.jsx("div",{className:"af-resource-grid",children:it.length>0?it.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(ft&&Bn(K)===Bn(ft)?" af-resource-card--active":""),onClick:()=>le(Bn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:El(K.type==="control"?"secondary":K.type==="provide"?"primary":"muted"),children:o.jsx(zn,{query:V,children:K.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(zn,{query:V,children:KN(K.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(zn,{query:V,children:K.label||K.displayName||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(zn,{query:V,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(zn,{query:V,children:K.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(K.inputs||{}).length,outputs:Object.keys(K.outputs||{}).length})})]}),K.packageId?o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),o.jsx("span",{className:"af-path-text",children:o.jsx(zn,{query:V,children:`${K.packageId}${K.version?` / ${K.version}`:""}`})})]}):null]},`${K.id}:${K.source||""}:${K.packageId||""}`)):M?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:mn?n("project:noNodeMatch",{query:V.trim()}):n(ae?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):ke?o.jsx("div",{className:"af-resource-grid",children:nn.length>0?nn.map(K=>{const pe=bP(K),$e=kP(K),Ce=Number.isFinite(Number(K.nodeCount))?Number(K.nodeCount):pe.length,et=Number.isFinite(Number(K.edgeCount))?Number(K.edgeCount):$e.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(Gt&&No(K)===No(Gt)?" af-resource-card--active":""),onClick:()=>le(No(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:El("primary"),children:o.jsx(zn,{query:V,children:K.version?`v${K.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(zn,{query:V,children:K.displayName||K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(zn,{query:V,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ce,edges:et})}),o.jsx("span",{children:o.jsx(zn,{query:V,children:K.id})})]}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),o.jsx("span",{className:"af-path-text",children:o.jsx(zn,{query:V,children:qN(K)})})]})]},No(K))}):M?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:mn?n("project:noFlowSnippetMatch",{query:V.trim()}):n("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?o.jsx("div",{className:"af-resource-grid",children:On.length>0?On.map(K=>{const pe=Bn(K),$e=b.filter(Ce=>{var et;return(et=bt.get(Ce.id))==null?void 0:et.has(pe)});return o.jsxs("button",{type:"button",className:"af-resource-card"+(Yt&&pe===Bn(Yt)?" af-resource-card--active":""),onClick:()=>le(pe),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:El(K.source==="builtin"?"muted":"primary"),children:o.jsx(zn,{query:V,children:K.sourceLabel||K.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(zn,{query:V,children:K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(zn,{query:V,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),o.jsx("span",{className:"af-path-text",children:o.jsx(zn,{query:V,children:K.path||K.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[$e.slice(0,3).map(Ce=>o.jsx("span",{children:Ce.name},Ce.id)),$e.length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},K.key||`${K.source}:${K.name}`)}):M?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:mn?n("project:noSkillMatch",{query:V.trim()}):n("project:noSkills")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):o.jsxs(o.Fragment,{children:[t!=null&&t.isAdmin&&a==="all"&&vt.length>0?o.jsxs("div",{className:"af-project-admin-panel",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"已隐藏内置"}),o.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),o.jsx("div",{className:"af-project-admin-hidden-list",children:vt.map(K=>{const pe=Ue===`show-builtin:builtin:${K}`;return o.jsxs("button",{type:"button",disabled:pe,onClick:()=>Jn({id:K,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:K}),o.jsx("em",{children:pe?"恢复中":"恢复"})]},K)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[kr.length>0?kr.map(K=>{var Sn,St;const pe=(t==null?void 0:t.isAdmin)&&K.source==="user"&&!K.archived&&!dr.has(K.id),$e=(t==null?void 0:t.isAdmin)&&K.source==="admin",Ce=(t==null?void 0:t.isAdmin)&&K.source==="builtin",et=Ue.endsWith(`:${K.source}:${K.id}`);return o.jsx("div",{className:wF(K.source),role:"button",tabIndex:0,onClick:()=>zr(K),onKeyDown:Kt=>{(Kt.key==="Enter"||Kt.key===" ")&&(Kt.preventDefault(),zr(K))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:El(yx(K.source,n).tone),children:o.jsx(zn,{query:V,children:yx(K.source,n).label})}),K.source==="workspace"&&((Sn=K.collaboration)!=null&&Sn.role)?o.jsx("span",{className:El(K.collaboration.role==="owner"?"primary":"muted"),children:K.collaboration.role==="owner"?"我创建的":`${K.collaboration.ownerUsername||K.collaboration.ownerId} 分享`}):null,K.archived?o.jsx("span",{className:El("muted"),children:o.jsx(zn,{query:V,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(zn,{query:V,children:K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(zn,{query:V,children:wP(K,n)})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),o.jsx("span",{className:"af-path-text",children:o.jsx(zn,{query:V,children:yP(K)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Kt=>Kt.stopPropagation(),onKeyDown:Kt=>Kt.stopPropagation(),children:[pe?o.jsx("button",{type:"button",disabled:et,onClick:()=>Jn(K,"promote"),children:"设为内置"}):null,$e?o.jsx("button",{type:"button",disabled:et,onClick:()=>Jn(K,"unpromote"),children:"取消内置"}):null,Ce?o.jsx("button",{type:"button",disabled:et,onClick:()=>Jn(K,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${K.id}:${K.source??"user"}:${K.archived?"a":""}:${((St=K.collaboration)==null?void 0:St.id)||"own"}`)}):z?Vn.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):c.length>0?n("project:noActive"):n(I?"project:loadFailed":"project:noPipelines")}),!I&&c.length===0&&a==="all"?o.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:V.trim()})})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),o.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>L(!0),children:[o.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),o.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),te?null:o.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[o.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),o.jsxs("span",{className:"af-hub-card__eyebrow",children:[o.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),o.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),o.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),o.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),o.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),o.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),vr?o.jsx("aside",{className:"af-resource-detail","aria-label":n(Ut?"project:nodeDetail":ke?"project:flowDetail":"project:skillDetail"),children:Ut&&ft?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:ft.label||ft.displayName||ft.id}),o.jsx("p",{children:ft.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(K=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(de===K?" af-resource-detail-tab--active":""),onClick:()=>we(K),children:n(`project:nodeDetailTabs.${K}`)},K))}),Pe===Bn(ft)?o.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):de==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:ft.description||((Ee=tt==null?void 0:tt.node)==null?void 0:Ee.description)||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailType")}),o.jsx("dd",{children:ft.type||((wt=tt==null?void 0:tt.node)==null?void 0:wt.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:KN(ft.source,n)})]}),ft.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPackage")}),o.jsx("dd",{children:ft.packageId})]}):null,ft.version?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:ft.version})]}):null,ft.packageDir||tt!=null&&tt.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:ft.packageDir||(tt==null?void 0:tt.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(tt==null?void 0:tt.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),ae&&ft.source==="marketplace"?o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myNodeManagement")}),o.jsx("p",{children:n("project:deleteMyNodeHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Ve===Bn(ft),onClick:()=>Fr(ft),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ve===Bn(ft)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),be?o.jsx("p",{className:"af-resource-action-message",children:be}):null]}):null,o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:nodesMeaning")})]})]}):de==="schema"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeSchema")}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeInputs")}),dp(((Ot=tt==null?void 0:tt.node)==null?void 0:Ot.inputs)||ft.inputs).length>0?dp(((Vt=tt==null?void 0:tt.node)==null?void 0:Vt.inputs)||ft.inputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),dp(((Dn=tt==null?void 0:tt.node)==null?void 0:Dn.outputs)||ft.outputs).length>0?dp(((Mn=tt==null?void 0:tt.node)==null?void 0:Mn.outputs)||ft.outputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]})]}):de==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeRuntime")}),tt!=null&&tt.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(tt.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),tt!=null&&tt.body?o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),o.jsx("pre",{className:"af-resource-skill-preview",children:tt.body})]}):o.jsx("p",{children:n("project:noNodeBody")})]}):de==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(tt==null?void 0:tt.files)&&tt.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:tt.files.map(K=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(gt===K.path?" af-node-file-item--active":""),onClick:()=>xe(K.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:K.path})]},K.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[ue===`${Bn(ft)}:${gt}`?n("project:loadingResources"):Xn!=null&&Xn.binary?n("project:binaryFile"):(Xn==null?void 0:Xn.content)||n("project:selectNodeFile"),Xn!=null&&Xn.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFiles")})]}):o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(tt==null?void 0:tt.usage)&&tt.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:tt.usage.map(K=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:K.flowId}),o.jsxs("span",{children:[K.flowSource,K.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:K.instances.map(pe=>pe.label||pe.instanceId).join(", ")})]},`${K.flowSource}:${K.flowId}:${K.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):ke&&Gt?(()=>{const K=MF(Gt);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"schema"}),o.jsxs("div",{children:[o.jsx("h3",{children:Gt.displayName||Gt.name||Gt.id}),o.jsx("p",{children:Gt.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Gt.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:Gt.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:qN(Gt)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Gt.nodeCount))?Number(Gt.nodeCount):K.nodes.length,edges:Number.isFinite(Number(Gt.edgeCount))?Number(Gt.edgeCount):K.edges.length})})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:myFlowsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myFlowManagement")}),o.jsx("p",{children:n("project:deleteMyFlowHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:ln===No(Gt),onClick:()=>on(Gt),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),ln===No(Gt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),hn?o.jsx("p",{className:"af-resource-action-message",children:hn}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),K.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:K.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:o.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),o.jsx("g",{className:"af-flow-snippet-map__edges",children:K.diagram.edges.map(pe=>o.jsxs("g",{children:[o.jsx("path",{d:pe.path}),pe.label?o.jsx("text",{x:pe.labelX,y:pe.labelY-5,textAnchor:"middle",children:Cy(pe.label,18)}):null]},pe.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:K.diagram.nodes.map((pe,$e)=>o.jsxs("g",{transform:`translate(${pe.x} ${pe.y})`,children:[o.jsx("rect",{width:pe.width,height:pe.height,rx:"10"}),o.jsx("circle",{cx:"19",cy:pe.height/2,r:"12"}),o.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:pe.height/2+4,textAnchor:"middle",children:$e+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:pe.height/2-3,children:Cy(pe.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:pe.height/2+16,children:Cy(pe.meta||pe.id,20)})]},pe.id))})]})}):o.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),o.jsxs("details",{className:"af-flow-snippet-json",children:[o.jsx("summary",{children:n("project:flowSnippetJson")}),o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Gt.snippet||{},null,2)})]})]})]})})():a==="skills"&&Yt?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:Yt.name||Yt.id}),o.jsx("p",{children:Yt.sourceLabel||Yt.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Yt.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:Yt.sourceLabel||Yt.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Yt.path||Yt.key})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:"Collections"}),b.length===0?o.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):o.jsx("div",{className:"af-skill-detail-collections",children:b.map(K=>{const pe=Bn(Yt),$e=bt.get(K.id)||new Set,Ce=$e.has(pe);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Ce,disabled:C||!i,onChange:et=>Rs(K.id,pe,et.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:K.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},K.id)})})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:skillsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:skillPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:Oe===Bn(Yt)?n("project:loadingResources"):(Sr==null?void 0:Sr.body)||(Sr==null?void 0:Sr.content)||n("project:skillPreviewEmpty")})]})]}):o.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):o.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(se?"":" af-activity--hidden"),"aria-hidden":!se,"aria-label":n("project:recentActivity"),children:[o.jsxs("h2",{className:"af-activity-title",children:[o.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),o.jsx("div",{className:"af-activity-list",children:br.length===0?o.jsx("p",{className:"af-activity-empty",children:xr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):br.map(K=>{const pe=J===UN(K);return o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(pe?" af-activity-row--active":""),"aria-current":pe?"page":void 0,onClick:()=>ho(K),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(zn,{query:V,children:K.flowId})}),o.jsx("span",{className:"af-activity-time",children:WN(K.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:xF(K.kind),children:K.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[K.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",WN(K.at,n)]})]})]},`${K.kind}-${K.flowId}-${K.flowSource}-${K.at}`)})})]})]}),o.jsx(tF,{open:D,onClose:()=>L(!1),onCreated:async K=>{L(!1),await vn();const pe=K.source??"user";r(up({id:K.id,source:pe},"workspace"))}}),T?o.jsx(ZD,{file:T,onClose:()=>W(null),onImported:async K=>{W(null),await vn();const pe=K.source??"user";r(up({id:K.id,source:pe},"workspace"))}},`${T.name}-${T.size}-${T.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 $F={value:()=>{}};function Dm(){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 Zp(n)}function Zp(e){this._=e}function LF(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}})}Zp.prototype=Dm.prototype={constructor:Zp,on:function(e,t){var n=this._,r=LF(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=OF(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]=JN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=JN(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 Zp(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 OF(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function JN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=$F,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var bx="http://www.w3.org/1999/xhtml";const XN={svg:"http://www.w3.org/2000/svg",xhtml:bx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),XN.hasOwnProperty(t)?{space:XN[t],local:e}:e}function DF(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===bx&&t.documentElement.namespaceURI===bx?t.createElement(e):t.createElementNS(n,e)}}function FF(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function vP(e){var t=Fm(e);return(t.local?FF:DF)(t)}function zF(){}function mk(e){return e==null?zF:function(){return this.querySelector(e)}}function BF(e){typeof e!="function"&&(e=mk(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,u,d=0;d<a;++d)(c=i[d])&&(u=e.call(c,c.__data__,d,i))&&("__data__"in c&&(u.__data__=c.__data__),l[d]=u);return new ps(r,this._parents)}function HF(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function WF(){return[]}function SP(e){return e==null?WF:function(){return this.querySelectorAll(e)}}function VF(e){return function(){return HF(e.apply(this,arguments))}}function KF(e){typeof e=="function"?e=VF(e):e=SP(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,u=0;u<l;++u)(c=a[u])&&(r.push(e.call(c,c.__data__,u,a)),s.push(c));return new ps(r,s)}function NP(e){return function(){return this.matches(e)}}function jP(e){return function(t){return t.matches(e)}}var qF=Array.prototype.find;function UF(e){return function(){return qF.call(this.children,e)}}function YF(){return this.firstElementChild}function GF(e){return this.select(e==null?YF:UF(typeof e=="function"?e:jP(e)))}var JF=Array.prototype.filter;function XF(){return Array.from(this.children)}function QF(e){return function(){return JF.call(this.children,e)}}function ZF(e){return this.selectAll(e==null?XF:QF(typeof e=="function"?e:jP(e)))}function ez(e){typeof e!="function"&&(e=NP(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,u=0;u<a;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&l.push(c);return new ps(r,this._parents)}function CP(e){return new Array(e.length)}function tz(){return new ps(this._enter||this._groups.map(CP),this._parents)}function Dh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Dh.prototype={constructor:Dh,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 nz(e){return function(){return e}}function rz(e,t,n,r,s,i){for(var a=0,l,c=t.length,u=i.length;a<u;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Dh(e,i[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function sz(e,t,n,r,s,i,a){var l,c,u=new Map,d=t.length,f=i.length,p=new Array(d),h;for(l=0;l<d;++l)(c=t[l])&&(p[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?s[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,i[l],l,i)+"",(c=u.get(h))?(r[l]=c,c.__data__=i[l],u.delete(h)):n[l]=new Dh(e,i[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function iz(e){return e.__data__}function oz(e,t){if(!arguments.length)return Array.from(this,iz);var n=t?sz:rz,r=this._parents,s=this._groups;typeof e!="function"&&(e=nz(e));for(var i=s.length,a=new Array(i),l=new Array(i),c=new Array(i),u=0;u<i;++u){var d=r[u],f=s[u],p=f.length,h=az(e.call(d,d&&d.__data__,u,r)),g=h.length,k=l[u]=new Array(g),b=a[u]=new Array(g),y=c[u]=new Array(p);n(d,f,k,b,y,h,t);for(var v=0,x=0,C,N;v<g;++v)if(C=k[v]){for(v>=x&&(x=v+1);!(N=b[x])&&++x<g;);C._next=N||null}}return a=new ps(a,r),a._enter=l,a._exit=c,a}function az(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function lz(){return new ps(this._exit||this._groups.map(CP),this._parents)}function cz(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 uz(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 u=n[c],d=r[c],f=u.length,p=l[c]=new Array(f),h,g=0;g<f;++g)(h=u[g]||d[g])&&(p[g]=h);for(;c<s;++c)l[c]=n[c];return new ps(l,this._parents)}function dz(){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 fz(e){e||(e=pz);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),u,d=0;d<l;++d)(u=a[d])&&(c[d]=u);c.sort(t)}return new ps(s,this._parents).order()}function pz(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function hz(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function mz(){return Array.from(this)}function gz(){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 yz(){let e=0;for(const t of this)++e;return e}function wz(){return!this.node()}function xz(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 bz(e){return function(){this.removeAttribute(e)}}function kz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function vz(e,t){return function(){this.setAttribute(e,t)}}function Sz(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Nz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function jz(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 Cz(e,t){var n=Fm(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?kz:bz:typeof t=="function"?n.local?jz:Nz:n.local?Sz:vz)(n,t))}function _P(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function _z(e){return function(){this.style.removeProperty(e)}}function Ez(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Az(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Pz(e,t,n){return arguments.length>1?this.each((t==null?_z:typeof t=="function"?Az:Ez)(e,t,n??"")):Sc(this.node(),e)}function Sc(e,t){return e.style.getPropertyValue(t)||_P(e).getComputedStyle(e,null).getPropertyValue(t)}function Iz(e){return function(){delete this[e]}}function Rz(e,t){return function(){this[e]=t}}function Tz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Mz(e,t){return arguments.length>1?this.each((t==null?Iz:typeof t=="function"?Tz:Rz)(e,t)):this.node()[e]}function EP(e){return e.trim().split(/^|\s+/)}function gk(e){return e.classList||new AP(e)}function AP(e){this._node=e,this._names=EP(e.getAttribute("class")||"")}AP.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 PP(e,t){for(var n=gk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function IP(e,t){for(var n=gk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function $z(e){return function(){PP(this,e)}}function Lz(e){return function(){IP(this,e)}}function Oz(e,t){return function(){(t.apply(this,arguments)?PP:IP)(this,e)}}function Dz(e,t){var n=EP(e+"");if(arguments.length<2){for(var r=gk(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?Oz:t?$z:Lz)(n,t))}function Fz(){this.textContent=""}function zz(e){return function(){this.textContent=e}}function Bz(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Hz(e){return arguments.length?this.each(e==null?Fz:(typeof e=="function"?Bz:zz)(e)):this.node().textContent}function Wz(){this.innerHTML=""}function Vz(e){return function(){this.innerHTML=e}}function Kz(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function qz(e){return arguments.length?this.each(e==null?Wz:(typeof e=="function"?Kz:Vz)(e)):this.node().innerHTML}function Uz(){this.nextSibling&&this.parentNode.appendChild(this)}function Yz(){return this.each(Uz)}function Gz(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Jz(){return this.each(Gz)}function Xz(e){var t=typeof e=="function"?e:vP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Qz(){return null}function Zz(e,t){var n=typeof e=="function"?e:vP(e),r=t==null?Qz:typeof t=="function"?t:mk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function e3(){var e=this.parentNode;e&&e.removeChild(this)}function t3(){return this.each(e3)}function n3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function r3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function s3(e){return this.select(e?r3:n3)}function i3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function o3(e){return function(t){e.call(this,t,this.__data__)}}function a3(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 l3(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 c3(e,t,n){return function(){var r=this.__on,s,i=o3(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 u3(e,t,n){var r=a3(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,d;c<u;++c)for(s=0,d=l[c];s<i;++s)if((a=r[s]).type===d.type&&a.name===d.name)return d.value}return}for(l=t?c3:l3,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function RP(e,t,n){var r=_P(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 d3(e,t){return function(){return RP(this,e,t)}}function f3(e,t){return function(){return RP(this,e,t.apply(this,arguments))}}function p3(e,t){return this.each((typeof t=="function"?f3:d3)(e,t))}function*h3(){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 TP=[null];function ps(e,t){this._groups=e,this._parents=t}function rf(){return new ps([[document.documentElement]],TP)}function m3(){return this}ps.prototype=rf.prototype={constructor:ps,select:BF,selectAll:KF,selectChild:GF,selectChildren:ZF,filter:ez,data:oz,enter:tz,exit:lz,join:cz,merge:uz,selection:m3,order:dz,sort:fz,call:hz,nodes:mz,node:gz,size:yz,empty:wz,each:xz,attr:Cz,style:Pz,property:Mz,classed:Dz,text:Hz,html:qz,raise:Yz,lower:Jz,append:Xz,insert:Zz,remove:t3,clone:s3,datum:i3,on:u3,dispatch:p3,[Symbol.iterator]:h3};function as(e){return typeof e=="string"?new ps([[document.querySelector(e)]],[document.documentElement]):new ps([[e]],TP)}function g3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function qs(e,t){if(e=g3(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 y3={passive:!1},Ed={capture:!0,passive:!1};function _y(e){e.stopImmediatePropagation()}function lc(e){e.preventDefault(),e.stopImmediatePropagation()}function MP(e){var t=e.document.documentElement,n=as(e).on("dragstart.drag",lc,Ed);"onselectstart"in t?n.on("selectstart.drag",lc,Ed):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function $P(e,t){var n=e.document.documentElement,r=as(e).on("dragstart.drag",null);t&&(r.on("click.drag",lc,Ed),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 fp=e=>()=>e;function kx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value: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:u,enumerable:!0,configurable:!0},_:{value:d}})}kx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function w3(e){return!e.ctrlKey&&!e.button}function x3(){return this.parentNode}function b3(e,t){return t??{x:e.x,y:e.y}}function k3(){return navigator.maxTouchPoints||"ontouchstart"in this}function LP(){var e=w3,t=x3,n=b3,r=k3,s={},i=Dm("start","drag","end"),a=0,l,c,u,d,f=0;function p(C){C.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",y,y3).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(C,N){if(!(d||!e.call(this,C,N))){var j=x(this,t.call(this,C,N),C,N,"mouse");j&&(as(C.view).on("mousemove.drag",g,Ed).on("mouseup.drag",k,Ed),MP(C.view),_y(C),u=!1,l=C.clientX,c=C.clientY,j("start",C))}}function g(C){if(lc(C),!u){var N=C.clientX-l,j=C.clientY-c;u=N*N+j*j>f}s.mouse("drag",C)}function k(C){as(C.view).on("mousemove.drag mouseup.drag",null),$P(C.view,u),lc(C),s.mouse("end",C)}function b(C,N){if(e.call(this,C,N)){var j=C.changedTouches,A=t.call(this,C,N),I=j.length,O,H;for(O=0;O<I;++O)(H=x(this,A,C,N,j[O].identifier,j[O]))&&(_y(C),H("start",C,j[O]))}}function y(C){var N=C.changedTouches,j=N.length,A,I;for(A=0;A<j;++A)(I=s[N[A].identifier])&&(lc(C),I("drag",C,N[A]))}function v(C){var N=C.changedTouches,j=N.length,A,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),A=0;A<j;++A)(I=s[N[A].identifier])&&(_y(C),I("end",C,N[A]))}function x(C,N,j,A,I,O){var H=i.copy(),B=qs(O||j,N),z,$,M;if((M=n.call(C,new kx("beforestart",{sourceEvent:j,target:p,identifier:I,active:a,x:B[0],y:B[1],dx:0,dy:0,dispatch:H}),A))!=null)return z=M.x-B[0]||0,$=M.y-B[1]||0,function q(D,L,T){var W=B,E;switch(D){case"start":s[I]=q,E=a++;break;case"end":delete s[I],--a;case"drag":B=qs(T||L,N),E=a;break}H.call(D,C,new kx(D,{sourceEvent:L,subject:M,target:p,identifier:I,active:E,x:B[0]+z,y:B[1]+$,dx:B[0]-W[0],dy:B[1]-W[1],dispatch:H}),A)}}return p.filter=function(C){return arguments.length?(e=typeof C=="function"?C:fp(!!C),p):e},p.container=function(C){return arguments.length?(t=typeof C=="function"?C:fp(C),p):t},p.subject=function(C){return arguments.length?(n=typeof C=="function"?C:fp(C),p):n},p.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:fp(!!C),p):r},p.on=function(){var C=i.on.apply(i,arguments);return C===i?p:C},p.clickDistance=function(C){return arguments.length?(f=(C=+C)*C,p):Math.sqrt(f)},p}function yk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function OP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function sf(){}var Ad=.7,Fh=1/Ad,cc="\\s*([+-]?\\d+)\\s*",Pd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ji="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",v3=/^#([0-9a-f]{3,8})$/,S3=new RegExp(`^rgb\\(${cc},${cc},${cc}\\)$`),N3=new RegExp(`^rgb\\(${ji},${ji},${ji}\\)$`),j3=new RegExp(`^rgba\\(${cc},${cc},${cc},${Pd}\\)$`),C3=new RegExp(`^rgba\\(${ji},${ji},${ji},${Pd}\\)$`),_3=new RegExp(`^hsl\\(${Pd},${ji},${ji}\\)$`),E3=new RegExp(`^hsla\\(${Pd},${ji},${ji},${Pd}\\)$`),QN={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};yk(sf,qa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ZN,formatHex:ZN,formatHex8:A3,formatHsl:P3,formatRgb:ej,toString:ej});function ZN(){return this.rgb().formatHex()}function A3(){return this.rgb().formatHex8()}function P3(){return DP(this).formatHsl()}function ej(){return this.rgb().formatRgb()}function qa(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=v3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?tj(t):n===3?new Yr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?pp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?pp(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=S3.exec(e))?new Yr(t[1],t[2],t[3],1):(t=N3.exec(e))?new Yr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=j3.exec(e))?pp(t[1],t[2],t[3],t[4]):(t=C3.exec(e))?pp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_3.exec(e))?sj(t[1],t[2]/100,t[3]/100,1):(t=E3.exec(e))?sj(t[1],t[2]/100,t[3]/100,t[4]):QN.hasOwnProperty(e)?tj(QN[e]):e==="transparent"?new Yr(NaN,NaN,NaN,0):null}function tj(e){return new Yr(e>>16&255,e>>8&255,e&255,1)}function pp(e,t,n,r){return r<=0&&(e=t=n=NaN),new Yr(e,t,n,r)}function I3(e){return e instanceof sf||(e=qa(e)),e?(e=e.rgb(),new Yr(e.r,e.g,e.b,e.opacity)):new Yr}function vx(e,t,n,r){return arguments.length===1?I3(e):new Yr(e,t,n,r??1)}function Yr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yk(Yr,vx,OP(sf,{brighter(e){return e=e==null?Fh:Math.pow(Fh,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ad:Math.pow(Ad,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Yr(Oa(this.r),Oa(this.g),Oa(this.b),zh(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:nj,formatHex:nj,formatHex8:R3,formatRgb:rj,toString:rj}));function nj(){return`#${Ia(this.r)}${Ia(this.g)}${Ia(this.b)}`}function R3(){return`#${Ia(this.r)}${Ia(this.g)}${Ia(this.b)}${Ia((isNaN(this.opacity)?1:this.opacity)*255)}`}function rj(){const e=zh(this.opacity);return`${e===1?"rgb(":"rgba("}${Oa(this.r)}, ${Oa(this.g)}, ${Oa(this.b)}${e===1?")":`, ${e})`}`}function zh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Oa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ia(e){return e=Oa(e),(e<16?"0":"")+e.toString(16)}function sj(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Gs(e,t,n,r)}function DP(e){if(e instanceof Gs)return new Gs(e.h,e.s,e.l,e.opacity);if(e instanceof sf||(e=qa(e)),!e)return new Gs;if(e instanceof Gs)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 Gs(a,l,c,e.opacity)}function T3(e,t,n,r){return arguments.length===1?DP(e):new Gs(e,t,n,r??1)}function Gs(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}yk(Gs,T3,OP(sf,{brighter(e){return e=e==null?Fh:Math.pow(Fh,e),new Gs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ad:Math.pow(Ad,e),new Gs(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Yr(Ey(e>=240?e-240:e+120,s,r),Ey(e,s,r),Ey(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Gs(ij(this.h),hp(this.s),hp(this.l),zh(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=zh(this.opacity);return`${e===1?"hsl(":"hsla("}${ij(this.h)}, ${hp(this.s)*100}%, ${hp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ij(e){return e=(e||0)%360,e<0?e+360:e}function hp(e){return Math.max(0,Math.min(1,e||0))}function Ey(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 wk=e=>()=>e;function M3(e,t){return function(n){return e+n*t}}function $3(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 L3(e){return(e=+e)==1?FP:function(t,n){return n-t?$3(t,n,e):wk(isNaN(t)?n:t)}}function FP(e,t){var n=t-e;return n?M3(e,n):wk(isNaN(e)?t:e)}const Bh=function e(t){var n=L3(t);function r(s,i){var a=n((s=vx(s)).r,(i=vx(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),u=FP(s.opacity,i.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function O3(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 D3(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function F3(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]=nd(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 z3(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function mi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function B3(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]=nd(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Sx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ay=new RegExp(Sx.source,"g");function H3(e){return function(){return e}}function W3(e){return function(t){return e(t)+""}}function zP(e,t){var n=Sx.lastIndex=Ay.lastIndex=0,r,s,i,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Sx.exec(e))&&(s=Ay.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:mi(r,s)})),n=Ay.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?W3(c[0].x):H3(t):(t=c.length,function(u){for(var d=0,f;d<t;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function nd(e,t){var n=typeof t,r;return t==null||n==="boolean"?wk(t):(n==="number"?mi:n==="string"?(r=qa(t))?(t=r,Bh):zP:t instanceof qa?Bh:t instanceof Date?z3:D3(t)?O3:Array.isArray(t)?F3:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?B3:mi)(e,t)}var oj=180/Math.PI,Nx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function BP(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)*oj,skewX:Math.atan(c)*oj,scaleX:a,scaleY:l}}var mp;function V3(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Nx:BP(t.a,t.b,t.c,t.d,t.e,t.f)}function K3(e){return e==null||(mp||(mp=document.createElementNS("http://www.w3.org/2000/svg","g")),mp.setAttribute("transform",e),!(e=mp.transform.baseVal.consolidate()))?Nx:(e=e.matrix,BP(e.a,e.b,e.c,e.d,e.e,e.f))}function HP(e,t,n,r){function s(u){return u.length?u.pop()+" ":""}function i(u,d,f,p,h,g){if(u!==f||d!==p){var k=h.push("translate(",null,t,null,n);g.push({i:k-4,x:mi(u,f)},{i:k-2,x:mi(d,p)})}else(f||p)&&h.push("translate("+f+t+p+n)}function a(u,d,f,p){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),p.push({i:f.push(s(f)+"rotate(",null,r)-2,x:mi(u,d)})):d&&f.push(s(f)+"rotate("+d+r)}function l(u,d,f,p){u!==d?p.push({i:f.push(s(f)+"skewX(",null,r)-2,x:mi(u,d)}):d&&f.push(s(f)+"skewX("+d+r)}function c(u,d,f,p,h,g){if(u!==f||d!==p){var k=h.push(s(h)+"scale(",null,",",null,")");g.push({i:k-4,x:mi(u,f)},{i:k-2,x:mi(d,p)})}else(f!==1||p!==1)&&h.push(s(h)+"scale("+f+","+p+")")}return function(u,d){var f=[],p=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,f,p),a(u.rotate,d.rotate,f,p),l(u.skewX,d.skewX,f,p),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,f,p),u=d=null,function(h){for(var g=-1,k=p.length,b;++g<k;)f[(b=p[g]).i]=b.x(h);return f.join("")}}}var q3=HP(V3,"px, ","px)","deg)"),U3=HP(K3,", ",")",")"),Y3=1e-12;function aj(e){return((e=Math.exp(e))+1/e)/2}function G3(e){return((e=Math.exp(e))-1/e)/2}function J3(e){return((e=Math.exp(2*e))-1)/(e+1)}const eh=function e(t,n,r){function s(i,a){var l=i[0],c=i[1],u=i[2],d=a[0],f=a[1],p=a[2],h=d-l,g=f-c,k=h*h+g*g,b,y;if(k<Y3)y=Math.log(p/u)/t,b=function(A){return[l+A*h,c+A*g,u*Math.exp(t*A*y)]};else{var v=Math.sqrt(k),x=(p*p-u*u+r*k)/(2*u*n*v),C=(p*p-u*u-r*k)/(2*p*n*v),N=Math.log(Math.sqrt(x*x+1)-x),j=Math.log(Math.sqrt(C*C+1)-C);y=(j-N)/t,b=function(A){var I=A*y,O=aj(N),H=u/(n*v)*(O*J3(t*I+N)-G3(N));return[l+H*h,c+H*g,u*O/aj(t*I+N)]}}return b.duration=y*1e3*t/Math.SQRT2,b}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 Nc=0,Du=0,Su=0,WP=1e3,Hh,Fu,Wh=0,Ua=0,zm=0,Id=typeof performance=="object"&&performance.now?performance:Date,VP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function xk(){return Ua||(VP(X3),Ua=Id.now()+zm)}function X3(){Ua=0}function Vh(){this._call=this._time=this._next=null}Vh.prototype=KP.prototype={constructor:Vh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?xk():+n)+(t==null?0:+t),!this._next&&Fu!==this&&(Fu?Fu._next=this:Hh=this,Fu=this),this._call=e,this._time=n,jx()},stop:function(){this._call&&(this._call=null,this._time=1/0,jx())}};function KP(e,t,n){var r=new Vh;return r.restart(e,t,n),r}function Q3(){xk(),++Nc;for(var e=Hh,t;e;)(t=Ua-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nc}function lj(){Ua=(Wh=Id.now())+zm,Nc=Du=0;try{Q3()}finally{Nc=0,eB(),Ua=0}}function Z3(){var e=Id.now(),t=e-Wh;t>WP&&(zm-=t,Wh=e)}function eB(){for(var e,t=Hh,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:Hh=n);Fu=e,jx(r)}function jx(e){if(!Nc){Du&&(Du=clearTimeout(Du));var t=e-Ua;t>24?(e<1/0&&(Du=setTimeout(lj,e-Id.now()-zm)),Su&&(Su=clearInterval(Su))):(Su||(Wh=Id.now(),Su=setInterval(Z3,WP)),Nc=1,VP(lj))}}function cj(e,t,n){var r=new Vh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var tB=Dm("start","end","cancel","interrupt"),nB=[],qP=0,uj=1,Cx=2,th=3,dj=4,_x=5,nh=6;function Bm(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;rB(e,n,{name:t,index:r,group:s,on:tB,tween:nB,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:qP})}function bk(e,t){var n=ii(e,t);if(n.state>qP)throw new Error("too late; already scheduled");return n}function Ri(e,t){var n=ii(e,t);if(n.state>th)throw new Error("too late; already running");return n}function ii(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function rB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=KP(i,0,n.time);function i(u){n.state=uj,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,f,p,h;if(n.state!==uj)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===th)return cj(a);h.state===dj?(h.state=nh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=nh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(cj(function(){n.state===th&&(n.state=dj,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Cx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Cx){for(n.state=th,s=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++f]=h);s.length=f+1}}function l(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=_x,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===_x&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=nh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function rh(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>Cx&&r.state<_x,r.state=nh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function sB(e){return this.each(function(){rh(this,e)})}function iB(e,t){var n,r;return function(){var s=Ri(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 oB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=Ri(this,e),a=i.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},c=0,u=s.length;c<u;++c)if(s[c].name===t){s[c]=l;break}c===u&&s.push(l)}i.tween=s}}function aB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ii(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?iB:oB)(n,e,t))}function kk(e,t,n){var r=e._id;return e.each(function(){var s=Ri(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return ii(s,r).value[t]}}function UP(e,t){var n;return(typeof t=="number"?mi:t instanceof qa?Bh:(n=qa(t))?(t=n,Bh):zP)(e,t)}function lB(e){return function(){this.removeAttribute(e)}}function cB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uB(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 dB(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 fB(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 pB(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 hB(e,t){var n=Fm(e),r=n==="transform"?U3:UP;return this.attrTween(e,typeof t=="function"?(n.local?pB:fB)(n,r,kk(this,"attr."+e,t)):t==null?(n.local?cB:lB)(n):(n.local?dB:uB)(n,r,t))}function mB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function yB(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&gB(e,i)),n}return s._value=t,s}function wB(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&mB(e,i)),n}return s._value=t,s}function xB(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=Fm(e);return this.tween(n,(r.local?yB:wB)(r,t))}function bB(e,t){return function(){bk(this,e).delay=+t.apply(this,arguments)}}function kB(e,t){return t=+t,function(){bk(this,e).delay=t}}function vB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bB:kB)(t,e)):ii(this.node(),t).delay}function SB(e,t){return function(){Ri(this,e).duration=+t.apply(this,arguments)}}function NB(e,t){return t=+t,function(){Ri(this,e).duration=t}}function jB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?SB:NB)(t,e)):ii(this.node(),t).duration}function CB(e,t){if(typeof t!="function")throw new Error;return function(){Ri(this,e).ease=t}}function _B(e){var t=this._id;return arguments.length?this.each(CB(t,e)):ii(this.node(),t).ease}function EB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ri(this,e).ease=n}}function AB(e){if(typeof e!="function")throw new Error;return this.each(EB(this._id,e))}function PB(e){typeof e!="function"&&(e=NP(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,u=0;u<a;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&l.push(c);return new oo(r,this._parents,this._name,this._id)}function IB(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],u=n[l],d=c.length,f=a[l]=new Array(d),p,h=0;h<d;++h)(p=c[h]||u[h])&&(f[h]=p);for(;l<r;++l)a[l]=t[l];return new oo(a,this._parents,this._name,this._id)}function RB(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 TB(e,t,n){var r,s,i=RB(t)?bk:Ri;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function MB(e,t){var n=this._id;return arguments.length<2?ii(this.node(),n).on.on(e):this.each(TB(n,e,t))}function $B(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function LB(){return this.on("end.remove",$B(this._id))}function OB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mk(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,u=i[a]=new Array(c),d,f,p=0;p<c;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f,Bm(u[p],t,n,p,u,ii(d,n)));return new oo(i,this._parents,t,n)}function DB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=SP(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var c=r[l],u=c.length,d,f=0;f<u;++f)if(d=c[f]){for(var p=e.call(d,d.__data__,f,c),h,g=ii(d,n),k=0,b=p.length;k<b;++k)(h=p[k])&&Bm(h,t,n,k,p,g);i.push(p),a.push(d)}return new oo(i,a,t,n)}var FB=rf.prototype.constructor;function zB(){return new FB(this._groups,this._parents)}function BB(e,t){var n,r,s;return function(){var i=Sc(this,e),a=(this.style.removeProperty(e),Sc(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function YP(e){return function(){this.style.removeProperty(e)}}function HB(e,t,n){var r,s=n+"",i;return function(){var a=Sc(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function WB(e,t,n){var r,s,i;return function(){var a=Sc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Sc(this,e))),a===c?null:a===r&&c===s?i:(s=c,i=t(r=a,l))}}function VB(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var c=Ri(this,e),u=c.on,d=c.value[i]==null?l||(l=YP(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(a,s=d),c.on=r}}function KB(e,t,n){var r=(e+="")=="transform"?q3:UP;return t==null?this.styleTween(e,BB(e,r)).on("end.style."+e,YP(e)):typeof t=="function"?this.styleTween(e,WB(e,r,kk(this,"style."+e,t))).each(VB(this._id,e)):this.styleTween(e,HB(e,r,t),n).on("end.style."+e,null)}function qB(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function UB(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&qB(e,a,n)),r}return i._value=t,i}function YB(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,UB(e,t,n??""))}function GB(e){return function(){this.textContent=e}}function JB(e){return function(){var t=e(this);this.textContent=t??""}}function XB(e){return this.tween("text",typeof e=="function"?JB(kk(this,"text",e)):GB(e==null?"":e+""))}function QB(e){return function(t){this.textContent=e.call(this,t)}}function ZB(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&QB(s)),t}return r._value=e,r}function e4(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,ZB(e))}function t4(){for(var e=this._name,t=this._id,n=GP(),r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var d=ii(c,t);Bm(c,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new oo(r,this._parents,e,n)}function n4(){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 u=Ri(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),s===0&&i()})}var r4=0;function oo(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function GP(){return++r4}var Bi=rf.prototype;oo.prototype={constructor:oo,select:OB,selectAll:DB,selectChild:Bi.selectChild,selectChildren:Bi.selectChildren,filter:PB,merge:IB,selection:zB,transition:t4,call:Bi.call,nodes:Bi.nodes,node:Bi.node,size:Bi.size,empty:Bi.empty,each:Bi.each,on:MB,attr:hB,attrTween:xB,style:KB,styleTween:YB,text:XB,textTween:e4,remove:LB,tween:aB,delay:vB,duration:jB,ease:_B,easeVarying:AB,end:n4,[Symbol.iterator]:Bi[Symbol.iterator]};function s4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var i4={time:null,delay:0,duration:250,ease:s4};function o4(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 a4(e){var t,n;e instanceof oo?(t=e._id,e=e._name):(t=GP(),(n=i4).time=xk(),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,u=0;u<l;++u)(c=a[u])&&Bm(c,e,t,u,a,n||o4(c,t));return new oo(r,this._parents,e,t)}rf.prototype.interrupt=sB;rf.prototype.transition=a4;const gp=e=>()=>e;function l4(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 Gi(e,t,n){this.k=e,this.x=t,this.y=n}Gi.prototype={constructor:Gi,scale:function(e){return e===1?this:new Gi(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Gi(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 Hm=new Gi(1,0,0);JP.prototype=Gi.prototype;function JP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Hm;return e.__zoom}function Py(e){e.stopImmediatePropagation()}function Nu(e){e.preventDefault(),e.stopImmediatePropagation()}function c4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function u4(){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 fj(){return this.__zoom||Hm}function d4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function f4(){return navigator.maxTouchPoints||"ontouchstart"in this}function p4(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 XP(){var e=c4,t=u4,n=p4,r=d4,s=f4,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=eh,u=Dm("start","zoom","end"),d,f,p,h=500,g=150,k=0,b=10;function y(M){M.property("__zoom",fj).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",H).filter(s).on("touchstart.zoom",B).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(M,q,D,L){var T=M.selection?M.selection():M;T.property("__zoom",fj),M!==T?N(M,q,D,L):T.interrupt().each(function(){j(this,arguments).event(L).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},y.scaleBy=function(M,q,D,L){y.scaleTo(M,function(){var T=this.__zoom.k,W=typeof q=="function"?q.apply(this,arguments):q;return T*W},D,L)},y.scaleTo=function(M,q,D,L){y.transform(M,function(){var T=t.apply(this,arguments),W=this.__zoom,E=D==null?C(T):typeof D=="function"?D.apply(this,arguments):D,Q=W.invert(E),V=typeof q=="function"?q.apply(this,arguments):q;return n(x(v(W,V),E,Q),T,a)},D,L)},y.translateBy=function(M,q,D,L){y.transform(M,function(){return n(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof D=="function"?D.apply(this,arguments):D),t.apply(this,arguments),a)},null,L)},y.translateTo=function(M,q,D,L,T){y.transform(M,function(){var W=t.apply(this,arguments),E=this.__zoom,Q=L==null?C(W):typeof L=="function"?L.apply(this,arguments):L;return n(Hm.translate(Q[0],Q[1]).scale(E.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof D=="function"?-D.apply(this,arguments):-D),W,a)},L,T)};function v(M,q){return q=Math.max(i[0],Math.min(i[1],q)),q===M.k?M:new Gi(q,M.x,M.y)}function x(M,q,D){var L=q[0]-D[0]*M.k,T=q[1]-D[1]*M.k;return L===M.x&&T===M.y?M:new Gi(M.k,L,T)}function C(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function N(M,q,D,L){M.on("start.zoom",function(){j(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(L).end()}).tween("zoom",function(){var T=this,W=arguments,E=j(T,W).event(L),Q=t.apply(T,W),V=D==null?C(Q):typeof D=="function"?D.apply(T,W):D,F=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),se=T.__zoom,ce=typeof q=="function"?q.apply(T,W):q,J=c(se.invert(V).concat(F/se.k),ce.invert(V).concat(F/ce.k));return function(ne){if(ne===1)ne=ce;else{var ee=J(ne),re=F/ee[2];ne=new Gi(re,V[0]-ee[0]*re,V[1]-ee[1]*re)}E.zoom(null,ne)}})}function j(M,q,D){return!D&&M.__zooming||new A(M,q)}function A(M,q){this.that=M,this.args=q,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,q),this.taps=0}A.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,q){return this.mouse&&M!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var q=as(this.that).datum();u.call(M,this.that,new l4(M,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:u}),q)}};function I(M,...q){if(!e.apply(this,arguments))return;var D=j(this,q).event(M),L=this.__zoom,T=Math.max(i[0],Math.min(i[1],L.k*Math.pow(2,r.apply(this,arguments)))),W=qs(M);if(D.wheel)(D.mouse[0][0]!==W[0]||D.mouse[0][1]!==W[1])&&(D.mouse[1]=L.invert(D.mouse[0]=W)),clearTimeout(D.wheel);else{if(L.k===T)return;D.mouse=[W,L.invert(W)],rh(this),D.start()}Nu(M),D.wheel=setTimeout(E,g),D.zoom("mouse",n(x(v(L,T),D.mouse[0],D.mouse[1]),D.extent,a));function E(){D.wheel=null,D.end()}}function O(M,...q){if(p||!e.apply(this,arguments))return;var D=M.currentTarget,L=j(this,q,!0).event(M),T=as(M.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",F,!0),W=qs(M,D),E=M.clientX,Q=M.clientY;MP(M.view),Py(M),L.mouse=[W,this.__zoom.invert(W)],rh(this),L.start();function V(se){if(Nu(se),!L.moved){var ce=se.clientX-E,J=se.clientY-Q;L.moved=ce*ce+J*J>k}L.event(se).zoom("mouse",n(x(L.that.__zoom,L.mouse[0]=qs(se,D),L.mouse[1]),L.extent,a))}function F(se){T.on("mousemove.zoom mouseup.zoom",null),$P(se.view,L.moved),Nu(se),L.event(se).end()}}function H(M,...q){if(e.apply(this,arguments)){var D=this.__zoom,L=qs(M.changedTouches?M.changedTouches[0]:M,this),T=D.invert(L),W=D.k*(M.shiftKey?.5:2),E=n(x(v(D,W),L,T),t.apply(this,q),a);Nu(M),l>0?as(this).transition().duration(l).call(N,E,L,M):as(this).call(y.transform,E,L,M)}}function B(M,...q){if(e.apply(this,arguments)){var D=M.touches,L=D.length,T=j(this,q,M.changedTouches.length===L).event(M),W,E,Q,V;for(Py(M),E=0;E<L;++E)Q=D[E],V=qs(Q,this),V=[V,this.__zoom.invert(V),Q.identifier],T.touch0?!T.touch1&&T.touch0[2]!==V[2]&&(T.touch1=V,T.taps=0):(T.touch0=V,W=!0,T.taps=1+!!d);d&&(d=clearTimeout(d)),W&&(T.taps<2&&(f=V[0],d=setTimeout(function(){d=null},h)),rh(this),T.start())}}function z(M,...q){if(this.__zooming){var D=j(this,q).event(M),L=M.changedTouches,T=L.length,W,E,Q,V;for(Nu(M),W=0;W<T;++W)E=L[W],Q=qs(E,this),D.touch0&&D.touch0[2]===E.identifier?D.touch0[0]=Q:D.touch1&&D.touch1[2]===E.identifier&&(D.touch1[0]=Q);if(E=D.that.__zoom,D.touch1){var F=D.touch0[0],se=D.touch0[1],ce=D.touch1[0],J=D.touch1[1],ne=(ne=ce[0]-F[0])*ne+(ne=ce[1]-F[1])*ne,ee=(ee=J[0]-se[0])*ee+(ee=J[1]-se[1])*ee;E=v(E,Math.sqrt(ne/ee)),Q=[(F[0]+ce[0])/2,(F[1]+ce[1])/2],V=[(se[0]+J[0])/2,(se[1]+J[1])/2]}else if(D.touch0)Q=D.touch0[0],V=D.touch0[1];else return;D.zoom("touch",n(x(E,Q,V),D.extent,a))}}function $(M,...q){if(this.__zooming){var D=j(this,q).event(M),L=M.changedTouches,T=L.length,W,E;for(Py(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),W=0;W<T;++W)E=L[W],D.touch0&&D.touch0[2]===E.identifier?delete D.touch0:D.touch1&&D.touch1[2]===E.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(E=qs(E,this),Math.hypot(f[0]-E[0],f[1]-E[1])<b)){var Q=as(this).on("dblclick.zoom");Q&&Q.apply(this,arguments)}}}return y.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:gp(+M),y):r},y.filter=function(M){return arguments.length?(e=typeof M=="function"?M:gp(!!M),y):e},y.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:gp(!!M),y):s},y.extent=function(M){return arguments.length?(t=typeof M=="function"?M:gp([[+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=u.on.apply(u,arguments);return M===u?y:M},y.clickDistance=function(M){return arguments.length?(k=(M=+M)*M,y):Math.sqrt(k)},y.tapDistance=function(M){return arguments.length?(b=+M,y):b},y}const Pi={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."},Rd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],QP=["Enter"," ","Escape"],ZP={"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 jc;(function(e){e.Strict="strict",e.Loose="loose"})(jc||(jc={}));var Da;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Da||(Da={}));var Td;(function(e){e.Partial="partial",e.Full="full"})(Td||(Td={}));const eI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var To;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(To||(To={}));var xi;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xi||(xi={}));var Ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ke||(Ke={}));const pj={[Ke.Left]:Ke.Right,[Ke.Right]:Ke.Left,[Ke.Top]:Ke.Bottom,[Ke.Bottom]:Ke.Top};function tI(e){return e===null?null:e?"valid":"invalid"}const nI=e=>"id"in e&&"source"in e&&"target"in e,h4=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),vk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),of=(e,t=[0,0])=>{const{width:n,height:r}=uo(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},m4=(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):vk(s)?s:t.nodeLookup.get(s.id));const l=a?Kh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Wm(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Vm(n)},af=(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=Wm(n,Kh(s)),r=!0)}),r?Vm(n):{x:0,y:0,width:0,height:0}},Sk=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...cf(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const u of e.values()){const{measured:d,selectable:f=!0,hidden:p=!1}=u;if(a&&!f||p)continue;const h=d.width??u.width??u.initialWidth??null,g=d.height??u.height??u.initialHeight??null,k=Md(l,_c(u)),b=(h??0)*(g??0),y=i&&k>0;(!u.internals.handleBounds||y||k>=b||u.dragging)&&c.push(u)}return c},g4=(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 y4(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 w4({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=y4(e,a),c=af(l),u=Nk(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(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function rI({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:u}=l?l.internals.positionAbsolute:{x:0,y:0},d=a.origin??r;let f=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Pi.error005());else{const h=l.measured.width,g=l.measured.height;h&&g&&(f=[[c,u],[c+h,u+g]])}else l&&Ec(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const p=Ec(f)?Ya(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Pi.error015())),{position:{x:p.x-c+(a.measured.width??0)*d[0],y:p.y-u+(a.measured.height??0)*d[1]},positionAbsolute:p}}async function x4({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(k=>k.id===p.parentId);(h||g)&&a.push(p)}const l=new Set(t.map(p=>p.id)),c=r.filter(p=>p.deletable!==!1),d=g4(a,c);for(const p of c)l.has(p.id)&&!d.find(g=>g.id===p.id)&&d.push(p);if(!s)return{edges:d,nodes:a};const f=await s({nodes:a,edges:d});return typeof f=="boolean"?f?{edges:d,nodes:a}:{edges:[],nodes:[]}:f}const Cc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ya=(e={x:0,y:0},t,n)=>({x:Cc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Cc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function sI(e,t,n){const{width:r,height:s}=uo(n),{x:i,y:a}=n.internals.positionAbsolute;return Ya(e,[[i,a],[i+r,a+s]],t)}const hj=(e,t,n)=>e<t?Cc(Math.abs(e-t),1,t)/t:e>n?-Cc(Math.abs(e-n),1,t)/t:0,iI=(e,t,n=15,r=40)=>{const s=hj(e.x,r,t.width-r)*n,i=hj(e.y,r,t.height-r)*n;return[s,i]},Wm=(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)}),Ex=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Vm=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_c=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=vk(e)?e.internals.positionAbsolute:of(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}},Kh=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=vk(e)?e.internals.positionAbsolute:of(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)}},oI=(e,t)=>Vm(Wm(Ex(e),Ex(t))),Md=(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)},mj=e=>Js(e.width)&&Js(e.height)&&Js(e.x)&&Js(e.y),Js=e=>!isNaN(e)&&isFinite(e),b4=(e,t)=>{},lf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),cf=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?lf(l,a):l},qh=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Pl(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 k4(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Pl(e,n),s=Pl(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Pl(e.top??e.y??0,n),s=Pl(e.bottom??e.y??0,n),i=Pl(e.left??e.x??0,t),a=Pl(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 v4(e,t,n,r,s,i){const{x:a,y:l}=qh(e,[t,n,r]),{x:c,y:u}=qh({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,f=i-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(d),bottom:Math.floor(f)}}const Nk=(e,t,n,r,s,i)=>{const a=k4(i,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Cc(u,r,s),f=e.x+e.width/2,p=e.y+e.height/2,h=t/2-f*d,g=n/2-p*d,k=v4(e,h,g,d,t,n),b={left:Math.min(k.left-a.left,0),top:Math.min(k.top-a.top,0),right:Math.min(k.right-a.right,0),bottom:Math.min(k.bottom-a.bottom,0)};return{x:h-b.left+b.right,y:g-b.top+b.bottom,zoom:d}},$d=()=>{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 uo(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 aI(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 lI(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 gj(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function S4(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function N4(e){return{...ZP,...e||{}}}function rd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Xs(e),l=cf({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?lf(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const jk=e=>({width:e.offsetWidth,height:e.offsetHeight}),cI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},j4=["INPUT","SELECT","TEXTAREA"];function uI(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:j4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const dI=e=>"clientX"in e,Xs=(e,t)=>{var i,a;const n=dI(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)}},yj=(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,...jk(a)}})};function fI({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,u=t*.125+i*.375+l*.375+r*.125,d=Math.abs(c-e),f=Math.abs(u-t);return[c,u,d,f]}function yp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function wj({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Ke.Left:return[t-yp(t-r,i),n];case Ke.Right:return[t+yp(r-t,i),n];case Ke.Top:return[t,n-yp(n-s,i)];case Ke.Bottom:return[t,n+yp(s-n,i)]}}function pI({sourceX:e,sourceY:t,sourcePosition:n=Ke.Bottom,targetX:r,targetY:s,targetPosition:i=Ke.Top,curvature:a=.25}){const[l,c]=wj({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=wj({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,g]=fI({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${l},${c} ${u},${d} ${r},${s}`,f,p,h,g]}function hI({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 C4({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 _4({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=Wm(Kh(e),Kh(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 Md(a,Vm(i))>0}const E4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,A4=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),sh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||E4;let s;return nI(e)?s={...e}:s={...e,id:r(e)},A4(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function mI({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=hI({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const xj={[Ke.Left]:{x:-1,y:0},[Ke.Right]:{x:1,y:0},[Ke.Top]:{x:0,y:-1},[Ke.Bottom]:{x:0,y:1}},P4=({source:e,sourcePosition:t=Ke.Bottom,target:n})=>t===Ke.Left||t===Ke.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},bj=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function I4({source:e,sourcePosition:t=Ke.Bottom,target:n,targetPosition:r=Ke.Top,center:s,offset:i,stepPosition:a}){const l=xj[t],c=xj[r],u={x:e.x+l.x*i,y:e.y+l.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},f=P4({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let g=[],k,b;const y={x:0,y:0},v={x:0,y:0},[,,x,C]=hI({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){p==="x"?(k=s.x??u.x+(d.x-u.x)*a,b=s.y??(u.y+d.y)/2):(k=s.x??(u.x+d.x)/2,b=s.y??u.y+(d.y-u.y)*a);const I=[{x:k,y:u.y},{x:k,y:d.y}],O=[{x:u.x,y:b},{x:d.x,y:b}];l[p]===h?g=p==="x"?I:O:g=p==="x"?O:I}else{const I=[{x:u.x,y:d.y}],O=[{x:d.x,y:u.y}];if(p==="x"?g=l.x===h?O:I:g=l.y===h?I:O,t===r){const M=Math.abs(e[p]-n[p]);if(M<=i){const q=Math.min(i-1,i-M);l[p]===h?y[p]=(u[p]>e[p]?-1:1)*q:v[p]=(d[p]>n[p]?-1:1)*q}}if(t!==r){const M=p==="x"?"y":"x",q=l[p]===c[M],D=u[M]>d[M],L=u[M]<d[M];(l[p]===1&&(!q&&D||q&&L)||l[p]!==1&&(!q&&L||q&&D))&&(g=p==="x"?I:O)}const H={x:u.x+y.x,y:u.y+y.y},B={x:d.x+v.x,y:d.y+v.y},z=Math.max(Math.abs(H.x-g[0].x),Math.abs(B.x-g[0].x)),$=Math.max(Math.abs(H.y-g[0].y),Math.abs(B.y-g[0].y));z>=$?(k=(H.x+B.x)/2,b=g[0].y):(k=g[0].x,b=(H.y+B.y)/2)}const N={x:u.x+y.x,y:u.y+y.y},j={x:d.x+v.x,y:d.y+v.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...j.x!==g[g.length-1].x||j.y!==g[g.length-1].y?[j]:[],n],k,b,x,C]}function R4(e,t,n,r){const s=Math.min(bj(e,t)/2,bj(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 u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+s*u},${a}Q ${i},${a} ${i},${a+s*d}`}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 Ax({sourceX:e,sourceY:t,sourcePosition:n=Ke.Bottom,targetX:r,targetY:s,targetPosition:i=Ke.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:d=.5}){const[f,p,h,g,k]=I4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:c},offset:u,stepPosition:d});let b=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)b+=R4(f[y-1],f[y],f[y+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,p,h,g,k]}function kj(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function T4(e){var f;const{sourceNode:t,targetNode:n}=e;if(!kj(t)||!kj(n))return null;const r=t.internals.handleBounds||vj(t.handles),s=n.internals.handleBounds||vj(n.handles),i=Sj((r==null?void 0:r.source)??[],e.sourceHandle),a=Sj(e.connectionMode===jc.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",Pi.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Ke.Bottom,c=(a==null?void 0:a.position)||Ke.Top,u=Ga(t,i,l),d=Ga(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function vj(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 Ga(e,t,n=Ke.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??uo(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Ke.Top:return{x:s+a/2,y:i};case Ke.Right:return{x:s+a,y:i+l/2};case Ke.Bottom:return{x:s+a/2,y:i+l};case Ke.Left:return{x:s,y:i+l/2}}}function Sj(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Px(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function M4(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 u=Px(c,t);i.has(u)||(a.push({id:u,color:c.color||n,...c}),i.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const gI=1e3,$4=10,Ck={nodeOrigin:[0,0],nodeExtent:Rd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},L4={...Ck,checkEquality:!0};function _k(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function O4(e,t,n){const r=_k(Ck,n);for(const s of e.values())if(s.parentId)Ak(s,e,t,r);else{const i=of(s,r.nodeOrigin),a=Ec(s.extent)?s.extent:r.nodeExtent,l=Ya(i,a,uo(s));s.internals.positionAbsolute=l}}function D4(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 Ek(e){return e==="manual"}function Ix(e,t,n,r={}){var d,f;const s=_k(L4,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Ek(s.zIndexMode)?gI:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const p of e){let h=a.get(p.id);if(s.checkEquality&&p===(h==null?void 0:h.internals.userNode))t.set(p.id,h);else{const g=of(p,s.nodeOrigin),k=Ec(p.extent)?p.extent:s.nodeExtent,b=Ya(g,k,uo(p));h={...s.defaults,...p,measured:{width:(d=p.measured)==null?void 0:d.width,height:(f=p.measured)==null?void 0:f.height},internals:{positionAbsolute:b,handleBounds:D4(p,h),z:yI(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&&Ak(h,t,n,r,i),u||(u=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function F4(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 Ak(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=_k(Ck,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}F4(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*$4),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=i&&!Ek(c)?gI:0,{x:p,y:h,z:g}=z4(e,d,a,l,f,c),{positionAbsolute:k}=e.internals,b=p!==k.x||h!==k.y;(b||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:p,y:h}:k,z:g}})}function yI(e,t,n){const r=Js(e.zIndex)?e.zIndex:0;return Ek(n)?r:r+(e.selected?t:0)}function z4(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,c=uo(e),u=of(e,n),d=Ec(e.extent)?Ya(u,e.extent,c):u;let f=Ya({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=sI(f,c,t));const p=yI(e,s,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Pk(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 u=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??_c(c),d=oI(u,l.rect);i.set(l.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:l,parent:c},u)=>{var x;const d=c.internals.positionAbsolute,f=uo(c),p=c.origin??r,h=l.x<d.x?Math.round(Math.abs(d.x-l.x)):0,g=l.y<d.y?Math.round(Math.abs(d.y-l.y)):0,k=Math.max(f.width,Math.round(l.width)),b=Math.max(f.height,Math.round(l.height)),y=(k-f.width)*p[0],v=(b-f.height)*p[1];(h>0||g>0||y||v)&&(s.push({id:u,type:"position",position:{x:c.position.x-h+y,y:c.position.y-g+v}}),(x=n.get(u))==null||x.forEach(C=>{e.some(N=>N.id===C.id)||s.push({id:C.id,type:"position",position:{x:C.position.x+h,y:C.position.y+g}})})),(f.width<l.width||f.height<l.height||h||g)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:k+(h?p[0]*h-y:0),height:b+(g?p[1]*g-v:0)}})}),s}function B4(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 u=[],d=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(d.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 k=jk(h.nodeElement),b=g.measured.width!==k.width||g.measured.height!==k.height;if(!!(k.width&&k.height&&(b||!g.internals.handleBounds||h.force))){const v=h.nodeElement.getBoundingClientRect(),x=Ec(g.extent)?g.extent:i;let{positionAbsolute:C}=g.internals;g.parentId&&g.extent==="parent"?C=sI(C,k,t.get(g.parentId)):x&&(C=Ya(C,x,k));const N={...g,measured:k,internals:{...g.internals,positionAbsolute:C,handleBounds:{source:yj("source",h.nodeElement,v,f,g.id),target:yj("target",h.nodeElement,v,f,g.id)}}};t.set(g.id,N),g.parentId&&Ak(N,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,b&&(u.push({id:g.id,type:"dimensions",dimensions:k}),g.expandParent&&g.parentId&&p.push({id:g.id,parentId:g.parentId,rect:_c(N,s)}))}}if(p.length>0){const h=Pk(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function H4({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 Nj(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 u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function wI(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},u=`${s}-${a}--${i}-${l}`,d=`${i}-${l}--${s}-${a}`;Nj("source",c,d,e,s,a),Nj("target",c,u,e,i,l),t.set(r.id,r)}}function xI(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:xI(n,t):!1}function jj(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 W4(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!xI(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 Iy({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const s=[];for(const[u,d]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&s.push({...f,position:d.position,dragging:r})}if(!e)return[s[0],s];const 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 V4({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=lf(i,t);return{x:a.x-i.x,y:a.y-i.y}}function K4({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,g=!1,k=null;function b({noDragClassName:v,handleSelector:x,domNode:C,isSelectable:N,nodeId:j,nodeClickDistance:A=0}){p=as(C);function I({x:z,y:$}){const{nodeLookup:M,nodeExtent:q,snapGrid:D,snapToGrid:L,nodeOrigin:T,onNodeDrag:W,onSelectionDrag:E,onError:Q,updateNodePositions:V}=t();i={x:z,y:$};let F=!1;const se=l.size>1,ce=se&&q?Ex(af(l)):null,J=se&&L?V4({dragItems:l,snapGrid:D,x:z,y:$}):null;for(const[ne,ee]of l){if(!M.has(ne))continue;let re={x:z-ee.distance.x,y:$-ee.distance.y};L&&(re=J?{x:Math.round(re.x+J.x),y:Math.round(re.y+J.y)}:lf(re,D));let Z=null;if(se&&q&&!ee.extent&&ce){const{positionAbsolute:we}=ee.internals,De=we.x-ce.x+q[0][0],Qe=we.x+ee.measured.width-ce.x2+q[1][0],Oe=we.y-ce.y+q[0][1],st=we.y+ee.measured.height-ce.y2+q[1][1];Z=[[De,Oe],[Qe,st]]}const{position:le,positionAbsolute:de}=rI({nodeId:ne,nextPosition:re,nodeLookup:M,nodeExtent:Z||q,nodeOrigin:T,onError:Q});F=F||ee.position.x!==le.x||ee.position.y!==le.y,ee.position=le,ee.internals.positionAbsolute=de}if(g=g||F,!!F&&(V(l,!0),k&&(r||W||!j&&E))){const[ne,ee]=Iy({nodeId:j,dragItems:l,nodeLookup:M});r==null||r(k,l,ne,ee),W==null||W(k,ne,ee),j||E==null||E(k,ee)}}async function O(){if(!d)return;const{transform:z,panBy:$,autoPanSpeed:M,autoPanOnNodeDrag:q}=t();if(!q){c=!1,cancelAnimationFrame(a);return}const[D,L]=iI(u,d,M);(D!==0||L!==0)&&(i.x=(i.x??0)-D/z[2],i.y=(i.y??0)-L/z[2],await $({x:D,y:L})&&I(i)),a=requestAnimationFrame(O)}function H(z){var se;const{nodeLookup:$,multiSelectionActive:M,nodesDraggable:q,transform:D,snapGrid:L,snapToGrid:T,selectNodesOnDrag:W,onNodeDragStart:E,onSelectionDragStart:Q,unselectNodesAndEdges:V}=t();f=!0,(!W||!N)&&!M&&j&&((se=$.get(j))!=null&&se.selected||V()),N&&W&&j&&(e==null||e(j));const F=rd(z.sourceEvent,{transform:D,snapGrid:L,snapToGrid:T,containerBounds:d});if(i=F,l=W4($,q,F,j),l.size>0&&(n||E||!j&&Q)){const[ce,J]=Iy({nodeId:j,dragItems:l,nodeLookup:$});n==null||n(z.sourceEvent,l,ce,J),E==null||E(z.sourceEvent,ce,J),j||Q==null||Q(z.sourceEvent,J)}}const B=LP().clickDistance(A).on("start",z=>{const{domNode:$,nodeDragThreshold:M,transform:q,snapGrid:D,snapToGrid:L}=t();d=($==null?void 0:$.getBoundingClientRect())||null,h=!1,g=!1,k=z.sourceEvent,M===0&&H(z),i=rd(z.sourceEvent,{transform:q,snapGrid:D,snapToGrid:L,containerBounds:d}),u=Xs(z.sourceEvent,d)}).on("drag",z=>{const{autoPanOnNodeDrag:$,transform:M,snapGrid:q,snapToGrid:D,nodeDragThreshold:L,nodeLookup:T}=t(),W=rd(z.sourceEvent,{transform:M,snapGrid:q,snapToGrid:D,containerBounds:d});if(k=z.sourceEvent,(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1||j&&!T.has(j))&&(h=!0),!h){if(!c&&$&&f&&(c=!0,O()),!f){const E=Xs(z.sourceEvent,d),Q=E.x-u.x,V=E.y-u.y;Math.sqrt(Q*Q+V*V)>L&&H(z)}(i.x!==W.xSnapped||i.y!==W.ySnapped)&&l&&f&&(u=Xs(z.sourceEvent,d),I(W))}}).on("end",z=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:$,updateNodePositions:M,onNodeDragStop:q,onSelectionDragStop:D}=t();if(g&&(M(l,!1),g=!1),s||q||!j&&D){const[L,T]=Iy({nodeId:j,dragItems:l,nodeLookup:$,dragging:!1});s==null||s(z.sourceEvent,l,L,T),q==null||q(z.sourceEvent,L,T),j||D==null||D(z.sourceEvent,T)}}}).filter(z=>{const $=z.target;return!z.button&&(!v||!jj($,`.${v}`,C))&&(!x||jj($,x,C))});p.call(B)}function y(){p==null||p.on(".drag",null)}return{update:b,destroy:y}}function q4(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())Md(s,_c(i))>0&&r.push(i);return r}const U4=250;function Y4(e,t,n,r){var l,c;let s=[],i=1/0;const a=q4(e,n,t+U4);for(const u of a){const d=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of d){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:h}=Ga(u,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 u=r.type==="source"?"target":"source";return s.find(d=>d.type===u)??s[0]}return s[0]}function bI(e,t,n,r,s,i=!1){var u,d,f;const a=r.get(e);if(!a)return null;const l=s==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((d=a.internals.handleBounds)==null?void 0:d.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return c&&i?{...c,...Ga(a,c,c.position,!0)}:c}function kI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function G4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const vI=()=>!0;function J4(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:h,onConnectStart:g,onConnect:k,onConnectEnd:b,isValidConnection:y=vI,onReconnectEnd:v,updateConnection:x,getTransform:C,getFromHandle:N,autoPanSpeed:j,dragThreshold:A=1,handleDomNode:I}){const O=cI(e.target);let H=0,B;const{x:z,y:$}=Xs(e),M=kI(i,I),q=l==null?void 0:l.getBoundingClientRect();let D=!1;if(!q||!M)return;const L=bI(s,M,r,c,t);if(!L)return;let T=Xs(e,q),W=!1,E=null,Q=!1,V=null;function F(){if(!d||!q)return;const[le,de]=iI(T,q,j);p({x:le,y:de}),H=requestAnimationFrame(F)}const se={...L,nodeId:s,type:M,position:L.position},ce=c.get(s);let ne={inProgress:!0,isValid:null,from:Ga(ce,se,Ke.Left,!0),fromHandle:se,fromPosition:se.position,fromNode:ce,to:T,toHandle:null,toPosition:pj[se.position],toNode:null,pointer:T};function ee(){D=!0,x(ne),g==null||g(e,{nodeId:s,handleId:r,handleType:M})}A===0&&ee();function re(le){if(!D){const{x:st,y:mt}=Xs(le),kt=st-z,Pe=mt-$;if(!(kt*kt+Pe*Pe>A*A))return;ee()}if(!N()||!se){Z(le);return}const de=C();T=Xs(le,q),B=Y4(cf(T,de,!1,[1,1]),n,c,se),W||(F(),W=!0);const we=SI(le,{handle:B,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:O,lib:u,flowId:f,nodeLookup:c});V=we.handleDomNode,E=we.connection,Q=G4(!!B,we.isValid);const De=c.get(s),Qe=De?Ga(De,se,Ke.Left,!0):ne.from,Oe={...ne,from:Qe,isValid:Q,to:we.toHandle&&Q?qh({x:we.toHandle.x,y:we.toHandle.y},de):T,toHandle:we.toHandle,toPosition:Q&&we.toHandle?we.toHandle.position:pj[se.position],toNode:we.toHandle?c.get(we.toHandle.nodeId):null,pointer:T};x(Oe),ne=Oe}function Z(le){if(!("touches"in le&&le.touches.length>0)){if(D){(B||V)&&E&&Q&&(k==null||k(E));const{inProgress:de,...we}=ne,De={...we,toPosition:ne.toHandle?ne.toPosition:null};b==null||b(le,De),i&&(v==null||v(le,De))}h(),cancelAnimationFrame(H),W=!1,Q=!1,E=null,V=null,O.removeEventListener("mousemove",re),O.removeEventListener("mouseup",Z),O.removeEventListener("touchmove",re),O.removeEventListener("touchend",Z)}}O.addEventListener("mousemove",re),O.addEventListener("mouseup",Z),O.addEventListener("touchmove",re),O.addEventListener("touchend",Z)}function SI(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:c,isValidConnection:u=vI,nodeLookup:d}){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}=Xs(e),k=a.elementFromPoint(h,g),b=k!=null&&k.classList.contains(`${l}-flow__handle`)?k:p,y={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const v=kI(void 0,b),x=b.getAttribute("data-nodeid"),C=b.getAttribute("data-handleid"),N=b.classList.contains("connectable"),j=b.classList.contains("connectableend");if(!x||!v)return y;const A={source:f?x:r,sourceHandle:f?C:s,target:f?r:x,targetHandle:f?s:C};y.connection=A;const O=N&&j&&(n===jc.Strict?f&&v==="source"||!f&&v==="target":x!==r||C!==s);y.isValid=O&&u(A),y.toHandle=bI(x,v,C,d,n,!0)}return y}const Rx={onPointerDown:J4,isValid:SI};function X4({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=as(e);function i({translateExtent:l,width:c,height:u,zoomStep:d=1,pannable:f=!0,zoomable:p=!0,inversePan:h=!1}){const g=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const C=n(),N=x.sourceEvent.ctrlKey&&$d()?10:1,j=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*d,A=C[2]*Math.pow(2,j*N);t.scaleTo(A)};let k=[0,0];const b=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(k=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},y=x=>{const C=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const N=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],j=[N[0]-k[0],N[1]-k[1]];k=N;const A=r()*Math.max(C[2],Math.log(C[2]))*(h?-1:1),I={x:C[0]-j[0]*A,y:C[1]-j[1]*A},O=[[0,0],[c,u]];t.setViewportConstrained({x:I.x,y:I.y,zoom:C[2]},O,l)},v=XP().on("start",b).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:qs}}const Km=e=>({x:e.x,y:e.y,zoom:e.k}),Ry=({x:e,y:t,zoom:n})=>Hm.translate(e,t).scale(n),Ql=(e,t)=>e.target.closest(`.${t}`),NI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Q4=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ty=(e,t=0,n=Q4,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},jI=e=>{const t=e.ctrlKey&&$d()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Z4({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Ql(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const b=qs(d),y=jI(d),v=f*Math.pow(2,y);r.scaleTo(n,v,b,d);return}const p=d.deltaMode===1?20:1;let h=s===Da.Vertical?0:d.deltaX*p,g=s===Da.Horizontal?0:d.deltaY*p;!$d()&&d.shiftKey&&s!==Da.Vertical&&(h=d.deltaY*p,g=0),r.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const k=Km(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,k),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,k),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(d,k))}}function eH({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 tH({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Km(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 nH({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&NI(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,Km(i.transform)))}}function rH({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&&NI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Km(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function sH({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:d}){return f=>{var b;const p=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Ql(f,`${u}-flow__node`)||Ql(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||d&&!g||Ql(f,l)&&g||Ql(f,c)&&(!g||s&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&((b=f.touches)==null?void 0:b.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 k=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&k}}function iH({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),f=XP().scaleExtent([t,n]).translateExtent(r),p=as(e).call(f);v({x:s.x,y:s.y,zoom:Cc(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),g=p.on("dblclick.zoom");f.wheelDelta(jI);function k(B,z){return p?new Promise($=>{f==null||f.interpolate((z==null?void 0:z.interpolate)==="linear"?nd:eh).transform(Ty(p,z==null?void 0:z.duration,z==null?void 0:z.ease,()=>$(!0)),B)}):Promise.resolve(!1)}function b({noWheelClassName:B,noPanClassName:z,onPaneContextMenu:$,userSelectionActive:M,panOnScroll:q,panOnDrag:D,panOnScrollMode:L,panOnScrollSpeed:T,preventScrolling:W,zoomOnPinch:E,zoomOnScroll:Q,zoomOnDoubleClick:V,zoomActivationKeyPressed:F,lib:se,onTransformChange:ce,connectionInProgress:J,paneClickDistance:ne,selectionOnDrag:ee}){M&&!u.isZoomingOrPanning&&y();const re=q&&!F&&!M;f.clickDistance(ee?1/0:!Js(ne)||ne<0?0:ne);const Z=re?Z4({zoomPanValues:u,noWheelClassName:B,d3Selection:p,d3Zoom:f,panOnScrollMode:L,panOnScrollSpeed:T,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):eH({noWheelClassName:B,preventScrolling:W,d3ZoomHandler:h});if(p.on("wheel.zoom",Z,{passive:!1}),!M){const de=tH({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const we=nH({zoomPanValues:u,panOnDrag:D,onPaneContextMenu:!!$,onPanZoom:i,onTransformChange:ce});f.on("zoom",we);const De=rH({zoomPanValues:u,panOnDrag:D,panOnScroll:q,onPaneContextMenu:$,onPanZoomEnd:l,onDraggingChange:c});f.on("end",De)}const le=sH({zoomActivationKeyPressed:F,panOnDrag:D,zoomOnScroll:Q,panOnScroll:q,zoomOnDoubleClick:V,zoomOnPinch:E,userSelectionActive:M,noPanClassName:z,noWheelClassName:B,lib:se,connectionInProgress:J});f.filter(le),V?p.on("dblclick.zoom",g):p.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function v(B,z,$){const M=Ry(B),q=f==null?void 0:f.constrain()(M,z,$);return q&&await k(q),new Promise(D=>D(q))}async function x(B,z){const $=Ry(B);return await k($,z),new Promise(M=>M($))}function C(B){if(p){const z=Ry(B),$=p.property("__zoom");($.k!==B.zoom||$.x!==B.x||$.y!==B.y)&&(f==null||f.transform(p,z,null,{sync:!0}))}}function N(){const B=p?JP(p.node()):{x:0,y:0,k:1};return{x:B.x,y:B.y,zoom:B.k}}function j(B,z){return p?new Promise($=>{f==null||f.interpolate((z==null?void 0:z.interpolate)==="linear"?nd:eh).scaleTo(Ty(p,z==null?void 0:z.duration,z==null?void 0:z.ease,()=>$(!0)),B)}):Promise.resolve(!1)}function A(B,z){return p?new Promise($=>{f==null||f.interpolate((z==null?void 0:z.interpolate)==="linear"?nd:eh).scaleBy(Ty(p,z==null?void 0:z.duration,z==null?void 0:z.ease,()=>$(!0)),B)}):Promise.resolve(!1)}function I(B){f==null||f.scaleExtent(B)}function O(B){f==null||f.translateExtent(B)}function H(B){const z=!Js(B)||B<0?0:B;f==null||f.clickDistance(z)}return{update:b,destroy:y,setViewport:x,setViewportConstrained:v,getViewport:N,scaleTo:j,scaleBy:A,setScaleExtent:I,setTranslateExtent:O,syncViewport:C,setClickDistance:H}}var Ac;(function(e){e.Line="line",e.Handle="handle"})(Ac||(Ac={}));function oH({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 Cj(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 jo(e,t){return Math.max(0,t-e)}function Co(e,t){return Math.max(0,e-t)}function wp(e,t,n){return Math.max(0,t-e,e-n)}function _j(e,t){return e?!t:t}function aH(e,t,n,r,s,i,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:f}=t,p=d&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:k,maxWidth:b,minHeight:y,maxHeight:v}=r,{x,y:C,width:N,height:j,aspectRatio:A}=e;let I=Math.floor(d?h-e.pointerX:0),O=Math.floor(f?g-e.pointerY:0);const H=N+(c?-I:I),B=j+(u?-O:O),z=-i[0]*N,$=-i[1]*j;let M=wp(H,k,b),q=wp(B,y,v);if(a){let T=0,W=0;c&&I<0?T=jo(x+I+z,a[0][0]):!c&&I>0&&(T=Co(x+H+z,a[1][0])),u&&O<0?W=jo(C+O+$,a[0][1]):!u&&O>0&&(W=Co(C+B+$,a[1][1])),M=Math.max(M,T),q=Math.max(q,W)}if(l){let T=0,W=0;c&&I>0?T=Co(x+I,l[0][0]):!c&&I<0&&(T=jo(x+H,l[1][0])),u&&O>0?W=Co(C+O,l[0][1]):!u&&O<0&&(W=jo(C+B,l[1][1])),M=Math.max(M,T),q=Math.max(q,W)}if(s){if(d){const T=wp(H/A,y,v)*A;if(M=Math.max(M,T),a){let W=0;!c&&!u||c&&!u&&p?W=Co(C+$+H/A,a[1][1])*A:W=jo(C+$+(c?I:-I)/A,a[0][1])*A,M=Math.max(M,W)}if(l){let W=0;!c&&!u||c&&!u&&p?W=jo(C+H/A,l[1][1])*A:W=Co(C+(c?I:-I)/A,l[0][1])*A,M=Math.max(M,W)}}if(f){const T=wp(B*A,k,b)/A;if(q=Math.max(q,T),a){let W=0;!c&&!u||u&&!c&&p?W=Co(x+B*A+z,a[1][0])/A:W=jo(x+(u?O:-O)*A+z,a[0][0])/A,q=Math.max(q,W)}if(l){let W=0;!c&&!u||u&&!c&&p?W=jo(x+B*A,l[1][0])/A:W=Co(x+(u?O:-O)*A,l[0][0])/A,q=Math.max(q,W)}}}O=O+(O<0?q:-q),I=I+(I<0?M:-M),s&&(p?H>B*A?O=(_j(c,u)?-I:I)/A:I=(_j(c,u)?-O:O)*A:d?(O=I/A,u=c):(I=O*A,c=u));const D=c?x+I:x,L=u?C+O:C;return{width:N+(c?-I:I),height:j+(u?-O:O),x:i[0]*I*(c?-1:1)+D,y:i[1]*O*(u?-1:1)+L}}const CI={width:0,height:0,x:0,y:0},lH={...CI,pointerX:0,pointerY:0,aspectRatio:1};function cH(e){return[[0,0],[e.measured.width,e.measured.height]]}function uH(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 dH({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=as(e);let a={controlDirection:Cj("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:d,keepAspectRatio:f,resizeDirection:p,onResizeStart:h,onResize:g,onResizeEnd:k,shouldResize:b}){let y={...CI},v={...lH};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:Cj(u)};let x,C=null,N=[],j,A,I,O=!1;const H=LP().on("start",B=>{const{nodeLookup:z,transform:$,snapGrid:M,snapToGrid:q,nodeOrigin:D,paneDomNode:L}=n();if(x=z.get(t),!x)return;C=(L==null?void 0:L.getBoundingClientRect())??null;const{xSnapped:T,ySnapped:W}=rd(B.sourceEvent,{transform:$,snapGrid:M,snapToGrid:q,containerBounds:C});y={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},v={...y,pointerX:T,pointerY:W,aspectRatio:y.width/y.height},j=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(j=z.get(x.parentId),A=j&&x.extent==="parent"?cH(j):void 0),N=[],I=void 0;for(const[E,Q]of z)if(Q.parentId===t&&(N.push({id:E,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const V=uH(Q,x,Q.origin??D);I?I=[[Math.min(V[0][0],I[0][0]),Math.min(V[0][1],I[0][1])],[Math.max(V[1][0],I[1][0]),Math.max(V[1][1],I[1][1])]]:I=V}h==null||h(B,{...y})}).on("drag",B=>{const{transform:z,snapGrid:$,snapToGrid:M,nodeOrigin:q}=n(),D=rd(B.sourceEvent,{transform:z,snapGrid:$,snapToGrid:M,containerBounds:C}),L=[];if(!x)return;const{x:T,y:W,width:E,height:Q}=y,V={},F=x.origin??q,{width:se,height:ce,x:J,y:ne}=aH(v,a.controlDirection,D,a.boundaries,a.keepAspectRatio,F,A,I),ee=se!==E,re=ce!==Q,Z=J!==T&&ee,le=ne!==W&&re;if(!Z&&!le&&!ee&&!re)return;if((Z||le||F[0]===1||F[1]===1)&&(V.x=Z?J:y.x,V.y=le?ne:y.y,y.x=V.x,y.y=V.y,N.length>0)){const Qe=J-T,Oe=ne-W;for(const st of N)st.position={x:st.position.x-Qe+F[0]*(se-E),y:st.position.y-Oe+F[1]*(ce-Q)},L.push(st)}if((ee||re)&&(V.width=ee&&(!a.resizeDirection||a.resizeDirection==="horizontal")?se:y.width,V.height=re&&(!a.resizeDirection||a.resizeDirection==="vertical")?ce:y.height,y.width=V.width,y.height=V.height),j&&x.expandParent){const Qe=F[0]*(V.width??0);V.x&&V.x<Qe&&(y.x=Qe,v.x=v.x-(V.x-Qe));const Oe=F[1]*(V.height??0);V.y&&V.y<Oe&&(y.y=Oe,v.y=v.y-(V.y-Oe))}const de=oH({width:y.width,prevWidth:E,height:y.height,prevHeight:Q,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),we={...y,direction:de};(b==null?void 0:b(B,we))!==!1&&(O=!0,g==null||g(B,we),r(V,L))}).on("end",B=>{O&&(k==null||k(B,{...y}),s==null||s({...y}),O=!1)});i.call(H)}function c(){i.on(".drag",null)}return{update:l,destroy:c}}var _I={exports:{}},EI={},AI={exports:{}},PI={};/**
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 fH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var pH=typeof Object.is=="function"?Object.is:fH,hH=Pc.useState,mH=Pc.useEffect,gH=Pc.useLayoutEffect,yH=Pc.useDebugValue;function wH(e,t){var n=t(),r=hH({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return gH(function(){s.value=n,s.getSnapshot=t,My(s)&&i({inst:s})},[e,n,t]),mH(function(){return My(s)&&i({inst:s}),e(function(){My(s)&&i({inst:s})})},[e]),yH(n),n}function My(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!pH(e,n)}catch{return!0}}function xH(e,t){return t()}var bH=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?xH:wH;PI.useSyncExternalStore=Pc.useSyncExternalStore!==void 0?Pc.useSyncExternalStore:bH;AI.exports=PI;var II=AI.exports;/**
53
- * @license React
54
- * use-sync-external-store-shim/with-selector.production.js
55
- *
56
- * Copyright (c) Meta Platforms, Inc. and affiliates.
57
- *
58
- * This source code is licensed under the MIT license found in the
59
- * LICENSE file in the root directory of this source tree.
60
- */var qm=m,kH=II;function vH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var SH=typeof Object.is=="function"?Object.is:vH,NH=kH.useSyncExternalStore,jH=qm.useRef,CH=qm.useEffect,_H=qm.useMemo,EH=qm.useDebugValue;EI.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=jH(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=_H(function(){function c(h){if(!u){if(u=!0,d=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,SH(d,h))return g;var k=r(h);return s!==void 0&&s(g,k)?(d=h,g):(d=h,f=k)}var u=!1,d,f,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var l=NH(e,i[0],i[1]);return CH(function(){a.hasValue=!0,a.value=l},[l]),EH(l),l};_I.exports=EI;var AH=_I.exports;const PH=ra(AH),IH={},Ej=e=>{let t;const n=new Set,r=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const h=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(IH?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},RH=e=>e?Ej(e):Ej,{useDebugValue:TH}=ut,{useSyncExternalStoreWithSelector:MH}=PH,$H=e=>e;function RI(e,t=$H,n){const r=MH(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return TH(r),r}const Aj=(e,t)=>{const n=RH(e),r=(s,i=t)=>RI(n,s,i);return Object.assign(r,n),r},LH=(e,t)=>e?Aj(e,t):Aj;function Cn(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 Um=m.createContext(null),OH=Um.Provider,TI=Pi.error001();function Bt(e,t){const n=m.useContext(Um);if(n===null)throw new Error(TI);return RI(n,e,t)}function bn(){const e=m.useContext(Um);if(e===null)throw new Error(TI);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Pj={display:"none"},DH={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},MI="react-flow__node-desc",$I="react-flow__edge-desc",FH="react-flow__aria-live",zH=e=>e.ariaLiveMessage,BH=e=>e.ariaLabelConfig;function HH({rfId:e}){const t=Bt(zH);return o.jsx("div",{id:`${FH}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:DH,children:t})}function WH({rfId:e,disableKeyboardA11y:t}){const n=Bt(BH);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${MI}-${e}`,style:Pj,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${$I}-${e}`,style:Pj,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(HH,{rfId:e})]})}const Ym=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})});Ym.displayName="Panel";function VH({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(Ym,{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 KH=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}},xp=e=>e.id;function qH(e,t){return Cn(e.selectedNodes.map(xp),t.selectedNodes.map(xp))&&Cn(e.selectedEdges.map(xp),t.selectedEdges.map(xp))}function UH({onSelectionChange:e}){const t=bn(),{selectedNodes:n,selectedEdges:r}=Bt(KH,qH);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 YH=e=>!!e.onSelectionChangeHandlers;function GH({onSelectionChange:e}){const t=Bt(YH);return e||t?o.jsx(UH,{onSelectionChange:e}):null}const Tx=typeof window<"u"?m.useLayoutEffect:m.useEffect,LI=[0,0],JH={x:0,y:0,zoom:1},XH=["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"],Ij=[...XH,"rfId"],QH=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}),Rj={translateExtent:Rd,nodeOrigin:LI,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function ZH(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Bt(QH,Cn),u=bn();Tx(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Rj,l()}),[]);const d=m.useRef(Rj);return Tx(()=>{for(const f of Ij){const p=e[f],h=d.current[f];p!==h&&(typeof e[f]>"u"||(f==="nodes"?t(p):f==="edges"?n(p):f==="minZoom"?r(p):f==="maxZoom"?s(p):f==="translateExtent"?i(p):f==="nodeExtent"?a(p):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:N4(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},Ij.map(f=>e[f])),null}function Tj(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function e5(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=Tj(),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=Tj())!=null&&r.matches?"dark":"light"}const Mj=typeof document<"u"?document:null;function Ld(e=null,t={target:Mj,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 u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),d=u.reduce((f,p)=>f.concat(...p),[]);return[u,d]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??Mj,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var b,y;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&uI(h))return!1;const k=Lj(h.code,l);if(i.current.add(h[k]),$j(a,i.current,!1)){const v=((y=(b=h.composedPath)==null?void 0:b.call(h))==null?void 0:y[0])||h.target,x=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const g=Lj(h.code,l);$j(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",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function $j(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Lj(e,t){return t.includes(e)?"code":"key"}const t5=()=>{const e=bn();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=Nk(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(),u={x:t.x-l,y:t.y-c},d=n.snapGrid??s,f=n.snapToGrid??i;return cf(u,r,f,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=qh(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function OI(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)n5(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 n5(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 Uh(e,t){return OI(e,t)}function Yh(e,t){return OI(e,t)}function Sa(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(Sa(i.id,a)))}return r}function Oj({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 Dj(e){return{id:e.id,type:"remove"}}const Fj=e=>h4(e),r5=e=>nI(e);function DI(e){return m.forwardRef(e)}function zj(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>s5(()=>n(s=>s+BigInt(1))));return Tx(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function s5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const FI=m.createContext(null);function i5({children:e}){const t=bn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:p,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let k=c;for(const y of l)k=typeof y=="function"?y(k):y;let b=Oj({items:k,lookup:p});for(const y of g.values())b=y(b);d&&u(k),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:v,setNodes:x}=t.getState();y&&x(v)})},[]),r=zj(n),s=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:p}=t.getState();let h=c;for(const g of l)h=typeof g=="function"?g(h):g;d?u(h):f&&f(Oj({items:h,lookup:p}))},[]),i=zj(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(FI.Provider,{value:a,children:e})}function o5(){const e=m.useContext(FI);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const a5=e=>!!e.panZoom;function Oc(){const e=t5(),t=bn(),n=o5(),r=Bt(a5),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=Fj(f)?f:p.get(f.id),k=g.parentId?lI(g.position,g.measured,g.parentId,p,h):g.position,b={...g,position:k,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return _c(b)},u=(f,p,h={replace:!1})=>{a(g=>g.map(k=>{if(k.id===f){const b=typeof p=="function"?p(k):p;return h.replace&&Fj(b)?b:{...k,...b}}return k}))},d=(f,p,h={replace:!1})=>{l(g=>g.map(k=>{if(k.id===f){const b=typeof p=="function"?p(k):p;return h.replace&&r5(b)?b:{...k,...b}}return k}))};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,k,b]=h;return{nodes:f.map(y=>({...y})),edges:p.map(y=>({...y})),viewport:{x:g,y:k,zoom:b}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:h,edges:g,onNodesDelete:k,onEdgesDelete:b,triggerNodeChanges:y,triggerEdgeChanges:v,onDelete:x,onBeforeDelete:C}=t.getState(),{nodes:N,edges:j}=await x4({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:g,onBeforeDelete:C}),A=j.length>0,I=N.length>0;if(A){const O=j.map(Dj);b==null||b(j),v(O)}if(I){const O=N.map(Dj);k==null||k(N),y(O)}return(I||A)&&(x==null||x({nodes:N,edges:j})),{deletedNodes:N,deletedEdges:j}},getIntersectingNodes:(f,p=!0,h)=>{const g=mj(f),k=g?f:c(f),b=h!==void 0;return k?(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 x=_c(b?y:v),C=Md(x,k);return p&&C>0||C>=x.width*x.height||C>=k.width*k.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const k=mj(f)?f:c(f);if(!k)return!1;const b=Md(k,p);return h&&b>0||b>=p.width*p.height||b>=k.width*k.height},updateNode:u,updateNodeData:(f,p,h={replace:!1})=>{u(f,g=>{const k=typeof p=="function"?p(g):p;return h.replace?{...g,data:k}:{...g,data:{...g.data,...k}}},h)},updateEdge:d,updateEdgeData:(f,p,h={replace:!1})=>{d(f,g=>{const k=typeof p=="function"?p(g):p;return h.replace?{...g,data:k}:{...g,data:{...g.data,...k}}},h)},getNodesBounds:f=>{const{nodeLookup:p,nodeOrigin:h}=t.getState();return m4(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??S4();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 Bj=e=>e.selected,l5=typeof window<"u"?window:void 0;function c5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=bn(),{deleteElements:r}=Oc(),s=Ld(e,{actInsideInputWithModifier:!1}),i=Ld(t,{target:l5});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(Bj),edges:a.filter(Bj)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function u5(e){const t=bn();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=jk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Pi.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 Gm={position:"absolute",width:"100%",height:"100%",top:0,left:0},d5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function f5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Da.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:h=!0,children:g,noWheelClassName:k,noPanClassName:b,onViewportChange:y,isControlledViewport:v,paneClickDistance:x,selectionOnDrag:C}){const N=bn(),j=m.useRef(null),{userSelectionActive:A,lib:I,connectionInProgress:O}=Bt(d5,Cn),H=Ld(p),B=m.useRef();u5(j);const z=m.useCallback($=>{y==null||y({x:$[0],y:$[1],zoom:$[2]}),v||N.setState({transform:$})},[y,v]);return m.useEffect(()=>{if(j.current){B.current=iH({domNode:j.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:D=>N.setState(L=>L.paneDragging===D?L:{paneDragging:D}),onPanZoomStart:(D,L)=>{const{onViewportChangeStart:T,onMoveStart:W}=N.getState();W==null||W(D,L),T==null||T(L)},onPanZoom:(D,L)=>{const{onViewportChange:T,onMove:W}=N.getState();W==null||W(D,L),T==null||T(L)},onPanZoomEnd:(D,L)=>{const{onViewportChangeEnd:T,onMoveEnd:W}=N.getState();W==null||W(D,L),T==null||T(L)}});const{x:$,y:M,zoom:q}=B.current.getViewport();return N.setState({panZoom:B.current,transform:[$,M,q],domNode:j.current.closest(".react-flow")}),()=>{var D;(D=B.current)==null||D.destroy()}}},[]),m.useEffect(()=>{var $;($=B.current)==null||$.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:H,preventScrolling:h,noPanClassName:b,userSelectionActive:A,noWheelClassName:k,lib:I,onTransformChange:z,connectionInProgress:O,selectionOnDrag:C,paneClickDistance:x})},[e,t,n,r,s,i,a,l,H,h,b,A,k,I,z,O,C,x]),o.jsx("div",{className:"react-flow__renderer",ref:j,style:Gm,children:g})}const p5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function h5(){const{userSelectionActive:e,userSelectionRect:t}=Bt(p5,Cn);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 $y=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},m5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function g5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Td.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:g}){const k=bn(),{userSelectionActive:b,elementsSelectable:y,dragging:v,connectionInProgress:x}=Bt(m5,Cn),C=y&&(e||b),N=m.useRef(null),j=m.useRef(),A=m.useRef(new Set),I=m.useRef(new Set),O=m.useRef(!1),H=T=>{if(O.current||x){O.current=!1;return}c==null||c(T),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},B=T=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){T.preventDefault();return}u==null||u(T)},z=d?T=>d(T):void 0,$=T=>{O.current&&(T.stopPropagation(),O.current=!1)},M=T=>{var ce,J;const{domNode:W}=k.getState();if(j.current=W==null?void 0:W.getBoundingClientRect(),!j.current)return;const E=T.target===N.current;if(!E&&!!T.target.closest(".nokey")||!e||!(i&&E||t)||T.button!==0||!T.isPrimary)return;(J=(ce=T.target)==null?void 0:ce.setPointerCapture)==null||J.call(ce,T.pointerId),O.current=!1;const{x:F,y:se}=Xs(T.nativeEvent,j.current);k.setState({userSelectionRect:{width:0,height:0,startX:F,startY:se,x:F,y:se}}),E||(T.stopPropagation(),T.preventDefault())},q=T=>{const{userSelectionRect:W,transform:E,nodeLookup:Q,edgeLookup:V,connectionLookup:F,triggerNodeChanges:se,triggerEdgeChanges:ce,defaultEdgeOptions:J,resetSelectedElements:ne}=k.getState();if(!j.current||!W)return;const{x:ee,y:re}=Xs(T.nativeEvent,j.current),{startX:Z,startY:le}=W;if(!O.current){const Oe=t?0:s;if(Math.hypot(ee-Z,re-le)<=Oe)return;ne(),a==null||a(T)}O.current=!0;const de={startX:Z,startY:le,x:ee<Z?ee:Z,y:re<le?re:le,width:Math.abs(ee-Z),height:Math.abs(re-le)},we=A.current,De=I.current;A.current=new Set(Sk(Q,de,E,n===Td.Partial,!0).map(Oe=>Oe.id)),I.current=new Set;const Qe=(J==null?void 0:J.selectable)??!0;for(const Oe of A.current){const st=F.get(Oe);if(st)for(const{edgeId:mt}of st.values()){const kt=V.get(mt);kt&&(kt.selectable??Qe)&&I.current.add(mt)}}if(!gj(we,A.current)){const Oe=Zl(Q,A.current,!0);se(Oe)}if(!gj(De,I.current)){const Oe=Zl(V,I.current);ce(Oe)}k.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},D=T=>{var W,E;T.button===0&&((E=(W=T.target)==null?void 0:W.releasePointerCapture)==null||E.call(W,T.pointerId),!b&&T.target===N.current&&k.getState().userSelectionRect&&(H==null||H(T)),k.setState({userSelectionActive:!1,userSelectionRect:null}),O.current&&(l==null||l(T),k.setState({nodesSelectionActive:A.current.size>0})))},L=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:Gn(["react-flow__pane",{draggable:L,dragging:v,selection:e}]),onClick:C?void 0:$y(H,N),onContextMenu:$y(B,N),onWheel:$y(z,N),onPointerEnter:C?void 0:f,onPointerMove:C?q:p,onPointerUp:C?D:void 0,onPointerDownCapture:C?M:void 0,onClickCapture:C?$:void 0,onPointerLeave:h,ref:N,style:Gm,children:[g,o.jsx(h5,{})]})}function Mx({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Pi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function zI({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=bn(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=K4({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Mx({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var f;(f=d.current)==null||f.destroy()}},[n,r,t,i,e,s,a]),c}const y5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function BI(){const e=bn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),f=new Map,p=y5(a),h=s?i[0]:5,g=s?i[1]:5,k=n.direction.x*h*n.factor,b=n.direction.y*g*n.factor;for(const[,y]of u){if(!p(y))continue;let v={x:y.internals.positionAbsolute.x+k,y:y.internals.positionAbsolute.y+b};s&&(v=lf(v,i));const{position:x,positionAbsolute:C}=rI({nodeId:y.id,nextPosition:v,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:l});y.position=x,y.internals.positionAbsolute=C,f.set(y.id,y)}c(f)},[])}const Ik=m.createContext(null),w5=Ik.Provider;Ik.Consumer;const HI=()=>m.useContext(Ik),x5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),b5=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===jc.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:d&&u}};function k5({type:e="source",position:t=Ke.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:d,onTouchStart:f,...p},h){var q,D;const g=a||null,k=e==="target",b=bn(),y=HI(),{connectOnClick:v,noPanClassName:x,rfId:C}=Bt(x5,Cn),{connectingFrom:N,connectingTo:j,clickConnecting:A,isPossibleEndHandle:I,connectionInProcess:O,clickConnectionInProcess:H,valid:B}=Bt(b5(y,g,e),Cn);y||(D=(q=b.getState()).onError)==null||D.call(q,"010",Pi.error010());const z=L=>{const{defaultEdgeOptions:T,onConnect:W,hasDefaultEdges:E}=b.getState(),Q={...T,...L};if(E){const{edges:V,setEdges:F}=b.getState();F(sh(Q,V))}W==null||W(Q),l==null||l(Q)},$=L=>{if(!y)return;const T=dI(L.nativeEvent);if(s&&(T&&L.button===0||!T)){const W=b.getState();Rx.onPointerDown(L.nativeEvent,{handleDomNode:L.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:k,handleId:g,nodeId:y,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...E)=>{var Q,V;return(V=(Q=b.getState()).onConnectEnd)==null?void 0:V.call(Q,...E)},updateConnection:W.updateConnection,onConnect:z,isValidConnection:n||((...E)=>{var Q,V;return((V=(Q=b.getState()).isValidConnection)==null?void 0:V.call(Q,...E))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}T?d==null||d(L):f==null||f(L)},M=L=>{const{onClickConnectStart:T,onClickConnectEnd:W,connectionClickStartHandle:E,connectionMode:Q,isValidConnection:V,lib:F,rfId:se,nodeLookup:ce,connection:J}=b.getState();if(!y||!E&&!s)return;if(!E){T==null||T(L.nativeEvent,{nodeId:y,handleId:g,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const ne=cI(L.target),ee=n||V,{connection:re,isValid:Z}=Rx.isValid(L.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:Q,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:ee,flowId:se,doc:ne,lib:F,nodeLookup:ce});Z&&re&&z(re);const le=structuredClone(J);delete le.inProgress,le.toPosition=le.toHandle?le.toHandle.position:null,W==null||W(L,le),b.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${C}-${y}-${g}-${e}`,className:Gn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!k,target:k,connectable:r,connectablestart:s,connectableend:i,clickconnecting:A,connectingfrom:N,connectingto:j,valid:B,connectionindicator:r&&(!O||I)&&(O||H?i:s)}]),onMouseDown:$,onTouchStart:$,onClick:v?M:void 0,ref:h,...p,children:c})}const Yn=m.memo(DI(k5));function v5({data:e,isConnectable:t,sourcePosition:n=Ke.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Yn,{type:"source",position:n,isConnectable:t})]})}function S5({data:e,isConnectable:t,targetPosition:n=Ke.Top,sourcePosition:r=Ke.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Yn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Yn,{type:"source",position:r,isConnectable:t})]})}function N5(){return null}function j5({data:e,isConnectable:t,targetPosition:n=Ke.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Yn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Gh={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Hj={input:v5,default:S5,output:j5,group:N5};function C5(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 _5=e=>{const{width:t,height:n,x:r,y:s}=af(e.nodeLookup,{filter:i=>!!i.selected});return{width:Js(t)?t:null,height:Js(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 E5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=bn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Bt(_5,Cn),c=BI(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const d=!l&&s!==null&&i!==null;if(zI({nodeRef:u,disabled:!d}),!d)return null;const f=e?h=>{const g=r.getState().nodes.filter(k=>k.selected);e(h,g)}:void 0,p=h=>{Object.prototype.hasOwnProperty.call(Gh,h.key)&&(h.preventDefault(),c({direction:Gh[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:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const Wj=typeof window<"u"?window:void 0,A5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function WI({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:k,zoomActivationKeyCode:b,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:C,panOnScrollSpeed:N,panOnScrollMode:j,zoomOnDoubleClick:A,panOnDrag:I,defaultViewport:O,translateExtent:H,minZoom:B,maxZoom:z,preventScrolling:$,onSelectionContextMenu:M,noWheelClassName:q,noPanClassName:D,disableKeyboardA11y:L,onViewportChange:T,isControlledViewport:W}){const{nodesSelectionActive:E,userSelectionActive:Q}=Bt(A5,Cn),V=Ld(u,{target:Wj}),F=Ld(k,{target:Wj}),se=F||I,ce=F||C,J=d&&se!==!0,ne=V||Q||J;return c5({deleteKeyCode:c,multiSelectionKeyCode:g}),o.jsx(f5,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:x,panOnScroll:ce,panOnScrollSpeed:N,panOnScrollMode:j,zoomOnDoubleClick:A,panOnDrag:!V&&se,defaultViewport:O,translateExtent:H,minZoom:B,maxZoom:z,zoomActivationKeyCode:b,preventScrolling:$,noWheelClassName:q,noPanClassName:D,onViewportChange:T,isControlledViewport:W,paneClickDistance:l,selectionOnDrag:J,children:o.jsxs(g5,{onSelectionStart:p,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:se,isSelecting:!!ne,selectionMode:f,selectionKeyPressed:V,paneClickDistance:l,selectionOnDrag:J,children:[e,E&&o.jsx(E5,{onSelectionContextMenu:M,noPanClassName:D,disableKeyboardA11y:L})]})})}WI.displayName="FlowRenderer";const P5=m.memo(WI),I5=e=>t=>e?Sk(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 R5(e){return Bt(m.useCallback(I5(e),[e]),Cn)}const T5=e=>e.updateNodeInternals;function M5(){const e=Bt(T5),[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 $5({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=bn(),i=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),d=n&&!!e.internals.handleBounds;return m.useEffect(()=>{i.current&&!e.hidden&&(!d||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[d,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(i.current){const f=u.current!==t,p=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||p||h)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function L5({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:p,noPanClassName:h,disableKeyboardA11y:g,rfId:k,nodeTypes:b,nodeClickDistance:y,onError:v}){const{node:x,internals:C,isParent:N}=Bt(ee=>{const re=ee.nodeLookup.get(e),Z=ee.parentLookup.has(e);return{node:re,internals:re.internals,isParent:Z}},Cn);let j=x.type||"default",A=(b==null?void 0:b[j])||Hj[j];A===void 0&&(v==null||v("003",Pi.error003(j)),j="default",A=(b==null?void 0:b.default)||Hj.default);const I=!!(x.draggable||l&&typeof x.draggable>"u"),O=!!(x.selectable||c&&typeof x.selectable>"u"),H=!!(x.connectable||u&&typeof x.connectable>"u"),B=!!(x.focusable||d&&typeof x.focusable>"u"),z=bn(),$=aI(x),M=$5({node:x,nodeType:j,hasDimensions:$,resizeObserver:f}),q=zI({nodeRef:M,disabled:x.hidden||!I,noDragClassName:p,handleSelector:x.dragHandle,nodeId:e,isSelectable:O,nodeClickDistance:y}),D=BI();if(x.hidden)return null;const L=uo(x),T=C5(x),W=O||I||t||n||r||s,E=n?ee=>n(ee,{...C.userNode}):void 0,Q=r?ee=>r(ee,{...C.userNode}):void 0,V=s?ee=>s(ee,{...C.userNode}):void 0,F=i?ee=>i(ee,{...C.userNode}):void 0,se=a?ee=>a(ee,{...C.userNode}):void 0,ce=ee=>{const{selectNodesOnDrag:re,nodeDragThreshold:Z}=z.getState();O&&(!re||!I||Z>0)&&Mx({id:e,store:z,nodeRef:M}),t&&t(ee,{...C.userNode})},J=ee=>{if(!(uI(ee.nativeEvent)||g)){if(QP.includes(ee.key)&&O){const re=ee.key==="Escape";Mx({id:e,store:z,unselect:re,nodeRef:M})}else if(I&&x.selected&&Object.prototype.hasOwnProperty.call(Gh,ee.key)){ee.preventDefault();const{ariaLabelConfig:re}=z.getState();z.setState({ariaLiveMessage:re["node.a11yDescription.ariaLiveMessage"]({direction:ee.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),D({direction:Gh[ee.key],factor:ee.shiftKey?4:1})}}},ne=()=>{var De;if(g||!((De=M.current)!=null&&De.matches(":focus-visible")))return;const{transform:ee,width:re,height:Z,autoPanOnNodeFocus:le,setCenter:de}=z.getState();if(!le)return;Sk(new Map([[e,x]]),{x:0,y:0,width:re,height:Z},ee,!0).length>0||de(x.position.x+L.width/2,x.position.y+L.height/2,{zoom:ee[2]})};return o.jsx("div",{className:Gn(["react-flow__node",`react-flow__node-${j}`,{[h]:I},x.className,{selected:x.selected,selectable:O,parent:N,draggable:I,dragging:q}]),ref:M,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:$?"visible":"hidden",...x.style,...T},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:Q,onMouseLeave:V,onContextMenu:F,onClick:ce,onDoubleClick:se,onKeyDown:B?J:void 0,tabIndex:B?0:void 0,onFocus:B?ne:void 0,role:x.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${MI}-${k}`,"aria-label":x.ariaLabel,...x.domAttributes,children:o.jsx(w5,{value:e,children:o.jsx(A,{id:e,data:x.data,type:j,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:x.selected??!1,selectable:O,draggable:I,deletable:x.deletable??!0,isConnectable:H,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:q,dragHandle:x.dragHandle,zIndex:C.z,parentId:x.parentId,...L})})})}var O5=m.memo(L5);const D5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function VI(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Bt(D5,Cn),a=R5(e.onlyRenderVisibleElements),l=M5();return o.jsx("div",{className:"react-flow__nodes",style:Gm,children:a.map(c=>o.jsx(O5,{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))})}VI.displayName="NodeRenderer";const F5=m.memo(VI);function z5(e){return Bt(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&&_4({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Cn)}const B5=({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"})},H5=({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"})},Vj={[xi.Arrow]:B5,[xi.ArrowClosed]:H5};function W5(e){const t=bn();return m.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(Vj,e)?Vj[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Pi.error009(e)),null)},[e])}const V5=({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=W5(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},KI=({defaultColor:e,rfId:t})=>{const n=Bt(i=>i.edges),r=Bt(i=>i.defaultEdgeOptions),s=m.useMemo(()=>M4(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(V5,{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};KI.displayName="MarkerDefinitions";var K5=m.memo(KI);function qI({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...d}){const[f,p]=m.useState({x:1,y:0,width:0,height:0}),h=Gn(["react-flow__edge-textwrapper",u]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const k=g.current.getBBox();p({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...d,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}qI.displayName="EdgeText";const q5=m.memo(qI);function Jm({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...d,d:e,fill:"none",className:Gn(["react-flow__edge-path",d.className])}),u?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&Js(t)&&Js(n)?o.jsx(q5,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function Kj({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ke.Left||e===Ke.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function UI({sourceX:e,sourceY:t,sourcePosition:n=Ke.Bottom,targetX:r,targetY:s,targetPosition:i=Ke.Top}){const[a,l]=Kj({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=Kj({pos:i,x1:r,y1:s,x2:e,y2:t}),[d,f,p,h]=fI({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,d,f,p,h]}function YI(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:k,markerStart:b,interactionWidth:y})=>{const[v,x,C]=UI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),N=e.isInternal?void 0:t;return o.jsx(Jm,{id:N,path:v,labelX:x,labelY:C,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:k,markerStart:b,interactionWidth:y})})}const U5=YI({isInternal:!1}),GI=YI({isInternal:!0});U5.displayName="SimpleBezierEdge";GI.displayName="SimpleBezierEdgeInternal";function JI(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,sourcePosition:h=Ke.Bottom,targetPosition:g=Ke.Top,markerEnd:k,markerStart:b,pathOptions:y,interactionWidth:v})=>{const[x,C,N]=Ax({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}),j=e.isInternal?void 0:t;return o.jsx(Jm,{id:j,path:x,labelX:C,labelY:N,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:k,markerStart:b,interactionWidth:v})})}const XI=JI({isInternal:!1}),QI=JI({isInternal:!0});XI.displayName="SmoothStepEdge";QI.displayName="SmoothStepEdgeInternal";function ZI(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(XI,{...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 Y5=ZI({isInternal:!1}),eR=ZI({isInternal:!0});Y5.displayName="StepEdge";eR.displayName="StepEdgeInternal";function tR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:g,interactionWidth:k})=>{const[b,y,v]=mI({sourceX:n,sourceY:r,targetX:s,targetY:i}),x=e.isInternal?void 0:t;return o.jsx(Jm,{id:x,path:b,labelX:y,labelY:v,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:g,interactionWidth:k})})}const G5=tR({isInternal:!1}),nR=tR({isInternal:!0});G5.displayName="StraightEdge";nR.displayName="StraightEdgeInternal";function rR(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Ke.Bottom,targetPosition:l=Ke.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:k,markerStart:b,pathOptions:y,interactionWidth:v})=>{const[x,C,N]=pI({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),j=e.isInternal?void 0:t;return o.jsx(Jm,{id:j,path:x,labelX:C,labelY:N,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:g,markerEnd:k,markerStart:b,interactionWidth:v})})}const J5=rR({isInternal:!1}),sR=rR({isInternal:!0});J5.displayName="BezierEdge";sR.displayName="BezierEdgeInternal";const qj={default:sR,straight:nR,step:eR,smoothstep:QI,simplebezier:GI},Uj={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},X5=(e,t,n)=>n===Ke.Left?e-t:n===Ke.Right?e+t:e,Q5=(e,t,n)=>n===Ke.Top?e-t:n===Ke.Bottom?e+t:e,Yj="react-flow__edgeupdater";function Gj({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([Yj,`${Yj}-${l}`]),cx:X5(t,r,e),cy:Q5(n,r,e),r,stroke:"transparent",fill:"transparent"})}function Z5({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:p,setUpdateHover:h}){const g=bn(),k=(C,N)=>{if(C.button!==0)return;const{autoPanOnConnect:j,domNode:A,connectionMode:I,connectionRadius:O,lib:H,onConnectStart:B,cancelConnection:z,nodeLookup:$,rfId:M,panBy:q,updateConnection:D}=g.getState(),L=N.type==="target",T=(Q,V)=>{p(!1),f==null||f(Q,n,N.type,V)},W=Q=>u==null?void 0:u(n,Q),E=(Q,V)=>{p(!0),d==null||d(C,n,N.type),B==null||B(Q,V)};Rx.onPointerDown(C.nativeEvent,{autoPanOnConnect:j,connectionMode:I,connectionRadius:O,domNode:A,handleId:N.id,nodeId:N.nodeId,nodeLookup:$,isTarget:L,edgeUpdaterType:N.type,lib:H,flowId:M,cancelConnection:z,panBy:q,isValidConnection:(...Q)=>{var V,F;return((F=(V=g.getState()).isValidConnection)==null?void 0:F.call(V,...Q))??!0},onConnect:W,onConnectStart:E,onConnectEnd:(...Q)=>{var V,F;return(F=(V=g.getState()).onConnectEnd)==null?void 0:F.call(V,...Q)},onReconnectEnd:T,updateConnection:D,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:C.currentTarget})},b=C=>k(C,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=C=>k(C,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>h(!0),x=()=>h(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(Gj,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:b,onMouseEnter:v,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&o.jsx(Gj,{position:c,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:v,onMouseOut:x,type:"target"})]})}function eW({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,rfId:g,edgeTypes:k,noPanClassName:b,onError:y,disableKeyboardA11y:v}){let x=Bt(de=>de.edgeLookup.get(e));const C=Bt(de=>de.defaultEdgeOptions);x=C?{...C,...x}:x;let N=x.type||"default",j=(k==null?void 0:k[N])||qj[N];j===void 0&&(y==null||y("011",Pi.error011(N)),N="default",j=(k==null?void 0:k.default)||qj.default);const A=!!(x.focusable||t&&typeof x.focusable>"u"),I=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),O=!!(x.selectable||r&&typeof x.selectable>"u"),H=m.useRef(null),[B,z]=m.useState(!1),[$,M]=m.useState(!1),q=bn(),{zIndex:D,sourceX:L,sourceY:T,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V}=Bt(m.useCallback(de=>{const we=de.nodeLookup.get(x.source),De=de.nodeLookup.get(x.target);if(!we||!De)return{zIndex:x.zIndex,...Uj};const Qe=T4({id:e,sourceNode:we,targetNode:De,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:de.connectionMode,onError:y});return{zIndex:C4({selected:x.selected,zIndex:x.zIndex,sourceNode:we,targetNode:De,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Qe||Uj}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Cn),F=m.useMemo(()=>x.markerStart?`url('#${Px(x.markerStart,g)}')`:void 0,[x.markerStart,g]),se=m.useMemo(()=>x.markerEnd?`url('#${Px(x.markerEnd,g)}')`:void 0,[x.markerEnd,g]);if(x.hidden||L===null||T===null||W===null||E===null)return null;const ce=de=>{var Oe;const{addSelectedEdges:we,unselectNodesAndEdges:De,multiSelectionActive:Qe}=q.getState();O&&(q.setState({nodesSelectionActive:!1}),x.selected&&Qe?(De({nodes:[],edges:[x]}),(Oe=H.current)==null||Oe.blur()):we([e])),s&&s(de,x)},J=i?de=>{i(de,{...x})}:void 0,ne=a?de=>{a(de,{...x})}:void 0,ee=l?de=>{l(de,{...x})}:void 0,re=c?de=>{c(de,{...x})}:void 0,Z=u?de=>{u(de,{...x})}:void 0,le=de=>{var we;if(!v&&QP.includes(de.key)&&O){const{unselectNodesAndEdges:De,addSelectedEdges:Qe}=q.getState();de.key==="Escape"?((we=H.current)==null||we.blur(),De({edges:[x]})):Qe([e])}};return o.jsx("svg",{style:{zIndex:D},children:o.jsxs("g",{className:Gn(["react-flow__edge",`react-flow__edge-${N}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!O&&!s,updating:B,selectable:O}]),onClick:ce,onDoubleClick:J,onContextMenu:ne,onMouseEnter:ee,onMouseMove:re,onMouseLeave:Z,onKeyDown:A?le:void 0,tabIndex:A?0:void 0,role:x.ariaRole??(A?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":A?`${$I}-${g}`:void 0,ref:H,...x.domAttributes,children:[!$&&o.jsx(j,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:O,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:L,sourceY:T,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:F,markerEnd:se,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),I&&o.jsx(Z5,{edge:x,isReconnectable:I,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:L,sourceY:T,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,setUpdateHover:z,setReconnecting:M})]})})}var tW=m.memo(eW);const nW=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function iR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:p,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:k}){const{edgesFocusable:b,edgesReconnectable:y,elementsSelectable:v,onError:x}=Bt(nW,Cn),C=z5(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(K5,{defaultColor:e,rfId:n}),C.map(N=>o.jsx(tW,{id:N,edgesFocusable:b,edgesReconnectable:y,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:p,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:k},N))]})}iR.displayName="EdgeRenderer";const rW=m.memo(iR),sW=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function iW({children:e}){const t=Bt(sW);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function oW(e){const t=Oc(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const aW=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function lW(e){const t=Bt(aW),n=bn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function cW(e){return e.connection.inProgress?{...e.connection,to:cf(e.connection.to,e.transform)}:{...e.connection}}function uW(e){return cW}function dW(e){const t=uW();return Bt(t,Cn)}const fW=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function pW({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:c}=Bt(fW,Cn);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",tI(l)]),children:o.jsx(oR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const oR=({style:e,type:t=To.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:d,toHandle:f,toPosition:p,pointer:h}=dW();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:p,connectionStatus:tI(r),toNode:d,toHandle:f,pointer:h});let g="";const k={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:p};switch(t){case To.Bezier:[g]=pI(k);break;case To.SimpleBezier:[g]=UI(k);break;case To.Step:[g]=Ax({...k,borderRadius:0});break;case To.SmoothStep:[g]=Ax(k);break;default:[g]=mI(k)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};oR.displayName="ConnectionLine";const hW={};function Jj(e=hW){m.useRef(e),bn(),m.useEffect(()=>{},[e])}function mW(){bn(),m.useRef(!1),m.useEffect(()=>{},[])}function aR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:p,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:k,connectionLineComponent:b,connectionLineContainerStyle:y,selectionKeyCode:v,selectionOnDrag:x,selectionMode:C,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:A,deleteKeyCode:I,onlyRenderVisibleElements:O,elementsSelectable:H,defaultViewport:B,translateExtent:z,minZoom:$,maxZoom:M,preventScrolling:q,defaultMarkerColor:D,zoomOnScroll:L,zoomOnPinch:T,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,zoomOnDoubleClick:V,panOnDrag:F,onPaneClick:se,onPaneMouseEnter:ce,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneScroll:ee,onPaneContextMenu:re,paneClickDistance:Z,nodeClickDistance:le,onEdgeContextMenu:de,onEdgeMouseEnter:we,onEdgeMouseMove:De,onEdgeMouseLeave:Qe,reconnectRadius:Oe,onReconnect:st,onReconnectStart:mt,onReconnectEnd:kt,noDragClassName:Pe,noWheelClassName:dt,noPanClassName:gt,disableKeyboardA11y:xe,nodeExtent:Fe,rfId:Me,viewport:ue,onViewportChange:ve}){return Jj(e),Jj(t),mW(),oW(n),lW(ue),o.jsx(P5,{onPaneClick:se,onPaneMouseEnter:ce,onPaneMouseMove:J,onPaneMouseLeave:ne,onPaneContextMenu:re,onPaneScroll:ee,paneClickDistance:Z,deleteKeyCode:I,selectionKeyCode:v,selectionOnDrag:x,selectionMode:C,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:A,elementsSelectable:H,zoomOnScroll:L,zoomOnPinch:T,zoomOnDoubleClick:V,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,panOnDrag:F,defaultViewport:B,translateExtent:z,minZoom:$,maxZoom:M,onSelectionContextMenu:f,preventScrolling:q,noDragClassName:Pe,noWheelClassName:dt,noPanClassName:gt,disableKeyboardA11y:xe,onViewportChange:ve,isControlledViewport:!!ue,children:o.jsxs(iW,{children:[o.jsx(rW,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:st,onReconnectStart:mt,onReconnectEnd:kt,onlyRenderVisibleElements:O,onEdgeContextMenu:de,onEdgeMouseEnter:we,onEdgeMouseMove:De,onEdgeMouseLeave:Qe,reconnectRadius:Oe,defaultMarkerColor:D,noPanClassName:gt,disableKeyboardA11y:xe,rfId:Me}),o.jsx(pW,{style:k,type:g,component:b,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(F5,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:le,onlyRenderVisibleElements:O,noPanClassName:gt,noDragClassName:Pe,disableKeyboardA11y:xe,nodeExtent:Fe,rfId:Me}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}aR.displayName="GraphView";const gW=m.memo(aR),Xj=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f,zIndexMode:p="basic"}={})=>{const h=new Map,g=new Map,k=new Map,b=new Map,y=r??t??[],v=n??e??[],x=d??[0,0],C=f??Rd;wI(k,b,y);const{nodesInitialized:N}=Ix(v,h,g,{nodeOrigin:x,nodeExtent:C,zIndexMode:p});let j=[0,0,1];if(a&&s&&i){const A=af(h,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:I,y:O,zoom:H}=Nk(A,s,i,c,u,(l==null?void 0:l.padding)??.1);j=[I,O,H]}return{rfId:"1",width:s??0,height:i??0,transform:j,nodes:v,nodesInitialized:N,nodeLookup:h,parentLookup:g,edges:y,edgeLookup:b,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:Rd,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:jc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...eI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:b4,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ZP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},yW=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p})=>LH((h,g)=>{async function k(){const{nodeLookup:b,panZoom:y,fitViewOptions:v,fitViewResolver:x,width:C,height:N,minZoom:j,maxZoom:A}=g();y&&(await w4({nodes:b,width:C,height:N,panZoom:y,minZoom:j,maxZoom:A},v),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{...Xj({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:b=>{const{nodeLookup:y,parentLookup:v,nodeOrigin:x,elevateNodesOnSelect:C,fitViewQueued:N,zIndexMode:j,nodesSelectionActive:A}=g(),{nodesInitialized:I,hasSelectedNodes:O}=Ix(b,y,v,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:j}),H=A&&O;N&&I?(k(),h({nodes:b,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:H})):h({nodes:b,nodesInitialized:I,nodesSelectionActive:H})},setEdges:b=>{const{connectionLookup:y,edgeLookup:v}=g();wI(y,v,b),h({edges:b})},setDefaultNodesAndEdges:(b,y)=>{if(b){const{setNodes:v}=g();v(b),h({hasDefaultNodes:!0})}if(y){const{setEdges:v}=g();v(y),h({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:y,nodeLookup:v,parentLookup:x,domNode:C,nodeOrigin:N,nodeExtent:j,debug:A,fitViewQueued:I,zIndexMode:O}=g(),{changes:H,updatedInternals:B}=B4(b,v,x,C,N,j,O);B&&(O4(v,x,{nodeOrigin:N,nodeExtent:j,zIndexMode:O}),I?(k(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(H==null?void 0:H.length)>0&&(A&&console.log("React Flow: trigger node changes",H),y==null||y(H)))},updateNodePositions:(b,y=!1)=>{const v=[];let x=[];const{nodeLookup:C,triggerNodeChanges:N,connection:j,updateConnection:A,onNodesChangeMiddlewareMap:I}=g();for(const[O,H]of b){const B=C.get(O),z=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(H!=null&&H.position)),$={id:O,type:"position",position:z?{x:Math.max(0,H.position.x),y:Math.max(0,H.position.y)}:H.position,dragging:y};if(B&&j.inProgress&&j.fromNode.id===B.id){const M=Ga(B,j.fromHandle,Ke.Left,!0);A({...j,from:M})}z&&B.parentId&&v.push({id:O,parentId:B.parentId,rect:{...H.internals.positionAbsolute,width:H.measured.width??0,height:H.measured.height??0}}),x.push($)}if(v.length>0){const{parentLookup:O,nodeOrigin:H}=g(),B=Pk(v,C,O,H);x.push(...B)}for(const O of I.values())x=O(x);N(x)},triggerNodeChanges:b=>{const{onNodesChange:y,setNodes:v,nodes:x,hasDefaultNodes:C,debug:N}=g();if(b!=null&&b.length){if(C){const j=Uh(b,x);v(j)}N&&console.log("React Flow: trigger node changes",b),y==null||y(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:y,setEdges:v,edges:x,hasDefaultEdges:C,debug:N}=g();if(b!=null&&b.length){if(C){const j=Yh(b,x);v(j)}N&&console.log("React Flow: trigger edge changes",b),y==null||y(b)}},addSelectedNodes:b=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:x,triggerNodeChanges:C,triggerEdgeChanges:N}=g();if(y){const j=b.map(A=>Sa(A,!0));C(j);return}C(Zl(x,new Set([...b]),!0)),N(Zl(v))},addSelectedEdges:b=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:x,triggerNodeChanges:C,triggerEdgeChanges:N}=g();if(y){const j=b.map(A=>Sa(A,!0));N(j);return}N(Zl(v,new Set([...b]))),C(Zl(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:y}={})=>{const{edges:v,nodes:x,nodeLookup:C,triggerNodeChanges:N,triggerEdgeChanges:j}=g(),A=b||x,I=y||v,O=[];for(const B of A){if(!B.selected)continue;const z=C.get(B.id);z&&(z.selected=!1),O.push(Sa(B.id,!1))}const H=[];for(const B of I)B.selected&&H.push(Sa(B.id,!1));N(O),j(H)},setMinZoom:b=>{const{panZoom:y,maxZoom:v}=g();y==null||y.setScaleExtent([b,v]),h({minZoom:b})},setMaxZoom:b=>{const{panZoom:y,minZoom:v}=g();y==null||y.setScaleExtent([v,b]),h({maxZoom:b})},setTranslateExtent:b=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(b),h({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:y,triggerNodeChanges:v,triggerEdgeChanges:x,elementsSelectable:C}=g();if(!C)return;const N=y.reduce((A,I)=>I.selected?[...A,Sa(I.id,!1)]:A,[]),j=b.reduce((A,I)=>I.selected?[...A,Sa(I.id,!1)]:A,[]);v(N),x(j)},setNodeExtent:b=>{const{nodes:y,nodeLookup:v,parentLookup:x,nodeOrigin:C,elevateNodesOnSelect:N,nodeExtent:j,zIndexMode:A}=g();b[0][0]===j[0][0]&&b[0][1]===j[0][1]&&b[1][0]===j[1][0]&&b[1][1]===j[1][1]||(Ix(y,v,x,{nodeOrigin:C,nodeExtent:b,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:A}),h({nodeExtent:b}))},panBy:b=>{const{transform:y,width:v,height:x,panZoom:C,translateExtent:N}=g();return H4({delta:b,panZoom:C,transform:y,translateExtent:N,width:v,height:x})},setCenter:async(b,y,v)=>{const{width:x,height:C,maxZoom:N,panZoom:j}=g();if(!j)return Promise.resolve(!1);const A=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:N;return await j.setViewport({x:x/2-b*A,y:C/2-y*A,zoom:A},{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:{...eI}})},updateConnection:b=>{h({connection:b})},reset:()=>h({...Xj()})}},Object.is);function Rk({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:h}){const[g]=m.useState(()=>yW({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:d,nodeExtent:f,zIndexMode:p}));return o.jsx(OH,{value:g,children:o.jsx(i5,{children:h})})}function wW({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h}){return m.useContext(Um)?o.jsx(o.Fragment,{children:e}):o.jsx(Rk,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:p,zIndexMode:h,children:e})}const xW={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function bW({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:h,onConnectStart:g,onConnectEnd:k,onClickConnectStart:b,onClickConnectEnd:y,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:C,onNodeContextMenu:N,onNodeDoubleClick:j,onNodeDragStart:A,onNodeDrag:I,onNodeDragStop:O,onNodesDelete:H,onEdgesDelete:B,onDelete:z,onSelectionChange:$,onSelectionDragStart:M,onSelectionDrag:q,onSelectionDragStop:D,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:W,onBeforeDelete:E,connectionMode:Q,connectionLineType:V=To.Bezier,connectionLineStyle:F,connectionLineComponent:se,connectionLineContainerStyle:ce,deleteKeyCode:J="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:ee=!1,selectionMode:re=Td.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:le=$d()?"Meta":"Control",zoomActivationKeyCode:de=$d()?"Meta":"Control",snapToGrid:we,snapGrid:De,onlyRenderVisibleElements:Qe=!1,selectNodesOnDrag:Oe,nodesDraggable:st,autoPanOnNodeFocus:mt,nodesConnectable:kt,nodesFocusable:Pe,nodeOrigin:dt=LI,edgesFocusable:gt,edgesReconnectable:xe,elementsSelectable:Fe=!0,defaultViewport:Me=JH,minZoom:ue=.5,maxZoom:ve=2,translateExtent:Ve=Rd,preventScrolling:qe=!0,nodeExtent:be,defaultMarkerColor:Tt="#b1b1b7",zoomOnScroll:ln=!0,zoomOnPinch:_t=!0,panOnScroll:hn=!1,panOnScrollSpeed:tn=.5,panOnScrollMode:te=Da.Free,zoomOnDoubleClick:Ie=!0,panOnDrag:Ue=!0,onPaneClick:Ze,onPaneMouseEnter:Mt,onPaneMouseMove:At,onPaneMouseLeave:tr,onPaneScroll:kn,onPaneContextMenu:nr,paneClickDistance:vn=1,nodeClickDistance:Jn=0,children:Wn,onReconnect:ur,onReconnectStart:gs,onReconnectEnd:wr,onEdgeContextMenu:Rs,onEdgeDoubleClick:Fr,onEdgeMouseEnter:on,onEdgeMouseMove:xr,onEdgeMouseLeave:br,reconnectRadius:mn=10,onNodesChange:Vn,onEdgesChange:kr,noDragClassName:dr="nodrag",noWheelClassName:vt="nowheel",noPanClassName:Ut="nopan",fitView:ae,fitViewOptions:ke,connectOnClick:it,attributionPosition:bt,proOptions:cn,defaultEdgeOptions:On,elevateNodesOnSelect:nn=!0,elevateEdgesOnSelect:vr=!1,disableKeyboardA11y:ft=!1,autoPanOnConnect:Yt,autoPanOnNodeDrag:Gt,autoPanSpeed:Sr,connectionRadius:tt,isValidConnection:Xn,onError:Mi,style:zr,id:ho,nodeDragThreshold:ai,connectionDragThreshold:Ts,viewport:ie,onViewportChange:Se,width:Ee,height:wt,colorMode:Ot="light",debug:Vt,onScroll:Dn,ariaLabelConfig:Mn,zIndexMode:K="basic",...pe},$e){const Ce=ho||"1",et=e5(Ot),Sn=m.useCallback(St=>{St.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Dn==null||Dn(St)},[Dn]);return o.jsx("div",{"data-testid":"rf__wrapper",...pe,onScroll:Sn,style:{...zr,...xW},ref:$e,className:Gn(["react-flow",s,et]),id:ho,role:"application",children:o.jsxs(wW,{nodes:e,edges:t,width:Ee,height:wt,fitView:ae,fitViewOptions:ke,minZoom:ue,maxZoom:ve,nodeOrigin:dt,nodeExtent:be,zIndexMode:K,children:[o.jsx(ZH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:k,onClickConnectStart:b,onClickConnectEnd:y,nodesDraggable:st,autoPanOnNodeFocus:mt,nodesConnectable:kt,nodesFocusable:Pe,edgesFocusable:gt,edgesReconnectable:xe,elementsSelectable:Fe,elevateNodesOnSelect:nn,elevateEdgesOnSelect:vr,minZoom:ue,maxZoom:ve,nodeExtent:be,onNodesChange:Vn,onEdgesChange:kr,snapToGrid:we,snapGrid:De,connectionMode:Q,translateExtent:Ve,connectOnClick:it,defaultEdgeOptions:On,fitView:ae,fitViewOptions:ke,onNodesDelete:H,onEdgesDelete:B,onDelete:z,onNodeDragStart:A,onNodeDrag:I,onNodeDragStop:O,onSelectionDrag:q,onSelectionDragStart:M,onSelectionDragStop:D,onMove:d,onMoveStart:f,onMoveEnd:p,noPanClassName:Ut,nodeOrigin:dt,rfId:Ce,autoPanOnConnect:Yt,autoPanOnNodeDrag:Gt,autoPanSpeed:Sr,onError:Mi,connectionRadius:tt,isValidConnection:Xn,selectNodesOnDrag:Oe,nodeDragThreshold:ai,connectionDragThreshold:Ts,onBeforeDelete:E,debug:Vt,ariaLabelConfig:Mn,zIndexMode:K}),o.jsx(gW,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:x,onNodeMouseLeave:C,onNodeContextMenu:N,onNodeDoubleClick:j,nodeTypes:i,edgeTypes:a,connectionLineType:V,connectionLineStyle:F,connectionLineComponent:se,connectionLineContainerStyle:ce,selectionKeyCode:ne,selectionOnDrag:ee,selectionMode:re,deleteKeyCode:J,multiSelectionKeyCode:le,panActivationKeyCode:Z,zoomActivationKeyCode:de,onlyRenderVisibleElements:Qe,defaultViewport:Me,translateExtent:Ve,minZoom:ue,maxZoom:ve,preventScrolling:qe,zoomOnScroll:ln,zoomOnPinch:_t,zoomOnDoubleClick:Ie,panOnScroll:hn,panOnScrollSpeed:tn,panOnScrollMode:te,panOnDrag:Ue,onPaneClick:Ze,onPaneMouseEnter:Mt,onPaneMouseMove:At,onPaneMouseLeave:tr,onPaneScroll:kn,onPaneContextMenu:nr,paneClickDistance:vn,nodeClickDistance:Jn,onSelectionContextMenu:L,onSelectionStart:T,onSelectionEnd:W,onReconnect:ur,onReconnectStart:gs,onReconnectEnd:wr,onEdgeContextMenu:Rs,onEdgeDoubleClick:Fr,onEdgeMouseEnter:on,onEdgeMouseMove:xr,onEdgeMouseLeave:br,reconnectRadius:mn,defaultMarkerColor:Tt,noDragClassName:dr,noWheelClassName:vt,noPanClassName:Ut,rfId:Ce,disableKeyboardA11y:ft,nodeExtent:be,viewport:ie,onViewportChange:Se}),o.jsx(GH,{onSelectionChange:$}),Wn,o.jsx(VH,{proOptions:cn,position:bt}),o.jsx(WH,{rfId:Ce,disableKeyboardA11y:ft})]})})}var lR=DI(bW);function kW(){const e=bn();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 vW(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>Uh(s,i)),[]);return[t,n,r]}function SW(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(i=>Yh(s,i)),[]);return[t,n,r]}function NW({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 jW({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:Gn(["react-flow__background-pattern","dots",t])})}var Uo;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Uo||(Uo={}));const CW={[Uo.Dots]:1,[Uo.Lines]:1,[Uo.Cross]:6},_W=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function cR({id:e,variant:t=Uo.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:c,className:u,patternClassName:d}){const f=m.useRef(null),{transform:p,patternId:h}=Bt(_W,Cn),g=r||CW[t],k=t===Uo.Dots,b=t===Uo.Cross,y=Array.isArray(n)?n:[n,n],v=[y[0]*p[2]||1,y[1]*p[2]||1],x=g*p[2],C=Array.isArray(i)?i:[i,i],N=b?[x,x]:v,j=[C[0]*p[2]||1+N[0]/2,C[1]*p[2]||1+N[1]/2],A=`${h}${e||""}`;return o.jsxs("svg",{className:Gn(["react-flow__background",u]),style:{...c,...Gm,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[o.jsx("pattern",{id:A,x:p[0]%v[0],y:p[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:k?o.jsx(jW,{radius:x/2,className:d}):o.jsx(NW,{dimensions:N,lineWidth:s,variant:t,className:d})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${A})`})]})}cR.displayName="Background";const uR=m.memo(cR);function EW(){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 AW(){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 PW(){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 IW(){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 RW(){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 bp({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:Gn(["react-flow__controls-button",t]),...n,children:e})}const TW=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function dR({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:d,position:f="bottom-left",orientation:p="vertical","aria-label":h}){const g=bn(),{isInteractive:k,minZoomReached:b,maxZoomReached:y,ariaLabelConfig:v}=Bt(TW,Cn),{zoomIn:x,zoomOut:C,fitView:N}=Oc(),j=()=>{x(),i==null||i()},A=()=>{C(),a==null||a()},I=()=>{N(s),l==null||l()},O=()=>{g.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),c==null||c(!k)},H=p==="horizontal"?"horizontal":"vertical";return o.jsxs(Ym,{className:Gn(["react-flow__controls",H,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??v["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(bp,{onClick:j,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(EW,{})}),o.jsx(bp,{onClick:A,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:b,children:o.jsx(AW,{})})]}),n&&o.jsx(bp,{className:"react-flow__controls-fitview",onClick:I,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:o.jsx(PW,{})}),r&&o.jsx(bp,{className:"react-flow__controls-interactive",onClick:O,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:k?o.jsx(RW,{}):o.jsx(IW,{})}),d]})}dR.displayName="Controls";m.memo(dR);function MW({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:d,shapeRendering:f,selected:p,onClick:h}){const{background:g,backgroundColor:k}=i||{},b=a||g||k;return o.jsx("rect",{className:Gn(["react-flow__minimap-node",{selected:p},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?y=>h(y,e):void 0})}const $W=m.memo(MW),LW=e=>e.nodes.map(t=>t.id),Ly=e=>e instanceof Function?e:()=>e;function OW({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=$W,onClick:a}){const l=Bt(LW,Cn),c=Ly(t),u=Ly(e),d=Ly(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(FW,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:f},p))})}function DW({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:d,y:f,width:p,height:h}=Bt(g=>{const k=g.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const b=k.internals.userNode,{x:y,y:v}=k.internals.positionAbsolute,{width:x,height:C}=uo(b);return{node:b,x:y,y:v,width:x,height:C}},Cn);return!u||u.hidden||!aI(u)?null:o.jsx(l,{x:d,y:f,width:p,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:s,strokeColor:n(u),strokeWidth:i,shapeRendering:a,onClick:c,id:u.id})}const FW=m.memo(DW);var zW=m.memo(OW);const BW=200,HW=150,WW=e=>!e.hidden,VW=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?oI(af(e.nodeLookup,{filter:WW}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},KW="react-flow__minimap-desc";function fR({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:p="bottom-right",onClick:h,onNodeClick:g,pannable:k=!1,zoomable:b=!1,ariaLabel:y,inversePan:v,zoomStep:x=1,offsetScale:C=5}){const N=bn(),j=m.useRef(null),{boundingRect:A,viewBB:I,rfId:O,panZoom:H,translateExtent:B,flowWidth:z,flowHeight:$,ariaLabelConfig:M}=Bt(VW,Cn),q=(e==null?void 0:e.width)??BW,D=(e==null?void 0:e.height)??HW,L=A.width/q,T=A.height/D,W=Math.max(L,T),E=W*q,Q=W*D,V=C*W,F=A.x-(E-A.width)/2-V,se=A.y-(Q-A.height)/2-V,ce=E+V*2,J=Q+V*2,ne=`${KW}-${O}`,ee=m.useRef(0),re=m.useRef();ee.current=W,m.useEffect(()=>{if(j.current&&H)return re.current=X4({domNode:j.current,panZoom:H,getTransform:()=>N.getState().transform,getViewScale:()=>ee.current}),()=>{var we;(we=re.current)==null||we.destroy()}},[H]),m.useEffect(()=>{var we;(we=re.current)==null||we.update({translateExtent:B,width:z,height:$,inversePan:v,pannable:k,zoomStep:x,zoomable:b})},[k,b,v,x,B,z,$]);const Z=h?we=>{var Oe;const[De,Qe]=((Oe=re.current)==null?void 0:Oe.pointer(we))||[0,0];h(we,{x:De,y:Qe})}:void 0,le=g?m.useCallback((we,De)=>{const Qe=N.getState().nodeLookup.get(De).internals.userNode;g(we,Qe)},[]):void 0,de=y??M["minimap.ariaLabel"];return o.jsx(Ym,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*W:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:Gn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:q,height:D,viewBox:`${F} ${se} ${ce} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:j,onClick:Z,children:[de&&o.jsx("title",{id:ne,children:de}),o.jsx(zW,{onClick:le,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${F-V},${se-V}h${ce+V*2}v${J+V*2}h${-ce-V*2}z
66
- M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}fR.displayName="MiniMap";m.memo(fR);const qW=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,UW={[Ac.Line]:"right",[Ac.Handle]:"bottom-right"};function YW({nodeId:e,position:t,variant:n=Ac.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:p,autoScale:h=!0,shouldResize:g,onResizeStart:k,onResize:b,onResizeEnd:y}){const v=HI(),x=typeof e=="string"?e:v,C=bn(),N=m.useRef(null),j=n===Ac.Handle,A=Bt(m.useCallback(qW(j&&h),[j,h]),Cn),I=m.useRef(null),O=t??UW[n];m.useEffect(()=>{if(!(!N.current||!x))return I.current||(I.current=dH({domNode:N.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:B,transform:z,snapGrid:$,snapToGrid:M,nodeOrigin:q,domNode:D}=C.getState();return{nodeLookup:B,transform:z,snapGrid:$,snapToGrid:M,nodeOrigin:q,paneDomNode:D}},onChange:(B,z)=>{const{triggerNodeChanges:$,nodeLookup:M,parentLookup:q,nodeOrigin:D}=C.getState(),L=[],T={x:B.x,y:B.y},W=M.get(x);if(W&&W.expandParent&&W.parentId){const E=W.origin??D,Q=B.width??W.measured.width??0,V=B.height??W.measured.height??0,F={id:W.id,parentId:W.parentId,rect:{width:Q,height:V,...lI({x:B.x??W.position.x,y:B.y??W.position.y},{width:Q,height:V},W.parentId,M,E)}},se=Pk([F],M,q,D);L.push(...se),T.x=B.x?Math.max(E[0]*Q,B.x):void 0,T.y=B.y?Math.max(E[1]*V,B.y):void 0}if(T.x!==void 0&&T.y!==void 0){const E={id:x,type:"position",position:{...T}};L.push(E)}if(B.width!==void 0&&B.height!==void 0){const Q={id:x,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};L.push(Q)}for(const E of z){const Q={...E,type:"position"};L.push(Q)}$(L)},onEnd:({width:B,height:z})=>{const $={id:x,type:"dimensions",resizing:!1,dimensions:{width:B,height:z}};C.getState().triggerNodeChanges([$])}})),I.current.update({controlPosition:O,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:k,onResize:b,onResizeEnd:y,shouldResize:g}),()=>{var B;(B=I.current)==null||B.destroy()}},[O,l,c,u,d,f,k,b,y,g]);const H=O.split("-");return o.jsx("div",{className:Gn(["react-flow__resize-control","nodrag",...H,n,r]),ref:N,style:{...s,scale:A,...a&&{[j?"backgroundColor":"borderColor"]:a}},children:i})}const Tk=m.memo(YW),GW="modulepreload",JW=function(e){return"/"+e},Qj={},XW=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=JW(c),c in Qj)return;Qj[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":GW,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};function QW(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ZW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,e6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,t6={};function Zj(e,t){return(t6.jsx?e6:ZW).test(e)}const n6=/[ \t\n\f\r]/g;function r6(e){return typeof e=="object"?e.type==="text"?e1(e.value):!1:e1(e)}function e1(e){return e.replace(n6,"")===""}class uf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}uf.prototype.normal={};uf.prototype.property={};uf.prototype.space=void 0;function pR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new uf(n,r,t)}function $x(e){return e.toLowerCase()}class es{constructor(t,n){this.attribute=n,this.property=t}}es.prototype.attribute="";es.prototype.booleanish=!1;es.prototype.boolean=!1;es.prototype.commaOrSpaceSeparated=!1;es.prototype.commaSeparated=!1;es.prototype.defined=!1;es.prototype.mustUseProperty=!1;es.prototype.number=!1;es.prototype.overloadedBoolean=!1;es.prototype.property="";es.prototype.spaceSeparated=!1;es.prototype.space=void 0;let s6=0;const jt=il(),qn=il(),Lx=il(),Ae=il(),dn=il(),uc=il(),ss=il();function il(){return 2**++s6}const Ox=Object.freeze(Object.defineProperty({__proto__:null,boolean:jt,booleanish:qn,commaOrSpaceSeparated:ss,commaSeparated:uc,number:Ae,overloadedBoolean:Lx,spaceSeparated:dn},Symbol.toStringTag,{value:"Module"})),Oy=Object.keys(Ox);class Mk extends es{constructor(t,n,r,s){let i=-1;if(super(t,n),t1(this,"space",s),typeof r=="number")for(;++i<Oy.length;){const a=Oy[i];t1(this,Oy[i],(r&Ox[a])===Ox[a])}}}Mk.prototype.defined=!0;function t1(e,t,n){n&&(e[t]=n)}function Dc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new Mk(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[$x(r)]=r,n[$x(i.attribute)]=r}return new uf(t,n,e.space)}const hR=Dc({properties:{ariaActiveDescendant:null,ariaAtomic:qn,ariaAutoComplete:null,ariaBusy:qn,ariaChecked:qn,ariaColCount:Ae,ariaColIndex:Ae,ariaColSpan:Ae,ariaControls:dn,ariaCurrent:null,ariaDescribedBy:dn,ariaDetails:null,ariaDisabled:qn,ariaDropEffect:dn,ariaErrorMessage:null,ariaExpanded:qn,ariaFlowTo:dn,ariaGrabbed:qn,ariaHasPopup:null,ariaHidden:qn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:dn,ariaLevel:Ae,ariaLive:null,ariaModal:qn,ariaMultiLine:qn,ariaMultiSelectable:qn,ariaOrientation:null,ariaOwns:dn,ariaPlaceholder:null,ariaPosInSet:Ae,ariaPressed:qn,ariaReadOnly:qn,ariaRelevant:null,ariaRequired:qn,ariaRoleDescription:dn,ariaRowCount:Ae,ariaRowIndex:Ae,ariaRowSpan:Ae,ariaSelected:qn,ariaSetSize:Ae,ariaSort:null,ariaValueMax:Ae,ariaValueMin:Ae,ariaValueNow:Ae,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function mR(e,t){return t in e?e[t]:t}function gR(e,t){return mR(e,t.toLowerCase())}const i6=Dc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:uc,acceptCharset:dn,accessKey:dn,action:null,allow:null,allowFullScreen:jt,allowPaymentRequest:jt,allowUserMedia:jt,alt:null,as:null,async:jt,autoCapitalize:null,autoComplete:dn,autoFocus:jt,autoPlay:jt,blocking:dn,capture:null,charSet:null,checked:jt,cite:null,className:dn,cols:Ae,colSpan:null,content:null,contentEditable:qn,controls:jt,controlsList:dn,coords:Ae|uc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:jt,defer:jt,dir:null,dirName:null,disabled:jt,download:Lx,draggable:qn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:jt,formTarget:null,headers:dn,height:Ae,hidden:Lx,high:Ae,href:null,hrefLang:null,htmlFor:dn,httpEquiv:dn,id:null,imageSizes:null,imageSrcSet:null,inert:jt,inputMode:null,integrity:null,is:null,isMap:jt,itemId:null,itemProp:dn,itemRef:dn,itemScope:jt,itemType:dn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:jt,low:Ae,manifest:null,max:null,maxLength:Ae,media:null,method:null,min:null,minLength:Ae,multiple:jt,muted:jt,name:null,nonce:null,noModule:jt,noValidate:jt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:jt,optimum:Ae,pattern:null,ping:dn,placeholder:null,playsInline:jt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:jt,referrerPolicy:null,rel:dn,required:jt,reversed:jt,rows:Ae,rowSpan:Ae,sandbox:dn,scope:null,scoped:jt,seamless:jt,selected:jt,shadowRootClonable:jt,shadowRootDelegatesFocus:jt,shadowRootMode:null,shape:null,size:Ae,sizes:null,slot:null,span:Ae,spellCheck:qn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ae,step:null,style:null,tabIndex:Ae,target:null,title:null,translate:null,type:null,typeMustMatch:jt,useMap:null,value:qn,width:Ae,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:dn,axis:null,background:null,bgColor:null,border:Ae,borderColor:null,bottomMargin:Ae,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:jt,declare:jt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ae,leftMargin:Ae,link:null,longDesc:null,lowSrc:null,marginHeight:Ae,marginWidth:Ae,noResize:jt,noHref:jt,noShade:jt,noWrap:jt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ae,rules:null,scheme:null,scrolling:qn,standby:null,summary:null,text:null,topMargin:Ae,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ae,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:jt,disableRemotePlayback:jt,prefix:null,property:null,results:Ae,security:null,unselectable:null},space:"html",transform:gR}),o6=Dc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ss,accentHeight:Ae,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ae,amplitude:Ae,arabicForm:null,ascent:Ae,attributeName:null,attributeType:null,azimuth:Ae,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ae,by:null,calcMode:null,capHeight:Ae,className:dn,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:Ae,diffuseConstant:Ae,direction:null,display:null,dur:null,divisor:Ae,dominantBaseline:null,download:jt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ae,enableBackground:null,end:null,event:null,exponent:Ae,externalResourcesRequired:null,fill:null,fillOpacity:Ae,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:uc,g2:uc,glyphName:uc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ae,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ae,horizOriginX:Ae,horizOriginY:Ae,id:null,ideographic:Ae,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ae,k:Ae,k1:Ae,k2:Ae,k3:Ae,k4:Ae,kernelMatrix:ss,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ae,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:Ae,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:Ae,overlineThickness:Ae,paintOrder:null,panose1:null,path:null,pathLength:Ae,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:dn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ae,pointsAtY:Ae,pointsAtZ:Ae,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ss,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ss,rev:ss,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ss,requiredFeatures:ss,requiredFonts:ss,requiredFormats:ss,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ae,specularExponent:Ae,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ae,strikethroughThickness:Ae,string:null,stroke:null,strokeDashArray:ss,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ae,strokeOpacity:Ae,strokeWidth:null,style:null,surfaceScale:Ae,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ss,tabIndex:Ae,tableValues:null,target:null,targetX:Ae,targetY:Ae,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ss,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ae,underlineThickness:Ae,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ae,values:null,vAlphabetic:Ae,vMathematical:Ae,vectorEffect:null,vHanging:Ae,vIdeographic:Ae,version:null,vertAdvY:Ae,vertOriginX:Ae,vertOriginY:Ae,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ae,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:mR}),yR=Dc({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()}}),wR=Dc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:gR}),xR=Dc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),a6={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"},l6=/[A-Z]/g,n1=/-[a-z]/g,c6=/^data[-\w.:]+$/i;function u6(e,t){const n=$x(t);let r=t,s=es;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&c6.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(n1,f6);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!n1.test(i)){let a=i.replace(l6,d6);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Mk}return new s(r,t)}function d6(e){return"-"+e.toLowerCase()}function f6(e){return e.charAt(1).toUpperCase()}const p6=pR([hR,i6,yR,wR,xR],"html"),$k=pR([hR,o6,yR,wR,xR],"svg");function h6(e){return e.join(" ").trim()}var Lk={},r1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,m6=/\n/g,g6=/^\s*/,y6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,w6=/^:\s*/,x6=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,b6=/^[;\s]*/,k6=/^\s+|\s+$/g,v6=`
67
- `,s1="/",i1="*",ja="",S6="comment",N6="declaration";function j6(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 k=g.match(m6);k&&(n+=k.length);var b=g.lastIndexOf(v6);r=~b?g.length-b:r+g.length}function i(){var g={line:n,column:r};return function(k){return k.position=new a(g),u(),k}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var k=new Error(t.source+":"+n+":"+r+": "+g);if(k.reason=g,k.filename=t.source,k.line=n,k.column=r,k.source=e,!t.silent)throw k}function c(g){var k=g.exec(e);if(k){var b=k[0];return s(b),e=e.slice(b.length),k}}function u(){c(g6)}function d(g){var k;for(g=g||[];k=f();)k!==!1&&g.push(k);return g}function f(){var g=i();if(!(s1!=e.charAt(0)||i1!=e.charAt(1))){for(var k=2;ja!=e.charAt(k)&&(i1!=e.charAt(k)||s1!=e.charAt(k+1));)++k;if(k+=2,ja===e.charAt(k-1))return l("End of comment missing");var b=e.slice(2,k-2);return r+=2,s(b),e=e.slice(k),r+=2,g({type:S6,comment:b})}}function p(){var g=i(),k=c(y6);if(k){if(f(),!c(w6))return l("property missing ':'");var b=c(x6),y=g({type:N6,property:o1(k[0].replace(r1,ja)),value:b?o1(b[0].replace(r1,ja)):ja});return c(b6),y}}function h(){var g=[];d(g);for(var k;k=p();)k!==!1&&(g.push(k),d(g));return g}return u(),h()}function o1(e){return e?e.replace(k6,ja):ja}var C6=j6,_6=ud&&ud.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Lk,"__esModule",{value:!0});Lk.default=A6;const E6=_6(C6);function A6(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,E6.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 Xm={};Object.defineProperty(Xm,"__esModule",{value:!0});Xm.camelCase=void 0;var P6=/^--[a-zA-Z0-9_-]+$/,I6=/-([a-z])/g,R6=/^[^-]+$/,T6=/^-(webkit|moz|ms|o|khtml)-/,M6=/^-(ms)-/,$6=function(e){return!e||R6.test(e)||P6.test(e)},L6=function(e,t){return t.toUpperCase()},a1=function(e,t){return"".concat(t,"-")},O6=function(e,t){return t===void 0&&(t={}),$6(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(M6,a1):e=e.replace(T6,a1),e.replace(I6,L6))};Xm.camelCase=O6;var D6=ud&&ud.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},F6=D6(Lk),z6=Xm;function Dx(e,t){var n={};return!e||typeof e!="string"||(0,F6.default)(e,function(r,s){r&&s&&(n[(0,z6.camelCase)(r,t)]=s)}),n}Dx.default=Dx;var B6=Dx;const H6=ra(B6),bR=kR("end"),Ok=kR("start");function kR(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 W6(e){const t=Ok(e),n=bR(e);if(t&&n)return{start:t,end:n}}function sd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?l1(e.position):"start"in e||"end"in e?l1(e):"line"in e||"column"in e?Fx(e):""}function Fx(e){return c1(e&&e.line)+":"+c1(e&&e.column)}function l1(e){return Fx(e&&e.start)+"-"+Fx(e&&e.end)}function c1(e){return e&&typeof e=="number"?e:1}class Pr 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=sd(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}}Pr.prototype.file="";Pr.prototype.name="";Pr.prototype.reason="";Pr.prototype.message="";Pr.prototype.stack="";Pr.prototype.column=void 0;Pr.prototype.line=void 0;Pr.prototype.ancestors=void 0;Pr.prototype.cause=void 0;Pr.prototype.fatal=void 0;Pr.prototype.place=void 0;Pr.prototype.ruleId=void 0;Pr.prototype.source=void 0;const Dk={}.hasOwnProperty,V6=new Map,K6=/[A-Z]/g,q6=new Set(["table","tbody","thead","tfoot","tr"]),U6=new Set(["td","th"]),vR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Y6(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=n8(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=t8(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"?$k:p6,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=SR(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function SR(e,t,n){if(t.type==="element")return G6(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return J6(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Q6(e,t,n);if(t.type==="mdxjsEsm")return X6(e,t);if(t.type==="root")return Z6(e,t,n);if(t.type==="text")return e8(e,t)}function G6(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=$k,e.schema=s),e.ancestors.push(t);const i=jR(e,t.tagName,!1),a=r8(e,t);let l=zk(e,t);return q6.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!r6(c):!0})),NR(e,a,i,t),Fk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function J6(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)}Od(e,t.position)}function X6(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Od(e,t.position)}function Q6(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=$k,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:jR(e,t.name,!0),a=s8(e,t),l=zk(e,t);return NR(e,a,i,t),Fk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function Z6(e,t,n){const r={};return Fk(r,zk(e,t)),e.create(t,e.Fragment,r,n)}function e8(e,t){return t.value}function NR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Fk(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function t8(e,t,n){return r;function r(s,i,a,l){const u=Array.isArray(a.children)?n:t;return l?u(i,a,l):u(i,a)}}function n8(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),c=Ok(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 r8(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Dk.call(t.properties,s)){const i=i8(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&U6.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 s8(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 Od(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 Od(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function zk(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:V6;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 u=s.get(c)||0;a=c+"-"+u,s.set(c,u+1)}}const l=SR(e,i,a);l!==void 0&&n.push(l)}return n}function i8(e,t,n){const r=u6(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?QW(n):h6(n)),r.property==="style"){let s=typeof n=="object"?n:o8(e,String(n));return e.stylePropertyNameCase==="css"&&(s=a8(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?a6[r.property]||r.property:r.attribute,n]}}function o8(e,t){try{return H6(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Pr("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=vR+"#cannot-parse-style-attribute",s}}function jR(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=Zj(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=Zj(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Dk.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Od(e)}function Od(e,t){const n=new Pr("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=vR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function a8(e){const t={};let n;for(n in e)Dk.call(e,n)&&(t[l8(n)]=e[n]);return t}function l8(e){let t=e.replace(K6,c8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function c8(e){return"-"+e.toLowerCase()}const Dy={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"]},u8={};function d8(e,t){const n=u8,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return CR(e,r,s)}function CR(e,t,n){if(f8(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 u1(e.children,t,n)}return Array.isArray(e)?u1(e,t,n):""}function u1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=CR(e[s],t,n);return r.join("")}function f8(e){return!!(e&&typeof e=="object")}const d1=document.createElement("i");function Bk(e){const t="&"+e+";";d1.innerHTML=t;const n=d1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ii(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 Cs(e,t){return e.length>0?(Ii(e,e.length,0,t),e):t}const f1={}.hasOwnProperty;function p8(e){const t={};let n=-1;for(;++n<e.length;)h8(t,e[n]);return t}function h8(e,t){let n;for(n in t){const s=(f1.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){f1.call(s,a)||(s[a]=[]);const l=i[a];m8(s[a],Array.isArray(l)?l:l?[l]:[])}}}function m8(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ii(e,0,0,r)}function _R(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 dc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const bi=aa(/[A-Za-z]/),cs=aa(/[\dA-Za-z]/),g8=aa(/[#-'*+\--9=?A-Z^-~]/);function zx(e){return e!==null&&(e<32||e===127)}const Bx=aa(/\d/),y8=aa(/[\dA-Fa-f]/),w8=aa(/[!-/:-@[-`{-~]/);function yt(e){return e!==null&&e<-2}function Zr(e){return e!==null&&(e<0||e===32)}function Jt(e){return e===-2||e===-1||e===32}const x8=aa(new RegExp("\\p{P}|\\p{S}","u")),b8=aa(/\s/);function aa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Fc(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&cs(e.charCodeAt(n+1))&&cs(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 pn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return Jt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Jt(c)&&i++<s?(e.consume(c),l):(e.exit(n),t(c))}}const k8={tokenize:v8};function v8(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"),pn(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return yt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const S8={tokenize:N8},p1={tokenize:j8};function N8(e){const t=this,n=[];let r=0,s,i,a;return l;function l(x){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const C=t.events.length;let N=C,j;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){j=t.events[N][1].end;break}y(r);let A=C;for(;A<t.events.length;)t.events[A][1].end={...j},A++;return Ii(t.events,N+1,0,t.events.slice(C)),t.events.length=A,u(x)}return l(x)}function u(x){if(r===n.length){if(!s)return p(x);if(s.currentConstruct&&s.currentConstruct.concrete)return g(x);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(p1,d,f)(x)}function d(x){return s&&v(),y(r),p(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(x)}function p(x){return t.containerState={},e.attempt(p1,h,g)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),p(x)}function g(x){if(x===null){s&&v(),y(0),e.consume(x);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),k(x)}function k(x){if(x===null){b(e.exit("chunkFlow"),!0),y(0),e.consume(x);return}return yt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),k)}function b(x,C){const N=t.sliceStream(x);if(C&&N.push(null),x.previous=i,i&&(i.next=x),i=x,s.defineSkip(x.start),s.write(N),t.parser.lazy[x.start.line]){let j=s.events.length;for(;j--;)if(s.events[j][1].start.offset<a&&(!s.events[j][1].end||s.events[j][1].end.offset>a))return;const A=t.events.length;let I=A,O,H;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){if(O){H=t.events[I][1].end;break}O=!0}for(y(r),j=A;j<t.events.length;)t.events[j][1].end={...H},j++;Ii(t.events,I+1,0,t.events.slice(A)),t.events.length=j}}function y(x){let C=n.length;for(;C-- >x;){const N=n[C];t.containerState=N[1],N[0].exit.call(t,e)}n.length=x}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function j8(e,t,n){return pn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function h1(e){if(e===null||Zr(e)||b8(e))return 1;if(x8(e))return 2}function Hk(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 Hx={name:"attention",resolveAll:C8,tokenize:_8};function C8(e,t){let n=-1,r,s,i,a,l,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},p={...e[n][1].start};m1(f,-c),m1(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},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Cs(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Cs(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),u=Cs(u,Hk(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Cs(u,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Cs(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Ii(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function _8(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=h1(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 u=e.exit("attentionSequence"),d=h1(c),f=!d||d===2&&s||n.includes(c),p=!s||s===2&&d||n.includes(r);return u._open=!!(i===42?f:f&&(s||!p)),u._close=!!(i===42?p:p&&(d||!f)),t(c)}}function m1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const E8={name:"autolink",tokenize:A8};function A8(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 bi(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||cs(h)?(r=1,l(h)):u(h)}function l(h){return h===58?(e.consume(h),r=0,c):(h===43||h===45||h===46||cs(h))&&r++<32?(e.consume(h),l):(r=0,u(h))}function c(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||zx(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):g8(h)?(e.consume(h),u):n(h)}function d(h){return cs(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||cs(h))&&r++<63){const g=h===45?p:f;return e.consume(h),g}return n(h)}}const Qm={partial:!0,tokenize:P8};function P8(e,t,n){return r;function r(i){return Jt(i)?pn(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||yt(i)?t(i):n(i)}}const ER={continuation:{tokenize:R8},exit:T8,name:"blockQuote",tokenize:I8};function I8(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 Jt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function R8(e,t,n){const r=this;return s;function s(a){return Jt(a)?pn(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(ER,t,n)(a)}}function T8(e){e.exit("blockQuote")}const AR={name:"characterEscape",tokenize:M8};function M8(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 w8(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const PR={name:"characterReference",tokenize:$8};function $8(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"),u):(e.enter("characterReferenceValue"),i=31,a=cs,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=y8,d):(e.enter("characterReferenceValue"),i=7,a=Bx,d(f))}function d(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===cs&&!Bk(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),d):n(f)}}const g1={partial:!0,tokenize:O8},y1={concrete:!0,name:"codeFenced",tokenize:L8};function L8(e,t,n){const r=this,s={partial:!0,tokenize:N};let i=0,a=0,l;return c;function c(j){return u(j)}function u(j){const A=r.events[r.events.length-1];return i=A&&A[1].type==="linePrefix"?A[2].sliceSerialize(A[1],!0).length:0,l=j,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(j)}function d(j){return j===l?(a++,e.consume(j),d):a<3?n(j):(e.exit("codeFencedFenceSequence"),Jt(j)?pn(e,f,"whitespace")(j):f(j))}function f(j){return j===null||yt(j)?(e.exit("codeFencedFence"),r.interrupt?t(j):e.check(g1,k,C)(j)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(j))}function p(j){return j===null||yt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(j)):Jt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),pn(e,h,"whitespace")(j)):j===96&&j===l?n(j):(e.consume(j),p)}function h(j){return j===null||yt(j)?f(j):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(j))}function g(j){return j===null||yt(j)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(j)):j===96&&j===l?n(j):(e.consume(j),g)}function k(j){return e.attempt(s,C,b)(j)}function b(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),y}function y(j){return i>0&&Jt(j)?pn(e,v,"linePrefix",i+1)(j):v(j)}function v(j){return j===null||yt(j)?e.check(g1,k,C)(j):(e.enter("codeFlowValue"),x(j))}function x(j){return j===null||yt(j)?(e.exit("codeFlowValue"),v(j)):(e.consume(j),x)}function C(j){return e.exit("codeFenced"),t(j)}function N(j,A,I){let O=0;return H;function H(q){return j.enter("lineEnding"),j.consume(q),j.exit("lineEnding"),B}function B(q){return j.enter("codeFencedFence"),Jt(q)?pn(j,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):z(q)}function z(q){return q===l?(j.enter("codeFencedFenceSequence"),$(q)):I(q)}function $(q){return q===l?(O++,j.consume(q),$):O>=a?(j.exit("codeFencedFenceSequence"),Jt(q)?pn(j,M,"whitespace")(q):M(q)):I(q)}function M(q){return q===null||yt(q)?(j.exit("codeFencedFence"),A(q)):I(q)}}}function O8(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 Fy={name:"codeIndented",tokenize:F8},D8={partial:!0,tokenize:z8};function F8(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),pn(e,i,"linePrefix",5)(u)}function i(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):yt(u)?e.attempt(D8,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||yt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function z8(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):yt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):pn(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):yt(a)?s(a):n(a)}}const B8={name:"codeText",previous:W8,resolve:H8,tokenize:V8};function H8(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 W8(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function V8(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,d(f)):yt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||yt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(i.type="codeTextData",u(f))}}class K8{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&&ju(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),ju(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ju(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);ju(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ju(this.left,n.reverse())}}}function ju(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 IR(e){const t={};let n=-1,r,s,i,a,l,c,u;const d=new K8(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,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,q8(d,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=d.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(d.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={...d.get(s)[1].start},l=d.slice(s,n),l.unshift(r),d.splice(s,n-s+1,l))}}return Ii(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function q8(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=[],u={};let d,f,p=-1,h=n,g=0,k=0;const b=[k];for(;h;){for(;e.get(++s)[1]!==h;);i.push(s),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++p<l.length;)l[p][0]==="exit"&&l[p-1][0]==="enter"&&l[p][1].type===l[p-1][1].type&&l[p][1].start.line!==l[p][1].end.line&&(k=p+1,b.push(k),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),p=b.length;p--;){const y=l.slice(b[p],b[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;)u[g+c[p][0]]=g+c[p][1],g+=c[p][1]-c[p][0]-1;return u}const U8={resolve:G8,tokenize:J8},Y8={partial:!0,tokenize:X8};function G8(e){return IR(e),e}function J8(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?i(l):yt(l)?e.check(Y8,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 X8(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),pn(e,i,"linePrefix")}function i(a){if(a===null||yt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function RR(e,t,n,r,s,i,a,l,c){const u=c||Number.POSITIVE_INFINITY;let d=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||zx(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),k(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||yt(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 k(y){return!d&&(y===null||y===41||Zr(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):d<u&&y===40?(e.consume(y),d++,k):y===41?(e.consume(y),d--,k):y===null||y===32||y===40||zx(y)?n(y):(e.consume(y),y===92?b:k)}function b(y){return y===40||y===41||y===92?(e.consume(y),k):k(y)}}function TR(e,t,n,r,s,i){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(s),e.consume(h),e.exit(s),e.enter(i),d}function d(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(i),e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):yt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||yt(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!Jt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function MR(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),u(p))}function u(p){return p===a?(e.exit(i),c(a)):p===null?n(p):yt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),pn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||yt(p)?(e.exit("chunkString"),u(p)):(e.consume(p),p===92?f:d)}function f(p){return p===a||p===92?(e.consume(p),d):d(p)}}function id(e,t){let n;return r;function r(s){return yt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Jt(s)?pn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const Q8={name:"definition",tokenize:e9},Z8={partial:!0,tokenize:t9};function e9(e,t,n){const r=this;let s;return i;function i(h){return e.enter("definition"),a(h)}function a(h){return TR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=dc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),c):n(h)}function c(h){return Zr(h)?id(e,u)(h):u(h)}function u(h){return RR(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(Z8,f,f)(h)}function f(h){return Jt(h)?pn(e,p,"whitespace")(h):p(h)}function p(h){return h===null||yt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function t9(e,t,n){return r;function r(l){return Zr(l)?id(e,s)(l):n(l)}function s(l){return MR(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Jt(l)?pn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||yt(l)?t(l):n(l)}}const n9={name:"hardBreakEscape",tokenize:r9};function r9(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return yt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const s9={name:"headingAtx",resolve:i9,tokenize:o9};function i9(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"},Ii(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function o9(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),i(d)}function i(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&r++<6?(e.consume(d),a):d===null||Zr(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||yt(d)?(e.exit("atxHeading"),t(d)):Jt(d)?pn(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||Zr(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const a9=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],w1=["pre","script","style","textarea"],l9={concrete:!0,name:"htmlFlow",resolveTo:d9,tokenize:f9},c9={partial:!0,tokenize:h9},u9={partial:!0,tokenize:p9};function d9(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 f9(e,t,n){const r=this;let s,i,a,l,c;return u;function u(F){return d(F)}function d(F){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(F),f}function f(F){return F===33?(e.consume(F),p):F===47?(e.consume(F),i=!0,k):F===63?(e.consume(F),s=3,r.interrupt?t:E):bi(F)?(e.consume(F),a=String.fromCharCode(F),b):n(F)}function p(F){return F===45?(e.consume(F),s=2,h):F===91?(e.consume(F),s=5,l=0,g):bi(F)?(e.consume(F),s=4,r.interrupt?t:E):n(F)}function h(F){return F===45?(e.consume(F),r.interrupt?t:E):n(F)}function g(F){const se="CDATA[";return F===se.charCodeAt(l++)?(e.consume(F),l===se.length?r.interrupt?t:z:g):n(F)}function k(F){return bi(F)?(e.consume(F),a=String.fromCharCode(F),b):n(F)}function b(F){if(F===null||F===47||F===62||Zr(F)){const se=F===47,ce=a.toLowerCase();return!se&&!i&&w1.includes(ce)?(s=1,r.interrupt?t(F):z(F)):a9.includes(a.toLowerCase())?(s=6,se?(e.consume(F),y):r.interrupt?t(F):z(F)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(F):i?v(F):x(F))}return F===45||cs(F)?(e.consume(F),a+=String.fromCharCode(F),b):n(F)}function y(F){return F===62?(e.consume(F),r.interrupt?t:z):n(F)}function v(F){return Jt(F)?(e.consume(F),v):H(F)}function x(F){return F===47?(e.consume(F),H):F===58||F===95||bi(F)?(e.consume(F),C):Jt(F)?(e.consume(F),x):H(F)}function C(F){return F===45||F===46||F===58||F===95||cs(F)?(e.consume(F),C):N(F)}function N(F){return F===61?(e.consume(F),j):Jt(F)?(e.consume(F),N):x(F)}function j(F){return F===null||F===60||F===61||F===62||F===96?n(F):F===34||F===39?(e.consume(F),c=F,A):Jt(F)?(e.consume(F),j):I(F)}function A(F){return F===c?(e.consume(F),c=null,O):F===null||yt(F)?n(F):(e.consume(F),A)}function I(F){return F===null||F===34||F===39||F===47||F===60||F===61||F===62||F===96||Zr(F)?N(F):(e.consume(F),I)}function O(F){return F===47||F===62||Jt(F)?x(F):n(F)}function H(F){return F===62?(e.consume(F),B):n(F)}function B(F){return F===null||yt(F)?z(F):Jt(F)?(e.consume(F),B):n(F)}function z(F){return F===45&&s===2?(e.consume(F),D):F===60&&s===1?(e.consume(F),L):F===62&&s===4?(e.consume(F),Q):F===63&&s===3?(e.consume(F),E):F===93&&s===5?(e.consume(F),W):yt(F)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(c9,V,$)(F)):F===null||yt(F)?(e.exit("htmlFlowData"),$(F)):(e.consume(F),z)}function $(F){return e.check(u9,M,V)(F)}function M(F){return e.enter("lineEnding"),e.consume(F),e.exit("lineEnding"),q}function q(F){return F===null||yt(F)?$(F):(e.enter("htmlFlowData"),z(F))}function D(F){return F===45?(e.consume(F),E):z(F)}function L(F){return F===47?(e.consume(F),a="",T):z(F)}function T(F){if(F===62){const se=a.toLowerCase();return w1.includes(se)?(e.consume(F),Q):z(F)}return bi(F)&&a.length<8?(e.consume(F),a+=String.fromCharCode(F),T):z(F)}function W(F){return F===93?(e.consume(F),E):z(F)}function E(F){return F===62?(e.consume(F),Q):F===45&&s===2?(e.consume(F),E):z(F)}function Q(F){return F===null||yt(F)?(e.exit("htmlFlowData"),V(F)):(e.consume(F),Q)}function V(F){return e.exit("htmlFlow"),t(F)}}function p9(e,t,n){const r=this;return s;function s(a){return yt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function h9(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Qm,t,n)}}const m9={name:"htmlText",tokenize:g9};function g9(e,t,n){const r=this;let s,i,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),c}function c(E){return E===33?(e.consume(E),u):E===47?(e.consume(E),N):E===63?(e.consume(E),x):bi(E)?(e.consume(E),I):n(E)}function u(E){return E===45?(e.consume(E),d):E===91?(e.consume(E),i=0,g):bi(E)?(e.consume(E),v):n(E)}function d(E){return E===45?(e.consume(E),h):n(E)}function f(E){return E===null?n(E):E===45?(e.consume(E),p):yt(E)?(a=f,L(E)):(e.consume(E),f)}function p(E){return E===45?(e.consume(E),h):f(E)}function h(E){return E===62?D(E):E===45?p(E):f(E)}function g(E){const Q="CDATA[";return E===Q.charCodeAt(i++)?(e.consume(E),i===Q.length?k:g):n(E)}function k(E){return E===null?n(E):E===93?(e.consume(E),b):yt(E)?(a=k,L(E)):(e.consume(E),k)}function b(E){return E===93?(e.consume(E),y):k(E)}function y(E){return E===62?D(E):E===93?(e.consume(E),y):k(E)}function v(E){return E===null||E===62?D(E):yt(E)?(a=v,L(E)):(e.consume(E),v)}function x(E){return E===null?n(E):E===63?(e.consume(E),C):yt(E)?(a=x,L(E)):(e.consume(E),x)}function C(E){return E===62?D(E):x(E)}function N(E){return bi(E)?(e.consume(E),j):n(E)}function j(E){return E===45||cs(E)?(e.consume(E),j):A(E)}function A(E){return yt(E)?(a=A,L(E)):Jt(E)?(e.consume(E),A):D(E)}function I(E){return E===45||cs(E)?(e.consume(E),I):E===47||E===62||Zr(E)?O(E):n(E)}function O(E){return E===47?(e.consume(E),D):E===58||E===95||bi(E)?(e.consume(E),H):yt(E)?(a=O,L(E)):Jt(E)?(e.consume(E),O):D(E)}function H(E){return E===45||E===46||E===58||E===95||cs(E)?(e.consume(E),H):B(E)}function B(E){return E===61?(e.consume(E),z):yt(E)?(a=B,L(E)):Jt(E)?(e.consume(E),B):O(E)}function z(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,$):yt(E)?(a=z,L(E)):Jt(E)?(e.consume(E),z):(e.consume(E),M)}function $(E){return E===s?(e.consume(E),s=void 0,q):E===null?n(E):yt(E)?(a=$,L(E)):(e.consume(E),$)}function M(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Zr(E)?O(E):(e.consume(E),M)}function q(E){return E===47||E===62||Zr(E)?O(E):n(E)}function D(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function L(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),T}function T(E){return Jt(E)?pn(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):W(E)}function W(E){return e.enter("htmlTextData"),a(E)}}const Wk={name:"labelEnd",resolveAll:b9,resolveTo:k9,tokenize:v9},y9={tokenize:S9},w9={tokenize:N9},x9={tokenize:j9};function b9(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&&Ii(e,0,e.length,n),e}function k9(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}},u={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Cs(l,e.slice(i+1,i+r+3)),l=Cs(l,[["enter",d,t]]),l=Cs(l,Hk(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=Cs(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=Cs(l,e.slice(a+1)),l=Cs(l,[["exit",c,t]]),Ii(e,i,e.length,l),e}function v9(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(dc(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(y9,d,a?d:f)(p):p===91?e.attempt(w9,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt(x9,d,f)(p)}function d(p){return t(p)}function f(p){return i._balanced=!0,n(p)}}function S9(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return Zr(f)?id(e,i)(f):i(f)}function i(f){return f===41?d(f):RR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Zr(f)?id(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?MR(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Zr(f)?id(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function N9(e,t,n){const r=this;return s;function s(l){return TR.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(dc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function j9(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 C9={name:"labelStartImage",resolveAll:Wk.resolveAll,tokenize:_9};function _9(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 E9={name:"labelStartLink",resolveAll:Wk.resolveAll,tokenize:A9};function A9(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 zy={name:"lineEnding",tokenize:P9};function P9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),pn(e,t,"linePrefix")}}const ih={name:"thematicBreak",tokenize:I9};function I9(e,t,n){let r=0,s;return i;function i(u){return e.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||yt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Jt(u)?pn(e,l,"whitespace")(u):l(u))}}const Vr={continuation:{tokenize:$9},exit:O9,name:"list",tokenize:M9},R9={partial:!0,tokenize:D9},T9={partial:!0,tokenize:L9};function M9(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:Bx(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(ih,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(h)}return n(h)}function c(h){return Bx(h)&&++a<10?(e.consume(h),c):(!r.interrupt||a<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Qm,r.interrupt?n:d,e.attempt(R9,p,f))}function d(h){return r.containerState.initialBlankLine=!0,i++,p(h)}function f(h){return Jt(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 $9(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Qm,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,pn(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(l){return r.containerState.furtherBlankLines||!Jt(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,a(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(T9,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,pn(e,e.attempt(Vr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function L9(e,t,n){const r=this;return pn(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 O9(e){e.exit(this.containerState.type)}function D9(e,t,n){const r=this;return pn(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!Jt(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const x1={name:"setextUnderline",resolveTo:F9,tokenize:z9};function F9(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 z9(e,t,n){const r=this;let s;return i;function i(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===s?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),Jt(u)?pn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||yt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const B9={tokenize:H9};function H9(e){const t=this,n=e.attempt(Qm,r,e.attempt(this.parser.constructs.flowInitial,s,pn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(U8,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 W9={resolveAll:LR()},V9=$R("string"),K9=$R("text");function $R(e){return{resolveAll:LR(e==="text"?q9: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(d){return u(d)?i(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),i(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let p=-1;if(f)for(;++p<f.length;){const h=f[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function LR(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 q9(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 u=s[i];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={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={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const U9={42:Vr,43:Vr,45:Vr,48:Vr,49:Vr,50:Vr,51:Vr,52:Vr,53:Vr,54:Vr,55:Vr,56:Vr,57:Vr,62:ER},Y9={91:Q8},G9={[-2]:Fy,[-1]:Fy,32:Fy},J9={35:s9,42:ih,45:[x1,ih],60:l9,61:x1,95:ih,96:y1,126:y1},X9={38:PR,92:AR},Q9={[-5]:zy,[-4]:zy,[-3]:zy,33:C9,38:PR,42:Hx,60:[E8,m9],91:E9,92:[n9,AR],93:Wk,95:Hx,96:B8},Z9={null:[Hx,W9]},eV={null:[42,95]},tV={null:[]},nV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eV,contentInitial:Y9,disable:tV,document:U9,flow:J9,flowInitial:G9,insideSpan:Z9,string:X9,text:Q9},Symbol.toStringTag,{value:"Module"}));function rV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},i=[];let a=[],l=[];const c={attempt:A(N),check:A(j),consume:v,enter:x,exit:C,interrupt:A(j,{interrupt:!0})},u={code:null,containerState:{},defineSkip:k,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&i.push(t),u;function f(B){return a=Cs(a,B),b(),a[a.length-1]!==null?[]:(I(t,0),u.events=Hk(i,u.events,u),u.events)}function p(B,z){return iV(h(B),z)}function h(B){return sV(a,B)}function g(){const{_bufferIndex:B,_index:z,line:$,column:M,offset:q}=r;return{_bufferIndex:B,_index:z,line:$,column:M,offset:q}}function k(B){s[B.line]=B.column,H()}function b(){let B;for(;r._index<a.length;){const z=a[r._index];if(typeof z=="string")for(B=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===B&&r._bufferIndex<z.length;)y(z.charCodeAt(r._bufferIndex));else y(z)}}function y(B){d=d(B)}function v(B){yt(B)?(r.line++,r.column=1,r.offset+=B===-3?2:1,H()):B!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=B}function x(B,z){const $=z||{};return $.type=B,$.start=g(),u.events.push(["enter",$,u]),l.push($),$}function C(B){const z=l.pop();return z.end=g(),u.events.push(["exit",z,u]),z}function N(B,z){I(B,z.from)}function j(B,z){z.restore()}function A(B,z){return $;function $(M,q,D){let L,T,W,E;return Array.isArray(M)?V(M):"tokenize"in M?V([M]):Q(M);function Q(J){return ne;function ne(ee){const re=ee!==null&&J[ee],Z=ee!==null&&J.null,le=[...Array.isArray(re)?re:re?[re]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return V(le)(ee)}}function V(J){return L=J,T=0,J.length===0?D:F(J[T])}function F(J){return ne;function ne(ee){return E=O(),W=J,J.partial||(u.currentConstruct=J),J.name&&u.parser.constructs.disable.null.includes(J.name)?ce():J.tokenize.call(z?Object.assign(Object.create(u),z):u,c,se,ce)(ee)}}function se(J){return B(W,E),q}function ce(J){return E.restore(),++T<L.length?F(L[T]):D}}}function I(B,z){B.resolveAll&&!i.includes(B)&&i.push(B),B.resolve&&Ii(u.events,z,u.events.length-z,B.resolve(u.events.slice(z),u)),B.resolveTo&&(u.events=B.resolveTo(u.events,u))}function O(){const B=g(),z=u.previous,$=u.currentConstruct,M=u.events.length,q=Array.from(l);return{from:M,restore:D};function D(){r=B,u.previous=z,u.currentConstruct=$,u.events.length=M,l=q,H()}}function H(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function sV(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 iV(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 oV(e){const r={constructs:p8([nV,...(e||{}).extensions||[]]),content:s(k8),defined:[],document:s(S8),flow:s(B9),lazy:{},string:s(V9),text:s(K9)};return r;function s(i){return a;function a(l){return rV(r,i,l)}}}function aV(e){for(;!IR(e););return e}const b1=/[\0\t\n\r]/g;function lV(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const c=[];let u,d,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(b1.lastIndex=f,u=b1.exec(i),p=u&&u.index!==void 0?u.index:i.length,h=i.charCodeAt(p),!u){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(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=p+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const cV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uV(e){return e.replace(cV,dV)}function dV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return _R(n.slice(i?2:1),i?16:10)}return Bk(n)||e}const OR={}.hasOwnProperty;function fV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),pV(n)(aV(oV(n).document().write(lV()(e,t,!0))))}function pV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(kt),autolinkProtocol:O,autolinkEmail:O,atxHeading:i(Qe),blockQuote:i(Z),characterEscape:O,characterReference:O,codeFenced:i(le),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(le,a),codeText:i(de,a),codeTextData:O,data:O,codeFlowValue:O,definition:i(we),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(De),hardBreakEscape:i(Oe),hardBreakTrailing:i(Oe),htmlFlow:i(st,a),htmlFlowData:O,htmlText:i(st,a),htmlTextData:O,image:i(mt),label:a,link:i(kt),listItem:i(dt),listItemValue:p,listOrdered:i(Pe,f),listUnordered:i(Pe),paragraph:i(gt),reference:F,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(Qe),strong:i(xe),thematicBreak:i(Me)},exit:{atxHeading:c(),atxHeadingSequence:N,autolink:c(),autolinkEmail:re,autolinkProtocol:ee,blockQuote:c(),characterEscapeValue:H,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:J,characterReference:ne,codeFenced:c(b),codeFencedFence:k,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:H,codeIndented:c(y),codeText:c(q),codeTextData:H,data:H,definition:c(),definitionDestinationString:C,definitionLabelString:v,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(z),hardBreakTrailing:c(z),htmlFlow:c($),htmlFlowData:H,htmlText:c(M),htmlTextData:H,image:c(L),label:W,labelText:T,lineEnding:B,link:c(D),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:E,resourceTitleString:Q,resource:V,setextHeading:c(I),setextHeadingLineSequence:A,setextHeadingText:j,strong:c(),thematicBreak:c()}};DR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ue){let ve={type:"root",children:[]};const Ve={stack:[ve],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:d,data:n},qe=[];let be=-1;for(;++be<ue.length;)if(ue[be][1].type==="listOrdered"||ue[be][1].type==="listUnordered")if(ue[be][0]==="enter")qe.push(be);else{const Tt=qe.pop();be=s(ue,Tt,be)}for(be=-1;++be<ue.length;){const Tt=t[ue[be][0]];OR.call(Tt,ue[be][1].type)&&Tt[ue[be][1].type].call(Object.assign({sliceSerialize:ue[be][2].sliceSerialize},Ve),ue[be][1])}if(Ve.tokenStack.length>0){const Tt=Ve.tokenStack[Ve.tokenStack.length-1];(Tt[1]||k1).call(Ve,void 0,Tt[0])}for(ve.position={start:_o(ue.length>0?ue[0][1].start:{line:1,column:1,offset:0}),end:_o(ue.length>0?ue[ue.length-2][1].end:{line:1,column:1,offset:0})},be=-1;++be<t.transforms.length;)ve=t.transforms[be](ve)||ve;return ve}function s(ue,ve,Ve){let qe=ve-1,be=-1,Tt=!1,ln,_t,hn,tn;for(;++qe<=Ve;){const te=ue[qe];switch(te[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{te[0]==="enter"?be++:be--,tn=void 0;break}case"lineEndingBlank":{te[0]==="enter"&&(ln&&!tn&&!be&&!hn&&(hn=qe),tn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:tn=void 0}if(!be&&te[0]==="enter"&&te[1].type==="listItemPrefix"||be===-1&&te[0]==="exit"&&(te[1].type==="listUnordered"||te[1].type==="listOrdered")){if(ln){let Ie=qe;for(_t=void 0;Ie--;){const Ue=ue[Ie];if(Ue[1].type==="lineEnding"||Ue[1].type==="lineEndingBlank"){if(Ue[0]==="exit")continue;_t&&(ue[_t][1].type="lineEndingBlank",Tt=!0),Ue[1].type="lineEnding",_t=Ie}else if(!(Ue[1].type==="linePrefix"||Ue[1].type==="blockQuotePrefix"||Ue[1].type==="blockQuotePrefixWhitespace"||Ue[1].type==="blockQuoteMarker"||Ue[1].type==="listItemIndent"))break}hn&&(!_t||hn<_t)&&(ln._spread=!0),ln.end=Object.assign({},_t?ue[_t][1].start:te[1].end),ue.splice(_t||qe,0,["exit",ln,te[2]]),qe++,Ve++}if(te[1].type==="listItemPrefix"){const Ie={type:"listItem",_spread:!1,start:Object.assign({},te[1].start),end:void 0};ln=Ie,ue.splice(qe,0,["enter",Ie,te[2]]),qe++,Ve++,hn=void 0,tn=!0}}}return ue[ve][1]._spread=Tt,Ve}function i(ue,ve){return Ve;function Ve(qe){l.call(this,ue(qe),qe),ve&&ve.call(this,qe)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ue,ve,Ve){this.stack[this.stack.length-1].children.push(ue),this.stack.push(ue),this.tokenStack.push([ve,Ve||void 0]),ue.position={start:_o(ve.start),end:void 0}}function c(ue){return ve;function ve(Ve){ue&&ue.call(this,Ve),u.call(this,Ve)}}function u(ue,ve){const Ve=this.stack.pop(),qe=this.tokenStack.pop();if(qe)qe[0].type!==ue.type&&(ve?ve.call(this,ue,qe[0]):(qe[1]||k1).call(this,ue,qe[0]));else throw new Error("Cannot close `"+ue.type+"` ("+sd({start:ue.start,end:ue.end})+"): it’s not open");Ve.position.end=_o(ue.end)}function d(){return d8(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(ue){if(this.data.expectingFirstListItemValue){const ve=this.stack[this.stack.length-2];ve.start=Number.parseInt(this.sliceSerialize(ue),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.lang=ue}function g(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.meta=ue}function k(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue.replace(/(\r?\n|\r)$/g,"")}function v(ue){const ve=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=ve,Ve.identifier=dc(this.sliceSerialize(ue)).toLowerCase()}function x(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ue}function C(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ue}function N(ue){const ve=this.stack[this.stack.length-1];if(!ve.depth){const Ve=this.sliceSerialize(ue).length;ve.depth=Ve}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function A(ue){const ve=this.stack[this.stack.length-1];ve.depth=this.sliceSerialize(ue).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function O(ue){const Ve=this.stack[this.stack.length-1].children;let qe=Ve[Ve.length-1];(!qe||qe.type!=="text")&&(qe=Fe(),qe.position={start:_o(ue.start),end:void 0},Ve.push(qe)),this.stack.push(qe)}function H(ue){const ve=this.stack.pop();ve.value+=this.sliceSerialize(ue),ve.position.end=_o(ue.end)}function B(ue){const ve=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ve=ve.children[ve.children.length-1];Ve.position.end=_o(ue.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ve.type)&&(O.call(this,ue),H.call(this,ue))}function z(){this.data.atHardBreak=!0}function $(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue}function M(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue}function q(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ue}function D(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=ve,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function L(){const ue=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ue.type+="Reference",ue.referenceType=ve,delete ue.url,delete ue.title}else delete ue.identifier,delete ue.label;this.data.referenceType=void 0}function T(ue){const ve=this.sliceSerialize(ue),Ve=this.stack[this.stack.length-2];Ve.label=uV(ve),Ve.identifier=dc(ve).toLowerCase()}function W(){const ue=this.stack[this.stack.length-1],ve=this.resume(),Ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ve.type==="link"){const qe=ue.children;Ve.children=qe}else Ve.alt=ve}function E(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ue}function Q(){const ue=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ue}function V(){this.data.inReference=void 0}function F(){this.data.referenceType="collapsed"}function se(ue){const ve=this.resume(),Ve=this.stack[this.stack.length-1];Ve.label=ve,Ve.identifier=dc(this.sliceSerialize(ue)).toLowerCase(),this.data.referenceType="full"}function ce(ue){this.data.characterReferenceType=ue.type}function J(ue){const ve=this.sliceSerialize(ue),Ve=this.data.characterReferenceType;let qe;Ve?(qe=_R(ve,Ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):qe=Bk(ve);const be=this.stack[this.stack.length-1];be.value+=qe}function ne(ue){const ve=this.stack.pop();ve.position.end=_o(ue.end)}function ee(ue){H.call(this,ue);const ve=this.stack[this.stack.length-1];ve.url=this.sliceSerialize(ue)}function re(ue){H.call(this,ue);const ve=this.stack[this.stack.length-1];ve.url="mailto:"+this.sliceSerialize(ue)}function Z(){return{type:"blockquote",children:[]}}function le(){return{type:"code",lang:null,meta:null,value:""}}function de(){return{type:"inlineCode",value:""}}function we(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function De(){return{type:"emphasis",children:[]}}function Qe(){return{type:"heading",depth:0,children:[]}}function Oe(){return{type:"break"}}function st(){return{type:"html",value:""}}function mt(){return{type:"image",title:null,url:"",alt:null}}function kt(){return{type:"link",title:null,url:"",children:[]}}function Pe(ue){return{type:"list",ordered:ue.type==="listOrdered",start:null,spread:ue._spread,children:[]}}function dt(ue){return{type:"listItem",spread:ue._spread,checked:null,children:[]}}function gt(){return{type:"paragraph",children:[]}}function xe(){return{type:"strong",children:[]}}function Fe(){return{type:"text",value:""}}function Me(){return{type:"thematicBreak"}}}function _o(e){return{line:e.line,column:e.column,offset:e.offset}}function DR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?DR(e,r):hV(e,r)}}function hV(e,t){let n;for(n in t)if(OR.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function k1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+sd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+sd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+sd({start:t.start,end:t.end})+") is still open")}function mV(e){const t=this;t.parser=n;function n(r){return fV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gV(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 yV(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function wV(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 xV(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bV(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kV(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Fc(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 u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function vV(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 SV(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function FR(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 NV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return FR(e,t);const s={src:Fc(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 jV(e,t){const n={src:Fc(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 CV(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 _V(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return FR(e,t);const s={href:Fc(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 EV(e,t){const n={href:Fc(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 AV(e,t,n){const r=e.all(t),s=n?PV(n):zR(t),i={},a=[];if(typeof t.checked=="boolean"){const d=r[0];let f;d&&d.type==="element"&&d.tagName==="p"?f=d:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const d=r[l];(s||l!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),d.type==="element"&&d.tagName==="p"&&!s?a.push(...d.children):a.push(d)}const c=r[r.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const u={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,u),e.applyData(t,u)}function PV(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=zR(n[r])}return t}function zR(e){const t=e.spread;return t??e.children.length>1}function IV(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 RV(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function TV(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function MV(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $V(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=Ok(t.children[1]),c=bR(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 LV(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 u=[];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)),u.push(g)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function OV(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const v1=9,S1=32;function DV(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(N1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(N1(t.slice(s),s>0,!1)),i.join("")}function N1(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===v1||i===S1;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===v1||i===S1;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function FV(e,t){const n={type:"text",value:DV(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function zV(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const BV={blockquote:gV,break:yV,code:wV,delete:xV,emphasis:bV,footnoteReference:kV,heading:vV,html:SV,imageReference:NV,image:jV,inlineCode:CV,linkReference:_V,link:EV,listItem:AV,list:IV,paragraph:RV,root:TV,strong:MV,table:$V,tableCell:OV,tableRow:LV,text:FV,thematicBreak:zV,toml:kp,yaml:kp,definition:kp,footnoteDefinition:kp};function kp(){}const BR=-1,Zm=0,od=1,Jh=2,Vk=3,Kk=4,qk=5,Uk=6,HR=7,WR=8,j1=typeof self=="object"?self:globalThis,HV=(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 Zm:case BR:return n(a,s);case od:{const l=n([],s);for(const c of a)l.push(r(c));return l}case Jh:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case Vk:return n(new Date(a),s);case Kk:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case qk:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case Uk:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case HR:{const{name:l,message:c}=a;return n(new j1[l](c),s)}case WR: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 j1[i](a),s)};return r},C1=e=>HV(new Map,e)(0),Il="",{toString:WV}={},{keys:VV}=Object,Cu=e=>{const t=typeof e;if(t!=="object"||!e)return[Zm,t];const n=WV.call(e).slice(8,-1);switch(n){case"Array":return[od,Il];case"Object":return[Jh,Il];case"Date":return[Vk,Il];case"RegExp":return[Kk,Il];case"Map":return[qk,Il];case"Set":return[Uk,Il];case"DataView":return[od,n]}return n.includes("Array")?[od,n]:n.includes("Error")?[HR,n]:[Jh,n]},vp=([e,t])=>e===Zm&&(t==="function"||t==="symbol"),KV=(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]=Cu(a);switch(l){case Zm:{let d=a;switch(c){case"bigint":l=WR,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([BR],a)}return s([l,d],a)}case od:{if(c){let p=a;return c==="DataView"?p=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(p=new Uint8Array(a)),s([c,[...p]],a)}const d=[],f=s([l,d],a);for(const p of a)d.push(i(p));return f}case Jh:{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 d=[],f=s([l,d],a);for(const p of VV(a))(e||!vp(Cu(a[p])))&&d.push([i(p),i(a[p])]);return f}case Vk:return s([l,a.toISOString()],a);case Kk:{const{source:d,flags:f}=a;return s([l,{source:d,flags:f}],a)}case qk:{const d=[],f=s([l,d],a);for(const[p,h]of a)(e||!(vp(Cu(p))||vp(Cu(h))))&&d.push([i(p),i(h)]);return f}case Uk:{const d=[],f=s([l,d],a);for(const p of a)(e||!vp(Cu(p)))&&d.push(i(p));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return i},_1=(e,{json:t,lossy:n}={})=>{const r=[];return KV(!(t||n),!!t,new Map,r)(e),r},Xh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?C1(_1(e,t)):structuredClone(e):(e,t)=>C1(_1(e,t));function qV(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 UV(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function YV(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||qV,r=e.options.footnoteBackLabel||UV,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 u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const d=e.all(u),f=String(u.identifier).toUpperCase(),p=Fc(f.toLowerCase());let h=0;const g=[],k=e.footnoteCounts.get(f);for(;k!==void 0&&++h<=k;){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 b=d[d.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const v=b.children[b.children.length-1];v&&v.type==="text"?v.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...g)}else d.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(d,!0)};e.patch(u,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Xh(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 VR=function(e){if(e==null)return QV;if(typeof e=="function")return eg(e);if(typeof e=="object")return Array.isArray(e)?GV(e):JV(e);if(typeof e=="string")return XV(e);throw new Error("Expected function, string, or object as test")};function GV(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=VR(e[n]);return eg(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function JV(e){const t=e;return eg(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function XV(e){return eg(t);function t(n){return n&&n.type===e}}function eg(e){return t;function t(n,r,s){return!!(ZV(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function QV(){return!0}function ZV(e){return e!==null&&typeof e=="object"&&"type"in e}const KR=[],eK=!0,E1=!1,tK="skip";function nK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=VR(s),a=r?-1:1;l(e,void 0,[])();function l(c,u,d){const f=c&&typeof c=="object"?c:{};if(typeof f.type=="string"){const h=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return p;function p(){let h=KR,g,k,b;if((!t||i(c,u,d[d.length-1]||void 0))&&(h=rK(n(c,d)),h[0]===E1))return h;if("children"in c&&c.children){const y=c;if(y.children&&h[0]!==tK)for(k=(r?y.children.length:-1)+a,b=d.concat(y);k>-1&&k<y.children.length;){const v=y.children[k];if(g=l(v,k,b)(),g[0]===E1)return g;k=typeof g[1]=="number"?g[1]:k+a}}return h}}}function rK(e){return Array.isArray(e)?e:typeof e=="number"?[eK,e]:e==null?KR:[e]}function qR(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),nK(e,i,l,s);function l(c,u){const d=u[u.length-1],f=d?d.children.indexOf(c):void 0;return a(c,f,d)}}const Wx={}.hasOwnProperty,sK={};function iK(e,t){const n=t||sK,r=new Map,s=new Map,i=new Map,a={...BV,...n.handlers},l={all:u,applyData:aK,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:n,patch:oK,wrap:cK};return qR(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const f=d.type==="definition"?r:s,p=String(d.identifier).toUpperCase();f.has(p)||f.set(p,d)}}),l;function c(d,f){const p=d.type,h=l.handlers[p];if(Wx.call(l.handlers,p)&&h)return h(l,d,f);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in d){const{children:k,...b}=d,y=Xh(b);return y.children=l.all(d),y}return Xh(d)}return(l.options.unknownHandler||lK)(l,d,f)}function u(d){const f=[];if("children"in d){const p=d.children;let h=-1;for(;++h<p.length;){const g=l.one(p[h],d);if(g){if(h&&p[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=A1(g.value)),!Array.isArray(g)&&g.type==="element")){const k=g.children[0];k&&k.type==="text"&&(k.value=A1(k.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function oK(e,t){e.position&&(t.position=W6(e))}function aK(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,Xh(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function lK(e,t){const n=t.data||{},r="value"in t&&!(Wx.call(n,"hProperties")||Wx.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 cK(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 A1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function P1(e,t){const n=iK(e,t),r=n.one(e,void 0),s=YV(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 uK(e,t){return e&&"run"in e?async function(n,r){const s=P1(n,{file:r,...t});await e.run(s,r)}:function(n,r){return P1(n,{file:r,...e||t})}}function I1(e){if(e)throw e}var oh=Object.prototype.hasOwnProperty,UR=Object.prototype.toString,R1=Object.defineProperty,T1=Object.getOwnPropertyDescriptor,M1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):UR.call(t)==="[object Array]"},$1=function(t){if(!t||UR.call(t)!=="[object Object]")return!1;var n=oh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&oh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||oh.call(t,s)},L1=function(t,n){R1&&n.name==="__proto__"?R1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},O1=function(t,n){if(n==="__proto__")if(oh.call(t,n)){if(T1)return T1(t,n).value}else return;return t[n]},dK=function e(){var t,n,r,s,i,a,l=arguments[0],c=1,u=arguments.length,d=!1;for(typeof l=="boolean"&&(d=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=O1(l,n),s=O1(t,n),l!==s&&(d&&s&&($1(s)||(i=M1(s)))?(i?(i=!1,a=r&&M1(r)?r:[]):a=r&&$1(r)?r:{},L1(l,{name:n,newValue:e(d,a,s)})):typeof s<"u"&&L1(l,{name:n,newValue:s}));return l};const By=ra(dK);function Vx(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 fK(){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,...u){const d=e[++i];let f=-1;if(c){a(c);return}for(;++f<s.length;)(u[f]===null||u[f]===void 0)&&(u[f]=s[f]);s=u,d?pK(d,l)(...u):a(null,...u)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function pK(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(s);try{c=e.apply(this,a)}catch(u){const d=u;if(l&&n)throw d;return s(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(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 hi={basename:hK,dirname:mK,extname:gK,join:yK,sep:"/"};function hK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');df(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 mK(e){if(df(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 gK(e){df(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 yK(...e){let t=-1,n;for(;++t<e.length;)df(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":wK(n)}function wK(e){df(e);const t=e.codePointAt(0)===47;let n=xK(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function xK(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 df(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const bK={cwd:kK};function kK(){return"/"}function Kx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function vK(e){if(typeof e=="string")e=new URL(e);else if(!Kx(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 SK(e)}function SK(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 Hy=["history","path","basename","stem","extname","dirname"];class YR{constructor(t){let n;t?Kx(t)?n={path:t}:typeof t=="string"||NK(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":bK.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Hy.length;){const i=Hy[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)Hy.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?hi.basename(this.path):void 0}set basename(t){Vy(t,"basename"),Wy(t,"basename"),this.path=hi.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?hi.dirname(this.path):void 0}set dirname(t){D1(this.basename,"dirname"),this.path=hi.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?hi.extname(this.path):void 0}set extname(t){if(Wy(t,"extname"),D1(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=hi.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Kx(t)&&(t=vK(t)),Vy(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?hi.basename(this.path,this.extname):void 0}set stem(t){Vy(t,"stem"),Wy(t,"stem"),this.path=hi.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 Pr(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 Wy(e,t){if(e&&e.includes(hi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+hi.sep+"`")}function Vy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function D1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function NK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const jK=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},CK={}.hasOwnProperty;class Yk extends jK{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=fK()}copy(){const t=new Yk;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(By(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Uy("data",this.frozen),this.namespace[t]=n,this):CK.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Uy("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=Sp(t),r=this.parser||this.Parser;return Ky("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ky("process",this.parser||this.Parser),qy("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=Sp(t),c=r.parse(l);r.run(c,l,function(d,f,p){if(d||!f||!p)return u(d);const h=f,g=r.stringify(h,p);AK(g)?p.value=g:p.result=g,u(d,p)});function u(d,f){d||!f?a(d):i?i(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),Ky("processSync",this.parser||this.Parser),qy("processSync",this.compiler||this.Compiler),this.process(t,s),z1("processSync","process",n),r;function s(i,a){n=!0,I1(i),r=a}}run(t,n,r){F1(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=Sp(n);s.run(t,c,u);function u(d,f,p){const h=f||t;d?l(d):a?a(h):r(void 0,h,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),z1("runSync","run",r),s;function i(a,l){I1(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Sp(n),s=this.compiler||this.Compiler;return qy("stringify",s),F1(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Uy("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(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...f]=u;c(d,f)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(s.settings=By(!0,s.settings,u.settings))}function l(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const f=u[d];i(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let f=-1,p=-1;for(;++f<r.length;)if(r[f][0]===u){p=f;break}if(p===-1)r.push([u,...d]);else if(d.length>0){let[h,...g]=d;const k=r[p][1];Vx(k)&&Vx(h)&&(h=By(!0,k,h)),r[p]=[u,h,...g]}}}}const _K=new Yk().freeze();function Ky(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function qy(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Uy(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 F1(e){if(!Vx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function z1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Sp(e){return EK(e)?e:new YR(e)}function EK(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function AK(e){return typeof e=="string"||PK(e)}function PK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const IK="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",B1=[],H1={allowDangerousHtml:!0},RK=/^(https?|ircs?|mailto|xmpp)$/i,TK=[{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 GR(e){const t=MK(e),n=$K(e);return LK(t.runSync(t.parse(n),n),e)}function MK(e){const t=e.rehypePlugins||B1,n=e.remarkPlugins||B1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...H1}:H1;return _K().use(mV).use(n).use(uK,r).use(t)}function $K(e){const t=e.children||"",n=new YR;return typeof t=="string"&&(n.value=t),n}function LK(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||OK;for(const d of TK)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+IK+d.id,void 0);return qR(e,u),Y6(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function u(d,f,p){if(d.type==="raw"&&p&&typeof f=="number")return a?p.children.splice(f,1):p.children[f]={type:"text",value:d.value},f;if(d.type==="element"){let h;for(h in Dy)if(Object.hasOwn(Dy,h)&&Object.hasOwn(d.properties,h)){const g=d.properties[h],k=Dy[h];(k===null||k.includes(d.tagName))&&(d.properties[h]=c(String(g||""),h,d))}}if(d.type==="element"){let h=n?!n.includes(d.tagName):i?i.includes(d.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(d,f,p)),h&&p&&typeof f=="number")return l&&d.children?p.children.splice(f,1,...d.children):p.children.splice(f,1),f}}}function OK(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||RK.test(e.slice(0,t))?e:""}const DK=new Set(["echarts"]),FK=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),zK=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),BK=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Yo(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Ja(e,t){if(!Yo(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Yo(n[r])&&Yo(s)&&(n[r]=Ja(n[r],s));return n}function tg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Yo(n)?Ja(n,t):n):Yo(e)?Ja(e,t):e}function HK(e){let t=String(e||"").trim();if(!t)return"";const n=t.match(/```(?:json|chart|echarts)?\s*\n?([\s\S]*?)```/i);if(n!=null&&n[1])t=n[1].trim();else{const r=t.indexOf("{"),s=t.lastIndexOf("}");r>=0&&s>r&&(t=t.slice(r,s+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function qx(e,t="$"){if(e!=null){if(typeof e=="string"){if(/<\s*(script|iframe|object|embed|link|meta)\b/i.test(e))throw new Error(`${t} contains unsafe HTML`);if(/\bjavascript\s*:/i.test(e)||/\bdata\s*:\s*text\/html/i.test(e))throw new Error(`${t} contains unsafe URL text`);return}if(Array.isArray(e)){e.forEach((n,r)=>qx(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||zK.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);qx(r,`${t}.${n}`)}}}function WK(e){const t=Array.isArray(e)?e:[e].filter(Boolean);if(!t.length)throw new Error("option.series is required");for(const n of t){const r=String((n==null?void 0:n.type)||"").trim();if(!FK.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function VK(e){const t={trigger:"item",renderMode:"richText",backgroundColor:"rgba(20, 22, 28, 0.96)",borderColor:"rgba(124, 156, 255, 0.28)",textStyle:{color:"rgba(255, 255, 255, 0.92)"}};return!e||typeof e!="object"||Array.isArray(e)?t:Ja(e,t)}function KK(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!Yo(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return Ja(i,n)}):Yo(e)?Ja(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function qK(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:tg(e,n)}function W1(e,t="rgba(255, 255, 255, 0.62)"){return tg(e,{nameTextStyle:{color:t},axisLabel:{color:"rgba(255, 255, 255, 0.58)"},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.22)"}},axisTick:{lineStyle:{color:"rgba(255, 255, 255, 0.18)"}},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}}})}function UK(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:tg(e,n)}function YK(e){const t={axisName:{color:"rgba(255, 255, 255, 0.68)"},splitLine:{lineStyle:{color:"rgba(255, 255, 255, 0.12)"}},splitArea:{areaStyle:{color:["rgba(255, 255, 255, 0.025)","rgba(255, 255, 255, 0.045)"]}},axisLine:{lineStyle:{color:"rgba(255, 255, 255, 0.16)"}}};return e==null?e:tg(e,t)}function GK(e,t,n){const r=KK(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Yo(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??BK,textStyle:Ja(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:VK(e.tooltip),legend:qK(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?UK(e.grid,s||i):e.grid,xAxis:W1(e.xAxis),yAxis:W1(e.yAxis),radar:YK(e.radar),series:t}}function JK(e){const t=HK(e);if(!t)return{ok:!1,error:"No chart content"};try{const n=JSON.parse(t);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("ChartSpec must be a JSON object");if(n.type!=="chart")throw new Error('type must be "chart"');if(n.version!=="1.0")throw new Error('version must be "1.0"');if(!DK.has(n.renderer))throw new Error('renderer must be "echarts"');if(!n.option||typeof n.option!="object"||Array.isArray(n.option))throw new Error("option must be an ECharts option object");qx(n);const r=WK(n.option.series),s=n.title==null?"":String(n.title),i=GK(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function Np(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function XK(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function Ji(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!Np(t,t.length-1)&&(t=t.slice(0,-1));const n=[];let r="",s=0;for(let i=0;i<t.length;i+=1){const a=t[i];if(a==="`"&&!Np(t,i)){const l=XK(t,i);r+=t.slice(i,i+l),s===0?s=l:s===l&&(s=0),i+=l-1;continue}if(s===0&&a==="|"&&!Np(t,i)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[i+1]==="|"&&Np(t,i+1)){r+="|",i+=1;continue}r+=a}return n.push(r.trim()),n}function JR(e,t){if(!t)return e;const n=e.slice(0,t);for(e.length>t&&(n[t-1]=[e[t-1],...e.slice(t)].filter(Boolean).join(" | "));n.length<t;)n.push("");return n}function XR(e){const t=Ji(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function QR(e){return Ji(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function QK(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function ZK(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 u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?i(u[1],u[2]||u[3]||u[4]||u[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 u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function e7({code:e}){const t=m.useMemo(()=>ZK(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,s=46,i=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((d,f)=>{l.set(d.id,{x:28+(n?f*(r+i):f%3*(r+i)),y:28+(n?f%3*(s+a):f*(s+a))})});const c=Math.max(520,...Array.from(l.values()).map(d=>d.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(d=>d.y+s+28));return o.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid flowchart preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-md-mermaid-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((d,f)=>{const p=l.get(d.from),h=l.get(d.to);if(!p||!h)return null;const 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-md-mermaid-edge",d:g,markerEnd:"url(#af-md-mermaid-arrow)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-md-mermaid-box",x:f.x,y:f.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-md-mermaid-text",x:f.x+r/2,y:f.y+s/2+5,textAnchor:"middle",children:d.label.slice(0,24)})]},d.id)})]})}function t7(e){const t=String(e||"").split(/\r?\n/).map(i=>i.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],s=(i,a="")=>{const l=String(i||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const i of t){if(/^sequenceDiagram\b/i.test(i))continue;const a=i.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){s(a[2],a[3]||a[2]);continue}const l=i.match(/^([A-Za-z0-9_]+)\s*[-=]+>>\+?\s*([A-Za-z0-9_]+)\s*:\s*(.+)$/);if(l){s(l[1]),s(l[2]),r.push({type:"message",from:l[1],to:l[2],text:l[3]});continue}const c=i.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:c?c[2]:i})}return{participants:Array.from(n,([i,a])=>({id:i,label:a})),rows:r}}function n7({code:e}){const t=m.useMemo(()=>t7(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,s=48,i=26,a=44,l=48,c=Math.max(620,s*2+n.length*r),u=Math.max(220,i+a+Math.max(1,t.rows.length)*l+34),d=f=>{const p=Math.max(0,n.findIndex(h=>h.id===f));return s+p*r+r/2};return o.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-md-sequence-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((f,p)=>{const h=s+p*r+r/2;return o.jsxs("g",{children:[o.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:i,width:"136",height:"34",rx:"8"}),o.jsx("text",{className:"af-md-mermaid-text",x:h,y:i+22,textAnchor:"middle",children:f.label.slice(0,18)}),o.jsx("line",{className:"af-md-sequence-life",x1:h,y1:i+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,p)=>{const h=i+a+p*l+24;if(f.type!=="message")return o.jsxs("g",{children:[o.jsx("rect",{className:"af-md-sequence-note",x:s,y:h-17,width:c-s*2,height:"30",rx:"7"}),o.jsx("text",{className:"af-md-mermaid-text",x:s+12,y:h+4,children:f.text.slice(0,120)})]},`note-${p}`);const g=d(f.from),k=d(f.to),b=(g+k)/2;return o.jsxs("g",{children:[o.jsx("line",{className:"af-md-mermaid-edge",x1:g,y1:h,x2:k,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),o.jsx("text",{className:"af-md-sequence-label",x:b,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${p}`)})]})}function ZR({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return o.jsx("div",{className:"af-md-mermaid-preview",children:n?o.jsx(n7,{code:t}):o.jsx(e7,{code:t})})}function r7(e){const t=String(e||"").replace(/\r\n/g,`
80
- `).split(`
81
- `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
82
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!s&&c){i();const u=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)u.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:u.join(`
83
- `)});continue}if(!s&&QK(l)){i();const u=[];for(;a<t.length;){const d=t[a]||"";if(u.length>0&&(!d.trim()||/^-{3,}\s*$/.test(d)||/^#{1,6}\s+/.test(d)))break;u.push(d),a++}n.push({type:"mermaid",text:u.join(`
84
- `)});continue}if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&Ji(l).length>1&&XR(t[a+1])){i();const u=Ji(l),d=QR(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Ji(t[a]).length>1;)f.push(JR(Ji(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return i(),n}function V1(e,t=""){const n=String(e||"").trim();if(!n||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n)||n.startsWith("/")||n.startsWith("#")||!t||n.startsWith("outputs/"))return n;const r=String(t||"").split("/").filter(Boolean);r.pop();const s=[...r,...n.split("/")].filter(Boolean),i=[];for(const a of s)if(a!=="."){if(a===".."){if(i.length===0)return n;i.pop();continue}i.push(a)}return i.join("/")}function eT(e){const t=String(e||"").replace(/\r\n/g,`
85
- `).split(`
86
- `);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let s="",i=0,a=!1;for(;i<r.length;){const l=r[i];if(l==="`"){a=!a,s+=l,i+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(i)))){s+=l,i+=1;continue}if((i>0?r[i-1]:"")==="("){s+=l,i+=1;continue}let d=i;for(;d<r.length&&!/\s|<|>/.test(r[d]);)d+=1;let f=r.slice(i,d),p="";for(;/[.,;:!?)}\]]$/.test(f);)p=f.slice(-1)+p,f=f.slice(0,-1);f?s+=`[${f}](${f})${p}`:s+=r.slice(i,d),i=d}return s}).join(`
87
- `)}function tT(e,t=!1,n=""){const r=i=>{const a=String(i||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=V1(a,n);return e?e(l,{kind:"link",download:!0}):l},s=(i,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(i.stopPropagation(),!(i.defaultPrevented||i.button!==0)&&(i.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:i})=>o.jsx(o.Fragment,{children:i})}:{},code:({inline:i,className:a,children:l})=>{var d;const c=((d=String(a||"").match(/language-(\w+)/i))==null?void 0:d[1])||"",u=String(l||"").replace(/\n$/,"");return!i&&/^(mermaid|mmd)$/i.test(c)?o.jsx(ZR,{code:u}):i?o.jsx("code",{className:a,children:l}):o.jsx("code",{className:a,children:l})},img:({src:i,alt:a})=>o.jsx("img",{src:e?e(V1(i,n)):i||"",alt:a||"",loading:"lazy"}),a:({href:i,children:a})=>o.jsx("a",{href:r(i),target:"_blank",rel:"noopener noreferrer",onClick:l=>s(l,i),children:a})}}function K1({children:e,resolveSrc:t,basePath:n=""}){return o.jsx(GR,{components:tT(t,!0,n),children:eT(e)})}function Gk({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>r7(e),[e]),s=m.useMemo(()=>tT(t,!1,n),[n,t]);return o.jsx(o.Fragment,{children:r.map((i,a)=>i.type==="mermaid"?o.jsx(ZR,{code:i.text},`mermaid-${a}`):i.type!=="table"?o.jsx(GR,{components:s,children:eT(i.text)},`md-${a}`):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:i.headers.map((l,c)=>o.jsx("th",{style:{textAlign:i.align[c]||"left"},children:o.jsx(K1,{resolveSrc:t,basePath:n,children:l})},c))})}),o.jsx("tbody",{children:i.rows.map((l,c)=>o.jsx("tr",{children:i.headers.map((u,d)=>o.jsx("td",{style:{textAlign:i.align[d]||"left"},children:o.jsx(K1,{resolveSrc:t,basePath:n,children:l[d]||""})},d))},c))})]})},`table-${a}`))})}function s7(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
88
- `);for(let l=0;l<a.length;l+=1){const c=a[l],u=a[l+1];if(i){c==='"'&&u==='"'?(s+='"',l+=1):c==='"'?i=!1:s+=c;continue}c==='"'?i=!0:c===t?(r.push(s.trim()),s=""):c===`
89
- `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function fi(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function i7(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>fi(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>fi(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>fi(i[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:fi(s)||`Column ${i+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,i)=>({key:String(i),label:fi(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>fi(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>fi(s[a])):s&&typeof s=="object"?r.map(i=>fi(s[i.key])):r.map((i,a)=>a===0?fi(s):""))}}function o7(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=i7(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
90
- `).split(`
91
- `).filter(l=>l.trim());if(s.length>=2&&Ji(s[0]).length>1&&XR(s[1])){const l=Ji(s[0]),c=QR(s[1]);return{columns:l.map((u,d)=>({key:String(d),label:u,align:c[d]||"left"})),rows:s.slice(2).map(u=>JR(Ji(u),l.length)),error:""}}const i=r.includes(" ")?" ":",",a=s7(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((c,u)=>c||`Column ${u+1}`).map((c,u)=>({key:String(u),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function Jk({content:e}){const t=m.useMemo(()=>o7(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:fi(n[i])},`${s.key}-${i}`))},r))})]})})}function Xk({content:e}){const t=m.useRef(null),n=m.useMemo(()=>JK(e),[e]),[r,s]=m.useState({loading:!1,error:""});return m.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),XW(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{i||!t.current||(a=u.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),i||s({loading:!1,error:""}))}).catch(u=>{i||s({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,d;i=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(d=a==null?void 0:a.dispose)==null||d.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function nT(e){return typeof e>"u"||e===null}function a7(e){return typeof e=="object"&&e!==null}function l7(e){return Array.isArray(e)?e:nT(e)?[]:[e]}function c7(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 u7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function d7(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var f7=nT,p7=a7,h7=l7,m7=u7,g7=d7,y7=c7,Qk={isNothing:f7,isObject:p7,toArray:h7,repeat:m7,isNegativeZero:g7,extend:y7};function rT(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
92
-
93
- `+e.mark.snippet),r+" "+n):r}function Dd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=rT(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+": "+rT(this,t)};var Ca=Dd,w7=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],x7=["scalar","sequence","mapping"];function b7(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function k7(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(w7.indexOf(n)===-1)throw new Ca('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=b7(t.styleAliases||null),x7.indexOf(this.kind)===-1)throw new Ca('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var _r=k7;function q1(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 v7(){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 Ux(e){return this.extend(e)}Ux.prototype.extend=function(t){var n=[],r=[];if(t instanceof _r)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 Ca("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof _r))throw new Ca("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new Ca("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 Ca("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 _r))throw new Ca("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(Ux.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=q1(s,"implicit"),s.compiledExplicit=q1(s,"explicit"),s.compiledTypeMap=v7(s.compiledImplicit,s.compiledExplicit),s};var S7=Ux,N7=new _r("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),j7=new _r("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),C7=new _r("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),_7=new S7({explicit:[N7,j7,C7]});function E7(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function A7(){return null}function P7(e){return e===null}var I7=new _r("tag:yaml.org,2002:null",{kind:"scalar",resolve:E7,construct:A7,predicate:P7,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function R7(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 T7(e){return e==="true"||e==="True"||e==="TRUE"}function M7(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var $7=new _r("tag:yaml.org,2002:bool",{kind:"scalar",resolve:R7,construct:T7,predicate:M7,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 L7(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function O7(e){return 48<=e&&e<=55}function D7(e){return 48<=e&&e<=57}function F7(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(!L7(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!O7(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!D7(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function z7(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 B7(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Qk.isNegativeZero(e)}var H7=new _r("tag:yaml.org,2002:int",{kind:"scalar",resolve:F7,construct:z7,predicate:B7,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"]}}),W7=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function V7(e){return!(e===null||!W7.test(e)||e[e.length-1]==="_")}function K7(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 q7=/^[-+]?[0-9]+e/;function U7(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(Qk.isNegativeZero(e))return"-0.0";return n=e.toString(10),q7.test(n)?n.replace("e",".e"):n}function Y7(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Qk.isNegativeZero(e))}var G7=new _r("tag:yaml.org,2002:float",{kind:"scalar",resolve:V7,construct:K7,predicate:Y7,represent:U7,defaultStyle:"lowercase"}),J7=_7.extend({implicit:[I7,$7,H7,G7]}),X7=J7,sT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),iT=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 Q7(e){return e===null?!1:sT.exec(e)!==null||iT.exec(e)!==null}function Z7(e){var t,n,r,s,i,a,l,c=0,u=null,d,f,p;if(t=sT.exec(e),t===null&&(t=iT.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]&&(d=+t[10],f=+(t[11]||0),u=(d*60+f)*6e4,t[9]==="-"&&(u=-u)),p=new Date(Date.UTC(n,r,s,i,a,l,c)),u&&p.setTime(p.getTime()-u),p}function eq(e){return e.toISOString()}var tq=new _r("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Q7,construct:Z7,instanceOf:Date,represent:eq});function nq(e){return e==="<<"||e===null}var rq=new _r("tag:yaml.org,2002:merge",{kind:"scalar",resolve:nq}),Zk=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
94
- \r`;function sq(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=Zk;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 iq(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=Zk,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 oq(e){var t="",n=0,r,s,i=e.length,a=Zk;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 aq(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var lq=new _r("tag:yaml.org,2002:binary",{kind:"scalar",resolve:sq,construct:iq,predicate:aq,represent:oq}),cq=Object.prototype.hasOwnProperty,uq=Object.prototype.toString;function dq(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,uq.call(s)!=="[object Object]")return!1;for(i in s)if(cq.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 fq(e){return e!==null?e:[]}var pq=new _r("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dq,construct:fq}),hq=Object.prototype.toString;function mq(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],hq.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function gq(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 yq=new _r("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:mq,construct:gq}),wq=Object.prototype.hasOwnProperty;function xq(e){if(e===null)return!0;var t,n=e;for(t in n)if(wq.call(n,t)&&n[t]!==null)return!1;return!0}function bq(e){return e!==null?e:{}}var kq=new _r("tag:yaml.org,2002:set",{kind:"mapping",resolve:xq,construct:bq});X7.extend({implicit:[tq,rq],explicit:[lq,pq,yq,kq]});function U1(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
95
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}var vq=new Array(256),Sq=new Array(256);for(var Rl=0;Rl<256;Rl++)vq[Rl]=U1(Rl)?1:0,Sq[Rl]=U1(Rl);const Fd=["requirement","planning","code","test","normal"],Y1={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function ev(e,t){var s,i,a,l,c,u,d,f,p,h,g,k,b,y;const n=v=>{const x={type:(v==null?void 0:v.type)??"node",name:(v==null?void 0:v.name)??"",value:(v==null?void 0:v.value)??(v==null?void 0:v.default)??""};return(v==null?void 0:v.required)===!0&&(x.required=!0),(v==null?void 0:v.description)!=null&&String(v.description).trim()&&(x.description=String(v.description)),(v==null?void 0:v.showOnNode)!=null&&(x.showOnNode=!!v.showOnNode),x},r={};for(const v of e){if((s=v==null?void 0:v.data)!=null&&s.isWorkspaceGroup)continue;const x=t[v.id]&&typeof t[v.id]=="object"?{...t[v.id]}:{},C=((i=v.data)==null?void 0:i.definitionId)||v.id,N=((a=v.data)==null?void 0:a.inputs)??[],j=((l=v.data)==null?void 0:l.outputs)??[],A=((c=v.data)==null?void 0:c.role)!=null?String(v.data.role).trim():"",I=x.role!=null?String(x.role).trim():"",O=Y1[A]||A,H=Y1[I]||I,B=Fd.includes(O)?O:Fd.includes(H)?H:"normal",z=Array.isArray(N)?N.map(n):Array.isArray(x.input)?x.input.map(ce=>n(ce)):[],$=Array.isArray(j)?j.map(n):Array.isArray(x.output)?x.output.map(ce=>n(ce)):[],M=((u=v.data)==null?void 0:u.label)!=null?String(v.data.label):x.label!=null?String(x.label):v.id,q=(d=v.data)==null?void 0:d.body,D=q!=null?String(q):x.body!=null?String(x.body):"";let L=((f=v.data)==null?void 0:f.model)!=null&&String(v.data.model).trim()!==""?String(v.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(L===""||L==="default")&&(L=void 0);const T={...x,definitionId:C,label:M,role:B,model:L,input:z,output:$},W=((p=v.data)==null?void 0:p.marketplaceRef)||x.marketplaceRef;W?T.marketplaceRef=String(W):delete T.marketplaceRef;const E=((h=v.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;E?T.marketplacePackageId=String(E):delete T.marketplacePackageId;const Q=((g=v.data)==null?void 0:g.marketplaceVersion)||x.marketplaceVersion;Q?T.marketplaceVersion=String(Q):delete T.marketplaceVersion,C.startsWith("provide_")||D.trim()===""?delete T.body:T.body=D;const V=Array.isArray((k=v.data)==null?void 0:k.images)?v.data.images:Array.isArray(x.images)?x.images:[];V.length>0?T.images=V:delete T.images;const F=(b=v.data)==null?void 0:b.script,se=F!=null?String(F):x.script!=null?String(x.script):"";se.trim()===""?delete T.script:T.script=se;for(const ce of["scriptRef","implementationRef","implementationMode"]){const J=(y=v.data)==null?void 0:y[ce],ne=J!=null?String(J):x[ce]!=null?String(x[ce]):"";ne.trim()===""?delete T[ce]:T[ce]=ne.trim()}delete T.temperature,delete T.maxTokens,delete T.description,r[v.id]=T}return r}function ad(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Nq(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 jq(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=>ad(a)),edges:i.map(a=>ad(a)),instances:ev(r,n||{})}}function Cq(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,Nq(p.id,a));const c=e.nodes.map(p=>{var g,k;const h=l.get(p.id);return{...ad(p),id:h,selected:!0,dragging:!1,position:{x:Number(((g=p.position)==null?void 0:g.x)||0)+i.x,y:Number(((k=p.position)==null?void 0:k.y)||0)+i.y}}}),u=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,h)=>{const g=l.get(p.source),k=l.get(p.target);return{...ad(p),id:`e-${g}-${k}-${Date.now()}-${h}`,source:g,target:k,selected:!1}}),d={...r||{}};for(const[p,h]of l.entries()){const g=(f=e.instances)==null?void 0:f[p];g&&(d[h]={...ad(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})),...u],instances:d,pastedNodeIds:c.map(p=>p.id)}}function In(e){switch(Qh(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Qh(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 _q(e,t){const n=Qh(e),r=Qh(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const Eq=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function Yx(e){const t=Qh(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&Eq.has(n)?`${t}+${n}`:t}function Aq(e){return Yx(e)}function zd(e,t){if(!e||!t||!_q(e.type,t.type))return!1;const n=Yx(e),r=Yx(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function Pq(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 Gx(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=Pq(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}const Zh=/\[image\s+(\d+)\]/gi;function fo(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 Iq(e){return`image ${fo(e).length+1}`}function Rq(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function Tq(e,t){const n=fo(e),r=String(t||""),s=new Set;Zh.lastIndex=0;let i;for(;i=Zh.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function Mq(e){return new Promise((t,n)=>{if(!e||!String(e.type||"").startsWith("image/")){n(new Error("Only image files are supported"));return}const r=new FileReader;r.onload=()=>{t({name:e.name||"image",mimeType:e.type||"image/png",dataUrl:String(r.result||"")})},r.onerror=()=>n(r.error||new Error("Failed to read image")),r.readAsDataURL(e)})}function oT(e){var n;return Array.from(((n=e==null?void 0:e.clipboardData)==null?void 0:n.items)||[]).filter(r=>r.kind==="file"&&String(r.type||"").startsWith("image/")).map(r=>r.getAsFile()).filter(Boolean)}function ld(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 aT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=fo(n);for(const a of r){const l=await Mq(a),c=Iq(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:c,...l}),s=Rq(s,c)}return{body:s,images:i}}function ks(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function $q(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 Lq(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Qt(e){e.stopPropagation()}function Oq(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dq(e,t){const n=`\\[${Oq(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
96
- `).replace(/\n{3,}/g,`
97
-
98
- `).trimEnd()}function Yy(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Fq(e){const t=String(e||"");let n="",r=0;Zh.lastIndex=0;let s;for(;s=Zh.exec(t);)n+=Yy(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${Yy(s[0])}</span>`,r=s.index+s[0].length;return n+=Yy(t.slice(r)),n||" "}function zq(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,u=Math.min(Math.max(c,2),8);return Math.ceil(u*r+s+i+a+l)}function Bq({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u}){var vt,Ut;const{t:d}=Dr(),f=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],h=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=$q(e),k=(e==null?void 0:e.isRunMode)??!1,b=!!(e!=null&&e.readOnly),y=(e==null?void 0:e.isExecuting)??!1,v=(e==null?void 0:e.isDim)??!1,x=(e==null?void 0:e.nodeStatus)??null,C=(e==null?void 0:e.nodeElapsed)??null,N=(e==null?void 0:e.definitionId)||"",j=N.startsWith("provide_"),A=N==="provide_bool",I=N==="provide_str",O=N==="provide_file",H=N==="provide_password",B=N==="agent_subAgent",z=N==="control_agent_toBool",$=(B||z)&&!k,M=A?Lq(p[0]):!1,q=j?String(((vt=p[0])==null?void 0:vt.value)??((Ut=p[0])==null?void 0:Ut.default)??(e==null?void 0:e.body)??""):"",D=String((e==null?void 0:e.body)||""),L=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||d("flow:node.fallbackLabel"),T=!j&&!$&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",W=fo(e==null?void 0:e.images),E=A||I||O||H||$||!!T,Q=m.useRef(!1),V=m.useRef(!1),F=m.useRef(null),se=m.useRef(null),ce=m.useRef(null),J=m.useRef(null),ne=m.useRef(null),[ee,re]=m.useState(q),[Z,le]=m.useState(!1),[de,we]=m.useState(D),[De,Qe]=m.useState(!1),[Oe,st]=m.useState({visible:!1,top:0,height:100}),[mt,kt]=m.useState(!1),Pe=m.useCallback(()=>{const ae=se.current;if(!ae)return;const ke=Math.max(1,ae.scrollHeight),it=Math.max(1,ae.clientHeight),bt=ke>it+1,cn=bt?Math.max(12,it/ke*100):100,On=Math.max(0,100-cn),nn=bt?Math.min(On,ae.scrollTop/Math.max(1,ke-it)*On):0;st({visible:bt,top:nn,height:cn})},[]);m.useEffect(()=>{Q.current||re(q)},[n,q]),m.useEffect(()=>{V.current||we(D)},[n,D]),m.useEffect(()=>{const ae=se.current;if(!ae)return;if($){ae.style.minHeight="",ae.style.height="",ce.current&&(ce.current.style.minHeight="",ce.current.style.height="");return}const ke=zq(ae,de);ae.style.minHeight=`${ke}px`,ae.style.height="",ce.current&&(ce.current.style.minHeight=`${ke}px`,ce.current.style.height="")},[de,$]),m.useEffect(()=>{if(!$)return;const ae=window.requestAnimationFrame(Pe),ke=se.current;if(!ke||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(ae);const it=new ResizeObserver(Pe);return it.observe(ke),()=>{window.cancelAnimationFrame(ae),it.disconnect()}},[de,$,Pe]),m.useEffect(()=>{const ae=F.current,ke=e==null?void 0:e.onNodeContentResize;if(!$||!ae||!ke||typeof ResizeObserver>"u")return;let it=0;const bt=()=>{window.cancelAnimationFrame(it),it=window.requestAnimationFrame(()=>ke(n))},cn=new ResizeObserver(bt);return cn.observe(ae),bt(),()=>{window.cancelAnimationFrame(it),cn.disconnect()}},[e==null?void 0:e.onNodeContentResize,$,n]),m.useEffect(()=>{if(!mt)return;const ae=window.setTimeout(()=>{const ke=ne.current;if(!ke)return;ke.focus();const it=ke.value.length;ke.setSelectionRange(it,it)},0);return()=>window.clearTimeout(ae)},[mt]);const dt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],gt=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],xe=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Fe=Array.isArray(c==null?void 0:c.codex)?c.codex:[],Me=((e==null?void 0:e.model)??"").trim(),ue=h==="agent"&&!N.startsWith("tool_nodejs"),ve=new Set(dt.map(ks)),Ve=new Set(gt.map(ks)),qe=new Set(xe.map(ks)),be=new Set(Fe.map(ks)),Tt=Me?Me.startsWith("cursor:")||Me.startsWith("opencode:")||Me.startsWith("codex:")||Me.startsWith("claude-code:")?Me:qe.has(Me)?`claude-code:${Me}`:be.has(Me)?`codex:${Me}`:Ve.has(Me)?`opencode:${Me}`:ve.has(Me)?`cursor:${Me}`:Me:"",ln=Me&&!Tt.startsWith("cursor:")&&!Tt.startsWith("opencode:")&&!Tt.startsWith("codex:")&&!Tt.startsWith("claude-code:")&&!ve.has(Me)&&!Ve.has(Me)&&!qe.has(Me)&&!be.has(Me),_t=Me.startsWith("cursor:")?Me.slice(7):Me.startsWith("opencode:")?Me.slice(9):Me.startsWith("codex:")?Me.slice(6):Me.startsWith("claude-code:")?Me.slice(12):Me,hn=ae=>{if(b)return;const ke=ae.target.value;u&&u(n,ke)},tn=ae=>{ae.stopPropagation(),!b&&r&&r(n)},te=ae=>{ae.stopPropagation(),s&&s()},Ie=ae=>{ae.stopPropagation(),!b&&(i==null||i(n,ae.target.value==="true"?"true":"false"))},Ue=ae=>{if(ae.stopPropagation(),b)return;const ke=ae.target.value;re(ke),Q.current||i==null||i(n,ke)},Ze=ae=>{ae.stopPropagation(),Q.current=!0},Mt=ae=>{if(ae.stopPropagation(),b)return;Q.current=!1;const ke=ae.currentTarget.value;re(ke),i==null||i(n,ke)},At=()=>{b||i==null||i(n,ee)},tr=ae=>{if(ae.stopPropagation(),b)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ee);return}const ke=window.prompt("文件路径",ee);ke!=null&&(re(ke),i==null||i(n,ke))},kn=ae=>{ae.stopPropagation(),le(ke=>!ke)},nr=ae=>{if(we(ae),a==null||a(n,ae),l){const ke=Tq(W,ae);(ke.length!==W.length||ke.some((it,bt)=>{var cn;return it.id!==((cn=W[bt])==null?void 0:cn.id)}))&&l(n,ke)}},vn=ae=>{if(ae.stopPropagation(),b)return;const ke=ae.target.value;V.current?we(ke):nr(ke)},Jn=ae=>{ae.stopPropagation(),!b&&(V.current=!0,Qe(!0))},Wn=ae=>{if(ae.stopPropagation(),b)return;V.current=!1,Qe(!1);const ke=ae.currentTarget.value;nr(ke)},ur=()=>{b||(V.current=!1,Qe(!1),nr(de))},gs=ae=>{ae.stopPropagation(),ae.preventDefault(),!b&&kt(!0)},wr=()=>{kt(!1),ur()},Rs=ae=>{ae.stopPropagation(),ae.key==="Escape"&&(ae.preventDefault(),wr())},Fr=m.useCallback(ae=>{const ke=se.current;if(!ke)return;const it=Math.max(0,ke.scrollHeight-ke.clientHeight);ke.scrollTop=Math.min(1,Math.max(0,ae))*it,Pe()},[Pe]),on=m.useCallback((ae,ke=0)=>{const it=J.current;if(!it)return 0;const bt=it.getBoundingClientRect(),cn=Oe.height/100*bt.height,On=Math.max(1,bt.height-cn);return(ae-bt.top-ke)/On},[Oe.height]),xr=m.useCallback(ae=>{var Gt,Sr;if(!Oe.visible)return;ae.preventDefault(),ae.stopPropagation();const ke=J.current;if(!ke)return;const it=ke.getBoundingClientRect(),bt=Oe.top/100*it.height,cn=Oe.height/100*it.height,nn=ae.clientY>=it.top+bt&&ae.clientY<=it.top+bt+cn?ae.clientY-it.top-bt:cn/2;Fr(on(ae.clientY,nn));const vr=ae.pointerId;(Sr=(Gt=ae.currentTarget).setPointerCapture)==null||Sr.call(Gt,vr);const ft=tt=>{tt.preventDefault(),Fr(on(tt.clientY,nn))},Yt=()=>{window.removeEventListener("pointermove",ft),window.removeEventListener("pointerup",Yt),window.removeEventListener("pointercancel",Yt)};window.addEventListener("pointermove",ft),window.addEventListener("pointerup",Yt),window.addEventListener("pointercancel",Yt)},[on,Oe.height,Oe.top,Oe.visible,Fr]),br=async ae=>{if(b)return;const ke=await aT({files:ae,body:de,images:W});ke&&(we(ke.body),a==null||a(n,ke.body),l==null||l(n,ke.images))},mn=(ae,ke)=>{if(ae.stopPropagation(),b)return;const it=W.filter(cn=>cn.id!==ke.id),bt=Dq(de,ke.label);we(bt),a==null||a(n,bt),l==null||l(n,it)},Vn=ae=>{if(b)return;const ke=oT(ae);ke.length!==0&&(ae.preventDefault(),ae.stopPropagation(),br(ke).catch(()=>{}))},kr=ae=>{if(b)return;const ke=ld(ae);ke.length!==0&&(ae.preventDefault(),ae.stopPropagation(),br(ke).catch(()=>{}))},dr=()=>{const ae=se.current,ke=ce.current;!ae||!ke||(ke.scrollTop=ae.scrollTop,ke.scrollLeft=ae.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(y?" af-flow-node--executing":"")+(x==="success"?" af-flow-node--done":"")+(x==="failed"?" af-flow-node--failed":"")+(x==="running"&&!y?" af-flow-node--running-disk":"")+(v?" af-flow-node--dim":"")+($?" af-flow-node--inline-body-editor":"")+(I?" af-flow-node--provide-text":"")+(H?" af-flow-node--provide-password":"")+" 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__title af-flow-node__title--chrome",title:`${L}${n?` (${n})`:""}${g?` · ${g}`:""}`,children:L}),!k&&ue&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:Tt,onChange:hn,onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,"aria-label":d("flow:node.model"),title:_t||d("flow:node.defaultModel"),disabled:b,children:[o.jsx("option",{value:"",children:d("flow:node.defaultModel")}),ln&&o.jsx("option",{value:Me,children:Me}),dt.length>0&&o.jsx("optgroup",{label:"Cursor",children:dt.map(ae=>o.jsx("option",{value:`cursor:${ks(ae)}`,children:ks(ae)},`c-${ae}`))}),gt.length>0&&o.jsx("optgroup",{label:"OpenCode",children:gt.map(ae=>o.jsx("option",{value:`opencode:${ks(ae)}`,children:ks(ae)},`o-${ae}`))}),Fe.length>0&&o.jsx("optgroup",{label:"Codex",children:Fe.map(ae=>o.jsx("option",{value:`codex:${ks(ae)}`,children:ks(ae)},`codex-${ae}`))}),xe.length>0&&o.jsx("optgroup",{label:"Claude Code",children:xe.map(ae=>o.jsx("option",{value:`claude-code:${ks(ae)}`,children:ks(ae)},`cc-${ae}`))})]}),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"}),x==="running"&&!y&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:d("flow:node.diskRunning"),children:"RUNNING"}),x==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:C!=null&&String(C).trim()!==""?C:"--"}),x==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!k&&j&&!A&&!I&&!O&&!H&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:te,"aria-label":d("flow:node.expandProvide"),title:d("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!k&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:b,onClick:tn,"aria-label":d("flow:node.deleteNode"),title:d("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((ae,ke)=>{if(ae.showOnNode===!1)return null;const it=d("flow:node.inputTooltip",{name:ae.name||`#${ke}`,type:ae.type})+(ae.default!=null&&ae.default!==""?d("flow:node.defaultSuffix",{value:ae.default}):""),bt=ae.name||`#${ke+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[bt,ae.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${ke}`,className:"af-flow-node__handle",style:{background:In(ae.type)},title:it})]},`in-${ke}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[A?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(M?" af-flow-node__bool-select--true":""),value:M?"true":"false",onChange:Ie,onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,"aria-label":"Boolean value",title:M?"true":"false",disabled:b,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):I?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ee,onChange:Ue,onCompositionStart:Ze,onCompositionEnd:Mt,onBlur:At,onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,placeholder:"输入文本",rows:2,readOnly:b}):O?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:ee,onChange:Ue,onCompositionStart:Ze,onCompositionEnd:Mt,onBlur:At,placeholder:"选择或输入文件路径",title:ee||"选择或输入文件路径",readOnly:b}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:b,onClick:tr,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):H?o.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,children:[o.jsx("input",{className:"af-flow-node__password-input nodrag",type:Z?"text":"password",value:ee,onChange:Ue,onCompositionStart:Ze,onCompositionEnd:Mt,onBlur:At,placeholder:"输入密码或密钥",title:Z?ee:"密码已隐藏",autoComplete:"off",readOnly:b}),o.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:b,onClick:kn,"aria-label":Z?"隐藏密码":"预览密码",title:Z?"隐藏密码":"预览密码",children:o.jsx("span",{className:"material-symbols-outlined",children:Z?"visibility_off":"visibility"})})]}):$?o.jsxs("div",{ref:F,className:"af-flow-node__prompt-stack nodrag"+(De?" af-flow-node__prompt-stack--composing":""),children:[o.jsx("pre",{ref:ce,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:Fq(de)+`
99
- `}}),o.jsx("textarea",{ref:se,className:"af-flow-node__prompt-editor nodrag",value:de,onChange:vn,onCompositionStart:Jn,onCompositionEnd:Wn,onBlur:ur,onPaste:Vn,onDrop:kr,onScroll:ae=>{dr(),Pe()},onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,onKeyDown:Qt,onDragOver:ae=>{ld(ae).length>0&&ae.preventDefault()},placeholder:z?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:b}),!b&&o.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:Qt,onMouseDown:Qt,onClick:gs,"aria-label":"放大编辑",title:"放大编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),o.jsx("div",{ref:J,className:"af-flow-node__prompt-scrollbar"+(Oe.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:xr,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${Oe.height}%`,top:`${Oe.top}%`}})})]}):null,$&&W.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:W.map((ae,ke)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:ae.name,children:[o.jsx("img",{src:ae.dataUrl,alt:""}),o.jsxs("span",{children:["[",ae.label||`image ${ke+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:b,onClick:it=>mn(it,ae),onPointerDown:Qt,onMouseDown:Qt,"aria-label":`删除 ${ae.label||`image ${ke+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ae.id||ke))}):null,T?o.jsx("span",{className:"af-flow-node__prompt-preview",title:T,children:T}):null,E?null:o.jsx("span",{className:"af-flow-node__body-title",title:L,children:L})]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((ae,ke)=>{if(ae.showOnNode===!1)return null;const it=d("flow:node.outputTooltip",{name:ae.name||`#${ke}`,type:ae.type})+(ae.default!=null&&ae.default!==""?d("flow:node.defaultSuffix",{value:ae.default}):""),bt=ae.name||`#${ke+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:it,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[bt,ae.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${ke}`,className:"af-flow-node__handle",style:{background:In(ae.type)},title:it})]},`out-${ke}`)})})]}),mt?or.createPortal(o.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:Qt,onMouseDown:Qt,onClick:Qt,onWheel:Qt,children:o.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[o.jsxs("div",{className:"af-flow-node-full-editor__header",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-flow-node-full-editor__title",children:L}),o.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),o.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:wr,"aria-label":"关闭",title:"关闭",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("textarea",{ref:ne,className:"af-flow-node-full-editor__textarea",value:de,onChange:vn,onCompositionStart:Jn,onCompositionEnd:Wn,onPaste:Vn,onDrop:kr,onKeyDown:Rs,onDragOver:ae=>{ld(ae).length>0&&ae.preventDefault()},placeholder:z?"输入判断条件 / prompt":"输入 prompt",readOnly:b})]})}),document.body):null]})}const fc="flowNode";function Jx(e){const t=e.type||"node",n=e.showOnNode!=null,r={type:t,name:e.name||"",default:e.value!==void 0&&e.value!==null?String(e.value):e.default!==void 0?String(e.default):""};return e.required!=null&&(r.required=!!e.required),e.description!=null&&(r.description=String(e.description)),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const Hq={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace","Load Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],workspace_scheduled_run:["Scheduled Run"],workspace_run:["Run"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_set_run_env:["Set Run Env","Set Env"],tool_display_share_link:["Display Share Link","Share Link"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_password:["Password"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_react_app:["React App"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function Wq(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(Hq[e]||[]).includes(s)?r:s}const Vq={tool_git_checkout:new Set(["targetDir","pullIfExists","includeSubmodules","workspaceContext","commit","changed"]),control_load_skills:new Set(["mergeMode","workspaceContext","skillsContext","loadedCount","summary"]),control_load_mcp:new Set(["workspaceContext","mcpContext","loadedCount","summary"]),agent_subAgent:new Set(["workspaceContext","skillsContext","mcpContext"])},Kq={control_cd_workspace:new Set(["mode","label","workspaceContext","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_react_app:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},qq={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},Uq=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function Yq(e,t){if(!Uq.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function Gq(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Jq(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function lT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function Xq(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function Qq(e){const t=String(e??"").trim();return t?t.includes("${")?t:lT(t):""}function Zq(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const r=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),s=r?`${r}/${n}`:`\${flowDir}/${n}`,i=Array.isArray(t.args)?t.args.map(Qq).filter(Boolean):[];return[Xq(t,n),lT(s),...i].join(" ")}return String(t.command||"").trim()}function G1(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var u,d,f;const i=n[s],l=n.find(p=>(p==null?void 0:p.name)&&p.name===r.name)||i;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=Vq[e])==null?void 0:u.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...c?{showOnNode:!0}:{},...!r._showOnNodeExplicit&&l.showOnNode!=null?{showOnNode:!!l.showOnNode}:{},...!r._showOnNodeExplicit&&l.showOnNode==null?{showOnNode:!!r.required||String(r.type||"").trim().toLowerCase()==="node"}:{},...!r._showOnNodeExplicit&&Yq(e,r)?{showOnNode:!0}:{},...(d=qq[e])!=null&&d.has(r.name)?{showOnNode:!0}:{},...(f=Kq[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function eU(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=Jx(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,description:String(c.description??""),showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function Xx(e,t,n,r,s){var T,W,E,Q,V,F,se,ce,J,ne,ee,re,Z,le,de,we,De,Qe,Oe,st,mt,kt;const i=((T=e.data)==null?void 0:T.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Pe=>Pe.id===i),l=t[e.id];let c=[],u=[],d=((W=e.data)==null?void 0:W.label)??e.id,f,p,h,g,k;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(Jx)),Array.isArray(l.output)&&(u=l.output.map(Jx)),l.label&&(d=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(k=String(l.script)));const y=f??(typeof((E=e.data)==null?void 0:E.role)=="string"?e.data.role:"普通"),v=p??((Q=e.data)==null?void 0:Q.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",C=x!==""?x:void 0,N=h??((V=e.data)==null?void 0:V.body)??"",j=Array.isArray(g)?g:Array.isArray((F=e.data)==null?void 0:F.images)?e.data.images:[],A=Zq(a),I=k!==void 0?k:((se=e.data)==null?void 0:se.script)!=null?String(e.data.script):A,O=String(e.id),H=(ce=r==null?void 0:r[s])==null?void 0:ce[O],B=(J=H==null?void 0:H.label)==null?void 0:J.label,z=H==null?void 0:H.body,$=H==null?void 0:H.description;b||(c.length===0&&((ne=a==null?void 0:a.inputs)!=null&&ne.length)&&(c=a.inputs.map(Pe=>({...Pe}))),u.length===0&&((ee=a==null?void 0:a.outputs)!=null&&ee.length)&&(u=a.outputs.map(Pe=>({...Pe}))));const M=Jq(a,(a==null?void 0:a.id)??i),q=(l==null?void 0:l.marketplaceRef)||((re=e.data)==null?void 0:re.marketplaceRef)||Gq(a);if(M==="agent_subAgent"&&!u.some(Pe=>(Pe==null?void 0:Pe.name)==="result")){const Pe=(Z=a==null?void 0:a.outputs)==null?void 0:Z.find(dt=>(dt==null?void 0:dt.name)==="result");u=[...u,Pe?{...Pe}:{type:"text",name:"result",default:""}]}if(M==="agent_subAgent"&&!c.some(Pe=>(Pe==null?void 0:Pe.name)==="knowledgeContext")){const Pe=(le=a==null?void 0:a.inputs)==null?void 0:le.find(dt=>(dt==null?void 0:dt.name)==="knowledgeContext");c=[...c,Pe?{...Pe}:{type:"text",name:"knowledgeContext",default:"",showOnNode:!0}]}if((M==="display_markdown"||M==="display_mermaid"||M==="display_ascii"||M==="display_chart"||M==="display_table")&&!u.some(Pe=>(Pe==null?void 0:Pe.name)==="next")){const Pe=(de=a==null?void 0:a.outputs)==null?void 0:de.find(dt=>(dt==null?void 0:dt.name)==="next");u=[...u,Pe?{...Pe}:{type:"node",name:"next",default:""}]}if(M==="workspace_run"){if(!c.some(Pe=>(Pe==null?void 0:Pe.name)==="prev")){const Pe=(we=a==null?void 0:a.inputs)==null?void 0:we.find(dt=>(dt==null?void 0:dt.name)==="prev");c=[Pe?{...Pe}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Pe=>(Pe==null?void 0:Pe.name)==="next")){const Pe=(De=a==null?void 0:a.outputs)==null?void 0:De.find(dt=>(dt==null?void 0:dt.name)==="next");u=[...u,Pe?{...Pe}:{type:"node",name:"next",default:""}]}}c=G1(M,c,a==null?void 0:a.inputs),u=G1(M,u,a==null?void 0:a.outputs),M.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(N).trim()!==""&&(u=u.map((Pe,dt)=>dt===0?{...Pe,default:N,value:N}:Pe));const D=Wq(M,d,a),L=M==="tool_nodejs"||String(I).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:B||d,displayLabel:D,definitionDisplayName:a==null?void 0:a.displayName,definitionId:M,...q?{marketplaceRef:q}:{},...l!=null&&l.marketplacePackageId||(Qe=e.data)!=null&&Qe.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((Oe=e.data)==null?void 0:Oe.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(st=e.data)!=null&&st.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((mt=e.data)==null?void 0:mt.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((kt=e.data)==null?void 0:kt.schemaType)??e.type??"agent",role:y,model:v,body:z||N,images:j,script:I,inputs:c,outputs:u,description:$||C,originalLabel:d,originalBody:N,...L?{script:I}:{}}}}function tU(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var d,f,p,h;const s=n.get(r.source),i=n.get(r.target),a=((f=(d=s==null?void 0:s.data)==null?void 0:d.outputs)==null?void 0:f.length)??0,l=((h=(p=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,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&i&&c>=0&&c<a&&u>=0&&u<l})}function J1(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 X1(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function Gy(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=J1(t==null?void 0:t.sourceHandle,"output"),i=J1(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,d,f,p;if(c.id===n){const h=X1((u=c.data)==null?void 0:u.outputs,s);if(h!==((d=c.data)==null?void 0:d.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=X1((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 nU(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 Q1(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function rU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function sU({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function Ws({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(sU,{children:t})]},n))})}function iU({open:e,onClose:t}){const{t:n}=Dr(),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=rU()?"⌘":"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(Ws,{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(Ws,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(Ws,{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(Ws,{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(Ws,{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(Ws,{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(Ws,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(Ws,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(Ws,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(Ws,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(Ws,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function oU(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 aU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Dr(),[i,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),d=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var k;return(k=u.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e]);const f=m.useMemo(()=>{const g=(r||[]).map(y=>{var v,x,C;return{id:y.id,label:((v=y.data)==null?void 0:v.label)||"",definitionId:((x=y.data)==null?void 0:x.definitionId)||"",schemaType:((C=y.data)==null?void 0:C.schemaType)||""}}),k=i.trim(),b=g.map(y=>({e:y,s:oU(y,k)})).filter(y=>y.s>0);return b.sort((y,v)=>v.s-y.s||y.e.id.localeCompare(v.e.id)),b.slice(0,50).map(y=>y.e)},[r,i]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var k;const g=(k=d.current)==null?void 0:k.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const k=f[g];k&&(n(k.id),t())},h=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(k=>Math.min(f.length-1,k+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(k=>Math.max(0,k-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:u,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:d,className:"af-jump-panel__list",role:"listbox",children:f.map((g,k)=>o.jsxs("li",{"data-idx":k,role:"option","aria-selected":k===l,className:"af-jump-panel__item"+(k===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(k),onMouseDown:b=>{b.preventDefault(),p(k)},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 Z1(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=s=>String(s).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function lU(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";if(t<1e3)return`${Math.round(t)}ms`;const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60),s=n%60;return`${r}m${String(s).padStart(2,"0")}s`}function eC(e){if(!e||typeof e!="object")return"";if(e.line)return String(e.line);if(e.text)return String(e.text);if(e.error)return String(e.error);if(e.message)return String(e.message);if(e.status)return String(e.status);if(e.type==="graph"){const n=Array.isArray(e.displayNodeIds)?e.displayNodeIds.join(", "):"";return n?`graph updated: ${n}`:"graph updated"}const t=JSON.stringify(e);return t.length>4e3?`${t.slice(0,4e3)}
100
- ... [truncated]`:t}function Jy(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function tC(e){const t=String(e||"").toLowerCase();return t.includes("success")?"success":t.includes("fail")||t.includes("error")?"failed":t.includes("skip")||t.includes("disabled")?"skipped":t.includes("running")?"running":t.includes("stop")?"stopped":"idle"}function cU({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:s="",onClose:i}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[d,f]=m.useState(null),[p,h]=m.useState(!1),[g,k]=m.useState(!1),[b,y]=m.useState(""),[v,x]=m.useState(""),C=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),y("");try{const I=new URLSearchParams;I.set("flowId",e.flowId),I.set("flowSource",e.flowSource||"user"),t?I.set("scheduleNodeId",t):n&&I.set("runNodeId",n),I.set("limit","80");const O=await fetch(`/api/workspace/run-logs?${I.toString()}`),H=await O.json().catch(()=>({}));if(!O.ok)throw new Error(H.error||"读取日志失败");const B=Array.isArray(H.runs)?H.runs:[];l(B),u(z=>{const $=B[0]||null;return $&&String($.status||"")==="running"&&$.runId!==z?$.runId:z&&B.some(M=>M.runId===z)?z:r&&B.some(M=>M.runId===r)?r:($==null?void 0:$.runId)||""})}catch(I){y(String(I.message||I)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),N=m.useCallback(async I=>{if(!I){f(null);return}k(!0);try{const O=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&O.set("archived","1");const H=await fetch(`/api/workspace/run-logs/${encodeURIComponent(I)}?${O.toString()}`),B=await H.json().catch(()=>({}));if(!H.ok)throw new Error(B.error||"读取日志详情失败");f(B)}catch(O){f({error:String(O.message||O),events:[]})}finally{k(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{C()},[C]),m.useEffect(()=>{N(c)},[N,c]),m.useEffect(()=>{const I=a.find(H=>H.runId===c),O=window.setInterval(()=>{C(),(!I||I.status==="running")&&c&&N(c)},2e3);return()=>window.clearInterval(O)},[N,C,a,c]);const j=m.useMemo(()=>{const I=Array.isArray(d==null?void 0:d.events)?d.events:[],O=v.trim().toLowerCase();return O?I.filter(H=>String(H.type||"").toLowerCase().includes(O)||Jy(H).toLowerCase().includes(O)||eC(H).toLowerCase().includes(O)):I},[d==null?void 0:d.events,v]),A=(d==null?void 0:d.run)||a.find(I=>I.runId===c)||null;return o.jsxs("div",{className:"af-work-run-logs",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:i,"aria-label":"关闭日志侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-run-logs__meta",children:[o.jsx("span",{children:s||t||n||"Workspace Run"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void C(),title:"刷新日志","aria-label":"刷新日志",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),b?o.jsx("div",{className:"af-work-run-logs__error",children:b}):null,o.jsxs("div",{className:"af-work-run-logs__body",children:[o.jsxs("div",{className:"af-work-run-logs__list",children:[o.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),p?o.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!p&&a.length===0?o.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(I=>o.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(I.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(I.runId),title:I.runId,children:[o.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${tC(I.status)}`,children:I.status||"unknown"}),o.jsx("span",{className:"af-work-run-logs__run-label",children:I.label||I.runNodeId||I.scheduleNodeId||"Workspace Run"}),o.jsx("span",{children:Z1(I.startedAt)}),o.jsx("span",{children:lU(I.durationMs)})]},I.runId))]}),o.jsxs("div",{className:"af-work-run-logs__detail",children:[o.jsxs("div",{className:"af-work-run-logs__detail-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),A!=null&&A.label?o.jsx("div",{className:"af-work-run-logs__detail-label",children:A.label}):null,o.jsx("div",{className:"af-work-run-logs__run-id",children:(A==null?void 0:A.runId)||"-"})]}),A?o.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${tC(A.status)}`,children:A.status}):null]}),o.jsxs("label",{className:"af-work-run-logs__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{value:v,onChange:I=>x(I.target.value),placeholder:"搜索事件、节点、错误"})]}),g?o.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,d!=null&&d.error?o.jsx("div",{className:"af-work-run-logs__error",children:d.error}):null,!g&&!j.length?o.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,o.jsx("div",{className:"af-work-run-logs__events",children:j.map((I,O)=>o.jsxs("div",{className:"af-work-run-logs__event",children:[o.jsx("span",{className:"af-work-run-logs__event-time",children:Z1(I.ts)}),o.jsx("span",{className:"af-work-run-logs__event-type",children:I.type||"event"}),Jy(I)?o.jsx("span",{className:"af-work-run-logs__event-node",children:Jy(I)}):null,o.jsx("pre",{children:eC(I)})]},`${I.ts||O}-${O}`))})]})]})]})}function uU(e){let t=String(e||"").trim();const n=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*?)```/i);if(n&&n[1])t=n[1].trim();else{const r=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*)$/i);r&&r[1]&&(t=r[1].trim())}return t.replace(/```\s*$/g,"").trim()}function cT(e){const t=uU(e);if(!t)return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":"export default function App() { return <main><h1>React App</h1><p>No project files yet.</p></main>; }"},inputs:{}};try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.files&&typeof n.files=="object"&&!Array.isArray(n.files)?n.files:{};return{title:String(n.title||n.name||"React App"),entry:String(n.entry||n.main||"src/App.jsx"),files:Object.fromEntries(Object.entries(r).map(([s,i])=>[String(s),String(i??"")])),packageJson:n.packageJson&&typeof n.packageJson=="object"?n.packageJson:null,inputs:n.inputs&&typeof n.inputs=="object"&&!Array.isArray(n.inputs)?n.inputs:{}}}}catch{}return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":t},inputs:{}}}function dU(e){let t=String(e||"");return t=t.replace(/^\s*import\s+[^;]+;\s*$/gm,""),t=t.replace(/^\s*import\s+["'][^"']+["'];\s*$/gm,""),t=t.replace(/\bexport\s+default\s+function\s+([A-Za-z_$][\w$]*)\s*\(/g,"const __AgentFlowDefault = function $1("),t=t.replace(/\bexport\s+default\s+function\s*\(/g,"const __AgentFlowDefault = function App("),t=t.replace(/\bexport\s+default\s+class\s+([A-Za-z_$][\w$]*)\s+extends/g,"const __AgentFlowDefault = class $1 extends"),t=t.replace(/\bexport\s+default\s+class\s+extends/g,"const __AgentFlowDefault = class extends"),t=t.replace(/\bexport\s+default\s+(\([^)]*\)\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;?/g,"const __AgentFlowDefault = $1;"),t=t.replace(/\bexport\s+(const|let|var|function|class)\s+/g,"$1 "),t=t.replace(/^\s*export\s+\{[^}]+\};?\s*$/gm,""),t.trim()}function fU(e){return String(e).replace(/<\/script/gi,"<\\/script")}function ng(e){const t=cT(e);return JSON.stringify({title:t.title,entry:t.entry,packageJson:t.packageJson||{scripts:{dev:"vite --host 0.0.0.0",build:"vite build"},dependencies:{"@vitejs/plugin-react":"latest",vite:"latest",react:"latest","react-dom":"latest"},devDependencies:{}},files:t.files,inputs:t.inputs},null,2)}function tv(e,t=""){const n=cT(e),r=n.files||{},s=r[n.entry]!=null?n.entry:Object.keys(r).find(p=>/(?:^|\/)App\.[jt]sx$/i.test(p))||Object.keys(r).find(p=>/\.[jt]sx?$/i.test(p))||n.entry,i=dU(r[s]||""),a=Object.entries(r).filter(([p])=>/\.css$/i.test(p)).map(([,p])=>String(p||"")).join(`
101
-
102
- `),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),d=fU(i||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),f=a||`
103
- * { box-sizing: border-box; }
104
- body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
105
- main { min-height: 100vh; padding: 24px; }
106
- button, input, select, textarea { font: inherit; }
107
- `;return`<!doctype html>
108
- <html>
109
- <head>
110
- <meta charset="utf-8" />
111
- <meta name="viewport" content="width=device-width, initial-scale=1" />
112
- <base target="_blank" />
113
- <title>${l.replace(/[<&>]/g,p=>({"<":"&lt;",">":"&gt;","&":"&amp;"})[p])}</title>
114
- <style>${f.replace(/<\/style/gi,"<\\/style")}</style>
115
- </head>
116
- <body>
117
- <div id="root"></div>
118
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
119
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
120
- <script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>
121
- <script>
122
- window.AGENTFLOW_INPUTS = ${u};
123
- window.addEventListener("error", (event) => {
124
- const root = document.getElementById("root");
125
- if (root && !root.__agentflowRendered) {
126
- root.innerHTML = '<pre style="margin:16px;padding:16px;border:1px solid rgba(255,117,117,.35);border-radius:8px;background:rgba(127,29,29,.18);color:#ffb8b8;white-space:pre-wrap;">' + String(event.message || event.error || 'React app failed').replace(/[<>&]/g, (ch) => ({'<':'&lt;','>':'&gt;','&':'&amp;'}[ch])) + '</pre>';
127
- }
128
- });
129
- document.addEventListener("click", (event) => {
130
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
131
- if (!link) return;
132
- const rawHref = String(link.getAttribute("href") || "").trim();
133
- if (!rawHref || rawHref.startsWith("#")) return;
134
- if (/^javascript:/i.test(rawHref)) {
135
- event.preventDefault();
136
- return;
137
- }
138
- event.preventDefault();
139
- window.open(link.href, "_blank", "noopener,noreferrer");
140
- }, true);
141
- <\/script>
142
- <script type="text/babel">
143
- const { useCallback, useEffect, useMemo, useRef, useState } = React;
144
- ${d}
145
- const RootComponent = typeof __AgentFlowDefault !== "undefined" ? __AgentFlowDefault : (typeof App !== "undefined" ? App : function MissingApp() {
146
- return <main><h1>React App</h1><p>Entry file must export or define an App component.</p></main>;
147
- });
148
- ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent inputs={window.AGENTFLOW_INPUTS} />);
149
- document.getElementById("root").__agentflowRendered = true;
150
- <\/script>
151
- <script>
152
- (() => {
153
- const frameId = ${c};
154
- const postSize = () => {
155
- const doc = document.documentElement;
156
- const body = document.body;
157
- const height = Math.ceil(Math.max(
158
- doc ? doc.scrollHeight : 0,
159
- doc ? doc.offsetHeight : 0,
160
- doc ? doc.clientHeight : 0,
161
- body ? body.scrollHeight : 0,
162
- body ? body.offsetHeight : 0,
163
- body ? body.clientHeight : 0,
164
- window.innerHeight || 0
165
- ));
166
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
167
- };
168
- window.addEventListener("load", postSize);
169
- window.addEventListener("resize", postSize);
170
- requestAnimationFrame(postSize);
171
- setTimeout(postSize, 300);
172
- setTimeout(postSize, 1000);
173
- if (typeof ResizeObserver !== "undefined") {
174
- const resizeObserver = new ResizeObserver(postSize);
175
- resizeObserver.observe(document.documentElement);
176
- if (document.body) resizeObserver.observe(document.body);
177
- }
178
- })();
179
- <\/script>
180
- </body>
181
- </html>`}const uT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),pU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function hU(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 mU(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 nC(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 dT(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(uT.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 fT(e){return{inputNames:nC(e==null?void 0:e.inputs),outputNames:nC(e==null?void 0:e.outputs)}}function gU(e,t,n){const r=fT(t),s=mU(e),i=[];for(const a of s)if(!dT(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 yU(e,t){const n=fT(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=dT(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 wU(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xU(e){return e.map(t=>{const n=wU(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 bU(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 pU)uT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function kU(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 vU(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),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function jp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:d}=Dr(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[g,k]=m.useState(0),[b,y]=m.useState(0),[v,x]=m.useState(null),C=m.useMemo(()=>fo(c),[c]),N=m.useMemo(()=>gU(e,a,d),[e,a,d]),j=N.length>0,A=m.useMemo(()=>yU(e,a),[e,a]),I=m.useMemo(()=>xU(A),[A]),O=m.useMemo(()=>n?null:hU(e,g),[e,g,n]),H=m.useMemo(()=>{if(!O)return[];const D=bU(a,d);return kU(D,O.query)},[O,a,d]);m.useEffect(()=>{y(D=>{const L=Math.max(0,H.length-1);return Math.min(Math.max(0,D),L)})},[H.length]);const B=m.useCallback(()=>{const D=p.current;if(!D||!O||H.length===0){x(null);return}const L=vU(D,g);if(!L){x(null);return}const T=4,W=44,E=13.5*16,Q=Math.min(H.length*W+8,E);let V=L.bottom+T;V+Q>window.innerHeight-8&&(V=Math.max(8,L.top-Q-T));const F=288;let se=L.left;se=Math.max(8,Math.min(se,window.innerWidth-F-8)),x({top:V,left:se})},[O,H.length,g]);m.useLayoutEffect(()=>{if(!O||H.length===0){x(null);return}const D=requestAnimationFrame(()=>B());return()=>cancelAnimationFrame(D)},[O,H.length,g,e,B]),m.useEffect(()=>{if(!O||H.length===0)return;const D=()=>B();return window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),()=>{window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D)}},[O,H.length,B]);const z=m.useCallback(D=>{if(!O)return;const{atIndex:L}=O,T=e.slice(0,L)+"${"+D+"}"+e.slice(g);t(T);const W=L+D.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(W,W)),k(W)})},[O,e,g,t]),$=m.useCallback(()=>{const D=p.current,L=h.current;!D||!L||(L.scrollTop=D.scrollTop,L.scrollLeft=D.scrollLeft,O&&H.length>0&&queueMicrotask(()=>B()))},[O,H.length,B]),M=m.useCallback(D=>{if(!n&&O&&H.length>0&&(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter")){if(D.key==="ArrowDown")D.preventDefault(),y(L=>(L+1)%H.length);else if(D.key==="ArrowUp")D.preventDefault(),y(L=>(L-1+H.length)%H.length);else if(D.key==="Enter"&&!D.shiftKey){D.preventDefault();const L=H[b];L&&z(L.insert)}}},[n,O,H,b,z]),q=m.useCallback(async D=>{if(n||typeof u!="function")return!1;const L=await aT({files:D,body:e,images:C});return L?(t(L.body),u(L.images),queueMicrotask(()=>{const T=p.current;if(!T)return;T.focus();const W=L.body.length;T.setSelectionRange(W,W),k(W)}),!0):!1},[n,C,t,u,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[C.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:C.map((D,L)=>o.jsxs("span",{className:"af-body-image-chip",title:D.name,children:[o.jsx("img",{src:D.dataUrl,alt:""}),o.jsxs("span",{children:["[",D.label||`image ${L+1}`,"]"]})]},D.id||L))}):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:I+`
182
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":j,"aria-describedby":j?f:void 0,onChange:D=>{t(D.target.value),k(D.target.selectionStart??D.target.value.length)},onSelect:D=>{const L=D.target;L instanceof HTMLTextAreaElement&&k(L.selectionStart??0)},onClick:D=>{const L=D.target;L instanceof HTMLTextAreaElement&&k(L.selectionStart??0)},onKeyUp:D=>{const L=D.target;L instanceof HTMLTextAreaElement&&k(L.selectionStart??L.value.length)},onKeyDown:M,onPaste:D=>{const L=oT(D);L.length!==0&&(D.preventDefault(),q(L).catch(()=>{}))},onDragOver:D=>{ld(D).length>0&&D.preventDefault()},onDrop:D=>{const L=ld(D);L.length!==0&&(D.preventDefault(),q(L).catch(()=>{}))},onScroll:$})]}),O&&H.length>0&&v?or.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":d("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:H.map((D,L)=>o.jsx("li",{role:"option","aria-selected":L===b,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(L===b?" af-composer-mention-item--active":""),onMouseDown:T=>T.preventDefault(),onMouseEnter:()=>y(L),onClick:()=>z(D.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${D.insert}}`}),D.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:D.subtitle}):null]})},`${D.section}-${D.insert}`))}),document.body):null,j?o.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:N.map(D=>D.message).join(" · ")}):null]})}const SU=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function _u(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function rC({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Dr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),u=(f,p,h)=>{const g=n.map((k,b)=>{if(b!==f)return k;const y={...k,[p]:h};return p==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},d=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:d})}),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.description")}),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:`${d}-${p}`,children:[d,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>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=>u(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=>u(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(p,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:p})}),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||u(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=>u(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"})})]},`${d}-${p}`))]}):null]})}function NU({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:d,ioSlots:f}){const{t:p}=Dr(),[h,g]=m.useState(!1),[k,b]=m.useState(!1),[y,v]=m.useState({status:"idle",message:""}),x=m.useCallback($=>{t(M=>M&&{...M,...$})},[t]),{cursorList:C,opencodeList:N,claudeCodeList:j,codexList:A,currentNotInLists:I}=m.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],M=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],q=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],D=Array.isArray(s==null?void 0:s.codex)?s.codex:[],L=new Set([...$,...M,...q,...D].map(_u)),T=((e==null?void 0:e.model)??"").trim(),W=T.startsWith("cursor:")?T.slice(7):T.startsWith("opencode:")?T.slice(9):T.startsWith("codex:")?T.slice(6):T.startsWith("claude-code:")?T.slice(12):T,E=T&&!L.has(W)?T:"";return{cursorList:$,opencodeList:M,claudeCodeList:q,codexList:D,currentNotInLists:E}},[s,e==null?void 0:e.model]);if(!e)return null;const O=String(e.script??""),H=n==="tool_nodejs"||O.trim()!=="",B=typeof c=="function"&&!i&&(e==null?void 0:e.newId),z=async()=>{if(B){v({status:"running",message:p("flow:nodeProps.publishRunning")});try{const $=await c(e,n);v({status:"success",message:$!=null&&$.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):p("flow:nodeProps.publishSuccess")})}catch($){v({status:"error",message:String(($==null?void 0:$.message)||$)})}}};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:z,disabled:!B||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:[d?o.jsx("p",{className:"af-err af-node-props-err",children:d}):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:$=>x({newId:$.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:$=>x({label:$.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:Fd.includes(e.role)?e.role:p("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:i,children:Fd.map($=>o.jsx("option",{value:$,children:$},$))})]}),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 $=(e.model||"").trim();return $?I||$:""})(),onChange:$=>x({model:$.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,C.length>0?o.jsx("optgroup",{label:"Cursor",children:C.map($=>o.jsx("option",{value:_u($),children:$},`c-${$}`))}):null,N.length>0?o.jsx("optgroup",{label:"OpenCode",children:N.map($=>o.jsx("option",{value:`opencode:${_u($)}`,children:$},`o-${$}`))}):null,A.length>0?o.jsx("optgroup",{label:"Codex",children:A.map($=>o.jsx("option",{value:`codex:${_u($)}`,children:$},`codex-${$}`))}):null,j.length>0?o.jsx("optgroup",{label:"Claude Code",children:j.map($=>o.jsx("option",{value:`claude-code:${_u($)}`,children:$},`cc-${$}`))}):null]})]}),o.jsx(rC,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:i,requiredReadonly:!u}),o.jsx(rC,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:i,requiredReadonly:!u}),H?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:()=>b(!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(jp,{value:O,onChange:$=>x({script:$}),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("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:$=>x({scriptRef:$.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:$=>x({implementationRef:$.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),o.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:$=>x({implementationMode:$.target.value}),disabled:i,children:[o.jsx("option",{value:"",children:"auto"}),o.jsx("option",{value:"script",children:"script"}),o.jsx("option",{value:"steps",children:"steps"}),o.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),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(jp,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),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})]})]}),k?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&b(!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:()=>b(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(jp,{value:O,onChange:$=>x({script:$}),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:$=>{$.target===$.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(jp,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function jU({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Dr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const 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(),k=g===n;async function b(y){if(y.preventDefault(),!(!k||d)){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})}),x=await v.json().catch(()=>({}));if(!v.ok){h(typeof x.error=="string"?x.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:b,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=>u(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),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:d,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!k||d,children:i(d?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function CU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:i="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Dr(),u=m.useId(),d=m.useRef(null),[f,p]=m.useState(""),[h,g]=m.useState(!1),[k,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),b(""),g(!1);const C=requestAnimationFrame(()=>{var N;return(N=d.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(C)},[e,n]),!e)return null;const y=f.trim(),v=a||y===n;async function x(C){if(C.preventDefault(),!v||h)return;g(!0),b("");let N=null;try{const j=new AbortController;N=setTimeout(()=>j.abort(),15e3);const A=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:y,flowArchived:s,workspaceId:i}),signal:j.signal}),I=await A.json().catch(()=>({}));if(!A.ok){b(typeof I.error=="string"?I.error:c("project:deleteModal.deleteFailed"));return}try{for(let O=localStorage.length-1;O>=0;O--){const H=localStorage.key(O);H&&(H.startsWith(`af:composer-sessions:${n}:${r}`)||H.startsWith(`af:composer-active-session:${n}:${r}`)||H.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(H)}}catch{}await l()}catch(j){if((j==null?void 0:j.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((j==null?void 0:j.message)||j))}finally{N&&clearTimeout(N),g(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:C=>{C.target===C.currentTarget&&t()},children:o.jsxs("div",{ref:d,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:C=>C.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("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:x,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:C=>p(C.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),k?o.jsx("p",{className:"af-err af-new-pipeline-err",children:k}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!v||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const sC=80,_U=220;function EU(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...c}=e;return c}function AU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Cp(e,t,n){const r={nodes:Array.isArray(e)?e.map(EU):[],edges:Array.isArray(t)?t.map(AU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function Xy(e,t){const n=[...e,t];return n.length>sC?n.slice(n.length-sC):n}function PU({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null),p=m.useRef(null),h=m.useRef(!1),g=m.useCallback(()=>a(N=>N+1),[]),k=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),b=m.useCallback(()=>{k();const N=d.current,j=f.current;return d.current=null,f.current=null,!N||!j||N.signature===j.signature?(j&&(u.current=j),!1):(l.current=Xy(l.current,N),c.current=[],u.current=j,g(),!0)},[g,k]),y=m.useCallback((N=[],j=[],A={})=>{k(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Cp(N,j,A),h.current=!1,g()},[g,k]),v=m.useCallback(N=>{h.current=!0,u.current=N,d.current=null,f.current=null,k(),s==null||s(N.value),g()},[g,k,s]),x=m.useCallback(()=>{b();const N=u.current||Cp(e,t,n),j=l.current.pop();return j?(c.current=Xy(c.current,N),v(j),!0):(g(),!1)},[g,t,n,b,e,v]),C=m.useCallback(()=>{b();const N=u.current||Cp(e,t,n),j=c.current.pop();return j?(l.current=Xy(l.current,N),v(j),!0):(g(),!1)},[g,t,n,b,e,v]);return m.useEffect(()=>()=>k(),[k]),m.useEffect(()=>{if(!r)return;const N=Cp(e,t,n);if(!u.current){u.current=N;return}if(h.current){h.current=!1,u.current=N;return}N.signature!==u.current.signature&&(d.current||(d.current=u.current),f.current=N,k(),p.current=window.setTimeout(()=>{b()},_U))},[k,t,r,n,b,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:y,undo:x,redo:C,version:i}}function ao(e){return String(e??"").trim()}function iC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(ao(e).toLowerCase())}function IU(e){return e===!1?!0:["false","no","not_required","waived"].includes(ao(e).toLowerCase())}function RU(e,t=""){return ao((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||t)}function pT(e){return ao((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function hT(e){return pT(e)==="all"}function TU(e,t=[]){const n=ao((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||(e==null?void 0:e.parent));if(n)return n;const r=pT(e),s=RU(e);if(!s||!["android","ios"].includes(r))return"";const i=`-${r}`;if(!s.endsWith(i))return"";const a=s.slice(0,-i.length);return new Set(t.map(l=>ao(l))).has(a)?a:""}function em(e){const t=ao(e==null?void 0:e.label).toLowerCase(),n=ao((e==null?void 0:e.href)||(e==null?void 0:e.url)).toLowerCase();return/\/merge_requests\/\d+/.test(n)||/\bmr\b|merge request|合并请求|实现 mr|修复 mr|提测 mr|集成 mr/i.test(t)?"mr":/\/issues\/\d+/.test(n)||/gitlab issue/i.test(t)?"issue":"other"}function MU(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[em(n)]-t[em(r)])}function $U(e){const t=ao((e==null?void 0:e.noMrReason)||(e==null?void 0:e.no_mr_reason)||(e==null?void 0:e.mrWaiverReason)||(e==null?void 0:e.mr_waiver_reason)||(e==null?void 0:e.implementationNotRequiredReason)||(e==null?void 0:e.implementation_not_required_reason));return/user confirmed self-test completion without implementation mr evidence/i.test(t)?"自测确认,无需实现 MR":t}function LU(e,t=[]){if(hT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(em);if(n.includes("mr"))return{kind:"linked",label:"MR 已关联",detail:""};const r=(e==null?void 0:e.mrRequired)??(e==null?void 0:e.mr_required)??(e==null?void 0:e.requiresMr)??(e==null?void 0:e.requires_mr);return iC(e==null?void 0:e.implementationNotRequired)||iC(e==null?void 0:e.implementation_not_required)||IU(r)?{kind:"not-required",label:$U(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function Qx(e=[]){return e.reduce((t,n)=>t+1+Qx(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function hr(e){return String(e||"").trim()}function Mo(e){return hr(e).toLowerCase()}function tm(e){return typeof e=="string"?Mo(e):!e||typeof e!="object"||Array.isArray(e)?"":Mo(e.kind||e.type||e.persistence||e.durability)}function OU(e,t="http://localhost"){const n=hr(e);if(!n)return"";try{const r=new URL(n,t);return`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function mT(e={}){const t=hr(e.href||e.url);if(!t)return!1;const n=Mo(e.kind||e.type),r=Mo(e.durability),s=Mo(e.persistence),i=Mo(e.truth||e.stateTruth||e.state_truth),a=Mo(e.authority),l=tm(e.source)||tm(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(hr).join(" "),u=[e.label,e.title,n,s,a,l,t].map(hr).join(" ");if(r==="temporary"||s==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const p=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&p,g=i==="durable_fact"||i==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||g)}function gT(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(hr).join(" ");return/技术方案|tech(?:nical)?[-_ ]?design/i.test(t)?"tech-design":/方案文档|方案已确认|plan(?:[-_ ]?doc)?/i.test(t)?"plan":/代码审查|code[-_ ]?review/i.test(t)?"code-review":/设计文档|design[-_ ]?doc/i.test(t)?"design":"document"}function DU(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=hr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(hr(t)?hr(t):gT(e)==="tech-design"&&hr(n)?hr(n):hr(e.title||e.label))}function FU(e={},t="http://localhost"){const n=hr(e.issueKey||e.issue_key||e.issue),r=gT(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=hr(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${OU(e.href||e.url,t)}`}function oC(e={}){const t=hr(e.href||e.url),n=Mo(e.kind||e.type),r=tm(e.source)||tm(e.sourceArtifact||e.source_artifact),s=hr(e.label);let i=0;return e.confirmed===!0&&(i+=100),r==="ai-doc"&&(i+=80),n==="ai-doc"&&(i+=70),/^https?:\/\//i.test(t)&&(i+=30),/\/api\/prd-workflow\/review\//.test(t)&&(i+=20),/预览|review/i.test(s)||(i+=10),i}function aC(e){const t=hr(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function zU(e=[],t="http://localhost"){const n=new Map;for(const r of Array.isArray(e)?e:[]){if(!mT(r))continue;const s=FU(r,t),i=n.get(s);if(!i){n.set(s,r);continue}const a=oC(r)>oC(i)?r:i,l=a===r?i:r;n.set(s,{...l,...a,title:aC(i.title)>=aC(r.title)?i.title:r.title,issueKey:i.issueKey||r.issueKey,platform:i.platform||r.platform})}return Array.from(n.values())}function qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function nm(e){return Array.isArray(e)?e.map(nm):qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,nm(e[t])])):e}function Zi(e,t){return JSON.stringify(nm(e))===JSON.stringify(nm(t))}function yT(e){return qr(e==null?void 0:e.instances)?e.instances:{}}function Bd(e){return qr(e==null?void 0:e.ui)?e.ui:{}}function _p(e,t){if(!qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function BU(e,t){if(!qr(e)||!qr(t)||!qr(e.instances)||!qr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!qr(e.ui)||!qr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=_p(e,["version","instances","edges","ui"]),r=_p(t,["version","instances","edges","ui"]);if(!Zi(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return Zi(_p(e.ui,s),_p(t.ui,s))}function wT(e){const t=Array.isArray(Bd(e).groups)?Bd(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function lC(e){const t=new Set(Object.keys(yT(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of wT(e).keys())t.add(n);return t}function cC(e,t){const n=yT(e),r=Bd(e),s=wT(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:qr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:qr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function uC(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(i=>String(i??"")).join("\0"),s=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(i=>String(i??"")).join("\0");return r.localeCompare(s)})}function HU(e,t){if(!BU(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...lC(e),...lC(t)]),r=Array.from(n).filter(s=>!Zi(cC(e,s),cC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!Zi(uC(e),uC(t)),displayPageChanged:!Zi(Bd(e).displayPage||null,Bd(t).displayPage||null)}}function WU(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(i=>[i.id,i])),s=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(i=>{const a=r.get(i.id);return a&&!s.has(i.id)?a:a?{...i,selected:a.selected===!0}:i})}function dC(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function fC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function VU(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[dC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(dC(r));return s?Zi(fC(s),fC(r))?s:{...r,selected:s.selected===!0}:r})}function KU(e,t,n){const r=qr(e)?e:{},s=qr(t)?t:{},i=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(s).map(([a,l])=>[a,!i.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function qU({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:s=0,currentEditVersion:i=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||i!==s||l!==a)?"local-edits":""}function UU({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function YU(e=[]){let t=!1,n=!1,r=!1;for(const s of Array.isArray(e)?e:[]){if((s==null?void 0:s.type)==="position"&&s.position){r=!0,s.dragging===!0&&(t=!0),s.dragging===!1&&(n=!0);continue}if((s==null?void 0:s.type)==="dimensions"&&s.dimensions){r=!0,s.resizing===!0&&(t=!0),s.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(s==null?void 0:s.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function GU(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function JU(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function ah(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const s=String((r==null?void 0:r.id)||"").trim();if(!(s&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${s}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function XU(e=[]){return ah(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function pC(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function QU({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function ZU({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const eY="af:workspace-graph:v2",hC="agentflow.workspace.sidebarCollapsed",Ll=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],tY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),nY={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},rY={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},sY={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},iY={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},oY={id:"control_cd_workspace",displayName:"加载知识库",label:"加载知识库",description:"Select one or more knowledge sources and pass knowledgeContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"knowledgeContext",default:"",showOnNode:!0},{type:"text",name:"workspaceContext",default:"",showOnNode:!1},{type:"file",name:"cwd",default:"",showOnNode:!1}]},aY={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},lY=new Set(["png","jpg","jpeg","gif","webp","svg"]),xT=320,bT=180,kT=960,rm=96,vT=900,Zx=520,eb=320,Ep=52,Xa=240,Qa=160,tb="display-ref:",Hd="0 9 * * *",cY="Asia/Shanghai",uY="0.1.108";function dY(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Tr(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.archived&&t.set("archived","1"),t}function nv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
183
- ...[truncated ${n.length-t} chars]`:n:""}function fY(e){const t=nv(e==null?void 0:e.text,4e3);return t?{role:(e==null?void 0:e.role)==="user"?"user":"assistant",...e!=null&&e.kind?{kind:String(e.kind)}:{},text:t,...e!=null&&e.error?{error:!0}:{},at:Number.isFinite(Number(e==null?void 0:e.at))?Number(e.at):Date.now()}:null}function rv(e,t=80){return(Array.isArray(e)?e:[]).map(fY).filter(Boolean).slice(-t)}function pY(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,s]of Object.entries(t).slice(-80)){const i=String(r||"").trim();if(!i||!s||typeof s!="object")continue;const a=rv(s.messages,40),l=nv(s.draft||"",2e3);!a.length&&!l||(n[i]={sessionId:String(s.sessionId||`nodechat_${i}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function hY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=rv(t==null?void 0:t.messages,80);if(!r.length)return null;const s=String((t==null?void 0:t.status)||"done");return{id:n,label:nv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function mC(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=t.composer&&typeof t.composer=="object"&&!Array.isArray(t.composer)?t.composer:{};return{composer:{activeSessionId:String(n.activeSessionId||"workspace").trim()||"workspace",messages:rv(n.messages,100),runSessions:hY(n.runSessions)},nodeChats:pY(t.nodeChats)}}function sm(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return lY.has(n)}function Wd(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=Tr(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function mY(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 gY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${hC}:${t}`:hC}function yY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function gC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function wY(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function xY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!wY(e)}function bY(e){const t=String(e||"").trim();if(!t||kY(t))return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function kY(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function vY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function Qy(e,t,n,r="Workspace Run"){var c;const s=String(n||"").trim(),i=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===s):null,a=t&&typeof t=="object"?t[s]:null;return String(((c=i==null?void 0:i.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||s||r}function Zy(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function _a(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function yC(e){const t=String(e||"").trim().toLowerCase();return{unselected:"未选择需求",unavailable:"未连接",json_unsupported:"待升级",command_failed:"读取失败",uninitialized:"未初始化",preflight_blocked:"环境阻塞",tech_design_missing:"缺技术方案",tech_design_draft_review:"方案待确认",tech_design_confirmed:"方案已确认",baseline_missing:"缺基线",plan_missing:"缺计划",plan_draft_review:"计划待确认",issue_binding_missing:"待绑定 Issue",ready_for_implementation:"待实现",implementation_ready:"待实现",implementing:"实现中",implementation_in_progress:"实现中",implementation_review:"实现待审",self_test_ready:"待自测",bugfix:"修 Bug",fix_ready:"待修复",fix_in_progress:"修复中",testing:"已提测",done:"完成",blocked:"阻塞",conflict:"冲突",requirement_changed:"需求变更"}[t]||t||"未知"}function SY(e){const t=String(e||"").trim().toLowerCase();return!t||["unselected","unavailable","json_unsupported","command_failed","uninitialized","preflight_blocked"].includes(t)?-1:/done|complete|closed|finished/.test(t)?3:/bug|fix|testing|test|self_test|submit_test/.test(t)?2:/implement|development|ready_for_implementation|issue_binding|gitlab|mr/.test(t)?1:0}function NY(e){const t=SY(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let s="pending";return t>r?s="done":t===r&&(s=r===3?"done":"current"),{label:n,status:s}})}function ST(e){const t=String(e||"").trim();if(!/^https?:\/\//i.test(t))return t;try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const s=window.location.hostname;n.hostname=s&&s!=="0.0.0.0"&&s!=="::"?s:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function pc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return ST(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function la(e){const t=String(e||"").trim().toLowerCase();return["done","success","completed","passed"].includes(t)?"done":["current","running","active","next"].includes(t)?"current":["observed","observation"].includes(t)?"observed":["superseded","stale","replaced"].includes(t)?"superseded":["blocked","failed","error","conflict"].includes(t)?"blocked":"pending"}function Qo(e){if(!e||typeof e!="object")return"";const t=String(e.truth||e.stateTruth||e.state_truth||"").trim().toLowerCase();return t||(String(e.idempotencyKey||e.idempotency_key||"").trim().startsWith("snapshot-action:")||String(e.source||"")==="prd-flow-client"&&String(e.type||"")==="workflow-action"?"observation":String(e.type||"")==="review-link"?"runtime_event":"")}function sv(e){return la(e==null?void 0:e.status)==="done"&&Qo(e)!=="observation"}function eo(e,t){return!e||typeof e!="object"?`Action ${t+1}`:String(e.title||e.label||e.name||e.actionLabel||e.action_label||e.id||e.action||`Action ${t+1}`)}function lh(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function iv(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function jY(e,t="当前任务"){const r=[e==null?void 0:e.issueLabel,e==null?void 0:e.issue_label,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.name].map(s=>String(s||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function CY(e,t){const n=eo(e,t),r=la(e==null?void 0:e.status),s=sv(e),a=`${Za(e)} ${iv(e)}`,l=jY(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)){if(s)return`${l} 方案已确认`;if(r==="observed"||r==="superseded"||Qo(e)==="observation")return`${l} 方案状态已观察`;if(r==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)){if(s)return`已为 ${l} 创建/绑定 GitLab Issue`;if(r==="observed"||r==="superseded"||Qo(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function _Y(e){if(!e||typeof e!="object")return"";const t=la(e.status),n=Qo(e),r=sv(e),i=`${Za(e)} ${iv(e)}`,a=ov(e),l=a.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),c=a.some(f=>/gitlab issue/i.test(String(f.label||""))),u=a.some(f=>/gitlab epic/i.test(String(f.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(i))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(i))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(i))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(i))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const d=lh(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function im(e){return!e||typeof e!="object"?"":String(e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const NT="Asia/Shanghai",EY=new Intl.DateTimeFormat("zh-CN",{timeZone:NT,year:"numeric",month:"2-digit",day:"2-digit"}),AY=new Intl.DateTimeFormat("zh-CN",{timeZone:NT,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function jT(e){const t=im(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function PY(e){const t=jT(e);return t?EY.format(t).replace(/\//g,"-"):"无时间"}function IY(e){const t=jT(e);return t?AY.format(t):""}function RY(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=PY(n);let i=t[t.length-1];(!i||i.day!==s)&&(i={day:s,items:[]},t.push(i)),i.items.push({item:n,index:r})}),t}function CT(e){const t=la(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Ra(e){const t=String(e||"").trim(),n=t.toLowerCase();return n==="android"?"Android":n==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(n)?"双端":t}function TY(e){const t=la(e==null?void 0:e.status);return Qo(e)==="observation"&&t==="done"?"已观察":CT(t)}function _T(e){if(!e||typeof e!="object")return[];const t=[],n=(i,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${i}:${c}`,type:i,label:String(a||c),value:c})},r=la(e.status),s=Qo(e)==="observation"&&r==="done"?"observed":r;return n("status",CT(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Ra(e.platform),e.platform),t}function MY(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{_T(n).forEach(r=>{const s=t.get(r.key);t.set(r.key,{...r,count:((s==null?void 0:s.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const s={status:0,issue:1,platform:2,source:3,actor:4};return(s[n.type]??9)-(s[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function $Y(e,t){const n=String(t||"all");return!n||n==="all"?!0:_T(e).some(r=>r.key===n)}function LY(e){if(!e||typeof e!="object")return[];const t=[],n=(r,s)=>{const i=String(s||"").trim();i&&t.push({label:r,value:i})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",Ra(e.platform)),t}function ov(e){const t=[],n=(c,u)=>{const d=ST(u);d&&t.push({label:String(c||d).trim()||d,href:d})},r=(c,u="链接",d=0)=>{if(d>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((p,h)=>r(p,`${u} ${h+1}`,d+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path);for(const p of["links","urls","artifacts","outputs","output","results","result","files"])c[p]!=null&&r(c[p],p,d+1)},s=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of s)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href));for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",pc(c));n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const i=c=>{const u=String(c||"").trim();try{const d=new URL(u,window.location.origin);return`${d.origin}${d.pathname}`}catch{return u.split(/[?#]/)[0]}},a=c=>{const u=String(c||"");return/方案文档/.test(u)?50:/临时/.test(u)?40:/Markdown Review/i.test(u)?20:/预览|review/i.test(u)?10:0},l=new Map;for(const c of t){const u=/\/api\/prd-workflow\/review\//.test(String(c.href||"")),d=u?`review:${i(c.href)}`:`${c.label}
184
- ${c.href}`,f=l.get(d);if(!f){l.set(d,c);continue}if(u){const p=a(f.label),h=a(c.label);(h>p||h===p&&String(c.label||"").length>String(f.label||"").length)&&l.set(d,c)}}return Array.from(l.values())}function OY(e,t=[]){var a,l,c,u;const n=[],r=new Map,s=String(((l=(a=e==null?void 0:e.overall)==null?void 0:a.requirement)==null?void 0:l.title)||((u=(c=e==null?void 0:e.overall)==null?void 0:c.requirement)==null?void 0:u.name)||"").trim();for(const d of nb(e)){const f=Ci(d),p=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();f&&p&&r.set(f,p)}const i=(d,f={})=>{if(!d||typeof d!="object")return;const p=(g,k={})=>{if(!g||typeof g!="object")return;const b=String(f.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),y=g.source||g.sourceArtifact||g.source_artifact||d.sourceArtifact||d.source_artifact||d.source||f.source||null,v=DU({...g,title:g.title||f.documentTitle||(d==null?void 0:d.title)||"",documentTitle:g.documentTitle||g.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(b)||"",requirementTitle:s}),x={label:String(g.label||"ai-doc").trim()||"ai-doc",href:String(g.href||g.url||"").trim(),kind:String(g.kind||g.type||d.kind||d.type||"").trim(),title:v,issueKey:b,platform:f.platform||Ra(d.platform),durability:g.durability||d.durability||f.durability||"",persistence:g.persistence||d.persistence||f.persistence||"",truth:g.truth||g.stateTruth||g.state_truth||Qo(d)||f.truth||"",authority:g.authority||d.authority||f.authority||"",confirmed:g.confirmed??d.confirmed??f.confirmed,source:y,documentPath:g.documentPath||g.document_path||g.path||k.documentPath||(y==null?void 0:y.path)||(y==null?void 0:y.documentPath)||(y==null?void 0:y.document_path)||""};x.href&&n.push(x)};for(const g of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!g||typeof g!="object"||p({...g,label:g.label||g.title||g.kind||"ai-doc",href:pc(g)},{documentPath:g.path});for(const g of Array.isArray(d==null?void 0:d.links)?d.links:[])!g||typeof g!="object"||p({...g,label:g.label||g.title||g.kind||"ai-doc",href:pc(g)},{documentPath:g.path});const h=pc(d);h&&p({...d,label:d.label||d.title||d.kind||"ai-doc",href:h},{documentPath:d.path})};i(e);for(const d of Array.isArray(t)?t:[])i(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:Ra(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const f of Array.isArray(e==null?void 0:e[d])?e[d]:[])i(f,{issueKey:String((f==null?void 0:f.issueKey)||(f==null?void 0:f.issue_key)||(f==null?void 0:f.issue)||"").trim(),platform:Ra(f==null?void 0:f.platform),documentTitle:String((f==null?void 0:f.documentTitle)||(f==null?void 0:f.document_title)||(f==null?void 0:f.title)||"").trim()});for(const d of nb(e))i(d,{issueKey:Ci(d),platform:Ra(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});return zU(n,window.location.origin)}function DY(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function Ci(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function FY(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||Ci(e,t)||`Issue ${t+1}`).trim()}function zY(e){return String((e==null?void 0:e.epicKey)||(e==null?void 0:e.epic_key)||(e==null?void 0:e.epic)||(e==null?void 0:e.epicTitle)||(e==null?void 0:e.epic_title)||(e==null?void 0:e.parentEpic)||(e==null?void 0:e.parent_epic)||"未归类").trim()}function BY(e){return String((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parent)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||"").trim()}function HY(e){const t=ov(e),n=(s,i)=>{if(Array.isArray(s)){for(const a of s)if(a)if(typeof a=="string")t.push({label:i,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||i,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(s=>{const i=String(s.href||"").trim();if(!i)return!1;const a=`${s.label}
185
- ${i}`;return r.has(a)?!1:(r.add(a),!0)})}function WY(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,s=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=s(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const d of u)d&&typeof d=="object"&&c.issues.push({...d,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)s(zY(a)).issues.push(a);const i=a=>{const l=new Map,c=[],u=a.map((d,f)=>Ci(d,f));return a.forEach((d,f)=>{const p=Ci(d,f);l.set(p,{issue:d,children:[]})}),a.forEach((d,f)=>{const p=Ci(d,f),h=BY(d)||TU(d,u),g=l.get(p);h&&l.has(h)?l.get(h).children.push(g):c.push(g)}),c};return Array.from(r.values()).map(a=>({...a,issues:i(a.issues)}))}function Vd(e){return String((e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.action)||(e==null?void 0:e.id)||"").trim()}function Za(e){if(!e||typeof e!="object")return"";const t=String(e.issueKey||e.issue_key||e.issue||"").trim(),n=String(e.action||e.actionId||e.action_id||Vd(e)||"").trim(),r=String(e.stageKey||e.stage_key||e.stage||e.phase||e.code||e.pointer||n).trim(),s=[r,n,e.code,e.type,e.title].map(i=>String(i||"")).join(" ").toLowerCase();if(t){if(/plan_draft_local|submit-plan|plan-doc/.test(s))return`issue-plan:${t}`;if(/gitlab_issue_missing|ensure-gitlab-issue/.test(s))return`issue-gitlab:${t}`}return r}function om(e){const t=im(e)||String((e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)||""),n=Date.parse(t);return Number.isFinite(n)?n:NaN}function nb(e){var s,i,a,l,c,u,d,f,p,h,g,k;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const y=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const v of y)!v||typeof v!="object"||Array.isArray(v)||(v.issue&&typeof v.issue=="object"?(n(v.issue),Array.isArray(v.children)&&v.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(v))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(i=e==null?void 0:e.raw)==null?void 0:i.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:f.epics,(h=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:h.epicGroups,(k=(g=e==null?void 0:e.raw)==null?void 0:g.prd)==null?void 0:k.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function VY(e,t){const n=String(t||"").trim();return n&&nb(e).find((r,s)=>Ci(r,s)===n)||null}function KY(e){var t,n,r,s,i,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((s=e==null?void 0:e.raw)==null?void 0:s.gitlab_epic)||((a=(i=e==null?void 0:e.raw)==null?void 0:i.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function qY(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=VY(e,n),s=String(t.platform||(r==null?void 0:r.platform)||"").trim(),i=s&&!t.platform?{...t,platform:s}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||i.gitlabIssue||i.gitlab_issue||"").trim(),l=KY(e);if(!a&&!l)return i;const c=Za(i),u=`${c} ${iv(i)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return i;const f=[];a&&f.push({label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const p=la(i.status),h=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(i.title||i.label||""));return{...i,...a?{gitlabIssue:a,gitlab_issue:a}:{},...l?{gitlabEpic:l,gitlab_epic:l}:{},...h?{title:String(i.title||i.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(i.label||i.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:ki(i.artifacts,f)}}function ki(e,t){const n=[],r=new Set,s=i=>{if(!i)return;const a=typeof i=="string"?i:JSON.stringify(i);r.has(a)||(r.add(a),n.push(i))};return(Array.isArray(e)?e:[]).forEach(s),(Array.isArray(t)?t:[]).forEach(s),n}function wC(e,t){const n=om(t),r=om(e),s=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,i=(s==null?void 0:s.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:eo(s,0)||eo(t,0)||eo(e,0),detail:lh(s)||lh(t)||lh(e),status:i,links:ki(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:ki(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:ki(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:ki(e==null?void 0:e.results,t==null?void 0:t.results),events:ki(e==null?void 0:e.events,t==null?void 0:t.events),createdAt:(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(t==null?void 0:t.createdAt)||(t==null?void 0:t.created_at),startedAt:(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(t==null?void 0:t.startedAt)||(t==null?void 0:t.started_at),updatedAt:(s==null?void 0:s.updatedAt)||(s==null?void 0:s.updated_at)||(t==null?void 0:t.updatedAt)||(t==null?void 0:t.updated_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)}}function UY(e,t){const n=[],r=new Map,s=new Map,i=new Map,a=f=>{var p,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((p=f.conflict)==null?void 0:p.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,p)=>({...f,links:ki(f==null?void 0:f.links,p==null?void 0:p.links),artifacts:ki(f==null?void 0:f.artifacts,p==null?void 0:p.artifacts),outputs:ki(f==null?void 0:f.outputs,p==null?void 0:p.outputs),results:ki(f==null?void 0:f.results,p==null?void 0:p.results)}),c=(f,p)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],p);return}i.set(f,l(i.get(f)||{},p))},u=(f,p)=>f&&i.has(f)?l(p,i.get(f)):p,d=f=>{if(Array.isArray(f))for(const p of f){const h=Za(p);if(a(p)){c(h,p);continue}const g=String(p.id||p.eventId||p.event_id||p.actionId||p.action_id||"").trim(),k=h||g,b=k?r.get(k)??s.get(g):null;k&&b!=null?(n[b]=u(h,wC(n[b],p)),h&&r.set(h,b),g&&s.set(g,b)):(k&&r.set(k,n.length),g&&s.set(g,n.length),n.push(u(h,p)))}};if(d(e==null?void 0:e.actions),d(e==null?void 0:e.workflowActions),d(e==null?void 0:e.workflow_actions),d(e==null?void 0:e.timeline),d(e==null?void 0:e.history),d(e==null?void 0:e.events),d(e==null?void 0:e.runtimeEvents),d(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=Vd(t),p=Za(t),h=p?r.get(p):f?s.get(f):null,g={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=wC(n[h],g))}return n.map((f,p)=>({item:f,index:p,ts:om(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>qY(e,f.item))}function YY(e){return(Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[]).filter(n=>n&&typeof n=="object").map((n,r)=>({item:n,index:r,ts:om(n)})).sort((n,r)=>{const s=Number.isFinite(n.ts),i=Number.isFinite(r.ts);return s&&i?r.ts-n.ts||r.index-n.index:s?-1:i?1:r.index-n.index}).slice(0,8).map(n=>n.item)}function GY(e,t){const n=String(t||"all");if(n==="all")return!0;const r=[e==null?void 0:e.status,e==null?void 0:e.type,e==null?void 0:e.kind,e==null?void 0:e.title,e==null?void 0:e.detail,e==null?void 0:e.error,JSON.stringify((e==null?void 0:e.links)||[]),JSON.stringify((e==null?void 0:e.artifacts)||[])].join(" ").toLowerCase();return n==="errors"?/error|failed|conflict|blocked|stale|revision|冲突|失败/.test(r):n==="review"?/review|temporary-review|临时/.test(r):n==="external"?/mr|merge request|gitlab|jenkins|package|build|tapd/.test(r):!0}function JY(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,i=Number.isFinite(r)&&Number.isFinite(s)?`(+${_a(r)} / 总 ${_a(s)})`:"";return`${t+1}. ${n}${i}`}function ET(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Ol(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function XY(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function QY(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function ZY(e,t){var s;const n=String(((s=t==null?void 0:t.args)==null?void 0:s.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function eG(e){var i,a,l;const t=ET(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Ol(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=QY(t),u=XY(t),d=Ol(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Ol(t.completedAtMs,c==null?void 0:c.completedAtMs),p=((i=c==null?void 0:c.result)==null?void 0:i.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(d)&&Number.isFinite(f)?Math.max(0,f-d):Ol(p.executionTime,p.localExecutionTimeMs),g=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||p.command||"").trim(),k=g?g.split(`
186
- `).find(Boolean)||g:"";return{kind:"tool",label:ZY(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:k?k.slice(0,90):""}}if(n==="result"){const c=Ol(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:s,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:s,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:s,detail:""}:null}function xC(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(b=>typeof b=="string"?{text:b}:b).filter(b=>b&&String(b.text||"").trim()),i=Array.isArray(t)?t:[],a=[...i].reverse().find(b=>(b==null?void 0:b.kind)==="total"&&Number.isFinite(Number(b.durationMs))),l=[...s].reverse().find(b=>Number.isFinite(Number(b.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=Ol(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),d=s.filter(b=>b.kind==="model").reduce((b,y)=>b+(Number(y.stepMs)||0),0),f=i.filter(b=>(b==null?void 0:b.kind)==="tool"),p=f.reduce((b,y)=>b+(Number(y.durationMs)||0),0),h=i.filter(b=>(b==null?void 0:b.kind)==="network").length,g=[...s.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,y)=>y.durationMs-b.durationMs).slice(0,6),k=["耗时概览"];return Number.isFinite(u)&&k.push(`- 当前总耗时:${_a(u)}`),d>0&&k.push(`- 模型相关间隔:约 ${_a(d)}(按 Activity 间隔估算)`),f.length>0&&k.push(`- 工具实际执行:${_a(p)}(${f.length} 次完成事件)`),h>0&&k.push(`- 网络/会话恢复事件:${h} 次`),g.length>0&&(k.push(""),k.push("慢步骤"),g.forEach((b,y)=>{const v=b.detail?` · ${b.detail}`:"";k.push(`${y+1}. ${b.label}:${_a(b.durationMs)}${v}`)})),s.length>0&&(k.push(""),k.push("最近 Activity"),s.slice(-10).forEach((b,y)=>{k.push(JY(b,y))})),f.length>0&&(k.push(""),k.push("最近工具完成"),f.slice(-8).forEach((b,y)=>{const v=Number.isFinite(Number(b.durationMs))?` ${_a(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";k.push(`${y+1}. ${b.label}${v}${x}`)})),k.join(`
187
- `)}function bC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=ET(e);if((t==null?void 0:t.type)!=="thinking")return"";const n=String((t==null?void 0:t.subtype)||"");return n&&n!=="delta"?"":String((t==null?void 0:t.text)||(t==null?void 0:t.delta)||(t==null?void 0:t.thinking)||"").trim()}function AT(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 PT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function av(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function IT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function tG(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function nG(e){const t=String(e??"").trim();return t?t.includes("${")?t:IT(t):""}function RT(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const s=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),i=s?`${s}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(nG).filter(Boolean):[];return[tG(t,n),IT(i),...a].join(" ")}return String(t.command||"").trim()}function zu(e){const t=String(av(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function kC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function am(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Bu(e){return am(e)}function rb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Ap(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 vC(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 SC(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 ew(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=Gx(s.get(n),e.sourceHandle||"output-0","source"),a=Gx(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&zd(i,a))}function rG(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=Gx(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:Aq(a)}:null}function sG(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"?zd(t.slot,a):zd(a,t.slot)))continue;const c=zu(n);return{def:n,order:r,category:c,categoryRank:Ll.indexOf(c),slot:a,slotIndex:i,displayLabel:Bu(n),description:rb(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 iG(e,t,n){var i,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const d=Array.isArray(s?(i=u.data)==null?void 0:i.inputs:(a=u.data)==null?void 0:a.outputs)?s?u.data.inputs:u.data.outputs:[];for(let f=0;f<d.length;f+=1){const p=d[f];if((p==null?void 0:p.showOnNode)===!1||!(s?zd(n.slot,p):zd(p,n.slot)))continue;const g=s?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${f}`}:{source:u.id,sourceHandle:`output-${f}`,target:n.nodeId,targetHandle:n.handleId},k=(t||[]).some(b=>b.target===g.target&&b.targetHandle===g.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:p,slotIndex:f,handleId:s?g.targetHandle:g.sourceHandle,connection:g,occupied:k})}}return r.sort((u,d)=>{var k,b,y,v,x,C,N,j;const f=Number(((b=(k=u.node)==null?void 0:k.position)==null?void 0:b.y)||0),p=Number(((v=(y=d.node)==null?void 0:y.position)==null?void 0:v.y)||0),h=Number(((C=(x=u.node)==null?void 0:x.position)==null?void 0:C.x)||0),g=Number(((j=(N=d.node)==null?void 0:N.position)==null?void 0:j.x)||0);return f-p||h-g||u.slotIndex-d.slotIndex||String(u.nodeId).localeCompare(String(d.nodeId))})}function ec(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function oG(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 aG(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function lG(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return Hd;const n=Math.max(1,Math.min(1440,Math.round(t)));return n<60?`*/${n} * * * *`:n===60?"0 * * * *":n<1440&&n%60===0?`0 */${n/60} * * *`:Hd}function Oo(e,t=0,n=0,r=59){const s=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(s).padStart(2,"0")}function lv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Oo(t[1],9,0,23)}:${Oo(t[2],0,0,59)}`:"09:00"}function Hu(e,t,n,r,s){const i=lv(t),[a,l]=i.split(":").map(u=>Number.parseInt(u,10)),c=String(e||"daily");if(c==="weekly"){const u=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${u}`}if(c==="monthly"){const u=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${u} * *`}return c==="custom"?String(s||"").trim()||Hd:`${l} ${a} * * *`}function cG(e){const n=String(e||Hd).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,s,i,a,l]=n,c=Number.parseInt(r,10),u=Number.parseInt(s,10),d=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&s===String(u),f=d?`${Oo(u,9,0,23)}:${Oo(c,0,0,59)}`:"09:00";return d&&i==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:d&&i==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:d&&/^\d+$/.test(i)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:f,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(i,10)))}:{scheduleType:"custom",time:f,weekday:1,monthDay:1}}function cv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=lG(r),i=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=cG(i),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=lv(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),d=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=Hu(l,c,u,d,i);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:d,cron:f,timezone:cY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function uG(e){const t=cv(JSON.stringify(e||{}));return JSON.stringify(t)}function dG(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function fG(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function NC(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function Pp(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:NC(n.nextRunAt),lastAt:NC(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function lm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function cm(e){return e>0?`Group ${e+1}`:"Group"}function pG(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const s=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),i=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!s||!Number.isFinite(i)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:s,title:String((n==null?void 0:n.title)||cm(r)).trim()||cm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:i,y:a,width:Math.max(Xa,Math.round(l)),height:Math.max(Qa,Math.round(c))}}).filter(Boolean)}function hG(e){var n;return pG((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:fc,position:{x:r.x,y:r.y},width:r.width,height:r.height,selected:!1,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:r.title,title:r.title,color:r.color,nodeSize:{width:r.width,height:r.height}}}))}function sb(e){const t=Number(e==null?void 0:e.width),n=Number(e==null?void 0:e.height);return!Number.isFinite(t)||!Number.isFinite(n)?null:{width:Math.max(Xa,Math.round(t)),height:Math.max(Qa,Math.round(n))}}function Wu(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:aG(t),required:!!(t!=null&&t.required),description:String((t==null?void 0:t.description)||""),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function TT(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function mG(e){var i,a,l,c;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{},s=rg(t);return[TT(e),An(t)||"",s?"has-result":"",(t==null?void 0:t.contextRunResultNonce)||"",Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.width)||0)||"",Number(((a=e==null?void 0:e.measured)==null?void 0:a.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(c=(l=t==null?void 0:t.runningRunNodeIds)==null?void 0:l.has)!=null&&c.call(l,e==null?void 0:e.id)?"running-run":""].join("::")}function jC(e,t){return!e||!t?!1:e.selected===t.selected&&e.isExecuting===t.isExecuting&&e.nodeStatus===t.nodeStatus&&e.nodeElapsed===t.nodeElapsed&&e.optimizingRun===t.optimizingRun&&e.scheduledRunState===t.scheduledRunState&&e.nodeChatActive===t.nodeChatActive&&e.nodeChat===t.nodeChat}const gG=new Map,yG=[];function Eu(e,t){var h,g;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=LT(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(h=e==null?void 0:e.ui)!=null&&h.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(g=e==null?void 0:e.ui)!=null&&g.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const k of s)k!=null&&k.source&&l.add(String(k.source)),k!=null&&k.target&&l.add(String(k.target));const u=Array.from(l).map(k=>{const b=r[k]||{},y=b.definitionId||k,v=t.find(z=>z.id===y),x=av(v)||y,C=t.find(z=>z.id===x)||v,N=b.marketplaceRef||PT(v),j=RT(v),A=i[k]&&typeof i[k].x=="number"&&typeof i[k].y=="number"?i[k]:{x:320+l.size*20,y:180+l.size*12},I=!!An({definitionId:x,inputs:b.input,outputs:b.output}),O=a[k]&&typeof a[k].width=="number"&&typeof a[k].height=="number"?{width:a[k].width,height:a[k].height}:null,H=Fa(O,{display:I}),B=H&&!ei(x);return{id:k,type:fc,position:A,...B?{width:H.width,height:H.height}:{},data:{label:b.label||am(v)||am(C)||k,definitionId:x,...N?{marketplaceRef:N}:{},...v!=null&&v.packageId?{marketplacePackageId:v.packageId}:{},...v!=null&&v.version?{marketplaceVersion:v.version}:{},schemaType:AT(x,C||v),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||j||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...B?{nodeSize:H}:{},...I&&B?{displaySize:H}:{}}}}).map(k=>Xx(k,r,t)),d=hG(e),f=s.filter(k=>(k==null?void 0:k.source)&&(k==null?void 0:k.target)).filter(k=>!d.some(b=>b.id===String(k.source)||b.id===String(k.target))).map((k,b)=>({id:k.id||`we-${k.source}-${k.target}-${b}`,source:String(k.source),target:String(k.target),sourceHandle:k.sourceHandle??void 0,targetHandle:k.targetHandle??void 0,markerEnd:{type:xi.ArrowClosed}})),p=[...d,...u];return{nodes:p,edges:tU(f,p),instances:r}}function CC(e){return`${tb}${e}`}function Ip(e){const t=String(e||"");return t.startsWith(tb)?t.slice(tb.length):t}function ib(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function ch(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var p;return el((p=f==null?void 0:f.data)==null?void 0:p.definitionId)}).map(f=>[f.id,f])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const f of r){const p=String(f||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((f,p)=>{const h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+p*36,y:120+p*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(f=>{const p=Fa(u[f],{display:!0});p&&(c[f]=p)});const d=ib(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...d?{viewport:d}:{}}}function _C(e,t=[]){return ch(e,t)}const tw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function nw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function EC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function AC(e={}){if(e.permanent)return{expiresMode:"permanent",permanent:!0};const t=Number(e.expiresInDays||30);return{expiresMode:"days",expiresInDays:Number.isFinite(t)?t:30}}function wG(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function PC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const MT="af:workspace:canvas-clipboard",$T="agentflow.workspace.canvas-clipboard";function xG(e){return JSON.stringify({type:$T,version:1,clipboard:e})}function bG(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==$T)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function kG(e){try{localStorage.setItem(MT,xG(e))}catch{}}function vG(){try{return bG(localStorage.getItem(MT))}catch{return null}}function SG(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function ob(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function IC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Fa(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:IC(n,bT,kT)||xT,height:IC(r,rm,vT)||rm}}function um(e){const t=Fa(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function NG(e){const t=String(e||"").trim().toLowerCase();return t==="html"||t==="react"?{width:720,height:520}:t==="table"||t==="chart"?{width:640,height:380}:t==="image"?{width:520,height:360}:{width:Zx,height:eb}}function jG(e,t=""){const n=um(e==null?void 0:e.displaySize);if(n)return n;const r=um(e==null?void 0:e.nodeSize);if(r)return r;const s=el(t)||ff(ea((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return NG(s)}function Dl(e){var s,i,a,l,c,u,d,f,p,h,g;if(ei((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!An(e==null?void 0:e.data),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((f=(d=e==null?void 0:e.data)==null?void 0:d.displaySize)==null?void 0:f.height)||((h=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return Fa({width:n,height:r},{display:t})}function Tl(e,t,n){var d,f,p,h,g,k,b,y,v,x,C,N,j;const r=(e||[]).filter(A=>!lm(A)),s=(e||[]).filter(lm),i=LT(ev(r,n||{})),a=t.map(A=>({source:A.source,target:A.target,sourceHandle:A.sourceHandle??null,targetHandle:A.targetHandle??null})).filter(A=>!s.some(I=>I.id===A.source||I.id===A.target)),l={},c={},u=[];for(const A of r){l[A.id]={x:((d=A.position)==null?void 0:d.x)||0,y:((f=A.position)==null?void 0:f.y)||0};const I=Dl(A);I&&(c[A.id]=I)}for(const A of s){const I=Number(((h=(p=A.data)==null?void 0:p.nodeSize)==null?void 0:h.width)||A.width||((g=A.measured)==null?void 0:g.width)||0),O=Number(((b=(k=A.data)==null?void 0:k.nodeSize)==null?void 0:b.height)||A.height||((y=A.measured)==null?void 0:y.height)||0);u.push({id:A.id,title:String(((v=A.data)==null?void 0:v.title)||((x=A.data)==null?void 0:x.label)||"Group"),color:String(((C=A.data)==null?void 0:C.color)||"purple"),x:Number(((N=A.position)==null?void 0:N.x)||0),y:Number(((j=A.position)==null?void 0:j.y)||0),width:Math.max(Xa,Math.round(I||Xa)),height:Math.max(Qa,Math.round(O||Qa))})}return{version:1,instances:i,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function LT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!el(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function el(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_react_app"?"react":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function An(e){const t=el(e==null?void 0:e.definitionId);return t||(ei(e==null?void 0:e.definitionId)&&rg(e)?ff(ea((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function to(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=An(e),r=ei(e==null?void 0:e.definitionId),s=n==="image"?"src":"content",i=u=>String((u==null?void 0:u.value)??(u==null?void 0:u.default)??""),a=u=>i(u).trim(),l=t.find(u=>(u==null?void 0:u.name)===s&&a(u))||t.find(u=>(u==null?void 0:u.name)==="filePath"&&a(u))||t.find(u=>(u==null?void 0:u.type)==="text"&&a(u)),c=l?i(l):"";return String(r?c:(e==null?void 0:e.body)||c)}function Zo(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),react:new Set(["json","jsx","tsx","js","txt"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function CG(e){let t=String(e||"").replace(/\r\n/g,`
188
- `).trim();return t.includes(`
189
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
190
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
191
- $2`)),t}function _i(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=CG(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
192
- `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
193
- `).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),i=t.lastIndexOf("}");s>=0&&i>s&&r.unshift(t.slice(s,i+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function tl(e,t){const n=Tr(e);n.set("path",t);const r=await fetch(`/api/workspace/file?${n.toString()}`),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error||`读取文件失败:${t}`);return String(s.content||"")}async function ab(e,t,n){const r=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,path:t,content:String(n||"")})}),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error||`写入文件失败:${t}`);return s.path||t}function _G(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(i=>[i.id,i]));return(Array.isArray(n)?n:[]).filter(i=>String((i==null?void 0:i.target)||"")===r).slice(0,4).map(i=>{const a=s.get(String((i==null?void 0:i.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
194
- `)}).filter(Boolean).join(`
195
-
196
- `)}function zc(e){let t=_i(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 EG(e){const t=zc(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ta(e,t){return e==="html"?EG(t):""}function OT(e,t=""){const n=zc(e);if(!n.trim())return"";const s=`<base target="_blank"><script data-agentflow-display-link-guard="1">
197
- (() => {
198
- const frameId = ${JSON.stringify(String(t||""))};
199
- const postSize = () => {
200
- const doc = document.documentElement;
201
- const body = document.body;
202
- const height = Math.ceil(Math.max(
203
- doc ? doc.scrollHeight : 0,
204
- doc ? doc.offsetHeight : 0,
205
- doc ? doc.clientHeight : 0,
206
- body ? body.scrollHeight : 0,
207
- body ? body.offsetHeight : 0,
208
- body ? body.clientHeight : 0,
209
- window.innerHeight || 0
210
- ));
211
- window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
212
- };
213
- document.addEventListener("click", (event) => {
214
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
215
- if (!link) return;
216
- const rawHref = String(link.getAttribute("href") || "").trim();
217
- if (!rawHref || rawHref.startsWith("#")) return;
218
- if (/^javascript:/i.test(rawHref)) {
219
- event.preventDefault();
220
- return;
221
- }
222
- event.preventDefault();
223
- window.open(link.href, "_blank", "noopener,noreferrer");
224
- }, true);
225
- window.addEventListener("load", postSize);
226
- window.addEventListener("resize", postSize);
227
- requestAnimationFrame(postSize);
228
- setTimeout(postSize, 60);
229
- setTimeout(postSize, 300);
230
- if (typeof ResizeObserver !== "undefined") {
231
- const resizeObserver = new ResizeObserver(postSize);
232
- resizeObserver.observe(document.documentElement);
233
- if (document.body) resizeObserver.observe(document.body);
234
- }
235
- if (typeof MutationObserver !== "undefined") {
236
- const mutationObserver = new MutationObserver(postSize);
237
- mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
238
- }
239
- })();
240
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${s}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${n}</body></html>`}function AG(e,t){const n=String(e).trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g,"-").replace(/^-+|-+$/g,"")||"html-render",r=String(t).replace(/^\.+/,"")||"png";return`${n}.${r}`}function PG(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function IG(e,t){const n=URL.createObjectURL(e);try{PG(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function DT(e){var t;try{return(e==null?void 0:e.contentDocument)||((t=e==null?void 0:e.contentWindow)==null?void 0:t.document)||null}catch{return null}}function RG(e){const t=DT(e);return t!=null&&t.documentElement?`${t.doctype?`<!DOCTYPE ${t.doctype.name}${t.doctype.publicId?` PUBLIC "${t.doctype.publicId}"`:""}${t.doctype.systemId?` "${t.doctype.systemId}"`:""}>`:"<!DOCTYPE html>"}
241
- ${t.documentElement.outerHTML}`:""}function rw(e){var n;if(!e)return null;const t=(n=e.getBoundingClientRect)==null?void 0:n.call(e);return{rectWidth:t!=null&&t.width?Math.round(t.width):null,rectHeight:t!=null&&t.height?Math.round(t.height):null,clientWidth:e.clientWidth||null,clientHeight:e.clientHeight||null,scrollWidth:e.scrollWidth||null,scrollHeight:e.scrollHeight||null,offsetWidth:e.offsetWidth||null,offsetHeight:e.offsetHeight||null}}function TG(e,t,n,r={}){var b;const s=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),i=DT(e),a=i==null?void 0:i.documentElement,l=i==null?void 0:i.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,d=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,p={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((f==null?void 0:f.width)||0)||null,displaySizeHeight:Number((f==null?void 0:f.height)||0)||null,rectWidth:s!=null&&s.width?Math.round(s.width):null,rectHeight:s!=null&&s.height?Math.round(s.height):null,iframeClientWidth:(e==null?void 0:e.clientWidth)||null,iframeClientHeight:(e==null?void 0:e.clientHeight)||null,docScrollWidth:(a==null?void 0:a.scrollWidth)||null,docScrollHeight:(a==null?void 0:a.scrollHeight)||null,bodyScrollWidth:(l==null?void 0:l.scrollWidth)||null,bodyScrollHeight:(l==null?void 0:l.scrollHeight)||null,docOffsetWidth:(a==null?void 0:a.offsetWidth)||null,bodyOffsetWidth:(l==null?void 0:l.offsetWidth)||null,card:rw(c),displayBody:rw(u),scroller:rw(d)},h=[Number(t)||0,Number((f==null?void 0:f.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((d==null?void 0:d.clientWidth)||0),Number((d==null?void 0:d.scrollWidth)||0),Number(s==null?void 0:s.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(y=>Math.ceil(y)).filter(y=>y>0),g=Math.max(1,...h.length?h:[960]),k=Math.max(1,Math.round(Number(n)||(s==null?void 0:s.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:g,height:k,debug:p}}async function MG({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:i,filename:a,snapshotElements:l,displaySize:c}){const u=TG(r,s,i,{...l||{},displaySize:c}),d=RG(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:d||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!f.ok){const h=await f.json().catch(()=>({}));throw new Error(h.error||"截图失败")}const p=await f.blob();IG(p,a)}function $G(e){const n=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]].find(r=>(r==null?void 0:r.name)==="alt");return String((n==null?void 0:n.value)||(n==null?void 0:n.default)||(e==null?void 0:e.label)||"Image preview")}function FT(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function LG(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 u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?i(u[1],u[2]||u[3]||u[4]||u[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 u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function zT({code:e}){const t=m.useMemo(()=>LG(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((d,f)=>{l.set(d.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(d=>d.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(d=>d.y+s+24));return o.jsx("div",{className:"af-work-node__mermaid-preview",children:o.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,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((d,f)=>{const p=l.get(d.from),h=l.get(d.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)"},`${d.from}-${d.to}-${f}`)}),t.nodes.map(d=>{const f=l.get(d.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:d.label.slice(0,22)})]},d.id)})]})})}function di({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 d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,g=h?Math.max(12,p/f*100):100,k=Math.max(0,100-g),b=h?Math.min(k,d.scrollTop/Math.max(1,f-p)*k):0;i({visible:h,top:b,height:g})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),g=s.height/100*h.height,k=Math.max(1,h.height-g);return(d-h.top-f)/k},[s.height]),u=m.useCallback(d=>{var C,N;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,g=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+g?d.clientY-p.top-h:g/2;l(c(d.clientY,b));const y=d.pointerId;(N=(C=d.currentTarget).setPointerCapture)==null||N.call(C,y);const v=j=>{j.preventDefault(),l(c(j.clientY,b))},x=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[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:u,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function BT({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=An(e),i=to(e),a=s==="image"?i:_i(i),l=s==="image"?"":Zo(a,s),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1);m.useEffect(()=>{let v=!1;return l?(h(!0),f(""),u(""),tl(t,l).then(x=>{v||u(x)}).catch(x=>{v||f(String(x.message||x))}).finally(()=>{v||h(!1)}),()=>{v=!0}):(u(""),f(""),h(!1),()=>{v=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const g=l?c:a,k=s==="html"?zc(g):s==="react"?ng(g):_i(g),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const y=Ta(s,k);if(p)return o.jsxs(di,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(d)return o.jsx(di,{className:"af-work-display-empty",children:d});if(y)return o.jsx(di,{className:"af-work-display-empty",children:y});if(!k.trim())return o.jsx(di,{className:"af-work-display-empty",children:"No display content"});if(s==="html"||s==="react")return o.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(s==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:s==="react"?tv(k,b.current):OT(k,b.current)},r)});if(s==="image"){const v=Wd(k,t);return o.jsx(di,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:v,alt:$G(e),loading:"lazy"})})}return s==="markdown"?o.jsx(di,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(Gk,{content:k,basePath:l,resolveSrc:(v,x)=>Wd(v,t,x)})}):s==="chart"?o.jsx(di,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(Xk,{content:k})}):s==="table"?o.jsx(di,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(Jk,{content:k})}):s==="mermaid"?o.jsxs(di,{className:"af-work-display-body",children:[o.jsx(zT,{code:k}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:k})]}):o.jsx(di,{className:"af-work-display-body af-work-display-body--ascii",children:o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:k})})}function OG({node:e,onClose:t}){var v,x,C,N,j,A,I,O,H,B,z;const n=m.useRef(null),r=An(e==null?void 0:e.data),s=((v=e==null?void 0:e.data)==null?void 0:v.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),i=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState(!1),g=to(e==null?void 0:e.data),k=r==="markdown"?_i(g):"",b=r==="markdown"?Zo(k,"markdown"):"",y=r==="markdown"?b?d:k:"";return m.useEffect(()=>{const $=M=>{if(M.key==="Escape"){if(a){u(String(y||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[y,a,t]),m.useEffect(()=>{var M;let $=!1;return r!=="markdown"||!b?(f(""),h(!1),()=>{$=!0}):(h(!0),tl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},b).then(q=>{$||f(q)}).catch(q=>{var D,L;$||(f(""),(L=(D=e==null?void 0:e.data)==null?void 0:D.onStatus)==null||L.call(D,String(q.message||q)))}).finally(()=>{$||h(!1)}),()=>{$=!0})},[r,b,(N=(C=e==null?void 0:e.data)==null?void 0:C.flowParams)==null?void 0:N.flowId,(A=(j=e==null?void 0:e.data)==null?void 0:j.flowParams)==null?void 0:A.flowSource,(O=(I=e==null?void 0:e.data)==null?void 0:I.flowParams)==null?void 0:O.archived,(H=e==null?void 0:e.data)==null?void 0:H.displayReloadKey]),m.useEffect(()=>{a||u(String(y||""))},[y,a]),e?or.createPortal(o.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:o.jsxs("div",{className:"af-display-preview-shell",children:[o.jsxs("div",{className:"af-display-preview-head",children:[o.jsxs("div",{className:"af-display-preview-title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:FT(r)}),o.jsx("strong",{children:s}),o.jsx("span",{children:e.id})]}),o.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-display-preview-action",disabled:i||p,onClick:async()=>{var $,M;try{await WT({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:f}),l(!1)}catch(q){(M=($=e==null?void 0:e.data)==null?void 0:$.onStatus)==null||M.call($,String(q.message||q))}},"aria-label":"保存并预览",title:"保存并预览",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"done"})}),o.jsx("button",{type:"button",className:"af-display-preview-action",onClick:()=>{u(String(y||"")),l(!1)},"aria-label":"取消编辑",title:"取消编辑",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):o.jsx("button",{type:"button",className:"af-display-preview-action",disabled:i||p,onClick:()=>{u(String(y||"")),l(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"})}):null,o.jsx("button",{type:"button",className:"af-display-preview-action",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close_fullscreen"})})]})]}),o.jsx("div",{className:"af-display-preview-content",children:r==="markdown"&&a?o.jsx(HT,{value:c,onChange:u,onUploadImage:(B=e.data)==null?void 0:B.onUploadWorkspaceImage,readOnly:i}):o.jsx(BT,{data:e.data,flowParams:(z=e.data)==null?void 0:z.flowParams,htmlFrameRef:n})})]})}),document.body):null}function DG({node:e}){var p,h,g,k,b,y,v,x,C,N;const t=An(e==null?void 0:e.data),n=to(e==null?void 0:e.data),r=t==="image"?n:_i(n),s=t==="image"?"":Zo(r,t),[i,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var A;let j=!1;return s?(c(!0),a(""),tl(((A=e==null?void 0:e.data)==null?void 0:A.flowParams)||{},s).then(I=>{j||a(I)}).catch(()=>{j||a("")}).finally(()=>{j||c(!1)}),()=>{j=!0}):(a(""),c(!1),()=>{j=!0})},[s,(h=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:h.flowId,(k=(g=e==null?void 0:e.data)==null?void 0:g.flowParams)==null?void 0:k.flowSource,(y=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:y.archived,(v=e==null?void 0:e.data)==null?void 0:v.displayReloadKey]);const u=s?i:r,d=t==="html"?zc(u):t==="react"?ng(u):_i(u),f=Ta(t,d);return l?o.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?o.jsx("div",{className:"af-display-picker-preview__empty",children:f}):d.trim()?t==="html"||t==="react"?o.jsx("iframe",{title:((x=e==null?void 0:e.data)==null?void 0:x.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?tv(d):OT(d)}):t==="image"?o.jsx("img",{src:Wd(d,(C=e==null?void 0:e.data)==null?void 0:C.flowParams),alt:((N=e==null?void 0:e.data)==null?void 0:N.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?o.jsx("div",{className:"af-display-picker-preview__markdown",children:o.jsx(Gk,{content:d,basePath:s,resolveSrc:(j,A)=>{var I;return Wd(j,(I=e==null?void 0:e.data)==null?void 0:I.flowParams,A)}})}):t==="chart"?o.jsx(Xk,{content:d}):t==="table"?o.jsx(Jk,{content:d}):t==="mermaid"?o.jsxs("div",{className:"af-display-picker-preview__diagram",children:[o.jsx(zT,{code:d}),o.jsx("pre",{children:d})]}):o.jsx("pre",{className:"af-display-picker-preview__pre",children:d}):o.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function HT({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=m.useRef(null),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,d]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const y=s.current;if(!y)return;const v=Math.max(1,y.scrollHeight),x=Math.max(1,y.clientHeight),C=v>x+1,N=C?Math.max(12,x/v*100):100,j=Math.max(0,100-N),A=C?Math.min(j,y.scrollTop/Math.max(1,v-x)*j):0;d({visible:C,top:A,height:N})},[]);m.useEffect(()=>{const y=requestAnimationFrame(f),v=s.current;if(!v||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(y);const x=new ResizeObserver(f);return x.observe(v),()=>{cancelAnimationFrame(y),x.disconnect()}},[f,e]);const p=m.useCallback(y=>{const v=s.current;if(!v)return;const x=Math.max(0,v.scrollHeight-v.clientHeight);v.scrollTop=Math.min(1,Math.max(0,y))*x,f()},[f]),h=m.useCallback((y,v=0)=>{const x=a.current;if(!x)return 0;const C=x.getBoundingClientRect(),N=u.height/100*C.height,j=Math.max(1,C.height-N);return(y-C.top-v)/j},[u.height]),g=m.useCallback(y=>{if(!u.visible)return;y.preventDefault(),y.stopPropagation();const v=a.current;if(!v)return;const x=v.getBoundingClientRect(),C=u.top/100*x.height,N=u.height/100*x.height,A=y.clientY>=x.top+C&&y.clientY<=x.top+C+N?y.clientY-x.top-C:N/2;p(h(y.clientY,A));const I=H=>{H.preventDefault(),p(h(H.clientY,A))},O=()=>{window.removeEventListener("pointermove",I),window.removeEventListener("pointerup",O),window.removeEventListener("pointercancel",O)};window.addEventListener("pointermove",I),window.addEventListener("pointerup",O),window.addEventListener("pointercancel",O)},[h,p,u.height,u.top,u.visible]),k=m.useCallback(y=>{const v=String(e||""),x=s.current,C=Number((x==null?void 0:x.selectionStart)??v.length),N=Number((x==null?void 0:x.selectionEnd)??C),j=v.slice(0,C),A=v.slice(N),I=j&&!j.endsWith(`
242
- `)?`
243
- `:"",O=A&&!A.startsWith(`
244
- `)?`
245
- `:"",H=`${j}${I}${y}${O}${A}`;t==null||t(H),window.requestAnimationFrame(()=>{var z,$;const B=j.length+I.length+y.length;(z=s.current)==null||z.focus(),($=s.current)==null||$.setSelectionRange(B,B)})},[t,e]),b=m.useCallback(async y=>{if(!r&&!(!y||l)){c(!0);try{const v=await(n==null?void 0:n(y)),x=String(v||"").trim();if(x){const C=String(y.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";k(`![${C}](${x})`)}}finally{c(!1)}}},[k,n,r,l]);return o.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:y=>y.stopPropagation(),onDragOver:y=>{var x;Array.from(((x=y.dataTransfer)==null?void 0:x.items)||[]).some(C=>String((C==null?void 0:C.type)||"").startsWith("image/"))&&(y.preventDefault(),y.dataTransfer.dropEffect="copy")},onDrop:y=>{var x;const v=Array.from(((x=y.dataTransfer)==null?void 0:x.files)||[]).find(sm);v&&(y.preventDefault(),b(v))},children:[o.jsxs("div",{className:"af-work-display-editor__toolbar",children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var y;return(y=i.current)==null?void 0:y.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),o.jsx("input",{ref:i,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:y=>{var x;const v=(x=y.target.files)==null?void 0:x[0];y.target.value="",v&&b(v)}})]}),o.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:y=>t==null?void 0:t(y.target.value),onScroll:f,onKeyDown:y=>{y.key==="Escape"&&y.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),o.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:g,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function FG({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},i=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,c]=m.useState(a),u=m.useRef(!1),d=String(s.candidateContent||""),f=!!s.running,p=!!(t!=null&&t.readOnly),h=String(s.error||""),g=i.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:k=>k.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 k;return(k=t==null?void 0:t.onCloseNodeChat)==null?void 0:k.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.length>0||f||h?o.jsxs("div",{className:"af-work-node-chat__messages",children:[g.map((k,b)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${k.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:k.role==="assistant"?"AI":"你"}),o.jsx("p",{children:k.text})]},`${k.at||b}-${b}`)),f?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?o.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,o.jsxs("div",{className:"af-work-node-chat__composer",children:[o.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f||p,"aria-label":"添加上下文",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),o.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:f||p,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:k=>{var y;u.current=!1;const b=k.currentTarget.value;c(b),(y=t==null?void 0:t.onUpdateNodeChatDraft)==null||y.call(t,e,b)},onChange:k=>{var y;const b=k.target.value;c(b),u.current||(y=t==null?void 0:t.onUpdateNodeChatDraft)==null||y.call(t,e,b)},onKeyDown:k=>{var b,y;k.isComposing||(b=k.nativeEvent)!=null&&b.isComposing||k.keyCode===229||(k.metaKey||k.ctrlKey)&&k.key==="Enter"&&(k.preventDefault(),(y=t==null?void 0:t.onSendNodeChat)==null||y.call(t,e,l))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||p||!l.trim(),onClick:()=>{var k;return(k=t==null?void 0:t.onSendNodeChat)==null?void 0:k.call(t,e,l)},"aria-label":"发送",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),d.trim()?o.jsx("div",{className:"af-work-node-chat__messages",children:o.jsxs("div",{className:"af-work-node-chat__msg af-work-node-chat__msg--assistant",children:[o.jsx("span",{children:"AI"}),o.jsx("p",{children:d})]})}):null]}):o.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:k=>{var b;k.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function zG(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function BG(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function HG(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function RC(e,t=""){const n=Zo(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function WG(e,t){const n=HG(e),r=new Set,s=An(t)||"";ei(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const i=RC(to(t),s);return i&&r.add(i),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),d=RC(u,s);return d&&r.add(d),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function TC(e,t){const n=An(t)||"markdown";return`outputs/${BG((t==null?void 0:t.label)||e||n)}.${zG(n)}`}async function WT({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var i,a;if(n){const l=await ab((t==null?void 0:t.flowParams)||{},n,r);s==null||s(r),(i=t==null?void 0:t.onSetDisplayNodeContent)==null||i.call(t,e,l,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${l}`});return}(a=t==null?void 0:t.onSetDisplayNodeContent)==null||a.call(t,e,r,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"})}function VT({id:e,data:t,selected:n,deleteNode:r}){var ne,ee,re;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((Z,le)=>({slot:Z,idx:le})).sort((Z,le)=>{var Oe,st,mt,kt;const de=String(((Oe=Z.slot)==null?void 0:Oe.name)||"").trim(),we=String(((st=le.slot)==null?void 0:st.name)||"").trim();if(de==="next"&&we!=="next")return-1;if(we==="next"&&de!=="next")return 1;const De=String(((mt=Z.slot)==null?void 0:mt.type)||"").trim(),Qe=String(((kt=le.slot)==null?void 0:kt.type)||"").trim();return De==="node"&&Qe!=="node"?-1:Qe==="node"&&De!=="node"?1:Z.idx-le.idx}),l=An(t),c=m.useRef(null),u=m.useRef(null),[d,f]=m.useState(0),[p,h]=m.useState(!1),[g,k]=m.useState(!1),[b,y]=m.useState(!1),[v,x]=m.useState(""),[C,N]=m.useState(""),[j,A]=m.useState(!1),[I,O]=m.useState(!1),H=m.useRef(null),B=to(t),z=l==="markdown"?_i(B):"",$=l==="markdown"?Zo(z,"markdown"):"",M=l==="markdown"?$?C:z:"",q=!!(t!=null&&t.readOnly),D=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let Z=!1;return l!=="markdown"||!$?(N(""),A(!1),()=>{Z=!0}):(A(!0),tl((t==null?void 0:t.flowParams)||{},$).then(le=>{Z||N(le)}).catch(le=>{var de;Z||(N(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(le.message||le)))}).finally(()=>{Z||A(!1)}),()=>{Z=!0})},[l,$,(ne=t==null?void 0:t.flowParams)==null?void 0:ne.flowId,(ee=t==null?void 0:t.flowParams)==null?void 0:ee.flowSource,(re=t==null?void 0:t.flowParams)==null?void 0:re.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!g)return;const Z=()=>k(!1);return window.addEventListener("pointerup",Z,!0),window.addEventListener("pointercancel",Z,!0),window.addEventListener("mouseup",Z,!0),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointerup",Z,!0),window.removeEventListener("pointercancel",Z,!0),window.removeEventListener("mouseup",Z,!0),window.removeEventListener("blur",Z)}},[g]),m.useEffect(()=>{b||x(String(M||""))},[M,b]);const L=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),T=String((t==null?void 0:t.sourceNodeId)||e),W=(t==null?void 0:t.sharingDisplayNodeId)===T,E=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Pe,dt,gt,xe,Fe,Me,ue,ve,Ve,qe;if(l!=="html"||p)return;const Z=to(t),le=Zo(Z,l);let de=Z;if(le)try{de=await tl((t==null?void 0:t.flowParams)||{},le)}catch(be){h(!1),console.warn("Failed to read HTML display file before saving image.",be);return}const we=zc(de);if(!we.trim())return;const De=Ta(l,we);if(De){console.warn(De);return}const Qe=(dt=(Pe=u.current)==null?void 0:Pe.getBoundingClientRect)==null?void 0:dt.call(Pe),Oe=(xe=(gt=c.current)==null?void 0:gt.querySelector)==null?void 0:xe.call(gt,".af-work-display-body"),st=(Me=(Fe=c.current)==null?void 0:Fe.querySelector)==null?void 0:Me.call(Fe,".af-visible-scroll-frame__scroller"),mt=Math.round(Math.max(Number((Qe==null?void 0:Qe.width)||0),Number((E==null?void 0:E.width)||0),Number(((ue=c.current)==null?void 0:ue.clientWidth)||0),Number((Oe==null?void 0:Oe.clientWidth)||0),Number((st==null?void 0:st.clientWidth)||0),Math.max(320,Number((E==null?void 0:E.width)||960)-2))),kt=Math.round(Math.max(Number((Qe==null?void 0:Qe.height)||0),Number((E==null?void 0:E.height)||0),Number(((ve=c.current)==null?void 0:ve.clientHeight)||0),Number((Oe==null?void 0:Oe.clientHeight)||0),Number((st==null?void 0:st.clientHeight)||0),Math.max(180,Number((E==null?void 0:E.height)||640)-46)));h(!0);try{await MG({flowParams:(t==null?void 0:t.flowParams)||{},content:we,sourceFilePath:le,iframe:u.current,width:mt,height:kt,filename:AG((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:Oe,scroller:st},displaySize:E}),(Ve=t==null?void 0:t.onStatus)==null||Ve.call(t,"已导出 HTML 展示截图")}catch(be){const Tt=String((be==null?void 0:be.message)||be||"截图失败");(qe=t==null?void 0:t.onStatus)==null||qe.call(t,`HTML 截图失败:${Tt}`),console.warn("Failed to save HTML display as PNG.",be)}finally{h(!1)}},[t,E==null?void 0:E.height,E==null?void 0:E.width,e,l,p]),V=m.useCallback(Z=>{var le;q||!Z||l!=="image"||(le=t==null?void 0:t.onUploadImageToDisplayNode)==null||le.call(t,e,Z)},[t,e,l,q]),F=m.useCallback(Z=>{var le,de;(le=Z==null?void 0:Z.stopPropagation)==null||le.call(Z),!q&&((de=t==null?void 0:t.onSetDisplayNodeContent)==null||de.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),y(!1)))},[t,e,l,q]),se=m.useCallback(Z=>{var we,De;q||l!=="image"||!(Array.from(((we=Z.dataTransfer)==null?void 0:we.files)||[]).some(sm)||Array.from(((De=Z.dataTransfer)==null?void 0:De.items)||[]).some(Qe=>String((Qe==null?void 0:Qe.type)||"").startsWith("image/")))||(Z.preventDefault(),Z.stopPropagation(),Z.dataTransfer.dropEffect="copy",O(!0))},[l,q]),ce=m.useCallback(Z=>{l==="image"&&(Z.currentTarget.contains(Z.relatedTarget)||O(!1))},[l]),J=m.useCallback(Z=>{var de;if(l!=="image")return;const le=Array.from(((de=Z.dataTransfer)==null?void 0:de.files)||[]).find(sm);le&&(Z.preventDefault(),Z.stopPropagation(),O(!1),V(le))},[l,V]);return o.jsxs("div",{className:"af-work-display-card"+(E?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(g?" af-work-display-card--resizing":"")+(I?" af-work-display-card--image-drop":"")+(D?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:E?{width:E.width,height:E.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:se,onDragLeave:ce,onDrop:J,children:[o.jsx(Tk,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>k(!0),onResizeEnd:()=>k(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((Z,le)=>{if(Z.showOnNode===!1)return null;const de=`${4.15+le*1.75}rem`,we=Z.name||`#${le+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:de},children:we}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${le}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:In(Z.type)},title:`${we} · ${Z.type}`})]},`in-${le}`)}),a.map(({slot:Z,idx:le},de)=>{if(Z.showOnNode===!1)return null;const we=`${4.15+de*1.75}rem`,De=Z.name||`#${le+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:we},children:De}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${le}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:we,background:In(Z.type)},title:`${De} · ${Z.type}`})]},`out-${le}`)}),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:FT(l)}),o.jsx("strong",{children:L}),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:Z=>Z.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Z,le,de,we;try{(we=(de=(le=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:le.history)==null?void 0:de.back)==null||we.call(de)}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 Z,le,de,we;try{(we=(de=(le=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:le.history)==null?void 0:de.forward)==null||we.call(de)}catch{}},"aria-label":"前进",title:"前进",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>f(Z=>Z+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:p,onClick:Q,"aria-label":"截图另存为图片",title:"截图另存为图片",children:o.jsx("span",{className:"material-symbols-outlined",children:p?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Z=>Z.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:q||j,onClick:async()=>{var Z;try{await WT({nodeId:e,data:t,filePath:$,content:v,setFileContent:N}),y(!1)}catch(le){(Z=t==null?void 0:t.onStatus)==null||Z.call(t,String(le.message||le))}},"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:()=>{x(String(M||"")),y(!1)},"aria-label":"取消编辑",title:"取消编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:q||j,onClick:Z=>{Z.stopPropagation(),x(String(M||"")),y(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:H,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Z=>{var de;const le=(de=Z.target.files)==null?void 0:de[0];Z.target.value="",le&&V(le)}}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:q,onClick:Z=>{var le;Z.stopPropagation(),(le=H.current)==null||le.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:Z=>{var le;Z.stopPropagation(),(le=t==null?void 0:t.onOpenDisplayPreview)==null||le.call(t,T)},"aria-label":"全屏预览",title:"全屏预览",children:o.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:W,onClick:Z=>{var le;Z.stopPropagation(),(le=t==null?void 0:t.onShareDisplayNode)==null||le.call(t,T)},"aria-label":"分享展示",title:"分享展示",children:o.jsx("span",{className:"material-symbols-outlined",children:W?"hourglass_empty":"ios_share"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:q,onClick:F,"aria-label":"清空内容",title:"清空内容",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:q,onClick:()=>{var Z;return(Z=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:Z.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"save"})}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:q,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?o.jsx(HT,{value:v,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:q}):o.jsx(BT,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),o.jsx(FG,{nodeId:e,data:t})]})}function VG({id:e,data:t,selected:n,deleteNode:r}){var d,f,p;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((f=(d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d.has)==null?void 0:f.call(d,e))||((p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return 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":"")+(c?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((h,g)=>{if(h.showOnNode===!1)return null;const k=`${2.25+g*1.75}rem`,b=h.name||`#${g+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:b}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:In(h.type)},title:`${b} · ${h.type}`})]},`in-${g}`)}),i.map((h,g)=>{if(h.showOnNode===!1)return null;const k=`${2.25+g*1.75}rem`,b=h.name||`#${g+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:b}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:In(h.type)},title:`${b} · ${h.type}`})]},`out-${g}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,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-run-card__actions",children:[o.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:h=>{var g,k;h.stopPropagation(),a?(g=t==null?void 0:t.onStopWorkspaceNode)==null||g.call(t,e):(k=t==null?void 0:t.onRunWorkspaceNode)==null||k.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),o.jsx("span",{children:a?"Stop":"Run line"})]}),o.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:h=>{var g;h.stopPropagation(),(g=t==null?void 0:t.onOptimizeWorkspaceRun)==null||g.call(t,e)},children:o.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),o.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:h=>{var g;h.stopPropagation(),(g=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||g.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:o.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function KG({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:i,workspaces:a}){var qe,be,Tt,ln,_t,hn,tn;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=aJ(t),[d,f]=m.useState(u.task),p=m.useRef(!1),h=m.useRef(u.task),g=((be=(qe=t==null?void 0:t.runningRunNodeIds)==null?void 0:qe.has)==null?void 0:be.call(qe,e))||((Tt=t==null?void 0:t.runningRunNodeIds)==null?void 0:Tt[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",k=(t==null?void 0:t.nodeStatus)==="stopped",b=!!(t!=null&&t.readOnly),y=Array.isArray(s)?s:[],v=Array.isArray(i)?i:[],x=m.useMemo(()=>(Array.isArray(a)?a:[]).map(te=>({id:String((te==null?void 0:te.id)||""),label:String((te==null?void 0:te.label)||(te==null?void 0:te.name)||"知识库"),kind:(te==null?void 0:te.kind)==="git"?"git":"local",path:String((te==null?void 0:te.path)||""),repoUrl:String((te==null?void 0:te.repoUrl)||""),branch:String((te==null?void 0:te.branch)||""),mountPath:String((te==null?void 0:te.mountPath)||""),builtin:(te==null?void 0:te.builtin)===!0,exists:(te==null?void 0:te.exists)!==!1,type:String((te==null?void 0:te.type)||"")})).filter(te=>te.path),[a]),[C,N]=m.useState(!1),[j,A]=m.useState(""),[I,O]=m.useState(()=>new Set),[H,B]=m.useState(!1),[z,$]=m.useState(""),[M,q]=m.useState("config"),D=rg(t),L=!!D,T=XT(u.displayType),W=m.useMemo(()=>jG(t,T),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,T]),E=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:T,displaySize:W,nodeSize:W,body:D,inputs:[{type:"text",name:T==="display_image"?"src":"content",value:D,default:D}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,T,e,D,c,W]),Q=Array.isArray((ln=t==null?void 0:t.modelLists)==null?void 0:ln.cursor)?t.modelLists.cursor:[],V=Array.isArray((_t=t==null?void 0:t.modelLists)==null?void 0:_t.opencode)?t.modelLists.opencode:[],F=Array.isArray((hn=t==null?void 0:t.modelLists)==null?void 0:hn.claudeCode)?t.modelLists.claudeCode:[],se=Array.isArray((tn=t==null?void 0:t.modelLists)==null?void 0:tn.codex)?t.modelLists.codex:[],ce=m.useMemo(()=>new Set(Q.map(vs)),[Q]),J=m.useMemo(()=>new Set(V.map(vs)),[V]),ne=m.useMemo(()=>new Set(F.map(vs)),[F]),ee=m.useMemo(()=>new Set(se.map(vs)),[se]),re=u.model,Z=m.useMemo(()=>re?re.startsWith("cursor:")||re.startsWith("opencode:")||re.startsWith("codex:")||re.startsWith("claude-code:")?re:ne.has(re)?`claude-code:${re}`:ee.has(re)?`codex:${re}`:J.has(re)?`opencode:${re}`:ce.has(re)?`cursor:${re}`:re:"",[ne,ee,ce,J,re]),le=re.startsWith("cursor:")?re.slice(7):re.startsWith("opencode:")?re.slice(9):re.startsWith("codex:")?re.slice(6):re.startsWith("claude-code:")?re.slice(12):re,de=le,we=!!re&&!ce.has(de)&&!J.has(de)&&!ne.has(de)&&!ee.has(de),De=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Qe=m.useMemo(()=>new Map(y.map(te=>[te.key,te])),[y]),Oe=m.useMemo(()=>{const te=new Set,Ie=v.map(Ze=>{const Mt=Xo(Ze,y).map(At=>Qe.get(At)).filter(Boolean);for(const At of Mt)te.add(At.key);return{...Ze,skills:Mt}}).filter(Ze=>Ze.skills.length>0),Ue=y.filter(Ze=>!te.has(Ze.key));return{collectionGroups:Ie,ungrouped:Ue}},[v,Qe,y]);m.useEffect(()=>{O(te=>{let Ie=!1;const Ue=new Set(te);for(const Ze of Oe.collectionGroups)Ue.has(Ze.id)||(Ue.add(Ze.id),Ie=!0);return Ie?Ue:te})},[Oe.collectionGroups]);const st=m.useMemo(()=>{const te=j.trim().toLowerCase();if(!te)return Oe;const Ie=Ze=>[Ze==null?void 0:Ze.key,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(Mt=>String(Mt||"").toLowerCase()).join(" ").includes(te);return{collectionGroups:Oe.collectionGroups.map(Ze=>{const Mt=[Ze==null?void 0:Ze.id,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(At=>String(At||"").toLowerCase()).join(" ").includes(te);return{...Ze,skills:Mt?Ze.skills:Ze.skills.filter(Ie)}}).filter(Ze=>Ze.skills.length>0),ungrouped:Oe.ungrouped.filter(Ie)}},[Oe,j]),mt=lb(C,[st.collectionGroups.length,st.ungrouped.length,I.size,u.skillKeys.length,j]),kt=m.useMemo(()=>{const te=z.trim().toLowerCase();return te?x.filter(Ie=>[Ie.id,Ie.label,Ie.path,Ie.repoUrl,Ie.branch,Ie.mountPath,Ie.type].join(" ").toLowerCase().includes(te)):x},[x,z]),Pe=m.useMemo(()=>tM(u.knowledgeContext),[u.knowledgeContext]),dt=m.useMemo(()=>new Set(Pe.map(te=>te.id||te.path||te.repoPath).filter(Boolean)),[Pe]),gt=lb(H,[kt.length,Pe.length,z]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,p.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!L){q("config");return}g||q("result")},[L,D,g]),m.useEffect(()=>{var Ie,Ue;if(!(M==="result"&&L))return;(Ie=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Ie.call(t,e,W),(Ue=t==null?void 0:t.onRefreshNodeInternals)==null||Ue.call(t,e);const te=window.setTimeout(()=>{var Ze;return(Ze=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:Ze.call(t,e)},120);return()=>window.clearTimeout(te)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,T,L,e,D,W,M]);const xe=te=>{var Ie;(Ie=t==null?void 0:t.onChangeContextRunConfig)==null||Ie.call(t,e,{...u,task:d,...te})},Fe=(te=d)=>{var Ue;const Ie=String(te??"");Ie!==u.task&&(h.current=Ie,(Ue=t==null?void 0:t.onChangeContextRunConfig)==null||Ue.call(t,e,{...u,task:Ie}))},Me=(te,Ie)=>{const Ue=new Set(u.skillKeys);for(const Ze of te){const Mt=String(Ze||"").trim();Mt&&(Ie?Ue.add(Mt):Ue.delete(Mt))}xe({skillKeys:Array.from(Ue)})},ue=te=>{O(Ie=>{const Ue=new Set(Ie);return Ue.has(te)?Ue.delete(te):Ue.add(te),Ue})},ve=(te,Ie)=>{const Ue=(te==null?void 0:te.id)||(te==null?void 0:te.path)||"";if(!Ue)return;const Ze=x.filter(Mt=>{const At=Mt.id||Mt.path||"";return At===Ue?Ie:dt.has(At)});xe({knowledgeContext:sg(Ze)})},Ve=()=>{xe({knowledgeContext:null})};return M==="result"&&L?o.jsx(VT,{id:e,data:{...E,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):o.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+(M==="result"&&L?" af-work-context-run-card--result":"")+(g?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(k?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((te,Ie)=>{if(te.showOnNode===!1)return null;const Ue=`${2.25+Ie*1.75}rem`,Ze=te.name||`#${Ie+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Ue},children:Ze}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${Ie}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Ue,background:In(te.type)},title:`${Ze} · ${te.type}`})]},`in-${Ie}`)}),c.map((te,Ie)=>{if(te.showOnNode===!1)return null;const Ue=`${2.25+Ie*1.75}rem`,Ze=te.name||`#${Ie+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Ue},children:Ze}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${Ie}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Ue,background:In(te.type)},title:`${Ze} · ${te.type}`})]},`out-${Ie}`)}),o.jsxs("div",{className:"af-work-context-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"automation"}),o.jsx("strong",{children:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"}),o.jsxs("div",{className:"af-work-context-run-card__model-wrap nodrag",onPointerDown:te=>te.stopPropagation(),onMouseDown:te=>te.stopPropagation(),onClick:te=>te.stopPropagation(),children:[o.jsxs("select",{className:"af-work-context-run-card__model",value:Z,disabled:b,"aria-label":"模型",title:le||"默认模型",onChange:te=>xe({model:te.target.value}),children:[o.jsx("option",{value:"",children:"默认"}),we?o.jsx("option",{value:re,children:re}):null,Q.length?o.jsx("optgroup",{label:"Cursor",children:Q.map(te=>o.jsx("option",{value:`cursor:${vs(te)}`,children:vs(te)},`context-cursor-${te}`))}):null,V.length?o.jsx("optgroup",{label:"OpenCode",children:V.map(te=>o.jsx("option",{value:`opencode:${vs(te)}`,children:vs(te)},`context-opencode-${te}`))}):null,se.length?o.jsx("optgroup",{label:"Codex",children:se.map(te=>o.jsx("option",{value:`codex:${vs(te)}`,children:vs(te)},`context-codex-${te}`))}):null,F.length?o.jsx("optgroup",{label:"Claude Code",children:F.map(te=>o.jsx("option",{value:`claude-code:${vs(te)}`,children:vs(te)},`context-claude-${te}`))}):null]}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"expand_more"})]}),o.jsx("span",{className:"af-work-context-run-card__kind",children:ei(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),L?o.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:te=>te.stopPropagation(),children:[o.jsx("button",{type:"button",className:M==="config"?"is-active":"",onClick:()=>q("config"),"aria-label":"切换到任务配置",children:o.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),o.jsx("button",{type:"button",className:M==="result"?"is-active":"",onClick:()=>q("result"),"aria-label":"切换到展示结果",children:o.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:b,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-context-run-card__body nodrag",children:[o.jsxs(o.Fragment,{children:[o.jsx("textarea",{value:d,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{p.current=!0},onCompositionEnd:te=>{p.current=!1,f(te.currentTarget.value),Fe(te.currentTarget.value)},onChange:te=>{f(te.target.value)},onBlur:te=>Fe(te.currentTarget.value)}),o.jsxs("div",{className:"af-work-context-run-card__grid",children:[o.jsxs("div",{className:"af-work-context-run-card__skills",children:[o.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:te=>{var Ie;te.stopPropagation(),C||(Ie=t==null?void 0:t.onRefreshSkills)==null||Ie.call(t),N(Ue=>!Ue)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsx("span",{children:u.skillKeys.length?`${u.skillKeys.length} skills`:"Skills"}),o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),C?o.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:te=>te.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:j,onChange:te=>A(te.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),j?o.jsx("button",{type:"button",onClick:()=>A(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:mt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:mt.updateMenuScrollbar,children:[st.collectionGroups.map(te=>{const Ie=te.skills.map(At=>At.key),Ue=Ie.filter(At=>De.has(At)).length,Ze=Ie.length>0&&Ue===Ie.length,Mt=I.has(te.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(Mt?" 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:Ze,disabled:b,onChange:At=>Me(Ie,At.target.checked),"aria-label":`选择 ${te.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>ue(te.id),"aria-expanded":!Mt,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:te.name}),te.description?o.jsx("em",{children:te.description}):null]})}),o.jsxs("small",{children:[Ue,"/",Ie.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>ue(te.id),"aria-label":Mt?`展开 ${te.name}`:`收起 ${te.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Mt?"chevron_right":"expand_more"})})]}),Mt?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:te.skills.map(At=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:De.has(At.key),disabled:b,onChange:tr=>Me([At.key],tr.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:At.name}),At.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:At.description}):null]})]},`${te.id}:${At.key}`))})]},te.id)}),st.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:st.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:st.ungrouped.map(te=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:De.has(te.key),disabled:b,onChange:Ie=>Me([te.key],Ie.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:te.name}),te.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:te.description}):null]})]},`ungrouped:${te.key}`))})]}):null,st.collectionGroups.length===0&&st.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:()=>xe({skillKeys:[]}),children:"清空"})]}),o.jsx("div",{ref:mt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(mt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:mt.handleScrollbarPointerDown,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${mt.scrollbar.height}%`,top:`${mt.scrollbar.top}%`}})})]}):null]}),o.jsxs("div",{className:"af-work-context-run-card__workspace",children:[o.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:te=>{var Ie;te.stopPropagation(),H||(Ie=t==null?void 0:t.onRefreshWorkspaces)==null||Ie.call(t),B(Ue=>!Ue)},children:[o.jsx("span",{className:"material-symbols-outlined",children:Pe.length?"folder_open":"folder_off"}),o.jsx("span",{children:Pe.length?`${Pe.length} 知识库`:"知识库"}),o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),H?o.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:te=>te.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:z,onChange:te=>$(te.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),z?o.jsx("button",{type:"button",onClick:()=>$(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:gt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:gt.updateMenuScrollbar,children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"知识库"}),o.jsx("small",{children:kt.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:kt.map(te=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:dt.has(te.id||te.path),disabled:b,onChange:Ie=>ve(te,Ie.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:te.label}),o.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[te.kind==="git"&&te.repoUrl?`${te.repoUrl}${te.branch?` · ${te.branch}`:""}${te.mountPath?` · ${te.mountPath}`:""}`:te.path,te.exists?"":" · 路径未就绪"]})]})]},`${te.id}:${te.path}`))})]}),kt.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:Ve,children:"清空知识库"})]}),o.jsx("div",{ref:gt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(gt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:gt.handleScrollbarPointerDown,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${gt.scrollbar.height}%`,top:`${gt.scrollbar.top}%`}})})]}):null]}),o.jsxs("select",{value:u.displayType,disabled:b,onChange:te=>xe({displayType:te.target.value}),children:[o.jsx("option",{value:"markdown",children:"Markdown"}),o.jsx("option",{value:"html",children:"HTML"}),o.jsx("option",{value:"react",children:"React"}),o.jsx("option",{value:"table",children:"Table"}),o.jsx("option",{value:"chart",children:"Chart"}),o.jsx("option",{value:"ascii",children:"ASCII"}),o.jsx("option",{value:"mermaid",children:"Mermaid"})]})]}),D?o.jsx("pre",{className:"af-work-context-run-card__preview",children:D.slice(0,520)}):null]}),o.jsxs("div",{className:"af-work-context-run-card__actions",children:[o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(g?" af-work-run-card__button--stop":""),disabled:b,onClick:te=>{var Ie,Ue;te.stopPropagation(),Fe(),g?(Ie=t==null?void 0:t.onStopWorkspaceNode)==null||Ie.call(t,e):(Ue=t==null?void 0:t.onRunWorkspaceNode)==null||Ue.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:g?"stop_circle":"play_arrow"}),o.jsx("span",{children:g?"Stop":"Run"})]}),o.jsx("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__logs nodrag",onClick:te=>{var Ie;te.stopPropagation(),(Ie=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Ie.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"})},children:o.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})]})}function qG({id:e,data:t,selected:n,deleteNode:r}){var C,N,j;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=cv((t==null?void 0:t.body)||""),l=(t==null?void 0:t.scheduledRunState)||{},c=((N=(C=t==null?void 0:t.runningRunNodeIds)==null?void 0:C.has)==null?void 0:N.call(C,e))||((j=t==null?void 0:t.runningRunNodeIds)==null?void 0:j[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",u=(t==null?void 0:t.optimizingRun)===!0,d=(t==null?void 0:t.nodeStatus)==="stopped",f=!!(t!=null&&t.readOnly),p=A=>{var I;(I=t==null?void 0:t.onChangeScheduledRunConfig)==null||I.call(t,e,{...a,...A})},h=A=>{p({scheduleType:A,cron:Hu(A,a.time,a.weekday,a.monthDay,a.cron)})},g=A=>{p({time:A,cron:Hu(a.scheduleType,A,a.weekday,a.monthDay,a.cron)})},[k,b]=lv(a.time).split(":"),y=(A,I)=>{g(`${Oo(A,9,0,23)}:${Oo(I,0,0,59)}`)},v=A=>{p({weekday:A,cron:Hu(a.scheduleType,a.time,A,a.monthDay,a.cron)})},x=A=>{p({monthDay:A,cron:Hu(a.scheduleType,a.time,a.weekday,A,a.cron)})};return o.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(c?" 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":"")+(d?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((A,I)=>{if(A.showOnNode===!1)return null;const O=`${2.25+I*1.75}rem`,H=A.name||`#${I+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:O},children:H}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${I}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:O,background:In(A.type)},title:`${H} · ${A.type}`})]},`in-${I}`)}),i.map((A,I)=>{if(A.showOnNode===!1)return null;const O=`${2.25+I*1.75}rem`,H=A.name||`#${I+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:O},children:H}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${I}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:O,background:In(A.type)},title:`${H} · ${A.type}`})]},`out-${I}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:f,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-schedule-card__body nodrag",children:[o.jsxs("label",{className:"af-work-schedule-card__toggle",children:[o.jsx("input",{type:"checkbox",checked:a.enabled,disabled:f,onChange:A=>p({enabled:A.target.checked})}),o.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"频率"}),o.jsxs("select",{value:a.scheduleType,disabled:f,onChange:A=>h(A.target.value),children:[o.jsx("option",{value:"daily",children:"每天"}),o.jsx("option",{value:"weekly",children:"每周"}),o.jsx("option",{value:"monthly",children:"每月"}),o.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"时间"}),o.jsxs("div",{className:"af-work-schedule-time-selects",children:[o.jsx("select",{value:k,disabled:f,"aria-label":"小时",onChange:A=>y(A.target.value,b),children:Array.from({length:24},(A,I)=>Oo(I,0,0,23)).map(A=>o.jsxs("option",{value:A,children:[A," 时"]},A))}),o.jsx("select",{value:b,disabled:f,"aria-label":"分钟",onChange:A=>y(k,A.target.value),children:Array.from({length:12},(A,I)=>Oo(I*5,0,0,59)).map(A=>o.jsxs("option",{value:A,children:[A," 分"]},A))})]})]}):null,a.scheduleType==="weekly"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"星期"}),o.jsxs("select",{value:a.weekday,disabled:f,onChange:A=>v(A.target.value),children:[o.jsx("option",{value:1,children:"周一"}),o.jsx("option",{value:2,children:"周二"}),o.jsx("option",{value:3,children:"周三"}),o.jsx("option",{value:4,children:"周四"}),o.jsx("option",{value:5,children:"周五"}),o.jsx("option",{value:6,children:"周六"}),o.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"日期"}),o.jsx("select",{value:a.monthDay,disabled:f,onChange:A=>x(A.target.value),children:Array.from({length:31},(A,I)=>I+1).map(A=>o.jsxs("option",{value:A,children:[A," 日"]},A))})]}):null,a.scheduleType==="custom"?o.jsxs("label",{className:"af-work-schedule-card__field",children:[o.jsx("span",{children:"Cron"}),o.jsx("input",{type:"text",value:a.cron,disabled:f,spellCheck:!1,placeholder:Hd,onChange:A=>p({cron:A.target.value})})]}):null,o.jsxs("div",{className:"af-work-schedule-card__meta",children:[o.jsxs("span",{children:[fG(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),o.jsxs("span",{children:["Next ",dG(l.nextAt)]}),o.jsx("span",{children:c?"running":l.lastStatus||"idle"})]}),l.lastError?o.jsx("div",{className:"af-work-schedule-card__error",children:l.lastError}):null,o.jsxs("div",{className:"af-work-schedule-card__actions",children:[o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(c?" af-work-run-card__button--stop":""),disabled:f||u,onClick:A=>{var I,O;A.stopPropagation(),c?(I=t==null?void 0:t.onStopWorkspaceNode)==null||I.call(t,e):(O=t==null?void 0:t.onRunWorkspaceNode)==null||O.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:c?"stop_circle":"play_arrow"}),o.jsx("span",{children:c?"停止":"立即运行"})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(u?" af-work-schedule-card__optimize--running":""),disabled:f||c||u,title:"为下游节点提前生成 implementation",onClick:A=>{var I;A.stopPropagation(),(I=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||I.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:u?"sync":"auto_fix_high"}),o.jsx("span",{children:u?"优化中":"优化"})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:A=>{var I;A.stopPropagation(),(I=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||I.call(t,{nodeId:e,scheduleNodeId:e,runNodeId:l.targetRunNodeId||e,lastRunId:l.lastRunId||"",label:(t==null?void 0:t.label)||"Scheduled Run"})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"article"}),o.jsx("span",{children:"日志"})]})]})]})]})}function UG({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Oc(),i=!!(t!=null&&t.readOnly),a=sb(t==null?void 0:t.nodeSize)||{width:Xa,height:Qa},l=m.useCallback(c=>{var u,d;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(d=(u=c.target)==null?void 0:u.closest)!=null&&d.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||s(f=>UT(f,e))},[e,s]);return o.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[i?null:o.jsx(Tk,{className:"af-work-group-node__resize nodrag",minWidth:Xa,minHeight:Qa,position:"bottom-right",children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),o.jsxs("div",{className:"af-work-group-node__title nodrag",children:[o.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),o.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:i,onClick:c=>{c.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function YG(e){var g,k,b,y,v,x,C,N,j,A,I,O,H,B,z,$,M,q,D,L,T,W,E,Q,V,F,se,ce;const{setEdges:t,setNodes:n}=Oc(),r=(g=e.data)==null?void 0:g.onSyncNodePropDraft,s=!!((k=e.data)!=null&&k.readOnly),[i,a]=m.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=m.useCallback(J=>{var re,Z,le;if(s)return;(Z=(re=e.data)==null?void 0:re.onCleanupWorkspaceNodeOutputs)==null||Z.call(re,J,e.data);const ne=ei((le=e.data)==null?void 0:le.definitionId)?QT(J):"",ee=new Set([J,ne].filter(Boolean));n(de=>de.filter(we=>!ee.has(we.id))),t(de=>de.filter(we=>!ee.has(we.source)&&!ee.has(we.target)))},[e.data,s,t,n]),u=m.useCallback(J=>{var ne,ee;J.button!==0||J.metaKey||J.ctrlKey||J.shiftKey||(ee=(ne=J.target)==null?void 0:ne.closest)!=null&&ee.call(ne,".react-flow__handle, .af-work-display-resize")||(n(re=>UT(re,e.id)),t(re=>QG(re)))},[e.id,t,n]),d=m.useCallback((J,ne)=>{s||(n(ee=>ee.map(re=>re.id===J?{...re,data:{...re.data,model:ne}}:re)),r==null||r(J,{model:ne}))},[s,n,r]),f=m.useCallback((J,ne)=>{s||(n(ee=>ee.map(re=>{var le;if(re.id!==J)return re;const Z=Array.isArray((le=re.data)==null?void 0:le.outputs)&&re.data.outputs.length?re.data.outputs.map((de,we)=>we===0?{...de,default:ne,value:ne}:de):[{type:"bool",name:"value",default:ne,value:ne}];return{...re,data:{...re.data,body:"",outputs:Z}}})),r==null||r(J,ee=>({body:"",outputs:Array.isArray(ee==null?void 0:ee.outputs)&&ee.outputs.length?ee.outputs.map((Z,le)=>le===0?{...Z,default:ne,value:ne}:Z):[{type:"bool",name:"value",default:ne,value:ne}]})))},[s,n,r]),p=m.useCallback((J,ne)=>{s||(n(ee=>ee.map(re=>re.id===J?{...re,data:{...re.data,body:ne}}:re)),r==null||r(J,{body:ne}))},[s,n,r]),h=m.useCallback((J,ne)=>{if(s)return;const ee=fo(ne);n(re=>re.map(Z=>Z.id===J?{...Z,data:{...Z.data,images:ee}}:Z)),r==null||r(J,{images:ee})},[s,n,r]);return(y=e.data)!=null&&y.isWorkspaceGroup?o.jsx(UG,{...e,deleteNode:c}):el((v=e.data)==null?void 0:v.definitionId)?o.jsx(VT,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?o.jsx(VG,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((C=e.data)==null?void 0:C.definitionId)==="workspace_scheduled_run"?o.jsx(qG,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):ei((N=e.data)==null?void 0:N.definitionId)?o.jsx(KG,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(j=e.data)==null?void 0:j.skills,skillCollections:(A=e.data)==null?void 0:A.skillCollections,workspaces:(I=e.data)==null?void 0:I.workspaceTargets}):((O=e.data)==null?void 0:O.definitionId)==="control_load_skills"?o.jsx(hJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(H=e.data)==null?void 0:H.skills,skillCollections:(B=e.data)==null?void 0:B.skillCollections,onChangeSkillKeys:(z=e.data)==null?void 0:z.onChangeLoadSkillKeys}):(($=e.data)==null?void 0:$.definitionId)==="control_load_mcp"?o.jsx(mJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:(M=e.data)==null?void 0:M.mcpServers,onChangeMcpNames:(q=e.data)==null?void 0:q.onChangeLoadMcpNames}):((D=e.data)==null?void 0:D.definitionId)==="control_cd_workspace"?o.jsx(gJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(L=e.data)==null?void 0:L.workspaceTargets,onChangeWorkspace:(T=e.data)==null?void 0:T.onChangeLoadWorkspace,onRefreshWorkspaces:(W=e.data)==null?void 0:W.onRefreshWorkspaces}):o.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(i?" af-work-flow-node--resizing":"")+((E=e.data)!=null&&E.isExecuting||((Q=e.data)==null?void 0:Q.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((V=e.data)==null?void 0:V.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((F=e.data)==null?void 0:F.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((se=e.data)==null?void 0:se.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[s?null:o.jsx(Tk,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:bT,minHeight:rm,maxWidth:kT,maxHeight:vT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),o.jsx(Bq,{...e,deleteNode:c,modelLists:(ce=e.data)==null?void 0:ce.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:p,onNodeImagesChange:h})]})}const GG={[fc]:m.memo(YG)};function uv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&uv(n.children,t);return t}function KT(e,t){const n=String(t||"");if(!n)return null;for(const r of e||[]){if(r.path===n)return r;const s=Array.isArray(r.children)?KT(r.children,n):null;if(s)return s}return null}function JG(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function qT(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&qT(n.children,t));return t}function Rp(e){const t=String(e||"").replace(/\\/g,"/").split("/").filter(Boolean),n=[];for(let r=1;r<t.length;r++)n.push(t.slice(0,r).join("/"));return n}function XG(e,t){const n=String(t||"");let r=!1;const s=(e||[]).map(i=>{const a=i.id===n;return i.selected===a?i:(r=!0,{...i,selected:a})});return r?s:e}function UT(e,t){const n=String(t||""),r=(e||[]).find(i=>i.id===n),s=(e||[]).reduce((i,a)=>i+(a.selected?1:0),0);return r!=null&&r.selected&&s>1?e:XG(e,n)}function QG(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function ZG(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function eJ(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(i,a,l)=>{const c=r[a],u=l?`${l}/${c}`:c,d=a===r.length-1;let f=!1;const p=(Array.isArray(i)?i:[]).map(h=>h.name!==c?h:(f=!0,d?{...h,type:"file",name:c,path:u,icon:ec(c),size:n}:{...h,type:"directory",name:c,path:u,icon:ec(c,!0),children:s(h.children||[],a+1,u)}));return f||p.push(d?{type:"file",name:c,path:u,icon:ec(c),size:n}:{type:"directory",name:c,path:u,icon:ec(c,!0),children:s([],a+1,u)}),ZG(p)};return s(e||[],0,"")}function tJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"":t<1024?`${t} B`:t<1024*1024?`${Math.round(t/102.4)/10} KB`:`${Math.round(t/1024/102.4)/10} MB`}function YT({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:i,onFileDragStart:a,onDelete:l,onDownload:c}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const d=u.type==="directory",f=d&&(r==null?void 0:r.has(u.path)),p=n===u.path;return 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--"+u.type+(p?" af-work-file--selected":""),draggable:!d,onDragStart:g=>{d||a==null||a(g,u)},onClick:()=>{i==null||i(u),d&&(s==null||s(u.path))},onDoubleClick:()=>{d||t(u)},title:u.path,children:[d?o.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:f?"chevron_right":"expand_more"}):null,o.jsx("span",{className:"material-symbols-outlined",children:u.icon||ec(u.name,d)}),o.jsx("span",{children:u.name})]}),p?o.jsxs("div",{className:"af-work-file-actions",children:[d?null:o.jsx("button",{type:"button",className:"af-work-file-action",onClick:g=>{g.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),o.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:g=>{g.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),d&&!f&&((h=u.children)!=null&&h.length)?o.jsx(YT,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:i,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function nJ({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:i}){const a=m.useMemo(()=>uv(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(u=>l?`${u.path} ${u.name}`.toLowerCase().includes(l):!0);return o.jsx("div",{className:"af-flow-snippet-modal-overlay",onMouseDown:i,children:o.jsxs("div",{className:"af-flow-snippet-modal af-work-file-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择文件",onMouseDown:u=>u.stopPropagation(),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",children:"folder_open"}),"选择文件"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:i,"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("div",{className:"af-work-file-picker-modal__tools",children:[o.jsx("input",{value:t,onChange:u=>n(u.target.value),placeholder:"搜索文件路径...",autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>s==null?void 0:s(""),children:[o.jsx("span",{className:"material-symbols-outlined",children:"upload_file"}),"上传"]})]}),o.jsxs("div",{className:"af-work-file-picker-modal__list",children:[c.map(u=>o.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(u),children:[o.jsx("span",{className:"material-symbols-outlined",children:u.icon||ec(u.name)}),o.jsxs("span",{className:"af-work-file-picker-modal__main",children:[o.jsx("strong",{children:u.name}),o.jsx("small",{children:u.path})]}),u.size?o.jsx("em",{children:tJ(u.size)}):null]},u.path)),c.length===0?o.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function MC({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 GT(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function rJ(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(i=>!GT(i));if(r.length>0)return r;const s=[...n].reverse().find(i=>(i==null?void 0:i.kind)==="result"||(i==null?void 0:i.kind)==="assistant"||(i==null?void 0:i.error));return s?[s]:n.length>0||t?[{role:"assistant",kind:"assistant",text:t?"正在执行,可以在完成后继续追问或要求调整。":"运行已完成。可以在下方继续追问、要求总结或调整结果。",at:0}]:[]}function sJ(e){return(Array.isArray(e)?e:[]).filter(GT)}function Kd(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 iJ(e){const t=Kd((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 Kd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function oJ(e){const n=[...Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],...Array.isArray(e==null?void 0:e.outputs)?e.outputs:[]].find(r=>(r==null?void 0:r.name)==="skillKeys"||(r==null?void 0:r.name)==="skillsContext");return Kd((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function JT(e,t,n=1){const r=(Array.isArray(e)?e:[]).map(i=>String(i||"").trim()).filter(Boolean);return r.length?{head:r.slice(0,n).join("、"),extra:r.length>n?`等 ${r.length} 个`:"",title:r.join(", ")}:{head:t,extra:"",title:""}}function $C(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function ea(e,t,n=""){const r=(Array.isArray(e)?e:[]).find(i=>(i==null?void 0:i.name)===t);return String((r==null?void 0:r.value)??(r==null?void 0:r.default)??"").trim()||n}function dm(e,t){const n=ea(e,t,"");if(!n)return null;try{const r=JSON.parse(n);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function ff(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function vs(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function XT(e){const t=ff(e);return t==="html"?"display_html":t==="react"?"display_react_app":t==="table"?"display_table":t==="chart"?"display_chart":t==="ascii"?"display_ascii":t==="mermaid"?"display_mermaid":"display_markdown"}function QT(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function ZT(e){return e==="display_image"?"src":"content"}function LC(e,t,n){const r=ZT(t),s=Wu(e);let i=!1;const a=s.map(l=>(l==null?void 0:l.name)===r?(i=!0,{...l,default:n,value:n,showOnNode:l.showOnNode!==!1}):(l==null?void 0:l.name)==="filePath"?{...l,default:"",value:""}:l);return i||a.push({type:"text",name:r,default:n,value:n,required:!0,showOnNode:!0}),a}function OC(e,t,n=[],r=[]){const s=Array.isArray(e)?e:[],i=new Set((Array.isArray(n)?n:[]).map(u=>String(u||"").trim()).filter(Boolean)),a=new Set((Array.isArray(r)?r:[]).map(u=>String(u||"").trim()).filter(Boolean)),l=u=>(u==null?void 0:u.showOnNode)!==!1;let c=s.findIndex(u=>l(u)&&i.has(String((u==null?void 0:u.name)||"").trim()));return c<0&&(c=s.findIndex(u=>i.has(String((u==null?void 0:u.name)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u)&&a.has(String((u==null?void 0:u.type)||"").trim()))),c<0&&(c=s.findIndex(u=>l(u))),c<0&&(c=0),`${t}-${c}`}function DC(e){return(Array.isArray(e)?e:[]).map(t=>(t==null?void 0:t.type)==="node"||(t==null?void 0:t.name)==="next"?t:{...t,default:"",value:""})}function rg(e){const t=Array.isArray(e==null?void 0:e.outputs)?e.outputs:Array.isArray(e==null?void 0:e.output)?e.output:[],n=s=>String((s==null?void 0:s.value)??(s==null?void 0:s.default)??"").trim(),r=t.find(s=>((s==null?void 0:s.name)==="content"||(s==null?void 0:s.name)==="result")&&n(s))||t.find(s=>(s==null?void 0:s.name)==="resultFile"&&n(s))||t.find(s=>(s==null?void 0:s.type)!=="node"&&(s==null?void 0:s.name)!=="next"&&(s==null?void 0:s.name)!=="displayType"&&n(s));return r?n(r):""}function aJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=ea(t,"includeWorkspaceContext","true").toLowerCase(),r=dm(t,"knowledgeContext"),s=dm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:oJ(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?sg([s]):null),workspaceContext:s,displayType:ff(ea(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function ei(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function lJ(e){const t=Kd((e==null?void 0:e.body)||"");if(t.length>0)return t;const r=(Array.isArray(e==null?void 0:e.inputs)?e.inputs:[]).find(s=>(s==null?void 0:s.name)==="mcpContext"||(s==null?void 0:s.name)==="serverNames"||(s==null?void 0:s.type)==="text");return Kd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function cJ(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function eM(e={},t="context"){const n=String((e==null?void 0:e.cwd)||(e==null?void 0:e.workspaceRoot)||(e==null?void 0:e.path)||"").trim(),r=String((e==null?void 0:e.id)||"").trim(),s=String((e==null?void 0:e.label)||(e==null?void 0:e.name)||"").trim();if(!n&&!r&&!s)return null;const i=String(s||r||"知识库").trim();return{id:r,label:i,kind:(e==null?void 0:e.kind)==="git"?"git":"local",type:String((e==null?void 0:e.type)||""),repoPath:n,path:n,mountPath:String((e==null?void 0:e.mountPath)||r||i).trim(),repoUrl:String((e==null?void 0:e.repoUrl)||"").trim(),branch:String((e==null?void 0:e.branch)||"").trim(),readonly:!0,role:t}}function sg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>eM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function tM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>eM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function uJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=dm(t,"knowledgeContext"),r=dm(t,"workspaceContext");return{sources:tM(n||(r?sg([r]):null)),path:ea(t,"path",""),label:ea(t,"label","")}}function FC(e){var r,s,i,a,l,c,u,d,f;if(!e)return null;const{inputs:t,outputs:n}=eU(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((s=e.data)==null?void 0:s.role)??"normal"),model:String(((i=e.data)==null?void 0:i.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:fo((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((u=e.data)==null?void 0:u.scriptRef)??""),implementationRef:String(((d=e.data)==null?void 0:d.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function zC(e,t,n,r=""){var c,u;const s=String(n||"").trim(),i=(Array.isArray(e)?e:[]).find(d=>String((d==null?void 0:d.id)||"")===s),a=String(((c=i==null?void 0:i.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[s])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function BC(e){return(Array.isArray(e)?e:[]).map(t=>({type:String((t==null?void 0:t.type)??"node").trim()||"node",name:String((t==null?void 0:t.name)??""),default:String((t==null?void 0:t.default)??""),required:!!(t!=null&&t.required),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)??"node").trim().toLowerCase()==="node"}))}function dJ(e,t,n){var d,f;const r=String(((d=e==null?void 0:e.data)==null?void 0:d.definitionId)??n),s=r.startsWith("provide_"),i=String((t==null?void 0:t.role)||"").trim(),a=Fd.includes(i)?i:"normal",l=String((t==null?void 0:t.model)||"").trim(),c={...e.data,label:String((t==null?void 0:t.label)||"").trim()||n,role:a,model:l===""||l==="default"?void 0:l,body:s?"":String((t==null?void 0:t.body)??""),images:s?[]:fo(t==null?void 0:t.images),inputs:BC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:BC(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const p of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[p])??"").trim();h?c[p]=h:delete c[p]}return c}function HC({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:i=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),c=i?l:a;if(i){if(!SU.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(k=>k.id===c&&k.id!==a))return{ok:!1,error:"Duplicate instance id"}}const u=dJ(r,s,c),d=r.data||{};if(!(c!==a||d.label!==u.label||d.role!==u.role||d.model!==u.model||d.body!==u.body||JSON.stringify(fo(d.images))!==JSON.stringify(u.images)||(d.script??void 0)!==(u.script??void 0)||(d.scriptRef??void 0)!==(u.scriptRef??void 0)||(d.implementationRef??void 0)!==(u.implementationRef??void 0)||(d.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(d.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(d.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const p=e.map(k=>k.id===a?{...k,id:c,selected:!0,data:u}:k);let h=t,g=n;if(c!==a){g={...n||{}};const k={...g[a]||{}};delete g[a],g[c]=k,h=t.map((b,y)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${y}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:h,instances:g}}function fJ(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function pJ(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","scriptRef","implementationRef","implementationMode","inputs","outputs"])fJ(e[s],t[s])&&(r[s]=n[s]);return r}function lb(e,t=[]){const n=m.useRef(null),r=m.useRef(null),[s,i]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,g=h?Math.max(12,p/f*100):100,k=Math.max(0,100-g),b=h?Math.min(k,d.scrollTop/Math.max(1,f-p)*k):0;i({visible:h,top:b,height:g})},[]);m.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)},[e,a,...t]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),g=s.height/100*h.height,k=Math.max(1,h.height-g);return(d-h.top-f)/k},[s.height]),u=m.useCallback(d=>{var C,N;if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,g=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+g?d.clientY-p.top-h:g/2;l(c(d.clientY,b));const y=d.pointerId;(N=(C=d.currentTarget).setPointerCapture)==null||N.call(C,y);const v=j=>{j.preventDefault(),l(c(j.clientY,b))},x=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,s.height,s.top,s.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:s,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function hJ({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:[],u=Array.isArray(s)?s:[],d=Array.isArray(i)?i:[],[f,p]=m.useState(!1),[h,g]=m.useState(""),[k,b]=m.useState(()=>new Set),y=m.useRef(null),v=m.useRef(null),[x,C]=m.useState({visible:!1,top:0,height:100}),N=m.useMemo(()=>new Set(iJ(t)),[t]),j=m.useMemo(()=>new Map(u.map(L=>[L.key,L])),[u]),A=m.useMemo(()=>Array.from(N).map(L=>{var T;return((T=j.get(L))==null?void 0:T.name)||L}),[j,N]),I=m.useMemo(()=>JT(A,"选择 Skills"),[A]),O=m.useMemo(()=>{const L=new Set,T=d.map(E=>{const Q=Xo(E,u).map(V=>j.get(V)).filter(Boolean);for(const V of Q)L.add(V.key);return{...E,skills:Q}}).filter(E=>E.skills.length>0),W=u.filter(E=>!L.has(E.key));return{collectionGroups:T,ungrouped:W}},[j,d,u]);m.useEffect(()=>{b(L=>{let T=!1;const W=new Set(L);for(const E of O.collectionGroups)W.has(E.id)||(W.add(E.id),T=!0);return T?W:L})},[O.collectionGroups]);const H=m.useMemo(()=>{const L=h.trim().toLowerCase();if(!L)return O;const T=E=>[E==null?void 0:E.key,E==null?void 0:E.name,E==null?void 0:E.description].map(V=>String(V||"").toLowerCase()).join(" ").includes(L);return{collectionGroups:O.collectionGroups.map(E=>{const V=[E==null?void 0:E.id,E==null?void 0:E.name,E==null?void 0:E.description].map(F=>String(F||"").toLowerCase()).join(" ").includes(L)?E.skills:E.skills.filter(T);return{...E,skills:V}}).filter(E=>E.skills.length>0),ungrouped:O.ungrouped.filter(T)}},[O,h]),B=m.useCallback((L,T)=>{const W=new Set(N);for(const E of L)T?W.add(E):W.delete(E);a==null||a(e,Array.from(W))},[e,N,a]),z=m.useCallback(L=>{b(T=>{const W=new Set(T);return W.has(L)?W.delete(L):W.add(L),W})},[]),$=m.useCallback(()=>{const L=y.current;if(!L)return;const T=Math.max(1,L.scrollHeight),W=Math.max(1,L.clientHeight),E=T>W+1,Q=E?Math.max(12,W/T*100):100,V=Math.max(0,100-Q),F=E?Math.min(V,L.scrollTop/Math.max(1,T-W)*V):0;C({visible:E,top:F,height:Q})},[]);m.useEffect(()=>{if(!f)return;const L=requestAnimationFrame($);return()=>cancelAnimationFrame(L)},[k,H,N.size,f,$]);const M=m.useCallback(L=>{const T=y.current;if(!T)return;const W=Math.max(0,T.scrollHeight-T.clientHeight);T.scrollTop=Math.min(1,Math.max(0,L))*W,$()},[$]),q=m.useCallback((L,T=0)=>{const W=v.current;if(!W)return 0;const E=W.getBoundingClientRect(),Q=x.height/100*E.height,V=Math.max(1,E.height-Q);return(L-E.top-T)/V},[x.height]),D=m.useCallback(L=>{var ne,ee;if(!x.visible)return;L.preventDefault(),L.stopPropagation();const T=v.current;if(!T)return;const W=T.getBoundingClientRect(),E=x.top/100*W.height,Q=x.height/100*W.height,F=L.clientY>=W.top+E&&L.clientY<=W.top+E+Q?L.clientY-W.top-E:Q/2;M(q(L.clientY,F));const se=L.pointerId;(ee=(ne=L.currentTarget).setPointerCapture)==null||ee.call(ne,se);const ce=re=>{re.preventDefault(),M(q(re.clientY,F))},J=()=>{window.removeEventListener("pointermove",ce),window.removeEventListener("pointerup",J),window.removeEventListener("pointercancel",J)};window.addEventListener("pointermove",ce),window.addEventListener("pointerup",J),window.addEventListener("pointercancel",J)},[q,M,x.height,x.top,x.visible]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(f?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((L,T)=>{if(L.showOnNode===!1)return null;const W=`${2.6+T*1.7}rem`,E=L.name||`#${T+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:W},children:E}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${T}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:W,background:In(L.type)},title:`${E} · ${L.type}`})]},`in-${T}`)}),c.map((L,T)=>{if(L.showOnNode===!1)return null;const W=`${2.6+T*1.7}rem`,E=L.name||`#${T+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:W},children:E}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${T}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:W,background:In(L.type)},title:`${E} · ${L.type}`})]},`out-${T}`)}),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:L=>{var T;L.stopPropagation(),f||(T=t==null?void 0:t.onRefreshSkills)==null||T.call(t),p(W=>!W)},children:[o.jsxs("span",{className:"af-work-load-skills-card__summary",title:I.title,children:[o.jsx("span",{className:"af-work-load-skills-card__summary-main",children:I.head}),I.extra?o.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:I.extra}):null]}),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:L=>L.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:L=>g(L.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:$,children:[H.collectionGroups.map(L=>{const T=L.skills.map(V=>V.key),W=T.filter(V=>N.has(V)).length,E=T.length>0&&W===T.length,Q=k.has(L.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(Q?" 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:E,onChange:V=>B(T,V.target.checked),"aria-label":`选择 ${L.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>z(L.id),"aria-expanded":!Q,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:L.name}),L.description?o.jsx("em",{children:L.description}):null]})}),o.jsxs("small",{children:[W,"/",T.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>z(L.id),"aria-label":Q?`展开 ${L.name}`:`收起 ${L.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Q?"chevron_right":"expand_more"})})]}),Q?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:L.skills.map(V=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:N.has(V.key),onChange:F=>B([V.key],F.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:V.name}),V.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:V.description}):null]})]},`${L.id}:${V.key}`))})]},L.id)}),H.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:H.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:H.ungrouped.map(L=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:N.has(L.key),onChange:T=>B([L.key],T.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:L.name}),L.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:L.description}):null]})]},`ungrouped:${L.key}`))})]}):null,H.collectionGroups.length===0&&H.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"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:D,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function mJ({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:i}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,u]=m.useState(!1),[d,f]=m.useState(""),p=m.useMemo(()=>new Set(lJ(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(b=>({name:String((b==null?void 0:b.name)||""),description:String((b==null?void 0:b.description)||""),detail:String((b==null?void 0:b.url)||[b==null?void 0:b.command,...Array.isArray(b==null?void 0:b.args)?b.args:[]].filter(Boolean).join(" ")||""),type:String((b==null?void 0:b.type)||"")})).filter(b=>b.name),[s]),g=m.useMemo(()=>{const b=d.trim().toLowerCase();return b?h.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(b)):h},[d,h]),k=m.useCallback((b,y)=>{const v=new Set(p);for(const x of b)y?v.add(x):v.delete(x);i==null||i(e,Array.from(v))},[e,p,i]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(c?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((b,y)=>{if(b.showOnNode===!1)return null;const v=`${2.6+y*1.7}rem`,x=b.name||`#${y+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:x}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:In(b.type)},title:`${x} · ${b.type}`})]},`in-${y}`)}),l.map((b,y)=>{if(b.showOnNode===!1)return null;const v=`${2.6+y*1.7}rem`,x=b.name||`#${y+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:x}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:In(b.type)},title:`${x} · ${b.type}`})]},`out-${y}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"hub"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:b=>{var y;b.stopPropagation(),c||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),u(v=>!v)},children:[o.jsx("span",{children:p.size>0?`${p.size} MCP selected`:"选择 MCP"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:b=>b.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:d,onChange:b=>f(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),d?o.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{className:"af-work-load-skills-menu",children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"MCP Servers"}),o.jsx("small",{children:g.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(b=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:p.has(b.name),onChange:y=>k([b.name],y.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:b.name}),b.description||b.detail?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:b.description||b.detail}):null]})]},b.name))})]}),g.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>i==null?void 0:i(e,[]),children:"清空"})]})]}):null]})]})}function gJ({id:e,data:t,selected:n,deleteNode:r,workspaces:s=[],onChangeWorkspace:i,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,d]=m.useState(!1),[f,p]=m.useState(""),h=uJ(t),g=m.useMemo(()=>(Array.isArray(s)?s:[]).map(N=>({id:String((N==null?void 0:N.id)||""),label:String((N==null?void 0:N.label)||(N==null?void 0:N.name)||"知识库"),kind:(N==null?void 0:N.kind)==="git"?"git":"local",path:String((N==null?void 0:N.path)||""),repoUrl:String((N==null?void 0:N.repoUrl)||""),branch:String((N==null?void 0:N.branch)||""),mountPath:String((N==null?void 0:N.mountPath)||""),builtin:(N==null?void 0:N.builtin)===!0,exists:(N==null?void 0:N.exists)!==!1})).filter(N=>N.path),[s]),k=m.useMemo(()=>{const N=f.trim().toLowerCase();return N?g.filter(j=>[j.id,j.label,j.path,j.repoUrl,j.branch,j.mountPath].join(" ").toLowerCase().includes(N)):g},[f,g]),b=m.useMemo(()=>new Set((h.sources||[]).map(N=>N.id||N.path||N.repoPath).filter(Boolean)),[h.sources]),y=m.useMemo(()=>(h.sources||[]).map(N=>N.label||N.id||N.mountPath||N.path),[h.sources]),v=m.useMemo(()=>JT(y,"选择知识库"),[y]),x=lb(u,[k.length,y.length,f]),C=(N,j)=>{const A=(N==null?void 0:N.id)||(N==null?void 0:N.path)||"",I=g.filter(O=>{const H=O.id||O.path||"";return H===A?j:b.has(H)});i==null||i(e,I)};return o.jsxs("div",{className:"af-work-load-skills-card af-work-load-workspace-card"+(n?" af-work-load-skills-card--selected":"")+(u?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((N,j)=>{if(N.showOnNode===!1)return null;const A=`${2.6+j*1.7}rem`,I=N.name||`#${j+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:A},children:I}),o.jsx(Yn,{type:"target",position:Ke.Left,id:`input-${j}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:A,background:In(N.type)},title:`${I} · ${N.type}`})]},`in-${j}`)}),c.map((N,j)=>{if(N.showOnNode===!1)return null;const A=`${2.6+j*1.7}rem`,I=N.name||`#${j+1}`;return o.jsxs(m.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:A},children:I}),o.jsx(Yn,{type:"source",position:Ke.Right,id:`output-${j}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:A,background:In(N.type)},title:`${I} · ${N.type}`})]},`out-${j}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"加载知识库"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),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:N=>{N.stopPropagation(),u||a==null||a(),d(j=>!j)},children:[o.jsxs("span",{className:"af-work-load-skills-card__summary",title:v.title,children:[o.jsx("span",{className:"af-work-load-skills-card__summary-main",children:v.head}),v.extra?o.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:v.extra}):null]}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:N=>N.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:f,onChange:N=>p(N.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),f?o.jsx("button",{type:"button",onClick:()=>p(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:x.menuRef,className:"af-work-load-skills-menu",onScroll:x.updateMenuScrollbar,children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"知识库"}),o.jsx("small",{children:k.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:k.map(N=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:b.has(N.id||N.path),onChange:j=>C(N,j.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:N.label}),o.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[N.kind==="git"&&N.repoUrl?`${N.repoUrl}${N.branch?` · ${N.branch}`:""}${N.mountPath?` · ${N.mountPath}`:""}`:N.path,N.exists?"":" · 路径未就绪"]})]})]},`${N.id}:${N.path}`))})]}),k.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>i==null?void 0:i(e,[]),children:"清空知识库"})]}),o.jsx("div",{ref:x.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(x.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:x.handleScrollbarPointerDown,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${x.scrollbar.height}%`,top:`${x.scrollbar.top}%`}})})]}):null]})]})}function nM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=hT(r),i=MU(HY(r)),a=s?i.filter(p=>!["issue","mr"].includes(em(p))):i,l=LU(r,i),c=Ci(r,t),u=s?"":Ra(r.platform),d=Array.isArray(e==null?void 0:e.children)?e.children.length:0,f=[c,s&&d?`${d} 个端侧 Issue`:u,r.status].filter(Boolean);return o.jsxs("div",{className:`af-prd-workflow-issue${n?" af-prd-workflow-issue--child":""}${s?" af-prd-workflow-issue--aggregate":""}`,children:[o.jsx("strong",{children:FY(r,t)}),o.jsx("small",{children:f.join(" · ")}),o.jsxs("div",{className:"af-prd-workflow-issue__state-row",children:[o.jsx("span",{className:`af-prd-workflow-issue__state af-prd-workflow-issue__state--${l.kind}`,children:l.label}),l.detail?o.jsx("small",{children:l.detail}):null]}),a.length?o.jsx("div",{className:"af-prd-workflow-issue__links",children:a.map(p=>o.jsx("a",{href:p.href,target:"_blank",rel:"noreferrer",children:p.label},`${p.label}-${p.href}`))}):null,d?o.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((p,h)=>o.jsx(nM,{row:p,index:h,child:!0},Ci((p==null?void 0:p.issue)||{},h)))}):null]})}function rM(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e).trim():typeof e!="object"||Array.isArray(e)?"":String(e.label||e.name||e.value||e.key||e.code||e.username||e.userId||"").trim()}function sM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>rM(n)).filter(Boolean)}function yJ({fieldKey:e,field:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=String(t.label||e||"").trim(),r=String(t.type||"text").trim().toLowerCase(),s=["text","user","chips","list","link"].includes(r)?r:"text",i=sM(t.value);if(!i.length)return null;if(s==="list")return o.jsxs("div",{className:"af-prd-overall-platform__rules",children:[o.jsx("small",{children:n}),o.jsx("ul",{children:i.map((a,l)=>o.jsx("li",{children:a},`${e}-${l}-${a}`))})]});if(s==="link"){const a=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},l=String(t.href||t.url||a.href||a.url||"").trim();return o.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[o.jsx("small",{children:n}),l?o.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[o.jsx("span",{children:i[0]}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):o.jsx("strong",{children:i[0]})]})}return o.jsxs("div",{className:`af-prd-overall-platform__row af-prd-overall-platform__row--${s}`,children:[o.jsx("small",{children:n}),o.jsx("div",{children:i.map((a,l)=>o.jsx("span",{children:a},`${e}-${l}-${a}`))})]})}function wJ({sectionKey:e,section:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=(t.fields&&typeof t.fields=="object"&&!Array.isArray(t.fields)?Object.entries(t.fields):[]).filter(([,s])=>s&&typeof s=="object"&&sM(s.value).length);return r.length?o.jsxs("section",{className:"af-prd-overall-platform",children:[o.jsx("div",{className:"af-prd-overall-platform__head",children:o.jsx("strong",{children:String(t.title||e||"").trim()})}),r.map(([s,i])=>o.jsx(yJ,{fieldKey:s,field:i},s))]}):null}function xJ({globalState:e,tapdId:t}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=n.workflow&&typeof n.workflow=="object"&&!Array.isArray(n.workflow)?n.workflow:{},s=n.sections&&typeof n.sections=="object"&&!Array.isArray(n.sections)?n.sections:{},i=String(n.title||"").trim(),a=String(n.url||"").trim(),l=rM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(s).filter(([f,p])=>f&&p&&typeof p=="object"&&!Array.isArray(p)),d=!!(i||a||l||u.length);return!c&&!d?null:o.jsxs("article",{className:"af-prd-workflow-card af-prd-overall",children:[o.jsxs("div",{className:"af-prd-workflow-card__head",children:[o.jsx("h2",{children:"需求概览"}),l?o.jsx("span",{className:"af-prd-overall__status",children:l}):null]}),i||a||c?o.jsx("div",{className:"af-prd-overall__requirement",children:a?o.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",children:[o.jsx("strong",{children:i||`${r.namespace||"Workflow"} ${c}`}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):o.jsx("strong",{children:i||`${r.namespace==="tapd"?"TAPD":"Workflow"} ${c}`})}):null,d?o.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([f,p])=>o.jsx(wJ,{sectionKey:f,section:p},f))}):o.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function bJ({flowParams:e={},tapdId:t,setTapdId:n,snapshot:r,loading:s,error:i,actionRunning:a,actionOutput:l,pendingConfirm:c,conflict:u,reviewPublishing:d,onRefresh:f,onRunDryRun:p,onConfirmAction:h,onRetryConflict:g,onPublishReview:k}){const[b,y]=m.useState("all"),[v,x]=m.useState("all"),[C,N]=m.useState(!1),[j,A]=m.useState(!1),[I,O]=m.useState(!1),[H,B]=m.useState(""),[z,$]=m.useState(!1),[M,q]=m.useState(""),[D,L]=m.useState(null),T=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),W=Array.isArray(r==null?void 0:r.issues)?r.issues:[],E=WY(r),Q=E.reduce((xe,Fe)=>xe+Qx(Fe.issues),0),V=Array.isArray(r==null?void 0:r.artifacts)?r.artifacts:[];Array.isArray(r==null?void 0:r.optionalGaps)&&r.optionalGaps;const F=r!=null&&r.nextAction&&typeof r.nextAction=="object"?r.nextAction:null,se=UY(r,F),ce=OY(r,se),J=V.filter(xe=>!mT({...xe,href:pc(xe)})),ne=m.useMemo(()=>MY(se),[se]);m.useEffect(()=>{v!=="all"&&(ne.some(xe=>xe.key===v)||x("all"))},[v,ne]);const ee=se.filter(xe=>$Y(xe,v)),re=RY(ee),Z=YY(r),le=Z.filter(xe=>GY(xe,b)),de=ee.filter(xe=>sv(xe)).length,we=r!=null&&r.collaboration&&typeof r.collaboration=="object"?r.collaboration:{},De=we.activeAction&&typeof we.activeAction=="object"?we.activeAction:null;Array.isArray(r==null?void 0:r.clientObservations)&&r.clientObservations;const Qe=String((r==null?void 0:r.rawOutput)||""),Oe=r!=null&&r.globalState&&typeof r.globalState=="object"?r.globalState:null,st=NY(T),mt=m.useCallback(async()=>{const xe=String(t||"").trim();if(!xe){L(null);return}A(!0),B(""),q("");try{const Fe=new URLSearchParams({tapdId:xe});e.workflowShare&&Fe.set("workflowShare",e.workflowShare);const Me=await fetch(`/api/prd-workflow/share?${Fe.toString()}`),ue=await Me.json().catch(()=>({}));if(!Me.ok)throw new Error(ue.error||"读取 Workflow 分享状态失败");let ve=ue.share||null;const Ve=ue.canCreate===!0&&!e.workflowShare;if($(Ve),!ve&&Ve){const qe=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:xe})}),be=await qe.json().catch(()=>({}));if(!qe.ok)throw new Error(be.error||"生成 Workflow 分享链接失败");ve=be.share||null}L(ve)}catch(Fe){B(String(Fe.message||Fe))}finally{A(!1)}},[e,t]),kt=()=>{N(!0),mt()},Pe=async()=>{if(!(!t||I||e.workflowShare)){O(!0),B(""),q("");try{const xe=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),Fe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Fe.error||"生成 Workflow 分享链接失败");L(Fe.share||null),$(!0)}catch(xe){B(String(xe.message||xe))}finally{O(!1)}}},dt=async()=>{const xe=await ob((D==null?void 0:D.url)||"");q(xe?"已复制":"复制失败")},gt=async()=>{if(!(!t||I||!(D!=null&&D.canManage))){O(!0),B(""),q("");try{const xe=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),Fe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Fe.error||"取消 Workflow 分享链接失败");L(null),$(!0)}catch(xe){B(String(xe.message||xe))}finally{O(!1)}}};return o.jsxs("main",{className:"af-prd-workflow af-prd-workflow--timeline","aria-label":"PRD Workflow",children:[o.jsxs("section",{className:"af-prd-workflow__statusbar",children:[o.jsxs("div",{className:"af-prd-workflow__status-main",children:[o.jsx("span",{className:`af-prd-workflow-phase af-prd-workflow-phase--${T.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:yC(T)}),o.jsx("h1",{children:(r==null?void 0:r.pointer)||(t?"等待 prd-flow 返回状态":"选择 TAPD 需求后读取状态")}),o.jsx("p",{className:"af-prd-workflow__status-subtitle",children:t?o.jsxs(o.Fragment,{children:["TAPD ",o.jsx("strong",{children:t})," · 独立需求 Workflow"]}):o.jsx(o.Fragment,{children:"尚未选择 TAPD 需求"})}),i?o.jsx("p",{className:"af-prd-workflow-error",children:i}):null,De||we.subscribers?o.jsxs("div",{className:"af-prd-workflow-collab",children:[De?o.jsxs("span",{children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),De.title||De.action||"Workflow action"," 执行中",De.userId?o.jsx("small",{children:De.userId}):null]}):null,we.subscribers?o.jsxs("span",{children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),we.subscribers," 个连接"]}):null]}):null]}),o.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:xe=>{xe.preventDefault(),f==null||f()},children:[o.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:st.map(xe=>o.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${xe.status}`,children:[o.jsx("span",{"aria-hidden":"true"}),o.jsx("small",{children:xe.label})]},xe.label))}),o.jsxs("div",{className:"af-prd-workflow__lookup-row",children:[o.jsxs("label",{children:[o.jsx("span",{children:"TAPD Workflow"}),o.jsx("input",{value:t,onChange:xe=>n(xe.target.value),placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),o.jsxs("button",{type:"submit",disabled:s,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"hourglass_empty":"sync"}),s?"读取中":t?"刷新":"读取"]}),o.jsxs("button",{type:"button",disabled:!t,onClick:kt,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"share"}),"分享"]})]})]})]}),u?o.jsxs("section",{className:"af-prd-workflow-conflict","aria-label":"Workflow conflict",children:[o.jsxs("div",{children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"sync_problem"}),o.jsxs("div",{children:[o.jsx("strong",{children:"状态已变化,需要重新确认"}),o.jsx("p",{children:u.message||"当前 workflow 状态和执行前不一致。"})]})]}),o.jsxs("dl",{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"执行时 revision"}),o.jsx("dd",{children:u.expectedRevision||"空"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"当前 revision"}),o.jsx("dd",{children:u.currentRevision||"未知"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"当前状态"}),o.jsx("dd",{children:[yC(u.currentPhase),u.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),o.jsx("div",{className:"af-prd-workflow-conflict__actions",children:o.jsx("button",{type:"button",onClick:()=>f==null?void 0:f(),disabled:s||a,children:"刷新状态"})})]}):null,o.jsxs("section",{className:"af-prd-workflow__main",children:[o.jsxs("article",{className:"af-prd-workflow-actions","aria-label":"Workflow actions",children:[o.jsxs("div",{className:"af-prd-workflow-actions__head",children:[o.jsxs("div",{children:[o.jsx("h2",{children:"Action 时间线"}),o.jsx("p",{children:se.length?`${de}/${ee.length} 已完成${v!=="all"?` · 共 ${se.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),F&&Vd(F)?o.jsxs("div",{className:"af-prd-workflow-local-command",children:[o.jsx("span",{children:"本地 agent 执行"}),o.jsx("code",{children:F.command||eo(F,0)})]}):null]}),ne.length?o.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[o.jsxs("button",{type:"button",className:v==="all"?"is-active":"","aria-pressed":v==="all",onClick:()=>x("all"),children:["全部 ",o.jsx("span",{children:se.length})]}),ne.map(xe=>o.jsxs("button",{type:"button",className:v===xe.key?"is-active":"","aria-pressed":v===xe.key,onClick:()=>x(xe.key),children:[xe.label," ",o.jsx("span",{children:xe.count})]},xe.key))]}):null,o.jsx("div",{className:"af-prd-workflow-action-list",children:ee.length?re.map(xe=>o.jsxs("section",{className:"af-prd-workflow-action-day",children:[o.jsxs("div",{className:"af-prd-workflow-action-day__label",children:[o.jsx("span",{children:xe.day}),o.jsx("small",{children:"北京时间"})]}),o.jsx("div",{className:"af-prd-workflow-action-day__items",children:xe.items.map(({item:Fe,index:Me})=>{const ue=la(Fe.status),ve=Qo(Fe)==="observation"&&ue==="done"?"observed":ue,Ve=ov(Fe),qe=IY(Fe),be=LY(Fe),Tt=CY(Fe,Me),ln=_Y(Fe);return o.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${ve}`,children:[o.jsx("div",{className:"af-prd-workflow-action__rail",children:o.jsx("span",{className:"af-prd-workflow-action__dot"})}),o.jsxs("div",{className:"af-prd-workflow-action__body",children:[o.jsxs("div",{className:"af-prd-workflow-action__top",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-prd-workflow-action__title",children:[qe?o.jsx("time",{dateTime:im(Fe),children:qe}):null,o.jsx("strong",{children:Tt})]}),ln?o.jsx("p",{children:ln}):null,be.length?o.jsx("div",{className:"af-prd-workflow-action__meta",children:be.map(_t=>o.jsxs("span",{children:[o.jsx("b",{children:_t.label}),_t.value]},`${_t.label}-${_t.value}`))}):null]}),o.jsx("span",{className:"af-prd-workflow-action__status",children:TY(Fe)})]}),Ve.length?o.jsx("div",{className:"af-prd-workflow-action__links",children:Ve.map(_t=>o.jsxs("a",{href:_t.href,target:"_blank",rel:"noreferrer",children:[o.jsx("span",{children:_t.label}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${_t.label}-${_t.href}`))}):null]})]},Fe.id||Fe.actionId||`${eo(Fe,Me)}-${Me}`)})})]},xe.day)):o.jsxs("div",{className:"af-prd-workflow-action-empty",children:[o.jsx("strong",{children:t?se.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),o.jsx("p",{children:t?se.length?"切换到其它 tag 或查看全部。":"Workflow tab 不会生成默认步骤;需要 prd-flow snapshot 返回 actions/timeline/events/history 或 nextAction。":"选择后从 prd-flow 读取真实 action、产物和 URL。"})]})})]}),o.jsxs("aside",{className:"af-prd-workflow-side","aria-label":"Workflow related links",children:[o.jsx(xJ,{globalState:Oe,tapdId:t}),J.length?o.jsxs("article",{className:"af-prd-workflow-card",children:[o.jsxs("div",{className:"af-prd-workflow-card__head",children:[o.jsx("h2",{children:"关联产物"}),o.jsx("span",{children:J.length})]}),o.jsx("div",{className:"af-prd-workflow-list",children:J.map((xe,Fe)=>{const Me=pc(xe),ue=String(xe.label||xe.title||xe.kind||Me||`Artifact ${Fe+1}`);return Me?o.jsxs("a",{href:Me,target:"_blank",rel:"noreferrer",children:[o.jsx("span",{children:ue}),o.jsx("small",{children:xe.kind||Me})]},`${Me}-${Fe}`):o.jsxs("div",{children:[o.jsx("span",{children:ue}),o.jsx("small",{children:xe.kind||""})]},`${ue}-${Fe}`)})})]}):null,o.jsxs("article",{className:"af-prd-workflow-card",children:[o.jsxs("div",{className:"af-prd-workflow-card__head",children:[o.jsx("h2",{children:"AI Docs"}),o.jsx("span",{children:ce.length})]}),o.jsx("div",{className:"af-prd-workflow-list",children:ce.length?ce.map(xe=>{const Fe=String(xe.title||xe.label||"ai-doc").trim(),Me=[xe.label&&xe.label!==Fe?xe.label:"",xe.platform,xe.issueKey].filter(Boolean);return o.jsxs("a",{className:"af-prd-ai-doc",href:xe.href,target:"_blank",rel:"noreferrer",title:Fe,children:[o.jsx("span",{className:"af-prd-ai-doc__title",children:Fe}),o.jsx("small",{className:"af-prd-ai-doc__meta",children:Me.join(" · ")||xe.kind||"ai-doc"})]},xe.href)}):o.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 ai-doc 文档。"})})]}),o.jsxs("article",{className:"af-prd-workflow-card",children:[o.jsxs("div",{className:"af-prd-workflow-card__head",children:[o.jsx("h2",{children:"Issues"}),o.jsx("span",{children:Q||W.length})]}),o.jsx("div",{className:"af-prd-workflow-issues",children:E.length?E.map(xe=>o.jsxs("div",{className:"af-prd-workflow-epic",children:[o.jsxs("div",{className:"af-prd-workflow-epic__head",children:[o.jsx("strong",{children:xe.title||xe.key}),o.jsx("small",{children:Qx(xe.issues)})]}),xe.issues.map((Fe,Me)=>o.jsx(nM,{row:Fe,index:Me},Ci((Fe==null?void 0:Fe.issue)||{},Me)))]},xe.key)):o.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 Issue 信息。"})})]}),o.jsxs("article",{className:"af-prd-workflow-card",children:[o.jsxs("div",{className:"af-prd-workflow-card__head",children:[o.jsx("h2",{children:"运行审计"}),o.jsxs("span",{children:[le.length,"/",Z.length]})]}),o.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([xe,Fe])=>o.jsx("button",{type:"button",className:b===xe?"is-active":"",onClick:()=>y(xe),children:Fe},xe))}),o.jsx("div",{className:"af-prd-workflow-audit",children:le.length?le.map((xe,Fe)=>o.jsxs("div",{children:[o.jsx("strong",{children:eo(xe,Fe)}),o.jsx("small",{children:[xe.status,xe.type,im(xe)].filter(Boolean).join(" · ")})]},xe.id||`${xe.type}-${Fe}`)):o.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),Qe||l?o.jsxs("article",{className:"af-prd-workflow-card af-prd-workflow-card--raw",children:[o.jsx("div",{className:"af-prd-workflow-card__head",children:o.jsx("h2",{children:"Raw"})}),o.jsx("pre",{children:l||Qe})]}):null]})]}),C?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"分享需求 Workflow",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:"share"}),"分享需求 Workflow"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>N(!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("p",{className:"af-display-link-modal__empty",children:["通过只读链接分享 TAPD ",t," 的需求流程;不会分享当前 Project、画布或项目文件。"]}),j?o.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!j&&(D!=null&&D.url)?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-display-link-modal__url",children:[o.jsx("input",{type:"text",value:D.url,readOnly:!0,onFocus:xe=>xe.currentTarget.select(),"aria-label":"Workflow 分享链接"}),o.jsxs("button",{type:"button",disabled:I,onClick:()=>void dt(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),M||"复制链接"]}),D.canManage?o.jsx("button",{type:"button",disabled:I,onClick:()=>void gt(),children:I?"处理中...":"取消分享"}):null]}),o.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的 AgentFlow 用户可以只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!j&&!(D!=null&&D.url)&&z?o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:I,onClick:()=>void Pe(),children:I?"生成中...":"生成分享链接"}):null,H?o.jsx("div",{className:"af-flow-snippet-error",children:H}):null]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>N(!1),children:"完成"})})]})}),document.body):null]})}function WC(e,t){if(!(e!=null&&e[`has${t[0].toUpperCase()}${t.slice(1)}`]))return"(删除该字段)";const n=e==null?void 0:e[t];if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return String(n)}}function Au(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function kJ(e,t,n,r=!0){const s=JSON.parse(JSON.stringify(e||{})),i=Array.isArray(t)?t:[];if(!i.length)return r?n:{};let a=s;for(let c=0;c<i.length-1;c+=1){const u=i[c],d=i[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(d)?[]:{}),a=a[u]}const l=i[i.length-1];return r?a[l]=n:Array.isArray(a)&&Number.isInteger(l)?a.splice(l,1):delete a[l],s}function vJ(){var h0,m0,g0;const{t:e,i18n:t}=Dr(),{navigate:n}=si(),r=Oc(),s=kW(),i=m.useMemo(dY,[]),a=m.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),l=m.useMemo(()=>i.workspaceId?`agentflow.workspace.viewport:shared:${i.workspaceId}`:`agentflow.workspace.viewport:${i.flowSource||"user"}:${i.flowId||""}`,[i]),[c,u]=m.useState(()=>(()=>{const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,k]=vW([]),[b,y]=SW([]),v=m.useRef([]),x=m.useRef([]),C=m.useRef(null),[N,j]=m.useState(()=>ch(null,[])),A=m.useRef(N),[I,O]=m.useState(null),H=m.useRef(null),B=m.useRef(!1),[z,$]=m.useState([]),M=m.useRef(new Map),q=m.useRef(new Map),D=m.useRef(new Set),L=m.useRef(new Set),T=m.useRef(null),W=m.useRef(null),E=m.useRef([]),Q=m.useRef([]),V=m.useRef(null),F=m.useRef(null),se=m.useRef(null),ce=m.useRef(null),[J,ne]=m.useState(null),[ee,re]=m.useState({}),Z=m.useRef({}),le=m.useRef(!1),de=m.useRef(null),we=m.useRef(""),De=m.useRef(null),Qe=m.useRef(Promise.resolve()),Oe=m.useRef({running:!1,pending:null}),st=m.useRef(0),mt=m.useRef(!1),kt=m.useRef(0),Pe=m.useRef(null),dt=m.useRef(!1),gt=m.useRef(!1),xe=m.useRef(""),Fe=m.useRef(!1),Me=m.useRef(!1),ue=m.useRef(!1),ve=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),Ve=m.useRef(!1),qe=m.useRef(null),[be,Tt]=m.useState([]),ln=m.useRef([]),[_t,hn]=m.useState(""),[tn,te]=m.useState("nodes"),[Ie,Ue]=m.useState([]),[Ze,Mt]=m.useState(!1),[At,tr]=m.useState(""),[kn,nr]=m.useState(!1),[vn,Jn]=m.useState({name:"",id:"",description:""}),[Wn,ur]=m.useState(!1),[gs,wr]=m.useState(""),[Rs,Fr]=m.useState(""),on=m.useRef(null),[xr,br]=m.useState(!1),[mn,Vn]=m.useState(!1),[kr,dr]=m.useState(""),[vt,Ut]=m.useState(null),[ae,ke]=m.useState(()=>nw()),[it,bt]=m.useState(""),[cn,On]=m.useState(!1),[nn,vr]=m.useState(""),[ft,Yt]=m.useState(!1),[Gt,Sr]=m.useState([]),[tt,Xn]=m.useState(!1),[Mi,zr]=m.useState(""),[ho,ai]=m.useState(""),[Ts,ie]=m.useState(""),[Se,Ee]=m.useState(!1),[wt,Ot]=m.useState(""),[Vt,Dn]=m.useState(""),[Mn,K]=m.useState(!1),[pe,$e]=m.useState("nodes"),[Ce,et]=m.useState(""),[Sn,St]=m.useState(0),[Kt,Nn]=m.useState(""),mo=m.useRef(""),[ot,ys]=m.useState(null),jv=m.useRef(null),[XM,ol]=m.useState(""),[al,Cv]=m.useState([]),[_v,QM]=m.useState(""),[je,ZM]=m.useState(!0),[rn,dg]=m.useState(null),[e$,fg]=m.useState(!1),[pg,Ev]=m.useState(!1),[Av,qc]=m.useState(""),[Uc,Pv]=m.useState(""),[Iv,Rv]=m.useState(""),[_n,ll]=m.useState(null),[t$,ca]=m.useState(!1),[hg,cl]=m.useState({}),[wf,Tv]=m.useState(!1),[Mv,Yc]=m.useState(""),[mg,n$]=m.useState(""),[r$,ul]=m.useState(()=>new Set),[gg,yg]=m.useState(""),[Gc,wg]=m.useState({nodeId:"",query:""}),[$v,Lv]=m.useState(!1),Ov=m.useRef(null),Dv=m.useRef(null),Fv=m.useRef(""),[xg,s$]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[i$,zv]=m.useState(!1),[ua,o$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[$i,a$]=m.useState(""),[Ms,l$]=m.useState([]),[Bv,Hv]=m.useState(!1),[$s,Jc]=m.useState([]),[dl,c$]=m.useState([]),[Wv,u$]=m.useState(!1),[Vv,Kv]=m.useState([]),[qv,Uv]=m.useState([]),[fr,d$]=m.useState(()=>{try{const w=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return w||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${i.flowSource||"user"}:${i.flowId||""}`)||"").trim()}catch{return""}}),[sn,xf]=m.useState(null),[f$,Yv]=m.useState(!1),[p$,fl]=m.useState(""),[bg,Gv]=m.useState(!1),[kg,bf]=m.useState(""),[ws,kf]=m.useState(null),[vg,Jv]=m.useState(!1),[Xc,Qc]=m.useState(null),Xv=m.useCallback(w=>{on.current&&window.clearTimeout(on.current),Fr(w),on.current=window.setTimeout(()=>{Fr(""),on.current=null},3800)},[]),Br=m.useCallback(w=>{const S=Array.isArray(w)||w instanceof Set?w:[w];for(const _ of S){const P=String(_||"").trim();P&&(D.current.add(P),L.current.add(P))}D.current.size!==0&&(T.current==null&&(T.current=window.requestAnimationFrame(()=>{T.current=null;const _=Array.from(D.current);D.current.clear(),_.forEach(P=>s(P))})),W.current!=null&&window.clearTimeout(W.current),W.current=window.setTimeout(()=>{W.current=null;const _=Array.from(L.current);L.current.clear(),_.forEach(P=>s(P))},80))},[s]);m.useEffect(()=>()=>{T.current!=null&&window.cancelAnimationFrame(T.current),W.current!=null&&window.clearTimeout(W.current),D.current.clear(),L.current.clear()},[]);const Qv=m.useCallback((w,S)=>{const _=String(w||"").trim(),P=um(S);!_||!P||(k(R=>R.map(U=>{var oe;if(U.id!==_)return U;const X=um((oe=U.data)==null?void 0:oe.displaySize),G=X&&X.width===P.width&&X.height===P.height,Y=Math.round(Number(U.width||0))===P.width&&Math.round(Number(U.height||0))===P.height;return G&&Y?U:{...U,width:P.width,height:P.height,data:{...U.data,nodeSize:P,displaySize:P}}})),Br(_))},[Br,k]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(xg)))}catch{}},[xg]);const Sg=m.useCallback(w=>{const S=Ov.current;if(!S)return;const _=S.getBoundingClientRect(),P=16,R=150,U=230,X=_.top+P,G=_.bottom-P,Y=Math.max(R,G-X-U),oe=Math.min(Math.max(w-X,R),Y);s$(oe)},[]),h$=m.useCallback(w=>{w.preventDefault(),w.stopPropagation(),zv(!0),Sg(w.clientY);const S=P=>{P.preventDefault(),Sg(P.clientY)},_=()=>{zv(!1),window.removeEventListener("pointermove",S,!0),window.removeEventListener("pointerup",_,!0),window.removeEventListener("pointercancel",_,!0)};window.addEventListener("pointermove",S,!0),window.addEventListener("pointerup",_,!0),window.addEventListener("pointercancel",_,!0)},[Sg]);m.useEffect(()=>()=>{on.current&&window.clearTimeout(on.current),qe.current&&window.clearTimeout(qe.current)},[]);const[m$,Zv]=m.useState(()=>new Set),[vf,Ng]=m.useState(!1),jg=m.useRef(null),eS=m.useRef(null),tS=m.useRef(null),[g$,y$]=m.useState({}),[da,Cg]=m.useState(""),[ts,nS]=m.useState(!1),[fa,pl]=m.useState([]),[Ls,Kn]=m.useState([]),[Hr,xs]=m.useState("workspace"),[Zc,hl]=m.useState(!1),rS=m.useRef(null),_g=m.useRef(null),[eu,ml]=m.useState(null),[w$,Eg]=m.useState(!0),[sS,iS]=m.useState(""),[pa,go]=m.useState({}),[Ir,oS]=m.useState(null),[aS,lS]=m.useState(!1),gl=m.useMemo(()=>aS?gY(Ir):"",[aS,Ir]),[tu,Sf]=m.useState(!0);m.useEffect(()=>{gl&&Sf(yY(gl))},[gl]),m.useEffect(()=>{if(gl)try{window.localStorage.setItem(gl,tu?"true":"false")}catch{}},[tu,gl]);const[Ag,Nf]=m.useState(!1),[Pg,cS]=m.useState(!1),[Ig,uS]=m.useState("pan"),[dS,x$]=m.useState({}),nu=m.useRef({}),[fS,ha]=m.useState({}),ru=m.useRef(new Map),su=m.useRef(new Set),[pS,yl]=m.useState(()=>new Set),[Rg,wl]=m.useState({}),[hS,mS]=m.useState(""),[Jle,me]=m.useState(""),[gS,Os]=m.useState("loading"),[yS,Ds]=m.useState("正在载入 Project"),Li=m.useMemo(()=>mY(i),[i]),[wS,xS]=m.useState(""),iu=i.flowSource||"user",bS=m.useMemo(()=>new Set(Object.values(dS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[dS]),Oi=m.useCallback(w=>{const S=nu.current||{},_=typeof w=="function"?w(S):w,P=_&&typeof _=="object"&&!Array.isArray(_)?_:{};return nu.current=P,x$(P),P},[]),kS=!!(i.flowId&&!i.archived&&(rn!=null&&rn.role?rn.role==="owner":iu==="user"||iu==="workspace")),ou=!!(iu==="workspace"&&(rn!=null&&rn.role)&&rn.role!=="owner"),vS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[gS]||"同步状态",ns=m.useCallback(()=>{!le.current||!je||(Fe.current=!1,st.current+=1,mt.current=!0,Os("dirty"),Ds("本地修改等待同步"))},[je]);m.useEffect(()=>{i.flowId&&iF(i.flowId,i.flowSource||"user","workspace",!!i.archived)},[i]),m.useEffect(()=>{const w=()=>{u(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{pl([]),Kn([]),xs("workspace"),Eg(!0)},[i]);const En=m.useCallback(async()=>{const w=Tr(i),S=await fetch(`/api/workspace/files?${w.toString()}`),_=await S.json();if(!S.ok)throw new Error(_.error||"读取 workspace 失败");const P=_.files||[];Cv(P),ul(new Set(qT(P))),QM(_.root||"")},[i]),jf=m.useCallback(async()=>{Mt(!0),tr("");try{const w=await fetch("/api/marketplace/flow-snippets"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取流程片段失败");Ue(Array.isArray(S.snippets)?S.snippets:[])}catch(w){tr(String(w.message||w)),Ue([])}finally{Mt(!1)}},[]),SS=m.useCallback(async(w,S,_)=>{var Y,oe,he;if(!le.current)return;if(!je)throw me("Readonly workspace"),Os("readonly"),Ds("只读 Project"),new Error("Readonly workspace");Os("saving"),Ds("正在同步修改");const P=Tl(w,S,Z.current);P.ui={...P.ui||{},displayPage:_C(A.current,w)};const R=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:P,baseRevision:we.current,baseGraph:De.current,clientId:ve.current})}),U=await R.json().catch(()=>({}));if(!R.ok){if(R.status===409||R.status===428){const Ne=Array.isArray(U.conflictItems)?U.conflictItems:[];ll({currentRevision:String(U.currentRevision||""),message:U.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(U.conflictPaths)?U.conflictPaths:[],conflictItems:Ne,mergeGraph:U.mergeGraph||null,currentGraph:U.currentGraph||null}),cl(Object.fromEntries(Ne.map((Be,Re)=>[String(Re),{mode:"local",manual:Au(Be)}]))),Yc(""),ca(Ne.length>0),Os("conflict"),Ds(U.error||"存在需要处理的字段冲突");const He=Array.isArray(U.conflictPaths)?U.conflictPaths:[],ze=He.length?`${U.error||"Workspace 已被其他成员更新"}:${He.join("、")}`:U.error||"Workspace 已被其他成员更新",We=new Error(ze);throw We.code="WORKSPACE_REVISION_CONFLICT",We.currentRevision=U.currentRevision||"",We}const fe=new Error(U.error||"保存 workspace graph 失败");throw Os("error"),Ds(fe.message),fe}const X=st.current!==_,G=UU({savedGraph:U.graph,sentGraph:P,savedRevision:U.revision,currentRevision:we.current});if(we.current=G.revision,De.current=G.graph,!X){if(Z.current=((Y=U.graph)==null?void 0:Y.instances)||P.instances,re(Z.current),U.merged&&U.graph){const fe=Eu(U.graph,be),Ne=ch((he=(oe=U.graph)==null?void 0:oe.ui)==null?void 0:he.displayPage,fe.nodes);Z.current=fe.instances,re(fe.instances),k(fe.nodes),y(fe.edges),A.current=Ne,j(Ne)}mt.current=!1}return ha(Pp(U.workspaceSchedules||[])),ll(null),ca(!1),Os(X?"dirty":"synced"),Ds(X?"本地仍有修改等待同步":"所有修改已同步"),me(X?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[i,be,y,k,je]),Xt=m.useCallback((w=g,S=b)=>{const _=Oe.current,P={nextNodes:w,nextEdges:S,saveEditVersion:st.current,waiters:[]},R=new Promise((G,Y)=>{P.waiters.push({resolve:G,reject:Y})});if(_.running)return _.pending=pC(_.pending,P),R;_.running=!0;const U=async()=>{let G=P;for(;G;){_.pending&&(G=pC(G,_.pending),_.pending=null);try{const Y=await SS(G.nextNodes,G.nextEdges,G.saveEditVersion);G.waiters.forEach(({resolve:oe})=>oe(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Os("error"),Ds(String(Y.message||Y))),G.waiters.forEach(({reject:oe})=>oe(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&_.pending&&(_.pending.waiters.forEach(({reject:oe})=>oe(Y)),_.pending=null)}G=_.pending,_.pending=null}_.running=!1},X=Qe.current.catch(()=>{}).then(U);return Qe.current=X,R},[b,g,SS]),b$=m.useCallback(w=>{var _;const S=(_=w==null?void 0:w.extra)!=null&&_.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};Z.current=S,re(S),k(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),y(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),Nn(""),ne(null)},[y,k]),k$=m.useMemo(()=>({instances:ee}),[ee]),v$=PU({nodes:g,edges:b,extra:k$,enabled:le.current,onRestore:b$}),{resetHistory:au,undo:NS,redo:jS}=v$,bs=m.useCallback(async(w={})=>{var Te,$t;const S=(w==null?void 0:w.background)===!0,_=kt.current+1;kt.current=_;const P=st.current,R=we.current;S||(le.current=!1);const U=QU({background:S}),X=Tr(i);let G=null,Y;if(!U.nodes&&!U.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const Le=Tr(i);Le.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[ct,Pt]=await Promise.all([fetch(`/api/nodes?${Le.toString()}`),fetch(`/api/workspace/graph?${X.toString()}`),En()]);if(G=await ct.json(),!ct.ok)throw new Error(G.error||"读取节点定义失败");Y=Pt}const oe=await Y.json();if(!Y.ok)throw new Error(oe.error||"读取 workspace graph 失败");const he=qU({background:S,requestId:_,currentRequestId:kt.current,dirty:mt.current,startedEditVersion:P,currentEditVersion:st.current,startedRevision:R,currentRevision:we.current});if(he==="superseded")return{skipped:!0,reason:he};if(he==="local-edits")return me("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:he};const fe=S?ln.current:[...(Array.isArray(G)?G:G.nodes||[]).filter(Le=>!tY.has(Le.id)),aY,oY,sY,iY,nY,rY];S||(ln.current=fe,Tt(fe));const Ne=oe.graph||JSON.parse(localStorage.getItem(eY)||"null")||{},He=Eu(Ne,fe),ze=ch((Te=Ne==null?void 0:Ne.ui)==null?void 0:Te.displayPage,He.nodes),We=!B.current;let Be=H.current;if(We){let Le=null;try{Le=JSON.parse(window.localStorage.getItem(l)||"null")}catch{Le=null}Be=ib(Le)||ib(($t=Ne==null?void 0:Ne.ui)==null?void 0:$t.viewport)}const Re=S?HU(De.current,Ne):null;if(S&&(Re!=null&&Re.safe)){const Le=Re.nodesChanged?WU(v.current,He.nodes,Re.changedNodeIds):v.current,ct=Re.edgesChanged?VU(x.current,He.edges):x.current,Pt=Re.displayPageChanged||!Zi(A.current,ze),Cl=Re.nodesChanged||Re.edgesChanged||Pt;if(Cl&&(Fe.current=!0),Re.nodesChanged){const li=KU(Z.current,He.instances,Re.changedNodeIds);Z.current=li,v.current=Le,re(li),k(Le)}if(Re.edgesChanged&&(x.current=ct,y(ct)),Pt&&(A.current=ze,j(ze)),Cl&&au(Le,ct,{instances:Re.nodesChanged?Z.current:He.instances}),Re.nodesChanged||Pt){const li=new Set(ze.nodeIds);$(ya=>{const wa=ya.filter(Bf=>li.has(Bf));return wa.length===ya.length?ya:wa})}}else Z.current=He.instances,v.current=He.nodes,x.current=He.edges,A.current=ze,Fe.current=!0,re(He.instances),k(He.nodes),y(He.edges),j(ze),$([]),au(He.nodes,He.edges,{instances:He.instances});const Ft=Pp(oe.workspaceSchedules||[]);ha(Le=>Zi(Le,Ft)?Le:Ft),we.current=String(oe.revision||""),De.current=Ne,mt.current=!1;const rt=oe.collaboration||null;dg(Le=>Zi(Le,rt)?Le:rt),ll(null),We&&(O(Be),H.current=Be,B.current=!0);const Ye=oe.writable!==!1;return ZM(Ye),me(Ye?"Workspace ready":"Readonly workspace"),Os(Ye?"synced":"readonly"),Ds(Ye?"所有修改已同步":"只读 Project"),le.current=!0,{skipped:!1}},[i,t.language,En,au,y,k,l]),Tg=m.useCallback((w={})=>{if(!le.current)return;const S=String(w.revision||""),_=w.type==="graph.committed",P=!!(Pe.current||dt.current||gt.current);if(ZU({eventType:w.type,revision:S,currentRevision:we.current,targetRevision:xe.current,refreshPending:P}))return;if(_&&S&&(xe.current=S),mt.current){gt.current=!1,me("检测到其他成员的更新;保存时将自动合并");return}if(gt.current=!0,Pe.current||dt.current)return;const R=async()=>{if(Pe.current=null,mt.current){gt.current=!1,me("检测到其他成员的更新;保存时将自动合并");return}gt.current=!1,dt.current=!0;try{await bs({background:!0}),xe.current=we.current}catch(U){xe.current="",me(String(U.message||U))}finally{dt.current=!1,gt.current&&!mt.current&&(Pe.current=window.setTimeout(R,40))}};Pe.current=window.setTimeout(R,40)},[bs]),Cf=m.useCallback(async(w=fr)=>{const S=String(w||"").trim();Yv(!0),fl("");try{const _=Tr(i);_.set("tapdId",S),_.set("runtimeOnly","1");const P=await fetch(`/api/prd-workflow/snapshot?${_.toString()}`),R=await P.json().catch(()=>({}));if(!P.ok)throw new Error(R.error||"读取 PRD Workflow 失败");xf(R.snapshot||null),bf(""),kf(null),Qc(null);try{const U=`agentflow.workflow.tapdId:${i.flowSource||"user"}:${i.flowId||""}`;S?window.localStorage.setItem(U,S):window.localStorage.removeItem(U)}catch{}}catch(_){fl(String(_.message||_))}finally{Yv(!1)}},[i,fr]),xl=m.useCallback(async(w=null,S={})=>{const _=w&&typeof w=="object"?w:sn==null?void 0:sn.nextAction,P=Vd(_);if(!P||bg)return;const R=(S==null?void 0:S.confirm)===!0,U=String((S==null?void 0:S.expectedRevision)||(sn==null?void 0:sn.revision)||"");Gv(!0),fl(""),R||(bf(""),kf(null),Qc(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,tapdId:fr,action:P,stage:Za(_),title:eo(_,0),...DY(_),dryRun:!R,confirm:R,issueKey:_.issueKey||_.issue_key||"",expectedRevision:U,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),G=await X.json().catch(()=>({}));if(!X.ok||G.ok===!1)throw G.snapshot&&xf(G.snapshot),G.conflict&&Qc({...G.conflict,action:_}),new Error(G.error||"执行 PRD Workflow action 失败");bf(G.rawOutput||(G.output?JSON.stringify(G.output,null,2):"")),xf(G.snapshot||sn),Qc(null),kf(R?null:{action:_,output:G.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(X){fl(String(X.message||X))}finally{Gv(!1)}},[i,bg,sn,fr]),S$=m.useCallback((w=null)=>xl(w,{confirm:!1}),[xl]),N$=m.useCallback(()=>{const w=(ws==null?void 0:ws.action)||(sn==null?void 0:sn.nextAction);return xl(w,{confirm:!0,expectedRevision:(ws==null?void 0:ws.expectedRevision)||""})},[xl,ws,sn]),j$=m.useCallback(()=>{const w=(Xc==null?void 0:Xc.action)||(sn==null?void 0:sn.nextAction);return Qc(null),xl(w,{confirm:!1})},[xl,Xc,sn]),C$=m.useCallback(async()=>{var U;const w=String(kg||(sn==null?void 0:sn.rawOutput)||"").trim();if(!w||vg)return;const S=(ws==null?void 0:ws.action)||(sn==null?void 0:sn.nextAction)||{},_=`Review: ${eo(S,0)||(sn==null?void 0:sn.pointer)||fr||"PRD Workflow"}`,P=/^[\[{]/.test(w),R=w.startsWith("#")?w:`# ${_}
246
-
247
- ${P?`\`\`\`json
248
- ${w}
249
- \`\`\``:w}`;Jv(!0),fl("");try{const X=await fetch("/api/prd-workflow/review-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,tapdId:fr,title:_,markdown:R,action:Vd(S),stage:Za(S),issueKey:S.issueKey||S.issue_key||"",artifactLabel:"临时 Review"})}),G=await X.json().catch(()=>({}));if(!X.ok||G.ok===!1)throw new Error(G.error||"生成 Review 链接失败");xf(G.snapshot||sn);const Y=((U=G.review)==null?void 0:U.url)||"";Y&&bf(oe=>`${oe||w}
250
-
251
- Review link: ${Y}`)}catch(X){fl(String(X.message||X))}finally{Jv(!1)}},[i,kg,ws,vg,sn,fr]),_$=m.useCallback(async(w,S)=>{const _={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:S,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",scriptRef:(w==null?void 0:w.scriptRef)||"",implementationRef:(w==null?void 0:w.implementationRef)||"",implementationMode:(w==null?void 0:w.implementationMode)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:i.flowId,flowSource:i.flowSource||"user",archived:!!i.archived},P=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),R=await P.json().catch(()=>({}));if(!P.ok||(R==null?void 0:R.ok)===!1)throw new Error((R==null?void 0:R.error)||"Publish failed");return await bs(),me(`Published node ${R.definitionId||R.id||_.packageId}`),R},[i,bs]),ma=m.useCallback((w=Ls)=>{const S=Array.isArray(w)?w:[],P=[...S].reverse().find(R=>(R==null?void 0:R.status)==="running"||(R==null?void 0:R.status)==="stopping")||[...S].reverse().find(R=>R==null?void 0:R.id);return String((P==null?void 0:P.id)||"workspace")},[Ls]),E$=m.useCallback(w=>{const S=String(w||"").trim();!S||S==="workspace"||Kn(_=>{const P=(Array.isArray(_)?_:[]).filter(R=>R.id!==S);return xs(R=>R===S?ma(P):R),P})},[ma]);m.useCallback((w="")=>{hl(!0),ml(null),ys(null),xs(w||ma())},[ma]);const CS=m.useCallback((w={})=>{ml({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),hl(!1),ys(null),Nn("")},[]),Mg=m.useCallback(async(w="")=>{const S=String(w||"").trim();if(!(!S||!je)){mS(S),me(`Optimizing run: ${S}`);try{await Xt(v.current,x.current);const _=Tl(v.current,x.current,Z.current),P=zC(v.current,Z.current,S,$i),R=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,runNodeId:S,graph:_,model:P})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"优化失败");const X=U.graph||_,G=Eu(X,be);Z.current=G.instances,re(G.instances),k(G.nodes),y(G.edges),ha(Pp(U.workspaceSchedules||[])),au(G.nodes,G.edges,{instances:G.instances});const Y=Array.isArray(U.optimized)?U.optimized.length:0;me(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(_){me(String(_.message||_))}finally{mS("")}}},[$i,x,i,v,be,au,Xt,y,k,je]),_S=m.useCallback(async(w="")=>{const S=String(w||"").trim(),_=nu.current||{},P=Object.entries(_).find(([Y,oe])=>Y===S||String((oe==null?void 0:oe.runNodeId)||"")===S)||Object.entries(_)[0]||null,R=(P==null?void 0:P[0])||"",U=(P==null?void 0:P[1])||null,X=String((U==null?void 0:U.runNodeId)||S||"").trim();if((U==null?void 0:U.status)==="stopping")return;const G=new Set([X,...Array.isArray(U==null?void 0:U.plannedNodeIds)?U.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));R&&Oi(Y=>{const oe={...Y};return oe[R]&&(oe[R]={...oe[R],status:"stopping"}),oe}),me(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Kn(Y=>Y.map(oe=>(R?oe.id===R:!X||oe.runNodeId===X)&&oe.status==="running"?{...oe,status:"stopping"}:oe));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,runId:R,runNodeId:X})}),oe=await Y.json().catch(()=>({}));if(!Y.ok||(oe==null?void 0:oe.stopped)!==!0)throw new Error(oe.error||"Workspace run stop failed");const he=R?ru.current.get(R):null;he&&(he.abort(),ru.current.delete(R)),R&&Oi(fe=>{const Ne={...fe};return delete Ne[R],Ne}),yl(fe=>{const Ne=new Set(fe);for(const He of G)Ne.delete(He);return Ne}),wl(fe=>{var He;const Ne={...fe};for(const ze of G)ze&&(!Ne[ze]||((He=Ne[ze])==null?void 0:He.status)==="running")&&(Ne[ze]={status:"stopped"});return Ne}),me(X?`Workspace run stopped: ${X}`:"Workspace run stopped"),Kn(fe=>fe.map(Ne=>(R?Ne.id===R:!X||Ne.runNodeId===X)?{...Ne,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(Ne.messages)?Ne.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:Ne))}catch(Y){R&&Oi(he=>{const fe={...he};return fe[R]&&(fe[R]={...fe[R],status:"running"}),fe});const oe=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");me(`停止失败:${oe}`),Kn(he=>he.map(fe=>(R?fe.id===R:!X||fe.runNodeId===X)?{...fe,status:"running",messages:[...Array.isArray(fe.messages)?fe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${oe}`,at:Date.now()}].slice(-160)}:fe))}},[i,Oi]),_f=m.useCallback(async()=>{if(i.flowId)try{const w=Tr(i),S=await fetch(`/api/workspace/run/status?${w.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok||!_.running)return;const P=Array.isArray(_.runs)&&_.runs.length?_.runs:[{runId:`run-restored-${_.startedAt||Date.now()}`,runNodeId:_.runNodeId||"",startedAt:_.startedAt||Date.now(),plannedNodeIds:[]}],R={},U=[];for(const X of P){const G=String((X==null?void 0:X.runNodeId)||"").trim(),Y=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${G}`).trim();if(!Y)continue;const oe=String((X==null?void 0:X.label)||"").trim()||Qy(v.current,Z.current,G,"Workspace Run");R[Y]={id:Y,runNodeId:G,label:oe,status:(X==null?void 0:X.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(X==null?void 0:X.plannedNodeIds)?X.plannedNodeIds:[],startedAt:(X==null?void 0:X.startedAt)||Date.now()},G&&U.push(G)}if(!Object.keys(R).length)return;Oi(X=>({...X,...R})),yl(X=>{const G=new Set(X);for(const Y of U)G.add(Y);return G}),wl(X=>{const G={...X};for(const Y of U)G[Y]={status:"running"};return G}),me(U.length?`Workspace run still running: ${U.join(", ")}`:"Workspace run still running"),Kn(X=>{const G=[...X];for(const[Y,oe]of Object.entries(R)){if(G.some(Ne=>Ne.id===Y||["running","stopping"].includes(Ne.status)&&Ne.runNodeId===oe.runNodeId))continue;const he=String(oe.runNodeId||""),fe=String(oe.label||"").trim()||Qy(v.current,Z.current,he,"Workspace Run");G.push({id:Y,label:Zy(fe,he,"Workspace Run"),alias:fe,runNodeId:he,status:oe.status,startedAt:oe.startedAt||Date.now(),steps:he?[{id:he,label:Zy(fe,he,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:oe.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...G.slice(-8)]})}catch{}},[i,v,Oi]),ES=m.useCallback(async w=>{if(!je){me("Readonly workspace");return}if(!w)return;if(Object.values(nu.current||{}).find(rt=>String((rt==null?void 0:rt.runNodeId)||"")===String(w||""))){me(`Workspace run already running: ${w}`);return}let _=v.current,P=x.current,R=Z.current;const U=jv.current;if(U!=null&&U.id){const rt=_.find(Te=>Te.id===U.id),Ye=HC({nodes:_,edges:P,instances:R,selectedNode:rt,draft:U,allowRename:!1});if(Ye!=null&&Ye.error){ol(Ye.error),me(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(_=Ye.nodes,P=Ye.edges,R=Ye.instances,Z.current=R,v.current=_,x.current=P,re(R),k(_),y(P),Br(Ye.nextId||U.id))}const X=Tl(_,P,R),G=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=Qy(_,R,w,"Workspace Run"),oe=Zy(Y,w,"Workspace Run");let he=[w];try{const rt=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:X,runNodeId:w})}),Ye=await rt.json().catch(()=>({}));if(!rt.ok||(Ye==null?void 0:Ye.ok)===!1)throw new Error(Ye.error||"Workspace run plan failed");he=Array.isArray(Ye.plannedNodeIds)&&Ye.plannedNodeIds.length?Ye.plannedNodeIds.map($t=>String($t||"").trim()).filter(Boolean):[w],he=Array.from(new Set([w,...he].filter(Boolean)));const Te=Ye.conflict||null;if(Te!=null&&Te.runNodeId||Te!=null&&Te.runId){const $t=Array.isArray(Te.conflictNodeIds)&&Te.conflictNodeIds.length?`: ${Te.conflictNodeIds.join(", ")}`:"";me(`Run ${w} conflicts with running ${Te.runNodeId||Te.runId}${$t}`);return}}catch(rt){me(String(rt.message||rt));return}const fe=new Set(he),Ne=Object.values(nu.current||{}).find(rt=>(Array.isArray(rt==null?void 0:rt.plannedNodeIds)?rt.plannedNodeIds:[]).some(Ye=>fe.has(String(Ye||"").trim())));if(Ne){const rt=(Array.isArray(Ne.plannedNodeIds)?Ne.plannedNodeIds:[]).map(Ye=>String(Ye||"").trim()).filter(Ye=>Ye&&fe.has(Ye));me(`Run ${w} conflicts with running ${Ne.runNodeId||"workspace run"}${rt.length?`: ${rt.join(", ")}`:""}`);return}const He=new AbortController;ru.current.set(G,He),su.current.delete(G),Oi(rt=>({...rt,[G]:{id:G,runNodeId:w,label:Y,plannedNodeIds:he,startedAt:Date.now()}})),yl(rt=>new Set([...rt,w])),wl(rt=>({...rt,[w]:{status:"running"}})),me(`Running ${oe}...`),xs(G),Kn(rt=>[...rt.slice(-7),{id:G,label:oe,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let ze=w;const We=new Map,Be=()=>su.current.has(G),Re=rt=>{const Ye=new Set((rt||[]).map(Te=>String(Te||"").trim()).filter(Boolean));Ye.size||Ye.add(String(w||"")),yl(Te=>{const $t=new Set(Te);for(const Le of Ye)$t.delete(Le);return $t})},Ft=(rt,Ye)=>{const Te=new Set((rt||[]).map($t=>String($t||"").trim()).filter(Boolean));Te.size||Te.add(String(w||"")),wl($t=>{var ct;const Le={...$t};for(const Pt of Te)Pt&&(!Le[Pt]||((ct=Le[Pt])==null?void 0:ct.status)==="running")&&(Le[Pt]={status:Ye});return Le})};try{await Xt(_,P);const rt=zC(_,R,w,$i),Ye=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:He.signal,body:JSON.stringify({...i,graph:X,runNodeId:w,runAlias:Y,runSessionId:G,expectedRevision:we.current,clientId:ve.current,model:rt,selectedSkills:$s,stream:!0})});if(!Ye.ok){const ge=await Ye.json().catch(()=>({}));throw new Error(ge.error||"Workspace run failed")}if(!Ye.body)throw new Error("Workspace run stream unavailable");const Te=Ye.body.getReader(),$t=new TextDecoder;let Le="",ct=[],Pt=[];const Cl=(ge,nt)=>{var at,Et;const Ge=g.find(Dt=>Dt.id===ge),pt=String(((at=Ge==null?void 0:Ge.data)==null?void 0:at.label)||ge||"").trim(),ye=String(nt||((Et=Ge==null?void 0:Ge.data)==null?void 0:Et.definitionId)||"").trim();return ye&&ye!==pt?`${pt} (${ye})`:pt},li=(ge,nt,Ge)=>{const pt=String(ge||"").trim();pt&&Kn(ye=>ye.map(at=>{if(at.id!==G)return at;const Dt=[...Array.isArray(at.steps)?at.steps:[]],ht=Dt.findIndex(un=>un.id===pt),Nt={id:pt,label:Cl(pt,nt),status:Ge};ht>=0?Dt[ht]={...Dt[ht],...Nt}:Dt.push(Nt);const an=Dt.map((un,xo)=>{const zi=un.status==="done"?"[done]":un.status==="failed"?"[failed]":"[running]";return`${xo+1}. ${zi} ${un.label}`}).join(`
252
- `),qt=Array.isArray(at.messages)?at.messages:[],Zt=qt.findIndex(un=>un.kind==="run-summary"),gn={role:"assistant",kind:"run-summary",text:an||"准备运行...",at:Date.now()},zt=[...qt];return Zt>=0?zt[Zt]=gn:zt.unshift(gn),{...at,steps:Dt,messages:zt.slice(-160)}}))},ya=(ge,nt)=>{var k0,v0,S0,N0,j0,C0,_0,E0,A0,P0;const Ge=String(ge||"").trim(),pt=String(nt||"").trim();if(!Ge||!pt)return;const ye=(k0=Z.current)==null?void 0:k0[Ge];if(!ei(ye==null?void 0:ye.definitionId))return;const at=ea(ye==null?void 0:ye.input,"displayType","markdown"),Et=XT(at),Dt=QT(Ge),ht=be.find(Rr=>Rr.id===Et),Nt=LC(ht==null?void 0:ht.inputs,Et,pt),an=LC(ht==null?void 0:ht.outputs,Et,pt),qt=String((ye==null?void 0:ye.label)||Ge||"一键任务").trim(),Zt={...Z.current||{},[Ge]:{...ye||{},output:DC(ye==null?void 0:ye.output)},[Dt]:{...((v0=Z.current)==null?void 0:v0[Dt])||{},definitionId:Et,label:qt,role:"normal",body:pt,input:Nt,output:an,sourceContextRunNodeId:Ge,displayReloadKey:String(Date.now())}};Z.current=Zt,re(Zt);const gn=v.current||[],zt=gn.find(Rr=>Rr.id===Ge),un=gn.find(Rr=>Rr.id===Dt),xo=Number(((S0=zt==null?void 0:zt.measured)==null?void 0:S0.width)||(zt==null?void 0:zt.width)||((j0=(N0=zt==null?void 0:zt.data)==null?void 0:N0.nodeSize)==null?void 0:j0.width)||520),zi=(un==null?void 0:un.position)||{x:Number(((C0=zt==null?void 0:zt.position)==null?void 0:C0.x)||0)+xo+120,y:Number(((_0=zt==null?void 0:zt.position)==null?void 0:_0.y)||0)},sr=((E0=un==null?void 0:un.data)==null?void 0:E0.displaySize)||((A0=un==null?void 0:un.data)==null?void 0:A0.nodeSize)||{width:Zx,height:eb},ci=Xx({id:Dt,type:fc,position:zi,width:Number(sr.width)||Zx,height:Number(sr.height)||eb,data:{label:qt,definitionId:Et,role:"normal",body:pt,inputs:Nt,outputs:an,sourceContextRunNodeId:Ge,displayReloadKey:Zt[Dt].displayReloadKey,nodeSize:sr,displaySize:sr}},Zt,be),bo=gn.map(Rr=>{if(Rr.id===Ge){const{width:Xle,height:Qle,measured:Zle,...C2}=Rr,{nodeSize:ece,displaySize:tce,...qf}=Rr.data||{};return{...C2,data:{...qf,outputs:DC(qf==null?void 0:qf.outputs),contextRunResultNonce:Date.now()}}}return Rr.id===Dt?{...ci,selected:Rr.selected}:Rr});un||bo.push(ci),v.current=bo,k(bo);const ko=x.current||[],Kf=ZT(Et),Yg=OC((ye==null?void 0:ye.output)||((P0=zt==null?void 0:zt.data)==null?void 0:P0.outputs),"output",["content","result"],["text"]),N2=OC(Nt,"input",[Kf,"content"],["text"]),j2={id:`we-${Ge}-${Dt}`,source:Ge,target:Dt,sourceHandle:Yg,targetHandle:N2,markerEnd:{type:xi.ArrowClosed}},b0=[...ko.filter(Rr=>!(Rr.source===Ge&&Rr.target===Dt)),j2];x.current=b0,y(b0),window.requestAnimationFrame(()=>{s(Ge),s(Dt)})},wa=(ge,nt=null)=>{const Ge=ge!=null&&ge.instances&&typeof ge.instances=="object"?ge.instances:{},pt=nt instanceof Set?nt:null;for(const[ye,at]of Object.entries(Ge)){if(pt&&!pt.has(ye)||!ei(at==null?void 0:at.definitionId))continue;const Et=rg({outputs:at.output});Et&&ya(ye,Et)}},Bf=ge=>{const nt=String(ge||"").trim();if(!nt)return;const Ge=ze;ze=nt,yl(pt=>{const ye=new Set(pt);return Ge&&Ge!==nt&&Ge!==w&&ye.delete(Ge),w&&ye.add(w),ye.add(nt),ye}),wl(pt=>{var ye;return{...pt,...Ge&&Ge!==nt&&Ge!==w&&((ye=pt[Ge])==null?void 0:ye.status)==="running"?{[Ge]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[nt]:{status:"running"}}})},y0=ge=>{const nt=String(ge||"").trim();nt&&(yl(Ge=>{const pt=new Set(Ge);return pt.delete(nt),pt}),wl(Ge=>({...Ge,[nt]:{status:"success"}})))},w0=(ge,nt)=>{const Ge=String(nt||"");if(!Ge.trim())return;const pt=["assistant","thinking","result","error","prompt"].includes(ge)?ge:"assistant";Kn(ye=>ye.map(at=>{if(at.id!==G)return at;let Et=Array.isArray(at.messages)?at.messages:[];if(pt==="result"){const Nt=[...Et].reverse().find(an=>an.kind==="assistant");if(String((Nt==null?void 0:Nt.text)||"").trim()===Ge.trim())return at}if(pt==="assistant"){const Nt=Et.findIndex(an=>an.kind==="result"&&String(an.text||"").trim()===Ge.trim());Nt>=0&&(Et=Et.filter((an,qt)=>qt!==Nt))}const Dt=[...Et],ht=Dt[Dt.length-1];return ht&&ht.kind===pt&&!ht.error?Dt[Dt.length-1]={...ht,text:`${ht.text||""}${ht.text?`
253
- `:""}${Ge}`}:Dt.push({role:"assistant",kind:pt,text:Ge,...pt==="error"?{error:!0}:{},at:Date.now()}),{...at,messages:Dt.slice(-160)}}))},Hf=ge=>{const nt=String(ge||"");nt.trim()&&Kn(Ge=>Ge.map(pt=>{var Dt;if(pt.id!==G)return pt;const ye=Array.isArray(pt.messages)?pt.messages:[],at=ye.findIndex(ht=>ht.kind==="thinking"),Et=[...ye];if(at>=0){const ht=String(((Dt=Et[at])==null?void 0:Dt.text)||"");Et[at]={...Et[at],text:`${ht}${ht&&!ht.endsWith(`
254
- `),""}${nt}`,at:Date.now()}}else{const ht=Et.findIndex(Nt=>Nt.kind==="activity");Et.splice(ht>=0?ht+1:Et.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...pt,messages:Et.slice(-160)}}))},wo=(ge,nt=null)=>{const Ge=bY(ge);Ge&&Kn(pt=>pt.map(ye=>{if(ye.id!==G)return ye;const at=Number(nt==null?void 0:nt.ts)||Date.now(),Et=Number(ye.startedAt)||at,Dt=Number(ye.lastActivityAt)||Et,ht=Math.max(0,at-Dt),Nt=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,at-Et),an=Array.isArray(ye.activities)?ye.activities:[],qt=an[an.length-1],gn=(typeof qt=="string"?qt:String((qt==null?void 0:qt.text)||""))===Ge?an:[...an,{text:Ge,kind:vY(Ge),stepMs:ht,totalMs:Nt,at}].slice(-30),zt=Array.isArray(ye.timingEntries)?ye.timingEntries:[],un=Array.isArray(ye.messages)?ye.messages:[],xo=un.findIndex(ci=>ci.kind==="activity"),zi={role:"assistant",kind:"activity",text:xC(gn,zt,Et,at),at:Date.now()},sr=[...un];if(xo>=0)sr[xo]=zi;else{const ci=sr.findIndex(bo=>bo.kind==="run-summary");sr.splice(ci>=0?ci+1:0,0,zi)}return{...ye,activities:gn,lastActivityAt:at,messages:sr.slice(-160)}}))},x0=ge=>{const nt=String((ge==null?void 0:ge.source)||"runner"),Ge=String((ge==null?void 0:ge.stream)||""),pt=String((ge==null?void 0:ge.eventType)||"event"),ye=String((ge==null?void 0:ge.text)||"").trim();if(!ye)return;const at=`[${nt}${Ge?`:${Ge}`:""}] ${pt}
255
- ${ye}`,Et=eG(ge);Kn(Dt=>Dt.map(ht=>{if(ht.id!==G)return ht;const an=[...Array.isArray(ht.rawTrace)?ht.rawTrace:[],at].slice(-80),qt=Array.isArray(ht.timingEntries)?ht.timingEntries:[],Zt=Et?[...qt,Et].slice(-80):qt,gn=Array.isArray(ht.activities)?ht.activities:[],zt=Number(ht.startedAt)||Number(ge==null?void 0:ge.ts)||Date.now(),un=Number(Et==null?void 0:Et.at)||Number(ge==null?void 0:ge.ts)||Date.now(),xo=Array.isArray(ht.messages)?ht.messages:[],zi={role:"assistant",kind:"raw",text:an.join(`
256
-
257
- ---
258
-
259
- `),at:Date.now()},sr=[...xo],ci=sr.findIndex(ko=>ko.kind==="activity");if(Et){const ko={role:"assistant",kind:"activity",text:xC(gn,Zt,zt,un),at:Date.now()};if(ci>=0)sr[ci]=ko;else{const Kf=sr.findIndex(Yg=>Yg.kind==="run-summary");sr.splice(Kf>=0?Kf+1:0,0,ko)}}const bo=sr.findIndex(ko=>ko.kind==="raw");return bo>=0?sr[bo]=zi:sr.push(zi),{...ht,rawTrace:an,timingEntries:Zt,messages:sr.slice(-160)}}))},S2=ge=>{Kn(nt=>nt.map(Ge=>Ge.id===G?{...Ge,status:ge,endedAt:Date.now()}:Ge))},Wf=ge=>{const nt=new Set,Ge=String((ge==null?void 0:ge.nodeId)||"").trim();Ge&&nt.add(Ge);for(const pt of Array.isArray(ge==null?void 0:ge.displayNodeIds)?ge.displayNodeIds:[]){const ye=String(pt||"").trim();ye&&nt.add(ye)}for(const pt of Array.isArray(ge==null?void 0:ge.touchedNodeIds)?ge.touchedNodeIds:[]){const ye=String(pt||"").trim();ye&&nt.add(ye)}if(nt.size===0)for(const pt of Array.isArray(ge==null?void 0:ge.order)?ge.order:[]){const ye=String(pt||"").trim();ye&&nt.add(ye)}return nt},Vf=(ge,nt=null)=>{const Ge=Eu(ge||X,be),pt=new Map(Ge.nodes.map(ht=>[ht.id,ht])),ye=Ge.instances||{},at=nt instanceof Set?nt:null,Et=(ht,Nt)=>{const an={...ht||Nt};Array.isArray(Nt==null?void 0:Nt.output)&&(an.output=Nt.output);for(const qt of["scriptRef","implementationRef","implementationMode"])(Nt==null?void 0:Nt[qt])!=null&&String(Nt[qt]).trim()!==""&&(an[qt]=Nt[qt]);return an},Dt=(ht,Nt)=>{const an={...ht||{}};Array.isArray(Nt==null?void 0:Nt.outputs)&&(an.outputs=Nt.outputs);for(const qt of["scriptRef","implementationRef","implementationMode"])(Nt==null?void 0:Nt[qt])!=null&&String(Nt[qt]).trim()!==""&&(an[qt]=Nt[qt]);return an};k(ht=>{const Nt=new Set(ht.map(Zt=>Zt.id)),qt={...Tl(ht,x.current,Z.current).instances||{}};for(const[Zt,gn]of Object.entries(ye)){if(at&&!at.has(Zt)||!Nt.has(Zt))continue;const zt=qt[Zt];el((gn==null?void 0:gn.definitionId)||(zt==null?void 0:zt.definitionId))?qt[Zt]=gn:Array.isArray(gn==null?void 0:gn.output)&&(qt[Zt]=Et(zt,gn))}return Z.current=qt,re(qt),ht.map(Zt=>{var zt,un;if(at&&!at.has(Zt.id))return Zt;const gn=pt.get(Zt.id);return gn?el(((zt=gn.data)==null?void 0:zt.definitionId)||((un=Zt.data)==null?void 0:un.definitionId))?{...Zt,data:{...Zt.data,...gn.data}}:{...Zt,data:Dt(Zt.data,gn.data)}:Zt})})};for(;;){const{value:ge,done:nt}=await Te.read();if(nt)break;Le+=$t.decode(ge,{stream:!0});const Ge=Le.split(`
260
- `);Le=Ge.pop()||"";for(const pt of Ge){if(!pt.trim())continue;const ye=JSON.parse(pt);if(ye.type==="error")throw new Error(ye.error||"Workspace run failed");if(ye.type==="stopped"){su.current.add(G),ct=Array.isArray(ye.order)?ye.order:ct,wo("运行停止",ye);continue}if(ye.type==="node-start"&&(me(`Running ${ye.nodeId}...`),Bf(ye.nodeId),li(ye.nodeId,ye.definitionId,"running")),ye.type==="node-done"){const at=We.get(String(ye.nodeId||"").trim());at&&ya(ye.nodeId,at),y0(ye.nodeId),li(ye.nodeId,ye.definitionId,"done")}if(ye.type==="status"&&wo(ye.line||ye.message||"",ye),ye.type==="paused"&&(Pt=Array.isArray(ye.nodeIds)?ye.nodeIds:[],wo("运行暂停",ye)),ye.type==="natural"&&((ye.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(ye.text||"")))&&ye.nodeId&&We.set(String(ye.nodeId||"").trim(),String(ye.text||"")),ye.kind==="thinking"?Hf(ye.text||""):w0(ye.kind,ye.text||"")),ye.type==="raw"){const at=bC(ye);at&&Hf(at),x0(ye)}if(ye.type==="graph"&&ye.graph){const at=Wf(ye);Vf(ye.graph,at),wa(ye.graph,at)}if(ye.type==="done"){if(ye.revision&&(we.current=String(ye.revision)),ye.graph){De.current=ye.graph;const at=Wf(ye);Vf(ye.graph,at),wa(ye.graph,at)}ct=Array.isArray(ye.order)?ye.order:[],Pt=Array.isArray(ye.pauseNodeIds)?ye.pauseNodeIds:Pt,wo(Pt.length?"运行暂停":"运行完成",ye)}}}if(Le.trim()){const ge=JSON.parse(Le);if(ge.type==="error")throw new Error(ge.error||"Workspace run failed");if(ge.type==="stopped"&&(su.current.add(G),wo("运行停止",ge)),ge.type==="node-start"&&(me(`Running ${ge.nodeId}...`),Bf(ge.nodeId),li(ge.nodeId,ge.definitionId,"running")),ge.type==="node-done"){const nt=We.get(String(ge.nodeId||"").trim());nt&&ya(ge.nodeId,nt),y0(ge.nodeId),li(ge.nodeId,ge.definitionId,"done")}if(ge.type==="status"&&wo(ge.line||ge.message||"",ge),ge.type==="paused"&&(Pt=Array.isArray(ge.nodeIds)?ge.nodeIds:[],wo("运行暂停",ge)),ge.type==="natural"&&((ge.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(ge.text||"")))&&ge.nodeId&&We.set(String(ge.nodeId||"").trim(),String(ge.text||"")),ge.kind==="thinking"?Hf(ge.text||""):w0(ge.kind,ge.text||"")),ge.type==="raw"){const nt=bC(ge);nt&&Hf(nt),x0(ge)}if(ge.type==="graph"&&ge.graph){const nt=Wf(ge);Vf(ge.graph,nt),wa(ge.graph,nt)}if(ge.type==="done"){if(ge.revision&&(we.current=String(ge.revision)),ge.graph){De.current=ge.graph;const nt=Wf(ge);Vf(ge.graph,nt),wa(ge.graph,nt)}ct=Array.isArray(ge.order)?ge.order:[],Pt=Array.isArray(ge.pauseNodeIds)?ge.pauseNodeIds:Pt,wo(Pt.length?"运行暂停":"运行完成",ge)}}Be()&&(Re(he),Ft(he,"stopped"));const Ug=Be()?`Workspace run stopped: ${w}`:Pt.length?`Workspace run paused at ${Pt.join(", ")}`:`Workspace run done: ${ct.length?ct.join(" -> "):w}`;if(me(Ug),Be()||Ft(he,Pt.length?"paused":"success"),S2(Be()?"stopped":Pt.length?"paused":"done"),!Be()){try{await Xt(v.current,x.current),me(Ug)}catch(ge){me(`${Ug},但保存结果失败:${String(ge.message||ge)}`)}await En()}}catch(rt){if(Be()||(rt==null?void 0:rt.name)==="AbortError"){Re(he),Ft(he,"stopped"),me(`Workspace run stopped: ${w}`),Kn(Ye=>Ye.map(Te=>Te.id===G?{...Te,status:"stopped",endedAt:Date.now()}:Te));return}Re(he),Ft([w,ze].filter(Boolean),"failed"),me(String(rt.message||rt)),Kn(Ye=>Ye.map(Te=>Te.id===G?{...Te,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Te.messages)?Te.messages:[],{role:"assistant",error:!0,text:String(rt.message||rt),at:Date.now()}].slice(-160)}:Te))}finally{ru.current.get(G)===He&&ru.current.delete(G),Oi(rt=>{const Ye={...rt};return delete Ye[G],Ye}),su.current.delete(G),Re(he)}},[$i,b,i,En,g,be,Br,Xt,$s,y,k,Oi,s,je]),Ef=m.useCallback(async()=>{try{const S=await(await fetch("/api/skills")).json().catch(()=>({})),_=Array.isArray(S.skills)?S.skills.map(P=>({key:String(P.key),name:String(P.name||P.id||P.key),description:P.description?String(P.description):"",sourceLabel:P.sourceLabel?String(P.sourceLabel):""})):[];l$(_),Hv(!0)}catch{Hv(!0)}},[]),Af=m.useCallback(async()=>{try{const S=await(await fetch("/api/mcps")).json().catch(()=>({})),_=Array.isArray(S.servers)?S.servers.map(P=>({name:String((P==null?void 0:P.name)||""),type:String((P==null?void 0:P.type)||""),url:String((P==null?void 0:P.url)||""),command:String((P==null?void 0:P.command)||""),args:Array.isArray(P==null?void 0:P.args)?P.args.map(String):[],description:String((P==null?void 0:P.description)||"")})).filter(P=>P.name):[];Kv(_)}catch{Kv([])}},[]),Pf=m.useCallback(async()=>{try{const w=Tr(i),_=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),P=Array.isArray(_.workspaces)?_.workspaces.map(R=>({id:String((R==null?void 0:R.id)||""),label:String((R==null?void 0:R.label)||(R==null?void 0:R.name)||"知识库"),path:String((R==null?void 0:R.path)||""),kind:(R==null?void 0:R.kind)==="git"?"git":"local",repoUrl:String((R==null?void 0:R.repoUrl)||""),branch:String((R==null?void 0:R.branch)||""),mountPath:String((R==null?void 0:R.mountPath)||""),type:String((R==null?void 0:R.type)||""),builtin:(R==null?void 0:R.builtin)===!0,exists:(R==null?void 0:R.exists)!==!1})).filter(R=>R.path):[];Uv(P)}catch{Uv([])}},[i]),AS=m.useCallback(async()=>{Ve.current=!1;try{const w=Tr(i),S=await fetch(`/api/workspace/conversations?${w.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok)throw new Error(_.error||`HTTP ${S.status}`);const P=mC(_.conversations||{});pl(P.composer.messages),Kn(P.composer.runSessions),xs(P.composer.activeSessionId||"workspace"),go(P.nodeChats)}catch{pl([]),Kn([]),xs("workspace"),go({})}finally{Ve.current=!0}},[i]),PS=m.useCallback(async()=>{if(!je||i.archived)return;const w=mC({composer:{activeSessionId:Hr,messages:fa,runSessions:Ls},nodeChats:pa});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,conversations:w})}).then(async S=>{if(!S.ok){const _=await S.json().catch(()=>({}));throw new Error(_.error||`HTTP ${S.status}`)}})},[Hr,fa,Ls,i,pa,je]);m.useEffect(()=>{let w=!1;return(async()=>{const _=new URL(window.location.href),P=String(_.searchParams.get("invite")||"").trim();if(P){me("正在加入共享 Workspace...");const R=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:P})}),U=await R.json().catch(()=>({}));if(!R.ok)throw new Error(U.error||"加入共享 Workspace 失败");_.searchParams.delete("invite"),window.history.replaceState({},"",`${_.pathname}${_.search}${_.hash}`)}w||(await bs(),w||await AS())})().catch(_=>{const P=String(_.message||_);me(P),Os("error"),Ds(P)}),jf(),fetch("/api/model-lists").then(_=>_.json()).then(_=>o$({cursor:Array.isArray(_.cursor)?_.cursor.map(String):[],opencode:Array.isArray(_.opencode)?_.opencode.map(String):[],claudeCode:Array.isArray(_.claudeCode)?_.claudeCode.map(String):[],codex:Array.isArray(_.codex)?_.codex.map(String):[]})).catch(()=>{}),Ef(),Af(),Pf(),_f(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{c$(La(_)),u$(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>{oS(_.user||null),lS(!0)}).catch(()=>{oS(null),lS(!0)}),()=>{w=!0}},[bs,AS,jf,Af,Ef,_f,Pf,Li]),m.useEffect(()=>{if(xS(""),!(!Bv||!Wv)){if(!Li){Jc([]);return}Jc(yF(Li,"workspace",Ms,dl)),xS(Li)}},[dl,Wv,Ms,Bv,Li]),m.useEffect(()=>{if(!(wS!==Li||!Li))try{localStorage.setItem(Li,JSON.stringify($s))}catch{}},[$s,Li,wS]),m.useEffect(()=>{Z.current=ee},[ee]),m.useEffect(()=>{v.current=g},[g]),m.useEffect(()=>{if(Me.current)return;const w=M.current,S=new Map,_=[];for(const P of g){const R=TT(P);S.set(P.id,R),w.get(P.id)!==R&&_.push(P.id)}M.current=S,_.length!==0&&Br(_)},[g,Br]),m.useEffect(()=>{x.current=b},[b]),m.useEffect(()=>{A.current=N},[N]),m.useEffect(()=>{H.current=I},[I]),m.useEffect(()=>{jv.current=ot},[ot]),m.useEffect(()=>{mo.current=Kt},[Kt]),m.useEffect(()=>{ce.current=J},[J]),m.useEffect(()=>{if(!J)return;const w=_=>{_.key==="Escape"&&ne(null)},S=_=>{var P,R;(R=(P=_.target)==null?void 0:P.closest)!=null&&R.call(P,".af-connect-node-menu")||ne(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S)}},[J]),m.useEffect(()=>{if(!le.current||!je)return;if(Me.current){de.current&&window.clearTimeout(de.current);return}if(Fe.current){Fe.current=!1;return}ns(),de.current&&window.clearTimeout(de.current);const w=ue.current?0:650;return ue.current=!1,de.current=window.setTimeout(()=>{Xt().catch(S=>me(String(S.message||S)))},w),()=>{de.current&&window.clearTimeout(de.current)}},[g,b,N,ns,Xt,je]),m.useEffect(()=>{if(Ve.current&&!(!je||i.archived))return qe.current&&window.clearTimeout(qe.current),qe.current=window.setTimeout(()=>{PS().catch(w=>me(String(w.message||w)))},900),()=>{qe.current&&window.clearTimeout(qe.current)}},[Hr,fa,Ls,i.archived,pa,PS,je]);const lu=m.useMemo(()=>g.filter(w=>{var S;return((S=w==null?void 0:w.data)==null?void 0:S.definitionId)==="workspace_scheduled_run"}).map(w=>{var S;return{id:w.id,config:cv(((S=w.data)==null?void 0:S.body)||"")}}),[g]),A$=m.useMemo(()=>lu.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[lu]);m.useEffect(()=>{if(!le.current||c!=="workspace"||!i.flowId){ha({});return}if(!lu.length){ha({});return}let w=!1;const S=async()=>{try{const P=Tr(i),R=await fetch(`/api/workspace/schedules?${P.toString()}`),U=await R.json().catch(()=>({}));if(!R.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");w||ha(Pp(U.schedules||[]))}catch{w||ha(P=>{var U;const R={};for(const X of lu)R[X.id]={...P[X.id]||{},lastStatus:((U=P[X.id])==null?void 0:U.lastStatus)||"unknown"};return R})}};S();const _=window.setInterval(S,5e3);return()=>{w=!0,window.clearInterval(_)}},[i,lu,A$,c]);const IS=m.useCallback((w,S)=>{if(!je){me("Readonly workspace");return}const _=$C(S),P=Y=>Array.isArray(Y)?Y.map(oe=>(oe==null?void 0:oe.name)!=="skillKeys"&&(oe==null?void 0:oe.name)!=="skillsContext"&&(oe==null?void 0:oe.type)!=="text"?oe:{...oe,default:_,value:_}):[],R=g.map(Y=>{var oe;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:P((oe=Y.data)==null?void 0:oe.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},G={...U,[w]:{...X,body:_,input:P(X.input)}};Z.current=G,k(R),re(G),ys(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:P(Y.inputs)}),Xt(R,b).catch(Y=>me(String(Y.message||Y)))},[b,g,Xt,k,je]),RS=m.useCallback((w,S)=>{if(!je){me("Readonly workspace");return}const _=cJ(S),P=Y=>Array.isArray(Y)?Y.map(oe=>(oe==null?void 0:oe.name)!=="serverNames"&&(oe==null?void 0:oe.name)!=="mcpContext"&&(oe==null?void 0:oe.type)!=="text"?oe:{...oe,default:_,value:_}):[],R=g.map(Y=>{var oe;return Y.id!==w?Y:{...Y,data:{...Y.data,body:_,inputs:P((oe=Y.data)==null?void 0:oe.inputs)}}}),U=Z.current||{},X=U[w]&&typeof U[w]=="object"?U[w]:{},G={...U,[w]:{...X,body:_,input:P(X.input)}};Z.current=G,k(R),re(G),ys(Y=>!Y||Y.id!==w?Y:{...Y,body:_,inputs:P(Y.inputs)}),Xt(R,b).catch(Y=>me(String(Y.message||Y)))},[b,g,Xt,k,je]),TS=m.useCallback((w,S)=>{if(!je){me("Readonly workspace");return}const _=(Array.isArray(S)?S:S?[S]:[]).filter(ze=>String((ze==null?void 0:ze.path)||"").trim()),P=_[0]||null,R=String((P==null?void 0:P.path)||"").trim(),U=_.length===1?String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim():_.length?`${_.length} 个知识库`:"",X=_.length?JSON.stringify(sg(_)):"",G=P?JSON.stringify({version:1,id:(P==null?void 0:P.id)||"",label:String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim(),kind:(P==null?void 0:P.kind)||"local",cwd:R,workspaceRoot:R,repoUrl:(P==null?void 0:P.repoUrl)||"",branch:(P==null?void 0:P.branch)||"",mountPath:(P==null?void 0:P.mountPath)||"",type:(P==null?void 0:P.type)||""}):"",Y=ze=>Array.isArray(ze)?ze.map(We=>(We==null?void 0:We.name)==="path"?{...We,default:R,value:R}:(We==null?void 0:We.name)==="label"?{...We,default:U,value:U}:(We==null?void 0:We.name)==="knowledgeContext"?{...We,default:X,value:X}:(We==null?void 0:We.name)==="workspaceContext"?{...We,default:G,value:G}:(We==null?void 0:We.name)==="mode"?{...We,default:"set",value:"set"}:We):[],oe=ze=>Array.isArray(ze)?ze.map(We=>(We==null?void 0:We.name)==="knowledgeContext"?{...We,default:X,value:X}:(We==null?void 0:We.name)==="workspaceContext"?{...We,default:G,value:G,showOnNode:!1}:(We==null?void 0:We.name)==="cwd"?{...We,default:R,value:R,showOnNode:!1}:We):[],he=g.map(ze=>{var We,Be,Re;return ze.id===w?{...ze,data:{...ze.data,label:((We=ze.data)==null?void 0:We.label)||"加载知识库",inputs:Y((Be=ze.data)==null?void 0:Be.inputs),outputs:oe((Re=ze.data)==null?void 0:Re.outputs)}}:ze}),fe=Z.current||{},Ne=fe[w]&&typeof fe[w]=="object"?fe[w]:{},He={...fe,[w]:{...Ne,label:Ne.label||"加载知识库",input:Y(Ne.input),output:oe(Ne.output)}};Z.current=He,k(he),re(He),ys(ze=>(ze==null?void 0:ze.id)===w?{...ze,inputs:Y(ze.inputs),outputs:oe(ze.outputs)}:ze),Xt(he,b).catch(ze=>me(String(ze.message||ze)))},[b,g,Xt,k,je]),MS=m.useCallback((w,S)=>{if(!je){me("Readonly workspace");return}const _=String(w||"");if(!_)return;const P=$C((S==null?void 0:S.skillKeys)||[]),R=ff((S==null?void 0:S.displayType)||"markdown"),U=String((S==null?void 0:S.model)||"").trim(),X=(S==null?void 0:S.includeWorkspaceContext)===!1?"false":"true",G=S!=null&&S.workspaceContext&&typeof S.workspaceContext=="object"?JSON.stringify(S.workspaceContext):"",Y=S!=null&&S.knowledgeContext&&typeof S.knowledgeContext=="object"?JSON.stringify(S.knowledgeContext):"",oe=Be=>Array.isArray(Be)?Be.map(Re=>(Re==null?void 0:Re.name)==="skillKeys"?{...Re,default:P,value:P}:(Re==null?void 0:Re.name)==="displayType"?{...Re,default:R,value:R}:(Re==null?void 0:Re.name)==="includeWorkspaceContext"?{...Re,default:X,value:X}:(Re==null?void 0:Re.name)==="knowledgeContext"?{...Re,default:Y,value:Y}:(Re==null?void 0:Re.name)==="workspaceContext"?{...Re,default:G,value:G}:Re):[],he=Be=>Array.isArray(Be)?Be.map(Re=>(Re==null?void 0:Re.name)==="displayType"?{...Re,default:R,value:R}:Re):[],fe=String((S==null?void 0:S.task)??""),Ne=g.map(Be=>{var Re,Ft;return Be.id===_?{...Be,data:{...Be.data,body:fe,model:U,inputs:oe((Re=Be.data)==null?void 0:Re.inputs),outputs:he((Ft=Be.data)==null?void 0:Ft.outputs)}}:Be}),He=Z.current||{},ze=He[_]&&typeof He[_]=="object"?He[_]:{},We={...He,[_]:{...ze,body:fe,model:U,input:oe(ze.input),output:he(ze.output)}};Z.current=We,k(Ne),re(We),ys(Be=>(Be==null?void 0:Be.id)===_?{...Be,body:fe,model:U,inputs:oe(Be.inputs),outputs:he(Be.outputs)}:Be),Xt(Ne,b).catch(Be=>me(String(Be.message||Be)))},[b,g,Xt,k,je]),$S=m.useCallback((w,S)=>{if(!je){me("Readonly workspace");return}const _=uG(S),P=g.map(G=>G.id===w?{...G,data:{...G.data,body:_}}:G),R=Z.current||{},U=R[w]&&typeof R[w]=="object"?R[w]:{},X={...R,[w]:{...U,body:_}};Z.current=X,k(P),re(X),ys(G=>(G==null?void 0:G.id)===w?{...G,body:_}:G),Xt(P,b).catch(G=>me(String(G.message||G)))},[b,g,Xt,k,je]),LS=m.useCallback(w=>{const S=String(w||"").trim();S&&(iS(_=>_===S?"":S),go(_=>({..._,[S]:_[S]||{sessionId:`nodechat_${Date.now()}_${S.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),OS=m.useCallback(()=>iS(""),[]),DS=m.useCallback((w,S)=>{const _=String(w||"").trim();_&&go(P=>({...P,[_]:{...P[_]||{sessionId:`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(S||""),error:""}}))},[]),Fs=m.useCallback((w,S,_="replace",P={})=>{var rt,Ye;if(!je){me("Readonly workspace");return}const R=String(w||"").trim();if(!R)return;const U=v.current.find(Te=>Te.id===R),X=An(U==null?void 0:U.data),G=ei((rt=U==null?void 0:U.data)==null?void 0:rt.definitionId),Y=_i(S),oe=X==="html"?zc(Y):X==="react"?ng(Y):String(Y||""),he=U?to(U.data):"",fe=_==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
261
-
262
- ${oe.trim()}`:oe,Ne=X==="image"?"src":"content",He=P!=null&&P.reloadDisplay?Date.now():(Ye=U==null?void 0:U.data)==null?void 0:Ye.displayReloadKey,ze=Te=>{let $t=!1;return(Array.isArray(Te)?Te:[]).map(ct=>{const Pt=String((ct==null?void 0:ct.name)||""),Cl=String((ct==null?void 0:ct.type)||"");return(G?Pt===Ne||Pt==="result"||Pt==="filePath":Pt===Ne||Pt==="filePath"||Cl==="text")?$t?{...ct,default:"",value:""}:($t=!0,{...ct,default:fe,value:fe}):ct})},We=v.current.map(Te=>{var $t,Le;return Te.id!==R?Te:{...Te,data:{...Te.data,body:G?Te.data.body:fe,...He?{displayReloadKey:He}:{},inputs:ze(($t=Te.data)==null?void 0:$t.inputs),outputs:ze((Le=Te.data)==null?void 0:Le.outputs)}}}),Be=Z.current||{},Re=Be[R]&&typeof Be[R]=="object"?Be[R]:{},Ft={...Be,[R]:{...Re,body:G?Re.body:fe,input:ze(Re.input),output:ze(Re.output)}};Z.current=Ft,k(We),re(Ft),ys(Te=>(Te==null?void 0:Te.id)===R?{...Te,...G?{}:{body:fe}}:Te),(P==null?void 0:P.logChat)!==!1&&go(Te=>{var $t;return{...Te,[R]:{...Te[R]||{},candidateContent:"",messages:[...($t=Te[R])!=null&&$t.messages&&Array.isArray(Te[R].messages)?Te[R].messages:[],{role:"assistant",text:_==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),Xt(We,x.current).catch(Te=>me(String(Te.message||Te))),me(String((P==null?void 0:P.statusMessage)||"")||(_==="append"?"已追加节点内容":"已替换节点内容"))},[Xt,k,je]),If=m.useCallback(async(w,S="")=>{if(!je)return me("Readonly workspace"),"";if(!w)return"";try{const _=new FormData;_.set("file",w),_.set("dir",String(S||"")),i.flowId&&_.set("flowId",i.flowId),i.flowSource&&_.set("flowSource",i.flowSource),i.archived&&_.set("archived","1");const P=await fetch("/api/workspace/upload",{method:"POST",body:_}),R=await P.json().catch(()=>({}));if(!P.ok)throw new Error(R.error||"上传文件失败");const U=String(R.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await En(),ul(X=>{const G=new Set(X);for(const Y of Rp(U))G.delete(Y);return G}),me(`已上传 ${U}`),U}catch(_){return me(String(_.message||_)),""}},[i,En,je]),Rf=m.useCallback(async w=>sm(w)?If(w,"img"):(me("请选择图片文件"),""),[If]),FS=m.useCallback((w="")=>{var S;if(!je){me("Readonly workspace");return}Fv.current=String(w||""),(S=Dv.current)==null||S.click()},[je]),P$=m.useCallback(async w=>{const S=Array.from(w.target.files||[]);if(w.target.value="",!S.length)return;const _=Fv.current||"";Lv(!0);try{let P="";for(const R of S){const U=await If(R,_);U&&(P=U)}S.length>1&&me(`已上传 ${S.length} 个文件${P?`,最后一个:${P}`:""}`)}catch(P){me(String(P.message||P))}finally{Lv(!1)}},[If]),zS=m.useCallback(async(w,S)=>{const _=String(w||"").trim();if(!_)return;const P=await Rf(S);P&&Fs(_,P,"replace",{logChat:!1,statusMessage:`已上传图片 ${P}`})},[Fs,Rf]),BS=m.useCallback(async(w,S=void 0)=>{var ze,We;if(!je){me("Readonly workspace");return}const _=String(w||"").trim();if(!_)return;const P=pa[_]||{},R=String(S!==void 0?S:P.draft||"").trim();if(!R||P.running)return;const U=v.current.find(Be=>Be.id===_);if(!U)return;const X=An(U.data)||"markdown",G=to(U.data);let Y=Zo(G,X),oe=_i(G);if(Y)try{oe=await tl(i,Y)}catch(Be){me(String(Be.message||Be))}else if(X!=="image"&&String(oe||"").trim()){const Be=Ta(X,oe);if(Be){me(`${Be} 未进入微调。`);return}try{const Re=await ab(i,TC(_,U.data),oe);await En(),Fs(_,Re,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Re}`}),Y=Re,oe=""}catch(Re){me(String(Re.message||Re));return}}const he=_G(_,v.current,x.current),fe={role:"user",text:R,at:Date.now()},Ne=Array.isArray(P.messages)?P.messages:[],He=P.sessionId||`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`;go(Be=>({...Be,[_]:{...P,sessionId:He,messages:[...Ne,fe],draft:"",running:!0,error:""}}));try{const Be=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,sessionId:He,node:{id:_,label:((ze=U.data)==null?void 0:ze.label)||_,definitionId:((We=U.data)==null?void 0:We.definitionId)||""},nodeKind:X,currentContent:Y?"":oe,sourceContext:he,targetFilePath:Y,messages:Ne,message:R,model:$i})}),Re=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(Re.error||"节点微调失败");const Ft=String(Re.candidateContent||Re.reply||"").trim(),rt=!!Re.directFileEdit,Ye=String(Re.artifactPath||Y||"").trim();if(rt&&Ye){const Te=Ta(X,Ft);if(Te)throw new Error(`${Te} 文件已由 agent 修改,请检查 ${Ye}。`);await En(),Fs(_,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(Ft){const Te=Ta(X,Ft);if(Te)throw new Error(`${Te} 已取消写入,避免覆盖当前展示文件。`);if(Y){const $t=await ab(i,Y,Ft);await En(),Fs(_,$t,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${$t}`})}else Fs(_,Ft,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}go(Te=>{var $t;return{...Te,[_]:{...Te[_]||{},sessionId:String(Re.sessionId||He),running:!1,candidateContent:"",messages:[...($t=Te[_])!=null&&$t.messages&&Array.isArray(Te[_].messages)?Te[_].messages:[...Ne,fe],{role:"assistant",text:Ft||rt?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(Be){const Re=String(Be.message||Be);go(Ft=>({...Ft,[_]:{...Ft[_]||{},running:!1,error:Re}})),me(Re)}},[$i,i,En,pa,Fs,je]),HS=m.useCallback(async(w,S)=>{if(!je){me("Readonly workspace");return}const _=An(S)||"markdown",P=to(S),R=Zo(P,_);let U=_i(P);if(R)try{U=await tl(i,R)}catch(oe){me(String(oe.message||oe));return}if(!String(U||"").trim()){me("展示节点没有可保存内容");return}const X=Ta(_,U);if(X){me(`${X} 未保存文件。`);return}const G=TC(w,S),Y=window.prompt("保存到 workspace 相对路径",G);if(Y)try{const oe=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:Y,content:U})}),he=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(he.error||"保存文件失败");const fe=he.path||Y,Ne=Tr(i);Ne.set("path",fe);const He=await fetch(`/api/workspace/file?${Ne.toString()}`);if(!He.ok){const ze=await He.json().catch(()=>({}));throw new Error(ze.error||`保存后读取失败:${fe}`)}await En(),Cv(ze=>eJ(ze,fe,String(U||"").length)),ul(ze=>{const We=new Set(ze);for(const Be of Rp(fe))We.delete(Be);return We}),Fs(w,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),me(`已保存 ${fe}`)}catch(oe){me(String(oe.message||oe))}},[i,En,Fs,je]),WS=m.useCallback(w=>{var R,U;const S=String(w||"").trim();if(!S||it)return;const _=v.current.find(X=>X.id===S);if(!_||!An(_==null?void 0:_.data)){me("展示节点不可用");return}const P=String(((R=_.data)==null?void 0:R.label)||((U=_.data)==null?void 0:U.displayName)||S).trim()||"AgentFlow Display";ke(nw({title:P,layout:"single",nodeIds:[S],mode:"single-node",sourceNodeId:S})),dr(""),Ut(null),br(!0)},[it]),Tf=m.useCallback((w,S)=>{const _=String(w||"");_&&ys(P=>{if(!P||P.id!==_)return P;const R=typeof S=="function"?S(P):S;return!R||typeof R!="object"?P:{...P,...R}})},[]),VS=m.useCallback((w,S)=>{const _=String(w||"");!_||!je||(k(P=>P.map(R=>{var X;if(R.id!==_)return R;const U=Array.isArray((X=R.data)==null?void 0:X.outputs)&&R.data.outputs.length?R.data.outputs.map((G,Y)=>Y===0?{...G,default:S,value:S}:G):[{type:"file",name:"value",default:S,value:S}];return{...R,data:{...R.data,body:"",outputs:U}}})),Tf(_,P=>({body:"",outputs:Array.isArray(P==null?void 0:P.outputs)&&P.outputs.length?P.outputs.map((U,X)=>X===0?{...U,default:S,value:S}:U):[{type:"file",name:"value",default:S,value:S}]})),me(`已选择文件 ${S}`))},[k,Tf,je]),KS=m.useCallback(w=>{wg({nodeId:String(w||""),query:""})},[]),$g=m.useCallback(()=>{wg({nodeId:"",query:""})},[]),I$=m.useCallback(w=>{const S=String((w==null?void 0:w.path)||"").trim();!S||!Gc.nodeId||(VS(Gc.nodeId,S),$g())},[$g,Gc.nodeId,VS]),qS=m.useCallback(async(w,S)=>{if(!je)return;const _=WG(w,S);if(_.length===0)return;const P=[];try{for(const R of _){const U=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:R})});if(U.status===404)continue;const X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"清理节点输出失败");P.push(X.path||R)}if(P.length===0)return;me(`已清理 ${P.join(", ")}`),await En(),yg(R=>_.some(U=>R===U||R.startsWith(`${U}/`))?"":R)}catch(R){me(String(R.message||R))}},[i,En,je]),cu=m.useMemo(()=>({modelLists:ua,showBodyPreview:!0,flowParams:i,readOnly:!je,onRunWorkspaceNode:ES,onStopWorkspaceNode:_S,onOpenWorkspaceRunLogs:CS,onOptimizeWorkspaceRun:Mg,onOptimizeWorkspaceSchedule:Mg,runningRunNodeIds:bS,onChangeScheduledRunConfig:$S,onChangeContextRunConfig:MS,skills:Ms,skillCollections:dl,onChangeLoadSkillKeys:IS,onRefreshSkills:Ef,mcpServers:Vv,onChangeLoadMcpNames:RS,onRefreshMcps:Af,workspaceTargets:qv,onChangeLoadWorkspace:TS,onRefreshWorkspaces:Pf,onSaveDisplayNodeToFile:HS,onShareDisplayNode:WS,onOpenDisplayPreview:Dn,onRefreshNodeInternals:Br,onEnsureWorkspaceNodeDisplaySize:Qv,sharingDisplayNodeId:it,onUploadWorkspaceImage:Rf,onUploadImageToDisplayNode:zS,onOpenProvideFilePicker:KS,onStatus:me,onSetDisplayNodeContent:Fs,onToggleNodeChat:LS,onCloseNodeChat:OS,onUpdateNodeChatDraft:DS,onSendNodeChat:BS,onSyncNodePropDraft:Tf,onCleanupWorkspaceNodeOutputs:qS}),[MS,RS,IS,TS,$S,qS,OS,Qv,i,Vv,ua,KS,CS,Mg,Af,Br,Ef,Pf,ES,bS,HS,BS,Fs,WS,it,dl,Ms,_S,Tf,LS,DS,zS,Rf,qv,je]),R$=m.useRef(new Map),rs=m.useMemo(()=>{const w=R$.current,S=new Set,_=g.map(P=>{var Y,oe,he;const R={selected:P.selected===!0,isExecuting:pS.has(P.id),nodeStatus:((Y=Rg[P.id])==null?void 0:Y.status)??null,nodeElapsed:((oe=Rg[P.id])==null?void 0:oe.elapsed)??null,optimizingRun:hS===P.id,scheduledRunState:fS[P.id]||null,nodeChatActive:sS===P.id,nodeChat:pa[P.id]||null},U=w.get(P.id);if(U&&U.source===P&&U.commonData===cu&&jC(U.runtime,R))return S.add(P.id),U.node;const X=!!(U&&((he=U.source)==null?void 0:he.data)===P.data&&U.commonData===cu&&jC(U.runtime,R)),G={...P,data:X?U.node.data:{...P.data,...cu,...R}};return w.set(P.id,{source:P,commonData:cu,runtime:R,node:G}),S.add(P.id),G});for(const P of w.keys())S.has(P)||w.delete(P);return _},[sS,cu,pa,g,hS,fS,pS,Rg]),lt=c==="display",Fn=c==="workflow",US=m.useMemo(()=>lt?new Map(rs.map(w=>[w.id,w])):gG,[rs,lt]),YS=m.useMemo(()=>Vt&&rs.find(w=>w.id===Vt)||null,[Vt,rs]),GS=m.useRef(new Map),uu=m.useMemo(()=>{if(!lt)return GS.current.clear(),yG;const w=new Set(z),S=GS.current,_=new Set,P=N.nodeIds.map((R,U)=>{var He,ze,We,Be;const X=US.get(R);if(!X||!An(X.data))return null;const G=Dl(X)||{width:520,height:320},Y=Fa(N.nodeSizes[R]||G,{display:!0})||G,oe=N.nodePositions[R]||{x:180+U*36,y:120+U*28},he=w.has(R),fe=S.get(R);if(fe&&fe.source===X&&((He=fe.position)==null?void 0:He.x)===oe.x&&((ze=fe.position)==null?void 0:ze.y)===oe.y&&((We=fe.size)==null?void 0:We.width)===Y.width&&((Be=fe.size)==null?void 0:Be.height)===Y.height&&fe.selected===he)return _.add(R),fe.node;const Ne={...X,id:CC(R),position:oe,selected:he,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:R,displayPageMode:!0,readOnly:!0,selected:he,displaySize:Y,nodeSize:Y}};return S.set(R,{source:X,position:oe,size:Y,selected:he,node:Ne}),_.add(R),Ne}).filter(Boolean);for(const R of S.keys())_.has(R)||S.delete(R);return P},[N,US,lt,z]),bl=m.useMemo(()=>rs.filter(w=>An(w==null?void 0:w.data)),[rs]);m.useEffect(()=>{if(!lt||!N.viewport)return;const w=N.viewport,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[N.viewport,lt,r]),m.useEffect(()=>{if(lt||Fn||!I)return;const w=I,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[lt,Fn,r,I]),m.useEffect(()=>{Fn&&Cf(fr)},[Fn]),m.useEffect(()=>{if(!Fn||!fr)return;const w=Tr(i);w.set("tapdId",fr);const S=new EventSource(`/api/prd-workflow/events?${w.toString()}`);return S.onmessage=()=>{Cf(fr)},S.onerror=()=>{S.close()},()=>S.close()},[i,Fn,Cf,fr]),m.useEffect(()=>{if(!i.flowId)return;const w=Tr(i);w.set("clientId",ve.current);const S=new EventSource(`/api/workspace/events?${w.toString()}`);return S.onmessage=_=>{let P=null;try{P=JSON.parse(_.data||"{}")}catch{P=null}if(!(!P||P.clientId===ve.current)){if(P.type==="graph.committed"){Tg(P);return}if(P.type==="runtime.committed"){Tg(P);return}if(String(P.type||"").startsWith("file.")){En();return}String(P.type||"").startsWith("run.")&&_f()}},()=>{S.close(),Pe.current&&(window.clearTimeout(Pe.current),Pe.current=null),gt.current=!1}},[i,En,_f,Tg]),m.useEffect(()=>{if(Me.current)return;const w=q.current,S=new Map,_=[];for(const P of[...rs,...uu]){const R=mG(P);S.set(P.id,R),w.get(P.id)!==R&&_.push(P.id)}q.current=S,_.length!==0&&Br(_)},[uu,rs,Br]);const Ht=m.useMemo(()=>g.find(w=>w.id===Kt)||null,[g,Kt]),Lg=m.useRef({id:"",draft:null}),T$=m.useMemo(()=>{const w=FC(Ht);return w?JSON.stringify(w):""},[Ht==null?void 0:Ht.data,Ht==null?void 0:Ht.id]);m.useEffect(()=>{if(!Ht){Lg.current={id:"",draft:null},ys(null),ol("");return}const w=FC(Ht),S=Lg.current;Lg.current={id:Ht.id,draft:w},ys(_=>!_||_.id!==Ht.id||S.id!==Ht.id||!S.draft?w:pJ(_,S.draft,w)),ol("")},[Ht==null?void 0:Ht.id,T$]);const Og=m.useCallback((w=!1)=>{if(!ot||!Ht)return!1;if(!je)return ol("Readonly workspace"),me("Readonly workspace"),!1;ol("");const S=HC({nodes:g,edges:b,instances:Z.current,selectedNode:Ht,draft:ot,allowRename:w});return S!=null&&S.error?(ol(S.error),!1):(!(S!=null&&S.ok)||!S.changed||(Z.current=S.instances,re(S.instances),k(S.nodes),y(S.edges),S.nextId!==Ht.id&&Nn(S.nextId),Br(S.nextId)),!0)},[b,ot,g,Ht,y,k,Br,je]);m.useEffect(()=>{if(!je||!ot||!Ht)return;const w=window.setTimeout(()=>{Og(!1)},350);return()=>window.clearTimeout(w)},[ot==null?void 0:ot.label,ot==null?void 0:ot.role,ot==null?void 0:ot.model,ot==null?void 0:ot.body,JSON.stringify((ot==null?void 0:ot.images)||[]),ot==null?void 0:ot.script,ot==null?void 0:ot.scriptRef,ot==null?void 0:ot.implementationRef,ot==null?void 0:ot.implementationMode,JSON.stringify((ot==null?void 0:ot.inputs)||[]),JSON.stringify((ot==null?void 0:ot.outputs)||[]),Og,Ht==null?void 0:Ht.id,je]);const JS=m.useRef({refs:new Map,nodeDataById:new Map}),Dg=m.useMemo(()=>{const w=JS.current;let S=w.refs.size!==g.length;const _=new Map;for(const R of g)_.set(R.id,R.data),(!w.refs.has(R.id)||w.refs.get(R.id)!==R.data)&&(S=!0);if(!S)return w.nodeDataById;const P=new Map(g.map(R=>[R.id,R.data]));return JS.current={refs:_,nodeDataById:P},P},[g]),M$=m.useMemo(()=>b.map(w=>{var Y,oe;const S=Dg.get(w.source),_=Dg.get(w.target),P=/^output-(\d+)$/.exec(w.sourceHandle||""),R=/^input-(\d+)$/.exec(w.targetHandle||""),U=S&&P?(Y=S.outputs)==null?void 0:Y[parseInt(P[1],10)]:null,X=_&&R?(oe=_.inputs)==null?void 0:oe[parseInt(R[1],10)]:null,G=U!=null&&U.type?In(U.type):X!=null&&X.type?In(X.type):"";return G?{...w,style:{...w.style||{},stroke:G,strokeWidth:2},markerEnd:{type:xi.ArrowClosed,color:G}}:w}),[Dg,b]),XS=lt?uu:rs,$$=lt?[]:M$,L$=m.useMemo(()=>lt?uu.map(w=>({...w,id:Ip(w.id)})):rs,[uu,rs,lt]),Fg=m.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const _=lt?CC(S):S;lt?$([S]):(k(R=>R.map(U=>({...U,selected:U.id===_}))),y(R=>R.map(U=>({...U,selected:!1}))),Nn(_));const P=()=>{var oe,he,fe;const R=r.getNode(_);if(!R)return;const U=(oe=r.getInternalNode)==null?void 0:oe.call(r,_),X=((he=U==null?void 0:U.measured)==null?void 0:he.width)??(U==null?void 0:U.width)??R.width??260,G=((fe=U==null?void 0:U.measured)==null?void 0:fe.height)??(U==null?void 0:U.height)??R.height??120,{zoom:Y}=r.getViewport();r.setCenter(R.position.x+X/2,R.position.y+G/2,{zoom:SG(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(P))},[lt,r,y,k]);m.useEffect(()=>{const w=String(a.current||"").trim();!w||!le.current||c!=="workspace"||rs.some(S=>S.id===w)&&(a.current="",Fe.current=!0,Fg(w))},[rs,Fg,c]);const QS=m.useCallback(()=>{const w=r.getViewport(),S={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(lt){const _={...A.current,viewport:S};A.current=_,j(_),me("已固定 Display 进入视角")}else{H.current=S,O(S);try{window.localStorage.setItem(l,JSON.stringify(S))}catch{}me("已固定 Workspace 进入视角");return}Xt(v.current,x.current).catch(_=>me(String(_.message||_)))},[lt,r,Xt,l]),zg=m.useMemo(()=>{const w=_t.trim().toLowerCase(),S={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const _ of be)w&&![_.id,_.label,_.displayName,_.description].some(P=>String(P||"").toLowerCase().includes(w))||S[zu(_)].push(_);for(const _ of Ll)S[_].sort((P,R)=>P.id.localeCompare(R.id));return S},[be,_t]),du=m.useMemo(()=>{const w=Ce.trim().toLowerCase();return be.filter(S=>!w||[S.id,S.label,S.displayName,S.description].some(_=>String(_||"").toLowerCase().includes(w))).sort((S,_)=>{const P=Ll.indexOf(zu(S)),R=Ll.indexOf(zu(_));return P!==R?P-R:Bu(S).localeCompare(Bu(_))}).slice(0,30)},[be,Ce]),fu=m.useMemo(()=>{const w=Ce.trim().toLowerCase();return Ie.filter(S=>!w||[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].some(_=>String(_||"").toLowerCase().includes(w))).sort((S,_)=>String(S.displayName||S.name||S.id).localeCompare(String(_.displayName||_.name||_.id))).slice(0,30)},[Ie,Ce]);m.useEffect(()=>{St(0)},[Ce,Mn,pe]),m.useEffect(()=>{if(!Mn)return;const w=window.setTimeout(()=>{var S;return(S=tS.current)==null?void 0:S.focus()},0);return()=>window.clearTimeout(w)},[Mn]);const O$=m.useMemo(()=>{const w=mg.trim().toLowerCase();return w?uv(al).filter(S=>S.path.toLowerCase().includes(w)):al},[mg,al]),ga=m.useMemo(()=>KT(al,gg),[al,gg]),Di=(ga==null?void 0:ga.type)==="directory"?ga.path:JG((ga==null?void 0:ga.path)||""),D$=m.useCallback(w=>{var S,_;(_=(S=w.target)==null?void 0:S.closest)!=null&&_.call(S,".af-work-file")||yg("")},[]),F$=[...(ua.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(ua.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(ua.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(ua.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],Bg=m.useMemo(()=>new Set($s),[$s]),kl=m.useMemo(()=>{const w=new Map(Ms.map(U=>[U.key,U])),S=new Set,_=new Set,P=dl.map(U=>{const X=Xo(U,Ms).map(G=>w.get(G)).filter(Boolean);for(const G of X)S.add(G.key),_.add(String(G.name||G.id||G.key||"").trim());return{...U,skills:X}}).filter(U=>U.skills.length>0),R=Ms.filter(U=>{const X=String(U.name||U.id||U.key||"").trim();return!S.has(U.key)&&!_.has(X)});return{groups:P,ungrouped:R}},[dl,Ms]);m.useEffect(()=>{Zv(w=>{let S=!1;const _=new Set(w);for(const P of kl.groups)_.has(P.id)||(_.add(P.id),S=!0);return S?_:w})},[kl.groups]);const Qn=m.useMemo(()=>{const w=g.filter(S=>S.selected);return w.length>0?w:Kt?g.filter(S=>S.id===Kt):[]},[g,Kt]),Mf=m.useMemo(()=>Qn.map(w=>w.id),[Qn]),ZS=m.useCallback(()=>{if(lt)return;if(!je){me("Readonly workspace");return}const w=(v.current||[]).filter(G=>(G==null?void 0:G.selected)&&!lm(G));if(w.length<2){me("选择至少两个节点后按 G 创建 Group");return}const S=w.reduce((G,Y)=>{var He,ze,We,Be,Re,Ft,rt,Ye,Te,$t,Le,ct;const oe=Number(((He=Y.position)==null?void 0:He.x)||0),he=Number(((ze=Y.position)==null?void 0:ze.y)||0),fe=Number(((We=Y.measured)==null?void 0:We.width)||Y.width||((Re=(Be=Y.data)==null?void 0:Be.nodeSize)==null?void 0:Re.width)||((rt=(Ft=Y.data)==null?void 0:Ft.displaySize)==null?void 0:rt.width)||xT),Ne=Number(((Ye=Y.measured)==null?void 0:Ye.height)||Y.height||(($t=(Te=Y.data)==null?void 0:Te.nodeSize)==null?void 0:$t.height)||((ct=(Le=Y.data)==null?void 0:Le.displaySize)==null?void 0:ct.height)||rm);return{minX:Math.min(G.minX,oe),minY:Math.min(G.minY,he),maxX:Math.max(G.maxX,oe+fe),maxY:Math.max(G.maxY,he+Ne)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(S.minX)||!Number.isFinite(S.minY))return;const _=new Set((v.current||[]).map(G=>G.id));let P=1,R=`group_${P}`;for(;_.has(R);)P+=1,R=`group_${P}`;const U=sb({width:S.maxX-S.minX+Ep*2,height:S.maxY-S.minY+Ep*2})||{width:Xa,height:Qa},X={id:R,type:fc,position:{x:S.minX-Ep,y:S.minY-Ep},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:cm(P-1),title:cm(P-1),color:"purple",nodeSize:U}};k(G=>[X,...G.map(Y=>({...Y,selected:!1}))]),y(G=>G.map(Y=>({...Y,selected:!1}))),Nn(""),me(`Created group for ${w.length} nodes`)},[lt,y,k,je]),pu=m.useMemo(()=>g.filter(w=>An(w==null?void 0:w.data)),[g]),Hg=m.useMemo(()=>Qn.filter(w=>An(w==null?void 0:w.data)).map(w=>w.id),[Qn]),z$=m.useMemo(()=>{const w=String((Ir==null?void 0:Ir.username)||(Ir==null?void 0:Ir.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Ir]),Wg=m.useMemo(()=>new Set(Mf),[Mf]),$f=m.useMemo(()=>b.filter(w=>Wg.has(w.source)&&Wg.has(w.target)),[b,Wg]),Vg=m.useCallback(w=>{const S=w==="display"?"display":w==="workflow"?"workflow":"workspace";u(S),Nn(""),$([]),ne(null),K(!1),Ee(!1);const _=Tr(i);S==="display"&&_.set("view","display"),S==="workflow"&&(_.set("view","workflow"),fr.trim()&&_.set("tapdId",fr.trim()));const P=`/workspace${_.toString()?`?${_.toString()}`:""}`;window.history.pushState({},"",P)},[i,fr]),e0=m.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const _=v.current.find(P=>P.id===S);if(!_||!An(_.data)){me("展示节点不可用");return}j(P=>{if(P.nodeIds.includes(S))return P;const R=P.nodeIds.length,U=Dl(_);return{nodeIds:[...P.nodeIds,S],nodePositions:{...P.nodePositions,[S]:{x:180+R*36,y:120+R*28}},nodeSizes:{...P.nodeSizes,...U?{[S]:U}:{}}}}),$([S])},[]),t0=m.useCallback(w=>{const S=String(w||"").trim();S&&(j(_=>{const P=_.nodeIds.filter(X=>X!==S),R={..._.nodePositions},U={..._.nodeSizes};return delete R[S],delete U[S],{nodeIds:P,nodePositions:R,nodeSizes:U}}),$(_=>_.filter(P=>P!==S)))},[]),n0=m.useCallback(w=>{const S=String(w||"").trim();S&&(A.current.nodeIds.includes(S)?t0(S):e0(S))},[e0,t0]),Lf=m.useMemo(()=>{const w=wt.trim().toLowerCase();return w?bl.filter(S=>{var _,P;return[S.id,(_=S.data)==null?void 0:_.label,(P=S.data)==null?void 0:P.definitionId].filter(Boolean).some(R=>String(R).toLowerCase().includes(w))}):bl},[bl,wt]),r0=m.useMemo(()=>{const w=Lf.length,S=w<=1?1:w<=4?2:3,_=Array.from({length:S},()=>({height:0,nodes:[]}));for(const P of Lf){const R=Dl(P)||{width:420,height:260},U=Math.max(1,Number(R.width)||420),X=Math.max(1,Number(R.height)||260),G=Math.min(26,Math.max(5.5,X/U*16))+3.2;let Y=_[0];for(const oe of _)oe.height<Y.height&&(Y=oe);Y.nodes.push(P),Y.height+=G}return _.map(P=>P.nodes)},[Lf]),B$=m.useCallback(w=>{var U;const S=N.nodeIds.includes(w.id),_=Dl(w)||{width:420,height:260},P=Math.max(1,Math.round(Number(_.width)||420)),R=Math.max(1,Math.round(Number(_.height)||260));return o.jsxs("button",{type:"button",className:"af-display-picker-card"+(S?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${P} / ${R}`},onClick:()=>n0(w.id),children:[o.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:o.jsx("input",{type:"checkbox",checked:S,readOnly:!0,tabIndex:-1})}),o.jsx("span",{className:"af-display-picker-card__preview",children:o.jsx(DG,{node:w})}),o.jsxs("span",{className:"af-display-picker-card__meta",children:[o.jsx("strong",{children:((U=w.data)==null?void 0:U.label)||w.id}),o.jsxs("small",{children:[An(w.data)," · ",w.id]})]})]},w.id)},[N.nodeIds,n0]),s0=m.useMemo(()=>{const w=_t.trim().toLowerCase();return w?Ie.filter(S=>[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].filter(Boolean).some(_=>String(_).toLowerCase().includes(w))):Ie},[Ie,_t]),i0=m.useCallback((w,S)=>{const _=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let P=`${_}_${Date.now().toString(36)}`,R=2;for(;S.has(P);)P=`${_}_${Date.now().toString(36)}_${R}`,R+=1;return S.add(P),P},[]),hu=m.useCallback((w,S)=>{var Te,$t;if(!je){me("Readonly workspace");return}const _=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},P=_.instances&&typeof _.instances=="object"?_.instances:{},R=Object.keys(P);if(R.length===0)return;const U=new Set(v.current.map(Le=>Le.id)),X={};for(const Le of R)X[Le]=i0(Le,U);const G=(Te=_.ui)!=null&&Te.nodePositions&&typeof _.ui.nodePositions=="object"?_.ui.nodePositions:{},Y=($t=_.ui)!=null&&$t.nodeSizes&&typeof _.ui.nodeSizes=="object"?_.ui.nodeSizes:{},oe=R.map(Le=>{const ct=G[Le];return{id:Le,x:typeof(ct==null?void 0:ct.x)=="number"?ct.x:0,y:typeof(ct==null?void 0:ct.y)=="number"?ct.y:0}}),he=Math.min(...oe.map(Le=>Le.x)),fe=Math.min(...oe.map(Le=>Le.y));let Ne=S||{x:360+v.current.length*24,y:180+v.current.length*18};if(!S){const Le=document.querySelector(".af-workspace-canvas .react-flow");if(Le){const ct=Le.getBoundingClientRect();Ne=r.screenToFlowPosition({x:ct.left+ct.width*.48,y:ct.top+ct.height*.32})}}const He={},ze={},We={};for(const Le of oe){const ct=X[Le.id];He[ct]={...P[Le.id]||{}},ze[ct]={x:Ne.x+(Le.x-he),y:Ne.y+(Le.y-fe)};const Pt=Y[Le.id];typeof(Pt==null?void 0:Pt.width)=="number"&&typeof(Pt==null?void 0:Pt.height)=="number"&&(We[ct]={width:Pt.width,height:Pt.height})}const Be=new Set(R),Re=(Array.isArray(_.edges)?_.edges:[]).filter(Le=>Be.has(Le==null?void 0:Le.source)&&Be.has(Le==null?void 0:Le.target)).map(Le=>({source:X[Le.source],target:X[Le.target],sourceHandle:Le.sourceHandle??null,targetHandle:Le.targetHandle??null})),Ft=Eu({instances:He,edges:Re,ui:{nodePositions:ze,nodeSizes:We}},be),rt=Ft.nodes.map(Le=>Le.id),Ye=Ft.nodes.map(Le=>({...Le,selected:!0}));Z.current={...Z.current,...Ft.instances},re(Z.current),k(Le=>[...Le.map(ct=>({...ct,selected:!1})),...Ye]),y(Le=>[...Le.map(ct=>({...ct,selected:!1})),...Ft.edges.map(ct=>({...ct,selected:!1}))]),Nn(""),$([]),me(`已添加流程片段:${w.displayName||w.id}(已选中 ${rt.length} 个节点)`)},[i0,be,r,y,k,je]),H$=m.useCallback(()=>{var _,P;if(Qn.length<2){tr("请先在 workspace 画布上选择至少两个节点。"),te("flows");return}const w=Qn[0],S=Qn.length===2?`${((_=w.data)==null?void 0:_.label)||w.id} 片段`:`${((P=w.data)==null?void 0:P.label)||w.id} 等 ${Qn.length} 个节点`;Jn({name:S,id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),wr(""),nr(!0),te("flows")},[Qn]),W$=m.useCallback(async()=>{var R,U;if(Qn.length<2)return;const w=vn.name.trim();if(!w){wr("请填写片段名称。");return}const S={},_={};for(const X of Qn){S[X.id]={x:((R=X.position)==null?void 0:R.x)||0,y:((U=X.position)==null?void 0:U.y)||0};const G=Dl(X);G&&(_[X.id]=G)}const P=$f.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));ur(!0),wr("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:vn.id,name:w,displayName:w,version:"1.0.0",description:vn.description,snippet:{instances:ev(Qn,Z.current),edges:P,ui:{nodePositions:S,nodeSizes:_}}})}),G=await X.json().catch(()=>({}));if(!X.ok||G.ok===!1)throw new Error(G.error||"发布流程片段失败");nr(!1),me(`流程片段已发布:${G.id||w}`),Xv(`流程片段已发布:${G.id||w}`),await jf(),te("flows")}catch(X){wr(String(X.message||X))}finally{ur(!1)}},[jf,vn,$f,Qn,Xv]),o0=m.useCallback(async()=>{var S;const w=Uc.trim();if(w){Ev(!0),qc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,username:w,role:"editor"})}),P=await _.json().catch(()=>({}));if(!_.ok)throw new Error(P.error||"添加协作成员失败");dg(P.workspace||null),Pv(""),me(`已将 Workspace 分享给 ${((S=P.member)==null?void 0:S.username)||w}`)}catch(_){qc(String(_.message||_))}finally{Ev(!1)}}},[i,Uc]),V$=m.useCallback(()=>{qc(""),fg(!0)},[]),K$=m.useCallback(async w=>{const S=String((w==null?void 0:w.userId)||"").trim();if(!(!S||S===(rn==null?void 0:rn.ownerId))){Rv(S),qc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,memberUserId:S})}),P=await _.json().catch(()=>({}));if(!_.ok)throw new Error(P.error||"取消成员分享失败");dg(P.workspace||null),me(`已取消对 ${(w==null?void 0:w.username)||S} 的分享`)}catch(_){qc(String(_.message||_))}finally{Rv("")}}},[i,rn==null?void 0:rn.ownerId]),a0=m.useCallback(async()=>{const w=Tl(v.current,x.current,Z.current);w.ui={...w.ui||{},...H.current?{viewport:H.current}:{},displayPage:_C(A.current,v.current)};const S=new Blob([`${JSON.stringify(w,null,2)}
263
- `],{type:"application/json"}),_=URL.createObjectURL(S),P=document.createElement("a");P.href=_,P.download=`${i.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(_),await bs(),ll(null),ca(!1),me("已备份本地草稿并载入远端最新版本")},[x,i.flowId,bs,v]),q$=m.useCallback(async()=>{const w=Array.isArray(_n==null?void 0:_n.conflictItems)?_n.conflictItems:[];if(!w.length||!(_n!=null&&_n.mergeGraph)||!(_n!=null&&_n.currentGraph)){Yc("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let S=_n.mergeGraph;try{w.forEach((P,R)=>{const U=hg[String(R)]||{mode:"local"};let X,G=!0;U.mode==="remote"?(X=P.current,G=P.hasCurrent!==!1):U.mode==="manual"?X=JSON.parse(String(U.manual||"")):(X=P.incoming,G=P.hasIncoming!==!1),S=kJ(S,P.pathParts,X,G)})}catch(P){Yc(`手动值不是有效 JSON:${String(P.message||P)}`);return}Tv(!0),Yc(""),Os("saving"),Ds("正在提交冲突解决结果");const _=Qe.current.catch(()=>{}).then(async()=>{const P=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:S,baseRevision:_n.currentRevision,baseGraph:_n.currentGraph,clientId:ve.current})}),R=await P.json().catch(()=>({}));if(!P.ok){if(P.status===409&&Array.isArray(R.conflictItems)){const U=R.conflictItems;ll({currentRevision:String(R.currentRevision||""),message:R.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(R.conflictPaths)?R.conflictPaths:[],conflictItems:U,mergeGraph:R.mergeGraph||null,currentGraph:R.currentGraph||null}),cl(Object.fromEntries(U.map((X,G)=>[String(G),{mode:"local",manual:Au(X)}])))}throw new Error(R.error||"提交冲突解决结果失败")}await bs(),ll(null),ca(!1),me("冲突已解决并保存")});Qe.current=_;try{await _}catch(P){Yc(String(P.message||P)),Os("error"),Ds(String(P.message||P))}finally{Tv(!1)}},[i,bs,_n,hg]);m.useCallback(()=>{if(pu.length===0){me("当前 workspace 没有 display 节点");return}const w=Hg.length>0?Hg:pu.map(_=>_.id),S=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display";ke(nw({title:S,layout:"gallery",nodeIds:w,mode:"multi-node"})),dr(""),Ut(null),br(!0)},[i.flowId,Hg,pu]);const U$=m.useCallback(w=>{ke(S=>{const _=Array.isArray(S.nodeIds)?S.nodeIds:[];return _.includes(w)?{...S,nodeIds:_.filter(P=>P!==w)}:{...S,nodeIds:[..._,w]}})},[]),zs=m.useCallback(async()=>{Xn(!0),zr("");try{const w=await fetch("/api/display/shares"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取分享列表失败");Sr(Array.isArray(S.shares)?S.shares:[])}catch(w){zr(String(w.message||w)),Sr([])}finally{Xn(!1)}},[]),Y$=m.useCallback(()=>{Yt(!0),ie(""),zs()},[zs]),G$=m.useCallback(async()=>{var _,P;const w=ae.title.trim(),S=Array.isArray(ae.nodeIds)?ae.nodeIds:[];if(S.length===0){dr("请选择至少一个 display 节点。");return}Vn(!0),dr(""),Ut(null);try{await Xt(g,b);const R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:w,layout:ae.layout,nodeIds:S,...AC(ae)})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"发布展示页失败");const X=new URL(U.url||`/display/${((_=U.share)==null?void 0:_.id)||""}`,window.location.origin).href;Ut({...U,absoluteUrl:X}),me((P=U.share)!=null&&P.expiresAt?"展示页已生成":"展示页已生成:永久有效"),ft&&zs()}catch(R){dr(String(R.message||R))}finally{Vn(!1)}},[ae,ft,b,i,zs,g,Xt]),J$=m.useCallback(async()=>{var S,_;const w=Array.isArray(N.nodeIds)?N.nodeIds:[];if(w.length===0){dr("请先添加至少一个展示节点。"),me("请先添加至少一个展示节点"),Ee(!0);return}Vn(!0),dr("");try{await Xt(g,b);const P=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display",R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:P,layout:"canvas",nodeIds:w,...AC(ae)})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"生成展示链接失败");const X=new URL(U.url||`/display/${((S=U.share)==null?void 0:S.id)||""}`,window.location.origin).href;Ut({...U,absoluteUrl:X}),On(!0),me((_=U.share)!=null&&_.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),ft&&zs()}catch(P){const R=String(P.message||P);dr(R),me(R)}finally{Vn(!1)}},[N.nodeIds,ae,ft,b,i,zs,g,Xt]),l0=m.useCallback(async()=>{const w=vt==null?void 0:vt.absoluteUrl;if(!w)return;const S=await ob(w);vr(S?"copied":"failed"),window.setTimeout(()=>vr(""),1600)},[vt==null?void 0:vt.absoluteUrl]),X$=m.useCallback(async w=>{const S=PC(w),_=await ob(S);ie(_?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>ie(""),1600)},[]),Q$=m.useCallback(async(w,S)=>{const _=String((w==null?void 0:w.id)||"");if(_){ai(_),zr("");try{const P=S==="permanent"?{id:_,expiresMode:"permanent",permanent:!0}:{id:_,expiresMode:"days",expiresInDays:Number(S||30)},R=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await zs(),me("分享有效期已更新")}catch(P){zr(String(P.message||P))}finally{ai("")}}},[zs]),Z$=m.useCallback(async w=>{const S=String((w==null?void 0:w.id)||"");if(S){ai(S),zr("");try{const _=await fetch(`/api/display/share?id=${encodeURIComponent(S)}`,{method:"DELETE"}),P=await _.json().catch(()=>({}));if(!_.ok||P.ok===!1)throw new Error(P.error||"撤销分享失败");await zs(),me("分享已撤销")}catch(_){zr(String(_.message||_))}finally{ai("")}}},[zs]),e2=m.useCallback(w=>{k(S=>S.map(_=>_.id===w?{..._,selected:!1}:_)),Nn(S=>S===w?"":S)},[k]),vl=m.useCallback(()=>{const w=jg.current;if(!w)return;const S=w.getBoundingClientRect(),_=Math.min(420,Math.max(320,S.width+160)),P=12,R=Math.max(180,S.top-P*2),U=Math.min(560,R);y$({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-_-12,S.left)),top:Math.max(P,S.top-U-P),width:_,maxHeight:U,zIndex:1e4})},[]);m.useEffect(()=>{if(!vf)return;vl();const w=_=>{var R,U;const P=_.target;(R=jg.current)!=null&&R.contains(P)||(U=eS.current)!=null&&U.contains(P)||Ng(!1)},S=_=>{_.key==="Escape"&&Ng(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",S),window.addEventListener("resize",vl),window.addEventListener("scroll",vl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",S),window.removeEventListener("resize",vl),window.removeEventListener("scroll",vl,!0)}},[vf,vl]);const Sl=m.useCallback(w=>{const S=YU(w);if(S.active?(Me.current||ns(),Me.current=!0):S.finished&&(!Me.current&&S.mutated&&ns(),Me.current=!1,ue.current=!0),c==="display"){S.mutated&&!S.active&&!S.finished&&ns(),j(R=>{var Y,oe;let U=R.nodePositions,X=R.nodeSizes;for(const he of w||[]){const fe=Ip(he==null?void 0:he.id);if(!(!fe||!R.nodeIds.includes(fe))&&he.type!=="select"){if(he.type==="position"&&he.position){const Ne=U[fe];if((Ne==null?void 0:Ne.x)===he.position.x&&(Ne==null?void 0:Ne.y)===he.position.y)continue;U===R.nodePositions&&(U={...R.nodePositions}),U[fe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((Y=he.dimensions)!=null&&Y.width)&&((oe=he.dimensions)!=null&&oe.height)){const Ne=Fa({width:Math.round(Number(he.dimensions.width)),height:Math.round(Number(he.dimensions.height))},{display:!0});if(Ne){const He=X[fe];if((He==null?void 0:He.width)===Ne.width&&(He==null?void 0:He.height)===Ne.height)continue;X===R.nodeSizes&&(X={...R.nodeSizes}),X[fe]=Ne}}}}if(U===R.nodePositions&&X===R.nodeSizes)return R;const G={...R,nodePositions:U,nodeSizes:X};return A.current=G,G});const P=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");P.length>0&&$(R=>{const U=new Set(R);for(const G of P){const Y=Ip(G==null?void 0:G.id);Y&&(G.selected?U.add(Y):U.delete(Y))}const X=Array.from(U);return X.length===R.length&&X.every((G,Y)=>G===R[Y])?R:X});return}if(!je){const P=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");P.length>0&&k(R=>Uh(P,R));return}S.mutated&&!S.active&&!S.finished&&ns();const _=(w||[]).filter(P=>{var R,U;return(P==null?void 0:P.type)==="dimensions"&&((R=P.dimensions)==null?void 0:R.width)&&((U=P.dimensions)==null?void 0:U.height)});k(P=>{const R=new Map;if(_.length>0){const G=new Map(P.map(Y=>[Y.id,Y]));for(const Y of _){const oe=G.get(Y.id),he={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=lm(oe)?sb(he):Fa(he,{display:!!An(oe==null?void 0:oe.data)});fe&&R.set(Y.id,fe)}}const U=Uh(w,P),X=R.size===0?U:U.map(G=>{const Y=R.get(G.id);if(!Y)return G;const oe={...G.data,nodeSize:Y};return An(G.data)&&(oe.displaySize=Y),{...G,width:Y.width,height:Y.height,data:oe}});return v.current=X,X}),_.length>0&&Br(_.map(P=>P.id))},[ns,Br,k,c,je]),Of=m.useCallback((w=[],{finish:S=!1}={})=>{V.current!=null&&(window.cancelAnimationFrame(V.current),V.current=null);const _=E.current;E.current=[];const P=S?XU([...Q.current,..._,...w]):ah([..._,...w]);S&&(Q.current=[]),P.length>0&&Sl(P)},[Sl]),c0=m.useCallback(()=>{V.current==null&&(V.current=window.requestAnimationFrame(()=>{V.current=null;const w=E.current;E.current=[],w.length>0&&Sl(w)}))},[Sl]),t2=m.useCallback(w=>{const S=[],_=[];let P=!1;for(const R of Array.isArray(w)?w:[])GU(R)?S.push(R):(_.push(R),JU(R)&&(P=!0));if(S.length>0&&(Q.current=ah([...Q.current,...S]),E.current=ah([...E.current,...S])),P){Of(_,{finish:!0});return}_.length>0&&Sl(_),E.current.length>0&&c0()},[Sl,Of,c0]);m.useEffect(()=>{const w=()=>{!Me.current&&E.current.length===0&&Q.current.length===0||Of([],{finish:!0})},S=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w),window.addEventListener("blur",w),document.addEventListener("visibilitychange",S),()=>{window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",S),V.current!=null&&window.cancelAnimationFrame(V.current),E.current=[],Q.current=[]}},[Of]);const n2=m.useCallback(w=>{if(c!=="display"){if(!je){const S=(w||[]).filter(_=>(_==null?void 0:_.type)==="select");S.length>0&&y(_=>{const P=Yh(S,_);return x.current=P,P});return}(w||[]).some(S=>(S==null?void 0:S.type)!=="select")&&ns(),y(S=>{const _=Yh(w,S);return x.current=_,_})}},[ns,y,c,je]),Nl=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const S=w.getBoundingClientRect();return r.screenToFlowPosition({x:S.left+S.width*.48,y:S.top+S.height*.32})}return{x:360+g.length*36,y:180+g.length*28}},[g.length,r]),Df=m.useCallback(()=>{var w,S,_;if(Ht){const P=Number(((w=Ht.measured)==null?void 0:w.width)||Ht.width||260);return{x:Number(((S=Ht.position)==null?void 0:S.x)||0)+P+140,y:Number(((_=Ht.position)==null?void 0:_.y)||0)}}return Nl()},[Nl,Ht]),Fi=m.useCallback((w,S={})=>{if(!je)return me("Readonly workspace"),null;if(!w)return null;const _=av(w)||w.id,P=PT(w),R=RT(w),U=S.id||oG(_,g),X=Wu(w.inputs),G=Wu(w.outputs),Y={definitionId:_,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:S.label||am(w),role:"normal",body:S.body||"",...S.script||R?{script:S.script||R}:{},...S.scriptRef?{scriptRef:S.scriptRef}:{},...S.implementationRef?{implementationRef:S.implementationRef}:{},...S.implementationMode?{implementationMode:S.implementationMode}:{},input:S.inputs||X,output:S.outputs||G},oe={id:U,type:fc,position:S.position||Nl(),data:{label:Y.label,definitionId:_,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:AT(_,w),role:"normal",body:Y.body,...Y.script?{script:Y.script}:{},...Y.scriptRef?{scriptRef:Y.scriptRef}:{},...Y.implementationRef?{implementationRef:Y.implementationRef}:{},...Y.implementationMode?{implementationMode:Y.implementationMode}:{},inputs:Y.input,outputs:Y.output}},he={...Xx(oe,{...Z.current,[U]:Y},be),selected:!0};return ns(),k(fe=>[...fe.map(Ne=>({...Ne,selected:!1})),he]),S.openProperties&&Nn(U),U},[Nl,ns,g,be,k,je]),r2=m.useCallback(w=>ew(w,v.current),[]),s2=m.useCallback(w=>{if(!je){me("Readonly workspace");return}if(!ew(w,v.current)){me("端口类型不匹配,已取消连线");return}ne(null),ns(),k(S=>Gy(S,w)),y(S=>{const _=S.filter(R=>!(R.target===w.target&&R.targetHandle===w.targetHandle)),P=sh({...w,markerEnd:{type:xi.ArrowClosed}},_);return x.current=P,P})},[ns,y,k,je]),i2=m.useCallback((w,S)=>{if(!je)return;const _=rG(S,v.current);se.current=_?{..._,preferExisting:!!(w!=null&&w.shiftKey)}:null,ne(null)},[je]),o2=m.useCallback((w,S)=>{var Be,Re,Ft,rt;if(!je)return;const _=se.current;if(se.current=null,!_||S!=null&&S.toNode)return;const P=sG(be,_),R=iG(v.current,x.current,_);if(P.length===0&&R.length===0){me(`没有匹配 ${_.slotType} 端口的节点`);return}const X=!!(w!=null&&w.shiftKey||_.preferExisting)?R.length>0?"existing":"create":P.length>0?"create":"existing",G=((Re=(Be=w==null?void 0:w.changedTouches)==null?void 0:Be[0])==null?void 0:Re.clientX)??(w==null?void 0:w.clientX),Y=((rt=(Ft=w==null?void 0:w.changedTouches)==null?void 0:Ft[0])==null?void 0:rt.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(G)||!Number.isFinite(Y))return;const oe=document.querySelector(".af-workspace-canvas .react-flow");if(!oe)return;const he=oe.getBoundingClientRect(),fe=320,Ne=Math.max(P.length,R.length),He=Math.min(480,150+Ne*58),ze=Math.max(12,Math.min(G-he.left,he.width-fe-12)),We=Math.max(12,Math.min(Y-he.top,he.height-He-12));ne({left:ze,top:We,flowPosition:r.screenToFlowPosition({x:G,y:Y}),draft:_,candidates:P,existingCandidates:R,mode:X,query:""})},[be,r,je]),a2=m.useCallback(w=>{if(!je){me("Readonly workspace"),ne(null);return}const S=ce.current;if(!S||!(w!=null&&w.def))return;const _=Fi(w.def,{position:S.flowPosition});if(!_)return;const P=S.draft.handleType==="source"?{source:S.draft.nodeId,sourceHandle:S.draft.handleId,target:_,targetHandle:`input-${w.slotIndex}`}:{source:_,sourceHandle:`output-${w.slotIndex}`,target:S.draft.nodeId,targetHandle:S.draft.handleId};k(R=>Gy(R,P)),y(R=>{const U=R.filter(G=>!(G.target===P.target&&G.targetHandle===P.targetHandle)),X=sh({...P,markerEnd:{type:xi.ArrowClosed}},U);return x.current=X,X}),ne(null)},[Fi,y,je]),l2=m.useCallback(w=>{if(!je){me("Readonly workspace"),ne(null);return}const S=w==null?void 0:w.connection;if(!S||!ew(S,v.current)){me("端口类型不匹配,已取消连线"),ne(null);return}k(_=>Gy(_,S)),y(_=>{const P=_.filter(U=>!(U.target===S.target&&U.targetHandle===S.targetHandle)),R=sh({...S,markerEnd:{type:xi.ArrowClosed}},P);return x.current=R,R}),ne(null)},[y,k,je]),u0=m.useCallback(w=>{w&&(Fi(w,{position:Df()}),K(!1),et(""))},[Fi,Df]),d0=m.useCallback(w=>{w&&(hu(w,Df()),K(!1),et(""))},[hu,Df]),c2=m.useCallback(w=>{var _,P,R;if(lt||Fn)return;const S=w==null?void 0:w.target;gC(S)||(_=S==null?void 0:S.closest)!=null&&_.call(S,"button, a, [role='button'], .react-flow__handle")||(R=(P=C.current)==null?void 0:P.focus)==null||R.call(P,{preventScroll:!0})},[lt,Fn]);m.useEffect(()=>{const w=S=>{var oe;if(S.defaultPrevented)return;const _=nU(S.target)||gC(S.target);if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="s"){S.preventDefault(),Xt().catch(he=>me(String(he.message||he)));return}if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"){S.preventDefault(),S.stopPropagation(),cS(he=>!he);return}if(Pg)return;if(Ag){(S.key==="Escape"||Q1(S))&&(S.preventDefault(),Nf(!1));return}const P=S.key.toLowerCase(),R=(S.metaKey||S.ctrlKey)&&P==="c",U=(S.metaKey||S.ctrlKey)&&P==="v",X=_&&R&&xY(S.target);if(_&&!X)return;const G=(S.metaKey||S.ctrlKey)&&!S.shiftKey&&P==="z",Y=(S.metaKey||S.ctrlKey)&&(S.shiftKey&&P==="z"||P==="y");if(G||Y){if(lt){S.preventDefault(),S.stopPropagation(),me("展示页布局会自动保存");return}if(!je){S.preventDefault(),me("Readonly workspace");return}S.preventDefault(),S.stopPropagation();const he=G?NS():jS();me(he?G?"Undo canvas change":"Redo canvas change":G?"Nothing to undo":"Nothing to redo");return}if(R){if(lt)return;const he=mo.current,fe=(v.current||[]).some(He=>He==null?void 0:He.selected)?v.current:(v.current||[]).map(He=>he&&He.id===he?{...He,selected:!0}:He),Ne=jq(fe,x.current,Z.current);Ne&&(S.preventDefault(),S.stopPropagation(),F.current=Ne,kG(Ne),X&&typeof((oe=S.target)==null?void 0:oe.blur)=="function"&&S.target.blur(),me(`Copied ${Ne.nodes.length} node${Ne.nodes.length>1?"s":""}`));return}if(U){if(lt){S.preventDefault(),S.stopPropagation();return}if(!je){S.preventDefault(),me("Readonly workspace");return}const he=F.current||vG();he&&!F.current&&(F.current=he);const fe=Cq(he,v.current,x.current,Z.current);fe&&(S.preventDefault(),S.stopPropagation(),Z.current=fe.instances,re(fe.instances),k(fe.nodes),y(fe.edges),me(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(Q1(S)&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),Nf(!0);return}if(P==="g"&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),ZS();return}if(S.key==="a"||S.key==="A"){if(S.metaKey||S.ctrlKey){S.preventDefault(),lt?$(A.current.nodeIds):(k(he=>he.map(fe=>({...fe,selected:!0}))),y(he=>he.map(fe=>({...fe,selected:!1}))));return}if(S.altKey)return;if(lt){S.preventDefault(),Ee(!0);return}if(!je){S.preventDefault(),me("Readonly workspace");return}S.preventDefault(),K(!0);return}if((S.key==="v"||S.key==="V")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),uS("select");return}if((S.key==="h"||S.key==="H")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),uS("pan");return}(S.key==="f"||S.key==="F")&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&(S.preventDefault(),QS())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[ZS,lt,Pg,QS,jS,Xt,Ag,y,k,NS,je]);const u2=m.useCallback(w=>{ul(S=>{const _=new Set(S);return _.has(w)?_.delete(w):_.add(w),_})},[]),d2=m.useCallback((w,S)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:S.path,name:S.name,type:S.type})),w.dataTransfer.setData("text/plain",S.path)},[]),f2=m.useCallback((w,S)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",S.id),w.dataTransfer.setData("text/plain",S.id)},[]),Ff=m.useCallback(async(w,S)=>{const _=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),P=_.split(".").pop(),R=["jsx","tsx","js"].includes(P)?"display_react_app":P==="html"?"display_html":P==="csv"||P==="tsv"||P==="json"&&/\b(table|data|rows|report)\b/i.test(_)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(P)?"display_image":"display_markdown",U=be.find(fe=>fe.id===R);if(!U){me("展示节点不可用");return}const X=R==="display_image";let G=String(w.path||"");if(!X){const fe=Tr(i);fe.set("path",w.path);const Ne=await fetch(`/api/workspace/file?${fe.toString()}`),He=await Ne.json();if(!Ne.ok)throw new Error(He.error||"读取文件失败");G=String(He.content||"")}const Y=R==="display_image"?"src":"content",oe=Wu(U.inputs).map(fe=>fe.name===Y?{...fe,default:G,value:G}:fe),he=Wu(U.outputs).map(fe=>fe.name===Y?{...fe,default:G,value:G}:fe);Fi(U,{label:w.name||"Display",body:G,inputs:oe,outputs:he,position:S}),me(`已创建展示:${w.path}`)},[Fi,i,be]),p2=m.useCallback(w=>{if(!je){me("Readonly workspace");return}Ff(w,Nl()).catch(S=>me(String(S.message||S)))},[Ff,Nl,je]),h2=m.useCallback(w=>{if(!je){w.preventDefault(),me("Readonly workspace");return}const S=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(S){w.preventDefault();let X;try{X=JSON.parse(S)}catch{return}if(!(X!=null&&X.path))return;const G=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Ff(X,G).catch(Y=>me(String(Y.message||Y)));return}const _=w.dataTransfer.getData("application/agentflow-snippet");if(_){const X=Ie.find(Y=>`${Y.id}@${Y.version}`===_);if(!X)return;w.preventDefault();const G=r.screenToFlowPosition({x:w.clientX,y:w.clientY});hu(X,G);return}const P=w.dataTransfer.getData("application/agentflow-node");if(!P)return;const R=be.find(X=>X.id===P);if(!R)return;w.preventDefault();const U=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Fi(R,{position:U})},[Ff,Fi,Ie,hu,be,r,je]),m2=m.useCallback(w=>{if(!je)return;const S=Array.from(w.dataTransfer.types||[]);!S.includes("application/x-agentflow-workspace-file")&&!S.includes("application/agentflow-node")&&!S.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=S.includes("application/agentflow-node")||S.includes("application/agentflow-snippet")?"move":"copy")},[je]),g2=m.useCallback(async(w="")=>{if(!je){me("Readonly workspace");return}const S=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!S)return;const _=w&&!S.includes("/")?`${w}/${S}`:S;try{const P=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:_,content:""})}),R=await P.json();if(!P.ok)throw new Error(R.error||"创建文件失败");await En(),ul(U=>{const X=new Set(U);for(const G of Rp(R.path||_))X.delete(G);return X}),me(`已创建 ${R.path}`)}catch(P){me(String(P.message||P))}},[i,En,je]),y2=m.useCallback(async(w="")=>{if(!je){me("Readonly workspace");return}const S=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!S)return;const _=w&&!S.includes("/")?`${w}/${S}`:S;try{const P=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:_})}),R=await P.json();if(!P.ok)throw new Error(R.error||"创建文件夹失败");await En(),ul(U=>{const X=new Set(U);for(const G of Rp(R.path||_))X.delete(G);return R.path&&X.delete(R.path),X}),me(`已创建 ${R.path}`)}catch(P){me(String(P.message||P))}},[i,En,je]),w2=m.useCallback(async w=>{if(!je){me("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const S=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:w.path})}),_=await S.json();if(!S.ok)throw new Error(_.error||"删除失败");me(`已删除 ${_.path}`),await En()}catch(S){me(String(S.message||S))}},[i,En,je]),x2=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const S=Wd(w.path,i,{download:!0});if(!S)return;const _=document.createElement("a");_.href=S,_.download=w.name||w.path.split("/").pop()||"download",_.rel="noopener",document.body.appendChild(_),_.click(),_.remove()},[i]),zf=m.useCallback(async()=>{if(!je){me("Readonly workspace");return}const w=da.trim(),S=Hr,_=Ls.find(X=>X.id===S)||null;if(!w||ts||(_==null?void 0:_.status)==="running"||(_==null?void 0:_.status)==="stopping")return;const P=_?Array.isArray(_.messages)?_.messages:[]:fa,R=Tl(g,b,Z.current);Cg(""),nS(!0),hl(!0),ml(null);const U={role:"user",text:w,at:Date.now()};_?Kn(X=>X.map(G=>G.id===S?{...G,status:"running",messages:[...Array.isArray(G.messages)?G.messages:[],U].slice(-180)}:G)):(xs("workspace"),pl(X=>[...X,U]));try{await Xt(g,b);const X=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,prompt:w,outputKind:"markdown",workspaceGraph:R,allowFlowYaml:!1,model:$i,selectedSkills:$s,selectedNodeIds:Mf,messages:P})}),G=await X.json();if(!X.ok)throw new Error(G.error||"生成失败");const oe={role:"assistant",kind:"assistant",text:String(G.content||"").trim(),at:Date.now()};_?Kn(he=>he.map(fe=>fe.id===S?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],oe].slice(-180)}:fe)):pl(he=>[...he,oe]),await bs(),me("AI 生成完成")}catch(X){const G=String(X.message||X),Y={role:"assistant",text:G,error:!0,at:Date.now()};_?Kn(oe=>oe.map(he=>he.id===S?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],Y].slice(-180)}:he)):pl(oe=>[...oe,Y]),me(G)}finally{nS(!1)}},[Hr,fa,$i,Ls,ts,da,b,i,bs,g,Xt,Mf,$s,je]),rr=Ls.find(w=>w.id===Hr)||null,Kg=rr?Array.isArray(rr.messages)?rr.messages:[]:fa,jl=rr&&(rr.status==="running"||rr.status==="stopping")||ts,b2=rJ(Kg,jl),qg=sJ(Kg),f0=rr?rr.status==="stopping"?`${rr.label} stopping`:rr.status==="running"?`${rr.label} running`:rr.status==="paused"?`${rr.label} paused`:rr.status==="failed"?`${rr.label} failed`:`${rr.label} done`:ts?"Workspace agent running":fa.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{Hr!=="workspace"&&(Ls.some(w=>w.id===Hr)||xs(ma()))},[Hr,Ls,ma]),m.useEffect(()=>{if(!Zc)return;const w=window.requestAnimationFrame(()=>{var _,P;const S=rS.current;S&&(S.scrollTop=S.scrollHeight),(P=(_=_g.current)==null?void 0:_.scrollIntoView)==null||P.call(_,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[Kg.length,Hr,f0,qg.length,Zc]);const k2=String(i.flowId||"").trim()||"Workspace",yo=(ae==null?void 0:ae.mode)==="single-node",p0=yo&&pu.find(w=>{var S;return w.id===ae.sourceNodeId||((S=ae.nodeIds)==null?void 0:S.includes(w.id))})||null,v2=yo&&p0?[p0]:pu;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:()=>n("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:i.flowId?`${i.flowId} · ${_v}`:_v||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:k2}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",uY,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:c==="workspace"?"af-view-switch__active":"",onClick:()=>Vg("workspace"),children:"Workspace"}),o.jsx("button",{type:"button",className:c==="display"?"af-view-switch__active":"",onClick:()=>Vg("display"),children:"Display"}),o.jsx("button",{type:"button",className:c==="workflow"?"af-view-switch__active":"",onClick:()=>Vg("workflow"),children:"Workflow"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:`af-workspace-sync-light is-${gS}`,title:`${vS} · ${yS}`,role:"status","aria-label":`${vS}:${yS}`,children:o.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),_n?o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=_n.conflictItems)!=null&&w.length?ca(!0):a0()},title:["先下载当前本地草稿,再载入远端最新版本",..._n.conflictPaths||[]].join(`
264
- `),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,lt?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:mn||!(vt!=null&&vt.absoluteUrl)&&N.nodeIds.length===0,onClick:()=>{vr(""),On(!0)},title:vt!=null&&vt.absoluteUrl?"查看展示链接":N.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:mn?"hourglass_empty":"ios_share"}),mn?"生成中":vt!=null&&vt.absoluteUrl?"展示链接":"生成链接"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:bl.length===0,onClick:()=>Ee(!0),title:bl.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!!(rn!=null&&rn.role&&rn.role!=="owner"),onClick:V$,title:rn!=null&&rn.role&&rn.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:Y$,title:"查看我的展示分享",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!kS,onClick:()=>f(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:o.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!kS&&!ou,onClick:()=>h(!0),"aria-label":ou?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:ou?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:o.jsx("span",{className:"material-symbols-outlined",children:ou?"logout":"delete_forever"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Nf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Zc?" af-composer-topbar-btn--active":"")+(ts?" af-composer-topbar-btn--running":""),disabled:lt||Fn,onClick:()=>{ml(null),hl(w=>(w||xs(ma()),!w))},children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!je,onClick:()=>Xt().catch(w=>me(String(w.message||w))),children:"Save"})]})]}),Rs?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:Rs}),o.jsx("button",{type:"button",onClick:()=>Fr(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(!lt&&!Fn&&(Zc||ot)?" af-workspace-body--drawer":"")+(!lt&&!Fn&&tu?" af-workspace-body--sidebar-collapsed":"")+(lt?" af-workspace-body--display-mode":"")+(Fn?" af-workspace-body--workflow-mode":""),children:[!lt&&!Fn&&tu?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:()=>K(!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:()=>Sf(!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:()=>Sf(!1),"aria-label":"展开侧边栏",title:(Ir==null?void 0:Ir.username)||(Ir==null?void 0:Ir.userId)||"展开侧边栏",children:z$})]})}):null,!lt&&!Fn?o.jsxs("aside",{ref:Ov,className:"af-workspace-sidebar"+(i$?" af-workspace-sidebar--resizing":""),"aria-hidden":tu,style:{"--af-work-files-pane-height":`${Math.round(xg)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Sf(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je,onClick:()=>g2(Di),"aria-label":"新增文件",title:Di?`在 ${Di} 新增文件`:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je,onClick:()=>y2(Di),"aria-label":"新增文件夹",title:Di?`在 ${Di} 新增文件夹`:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!je||$v,onClick:()=>FS(Di),"aria-label":"上传文件",title:Di?`上传到 ${Di}`:"上传文件",children:o.jsx("span",{className:"material-symbols-outlined",children:$v?"hourglass_top":"upload_file"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void En(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("input",{ref:Dv,type:"file",multiple:!0,className:"af-visually-hidden",onChange:P$})]})]}),o.jsx("input",{className:"af-workspace-search",value:mg,onChange:w=>n$(w.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",onClick:D$,children:o.jsx(YT,{items:O$,onOpen:p2,selectedPath:gg,collapsedDirs:r$,onToggleDir:u2,onSelect:w=>yg(w.path||""),onFileDragStart:d2,onDelete:w2,onDownload:x2})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:h$,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:tn==="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:_t,onChange:w=>hn(w.target.value),placeholder:tn==="flows"?"搜索流程片段...":"搜索节点...","aria-label":tn==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":tn==="nodes",className:"af-palette-tab"+(tn==="nodes"?" af-palette-tab--active":""),onClick:()=>te("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":tn==="flows",className:"af-palette-tab"+(tn==="flows"?" af-palette-tab--active":""),onClick:()=>te("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:tn==="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:H$,disabled:Qn.length<2,title:Qn.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:["已选 ",Qn.length," 节点 / ",$f.length," 连线"]})]})}),At?o.jsx("p",{className:"af-err af-palette-list-err",children:At}):null,Ze?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):s0.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:s0.map(w=>{const S=`${w.id}@${w.version}`,_=w.displayName||w.name||w.id,P=w.description||`${w.nodeCount||0} 个节点,${w.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:R=>{R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("application/agentflow-snippet",S),R.dataTransfer.setData("text/plain",S)},onClick:()=>hu(w),title:P,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:_}),o.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),P?o.jsx("span",{className:"af-palette-card-desc",children:P}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[w.nodeCount||0," nodes"]}),o.jsxs("span",{children:[w.edgeCount||0," edges"]})]})]},S)})})]}):o.jsx("p",{className:"af-palette-empty",children:_t.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Ll.map(w=>{var S;return(S=zg[w])!=null&&S.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${w}`,children:[o.jsx("h3",{className:"af-palette-cat",children:w}),o.jsx("div",{className:"af-palette-cards",children:zg[w].map(_=>{const P=SC(_.inputs,"input"),R=SC(_.outputs,"output"),U=rb(_),X=Bu(_);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:G=>f2(G,_),onClick:()=>Fi(_),title:U||_.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:kC(w)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:X}),X!==_.id?o.jsx("span",{className:"af-palette-card-id",children:_.id}):null]})]}),U?o.jsx("span",{className:"af-palette-card-desc",children:U}):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:[P.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[P.shown.map((G,Y)=>o.jsxs("span",{className:"af-palette-card-port",title:vC("input",G,Y),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:In(G==null?void 0:G.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Ap(G,Y)})]},`in-${Y}`)),P.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",P.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:[R.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[R.shown.map((G,Y)=>o.jsxs("span",{className:"af-palette-card-port",title:vC("output",G,Y),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Ap(G,Y)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:In(G==null?void 0:G.type)}})]},`out-${Y}`)),R.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",R.hidden]}):null]})]})]})]},_.id)})})]},w):null}),be.length>0&&_t.trim()&&Ll.every(w=>{var S;return!((S=zg[w])!=null&&S.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,Fn?o.jsx(bJ,{flowParams:i,tapdId:fr,setTapdId:d$,snapshot:sn,loading:f$,error:p$,actionRunning:bg,actionOutput:kg,pendingConfirm:ws,conflict:Xc,reviewPublishing:vg,onRefresh:()=>Cf(fr),onRunDryRun:S$,onConfirmAction:N$,onRetryConflict:j$,onPublishReview:C$}):o.jsxs("main",{ref:C,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:c2,children:[o.jsx(lR,{className:"af-flow-canvas af-workspace-flow"+(Ig==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(lt?" af-workspace-flow--display-mode":""),nodes:XS,edges:$$,nodeTypes:GG,onNodesChange:t2,onEdgesChange:n2,onConnect:lt?void 0:s2,onConnectStart:lt?void 0:i2,onConnectEnd:lt?void 0:o2,isValidConnection:lt?void 0:r2,onNodeClick:(w,S)=>{var _;if(lt){$([Ip(S.id)]);return}if((_=S==null?void 0:S.data)!=null&&_.isWorkspaceGroup){Nn("");return}if(w.detail>=3){hl(!1),k(P=>P.map(R=>({...R,selected:R.id===S.id}))),y(P=>P.map(R=>({...R,selected:!1}))),Nn(S.id);return}Kt&&Nn(S.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{lt?$([]):Nn("")},onDrop:lt?void 0:h2,onDragOver:lt?void 0:m2,nodesDraggable:lt?!0:je,nodesConnectable:lt?!1:je,edgesReconnectable:lt?!1:je,onlyRenderVisibleElements:XS.length>=80,deleteKeyCode:lt?null:je?["Backspace","Delete"]:null,selectionOnDrag:Ig==="select",panOnDrag:Ig==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(uR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!lt&&J?(()=>{var G;const w=String(J.query||"").trim().toLowerCase(),S=J.mode==="create"?"create":"existing",_=Array.isArray(J.candidates)?J.candidates:[],P=Array.isArray(J.existingCandidates)?J.existingCandidates:[],R=w?_.filter(Y=>{var oe,he,fe;return[(oe=Y.def)==null?void 0:oe.id,Y.displayLabel,Y.description,(he=Y.slot)==null?void 0:he.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(Ne=>String(Ne).toLowerCase().includes(w))}):_,U=w?P.filter(Y=>{var oe,he;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(oe=Y.slot)==null?void 0:oe.name,(he=Y.slot)==null?void 0:he.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(w))}):P,X=J.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:J.left,top:J.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:In((G=J.draft.slot)==null?void 0:G.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",J.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>ne(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[o.jsxs("button",{type:"button",className:S==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:P.length===0,onClick:()=>ne(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",o.jsx("span",{children:P.length})]}),o.jsxs("button",{type:"button",className:S==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:_.length===0,onClick:()=>ne(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",o.jsx("span",{children:_.length})]})]}),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:J.query,onChange:Y=>ne(oe=>oe&&{...oe,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[S==="create"?R.map(Y=>{var fe,Ne;const oe=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),he=Ap(Y.slot,Y.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>a2(Y),title:Y.description||Y.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:oe}),oe!==Y.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:X}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:In((Ne=Y.slot)==null?void 0:Ne.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:he})]})]},`${Y.def.id}-${Y.slotIndex}`)}):U.map(Y=>{var fe;const oe=Y.nodeLabel||Y.nodeId,he=Ap(Y.slot,Y.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>l2(Y),title:`${Y.definitionId||Y.nodeId} · ${he}`,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:oe}),o.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),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:In((fe=Y.slot)==null?void 0:fe.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:he}),Y.occupied?o.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(S==="create"?R.length:U.length)===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!lt&&!Fn&&!w$?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:()=>Eg(!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:Qn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Qn.map(w=>{var R,U;const S=String(((R=w.data)==null?void 0:R.label)??w.id),_=(U=w.data)!=null&&U.definitionId?String(w.data.definitionId):"",P=_&&_!==S?`${S} · ${w.id} · ${_}`:`${S} · ${w.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:P,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:_||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:S}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>e2(w.id),"aria-label":`取消选择 ${w.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},w.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:da,rows:2,onChange:w=>Cg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),zf())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!je})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:jg,type:"button",className:"af-composer-skills-button"+($s.length>0?" af-composer-skills-button--active":""),disabled:ts||!je,"aria-haspopup":"listbox","aria-expanded":vf,onClick:()=>Ng(w=>!w),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:$s.length>0?`Skills ${$s.length}`:"Skills"})]}),vf&&!ts?or.createPortal(o.jsx("div",{ref:eS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:g$,children:Ms.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[kl.groups.map(w=>{const S=Xo(w,Ms),_=mF(w,Bg,Ms),P=m$.has(w.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(P?" 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:_==="all",disabled:S.length===0,onChange:R=>{const U=R.target.checked;Jc(X=>U?pF(X,S):hF(X,S))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:w.name}),w.builtin?o.jsx("em",{children:"built-in"}):null,_==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":P?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{Zv(R=>{const U=new Set(R);return U.has(w.id)?U.delete(w.id):U.add(w.id),U})},children:[o.jsx("span",{children:w.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:P?"expand_more":"expand_less"})]})]}),P?null:o.jsx("div",{className:"af-composer-skill-group-items",children:w.skills.map(R=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Bg.has(R.key),onChange:U=>{const X=U.target.checked;Jc(G=>X?G.includes(R.key)?G:[...G,R.key]:G.filter(Y=>Y!==R.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:R.name}),R.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:R.description}):null]})]},`${w.id}:${R.key}`))})]},w.id)}),kl.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:kl.ungrouped.length})]}),kl.ungrouped.map(w=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:Bg.has(w.key),onChange:S=>{const _=S.target.checked;Jc(P=>_?P.includes(w.key)?P:[...P,w.key]:P.filter(R=>R!==w.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:w.name}),w.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:w.description}):null]})]},`ungrouped:${w.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:$i,onChange:w=>a$(w.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),F$.map(w=>o.jsx("option",{value:w.value,children:w.label},w.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(da.trim()&&!ts?" af-composer-send--active":"")+(ts?" af-composer-send--stop":""),disabled:ts||!da.trim()||!je,"aria-label":ts?"Running":"Send",onClick:()=>void zf(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ts?"sync":"arrow_upward"})})]})]})]})}):!lt&&!Fn?o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Eg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!lt&&!Fn&&Zc?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:()=>hl(!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"+(Hr==="workspace"?" af-composer-session-tab--active":""),ref:Hr==="workspace"?_g:null,onClick:()=>xs("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Ls.map(w=>o.jsxs("div",{role:"tab",tabIndex:0,ref:Hr===w.id?_g:null,className:"af-composer-session-tab"+(Hr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>xs(w.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),xs(w.id))},title:w.runNodeId||w.label,children:[o.jsx("span",{className:"af-composer-session-label",children:w.label}),o.jsx("button",{type:"button",className:"af-composer-session-close",onClick:S=>{S.preventDefault(),S.stopPropagation(),E$(w.id)},"aria-label":`关闭 ${w.label}`,title:"关闭 tab",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]},w.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(jl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:f0}),o.jsxs("div",{className:"af-composer-sidebar-thread",ref:rS,children:[o.jsx(MC,{messages:b2,running:jl,showRunningIndicator:!rr}),qg.length>0?o.jsxs("details",{className:"af-composer-sidebar-log-details",...jl?{open:!0}:{},children:[o.jsx("summary",{children:"执行日志"}),o.jsx(MC,{messages:qg,running:!1,showRunningIndicator:!1})]}):null]}),o.jsxs("div",{className:"af-composer-sidebar-input",children:[o.jsx("textarea",{className:"af-composer-sidebar-textarea",value:da,rows:3,onChange:w=>Cg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),zf())},placeholder:rr?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!je||jl}),o.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!je||jl||!da.trim(),onClick:()=>void zf(),"aria-label":"发送 AI 对话",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!lt&&!Fn&&ot&&Ht?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(NU,{draft:ot,setDraft:ys,definitionId:String(((h0=Ht.data)==null?void 0:h0.definitionId)||Ht.id),systemPromptReadonly:String(((m0=Ht.data)==null?void 0:m0.description)||""),modelLists:ua,disabled:!je,onIdBlur:()=>Og(!0),onClose:()=>Nn(""),onPublishToMarketplace:_$,error:XM,ioSlots:{inputs:Array.isArray(ot==null?void 0:ot.inputs)?ot.inputs:[],outputs:Array.isArray(ot==null?void 0:ot.outputs)?ot.outputs:[]}})}):null,!lt&&!Fn&&eu?or.createPortal(o.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>ml(null),children:o.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:o.jsx(cU,{flowParams:i,scheduleNodeId:eu.scheduleNodeId,runNodeId:eu.runNodeId,lastRunId:eu.lastRunId,label:eu.label,onClose:()=>ml(null)})})}),document.body):null,o.jsx(iU,{open:Ag,onClose:()=>Nf(!1)}),o.jsx(aU,{open:Pg,onClose:()=>cS(!1),onJump:Fg,nodes:L$}),o.jsx(jU,{open:d,onClose:()=>f(!1),flowId:i.flowId||"",flowSource:iu,onArchived:()=>{f(!1),n("/projects?tab=archived")}}),o.jsx(CU,{open:p&&!!i.flowId,onClose:()=>h(!1),flowId:i.flowId||"",flowSource:iu,flowArchived:!!i.archived,workspaceId:i.workspaceId||"",leaveShared:ou,onDeleted:async()=>{h(!1),n("/projects")}}),t$&&_n?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-workspace-conflict-modal",role:"dialog","aria-modal":"true","aria-label":"解决 Workspace 冲突",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:"difference"}),"解决 ",((g0=_n.conflictItems)==null?void 0:g0.length)||0," 处字段冲突"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ca(!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("div",{className:"af-workspace-conflict-summary",children:["未冲突的改动已经自动合并。这里只需要决定双方同时修改的字段。",o.jsxs("div",{className:"af-workspace-conflict-bulk",children:[o.jsx("button",{type:"button",onClick:()=>cl(Object.fromEntries((_n.conflictItems||[]).map((w,S)=>[String(S),{mode:"local",manual:Au(w)}]))),children:"全部保留我的"}),o.jsx("button",{type:"button",onClick:()=>cl(Object.fromEntries((_n.conflictItems||[]).map((w,S)=>[String(S),{mode:"remote",manual:Au(w)}]))),children:"全部使用远端"})]})]}),(_n.conflictItems||[]).map((w,S)=>{const _=hg[String(S)]||{mode:"local",manual:Au(w)};return o.jsxs("section",{className:"af-workspace-conflict-item",children:[o.jsx("code",{className:"af-workspace-conflict-path",children:w.path}),o.jsx("div",{className:"af-workspace-conflict-options",children:[["local","保留我的"],["remote","使用远端"],["manual","手动编辑"]].map(([P,R])=>o.jsx("button",{type:"button",className:_.mode===P?"is-active":"",onClick:()=>cl(U=>({...U,[String(S)]:{..._,mode:P}})),children:R},P))}),o.jsxs("div",{className:"af-workspace-conflict-values",children:[o.jsxs("div",{className:_.mode==="local"?"is-selected":"",children:[o.jsx("span",{children:"我的修改"}),o.jsx("pre",{children:WC(w,"incoming")})]}),o.jsxs("div",{className:_.mode==="remote"?"is-selected":"",children:[o.jsx("span",{children:"远端修改"}),o.jsx("pre",{children:WC(w,"current")})]})]}),_.mode==="manual"?o.jsxs("label",{className:"af-workspace-conflict-manual",children:[o.jsx("span",{children:"最终值(JSON)"}),o.jsx("textarea",{value:_.manual,onChange:P=>cl(R=>({...R,[String(S)]:{..._,manual:P.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${S}`)}),Mv?o.jsx("div",{className:"af-flow-snippet-error",children:Mv}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot af-workspace-conflict-foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:wf,onClick:()=>void a0(),children:"备份并载入远端"}),o.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:wf,onClick:()=>ca(!1),children:"稍后处理"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:wf||!(_n.conflictItems||[]).length,onClick:()=>void q$(),children:wf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,kn?or.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:()=>nr(!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:vn.name,onChange:w=>{const S=w.target.value;Jn(_=>({..._,name:S,id:_.id?_.id:S.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:vn.id,onChange:w=>Jn(S=>({...S,id:w.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:vn.description,onChange:w=>Jn(S=>({...S,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Qn.length," 个节点和 ",$f.length," 条内部连线。"]}),gs?o.jsx("div",{className:"af-flow-snippet-error",children:gs}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>nr(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Wn||!vn.name.trim(),onClick:()=>void W$(),children:Wn?"发布中...":"发布"})]})]})}),document.body):null,YS?o.jsx(OG,{node:YS,onClose:()=>Dn("")}):null,xr?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":yo?"新建分享":"发布展示页",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),yo?"新建分享":"发布展示页"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>br(!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:ae.title,onChange:w=>ke(S=>({...S,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),yo?null:o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"布局"}),o.jsxs("select",{className:"af-display-share-select",value:ae.layout,onChange:w=>ke(S=>({...S,layout:w.target.value})),children:[o.jsx("option",{value:"gallery",children:"Gallery"}),o.jsx("option",{value:"document",children:"Document"}),o.jsx("option",{value:"slides",children:"Slides"})]})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"有效期"}),o.jsx("select",{className:"af-display-share-select",value:EC(ae),onChange:w=>{const S=w.target.value;ke(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:tw.map(w=>o.jsx("option",{value:w.value,children:w.label},w.value))})]}),o.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":yo?"分享内容":"选择展示节点",children:[yo?o.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,v2.map(w=>{var _;const S=Array.isArray(ae.nodeIds)&&ae.nodeIds.includes(w.id);return o.jsxs("label",{className:"af-display-share-node-row",children:[o.jsx("input",{type:"checkbox",checked:S,disabled:yo,onChange:()=>U$(w.id)}),o.jsxs("span",{className:"af-display-share-node-row__main",children:[o.jsx("strong",{children:((_=w.data)==null?void 0:_.label)||w.id}),o.jsxs("small",{children:[An(w.data)," · ",w.id]})]})]},w.id)})]}),vt!=null&&vt.absoluteUrl?o.jsxs("div",{className:"af-display-share-result",children:[o.jsx("input",{type:"text",readOnly:!0,value:vt.absoluteUrl,onFocus:w=>w.target.select()}),o.jsx("button",{type:"button",onClick:()=>window.open(vt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),o.jsx("button",{type:"button",onClick:()=>void l0(),children:nn==="copied"?"已复制":nn==="failed"?"复制失败":"复制"})]}):null,kr?o.jsx("div",{className:"af-flow-snippet-error",children:kr}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>br(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:mn||!Array.isArray(ae.nodeIds)||ae.nodeIds.length===0,onClick:()=>void G$(),children:mn?"生成中...":"生成链接"})]})]})}),document.body):null,cn?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{vr(""),On(!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:[vt!=null&&vt.absoluteUrl?o.jsxs("div",{className:"af-display-link-modal__url",children:[o.jsx("input",{type:"text",readOnly:!0,value:vt.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>window.open(vt.absoluteUrl,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>void l0(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:nn==="copied"?"check":"content_copy"}),nn==="copied"?"已复制":nn==="failed"?"复制失败":"复制"]})]}):o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"新链接有效期"}),o.jsx("select",{className:"af-display-share-select",value:EC(ae),onChange:w=>{const S=w.target.value;ke(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:tw.map(w=>o.jsx("option",{value:w.value,children:w.label},w.value))})]}),kr?o.jsx("div",{className:"af-flow-snippet-error",children:kr}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{vr(""),On(!1)},children:"关闭"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:mn||N.nodeIds.length===0,onClick:()=>void J$(),children:mn?"生成中...":vt!=null&&vt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,e$?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"协作分享",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>fg(!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.jsx("p",{className:"af-display-link-modal__empty",children:"输入已注册用户名。添加后,这个 Workspace 会直接出现在对方的项目列表中。"}),o.jsxs("div",{className:"af-workspace-member-add",children:[o.jsx("input",{type:"text",value:Uc,onChange:w=>Pv(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Uc.trim()&&!pg&&(w.preventDefault(),o0())},placeholder:"输入用户名",autoFocus:!0}),o.jsx("button",{type:"button",disabled:pg||!Uc.trim(),onClick:()=>void o0(),children:pg?"添加中...":"添加成员"})]}),Av?o.jsx("div",{className:"af-flow-snippet-error",children:Av}):null,o.jsx("div",{className:"af-workspace-member-list",children:((rn==null?void 0:rn.members)||[]).map(w=>{const S=w.userId===(rn==null?void 0:rn.ownerId)||w.role==="owner";return o.jsxs("div",{className:"af-workspace-member-row",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S?"shield_person":"person"}),o.jsxs("div",{children:[o.jsx("strong",{children:w.username||w.userId}),o.jsx("small",{children:S?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),S?null:o.jsx("button",{type:"button",disabled:Iv===w.userId,onClick:()=>void K$(w),children:Iv===w.userId?"移除中...":"取消分享"})]},w.userId)})})]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>fg(!1),children:"完成"})})]})}),document.body):null,ft?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-shares-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:"folder_shared"}),"我的分享"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Yt(!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("div",{className:"af-display-shares-toolbar",children:[o.jsx("span",{children:Gt.length?`${Gt.length} 个分享`:"暂无分享"}),o.jsxs("button",{type:"button",onClick:()=>void zs(),disabled:tt,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),Mi?o.jsx("div",{className:"af-flow-snippet-error",children:Mi}):null,tt?o.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!tt&&Gt.length===0?o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,o.jsx("div",{className:"af-display-shares-list",children:Gt.map(w=>{const S=PC(w),_=ho===w.id,P=w.expiresAt?String(w.expiresInDays||30):"permanent";return o.jsxs("article",{className:"af-display-share-item",children:[o.jsxs("div",{className:"af-display-share-item__main",children:[o.jsx("strong",{children:w.title||"AgentFlow Display"}),o.jsxs("span",{children:[w.flowId||"-"," · ",w.layout||"gallery"," · ",Array.isArray(w.nodeIds)?w.nodeIds.length:0," nodes"]}),o.jsx("small",{children:wG(w)})]}),o.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:S,onFocus:R=>R.target.select()}),o.jsx("select",{className:"af-display-share-select",value:P,disabled:_,onChange:R=>void Q$(w,R.target.value),"aria-label":"修改分享有效期",children:tw.map(R=>o.jsx("option",{value:R.value,children:R.label},R.value))}),o.jsxs("div",{className:"af-display-share-item__actions",children:[o.jsxs("button",{type:"button",onClick:()=>window.open(S,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>void X$(w),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ts===w.id?"check":"content_copy"}),Ts===w.id?"已复制":"复制"]}),o.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:_,onClick:()=>void Z$(w),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,Se?or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Ee(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-display-picker-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:wt,onChange:w=>Ot(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),o.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":r0.length||1},children:Lf.length>0?r0.map((w,S)=>o.jsx("div",{className:"af-display-picker-column",children:w.map(B$)},`display-picker-column-${S}`)):o.jsx("div",{className:"af-display-picker-empty",children:bl.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>Ee(!1),children:"完成"})})]})}),document.body):null,Gc.nodeId?or.createPortal(o.jsx(nJ,{files:al,query:Gc.query,onQueryChange:w=>wg(S=>({...S,query:w})),onSelect:I$,onUpload:FS,onClose:$g}),document.body):null,!lt&&!Fn&&Mn?or.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>K(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:w=>w.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:()=>$e("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:()=>$e("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:tS,value:Ce,onChange:w=>et(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),K(!1);else if(w.key==="ArrowDown"){w.preventDefault();const S=pe==="flows"?fu.length:du.length;St(_=>Math.min(Math.max(0,S-1),_+1))}else w.key==="ArrowUp"?(w.preventDefault(),St(S=>Math.max(0,S-1))):w.key==="Tab"?(w.preventDefault(),$e(S=>S==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),pe==="flows"?d0(fu[Sn]||fu[0]):u0(du[Sn]||du[0]))},placeholder:pe==="flows"?"搜索流程片段...":"搜索节点...","aria-label":pe==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:pe==="flows"?fu.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:Ze?"正在加载流程片段...":At||"没有匹配的流程片段"}):fu.map((w,S)=>{const _=w.displayName||w.name||w.id,P=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,R=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,U=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(P||{}).length,X=Number.isFinite(Number(w.edgeCount))?Number(w.edgeCount):Array.isArray(R)?R.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Sn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>St(S),onClick:()=>d0(w),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:_}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[w.id,w.version?` · v${w.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:w.description||`${U} 节点 / ${X} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):du.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):du.map((w,S)=>{const _=zu(w),P=Bu(w),R=rb(w);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Sn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>St(S),onClick:()=>u0(w),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:kC(_)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:P}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:w.id}),R?o.jsx("span",{className:"af-workspace-quick-add__desc",children:R}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:_})]},w.id)})})]})}),document.body):null]})]})}function SJ(){return o.jsx(Rk,{children:o.jsx(vJ,{})})}function NJ(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=(e==null?void 0:e.kind)==="image"?"src":"content",r=a=>String((a==null?void 0:a.value)??(a==null?void 0:a.default)??""),s=a=>r(a).trim(),i=t.find(a=>(a==null?void 0:a.name)===n&&s(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&s(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&s(a));return String((e==null?void 0:e.body)||(i?r(i):""))}function jJ(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function CJ(e){let t=String(e||"").replace(/\r\n/g,`
265
- `).trim();return t.includes(`
266
- `)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
267
- $1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
268
- $2`)),t}function iM(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=CJ(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
269
- `).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
270
- `).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),i=t.lastIndexOf("}");s>=0&&i>s&&r.unshift(t.slice(s,i+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function dv(e){let t=iM(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 _J(e){const t=dv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function EJ(e){const t=dv(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
271
- (() => {
272
- document.addEventListener("click", (event) => {
273
- const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
274
- if (!link) return;
275
- const rawHref = String(link.getAttribute("href") || "").trim();
276
- if (!rawHref || rawHref.startsWith("#")) return;
277
- if (/^javascript:/i.test(rawHref)) {
278
- event.preventDefault();
279
- return;
280
- }
281
- event.preventDefault();
282
- window.open(link.href, "_blank", "noopener,noreferrer");
283
- }, true);
284
- })();
285
- <\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function oM(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=new URLSearchParams;return s.set("id",t),s.set("path",r),n.download&&s.set("download","1"),`/api/display/file/raw?${s.toString()}`}function AJ(e,t,n={}){const r=String(e||"").trim();return r?oM(r,t,n):""}function PJ({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 d=n.current;if(!d)return;const f=Math.max(1,d.scrollHeight),p=Math.max(1,d.clientHeight),h=f>p+1,g=h?Math.max(12,p/f*100):100,k=Math.max(0,100-g),b=h?Math.min(k,d.scrollTop/Math.max(1,f-p)*k):0;i({visible:h,top:b,height:g})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),g=s.height/100*h.height,k=Math.max(1,h.height-g);return(d-h.top-f)/k},[s.height]),u=m.useCallback(d=>{if(!s.visible)return;d.preventDefault(),d.stopPropagation();const f=r.current;if(!f)return;const p=f.getBoundingClientRect(),h=s.top/100*p.height,g=s.height/100*p.height,b=d.clientY>=p.top+h&&d.clientY<=p.top+h+g?d.clientY-p.top-h:g/2;l(c(d.clientY,b));const y=x=>{x.preventDefault(),l(c(x.clientY,b))},v=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v)},[c,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[o.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function cb({node:e,shareId:t,style:n,bare:r=!1}){const s=NJ(e),i=e.kind==="html"?dv(s):e.kind==="react"?ng(s):iM(s),a=e.kind==="html"?_J(i):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return o.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}${r?" af-public-display-node--bare":""}`,style:n,children:[r?null:o.jsx("div",{className:"af-public-display-node__head",children:o.jsxs("div",{className:"af-public-display-node__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:jJ(e.kind)}),o.jsx("strong",{children:e.label||e.id}),o.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),o.jsx(PJ,{className:l,children:a?o.jsx("div",{className:"af-public-display-empty",children:a}):i.trim()?o.jsxs(o.Fragment,{children:[e.kind==="html"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:EJ(i)}):null,e.kind==="react"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:tv(i)}):null,e.kind==="image"?o.jsx("img",{src:oM(i,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?o.jsx("div",{className:"af-public-display-markdown",children:o.jsx(Gk,{content:i,resolveSrc:(c,u)=>AJ(c,t,u)})}):null,e.kind==="chart"?o.jsx(Xk,{content:i}):null,e.kind==="table"?o.jsx(Jk,{content:i}):null,e.kind==="mermaid"||e.kind==="ascii"?o.jsx("pre",{children:i}):null]}):o.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function IJ({data:e}){return o.jsx(cb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const RJ={publicDisplay:IJ};function TJ(e){const t=String(e||"").split("/").filter(Boolean);return t[0]==="display"&&t[1]?decodeURIComponent(t[1]):new URLSearchParams(window.location.search).get("id")||""}function aM(){var l,c,u,d;const{path:e}=si(),t=m.useMemo(()=>TJ(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function p(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),g=await h.json().catch(()=>({}));if(!h.ok)throw new Error(g.error||"展示页不存在");f||r({loading:!1,error:"",share:g.share||null,nodes:Array.isArray(g.nodes)?g.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return p(),()=>{f=!0}},[t]);const s=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((p,h)=>{const g=p.position&&typeof p.position.x=="number"&&typeof p.position.y=="number"?p.position:{x:120+h*40,y:100+h*32},k=p.size&&typeof p.size.width=="number"&&typeof p.size.height=="number"?p.size:{width:520,height:320};return{id:p.id,type:"publicDisplay",position:g,data:{node:p,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(k.width)||520),height:Math.max(1,Number(k.height)||320)}}}),[t,n.nodes]),i=m.useMemo(()=>{var k;const f=(k=n.share)==null?void 0:k.viewport;if(!f||typeof f!="object")return null;const p=Number(f.x),h=Number(f.y),g=Number(f.zoom);return!Number.isFinite(p)||!Number.isFinite(h)||!Number.isFinite(g)?null:{x:p,y:h,zoom:Math.min(Math.max(g,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return o.jsx("main",{className:"af-public-display-page",children:o.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return o.jsx("main",{className:"af-public-display-page",children:o.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),o.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return o.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:o.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>o.jsx(cb,{node:p,shareId:t,bare:!0},p.id))})});const f=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return o.jsxs("main",{className:`af-public-display-page ${f}`,children:[o.jsxs("header",{className:"af-public-display-hero",children:[o.jsxs("div",{children:[o.jsx("p",{children:"AgentFlow Display"}),o.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),o.jsx("span",{children:(d=n.share)!=null&&d.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),o.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(p=>o.jsx(cb,{node:p,shareId:t},p.id))})]})}return o.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:o.jsx(Rk,{children:o.jsx(lR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:RJ,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:i||void 0,fitView:!i,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:o.jsx(uR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const xt=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},VC=e=>e==null?"":""+e,MJ=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},$J=/###/g,KC=e=>e&&e.indexOf("###")>-1?e.replace($J,"."):e,qC=e=>!e||xt(e),cd=(e,t,n)=>{const r=xt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(qC(e))return{};const i=KC(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return qC(e)?{}:{obj:e,k:KC(r[s])}},UC=(e,t,n)=>{const{obj:r,k:s}=cd(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=cd(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=cd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},LJ=(e,t,n,r)=>{const{obj:s,k:i}=cd(e,t,Object);s[i]=s[i]||[],s[i].push(n)},fm=(e,t)=>{const{obj:n,k:r}=cd(e,t);if(n)return n[r]},OJ=(e,t,n)=>{const r=fm(e,n);return r!==void 0?r:fm(t,n)},lM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?xt(e[r])||e[r]instanceof String||xt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):lM(e[r],t[r],n):e[r]=t[r]);return e},Ml=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var DJ={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const FJ=e=>xt(e)?e.replace(/[&<>"'\/]/g,t=>DJ[t]):e;class zJ{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 BJ=[" ",",","?","!",";"],HJ=new zJ(20),WJ=(e,t,n)=>{t=t||"",n=n||"";const r=BJ.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=HJ.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},ub=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},pm=e=>e&&e.replace("_","-"),VJ={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 hm{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||VJ,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(xt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new hm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new hm(this.logger,t)}}var vi=new hm;class ig{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const s=this.observers[r].get(n)||0;this.observers[r].set(n,s+1)}),this}off(t,n){if(this.observers[t]){if(!n){delete this.observers[t];return}this.observers[t].delete(n)}}emit(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l.apply(l,[t,...r])})}}class YC extends ig{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):xt(r)&&i?l.push(...r.split(i)):l.push(r)));const c=fm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!xt(r)?c:ub(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),UC(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)(xt(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=fm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?lM(c,r,i):c={...c,...r},UC(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 cM={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 GC={};class mm extends ig{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),MJ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=vi.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&&!WJ(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:xt(i)?[i]:i};const u=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(u[0])>-1)&&(i=u.shift()),t=u.join(s)}return{key:t,namespaces:xt(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],u=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(d){const C=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${C}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${C}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||a,g=f&&f.exactUsedKey||a,k=Object.prototype.toString.apply(p),b=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!xt(p)&&typeof p!="boolean"&&typeof p!="number";if(v&&p&&x&&b.indexOf(k)<0&&!(xt(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 C=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=C,f.usedParams=this.getUsedParamsDetails(n),f):C}if(i){const C=Array.isArray(p),N=C?[]:{},j=C?g:h;for(const A in p)if(Object.prototype.hasOwnProperty.call(p,A)){const I=`${j}${i}${A}`;N[A]=this.translate(I,{...n,joinArrays:!1,ns:l}),N[A]===I&&(N[A]=p[A])}p=N}}else if(v&&xt(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let C=!1,N=!1;const j=n.count!==void 0&&!xt(n.count),A=mm.hasDefaultValue(n),I=j?this.pluralResolver.getSuffix(u,n.count,n):"",O=n.ordinal&&j?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",H=j&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),B=H&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${I}`]||n[`defaultValue${O}`]||n.defaultValue;!this.isValidLookup(p)&&A&&(C=!0,p=B),this.isValidLookup(p)||(N=!0,p=a);const $=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:p,M=A&&B!==p&&this.options.updateMissing;if(N||C||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?B:p),i){const T=this.resolve(a,{...n,keySeparator:!1});T&&T.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 q=[];const D=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&D&&D[0])for(let T=0;T<D.length;T++)q.push(D[T]);else this.options.saveMissingTo==="all"?q=this.languageUtils.toResolveHierarchy(n.lng||this.language):q.push(n.lng||this.language);const L=(T,W,E)=>{const Q=A&&E!==p?E:$;this.options.missingKeyHandler?this.options.missingKeyHandler(T,c,W,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(T,c,W,Q,M,n),this.emit("missingKey",T,c,W,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&j?q.forEach(T=>{const W=this.pluralResolver.getSuffixes(T,n);H&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(E=>{L([T],a+E,n[`defaultValue${E}`]||B)})}):L(q,a,B))}p=this.extendTranslation(p,t,n,f,r),N&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(N||C)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,C?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,s,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 u=xt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(u){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=r.replace&&!xt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),u){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),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=xt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=cM.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 xt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;s=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!xt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(xt(n.context)||typeof n.context=="number")&&n.context!=="",k=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!GC[`${k[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(GC[`${k[0]}-${b}`]=!0,this.logger.warn(`key "${s}" for languages "${k.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!!!")),k.forEach(y=>{if(this.isValidLookup(r))return;a=y;const v=[d];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(v,d,y,b,n);else{let C;p&&(C=this.pluralResolver.getSuffix(y,n.count,n));const N=`${this.options.pluralSeparator}zero`,j=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(v.push(d+C),n.ordinal&&C.indexOf(j)===0&&v.push(d+C.replace(j,this.options.pluralSeparator)),h&&v.push(d+N)),g){const A=`${d}${this.options.contextSeparator}${n.context}`;v.push(A),p&&(v.push(A+C),n.ordinal&&C.indexOf(j)===0&&v.push(A+C.replace(j,this.options.pluralSeparator)),h&&v.push(A+N))}}let x;for(;x=v.pop();)this.isValidLookup(r)||(i=x,r=this.getResource(y,b,x,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&&!xt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const 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 sw=e=>e.charAt(0).toUpperCase()+e.slice(1);class JC{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=vi.create("languageUtils")}getScriptPartFromCode(t){if(t=pm(t),!t||t.indexOf("-")<0)return null;const n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(t){if(t=pm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(xt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=sw(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]=sw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=sw(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)),xt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return xt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):xt(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let KJ=[{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}],qJ={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 UJ=["v1","v2","v3"],YJ=["v4"],XC={zero:0,one:1,two:2,few:3,many:4,other:5},GJ=()=>{const e={};return KJ.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:qJ[t.fc]}})}),e};class JJ{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=vi.create("pluralResolver"),(!this.options.compatibilityJSON||YJ.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=GJ(),this.pluralRulesCache={}}addRule(t,n){this.rules[t]=n}clearCache(){this.pluralRulesCache={}}getRule(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi()){const r=pm(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",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)=>XC[s]-XC[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!UJ.includes(this.options.compatibilityJSON)}}const QC=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=OJ(e,t,n);return!i&&s&&xt(n)&&(i=ub(e,n,r),i===void 0&&(i=ub(t,n,r))),i},iw=e=>e.replace(/\$/g,"$$$$");class XJ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=vi.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:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:h,nestingSuffix:g,nestingSuffixEscaped:k,nestingOptionsSeparator:b,maxReplaces:y,alwaysFormat:v}=t.interpolation;this.escape=n!==void 0?n:FJ,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?Ml(i):a||"{{",this.suffix=l?Ml(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?Ml(p):h||Ml("$t("),this.nestingSuffix=g?Ml(g):k||Ml(")"),this.nestingOptionsSeparator=b||",",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||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const y=QC(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),k=g.shift().trim(),b=g.join(this.formatSeparator).trim();return this.format(QC(n,c,k,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...s,...n,interpolationkey:k})};this.resetRegExp();const d=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,f=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>iw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?iw(this.escape(h)):iw(h)}].forEach(h=>{for(l=0;i=h.regex.exec(t);){const g=i[1].trim();if(a=u(g),a===void 0)if(typeof d=="function"){const b=d(t,i,s);a=xt(b)?b:""}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!xt(a)&&!this.useRawValueToEscape&&(a=VC(a));const k=h.safeValue(a);if(t=t.replace(i[0],k),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,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const h=p.match(/'/g),g=p.match(/"/g);(h&&h.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),u&&(a={...u,...a})}catch(k){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,k),`${c}${d}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!xt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const d=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=d.shift(),c=d,u=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!xt(i))return i;xt(i)||(i=VC(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),u&&(i=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const QJ=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const s=r[1].substring(0,r[1].length-1);t==="currency"&&s.indexOf(":")<0?n.currency||(n.currency=s.trim()):t==="relativetime"&&s.indexOf(":")<0?n.range||(n.range=s.trim()):s.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},$l=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(pm(r),s),t[a]=l),l(n)}};class ZJ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=vi.create("formatter"),this.options=t,this.formats={number:$l((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:$l((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:$l((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:$l((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:$l((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()]=$l(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:u,formatOptions:d}=QJ(c);if(this.formats[u]){let f=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},h=p.locale||p.lng||s.locale||s.lng||r;f=this.formats[u](l,h,{...d,...s,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const eX=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class tX extends ig{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=vi.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(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,d=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!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=>{LJ(c.loaded,[i],a),eX(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,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=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();xt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),xt(n)&&(n=[n]);const 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},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(t,n,r,s,c):d=u(t,n,r,s),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const ZC=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),xt(e[1])&&(t.defaultValue=e[1]),xt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),e_=e=>(xt(e.ns)&&(e.ns=[e.ns]),xt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),xt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Tp=()=>{},nX=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class qd extends ig{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=e_(t),this.services={},this.logger=vi,this.modules={external:[]},nX(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(xt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=ZC();this.options={...s,...this.options,...e_(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=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?vi.init(i(this.modules.logger),this.options):vi.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:typeof Intl<"u"&&(d=ZJ);const f=new JC(this.options);this.store=new YC(this.options.resources,this.options);const p=this.services;p.logger=vi,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new JJ(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),d&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(d),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new XJ(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new tX(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(h){for(var g=arguments.length,k=new Array(g>1?g-1:0),b=1;b<g;b++)k[b-1]=arguments[b];t.emit(h,...k)}),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 mm(this.services,this.options),this.translator.on("*",function(h){for(var g=arguments.length,k=new Array(g>1?g-1:0),b=1;b<g;b++)k[b-1]=arguments[b];t.emit(h,...k)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Tp),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=function(){return t.store[d](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=function(){return t.store[d](...arguments),t}});const c=Pu(),u=()=>{const d=(f,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(p),r(f,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tp;const s=xt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&i.indexOf(u)<0&&i.push(u)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(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=Tp),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"&&cM.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,u)=>{u?(i(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const u=xt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,d=>{a(d,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const i=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,d=new Array(u>2?u-2:0),f=2;f<u;f++)d[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(d))}else c={...l};c.lng=c.lng||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 xt(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 u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(i,t)))}loadNamespaces(t,n){const r=Pu();return this.options.ns?(xt(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Pu();xt(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 JC(ZC());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 qd(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Tp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new qd(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 YC(this.store.data,s),i.services.resourceStore=i.store),i.translator=new mm(i.services,s),i.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];i.emit(l,...u)}),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 yr=qd.createInstance();yr.createInstance=qd.createInstance;yr.createInstance;yr.dir;yr.init;yr.loadResources;yr.reloadResources;yr.use;yr.changeLanguage;yr.getFixedT;yr.t;yr.exists;yr.setDefaultNamespace;yr.hasLoadedNamespace;yr.loadNamespaces;yr.loadLanguages;function rX(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ud(e){"@babel/helpers - typeof";return Ud=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},Ud(e)}function sX(e,t){if(Ud(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Ud(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function iX(e){var t=sX(e,"string");return Ud(t)=="symbol"?t:t+""}function oX(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,iX(r.key),r)}}function aX(e,t,n){return t&&oX(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var uM=[],lX=uM.forEach,cX=uM.slice;function uX(e){return lX.call(cX.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var t_=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,dX=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(!t_.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!t_.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},n_={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=dX(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)}},fX={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=n_.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&n_.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},pX={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}},Iu=null,r_=function(){if(Iu!==null)return Iu;try{Iu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Iu=!1}return Iu},hX={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&r_()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&r_()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Ru=null,s_=function(){if(Ru!==null)return Ru;try{Ru=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ru=!1}return Ru},mX={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&s_()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&s_()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},gX={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}},yX={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}},wX={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}},xX={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]}},dM=!1;try{document.cookie,dM=!0}catch{}var fM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];dM||fM.splice(1,1);function bX(){return{order:fM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var pM=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};rX(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return aX(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=uX(r,this.options||{},bX()),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(fX),this.addDetector(pX),this.addDetector(hX),this.addDetector(mX),this.addDetector(gX),this.addDetector(yX),this.addDetector(wX),this.addDetector(xX)}},{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)}))}}])}();pM.type="languageDetector";const kX={name:"AgentFlow",tagline:"AI Workflow Orchestration"},vX={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},SX={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"},NX={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},jX={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},CX={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},_X={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},EX={app:kX,nav:vX,common:SX,status:NX,nodeTypes:jX,engine:CX,links:_X},AX="Flow Editor",PX="Nodes",IX="Edges",RX="Properties",TX={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"},MX={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",description:"Description / format",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",pinDescriptionAriaLabel:"{{label}} {{index}} format description",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},$X={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},LX={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},OX={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"},DX={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)"},FX={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},zX={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},BX={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},HX={node:"Node",text:"Text",file:"File",bool:"Boolean"},WX={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"},VX={title:"Keyboard Shortcuts",general:"General",saveDesc:"Save; when node properties sidebar is open, submit node first then save flow",shortcutsLabel:"Keyboard Shortcuts",jumpToNode:"Jump to node by ID",openNodePalette:"Open node palette",canvas:"Canvas",selectTool:"Select Tool",panTool:"Pan Tool",holdSpacePan:"Hold Space to temporarily pan",saveViewport:"Save current entry view",selectAll:"Select all nodes",undo:"Undo canvas change",redo:"Redo canvas change"},KX={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},qX={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."},UX={mainNav:"Main Navigation"},YX={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'},GX={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):
286
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
287
- 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}}"},JX={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"},XX={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},QX={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}}"},ZX={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"},eQ={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"},tQ={title:"Scheduled Run",enabled:"Enable scheduled trigger",cron:"Cron expression",timezone:"Timezone",preset:"Run preset",defaultPreset:"Default inputs",overlapSkip:"Overlap policy: skip this trigger while the pipeline is running",nextRun:"Next estimated trigger: {{time}}",noNextRun:"No next trigger is configured",runtime:"Scheduler state",running:"Running",waiting:"Waiting",disabled:"Disabled",lastTriggeredAt:"Last triggered",lastSkippedAt:"Last skipped",lastRun:"Last run",lastExit:"Last exit code",lastFinishedAt:"Last finished",readonlyNote:"Built-in or archived pipelines cannot save schedule settings.",save:"Save schedule",saving:"Saving…",saved:"Schedule saved"},nQ={title:"Execution History",summary:"Execution results summary",successCount:"{{count}} succeeded",failedCount:"{{count}} failed",stoppedCount:"{{count}} stopped",interruptedCount:"{{count}} interrupted",runningCount:"{{count}} running",success:"Success",failed:"Failed",stopped:"Stopped",interrupted:"Interrupted",running:"Running",unknown:"Unknown",runLabel:"Run #{{id}}",enterRunView:"Enter run view with canvas and log"},rQ={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"},sQ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},iQ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},oQ={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"},aQ={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."},lQ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},cQ={save:"Save",cancel:"Cancel"},uQ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},dQ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},fQ={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"},pQ={title:AX,nodes:PX,edges:IX,properties:RX,node:TX,nodeProps:MX,actions:$X,panel:LX,palette:OX,pipeline:DX,status:FX,roles:zX,phases:BX,types:HX,runContext:WX,shortcuts:VX,jumpPalette:KX,emptyCanvas:qX,sidebar:UX,validation:YX,composer:GX,topbar:JX,palette2:XX,run:QX,fileEdit:ZX,settings:eQ,schedule:tQ,history:nQ,nodePropsError:rQ,placeholder:sQ,time:iQ,userCheck:oQ,userAsk:aQ,toolPrint:lQ,provideEdit:cQ,runParams:uQ,runPreset:dQ,runConfig:fQ},hQ="Settings",mQ={engine:"Engine Settings",preferences:"Global Preferences"},gQ={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)."},yQ={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..."}},wQ={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."},xQ={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."},bQ={title:"Codex CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Codex model id list",description:"Model list comes from codex debug models --bundled. Run 'codex login' first."},kQ={title:"Environment Variables",note:"Private to the current signed-in user; overrides service-level env at runtime",noteAdmin:"Configure personal or global env; personal values override global values",saving:"Saving...",key:"Key",value:"Value",scope:"Scope",personal:"Personal",global:"Global",add:"Add",delete:"Delete {{key}}",invalidKey:"Env key must start with a letter or underscore, and only contain letters, numbers, and underscores.",newKey:"New env key",newValue:"Value (be careful with secrets)"},vQ={title:"User Allowlist",description:"Only controls which usernames may register or sign in. Users set their own password on first sign-in.",enabled:"Allowlist enabled",open:"Open registration",refreshing:"Refreshing...",saving:"Saving...",file:"File",fileList:"File allowlist",envList:"Environment allowlist",readonly:"Read-only",userCount:"{{count}} users",remove:"Remove {{username}}",emptyFile:"No file allowlist configured. If env allowlist is also empty, every username can register.",emptyEnv:"AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS is not configured",unionHint:"The file allowlist and env allowlist are combined. This only stores usernames, never passwords.",add:"Add"},SQ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},NQ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},jQ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},CQ={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."},_Q={title:hQ,crumb:mQ,workspace:gQ,cursor:yQ,opencode:wQ,claudeCode:xQ,codex:bQ,env:kQ,allowlist:vQ,system:SQ,shortcuts:NQ,language:jQ,onboarding:CQ},EQ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},AQ={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)"},PQ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},IQ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},RQ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},TQ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},MQ={aiLabels:EQ,placeholders:AQ,actions:PQ,labels:IQ,tooltips:RQ,rightPanel:TQ},$Q="Projects",LQ="All",OQ="Archived",DQ="Nodes",FQ="My Nodes",zQ="My Flows",BQ="Skills",HQ="Active Projects",WQ="Archived Pipelines",VQ="Global Nodes",KQ="All Nodes",qQ="My Nodes",UQ="Manage node versions published to the current workspace marketplace, {{count}} total.",YQ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",GQ="Global Skills",JQ="Create New Project",XQ="New Pipeline",QQ="SEARCH PIPELINES...",ZQ="SEARCH NODES...",eZ="SEARCH FLOW SNIPPETS...",tZ="SEARCH SKILLS...",nZ="Refresh Resources",rZ="Loading pipelines...",sZ="Loading global resources...",iZ="Filter result: {{count}} items (matching title, description, path and tags)",oZ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",aZ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",lZ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",cZ="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",uZ="Executable building blocks for pipeline runtime",dZ="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.",fZ="Published local node packages",pZ="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",hZ="Published flow snippets",mZ="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",gZ="Operating guides for Composer and agents",yZ="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",wZ="No archived projects.",xZ="No active pipelines; archived items are in the Archived tab.",bZ="No global nodes available.",kZ="No marketplace nodes have been published.",vZ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",SZ="No skills available.",NZ="No description.",jZ='No node matches "{{query}}".',CZ='No flow snippet matches "{{query}}".',_Z='No skill matches "{{query}}".',EZ="{{inputs}} in / {{outputs}} out",AZ="Flow Snippet",PZ="{{nodes}} nodes / {{edges}} edges",IZ="Skill",RZ="Node detail",TZ="Flow snippet detail",MZ="Skill detail",$Z="Type",LZ="Source",OZ="Package",DZ="Version",FZ="Path",zZ="Editable",BZ="Read only",HZ="Editable",WZ="Schema",VZ="Inputs",KZ="Outputs",qZ="Runtime",UZ="Node Body",YZ="Files",GZ="Usage",JZ="No runtime manifest.",XZ="No node body or README.",QZ="No previewable files.",ZZ="Select a file to preview.",eee="Binary file preview is not supported.",tee="Large file; showing the first 256KB only.",nee="No pipelines using this node were found.",ree="Node Management",see="Delete Node Version",iee="Deleting...",oee="AgentFlow checks all flow references before deleting; installed or used versions are kept.",aee="Delete {{id}}@{{version}}? This cannot be undone.",lee="Deleted {{id}}@{{version}}.",cee="{{count}} flow(s) still use it.",uee="Flow Snippet Management",dee="Delete Flow Snippet",fee="Deleting...",pee="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",hee="Delete {{id}}@{{version}}? This cannot be undone.",mee="Deleted {{id}}@{{version}}.",gee="No slots",yee="Purpose",wee="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",xee="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.",bee="Scale",kee="Flow Preview",vee="Edges",See="Snippet JSON",Nee="{{count}} more edge(s)",jee="No previewable nodes.",Cee="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",_ee="SKILL.md Preview",Eee="No preview content available.",Aee="Select a resource to inspect details.",Pee="Failed to load pipeline list.",Iee="No pipelines in current workspace.",Ree="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.",Tee='No pipelines found matching "{{query}}". Try different keywords or clear the search.',Mee="Recent Activity",$ee="No recent activity",Lee="No recent activity matching the keyword",Oee="Recent Run",Dee="Recent Open",Fee={builtin:"Built-in",workspace:"Workspace",user:"User"},zee={flow:"Flow",global:"Global",marketplace:"Marketplace"},Bee={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Hee={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Wee="Open to edit this pipeline in the node canvas.",Vee={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>"},Kee={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"},qee={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"},Uee={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"},Yee={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"},Gee={title:$Q,all:LQ,archived:OQ,nodes:DQ,myNodes:FQ,myFlows:zQ,skills:BQ,activeProjects:HQ,archivedPipelines:WQ,globalNodes:VQ,nodeScopeAll:KQ,nodeScopeMine:qQ,myNodesHint:UQ,myFlowsHint:YQ,globalSkills:GQ,createNew:JQ,newPipeline:XQ,searchPipelines:QQ,searchNodes:ZQ,searchFlows:eZ,searchSkills:tZ,refreshResources:nZ,loadingPipelines:rZ,loadingResources:sZ,filterResult:iZ,archivedHint:oZ,activeHint:aZ,nodesHint:lZ,skillsHint:cZ,nodesPurposeTitle:uZ,nodesPurposeDesc:dZ,myNodesPurposeTitle:fZ,myNodesPurposeDesc:pZ,myFlowsPurposeTitle:hZ,myFlowsPurposeDesc:mZ,skillsPurposeTitle:gZ,skillsPurposeDesc:yZ,noArchived:wZ,noActive:xZ,noNodes:bZ,noMyNodes:kZ,noMyFlows:vZ,noSkills:SZ,noDescription:NZ,noNodeMatch:jZ,noFlowSnippetMatch:CZ,noSkillMatch:_Z,nodeSlots:EZ,flowSnippet:AZ,flowSnippetNodes:PZ,skill:IZ,nodeDetail:RZ,flowDetail:TZ,skillDetail:MZ,detailType:$Z,detailSource:LZ,detailPackage:OZ,detailVersion:DZ,detailPath:FZ,detailEditable:zZ,readOnly:BZ,editable:HZ,nodeSchema:WZ,nodeInputs:VZ,nodeOutputs:KZ,nodeRuntime:qZ,nodeBody:UZ,nodeFiles:YZ,nodeUsage:GZ,noRuntimeManifest:JZ,noNodeBody:XZ,noNodeFiles:QZ,selectNodeFile:ZZ,binaryFile:eee,fileTruncated:tee,noNodeUsage:nee,myNodeManagement:ree,deleteMyNode:see,deletingMyNode:iee,deleteMyNodeHint:oee,deleteMyNodeConfirm:aee,deleteMyNodeSuccess:lee,deleteMyNodeUsedBy:cee,myFlowManagement:uee,deleteMyFlow:dee,deletingMyFlow:fee,deleteMyFlowHint:pee,deleteMyFlowConfirm:hee,deleteMyFlowSuccess:mee,noSlots:gee,resourceMeaning:yee,nodesMeaning:wee,myFlowsMeaning:xee,flowSnippetScale:bee,flowSnippetPreview:kee,flowSnippetEdges:vee,flowSnippetJson:See,flowSnippetMoreEdges:Nee,noFlowSnippetPreview:jee,skillsMeaning:Cee,skillPreview:_ee,skillPreviewEmpty:Eee,selectResource:Aee,loadFailed:Pee,noPipelines:Iee,emptyHint:Ree,noMatch:Tee,recentActivity:Mee,noRecentActivity:$ee,noMatchRecent:Lee,recentRun:Oee,recentOpen:Dee,sourceBadge:Fee,resourceSource:zee,resourceFilter:Bee,nodeDetailTabs:Hee,defaultCardDesc:Wee,hubCard:Vee,newPipelineModal:Kee,importModal:qee,deleteModal:Uee,archiveModal:Yee},Jee="Back",Xee="Next",Qee="Skip",Zee="Done",ete="Start Creating",tte={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
288
-
289
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
290
-
291
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},nte={intro:`Now you're in the flow editor.
292
-
293
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
294
-
295
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
296
-
297
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
298
-
299
- The left node panel allows you to freely drag, delete, and adjust connections.`},rte={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"},ste={back:Jee,next:Xee,skip:Qee,done:Zee,startCreate:ete,projects:tte,flow:nte,newPipeline:rte},ite={name:"AgentFlow",tagline:"AI 工作流编排"},ote={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},ate={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},lte={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},cte={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},ute={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},dte={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},fte={app:ite,nav:ote,common:ate,status:lte,nodeTypes:cte,engine:ute,links:dte},pte="流程编辑器",hte="节点",mte="连线",gte="属性",yte={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:"编辑内容"},wte={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",description:"描述 / 格式",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",pinDescriptionAriaLabel:"{{label}} {{index}} 格式描述",conversationOutput:"对话与输出",addPin:"添加引脚",addPinAriaLabel:"添加{{label}}",handleHint:"与画布上 Handle 序号一致({{prefix}}-0、{{prefix}}-1…)。增删或调整顺序后,原有连线可能失效,保存后请留意校验提示。",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} 类型",pinNameAriaLabel:"{{label}} {{index}} 名称",pinDefaultAriaLabel:"{{label}} {{index}} 默认值",deletePinAriaLabel:"删除 {{label}} {{index}}",deletePin:"删除此引脚",instanceId:"节点 ID",yamlValueNotInList:"(YAML 中的值,不在当前列表)",inputPins:"输入引脚(INPUT)",outputPins:"输出引脚(OUTPUT)",expand:"展开",collapse:"收起",expandEditScript:"展开编辑 script",expandEdit:"展开编辑",editScript:"编辑 script",editUserPrompt:"编辑用户提示",scriptPlaceholder:"instances.*.script,完整 shell 命令;支持 ${workspaceRoot}、${pipelineWorkspace}、${flowDir}、${runDir} 与各槽位名(勿对占位符再包双引号)",scriptPlaceholderExpand:"instances.*.script,完整 shell 命令;勿对 ${workspaceRoot}、${pipelineWorkspace}、${flowDir} 等占位符再包双引号",bodyPlaceholder:"instances.*.body,支持多行与 ${变量};输入 ${ 选择槽位",bodyPlaceholderExpand:"instances.*.body,支持多行与 ${变量}",noDescription:"(当前节点定义无 description)",modelAriaLabel:"模型",placeholderSlots:"占位符:输入输出槽位",publishToMarketplace:"发布节点",publishToMarketplaceHint:"将当前节点发布到 Workspace 本地节点市场",publishing:"发布中…",publishRunning:"正在发布到本地节点市场…",publishSuccess:"节点已发布到本地节点市场",publishSuccessWithId:"节点已发布:{{id}}"},xte={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},bte={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},kte={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},vte={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},Ste={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},Nte={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},jte={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},Cte={node:"节点",text:"文本",file:"文件",bool:"布尔"},_te={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:"等待"},Ete={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},Ate={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},Pte={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},Ite={mainNav:"主导航"},Rte={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Tte={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}} 步):
300
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
301
- 当前:{{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}}"},Mte={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},$te={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Lte={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}} 的分支"},Ote={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Dte={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:"已复制"},Fte={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:"定时配置已保存"},zte={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},Bte={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},Hte={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Wte={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},Vte={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},Kte={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},qte={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},Ute={save:"保存",cancel:"取消"},Yte={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},Gte={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},Jte={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},Xte={title:pte,nodes:hte,edges:mte,properties:gte,node:yte,nodeProps:wte,actions:xte,panel:bte,palette:kte,pipeline:vte,status:Ste,roles:Nte,phases:jte,types:Cte,runContext:_te,shortcuts:Ete,jumpPalette:Ate,emptyCanvas:Pte,sidebar:Ite,validation:Rte,composer:Tte,topbar:Mte,palette2:$te,run:Lte,fileEdit:Ote,settings:Dte,schedule:Fte,history:zte,nodePropsError:Bte,placeholder:Hte,time:Wte,userCheck:Vte,userAsk:Kte,toolPrint:qte,provideEdit:Ute,runParams:Yte,runPreset:Gte,runConfig:Jte},Qte="设置",Zte={engine:"引擎设置",preferences:"全局首选项"},ene={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},tne={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},nne={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},rne={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},sne={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},ine={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},one={title:"用户白名单",description:"只控制 username 是否允许注册或登录,密码由用户首次登录时自行设置。",enabled:"白名单已启用",open:"开放注册",refreshing:"刷新中...",saving:"保存中...",file:"文件",fileList:"文件白名单",envList:"环境变量白名单",readonly:"只读",userCount:"{{count}} 个用户",remove:"删除 {{username}}",emptyFile:"未配置文件白名单;如果环境变量也为空,则所有用户可注册。",emptyEnv:"未配置 AGENTFLOW_USER_WHITELIST / AGENTFLOW_ALLOWED_USERS",unionHint:"文件白名单与环境变量白名单取并集;这里只会保存用户名,不保存密码。",add:"添加"},ane={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},lne={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},cne={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},une={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},dne={title:Qte,crumb:Zte,workspace:ene,cursor:tne,opencode:nne,claudeCode:rne,codex:sne,env:ine,allowlist:one,system:ane,shortcuts:lne,language:cne,onboarding:une},fne={thinking:"思考",result:"结果",reply:"回复",error:"错误"},pne={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},hne={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},mne={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},gne={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},yne={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},wne={aiLabels:fne,placeholders:pne,actions:hne,labels:mne,tooltips:gne,rightPanel:yne},xne="项目",bne="全部",kne="已归档",vne="Nodes",Sne="我的 Nodes",Nne="我的流程",jne="Skills",Cne="活跃项目",_ne="已归档流水线",Ene="全局 Nodes",Ane="全部 Nodes",Pne="我的 Nodes",Ine="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Rne="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Tne="全局 Skills",Mne="创建新项目",$ne="新建流水线",Lne="搜索流水线…",One="搜索 nodes…",Dne="搜索流程片段…",Fne="搜索 skills…",zne="刷新资源",Bne="加载流水线列表…",Hne="加载全局资源…",Wne="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",Vne="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",Kne="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",qne="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",Une="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",Yne="流程运行时的可执行积木",Gne="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",Jne="已发布的本地节点包",Xne="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",Qne="已发布的流程片段",Zne="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",ere="Composer/Agent 的操作指南",tre="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",nre="暂无归档项目。",rre="暂无未归档流水线;已归档项在 Archived 标签中查看。",sre="暂无可用全局 nodes。",ire="暂无已发布的 marketplace nodes。",ore="暂无已发布的流程片段。可在画布中选中多个节点后发布。",are="暂无可用 skills。",lre="暂无描述。",cre="未找到与「{{query}}」匹配的 node。",ure="未找到与「{{query}}」匹配的流程片段。",dre="未找到与「{{query}}」匹配的 skill。",fre="{{inputs}} in / {{outputs}} out",pre="流程片段",hre="{{nodes}} 节点 / {{edges}} 连线",mre="Skill",gre="Node 详情",yre="流程片段详情",wre="Skill 详情",xre="类型",bre="来源",kre="包",vre="版本",Sre="路径",Nre="可编辑",jre="只读",Cre="可编辑",_re="Schema",Ere="输入",Are="输出",Pre="Runtime",Ire="节点内容",Rre="Files",Tre="Usage",Mre="暂无 runtime manifest。",$re="暂无节点正文或 README。",Lre="暂无可预览文件。",Ore="请选择文件查看内容。",Dre="二进制文件暂不支持预览。",Fre="文件较大,仅显示前 256KB。",zre="暂未发现使用此 node 的流水线。",Bre="节点管理",Hre="删除节点版本",Wre="删除中…",Vre="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",Kre="确定删除 {{id}}@{{version}}?此操作不可撤销。",qre="已删除 {{id}}@{{version}}。",Ure="仍有 {{count}} 个 Flow 使用它。",Yre="流程片段管理",Gre="删除流程片段",Jre="删除中…",Xre="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",Qre="确定删除 {{id}}@{{version}}?此操作不可撤销。",Zre="已删除 {{id}}@{{version}}。",ese="无槽位",tse="作用",nse="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",rse="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",sse="规模",ise="流程预览",ose="连线",ase="片段 JSON",lse="还有 {{count}} 条连线",cse="暂无可预览节点。",use="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",dse="SKILL.md 预览",fse="暂无可预览内容。",pse="请选择一个资源查看详情。",hse="未能加载流水线列表。",mse="当前工作区暂无流水线。",gse="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",yse="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",wse="最近打开或最近运行",xse="暂无打开或运行记录",bse="暂无与关键词匹配的最近记录",kse="最近运行",vse="最近打开",Sse={builtin:"内置",workspace:"工作区",user:"用户"},Nse={flow:"Flow",global:"Global",marketplace:"Marketplace"},jse={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Cse={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},_se="打开以在节点画布中编辑此流水线。",Ese={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Ase={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:"关闭"},Pse={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Ise={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Rse={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Tse={title:xne,all:bne,archived:kne,nodes:vne,myNodes:Sne,myFlows:Nne,skills:jne,activeProjects:Cne,archivedPipelines:_ne,globalNodes:Ene,nodeScopeAll:Ane,nodeScopeMine:Pne,myNodesHint:Ine,myFlowsHint:Rne,globalSkills:Tne,createNew:Mne,newPipeline:$ne,searchPipelines:Lne,searchNodes:One,searchFlows:Dne,searchSkills:Fne,refreshResources:zne,loadingPipelines:Bne,loadingResources:Hne,filterResult:Wne,archivedHint:Vne,activeHint:Kne,nodesHint:qne,skillsHint:Une,nodesPurposeTitle:Yne,nodesPurposeDesc:Gne,myNodesPurposeTitle:Jne,myNodesPurposeDesc:Xne,myFlowsPurposeTitle:Qne,myFlowsPurposeDesc:Zne,skillsPurposeTitle:ere,skillsPurposeDesc:tre,noArchived:nre,noActive:rre,noNodes:sre,noMyNodes:ire,noMyFlows:ore,noSkills:are,noDescription:lre,noNodeMatch:cre,noFlowSnippetMatch:ure,noSkillMatch:dre,nodeSlots:fre,flowSnippet:pre,flowSnippetNodes:hre,skill:mre,nodeDetail:gre,flowDetail:yre,skillDetail:wre,detailType:xre,detailSource:bre,detailPackage:kre,detailVersion:vre,detailPath:Sre,detailEditable:Nre,readOnly:jre,editable:Cre,nodeSchema:_re,nodeInputs:Ere,nodeOutputs:Are,nodeRuntime:Pre,nodeBody:Ire,nodeFiles:Rre,nodeUsage:Tre,noRuntimeManifest:Mre,noNodeBody:$re,noNodeFiles:Lre,selectNodeFile:Ore,binaryFile:Dre,fileTruncated:Fre,noNodeUsage:zre,myNodeManagement:Bre,deleteMyNode:Hre,deletingMyNode:Wre,deleteMyNodeHint:Vre,deleteMyNodeConfirm:Kre,deleteMyNodeSuccess:qre,deleteMyNodeUsedBy:Ure,myFlowManagement:Yre,deleteMyFlow:Gre,deletingMyFlow:Jre,deleteMyFlowHint:Xre,deleteMyFlowConfirm:Qre,deleteMyFlowSuccess:Zre,noSlots:ese,resourceMeaning:tse,nodesMeaning:nse,myFlowsMeaning:rse,flowSnippetScale:sse,flowSnippetPreview:ise,flowSnippetEdges:ose,flowSnippetJson:ase,flowSnippetMoreEdges:lse,noFlowSnippetPreview:cse,skillsMeaning:use,skillPreview:dse,skillPreviewEmpty:fse,selectResource:pse,loadFailed:hse,noPipelines:mse,emptyHint:gse,noMatch:yse,recentActivity:wse,noRecentActivity:xse,noMatchRecent:bse,recentRun:kse,recentOpen:vse,sourceBadge:Sse,resourceSource:Nse,resourceFilter:jse,nodeDetailTabs:Cse,defaultCardDesc:_se,hubCard:Ese,newPipelineModal:Ase,importModal:Pse,deleteModal:Ise,archiveModal:Rse},Mse="返回",$se="下一步",Lse="跳过",Ose="完成",Dse="开始创建",Fse={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
302
-
303
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
304
-
305
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},zse={intro:`现在进入流程编辑器。
306
-
307
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
308
-
309
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
310
-
311
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
312
-
313
- 左侧节点面板可以自由拖拽、删除和调整连接。`},Bse={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Hse={back:Mse,next:$se,skip:Lse,done:Ose,startCreate:Dse,projects:Fse,flow:zse,newPipeline:Bse},Wse={en:{common:EX,flow:pQ,settings:_Q,composer:MQ,project:Gee,onboarding:ste},zh:{common:fte,flow:Xte,settings:dne,composer:wne,project:Tse,onboarding:Hse}};yr.use(pM).use(pD).init({resources:Wse,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 Vse=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Kse(e){return yr.changeLanguage(e)}const db="agentflow-settings-opencode-plan-v1",Vu="CURSOR_API_KEYS",Ku="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",ow=new Set([Vu,Ku,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),hM=["cursor","opencode","claudeCode","codex"];function mM(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function fb(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function xa(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of hM)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(fb).filter(Boolean))]:[];return n}function Hi(e){if(!e||typeof e!="object")return mM();const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],codex:Array.isArray(t.codex)?t.codex.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null,codexFetchedAt:t.codexFetchedAt??null}}function hc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function qse(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Na(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const s=String(r.key??"").trim(),i=String(r.value??""),a=String(r.id??"").trim()||hc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!i||n.push({id:a,key:s,value:i,scope:c})}return n}function i_(e){return Na(e).map(({key:t,value:n})=>({key:t,value:n}))}function o_(){try{return localStorage.getItem(db)??""}catch{return""}}function gM(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function Use(e){const t=String(e||"").trim();if(!t)return[];const n=(r,s)=>{if(typeof r=="string"){const a=r.trim();return a?{id:`legacy_${s}_${a.slice(-6)}`,name:`Key ${s+1}`,key:a,createdAt:""}:null}if(!r||typeof r!="object")return null;const i=String(r.key??"").trim();return i?{id:String(r.id??"").trim()||hc(),name:String(r.name??"").trim()||`Key ${s+1}`,key:i,createdAt:String(r.createdAt??"").trim()}:null};try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n).filter(Boolean)}catch{}return t.split(",").map((r,s)=>n(r,s)).filter(Boolean)}function a_(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||hc(),name:String((n==null?void 0:n.name)||"").trim()||`Key ${r+1}`,key:String((n==null?void 0:n.key)||"").trim(),createdAt:String((n==null?void 0:n.createdAt)||"").trim()||new Date().toISOString()})).filter(n=>n.key):[];return JSON.stringify(t)}function Yse(e){const t=String(e||"").trim();return t?t.length<=10?gM(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function Gse(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 Jse({authUser:e}){const{t,i18n:n}=Dr(["common","settings"]),r=n.language||"zh",[s,i]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[d,f]=m.useState(mM()),[p,h]=m.useState(()=>xa({})),[g,k]=m.useState(!1),[b,y]=m.useState(""),[v,x]=m.useState(""),[C,N]=m.useState(!1),[j,A]=m.useState(!1),[I,O]=m.useState(""),[H,B]=m.useState([]),[z,$]=m.useState(""),[M,q]=m.useState(!1),[D,L]=m.useState(""),[T,W]=m.useState(""),[E,Q]=m.useState(!1),[V,F]=m.useState(()=>new Set),[se,ce]=m.useState(""),[J,ne]=m.useState(""),[ee,re]=m.useState(!!(e!=null&&e.isAdmin)),[Z,le]=m.useState(""),[de,we]=m.useState([]),[De,Qe]=m.useState([]),[Oe,st]=m.useState(""),[mt,kt]=m.useState(""),[Pe,dt]=m.useState(!1),[gt,xe]=m.useState(!1),[Fe,Me]=m.useState(""),[ue,ve]=m.useState(""),[Ve,qe]=m.useState(""),[be,Tt]=m.useState(null),[ln,_t]=m.useState(!1),[hn,tn]=m.useState(!1),[te,Ie]=m.useState(""),Ue=m.useRef(null),Ze=m.useRef(!1),Mt=m.useRef(!1),At=m.useRef(""),tr=m.useCallback(async()=>{l("");try{const ie=await fetch("/api/ui-context");if(!ie.ok)throw new Error("HTTP "+ie.status);const Se=await ie.json();i(typeof Se.workspaceRoot=="string"?Se.workspaceRoot:"")}catch(ie){l(String(ie.message||ie)),i("")}},[]),kn=m.useCallback(async()=>{x(""),N(!0),y("");try{const ie=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!ie.ok)throw new Error("HTTP "+ie.status);const Se=await ie.json();if(e!=null&&e.isAdmin)u(Hi(Se.modelLists)),f(Hi(Se.allModelLists)),h(xa(Se.hiddenModels));else{const Ee=Hi(Se);u(Ee),f(Ee),h(xa({}))}}catch(ie){x(String(ie.message||ie))}finally{N(!1)}},[e==null?void 0:e.isAdmin]),nr=m.useCallback(async()=>{$("");try{const ie=await fetch("/api/user-env"),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Ee=Na(Array.isArray(Se.env)?Se.env:[],"user").map(Vt=>({...Vt,scope:"user"})),Ot=[...e!=null&&e.isAdmin?Na(Array.isArray(Se.globalEnv)?Se.globalEnv:[],"global").map(Vt=>({...Vt,scope:"global"})):[],...Ee];At.current=JSON.stringify(Ot),B(Ot)}catch(ie){B([]),$(String(ie.message||ie))}finally{Mt.current=!0}},[e==null?void 0:e.isAdmin]),vn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){dt(!0),Me("");try{const ie=await fetch("/api/admin/user-allowlist"),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Ee=Se.allowlist&&typeof Se.allowlist=="object"?Se.allowlist:{};we(Array.isArray(Ee.fileUsers)?Ee.fileUsers.map(String):[]),Qe(Array.isArray(Ee.envUsers)?Ee.envUsers.map(String):[]),st(typeof Ee.path=="string"?Ee.path:"")}catch(ie){Me(String(ie.message||ie))}finally{dt(!1)}}},[e==null?void 0:e.isAdmin]),Jn=m.useCallback(async ie=>{if(e!=null&&e.isAdmin){xe(!0),Me("");try{const Se=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ie})}),Ee=await Se.json().catch(()=>({}));if(!Se.ok)throw new Error(typeof Ee.error=="string"?Ee.error:"HTTP "+Se.status);const wt=Ee.allowlist&&typeof Ee.allowlist=="object"?Ee.allowlist:{};we(Array.isArray(wt.fileUsers)?wt.fileUsers.map(String):[]),Qe(Array.isArray(wt.envUsers)?wt.envUsers.map(String):[]),st(typeof wt.path=="string"?wt.path:"")}catch(Se){Me(String(Se.message||Se))}finally{xe(!1)}}},[e==null?void 0:e.isAdmin]),Wn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){_t(!0),Ie("");try{const ie=await fetch("/api/admin/storage-config"),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Ee=Se.config&&typeof Se.config=="object"?Se.config:{};Tt(Ee),ve(typeof Ee.dataRoot=="string"?Ee.dataRoot:""),qe(typeof Ee.skillsRoot=="string"?Ee.skillsRoot:"")}catch(ie){Ie(String(ie.message||ie))}finally{_t(!1)}}},[e==null?void 0:e.isAdmin]),ur=m.useCallback(async()=>{if(e!=null&&e.isAdmin){tn(!0),Ie("");try{const ie=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:ue.trim(),skillsRoot:Ve.trim(),migrateLegacySkills:!0})}),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);const Ee=Se.config&&typeof Se.config=="object"?Se.config:{};Tt(Ee),ve(typeof Ee.dataRoot=="string"?Ee.dataRoot:""),qe(typeof Ee.skillsRoot=="string"?Ee.skillsRoot:"")}catch(ie){Ie(String(ie.message||ie))}finally{tn(!1)}}},[e==null?void 0:e.isAdmin,ue,Ve]),gs=m.useCallback(async ie=>{const Se=Na(ie),Ee=Se.filter(Ot=>Ot.scope!=="global"),wt=Se.filter(Ot=>Ot.scope==="global");q(!0),$("");try{const Ot=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:i_(Ee),...e!=null&&e.isAdmin?{globalEnv:i_(wt)}:{}})}),Vt=await Ot.json().catch(()=>({}));if(!Ot.ok)throw new Error(typeof Vt.error=="string"?Vt.error:"HTTP "+Ot.status);const Dn=Na(Array.isArray(Vt.env)?Vt.env:[],"user").map(pe=>({...pe,scope:"user"})),K=[...e!=null&&e.isAdmin?Na(Array.isArray(Vt.globalEnv)?Vt.globalEnv:[],"global").map(pe=>({...pe,scope:"global"})):[],...Dn];At.current=JSON.stringify(K),B(K)}catch(Ot){$(String(Ot.message||Ot))}finally{q(!1)}},[e==null?void 0:e.isAdmin]),wr=m.useCallback(async()=>{x(""),N(!0);try{const ie=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z.trim()})}),Se=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+ie.status);u(Hi(Se.modelLists)),e!=null&&e.isAdmin?await kn():f(Hi(Se.modelLists))}catch(ie){x(String(ie.message||ie))}finally{N(!1)}},[e==null?void 0:e.isAdmin,kn,Z]),Rs=m.useCallback(async ie=>{if(!(e!=null&&e.isAdmin))return;const Se=xa(ie);h(Se),k(!0),y("");try{const Ee=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:Se})}),wt=await Ee.json().catch(()=>({}));if(!Ee.ok)throw new Error(typeof wt.error=="string"?wt.error:"HTTP "+Ee.status);u(Hi(wt.modelLists)),f(Hi(wt.allModelLists)),h(xa(wt.hiddenModels))}catch(Ee){y(String(Ee.message||Ee)),kn()}finally{k(!1)}},[e==null?void 0:e.isAdmin,kn]),Fr=m.useCallback((ie,Se,Ee)=>{const wt=hM.includes(ie)?ie:"cursor",Ot=fb(Se);if(!Ot)return;const Vt=xa(p),Dn=new Set(Vt[wt]);Ee?Dn.delete(Ot):Dn.add(Ot),Rs({...Vt,[wt]:Array.from(Dn)})},[p,Rs]);m.useEffect(()=>{nr(),e!=null&&e.isAdmin?(tr(),kn(),vn(),Wn(),(async()=>{try{const ie=await fetch("/api/agentflow-config");if(ie.ok){const Se=await ie.json(),Ee=typeof Se.opencodeProvider=="string"?Se.opencodeProvider:"";le(Ee),Ue.current=Ee;try{localStorage.setItem(db,Ee)}catch{}}else{const Se=o_();le(Se),Ue.current=Se}}catch{const ie=o_();le(ie),Ue.current=ie}finally{Ze.current=!0}})()):(i(""),Ze.current=!1)},[e==null?void 0:e.isAdmin,tr,kn,Wn,vn,nr]),m.useEffect(()=>{if(!Mt.current||JSON.stringify(Na(H))===At.current)return;const Se=setTimeout(()=>{gs(H)},350);return()=>clearTimeout(Se)},[H,gs]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!Ze.current)return;const ie=Z.trim();if(ie===Ue.current)return;const Se=setTimeout(()=>{(async()=>{A(!0),O("");try{const Ee=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ie})}),wt=await Ee.json().catch(()=>({}));if(!Ee.ok)throw new Error(typeof wt.error=="string"?wt.error:"HTTP "+Ee.status);Ue.current=ie;try{localStorage.setItem(db,ie)}catch{}wt.modelLists&&(u(Hi(wt.modelLists)),e!=null&&e.isAdmin?kn():f(Hi(wt.modelLists)))}catch(Ee){O(String(Ee.message||Ee))}finally{A(!1)}})()},450);return()=>clearTimeout(Se)},[e==null?void 0:e.isAdmin,kn,Z]);const on=e!=null&&e.isAdmin?d:c,xr=on.cursor.length>0,br=on.opencode.length>0,mn=on.claudeCode.length>0,Vn=on.codex.length>0,kr=xa(p),dr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},vt=m.useCallback((ie,Se,Ee)=>{const wt=Array.isArray(Se)?Se:[];if(!(e!=null&&e.isAdmin))return o.jsx("pre",{className:"af-set-model-preview","aria-label":Ee,children:wt.join(`
314
- `)});const Ot=new Set(kr[ie]||[]);return o.jsxs("div",{className:"af-set-model-visibility","aria-label":Ee,children:[o.jsxs("div",{className:"af-set-model-visibility-head",children:[o.jsxs("span",{children:["展示 ",dr[ie]||0," / ",wt.length]}),o.jsx("span",{children:g?"保存中":"取消勾选后从模型下拉隐藏"})]}),o.jsx("div",{className:"af-set-model-visibility-list",children:wt.map(Vt=>{const Dn=fb(Vt),Mn=!Ot.has(Dn);return o.jsxs("label",{className:"af-set-model-visibility-row",children:[o.jsx("input",{type:"checkbox",checked:Mn,disabled:g,onChange:K=>Fr(ie,Vt,K.target.checked)}),o.jsx("span",{children:Vt})]},`${ie}-${Vt}`)})})]})},[e==null?void 0:e.isAdmin,kr,g,dr,Fr]),Ut=de.length>0||De.length>0,ae=e!=null&&e.isAdmin?H:H.filter(ie=>!ow.has(String((ie==null?void 0:ie.key)||"").trim())),ke=e!=null&&e.isAdmin&&ee?"global":"user",it=m.useMemo(()=>H.find(ie=>ie.key===Vu&&(ie.scope||"user")===ke)||null,[ke,H]),bt=m.useMemo(()=>Use((it==null?void 0:it.value)||""),[it==null?void 0:it.value]),cn=m.useMemo(()=>H.find(ie=>ie.key===Ku&&(ie.scope||"user")===ke)||null,[ke,H]),On=cn!=null&&cn.value?String(cn.value):"30",nn=m.useCallback((ie,Se,Ee)=>{const wt=String(ie||"").trim();if(!wt)return;const Ot=String(Se??"");B(Vt=>{const Dn=Vt.find(Mn=>Mn.key===wt&&(Mn.scope||"user")===Ee);return Ot?Dn?Vt.map(Mn=>Mn.id===Dn.id?{...Mn,value:Ot,scope:Ee}:Mn):[{id:hc(),key:wt,value:Ot,scope:Ee},...Vt]:Vt.filter(Mn=>!(Mn.key===wt&&(Mn.scope||"user")===Ee))})},[]),vr=m.useCallback(()=>{const ie=J.trim();if(!ie)return;const Se=[...bt,{id:hc(),name:se.trim()||`Key ${bt.length+1}`,key:ie,createdAt:new Date().toISOString()}];nn(Vu,a_(Se),ke),ce(""),ne("")},[se,bt,ke,J,nn]),ft=m.useCallback(ie=>{const Se=bt.filter(Ee=>Ee.id!==ie);nn(Vu,Se.length?a_(Se):"",ke)},[bt,ke,nn]),Yt=m.useCallback(ie=>{const Se=String(ie||"").replace(/[^\d]/g,"");if(!Se){nn(Ku,"",ke);return}const Ee=Math.min(1440,Math.max(1,Number(Se)||30));nn(Ku,String(Ee),ke)},[ke,nn]),Gt=m.useCallback(()=>{var ie;s&&((ie=navigator.clipboard)==null||ie.writeText(s))},[s]),Sr=m.useCallback(()=>{const ie=D.trim(),Se=T;if(ie){if(!qse(ie)){$(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&ow.has(ie)){$("该运行基础设施变量仅管理员可配置。");return}B(Ee=>[{id:hc(),key:ie,value:Se,scope:e!=null&&e.isAdmin&&E?"global":"user"},...Ee]),L(""),W("")}},[e==null?void 0:e.isAdmin,E,D,T,t]),tt=m.useCallback(ie=>{B(Se=>Se.filter(Ee=>Ee.id!==ie))},[]),Xn=m.useCallback((ie,Se)=>{const Ee=String((Se==null?void 0:Se.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Ee&&ow.has(Ee)){$("该运行基础设施变量仅管理员可配置。");return}B(wt=>wt.map(Ot=>Ot.id===ie?{...Ot,...Se}:Ot))},[e==null?void 0:e.isAdmin]),Mi=m.useCallback(ie=>{F(Se=>{const Ee=new Set(Se);return Ee.has(ie)?Ee.delete(ie):Ee.add(ie),Ee})},[]),zr=m.useCallback(()=>{const ie=mt.trim();if(!ie)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ie)){Me("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Ee=>String(Ee||"").trim().toLowerCase())).has(ie.toLowerCase())){kt("");return}kt(""),Jn([...de,ie])},[mt,de,Jn]),ho=m.useCallback(ie=>{const Se=String(ie||"").trim().toLowerCase();Se&&Jn(de.filter(Ee=>String(Ee||"").trim().toLowerCase()!==Se))},[de,Jn]),ai=m.useCallback(ie=>{const Se=ie.target.value;Kse(Se)},[]),Ts=ie=>{const Se=Gse(ie,r);return Se?t("settings:cursor.modelList.fetchedAt",{time:Se}):t("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":t("settings:title"),children:[o.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),o.jsx("p",{className:"af-settings-lead",children:e!=null&&e.isAdmin?t("settings:workspace.description"):t("settings:env.note")}),e!=null&&e.isAdmin&&a?o.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,e!=null&&e.isAdmin&&v?o.jsx("p",{className:"af-err af-settings-api-hint",children:v}):null,z?o.jsx("p",{className:"af-err af-settings-api-hint",children:z}):null,te?o.jsx("p",{className:"af-err af-settings-api-hint",children:te}):null]}),o.jsx("div",{className:"af-settings-layout",children:o.jsxs("div",{className:"af-settings-bento",children:[e!=null&&e.isAdmin?o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[o.jsxs("div",{className:"af-set-card-inner",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),o.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),o.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Gt,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:o.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),o.jsx("p",{className:"af-set-hint",children:"当前页面只展示运行时根目录。可被节点加载的代码库和文档目录请在左侧“知识库”里维护。"})]}),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"+(xr?" af-set-badge--ok":" af-set-badge--muted"),children:t(xr?"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:xr?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(xr?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:xr?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${on.cursor.length}`:"")+" · "+Ts(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),xr?vt("cursor",on.cursor,t("settings:cursor.modelPreviewLabel")):null,b?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:b}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>wr(),disabled:C,children:t(C?"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-cursor-pool",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:"key"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"Cursor API Key 池"}),o.jsx("p",{className:"af-set-card-subtitle",children:"按请求轮换,遇到 usage limit 或 resource_exhausted 会自动尝试下一个 Key。"})]})]}),o.jsxs("span",{className:"af-set-badge"+(bt.length?" af-set-badge--ok":" af-set-badge--muted"),children:[bt.length," keys"]})]}),o.jsxs("div",{className:"af-set-cursor-pool-controls",children:[e!=null&&e.isAdmin?o.jsxs("div",{className:"af-set-env-scope-switch af-set-cursor-scope",role:"group","aria-label":"Cursor API Key scope",children:[o.jsx("button",{type:"button",className:ee?"":"is-active",onClick:()=>re(!1),children:"个人"}),o.jsx("button",{type:"button",className:ee?"is-active":"",onClick:()=>re(!0),children:"全局"})]}):null,o.jsxs("label",{className:"af-set-cursor-cooldown",children:[o.jsx("span",{children:"限额冷却"}),o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",inputMode:"numeric",value:On,onChange:ie=>Yt(ie.target.value)}),o.jsx("span",{children:"分钟"})]}),o.jsx("span",{className:"af-set-env-note",children:M?"保存中":ke==="global"?"全局配置":"个人配置"})]}),o.jsx("div",{className:"af-set-cursor-key-list",children:bt.length?bt.map(ie=>o.jsxs("div",{className:"af-set-cursor-key-row",children:[o.jsxs("div",{className:"af-set-cursor-key-main",children:[o.jsx("strong",{children:ie.name}),o.jsx("code",{children:Yse(ie.key)})]}),o.jsx("span",{className:"af-set-cursor-key-meta",children:ie.createdAt?new Date(ie.createdAt).toLocaleString():"历史 Key"}),o.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${ie.name}`,onClick:()=>ft(ie.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie.id)):o.jsx("div",{className:"af-set-cursor-key-empty",children:"还没有配置 Key。配置后 Cursor CLI runner 会自动轮换使用。"})}),o.jsxs("div",{className:"af-set-cursor-key-add",children:[o.jsx("input",{className:"af-set-input",value:se,onChange:ie=>ce(ie.target.value),placeholder:"名称,例如 Team Key 1"}),o.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:J,onChange:ie=>ne(ie.target.value),placeholder:"Cursor API Key"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:vr,disabled:!J.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),o.jsxs("p",{className:"af-set-hint",children:["保存到 ",Vu,";冷却时间保存到 ",Ku,"。个人配置会覆盖全局配置。"]})]}),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"+(br?" af-set-badge--ok":" af-set-badge--err"),children:t(br?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),o.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),o.jsxs("div",{children:[o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),o.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:Z,onChange:ie=>le(ie.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),j?o.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,I?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:I}):null]}),br?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+(e!=null&&e.isAdmin?` / ${on.opencode.length}`:"")+" · "+Ts(c.opencodeFetchedAt)}),vt("opencode",on.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>wr(),disabled:C,children:t(C?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),o.jsx("span",{className:"af-set-badge"+(mn?" af-set-badge--ok":" af-set-badge--err"),children:t(mn?"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:mn?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(mn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:mn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${on.claudeCode.length}`:"")+" · "+Ts(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),mn?vt("claudeCode",on.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>wr(),disabled:C,children:t(C?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:codex.title")}),o.jsx("span",{className:"af-set-badge"+(Vn?" af-set-badge--ok":" af-set-badge--err"),children:t(Vn?"settings:codex.status.ready":"settings:codex.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:Vn?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(Vn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:Vn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${on.codex.length}`:"")+" · "+Ts(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Vn?vt("codex",on.codex,t("settings:codex.modelPreviewLabel")):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>wr(),disabled:C,children:t(C?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]})]}):null,o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),o.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),o.jsx("span",{className:"af-set-env-note",children:M?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[o.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[o.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?o.jsx("span",{children:t("settings:env.scope")}):null,o.jsx("span",{children:t("settings:env.value")}),o.jsx("span",{})]}),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:D,onChange:ie=>L(ie.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:E?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:E?"is-active":"",onClick:()=>Q(!0),children:t("settings:env.global")})]})}):null,o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:T,onChange:ie=>W(ie.target.value),"aria-label":t("settings:env.newValue")})}),o.jsx("div",{className:"af-set-env-actions",children:o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Sr,disabled:!D.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),ae.map(ie=>o.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:ie.key,onChange:Se=>Xn(ie.id,{key:Se.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:ie.scope!=="global"?"is-active":"",onClick:()=>Xn(ie.id,{scope:"user"}),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:ie.scope==="global"?"is-active":"",onClick:()=>Xn(ie.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:V.has(ie.id)?"text":"password",value:ie.value,onChange:Se=>Xn(ie.id,{value:Se.target.value}),placeholder:gM(ie.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),o.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>Mi(ie.id),"aria-label":V.has(ie.id)?"Hide value":"Show value",children:o.jsx("span",{className:"material-symbols-outlined",children:V.has(ie.id)?"visibility_off":"visibility"})})]}),o.jsx("div",{className:"af-set-env-actions",children:o.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ie.key}),onClick:()=>tt(ie.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ie.id))]})]}),e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",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:"hard_drive_2"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),o.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),o.jsx("span",{className:"af-set-badge"+(be!=null&&be.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:be!=null&&be.envLocked?"Env locked":"Configurable"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Wn(),disabled:ln||hn,children:ln?"刷新中...":"刷新"})]}),te?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:te}):null,o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:ue,onChange:ie=>ve(ie.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(be!=null&&be.envLocked)||hn}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void ur(),"aria-label":"保存 AgentFlow Data Root",disabled:hn||!!(be!=null&&be.envLocked),children:o.jsx("span",{className:"material-symbols-outlined",children:hn?"hourglass_empty":"save"})})]}),o.jsxs("p",{className:"af-set-hint",children:["当前目录:",o.jsx("code",{children:(be==null?void 0:be.dataRoot)||ue||"-"}),be!=null&&be.configPath?o.jsxs(o.Fragment,{children:[";配置文件:",o.jsx("code",{children:be.configPath})]}):null]}),o.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",o.jsx("code",{children:"users/"}),"、",o.jsx("code",{children:"pipelines/"}),"、",o.jsx("code",{children:"runBuild/"}),"、",o.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",be!=null&&be.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]}),o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-skills-root",children:"Skills Root"}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-agentflow-skills-root",className:"af-set-input af-set-input--mono",type:"text",value:Ve,onChange:ie=>qe(ie.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(be!=null&&be.skillsEnvLocked)||hn}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void ur(),"aria-label":"保存 AgentFlow Skills Root",disabled:hn||!!(be!=null&&be.skillsEnvLocked),children:o.jsx("span",{className:"material-symbols-outlined",children:hn?"hourglass_empty":"save"})})]}),o.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",o.jsx("code",{children:(be==null?void 0:be.skillsRoot)||Ve||"-"}),be!=null&&be.legacySkillsRootExists?o.jsxs(o.Fragment,{children:[";保存时会补迁移旧目录 ",o.jsx("code",{children:be.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),o.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",be!=null&&be.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),o.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),o.jsx("span",{className:"af-set-badge"+(Ut?" af-set-badge--ok":" af-set-badge--muted"),children:t(Ut?"settings:allowlist.enabled":"settings:allowlist.open")}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void vn(),disabled:Pe,children:t(Pe?"settings:allowlist.refreshing":"common:common.refresh")})]}),Fe?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Fe}):null,Oe?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",o.jsx("code",{children:Oe})]}):null,o.jsxs("div",{className:"af-allowlist-grid",children:[o.jsxs("div",{className:"af-allowlist-main",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.fileList")}),o.jsx("span",{children:gt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:de.length})})]}),o.jsx("div",{className:"af-allowlist-list",children:de.length>0?de.map(ie=>o.jsxs("div",{className:"af-allowlist-row",children:[o.jsx("span",{className:"af-allowlist-name",children:ie}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>ho(ie),"aria-label":t("settings:allowlist.remove",{username:ie}),disabled:gt,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie)):o.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),o.jsxs("div",{className:"af-allowlist-add",children:[o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:mt,onChange:ie=>kt(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&zr()},placeholder:"username",autoComplete:"off"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:zr,disabled:gt||!mt.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),o.jsxs("div",{className:"af-allowlist-side",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.envList")}),o.jsx("span",{children:t("settings:allowlist.readonly")})]}),o.jsx("div",{className:"af-allowlist-env-list",children:De.length>0?De.map(ie=>o.jsx("code",{children:ie},ie)):o.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,o.jsxs("section",{className:"af-settings-rail","aria-label":t("settings:title"),children:[e!=null&&e.isAdmin?o.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[o.jsxs("div",{className:"af-set-rail-inner",children:[o.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),o.jsxs("div",{className:"af-set-health-line",children:[o.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),o.jsx("span",{className:"af-set-health-label",children:t(!a&&!v?"settings:system.normal":"settings:system.abnormal")})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.cursorModels")}),o.jsx("span",{children:c.cursor.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.opencodeModels")}),o.jsx("span",{children:c.opencode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.claudeCodeModels")}),o.jsx("span",{children:c.claudeCode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.codexModels")}),o.jsx("span",{children:c.codex.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.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"})})]}):null,o.jsxs("div",{className:"af-set-rail-card",children:[o.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),o.jsxs("div",{className:"af-set-language-selector",children:[o.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:ai,"aria-label":t("settings:language.description"),children:Vse.map(ie=>o.jsxs("option",{value:ie.code,children:[ie.flag," ",ie.name]},ie.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function Wr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function Mp(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function aw(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const s=Math.round(r/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function Xse(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function lw(e){if(!e)return"无运行记录";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(Number(e)))}catch{return String(e)}}function Qse(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function Zse(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function eie({authUser:e}){const[t,n]=m.useState(null),[r,s]=m.useState(!1),[i,a]=m.useState(""),l=m.useCallback(async()=>{if(e!=null&&e.isAdmin){s(!0),a("");try{const h=await fetch("/api/admin/usage-dashboard"),g=await h.json().catch(()=>({}));if(!h.ok)throw new Error(typeof g.error=="string"?g.error:"HTTP "+h.status);n(g)}catch(h){n(null),a(String((h==null?void 0:h.message)||h))}finally{s(!1)}}},[e==null?void 0:e.isAdmin]);m.useEffect(()=>{l()},[l]);const c=Array.isArray(t==null?void 0:t.dailyTrend)?t.dailyTrend:[],u=m.useMemo(()=>{const k={top:20,right:24,bottom:42,left:42},b=980-k.left-k.right,y=250-k.top-k.bottom,v=c.length>0?c:[],x=Math.max(1,...v.map(O=>Number(O.runs||0))),C=Math.max(1,...v.flatMap(O=>[Number(O.users||0),Number(O.pipelines||0)])),N=O=>k.left+(v.length<=1?b/2:O*b/(v.length-1)),j=O=>k.top+y-Math.max(0,Number(O||0))/x*y,A=O=>k.top+y-Math.max(0,Number(O||0))/C*y,I=O=>v.map((H,B)=>`${B===0?"M":"L"} ${N(B)} ${A(H[O])}`).join(" ");return{width:980,height:250,margin:k,innerHeight:y,rows:v,x:N,yRuns:j,yLine:A,lineUsers:I("users"),linePipelines:I("pipelines"),barWidth:Math.min(34,Math.max(12,b/Math.max(1,v.length)*.44))}},[c]),d=(t==null?void 0:t.usage)||{},f=(t==null?void 0:t.totals)||{},p=Array.isArray(t==null?void 0:t.recentRuns)?t.recentRuns:[];return e!=null&&e.isAdmin?o.jsxs("main",{className:"af-admin-usage-page",children:[o.jsxs("section",{className:"af-admin-usage-hero",children:[o.jsxs("div",{children:[o.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),o.jsx("h1",{children:"管理看板"}),o.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),o.jsxs("button",{type:"button",onClick:()=>void l(),disabled:r,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),r?"刷新中":"刷新"]})]}),i?o.jsx("div",{className:"af-project-admin-usage__error",children:i}):null,o.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[o.jsxs("div",{children:[o.jsx("span",{children:"7日活跃用户率"}),o.jsx("strong",{children:Mp(d.activeUserRate)}),o.jsxs("em",{children:[Wr(d.activeUsers)," / ",Wr(f.users)," users"]})]}),o.jsxs("div",{children:[o.jsx("span",{children:"7日流水线使用率"}),o.jsx("strong",{children:Mp(d.activePipelineRate)}),o.jsxs("em",{children:[Wr(d.activePipelines)," / ",Wr(f.activePipelines)," active"]})]}),o.jsxs("div",{children:[o.jsx("span",{children:"7日 Run"}),o.jsx("strong",{children:Wr(d.runs)}),o.jsxs("em",{children:[Wr(d.avgRunsPerDay)," / day"]})]}),o.jsxs("div",{children:[o.jsx("span",{children:"7日成功率"}),o.jsx("strong",{children:Mp(d.successRate)}),o.jsxs("em",{children:["失败率 ",Mp(d.failureRate)," · avg ",aw(d.avgDurationMs)]})]})]}),o.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[o.jsx("div",{className:"af-project-admin-usage__head",children:o.jsxs("div",{children:[o.jsx("strong",{children:"每日趋势"}),o.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),o.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[o.jsxs("div",{className:"af-admin-usage-chart__legend",children:[o.jsxs("span",{children:[o.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),o.jsxs("span",{children:[o.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),o.jsxs("span",{children:[o.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),o.jsx("div",{className:"af-admin-usage-chart__canvas",children:o.jsxs("svg",{viewBox:`0 0 ${u.width} ${u.height}`,preserveAspectRatio:"xMidYMid meet",children:[o.jsx("line",{className:"af-admin-usage-chart__axis",x1:u.margin.left,y1:u.margin.top+u.innerHeight,x2:u.width-u.margin.right,y2:u.margin.top+u.innerHeight}),[.25,.5,.75,1].map(h=>o.jsx("line",{className:"af-admin-usage-chart__grid",x1:u.margin.left,y1:u.margin.top+u.innerHeight-u.innerHeight*h,x2:u.width-u.margin.right,y2:u.margin.top+u.innerHeight-u.innerHeight*h},h)),u.rows.map((h,g)=>{const k=u.x(g),b=u.yRuns(h.runs),y=u.margin.top+u.innerHeight,v=Math.max(2,y-b);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:k-u.barWidth/2,y:y-v,width:u.barWidth,height:v,rx:"5",children:o.jsx("title",{children:`${h.date}: ${h.runs} runs`})}),o.jsx("text",{className:"af-admin-usage-chart__value",x:k,y:y+22,children:Wr(h.runs)}),o.jsx("text",{className:"af-admin-usage-chart__date",x:k,y:y+42,children:Xse(h.date)})]},h.date)}),u.rows.length>0?o.jsxs(o.Fragment,{children:[o.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:u.lineUsers}),o.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:u.linePipelines}),u.rows.map((h,g)=>{const k=u.x(g);return o.jsxs("g",{children:[o.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:k,cy:u.yLine(h.users),r:"3.5"}),o.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:k,cy:u.yLine(h.pipelines),r:"3.5"})]},`${h.date}-points`)})]}):null]})})]}),o.jsx("div",{className:"af-project-admin-usage__table-wrap",children:o.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"用户"}),o.jsx("th",{children:"流水线"}),o.jsx("th",{children:"运行时间"}),o.jsx("th",{children:"状态"}),o.jsx("th",{children:"耗时"}),o.jsx("th",{children:"Run ID"})]})}),o.jsx("tbody",{children:p.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:6,children:"暂无运行明细"})}):p.map(h=>o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:h.username||h.userId||"-"}),o.jsx("span",{children:h.userId||"-"})]}),o.jsxs("td",{children:[o.jsx("strong",{children:h.flowId||"-"}),o.jsxs("span",{children:[h.runType==="workspace"?"Workspace Run":"Pipeline"," · ",h.flowSource||"user"]})]}),o.jsxs("td",{children:[o.jsx("strong",{children:lw(h.at)}),h.endedAt?o.jsxs("span",{children:["结束 ",lw(h.endedAt)]}):o.jsx("span",{children:"未结束"})]}),o.jsx("td",{children:o.jsx("span",{className:"af-project-admin-usage__chips",children:o.jsx("em",{children:Zse(h.status)})})}),o.jsx("td",{children:aw(h.durationMs)}),o.jsx("td",{children:o.jsx("code",{className:"af-admin-usage-run-id",children:Qse(h.runId)})})]},`${h.userId}:${h.flowSource}:${h.flowId}:${h.runId}:${h.at}`))})]})})]}),o.jsxs("section",{className:"af-project-admin-usage",children:[o.jsx("div",{className:"af-project-admin-usage__head",children:o.jsxs("div",{children:[o.jsx("strong",{children:"用户使用明细"}),o.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),o.jsx("div",{className:"af-project-admin-usage__table-wrap",children:o.jsxs("table",{className:"af-project-admin-usage__table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"User"}),o.jsx("th",{children:"Pipeline"}),o.jsx("th",{children:"Runs"}),o.jsx("th",{children:"状态"}),o.jsx("th",{children:"最近运行"})]})}),o.jsx("tbody",{children:r&&!t?o.jsx("tr",{children:o.jsx("td",{colSpan:5,children:"正在加载..."})}):((t==null?void 0:t.users)||[]).length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:5,children:"暂无用户数据"})}):((t==null?void 0:t.users)||[]).map(h=>{var g,k,b,y,v,x,C,N,j,A,I;return o.jsxs("tr",{children:[o.jsxs("td",{children:[o.jsx("strong",{children:h.username||h.userId}),o.jsxs("span",{children:[h.userId,h.isAdmin?" · admin":""]})]}),o.jsxs("td",{children:[o.jsx("strong",{children:Wr((g=h.pipelines)==null?void 0:g.total)}),o.jsxs("span",{children:[Wr((k=h.pipelines)==null?void 0:k.active)," active / ",Wr((b=h.pipelines)==null?void 0:b.archived)," archived"]})]}),o.jsxs("td",{children:[o.jsx("strong",{children:Wr((y=h.runs)==null?void 0:y.total)}),o.jsxs("span",{children:["avg ",aw((v=h.runs)==null?void 0:v.avgDurationMs)]})]}),o.jsx("td",{children:o.jsxs("span",{className:"af-project-admin-usage__chips",children:[o.jsxs("em",{children:["成功 ",Wr((x=h.runs)==null?void 0:x.success)]}),o.jsxs("em",{children:["失败 ",Wr((C=h.runs)==null?void 0:C.failed)]}),o.jsxs("em",{children:["运行中 ",Wr((N=h.runs)==null?void 0:N.running)]})]})}),o.jsx("td",{children:(j=h.runs)!=null&&j.lastRunAt?o.jsxs(o.Fragment,{children:[o.jsx("strong",{children:((A=h.runs)==null?void 0:A.lastRunFlowId)||"-"}),o.jsxs("span",{children:[((I=h.runs)==null?void 0:I.lastRunStatus)||"unknown"," · ",lw(h.runs.lastRunAt)]})]}):o.jsx("span",{children:"无运行记录"})})]},h.userId)})})]})})]})]}):o.jsx("main",{className:"af-admin-usage-page",children:o.jsx("section",{className:"af-project-admin-usage",children:o.jsx("div",{className:"af-project-admin-usage__head",children:o.jsxs("div",{children:[o.jsx("strong",{children:"管理看板"}),o.jsx("span",{children:"需要管理员权限。"})]})})})})}function tie(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);try{return new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}).format(new Date(t))}catch{return String(e)}}function nie({authUser:e}){const{navigate:t}=si(),[n,r]=m.useState(""),[s,i]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState([]),[g,k]=m.useState(!1),[b,y]=m.useState(""),v=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(v){k(!0),y("");try{const N=await fetch("/api/feedback"),j=await N.json().catch(()=>({}));if(!N.ok)throw new Error(j.error||"加载失败");h(Array.isArray(j.feedback)?j.feedback:[])}catch(N){y(String(N.message||N)),h([])}finally{k(!1)}}},[v]);m.useEffect(()=>{x()},[x]);const C=async N=>{if(N.preventDefault(),!a){l(!0),u("");try{const j=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:s,pageUrl:window.location.href})}),A=await j.json().catch(()=>({}));if(!j.ok)throw new Error(A.error||"提交失败");f(!0),r(""),i("")}catch(j){u(String(j.message||j))}finally{l(!1)}}};return v?o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",children:[o.jsxs("div",{className:"af-feedback-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),o.jsx("h1",{children:"意见反馈"}),o.jsx("p",{children:"查看用户提交的问题、建议和功能需求。"})]}),o.jsxs("div",{className:"af-feedback-admin-actions",children:[o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:g,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:g?"hourglass_empty":"refresh"}),g?"刷新中...":"刷新"]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),b?o.jsx("p",{className:"af-err af-feedback-error",children:b}):null,o.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:p.length>0?p.map(N=>o.jsxs("article",{className:"af-feedback-item",children:[o.jsxs("header",{className:"af-feedback-item__head",children:[o.jsxs("div",{children:[o.jsx("h3",{children:N.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:N.username||N.userId||"unknown"}),o.jsx("span",{children:tie(N.createdAt)})]})]}),N.contact?o.jsx("span",{className:"af-feedback-item__contact",children:N.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:N.content}),N.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:N.pageUrl}):null]},N.id)):o.jsx("div",{className:"af-feedback-empty",children:g?"正在加载反馈...":"暂无反馈"})})]})}):o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel",children:[o.jsxs("div",{className:"af-feedback-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),o.jsx("h1",{children:"意见反馈"}),o.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在这里统一查看。"})]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?o.jsxs("div",{className:"af-feedback-success",role:"status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsxs("div",{children:[o.jsx("strong",{children:"已提交"}),o.jsx("span",{children:"感谢反馈,管理员可以在意见反馈页查看这条记录。"})]})]}):null,o.jsxs("form",{className:"af-feedback-form",onSubmit:C,children:[o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{value:n,onChange:N=>r(N.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"反馈内容"}),o.jsx("textarea",{value:s,onChange:N=>i(N.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),c?o.jsx("p",{className:"af-err af-feedback-error",children:c}):null,o.jsx("div",{className:"af-feedback-actions",children:o.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:a||!n.trim()||!s.trim(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"send"}),a?"提交中...":"提交反馈"]})})]})]})})}function yM(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function l_(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:yM(),key:r,value:String(s??""),private:n.has(r)}))}function c_(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 uh(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(`
315
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:l_(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:l_(t.headers||(e==null?void 0:e.headers),e==null?void 0:e.privateHeaderKeys),extraJson:JSON.stringify(Object.fromEntries(Object.entries(t).filter(([r])=>!["url","command","args","env","headers","description","__agentflowPrivateKeys"].includes(r))),null,2)}}function cw(){return uh({name:"",raw:{command:""}})}function rie(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=c_(e.envRows),s=c_(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 u_(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function d_(e){return e?e.ok?"ok":"error":"unknown"}function pb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function sie(e,t){return e&&e.label||t}async function uw(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText&&window.isSecureContext)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return r.remove(),s}catch{return!1}}function fv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function wM({baseUrl:e="",token:t=""}){return JSON.stringify({mcpServers:{agentflow:{command:"agentflow",args:["mcp"],env:{AGENTFLOW_BASE_URL:String(e||"http://127.0.0.1:8875"),AGENTFLOW_TOKEN:fv(t)}}}},null,2)}function xM({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(fv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
316
- `)}function iie({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=wM({baseUrl:n,token:t}),s=xM({baseUrl:n,token:t});return["你是一个 AI Coding Agent。请帮我把 AgentFlow 配置成当前开发环境可用的 MCP server。","","这是一项配置任务,不是调用任务:请修改 Cursor 或 Codex 的 MCP 配置文件,让它们能连接本机 AgentFlow。","","AgentFlow MCP server 信息:","- server name: agentflow","- command: agentflow",'- args: ["mcp"]',`- env.AGENTFLOW_BASE_URL: ${n}`,`- env.AGENTFLOW_TOKEN: ${fv(t)}`,"","Cursor 配置片段(合并到 .cursor/mcp.json 或 ~/.cursor/mcp.json):","```json",r,"```","","Codex 配置片段(合并到 ~/.codex/config.toml 的 mcp_servers 配置):","```toml",s,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 的 MCP 页面点击“使用当前登录 Token”后重新复制。","7. 如果外部 Agent 启动 MCP 时找不到 `agentflow` 命令,请把 command 改成本机 agentflow 可执行文件的绝对路径,或先把 agentflow 安装/软链到 PATH。","","配置后验证:","- 如果配置使用 `command: agentflow`,确认外部 Agent 所在环境可以执行这个命令;如果使用绝对路径,则确认路径存在且可执行。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
317
- `)}function oie({server:e}){const t=(e==null?void 0:e.backends)||{},n=[["Cursor",t.cursor],["Codex",t.codex]];return o.jsx("div",{className:"af-mcp-backends",children:n.map(([r,s])=>o.jsxs("div",{className:`af-mcp-backend af-mcp-backend--${pb(s==null?void 0:s.status)}`,children:[o.jsxs("div",{className:"af-mcp-backend-head",children:[o.jsx("strong",{children:r}),o.jsx("span",{children:sie(s,"Unknown")})]}),Array.isArray(s==null?void 0:s.reasons)&&s.reasons.length?o.jsx("ul",{children:s.reasons.map(i=>o.jsx("li",{children:i},i))}):o.jsx("p",{children:"当前配置可直接使用。"})]},r))})}function f_({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const i=(a,l,c)=>n(t.map(u=>u.id===a?{...u,[l]:c}:u));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:yM(),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 aie(){var ce;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,i]=m.useState(cw),[a,l]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[g,k]=m.useState({}),[b,y]=m.useState(""),[v,x]=m.useState(""),[C,N]=m.useState(()=>{var J;return typeof window<"u"&&((J=window.location)!=null&&J.origin)?window.location.origin:"http://127.0.0.1:8875"}),[j,A]=m.useState(""),[I,O]=m.useState(""),H=m.useMemo(()=>n.find(J=>J.name===a)||null,[a,n]),B=H&&g[H.name]||null,z=m.useMemo(()=>wM({baseUrl:C,token:j}),[C,j]),$=m.useMemo(()=>xM({baseUrl:C,token:j}),[C,j]),M=m.useMemo(()=>iie({baseUrl:C,token:j}),[C,j]),q=m.useCallback(async()=>{u(!0),y("");try{const J=await fetch("/api/mcps"),ne=await J.json().catch(()=>({}));if(!J.ok)throw new Error(ne.error||"MCP HTTP "+J.status);const ee=Array.isArray(ne.servers)?ne.servers:[];t(String(ne.path||"")),r(ee),a&&ee.some(re=>re.name===a)&&i(uh(ee.find(re=>re.name===a)))}catch(J){y(String(J.message||J))}finally{u(!1)}},[a]);m.useEffect(()=>{q()},[q]);const D=()=>{l(""),i(cw()),x(""),y("")},L=J=>{l(J.name),i(uh(J)),x(""),y("")},T=m.useCallback(async()=>{if(!M)return;const J=await uw(M);O(J?"prompt":"copy-failed"),window.setTimeout(()=>O(""),1200)},[M]),W=m.useCallback(async()=>{const J=await uw(z);O(J?"cursor":"copy-failed"),window.setTimeout(()=>O(""),1200)},[z]),E=m.useCallback(async()=>{const J=await uw($);O(J?"codex":"copy-failed"),window.setTimeout(()=>O(""),1200)},[$]),Q=m.useCallback(async()=>{try{const J=await fetch("/api/auth/session-token"),ne=await J.json().catch(()=>({}));if(!J.ok)throw new Error(typeof ne.error=="string"?ne.error:"HTTP "+J.status);A(String(ne.token||"")),O("token"),window.setTimeout(()=>O(""),1200)}catch(J){O(""),y(String(J.message||J))}},[]),V=async(J="")=>{h(!0),y(""),x("");try{const ne=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J?{name:J}:{})}),ee=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(ee.error||"检测 MCP 失败");const re=Array.isArray(ee.results)?ee.results:[];k(Z=>{const le={...Z};for(const de of re)de!=null&&de.name&&(le[de.name]=de);return le}),x(J?`已检测 ${J}。`:"已检测所有 MCP。")}catch(ne){y(String(ne.message||ne))}finally{h(!1)}},F=async()=>{f(!0),y(""),x("");try{const J=rie(s);if(!J.nextName)throw new Error("请填写 MCP 名称");const ne=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}),ee=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(ee.error||"保存 MCP 失败");const re=Array.isArray(ee.servers)?ee.servers:[];r(re),t(String(ee.path||e)),l(J.nextName),i(uh(re.find(Z=>Z.name===J.nextName)||null)),k(Z=>{const le={...Z};return s.originalName&&s.originalName!==J.nextName&&delete le[s.originalName],delete le[J.nextName],le}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(J){y(String(J.message||J))}finally{f(!1)}},se=async J=>{if(J!=null&&J.name&&window.confirm(`删除 MCP "${J.name}"?`)){f(!0),y(""),x("");try{const ne=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:J.name})}),ee=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(ee.error||"删除 MCP 失败");r(Array.isArray(ee.servers)?ee.servers:[]),l(""),i(cw()),k(re=>{const Z={...re};return delete Z[J.name],Z}),x("已删除。")}catch(ne){y(String(ne.message||ne))}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:q,disabled:c||d,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V(),disabled:p||c||d||n.length===0,children:p?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:D,disabled:d,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.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",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:"lan"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),o.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),o.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),o.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),o.jsxs("div",{className:"af-set-mcp-connect-grid",children:[o.jsxs("label",{className:"af-set-mcp-field",children:[o.jsx("span",{children:"Base URL"}),o.jsx("input",{className:"af-set-input af-set-input--mono",value:C,onChange:J=>N(J.target.value),placeholder:"http://127.0.0.1:8875"})]}),o.jsxs("label",{className:"af-set-mcp-field",children:[o.jsx("span",{children:"Token"}),o.jsxs("div",{className:"af-set-mcp-token-row",children:[o.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:j,onChange:J=>A(J.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:I==="token"?"已填入":"使用当前登录 Token"})]})]})]}),o.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-set-mcp-snippet-head",children:[o.jsx("span",{children:"Cursor mcp.json"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:W,children:I==="cursor"?"已复制":I==="copy-failed"?"复制失败":"复制"})]}),o.jsx("pre",{className:"af-set-mcp-code",children:z})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"af-set-mcp-snippet-head",children:[o.jsx("span",{children:"Codex config.toml"}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:E,children:I==="codex"?"已复制":I==="copy-failed"?"复制失败":"复制"})]}),o.jsx("pre",{className:"af-set-mcp-code",children:$})]})]}),o.jsx("div",{className:"af-set-mcp-copy-row",children:o.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:T,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),I==="prompt"?"已复制 Prompt":I==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),I==="copy-failed"?o.jsx("p",{className:"af-mcp-error",children:"浏览器禁止访问剪贴板,请手动选中下面的 Prompt 复制。"}):null,o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),o.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:M})]}),o.jsxs("section",{className:"af-settings-hero af-settings-hero--compact",children:[o.jsx("h2",{className:"af-settings-h2",children:"外部 MCP Servers"}),o.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 AgentFlow 可调用的外部 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:D,disabled:d,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:D,disabled:d,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(J=>{var ne,ee,re,Z;return o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===J.name?" af-mcp-server-item--active":""),onClick:()=>L(J),children:[o.jsx("span",{className:"material-symbols-outlined",children:J.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:J.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${d_(g[J.name])}`,children:u_(g[J.name])})]}),o.jsxs("span",{className:"af-mcp-server-backends",children:[o.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${pb((ee=(ne=J.backends)==null?void 0:ne.cursor)==null?void 0:ee.status)}`,children:"Cursor"}),o.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${pb((Z=(re=J.backends)==null?void 0:re.codex)==null?void 0:Z.status)}`,children:"Codex"})]}),o.jsx("em",{children:J.url||[J.command,...J.args||[]].filter(Boolean).join(" ")})]})]},J.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:H?"编辑 MCP":"新增 MCP"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),H?o.jsxs("div",{className:"af-mcp-editor-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V(H.name),disabled:p||d,children:p?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>se(H),disabled:d,children:"删除"})]}):null]}),b?o.jsx("p",{className:"af-mcp-error",children:b}):null,v?o.jsx("p",{className:"af-mcp-status",children:v}):null,H?o.jsx(oie,{server:H}):null,B?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${d_(B)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:u_(B)}),o.jsxs("span",{children:[B.elapsedMs||0,"ms"]})]}),B.error?o.jsx("p",{children:B.error}):null,(ce=B.tools)!=null&&ce.length?o.jsx("div",{className:"af-mcp-tools-list",children:B.tools.map(J=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:J.name}),J.description?o.jsx("span",{children:J.description}):null]},J.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:J=>i(ne=>({...ne,name:J.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:J=>i(ne=>({...ne,type:J.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:J=>i(ne=>({...ne,url:J.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:J=>i(ne=>({...ne,command:J.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:J=>i(ne=>({...ne,argsText:J.target.value})),placeholder:`mcp-server-example
318
- --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:J=>i(ne=>({...ne,description:J.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(f_,{title:"Headers",rows:s.headerRows,onChange:J=>i(ne=>({...ne,headerRows:J})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(f_,{title:"Env",rows:s.envRows,onChange:J=>i(ne=>({...ne,envRows:J})),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:J=>i(ne=>({...ne,extraJson:J.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:D,disabled:d,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:F,disabled:d,children:d?"保存中...":"保存 MCP"})]})]})]})]})})]})}function lie(e={}){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=new URLSearchParams({flowId:t,flowSource:String((e==null?void 0:e.flowSource)||"user").trim()||"user"}),r=String((e==null?void 0:e.workspaceId)||"").trim();if(r&&n.set("workspaceId",r),(e==null?void 0:e.kind)==="workspace"){const s=String((e==null?void 0:e.scheduleNodeId)||"").trim();s&&n.set("focusNodeId",s)}return`/workspace?${n.toString()}`}function p_(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function h_(e){if(!e)return"-";const t=typeof e=="number"?e:Date.parse(String(e));return Number.isFinite(t)?new Date(t).toLocaleString():String(e)}function cie(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function uie(e){if(e!=null&&e.running)return"运行中";if(!(e!=null&&e.enabled))return"已停用";const t=String((e==null?void 0:e.lastStatus)||"").trim();return!t||t==="armed"||t==="enabled"?"已启用":t==="success"?"上次成功":t==="failed"?"上次失败":t==="invalid"?"配置异常":t.startsWith("skipped")?"已跳过":t}function die(){const{navigate:e}=si(),[t,n]=m.useState([]),[r,s]=m.useState(!1),[i,a]=m.useState(""),[l,c]=m.useState(""),u=m.useCallback(async()=>{s(!0),a("");try{const p=await fetch("/api/schedules"),h=await p.json().catch(()=>({}));if(!p.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(p){a(String(p.message||p)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`;c(h),a("");try{const g=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:p.kind,flowId:p.flowId,flowSource:p.flowSource||"user",scheduleNodeId:p.scheduleNodeId||"",enabled:!p.enabled})}),k=await g.json().catch(()=>({}));if(!g.ok||k.success===!1)throw new Error(k.error||"更新定时任务失败");await u()}catch(g){a(String(g.message||g))}finally{c("")}},[u]),f=m.useMemo(()=>{const p=t.filter(g=>g.enabled).length,h=t.filter(g=>g.kind==="workspace").length;return{total:t.length,enabled:p,workspace:h,pipeline:t.length-h}},[t]);return o.jsxs("div",{className:"af-settings-page af-schedules-page",children:[o.jsxs("div",{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:"定时任务"})]}),o.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),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:"定时任务"}),o.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),o.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[o.jsxs("div",{children:[o.jsx("span",{children:"全部"}),o.jsx("strong",{children:f.total})]}),o.jsxs("div",{children:[o.jsx("span",{children:"启用中"}),o.jsx("strong",{children:f.enabled})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Workspace"}),o.jsx("strong",{children:f.workspace})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Pipeline"}),o.jsx("strong",{children:f.pipeline})]})]}),i?o.jsx("div",{className:"af-schedules-error",children:i}):null,r?o.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?o.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,o.jsx("div",{className:"af-schedules-list",children:t.map(p=>{const h=`${p.kind}:${p.flowSource||"user"}:${p.flowId||""}:${p.scheduleNodeId||""}`,g=l===h,k=lie(p);return o.jsxs("article",{className:"af-schedule-card",children:[o.jsxs("div",{className:"af-schedule-card__main",children:[o.jsxs("div",{className:"af-schedule-card__title-row",children:[o.jsx("strong",{children:p.label||p.flowId||"-"}),o.jsx("span",{className:`af-schedule-badge af-schedule-badge--${p.kind||"pipeline"}`,children:cie(p)}),o.jsx("span",{className:`af-schedule-state ${p.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:uie(p)})]}),o.jsxs("div",{className:"af-schedule-card__meta",children:[o.jsx("span",{children:p.flowId||"-"}),o.jsx("span",{children:p.flowSource||"user"}),p.scheduleNodeId?o.jsx("span",{children:p.scheduleNodeId}):null]}),o.jsxs("div",{className:"af-schedule-card__grid",children:[o.jsxs("div",{children:[o.jsx("span",{children:"Cron"}),o.jsx("strong",{children:p.cron||"-"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"时区"}),o.jsx("strong",{children:p.timezone||"Asia/Shanghai"})]}),o.jsxs("div",{children:[o.jsx("span",{children:"下次执行"}),o.jsx("strong",{children:h_(p.nextRunAt)})]}),o.jsxs("div",{children:[o.jsx("span",{children:"最近执行"}),o.jsx("strong",{children:h_(p.lastTriggeredAt)})]})]}),p.lastError?o.jsx("p",{className:"af-schedule-card__error",children:p.lastError}):null]}),o.jsxs("div",{className:"af-schedule-card__actions",children:[k?o.jsxs("button",{type:"button",className:"af-schedule-open",title:p_(p),onClick:()=>e(k),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),p_(p)]}):null,o.jsxs("button",{type:"button",className:p.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:g,"aria-pressed":p.enabled,title:p.enabled?"点击停用":"点击启用",onClick:()=>void d(p),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:g?"hourglass_empty":p.enabled?"toggle_on":"toggle_off"}),p.enabled?"已启用":"已停用"]})]})]},h)})})]})})]})}const m_={id:"",title:"Untitled Node",definitionId:"",agentMessages:[],promptDraft:"",manifest:{id:"",version:"1.0.0",name:"",runtime:{type:"agent_subAgent"},inputs:[],outputs:[],configSchema:{fields:[]},ui:{card:{icon:"extension",variant:"default",actions:[]}}},config:{},files:{},test:{inputs:{},log:[],status:"not run"}};function g_(e){const t=(e==null?void 0:e.manifest)||{};return(e==null?void 0:e.definitionId)||`marketplace:${t.id||(e==null?void 0:e.id)||"node"}@${t.version||"1.0.0"}`}function fie(e){var c,u,d,f,p,h,g,k,b,y,v,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],i=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((d=(u=t.ui)==null?void 0:u.card)==null?void 0:d.actions)?t.ui.card.actions:[],l=(f=e==null?void 0:e.test)!=null&&f.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(C=>[`input.${C.name||"-"}`,`${C.type||"text"}${C.required?" · required":""}${C.default?` · default: ${C.default}`:""}`]),...s.map(C=>[`output.${C.name||"-"}`,C.type||"text"]),...i.map(C=>[`config.${C.key||"-"}`,C.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((p=t.runtime)==null?void 0:p.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((k=(g=t.ui)==null?void 0:g.card)==null?void 0:k.variant)||"default"],["card.icon",((y=(b=t.ui)==null?void 0:b.card)==null?void 0:y.icon)||"extension"],...a.map(C=>[`action.${C.id||C.label||"-"}`,C.variant||C.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([C,N])=>[`sample.${C}`,String(N)]),["last run",`${((v=e==null?void 0:e.test)==null?void 0:v.status)||"not run"}${(x=e==null?void 0:e.test)!=null&&x.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function pie(){var $,M,q,D,L,T,W;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,i]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState(""),g=e||m_,k=m.useMemo(()=>fie(g),[g]),b=m.useMemo(()=>k.find(E=>E.id===n)||k[1],[n,k]),y=(g==null?void 0:g.manifest)||{},v=(g==null?void 0:g.config)||{},x=(($=g==null?void 0:g.test)==null?void 0:$.inputs)||{},C=Array.isArray((M=g==null?void 0:g.test)==null?void 0:M.log)?g.test.log:[],N=((D=(q=y.ui)==null?void 0:q.card)==null?void 0:D.icon)||"event_repeat",j=((T=(L=y.ui)==null?void 0:L.card)==null?void 0:T.variant)||"default",A=v.enabled===!0,I=m.useCallback(async()=>{var E;l(!0),u("");try{const Q=await fetch("/api/node-studio/drafts"),V=await Q.json().catch(()=>({}));if(!Q.ok)throw new Error(V.error||"读取节点草稿失败");const F=Array.isArray(V.drafts)?V.drafts[0]:null;if(!(F!=null&&F.id)){t(null),h("");return}const se=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(F.id)}`),ce=await se.json().catch(()=>({}));if(!se.ok)throw new Error(ce.error||"读取节点草稿失败");t(ce.draft||null),h(String(((E=ce.draft)==null?void 0:E.promptDraft)||""))}catch(Q){u(String(Q.message||Q))}finally{l(!1)}},[]);m.useEffect(()=>{I()},[I]);const O=m.useCallback(async(E={})=>{var Q;f(!0),u("");try{const V=await fetch("/api/node-studio/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:(e==null?void 0:e.id)||"untitled_node",...E})}),F=await V.json().catch(()=>({}));if(!V.ok||F.ok===!1)throw new Error(F.error||"保存节点草稿失败");t(F.draft||e),h(String(((Q=F.draft||e)==null?void 0:Q.promptDraft)||""))}catch(V){u(String(V.message||V))}finally{f(!1)}},[e]),H=()=>{i(!0),window.setTimeout(()=>i(!1),900)},B=E=>{const Q={...v,enabled:E};t(V=>({...V||m_,config:Q})),O({config:{enabled:E}})},z=()=>{O({promptDraft:p,appendUserMessage:!0})};return o.jsxs("div",{className:"af-node-studio-page",children:[o.jsxs("header",{className:"af-node-studio-top",children:[o.jsxs("div",{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:"Node Studio"})]}),o.jsx("h1",{children:"节点编辑器"})]}),o.jsxs("div",{className:"af-node-studio-actions",children:[o.jsxs("button",{type:"button",onClick:()=>void I(),disabled:a,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),o.jsxs("button",{type:"button",onClick:H,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"science"}),"Test"]}),o.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),o.jsxs("main",{className:"af-node-studio-shell",children:[o.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[o.jsxs("div",{className:"af-node-studio-panel-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),o.jsx("strong",{children:"AI Agent"})]}),c?o.jsx("div",{className:"af-node-studio-error",children:c}):null,o.jsxs("div",{className:"af-node-studio-thread",children:[e?null:o.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(g==null?void 0:g.agentMessages)?g.agentMessages:[]).map((E,Q)=>o.jsx("div",{className:E.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:E.text||""},`${E.role||"message"}-${Q}`)),o.jsxs("div",{className:"af-node-studio-agent-tools",children:[o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),o.jsxs("label",{className:"af-node-studio-prompt",children:[o.jsx("span",{children:"需求"}),o.jsx("textarea",{value:p,onChange:E=>h(E.target.value)})]}),o.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:z,disabled:d,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:d?"sync":"send"}),d?"Saving":"Send"]})]}),o.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[o.jsxs("div",{className:"af-node-studio-panel-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),o.jsx("strong",{children:"Preview / Test"})]}),o.jsxs("div",{className:"af-node-studio-preview-grid",children:[o.jsx("div",{className:"af-node-studio-preview-stage",children:e?j==="schedule"?o.jsxs("div",{className:"af-node-preview-card",children:[o.jsxs("div",{className:"af-node-preview-card__head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:N}),o.jsx("strong",{children:g.title||y.name||"Untitled Node"}),o.jsx("code",{children:g_(g)})]}),o.jsxs("label",{className:"af-node-preview-toggle",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:E=>B(E.target.checked)}),o.jsx("span",{children:A?"定时开启":"定时关闭"})]}),o.jsxs("div",{className:"af-node-preview-fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"频率"}),o.jsxs("select",{value:v.scheduleType||"daily",onChange:E=>O({config:{scheduleType:E.target.value}}),children:[o.jsx("option",{value:"daily",children:"每天"}),o.jsx("option",{value:"weekly",children:"每周"})]})]}),o.jsxs("label",{children:[o.jsx("span",{children:"时间"}),o.jsxs("div",{children:[o.jsxs("select",{value:v.hour||"09",onChange:E=>O({config:{hour:E.target.value}}),children:[o.jsx("option",{children:"09"}),o.jsx("option",{children:"10"})]}),o.jsxs("select",{value:v.minute||"00",onChange:E=>O({config:{minute:E.target.value}}),children:[o.jsx("option",{children:"00"}),o.jsx("option",{children:"30"})]})]})]})]}),o.jsxs("div",{className:"af-node-preview-meta",children:[o.jsxs("span",{children:[v.scheduleType==="weekly"?"每周":"每天"," ",v.hour||"09",":",v.minute||"00"]}),o.jsx("span",{children:"Next -"}),o.jsx("span",{children:A?"enabled":"disabled"})]}),o.jsxs("div",{className:"af-node-preview-actions",children:[o.jsxs("button",{type:"button",className:"af-node-preview-run",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),o.jsxs("button",{type:"button",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):o.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[o.jsxs("div",{className:"af-node-preview-card__head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:N}),o.jsx("strong",{children:g.title||y.name||"Untitled Node"}),o.jsx("code",{children:g_(g)})]}),o.jsxs("div",{className:"af-node-preview-default-body",children:[o.jsx("p",{children:y.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),o.jsxs("div",{children:[o.jsxs("span",{children:[Array.isArray(y.inputs)?y.inputs.length:0," inputs"]}),o.jsxs("span",{children:[Array.isArray(y.outputs)?y.outputs.length:0," outputs"]}),o.jsx("span",{children:((W=y.runtime)==null?void 0:W.type)||y.baseDefinitionId||"agent_subAgent"})]})]})]}):o.jsxs("div",{className:"af-node-preview-empty",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),o.jsx("strong",{children:"暂无预览"}),o.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),o.jsxs("div",{className:"af-node-studio-test",children:[o.jsxs("div",{className:"af-node-studio-subhead",children:[o.jsx("strong",{children:"Test Inputs"}),o.jsxs("button",{type:"button",onClick:H,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"play_arrow"}),"Run"]})]}),o.jsxs("div",{className:"af-node-studio-inputs",children:[o.jsxs("label",{children:[o.jsx("span",{children:"project"}),o.jsx("input",{value:x.project||"",readOnly:!0,placeholder:"-"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"date"}),o.jsx("input",{value:x.date||"",readOnly:!0,placeholder:"-"})]})]}),o.jsx("div",{className:"af-node-studio-log",children:(s?["running..."]:C.length?C:["No test run yet."]).map((E,Q)=>o.jsx("span",{children:E},`${E}-${Q}`))})]})]})]}),o.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[o.jsxs("div",{className:"af-node-studio-panel-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),o.jsx("strong",{children:"Internals"})]}),o.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:k.map(E=>o.jsxs("button",{type:"button",className:E.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(E.id),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:E.icon}),E.label]},E.id))}),o.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([E,Q])=>o.jsxs("div",{className:"af-node-studio-internal-row",children:[o.jsx("span",{children:E}),o.jsx("strong",{children:Q})]},E))}),o.jsx("pre",{className:"af-node-studio-code",children:b.id==="ui"?JSON.stringify(y.ui||{},null,2):b.id==="contract"?JSON.stringify({inputs:y.inputs||[],outputs:y.outputs||[],configSchema:y.configSchema||{}},null,2):b.id==="tests"?JSON.stringify((g==null?void 0:g.test)||{},null,2):JSON.stringify({runtime:y.runtime||{},files:(g==null?void 0:g.files)||{}},null,2)})]})]})]})}function hie(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function mie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function dh(e){const t=String(e||"").trim();if(!t)return"";let n=t;try{n=new URL(t).pathname}catch{n=t.split("?")[0].split("#")[0]}return(n.replace(/\/+$/,"").split("/").filter(Boolean).pop()||"").replace(/\.git$/i,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/^_+|_+$/g,"")}function gie(e={},t={}){return`${String(e.mountPath||t.mountPath||e.label||t.label||e.id||t.id||"workspace").trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"WORKSPACE"}_GIT_TOKEN`}function dw(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function $p(e={}){return{id:String((e==null?void 0:e.id)||""),label:String((e==null?void 0:e.label)||(e==null?void 0:e.name)||""),kind:(e==null?void 0:e.kind)==="local"?"local":"git",path:String((e==null?void 0:e.path)||""),repoUrl:String((e==null?void 0:e.repoUrl)||""),branch:String((e==null?void 0:e.branch)||"master"),mountPath:String((e==null?void 0:e.mountPath)||""),credentialRef:String((e==null?void 0:e.credentialRef)||""),type:String((e==null?void 0:e.type)||((e==null?void 0:e.kind)==="local"?"local":"code")),description:String((e==null?void 0:e.description)||""),enabled:(e==null?void 0:e.enabled)!==!1}}function yie(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||dh(n)||"").trim():"";return{id:String(e.id||"").trim(),label:String(e.label||"").trim(),kind:t,path:String(e.path||"").trim(),repoUrl:n,branch:t==="git"?String(e.branch||"master").trim()||"master":"",mountPath:r,credentialRef:t==="git"?String(e.credentialRef||"").trim():"",type:String(e.type||(t==="local"?"local":"code")).trim(),description:String(e.description||"").trim(),enabled:e.enabled!==!1}}function Wi(e,t=0){return(e==null?void 0:e.id)||(e==null?void 0:e.path)||(e==null?void 0:e.repoUrl)||`workspace-${t}`}function wie({ok:e}){return o.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function y_({item:e,selected:t,onClick:n,readOnly:r}){return o.jsxs("button",{type:"button",className:"af-workspaces-card"+(t?" af-workspaces-card--selected":""),onClick:n,children:[o.jsxs("div",{className:"af-workspaces-card__head",children:[o.jsx("strong",{children:e.label||"知识库"}),o.jsx("span",{children:e.kind==="git"?"Git":"Local"})]}),o.jsx("p",{children:e.description||e.repoUrl||e.path||"-"}),o.jsxs("div",{className:"af-workspaces-card__meta",children:[o.jsx(wie,{ok:e.exists!==!1}),o.jsx("span",{children:e.exists===!1?"路径未就绪":"路径可用"}),r?o.jsx("em",{children:"内置"}):e.enabled===!1?o.jsx("em",{children:"disabled"}):null]})]})}function xie(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[s,i]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[d,f]=m.useState(""),[p,h]=m.useState([]),[g,k]=m.useState([]),[b,y]=m.useState(dw),[v,x]=m.useState(""),[C,N]=m.useState([]),[j,A]=m.useState(""),I=m.useMemo(()=>g.findIndex((V,F)=>Wi(V,F)===j),[g,j]),H=!!m.useMemo(()=>p.find((V,F)=>Wi(V,F)===j)||null,[p,j]),B=m.useMemo(()=>{const V=String(b.credentialRef||"").trim();return V?C.some(F=>String((F==null?void 0:F.key)||"").trim()===V&&String((F==null?void 0:F.value)??"")!==""):!1},[b.credentialRef,C]),z=m.useCallback(async()=>{t(!0),l("");try{const[V,F]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),se=await V.json().catch(()=>({})),ce=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof ce.error=="string"?ce.error:"ENV HTTP "+F.status);if(!V.ok)throw new Error(typeof se.error=="string"?se.error:"HTTP "+V.status);const J=Array.isArray(se.workspaces)?se.workspaces:[],ne=Array.isArray(se.customWorkspaces)?se.customWorkspaces:[];f(String(se.path||"")),h(J.filter(ee=>ee==null?void 0:ee.builtin)),k(ne),N(Array.isArray(ce.env)?ce.env.map(ee=>({key:String((ee==null?void 0:ee.key)||""),value:String((ee==null?void 0:ee.value)??"")})):[])}catch(V){l(String(V.message||V))}finally{t(!1)}},[]);m.useEffect(()=>{z()},[z]);const $=m.useCallback(async(V,F="")=>{r(!0),l(""),u("");try{const se=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:V})}),ce=await se.json().catch(()=>({}));if(!se.ok)throw new Error(typeof ce.error=="string"?ce.error:"HTTP "+se.status);const J=Array.isArray(ce.customWorkspaces)?ce.customWorkspaces:V;k(J),h((Array.isArray(ce.workspaces)?ce.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin)),f(String(ce.path||d)),F&&A(F),u("已保存")}catch(se){l(String(se.message||se))}finally{r(!1)}},[d]),M=m.useCallback(()=>{A(""),y(dw()),x(""),u(""),l("")},[]),q=m.useCallback((V,F)=>{A(Wi(V,F)),y($p(V)),x(""),u("")},[]),D=m.useCallback((V,F)=>{A(Wi(V,F)),y($p(V)),x(""),u("")},[]),L=m.useCallback(async(V,F)=>{const se=String(V||"").trim(),ce=String(F??"");if(!se||!ce)return;const J=C.filter(re=>String((re==null?void 0:re.key)||"").trim()!==se);J.push({key:se,value:ce});const ne=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:J})}),ee=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(typeof ee.error=="string"?ee.error:"ENV HTTP "+ne.status);N(Array.isArray(ee.env)?ee.env.map(re=>({key:String((re==null?void 0:re.key)||""),value:String((re==null?void 0:re.value)??"")})):J)},[C]),T=m.useCallback(()=>{const V=yie({...b,id:b.id||hie()}),F=v.trim();if(V.kind==="git"&&F&&!V.credentialRef&&(V.credentialRef=gie(b,V)),V.kind==="local"&&!V.path){l("本地知识库需要填写路径");return}if(V.kind==="git"&&!V.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!V.label){l("请填写名称");return}if(V.kind==="git"&&V.credentialRef&&!mie(V.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const se=I>=0?g.map((ce,J)=>J===I?V:ce):[V,...g];y($p(V)),(async()=>{r(!0);try{F&&await L(V.credentialRef,F),x(""),await $(se,Wi(V))}catch(ce){l(String(ce.message||ce)),r(!1)}})()},[g,b,$,L,I,v]),W=m.useCallback(()=>{if(I<0)return;const V=g.filter((F,se)=>se!==I);y(dw()),A(""),$(V)},[g,$,I]),E=m.useCallback(async()=>{if(!H){if(I<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}i(!0),l(""),u("");try{const V=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),F=await V.json().catch(()=>({}));if(!V.ok)throw new Error(typeof F.error=="string"?F.error:"HTTP "+V.status);const se=Array.isArray(F.customWorkspaces)?F.customWorkspaces:g;k(se),h((Array.isArray(F.workspaces)?F.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin));const ce=se.find(ne=>String((ne==null?void 0:ne.id)||"")===String(b.id||""));ce&&y($p(ce));const J=String(F.commit||"").trim();u(F.changed?`已拉取更新${J?`:${J.slice(0,8)}`:""}`:`已是最新${J?`:${J.slice(0,8)}`:""}`)}catch(V){l(String(V.message||V))}finally{i(!1)}}},[g,b,H,I]),Q=m.useCallback(V=>{y(F=>({...F,...V}))},[]);return o.jsxs("div",{className:"af-workspaces-page",children:[o.jsxs("header",{className:"af-settings-top",children:[o.jsxs("div",{className:"af-settings-crumb","aria-label":"知识库",children:[o.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:"知识库"})]}),o.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:z,disabled:e,children:[o.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),o.jsx("main",{className:"af-settings-body",children:o.jsxs("div",{className:"af-workspaces-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsx("h1",{className:"af-settings-h1",children:"知识库"}),o.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),d?o.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",d]}):null,a?o.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?o.jsx("p",{className:"af-workspaces-status",children:c}):null]}),o.jsxs("section",{className:"af-workspaces-summary",children:[o.jsxs("div",{children:[o.jsx("span",{children:"内置"}),o.jsx("strong",{children:p.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"自定义"}),o.jsx("strong",{children:g.length})]}),o.jsxs("div",{children:[o.jsx("span",{children:"Git"}),o.jsx("strong",{children:g.filter(V=>V.kind==="git").length})]})]}),o.jsxs("div",{className:"af-workspaces-layout",children:[o.jsxs("section",{className:"af-workspaces-list",children:[o.jsxs("div",{className:"af-workspaces-section-head",children:[o.jsx("h2",{children:"自定义知识库"}),o.jsxs("button",{type:"button",onClick:M,children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]}),g.length?g.map((V,F)=>o.jsx(y_,{item:V,selected:Wi(V,F)===j,onClick:()=>q(V,F)},Wi(V,F))):o.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义知识库。新增 Git 或本地目录后,画布里的加载知识库和一键任务就可以选择它。"}),o.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:o.jsx("h2",{children:"内置知识库"})}),p.map((V,F)=>o.jsx(y_,{item:V,selected:Wi(V,F)===j,onClick:()=>D(V,F),readOnly:!0},Wi(V,F)))]}),o.jsxs("section",{className:"af-workspaces-editor",children:[o.jsxs("div",{className:"af-workspaces-editor__head",children:[o.jsxs("div",{children:[o.jsx("h2",{children:H?"查看内置知识库":I>=0?"编辑知识库":"新增知识库"}),o.jsx("p",{children:H?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),o.jsxs("label",{className:"af-workspaces-switch",children:[o.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:H,onChange:V=>Q({enabled:V.target.checked})}),o.jsx("span",{children:"启用"})]})]}),o.jsxs("div",{className:"af-workspaces-kind",children:[o.jsxs("button",{type:"button",className:b.kind==="git"?"active":"",disabled:H,onClick:()=>Q({kind:"git",type:b.type==="local"?"code":b.type}),children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),o.jsxs("button",{type:"button",className:b.kind==="local"?"active":"",disabled:H,onClick:()=>Q({kind:"local",type:"local"}),children:[o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),o.jsxs("div",{className:"af-workspaces-form",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{value:b.label,disabled:H,onChange:V=>Q({label:V.target.value}),placeholder:"Likee Android"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"类型"}),o.jsxs("select",{value:b.type,disabled:H,onChange:V=>Q({type:V.target.value}),children:[o.jsx("option",{value:"code",children:"code"}),o.jsx("option",{value:"docs",children:"docs"}),o.jsx("option",{value:"analytics",children:"analytics"}),o.jsx("option",{value:"config",children:"config"}),o.jsx("option",{value:"local",children:"local"}),o.jsx("option",{value:"other",children:"other"})]})]}),o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"本地路径"}),o.jsx("input",{value:b.path,disabled:H,onChange:V=>Q({path:V.target.value}),placeholder:b.kind==="git"?"可空,默认保存到全局资源目录/repos/<仓库名>":"/Users/.../project"})]}),b.kind==="git"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"Git URL"}),o.jsx("input",{value:b.repoUrl,disabled:H,onChange:V=>{const F=V.target.value,se=dh(b.repoUrl),ce=String(b.mountPath||"").trim();Q({repoUrl:F,...!ce||ce===se?{mountPath:dh(F)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"分支"}),o.jsx("input",{value:b.branch,disabled:H,onChange:V=>Q({branch:V.target.value}),placeholder:"master"})]}),o.jsxs("label",{children:[o.jsx("span",{children:"挂载目录"}),o.jsx("input",{value:b.mountPath,disabled:H,onChange:V=>Q({mountPath:V.target.value}),placeholder:dh(b.repoUrl)||"repo_name"})]}),o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"凭证环境变量"}),o.jsx("input",{value:b.credentialRef,disabled:H,onChange:V=>Q({credentialRef:V.target.value}),placeholder:"LIKEE_GIT_READONLY_TOKEN"})]}),o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"Token"}),o.jsx("input",{type:"password",value:v,disabled:H,onChange:V=>x(V.target.value),placeholder:B?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 workspace 配置"}),o.jsx("small",{children:"保存后只在知识库配置中保留 credentialRef,token 会写入当前用户的个人环境变量。"})]})]}):null,o.jsxs("label",{className:"af-workspaces-form__wide",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:b.description,disabled:H,onChange:V=>Q({description:V.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),o.jsxs("div",{className:"af-workspaces-actions",children:[!H&&I>=0?o.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:W,disabled:n||s,children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):o.jsx("span",{}),o.jsxs("div",{children:[b.kind==="git"&&I>=0?o.jsxs("button",{type:"button",onClick:E,disabled:H||n||s,children:[o.jsx("span",{className:"material-symbols-outlined",children:s?"sync":"download"}),s?"拉取中":"拉取更新"]}):null,o.jsx("button",{type:"button",onClick:M,disabled:n||s,children:"重置"}),o.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:T,disabled:H||n||s,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const bie=[{icon:"campaign",title:"首页 Feed 想加一个广告引导",question:"先判断入口、展示位、用户影响面,再决定弹框、浮层还是页面内引导。",context:["查客户端展示位逻辑","查历史需求与配置","查 m09 / Feed PV"],result:"原型 + PRD + TAPD 更新",tone:"pink"},{icon:"manage_search",title:"接到需求但不知道现有逻辑",question:"不用先找研发问一圈,直接从 Likee 代码、知识库、历史文档里拿上下文。",context:["客户端 / 后台 / 前端知识库","接口与配置链路","相关 Git 文档"],result:"背景结论 + 影响范围",tone:"cyan"},{icon:"query_stats",title:"运营要评估活动或入口价值",question:"先查人群规模、页面访问、历史转化,避免凭经验拍优先级。",context:["CK / Hive 查数","自动生成 SQL","指标口径解释"],result:"数据表 + 图表 + 结论",tone:"green"},{icon:"draw",title:"想快速把方案画给团队看",question:"把一句需求变成客户端或 H5 原型,让评审时先讨论体验,不只讨论文字。",context:["Likee 客户端样式","前端页面结构","交互状态与文案"],result:"HTML 原型 + Display 面板",tone:"amber"},{icon:"sync_alt",title:"需求写完后需要同步多个地方",question:"PRD、TAPD、Git 仓库和评审展示保持一致,减少重复复制和漏改。",context:["需求正文","变更记录","MR / 仓库路径"],result:"TAPD 更新 + Git 提交",tone:"violet"},{icon:"monitoring",title:"上线后要看效果和复盘",question:"沿用需求阶段的口径继续查数,把结果沉淀回下一轮需求线索。",context:["上线后 CK / Hive","分页面 / 分人群指标","实验和版本信息"],result:"复盘结论 + 后续建议",tone:"blue"}],kie=[{label:"Use Case 01",title:"Likee 客户端知识库查询(如广告占位)",images:["/likee-context/usecase-ad-query.png"],trigger:"产品或运营想确认客户端已有逻辑,例如 Likee Android 里有哪些广告占位,以及相关常量和代码位置。",steps:["在「我的流程」加载 Likee Android 流程片段","在子 Agent 节点输入客户端逻辑问题","点击 Run Line,只执行当前链路","在右侧 Markdown Display 查看知识库查询结果"],outputs:["SETTING_ID / PAGE_ID 表格","客户端代码路径与口径说明","可继续用于 PRD 的背景材料"]},{label:"Use Case 02",title:"客户端原型设计",images:["/likee-context/usecase-prototype.png"],trigger:"业务已经明确要在 Likee 首页加入广告引导,需要先把弹框体验画出来给产品、设计、研发评审。",steps:["在 Workspace 打开原型生成流程","加载客户端原型 Skill","在子 Agent 中说明生成一个首页 dialog 弹框","查看 HTML Display 中的手机预览稿"],outputs:["Likee 风格手机原型","弹框文案与按钮状态","可直接用于评审的 Display 面板"]},{label:"Use Case 03",title:"前端 H5 原型设计",images:["/likee-context/usecase-h5-prototype.png"],trigger:"运营活动需要快速产出 Likee 风格 H5 页面,例如幸运转盘、积分排行榜、活动首页或结果页。",steps:["在 Workspace 打开 H5 原型生成流程","加载前端 H5 原型相关 Skill","在子 Agent 中说明活动结构、页面模块和运营规则","查看 HTML Display 中的可交互 H5 原型"],outputs:["Likee 风格 H5 页面","抽奖转盘与排行榜布局","活动规则和状态页","可用于评审的 HTML Display"]},{label:"Use Case 04",title:"CK / Hive 查数与 SQL 生成",images:["/likee-context/usecase-data-query.png"],trigger:"运营或产品需要快速验证一个数据问题,例如找出典型 UID、对比不同日期的视频上传分辨率占比,并保留可复用 SQL。",steps:["在 Workspace 打开查数流程","加载查数相关 Skill","在子 Agent 中说明数据口径、日期和筛选条件","查看 Markdown Display 中的数据结果和查询 SQL"],outputs:["查询结果表格","SQL 语句","口径说明","可继续接入 PRD 或复盘面板的数据结论"]},{label:"Use Case 05",title:"需求文档生成、数据补齐与同步",images:["/likee-context/usecase-prd.png","/likee-context/usecase-sync.png"],trigger:"需求进入评审和落库阶段,需要把 TAPD 信息、Hive 数据、原型内容组织成 PRD,并同步到 TAPD 和 Git 仓库。",steps:["先运行 TAPD / 数据查询节点,拿到迭代、页面 PV 和业务背景","把查询结果和原型 Display 内容接入 PRD 生成子 Agent","在 Markdown Display 查看完整需求文档","把 PRD content 接入 TAPD 更新节点和 Git 仓库提交节点"],outputs:["完整 PRD 文档","项目背景与 Top 页面数据","TAPD 需求更新成功","Git MR 链接"]},{label:"Use Case 06",title:"Display 模式做需求评审面板",images:["/likee-context/usecase-display.png"],trigger:"流程跑完后,需要把 PRD、原型、数据图表、展示位表格放在一个页面里给产品、运营、研发一起看。",steps:["在 Workspace 中完成查数、原型、PRD、同步节点执行","确认 Markdown / HTML / 图表 / 表格展示节点都有结果","切换顶部 DISPLAY 模式","使用生成链接把评审面板发给相关同学"],outputs:["PRD 长文档","客户端原型预览","图表与表格","统一展示链接"]}],vie=[{name:"likee-client-ui",namespace:"智能助手 / 客户端原型",icon:"phone_iphone",mode:"客户端原型设计",usage:"生成 Likee 客户端风格页面、弹框、Feed 引导、个人页、活动入口等原型,适合产品评审前快速对齐体验。",examples:["首页 dialog 弹框","Feed 内引导","客户端红色主品牌视觉","移动端交互态"],tone:"pink"},{name:"tapd-likee",namespace:"智能助手 / TAPD",icon:"sync",mode:"需求系统交互",usage:"和 TAPD 交互,支持创建、同步、更新需求,把工作区生成的 PRD 或 Markdown 内容回写到需求系统。",examples:["创建 TAPD 需求","更新需求正文","同步处理人和链接","把结果回显到 Display"],tone:"green"},{name:"plain-language-response",namespace:"智能助手 / 回答风格",icon:"record_voice_over",mode:"业务化回答",usage:"用于把回答收敛成产品、运营更容易阅读的解释,避免直接把客户端代码库细节、函数调用链和实现细节暴露太多。",examples:["需求背景解释","代码结论转业务语言","评审材料摘要","减少实现细节噪音"],tone:"cyan"},{name:"create-likee-h5-style-html",namespace:"智能助手 / 前端 H5",icon:"language",mode:"H5 原型设计",usage:"创建 Likee H5 风格原型,适合运营活动、抽奖、排行榜、报告页、反馈表单、创作者认证页、订单列表等页面。",examples:["幸运转盘活动","积分排行榜","活动规则页","结果页和空状态"],tone:"amber"},{name:"analytics",namespace:"数据 / CK & Hive",icon:"query_stats",mode:"查数和 SQL 生成",usage:"面向 CK、Hive 的指标查询和 SQL 生成,适合 PV、UV、转化、分国家、分实验组、典型 UID 等数据问题。",examples:["自动生成 SQL","输出查询结果表","解释指标口径","沉淀复盘数据"],tone:"green"}],Sie=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Lp({icon:e,title:t,label:n,tone:r="violet"}){return o.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[o.jsx("span",{className:"material-symbols-outlined",children:e}),o.jsxs("div",{children:[o.jsx("strong",{children:t}),o.jsx("small",{children:n})]})]})}function Nie(){return o.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[o.jsx("div",{className:"likee-scene-grid"}),o.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[o.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),o.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),o.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),o.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),o.jsx("div",{className:"likee-node-pos likee-node-a",children:o.jsx(Lp,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),o.jsx("div",{className:"likee-node-pos likee-node-b",children:o.jsx(Lp,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),o.jsx("div",{className:"likee-node-pos likee-node-c",children:o.jsx(Lp,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),o.jsx("div",{className:"likee-node-pos likee-node-d",children:o.jsx(Lp,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),o.jsxs("div",{className:"likee-phone-preview",children:[o.jsxs("div",{className:"likee-phone-top",children:[o.jsx("span",{children:"关注"}),o.jsx("strong",{children:"推荐"}),o.jsx("span",{children:"直播"})]}),o.jsxs("div",{className:"likee-phone-card",children:[o.jsx("div",{className:"likee-gift",children:"AD"}),o.jsx("h4",{children:"广告个性化引导弹框"}),o.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),o.jsx("button",{children:"继续"}),o.jsx("button",{className:"secondary",children:"稍后"})]})]}),o.jsxs("div",{className:"likee-display-panel",children:[o.jsxs("div",{className:"likee-panel-header",children:[o.jsx("span",{children:"DISPLAY"}),o.jsx("strong",{children:"需求资产面板"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"需求"}),o.jsx("strong",{children:"首页广告个性化引导"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"数据"}),o.jsx("strong",{children:"m09 PV Top 1"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"同步"}),o.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function fh({kicker:e,title:t,children:n}){return o.jsxs("div",{className:"likee-section-copy",children:[o.jsx("p",{className:"likee-section-kicker",children:e}),o.jsx("h2",{children:t}),o.jsx("p",{children:n})]})}function jie(){return o.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[o.jsx(fh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),o.jsx("div",{className:"likee-skill-grid",children:vie.map(e=>o.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[o.jsxs("div",{className:"likee-skill-head",children:[o.jsx("div",{className:"likee-skill-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.name}),o.jsx("span",{children:e.namespace})]})]}),o.jsx("div",{className:"likee-skill-mode",children:e.mode}),o.jsx("p",{children:e.usage}),o.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>o.jsx("strong",{children:t},t))})]},e.name))})]})})}function bM(){return o.jsxs("div",{className:"likee-page",children:[o.jsx("div",{className:"likee-top-actions",children:o.jsxs("a",{href:"/projects",className:"likee-home-link",children:[o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),o.jsxs("section",{className:"likee-hero",children:[o.jsx(Nie,{}),o.jsxs("div",{className:"likee-hero-content",children:[o.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),o.jsx("h1",{children:"Likee Agent 工作台"}),o.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),o.jsxs("div",{className:"likee-signal-row",children:[o.jsx("span",{children:"查业务逻辑"}),o.jsx("span",{children:"查 CK / Hive"}),o.jsx("span",{children:"生成原型"}),o.jsx("span",{children:"生成 PRD"}),o.jsx("span",{children:"同步 TAPD / Git"})]}),o.jsxs("div",{className:"likee-hero-actions",children:[o.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),o.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),o.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),o.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),o.jsx("section",{id:"likee-scenarios",className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner",children:[o.jsx(fh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),o.jsx("div",{className:"likee-scenario-grid",children:bie.map(e=>o.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[o.jsx("div",{className:"likee-scenario-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.question})]}),o.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>o.jsx("span",{children:t},t))}),o.jsxs("div",{className:"likee-scenario-result",children:[o.jsx("span",{children:"产出"}),o.jsx("strong",{children:e.result})]})]},e.title))})]})}),o.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[o.jsx(fh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),o.jsx("div",{className:"likee-usecase-stack",children:kie.map(e=>o.jsxs("article",{className:"likee-usecase-card",children:[o.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>o.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),o.jsxs("div",{className:"likee-usecase-body",children:[o.jsx("div",{className:"likee-usecase-label",children:e.label}),o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.trigger}),o.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>o.jsx("li",{children:t},t))}),o.jsxs("div",{className:"likee-usecase-output",children:[o.jsx("span",{children:"实际产物"}),o.jsx("div",{children:e.outputs.map(t=>o.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),o.jsx(jie,{}),o.jsx("section",{className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[o.jsx(fh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),o.jsx("div",{className:"likee-capability-table",children:Sie.map(([e,t,n])=>o.jsxs("div",{className:"likee-capability-row",children:[o.jsx("span",{children:e}),o.jsx("strong",{children:t}),o.jsx("p",{children:n})]},e))})]})})]})}function kM(e){return t=>typeof t===e}var Cie=kM("function"),_ie=e=>e===null,w_=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",x_=e=>!Eie(e)&&!_ie(e)&&(Cie(e)||typeof e=="object"),Eie=kM("undefined");function Aie(e,t,n){return Lie(n,e,t)?!0:(Oie(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Pie(e,t,n):e instanceof Map&&t instanceof Map?Tie(e,t,n):e instanceof Set&&t instanceof Set?$ie(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Iie(e,t):w_(e)&&w_(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Rie(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Mie(e,t,n))}function pf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!x_(e)||!t||!x_(t)?!1:Aie(e,t,n)}function Pie(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!pf(e[s],t[s],n))return!1;return!0}function Iie(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 Rie(e,t,n){return e.message===t.message&&e.name===t.name&&pf(e.cause,t.cause,n)}function Tie(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(!pf(r[1],t.get(r[0]),n))return!1;return!0}function Mie(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)&&!pf(e[i],t[i],n))return!1}return!0}function $ie(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 Lie(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Oie(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function pv(e,t){return pf(e,t,new WeakMap)}function fw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function Die(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Fie(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function zie(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Bie(e,t){const n=zie();m.useEffect(()=>{if(!n)return e()},t)}function vM(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function Hie(e,t){const n=m.useRef(t);return pv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Wie(e){m.useEffect(()=>{e()},[])}function Vie(e=0){const[t,n]=m.useState({height:fw()?window.innerHeight:0,width:fw()?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(!fw())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Fie(window,"resize",i),()=>{Die(window,"resize",i)}},[]),t}var Kie=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],qie=["bigint","boolean","null","number","string","symbol","undefined"];function hf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Uie(t))return t}function oi(e){return t=>hf(t)===e}function Uie(e){return Kie.includes(e)}function Bc(e){return t=>typeof t===e}function Yie(e){return qie.includes(e)}var Gie=["innerHTML","ownerDocument","style","attributes","nodeValue"],mf=e=>Array.isArray(e),Jie=e=>hf(e)==="AsyncGeneratorFunction",Xie=oi("AsyncFunction"),Qie=Bc("bigint"),Zie=e=>e===!0||e===!1,eoe=oi("Date"),toe=oi("Error"),ta=Bc("function"),noe=oi("GeneratorFunction"),roe=e=>typeof e=="number"&&Number.isInteger(e),hb=oi("Map"),SM=e=>Number.isNaN(e),hv=e=>e===null,NM=oi("Function"),soe=oi("Promise"),ioe=oi("RegExp"),mb=oi("Set"),gf=Bc("string"),ooe=Bc("symbol"),mv=Bc("undefined"),aoe=oi("WeakMap"),loe=oi("WeakSet"),gv=e=>hv(e)||mv(e),jM=e=>!mv(e),coe=e=>Bc("number")(e)&&!SM(e),uoe=e=>gf(e)&&e.trim().length>0,doe=e=>{if(!gf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},og=e=>!gv(e)&&(ta(e)||typeof e=="object"),CM=e=>{if(hf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},foe=e=>hv(e)||Yie(typeof e),poe=e=>hf(e)==="URL",_M=e=>!gv(e)&&ta(e[Symbol.iterator]),hoe=e=>_M(e)&&ta(e.next)&&ta(e.throw),moe=e=>ta(e)&&/^class\s/.test(e.toString()),goe=(e,t)=>!mf(e)||!ta(t)?!1:e.every(n=>t(n)),yoe=e=>og(e)&&!CM(e)&&e.nodeType===1&&gf(e.nodeName)&&Gie.every(t=>t in e),woe=e=>gf(e)&&e.length===0||mf(e)&&e.length===0||og(e)&&!hb(e)&&!mb(e)&&Object.keys(e).length===0||mb(e)&&e.size===0||hb(e)&&e.size===0,xoe=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,boe=(e,t)=>mf(e)?e.indexOf(t)>-1:!1,koe=(e,t,n)=>{if(!og(e)||!t)return!1;const r=e[t];return ta(n)?n(r):jM(r)};function Ct(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(mf(e))return"Array";if(NM(e))return"Function";const t=hf(e);return t||"Object"}Ct.array=mf;Ct.arrayOf=goe;Ct.asyncGeneratorFunction=Jie;Ct.asyncFunction=Xie;Ct.bigint=Qie;Ct.boolean=Zie;Ct.class=moe;Ct.date=eoe;Ct.defined=jM;Ct.domElement=yoe;Ct.empty=woe;Ct.error=toe;Ct.function=ta;Ct.generator=hoe;Ct.generatorFunction=noe;Ct.instanceOf=xoe;Ct.integer=roe;Ct.iterable=_M;Ct.map=hb;Ct.nan=SM;Ct.null=hv;Ct.nullOrUndefined=gv;Ct.nonEmptyString=uoe;Ct.number=coe;Ct.numericString=doe;Ct.object=og;Ct.oneOf=boe;Ct.plainFunction=NM;Ct.plainObject=CM;Ct.primitive=foe;Ct.promise=soe;Ct.propertyOf=koe;Ct.regexp=ioe;Ct.set=mb;Ct.string=gf;Ct.symbol=ooe;Ct.undefined=mv;Ct.url=poe;Ct.weakMap=aoe;Ct.weakSet=loe;var Er=Ct;/* v8 ignore next -- @preserve */var voe=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Soe=function(e,t){return e+Yd(t)},Yd=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(Soe,""):voe(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Yd(e.props.children):""};Yd.default=Yd;var Noe=Yd;const pw=ra(Noe);var EM={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(N){return N!=="constructor"&&N!=="prototype"&&N!=="__proto__"}function a(N){let j=0;const A=N.length,I=new Array(A);for(j;j<A;++j)I[j]=y(N[j]);return I}function l(N){const j={};if(p&&Object.getPrototypeOf(N)!==t)return p(N);const A=f(N);let I,O,H;for(I=0,O=A.length;I<O;++I)i(H=A[I])&&(j[H]=y(N[H]));return j}function c(N,j){const A=N.length,I=j.length;let O=0;const H=new Array(A+I);for(O;O<A;++O)H[O]=y(N[O]);for(O=0;O<I;++O)H[O+A]=y(j[O]);return H}const u=Object.prototype.propertyIsEnumerable;function d(N){const j=Object.keys(N),A=Object.getOwnPropertySymbols(N);for(let I=0,O=A.length;I<O;++I)u.call(N,A[I])&&j.push(A[I]);return j}const f=s!=null&&s.symbols?d:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),g=(s==null?void 0:s.onlyDefinedProperties)===!0;function k(N){return typeof N!="object"||N===null}const b=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function y(N){return h(N)?Array.isArray(N)?a(N):l(N):N}function v(N,j){const A={},I=f(N),O=f(j);let H,B,z;for(H=0,B=I.length;H<B;++H)i(z=I[H])&&O.indexOf(z)===-1&&(A[z]=y(N[z]));for(H=0,B=O.length;H<B;++H)if(i(z=O[H]))if(z in N)I.indexOf(z)!==-1&&(p&&h(j[z])&&Object.getPrototypeOf(j[z])!==t?A[z]=p(j[z]):A[z]=x(N[z],j[z]));else{if(g&&typeof j[z]>"u")continue;A[z]=y(j[z])}return A}function x(N,j){if(g&&typeof j>"u")return y(N);const A=Array.isArray(j),I=Array.isArray(N);return k(j)?j:h(N)?A&&I?b(N,j):A!==I?y(j):v(N,j):y(j)}function C(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return x(arguments[0],arguments[1])}let N;for(let j=0,A=arguments.length;j<A;++j)N=x(N,arguments[j]);return N}return s!=null&&s.all?C:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(EM);var joe=EM.exports;const Coe=ra(joe);var _oe=new Error("Element already at target scroll position"),Eoe=new Error("Scroll cancelled"),Aoe=Math.min,b_=Date.now,Poe={left:k_("scrollLeft"),top:k_("scrollTop")};function k_(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=Roe);var a=b_(),l=n[e],c=s.ease||Ioe,u=isNaN(s.duration)?350:+s.duration,d=!1;return l===r?i(_oe,n[e]):requestAnimationFrame(p),f;function f(){d=!0}function p(h){if(d)return i(Eoe,n[e]);var g=b_(),k=Aoe(1,(g-a)/u),b=c(k);n[e]=b*(r-l)+l,k<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function Ioe(e){return .5*(1-Math.cos(Math.PI*e))}function Roe(){}const Toe=ra(Poe);var AM={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(ud,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})})(AM);var Moe=AM.exports;const PM=ra(Moe),$oe=["top","right","bottom","left"],v_=["start","end"],S_=$oe.reduce((e,t)=>e.concat(t,t+"-"+v_[0],t+"-"+v_[1]),[]),Ic=Math.min,za=Math.max,gm=Math.round,Op=Math.floor,Ei=e=>({x:e,y:e}),Loe={left:"right",right:"left",bottom:"top",top:"bottom"};function gb(e,t,n){return za(e,Ic(t,n))}function Hc(e,t){return typeof e=="function"?e(t):e}function lo(e){return e.split("-")[0]}function Ai(e){return e.split("-")[1]}function IM(e){return e==="x"?"y":"x"}function yv(e){return e==="y"?"height":"width"}function Do(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function wv(e){return IM(Do(e))}function RM(e,t,n){n===void 0&&(n=!1);const r=Ai(e),s=wv(e),i=yv(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=wm(a)),[a,wm(a)]}function Ooe(e){const t=wm(e);return[ym(e),t,ym(t)]}function ym(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const N_=["left","right"],j_=["right","left"],Doe=["top","bottom"],Foe=["bottom","top"];function zoe(e,t,n){switch(e){case"top":case"bottom":return n?t?j_:N_:t?N_:j_;case"left":case"right":return t?Doe:Foe;default:return[]}}function Boe(e,t,n,r){const s=Ai(e);let i=zoe(lo(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(ym)))),i}function wm(e){const t=lo(e);return Loe[t]+e.slice(t.length)}function Hoe(e){return{top:0,right:0,bottom:0,left:0,...e}}function TM(e){return typeof e!="number"?Hoe(e):{top:e,right:e,bottom:e,left:e}}function xm(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 C_(e,t,n){let{reference:r,floating:s}=e;const i=Do(t),a=wv(t),l=yv(a),c=lo(t),u=i==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Ai(t)){case"start":h[a]-=p*(n&&u?-1:1);break;case"end":h[a]+=p*(n&&u?-1:1);break}return h}async function Woe(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=Hc(t,e),g=TM(h),b=l[p?f==="floating"?"reference":"floating":f],y=xm(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),v=f==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),C=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},N=xm(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(y.top-N.top+g.top)/C.y,bottom:(N.bottom-y.bottom+g.bottom)/C.y,left:(y.left-N.left+g.left)/C.x,right:(N.right-y.right+g.right)/C.x}}const Voe=50,Koe=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Woe},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:f}=C_(u,r,c),p=r,h=0;const g={};for(let k=0;k<i.length;k++){const b=i[k];if(!b)continue;const{name:y,fn:v}=b,{x,y:C,data:N,reset:j}=await v({x:d,y:f,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:u,platform:l,elements:{reference:e,floating:t}});d=x??d,f=C??f,g[y]={...g[y],...N},j&&h<Voe&&(h++,typeof j=="object"&&(j.placement&&(p=j.placement),j.rects&&(u=j.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):j.rects),{x:d,y:f}=C_(u,p,c)),k=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:g}},qoe=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:u,padding:d=0}=Hc(e,t)||{};if(u==null)return{};const f=TM(d),p={x:n,y:r},h=wv(s),g=yv(h),k=await a.getDimensions(u),b=h==="y",y=b?"top":"left",v=b?"bottom":"right",x=b?"clientHeight":"clientWidth",C=i.reference[g]+i.reference[h]-p[h]-i.floating[g],N=p[h]-i.reference[h],j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let A=j?j[x]:0;(!A||!await(a.isElement==null?void 0:a.isElement(j)))&&(A=l.floating[x]||i.floating[g]);const I=C/2-N/2,O=A/2-k[g]/2-1,H=Ic(f[y],O),B=Ic(f[v],O),z=H,$=A-k[g]-B,M=A/2-k[g]/2+I,q=gb(z,M,$),D=!c.arrow&&Ai(s)!=null&&M!==q&&i.reference[g]/2-(M<z?H:B)-k[g]/2<0,L=D?M<z?M-z:M-$:0;return{[h]:p[h]+L,data:{[h]:q,centerOffset:M-q-L,...D&&{alignmentOffset:L}},reset:D}}});function Uoe(e,t,n){return(e?[...n.filter(s=>Ai(s)===e),...n.filter(s=>Ai(s)!==e)]:n.filter(s=>lo(s)===s)).filter(s=>e?Ai(s)===e||(t?ym(s)!==s:!1):!0)}const Yoe=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:u}=t,{crossAxis:d=!1,alignment:f,allowedPlacements:p=S_,autoAlignment:h=!0,...g}=Hc(e,t),k=f!==void 0||p===S_?Uoe(f||null,h,p):p,b=await c.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,v=k[y];if(v==null)return{};const x=RM(v,i,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==v)return{reset:{placement:k[0]}};const C=[b[lo(v)],b[x[0]],b[x[1]]],N=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:v,overflows:C}],j=k[y+1];if(j)return{data:{index:y+1,overflows:N},reset:{placement:j}};const A=N.map(H=>{const B=Ai(H.placement);return[H.placement,B&&d?H.overflows.slice(0,2).reduce((z,$)=>z+$,0):H.overflows[0],H.overflows]}).sort((H,B)=>H[1]-B[1]),O=((s=A.filter(H=>H[2].slice(0,Ai(H[0])?2:3).every(B=>B<=0))[0])==null?void 0:s[0])||A[0][0];return O!==l?{data:{index:y+1,overflows:N},reset:{placement:O}}:{}}}},Goe=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:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:k=!0,...b}=Hc(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=lo(s),v=Do(l),x=lo(l)===l,C=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=p||(x||!k?[wm(l)]:Ooe(l)),j=g!=="none";!p&&j&&N.push(...Boe(l,k,g,C));const A=[l,...N],I=await c.detectOverflow(t,b),O=[];let H=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&O.push(I[y]),f){const M=RM(s,a,C);O.push(I[M[0]],I[M[1]])}if(H=[...H,{placement:s,overflows:O}],!O.every(M=>M<=0)){var B,z;const M=(((B=i.flip)==null?void 0:B.index)||0)+1,q=A[M];if(q&&(!(f==="alignment"?v!==Do(q):!1)||H.every(T=>Do(T.placement)===v?T.overflows[0]>0:!0)))return{data:{index:M,overflows:H},reset:{placement:q}};let D=(z=H.filter(L=>L.overflows[0]<=0).sort((L,T)=>L.overflows[1]-T.overflows[1])[0])==null?void 0:z.placement;if(!D)switch(h){case"bestFit":{var $;const L=($=H.filter(T=>{if(j){const W=Do(T.placement);return W===v||W==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(W=>W>0).reduce((W,E)=>W+E,0)]).sort((T,W)=>T[1]-W[1])[0])==null?void 0:$[0];L&&(D=L);break}case"initialPlacement":D=l;break}if(s!==D)return{reset:{placement:D}}}return{}}}},Joe=new Set(["left","top"]);async function Xoe(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=lo(n),l=Ai(n),c=Do(n)==="y",u=Joe.has(a)?-1:1,d=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*d,y:p*u}:{x:p*u,y:h*d}}const Qoe=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 Xoe(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}}}}},Zoe=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:x}=y;return{x:v,y:x}}},...u}=Hc(e,t),d={x:n,y:r},f=await i.detectOverflow(t,u),p=Do(lo(s)),h=IM(p);let g=d[h],k=d[p];if(a){const y=h==="y"?"top":"left",v=h==="y"?"bottom":"right",x=g+f[y],C=g-f[v];g=gb(x,g,C)}if(l){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=k+f[y],C=k-f[v];k=gb(x,k,C)}const b=c.fn({...t,[h]:g,[p]:k});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[p]:l}}}}}};function ag(){return typeof window<"u"}function Wc(e){return MM(e)?(e.nodeName||"").toLowerCase():"#document"}function ds(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ti(e){var t;return(t=(MM(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function MM(e){return ag()?e instanceof Node||e instanceof ds(e).Node:!1}function ni(e){return ag()?e instanceof Element||e instanceof ds(e).Element:!1}function po(e){return ag()?e instanceof HTMLElement||e instanceof ds(e).HTMLElement:!1}function __(e){return!ag()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ds(e).ShadowRoot}function yf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=ri(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function eae(e){return/^(table|td|th)$/.test(Wc(e))}function lg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const tae=/transform|translate|scale|rotate|perspective|filter/,nae=/paint|layout|strict|content/,ba=e=>!!e&&e!=="none";let hw;function xv(e){const t=ni(e)?ri(e):e;return ba(t.transform)||ba(t.translate)||ba(t.scale)||ba(t.rotate)||ba(t.perspective)||!bv()&&(ba(t.backdropFilter)||ba(t.filter))||tae.test(t.willChange||"")||nae.test(t.contain||"")}function rae(e){let t=na(e);for(;po(t)&&!Rc(t);){if(xv(t))return t;if(lg(t))return null;t=na(t)}return null}function bv(){return hw==null&&(hw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hw}function Rc(e){return/^(html|body|#document)$/.test(Wc(e))}function ri(e){return ds(e).getComputedStyle(e)}function cg(e){return ni(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function na(e){if(Wc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||__(e)&&e.host||Ti(e);return __(t)?t.host:t}function $M(e){const t=na(e);return Rc(t)?e.ownerDocument?e.ownerDocument.body:e.body:po(t)&&yf(t)?t:$M(t)}function Gd(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=$M(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=ds(s);if(i){const l=yb(a);return t.concat(a,a.visualViewport||[],yf(s)?s:[],l&&n?Gd(l):[])}else return t.concat(s,Gd(s,[],n))}function yb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function LM(e){const t=ri(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=po(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=gm(n)!==i||gm(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function kv(e){return ni(e)?e:e.contextElement}function mc(e){const t=kv(e);if(!po(t))return Ei(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=LM(t);let a=(i?gm(n.width):n.width)/r,l=(i?gm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const sae=Ei(0);function OM(e){const t=ds(e);return!bv()||!t.visualViewport?sae:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function iae(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ds(e)?!1:t}function nl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=kv(e);let a=Ei(1);t&&(r?ni(r)&&(a=mc(r)):a=mc(e));const l=iae(i,n,r)?OM(i):Ei(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,d=s.width/a.x,f=s.height/a.y;if(i){const p=ds(i),h=r&&ni(r)?ds(r):r;let g=p,k=yb(g);for(;k&&r&&h!==g;){const b=mc(k),y=k.getBoundingClientRect(),v=ri(k),x=y.left+(k.clientLeft+parseFloat(v.paddingLeft))*b.x,C=y.top+(k.clientTop+parseFloat(v.paddingTop))*b.y;c*=b.x,u*=b.y,d*=b.x,f*=b.y,c+=x,u+=C,g=ds(k),k=yb(g)}}return xm({width:d,height:f,x:c,y:u})}function ug(e,t){const n=cg(e).scrollLeft;return t?t.left+n:nl(Ti(e)).left+n}function DM(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ug(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function oae(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=Ti(r),l=t?lg(t.floating):!1;if(r===a||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=Ei(1);const d=Ei(0),f=po(r);if((f||!f&&!i)&&((Wc(r)!=="body"||yf(a))&&(c=cg(r)),f)){const h=nl(r);u=mc(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=a&&!f&&!i?DM(a,c):Ei(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:n.y*u.y-c.scrollTop*u.y+d.y+p.y}}function aae(e){return Array.from(e.getClientRects())}function lae(e){const t=Ti(e),n=cg(e),r=e.ownerDocument.body,s=za(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=za(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ug(e);const l=-n.scrollTop;return ri(r).direction==="rtl"&&(a+=za(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const E_=25;function cae(e,t){const n=ds(e),r=Ti(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const d=bv();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=ug(r);if(u<=0){const d=r.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-h);g<=E_&&(i-=g)}else u<=E_&&(i+=u);return{width:i,height:a,x:l,y:c}}function uae(e,t){const n=nl(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=po(e)?mc(e):Ei(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,c=s*i.x,u=r*i.y;return{width:a,height:l,x:c,y:u}}function A_(e,t,n){let r;if(t==="viewport")r=cae(e,n);else if(t==="document")r=lae(Ti(e));else if(ni(t))r=uae(t,n);else{const s=OM(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return xm(r)}function FM(e,t){const n=na(e);return n===t||!ni(n)||Rc(n)?!1:ri(n).position==="fixed"||FM(n,t)}function dae(e,t){const n=t.get(e);if(n)return n;let r=Gd(e,[],!1).filter(l=>ni(l)&&Wc(l)!=="body"),s=null;const i=ri(e).position==="fixed";let a=i?na(e):e;for(;ni(a)&&!Rc(a);){const l=ri(a),c=xv(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||yf(a)&&!c&&FM(e,a))?r=r.filter(d=>d!==a):s=l,a=na(a)}return t.set(e,r),r}function fae(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?lg(t)?[]:dae(t,this._c):[].concat(n),r],l=A_(t,a[0],s);let c=l.top,u=l.right,d=l.bottom,f=l.left;for(let p=1;p<a.length;p++){const h=A_(t,a[p],s);c=za(h.top,c),u=Ic(h.right,u),d=Ic(h.bottom,d),f=za(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function pae(e){const{width:t,height:n}=LM(e);return{width:t,height:n}}function hae(e,t,n){const r=po(t),s=Ti(t),i=n==="fixed",a=nl(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Ei(0);function u(){c.x=ug(s)}if(r||!r&&!i)if((Wc(t)!=="body"||yf(s))&&(l=cg(t)),r){const h=nl(t,!0,i,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else s&&u();i&&!r&&s&&u();const d=s&&!r&&!i?DM(s,l):Ei(0),f=a.left+l.scrollLeft-c.x-d.x,p=a.top+l.scrollTop-c.y-d.y;return{x:f,y:p,width:a.width,height:a.height}}function mw(e){return ri(e).position==="static"}function P_(e,t){if(!po(e)||ri(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ti(e)===n&&(n=n.ownerDocument.body),n}function zM(e,t){const n=ds(e);if(lg(e))return n;if(!po(e)){let s=na(e);for(;s&&!Rc(s);){if(ni(s)&&!mw(s))return s;s=na(s)}return n}let r=P_(e,t);for(;r&&eae(r)&&mw(r);)r=P_(r,t);return r&&Rc(r)&&mw(r)&&!xv(r)?n:r||rae(e)||n}const mae=async function(e){const t=this.getOffsetParent||zM,n=this.getDimensions,r=await n(e.floating);return{reference:hae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gae(e){return ri(e).direction==="rtl"}const yae={convertOffsetParentRelativeRectToViewportRelativeRect:oae,getDocumentElement:Ti,getClippingRect:fae,getOffsetParent:zM,getElementRects:mae,getClientRects:aae,getDimensions:pae,getScale:mc,isElement:ni,isRTL:gae};function BM(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function wae(e,t){let n=null,r;const s=Ti(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 u=e.getBoundingClientRect(),{left:d,top:f,width:p,height:h}=u;if(l||t(),!p||!h)return;const g=Op(f),k=Op(s.clientWidth-(d+p)),b=Op(s.clientHeight-(f+h)),y=Op(d),x={rootMargin:-g+"px "+-k+"px "+-b+"px "+-y+"px",threshold:za(0,Ic(1,c))||1};let C=!0;function N(j){const A=j[0].intersectionRatio;if(A!==c){if(!C)return a();A?a(!1,A):r=setTimeout(()=>{a(!1,1e-7)},1e3)}A===1&&!BM(u,e.getBoundingClientRect())&&a(),C=!1}try{n=new IntersectionObserver(N,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(N,x)}n.observe(e)}return a(!0),i}function I_(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,u=kv(e),d=s||i?[...u?Gd(u):[],...t?Gd(t):[]]:[];d.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const f=u&&l?wae(u,n):null;let p=-1,h=null;a&&(h=new ResizeObserver(y=>{let[v]=y;v&&v.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let g,k=c?nl(e):null;c&&b();function b(){const y=nl(e);k&&!BM(k,y)&&n(),k=y,g=requestAnimationFrame(b)}return n(),()=>{var y;d.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 xae=Qoe,bae=Yoe,kae=Zoe,vae=Goe,R_=qoe,Sae=(e,t,n)=>{const r=new Map,s={platform:yae,...n},i={...s.platform,_c:r};return Koe(e,t,{...s,platform:i})};var Nae=typeof document<"u",jae=function(){},ph=Nae?m.useLayoutEffect:jae;function bm(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(!bm(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)&&!bm(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function HM(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function T_(e,t){const n=HM(e);return Math.round(t*n)/n}function gw(e){const t=m.useRef(e);return ph(()=>{t.current=e}),t}function M_(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:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);bm(p,r)||h(r);const[g,k]=m.useState(null),[b,y]=m.useState(null),v=m.useCallback(T=>{T!==j.current&&(j.current=T,k(T))},[]),x=m.useCallback(T=>{T!==A.current&&(A.current=T,y(T))},[]),C=i||g,N=a||b,j=m.useRef(null),A=m.useRef(null),I=m.useRef(d),O=c!=null,H=gw(c),B=gw(s),z=gw(u),$=m.useCallback(()=>{if(!j.current||!A.current)return;const T={placement:t,strategy:n,middleware:p};B.current&&(T.platform=B.current),Sae(j.current,A.current,T).then(W=>{const E={...W,isPositioned:z.current!==!1};M.current&&!bm(I.current,E)&&(I.current=E,or.flushSync(()=>{f(E)}))})},[p,t,n,B,z]);ph(()=>{u===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,f(T=>({...T,isPositioned:!1})))},[u]);const M=m.useRef(!1);ph(()=>(M.current=!0,()=>{M.current=!1}),[]),ph(()=>{if(C&&(j.current=C),N&&(A.current=N),C&&N){if(H.current)return H.current(C,N,$);$()}},[C,N,$,H,O]);const q=m.useMemo(()=>({reference:j,floating:A,setReference:v,setFloating:x}),[v,x]),D=m.useMemo(()=>({reference:C,floating:N}),[C,N]),L=m.useMemo(()=>{const T={position:n,left:0,top:0};if(!D.floating)return T;const W=T_(D.floating,d.x),E=T_(D.floating,d.y);return l?{...T,transform:"translate("+W+"px, "+E+"px)",...HM(D.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:E}},[n,l,D.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:$,refs:q,elements:D,floatingStyles:L}),[d,$,q,D,L])}const Cae=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?R_({element:r.current,padding:s}).fn(n):{}:r?R_({element:r,padding:s}).fn(n):{}}}},$_=(e,t)=>{const n=xae(e);return{name:n.name,fn:n.fn,options:[e,t]}},_ae=(e,t)=>{const n=kae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Eae=(e,t)=>{const n=vae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Aae=(e,t)=>{const n=bae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Pae=(e,t)=>{const n=Cae(e);return{name:n.name,fn:n.fn,options:[e,t]}},Iae={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},Rae={beaconOptions:{offset:-18}},WM={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Tae={isFixed:!1,locale:WM,placement:"bottom"},Mae={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Lt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},ir={TOUR_START:"tour:start",STEP_BEFORE_HOOK:"step:before_hook",STEP_BEFORE:"step:before",SCROLL_START:"scroll:start",SCROLL_END:"scroll:end",BEACON:"beacon",TOOLTIP:"tooltip",STEP_AFTER:"step:after",STEP_AFTER_HOOK:"step:after_hook",TOUR_END:"tour:end",TOUR_STATUS:"tour:status",TARGET_NOT_FOUND:"error:target_not_found",ERROR:"error"},Je={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},gi={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},It={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},$ae="react-joyride-portal";function Lae(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function tc(...e){return Coe({all:!0,isMergeableObject:t=>!(!Er.plainObject(t)||m.isValidElement(t))})(...e)}function VM(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function qi(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=pw(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&&VM(e.type)==="function")try{i=qi(e.type({}),t)}catch{i=pw(n)}else i=pw(n);return i}function lr(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 Oae(e,t){const n=Lae(t);return{...e,...n}}function Jd(){}function Dae(e){return Object.keys(e)}function km(e,...t){if(!Er.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 L_(e,...t){if(!Er.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 wb(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(VM(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(Er.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):wb(i,t,n))});if(Er.function(e.type)&&!Object.values(e.props).length)try{return wb(e.type({}),t,n)}catch{return e}return e}function O_(e){return Dae(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function vv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function D_(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 Sv(e){return e?e.getBoundingClientRect():null}function Fae(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 zae(e,t,n){const r=Sv(e),s=Vc(e),i=s?!s.isSameNode(Gr()):!1,a=n??Kc(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(Gr())||(c+=Gr().scrollTop)),Math.floor(c-t)}function Vc(e,t){if(!e)return Gr();const n=PM(e);if(n){if(n.isSameNode(Gr()))return t?document:Gr();if(!(n.scrollHeight>n.offsetHeight))return Gr()}return n}function Bae(e){const t=e.getBoundingClientRect(),n=Gr(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Hae(e,t){if(!e)return 0;const n=PM(e)??Gr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Sv(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(KM(e)||Wae(e))){const d=e.getBoundingClientRect(),f=d.top-((s==null?void 0:s.top)??0),p=f+d.height,h=n.clientHeight,g=h*.2;f>=g&&p<=h-g?c=i:c=f+i}const u=Math.floor(c-t-r);return u<0?0:u}function Wae(e){return e.offsetParent!==document.body}function KM(e){if(!e)return!1;const t=Vc(e);return t?!t.isSameNode(Gr()):!1}function Kc(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?Kc(e.parentNode,t):!1}function Dp(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 F_(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==Je.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?Vc(s):Gr(),l=a?!a.isSameNode(Gr()):!1;return(r.isFixed||Kc(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Gr(){return document.scrollingElement??document.documentElement}function z_(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=Toe.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function Vae(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 qM={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Fp={...qM,borderRadius:4,padding:8};function Kae(e,t){const{styles:n}=e,r=tc(n??{},t.styles??{});let{width:s}=t;vv()&&(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 tc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...qM,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(${Vae(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:{...Fp,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Fp,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Fp,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Fp,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 qae=["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 Nv(e,t){if(!t)return null;const n=tc(Tae,L_(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=tc(Iae,e.options??{},L_(t,...qae)),s=Kae(e,{...n,...r}),i=tc(Rae,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:tc(WM,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:Uae(r.spotlightPadding),styles:s}}function Uae(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 Yae(e,t,n){const{action:r}=t,s=n&&[Lt.PREV,Lt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function UM(e,t=!1){return Er.plainObject(e)?e.target?!0:(lr(t,"tour","target is missing from the step"),!1):(lr(t,"tour","step must be an object"),!1)}function YM(e,t=!1){return Er.array(e)?e.every(n=>UM(n,t)):(lr(t,"tour","steps must be an array"),!1)}var Gae=class{constructor(e){$n(this,"beaconPosition",null);$n(this,"debug");$n(this,"eventListeners",new Map);$n(this,"listeners",new Set);$n(this,"props");$n(this,"snapshot");$n(this,"state");$n(this,"steps");$n(this,"tooltipPosition",null);$n(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});$n(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);$n(this,"getServerSnapshot",()=>this.snapshot);$n(this,"getSnapshot",()=>this.snapshot);$n(this,"getEventState",()=>km(this.snapshot,"positioned"));$n(this,"getState",()=>km(this.snapshot,"positioned"));$n(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&lr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Je.BEACON_BEFORE||this.state.lifecycle===Je.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(i=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:i.onPosition;n&&n(t)});$n(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});$n(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});$n(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)}});$n(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));$n(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,!pv(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=Er.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,Er.number(t)&&lr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Er.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&lr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Lt.INIT,controlled:s,index:i,lifecycle:Je.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?It.READY:It.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===It.WAITING&&e.size>0?{...e,status:It.RUNNING}:e}getStep(e){return Nv(this.props,this.steps[e??this.state.index])}};function Jae(e){return new Gae(e)}function B_(e,t){return Math.min(Math.max(e,0),t)}function Xae(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:(b=null)=>{const{index:y,status:v}=i();v===It.RUNNING&&e.current.updateState({action:Lt.CLOSE,index:y+1,origin:b,lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:y,size:v,status:x}=i();if(y){lr(r.current,"tour","go() is not supported in controlled mode");return}x===It.RUNNING&&e.current.updateState({action:Lt.GO,index:b,lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,status:b<v?x:It.FINISHED,waiting:!1})},info:()=>km(e.current.getSnapshot(),"positioned"),next:b=>{const{index:y,size:v,status:x}=i();x===It.RUNNING&&e.current.updateState({action:Lt.NEXT,index:B_(y+1,v),lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=i();b===It.RUNNING&&e.current.updateState({action:Lt.UPDATE,lifecycle:Je.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:y,size:v,status:x}=i();x===It.RUNNING&&e.current.updateState({action:Lt.PREV,index:B_(y-1,v),lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:y}=i();if(y){lr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Lt.RESET,index:0,lifecycle:Je.INIT,positioned:!1,scrolling:!1,status:b?It.RUNNING:It.READY,waiting:!1})},skip:b=>{const{status:y}=i();y===It.RUNNING&&e.current.updateState({action:Lt.SKIP,lifecycle:Je.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:It.SKIPPED,waiting:!1})},start:b=>{const{index:y,size:v}=i();s.current(),e.current.updateState({action:Lt.START,index:Er.number(b)?b:y,lifecycle:Je.INIT,positioned:!1,scrolling:!1,status:v?It.RUNNING:It.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:y,status:v}=i();[It.FINISHED,It.SKIPPED].includes(v)||e.current.updateState({action:Lt.STOP,index:y+(b?1:0),lifecycle:Je.COMPLETE,positioned:!1,scrolling:!1,status:It.PAUSED,waiting:!1})}}},[e])}const Qae=new Set(["origin","positioned"]);function Zae(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return lr(!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]&&!Qae.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||lr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function ele(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 u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:i,...l};(u=r.current)==null||u.call(r,c,s.current),n.current.dispatch(c,s.current)},[n])}function Po(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 tle(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:c}=e,{action:u,index:d,lifecycle:f,positioned:p,scrolling:h,size:g,status:k}=a,b=vM(l)??null,y=m.useRef(null),v=m.useRef(i),x=m.useRef(a),C=m.useRef(s),N=m.useRef(l),j=m.useRef(b),A=m.useRef(n),I=m.useRef(null),O=m.useRef(null),H=m.useRef(null);v.current=i,x.current=a,C.current=s,N.current=l,j.current=b,A.current=n;const B=()=>{I.current&&(clearInterval(I.current),I.current=null),O.current=null,H.current&&(H.current.cancel(),H.current=null)};m.useEffect(()=>{if(!C.current)return;const{hasChangedTo:z}=Po(x.current,C.current);(z("action",[Lt.NEXT,Lt.PREV,Lt.SKIP,Lt.CLOSE])||y.current===Lt.CLOSE&&u===Lt.START)&&(y.current=u)},[u]),m.useEffect(()=>{if(!C.current)return()=>{B()};const{hasChanged:z}=Po(x.current,C.current),$=N.current;if(z("index")&&B(),k!==It.RUNNING||!$||f!==Je.INIT)return()=>{B()};const{hasChangedTo:M}=Po(x.current,C.current);M("status",It.RUNNING)&&[It.IDLE,It.READY,It.PAUSED].includes(C.current.status)&&r(ir.TOUR_START,$),c.current.cleanupPositionData();const{debug:q}=v.current;if($.before&&!H.current){lr(q,`step:${d}`,"before()",$),H.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(ir.STEP_BEFORE_HOOK,$,{action:y.current??x.current.action});const D=()=>{H.current=null,c.current.updateState({action:y.current??x.current.action,waiting:!1,lifecycle:Je.READY})},L=new AbortController,T=$.beforeTimeout;H.current={cancel:()=>L.abort()};const W=T?setTimeout(()=>{L.signal.aborted||(lr(q,`step:${d}`,"before()","timed out",`${T}ms`),L.abort(),t($,"before_hook"),r(ir.ERROR,$,{error:new Error("Step before hook timed out")}),D())},T):null;$.before({...c.current.getState(),action:y.current??c.current.getState().action,step:$}).then(()=>{L.signal.aborted||(W&&clearTimeout(W),D())}).catch(E=>{L.signal.aborted||(W&&clearTimeout(W),t($,"before_hook"),r(ir.ERROR,$,{error:E instanceof Error?E:new Error(String(E))}),D())})}else if(!H.current){I.current&&O.current!==$.target&&B();const D=_s($.target);if(D&&Dp(D))B(),c.current.updateState({action:y.current??Lt.UPDATE,lifecycle:Je.READY,waiting:!1});else if($.targetWaitTimeout===0)c.current.updateState({action:y.current??Lt.UPDATE,lifecycle:Je.READY,waiting:!1});else if(!I.current){const{targetWaitTimeout:L}=$,T=Date.now();O.current=$.target,lr(q,`step:${d}`,"polling","started",`${L}ms`),c.current.updateState({waiting:!0}),I.current=setInterval(()=>{const W=_s($.target),E=Date.now()-T,Q=E>=L;(W&&Dp(W)||Q)&&(lr(q,`step:${d}`,"polling",W&&Dp(W)?"found":"timed out",`${E}ms`),B(),c.current.updateState({action:y.current??Lt.UPDATE,lifecycle:Je.READY,waiting:!1}))},100)}}return()=>{B()}},[t,r,d,f,k,c]),m.useEffect(()=>{if(!C.current)return;const{hasChanged:z,hasChangedTo:$,previous:M}=Po(x.current,C.current),q=N.current;if(!q)return;const D=_s(q.target),L=!!D;if(L&&Dp(D)){if($("lifecycle",Je.READY)&&M.lifecycle===Je.INIT&&r(ir.STEP_BEFORE,q,{action:y.current??x.current.action}),$("lifecycle",Je.READY)){const T=x.current,W=Yae(q,T,v.current.continuous)?Je.TOOLTIP:Je.BEACON,E=_s(q.scrollTarget??q.spotlightTarget??q.target),Q=F_({isFirstStep:T.index===0,scrollToFirstStep:v.current.scrollToFirstStep,step:q,target:E,targetLifecycle:W}),V=W===Je.TOOLTIP?Je.TOOLTIP_BEFORE:Je.BEACON_BEFORE;lr(v.current.debug,`step:${d}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:Lt.UPDATE,lifecycle:V,scrolling:Q})}}else if(x.current.status===It.RUNNING&&f!==Je.INIT&&f!==Je.COMPLETE&&z("lifecycle")){lr(v.current.debug,`step:${d}`,L?"Target not visible":"Target not mounted",q),t(q,"target_not_found"),r(ir.TARGET_NOT_FOUND,q);const T=x.current;T.controlled||c.current.updateState({action:Lt.UPDATE,index:T.index+(T.action===Lt.PREV?-1:1),lifecycle:Je.INIT})}},[t,r,d,f,c]),m.useEffect(()=>{if(!C.current)return;const{hasChangedTo:z,previous:$}=Po(x.current,C.current),M=N.current,q=j.current;if(M&&z("lifecycle",Je.TOOLTIP_BEFORE)&&$.lifecycle===Je.BEACON){const T=_s(M.scrollTarget??M.spotlightTarget??M.target);if(F_({isFirstStep:x.current.index===0,scrollToFirstStep:v.current.scrollToFirstStep,step:M,target:T,targetLifecycle:Je.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const D=f===Je.BEACON_BEFORE||f===Je.TOOLTIP_BEFORE;if(M&&D&&!h){const T=f===Je.TOOLTIP_BEFORE?Je.TOOLTIP:Je.BEACON;c.current.updateState({action:Lt.UPDATE,lifecycle:T})}M&&z("lifecycle",Je.BEACON)&&r(ir.BEACON,M),M&&z("lifecycle",Je.TOOLTIP)&&r(ir.TOOLTIP,M);const L=x.current;if((L.status===It.RUNNING||L.controlled&&L.status===It.PAUSED&&M)&&q&&z("lifecycle",Je.COMPLETE)&&$.lifecycle===Je.TOOLTIP&&(r(ir.STEP_AFTER,q,{action:y.current??Lt.UPDATE,index:$.index??L.index,lifecycle:L.lifecycle}),q.after)){r(ir.STEP_AFTER_HOOK,q,{action:y.current??Lt.UPDATE,index:$.index??L.index,lifecycle:L.lifecycle});try{q.after({...c.current.getState(),action:y.current??Lt.UPDATE,index:$.index??L.index,lifecycle:L.lifecycle,step:q})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!C.current)return;const{hasChangedTo:z,previous:$}=Po(x.current,C.current),M=N.current,q=j.current;g&&!M&&f===Je.INIT&&c.current.updateState({action:Lt.UPDATE,lifecycle:Je.COMPLETE,status:It.FINISHED}),!x.current.controlled&&k===It.RUNNING&&z("lifecycle",Je.COMPLETE)&&d<g&&c.current.updateState({action:Lt.UPDATE,lifecycle:Je.INIT}),z("lifecycle",Je.COMPLETE)&&d>=g&&c.current.updateState({action:Lt.UPDATE,lifecycle:Je.COMPLETE,status:It.FINISHED});const D=M??q??Nv(v.current,v.current.steps[d-1]);if(D&&z("status",[It.FINISHED,It.SKIPPED])){let L;M?L=d:q?L=$.index??d:L=d-1,r(ir.TOUR_END,D,{index:L}),x.current.controlled||A.current.reset(),y.current=null}M&&z("action",Lt.STOP)&&(y.current=null,r(ir.TOUR_STATUS,M)),M&&z("action",Lt.RESET)&&(r(ir.TOUR_STATUS,M),y.current=null)},[u,r,d,f,g,k,c])}function nle({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,d=m.useRef(void 0),f=m.useRef(r),p=m.useRef(e);f.current=r,p.current=e,m.useEffect(()=>{const h=d.current;if(d.current=n,!h||n===h)return;const{hasChanged:g}=Po(n,h);if(pv(h.steps,u)||(YM(u,i)?s.current.setSteps(u):(lr(i,"tour","Steps are not valid",u),t(ir.ERROR,u[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(Er.number(c)&&g("stepIndex")){const k=Er.number(h.stepIndex)&&h.stepIndex<c?Lt.NEXT:Lt.PREV;[It.FINISHED,It.SKIPPED].includes(f.current.status)||s.current.updateState({action:k,index:c,lifecycle:Je.INIT,positioned:!1},!0)}},[i,t,a,n,l,c,u,s])}function rle(e,t){var l,c,u,d;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===Je.BEACON_BEFORE&&(n!=null&&n.placement)){const f=sle(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-s))}else if(r===Je.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=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((d=_s(i.target))==null?void 0:d.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+h/2-p/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function sle(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 ile({emitEvent:e,previousState:t,props:n,state:r,step:s,store:i}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:d}=r,f=m.useRef(null),p=m.useRef(r),h=m.useRef(t),g=m.useRef(n),k=m.useRef(s);p.current=r,h.current=t,g.current=n,k.current=s,m.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),m.useEffect(()=>{var N;if(!h.current||!k.current)return;const{hasChangedTo:b}=Po(p.current,h.current),y=k.current,{debug:v}=g.current,{scrollDuration:x}=y,C=l===Je.BEACON_BEFORE||l===Je.TOOLTIP_BEFORE;if(d===It.RUNNING&&C&&u&&b("positioned",!0)){const j=_s(y.scrollTarget??y.spotlightTarget??y.target),A=i.current.getPositionData("beacon"),I=Vc(j),O=I?!I.isSameNode(Gr()):!1;(N=f.current)==null||N.call(f),(async()=>{if(O&&!Kc(I)){const L=Gr(),T=Bae(I),W={initial:L.scrollTop,target:T,element:L,duration:x};e(ir.SCROLL_START,y,{scroll:W});const{cancel:E,promise:Q}=z_(T,{element:L,duration:x});f.current=E,await Q,e(ir.SCROLL_END,y,{scroll:W})}const B=Math.floor(Hae(j,y.scrollOffset))||0,z=O?B:rle(B,{beaconPosition:A,lifecycle:l,scrollOffset:y.scrollOffset,step:y});lr(v,`step:${a}`,"scroll",O?"custom":"document",`${B} → ${z}`);const $=I,M={initial:$.scrollTop,target:z,element:$,duration:x};e(ir.SCROLL_START,y,{scroll:M});const{cancel:q,promise:D}=z_(z,{element:$,duration:x});f.current=q,await D,e(ir.SCROLL_END,y,{scroll:M}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,c,u,d,i])}function ole(e){const t=Hie(()=>Oae(Mae,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,c=m.useRef(Jae(t)),u=II.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[d,f]=m.useState([]),p=m.useCallback((N,j)=>{f(A=>[...A,{reason:j,step:N}])},[]),h=m.useCallback(()=>{f([])},[]);Zae(c,n);const g=Xae(c,n,h),k=ele(s,g,c),{index:b,size:y,status:v}=u,x=vM(u),C=m.useMemo(()=>Nv(t,l[b]),[b,t,l]);return Wie(()=>{i&&y&&YM(l,n)&&g.start(a??r)}),Bie(()=>{i&&y&&v===It.IDLE&&c.current.updateState({status:It.READY})},[i,y,v]),nle({controls:g,emitEvent:k,props:t,state:u,store:c}),tle({addFailure:p,controls:g,emitEvent:k,previousState:x,props:t,state:u,step:C,store:c}),ile({emitEvent:k,previousState:x,props:t,state:u,step:C,store:c}),{controls:g,failures:d,mergedProps:t,state:u,step:C,store:c}}function ale(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(Er.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=$ae,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const lle={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function cle({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Jd;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
319
- @keyframes joyride-loader-spin {
320
- to { transform: rotate(360deg); }
321
- }
322
- `)),document.head.appendChild(c),()=>{const u=document.getElementById("joyride-loader-animation");u!=null&&u.parentNode&&u.parentNode.removeChild(u)}},[r,e]),n===null)return null;const{height:s,width:i,...a}=t.styles.loader;let l;if(n){const c=n;l=ut.createElement(c,{step:t})}else l=ut.createElement("div",{style:{...lle,height:s,width:i,borderTopColor:t.primaryColor}});return ut.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const ule={height:0,isFixed:!1,left:0,top:0,width:0};function Tu(e,t){const n=_s(e);if(!n)return ule;const r=Sv(n),s=Kc(n),i=zae(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 dle(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),u=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=Vc(g,!0),a.current&&a.current.addEventListener("scroll",u,{passive:!0}),window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(u),c.current.observe(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",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(g=c.current)==null||g.disconnect(),clearTimeout(i.current)}},[e,t,u]),m.useEffect(()=>{l.current&&!n&&s(Tu(e,t)),l.current=n},[n,e,t]);let d=r;return l.current&&!n&&(d=Tu(e,t)),d}function fle(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function H_(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 ple=[Je.BEACON_BEFORE,Je.BEACON];function hle(e){var D,L;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:d,spotlightRadius:f,spotlightTarget:p,styles:h,target:g,waiting:k}=e,b=Vie(),y=dle(p??g,d,u||k),v=m.useRef(null),x=(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE)&&l!=="center",[C,N]=m.useState(!1),j=c?(D=v.current)==null?void 0:D.offsetParent:null,A=(j==null?void 0:j.clientWidth)??b.width,I=(j==null?void 0:j.clientHeight)??Fae()??b.height,O=((L=h.overlay)==null?void 0:L.backgroundColor)??"rgba(0, 0, 0, 0.5)",H=m.useMemo(()=>{const{backgroundColor:T,mixBlendMode:W,...E}=h.overlay;return{height:I,pointerEvents:"none",...E}},[I,h.overlay]),B=x&&!u&&!k;m.useEffect(()=>{B?requestAnimationFrame(()=>N(!0)):N(!1)},[B]);const z=n&&ple.includes(s),$=!n&&s!==Je.TOOLTIP;if(r||!k&&(z||$))return null;let M="";if(B)if(c&&j){const T=_s(p??g);if(T){const W=D_(T),E=D_(j);M=H_(W.left-E.left-d.left,W.top-E.top-d.top,T.offsetWidth+d.left+d.right,T.offsetHeight+d.top+d.bottom,f)}}else M=H_(y.left,y.top,y.width,y.height,f);const q=fle(A,I,M);return ut.createElement("div",{ref:v,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:H},ut.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:I,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:A}},ut.createElement("path",{d:q,fill:O,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&ut.createElement("path",{d:M,fill:O,style:{opacity:C?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&ut.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function GM(e){const{children:t,element:n}=e;return n?or.createPortal(t,n):null}const mle='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function gle(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return Jd;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(mle)],{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 Xi(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 yle(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...Xi(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...Xi(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...Xi(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...Xi(e,t,n)};default:return null}}function wle(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...Xi(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...Xi(e,r,n)};case"left":return{right:-n,top:t.y??0,...Xi(e,r,n)};case"right":return{left:-n,top:t.y??0,...Xi(e,r,n)};default:return{}}}function xle({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let c=null;if(l){if(!Xi(r,n,i))return null;c=ut.createElement("span",{style:{flexShrink:0}},ut.createElement(l,{base:n,placement:r,size:i}))}else{const u=yle(r,n,i);if(!u)return null;c=ut.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},ut.createElement("polygon",{fill:"currentColor",points:u.points}))}return ut.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...wle(r,s,i,n),...s?{}:{visibility:"hidden"}}},c)}function ble(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:c,size:u,step:d,styles:f}=e,p=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return Jd;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
323
- @keyframes joyride-beacon-inner {
324
- 20% {
325
- opacity: 0.9;
326
- }
327
-
328
- 90% {
329
- opacity: 0.7;
330
- }
331
- }
332
-
333
- @keyframes joyride-beacon-outer {
334
- 0% {
335
- transform: scale(1);
336
- }
337
-
338
- 45% {
339
- opacity: 0.7;
340
- transform: scale(0.75);
341
- }
342
-
343
- 100% {
344
- opacity: 0.9;
345
- transform: scale(1);
346
- }
347
- }
348
- `)),document.head.appendChild(b);const y=setTimeout(()=>{Er.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=qi(i.open);let k;if(t){const b=t;k=ut.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else k=ut.createElement("span",{style:f.beacon},ut.createElement("span",{style:f.beaconOuter}),ut.createElement("span",{style:f.beaconInner}));return ut.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"},k)}function kle({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return ut.createElement("button",{style:i,type:"button",...t},ut.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"},ut.createElement("g",null,ut.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 vle(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,h={};u.includes("primary")&&(h.primary=ut.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...i})),u.includes("skip")&&!s&&(h.skip=ut.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=ut.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&ut.createElement(kle,{"data-testid":"button-close",styles:f.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":qi(d),"aria-describedby":"joyride-tooltip-content"};return ut.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...g},ut.createElement("div",{style:f.tooltipContainer},p&&ut.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),ut.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(k=>k==="back"||k==="primary"||k==="skip")&&ut.createElement("div",{style:f.tooltipFooter},ut.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Sle(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(gi.BUTTON_BACK)},c=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(gi.BUTTON_CLOSE):n.close(gi.BUTTON_CLOSE)},u=y=>{if(y.preventDefault(),!t){n.close(gi.BUTTON_PRIMARY);return}n.next(gi.BUTTON_PRIMARY)},d=y=>{y.preventDefault(),n.skip(gi.BUTTON_SKIP)},f=()=>{const{back:y,close:v,last:x,next:C,nextWithProgress:N,skip:j}=a.locale,A=qi(y),I=qi(v),O=qi(x),H=qi(C),B=qi(j);let z=v,$=I;if(t){if(z=C,$=H,a.showProgress&&!s){const M=qi(N,{step:r+1,steps:i});z=wb(N,r+1,i),$=M}s&&(z=x,$=O)}return{backProps:{"aria-label":A,children:y,"data-action":"back",onClick:l,role:"button",title:A},closeProps:{"aria-label":I,children:v,"data-action":"close",onClick:c,role:"button",title:I},primaryProps:{"aria-label":$,children:z,"data-action":"primary",onClick:u,role:"button",title:$},skipProps:{"aria-label":B,children:j,"data-action":"skip",onClick:d,role:"button",title:B},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:g,...k}=a;let b;if(g){const y=g;b=ut.createElement(y,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:k})}else b=ut.createElement(vle,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:k});return b}function Nle(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function jle(e,t,n){var r,s;return e?[Aae()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Eae({crossAxis:!1,fallbackPlacements:Nle(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Cle(e){var W,E,Q,V,F;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:d,size:f,step:p,target:h,updateState:g}=e,k=m.useRef(null),b=m.useRef({}),y=m.useRef({}),v=p.placement==="center",x=p.placement==="auto",C=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=m.useMemo(()=>KM(h)?Vc(h):void 0,[h]),j=m.useMemo(()=>Kc(h),[h]),A=m.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),I=v||x?"bottom":p.placement,O=v?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||j?"fixed":"absolute"),H=m.useMemo(()=>{var se,ce,J,ne;return v?[{name:"center",fn:({rects:ee})=>({x:(window.innerWidth-ee.floating.width)/2,y:(window.innerHeight-ee.floating.height)/2})}]:[$_(({placement:ee})=>{var le;let re="right";ee.startsWith("top")?re="top":ee.startsWith("bottom")?re="bottom":ee.startsWith("left")&&(re="left");const Z=p.spotlightTarget?0:p.spotlightPadding[re];return p.offset+Z+((le=p.floatingOptions)!=null&&le.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...jle(x,p,I),_ae({padding:10,...A,...(ce=p.floatingOptions)==null?void 0:ce.shiftOptions}),...(J=p.floatingOptions)!=null&&J.hideArrow?[]:[Pae({element:k,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ne=p.floatingOptions)==null?void 0:ne.middleware)??[]]},[v,p,x,I,A]),B=M_({...v?{elements:{reference:C}}:{},placement:I,strategy:O,middleware:H}),z=M_({strategy:O,placement:p.beaconPlacement??(x||v?"bottom":p.placement),middleware:m.useMemo(()=>{var se,ce;return[$_(((ce=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:ce.offset)??-18)]},[(Q=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:I_});y.current=B.middlewareData,b.current=z.middlewareData,m.useEffect(()=>{var J;const{floating:se,reference:ce}=B.elements;if(!(!ce||!se||s!==Je.TOOLTIP))return I_(ce,se,B.update,(J=p.floatingOptions)==null?void 0:J.autoUpdate)},[s,B.update,(V=p.floatingOptions)==null?void 0:V.autoUpdate,p.target,B.elements]),m.useEffect(()=>{!v&&h&&B.refs.setReference(h),h&&z.refs.setReference(h)},[z.refs,v,h,B.refs]),m.useEffect(()=>{B.isPositioned&&c("tooltip",{placement:B.placement,x:B.x??0,y:B.y??0,middlewareData:y.current})},[c,B.isPositioned,B.placement,B.x,B.y]),m.useEffect(()=>{z.isPositioned&&c("beacon",{placement:z.placement,x:z.x??0,y:z.y??0,middlewareData:b.current})},[c,z.isPositioned,z.placement,z.x,z.y]);const $=p.zIndex+100,M=m.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:Je.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),q=m.useCallback(se=>{se&&(B.refs.setFloating(se),u(se))},[B.refs,u]),{arrow:D,floater:L}=p.styles;let T=null;if(s===Je.TOOLTIP||s===Je.TOOLTIP_BEFORE){const se=O_({...L,...B.floatingStyles,zIndex:$,opacity:a&&B.isPositioned?1:0,...!a&&{transition:"none"}});T=ut.createElement("div",{ref:q,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},ut.createElement(Sle,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!v&&!((F=p.floatingOptions)!=null&&F.hideArrow)&&ut.createElement(xle,{arrowComponent:p.arrowComponent,arrowRef:k,base:p.arrowBase,placement:B.placement,position:B.middlewareData.arrow,size:p.arrowSize,styles:D}))}else(s===Je.BEACON||s===Je.BEACON_BEFORE)&&(T=ut.createElement("div",{ref:z.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:O_({...z.floatingStyles,zIndex:$})},ut.createElement(ble,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:i,onInteract:M,shouldFocus:d,size:f,step:p,styles:p.styles})));return ut.createElement(GM,{element:l},T)}function _le(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:d,updateState:f}=e,[p,h]=m.useState(null);gle(d.disableFocusTrap?null:p,"[data-action=primary]");const g=_s(d.target),k=s===Je.TOOLTIP;return!UM(d)||!Er.domElement(g)?null:ut.createElement(Cle,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:k,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:d,target:g,updateState:f})}function Ele({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=ale(c),{index:f,lifecycle:p,status:h}=n,g=h===It.RUNNING,[k,b]=m.useState(!1),y=m.useRef(null),v=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?v===0?b(!0):y.current=setTimeout(()=>{b(!0)},v):b(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[v,n.waiting]),m.useEffect(()=>{if(!g)return;const N=j=>{!r||p!==Je.TOOLTIP||j.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(gi.KEYBOARD):e.close(gi.KEYBOARD))};return document.body.addEventListener("keydown",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,g,p,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(gi.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(gi.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const C=n.action===Lt.START&&!r.skipBeacon&&r.placement!=="center";return ut.createElement(ut.Fragment,null,p!==Je.INIT&&ut.createElement(_le,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:d,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),ut.createElement(GM,{element:d},ut.createElement(ut.Fragment,null,k&&ut.createElement(cle,{nonce:l,step:r}),!C&&ut.createElement(hle,{...r,continuous:i,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Ale(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=ole(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>km(s,"positioned"),[s]),step:i,Tour:vv()?ut.createElement(Ele,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function Ple(e){const{Tour:t}=Ale(e);return t}function Ile(e){return vv()?ut.createElement(Ple,e):null}function Rle(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 Tle(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Mle(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const zp="af:onboarding";function $le({page:e,hasNodes:t=!1}){const{t:n}=Dr(),[r,s]=m.useState(!1),[i,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?Rle(n):t?Tle(n):Mle(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(zp),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(zp,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=d=>{var g;const f=d.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 k=localStorage.getItem(zp)||"{}",b=JSON.parse(k);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(zp,JSON.stringify(b)),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",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||i.length===0?null:o.jsx(Ile,{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 Lle(){const{navigate:e,path:t}=si(),[n,r]=m.useState([]),[s,i]=m.useState(!1);if(m.useEffect(()=>{let d=!1;const f=async()=>{try{const h=await fetch("/api/pipeline-recent-runs");if(!h.ok)return;const g=await h.json();if(d)return;const k=Array.isArray(g.runs)?g.runs:[];r(k.filter(b=>b&&b.status==="running"))}catch{}};f();const p=window.setInterval(f,3e3);return()=>{d=!0,window.clearInterval(p)}},[]),n.length===0)return null;const a=d=>{const f=new URLSearchParams({flowId:d.flowId,flowSource:d.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"))||"",u=n.length===1;return o.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!u&&o.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>i(!1),children:n.map(d=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(d.flowId===c?" af-run-indicator__item--current":""),onClick:()=>a(d),title:`${d.flowId} · ${d.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:d.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:d.runId.slice(0,12)})]},`${d.flowId}:${d.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>u?a(n[0]):i(d=>!d),title:u?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[o.jsx("span",{className:"af-run-indicator__pulse"}),o.jsx("span",{className:"af-run-indicator__label",children:u?n[0].flowId:`${n.length} running`})]})]})}const yw="0.1.108",Ole=6e4,Dle=30*6e4;function Tc(e){return String(e||"").trim().replace(/^v/i,"")}function Fle(e,t){const n=Tc(e),r=Tc(t);return!!(n&&r&&n!==r)}function zle(e,t){return`agentflow.app-version.snooze:${Tc(e)}:${Tc(t)}`}function Ble(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Hle(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const i=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const d=Tc(u.version);if(!Fle(yw,d)){t(null);return}const f=zle(yw,d);if(Ble(f)>Date.now())return;t({clientVersion:Tc(yw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&i()},l=window.setInterval(()=>void i(),Ole);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",i),i(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",i)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+Dle))}catch{}t(null)};return o.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),o.jsxs("div",{className:"af-app-version-notice__copy",children:[o.jsx("strong",{children:"AgentFlow 已更新"}),o.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),o.jsxs("div",{className:"af-app-version-notice__actions",children:[o.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),o.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function JM(e){return e==="/likee-context"||e==="/likee_context"}function Wle(){const{navigate:e}=si();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class Vle 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 Kle({authUser:e}){const{path:t}=si();return t==="/projects"||t==="/"?o.jsx(Al,{authUser:e}):t==="/nodes"?o.jsx(Al,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(Al,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(Al,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(Al,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?o.jsx(xie,{authUser:e}):t==="/mcps"?o.jsx(aie,{}):t==="/schedules"?o.jsx(die,{}):t==="/node-studio"?o.jsx(pie,{}):t==="/flow"?o.jsx(Wle,{}):t==="/workspace"?o.jsx(SJ,{}):t.startsWith("/display")?o.jsx(aM,{}):t==="/settings"?o.jsx(Jse,{authUser:e}):t==="/admin/usage"?o.jsx(eie,{authUser:e}):t==="/feedback"?o.jsx(nie,{authUser:e}):JM(t)?o.jsx(bM,{}):o.jsx(Al,{})}function qle({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),[u,d]=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}),d(g.error?String(g.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),d("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:i})}),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||"登录失败");s(""),a(""),window.location.replace(window.location.href);return}catch(g){d(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,autoComplete:"on",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",{id:"agentflow-auth-username",name:"username",type:"text",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",{id:"agentflow-auth-password",name:"password",type:"password",value:i,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?o.jsx("p",{className:"af-auth-error",children:u}):null,o.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||i.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Ule({authUser:e,onLogout:t}){const{path:n}=si(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx($le,{page:r?"flow":"projects"}):null,r?null:o.jsx(bD,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(Kle,{authUser:e})}),o.jsx(Lle,{})]})}function Yle(){return o.jsx(Vle,{children:o.jsxs(tD,{children:[o.jsx(Gle,{}),o.jsx(Hle,{})]})})}function Gle(){const{path:e}=si();return e.startsWith("/display")?o.jsx(aM,{}):JM(e)?o.jsx(bM,{}):o.jsx(qle,{children:({user:t,onLogout:n})=>o.jsx(Ule,{authUser:t,onLogout:n})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const W_=document.querySelector('link[rel="icon"]');W_&&(W_.href=iP);ww.createRoot(document.getElementById("root")).render(o.jsx(ut.StrictMode,{children:o.jsx(Yle,{})}));