@fieldwangai/agentflow 0.1.137 → 0.1.138
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.
- package/bin/lib/prd-workflow-collaboration.mjs +47 -1
- package/bin/lib/ui-server.mjs +358 -0
- package/builtin/web-ui/dist/assets/WorkflowAssistantThread-B3thaqH2.js +6 -0
- package/builtin/web-ui/dist/assets/index-COX1zMwq.css +1 -0
- package/builtin/web-ui/dist/assets/index-YS4XOpXF.js +590 -0
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/builtin/web-ui/dist/assets/index-CQsrSc3u.css +0 -1
- package/builtin/web-ui/dist/assets/index-DQvqqAeQ.js +0 -590
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
var _2=Object.defineProperty;var C2=(e,t,n)=>t in e?_2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qn=(e,t,n)=>C2(e,typeof t!="symbol"?t+"":t,n);function A2(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Td=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ma(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var NA={exports:{}},Vm={},_A={exports:{}},zt={};/**
|
|
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 bf=Symbol.for("react.element"),E2=Symbol.for("react.portal"),I2=Symbol.for("react.fragment"),P2=Symbol.for("react.strict_mode"),T2=Symbol.for("react.profiler"),R2=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 CA={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},AA=Object.assign,EA={};function Qc(e,t,n){this.props=e,this.context=t,this.refs=EA,this.updater=n||CA}Qc.prototype.isReactComponent={};Qc.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")};Qc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function IA(){}IA.prototype=Qc.prototype;function qb(e,t,n){this.props=e,this.context=t,this.refs=EA,this.updater=n||CA}var Ub=qb.prototype=new IA;Ub.constructor=qb;AA(Ub,Qc.prototype);Ub.isPureReactComponent=!0;var o0=Array.isArray,PA=Object.prototype.hasOwnProperty,Gb={current:null},TA={key:!0,ref:!0,__self:!0,__source:!0};function RA(e,t,n){var r,i={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)PA.call(t,r)&&!TA.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)i[r]===void 0&&(i[r]=l[r]);return{$$typeof:bf,type:e,key:o,ref:a,props:i,_owner:Gb.current}}function z2(e,t){return{$$typeof:bf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Yb(e){return typeof e=="object"&&e!==null&&e.$$typeof===bf}function W2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var a0=/\/+/g;function by(e,t){return typeof e=="object"&&e!==null&&e.key!=null?W2(""+e.key):t.toString(36)}function uh(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case bf:case E2:a=!0}}if(a)return a=e,i=i(a),e=r===""?"."+by(a,0):r,o0(i)?(n="",e!=null&&(n=e.replace(a0,"$&/")+"/"),uh(i,t,n,"",function(u){return u})):i!=null&&(Yb(i)&&(i=z2(i,n+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(a0,"$&/")+"/")+e)),t.push(i)),1;if(a=0,r=r===""?".":r+":",o0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+by(o,l);a+=uh(o,t,n,c,i)}else if(c=F2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+by(o,l++),a+=uh(o,t,n,c,i);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function mp(e,t,n){if(e==null)return e;var r=[],i=0;return uh(e,r,"","",function(o){return t.call(n,o,i++)}),r}function B2(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 Kr={current:null},dh={transition:null},H2={ReactCurrentDispatcher:Kr,ReactCurrentBatchConfig:dh,ReactCurrentOwner:Gb};function MA(){throw Error("act(...) is not supported in production builds of React.")}zt.Children={map:mp,forEach:function(e,t,n){mp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return mp(e,function(){t++}),t},toArray:function(e){return mp(e,function(t){return t})||[]},only:function(e){if(!Yb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};zt.Component=Qc;zt.Fragment=I2;zt.Profiler=T2;zt.PureComponent=qb;zt.StrictMode=P2;zt.Suspense=L2;zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H2;zt.act=MA;zt.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=AA({},e.props),i=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Gb.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)PA.call(t,c)&&!TA.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:bf,type:e.type,key:i,ref:o,props:r,_owner:a}};zt.createContext=function(e){return e={$$typeof:M2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:R2,_context:e},e.Consumer=e};zt.createElement=RA;zt.createFactory=function(e){var t=RA.bind(null,e);return t.type=e,t};zt.createRef=function(){return{current:null}};zt.forwardRef=function(e){return{$$typeof:$2,render:e}};zt.isValidElement=Yb;zt.lazy=function(e){return{$$typeof:D2,_payload:{_status:-1,_result:e},_init:B2}};zt.memo=function(e,t){return{$$typeof:O2,type:e,compare:t===void 0?null:t}};zt.startTransition=function(e){var t=dh.transition;dh.transition={};try{e()}finally{dh.transition=t}};zt.unstable_act=MA;zt.useCallback=function(e,t){return Kr.current.useCallback(e,t)};zt.useContext=function(e){return Kr.current.useContext(e)};zt.useDebugValue=function(){};zt.useDeferredValue=function(e){return Kr.current.useDeferredValue(e)};zt.useEffect=function(e,t){return Kr.current.useEffect(e,t)};zt.useId=function(){return Kr.current.useId()};zt.useImperativeHandle=function(e,t,n){return Kr.current.useImperativeHandle(e,t,n)};zt.useInsertionEffect=function(e,t){return Kr.current.useInsertionEffect(e,t)};zt.useLayoutEffect=function(e,t){return Kr.current.useLayoutEffect(e,t)};zt.useMemo=function(e,t){return Kr.current.useMemo(e,t)};zt.useReducer=function(e,t,n){return Kr.current.useReducer(e,t,n)};zt.useRef=function(e){return Kr.current.useRef(e)};zt.useState=function(e){return Kr.current.useState(e)};zt.useSyncExternalStore=function(e,t,n){return Kr.current.useSyncExternalStore(e,t,n)};zt.useTransition=function(){return Kr.current.useTransition()};zt.version="18.3.1";_A.exports=zt;var m=_A.exports;const dt=ma(m),kde=A2({__proto__:null,default:dt},[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,G2=V2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Y2={key:!0,ref:!0,__self:!0,__source:!0};function $A(e,t,n){var r,i={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)U2.call(t,r)&&!Y2.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:K2,type:e,key:o,ref:a,props:i,_owner:G2.current}}Vm.Fragment=q2;Vm.jsx=$A;Vm.jsxs=$A;NA.exports=Vm;var s=NA.exports,Vw={},LA={exports:{}},vs={},OA={exports:{}},DA={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(R,H){var A=R.length;R.push(H);e:for(;0<A;){var X=A-1>>>1,K=R[X];if(0<i(K,H))R[X]=H,R[A]=K,A=X;else break e}}function n(R){return R.length===0?null:R[0]}function r(R){if(R.length===0)return null;var H=R[0],A=R.pop();if(A!==H){R[0]=A;e:for(var X=0,K=R.length,W=K>>>1;X<W;){var te=2*(X+1)-1,ee=R[te],G=te+1,ne=R[G];if(0>i(ee,A))G<K&&0>i(ne,ee)?(R[X]=ne,R[G]=A,X=G):(R[X]=ee,R[te]=A,X=te);else if(G<K&&0>i(ne,A))R[X]=ne,R[G]=A,X=G;else break e}}return H}function i(R,H){var A=R.sortIndex-H.sortIndex;return A!==0?A:R.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],p=1,f=null,d=3,h=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(R){for(var H=n(u);H!==null;){if(H.callback===null)r(u);else if(H.startTime<=R)r(u),H.sortIndex=H.expirationTime,t(c,H);else break;H=n(u)}}function _(R){if(v=!1,x(R),!y)if(n(c)!==null)y=!0,B(S);else{var H=n(u);H!==null&&F(_,H.startTime-R)}}function S(R,H){y=!1,v&&(v=!1,g(T),T=-1),h=!0;var A=d;try{for(x(H),f=n(c);f!==null&&(!(f.expirationTime>H)||R&&!O());){var X=f.callback;if(typeof X=="function"){f.callback=null,d=f.priorityLevel;var K=X(f.expirationTime<=H);H=e.unstable_now(),typeof K=="function"?f.callback=K:f===n(c)&&r(c),x(H)}else r(c);f=n(c)}if(f!==null)var W=!0;else{var te=n(u);te!==null&&F(_,te.startTime-H),W=!1}return W}finally{f=null,d=A,h=!1}}var N=!1,I=null,T=-1,z=5,E=-1;function O(){return!(e.unstable_now()-E<z)}function D(){if(I!==null){var R=e.unstable_now();E=R;var H=!0;try{H=I(!0,R)}finally{H?L():(N=!1,I=null)}}else N=!1}var L;if(typeof k=="function")L=function(){k(D)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,V=$.port2;$.port1.onmessage=D,L=function(){V.postMessage(null)}}else L=function(){b(D,0)};function B(R){I=R,N||(N=!0,L())}function F(R,H){T=b(function(){R(e.unstable_now())},H)}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(R){R.callback=null},e.unstable_continueExecution=function(){y||h||(y=!0,B(S))},e.unstable_forceFrameRate=function(R){0>R||125<R?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<R?Math.floor(1e3/R):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(R){switch(d){case 1:case 2:case 3:var H=3;break;default:H=d}var A=d;d=H;try{return R()}finally{d=A}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(R,H){switch(R){case 1:case 2:case 3:case 4:case 5:break;default:R=3}var A=d;d=R;try{return H()}finally{d=A}},e.unstable_scheduleCallback=function(R,H,A){var X=e.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?X+A:X):A=X,R){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=A+K,R={id:p++,callback:H,priorityLevel:R,startTime:A,expirationTime:K,sortIndex:-1},A>X?(R.sortIndex=A,t(u,R),n(c)===null&&R===n(u)&&(v?(g(T),T=-1):v=!0,F(_,A-X))):(R.sortIndex=K,t(c,R),y||h||(y=!0,B(S))),R},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(R){var H=d;return function(){var A=d;d=H;try{return R.apply(this,arguments)}finally{d=A}}}})(DA);OA.exports=DA;var J2=OA.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,bs=J2;function Ie(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 FA=new Set,Rd={};function gl(e,t){Rc(e,t),Rc(e+"Capture",t)}function Rc(e,t){for(Rd[e]=t,e=0;e<t.length;e++)FA.add(t[e])}var fo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kw=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]*$/,l0={},c0={};function Z2(e){return Kw.call(c0,e)?!0:Kw.call(l0,e)?!1:Q2.test(e)?c0[e]=!0:(l0[e]=!0,!1)}function eO(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 tO(e,t,n,r){if(t===null||typeof t>"u"||eO(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 qr(e,t,n,r,i,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var Ar={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ar[e]=new qr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ar[t]=new qr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ar[e]=new qr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ar[e]=new qr(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){Ar[e]=new qr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ar[e]=new qr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ar[e]=new qr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ar[e]=new qr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ar[e]=new qr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jb=/[\-:]([a-z])/g;function Xb(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(Jb,Xb);Ar[t]=new qr(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(Jb,Xb);Ar[t]=new qr(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(Jb,Xb);Ar[t]=new qr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ar[e]=new qr(e,1,!1,e.toLowerCase(),null,!1,!1)});Ar.xlinkHref=new qr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ar[e]=new qr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Qb(e,t,n,r){var i=Ar.hasOwnProperty(t)?Ar[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(tO(t,n,i,r)&&(n=null),r||i===null?Z2(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var bo=X2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,gp=Symbol.for("react.element"),tc=Symbol.for("react.portal"),nc=Symbol.for("react.fragment"),Zb=Symbol.for("react.strict_mode"),qw=Symbol.for("react.profiler"),zA=Symbol.for("react.provider"),WA=Symbol.for("react.context"),ek=Symbol.for("react.forward_ref"),Uw=Symbol.for("react.suspense"),Gw=Symbol.for("react.suspense_list"),tk=Symbol.for("react.memo"),Fo=Symbol.for("react.lazy"),BA=Symbol.for("react.offscreen"),u0=Symbol.iterator;function Lu(e){return e===null||typeof e!="object"?null:(e=u0&&e[u0]||e["@@iterator"],typeof e=="function"?e:null)}var Bn=Object.assign,ky;function td(e){if(ky===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);ky=t&&t[1]||""}return`
|
|
34
|
+
`+ky+e}var vy=!1;function Sy(e,t){if(!e||vy)return"";vy=!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 i=u.stack.split(`
|
|
35
|
+
`),o=r.stack.split(`
|
|
36
|
+
`),a=i.length-1,l=o.length-1;1<=a&&0<=l&&i[a]!==o[l];)l--;for(;1<=a&&0<=l;a--,l--)if(i[a]!==o[l]){if(a!==1||l!==1)do if(a--,l--,0>l||i[a]!==o[l]){var c=`
|
|
37
|
+
`+i[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{vy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?td(e):""}function nO(e){switch(e.tag){case 5:return td(e.type);case 16:return td("Lazy");case 13:return td("Suspense");case 19:return td("SuspenseList");case 0:case 2:case 15:return e=Sy(e.type,!1),e;case 11:return e=Sy(e.type.render,!1),e;case 1:return e=Sy(e.type,!0),e;default:return""}}function Yw(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 nc:return"Fragment";case tc:return"Portal";case qw:return"Profiler";case Zb:return"StrictMode";case Uw:return"Suspense";case Gw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case WA:return(e.displayName||"Context")+".Consumer";case zA:return(e._context.displayName||"Context")+".Provider";case ek:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tk:return t=e.displayName||null,t!==null?t:Yw(e.type)||"Memo";case Fo:t=e._payload,e=e._init;try{return Yw(e(t))}catch{}}return null}function rO(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 Yw(t);case 8:return t===Zb?"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 aa(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function HA(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function sO(e){var t=HA(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 i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function yp(e){e._valueTracker||(e._valueTracker=sO(e))}function VA(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=HA(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Lh(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 Jw(e,t){var n=t.checked;return Bn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function d0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=aa(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 KA(e,t){t=t.checked,t!=null&&Qb(e,"checked",t,!1)}function Xw(e,t){KA(e,t);var n=aa(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")?Qw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Qw(e,t.type,aa(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function f0(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 Qw(e,t,n){(t!=="number"||Lh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var nd=Array.isArray;function xc(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+aa(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Zw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ie(91));return Bn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function p0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Ie(92));if(nd(n)){if(1<n.length)throw Error(Ie(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:aa(n)}}function qA(e,t){var n=aa(t.value),r=aa(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 h0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function UA(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 ex(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?UA(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var wp,GA=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(wp=wp||document.createElement("div"),wp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=wp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Md(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pd={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},iO=["Webkit","ms","Moz","O"];Object.keys(pd).forEach(function(e){iO.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pd[t]=pd[e]})});function YA(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||pd.hasOwnProperty(e)&&pd[e]?(""+t).trim():t+"px"}function JA(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=YA(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var oO=Bn({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 tx(e,t){if(t){if(oO[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ie(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ie(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ie(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ie(62))}}function nx(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 rx=null;function nk(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sx=null,bc=null,kc=null;function m0(e){if(e=Sf(e)){if(typeof sx!="function")throw Error(Ie(280));var t=e.stateNode;t&&(t=Ym(t),sx(e.stateNode,e.type,t))}}function XA(e){bc?kc?kc.push(e):kc=[e]:bc=e}function QA(){if(bc){var e=bc,t=kc;if(kc=bc=null,m0(e),t)for(e=0;e<t.length;e++)m0(t[e])}}function ZA(e,t){return e(t)}function eE(){}var jy=!1;function tE(e,t,n){if(jy)return e(t,n);jy=!0;try{return ZA(e,t,n)}finally{jy=!1,(bc!==null||kc!==null)&&(eE(),QA())}}function $d(e,t){var n=e.stateNode;if(n===null)return null;var r=Ym(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(Ie(231,t,typeof n));return n}var ix=!1;if(fo)try{var Ou={};Object.defineProperty(Ou,"passive",{get:function(){ix=!0}}),window.addEventListener("test",Ou,Ou),window.removeEventListener("test",Ou,Ou)}catch{ix=!1}function aO(e,t,n,r,i,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var hd=!1,Oh=null,Dh=!1,ox=null,lO={onError:function(e){hd=!0,Oh=e}};function cO(e,t,n,r,i,o,a,l,c){hd=!1,Oh=null,aO.apply(lO,arguments)}function uO(e,t,n,r,i,o,a,l,c){if(cO.apply(this,arguments),hd){if(hd){var u=Oh;hd=!1,Oh=null}else throw Error(Ie(198));Dh||(Dh=!0,ox=u)}}function yl(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 nE(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function g0(e){if(yl(e)!==e)throw Error(Ie(188))}function dO(e){var t=e.alternate;if(!t){if(t=yl(e),t===null)throw Error(Ie(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return g0(i),e;if(o===r)return g0(i),t;o=o.sibling}throw Error(Ie(188))}if(n.return!==r.return)n=i,r=o;else{for(var a=!1,l=i.child;l;){if(l===n){a=!0,n=i,r=o;break}if(l===r){a=!0,r=i,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=i;break}if(l===r){a=!0,r=o,n=i;break}l=l.sibling}if(!a)throw Error(Ie(189))}}if(n.alternate!==r)throw Error(Ie(190))}if(n.tag!==3)throw Error(Ie(188));return n.stateNode.current===n?e:t}function rE(e){return e=dO(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 iE=bs.unstable_scheduleCallback,y0=bs.unstable_cancelCallback,fO=bs.unstable_shouldYield,pO=bs.unstable_requestPaint,er=bs.unstable_now,hO=bs.unstable_getCurrentPriorityLevel,rk=bs.unstable_ImmediatePriority,oE=bs.unstable_UserBlockingPriority,Fh=bs.unstable_NormalPriority,mO=bs.unstable_LowPriority,aE=bs.unstable_IdlePriority,Km=null,Ri=null;function gO(e){if(Ri&&typeof Ri.onCommitFiberRoot=="function")try{Ri.onCommitFiberRoot(Km,e,void 0,(e.current.flags&128)===128)}catch{}}var ci=Math.clz32?Math.clz32:xO,yO=Math.log,wO=Math.LN2;function xO(e){return e>>>=0,e===0?32:31-(yO(e)/wO|0)|0}var xp=64,bp=4194304;function rd(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 zh(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~i;l!==0?r=rd(l):(o&=a,o!==0&&(r=rd(o)))}else a=n&~i,a!==0?r=rd(a):o!==0&&(r=rd(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-ci(t),i=1<<n,r|=e[n],t&=~i;return r}function bO(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 kO(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-ci(o),l=1<<a,c=i[a];c===-1?(!(l&n)||l&r)&&(i[a]=bO(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function ax(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function lE(){var e=xp;return xp<<=1,!(xp&4194240)&&(xp=64),e}function Ny(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function kf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ci(t),e[t]=n}function vO(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 i=31-ci(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function sk(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ci(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var un=0;function cE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var uE,ik,dE,fE,pE,lx=!1,kp=[],Xo=null,Qo=null,Zo=null,Ld=new Map,Od=new Map,Bo=[],SO="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 w0(e,t){switch(e){case"focusin":case"focusout":Xo=null;break;case"dragenter":case"dragleave":Qo=null;break;case"mouseover":case"mouseout":Zo=null;break;case"pointerover":case"pointerout":Ld.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Od.delete(t.pointerId)}}function Du(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Sf(t),t!==null&&ik(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function jO(e,t,n,r,i){switch(t){case"focusin":return Xo=Du(Xo,e,t,n,r,i),!0;case"dragenter":return Qo=Du(Qo,e,t,n,r,i),!0;case"mouseover":return Zo=Du(Zo,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Ld.set(o,Du(Ld.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,Od.set(o,Du(Od.get(o)||null,e,t,n,r,i)),!0}return!1}function hE(e){var t=Wa(e.target);if(t!==null){var n=yl(t);if(n!==null){if(t=n.tag,t===13){if(t=nE(n),t!==null){e.blockedOn=t,pE(e.priority,function(){dE(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 fh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=cx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);rx=r,n.target.dispatchEvent(r),rx=null}else return t=Sf(n),t!==null&&ik(t),e.blockedOn=n,!1;t.shift()}return!0}function x0(e,t,n){fh(e)&&n.delete(t)}function NO(){lx=!1,Xo!==null&&fh(Xo)&&(Xo=null),Qo!==null&&fh(Qo)&&(Qo=null),Zo!==null&&fh(Zo)&&(Zo=null),Ld.forEach(x0),Od.forEach(x0)}function Fu(e,t){e.blockedOn===t&&(e.blockedOn=null,lx||(lx=!0,bs.unstable_scheduleCallback(bs.unstable_NormalPriority,NO)))}function Dd(e){function t(i){return Fu(i,e)}if(0<kp.length){Fu(kp[0],e);for(var n=1;n<kp.length;n++){var r=kp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Xo!==null&&Fu(Xo,e),Qo!==null&&Fu(Qo,e),Zo!==null&&Fu(Zo,e),Ld.forEach(t),Od.forEach(t),n=0;n<Bo.length;n++)r=Bo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Bo.length&&(n=Bo[0],n.blockedOn===null);)hE(n),n.blockedOn===null&&Bo.shift()}var vc=bo.ReactCurrentBatchConfig,Wh=!0;function _O(e,t,n,r){var i=un,o=vc.transition;vc.transition=null;try{un=1,ok(e,t,n,r)}finally{un=i,vc.transition=o}}function CO(e,t,n,r){var i=un,o=vc.transition;vc.transition=null;try{un=4,ok(e,t,n,r)}finally{un=i,vc.transition=o}}function ok(e,t,n,r){if(Wh){var i=cx(e,t,n,r);if(i===null)$y(e,t,r,Bh,n),w0(e,r);else if(jO(i,e,t,n,r))r.stopPropagation();else if(w0(e,r),t&4&&-1<SO.indexOf(e)){for(;i!==null;){var o=Sf(i);if(o!==null&&uE(o),o=cx(e,t,n,r),o===null&&$y(e,t,r,Bh,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else $y(e,t,r,null,n)}}var Bh=null;function cx(e,t,n,r){if(Bh=null,e=nk(r),e=Wa(e),e!==null)if(t=yl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=nE(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(hO()){case rk:return 1;case oE:return 4;case Fh:case mO:return 16;case aE:return 536870912;default:return 16}default:return 16}}var Uo=null,ak=null,ph=null;function gE(){if(ph)return ph;var e,t=ak,n=t.length,r,i="value"in Uo?Uo.value:Uo.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===i[o-r];r++);return ph=i.slice(e,1<r?1-r:void 0)}function hh(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function vp(){return!0}function b0(){return!1}function Ss(e){function t(n,r,i,o,a){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?vp:b0,this.isPropagationStopped=b0,this}return Bn(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=vp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=vp)},persist:function(){},isPersistent:vp}),t}var Zc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},lk=Ss(Zc),vf=Bn({},Zc,{view:0,detail:0}),AO=Ss(vf),_y,Cy,zu,qm=Bn({},vf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ck,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!==zu&&(zu&&e.type==="mousemove"?(_y=e.screenX-zu.screenX,Cy=e.screenY-zu.screenY):Cy=_y=0,zu=e),_y)},movementY:function(e){return"movementY"in e?e.movementY:Cy}}),k0=Ss(qm),EO=Bn({},qm,{dataTransfer:0}),IO=Ss(EO),PO=Bn({},vf,{relatedTarget:0}),Ay=Ss(PO),TO=Bn({},Zc,{animationName:0,elapsedTime:0,pseudoElement:0}),RO=Ss(TO),MO=Bn({},Zc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),$O=Ss(MO),LO=Bn({},Zc,{data:0}),v0=Ss(LO),OO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},DO={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"},FO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=FO[e])?!!t[e]:!1}function ck(){return zO}var WO=Bn({},vf,{key:function(e){if(e.key){var t=OO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=hh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?DO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ck,charCode:function(e){return e.type==="keypress"?hh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?hh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),BO=Ss(WO),HO=Bn({},qm,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),S0=Ss(HO),VO=Bn({},vf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ck}),KO=Ss(VO),qO=Bn({},Zc,{propertyName:0,elapsedTime:0,pseudoElement:0}),UO=Ss(qO),GO=Bn({},qm,{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}),YO=Ss(GO),JO=[9,13,27,32],uk=fo&&"CompositionEvent"in window,md=null;fo&&"documentMode"in document&&(md=document.documentMode);var XO=fo&&"TextEvent"in window&&!md,yE=fo&&(!uk||md&&8<md&&11>=md),j0=" ",N0=!1;function wE(e,t){switch(e){case"keyup":return JO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var rc=!1;function QO(e,t){switch(e){case"compositionend":return xE(t);case"keypress":return t.which!==32?null:(N0=!0,j0);case"textInput":return e=t.data,e===j0&&N0?null:e;default:return null}}function ZO(e,t){if(rc)return e==="compositionend"||!uk&&wE(e,t)?(e=gE(),ph=ak=Uo=null,rc=!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 yE&&t.locale!=="ko"?null:t.data;default:return null}}var eD={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 _0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!eD[e.type]:t==="textarea"}function bE(e,t,n,r){XA(r),t=Hh(t,"onChange"),0<t.length&&(n=new lk("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var gd=null,Fd=null;function tD(e){PE(e,0)}function Um(e){var t=oc(e);if(VA(t))return e}function nD(e,t){if(e==="change")return t}var kE=!1;if(fo){var Ey;if(fo){var Iy="oninput"in document;if(!Iy){var C0=document.createElement("div");C0.setAttribute("oninput","return;"),Iy=typeof C0.oninput=="function"}Ey=Iy}else Ey=!1;kE=Ey&&(!document.documentMode||9<document.documentMode)}function A0(){gd&&(gd.detachEvent("onpropertychange",vE),Fd=gd=null)}function vE(e){if(e.propertyName==="value"&&Um(Fd)){var t=[];bE(t,Fd,e,nk(e)),tE(tD,t)}}function rD(e,t,n){e==="focusin"?(A0(),gd=t,Fd=n,gd.attachEvent("onpropertychange",vE)):e==="focusout"&&A0()}function sD(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Um(Fd)}function iD(e,t){if(e==="click")return Um(t)}function oD(e,t){if(e==="input"||e==="change")return Um(t)}function aD(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var fi=typeof Object.is=="function"?Object.is:aD;function zd(e,t){if(fi(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Kw.call(t,i)||!fi(e[i],t[i]))return!1}return!0}function E0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function I0(e,t){var n=E0(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=E0(n)}}function SE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?SE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jE(){for(var e=window,t=Lh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Lh(e.document)}return t}function dk(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 lD(e){var t=jE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&SE(n.ownerDocument.documentElement,n)){if(r!==null&&dk(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 i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=I0(n,o);var a=I0(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var cD=fo&&"documentMode"in document&&11>=document.documentMode,sc=null,ux=null,yd=null,dx=!1;function P0(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;dx||sc==null||sc!==Lh(r)||(r=sc,"selectionStart"in r&&dk(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}),yd&&zd(yd,r)||(yd=r,r=Hh(ux,"onSelect"),0<r.length&&(t=new lk("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sc)))}function Sp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ic={animationend:Sp("Animation","AnimationEnd"),animationiteration:Sp("Animation","AnimationIteration"),animationstart:Sp("Animation","AnimationStart"),transitionend:Sp("Transition","TransitionEnd")},Py={},NE={};fo&&(NE=document.createElement("div").style,"AnimationEvent"in window||(delete ic.animationend.animation,delete ic.animationiteration.animation,delete ic.animationstart.animation),"TransitionEvent"in window||delete ic.transitionend.transition);function Gm(e){if(Py[e])return Py[e];if(!ic[e])return e;var t=ic[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in NE)return Py[e]=t[n];return e}var _E=Gm("animationend"),CE=Gm("animationiteration"),AE=Gm("animationstart"),EE=Gm("transitionend"),IE=new Map,T0="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 ga(e,t){IE.set(e,t),gl(t,[e])}for(var Ty=0;Ty<T0.length;Ty++){var Ry=T0[Ty],uD=Ry.toLowerCase(),dD=Ry[0].toUpperCase()+Ry.slice(1);ga(uD,"on"+dD)}ga(_E,"onAnimationEnd");ga(CE,"onAnimationIteration");ga(AE,"onAnimationStart");ga("dblclick","onDoubleClick");ga("focusin","onFocus");ga("focusout","onBlur");ga(EE,"onTransitionEnd");Rc("onMouseEnter",["mouseout","mouseover"]);Rc("onMouseLeave",["mouseout","mouseover"]);Rc("onPointerEnter",["pointerout","pointerover"]);Rc("onPointerLeave",["pointerout","pointerover"]);gl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));gl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));gl("onBeforeInput",["compositionend","keypress","textInput","paste"]);gl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));gl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));gl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sd="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(" "),fD=new Set("cancel close invalid load scroll toggle".split(" ").concat(sd));function R0(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,uO(r,t,void 0,e),e.currentTarget=null}function PE(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==o&&i.isPropagationStopped())break e;R0(i,l,u),o=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==o&&i.isPropagationStopped())break e;R0(i,l,u),o=c}}}if(Dh)throw e=ox,Dh=!1,ox=null,e}function Cn(e,t){var n=t[gx];n===void 0&&(n=t[gx]=new Set);var r=e+"__bubble";n.has(r)||(TE(t,e,2,!1),n.add(r))}function My(e,t,n){var r=0;t&&(r|=4),TE(n,e,r,t)}var jp="_reactListening"+Math.random().toString(36).slice(2);function Wd(e){if(!e[jp]){e[jp]=!0,FA.forEach(function(n){n!=="selectionchange"&&(fD.has(n)||My(n,!1,e),My(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[jp]||(t[jp]=!0,My("selectionchange",!1,t))}}function TE(e,t,n,r){switch(mE(t)){case 1:var i=_O;break;case 4:i=CO;break;default:i=ok}n=i.bind(null,t,n,e),i=void 0,!ix||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function $y(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.parentNode===i)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;l!==null;){if(a=Wa(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}tE(function(){var u=o,p=nk(n),f=[];e:{var d=IE.get(e);if(d!==void 0){var h=lk,y=e;switch(e){case"keypress":if(hh(n)===0)break e;case"keydown":case"keyup":h=BO;break;case"focusin":y="focus",h=Ay;break;case"focusout":y="blur",h=Ay;break;case"beforeblur":case"afterblur":h=Ay;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=k0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=IO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=KO;break;case _E:case CE:case AE:h=RO;break;case EE:h=UO;break;case"scroll":h=AO;break;case"wheel":h=YO;break;case"copy":case"cut":case"paste":h=$O;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=S0}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?d!==null?d+"Capture":null:d;v=[];for(var k=u,x;k!==null;){x=k;var _=x.stateNode;if(x.tag===5&&_!==null&&(x=_,g!==null&&(_=$d(k,g),_!=null&&v.push(Bd(k,_,x)))),b)break;k=k.return}0<v.length&&(d=new h(d,y,null,n,p),f.push({event:d,listeners:v}))}}if(!(t&7)){e:{if(d=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",d&&n!==rx&&(y=n.relatedTarget||n.fromElement)&&(Wa(y)||y[po]))break e;if((h||d)&&(d=p.window===p?p:(d=p.ownerDocument)?d.defaultView||d.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?Wa(y):null,y!==null&&(b=yl(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=k0,_="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=S0,_="onPointerLeave",g="onPointerEnter",k="pointer"),b=h==null?d:oc(h),x=y==null?d:oc(y),d=new v(_,k+"leave",h,n,p),d.target=b,d.relatedTarget=x,_=null,Wa(p)===u&&(v=new v(g,k+"enter",y,n,p),v.target=x,v.relatedTarget=b,_=v),b=_,h&&y)t:{for(v=h,g=y,k=0,x=v;x;x=Hl(x))k++;for(x=0,_=g;_;_=Hl(_))x++;for(;0<k-x;)v=Hl(v),k--;for(;0<x-k;)g=Hl(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Hl(v),g=Hl(g)}v=null}else v=null;h!==null&&M0(f,d,h,v,!1),y!==null&&b!==null&&M0(f,b,y,v,!0)}}e:{if(d=u?oc(u):window,h=d.nodeName&&d.nodeName.toLowerCase(),h==="select"||h==="input"&&d.type==="file")var S=nD;else if(_0(d))if(kE)S=oD;else{S=sD;var N=rD}else(h=d.nodeName)&&h.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(S=iD);if(S&&(S=S(e,u))){bE(f,S,n,p);break e}N&&N(e,d,u),e==="focusout"&&(N=d._wrapperState)&&N.controlled&&d.type==="number"&&Qw(d,"number",d.value)}switch(N=u?oc(u):window,e){case"focusin":(_0(N)||N.contentEditable==="true")&&(sc=N,ux=u,yd=null);break;case"focusout":yd=ux=sc=null;break;case"mousedown":dx=!0;break;case"contextmenu":case"mouseup":case"dragend":dx=!1,P0(f,n,p);break;case"selectionchange":if(cD)break;case"keydown":case"keyup":P0(f,n,p)}var I;if(uk)e:{switch(e){case"compositionstart":var T="onCompositionStart";break e;case"compositionend":T="onCompositionEnd";break e;case"compositionupdate":T="onCompositionUpdate";break e}T=void 0}else rc?wE(e,n)&&(T="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(T="onCompositionStart");T&&(yE&&n.locale!=="ko"&&(rc||T!=="onCompositionStart"?T==="onCompositionEnd"&&rc&&(I=gE()):(Uo=p,ak="value"in Uo?Uo.value:Uo.textContent,rc=!0)),N=Hh(u,T),0<N.length&&(T=new v0(T,e,null,n,p),f.push({event:T,listeners:N}),I?T.data=I:(I=xE(n),I!==null&&(T.data=I)))),(I=XO?QO(e,n):ZO(e,n))&&(u=Hh(u,"onBeforeInput"),0<u.length&&(p=new v0("onBeforeInput","beforeinput",null,n,p),f.push({event:p,listeners:u}),p.data=I))}PE(f,t)})}function Bd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Hh(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=$d(e,n),o!=null&&r.unshift(Bd(e,o,i)),o=$d(e,t),o!=null&&r.push(Bd(e,o,i))),e=e.return}return r}function Hl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function M0(e,t,n,r,i){for(var o=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,i?(c=$d(n,o),c!=null&&a.unshift(Bd(n,c,l))):i||(c=$d(n,o),c!=null&&a.push(Bd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var pD=/\r\n?/g,hD=/\u0000|\uFFFD/g;function $0(e){return(typeof e=="string"?e:""+e).replace(pD,`
|
|
38
|
+
`).replace(hD,"")}function Np(e,t,n){if(t=$0(t),$0(e)!==t&&n)throw Error(Ie(425))}function Vh(){}var fx=null,px=null;function hx(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 mx=typeof setTimeout=="function"?setTimeout:void 0,mD=typeof clearTimeout=="function"?clearTimeout:void 0,L0=typeof Promise=="function"?Promise:void 0,gD=typeof queueMicrotask=="function"?queueMicrotask:typeof L0<"u"?function(e){return L0.resolve(null).then(e).catch(yD)}:mx;function yD(e){setTimeout(function(){throw e})}function Ly(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),Dd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Dd(t)}function ea(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 O0(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 eu=Math.random().toString(36).slice(2),Ci="__reactFiber$"+eu,Hd="__reactProps$"+eu,po="__reactContainer$"+eu,gx="__reactEvents$"+eu,wD="__reactListeners$"+eu,xD="__reactHandles$"+eu;function Wa(e){var t=e[Ci];if(t)return t;for(var n=e.parentNode;n;){if(t=n[po]||n[Ci]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=O0(e);e!==null;){if(n=e[Ci])return n;e=O0(e)}return t}e=n,n=e.parentNode}return null}function Sf(e){return e=e[Ci]||e[po],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function oc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ie(33))}function Ym(e){return e[Hd]||null}var yx=[],ac=-1;function ya(e){return{current:e}}function En(e){0>ac||(e.current=yx[ac],yx[ac]=null,ac--)}function xn(e,t){ac++,yx[ac]=e.current,e.current=t}var la={},Lr=ya(la),ss=ya(!1),el=la;function Mc(e,t){var n=e.type.contextTypes;if(!n)return la;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function is(e){return e=e.childContextTypes,e!=null}function Kh(){En(ss),En(Lr)}function D0(e,t,n){if(Lr.current!==la)throw Error(Ie(168));xn(Lr,t),xn(ss,n)}function RE(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Ie(108,rO(e)||"Unknown",i));return Bn({},n,r)}function qh(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||la,el=Lr.current,xn(Lr,e),xn(ss,ss.current),!0}function F0(e,t,n){var r=e.stateNode;if(!r)throw Error(Ie(169));n?(e=RE(e,t,el),r.__reactInternalMemoizedMergedChildContext=e,En(ss),En(Lr),xn(Lr,e)):En(ss),xn(ss,n)}var eo=null,Jm=!1,Oy=!1;function ME(e){eo===null?eo=[e]:eo.push(e)}function bD(e){Jm=!0,ME(e)}function wa(){if(!Oy&&eo!==null){Oy=!0;var e=0,t=un;try{var n=eo;for(un=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}eo=null,Jm=!1}catch(i){throw eo!==null&&(eo=eo.slice(e+1)),iE(rk,wa),i}finally{un=t,Oy=!1}}return null}var lc=[],cc=0,Uh=null,Gh=0,Ms=[],$s=0,tl=null,no=1,ro="";function Ma(e,t){lc[cc++]=Gh,lc[cc++]=Uh,Uh=e,Gh=t}function $E(e,t,n){Ms[$s++]=no,Ms[$s++]=ro,Ms[$s++]=tl,tl=e;var r=no;e=ro;var i=32-ci(r)-1;r&=~(1<<i),n+=1;var o=32-ci(t)+i;if(30<o){var a=i-i%5;o=(r&(1<<a)-1).toString(32),r>>=a,i-=a,no=1<<32-ci(t)+i|n<<i|r,ro=o+e}else no=1<<o|n<<i|r,ro=e}function fk(e){e.return!==null&&(Ma(e,1),$E(e,1,0))}function pk(e){for(;e===Uh;)Uh=lc[--cc],lc[cc]=null,Gh=lc[--cc],lc[cc]=null;for(;e===tl;)tl=Ms[--$s],Ms[$s]=null,ro=Ms[--$s],Ms[$s]=null,no=Ms[--$s],Ms[$s]=null}var ws=null,gs=null,Pn=!1,si=null;function LE(e,t){var n=Ds(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function z0(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,ws=e,gs=ea(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ws=e,gs=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=tl!==null?{id:no,overflow:ro}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ds(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,ws=e,gs=null,!0):!1;default:return!1}}function wx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function xx(e){if(Pn){var t=gs;if(t){var n=t;if(!z0(e,t)){if(wx(e))throw Error(Ie(418));t=ea(n.nextSibling);var r=ws;t&&z0(e,t)?LE(r,n):(e.flags=e.flags&-4097|2,Pn=!1,ws=e)}}else{if(wx(e))throw Error(Ie(418));e.flags=e.flags&-4097|2,Pn=!1,ws=e}}}function W0(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ws=e}function _p(e){if(e!==ws)return!1;if(!Pn)return W0(e),Pn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!hx(e.type,e.memoizedProps)),t&&(t=gs)){if(wx(e))throw OE(),Error(Ie(418));for(;t;)LE(e,t),t=ea(t.nextSibling)}if(W0(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Ie(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){gs=ea(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}gs=null}}else gs=ws?ea(e.stateNode.nextSibling):null;return!0}function OE(){for(var e=gs;e;)e=ea(e.nextSibling)}function $c(){gs=ws=null,Pn=!1}function hk(e){si===null?si=[e]:si.push(e)}var kD=bo.ReactCurrentBatchConfig;function Wu(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Ie(309));var r=n.stateNode}if(!r)throw Error(Ie(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=i.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Ie(284));if(!n._owner)throw Error(Ie(290,e))}return e}function Cp(e,t){throw e=Object.prototype.toString.call(t),Error(Ie(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function B0(e){var t=e._init;return t(e._payload)}function DE(e){function t(g,k){if(e){var x=g.deletions;x===null?(g.deletions=[k],g.flags|=16):x.push(k)}}function n(g,k){if(!e)return null;for(;k!==null;)t(g,k),k=k.sibling;return null}function r(g,k){for(g=new Map;k!==null;)k.key!==null?g.set(k.key,k):g.set(k.index,k),k=k.sibling;return g}function i(g,k){return g=sa(g,k),g.index=0,g.sibling=null,g}function o(g,k,x){return g.index=x,e?(x=g.alternate,x!==null?(x=x.index,x<k?(g.flags|=2,k):x):(g.flags|=2,k)):(g.flags|=1048576,k)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,k,x,_){return k===null||k.tag!==6?(k=Vy(x,g.mode,_),k.return=g,k):(k=i(k,x),k.return=g,k)}function c(g,k,x,_){var S=x.type;return S===nc?p(g,k,x.props.children,_,x.key):k!==null&&(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Fo&&B0(S)===k.type)?(_=i(k,x.props),_.ref=Wu(g,k,x),_.return=g,_):(_=kh(x.type,x.key,x.props,null,g.mode,_),_.ref=Wu(g,k,x),_.return=g,_)}function u(g,k,x,_){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=Ky(x,g.mode,_),k.return=g,k):(k=i(k,x.children||[]),k.return=g,k)}function p(g,k,x,_,S){return k===null||k.tag!==7?(k=Ga(x,g.mode,_,S),k.return=g,k):(k=i(k,x),k.return=g,k)}function f(g,k,x){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Vy(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case gp:return x=kh(k.type,k.key,k.props,null,g.mode,x),x.ref=Wu(g,null,k),x.return=g,x;case tc:return k=Ky(k,g.mode,x),k.return=g,k;case Fo:var _=k._init;return f(g,_(k._payload),x)}if(nd(k)||Lu(k))return k=Ga(k,g.mode,x,null),k.return=g,k;Cp(g,k)}return null}function d(g,k,x,_){var S=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return S!==null?null:l(g,k,""+x,_);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case gp:return x.key===S?c(g,k,x,_):null;case tc:return x.key===S?u(g,k,x,_):null;case Fo:return S=x._init,d(g,k,S(x._payload),_)}if(nd(x)||Lu(x))return S!==null?null:p(g,k,x,_,null);Cp(g,x)}return null}function h(g,k,x,_,S){if(typeof _=="string"&&_!==""||typeof _=="number")return g=g.get(x)||null,l(k,g,""+_,S);if(typeof _=="object"&&_!==null){switch(_.$$typeof){case gp:return g=g.get(_.key===null?x:_.key)||null,c(k,g,_,S);case tc:return g=g.get(_.key===null?x:_.key)||null,u(k,g,_,S);case Fo:var N=_._init;return h(g,k,x,N(_._payload),S)}if(nd(_)||Lu(_))return g=g.get(x)||null,p(k,g,_,S,null);Cp(k,_)}return null}function y(g,k,x,_){for(var S=null,N=null,I=k,T=k=0,z=null;I!==null&&T<x.length;T++){I.index>T?(z=I,I=null):z=I.sibling;var E=d(g,I,x[T],_);if(E===null){I===null&&(I=z);break}e&&I&&E.alternate===null&&t(g,I),k=o(E,k,T),N===null?S=E:N.sibling=E,N=E,I=z}if(T===x.length)return n(g,I),Pn&&Ma(g,T),S;if(I===null){for(;T<x.length;T++)I=f(g,x[T],_),I!==null&&(k=o(I,k,T),N===null?S=I:N.sibling=I,N=I);return Pn&&Ma(g,T),S}for(I=r(g,I);T<x.length;T++)z=h(I,g,T,x[T],_),z!==null&&(e&&z.alternate!==null&&I.delete(z.key===null?T:z.key),k=o(z,k,T),N===null?S=z:N.sibling=z,N=z);return e&&I.forEach(function(O){return t(g,O)}),Pn&&Ma(g,T),S}function v(g,k,x,_){var S=Lu(x);if(typeof S!="function")throw Error(Ie(150));if(x=S.call(x),x==null)throw Error(Ie(151));for(var N=S=null,I=k,T=k=0,z=null,E=x.next();I!==null&&!E.done;T++,E=x.next()){I.index>T?(z=I,I=null):z=I.sibling;var O=d(g,I,E.value,_);if(O===null){I===null&&(I=z);break}e&&I&&O.alternate===null&&t(g,I),k=o(O,k,T),N===null?S=O:N.sibling=O,N=O,I=z}if(E.done)return n(g,I),Pn&&Ma(g,T),S;if(I===null){for(;!E.done;T++,E=x.next())E=f(g,E.value,_),E!==null&&(k=o(E,k,T),N===null?S=E:N.sibling=E,N=E);return Pn&&Ma(g,T),S}for(I=r(g,I);!E.done;T++,E=x.next())E=h(I,g,T,E.value,_),E!==null&&(e&&E.alternate!==null&&I.delete(E.key===null?T:E.key),k=o(E,k,T),N===null?S=E:N.sibling=E,N=E);return e&&I.forEach(function(D){return t(g,D)}),Pn&&Ma(g,T),S}function b(g,k,x,_){if(typeof x=="object"&&x!==null&&x.type===nc&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case gp:e:{for(var S=x.key,N=k;N!==null;){if(N.key===S){if(S=x.type,S===nc){if(N.tag===7){n(g,N.sibling),k=i(N,x.props.children),k.return=g,g=k;break e}}else if(N.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Fo&&B0(S)===N.type){n(g,N.sibling),k=i(N,x.props),k.ref=Wu(g,N,x),k.return=g,g=k;break e}n(g,N);break}else t(g,N);N=N.sibling}x.type===nc?(k=Ga(x.props.children,g.mode,_,x.key),k.return=g,g=k):(_=kh(x.type,x.key,x.props,null,g.mode,_),_.ref=Wu(g,k,x),_.return=g,g=_)}return a(g);case tc:e:{for(N=x.key;k!==null;){if(k.key===N)if(k.tag===4&&k.stateNode.containerInfo===x.containerInfo&&k.stateNode.implementation===x.implementation){n(g,k.sibling),k=i(k,x.children||[]),k.return=g,g=k;break e}else{n(g,k);break}else t(g,k);k=k.sibling}k=Ky(x,g.mode,_),k.return=g,g=k}return a(g);case Fo:return N=x._init,b(g,k,N(x._payload),_)}if(nd(x))return y(g,k,x,_);if(Lu(x))return v(g,k,x,_);Cp(g,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,k!==null&&k.tag===6?(n(g,k.sibling),k=i(k,x),k.return=g,g=k):(n(g,k),k=Vy(x,g.mode,_),k.return=g,g=k),a(g)):n(g,k)}return b}var Lc=DE(!0),FE=DE(!1),Yh=ya(null),Jh=null,uc=null,mk=null;function gk(){mk=uc=Jh=null}function yk(e){var t=Yh.current;En(Yh),e._currentValue=t}function bx(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 Sc(e,t){Jh=e,mk=uc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ts=!0),e.firstContext=null)}function zs(e){var t=e._currentValue;if(mk!==e)if(e={context:e,memoizedValue:t,next:null},uc===null){if(Jh===null)throw Error(Ie(308));uc=e,Jh.dependencies={lanes:0,firstContext:e}}else uc=uc.next=e;return t}var Ba=null;function wk(e){Ba===null?Ba=[e]:Ba.push(e)}function zE(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,wk(t)):(n.next=i.next,i.next=n),t.interleaved=n,ho(e,r)}function ho(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 zo=!1;function xk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function WE(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 ao(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ta(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Zt&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,ho(e,n)}return i=r.interleaved,i===null?(t.next=t,wk(r)):(t.next=i.next,i.next=t),r.interleaved=t,ho(e,n)}function mh(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sk(e,n)}}function H0(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Xh(e,t,n,r){var i=e.updateQueue;zo=!1;var o=i.firstBaseUpdate,a=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?o=u:a.next=u,a=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==a&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(o!==null){var f=i.baseState;a=0,p=u=c=null,l=o;do{var d=l.lane,h=l.eventTime;if((r&d)===d){p!==null&&(p=p.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(d=t,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){f=y.call(h,f,d);break e}f=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,d=typeof y=="function"?y.call(h,f,d):y,d==null)break e;f=Bn({},f,d);break e;case 2:zo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=h,c=f):p=p.next=h,a|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(p===null&&(c=f),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=p,t=i.shared.interleaved,t!==null){i=t;do a|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);rl|=a,e.lanes=a,e.memoizedState=f}}function V0(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(Ie(191,i));i.call(r)}}}var jf={},Mi=ya(jf),Vd=ya(jf),Kd=ya(jf);function Ha(e){if(e===jf)throw Error(Ie(174));return e}function bk(e,t){switch(xn(Kd,t),xn(Vd,e),xn(Mi,jf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:ex(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=ex(t,e)}En(Mi),xn(Mi,t)}function Oc(){En(Mi),En(Vd),En(Kd)}function BE(e){Ha(Kd.current);var t=Ha(Mi.current),n=ex(t,e.type);t!==n&&(xn(Vd,e),xn(Mi,n))}function kk(e){Vd.current===e&&(En(Mi),En(Vd))}var Fn=ya(0);function Qh(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 Dy=[];function vk(){for(var e=0;e<Dy.length;e++)Dy[e]._workInProgressVersionPrimary=null;Dy.length=0}var gh=bo.ReactCurrentDispatcher,Fy=bo.ReactCurrentBatchConfig,nl=0,Wn=null,dr=null,xr=null,Zh=!1,wd=!1,qd=0,vD=0;function Pr(){throw Error(Ie(321))}function Sk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!fi(e[n],t[n]))return!1;return!0}function jk(e,t,n,r,i,o){if(nl=o,Wn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,gh.current=e===null||e.memoizedState===null?_D:CD,e=n(r,i),wd){o=0;do{if(wd=!1,qd=0,25<=o)throw Error(Ie(301));o+=1,xr=dr=null,t.updateQueue=null,gh.current=AD,e=n(r,i)}while(wd)}if(gh.current=em,t=dr!==null&&dr.next!==null,nl=0,xr=dr=Wn=null,Zh=!1,t)throw Error(Ie(300));return e}function Nk(){var e=qd!==0;return qd=0,e}function Si(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xr===null?Wn.memoizedState=xr=e:xr=xr.next=e,xr}function Ws(){if(dr===null){var e=Wn.alternate;e=e!==null?e.memoizedState:null}else e=dr.next;var t=xr===null?Wn.memoizedState:xr.next;if(t!==null)xr=t,dr=e;else{if(e===null)throw Error(Ie(310));dr=e,e={memoizedState:dr.memoizedState,baseState:dr.baseState,baseQueue:dr.baseQueue,queue:dr.queue,next:null},xr===null?Wn.memoizedState=xr=e:xr=xr.next=e}return xr}function Ud(e,t){return typeof t=="function"?t(e):t}function zy(e){var t=Ws(),n=t.queue;if(n===null)throw Error(Ie(311));n.lastRenderedReducer=e;var r=dr,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var a=i.next;i.next=o.next,o.next=a}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var l=a=null,c=null,u=o;do{var p=u.lane;if((nl&p)===p)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:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,Wn.lanes|=p,rl|=p}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,fi(r,t.memoizedState)||(ts=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,Wn.lanes|=o,rl|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Wy(e){var t=Ws(),n=t.queue;if(n===null)throw Error(Ie(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var a=i=i.next;do o=e(o,a.action),a=a.next;while(a!==i);fi(o,t.memoizedState)||(ts=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function HE(){}function VE(e,t){var n=Wn,r=Ws(),i=t(),o=!fi(r.memoizedState,i);if(o&&(r.memoizedState=i,ts=!0),r=r.queue,_k(UE.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||xr!==null&&xr.memoizedState.tag&1){if(n.flags|=2048,Gd(9,qE.bind(null,n,r,i,t),void 0,null),vr===null)throw Error(Ie(349));nl&30||KE(n,t,i)}return i}function KE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Wn.updateQueue,t===null?(t={lastEffect:null,stores:null},Wn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function qE(e,t,n,r){t.value=n,t.getSnapshot=r,GE(t)&&YE(e)}function UE(e,t,n){return n(function(){GE(t)&&YE(e)})}function GE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!fi(e,n)}catch{return!0}}function YE(e){var t=ho(e,1);t!==null&&ui(t,e,1,-1)}function K0(e){var t=Si();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ud,lastRenderedState:e},t.queue=e,e=e.dispatch=ND.bind(null,Wn,e),[t.memoizedState,e]}function Gd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Wn.updateQueue,t===null?(t={lastEffect:null,stores:null},Wn.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 JE(){return Ws().memoizedState}function yh(e,t,n,r){var i=Si();Wn.flags|=e,i.memoizedState=Gd(1|t,n,void 0,r===void 0?null:r)}function Xm(e,t,n,r){var i=Ws();r=r===void 0?null:r;var o=void 0;if(dr!==null){var a=dr.memoizedState;if(o=a.destroy,r!==null&&Sk(r,a.deps)){i.memoizedState=Gd(t,n,o,r);return}}Wn.flags|=e,i.memoizedState=Gd(1|t,n,o,r)}function q0(e,t){return yh(8390656,8,e,t)}function _k(e,t){return Xm(2048,8,e,t)}function XE(e,t){return Xm(4,2,e,t)}function QE(e,t){return Xm(4,4,e,t)}function ZE(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 eI(e,t,n){return n=n!=null?n.concat([e]):null,Xm(4,4,ZE.bind(null,t,e),n)}function Ck(){}function tI(e,t){var n=Ws();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Sk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function nI(e,t){var n=Ws();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Sk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function rI(e,t,n){return nl&21?(fi(n,t)||(n=lE(),Wn.lanes|=n,rl|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ts=!0),e.memoizedState=n)}function SD(e,t){var n=un;un=n!==0&&4>n?n:4,e(!0);var r=Fy.transition;Fy.transition={};try{e(!1),t()}finally{un=n,Fy.transition=r}}function sI(){return Ws().memoizedState}function jD(e,t,n){var r=ra(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},iI(e))oI(t,n);else if(n=zE(e,t,n,r),n!==null){var i=Vr();ui(n,e,r,i),aI(n,t,r)}}function ND(e,t,n){var r=ra(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(iI(e))oI(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,l=o(a,n);if(i.hasEagerState=!0,i.eagerState=l,fi(l,a)){var c=t.interleaved;c===null?(i.next=i,wk(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=zE(e,t,i,r),n!==null&&(i=Vr(),ui(n,e,r,i),aI(n,t,r))}}function iI(e){var t=e.alternate;return e===Wn||t!==null&&t===Wn}function oI(e,t){wd=Zh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function aI(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sk(e,n)}}var em={readContext:zs,useCallback:Pr,useContext:Pr,useEffect:Pr,useImperativeHandle:Pr,useInsertionEffect:Pr,useLayoutEffect:Pr,useMemo:Pr,useReducer:Pr,useRef:Pr,useState:Pr,useDebugValue:Pr,useDeferredValue:Pr,useTransition:Pr,useMutableSource:Pr,useSyncExternalStore:Pr,useId:Pr,unstable_isNewReconciler:!1},_D={readContext:zs,useCallback:function(e,t){return Si().memoizedState=[e,t===void 0?null:t],e},useContext:zs,useEffect:q0,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,yh(4194308,4,ZE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return yh(4194308,4,e,t)},useInsertionEffect:function(e,t){return yh(4,2,e,t)},useMemo:function(e,t){var n=Si();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Si();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=jD.bind(null,Wn,e),[r.memoizedState,e]},useRef:function(e){var t=Si();return e={current:e},t.memoizedState=e},useState:K0,useDebugValue:Ck,useDeferredValue:function(e){return Si().memoizedState=e},useTransition:function(){var e=K0(!1),t=e[0];return e=SD.bind(null,e[1]),Si().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Wn,i=Si();if(Pn){if(n===void 0)throw Error(Ie(407));n=n()}else{if(n=t(),vr===null)throw Error(Ie(349));nl&30||KE(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,q0(UE.bind(null,r,o,e),[e]),r.flags|=2048,Gd(9,qE.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Si(),t=vr.identifierPrefix;if(Pn){var n=ro,r=no;n=(r&~(1<<32-ci(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=vD++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},CD={readContext:zs,useCallback:tI,useContext:zs,useEffect:_k,useImperativeHandle:eI,useInsertionEffect:XE,useLayoutEffect:QE,useMemo:nI,useReducer:zy,useRef:JE,useState:function(){return zy(Ud)},useDebugValue:Ck,useDeferredValue:function(e){var t=Ws();return rI(t,dr.memoizedState,e)},useTransition:function(){var e=zy(Ud)[0],t=Ws().memoizedState;return[e,t]},useMutableSource:HE,useSyncExternalStore:VE,useId:sI,unstable_isNewReconciler:!1},AD={readContext:zs,useCallback:tI,useContext:zs,useEffect:_k,useImperativeHandle:eI,useInsertionEffect:XE,useLayoutEffect:QE,useMemo:nI,useReducer:Wy,useRef:JE,useState:function(){return Wy(Ud)},useDebugValue:Ck,useDeferredValue:function(e){var t=Ws();return dr===null?t.memoizedState=e:rI(t,dr.memoizedState,e)},useTransition:function(){var e=Wy(Ud)[0],t=Ws().memoizedState;return[e,t]},useMutableSource:HE,useSyncExternalStore:VE,useId:sI,unstable_isNewReconciler:!1};function ti(e,t){if(e&&e.defaultProps){t=Bn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function kx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Bn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Qm={isMounted:function(e){return(e=e._reactInternals)?yl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Vr(),i=ra(e),o=ao(r,i);o.payload=t,n!=null&&(o.callback=n),t=ta(e,o,i),t!==null&&(ui(t,e,i,r),mh(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Vr(),i=ra(e),o=ao(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=ta(e,o,i),t!==null&&(ui(t,e,i,r),mh(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Vr(),r=ra(e),i=ao(n,r);i.tag=2,t!=null&&(i.callback=t),t=ta(e,i,r),t!==null&&(ui(t,e,r,n),mh(t,e,r))}};function U0(e,t,n,r,i,o,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,a):t.prototype&&t.prototype.isPureReactComponent?!zd(n,r)||!zd(i,o):!0}function lI(e,t,n){var r=!1,i=la,o=t.contextType;return typeof o=="object"&&o!==null?o=zs(o):(i=is(t)?el:Lr.current,r=t.contextTypes,o=(r=r!=null)?Mc(e,i):la),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Qm,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function G0(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&&Qm.enqueueReplaceState(t,t.state,null)}function vx(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},xk(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=zs(o):(o=is(t)?el:Lr.current,i.context=Mc(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(kx(e,t,o,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Qm.enqueueReplaceState(i,i.state,null),Xh(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Dc(e,t){try{var n="",r=t;do n+=nO(r),r=r.return;while(r);var i=n}catch(o){i=`
|
|
39
|
+
Error generating stack: `+o.message+`
|
|
40
|
+
`+o.stack}return{value:e,source:t,stack:i,digest:null}}function By(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Sx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var ED=typeof WeakMap=="function"?WeakMap:Map;function cI(e,t,n){n=ao(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){nm||(nm=!0,Rx=r),Sx(e,t)},n}function uI(e,t,n){n=ao(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Sx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Sx(e,t),typeof r!="function"&&(na===null?na=new Set([this]):na.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Y0(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new ED;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=HD.bind(null,e,t,n),t.then(e,e))}function J0(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 X0(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,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=ao(-1,1),t.tag=2,ta(n,t,1))),n.lanes|=1),e)}var ID=bo.ReactCurrentOwner,ts=!1;function Hr(e,t,n,r){t.child=e===null?FE(t,null,n,r):Lc(t,e.child,n,r)}function Q0(e,t,n,r,i){n=n.render;var o=t.ref;return Sc(t,i),r=jk(e,t,n,r,o,i),n=Nk(),e!==null&&!ts?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,mo(e,t,i)):(Pn&&n&&fk(t),t.flags|=1,Hr(e,t,r,i),t.child)}function Z0(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!$k(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,dI(e,t,o,r,i)):(e=kh(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:zd,n(a,r)&&e.ref===t.ref)return mo(e,t,i)}return t.flags|=1,e=sa(o,r),e.ref=t.ref,e.return=t,t.child=e}function dI(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(zd(o,r)&&e.ref===t.ref)if(ts=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(ts=!0);else return t.lanes=e.lanes,mo(e,t,i)}return jx(e,t,n,r,i)}function fI(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},xn(fc,ps),ps|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,xn(fc,ps),ps|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,xn(fc,ps),ps|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,xn(fc,ps),ps|=r;return Hr(e,t,i,n),t.child}function pI(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function jx(e,t,n,r,i){var o=is(n)?el:Lr.current;return o=Mc(t,o),Sc(t,i),n=jk(e,t,n,r,o,i),r=Nk(),e!==null&&!ts?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,mo(e,t,i)):(Pn&&r&&fk(t),t.flags|=1,Hr(e,t,n,i),t.child)}function eN(e,t,n,r,i){if(is(n)){var o=!0;qh(t)}else o=!1;if(Sc(t,i),t.stateNode===null)wh(e,t),lI(t,n,r),vx(t,n,r,i),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=zs(u):(u=is(n)?el:Lr.current,u=Mc(t,u));var p=n.getDerivedStateFromProps,f=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&G0(t,a,r,u),zo=!1;var d=t.memoizedState;a.state=d,Xh(t,r,a,i),c=t.memoizedState,l!==r||d!==c||ss.current||zo?(typeof p=="function"&&(kx(t,n,p,r),c=t.memoizedState),(l=zo||U0(t,n,l,r,d,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,WE(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:ti(t.type,l),a.props=u,f=t.pendingProps,d=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=zs(c):(c=is(n)?el:Lr.current,c=Mc(t,c));var h=n.getDerivedStateFromProps;(p=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||d!==c)&&G0(t,a,r,c),zo=!1,d=t.memoizedState,a.state=d,Xh(t,r,a,i);var y=t.memoizedState;l!==f||d!==y||ss.current||zo?(typeof h=="function"&&(kx(t,n,h,r),y=t.memoizedState),(u=zo||U0(t,n,u,r,d,y,c)||!1)?(p||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,y,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,y,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),a.props=r,a.state=y,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Nx(e,t,n,r,o,i)}function Nx(e,t,n,r,i,o){pI(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return i&&F0(t,n,!1),mo(e,t,o);r=t.stateNode,ID.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Lc(t,e.child,null,o),t.child=Lc(t,null,l,o)):Hr(e,t,l,o),t.memoizedState=r.state,i&&F0(t,n,!0),t.child}function hI(e){var t=e.stateNode;t.pendingContext?D0(e,t.pendingContext,t.pendingContext!==t.context):t.context&&D0(e,t.context,!1),bk(e,t.containerInfo)}function tN(e,t,n,r,i){return $c(),hk(i),t.flags|=256,Hr(e,t,n,r),t.child}var _x={dehydrated:null,treeContext:null,retryLane:0};function Cx(e){return{baseLanes:e,cachePool:null,transitions:null}}function mI(e,t,n){var r=t.pendingProps,i=Fn.current,o=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),xn(Fn,i&1),e===null)return xx(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=tg(a,r,0,null),e=Ga(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Cx(n),t.memoizedState=_x,e):Ak(t,a));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return PD(e,t,a,r,l,i,n);if(o){o=r.fallback,a=t.mode,i=e.child,l=i.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=sa(i,c),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?o=sa(l,o):(o=Ga(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?Cx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=_x,r}return o=e.child,e=o.sibling,r=sa(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ak(e,t){return t=tg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ap(e,t,n,r){return r!==null&&hk(r),Lc(t,e.child,null,n),e=Ak(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function PD(e,t,n,r,i,o,a){if(n)return t.flags&256?(t.flags&=-257,r=By(Error(Ie(422))),Ap(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=tg({mode:"visible",children:r.children},i,0,null),o=Ga(o,i,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Lc(t,e.child,null,a),t.child.memoizedState=Cx(a),t.memoizedState=_x,o);if(!(t.mode&1))return Ap(e,t,a,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Ie(419)),r=By(o,r,void 0),Ap(e,t,a,r)}if(l=(a&e.childLanes)!==0,ts||l){if(r=vr,r!==null){switch(a&-a){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|a)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,ho(e,i),ui(r,e,i,-1))}return Mk(),r=By(Error(Ie(421))),Ap(e,t,a,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=VD.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,gs=ea(i.nextSibling),ws=t,Pn=!0,si=null,e!==null&&(Ms[$s++]=no,Ms[$s++]=ro,Ms[$s++]=tl,no=e.id,ro=e.overflow,tl=t),t=Ak(t,r.children),t.flags|=4096,t)}function nN(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),bx(e.return,t,n)}function Hy(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function gI(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(Hr(e,t,r.children,n),r=Fn.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&&nN(e,n,t);else if(e.tag===19)nN(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(xn(Fn,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Qh(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Hy(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Qh(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Hy(t,!0,n,null,o);break;case"together":Hy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function wh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function mo(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),rl|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ie(153));if(t.child!==null){for(e=t.child,n=sa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function TD(e,t,n){switch(t.tag){case 3:hI(t),$c();break;case 5:BE(t);break;case 1:is(t.type)&&qh(t);break;case 4:bk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;xn(Yh,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(xn(Fn,Fn.current&1),t.flags|=128,null):n&t.child.childLanes?mI(e,t,n):(xn(Fn,Fn.current&1),e=mo(e,t,n),e!==null?e.sibling:null);xn(Fn,Fn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return gI(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),xn(Fn,Fn.current),r)break;return null;case 22:case 23:return t.lanes=0,fI(e,t,n)}return mo(e,t,n)}var yI,Ax,wI,xI;yI=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}};Ax=function(){};wI=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ha(Mi.current);var o=null;switch(n){case"input":i=Jw(e,i),r=Jw(e,r),o=[];break;case"select":i=Bn({},i,{value:void 0}),r=Bn({},r,{value:void 0}),o=[];break;case"textarea":i=Zw(e,i),r=Zw(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Vh)}tx(n,r);var a;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Rd.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Rd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Cn("scroll",e),o||l===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};xI=function(e,t,n,r){n!==r&&(t.flags|=4)};function Bu(e,t){if(!Pn)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 Tr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function RD(e,t,n){var r=t.pendingProps;switch(pk(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tr(t),null;case 1:return is(t.type)&&Kh(),Tr(t),null;case 3:return r=t.stateNode,Oc(),En(ss),En(Lr),vk(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(_p(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,si!==null&&(Lx(si),si=null))),Ax(e,t),Tr(t),null;case 5:kk(t);var i=Ha(Kd.current);if(n=t.type,e!==null&&t.stateNode!=null)wI(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Ie(166));return Tr(t),null}if(e=Ha(Mi.current),_p(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Ci]=t,r[Hd]=o,e=(t.mode&1)!==0,n){case"dialog":Cn("cancel",r),Cn("close",r);break;case"iframe":case"object":case"embed":Cn("load",r);break;case"video":case"audio":for(i=0;i<sd.length;i++)Cn(sd[i],r);break;case"source":Cn("error",r);break;case"img":case"image":case"link":Cn("error",r),Cn("load",r);break;case"details":Cn("toggle",r);break;case"input":d0(r,o),Cn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},Cn("invalid",r);break;case"textarea":p0(r,o),Cn("invalid",r)}tx(n,o),i=null;for(var a in o)if(o.hasOwnProperty(a)){var l=o[a];a==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&Np(r.textContent,l,e),i=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&Np(r.textContent,l,e),i=["children",""+l]):Rd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Cn("scroll",r)}switch(n){case"input":yp(r),f0(r,o,!0);break;case"textarea":yp(r),h0(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Vh)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=UA(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[Ci]=t,e[Hd]=r,yI(e,t,!1,!1),t.stateNode=e;e:{switch(a=nx(n,r),n){case"dialog":Cn("cancel",e),Cn("close",e),i=r;break;case"iframe":case"object":case"embed":Cn("load",e),i=r;break;case"video":case"audio":for(i=0;i<sd.length;i++)Cn(sd[i],e);i=r;break;case"source":Cn("error",e),i=r;break;case"img":case"image":case"link":Cn("error",e),Cn("load",e),i=r;break;case"details":Cn("toggle",e),i=r;break;case"input":d0(e,r),i=Jw(e,r),Cn("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=Bn({},r,{value:void 0}),Cn("invalid",e);break;case"textarea":p0(e,r),i=Zw(e,r),Cn("invalid",e);break;default:i=r}tx(n,i),l=i;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?JA(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&GA(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Md(e,c):typeof c=="number"&&Md(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Rd.hasOwnProperty(o)?c!=null&&o==="onScroll"&&Cn("scroll",e):c!=null&&Qb(e,o,c,a))}switch(n){case"input":yp(e),f0(e,r,!1);break;case"textarea":yp(e),h0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+aa(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?xc(e,!!r.multiple,o,!1):r.defaultValue!=null&&xc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.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 Tr(t),null;case 6:if(e&&t.stateNode!=null)xI(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ie(166));if(n=Ha(Kd.current),Ha(Mi.current),_p(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ci]=t,(o=r.nodeValue!==n)&&(e=ws,e!==null))switch(e.tag){case 3:Np(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Np(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ci]=t,t.stateNode=r}return Tr(t),null;case 13:if(En(Fn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Pn&&gs!==null&&t.mode&1&&!(t.flags&128))OE(),$c(),t.flags|=98560,o=!1;else if(o=_p(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Ie(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Ie(317));o[Ci]=t}else $c(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Tr(t),o=!1}else si!==null&&(Lx(si),si=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Fn.current&1?fr===0&&(fr=3):Mk())),t.updateQueue!==null&&(t.flags|=4),Tr(t),null);case 4:return Oc(),Ax(e,t),e===null&&Wd(t.stateNode.containerInfo),Tr(t),null;case 10:return yk(t.type._context),Tr(t),null;case 17:return is(t.type)&&Kh(),Tr(t),null;case 19:if(En(Fn),o=t.memoizedState,o===null)return Tr(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Bu(o,!1);else{if(fr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Qh(e),a!==null){for(t.flags|=128,Bu(o,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,e=a.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return xn(Fn,Fn.current&1|2),t.child}e=e.sibling}o.tail!==null&&er()>Fc&&(t.flags|=128,r=!0,Bu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Qh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Bu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!Pn)return Tr(t),null}else 2*er()-o.renderingStartTime>Fc&&n!==1073741824&&(t.flags|=128,r=!0,Bu(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=er(),t.sibling=null,n=Fn.current,xn(Fn,r?n&1|2:n&1),t):(Tr(t),null);case 22:case 23:return Rk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ps&1073741824&&(Tr(t),t.subtreeFlags&6&&(t.flags|=8192)):Tr(t),null;case 24:return null;case 25:return null}throw Error(Ie(156,t.tag))}function MD(e,t){switch(pk(t),t.tag){case 1:return is(t.type)&&Kh(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Oc(),En(ss),En(Lr),vk(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kk(t),null;case 13:if(En(Fn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ie(340));$c()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return En(Fn),null;case 4:return Oc(),null;case 10:return yk(t.type._context),null;case 22:case 23:return Rk(),null;case 24:return null;default:return null}}var Ep=!1,Rr=!1,$D=typeof WeakSet=="function"?WeakSet:Set,et=null;function dc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Un(e,t,r)}else n.current=null}function Ex(e,t,n){try{n()}catch(r){Un(e,t,r)}}var rN=!1;function LD(e,t){if(fx=Wh,e=jE(),dk(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 i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,u=0,p=0,f=e,d=null;t:for(;;){for(var h;f!==n||i!==0&&f.nodeType!==3||(l=a+i),f!==o||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===e)break t;if(d===n&&++u===i&&(l=a),d===o&&++p===r&&(c=a),(h=f.nextSibling)!==null)break;f=d,d=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(px={focusedElem:e,selectionRange:n},Wh=!1,et=t;et!==null;)if(t=et,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,et=e;else for(;et!==null;){t=et;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,b=y.memoizedState,g=t.stateNode,k=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:ti(t.type,v),b);g.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ie(163))}}catch(_){Un(t,t.return,_)}if(e=t.sibling,e!==null){e.return=t.return,et=e;break}et=t.return}return y=rN,rN=!1,y}function xd(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&Ex(t,n,o)}i=i.next}while(i!==r)}}function Zm(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 Ix(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 bI(e){var t=e.alternate;t!==null&&(e.alternate=null,bI(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ci],delete t[Hd],delete t[gx],delete t[wD],delete t[xD])),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 kI(e){return e.tag===5||e.tag===3||e.tag===4}function sN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kI(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 Px(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(Px(e,t,n),e=e.sibling;e!==null;)Px(e,t,n),e=e.sibling}function Tx(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(Tx(e,t,n),e=e.sibling;e!==null;)Tx(e,t,n),e=e.sibling}var _r=null,ni=!1;function To(e,t,n){for(n=n.child;n!==null;)vI(e,t,n),n=n.sibling}function vI(e,t,n){if(Ri&&typeof Ri.onCommitFiberUnmount=="function")try{Ri.onCommitFiberUnmount(Km,n)}catch{}switch(n.tag){case 5:Rr||dc(n,t);case 6:var r=_r,i=ni;_r=null,To(e,t,n),_r=r,ni=i,_r!==null&&(ni?(e=_r,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):_r.removeChild(n.stateNode));break;case 18:_r!==null&&(ni?(e=_r,n=n.stateNode,e.nodeType===8?Ly(e.parentNode,n):e.nodeType===1&&Ly(e,n),Dd(e)):Ly(_r,n.stateNode));break;case 4:r=_r,i=ni,_r=n.stateNode.containerInfo,ni=!0,To(e,t,n),_r=r,ni=i;break;case 0:case 11:case 14:case 15:if(!Rr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&Ex(n,t,a),i=i.next}while(i!==r)}To(e,t,n);break;case 1:if(!Rr&&(dc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Un(n,t,l)}To(e,t,n);break;case 21:To(e,t,n);break;case 22:n.mode&1?(Rr=(r=Rr)||n.memoizedState!==null,To(e,t,n),Rr=r):To(e,t,n);break;default:To(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 $D),t.forEach(function(r){var i=KD.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Qs(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:_r=l.stateNode,ni=!1;break e;case 3:_r=l.stateNode.containerInfo,ni=!0;break e;case 4:_r=l.stateNode.containerInfo,ni=!0;break e}l=l.return}if(_r===null)throw Error(Ie(160));vI(o,a,i),_r=null,ni=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Un(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)SI(t,e),t=t.sibling}function SI(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Qs(t,e),bi(e),r&4){try{xd(3,e,e.return),Zm(3,e)}catch(v){Un(e,e.return,v)}try{xd(5,e,e.return)}catch(v){Un(e,e.return,v)}}break;case 1:Qs(t,e),bi(e),r&512&&n!==null&&dc(n,n.return);break;case 5:if(Qs(t,e),bi(e),r&512&&n!==null&&dc(n,n.return),e.flags&32){var i=e.stateNode;try{Md(i,"")}catch(v){Un(e,e.return,v)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,a=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&KA(i,o),nx(l,a);var u=nx(l,o);for(a=0;a<c.length;a+=2){var p=c[a],f=c[a+1];p==="style"?JA(i,f):p==="dangerouslySetInnerHTML"?GA(i,f):p==="children"?Md(i,f):Qb(i,p,f,u)}switch(l){case"input":Xw(i,o);break;case"textarea":qA(i,o);break;case"select":var d=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?xc(i,!!o.multiple,h,!1):d!==!!o.multiple&&(o.defaultValue!=null?xc(i,!!o.multiple,o.defaultValue,!0):xc(i,!!o.multiple,o.multiple?[]:"",!1))}i[Hd]=o}catch(v){Un(e,e.return,v)}}break;case 6:if(Qs(t,e),bi(e),r&4){if(e.stateNode===null)throw Error(Ie(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(v){Un(e,e.return,v)}}break;case 3:if(Qs(t,e),bi(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Dd(t.containerInfo)}catch(v){Un(e,e.return,v)}break;case 4:Qs(t,e),bi(e);break;case 13:Qs(t,e),bi(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(Pk=er())),r&4&&iN(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Rr=(u=Rr)||p,Qs(t,e),Rr=u):Qs(t,e),bi(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(et=e,p=e.child;p!==null;){for(f=et=p;et!==null;){switch(d=et,h=d.child,d.tag){case 0:case 11:case 14:case 15:xd(4,d,d.return);break;case 1:dc(d,d.return);var y=d.stateNode;if(typeof y.componentWillUnmount=="function"){r=d,n=d.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Un(r,n,v)}}break;case 5:dc(d,d.return);break;case 22:if(d.memoizedState!==null){aN(f);continue}}h!==null?(h.return=d,et=h):aN(f)}p=p.sibling}e:for(p=null,f=e;;){if(f.tag===5){if(p===null){p=f;try{i=f.stateNode,u?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=YA("display",a))}catch(v){Un(e,e.return,v)}}}else if(f.tag===6){if(p===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(v){Un(e,e.return,v)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;p===f&&(p=null),f=f.return}p===f&&(p=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Qs(t,e),bi(e),r&4&&iN(e);break;case 21:break;default:Qs(t,e),bi(e)}}function bi(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(kI(n)){var r=n;break e}n=n.return}throw Error(Ie(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Md(i,""),r.flags&=-33);var o=sN(e);Tx(e,o,i);break;case 3:case 4:var a=r.stateNode.containerInfo,l=sN(e);Px(e,l,a);break;default:throw Error(Ie(161))}}catch(c){Un(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function OD(e,t,n){et=e,jI(e)}function jI(e,t,n){for(var r=(e.mode&1)!==0;et!==null;){var i=et,o=i.child;if(i.tag===22&&r){var a=i.memoizedState!==null||Ep;if(!a){var l=i.alternate,c=l!==null&&l.memoizedState!==null||Rr;l=Ep;var u=Rr;if(Ep=a,(Rr=c)&&!u)for(et=i;et!==null;)a=et,c=a.child,a.tag===22&&a.memoizedState!==null?lN(i):c!==null?(c.return=a,et=c):lN(i);for(;o!==null;)et=o,jI(o),o=o.sibling;et=i,Ep=l,Rr=u}oN(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,et=o):oN(e)}}function oN(e){for(;et!==null;){var t=et;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Rr||Zm(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Rr)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:ti(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&V0(t,o,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}V0(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 p=u.memoizedState;if(p!==null){var f=p.dehydrated;f!==null&&Dd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ie(163))}Rr||t.flags&512&&Ix(t)}catch(d){Un(t,t.return,d)}}if(t===e){et=null;break}if(n=t.sibling,n!==null){n.return=t.return,et=n;break}et=t.return}}function aN(e){for(;et!==null;){var t=et;if(t===e){et=null;break}var n=t.sibling;if(n!==null){n.return=t.return,et=n;break}et=t.return}}function lN(e){for(;et!==null;){var t=et;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Zm(4,t)}catch(c){Un(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){Un(t,i,c)}}var o=t.return;try{Ix(t)}catch(c){Un(t,o,c)}break;case 5:var a=t.return;try{Ix(t)}catch(c){Un(t,a,c)}}}catch(c){Un(t,t.return,c)}if(t===e){et=null;break}var l=t.sibling;if(l!==null){l.return=t.return,et=l;break}et=t.return}}var DD=Math.ceil,tm=bo.ReactCurrentDispatcher,Ek=bo.ReactCurrentOwner,Fs=bo.ReactCurrentBatchConfig,Zt=0,vr=null,sr=null,Cr=0,ps=0,fc=ya(0),fr=0,Yd=null,rl=0,eg=0,Ik=0,bd=null,Zr=null,Pk=0,Fc=1/0,Zi=null,nm=!1,Rx=null,na=null,Ip=!1,Go=null,rm=0,kd=0,Mx=null,xh=-1,bh=0;function Vr(){return Zt&6?er():xh!==-1?xh:xh=er()}function ra(e){return e.mode&1?Zt&2&&Cr!==0?Cr&-Cr:kD.transition!==null?(bh===0&&(bh=lE()),bh):(e=un,e!==0||(e=window.event,e=e===void 0?16:mE(e.type)),e):1}function ui(e,t,n,r){if(50<kd)throw kd=0,Mx=null,Error(Ie(185));kf(e,n,r),(!(Zt&2)||e!==vr)&&(e===vr&&(!(Zt&2)&&(eg|=n),fr===4&&Ho(e,Cr)),os(e,r),n===1&&Zt===0&&!(t.mode&1)&&(Fc=er()+500,Jm&&wa()))}function os(e,t){var n=e.callbackNode;kO(e,t);var r=zh(e,e===vr?Cr:0);if(r===0)n!==null&&y0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&y0(n),t===1)e.tag===0?bD(cN.bind(null,e)):ME(cN.bind(null,e)),gD(function(){!(Zt&6)&&wa()}),n=null;else{switch(cE(r)){case 1:n=rk;break;case 4:n=oE;break;case 16:n=Fh;break;case 536870912:n=aE;break;default:n=Fh}n=TI(n,NI.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function NI(e,t){if(xh=-1,bh=0,Zt&6)throw Error(Ie(327));var n=e.callbackNode;if(jc()&&e.callbackNode!==n)return null;var r=zh(e,e===vr?Cr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=sm(e,r);else{t=r;var i=Zt;Zt|=2;var o=CI();(vr!==e||Cr!==t)&&(Zi=null,Fc=er()+500,Ua(e,t));do try{WD();break}catch(l){_I(e,l)}while(!0);gk(),tm.current=o,Zt=i,sr!==null?t=0:(vr=null,Cr=0,t=fr)}if(t!==0){if(t===2&&(i=ax(e),i!==0&&(r=i,t=$x(e,i))),t===1)throw n=Yd,Ua(e,0),Ho(e,r),os(e,er()),n;if(t===6)Ho(e,r);else{if(i=e.current.alternate,!(r&30)&&!FD(i)&&(t=sm(e,r),t===2&&(o=ax(e),o!==0&&(r=o,t=$x(e,o))),t===1))throw n=Yd,Ua(e,0),Ho(e,r),os(e,er()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Ie(345));case 2:$a(e,Zr,Zi);break;case 3:if(Ho(e,r),(r&130023424)===r&&(t=Pk+500-er(),10<t)){if(zh(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Vr(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=mx($a.bind(null,e,Zr,Zi),t);break}$a(e,Zr,Zi);break;case 4:if(Ho(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var a=31-ci(r);o=1<<a,a=t[a],a>i&&(i=a),r&=~o}if(r=i,r=er()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*DD(r/1960))-r,10<r){e.timeoutHandle=mx($a.bind(null,e,Zr,Zi),r);break}$a(e,Zr,Zi);break;case 5:$a(e,Zr,Zi);break;default:throw Error(Ie(329))}}}return os(e,er()),e.callbackNode===n?NI.bind(null,e):null}function $x(e,t){var n=bd;return e.current.memoizedState.isDehydrated&&(Ua(e,t).flags|=256),e=sm(e,t),e!==2&&(t=Zr,Zr=n,t!==null&&Lx(t)),e}function Lx(e){Zr===null?Zr=e:Zr.push.apply(Zr,e)}function FD(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 i=n[r],o=i.getSnapshot;i=i.value;try{if(!fi(o(),i))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 Ho(e,t){for(t&=~Ik,t&=~eg,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-ci(t),r=1<<n;e[n]=-1,t&=~r}}function cN(e){if(Zt&6)throw Error(Ie(327));jc();var t=zh(e,0);if(!(t&1))return os(e,er()),null;var n=sm(e,t);if(e.tag!==0&&n===2){var r=ax(e);r!==0&&(t=r,n=$x(e,r))}if(n===1)throw n=Yd,Ua(e,0),Ho(e,t),os(e,er()),n;if(n===6)throw Error(Ie(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,$a(e,Zr,Zi),os(e,er()),null}function Tk(e,t){var n=Zt;Zt|=1;try{return e(t)}finally{Zt=n,Zt===0&&(Fc=er()+500,Jm&&wa())}}function sl(e){Go!==null&&Go.tag===0&&!(Zt&6)&&jc();var t=Zt;Zt|=1;var n=Fs.transition,r=un;try{if(Fs.transition=null,un=1,e)return e()}finally{un=r,Fs.transition=n,Zt=t,!(Zt&6)&&wa()}}function Rk(){ps=fc.current,En(fc)}function Ua(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,mD(n)),sr!==null)for(n=sr.return;n!==null;){var r=n;switch(pk(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Kh();break;case 3:Oc(),En(ss),En(Lr),vk();break;case 5:kk(r);break;case 4:Oc();break;case 13:En(Fn);break;case 19:En(Fn);break;case 10:yk(r.type._context);break;case 22:case 23:Rk()}n=n.return}if(vr=e,sr=e=sa(e.current,null),Cr=ps=t,fr=0,Yd=null,Ik=eg=rl=0,Zr=bd=null,Ba!==null){for(t=0;t<Ba.length;t++)if(n=Ba[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var a=o.next;o.next=i,r.next=a}n.pending=r}Ba=null}return e}function _I(e,t){do{var n=sr;try{if(gk(),gh.current=em,Zh){for(var r=Wn.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}Zh=!1}if(nl=0,xr=dr=Wn=null,wd=!1,qd=0,Ek.current=null,n===null||n.return===null){fr=1,Yd=t,sr=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=Cr,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,f=p.tag;if(!(p.mode&1)&&(f===0||f===11||f===15)){var d=p.alternate;d?(p.updateQueue=d.updateQueue,p.memoizedState=d.memoizedState,p.lanes=d.lanes):(p.updateQueue=null,p.memoizedState=null)}var h=J0(a);if(h!==null){h.flags&=-257,X0(h,a,l,o,t),h.mode&1&&Y0(o,u,t),t=h,c=u;var y=t.updateQueue;if(y===null){var v=new Set;v.add(c),t.updateQueue=v}else y.add(c);break e}else{if(!(t&1)){Y0(o,u,t),Mk();break e}c=Error(Ie(426))}}else if(Pn&&l.mode&1){var b=J0(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),X0(b,a,l,o,t),hk(Dc(c,l));break e}}o=c=Dc(c,l),fr!==4&&(fr=2),bd===null?bd=[o]:bd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=cI(o,c,t);H0(o,g);break e;case 1:l=c;var k=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof k.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(na===null||!na.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var _=uI(o,l,t);H0(o,_);break e}}o=o.return}while(o!==null)}EI(n)}catch(S){t=S,sr===n&&n!==null&&(sr=n=n.return);continue}break}while(!0)}function CI(){var e=tm.current;return tm.current=em,e===null?em:e}function Mk(){(fr===0||fr===3||fr===2)&&(fr=4),vr===null||!(rl&268435455)&&!(eg&268435455)||Ho(vr,Cr)}function sm(e,t){var n=Zt;Zt|=2;var r=CI();(vr!==e||Cr!==t)&&(Zi=null,Ua(e,t));do try{zD();break}catch(i){_I(e,i)}while(!0);if(gk(),Zt=n,tm.current=r,sr!==null)throw Error(Ie(261));return vr=null,Cr=0,fr}function zD(){for(;sr!==null;)AI(sr)}function WD(){for(;sr!==null&&!fO();)AI(sr)}function AI(e){var t=PI(e.alternate,e,ps);e.memoizedProps=e.pendingProps,t===null?EI(e):sr=t,Ek.current=null}function EI(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=MD(n,t),n!==null){n.flags&=32767,sr=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{fr=6,sr=null;return}}else if(n=RD(n,t,ps),n!==null){sr=n;return}if(t=t.sibling,t!==null){sr=t;return}sr=t=e}while(t!==null);fr===0&&(fr=5)}function $a(e,t,n){var r=un,i=Fs.transition;try{Fs.transition=null,un=1,BD(e,t,n,r)}finally{Fs.transition=i,un=r}return null}function BD(e,t,n,r){do jc();while(Go!==null);if(Zt&6)throw Error(Ie(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Ie(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(vO(e,o),e===vr&&(sr=vr=null,Cr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Ip||(Ip=!0,TI(Fh,function(){return jc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Fs.transition,Fs.transition=null;var a=un;un=1;var l=Zt;Zt|=4,Ek.current=null,LD(e,n),SI(n,e),lD(px),Wh=!!fx,px=fx=null,e.current=n,OD(n),pO(),Zt=l,un=a,Fs.transition=o}else e.current=n;if(Ip&&(Ip=!1,Go=e,rm=i),o=e.pendingLanes,o===0&&(na=null),gO(n.stateNode),os(e,er()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(nm)throw nm=!1,e=Rx,Rx=null,e;return rm&1&&e.tag!==0&&jc(),o=e.pendingLanes,o&1?e===Mx?kd++:(kd=0,Mx=e):kd=0,wa(),null}function jc(){if(Go!==null){var e=cE(rm),t=Fs.transition,n=un;try{if(Fs.transition=null,un=16>e?16:e,Go===null)var r=!1;else{if(e=Go,Go=null,rm=0,Zt&6)throw Error(Ie(331));var i=Zt;for(Zt|=4,et=e.current;et!==null;){var o=et,a=o.child;if(et.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(et=u;et!==null;){var p=et;switch(p.tag){case 0:case 11:case 15:xd(8,p,o)}var f=p.child;if(f!==null)f.return=p,et=f;else for(;et!==null;){p=et;var d=p.sibling,h=p.return;if(bI(p),p===u){et=null;break}if(d!==null){d.return=h,et=d;break}et=h}}}var y=o.alternate;if(y!==null){var v=y.child;if(v!==null){y.child=null;do{var b=v.sibling;v.sibling=null,v=b}while(v!==null)}}et=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,et=a;else e:for(;et!==null;){if(o=et,o.flags&2048)switch(o.tag){case 0:case 11:case 15:xd(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,et=g;break e}et=o.return}}var k=e.current;for(et=k;et!==null;){a=et;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,et=x;else e:for(a=k;et!==null;){if(l=et,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Zm(9,l)}}catch(S){Un(l,l.return,S)}if(l===a){et=null;break e}var _=l.sibling;if(_!==null){_.return=l.return,et=_;break e}et=l.return}}if(Zt=i,wa(),Ri&&typeof Ri.onPostCommitFiberRoot=="function")try{Ri.onPostCommitFiberRoot(Km,e)}catch{}r=!0}return r}finally{un=n,Fs.transition=t}}return!1}function uN(e,t,n){t=Dc(n,t),t=cI(e,t,1),e=ta(e,t,1),t=Vr(),e!==null&&(kf(e,1,t),os(e,t))}function Un(e,t,n){if(e.tag===3)uN(e,e,n);else for(;t!==null;){if(t.tag===3){uN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(na===null||!na.has(r))){e=Dc(n,e),e=uI(t,e,1),t=ta(t,e,1),e=Vr(),t!==null&&(kf(t,1,e),os(t,e));break}}t=t.return}}function HD(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Vr(),e.pingedLanes|=e.suspendedLanes&n,vr===e&&(Cr&n)===n&&(fr===4||fr===3&&(Cr&130023424)===Cr&&500>er()-Pk?Ua(e,0):Ik|=n),os(e,t)}function II(e,t){t===0&&(e.mode&1?(t=bp,bp<<=1,!(bp&130023424)&&(bp=4194304)):t=1);var n=Vr();e=ho(e,t),e!==null&&(kf(e,t,n),os(e,n))}function VD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),II(e,n)}function KD(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Ie(314))}r!==null&&r.delete(t),II(e,n)}var PI;PI=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ss.current)ts=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ts=!1,TD(e,t,n);ts=!!(e.flags&131072)}else ts=!1,Pn&&t.flags&1048576&&$E(t,Gh,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wh(e,t),e=t.pendingProps;var i=Mc(t,Lr.current);Sc(t,n),i=jk(null,t,r,e,i,n);var o=Nk();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,is(r)?(o=!0,qh(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,xk(t),i.updater=Qm,t.stateNode=i,i._reactInternals=t,vx(t,r,e,n),t=Nx(null,t,r,!0,o,n)):(t.tag=0,Pn&&o&&fk(t),Hr(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wh(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=UD(r),e=ti(r,e),i){case 0:t=jx(null,t,r,e,n);break e;case 1:t=eN(null,t,r,e,n);break e;case 11:t=Q0(null,t,r,e,n);break e;case 14:t=Z0(null,t,r,ti(r.type,e),n);break e}throw Error(Ie(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),jx(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),eN(e,t,r,i,n);case 3:e:{if(hI(t),e===null)throw Error(Ie(387));r=t.pendingProps,o=t.memoizedState,i=o.element,WE(e,t),Xh(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Dc(Error(Ie(423)),t),t=tN(e,t,r,n,i);break e}else if(r!==i){i=Dc(Error(Ie(424)),t),t=tN(e,t,r,n,i);break e}else for(gs=ea(t.stateNode.containerInfo.firstChild),ws=t,Pn=!0,si=null,n=FE(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if($c(),r===i){t=mo(e,t,n);break e}Hr(e,t,r,n)}t=t.child}return t;case 5:return BE(t),e===null&&xx(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,a=i.children,hx(r,i)?a=null:o!==null&&hx(r,o)&&(t.flags|=32),pI(e,t),Hr(e,t,a,n),t.child;case 6:return e===null&&xx(t),null;case 13:return mI(e,t,n);case 4:return bk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Lc(t,null,r,n):Hr(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),Q0(e,t,r,i,n);case 7:return Hr(e,t,t.pendingProps,n),t.child;case 8:return Hr(e,t,t.pendingProps.children,n),t.child;case 12:return Hr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value,xn(Yh,r._currentValue),r._currentValue=a,o!==null)if(fi(o.value,a)){if(o.children===i.children&&!ss.current){t=mo(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){a=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=ao(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),bx(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Ie(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),bx(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}Hr(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,Sc(t,n),i=zs(i),r=r(i),t.flags|=1,Hr(e,t,r,n),t.child;case 14:return r=t.type,i=ti(r,t.pendingProps),i=ti(r.type,i),Z0(e,t,r,i,n);case 15:return dI(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),wh(e,t),t.tag=1,is(r)?(e=!0,qh(t)):e=!1,Sc(t,n),lI(t,r,i),vx(t,r,i,n),Nx(null,t,r,!0,e,n);case 19:return gI(e,t,n);case 22:return fI(e,t,n)}throw Error(Ie(156,t.tag))};function TI(e,t){return iE(e,t)}function qD(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ds(e,t,n,r){return new qD(e,t,n,r)}function $k(e){return e=e.prototype,!(!e||!e.isReactComponent)}function UD(e){if(typeof e=="function")return $k(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ek)return 11;if(e===tk)return 14}return 2}function sa(e,t){var n=e.alternate;return n===null?(n=Ds(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function kh(e,t,n,r,i,o){var a=2;if(r=e,typeof e=="function")$k(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case nc:return Ga(n.children,i,o,t);case Zb:a=8,i|=8;break;case qw:return e=Ds(12,n,t,i|2),e.elementType=qw,e.lanes=o,e;case Uw:return e=Ds(13,n,t,i),e.elementType=Uw,e.lanes=o,e;case Gw:return e=Ds(19,n,t,i),e.elementType=Gw,e.lanes=o,e;case BA:return tg(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case zA:a=10;break e;case WA:a=9;break e;case ek:a=11;break e;case tk:a=14;break e;case Fo:a=16,r=null;break e}throw Error(Ie(130,e==null?e:typeof e,""))}return t=Ds(a,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Ga(e,t,n,r){return e=Ds(7,e,r,t),e.lanes=n,e}function tg(e,t,n,r){return e=Ds(22,e,r,t),e.elementType=BA,e.lanes=n,e.stateNode={isHidden:!1},e}function Vy(e,t,n){return e=Ds(6,e,null,t),e.lanes=n,e}function Ky(e,t,n){return t=Ds(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function GD(e,t,n,r,i){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=Ny(0),this.expirationTimes=Ny(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ny(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Lk(e,t,n,r,i,o,a,l,c){return e=new GD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ds(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},xk(o),e}function YD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:tc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function RI(e){if(!e)return la;e=e._reactInternals;e:{if(yl(e)!==e||e.tag!==1)throw Error(Ie(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(is(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Ie(171))}if(e.tag===1){var n=e.type;if(is(n))return RE(e,n,t)}return t}function MI(e,t,n,r,i,o,a,l,c){return e=Lk(n,r,!0,e,i,o,a,l,c),e.context=RI(null),n=e.current,r=Vr(),i=ra(n),o=ao(r,i),o.callback=t??null,ta(n,o,i),e.current.lanes=i,kf(e,i,r),os(e,r),e}function ng(e,t,n,r){var i=t.current,o=Vr(),a=ra(i);return n=RI(n),t.context===null?t.context=n:t.pendingContext=n,t=ao(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ta(i,t,a),e!==null&&(ui(e,i,a,o),mh(e,i,a)),a}function im(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 dN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Ok(e,t){dN(e,t),(e=e.alternate)&&dN(e,t)}function JD(){return null}var $I=typeof reportError=="function"?reportError:function(e){console.error(e)};function Dk(e){this._internalRoot=e}rg.prototype.render=Dk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ie(409));ng(e,t,null,null)};rg.prototype.unmount=Dk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;sl(function(){ng(null,e,null,null)}),t[po]=null}};function rg(e){this._internalRoot=e}rg.prototype.unstable_scheduleHydration=function(e){if(e){var t=fE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Bo.length&&t!==0&&t<Bo[n].priority;n++);Bo.splice(n,0,e),n===0&&hE(e)}};function Fk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function sg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function fN(){}function XD(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var u=im(a);o.call(u)}}var a=MI(t,r,e,0,null,!1,!1,"",fN);return e._reactRootContainer=a,e[po]=a.current,Wd(e.nodeType===8?e.parentNode:e),sl(),a}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var l=r;r=function(){var u=im(c);l.call(u)}}var c=Lk(e,0,!1,null,null,!1,!1,"",fN);return e._reactRootContainer=c,e[po]=c.current,Wd(e.nodeType===8?e.parentNode:e),sl(function(){ng(t,c,n,r)}),c}function ig(e,t,n,r,i){var o=n._reactRootContainer;if(o){var a=o;if(typeof i=="function"){var l=i;i=function(){var c=im(a);l.call(c)}}ng(t,a,e,i)}else a=XD(n,t,e,i,r);return im(a)}uE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=rd(t.pendingLanes);n!==0&&(sk(t,n|1),os(t,er()),!(Zt&6)&&(Fc=er()+500,wa()))}break;case 13:sl(function(){var r=ho(e,1);if(r!==null){var i=Vr();ui(r,e,1,i)}}),Ok(e,1)}};ik=function(e){if(e.tag===13){var t=ho(e,134217728);if(t!==null){var n=Vr();ui(t,e,134217728,n)}Ok(e,134217728)}};dE=function(e){if(e.tag===13){var t=ra(e),n=ho(e,t);if(n!==null){var r=Vr();ui(n,e,t,r)}Ok(e,t)}};fE=function(){return un};pE=function(e,t){var n=un;try{return un=e,t()}finally{un=n}};sx=function(e,t,n){switch(t){case"input":if(Xw(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 i=Ym(r);if(!i)throw Error(Ie(90));VA(r),Xw(r,i)}}}break;case"textarea":qA(e,n);break;case"select":t=n.value,t!=null&&xc(e,!!n.multiple,t,!1)}};ZA=Tk;eE=sl;var QD={usingClientEntryPoint:!1,Events:[Sf,oc,Ym,XA,QA,Tk]},Hu={findFiberByHostInstance:Wa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ZD={bundleType:Hu.bundleType,version:Hu.version,rendererPackageName:Hu.rendererPackageName,rendererConfig:Hu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:bo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=rE(e),e===null?null:e.stateNode},findFiberByHostInstance:Hu.findFiberByHostInstance||JD,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 Pp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Pp.isDisabled&&Pp.supportsFiber)try{Km=Pp.inject(ZD),Ri=Pp}catch{}}vs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=QD;vs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Fk(t))throw Error(Ie(200));return YD(e,t,null,n)};vs.createRoot=function(e,t){if(!Fk(e))throw Error(Ie(299));var n=!1,r="",i=$I;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Lk(e,1,!1,null,null,n,!1,r,i),e[po]=t.current,Wd(e.nodeType===8?e.parentNode:e),new Dk(t)};vs.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(Ie(188)):(e=Object.keys(e).join(","),Error(Ie(268,e)));return e=rE(t),e=e===null?null:e.stateNode,e};vs.flushSync=function(e){return sl(e)};vs.hydrate=function(e,t,n){if(!sg(t))throw Error(Ie(200));return ig(null,e,t,!0,n)};vs.hydrateRoot=function(e,t,n){if(!Fk(e))throw Error(Ie(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",a=$I;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=MI(t,null,e,1,n??null,i,!1,o,a),e[po]=t.current,Wd(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new rg(t)};vs.render=function(e,t,n){if(!sg(t))throw Error(Ie(200));return ig(null,e,t,!1,n)};vs.unmountComponentAtNode=function(e){if(!sg(e))throw Error(Ie(40));return e._reactRootContainer?(sl(function(){ig(null,null,e,!1,function(){e._reactRootContainer=null,e[po]=null})}),!0):!1};vs.unstable_batchedUpdates=Tk;vs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!sg(n))throw Error(Ie(200));if(e==null||e._reactInternals===void 0)throw Error(Ie(38));return ig(e,t,n,!1,r)};vs.version="18.3.1-next-f1338f8080-20240426";function LI(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(LI)}catch(e){console.error(e)}}LI(),LA.exports=vs;var ur=LA.exports,pN=ur;Vw.createRoot=pN.createRoot,Vw.hydrateRoot=pN.hydrateRoot;const OI=m.createContext(null);function Ox(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function eF(){const e=Ox(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function tF({children:e}){const[t,n]=m.useState(eF);m.useEffect(()=>{const o=()=>n(Ox(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=m.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Ox(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),i=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return s.jsx(OI.Provider,{value:i,children:e})}function ls(){const e=m.useContext(OI);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function nF(){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 hN={};function Dx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&hN[t[0]]||(typeof t[0]=="string"&&(hN[t[0]]=new Date),nF(...t))}const DI=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function mN(e,t,n){e.loadNamespaces(t,DI(e,n))}function gN(e,t,n,r){typeof n=="string"&&(n=[n]),n.forEach(i=>{e.options.ns.indexOf(i)<0&&e.options.ns.push(i)}),e.loadLanguages(t,DI(e,r))}function rF(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],i=t.options?t.options.fallbackLng:!1,o=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!i||a(o,e)))}function sF(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Dx("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(i,o)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&i.services.backendConnector.backend&&i.isLanguageChangingTo&&!o(i.isLanguageChangingTo,e))return!1}}):rF(e,t,n)}const iF=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,oF={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},aF=e=>oF[e],lF=e=>e.replace(iF,aF);let Fx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:lF};function cF(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fx={...Fx,...e}}function uF(){return Fx}let FI;function dF(e){FI=e}function fF(){return FI}const pF={type:"3rdParty",init(e){cF(e.options.react),dF(e)}},hF=m.createContext();class mF{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const gF=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function Ur(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:i}=m.useContext(hF)||{},o=n||r||fF();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new mF),!o){Dx("You will need to pass in an i18next instance by using initReactI18next");const x=(S,N)=>typeof N=="string"?N:N&&typeof N=="object"&&typeof N.defaultValue=="string"?N.defaultValue:Array.isArray(S)?S[S.length-1]:S,_=[x,{},!1];return _.t=x,_.i18n={},_.ready=!1,_}o.options.react&&o.options.react.wait!==void 0&&Dx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...uF(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||i||o.options&&o.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const p=(o.isInitialized||o.initializedStoreOnce)&&u.every(x=>sF(x,o,a));function f(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[d,h]=m.useState(f);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=gF(y),b=m.useRef(!0);m.useEffect(()=>{const{bindI18n:x,bindI18nStore:_}=a;b.current=!0,!p&&!l&&(t.lng?gN(o,t.lng,u,()=>{b.current&&h(f)}):mN(o,u,()=>{b.current&&h(f)})),p&&v&&v!==y&&b.current&&h(f);function S(){b.current&&h(f)}return x&&o&&o.on(x,S),_&&o&&o.store.on(_,S),()=>{b.current=!1,x&&o&&x.split(" ").forEach(N=>o.off(N,S)),_&&o&&_.split(" ").forEach(N=>o.store.off(N,S))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{b.current&&!g.current&&h(f),g.current=!1},[o,c]);const k=[d,o,p];if(k.t=d,k.i18n=o,k.ready=p,p||!p&&!l)return k;throw new Promise(x=>{t.lng?gN(o,t.lng,u,()=>x()):mN(o,u,()=>x())})}const zI="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",yF=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/workflows",label:"迭代",icon:"timeline"},{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:"/admin/teams",label:"团队管理",icon:"groups",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],wF=[{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 xF(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function bF({authUser:e,onLogout:t}){const{path:n,navigate:r}=ls(),{t:i}=Ur(),[o,a]=m.useState(!1);return m.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),s.jsxs("aside",{className:"af-sidebar","aria-label":i("flow:sidebar.mainNav"),children:[s.jsxs("div",{className:"af-brand",children:[s.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:s.jsx("img",{src:zI,alt:"",width:"36",height:"36",decoding:"async"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),s.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),s.jsx("nav",{className:"af-nav",children:yF.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>s.jsxs("button",{type:"button",className:"af-nav-link"+(xF(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[s.jsx("span",{className:"material-symbols-outlined",children:l.icon}),s.jsx("span",{children:l.label||i(l.labelKey)})]},l.to))}),s.jsxs("div",{className:"af-sidebar-footer",children:[s.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[s.jsx("span",{className:"material-symbols-outlined",children:"person"}),s.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?s.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,s.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:s.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!o&&wF.map(l=>{const c=i(l.labelKey);return s.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:s.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const kF="agentflow.pipelineRecent",vF=15;function SF(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function jF(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(kF);return e?SF(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 NF(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 yN(e,t){const n=Date.now(),r=Math.max(0,n-e),i=Math.floor(r/1e3);if(i<60)return t("flow:time.justNow");const o=Math.floor(i/60);if(o<60)return t("flow:time.minutesAgo",{n:o});const a=Math.floor(o/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const p=Math.floor(a/24);return p<7?t("flow:time.daysAgo",{n:p}):`${l.getMonth()+1}/${l.getDate()}`}function _F(e,t,n){const r=[];for(const i of e)!i||typeof i.flowId!="string"||typeof i.at!="number"||r.push({flowId:i.flowId,flowSource:NF(n,i.flowId),kind:"executed",at:i.at});for(const i of t)r.push({flowId:i.flowId,flowSource:i.flowSource,kind:"opened",at:i.at});return r.sort((i,o)=>o.at-i.at),r.slice(0,vF)}var hs=Uint8Array,pc=Uint16Array,CF=Int32Array,WI=new hs([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]),BI=new hs([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]),AF=new hs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),HI=function(e,t){for(var n=new pc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new CF(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return{b:n,r:i}},VI=HI(WI,2),KI=VI.b,EF=VI.r;KI[28]=258,EF[258]=28;var IF=HI(BI,0),PF=IF.b,zx=new pc(32768);for(var An=0;An<32768;++An){var Ro=(An&43690)>>1|(An&21845)<<1;Ro=(Ro&52428)>>2|(Ro&13107)<<2,Ro=(Ro&61680)>>4|(Ro&3855)<<4,zx[An]=((Ro&65280)>>8|(Ro&255)<<8)>>1}var vd=function(e,t,n){for(var r=e.length,i=0,o=new pc(t);i<r;++i)e[i]&&++o[e[i]-1];var a=new pc(t);for(i=1;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;var l;if(n){l=new pc(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],p=t-e[i],f=a[e[i]-1]++<<p,d=f|(1<<p)-1;f<=d;++f)l[zx[f]>>c]=u}else for(l=new pc(r),i=0;i<r;++i)e[i]&&(l[i]=zx[a[e[i]-1]++]>>15-e[i]);return l},Nf=new hs(288);for(var An=0;An<144;++An)Nf[An]=8;for(var An=144;An<256;++An)Nf[An]=9;for(var An=256;An<280;++An)Nf[An]=7;for(var An=280;An<288;++An)Nf[An]=8;var qI=new hs(32);for(var An=0;An<32;++An)qI[An]=5;var TF=vd(Nf,9,1),RF=vd(qI,5,1),qy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Zs=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Uy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},MF=function(e){return(e+7)/8|0},zk=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new hs(e.subarray(t,n))},$F=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Rs=function(e,t,n){var r=new Error(t||$F[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Rs),!n)throw r;return r},LF=function(e,t,n,r){var i=e.length,o=r?r.length:0;if(!i||t.f&&!t.l)return n||new hs(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new hs(i*3));var u=function(de){var fe=n.length;if(de>fe){var ge=new hs(Math.max(fe*2,de));ge.set(n),n=ge}},p=t.f||0,f=t.p||0,d=t.b||0,h=t.l,y=t.d,v=t.m,b=t.n,g=i*8;do{if(!h){p=Zs(e,f,1);var k=Zs(e,f+1,3);if(f+=3,k)if(k==1)h=TF,y=RF,v=9,b=5;else if(k==2){var N=Zs(e,f,31)+257,I=Zs(e,f+10,15)+4,T=N+Zs(e,f+5,31)+1;f+=14;for(var z=new hs(T),E=new hs(19),O=0;O<I;++O)E[AF[O]]=Zs(e,f+O*3,7);f+=I*3;for(var D=qy(E),L=(1<<D)-1,$=vd(E,D,1),O=0;O<T;){var V=$[Zs(e,f,L)];f+=V&15;var x=V>>4;if(x<16)z[O++]=x;else{var B=0,F=0;for(x==16?(F=3+Zs(e,f,3),f+=2,B=z[O-1]):x==17?(F=3+Zs(e,f,7),f+=3):x==18&&(F=11+Zs(e,f,127),f+=7);F--;)z[O++]=B}}var R=z.subarray(0,N),H=z.subarray(N);v=qy(R),b=qy(H),h=vd(R,v,1),y=vd(H,b,1)}else Rs(1);else{var x=MF(f)+4,_=e[x-4]|e[x-3]<<8,S=x+_;if(S>i){c&&Rs(0);break}l&&u(d+_),n.set(e.subarray(x,S),d),t.b=d+=_,t.p=f=S*8,t.f=p;continue}if(f>g){c&&Rs(0);break}}l&&u(d+131072);for(var A=(1<<v)-1,X=(1<<b)-1,K=f;;K=f){var B=h[Uy(e,f)&A],W=B>>4;if(f+=B&15,f>g){c&&Rs(0);break}if(B||Rs(2),W<256)n[d++]=W;else if(W==256){K=f,h=null;break}else{var te=W-254;if(W>264){var O=W-257,ee=WI[O];te=Zs(e,f,(1<<ee)-1)+KI[O],f+=ee}var G=y[Uy(e,f)&X],ne=G>>4;G||Rs(3),f+=G&15;var H=PF[ne];if(ne>3){var ee=BI[ne];H+=Uy(e,f)&(1<<ee)-1,f+=ee}if(f>g){c&&Rs(0);break}l&&u(d+131072);var re=d+te;if(d<H){var ie=o-H,Z=Math.min(H,re);for(ie+d<0&&Rs(3);d<Z;++d)n[d]=r[ie+d]}for(;d<re;++d)n[d]=n[d-H]}}t.l=h,t.p=K,t.b=d,t.f=p,h&&(p=1,t.m=v,t.d=y,t.n=b)}while(!p);return d!=n.length&&a?zk(n,0,d):n.subarray(0,d)},OF=new hs(0),Ai=function(e,t){return e[t]|e[t+1]<<8},ii=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Gy=function(e,t){return ii(e,t)+ii(e,t+4)*4294967296};function DF(e,t){return LF(e,{i:2},t&&t.out,t&&t.dictionary)}var Wx=typeof TextDecoder<"u"&&new TextDecoder,FF=0;try{Wx.decode(OF,{stream:!0}),FF=1}catch{}var zF=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:zk(e,n-1)};i?i==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)):i&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 WF(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(Wx)return Wx.decode(e);var i=zF(e),o=i.s,n=i.r;return n.length&&Rs(8),o}}var BF=function(e,t){return t+30+Ai(e,t+26)+Ai(e,t+28)},HF=function(e,t,n){var r=Ai(e,t+28),i=WF(e.subarray(t+46,t+46+r),!(Ai(e,t+8)&2048)),o=t+46+r,a=ii(e,t+20),l=n&&a==4294967295?VF(e,o):[a,ii(e,t+24),ii(e,t+42)],c=l[0],u=l[1],p=l[2];return[Ai(e,t+10),c,u,i,o+Ai(e,t+30)+Ai(e,t+32),p]},VF=function(e,t){for(;Ai(e,t)!=1;t+=4+Ai(e,t+2));return[Gy(e,t+12),Gy(e,t+4),Gy(e,t+20)]};function KF(e,t){for(var n={},r=e.length-22;ii(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Rs(13);var i=Ai(e,r+8);if(!i)return{};var o=ii(e,r+16),a=o==4294967295||i==65535;if(a){var l=ii(e,r-12);a=ii(e,l)==101075792,a&&(i=ii(e,l+32),o=ii(e,l+48))}for(var c=0;c<i;++c){var u=HF(e,o,a),p=u[0],f=u[1],d=u[2],h=u[3],y=u[4],v=u[5],b=BF(e,v);o=y,p?p==8?n[h]=DF(e.subarray(b,b+f),{out:new hs(d)}):Rs(14,"unknown compression type "+p):n[h]=zk(e,b,b+f)}return n}const qF=8*1024*1024,UF=500;function GF(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 YF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function JF(e){const t=e.toLowerCase();if(t==="flow.yaml"||t==="flow.yml")return"";const n="/flow.yaml",r="/flow.yml";let i=null;if(t.endsWith(n))i=e.slice(0,-n.length);else if(t.endsWith(r))i=e.slice(0,-r.length);else return null;return i.includes("/")?null:i}const XF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function QF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=KF(t),r=new Map;let i=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const p=GF(c);if(!p||YF(p))continue;const f=(u==null?void 0:u.length)??0;if(i+=f,i>qF||(o+=1,o>UF))return null;r.set(p,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=JF(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 XF.test(l)?l:null}catch{return null}}const Yy=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function ZF({file:e,onClose:t,onImported:n}){const{t:r}=Ur(),i=m.useId(),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(""),[u,p]=m.useState("user"),[f,d]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),g=v??e;m.useEffect(()=>{const S=requestAnimationFrame(()=>{var N;return(N=o.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(S)},[]),m.useEffect(()=>{let S=!1;return(async()=>{const N=g.name||"",I=N.toLowerCase();let T="";if(I.endsWith(".zip")){if(T=await QF(g)||"",!T){const z=N.replace(/\.zip$/i,"");Yy.test(z)&&(T=z)}}else if(I.endsWith(".yaml")||I.endsWith(".yml")){const z=N.replace(/\.ya?ml$/i,"");Yy.test(z)&&(T=z)}S||c(T)})(),()=>{S=!0}},[g]);const k=l.trim(),x=k.length>0&&Yy.test(k);async function _(S){if(S.preventDefault(),!(!x||f)){d(!0),y("");try{const N=new FormData;N.set("flowId",k),N.set("targetSpace",u),N.set("file",g,g.name);const I=await fetch("/api/flows/import",{method:"POST",body:N}),T=await I.json().catch(()=>({}));if(!I.ok){y(typeof T.error=="string"?T.error:r("project:importModal.importFailed"));return}n({id:T.flowId,source:T.flowSource??"user"})}catch(N){y(String((N==null?void 0:N.message)||N))}finally{d(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:S=>{S.target===S.currentTarget&&t()},children:s.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":i,tabIndex:-1,onMouseDown:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:i,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:_,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:g.name})}),s.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:S=>{var I;const N=(I=S.target.files)==null?void 0:I[0];N&&b(N),S.target.value=""}}),s.jsxs("label",{className:"af-pipeline-drawer-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),s.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:S=>c(S.target.value),"aria-invalid":k.length>0&&!x}),s.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),s.jsx("div",{className:"af-import-repick",children:s.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var S;return(S=a.current)==null?void 0:S.click()},children:r("project:importModal.changeFile")})}),h?s.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:r("project:importModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const ez=/^[a-zA-Z][a-zA-Z0-9_-]*$/,wN="af:newPipelineGuide";function tz({open:e,onClose:t,onCreated:n}){const{t:r}=Ur(),i=m.useId(),o=m.useRef(null),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState("user"),[d,h]=m.useState(!1),[y,v]=m.useState(""),[b,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),h(!1),localStorage.getItem(wN)==="true"&&g(!0);const I=requestAnimationFrame(()=>{var T;return(T=o.current)==null?void 0:T.focus()});return()=>cancelAnimationFrame(I)},[e]);const k=()=>{localStorage.removeItem(wN),g(!1)};if(!e)return null;const x=a.trim(),_=x.length>0&&ez.test(x);async function S(N){if(N.preventDefault(),!(!_||d)){h(!0),v(""),k();try{const I=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:p})}),T=await I.json().catch(()=>({}));if(!I.ok){v(typeof T.error=="string"?T.error:r("project:newPipelineModal.createFailed"));return}n({id:T.flowId,source:T.flowSource??"user"})}catch(I){v(String((I==null?void 0:I.message)||I))}finally{h(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&(k(),t())},children:s.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":i,tabIndex:-1,onMouseDown:N=>N.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:i,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),b?s.jsx("div",{className:"af-new-pipeline-guide",children:s.jsxs("div",{className:"af-new-pipeline-guide-content",children:[s.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),s.jsxs("div",{className:"af-new-pipeline-guide-text",children:[s.jsx("p",{children:s.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),s.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),s.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:k,children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:S,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),s.jsxs("label",{className:"af-pipeline-drawer-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),s.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:N=>l(N.target.value),"aria-invalid":x.length>0&&!_}),s.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(b?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),s.jsxs("label",{className:"af-pipeline-drawer-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),s.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:N=>u(N.target.value)}),b?s.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),y?s.jsx("p",{className:"af-err af-new-pipeline-err",children:y}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:d,children:r("project:newPipelineModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!_||d,children:r(d?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const UI="agentflow.pipelineViewPreference";function GI(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function YI(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(UI)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function nz(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(UI,JSON.stringify(e))}catch{}}function Wk(e){return e==="display"?"display":"workspace"}function rz(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function JI(e,t){const n=Wk(t);return n==="pipeline"&&rz(e==null?void 0:e.source)?"workspace":n}function sz(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function iz(e,t,n,r=!1){if(!e)return;const i=YI();i[GI(e,t,r)]={view:Wk(n),at:Date.now()},nz(i)}function oz(e,t="workspace"){if(!(e!=null&&e.id))return Wk(t);const r=YI()[GI(e.id,e.source??"user",!!e.archived)],i=JI(e,(r==null?void 0:r.view)||t);return i==="pipeline"&&!sz(e)?"workspace":i}function az(e,t="workspace"){var i;const n=JI(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(i=e.collaboration)!=null&&i.id&&r.set("workspaceId",e.collaboration.id),e.archived&&r.set("archived","1"),n==="display"&&r.set("view","display"),`/workspace?${r.toString()}`}function Tp(e,t="workspace"){return az(e,oz(e,t))}function lz(e,t){const n=String(e||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),r=String(t||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),i=Math.max(n.length,r.length);for(let o=0;o<i;o+=1){const a=Number.isFinite(n[o])?n[o]:0,l=Number.isFinite(r[o])?r[o]:0;if(a!==l)return a>l?1:-1}return 0}function Bx(e){return String((e==null?void 0:e.version)||"").trim()}function cz(e){const t=Bx(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 uz({onChanged:e,canManage:t=!1}){const[n,r]=m.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[i,o]=m.useState([]),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState("keyword"),[d,h]=m.useState([]),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(""),N=m.useCallback(async()=>{x("");try{const[D,L]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),$=await D.json().catch(()=>({}));D.ok&&r({available:!!$.available,version:typeof $.version=="string"?$.version:"",loggedIn:!!$.loggedIn,user:typeof $.user=="string"?$.user:"",error:typeof $.error=="string"?$.error:""});const V=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+L.status);o(Array.isArray(V.skills)?V.skills:[]),l(typeof V.skillsRoot=="string"?V.skillsRoot:""),v({})}catch(D){x(String(D.message||D))}},[]);m.useEffect(()=>{N()},[N]);const I=m.useCallback(async()=>{const D=c.trim();if(D){g("search"),x(""),S("");try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(p)}`),$=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+L.status);h(Array.isArray($.items)?$.items:[])}catch(L){x(String(L.message||L))}finally{g("")}}},[c,p]),T=m.useCallback(async(D,L=!1)=>{if(!t)return;const $=D&&typeof D=="object"?D:null,V=String($?$.slug||$.name||$.collection||$.skillId||$.id:D||"").trim();if(V){g(`install:${V}`),x(""),S("");try{const B=$?{slug:$.slug||"",skillId:$.skillId||"",collection:$.collection||"",collectionName:$.collection&&$.name||"",target:"agentflow",agent:"codex",force:L}:{slug:V,target:"agentflow",agent:"codex",force:L},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)}),R=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+F.status);S(L?`已更新 ${V}`:`已安装 ${V}`),await N(),typeof e=="function"&&await e()}catch(B){x(String(B.message||B))}finally{g("")}}},[t,N,e]),z=m.useCallback(async()=>{if(t&&i.length!==0){g("check-updates"),x(""),S("");try{const D=await Promise.all(i.map(async V=>{const B=String(V.name||"").trim();if(!B)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(B)}&mode=keyword`),R=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+F.status);const H=Array.isArray(R.items)?R.items:[],A=H.find(te=>te.slug===B||te.name===B||te.id===B)||H[0],X=Bx(V),K=String((A==null?void 0:A.version)||"").trim();let W="unknown";return A?X&&K?W=lz(X,K)<0?"update":"current":K&&(W="remote-only"):W="missing",[B,{state:W,latestVersion:K,installedVersion:X,summary:(A==null?void 0:A.summary)||""}]}catch(F){return[B,{state:"error",error:String(F.message||F),installedVersion:Bx(V)}]}})),L={};for(const V of D)V&&(L[V[0]]=V[1]);v(L);const $=Object.values(L).filter(V=>V.state==="update").length;S($>0?`发现 ${$} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,i]),E=m.useCallback(async D=>{if(!t)return;const L=String(D||"").trim();if(L){g(`uninstall:${L}`),x(""),S("");try{const $=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:L,target:"agentflow",agent:"codex"})}),V=await $.json().catch(()=>({}));if(!$.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+$.status);S(`已卸载 ${L}`),await N(),typeof e=="function"&&await e()}catch($){x(String($.message||$))}finally{g("")}}},[t,N,e]),O=m.useCallback(async()=>{if(t){g("update-cli"),x(""),S("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),L=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+D.status);S("SkillHub CLI 已更新"),await N()}catch(D){x(String(D.message||D))}finally{g("")}}},[t,N]);return s.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),s.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?s.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",s.jsx("code",{children:a})]}):null]}),s.jsxs("div",{className:"af-set-skillhub-head-actions",children:[s.jsxs("div",{className:"af-set-skillhub-status",children:[s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),s.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),s.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),s.jsxs("div",{className:"af-set-skillhub-toolbar",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:!!b,children:"刷新"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:!t||!!b||i.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:!t||!!b,children:b==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),s.jsxs("div",{className:"af-set-skillhub-search",children:[s.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:p,onChange:D=>{f(D.target.value),h([])},children:[s.jsx("option",{value:"keyword",children:"关键词"}),s.jsx("option",{value:"skillId",children:"Skill ID"}),s.jsx("option",{value:"collectionId",children:"Collection ID"})]}),s.jsx("input",{className:"af-set-input af-set-input--sm",value:c,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&I()},placeholder:p==="collectionId"?"输入 collection id,例如 1":p==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>I(),disabled:!c.trim()||b==="search",children:[s.jsx("span",{className:"material-symbols-outlined",children:"search"}),b==="search"?"搜索中…":"搜索"]})]}),k?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:k}):null,_?s.jsx("p",{className:"af-set-hint af-set-hint--inline",children:_}):null,s.jsxs("div",{className:"af-set-skillhub-grid",children:[s.jsxs("div",{className:"af-set-skillhub-pane",children:[s.jsxs("div",{className:"af-set-skillhub-pane-head",children:[s.jsx("h3",{children:"已安装"}),s.jsx("span",{children:i.length})]}),s.jsx("div",{className:"af-set-skillhub-list",children:i.length===0?s.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):i.map(D=>{const L=y[D.name],$=!L||L.state==="update"||L.state==="remote-only"||L.state==="unknown"||L.state==="error",V=b===`install:${D.name}`?"更新中…":(L==null?void 0:L.state)==="current"?"已最新":(L==null?void 0:L.state)==="update"&&L.latestVersion?`更新到 v${L.latestVersion}`:(L==null?void 0:L.state)==="remote-only"&&L.latestVersion?`安装 v${L.latestVersion}`:"重装";return s.jsxs("div",{className:"af-set-skillhub-item",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-set-skillhub-title",children:D.displayName||D.name}),s.jsx("div",{className:"af-set-skillhub-meta",children:cz(D)}),s.jsx("div",{className:"af-set-skillhub-version-row",children:L?L.state==="update"?s.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",L.installedVersion?`v${L.installedVersion} -> `:"","v",L.latestVersion]}):L.state==="current"?s.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",L.latestVersion||L.installedVersion]}):L.state==="remote-only"?s.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",L.latestVersion,",本地版本未知"]}):L.state==="missing"?s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):L.state==="error"?s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),s.jsxs("div",{className:"af-set-skillhub-actions",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>T(D.name,!0),disabled:!t||!!b||!$,children:V}),s.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>E(D.name),disabled:!t||!!b,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.name}`)})})]}),s.jsxs("div",{className:"af-set-skillhub-pane",children:[s.jsxs("div",{className:"af-set-skillhub-pane-head",children:[s.jsx("h3",{children:"搜索结果"}),s.jsx("span",{children:d.length})]}),s.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?s.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(D=>{const L=D.slug||D.name,$=D.kind==="collection"||D.collection,V=!$&&i.some(B=>B.name===L||B.name===D.name);return s.jsxs("div",{className:"af-set-skillhub-item",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-set-skillhub-title",children:D.name||L}),s.jsxs("div",{className:"af-set-skillhub-meta",children:[$?`collection:${D.collection}`:L,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?s.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),s.jsx("button",{type:"button",className:V?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>T(D,V),disabled:!t||!!b,children:V?"更新":$?"安装合集":"安装"})]},D.id||L)})})]})]})]})}function Ya(e){return(Array.isArray(e==null?void 0:e.collections)?e.collections:[]).filter(n=>n&&typeof n=="object").map(n=>({id:String(n.id||n.name||"").trim(),name:String(n.name||n.id||"").trim(),skillKeys:Array.from(new Set((Array.isArray(n.skillKeys)?n.skillKeys:[]).map(r=>String(r||"").trim()).filter(Boolean))),builtin:!!n.builtin,createdAt:Number.isFinite(n.createdAt)?Number(n.createdAt):Date.now(),updatedAt:Number.isFinite(n.updatedAt)?Number(n.updatedAt):Date.now()})).filter(n=>n.id&&n.name)}function dz(e){return{version:1,collections:Ya({collections:e})}}function fz(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function XI(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 i=String(r||"").trim();return i&&(t.get(i)||n.get(fz(i)))||""}}function ca(e,t){const n=XI(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function pz(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 hz(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function mz(e,t,n){const r=ca(e,n);if(r.length===0)return"empty";const i=r.filter(o=>t.has(o)).length;return i===0?"none":i===r.length?"all":"partial"}function gz(e,t,n){const r=String(e).trim().toLowerCase(),i=Ya({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return ca(i,t)}function yz(e,t,n,r){const i=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Ya({collections:r}),l=gz(t,n,r),c=l.length>0?l:i;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const p=JSON.parse(u);if(Array.isArray(p)){const f=XI(n),d=Array.from(new Set(p.map(f).filter(Boolean)));if(i.length>0&&d.length===i.length)return c;const h=new Set(d),y=new Set(l),v=l.length>0&&l.every(g=>h.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=ca(g,n);return k.length>0&&k.every(x=>h.has(x))});return l.length>0&&b&&!v?c:d}}}catch{}return c}function Vl(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 wz(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function xz(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 Hx(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 QI(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 bz="project:defaultCardDesc";function ZI(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(bz)}function kz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qn({children:e,className:t="",query:n}){const r=n.trim(),i=String(e);if(!r)return s.jsx("span",{className:t,children:i});const o=new RegExp(`(${kz(r)})`,"gi"),a=i.split(o);return s.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?s.jsx("mark",{className:"af-search-hit",children:l},c):s.jsx("span",{children:l},c))})}function vz(e,t,n){const r=[String(e.id),ZI(e,n),QI(e),Hx(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
|
|
41
|
+
`).toLowerCase()}function Sz(e,t,n){return t?vz(e,t,n).includes(t):!0}function jz(e,t){const n=e.trim().toLowerCase();if(!n)return!0;const r=String(t.flowId).toLowerCase(),i=String(t.flowSource??"user").toLowerCase();return r.includes(n)||i.includes(n)}function Jy(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
|
|
42
|
+
`).toLowerCase().includes(n):!0}function xN(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 bN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const Nz=["all","agent","control","provide","marketplace"],_z=["all","agent","control","provide"],eP="agentflow.projects.activityPanelOpen",Vx="agentflow.projects.activitySelected",tP="agentflow.projects.scopeView";function Cz(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(tP)==="team"?"team":"personal"}catch{return"personal"}}function Az(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(eP);return e!=="0"}function kN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function Ez(){return typeof localStorage>"u"?"":localStorage.getItem(Vx)||""}function Rp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Zn(e){return(e==null?void 0:e.key)||`${(e==null?void 0:e.id)||(e==null?void 0:e.name)||""}:${(e==null?void 0:e.source)||""}:${(e==null?void 0:e.packageId)||""}`}function Iz(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 Mo(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function nP(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,i])=>({...i&&typeof i=="object"?i:{},instanceId:(i==null?void 0:i.instanceId)||r})):[]}function rP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.edges;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):[]}function Kx(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 vN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Kx(e,t))}function Pz(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function SN(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 Tz(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 Xy(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Rz(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 Mz(e,t){const n=e.map(p=>p.id),r=new Set(n),i=new Map(n.map(p=>[p,0])),o=new Map(n.map(p=>[p,[]]));t.forEach(p=>{var f;!r.has(p.sourceId)||!r.has(p.targetId)||(i.set(p.targetId,(i.get(p.targetId)||0)+1),(f=o.get(p.sourceId))==null||f.push(p.targetId))});const a=new Map,l=n.filter(p=>(i.get(p)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(p=>a.set(p,0));for(let p=0;p<l.length;p+=1){const f=l[p],d=(a.get(f)||0)+1;for(const h of o.get(f)||[])(!a.has(h)||d>a.get(h))&&(a.set(h,d),l.push(h))}n.forEach((p,f)=>{a.has(p)||a.set(p,f%3)});const c=new Map,u=new Map;return n.forEach(p=>{const f=a.get(p)||0,d=c.get(f)||0;c.set(f,d+1),u.set(p,{x:f*190,y:d*86})}),u}function $z(e){var v,b,g,k;const t=nP(e),n=rP(e),r=new Map(t.map((x,_)=>[Kx(x,_),vN(x,_)])),i=t.map((x,_)=>({id:Kx(x,_),title:vN(x,_),meta:Pz(x)})),o=n.map((x,_)=>{const S=SN(x,"source"),N=SN(x,"target");return{key:(x==null?void 0:x.id)||`${S}-${N}-${_}`,sourceId:S,targetId:N,source:r.get(S)||S||"?",target:r.get(N)||N||"?",label:Tz(x)}}),a=(b=(v=e==null?void 0:e.snippet)==null?void 0:v.ui)!=null&&b.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(k=(g=e==null?void 0:e.snippet)==null?void 0:g.ui)!=null&&k.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=Mz(i,o),u=i.map(x=>{const _=Rz(a[x.id])||c.get(x.id)||{x:0,y:0},S=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},N=Number(S.width),I=Number(S.height),T=Math.max(132,Math.min(210,Number.isFinite(N)?N*.62:150)),z=Math.max(48,Math.min(76,Number.isFinite(I)?I*.46:54));return{...x,x:_.x,y:_.y,width:T,height:z}}),p=new Map(u.map(x=>[x.id,x])),f=o.map(x=>{const _=p.get(x.sourceId),S=p.get(x.targetId);if(!_||!S)return null;const N=_.x+_.width,I=_.y+_.height/2,T=S.x,z=S.y+S.height/2,E=Math.max(48,Math.abs(T-N)*.45);return{...x,path:`M ${N} ${I} C ${N+E} ${I}, ${T-E} ${z}, ${T} ${z}`,labelX:(N+T)/2,labelY:(I+z)/2}}).filter(Boolean),d=u.reduce((x,_)=>({minX:Math.min(x.minX,_.x),minY:Math.min(x.minY,_.y),maxX:Math.max(x.maxX,_.x+_.width),maxY:Math.max(x.maxY,_.y+_.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,y=`${d.minX-h} ${d.minY-h} ${Math.max(360,d.maxX-d.minX+h*2)} ${Math.max(180,d.maxY-d.minY+h*2)}`;return{nodes:i,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Kl({resourceKind:e="",authUser:t=null}){var Dt,sn,Nn,Jn,js,Ns;const{t:n}=Ur(),{navigate:r,path:i}=ls(),o=!!(t!=null&&t.isAdmin),[a,l]=m.useState(e||"all"),[c,u]=m.useState([]),[p,f]=m.useState(Cz),[d,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState([]),[k,x]=m.useState([]),[_,S]=m.useState(""),[N,I]=m.useState(!1),[T,z]=m.useState([]),[E,O]=m.useState(""),[D,L]=m.useState(""),[$,V]=m.useState(!1),[B,F]=m.useState(!1),[R,H]=m.useState(!1),[A,X]=m.useState(null),[K,W]=m.useState(!1),[te,ee]=m.useState(""),[G,ne]=m.useState(Az),[re,ie]=m.useState(Ez),[Z,de]=m.useState("all"),[fe,ge]=m.useState(""),[Oe,_e]=m.useState("overview"),[Ne,He]=m.useState({}),[ct,xt]=m.useState(""),[Re,lt]=m.useState({}),[kt,Ot]=m.useState(""),[_t,Xt]=m.useState(""),[ae,ke]=m.useState({}),[Ue,it]=m.useState(""),[Ee,Kt]=m.useState(""),[en,Ut]=m.useState(""),[wt,mn]=m.useState(""),[se,Ce]=m.useState(""),[Ye,ze]=m.useState(!1),[Nt,St]=m.useState(""),[Gn,Rn]=m.useState({hiddenBuiltins:[],promoted:[]}),Sr=m.useRef(0),rn=m.useRef(0),vn=m.useRef(0),tr=m.useCallback(async()=>{var we,$e;const U=++rn.current;O("");try{const Ae=await fetch(`/api/flows?view=${encodeURIComponent(p)}`);if(U!==rn.current)return;if(!Ae.ok)throw new Error("HTTP "+Ae.status);const tt=await Ae.json();if(U!==rn.current)return;u(Array.isArray(tt)?tt:[])}catch(Ae){if(U!==rn.current)return;u([]),O(String(Ae.message||Ae))}try{const Ae=await fetch("/api/pipeline-recent-runs");if(U!==rn.current)return;if(Ae.ok){const tt=await Ae.json();if(U!==rn.current)return;z(Array.isArray(tt.runs)?tt.runs:[])}else z([])}catch{if(U!==rn.current)return;z([])}if(t!=null&&t.isAdmin)try{const Ae=await fetch("/api/admin/builtin-flows");if(U!==rn.current)return;const tt=await Ae.json().catch(()=>({}));Ae.ok&&Rn({hiddenBuiltins:Array.isArray((we=tt==null?void 0:tt.config)==null?void 0:we.hiddenBuiltins)?tt.config.hiddenBuiltins:[],promoted:Array.isArray(($e=tt==null?void 0:tt.config)==null?void 0:$e.promoted)?tt.config.promoted:[]})}catch{if(U!==rn.current)return;Rn({hiddenBuiltins:[],promoted:[]})}else Rn({hiddenBuiltins:[],promoted:[]});V(!0)},[t==null?void 0:t.isAdmin,p]),ar=m.useCallback(async(U,we)=>{if(!(t!=null&&t.isAdmin)||!(U!=null&&U.id))return;const $e=`${we}:${U.source}:${U.id}`;St($e),O("");try{const Ae=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:we,flowId:U.id,ownerUserId:U.ownerUserId||t.userId})}),tt=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(tt.error||"更新内置配置失败");await tr()}catch(Ae){O(String(Ae.message||Ae))}finally{St("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,tr]),fn=m.useCallback(async()=>{const U=++vn.current;L(""),F(!1);const we="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";h([]),g([]),ge("");try{const[Ae,tt,In,Wt]=await Promise.all([fetch(we),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),$n=await Ae.json().catch(()=>({})),mr=await tt.json().catch(()=>({})),Nr=await In.json().catch(()=>({})),on=await Wt.json().catch(()=>({}));if(!Ae.ok)throw new Error($n.error||"Nodes HTTP "+Ae.status);if(!tt.ok)throw new Error(mr.error||"Skills HTTP "+tt.status);if(!In.ok)throw new Error(Nr.error||"Collections HTTP "+In.status);if(!Wt.ok)throw new Error(on.error||"Flow snippets HTTP "+Wt.status);if(U!==vn.current)return;h(Array.isArray($n.nodes)?$n.nodes:Array.isArray($n)?$n:[]),v(Array.isArray(mr.skills)?mr.skills:[]),x(Ya(Nr)),g(Array.isArray(on.snippets)?on.snippets:[])}catch(Ae){if(U!==vn.current)return;h([]),v([]),g([]),x([]),L(String(Ae.message||Ae))}finally{if(U!==vn.current)return;F(!0)}},[e]);m.useEffect(()=>{V(!1),tr(),fn()},[tr,fn]),m.useEffect(()=>{try{localStorage.setItem(eP,G?"1":"0")}catch{}},[G]),m.useEffect(()=>{try{localStorage.setItem(tP,p)}catch{}},[p]),m.useEffect(()=>{try{re?localStorage.setItem(Vx,re):localStorage.removeItem(Vx)}catch{}},[re]),m.useEffect(()=>{let U=!1;return fetch("/api/ui-context").then(we=>we.json()).then(we=>{U||ze(!!we.hideCommunityLinks)}).catch(()=>{}),()=>{U=!0}},[]);const Sn=m.useCallback(async U=>{if(!o)return;const we=Ya({collections:U});I(!0),L("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(dz(we))}),Ae=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ae.error||"Collections HTTP "+$e.status);x(Ya(Ae))}catch($e){L(String($e.message||$e))}finally{I(!1)}},[o]),Ir=m.useCallback(()=>{if(!o)return;const U=_.trim();if(!U)return;const we=U.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(k.map(Wt=>Wt.id));let Ae=we,tt=2;for(;$e.has(Ae);)Ae=`${we}-${tt++}`;const In=Date.now();Sn([...k,{id:Ae,name:U,skillKeys:[],createdAt:In,updatedAt:In}]),S(""),de(`collection:${Ae}`)},[o,_,Sn,k]),Gr=m.useCallback(U=>{if(!o)return;const we=k.find(Ae=>Ae.id===U);if(we!=null&&we.builtin)return;const $e=k.filter(Ae=>Ae.id!==U);Z===`collection:${U}`&&de("all"),Sn($e)},[o,Z,Sn,k]),gn=m.useCallback((U,we,$e)=>{if(!o)return;const Ae=String(we||"").trim();if(!Ae)return;const tt=Date.now(),In=k.map(Wt=>{if(Wt.id!==U)return Wt;const $n=new Set(Wt.skillKeys||[]);return $e?$n.add(Ae):$n.delete(Ae),{...Wt,skillKeys:Array.from($n),updatedAt:tt}});Sn(In)},[o,Sn,k]),Hn=m.useCallback(async U=>{const we=U==null?void 0:U.packageId,$e=U==null?void 0:U.version;if(!we||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:we,version:$e})))return;const Ae=Zn(U);Kt(Ae),Ut(""),L("");try{const tt=new URLSearchParams({id:we,version:$e}),In=await fetch(`/api/marketplace/node?${tt.toString()}`,{method:"DELETE"}),Wt=await In.json().catch(()=>({}));if(!In.ok||(Wt==null?void 0:Wt.ok)===!1){const $n=Array.isArray(Wt==null?void 0:Wt.usage)&&Wt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Wt.usage.length})}`:"";throw new Error(((Wt==null?void 0:Wt.error)||"Delete failed")+$n)}Ut(n("project:deleteMyNodeSuccess",{id:we,version:$e})),lt($n=>{const mr={...$n};return delete mr[Ae],mr}),ke($n=>{const mr={};for(const[Nr,on]of Object.entries($n))Nr.startsWith(`${Ae}:`)||(mr[Nr]=on);return mr}),ge(""),await fn()}catch(tt){Ut(String(tt.message||tt))}finally{Kt("")}},[fn,n]),Dr=m.useCallback(async U=>{const we=U==null?void 0:U.id,$e=(U==null?void 0:U.version)||"1.0.0";if(!we||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:we,version:$e})))return;const Ae=Mo(U);mn(Ae),Ce(""),L("");try{const tt=new URLSearchParams({id:we,version:$e}),In=await fetch(`/api/marketplace/flow-snippet?${tt.toString()}`,{method:"DELETE"}),Wt=await In.json().catch(()=>({}));if(!In.ok||(Wt==null?void 0:Wt.ok)===!1)throw new Error((Wt==null?void 0:Wt.error)||"Delete failed");Ce(n("project:deleteMyFlowSuccess",{id:we,version:$e})),ge(""),await fn()}catch(tt){Ce(String(tt.message||tt))}finally{mn("")}},[fn,n]);m.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),de("all"),ge(""),_e("overview");return}l(U=>U==="archived"?"archived":"all")},[e]),m.useEffect(()=>{if(i!=="/projects"&&i!=="/")return;const U=new URLSearchParams(window.location.search),we=U.get("tab");let $e=!1;if(we==="nodes"){r("/nodes");return}if(we==="my-nodes"){r("/my-nodes");return}if(we==="my-flows"){r("/my-flows");return}if(we==="skills"){r("/skills");return}if(we==="archived"?(l("archived"),U.delete("tab"),$e=!0):we&&(l("all"),U.delete("tab"),$e=!0),U.get("new")==="1"&&(H(!0),U.delete("new"),$e=!0),$e){const Ae=U.toString();window.history.replaceState({},"",Ae?`/projects?${Ae}`:"/projects")}},[i,r]);const Yn=m.useMemo(()=>_F(T,jF(),c),[T,c,i]),Vn=m.useMemo(()=>Yn.filter(U=>jz(te,U)),[Yn,te]),pr=te.trim().toLowerCase(),hr=m.useMemo(()=>a==="archived"?c.filter(U=>U.archived):c.filter(U=>!U.archived),[c,a]),Kn=m.useMemo(()=>hr.filter(U=>Sz(U,pr,n)),[hr,pr,n]),lr=m.useMemo(()=>new Set((Gn.promoted||[]).map(U=>String((U==null?void 0:U.id)||"").trim()).filter(Boolean)),[Gn.promoted]),jr=m.useMemo(()=>(Gn.hiddenBuiltins||[]).map(U=>String(U||"").trim()).filter(Boolean),[Gn.hiddenBuiltins]),le=a==="nodes"||a==="my-nodes",he=a==="my-nodes",Je=a==="my-flows",st=m.useMemo(()=>d.filter(U=>he&&!Iz(U,t)?!1:(Z==="all"||(Z==="marketplace"?U.source==="marketplace":U.type===Z))&&Jy(te,[U.id,U.label,U.displayName,U.description,U.type,U.source,U.packageId,U.version])),[t,d,he,te,Z]),Tt=m.useMemo(()=>{const U=new Map;for(const we of k)U.set(we.id,new Set(ca(we,y)));return U},[y,k]),ue=m.useMemo(()=>[{id:"all",label:"全部"},...k.map(U=>{var we;return{id:`collection:${U.id}`,label:U.name,count:((we=Tt.get(U.id))==null?void 0:we.size)||0,collection:U}}),{id:"ungrouped",label:"未分组"}],[Tt,k]),Te=m.useMemo(()=>y.filter(U=>{var Ae;const we=Zn(U);let $e=Z==="all";if(Z.startsWith("collection:")){const tt=Z.slice(11);$e=!!((Ae=Tt.get(tt))!=null&&Ae.has(we))}else Z==="ungrouped"&&($e=!Array.from(Tt.values()).some(tt=>tt.has(we)));return $e&&Jy(te,[U.name,U.id,U.description,U.sourceLabel,U.source,U.path])}),[y,te,Z,Tt]),nt=m.useMemo(()=>b.filter(U=>Jy(te,[U.id,U.name,U.displayName,U.description,U.version,U.packageDir,Array.isArray(U.tags)?U.tags.join(" "):""])),[b,te]),gt=le||Je||a==="skills",Ve=m.useMemo(()=>st.find(U=>Zn(U)===fe)||st[0]||null,[st,fe]),Rt=m.useMemo(()=>Te.find(U=>Zn(U)===fe)||Te[0]||null,[Te,fe]),Pt=m.useMemo(()=>nt.find(U=>Mo(U)===fe)||nt[0]||null,[nt,fe]),jn=Rt?Ne[Zn(Rt)]:null,rt=Ve?Re[Zn(Ve)]:null,Mn=Ve&&_t?ae[`${Zn(Ve)}:${_t}`]:null,pn=n(le?"project:searchNodes":Je?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!Rt)return;const U=Zn(Rt);if(Ne[U])return;let we=!1;return xt(U),fetch(`/api/skills/detail?key=${encodeURIComponent(U)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&Ae.skill&&He(tt=>({...tt,[U]:Ae.skill}))}).catch(()=>{}).finally(()=>{we||xt("")}),()=>{we=!0}},[a,Rt,Ne]),m.useEffect(()=>{if(!le||!Ve)return;const U=Zn(Ve);if(Re[U])return;let we=!1;return Ot(U),fetch(`/api/nodes/detail?id=${encodeURIComponent(Ve.id)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&<(tt=>({...tt,[U]:Ae}))}).catch(()=>{}).finally(()=>{we||Ot("")}),()=>{we=!0}},[le,Ve,Re]),m.useEffect(()=>{if(!le)return;const U=Array.isArray(rt==null?void 0:rt.files)?rt.files:[];Xt(we=>{var $e;return we&&U.some(Ae=>Ae.path===we)?we:(($e=U[0])==null?void 0:$e.path)||""})},[le,rt]),m.useEffect(()=>{if(!le||!Ve||!_t)return;const U=`${Zn(Ve)}:${_t}`;if(ae[U])return;let we=!1;return it(U),fetch(`/api/nodes/file?id=${encodeURIComponent(Ve.id)}&path=${encodeURIComponent(_t)}`).then($e=>$e.json().then(Ae=>({ok:$e.ok,json:Ae}))).then(({ok:$e,json:Ae})=>{we||$e&&ke(tt=>({...tt,[U]:Ae}))}).catch(()=>{}).finally(()=>{we||it("")}),()=>{we=!0}},[le,Ve,_t,ae]),m.useEffect(()=>{Ut("")},[fe,a]);const Bs=U=>{r(Tp(U,"workspace"))},Hs=U=>{ie(kN(U)),r(Tp({id:U.flowId,source:U.flowSource,archived:!!U.archived},"workspace"))},oe=m.useCallback(U=>{var we,$e;U.preventDefault(),U.stopPropagation(),($e=(we=U.dataTransfer)==null?void 0:we.types)!=null&&$e.includes("Files")&&(Sr.current+=1,W(!0))},[]),ve=m.useCallback(U=>{U.preventDefault(),U.stopPropagation(),Sr.current-=1,Sr.current<=0&&(Sr.current=0,W(!1))},[]),Me=m.useCallback(U=>{U.preventDefault(),U.stopPropagation()},[]),jt=m.useCallback(U=>{var Ae,tt;U.preventDefault(),U.stopPropagation(),Sr.current=0,W(!1);const we=(tt=(Ae=U.dataTransfer)==null?void 0:Ae.files)==null?void 0:tt[0];if(!we)return;const $e=we.name.toLowerCase();!$e.endsWith(".yaml")&&!$e.endsWith(".yml")&&!$e.endsWith(".zip")||X(we)},[]);return s.jsxs("div",{className:"af-projects"+(K?" af-projects--drop-target":""),onDragEnter:oe,onDragLeave:ve,onDragOver:Me,onDrop:jt,children:[s.jsxs("header",{className:"af-projects-top",children:[e?s.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):s.jsxs("div",{className:"af-projects-tabs",children:[s.jsx("button",{type:"button",className:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),s.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),s.jsxs("div",{className:"af-projects-top-right",children:[gt?null:s.jsxs("div",{className:"af-scope-switch af-project-scope-switch","aria-label":"Project 视图",children:[s.jsx("button",{type:"button",className:p==="personal"?"is-active":"",onClick:()=>f("personal"),children:"个人"}),s.jsx("button",{type:"button",className:p==="team"?"is-active":"",onClick:()=>f("team"),children:"团队"})]}),s.jsxs("div",{className:"af-search-wrap",children:[s.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),s.jsx("input",{className:"af-search"+(te.trim()?" af-search--has-clear":""),type:"search",placeholder:pn,"aria-label":pn,autoComplete:"off",value:te,onChange:U=>ee(U.target.value),onKeyDown:U=>{U.key==="Escape"&&(ee(""),U.currentTarget.blur())}}),te.trim()?s.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>ee(""),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),gt?s.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>fn(),children:n("project:refreshResources")}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"af-icon-btn"+(G?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":G,"aria-controls":"af-recent-activity-panel",onClick:()=>ne(U=>!U),children:s.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),s.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>H(!0),children:n("project:createNew")})]})]})]}),s.jsxs("div",{className:"af-projects-body",children:[s.jsxs("section",{className:"af-projects-main",children:[s.jsxs("header",{className:"af-projects-section-head",children:[s.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")}),s.jsx("p",{className:"af-projects-sub",children:pr?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?st.length:a==="my-flows"?nt.length:a==="skills"?Te.length:Kn.length}):a==="my-nodes"?n("project:myNodesHint",{count:st.length}):a==="my-flows"?n("project:myFlowsHint",{count:nt.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:y.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),E?s.jsx("p",{className:"af-err af-projects-api-hint",children:E}):null,D&>?s.jsx("p",{className:"af-err af-projects-api-hint",children:D}):null]}),gt?s.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?s.jsx(uz,{onChanged:fn,canManage:!!(t!=null&&t.isAdmin)}):null,s.jsxs("div",{className:"af-resource-purpose",children:[s.jsx("span",{className:"material-symbols-outlined",children:Je?"schema":le?he?"deployed_code":"account_tree":"extension"}),s.jsxs("div",{children:[s.jsx("h3",{children:n(Je?"project:myFlowsPurposeTitle":he?"project:myNodesPurposeTitle":le?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),s.jsx("p",{children:n(Je?"project:myFlowsPurposeDesc":he?"project:myNodesPurposeDesc":le?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),Je?null:s.jsxs(s.Fragment,{children:[le?s.jsxs("div",{className:"af-resource-filter-row",children:[s.jsx("button",{type:"button",className:"af-resource-filter"+(he?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),de("all"),ge("")},children:n("project:nodeScopeAll")}),s.jsx("button",{type:"button",className:"af-resource-filter"+(he?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),de("all"),ge("")},children:n("project:nodeScopeMine")})]}):null,s.jsx("div",{className:"af-resource-filter-row",children:(le?(he?_z:Nz).map(U=>({id:U,label:n(`project:resourceFilter.${U}`)})):ue).map(U=>U.collection?s.jsxs("span",{className:"af-resource-filter-chip"+(Z===U.id?" af-resource-filter-chip--active":""),children:[s.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{de(U.id),ge("")},children:[U.label,s.jsx("em",{children:U.count}),U.collection.builtin?s.jsx("strong",{children:"built-in"}):null]}),o&&!U.collection.builtin?s.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${U.collection.name}`,onClick:()=>Gr(U.collection.id),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},U.id):s.jsx("button",{type:"button",className:"af-resource-filter"+(Z===U.id?" af-resource-filter--active":""),onClick:()=>{de(U.id),ge("")},children:U.label},U.id))})]}),a==="skills"&&o?s.jsx("div",{className:"af-skill-collections-manager",children:s.jsxs("div",{className:"af-skill-collections-create",children:[s.jsx("input",{className:"af-set-input af-set-input--sm",value:_,onChange:U=>S(U.target.value),onKeyDown:U=>{U.key==="Enter"&&Ir()},placeholder:"新建 skill collection"}),s.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!_.trim()||N,onClick:()=>Ir(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,le?s.jsx("div",{className:"af-resource-grid",children:st.length>0?st.map(U=>s.jsxs("button",{type:"button",className:"af-resource-card"+(Ve&&Zn(U)===Zn(Ve)?" af-resource-card--active":""),onClick:()=>ge(Zn(U)),children:[s.jsxs("div",{className:"af-resource-card-head",children:[s.jsx("span",{className:Vl(U.type==="control"?"secondary":U.type==="provide"?"primary":"muted"),children:s.jsx(Qn,{query:te,children:U.type||"node"})}),s.jsx("span",{className:"af-resource-source",children:s.jsx(Qn,{query:te,children:xN(U.source,n)})})]}),s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:te,children:U.label||U.displayName||U.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:te,children:U.description||n("project:noDescription")})}),s.jsxs("div",{className:"af-resource-meta-row",children:[s.jsx("span",{children:s.jsx(Qn,{query:te,children:U.id})}),s.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(U.inputs||{}).length,outputs:Object.keys(U.outputs||{}).length})})]}),U.packageId?s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:te,children:`${U.packageId}${U.version?` / ${U.version}`:""}`})})]}):null]},`${U.id}:${U.source||""}:${U.packageId||""}`)):B?s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:pr?n("project:noNodeMatch",{query:te.trim()}):n(he?"project:noMyNodes":"project:noNodes")})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):Je?s.jsx("div",{className:"af-resource-grid",children:nt.length>0?nt.map(U=>{const we=nP(U),$e=rP(U),Ae=Number.isFinite(Number(U.nodeCount))?Number(U.nodeCount):we.length,tt=Number.isFinite(Number(U.edgeCount))?Number(U.edgeCount):$e.length;return s.jsxs("button",{type:"button",className:"af-resource-card"+(Pt&&Mo(U)===Mo(Pt)?" af-resource-card--active":""),onClick:()=>ge(Mo(U)),children:[s.jsxs("div",{className:"af-resource-card-head",children:[s.jsx("span",{className:Vl("primary"),children:s.jsx(Qn,{query:te,children:U.version?`v${U.version}`:"flow"})}),s.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:te,children:U.displayName||U.name||U.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:te,children:U.description||n("project:noDescription")})}),s.jsxs("div",{className:"af-resource-meta-row",children:[s.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ae,edges:tt})}),s.jsx("span",{children:s.jsx(Qn,{query:te,children:U.id})})]}),s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:te,children:bN(U)})})]})]},Mo(U))}):B?s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:pr?n("project:noFlowSnippetMatch",{query:te.trim()}):n("project:noMyFlows")})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?s.jsx("div",{className:"af-resource-grid",children:Te.length>0?Te.map(U=>{const we=Zn(U),$e=k.filter(Ae=>{var tt;return(tt=Tt.get(Ae.id))==null?void 0:tt.has(we)});return s.jsxs("button",{type:"button",className:"af-resource-card"+(Rt&&we===Zn(Rt)?" af-resource-card--active":""),onClick:()=>ge(we),children:[s.jsxs("div",{className:"af-resource-card-head",children:[s.jsx("span",{className:Vl(U.source==="builtin"?"muted":"primary"),children:s.jsx(Qn,{query:te,children:U.sourceLabel||U.source||"skill"})}),s.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:te,children:U.name||U.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:te,children:U.description||n("project:noDescription")})}),s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:te,children:U.path||U.key||""})})]}),s.jsxs("div",{className:"af-skill-card-collections",children:[$e.slice(0,3).map(Ae=>s.jsx("span",{children:Ae.name},Ae.id)),$e.length===0?s.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},U.key||`${U.source}:${U.name}`)}):B?s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:pr?n("project:noSkillMatch",{query:te.trim()}):n("project:noSkills")})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):s.jsxs(s.Fragment,{children:[t!=null&&t.isAdmin&&a==="all"&&jr.length>0?s.jsxs("div",{className:"af-project-admin-panel",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"已隐藏内置"}),s.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),s.jsx("div",{className:"af-project-admin-hidden-list",children:jr.map(U=>{const we=Nt===`show-builtin:builtin:${U}`;return s.jsxs("button",{type:"button",disabled:we,onClick:()=>ar({id:U,source:"builtin"},"show-builtin"),children:[s.jsx("span",{children:U}),s.jsx("em",{children:we?"恢复中":"恢复"})]},U)})})]}):null,s.jsxs("div",{className:"af-project-grid",children:[Kn.length>0?Kn.map(U=>{var In,Wt,$n,mr,Nr;const we=(t==null?void 0:t.isAdmin)&&U.source==="user"&&!U.archived&&!lr.has(U.id),$e=(t==null?void 0:t.isAdmin)&&U.source==="admin",Ae=(t==null?void 0:t.isAdmin)&&U.source==="builtin",tt=Nt.endsWith(`:${U.source}:${U.id}`);return s.jsx("div",{className:wz(U.source),role:"button",tabIndex:0,onClick:()=>Bs(U),onKeyDown:on=>{(on.key==="Enter"||on.key===" ")&&(on.preventDefault(),Bs(U))},children:s.jsxs("div",{className:"af-project-card-body",children:[s.jsx("span",{className:Vl(Hx(U.source,n).tone),children:s.jsx(Qn,{query:te,children:Hx(U.source,n).label})}),(In=U.collaboration)!=null&&In.role?s.jsx("span",{className:Vl(U.collaboration.role==="owner"?"primary":"muted"),children:U.collaboration.role==="owner"?(Wt=U.collaboration.teamShares)!=null&&Wt.length?"已分享团队":"我创建的":U.collaboration.accessSource==="team"?`${((mr=($n=U.collaboration.teamShares)==null?void 0:$n.find(on=>on.teamId===U.collaboration.teamId))==null?void 0:mr.teamName)||"团队"}共享`:`${U.collaboration.ownerUsername||U.collaboration.ownerId} 分享`}):null,U.archived?s.jsx("span",{className:Vl("muted"),children:s.jsx(Qn,{query:te,children:n("project:archived")})}):null,s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:te,children:U.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:te,children:ZI(U,n)})}),s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:te,children:QI(U)})})]}),t!=null&&t.isAdmin?s.jsxs("div",{className:"af-project-admin-actions",onClick:on=>on.stopPropagation(),onKeyDown:on=>on.stopPropagation(),children:[we?s.jsx("button",{type:"button",disabled:tt,onClick:()=>ar(U,"promote"),children:"设为内置"}):null,$e?s.jsx("button",{type:"button",disabled:tt,onClick:()=>ar(U,"unpromote"),children:"取消内置"}):null,Ae?s.jsx("button",{type:"button",disabled:tt,onClick:()=>ar(U,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${U.id}:${U.source??"user"}:${U.archived?"a":""}:${((Nr=U.collaboration)==null?void 0:Nr.id)||"own"}`)}):$?hr.length===0?s.jsxs("div",{className:"af-projects-empty-block",children:[s.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):c.length>0?n("project:noActive"):n(E?"project:loadFailed":"project:noPipelines")}),!E&&c.length===0&&a==="all"?s.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:te.trim()})})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),s.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>H(!0),children:[s.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),s.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),Ye?null:s.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[s.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),s.jsxs("span",{className:"af-hub-card__eyebrow",children:[s.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),s.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),s.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),s.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),s.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),s.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),gt?s.jsx("aside",{className:"af-resource-detail","aria-label":n(le?"project:nodeDetail":Je?"project:flowDetail":"project:skillDetail"),children:le&&Ve?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-resource-detail-head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),s.jsxs("div",{children:[s.jsx("h3",{children:Ve.label||Ve.displayName||Ve.id}),s.jsx("p",{children:Ve.id})]})]}),s.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(U=>s.jsx("button",{type:"button",className:"af-resource-detail-tab"+(Oe===U?" af-resource-detail-tab--active":""),onClick:()=>_e(U),children:n(`project:nodeDetailTabs.${U}`)},U))}),kt===Zn(Ve)?s.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):Oe==="overview"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"af-resource-detail-desc",children:Ve.description||((Dt=rt==null?void 0:rt.node)==null?void 0:Dt.description)||n("project:noDescription")}),s.jsxs("dl",{className:"af-resource-detail-kv",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailType")}),s.jsx("dd",{children:Ve.type||((sn=rt==null?void 0:rt.node)==null?void 0:sn.type)||"node"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailSource")}),s.jsx("dd",{children:xN(Ve.source,n)})]}),Ve.packageId?s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPackage")}),s.jsx("dd",{children:Ve.packageId})]}):null,Ve.version?s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailVersion")}),s.jsx("dd",{children:Ve.version})]}):null,Ve.packageDir||rt!=null&&rt.baseDir?s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPath")}),s.jsx("dd",{children:Ve.packageDir||(rt==null?void 0:rt.baseDir)})]}):null,s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailEditable")}),s.jsx("dd",{children:(rt==null?void 0:rt.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),he&&Ve.source==="marketplace"?s.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[s.jsx("h4",{children:n("project:myNodeManagement")}),s.jsx("p",{children:n("project:deleteMyNodeHint")}),s.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Ee===Zn(Ve),onClick:()=>Hn(Ve),children:[s.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ee===Zn(Ve)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),en?s.jsx("p",{className:"af-resource-action-message",children:en}):null]}):null,s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:resourceMeaning")}),s.jsx("p",{children:n("project:nodesMeaning")})]})]}):Oe==="schema"?s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeSchema")}),s.jsxs("div",{className:"af-resource-slot-group",children:[s.jsx("span",{children:n("project:nodeInputs")}),Rp(((Nn=rt==null?void 0:rt.node)==null?void 0:Nn.inputs)||Ve.inputs).length>0?Rp(((Jn=rt==null?void 0:rt.node)==null?void 0:Jn.inputs)||Ve.inputs).map(U=>s.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):s.jsx("em",{children:n("project:noSlots")})]}),s.jsxs("div",{className:"af-resource-slot-group",children:[s.jsx("span",{children:n("project:nodeOutputs")}),Rp(((js=rt==null?void 0:rt.node)==null?void 0:js.outputs)||Ve.outputs).length>0?Rp(((Ns=rt==null?void 0:rt.node)==null?void 0:Ns.outputs)||Ve.outputs).map(U=>s.jsxs("code",{children:[U.name||U.key,U.type?`: ${U.type}`:""]},U.key)):s.jsx("em",{children:n("project:noSlots")})]})]}):Oe==="runtime"?s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeRuntime")}),rt!=null&&rt.runtime?s.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(rt.runtime,null,2)}):s.jsx("p",{children:n("project:noRuntimeManifest")}),rt!=null&&rt.body?s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),s.jsx("pre",{className:"af-resource-skill-preview",children:rt.body})]}):s.jsx("p",{children:n("project:noNodeBody")})]}):Oe==="files"?s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(rt==null?void 0:rt.files)&&rt.files.length>0?s.jsxs("div",{className:"af-node-file-browser",children:[s.jsx("div",{className:"af-node-file-list",children:rt.files.map(U=>s.jsxs("button",{type:"button",className:"af-node-file-item"+(_t===U.path?" af-node-file-item--active":""),onClick:()=>Xt(U.path),children:[s.jsx("span",{className:"material-symbols-outlined",children:"description"}),s.jsx("span",{children:U.path})]},U.path))}),s.jsxs("pre",{className:"af-resource-skill-preview",children:[Ue===`${Zn(Ve)}:${_t}`?n("project:loadingResources"):Mn!=null&&Mn.binary?n("project:binaryFile"):(Mn==null?void 0:Mn.content)||n("project:selectNodeFile"),Mn!=null&&Mn.truncated?`
|
|
43
|
+
|
|
44
|
+
${n("project:fileTruncated")}`:""]})]}):s.jsx("p",{children:n("project:noNodeFiles")})]}):s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(rt==null?void 0:rt.usage)&&rt.usage.length>0?s.jsx("div",{className:"af-node-usage-list",children:rt.usage.map(U=>s.jsxs("div",{className:"af-node-usage-item",children:[s.jsx("strong",{children:U.flowId}),s.jsxs("span",{children:[U.flowSource,U.archived?` · ${n("project:archived")}`:""]}),s.jsx("em",{children:U.instances.map(we=>we.label||we.instanceId).join(", ")})]},`${U.flowSource}:${U.flowId}:${U.archived?"a":""}`))}):s.jsx("p",{children:n("project:noNodeUsage")})]})]}):Je&&Pt?(()=>{const U=$z(Pt);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-resource-detail-head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"schema"}),s.jsxs("div",{children:[s.jsx("h3",{children:Pt.displayName||Pt.name||Pt.id}),s.jsx("p",{children:Pt.id})]})]}),s.jsx("p",{className:"af-resource-detail-desc",children:Pt.description||n("project:noDescription")}),s.jsxs("dl",{className:"af-resource-detail-kv",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailVersion")}),s.jsx("dd",{children:Pt.version||"1.0.0"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPath")}),s.jsx("dd",{children:bN(Pt)})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:flowSnippetScale")}),s.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Pt.nodeCount))?Number(Pt.nodeCount):U.nodes.length,edges:Number.isFinite(Number(Pt.edgeCount))?Number(Pt.edgeCount):U.edges.length})})]})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:resourceMeaning")}),s.jsx("p",{children:n("project:myFlowsMeaning")})]}),s.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[s.jsx("h4",{children:n("project:myFlowManagement")}),s.jsx("p",{children:n("project:deleteMyFlowHint")}),s.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:wt===Mo(Pt),onClick:()=>Dr(Pt),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),wt===Mo(Pt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),se?s.jsx("p",{className:"af-resource-action-message",children:se}):null]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:flowSnippetPreview")}),U.diagram.nodes.length>0?s.jsx("div",{className:"af-flow-snippet-map",children:s.jsxs("svg",{viewBox:U.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[s.jsx("defs",{children:s.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:s.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),s.jsx("g",{className:"af-flow-snippet-map__edges",children:U.diagram.edges.map(we=>s.jsxs("g",{children:[s.jsx("path",{d:we.path}),we.label?s.jsx("text",{x:we.labelX,y:we.labelY-5,textAnchor:"middle",children:Xy(we.label,18)}):null]},we.key))}),s.jsx("g",{className:"af-flow-snippet-map__nodes",children:U.diagram.nodes.map((we,$e)=>s.jsxs("g",{transform:`translate(${we.x} ${we.y})`,children:[s.jsx("rect",{width:we.width,height:we.height,rx:"10"}),s.jsx("circle",{cx:"19",cy:we.height/2,r:"12"}),s.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:we.height/2+4,textAnchor:"middle",children:$e+1}),s.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:we.height/2-3,children:Xy(we.title)}),s.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:we.height/2+16,children:Xy(we.meta||we.id,20)})]},we.id))})]})}):s.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),s.jsxs("details",{className:"af-flow-snippet-json",children:[s.jsx("summary",{children:n("project:flowSnippetJson")}),s.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Pt.snippet||{},null,2)})]})]})]})})():a==="skills"&&Rt?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-resource-detail-head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),s.jsxs("div",{children:[s.jsx("h3",{children:Rt.name||Rt.id}),s.jsx("p",{children:Rt.sourceLabel||Rt.source})]})]}),s.jsx("p",{className:"af-resource-detail-desc",children:Rt.description||n("project:noDescription")}),s.jsxs("dl",{className:"af-resource-detail-kv",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailSource")}),s.jsx("dd",{children:Rt.sourceLabel||Rt.source})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPath")}),s.jsx("dd",{children:Rt.path||Rt.key})]})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:"Collections"}),k.length===0?s.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):s.jsx("div",{className:"af-skill-detail-collections",children:k.map(U=>{const we=Zn(Rt),$e=Tt.get(U.id)||new Set,Ae=$e.has(we);return s.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[s.jsx("input",{type:"checkbox",checked:Ae,disabled:N||!o,onChange:tt=>gn(U.id,we,tt.target.checked)}),s.jsxs("span",{className:"af-composer-skill-option-main",children:[s.jsx("span",{className:"af-composer-skill-option-title",children:U.name}),s.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},U.id)})})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:resourceMeaning")}),s.jsx("p",{children:n("project:skillsMeaning")})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:skillPreview")}),s.jsx("pre",{className:"af-resource-skill-preview",children:ct===Zn(Rt)?n("project:loadingResources"):(jn==null?void 0:jn.body)||(jn==null?void 0:jn.content)||n("project:skillPreviewEmpty")})]})]}):s.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):s.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(G?"":" af-activity--hidden"),"aria-hidden":!G,"aria-label":n("project:recentActivity"),children:[s.jsxs("h2",{className:"af-activity-title",children:[s.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),s.jsx("div",{className:"af-activity-list",children:Vn.length===0?s.jsx("p",{className:"af-activity-empty",children:Yn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Vn.map(U=>{const we=re===kN(U);return s.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(we?" af-activity-row--active":""),"aria-current":we?"page":void 0,onClick:()=>Hs(U),children:[s.jsxs("div",{className:"af-activity-row-top",children:[s.jsx("h4",{className:"af-activity-name",children:s.jsx(Qn,{query:te,children:U.flowId})}),s.jsx("span",{className:"af-activity-time",children:yN(U.at,n)})]}),s.jsxs("div",{className:"af-activity-meta",children:[s.jsx("span",{className:xz(U.kind),children:U.kind==="executed"?"play_arrow":"visibility"}),s.jsxs("p",{className:"af-activity-text",children:[U.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",yN(U.at,n)]})]})]},`${U.kind}-${U.flowId}-${U.flowSource}-${U.at}`)})})]})]}),s.jsx(tz,{open:R,onClose:()=>H(!1),onCreated:async U=>{H(!1),await tr();const we=U.source??"user";r(Tp({id:U.id,source:we},"workspace"))}}),A?s.jsx(ZF,{file:A,onClose:()=>X(null),onImported:async U=>{X(null),await tr();const we=U.source??"user";r(Tp({id:U.id,source:we},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}const Lz="modulepreload",Oz=function(e){return"/"+e},jN={},sP=function(t,n,r){let i=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"));i=Promise.allSettled(n.map(c=>{if(c=Oz(c),c in jN)return;jN[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Lz,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function or(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=or(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Dz={value:()=>{}};function og(){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 vh(n)}function vh(e){this._=e}function Fz(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}vh.prototype=og.prototype={constructor:vh,on:function(e,t){var n=this._,r=Fz(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=zz(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=NN(n[i],e.name,t);else if(t==null)for(i in n)n[i]=NN(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new vh(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function zz(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function NN(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Dz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var qx="http://www.w3.org/1999/xhtml";const _N={svg:"http://www.w3.org/2000/svg",xhtml:qx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ag(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),_N.hasOwnProperty(t)?{space:_N[t],local:e}:e}function Wz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===qx&&t.documentElement.namespaceURI===qx?t.createElement(e):t.createElementNS(n,e)}}function Bz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function iP(e){var t=ag(e);return(t.local?Bz:Wz)(t)}function Hz(){}function Bk(e){return e==null?Hz:function(){return this.querySelector(e)}}function Vz(e){typeof e!="function"&&(e=Bk(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,l=r[i]=new Array(a),c,u,p=0;p<a;++p)(c=o[p])&&(u=e.call(c,c.__data__,p,o))&&("__data__"in c&&(u.__data__=c.__data__),l[p]=u);return new ks(r,this._parents)}function Kz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function qz(){return[]}function oP(e){return e==null?qz:function(){return this.querySelectorAll(e)}}function Uz(e){return function(){return Kz(e.apply(this,arguments))}}function Gz(e){typeof e=="function"?e=Uz(e):e=oP(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var a=t[o],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(r.push(e.call(c,c.__data__,u,a)),i.push(c));return new ks(r,i)}function aP(e){return function(){return this.matches(e)}}function lP(e){return function(t){return t.matches(e)}}var Yz=Array.prototype.find;function Jz(e){return function(){return Yz.call(this.children,e)}}function Xz(){return this.firstElementChild}function Qz(e){return this.select(e==null?Xz:Jz(typeof e=="function"?e:lP(e)))}var Zz=Array.prototype.filter;function e3(){return Array.from(this.children)}function t3(e){return function(){return Zz.call(this.children,e)}}function n3(e){return this.selectAll(e==null?e3:t3(typeof e=="function"?e:lP(e)))}function r3(e){typeof e!="function"&&(e=aP(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,l=r[i]=[],c,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new ks(r,this._parents)}function cP(e){return new Array(e.length)}function s3(){return new ks(this._enter||this._groups.map(cP),this._parents)}function om(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}om.prototype={constructor:om,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 i3(e){return function(){return e}}function o3(e,t,n,r,i,o){for(var a=0,l,c=t.length,u=o.length;a<u;++a)(l=t[a])?(l.__data__=o[a],r[a]=l):n[a]=new om(e,o[a]);for(;a<c;++a)(l=t[a])&&(i[a]=l)}function a3(e,t,n,r,i,o,a){var l,c,u=new Map,p=t.length,f=o.length,d=new Array(p),h;for(l=0;l<p;++l)(c=t[l])&&(d[l]=h=a.call(c,c.__data__,l,t)+"",u.has(h)?i[l]=c:u.set(h,c));for(l=0;l<f;++l)h=a.call(e,o[l],l,o)+"",(c=u.get(h))?(r[l]=c,c.__data__=o[l],u.delete(h)):n[l]=new om(e,o[l]);for(l=0;l<p;++l)(c=t[l])&&u.get(d[l])===c&&(i[l]=c)}function l3(e){return e.__data__}function c3(e,t){if(!arguments.length)return Array.from(this,l3);var n=t?a3:o3,r=this._parents,i=this._groups;typeof e!="function"&&(e=i3(e));for(var o=i.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var p=r[u],f=i[u],d=f.length,h=u3(e.call(p,p&&p.__data__,u,r)),y=h.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(d);n(p,f,v,b,g,h,t);for(var k=0,x=0,_,S;k<y;++k)if(_=v[k]){for(k>=x&&(x=k+1);!(S=b[x])&&++x<y;);_._next=S||null}}return a=new ks(a,r),a._enter=l,a._exit=c,a}function u3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function d3(){return new ks(this._exit||this._groups.map(cP),this._parents)}function f3(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function p3(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,a=Math.min(i,o),l=new Array(i),c=0;c<a;++c)for(var u=n[c],p=r[c],f=u.length,d=l[c]=new Array(f),h,y=0;y<f;++y)(h=u[y]||p[y])&&(d[y]=h);for(;c<i;++c)l[c]=n[c];return new ks(l,this._parents)}function h3(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],a;--i>=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function m3(e){e||(e=g3);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,c=i[o]=new Array(l),u,p=0;p<l;++p)(u=a[p])&&(c[p]=u);c.sort(t)}return new ks(i,this._parents).order()}function g3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function y3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function w3(){return Array.from(this)}function x3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null}function b3(){let e=0;for(const t of this)++e;return e}function k3(){return!this.node()}function v3(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,a=i.length,l;o<a;++o)(l=i[o])&&e.call(l,l.__data__,o,i);return this}function S3(e){return function(){this.removeAttribute(e)}}function j3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function N3(e,t){return function(){this.setAttribute(e,t)}}function _3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function C3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function A3(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 E3(e,t){var n=ag(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?j3:S3:typeof t=="function"?n.local?A3:C3:n.local?_3:N3)(n,t))}function uP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function I3(e){return function(){this.style.removeProperty(e)}}function P3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function T3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function R3(e,t,n){return arguments.length>1?this.each((t==null?I3:typeof t=="function"?T3:P3)(e,t,n??"")):zc(this.node(),e)}function zc(e,t){return e.style.getPropertyValue(t)||uP(e).getComputedStyle(e,null).getPropertyValue(t)}function M3(e){return function(){delete this[e]}}function $3(e,t){return function(){this[e]=t}}function L3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function O3(e,t){return arguments.length>1?this.each((t==null?M3:typeof t=="function"?L3:$3)(e,t)):this.node()[e]}function dP(e){return e.trim().split(/^|\s+/)}function Hk(e){return e.classList||new fP(e)}function fP(e){this._node=e,this._names=dP(e.getAttribute("class")||"")}fP.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=Hk(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function hP(e,t){for(var n=Hk(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function D3(e){return function(){pP(this,e)}}function F3(e){return function(){hP(this,e)}}function z3(e,t){return function(){(t.apply(this,arguments)?pP:hP)(this,e)}}function W3(e,t){var n=dP(e+"");if(arguments.length<2){for(var r=Hk(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?z3:t?D3:F3)(n,t))}function B3(){this.textContent=""}function H3(e){return function(){this.textContent=e}}function V3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function K3(e){return arguments.length?this.each(e==null?B3:(typeof e=="function"?V3:H3)(e)):this.node().textContent}function q3(){this.innerHTML=""}function U3(e){return function(){this.innerHTML=e}}function G3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Y3(e){return arguments.length?this.each(e==null?q3:(typeof e=="function"?G3:U3)(e)):this.node().innerHTML}function J3(){this.nextSibling&&this.parentNode.appendChild(this)}function X3(){return this.each(J3)}function Q3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Z3(){return this.each(Q3)}function eW(e){var t=typeof e=="function"?e:iP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function tW(){return null}function nW(e,t){var n=typeof e=="function"?e:iP(e),r=t==null?tW:typeof t=="function"?t:Bk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function rW(){var e=this.parentNode;e&&e.removeChild(this)}function sW(){return this.each(rW)}function iW(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oW(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function aW(e){return this.select(e?oW:iW)}function lW(e){return arguments.length?this.property("__data__",e):this.node().__data__}function cW(e){return function(t){e.call(this,t,this.__data__)}}function uW(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 dW(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function fW(e,t,n){return function(){var r=this.__on,i,o=cW(t);if(r){for(var a=0,l=r.length;a<l;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function pW(e,t,n){var r=uW(e+""),i,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,p;c<u;++c)for(i=0,p=l[c];i<o;++i)if((a=r[i]).type===p.type&&a.name===p.name)return p.value}return}for(l=t?fW:dW,i=0;i<o;++i)this.each(l(r[i],t,n));return this}function mP(e,t,n){var r=uP(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function hW(e,t){return function(){return mP(this,e,t)}}function mW(e,t){return function(){return mP(this,e,t.apply(this,arguments))}}function gW(e,t){return this.each((typeof t=="function"?mW:hW)(e,t))}function*yW(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,a;i<o;++i)(a=r[i])&&(yield a)}var gP=[null];function ks(e,t){this._groups=e,this._parents=t}function _f(){return new ks([[document.documentElement]],gP)}function wW(){return this}ks.prototype=_f.prototype={constructor:ks,select:Vz,selectAll:Gz,selectChild:Qz,selectChildren:n3,filter:r3,data:c3,enter:s3,exit:d3,join:f3,merge:p3,selection:wW,order:h3,sort:m3,call:y3,nodes:w3,node:x3,size:b3,empty:k3,each:v3,attr:E3,style:R3,property:O3,classed:W3,text:K3,html:Y3,raise:X3,lower:Z3,append:eW,insert:nW,remove:sW,clone:aW,datum:lW,on:pW,dispatch:gW,[Symbol.iterator]:yW};function ms(e){return typeof e=="string"?new ks([[document.querySelector(e)]],[document.documentElement]):new ks([[e]],gP)}function xW(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ri(e,t){if(e=xW(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 i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const bW={passive:!1},Jd={capture:!0,passive:!1};function Qy(e){e.stopImmediatePropagation()}function Nc(e){e.preventDefault(),e.stopImmediatePropagation()}function yP(e){var t=e.document.documentElement,n=ms(e).on("dragstart.drag",Nc,Jd);"onselectstart"in t?n.on("selectstart.drag",Nc,Jd):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function wP(e,t){var n=e.document.documentElement,r=ms(e).on("dragstart.drag",null);t&&(r.on("click.drag",Nc,Jd),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 Mp=e=>()=>e;function Ux(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:l,dx:c,dy:u,dispatch:p}){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:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:p}})}Ux.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function kW(e){return!e.ctrlKey&&!e.button}function vW(){return this.parentNode}function SW(e,t){return t??{x:e.x,y:e.y}}function jW(){return navigator.maxTouchPoints||"ontouchstart"in this}function xP(){var e=kW,t=vW,n=SW,r=jW,i={},o=og("start","drag","end"),a=0,l,c,u,p,f=0;function d(_){_.on("mousedown.drag",h).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,bW).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(_,S){if(!(p||!e.call(this,_,S))){var N=x(this,t.call(this,_,S),_,S,"mouse");N&&(ms(_.view).on("mousemove.drag",y,Jd).on("mouseup.drag",v,Jd),yP(_.view),Qy(_),u=!1,l=_.clientX,c=_.clientY,N("start",_))}}function y(_){if(Nc(_),!u){var S=_.clientX-l,N=_.clientY-c;u=S*S+N*N>f}i.mouse("drag",_)}function v(_){ms(_.view).on("mousemove.drag mouseup.drag",null),wP(_.view,u),Nc(_),i.mouse("end",_)}function b(_,S){if(e.call(this,_,S)){var N=_.changedTouches,I=t.call(this,_,S),T=N.length,z,E;for(z=0;z<T;++z)(E=x(this,I,_,S,N[z].identifier,N[z]))&&(Qy(_),E("start",_,N[z]))}}function g(_){var S=_.changedTouches,N=S.length,I,T;for(I=0;I<N;++I)(T=i[S[I].identifier])&&(Nc(_),T("drag",_,S[I]))}function k(_){var S=_.changedTouches,N=S.length,I,T;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),I=0;I<N;++I)(T=i[S[I].identifier])&&(Qy(_),T("end",_,S[I]))}function x(_,S,N,I,T,z){var E=o.copy(),O=ri(z||N,S),D,L,$;if(($=n.call(_,new Ux("beforestart",{sourceEvent:N,target:d,identifier:T,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:E}),I))!=null)return D=$.x-O[0]||0,L=$.y-O[1]||0,function V(B,F,R){var H=O,A;switch(B){case"start":i[T]=V,A=a++;break;case"end":delete i[T],--a;case"drag":O=ri(R||F,S),A=a;break}E.call(B,_,new Ux(B,{sourceEvent:F,subject:$,target:d,identifier:T,active:A,x:O[0]+D,y:O[1]+L,dx:O[0]-H[0],dy:O[1]-H[1],dispatch:E}),I)}}return d.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Mp(!!_),d):e},d.container=function(_){return arguments.length?(t=typeof _=="function"?_:Mp(_),d):t},d.subject=function(_){return arguments.length?(n=typeof _=="function"?_:Mp(_),d):n},d.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Mp(!!_),d):r},d.on=function(){var _=o.on.apply(o,arguments);return _===o?d:_},d.clickDistance=function(_){return arguments.length?(f=(_=+_)*_,d):Math.sqrt(f)},d}function Vk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function bP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Cf(){}var Xd=.7,am=1/Xd,_c="\\s*([+-]?\\d+)\\s*",Qd="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",$i="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",NW=/^#([0-9a-f]{3,8})$/,_W=new RegExp(`^rgb\\(${_c},${_c},${_c}\\)$`),CW=new RegExp(`^rgb\\(${$i},${$i},${$i}\\)$`),AW=new RegExp(`^rgba\\(${_c},${_c},${_c},${Qd}\\)$`),EW=new RegExp(`^rgba\\(${$i},${$i},${$i},${Qd}\\)$`),IW=new RegExp(`^hsl\\(${Qd},${$i},${$i}\\)$`),PW=new RegExp(`^hsla\\(${Qd},${$i},${$i},${Qd}\\)$`),CN={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};Vk(Cf,il,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:AN,formatHex:AN,formatHex8:TW,formatHsl:RW,formatRgb:EN,toString:EN});function AN(){return this.rgb().formatHex()}function TW(){return this.rgb().formatHex8()}function RW(){return kP(this).formatHsl()}function EN(){return this.rgb().formatRgb()}function il(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=NW.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?IN(t):n===3?new ns(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$p(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$p(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=_W.exec(e))?new ns(t[1],t[2],t[3],1):(t=CW.exec(e))?new ns(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=AW.exec(e))?$p(t[1],t[2],t[3],t[4]):(t=EW.exec(e))?$p(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=IW.exec(e))?RN(t[1],t[2]/100,t[3]/100,1):(t=PW.exec(e))?RN(t[1],t[2]/100,t[3]/100,t[4]):CN.hasOwnProperty(e)?IN(CN[e]):e==="transparent"?new ns(NaN,NaN,NaN,0):null}function IN(e){return new ns(e>>16&255,e>>8&255,e&255,1)}function $p(e,t,n,r){return r<=0&&(e=t=n=NaN),new ns(e,t,n,r)}function MW(e){return e instanceof Cf||(e=il(e)),e?(e=e.rgb(),new ns(e.r,e.g,e.b,e.opacity)):new ns}function Gx(e,t,n,r){return arguments.length===1?MW(e):new ns(e,t,n,r??1)}function ns(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Vk(ns,Gx,bP(Cf,{brighter(e){return e=e==null?am:Math.pow(am,e),new ns(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Xd:Math.pow(Xd,e),new ns(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ns(Ja(this.r),Ja(this.g),Ja(this.b),lm(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:PN,formatHex:PN,formatHex8:$W,formatRgb:TN,toString:TN}));function PN(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}`}function $W(){return`#${Va(this.r)}${Va(this.g)}${Va(this.b)}${Va((isNaN(this.opacity)?1:this.opacity)*255)}`}function TN(){const e=lm(this.opacity);return`${e===1?"rgb(":"rgba("}${Ja(this.r)}, ${Ja(this.g)}, ${Ja(this.b)}${e===1?")":`, ${e})`}`}function lm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ja(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Va(e){return e=Ja(e),(e<16?"0":"")+e.toString(16)}function RN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new oi(e,t,n,r)}function kP(e){if(e instanceof oi)return new oi(e.h,e.s,e.l,e.opacity);if(e instanceof Cf||(e=il(e)),!e)return new oi;if(e instanceof oi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,l=o-i,c=(o+i)/2;return l?(t===o?a=(n-r)/l+(n<r)*6:n===o?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?o+i:2-o-i,a*=60):l=c>0&&c<1?0:a,new oi(a,l,c,e.opacity)}function LW(e,t,n,r){return arguments.length===1?kP(e):new oi(e,t,n,r??1)}function oi(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Vk(oi,LW,bP(Cf,{brighter(e){return e=e==null?am:Math.pow(am,e),new oi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Xd:Math.pow(Xd,e),new oi(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,i=2*n-r;return new ns(Zy(e>=240?e-240:e+120,i,r),Zy(e,i,r),Zy(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new oi(MN(this.h),Lp(this.s),Lp(this.l),lm(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=lm(this.opacity);return`${e===1?"hsl(":"hsla("}${MN(this.h)}, ${Lp(this.s)*100}%, ${Lp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function MN(e){return e=(e||0)%360,e<0?e+360:e}function Lp(e){return Math.max(0,Math.min(1,e||0))}function Zy(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 Kk=e=>()=>e;function OW(e,t){return function(n){return e+n*t}}function DW(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 FW(e){return(e=+e)==1?vP:function(t,n){return n-t?DW(t,n,e):Kk(isNaN(t)?n:t)}}function vP(e,t){var n=t-e;return n?OW(e,n):Kk(isNaN(e)?t:e)}const cm=function e(t){var n=FW(t);function r(i,o){var a=n((i=Gx(i)).r,(o=Gx(o)).r),l=n(i.g,o.g),c=n(i.b,o.b),u=vP(i.opacity,o.opacity);return function(p){return i.r=a(p),i.g=l(p),i.b=c(p),i.opacity=u(p),i+""}}return r.gamma=e,r}(1);function zW(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=e[i]*(1-o)+t[i]*o;return r}}function WW(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function BW(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),o=new Array(n),a;for(a=0;a<r;++a)i[a]=Sd(e[a],t[a]);for(;a<n;++a)o[a]=t[a];return function(l){for(a=0;a<r;++a)o[a]=i[a](l);return o}}function HW(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ni(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function VW(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=Sd(e[i],t[i]):r[i]=t[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var Yx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ew=new RegExp(Yx.source,"g");function KW(e){return function(){return e}}function qW(e){return function(t){return e(t)+""}}function SP(e,t){var n=Yx.lastIndex=ew.lastIndex=0,r,i,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Yx.exec(e))&&(i=ew.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(i=i[0])?l[a]?l[a]+=i:l[++a]=i:(l[++a]=null,c.push({i:a,x:Ni(r,i)})),n=ew.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?qW(c[0].x):KW(t):(t=c.length,function(u){for(var p=0,f;p<t;++p)l[(f=c[p]).i]=f.x(u);return l.join("")})}function Sd(e,t){var n=typeof t,r;return t==null||n==="boolean"?Kk(t):(n==="number"?Ni:n==="string"?(r=il(t))?(t=r,cm):SP:t instanceof il?cm:t instanceof Date?HW:WW(t)?zW:Array.isArray(t)?BW:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?VW:Ni)(e,t)}var $N=180/Math.PI,Jx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function jP(e,t,n,r,i,o){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*$N,skewX:Math.atan(c)*$N,scaleX:a,scaleY:l}}var Op;function UW(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Jx:jP(t.a,t.b,t.c,t.d,t.e,t.f)}function GW(e){return e==null||(Op||(Op=document.createElementNS("http://www.w3.org/2000/svg","g")),Op.setAttribute("transform",e),!(e=Op.transform.baseVal.consolidate()))?Jx:(e=e.matrix,jP(e.a,e.b,e.c,e.d,e.e,e.f))}function NP(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function o(u,p,f,d,h,y){if(u!==f||p!==d){var v=h.push("translate(",null,t,null,n);y.push({i:v-4,x:Ni(u,f)},{i:v-2,x:Ni(p,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function a(u,p,f,d){u!==p?(u-p>180?p+=360:p-u>180&&(u+=360),d.push({i:f.push(i(f)+"rotate(",null,r)-2,x:Ni(u,p)})):p&&f.push(i(f)+"rotate("+p+r)}function l(u,p,f,d){u!==p?d.push({i:f.push(i(f)+"skewX(",null,r)-2,x:Ni(u,p)}):p&&f.push(i(f)+"skewX("+p+r)}function c(u,p,f,d,h,y){if(u!==f||p!==d){var v=h.push(i(h)+"scale(",null,",",null,")");y.push({i:v-4,x:Ni(u,f)},{i:v-2,x:Ni(p,d)})}else(f!==1||d!==1)&&h.push(i(h)+"scale("+f+","+d+")")}return function(u,p){var f=[],d=[];return u=e(u),p=e(p),o(u.translateX,u.translateY,p.translateX,p.translateY,f,d),a(u.rotate,p.rotate,f,d),l(u.skewX,p.skewX,f,d),c(u.scaleX,u.scaleY,p.scaleX,p.scaleY,f,d),u=p=null,function(h){for(var y=-1,v=d.length,b;++y<v;)f[(b=d[y]).i]=b.x(h);return f.join("")}}}var YW=NP(UW,"px, ","px)","deg)"),JW=NP(GW,", ",")",")"),XW=1e-12;function LN(e){return((e=Math.exp(e))+1/e)/2}function QW(e){return((e=Math.exp(e))-1/e)/2}function ZW(e){return((e=Math.exp(2*e))-1)/(e+1)}const Sh=function e(t,n,r){function i(o,a){var l=o[0],c=o[1],u=o[2],p=a[0],f=a[1],d=a[2],h=p-l,y=f-c,v=h*h+y*y,b,g;if(v<XW)g=Math.log(d/u)/t,b=function(I){return[l+I*h,c+I*y,u*Math.exp(t*I*g)]};else{var k=Math.sqrt(v),x=(d*d-u*u+r*v)/(2*u*n*k),_=(d*d-u*u-r*v)/(2*d*n*k),S=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(_*_+1)-_);g=(N-S)/t,b=function(I){var T=I*g,z=LN(S),E=u/(n*k)*(z*ZW(t*T+S)-QW(S));return[l+E*h,c+E*y,u*z/LN(t*T+S)]}}return b.duration=g*1e3*t/Math.SQRT2,b}return i.rho=function(o){var a=Math.max(.001,+o),l=a*a,c=l*l;return e(a,l,c)},i}(Math.SQRT2,2,4);var Wc=0,id=0,Vu=0,_P=1e3,um,od,dm=0,ol=0,lg=0,Zd=typeof performance=="object"&&performance.now?performance:Date,CP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qk(){return ol||(CP(eB),ol=Zd.now()+lg)}function eB(){ol=0}function fm(){this._call=this._time=this._next=null}fm.prototype=AP.prototype={constructor:fm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qk():+n)+(t==null?0:+t),!this._next&&od!==this&&(od?od._next=this:um=this,od=this),this._call=e,this._time=n,Xx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Xx())}};function AP(e,t,n){var r=new fm;return r.restart(e,t,n),r}function tB(){qk(),++Wc;for(var e=um,t;e;)(t=ol-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Wc}function ON(){ol=(dm=Zd.now())+lg,Wc=id=0;try{tB()}finally{Wc=0,rB(),ol=0}}function nB(){var e=Zd.now(),t=e-dm;t>_P&&(lg-=t,dm=e)}function rB(){for(var e,t=um,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:um=n);od=e,Xx(r)}function Xx(e){if(!Wc){id&&(id=clearTimeout(id));var t=e-ol;t>24?(e<1/0&&(id=setTimeout(ON,e-Zd.now()-lg)),Vu&&(Vu=clearInterval(Vu))):(Vu||(dm=Zd.now(),Vu=setInterval(nB,_P)),Wc=1,CP(ON))}}function DN(e,t,n){var r=new fm;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var sB=og("start","end","cancel","interrupt"),iB=[],EP=0,FN=1,Qx=2,jh=3,zN=4,Zx=5,Nh=6;function cg(e,t,n,r,i,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;oB(e,n,{name:t,index:r,group:i,on:sB,tween:iB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:EP})}function Uk(e,t){var n=mi(e,t);if(n.state>EP)throw new Error("too late; already scheduled");return n}function Bi(e,t){var n=mi(e,t);if(n.state>jh)throw new Error("too late; already running");return n}function mi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function oB(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=AP(o,0,n.time);function o(u){n.state=FN,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var p,f,d,h;if(n.state!==FN)return c();for(p in r)if(h=r[p],h.name===n.name){if(h.state===jh)return DN(a);h.state===zN?(h.state=Nh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[p]):+p<t&&(h.state=Nh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[p])}if(DN(function(){n.state===jh&&(n.state=zN,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Qx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Qx){for(n.state=jh,i=new Array(d=n.tween.length),p=0,f=-1;p<d;++p)(h=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(i[++f]=h);i.length=f+1}}function l(u){for(var p=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Zx,1),f=-1,d=i.length;++f<d;)i[f].call(e,p);n.state===Zx&&(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 _h(e,t){var n=e.__transition,r,i,o=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){o=!1;continue}i=r.state>Qx&&r.state<Zx,r.state=Nh,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function aB(e){return this.each(function(){_h(this,e)})}function lB(e,t){var n,r;return function(){var i=Bi(this,e),o=i.tween;if(o!==n){r=n=o;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function cB(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Bi(this,e),a=o.tween;if(a!==r){i=(r=a).slice();for(var l={name:t,value:n},c=0,u=i.length;c<u;++c)if(i[c].name===t){i[c]=l;break}c===u&&i.push(l)}o.tween=i}}function uB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=mi(this.node(),n).tween,i=0,o=r.length,a;i<o;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?lB:cB)(n,e,t))}function Gk(e,t,n){var r=e._id;return e.each(function(){var i=Bi(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return mi(i,r).value[t]}}function IP(e,t){var n;return(typeof t=="number"?Ni:t instanceof il?cm:(n=il(t))?(t=n,cm):SP)(e,t)}function dB(e){return function(){this.removeAttribute(e)}}function fB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pB(e,t,n){var r,i=n+"",o;return function(){var a=this.getAttribute(e);return a===i?null:a===r?o:o=t(r=a,n)}}function hB(e,t,n){var r,i=n+"",o;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?o:o=t(r=a,n)}}function mB(e,t,n){var r,i,o;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===r&&c===i?o:(i=c,o=t(r=a,l)))}}function gB(e,t,n){var r,i,o;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===r&&c===i?o:(i=c,o=t(r=a,l)))}}function yB(e,t){var n=ag(e),r=n==="transform"?JW:IP;return this.attrTween(e,typeof t=="function"?(n.local?gB:mB)(n,r,Gk(this,"attr."+e,t)):t==null?(n.local?fB:dB)(n):(n.local?hB:pB)(n,r,t))}function wB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function xB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function bB(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&xB(e,o)),n}return i._value=t,i}function kB(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&wB(e,o)),n}return i._value=t,i}function vB(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=ag(e);return this.tween(n,(r.local?bB:kB)(r,t))}function SB(e,t){return function(){Uk(this,e).delay=+t.apply(this,arguments)}}function jB(e,t){return t=+t,function(){Uk(this,e).delay=t}}function NB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?SB:jB)(t,e)):mi(this.node(),t).delay}function _B(e,t){return function(){Bi(this,e).duration=+t.apply(this,arguments)}}function CB(e,t){return t=+t,function(){Bi(this,e).duration=t}}function AB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_B:CB)(t,e)):mi(this.node(),t).duration}function EB(e,t){if(typeof t!="function")throw new Error;return function(){Bi(this,e).ease=t}}function IB(e){var t=this._id;return arguments.length?this.each(EB(t,e)):mi(this.node(),t).ease}function PB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Bi(this,e).ease=n}}function TB(e){if(typeof e!="function")throw new Error;return this.each(PB(this._id,e))}function RB(e){typeof e!="function"&&(e=aP(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,l=r[i]=[],c,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new go(r,this._parents,this._name,this._id)}function MB(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=n[l],p=c.length,f=a[l]=new Array(p),d,h=0;h<p;++h)(d=c[h]||u[h])&&(f[h]=d);for(;l<r;++l)a[l]=t[l];return new go(a,this._parents,this._name,this._id)}function $B(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 LB(e,t,n){var r,i,o=$B(t)?Uk:Bi;return function(){var a=o(this,e),l=a.on;l!==r&&(i=(r=l).copy()).on(t,n),a.on=i}}function OB(e,t){var n=this._id;return arguments.length<2?mi(this.node(),n).on.on(e):this.each(LB(n,e,t))}function DB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function FB(){return this.on("end.remove",DB(this._id))}function zB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bk(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var l=r[a],c=l.length,u=o[a]=new Array(c),p,f,d=0;d<c;++d)(p=l[d])&&(f=e.call(p,p.__data__,d,l))&&("__data__"in p&&(f.__data__=p.__data__),u[d]=f,cg(u[d],t,n,d,u,mi(p,n)));return new go(o,this._parents,t,n)}function WB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oP(e));for(var r=this._groups,i=r.length,o=[],a=[],l=0;l<i;++l)for(var c=r[l],u=c.length,p,f=0;f<u;++f)if(p=c[f]){for(var d=e.call(p,p.__data__,f,c),h,y=mi(p,n),v=0,b=d.length;v<b;++v)(h=d[v])&&cg(h,t,n,v,d,y);o.push(d),a.push(p)}return new go(o,a,t,n)}var BB=_f.prototype.constructor;function HB(){return new BB(this._groups,this._parents)}function VB(e,t){var n,r,i;return function(){var o=zc(this,e),a=(this.style.removeProperty(e),zc(this,e));return o===a?null:o===n&&a===r?i:i=t(n=o,r=a)}}function PP(e){return function(){this.style.removeProperty(e)}}function KB(e,t,n){var r,i=n+"",o;return function(){var a=zc(this,e);return a===i?null:a===r?o:o=t(r=a,n)}}function qB(e,t,n){var r,i,o;return function(){var a=zc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),zc(this,e))),a===c?null:a===r&&c===i?o:(i=c,o=t(r=a,l))}}function UB(e,t){var n,r,i,o="style."+t,a="end."+o,l;return function(){var c=Bi(this,e),u=c.on,p=c.value[o]==null?l||(l=PP(t)):void 0;(u!==n||i!==p)&&(r=(n=u).copy()).on(a,i=p),c.on=r}}function GB(e,t,n){var r=(e+="")=="transform"?YW:IP;return t==null?this.styleTween(e,VB(e,r)).on("end.style."+e,PP(e)):typeof t=="function"?this.styleTween(e,qB(e,r,Gk(this,"style."+e,t))).each(UB(this._id,e)):this.styleTween(e,KB(e,r,t),n).on("end.style."+e,null)}function YB(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function JB(e,t,n){var r,i;function o(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&YB(e,a,n)),r}return o._value=t,o}function XB(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,JB(e,t,n??""))}function QB(e){return function(){this.textContent=e}}function ZB(e){return function(){var t=e(this);this.textContent=t??""}}function e4(e){return this.tween("text",typeof e=="function"?ZB(Gk(this,"text",e)):QB(e==null?"":e+""))}function t4(e){return function(t){this.textContent=e.call(this,t)}}function n4(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&t4(i)),t}return r._value=e,r}function r4(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,n4(e))}function s4(){for(var e=this._name,t=this._id,n=TP(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var p=mi(c,t);cg(c,e,n,u,a,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new go(r,this._parents,e,n)}function i4(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,a){var l={value:a},c={value:function(){--i===0&&o()}};n.each(function(){var u=Bi(this,r),p=u.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),i===0&&o()})}var o4=0;function go(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function TP(){return++o4}var Ji=_f.prototype;go.prototype={constructor:go,select:zB,selectAll:WB,selectChild:Ji.selectChild,selectChildren:Ji.selectChildren,filter:RB,merge:MB,selection:HB,transition:s4,call:Ji.call,nodes:Ji.nodes,node:Ji.node,size:Ji.size,empty:Ji.empty,each:Ji.each,on:OB,attr:yB,attrTween:vB,style:GB,styleTween:XB,text:e4,textTween:r4,remove:FB,tween:uB,delay:NB,duration:AB,ease:IB,easeVarying:TB,end:i4,[Symbol.iterator]:Ji[Symbol.iterator]};function a4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var l4={time:null,delay:0,duration:250,ease:a4};function c4(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 u4(e){var t,n;e instanceof go?(t=e._id,e=e._name):(t=TP(),(n=l4).time=qk(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)(c=a[u])&&cg(c,e,t,u,a,n||c4(c,t));return new go(r,this._parents,e,t)}_f.prototype.interrupt=aB;_f.prototype.transition=u4;const Dp=e=>()=>e;function d4(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:i}})}function so(e,t,n){this.k=e,this.x=t,this.y=n}so.prototype={constructor:so,scale:function(e){return e===1?this:new so(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new so(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 ug=new so(1,0,0);RP.prototype=so.prototype;function RP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ug;return e.__zoom}function tw(e){e.stopImmediatePropagation()}function Ku(e){e.preventDefault(),e.stopImmediatePropagation()}function f4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function p4(){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 WN(){return this.__zoom||ug}function h4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function m4(){return navigator.maxTouchPoints||"ontouchstart"in this}function g4(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function MP(){var e=f4,t=p4,n=g4,r=h4,i=m4,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Sh,u=og("start","zoom","end"),p,f,d,h=500,y=150,v=0,b=10;function g($){$.property("__zoom",WN).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",E).filter(i).on("touchstart.zoom",O).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function($,V,B,F){var R=$.selection?$.selection():$;R.property("__zoom",WN),$!==R?S($,V,B,F):R.interrupt().each(function(){N(this,arguments).event(F).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},g.scaleBy=function($,V,B,F){g.scaleTo($,function(){var R=this.__zoom.k,H=typeof V=="function"?V.apply(this,arguments):V;return R*H},B,F)},g.scaleTo=function($,V,B,F){g.transform($,function(){var R=t.apply(this,arguments),H=this.__zoom,A=B==null?_(R):typeof B=="function"?B.apply(this,arguments):B,X=H.invert(A),K=typeof V=="function"?V.apply(this,arguments):V;return n(x(k(H,K),A,X),R,a)},B,F)},g.translateBy=function($,V,B,F){g.transform($,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),a)},null,F)},g.translateTo=function($,V,B,F,R){g.transform($,function(){var H=t.apply(this,arguments),A=this.__zoom,X=F==null?_(H):typeof F=="function"?F.apply(this,arguments):F;return n(ug.translate(X[0],X[1]).scale(A.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof B=="function"?-B.apply(this,arguments):-B),H,a)},F,R)};function k($,V){return V=Math.max(o[0],Math.min(o[1],V)),V===$.k?$:new so(V,$.x,$.y)}function x($,V,B){var F=V[0]-B[0]*$.k,R=V[1]-B[1]*$.k;return F===$.x&&R===$.y?$:new so($.k,F,R)}function _($){return[(+$[0][0]+ +$[1][0])/2,(+$[0][1]+ +$[1][1])/2]}function S($,V,B,F){$.on("start.zoom",function(){N(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(F).end()}).tween("zoom",function(){var R=this,H=arguments,A=N(R,H).event(F),X=t.apply(R,H),K=B==null?_(X):typeof B=="function"?B.apply(R,H):B,W=Math.max(X[1][0]-X[0][0],X[1][1]-X[0][1]),te=R.__zoom,ee=typeof V=="function"?V.apply(R,H):V,G=c(te.invert(K).concat(W/te.k),ee.invert(K).concat(W/ee.k));return function(ne){if(ne===1)ne=ee;else{var re=G(ne),ie=W/re[2];ne=new so(ie,K[0]-re[0]*ie,K[1]-re[1]*ie)}A.zoom(null,ne)}})}function N($,V,B){return!B&&$.__zooming||new I($,V)}function I($,V){this.that=$,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply($,V),this.taps=0}I.prototype={event:function($){return $&&(this.sourceEvent=$),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function($,V){return this.mouse&&$!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&$!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&$!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function($){var V=ms(this.that).datum();u.call($,this.that,new d4($,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),V)}};function T($,...V){if(!e.apply(this,arguments))return;var B=N(this,V).event($),F=this.__zoom,R=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),H=ri($);if(B.wheel)(B.mouse[0][0]!==H[0]||B.mouse[0][1]!==H[1])&&(B.mouse[1]=F.invert(B.mouse[0]=H)),clearTimeout(B.wheel);else{if(F.k===R)return;B.mouse=[H,F.invert(H)],_h(this),B.start()}Ku($),B.wheel=setTimeout(A,y),B.zoom("mouse",n(x(k(F,R),B.mouse[0],B.mouse[1]),B.extent,a));function A(){B.wheel=null,B.end()}}function z($,...V){if(d||!e.apply(this,arguments))return;var B=$.currentTarget,F=N(this,V,!0).event($),R=ms($.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",W,!0),H=ri($,B),A=$.clientX,X=$.clientY;yP($.view),tw($),F.mouse=[H,this.__zoom.invert(H)],_h(this),F.start();function K(te){if(Ku(te),!F.moved){var ee=te.clientX-A,G=te.clientY-X;F.moved=ee*ee+G*G>v}F.event(te).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=ri(te,B),F.mouse[1]),F.extent,a))}function W(te){R.on("mousemove.zoom mouseup.zoom",null),wP(te.view,F.moved),Ku(te),F.event(te).end()}}function E($,...V){if(e.apply(this,arguments)){var B=this.__zoom,F=ri($.changedTouches?$.changedTouches[0]:$,this),R=B.invert(F),H=B.k*($.shiftKey?.5:2),A=n(x(k(B,H),F,R),t.apply(this,V),a);Ku($),l>0?ms(this).transition().duration(l).call(S,A,F,$):ms(this).call(g.transform,A,F,$)}}function O($,...V){if(e.apply(this,arguments)){var B=$.touches,F=B.length,R=N(this,V,$.changedTouches.length===F).event($),H,A,X,K;for(tw($),A=0;A<F;++A)X=B[A],K=ri(X,this),K=[K,this.__zoom.invert(K),X.identifier],R.touch0?!R.touch1&&R.touch0[2]!==K[2]&&(R.touch1=K,R.taps=0):(R.touch0=K,H=!0,R.taps=1+!!p);p&&(p=clearTimeout(p)),H&&(R.taps<2&&(f=K[0],p=setTimeout(function(){p=null},h)),_h(this),R.start())}}function D($,...V){if(this.__zooming){var B=N(this,V).event($),F=$.changedTouches,R=F.length,H,A,X,K;for(Ku($),H=0;H<R;++H)A=F[H],X=ri(A,this),B.touch0&&B.touch0[2]===A.identifier?B.touch0[0]=X:B.touch1&&B.touch1[2]===A.identifier&&(B.touch1[0]=X);if(A=B.that.__zoom,B.touch1){var W=B.touch0[0],te=B.touch0[1],ee=B.touch1[0],G=B.touch1[1],ne=(ne=ee[0]-W[0])*ne+(ne=ee[1]-W[1])*ne,re=(re=G[0]-te[0])*re+(re=G[1]-te[1])*re;A=k(A,Math.sqrt(ne/re)),X=[(W[0]+ee[0])/2,(W[1]+ee[1])/2],K=[(te[0]+G[0])/2,(te[1]+G[1])/2]}else if(B.touch0)X=B.touch0[0],K=B.touch0[1];else return;B.zoom("touch",n(x(A,X,K),B.extent,a))}}function L($,...V){if(this.__zooming){var B=N(this,V).event($),F=$.changedTouches,R=F.length,H,A;for(tw($),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),H=0;H<R;++H)A=F[H],B.touch0&&B.touch0[2]===A.identifier?delete B.touch0:B.touch1&&B.touch1[2]===A.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(A=ri(A,this),Math.hypot(f[0]-A[0],f[1]-A[1])<b)){var X=ms(this).on("dblclick.zoom");X&&X.apply(this,arguments)}}}return g.wheelDelta=function($){return arguments.length?(r=typeof $=="function"?$:Dp(+$),g):r},g.filter=function($){return arguments.length?(e=typeof $=="function"?$:Dp(!!$),g):e},g.touchable=function($){return arguments.length?(i=typeof $=="function"?$:Dp(!!$),g):i},g.extent=function($){return arguments.length?(t=typeof $=="function"?$:Dp([[+$[0][0],+$[0][1]],[+$[1][0],+$[1][1]]]),g):t},g.scaleExtent=function($){return arguments.length?(o[0]=+$[0],o[1]=+$[1],g):[o[0],o[1]]},g.translateExtent=function($){return arguments.length?(a[0][0]=+$[0][0],a[1][0]=+$[1][0],a[0][1]=+$[0][1],a[1][1]=+$[1][1],g):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},g.constrain=function($){return arguments.length?(n=$,g):n},g.duration=function($){return arguments.length?(l=+$,g):l},g.interpolate=function($){return arguments.length?(c=$,g):c},g.on=function(){var $=u.on.apply(u,arguments);return $===u?g:$},g.clickDistance=function($){return arguments.length?(v=($=+$)*$,g):Math.sqrt(v)},g.tapDistance=function($){return arguments.length?(b=+$,g):b},g}const zi={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."},ef=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],$P=["Enter"," ","Escape"],LP={"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 Bc;(function(e){e.Strict="strict",e.Loose="loose"})(Bc||(Bc={}));var Xa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Xa||(Xa={}));var tf;(function(e){e.Partial="partial",e.Full="full"})(tf||(tf={}));const OP={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Vo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Vo||(Vo={}));var Ei;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ei||(Ei={}));var Ge;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ge||(Ge={}));const BN={[Ge.Left]:Ge.Right,[Ge.Right]:Ge.Left,[Ge.Top]:Ge.Bottom,[Ge.Bottom]:Ge.Top};function DP(e){return e===null?null:e?"valid":"invalid"}const FP=e=>"id"in e&&"source"in e&&"target"in e,y4=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Yk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Af=(e,t=[0,0])=>{const{width:n,height:r}=ko(e),i=e.origin??t,o=n*i[0],a=r*i[1];return{x:e.position.x-o,y:e.position.y-a}},w4=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const o=typeof i=="string";let a=!t.nodeLookup&&!o?i:void 0;t.nodeLookup&&(a=o?t.nodeLookup.get(i):Yk(i)?i:t.nodeLookup.get(i.id));const l=a?pm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return dg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fg(n)},Ef=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=dg(n,pm(i)),r=!0)}),r?fg(n):{x:0,y:0,width:0,height:0}},Jk=(e,t,[n,r,i]=[0,0,1],o=!1,a=!1)=>{const l={...Pf(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(const u of e.values()){const{measured:p,selectable:f=!0,hidden:d=!1}=u;if(a&&!f||d)continue;const h=p.width??u.width??u.initialWidth??null,y=p.height??u.height??u.initialHeight??null,v=nf(l,Vc(u)),b=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},x4=(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 b4(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function k4({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=b4(e,a),c=Ef(l),u=Xk(c,t,n,(a==null?void 0:a.minZoom)??i,(a==null?void 0:a.maxZoom)??o,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function zP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},p=a.origin??r;let f=a.extent||i;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",zi.error005());else{const h=l.measured.width,y=l.measured.height;h&&y&&(f=[[c,u],[c+h,u+y]])}else l&&Kc(a.extent)&&(f=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const d=Kc(f)?al(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",zi.error015())),{position:{x:d.x-c+(a.measured.width??0)*p[0],y:d.y-u+(a.measured.height??0)*p[1]},positionAbsolute:d}}async function v4({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const o=new Set(e.map(d=>d.id)),a=[];for(const d of n){if(d.deletable===!1)continue;const h=o.has(d.id),y=!h&&d.parentId&&a.find(v=>v.id===d.parentId);(h||y)&&a.push(d)}const l=new Set(t.map(d=>d.id)),c=r.filter(d=>d.deletable!==!1),p=x4(a,c);for(const d of c)l.has(d.id)&&!p.find(y=>y.id===d.id)&&p.push(d);if(!i)return{edges:p,nodes:a};const f=await i({nodes:a,edges:p});return typeof f=="boolean"?f?{edges:p,nodes:a}:{edges:[],nodes:[]}:f}const Hc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),al=(e={x:0,y:0},t,n)=>({x:Hc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Hc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function WP(e,t,n){const{width:r,height:i}=ko(n),{x:o,y:a}=n.internals.positionAbsolute;return al(e,[[o,a],[o+r,a+i]],t)}const HN=(e,t,n)=>e<t?Hc(Math.abs(e-t),1,t)/t:e>n?-Hc(Math.abs(e-n),1,t)/t:0,BP=(e,t,n=15,r=40)=>{const i=HN(e.x,r,t.width-r)*n,o=HN(e.y,r,t.height-r)*n;return[i,o]},dg=(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)}),eb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),fg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Vc=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=Yk(e)?e.internals.positionAbsolute:Af(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},pm=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=Yk(e)?e.internals.positionAbsolute:Af(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},HP=(e,t)=>fg(dg(eb(e),eb(t))),nf=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},VN=e=>ai(e.width)&&ai(e.height)&&ai(e.x)&&ai(e.y),ai=e=>!isNaN(e)&&isFinite(e),S4=(e,t)=>{},If=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pf=({x:e,y:t},[n,r,i],o=!1,a=[1,1])=>{const l={x:(e-n)/i,y:(t-r)/i};return o?If(l,a):l},hm=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function ql(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 j4(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ql(e,n),i=ql(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=ql(e.top??e.y??0,n),i=ql(e.bottom??e.y??0,n),o=ql(e.left??e.x??0,t),a=ql(e.right??e.x??0,t);return{top:r,right:a,bottom:i,left:o,x:o+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function N4(e,t,n,r,i,o){const{x:a,y:l}=hm(e,[t,n,r]),{x:c,y:u}=hm({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=i-c,f=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(p),bottom:Math.floor(f)}}const Xk=(e,t,n,r,i,o)=>{const a=j4(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),p=Hc(u,r,i),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*p,y=n/2-d*p,v=N4(e,h,y,p,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:h-b.left+b.right,y:y-b.top+b.bottom,zoom:p}},rf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Kc(e){return e!=null&&e!=="parent"}function ko(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 VP(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 KP(e,t={width:0,height:0},n,r,i){const o={...e},a=r.get(n);if(a){const l=a.origin||i;o.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],o.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return o}function KN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _4(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function C4(e){return{...LP,...e||{}}}function jd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:o,y:a}=li(e),l=Pf({x:o-((i==null?void 0:i.left)??0),y:a-((i==null?void 0:i.top)??0)},r),{x:c,y:u}=n?If(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Qk=e=>({width:e.offsetWidth,height:e.offsetHeight}),qP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},A4=["INPUT","SELECT","TEXTAREA"];function UP(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:A4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const GP=e=>"clientX"in e,li=(e,t)=>{var o,a;const n=GP(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,i=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},qN=(e,t,n,r,i)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:i,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...Qk(a)}})};function YP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:a,targetControlY:l}){const c=e*.125+i*.375+a*.375+n*.125,u=t*.125+o*.375+l*.375+r*.125,p=Math.abs(c-e),f=Math.abs(u-t);return[c,u,p,f]}function Fp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function UN({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Ge.Left:return[t-Fp(t-r,o),n];case Ge.Right:return[t+Fp(r-t,o),n];case Ge.Top:return[t,n-Fp(n-i,o)];case Ge.Bottom:return[t,n+Fp(i-n,o)]}}function JP({sourceX:e,sourceY:t,sourcePosition:n=Ge.Bottom,targetX:r,targetY:i,targetPosition:o=Ge.Top,curvature:a=.25}){const[l,c]=UN({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[u,p]=UN({pos:o,x1:r,y1:i,x2:e,y2:t,c:a}),[f,d,h,y]=YP({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:p});return[`M${e},${t} C${l},${c} ${u},${p} ${r},${i}`,f,d,h,y]}function XP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n<e?n+i:n-i,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[o,l,i,a]}function E4({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const a=i&&n?r+1e3:r,l=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return a+l}function I4({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){const o=dg(pm(e),pm(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return nf(a,fg(o))>0}const P4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,T4=(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)),Ch=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||P4;let i;return FP(e)?i={...e}:i={...e,id:r(e)},T4(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function QP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,a,l]=XP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,a,l]}const GN={[Ge.Left]:{x:-1,y:0},[Ge.Right]:{x:1,y:0},[Ge.Top]:{x:0,y:-1},[Ge.Bottom]:{x:0,y:1}},R4=({source:e,sourcePosition:t=Ge.Bottom,target:n})=>t===Ge.Left||t===Ge.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},YN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function M4({source:e,sourcePosition:t=Ge.Bottom,target:n,targetPosition:r=Ge.Top,center:i,offset:o,stepPosition:a}){const l=GN[t],c=GN[r],u={x:e.x+l.x*o,y:e.y+l.y*o},p={x:n.x+c.x*o,y:n.y+c.y*o},f=R4({source:u,sourcePosition:t,target:p}),d=f.x!==0?"x":"y",h=f[d];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,_]=XP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*c[d]===-1){d==="x"?(v=i.x??u.x+(p.x-u.x)*a,b=i.y??(u.y+p.y)/2):(v=i.x??(u.x+p.x)/2,b=i.y??u.y+(p.y-u.y)*a);const T=[{x:v,y:u.y},{x:v,y:p.y}],z=[{x:u.x,y:b},{x:p.x,y:b}];l[d]===h?y=d==="x"?T:z:y=d==="x"?z:T}else{const T=[{x:u.x,y:p.y}],z=[{x:p.x,y:u.y}];if(d==="x"?y=l.x===h?z:T:y=l.y===h?T:z,t===r){const $=Math.abs(e[d]-n[d]);if($<=o){const V=Math.min(o-1,o-$);l[d]===h?g[d]=(u[d]>e[d]?-1:1)*V:k[d]=(p[d]>n[d]?-1:1)*V}}if(t!==r){const $=d==="x"?"y":"x",V=l[d]===c[$],B=u[$]>p[$],F=u[$]<p[$];(l[d]===1&&(!V&&B||V&&F)||l[d]!==1&&(!V&&F||V&&B))&&(y=d==="x"?T:z)}const E={x:u.x+g.x,y:u.y+g.y},O={x:p.x+k.x,y:p.y+k.y},D=Math.max(Math.abs(E.x-y[0].x),Math.abs(O.x-y[0].x)),L=Math.max(Math.abs(E.y-y[0].y),Math.abs(O.y-y[0].y));D>=L?(v=(E.x+O.x)/2,b=y[0].y):(v=y[0].x,b=(E.y+O.y)/2)}const S={x:u.x+g.x,y:u.y+g.y},N={x:p.x+k.x,y:p.y+k.y};return[[e,...S.x!==y[0].x||S.y!==y[0].y?[S]:[],...y,...N.x!==y[y.length-1].x||N.y!==y[y.length-1].y?[N]:[],n],v,b,x,_]}function $4(e,t,n,r){const i=Math.min(YN(e,t)/2,YN(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+i*u},${a}Q ${o},${a} ${o},${a+i*p}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${a+i*c}Q ${o},${a} ${o+i*l},${a}`}function tb({sourceX:e,sourceY:t,sourcePosition:n=Ge.Bottom,targetX:r,targetY:i,targetPosition:o=Ge.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:p=.5}){const[f,d,h,y,v]=M4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:p});let b=`M${f[0].x} ${f[0].y}`;for(let g=1;g<f.length-1;g++)b+=$4(f[g-1],f[g],f[g+1],a);return b+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[b,d,h,y,v]}function JN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function L4(e){var f;const{sourceNode:t,targetNode:n}=e;if(!JN(t)||!JN(n))return null;const r=t.internals.handleBounds||XN(t.handles),i=n.internals.handleBounds||XN(n.handles),o=QN((r==null?void 0:r.source)??[],e.sourceHandle),a=QN(e.connectionMode===Bc.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),e.targetHandle);if(!o||!a)return(f=e.onError)==null||f.call(e,"008",zi.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||Ge.Bottom,c=(a==null?void 0:a.position)||Ge.Top,u=ll(t,o,l),p=ll(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:p.x,targetY:p.y,sourcePosition:l,targetPosition:c}}function XN(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 ll(e,t,n=Ge.Left,r=!1){const i=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??ko(e);if(r)return{x:i+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case Ge.Top:return{x:i+a/2,y:o};case Ge.Right:return{x:i+a,y:o+l/2};case Ge.Bottom:return{x:i+a/2,y:o+l};case Ge.Left:return{x:i,y:o+l/2}}}function QN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function nb(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function O4(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||i].forEach(c=>{if(c&&typeof c=="object"){const u=nb(c,t);o.has(u)||(a.push({id:u,color:c.color||n,...c}),o.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const ZP=1e3,D4=10,Zk={nodeOrigin:[0,0],nodeExtent:ef,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},F4={...Zk,checkEquality:!0};function ev(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function z4(e,t,n){const r=ev(Zk,n);for(const i of e.values())if(i.parentId)nv(i,e,t,r);else{const o=Af(i,r.nodeOrigin),a=Kc(i.extent)?i.extent:r.nodeExtent,l=al(o,a,ko(i));i.internals.positionAbsolute=l}}function W4(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(o):i.type==="target"&&r.push(o)}return{source:n,target:r}}function tv(e){return e==="manual"}function rb(e,t,n,r={}){var p,f;const i=ev(F4,r),o={i:0},a=new Map(t),l=i!=null&&i.elevateNodesOnSelect&&!tv(i.zIndexMode)?ZP:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let h=a.get(d.id);if(i.checkEquality&&d===(h==null?void 0:h.internals.userNode))t.set(d.id,h);else{const y=Af(d,i.nodeOrigin),v=Kc(d.extent)?d.extent:i.nodeExtent,b=al(y,v,ko(d));h={...i.defaults,...d,measured:{width:(p=d.measured)==null?void 0:p.width,height:(f=d.measured)==null?void 0:f.height},internals:{positionAbsolute:b,handleBounds:W4(d,h),z:eT(d,l,i.zIndexMode),userNode:d}},t.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),d.parentId&&nv(h,t,n,r,o),u||(u=d.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function B4(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 nv(e,t,n,r,i){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=ev(Zk,r),u=e.parentId,p=t.get(u);if(!p){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}B4(e,n),i&&!p.parentId&&p.internals.rootParentIndex===void 0&&c==="auto"&&(p.internals.rootParentIndex=++i.i,p.internals.z=p.internals.z+i.i*D4),i&&p.internals.rootParentIndex!==void 0&&(i.i=p.internals.rootParentIndex);const f=o&&!tv(c)?ZP:0,{x:d,y:h,z:y}=H4(e,p,a,l,f,c),{positionAbsolute:v}=e.internals,b=d!==v.x||h!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:d,y:h}:v,z:y}})}function eT(e,t,n){const r=ai(e.zIndex)?e.zIndex:0;return tv(n)?r:r+(e.selected?t:0)}function H4(e,t,n,r,i,o){const{x:a,y:l}=t.internals.positionAbsolute,c=ko(e),u=Af(e,n),p=Kc(e.extent)?al(u,e.extent,c):u;let f=al({x:a+p.x,y:l+p.y},r,c);e.extent==="parent"&&(f=WP(f,c,t));const d=eT(e,i,o),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function rv(e,t,n,r=[0,0]){var a;const i=[],o=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const u=((a=o.get(l.parentId))==null?void 0:a.expandedRect)??Vc(c),p=HP(u,l.rect);o.set(l.parentId,{expandedRect:p,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const p=c.internals.positionAbsolute,f=ko(c),d=c.origin??r,h=l.x<p.x?Math.round(Math.abs(p.x-l.x)):0,y=l.y<p.y?Math.round(Math.abs(p.y-l.y)):0,v=Math.max(f.width,Math.round(l.width)),b=Math.max(f.height,Math.round(l.height)),g=(v-f.width)*d[0],k=(b-f.height)*d[1];(h>0||y>0||g||k)&&(i.push({id:u,type:"position",position:{x:c.position.x-h+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(_=>{e.some(S=>S.id===_.id)||i.push({id:_.id,type:"position",position:{x:_.position.x+h,y:_.position.y+y}})})),(f.width<l.width||f.height<l.height||h||y)&&i.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?d[0]*h-g:0),height:b+(y?d[1]*y-k:0)}})}),i}function V4(e,t,n,r,i,o,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],p=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(p.transform),d=[];for(const h of e.values()){const y=t.get(h.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=Qk(h.nodeElement),b=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!y.internals.handleBounds||h.force))){const k=h.nodeElement.getBoundingClientRect(),x=Kc(y.extent)?y.extent:o;let{positionAbsolute:_}=y.internals;y.parentId&&y.extent==="parent"?_=WP(_,v,t.get(y.parentId)):x&&(_=al(_,x,v));const S={...y,measured:v,internals:{...y.internals,positionAbsolute:_,handleBounds:{source:qN("source",h.nodeElement,k,f,y.id),target:qN("target",h.nodeElement,k,f,y.id)}}};t.set(y.id,S),y.parentId&&nv(S,t,n,{nodeOrigin:i,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&d.push({id:y.id,parentId:y.parentId,rect:Vc(S,i)}))}}if(d.length>0){const h=rv(d,t,n,i);u.push(...h)}return{changes:u,updatedInternals:c}}async function K4({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,o]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function ZN(e,t,n,r,i,o){let a=i;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${i}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),o){a=`${i}-${e}-${o}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function tT(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:o,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:i,target:o,sourceHandle:a,targetHandle:l},u=`${i}-${a}--${o}-${l}`,p=`${o}-${l}--${i}-${a}`;ZN("source",c,p,e,i,a),ZN("target",c,u,e,o,l),t.set(r.id,r)}}function nT(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:nT(n,t):!1}function e1(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function q4(e,t,n,r){const i=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!nT(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(o);l&&i.set(o,{id:o,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return i}function nw({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const i=[];for(const[u,p]of t){const f=(a=n.get(u))==null?void 0:a.internals.userNode;f&&i.push({...f,position:p.position,dragging:r})}if(!e)return[i[0],i];const o=(l=n.get(e))==null?void 0:l.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:r}:i[0],i]}function U4({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:n-i.distance.x,y:r-i.distance.y},a=If(o,t);return{x:a.x-o.x,y:a.y-o.y}}function G4({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let o={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},p=null,f=!1,d=null,h=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:_,isSelectable:S,nodeId:N,nodeClickDistance:I=0}){d=ms(_);function T({x:D,y:L}){const{nodeLookup:$,nodeExtent:V,snapGrid:B,snapToGrid:F,nodeOrigin:R,onNodeDrag:H,onSelectionDrag:A,onError:X,updateNodePositions:K}=t();o={x:D,y:L};let W=!1;const te=l.size>1,ee=te&&V?eb(Ef(l)):null,G=te&&F?U4({dragItems:l,snapGrid:B,x:D,y:L}):null;for(const[ne,re]of l){if(!$.has(ne))continue;let ie={x:D-re.distance.x,y:L-re.distance.y};F&&(ie=G?{x:Math.round(ie.x+G.x),y:Math.round(ie.y+G.y)}:If(ie,B));let Z=null;if(te&&V&&!re.extent&&ee){const{positionAbsolute:ge}=re.internals,Oe=ge.x-ee.x+V[0][0],_e=ge.x+re.measured.width-ee.x2+V[1][0],Ne=ge.y-ee.y+V[0][1],He=ge.y+re.measured.height-ee.y2+V[1][1];Z=[[Oe,Ne],[_e,He]]}const{position:de,positionAbsolute:fe}=zP({nodeId:ne,nextPosition:ie,nodeLookup:$,nodeExtent:Z||V,nodeOrigin:R,onError:X});W=W||re.position.x!==de.x||re.position.y!==de.y,re.position=de,re.internals.positionAbsolute=fe}if(y=y||W,!!W&&(K(l,!0),v&&(r||H||!N&&A))){const[ne,re]=nw({nodeId:N,dragItems:l,nodeLookup:$});r==null||r(v,l,ne,re),H==null||H(v,ne,re),N||A==null||A(v,re)}}async function z(){if(!p)return;const{transform:D,panBy:L,autoPanSpeed:$,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(a);return}const[B,F]=BP(u,p,$);(B!==0||F!==0)&&(o.x=(o.x??0)-B/D[2],o.y=(o.y??0)-F/D[2],await L({x:B,y:F})&&T(o)),a=requestAnimationFrame(z)}function E(D){var te;const{nodeLookup:L,multiSelectionActive:$,nodesDraggable:V,transform:B,snapGrid:F,snapToGrid:R,selectNodesOnDrag:H,onNodeDragStart:A,onSelectionDragStart:X,unselectNodesAndEdges:K}=t();f=!0,(!H||!S)&&!$&&N&&((te=L.get(N))!=null&&te.selected||K()),S&&H&&N&&(e==null||e(N));const W=jd(D.sourceEvent,{transform:B,snapGrid:F,snapToGrid:R,containerBounds:p});if(o=W,l=q4(L,V,W,N),l.size>0&&(n||A||!N&&X)){const[ee,G]=nw({nodeId:N,dragItems:l,nodeLookup:L});n==null||n(D.sourceEvent,l,ee,G),A==null||A(D.sourceEvent,ee,G),N||X==null||X(D.sourceEvent,G)}}const O=xP().clickDistance(I).on("start",D=>{const{domNode:L,nodeDragThreshold:$,transform:V,snapGrid:B,snapToGrid:F}=t();p=(L==null?void 0:L.getBoundingClientRect())||null,h=!1,y=!1,v=D.sourceEvent,$===0&&E(D),o=jd(D.sourceEvent,{transform:V,snapGrid:B,snapToGrid:F,containerBounds:p}),u=li(D.sourceEvent,p)}).on("drag",D=>{const{autoPanOnNodeDrag:L,transform:$,snapGrid:V,snapToGrid:B,nodeDragThreshold:F,nodeLookup:R}=t(),H=jd(D.sourceEvent,{transform:$,snapGrid:V,snapToGrid:B,containerBounds:p});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||N&&!R.has(N))&&(h=!0),!h){if(!c&&L&&f&&(c=!0,z()),!f){const A=li(D.sourceEvent,p),X=A.x-u.x,K=A.y-u.y;Math.sqrt(X*X+K*K)>F&&E(D)}(o.x!==H.xSnapped||o.y!==H.ySnapped)&&l&&f&&(u=li(D.sourceEvent,p),T(H))}}).on("end",D=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:L,updateNodePositions:$,onNodeDragStop:V,onSelectionDragStop:B}=t();if(y&&($(l,!1),y=!1),i||V||!N&&B){const[F,R]=nw({nodeId:N,dragItems:l,nodeLookup:L,dragging:!1});i==null||i(D.sourceEvent,l,F,R),V==null||V(D.sourceEvent,F,R),N||B==null||B(D.sourceEvent,R)}}}).filter(D=>{const L=D.target;return!D.button&&(!k||!e1(L,`.${k}`,_))&&(!x||e1(L,x,_))});d.call(O)}function g(){d==null||d.on(".drag",null)}return{update:b,destroy:g}}function Y4(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())nf(i,Vc(o))>0&&r.push(o);return r}const J4=250;function X4(e,t,n,r){var l,c;let i=[],o=1/0;const a=Y4(e,n,t+J4);for(const u of a){const p=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const f of p){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:d,y:h}=ll(u,f,f.position,!0),y=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(h-e.y,2));y>t||(y<o?(i=[{...f,x:d,y:h}],o=y):y===o&&i.push({...f,x:d,y:h}))}}if(!i.length)return null;if(i.length>1){const u=r.type==="source"?"target":"source";return i.find(p=>p.type===u)??i[0]}return i[0]}function rT(e,t,n,r,i,o=!1){var u,p,f;const a=r.get(e);if(!a)return null;const l=i==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((p=a.internals.handleBounds)==null?void 0:p.source)??[],...((f=a.internals.handleBounds)==null?void 0:f.target)??[]],c=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...ll(a,c,c.position,!0)}:c}function sT(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Q4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const iT=()=>!0;function Z4(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:p,flowId:f,panBy:d,cancelConnection:h,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=iT,onReconnectEnd:k,updateConnection:x,getTransform:_,getFromHandle:S,autoPanSpeed:N,dragThreshold:I=1,handleDomNode:T}){const z=qP(e.target);let E=0,O;const{x:D,y:L}=li(e),$=sT(o,T),V=l==null?void 0:l.getBoundingClientRect();let B=!1;if(!V||!$)return;const F=rT(i,$,r,c,t);if(!F)return;let R=li(e,V),H=!1,A=null,X=!1,K=null;function W(){if(!p||!V)return;const[de,fe]=BP(R,V,N);d({x:de,y:fe}),E=requestAnimationFrame(W)}const te={...F,nodeId:i,type:$,position:F.position},ee=c.get(i);let ne={inProgress:!0,isValid:null,from:ll(ee,te,Ge.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:ee,to:R,toHandle:null,toPosition:BN[te.position],toNode:null,pointer:R};function re(){B=!0,x(ne),y==null||y(e,{nodeId:i,handleId:r,handleType:$})}I===0&&re();function ie(de){if(!B){const{x:He,y:ct}=li(de),xt=He-D,Re=ct-L;if(!(xt*xt+Re*Re>I*I))return;re()}if(!S()||!te){Z(de);return}const fe=_();R=li(de,V),O=X4(Pf(R,fe,!1,[1,1]),n,c,te),H||(W(),H=!0);const ge=oT(de,{handle:O,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:z,lib:u,flowId:f,nodeLookup:c});K=ge.handleDomNode,A=ge.connection,X=Q4(!!O,ge.isValid);const Oe=c.get(i),_e=Oe?ll(Oe,te,Ge.Left,!0):ne.from,Ne={...ne,from:_e,isValid:X,to:ge.toHandle&&X?hm({x:ge.toHandle.x,y:ge.toHandle.y},fe):R,toHandle:ge.toHandle,toPosition:X&&ge.toHandle?ge.toHandle.position:BN[te.position],toNode:ge.toHandle?c.get(ge.toHandle.nodeId):null,pointer:R};x(Ne),ne=Ne}function Z(de){if(!("touches"in de&&de.touches.length>0)){if(B){(O||K)&&A&&X&&(v==null||v(A));const{inProgress:fe,...ge}=ne,Oe={...ge,toPosition:ne.toHandle?ne.toPosition:null};b==null||b(de,Oe),o&&(k==null||k(de,Oe))}h(),cancelAnimationFrame(E),H=!1,X=!1,A=null,K=null,z.removeEventListener("mousemove",ie),z.removeEventListener("mouseup",Z),z.removeEventListener("touchmove",ie),z.removeEventListener("touchend",Z)}}z.addEventListener("mousemove",ie),z.addEventListener("mouseup",Z),z.addEventListener("touchmove",ie),z.addEventListener("touchend",Z)}function oT(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=iT,nodeLookup:p}){const f=o==="target",d=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}=li(e),v=a.elementFromPoint(h,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:d,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=sT(void 0,b),x=b.getAttribute("data-nodeid"),_=b.getAttribute("data-handleid"),S=b.classList.contains("connectable"),N=b.classList.contains("connectableend");if(!x||!k)return g;const I={source:f?x:r,sourceHandle:f?_:i,target:f?r:x,targetHandle:f?i:_};g.connection=I;const z=S&&N&&(n===Bc.Strict?f&&k==="source"||!f&&k==="target":x!==r||_!==i);g.isValid=z&&u(I),g.toHandle=rT(x,k,_,p,n,!0)}return g}const sb={onPointerDown:Z4,isValid:oT};function e5({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=ms(e);function o({translateExtent:l,width:c,height:u,zoomStep:p=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const _=n(),S=x.sourceEvent.ctrlKey&&rf()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*p,I=_[2]*Math.pow(2,N*S);t.scaleTo(I)};let v=[0,0];const b=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(v=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},g=x=>{const _=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const S=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],N=[S[0]-v[0],S[1]-v[1]];v=S;const I=r()*Math.max(_[2],Math.log(_[2]))*(h?-1:1),T={x:_[0]-N[0]*I,y:_[1]-N[1]*I},z=[[0,0],[c,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:_[2]},z,l)},k=MP().on("start",b).on("zoom",f?g:null).on("zoom.wheel",d?y:null);i.call(k,{})}function a(){i.on("zoom",null)}return{update:o,destroy:a,pointer:ri}}const pg=e=>({x:e.x,y:e.y,zoom:e.k}),rw=({x:e,y:t,zoom:n})=>ug.translate(e,t).scale(n),hc=(e,t)=>e.target.closest(`.${t}`),aT=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),t5=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,sw=(e,t=0,n=t5,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},lT=e=>{const t=e.ctrlKey&&rf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function n5({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return p=>{if(hc(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(p.ctrlKey&&a){const b=ri(p),g=lT(p),k=f*Math.pow(2,g);r.scaleTo(n,k,b,p);return}const d=p.deltaMode===1?20:1;let h=i===Xa.Vertical?0:p.deltaX*d,y=i===Xa.Horizontal?0:p.deltaY*d;!rf()&&p.shiftKey&&i!==Xa.Vertical&&(h=p.deltaY*d,y=0),r.translateBy(n,-(h/f)*o,-(y/f)*o,{internal:!0});const v=pg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(p,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(p,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(p,v))}}function r5({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=hc(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,i)}}function s5({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const i=pg(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function i5({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&aT(t,e.mouseButton??0)),(a=o.sourceEvent)!=null&&a.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!((l=o.sourceEvent)!=null&&l.internal)&&(i==null||i(o.sourceEvent,pg(o.transform)))}}function o5({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,o&&aT(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const c=pg(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(a.sourceEvent,c)},n?150:0)}}}function a5({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:p}){return f=>{var b;const d=e||t,h=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(hc(f,`${u}-flow__node`)||hc(f,`${u}-flow__edge`)))return!0;if(!r&&!d&&!i&&!o&&!n||a||p&&!y||hc(f,l)&&y||hc(f,c)&&(!y||i&&y&&!e)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&((b=f.touches)==null?void 0:b.length)>1)return f.preventDefault(),!1;if(!d&&!i&&!h&&y||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||y)&&v}}function l5({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),f=MP().scaleExtent([t,n]).translateExtent(r),d=ms(e).call(f);k({x:i.x,y:i.y,zoom:Hc(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const h=d.on("wheel.zoom"),y=d.on("dblclick.zoom");f.wheelDelta(lT);function v(O,D){return d?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Sd:Sh).transform(sw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function b({noWheelClassName:O,noPanClassName:D,onPaneContextMenu:L,userSelectionActive:$,panOnScroll:V,panOnDrag:B,panOnScrollMode:F,panOnScrollSpeed:R,preventScrolling:H,zoomOnPinch:A,zoomOnScroll:X,zoomOnDoubleClick:K,zoomActivationKeyPressed:W,lib:te,onTransformChange:ee,connectionInProgress:G,paneClickDistance:ne,selectionOnDrag:re}){$&&!u.isZoomingOrPanning&&g();const ie=V&&!W&&!$;f.clickDistance(re?1/0:!ai(ne)||ne<0?0:ne);const Z=ie?n5({zoomPanValues:u,noWheelClassName:O,d3Selection:d,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:R,zoomOnPinch:A,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):r5({noWheelClassName:O,preventScrolling:H,d3ZoomHandler:h});if(d.on("wheel.zoom",Z,{passive:!1}),!$){const fe=s5({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",fe);const ge=i5({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!L,onPanZoom:o,onTransformChange:ee});f.on("zoom",ge);const Oe=o5({zoomPanValues:u,panOnDrag:B,panOnScroll:V,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});f.on("end",Oe)}const de=a5({zoomActivationKeyPressed:W,panOnDrag:B,zoomOnScroll:X,panOnScroll:V,zoomOnDoubleClick:K,zoomOnPinch:A,userSelectionActive:$,noPanClassName:D,noWheelClassName:O,lib:te,connectionInProgress:G});f.filter(de),K?d.on("dblclick.zoom",y):d.on("dblclick.zoom",null)}function g(){f.on("zoom",null)}async function k(O,D,L){const $=rw(O),V=f==null?void 0:f.constrain()($,D,L);return V&&await v(V),new Promise(B=>B(V))}async function x(O,D){const L=rw(O);return await v(L,D),new Promise($=>$(L))}function _(O){if(d){const D=rw(O),L=d.property("__zoom");(L.k!==O.zoom||L.x!==O.x||L.y!==O.y)&&(f==null||f.transform(d,D,null,{sync:!0}))}}function S(){const O=d?RP(d.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function N(O,D){return d?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Sd:Sh).scaleTo(sw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function I(O,D){return d?new Promise(L=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?Sd:Sh).scaleBy(sw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function T(O){f==null||f.scaleExtent(O)}function z(O){f==null||f.translateExtent(O)}function E(O){const D=!ai(O)||O<0?0:O;f==null||f.clickDistance(D)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:S,scaleTo:N,scaleBy:I,setScaleExtent:T,setTranslateExtent:z,syncViewport:_,setClickDistance:E}}var qc;(function(e){e.Line="line",e.Handle="handle"})(qc||(qc={}));function c5({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:o}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&i&&(c[0]=c[0]*-1),l&&o&&(c[1]=c[1]*-1),c}function t1(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function $o(e,t){return Math.max(0,t-e)}function Lo(e,t){return Math.max(0,e-t)}function zp(e,t,n){return Math.max(0,t-e,e-n)}function n1(e,t){return e?!t:t}function u5(e,t,n,r,i,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:p,isVertical:f}=t,d=p&&f,{xSnapped:h,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:_,width:S,height:N,aspectRatio:I}=e;let T=Math.floor(p?h-e.pointerX:0),z=Math.floor(f?y-e.pointerY:0);const E=S+(c?-T:T),O=N+(u?-z:z),D=-o[0]*S,L=-o[1]*N;let $=zp(E,v,b),V=zp(O,g,k);if(a){let R=0,H=0;c&&T<0?R=$o(x+T+D,a[0][0]):!c&&T>0&&(R=Lo(x+E+D,a[1][0])),u&&z<0?H=$o(_+z+L,a[0][1]):!u&&z>0&&(H=Lo(_+O+L,a[1][1])),$=Math.max($,R),V=Math.max(V,H)}if(l){let R=0,H=0;c&&T>0?R=Lo(x+T,l[0][0]):!c&&T<0&&(R=$o(x+E,l[1][0])),u&&z>0?H=Lo(_+z,l[0][1]):!u&&z<0&&(H=$o(_+O,l[1][1])),$=Math.max($,R),V=Math.max(V,H)}if(i){if(p){const R=zp(E/I,g,k)*I;if($=Math.max($,R),a){let H=0;!c&&!u||c&&!u&&d?H=Lo(_+L+E/I,a[1][1])*I:H=$o(_+L+(c?T:-T)/I,a[0][1])*I,$=Math.max($,H)}if(l){let H=0;!c&&!u||c&&!u&&d?H=$o(_+E/I,l[1][1])*I:H=Lo(_+(c?T:-T)/I,l[0][1])*I,$=Math.max($,H)}}if(f){const R=zp(O*I,v,b)/I;if(V=Math.max(V,R),a){let H=0;!c&&!u||u&&!c&&d?H=Lo(x+O*I+D,a[1][0])/I:H=$o(x+(u?z:-z)*I+D,a[0][0])/I,V=Math.max(V,H)}if(l){let H=0;!c&&!u||u&&!c&&d?H=$o(x+O*I,l[1][0])/I:H=Lo(x+(u?z:-z)*I,l[0][0])/I,V=Math.max(V,H)}}}z=z+(z<0?V:-V),T=T+(T<0?$:-$),i&&(d?E>O*I?z=(n1(c,u)?-T:T)/I:T=(n1(c,u)?-z:z)*I:p?(z=T/I,u=c):(T=z*I,c=u));const B=c?x+T:x,F=u?_+z:_;return{width:S+(c?-T:T),height:N+(u?-z:z),x:o[0]*T*(c?-1:1)+B,y:o[1]*z*(u?-1:1)+F}}const cT={width:0,height:0,x:0,y:0},d5={...cT,pointerX:0,pointerY:0,aspectRatio:1};function f5(e){return[[0,0],[e.measured.width,e.measured.height]]}function p5(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,l=n[0]*o,c=n[1]*a;return[[r-l,i-c],[r+o-l,i+a-c]]}function h5({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const o=ms(e);let a={controlDirection:t1("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:p,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...cT},k={...d5};a={boundaries:p,resizeDirection:d,keepAspectRatio:f,controlDirection:t1(u)};let x,_=null,S=[],N,I,T,z=!1;const E=xP().on("start",O=>{const{nodeLookup:D,transform:L,snapGrid:$,snapToGrid:V,nodeOrigin:B,paneDomNode:F}=n();if(x=D.get(t),!x)return;_=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:H}=jd(O.sourceEvent,{transform:L,snapGrid:$,snapToGrid:V,containerBounds:_});g={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},k={...g,pointerX:R,pointerY:H,aspectRatio:g.width/g.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=D.get(x.parentId),I=N&&x.extent==="parent"?f5(N):void 0),S=[],T=void 0;for(const[A,X]of D)if(X.parentId===t&&(S.push({id:A,position:{...X.position},extent:X.extent}),X.extent==="parent"||X.expandParent)){const K=p5(X,x,X.origin??B);T?T=[[Math.min(K[0][0],T[0][0]),Math.min(K[0][1],T[0][1])],[Math.max(K[1][0],T[1][0]),Math.max(K[1][1],T[1][1])]]:T=K}h==null||h(O,{...g})}).on("drag",O=>{const{transform:D,snapGrid:L,snapToGrid:$,nodeOrigin:V}=n(),B=jd(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:$,containerBounds:_}),F=[];if(!x)return;const{x:R,y:H,width:A,height:X}=g,K={},W=x.origin??V,{width:te,height:ee,x:G,y:ne}=u5(k,a.controlDirection,B,a.boundaries,a.keepAspectRatio,W,I,T),re=te!==A,ie=ee!==X,Z=G!==R&&re,de=ne!==H&&ie;if(!Z&&!de&&!re&&!ie)return;if((Z||de||W[0]===1||W[1]===1)&&(K.x=Z?G:g.x,K.y=de?ne:g.y,g.x=K.x,g.y=K.y,S.length>0)){const _e=G-R,Ne=ne-H;for(const He of S)He.position={x:He.position.x-_e+W[0]*(te-A),y:He.position.y-Ne+W[1]*(ee-X)},F.push(He)}if((re||ie)&&(K.width=re&&(!a.resizeDirection||a.resizeDirection==="horizontal")?te:g.width,K.height=ie&&(!a.resizeDirection||a.resizeDirection==="vertical")?ee:g.height,g.width=K.width,g.height=K.height),N&&x.expandParent){const _e=W[0]*(K.width??0);K.x&&K.x<_e&&(g.x=_e,k.x=k.x-(K.x-_e));const Ne=W[1]*(K.height??0);K.y&&K.y<Ne&&(g.y=Ne,k.y=k.y-(K.y-Ne))}const fe=c5({width:g.width,prevWidth:A,height:g.height,prevHeight:X,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ge={...g,direction:fe};(b==null?void 0:b(O,ge))!==!1&&(z=!0,y==null||y(O,ge),r(K,F))}).on("end",O=>{z&&(v==null||v(O,{...g}),i==null||i({...g}),z=!1)});o.call(E)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var uT={exports:{}},dT={},fT={exports:{}},pT={};/**
|
|
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 Uc=m;function m5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var g5=typeof Object.is=="function"?Object.is:m5,y5=Uc.useState,w5=Uc.useEffect,x5=Uc.useLayoutEffect,b5=Uc.useDebugValue;function k5(e,t){var n=t(),r=y5({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return x5(function(){i.value=n,i.getSnapshot=t,iw(i)&&o({inst:i})},[e,n,t]),w5(function(){return iw(i)&&o({inst:i}),e(function(){iw(i)&&o({inst:i})})},[e]),b5(n),n}function iw(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!g5(e,n)}catch{return!0}}function v5(e,t){return t()}var S5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v5:k5;pT.useSyncExternalStore=Uc.useSyncExternalStore!==void 0?Uc.useSyncExternalStore:S5;fT.exports=pT;var hT=fT.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 hg=m,j5=hT;function N5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var _5=typeof Object.is=="function"?Object.is:N5,C5=j5.useSyncExternalStore,A5=hg.useRef,E5=hg.useEffect,I5=hg.useMemo,P5=hg.useDebugValue;dT.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=A5(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=I5(function(){function c(h){if(!u){if(u=!0,p=h,h=r(h),i!==void 0&&a.hasValue){var y=a.value;if(i(y,h))return f=y}return f=h}if(y=f,_5(p,h))return y;var v=r(h);return i!==void 0&&i(y,v)?(p=h,y):(p=h,f=v)}var u=!1,p,f,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,i]);var l=C5(e,o[0],o[1]);return E5(function(){a.hasValue=!0,a.value=l},[l]),P5(l),l};uT.exports=dT;var T5=uT.exports;const R5=ma(T5),M5={},r1=e=>{let t;const n=new Set,r=(p,f)=>{const d=typeof p=="function"?p(t):p;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(y=>y(t,h))}},i=()=>t,c={setState:r,getState:i,getInitialState:()=>u,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(M5?"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,i,c);return c},$5=e=>e?r1(e):r1,{useDebugValue:L5}=dt,{useSyncExternalStoreWithSelector:O5}=R5,D5=e=>e;function mT(e,t=D5,n){const r=O5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return L5(r),r}const s1=(e,t)=>{const n=$5(e),r=(i,o=t)=>mT(n,i,o);return Object.assign(r,n),r},F5=(e,t)=>e?s1(e,t):s1;function Tn(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,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const mg=m.createContext(null),z5=mg.Provider,gT=zi.error001();function Jt(e,t){const n=m.useContext(mg);if(n===null)throw new Error(gT);return mT(n,e,t)}function kn(){const e=m.useContext(mg);if(e===null)throw new Error(gT);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const i1={display:"none"},W5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},yT="react-flow__node-desc",wT="react-flow__edge-desc",B5="react-flow__aria-live",H5=e=>e.ariaLiveMessage,V5=e=>e.ariaLabelConfig;function K5({rfId:e}){const t=Jt(H5);return s.jsx("div",{id:`${B5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:W5,children:t})}function q5({rfId:e,disableKeyboardA11y:t}){const n=Jt(V5);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${yT}-${e}`,style:i1,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${wT}-${e}`,style:i1,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(K5,{rfId:e})]})}const gg=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...i},o)=>{const a=`${e}`.split("-");return s.jsx("div",{className:or(["react-flow__panel",n,...a]),style:r,ref:o,...i,children:t})});gg.displayName="Panel";function U5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:s.jsx(gg,{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:s.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const G5=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}},Wp=e=>e.id;function Y5(e,t){return Tn(e.selectedNodes.map(Wp),t.selectedNodes.map(Wp))&&Tn(e.selectedEdges.map(Wp),t.selectedEdges.map(Wp))}function J5({onSelectionChange:e}){const t=kn(),{selectedNodes:n,selectedEdges:r}=Jt(G5,Y5);return m.useEffect(()=>{const i={nodes:n,edges:r};e==null||e(i),t.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[n,r,e]),null}const X5=e=>!!e.onSelectionChangeHandlers;function Q5({onSelectionChange:e}){const t=Jt(X5);return e||t?s.jsx(J5,{onSelectionChange:e}):null}const ib=typeof window<"u"?m.useLayoutEffect:m.useEffect,xT=[0,0],Z5={x:0,y:0,zoom:1},eH=["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"],o1=[...eH,"rfId"],tH=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}),a1={translateExtent:ef,nodeOrigin:xT,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function nH(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Jt(tH,Tn),u=kn();ib(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=a1,l()}),[]);const p=m.useRef(a1);return ib(()=>{for(const f of o1){const d=e[f],h=p.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?r(d):f==="maxZoom"?i(d):f==="translateExtent"?o(d):f==="nodeExtent"?a(d):f==="ariaLabelConfig"?u.setState({ariaLabelConfig:C4(d)}):f==="fitView"?u.setState({fitViewQueued:d}):f==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[f]:d})))}p.current=e},o1.map(f=>e[f])),null}function l1(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function rH(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const i=l1(),o=()=>n(i!=null&&i.matches?"dark":"light");return o(),i==null||i.addEventListener("change",o),()=>{i==null||i.removeEventListener("change",o)}},[e]),t!==null?t:(r=l1())!=null&&r.matches?"dark":"light"}const c1=typeof document<"u"?document:null;function sf(e=null,t={target:c1,actInsideInputWithModifier:!0}){const[n,r]=m.useState(!1),i=m.useRef(!1),o=m.useRef(new Set([])),[a,l]=m.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
61
|
+
`).replace(`
|
|
62
|
+
|
|
63
|
+
`,`
|
|
64
|
+
+`).split(`
|
|
65
|
+
`)),p=u.reduce((f,d)=>f.concat(...d),[]);return[u,p]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??c1,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=h=>{var b,g;if(i.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!i.current||i.current&&!u)&&UP(h))return!1;const v=d1(h.code,l);if(o.current.add(h[v]),u1(a,o.current,!1)){const k=((g=(b=h.composedPath)==null?void 0:b.call(h))==null?void 0:g[0])||h.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(i.current||!x)&&h.preventDefault(),r(!0)}},f=h=>{const y=d1(h.code,l);u1(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[y]),h.key==="Meta"&&o.current.clear(),i.current=!1},d=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",p),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",p),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function u1(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function d1(e,t){return t.includes(e)?"code":"key"}const sH=()=>{const e=kn();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,i,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=Xk(t,r,i,o,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),u={x:t.x-l,y:t.y-c},p=n.snapGrid??i,f=n.snapToGrid??o;return Pf(u,r,f,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),a=hm(t,n);return{x:a.x+i,y:a.y+o}}}),[])};function bT(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...o};for(const c of a)iH(c,l);n.push(l)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function iH(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 Nd(e,t){return bT(e,t)}function mm(e,t){return bT(e,t)}function La(e,t){return{id:e,type:"select",selected:t}}function mc(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const a=t.has(i);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(La(o.id,a)))}return r}function f1({items:e=[],lookup:t}){var i;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,a]of e.entries()){const l=t.get(a.id),c=((i=l==null?void 0:l.internals)==null?void 0:i.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function p1(e){return{id:e.id,type:"remove"}}const h1=e=>y4(e),oH=e=>FP(e);function kT(e){return m.forwardRef(e)}function m1(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>aH(()=>n(i=>i+BigInt(1))));return ib(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function aH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const vT=m.createContext(null);function lH({children:e}){const t=kn(),n=m.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:p,onNodesChange:f,nodeLookup:d,fitViewQueued:h,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=f1({items:v,lookup:d});for(const g of y.values())b=g(b);p&&u(v),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=m1(n),i=m.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:p,onEdgesChange:f,edgeLookup:d}=t.getState();let h=c;for(const y of l)h=typeof y=="function"?y(h):y;p?u(h):f&&f(f1({items:h,lookup:d}))},[]),o=m1(i),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return s.jsx(vT.Provider,{value:a,children:e})}function cH(){const e=m.useContext(vT);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const uH=e=>!!e.panZoom;function tu(){const e=sH(),t=kn(),n=cH(),r=Jt(uH),i=m.useMemo(()=>{const o=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},c=f=>{var g,k;const{nodeLookup:d,nodeOrigin:h}=t.getState(),y=h1(f)?f:d.get(f.id),v=y.parentId?KP(y.position,y.measured,y.parentId,d,h):y.position,b={...y,position:v,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((k=y.measured)==null?void 0:k.height)??y.height};return Vc(b)},u=(f,d,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const b=typeof d=="function"?d(v):d;return h.replace&&h1(b)?b:{...v,...b}}return v}))},p=(f,d,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const b=typeof d=="function"?d(v):d;return h.replace&&oH(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>{var d;return(d=o(f))==null?void 0:d.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:l,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:h}=t.getState(),[y,v,b]=h;return{nodes:f.map(g=>({...g})),edges:d.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:h,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:_}=t.getState(),{nodes:S,edges:N}=await v4({nodesToRemove:f,edgesToRemove:d,nodes:h,edges:y,onBeforeDelete:_}),I=N.length>0,T=S.length>0;if(I){const z=N.map(p1);b==null||b(N),k(z)}if(T){const z=S.map(p1);v==null||v(S),g(z)}return(T||I)&&(x==null||x({nodes:S,edges:N})),{deletedNodes:S,deletedEdges:N}},getIntersectingNodes:(f,d=!0,h)=>{const y=VN(f),v=y?f:c(f),b=h!==void 0;return v?(h||t.getState().nodes).filter(g=>{const k=t.getState().nodeLookup.get(g.id);if(k&&!y&&(g.id===f.id||!k.internals.positionAbsolute))return!1;const x=Vc(b?g:k),_=nf(x,v);return d&&_>0||_>=x.width*x.height||_>=v.width*v.height}):[]},isNodeIntersecting:(f,d,h=!0)=>{const v=VN(f)?f:c(f);if(!v)return!1;const b=nf(v,d);return h&&b>0||b>=d.width*d.height||b>=v.width*v.height},updateNode:u,updateNodeData:(f,d,h={replace:!1})=>{u(f,y=>{const v=typeof d=="function"?d(y):d;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},updateEdge:p,updateEdgeData:(f,d,h={replace:!1})=>{p(f,y=>{const v=typeof d=="function"?d(y):d;return h.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},h)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:h}=t.getState();return w4(f,{nodeLookup:d,nodeOrigin:h})},getHandleConnections:({type:f,id:d,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}-${f}${d?`-${d}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:f,handleId:d,nodeId:h})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${h}${f?d?`-${f}-${d}`:`-${f}`:""}`))==null?void 0:y.values())??[])},fitView:async f=>{const d=t.getState().fitViewResolver??_4();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(h=>[...h]),d.promise}}},[]);return m.useMemo(()=>({...i,...e,viewportInitialized:r}),[r])}const g1=e=>e.selected,dH=typeof window<"u"?window:void 0;function fH({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=kn(),{deleteElements:r}=tu(),i=sf(e,{actInsideInputWithModifier:!1}),o=sf(t,{target:dH});m.useEffect(()=>{if(i){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(g1),edges:a.filter(g1)}),n.setState({nodesSelectionActive:!1})}},[i]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function pH(e){const t=kn();m.useEffect(()=>{const n=()=>{var i,o,a,l;if(!e.current||!(((o=(i=e.current).checkVisibility)==null?void 0:o.call(i))??!0))return!1;const r=Qk(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",zi.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 yg={position:"absolute",width:"100%",height:"100%",top:0,left:0},hH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function mH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:o=Xa.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:p,maxZoom:f,zoomActivationKeyCode:d,preventScrolling:h=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:_}){const S=kn(),N=m.useRef(null),{userSelectionActive:I,lib:T,connectionInProgress:z}=Jt(hH,Tn),E=sf(d),O=m.useRef();pH(N);const D=m.useCallback(L=>{g==null||g({x:L[0],y:L[1],zoom:L[2]}),k||S.setState({transform:L})},[g,k]);return m.useEffect(()=>{if(N.current){O.current=l5({domNode:N.current,minZoom:p,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:B=>S.setState(F=>F.paneDragging===B?F:{paneDragging:B}),onPanZoomStart:(B,F)=>{const{onViewportChangeStart:R,onMoveStart:H}=S.getState();H==null||H(B,F),R==null||R(F)},onPanZoom:(B,F)=>{const{onViewportChange:R,onMove:H}=S.getState();H==null||H(B,F),R==null||R(F)},onPanZoomEnd:(B,F)=>{const{onViewportChangeEnd:R,onMoveEnd:H}=S.getState();H==null||H(B,F),R==null||R(F)}});const{x:L,y:$,zoom:V}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[L,$,V],domNode:N.current.closest(".react-flow")}),()=>{var B;(B=O.current)==null||B.destroy()}}},[]),m.useEffect(()=>{var L;(L=O.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:E,preventScrolling:h,noPanClassName:b,userSelectionActive:I,noWheelClassName:v,lib:T,onTransformChange:D,connectionInProgress:z,selectionOnDrag:_,paneClickDistance:x})},[e,t,n,r,i,o,a,l,E,h,b,I,v,T,D,z,_,x]),s.jsx("div",{className:"react-flow__renderer",ref:N,style:yg,children:y})}const gH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function yH(){const{userSelectionActive:e,userSelectionRect:t}=Jt(gH,Tn);return e&&t?s.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 ow=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},wH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function xH({isSelecting:e,selectionKeyPressed:t,selectionMode:n=tf.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:p,onPaneMouseEnter:f,onPaneMouseMove:d,onPaneMouseLeave:h,children:y}){const v=kn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Jt(wH,Tn),_=g&&(e||b),S=m.useRef(null),N=m.useRef(),I=m.useRef(new Set),T=m.useRef(new Set),z=m.useRef(!1),E=R=>{if(z.current||x){z.current=!1;return}c==null||c(R),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},O=R=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){R.preventDefault();return}u==null||u(R)},D=p?R=>p(R):void 0,L=R=>{z.current&&(R.stopPropagation(),z.current=!1)},$=R=>{var ee,G;const{domNode:H}=v.getState();if(N.current=H==null?void 0:H.getBoundingClientRect(),!N.current)return;const A=R.target===S.current;if(!A&&!!R.target.closest(".nokey")||!e||!(o&&A||t)||R.button!==0||!R.isPrimary)return;(G=(ee=R.target)==null?void 0:ee.setPointerCapture)==null||G.call(ee,R.pointerId),z.current=!1;const{x:W,y:te}=li(R.nativeEvent,N.current);v.setState({userSelectionRect:{width:0,height:0,startX:W,startY:te,x:W,y:te}}),A||(R.stopPropagation(),R.preventDefault())},V=R=>{const{userSelectionRect:H,transform:A,nodeLookup:X,edgeLookup:K,connectionLookup:W,triggerNodeChanges:te,triggerEdgeChanges:ee,defaultEdgeOptions:G,resetSelectedElements:ne}=v.getState();if(!N.current||!H)return;const{x:re,y:ie}=li(R.nativeEvent,N.current),{startX:Z,startY:de}=H;if(!z.current){const Ne=t?0:i;if(Math.hypot(re-Z,ie-de)<=Ne)return;ne(),a==null||a(R)}z.current=!0;const fe={startX:Z,startY:de,x:re<Z?re:Z,y:ie<de?ie:de,width:Math.abs(re-Z),height:Math.abs(ie-de)},ge=I.current,Oe=T.current;I.current=new Set(Jk(X,fe,A,n===tf.Partial,!0).map(Ne=>Ne.id)),T.current=new Set;const _e=(G==null?void 0:G.selectable)??!0;for(const Ne of I.current){const He=W.get(Ne);if(He)for(const{edgeId:ct}of He.values()){const xt=K.get(ct);xt&&(xt.selectable??_e)&&T.current.add(ct)}}if(!KN(ge,I.current)){const Ne=mc(X,I.current,!0);te(Ne)}if(!KN(Oe,T.current)){const Ne=mc(K,T.current);ee(Ne)}v.setState({userSelectionRect:fe,userSelectionActive:!0,nodesSelectionActive:!1})},B=R=>{var H,A;R.button===0&&((A=(H=R.target)==null?void 0:H.releasePointerCapture)==null||A.call(H,R.pointerId),!b&&R.target===S.current&&v.getState().userSelectionRect&&(E==null||E(R)),v.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(l==null||l(R),v.setState({nodesSelectionActive:I.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:or(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:_?void 0:ow(E,S),onContextMenu:ow(O,S),onWheel:ow(D,S),onPointerEnter:_?void 0:f,onPointerMove:_?V:d,onPointerUp:_?B:void 0,onPointerDownCapture:_?$:void 0,onClickCapture:_?L:void 0,onPointerLeave:h,ref:S,style:yg,children:[y,s.jsx(yH,{})]})}function ob({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",zi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):i([e])}function ST({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,nodeClickDistance:a}){const l=kn(),[c,u]=m.useState(!1),p=m.useRef();return m.useEffect(()=>{p.current=G4({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{ob({id:f,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:i,nodeClickDistance:a}),()=>{var f;(f=p.current)==null||f.destroy()}},[n,r,t,o,e,i,a]),c}const bH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function jT(){const e=kn();return m.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:p}=e.getState(),f=new Map,d=bH(a),h=i?o[0]:5,y=i?o[1]:5,v=n.direction.x*h*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!d(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};i&&(k=If(k,o));const{position:x,positionAbsolute:_}=zP({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:p,onError:l});g.position=x,g.internals.positionAbsolute=_,f.set(g.id,g)}c(f)},[])}const sv=m.createContext(null),kH=sv.Provider;sv.Consumer;const NT=()=>m.useContext(sv),vH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),SH=(e,t,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,p=(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:p,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.id)===t&&(i==null?void 0:i.type)===n,isPossibleEndHandle:o===Bc.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:!!i,valid:p&&u}};function jH({type:e="source",position:t=Ge.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:p,onTouchStart:f,...d},h){var V,B;const y=a||null,v=e==="target",b=kn(),g=NT(),{connectOnClick:k,noPanClassName:x,rfId:_}=Jt(vH,Tn),{connectingFrom:S,connectingTo:N,clickConnecting:I,isPossibleEndHandle:T,connectionInProcess:z,clickConnectionInProcess:E,valid:O}=Jt(SH(g,y,e),Tn);g||(B=(V=b.getState()).onError)==null||B.call(V,"010",zi.error010());const D=F=>{const{defaultEdgeOptions:R,onConnect:H,hasDefaultEdges:A}=b.getState(),X={...R,...F};if(A){const{edges:K,setEdges:W}=b.getState();W(Ch(X,K))}H==null||H(X),l==null||l(X)},L=F=>{if(!g)return;const R=GP(F.nativeEvent);if(i&&(R&&F.button===0||!R)){const H=b.getState();sb.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:H.autoPanOnConnect,connectionMode:H.connectionMode,connectionRadius:H.connectionRadius,domNode:H.domNode,nodeLookup:H.nodeLookup,lib:H.lib,isTarget:v,handleId:y,nodeId:g,flowId:H.rfId,panBy:H.panBy,cancelConnection:H.cancelConnection,onConnectStart:H.onConnectStart,onConnectEnd:(...A)=>{var X,K;return(K=(X=b.getState()).onConnectEnd)==null?void 0:K.call(X,...A)},updateConnection:H.updateConnection,onConnect:D,isValidConnection:n||((...A)=>{var X,K;return((K=(X=b.getState()).isValidConnection)==null?void 0:K.call(X,...A))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:H.autoPanSpeed,dragThreshold:H.connectionDragThreshold})}R?p==null||p(F):f==null||f(F)},$=F=>{const{onClickConnectStart:R,onClickConnectEnd:H,connectionClickStartHandle:A,connectionMode:X,isValidConnection:K,lib:W,rfId:te,nodeLookup:ee,connection:G}=b.getState();if(!g||!A&&!i)return;if(!A){R==null||R(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ne=qP(F.target),re=n||K,{connection:ie,isValid:Z}=sb.isValid(F.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:X,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:re,flowId:te,doc:ne,lib:W,nodeLookup:ee});Z&&ie&&D(ie);const de=structuredClone(G);delete de.inProgress,de.toPosition=de.toHandle?de.toHandle.position:null,H==null||H(F,de),b.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${_}-${g}-${y}-${e}`,className:or(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:i,connectableend:o,clickconnecting:I,connectingfrom:S,connectingto:N,valid:O,connectionindicator:r&&(!z||T)&&(z||E?o:i)}]),onMouseDown:L,onTouchStart:L,onClick:k?$:void 0,ref:h,...d,children:c})}const ir=m.memo(kT(jH));function NH({data:e,isConnectable:t,sourcePosition:n=Ge.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(ir,{type:"source",position:n,isConnectable:t})]})}function _H({data:e,isConnectable:t,targetPosition:n=Ge.Top,sourcePosition:r=Ge.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(ir,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(ir,{type:"source",position:r,isConnectable:t})]})}function CH(){return null}function AH({data:e,isConnectable:t,targetPosition:n=Ge.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(ir,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const gm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},y1={input:NH,default:_H,output:AH,group:CH};function EH(e){var t,n,r,i;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??((i=e.style)==null?void 0:i.height)}}const IH=e=>{const{width:t,height:n,x:r,y:i}=Ef(e.nodeLookup,{filter:o=>!!o.selected});return{width:ai(t)?t:null,height:ai(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function PH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=kn(),{width:i,height:o,transformString:a,userSelectionActive:l}=Jt(IH,Tn),c=jT(),u=m.useRef(null);m.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const p=!l&&i!==null&&o!==null;if(ST({nodeRef:u,disabled:!p}),!p)return null;const f=e?h=>{const y=r.getState().nodes.filter(v=>v.selected);e(h,y)}:void 0,d=h=>{Object.prototype.hasOwnProperty.call(gm,h.key)&&(h.preventDefault(),c({direction:gm[h.key],factor:h.shiftKey?4:1}))};return s.jsx("div",{className:or(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:s.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:i,height:o}})})}const w1=typeof window<"u"?window:void 0,TH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function _T({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:p,selectionMode:f,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:_,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:I,panOnDrag:T,defaultViewport:z,translateExtent:E,minZoom:O,maxZoom:D,preventScrolling:L,onSelectionContextMenu:$,noWheelClassName:V,noPanClassName:B,disableKeyboardA11y:F,onViewportChange:R,isControlledViewport:H}){const{nodesSelectionActive:A,userSelectionActive:X}=Jt(TH,Tn),K=sf(u,{target:w1}),W=sf(v,{target:w1}),te=W||T,ee=W||_,G=p&&te!==!0,ne=K||X||G;return fH({deleteKeyCode:c,multiSelectionKeyCode:y}),s.jsx(mH,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:ee,panOnScrollSpeed:S,panOnScrollMode:N,zoomOnDoubleClick:I,panOnDrag:!K&&te,defaultViewport:z,translateExtent:E,minZoom:O,maxZoom:D,zoomActivationKeyCode:b,preventScrolling:L,noWheelClassName:V,noPanClassName:B,onViewportChange:R,isControlledViewport:H,paneClickDistance:l,selectionOnDrag:G,children:s.jsxs(xH,{onSelectionStart:d,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:te,isSelecting:!!ne,selectionMode:f,selectionKeyPressed:K,paneClickDistance:l,selectionOnDrag:G,children:[e,A&&s.jsx(PH,{onSelectionContextMenu:$,noPanClassName:B,disableKeyboardA11y:F})]})})}_T.displayName="FlowRenderer";const RH=m.memo(_T),MH=e=>t=>e?Jk(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 $H(e){return Jt(m.useCallback(MH(e),[e]),Tn)}const LH=e=>e.updateNodeInternals;function OH(){const e=Jt(LH),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(i=>{const o=i.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:i.target,force:!0})}),e(r)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function DH({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const i=kn(),o=m.useRef(null),a=m.useRef(null),l=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),u=m.useRef(t),p=n&&!!e.internals.handleBounds;return m.useEffect(()=>{o.current&&!e.hidden&&(!p||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[p,e.hidden]),m.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),m.useEffect(()=>{if(o.current){const f=u.current!==t,d=l.current!==e.sourcePosition,h=c.current!==e.targetPosition;(f||d||h)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function FH({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:p,resizeObserver:f,noDragClassName:d,noPanClassName:h,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:_,isParent:S}=Jt(re=>{const ie=re.nodeLookup.get(e),Z=re.parentLookup.has(e);return{node:ie,internals:ie.internals,isParent:Z}},Tn);let N=x.type||"default",I=(b==null?void 0:b[N])||y1[N];I===void 0&&(k==null||k("003",zi.error003(N)),N="default",I=(b==null?void 0:b.default)||y1.default);const T=!!(x.draggable||l&&typeof x.draggable>"u"),z=!!(x.selectable||c&&typeof x.selectable>"u"),E=!!(x.connectable||u&&typeof x.connectable>"u"),O=!!(x.focusable||p&&typeof x.focusable>"u"),D=kn(),L=VP(x),$=DH({node:x,nodeType:N,hasDimensions:L,resizeObserver:f}),V=ST({nodeRef:$,disabled:x.hidden||!T,noDragClassName:d,handleSelector:x.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:g}),B=jT();if(x.hidden)return null;const F=ko(x),R=EH(x),H=z||T||t||n||r||i,A=n?re=>n(re,{..._.userNode}):void 0,X=r?re=>r(re,{..._.userNode}):void 0,K=i?re=>i(re,{..._.userNode}):void 0,W=o?re=>o(re,{..._.userNode}):void 0,te=a?re=>a(re,{..._.userNode}):void 0,ee=re=>{const{selectNodesOnDrag:ie,nodeDragThreshold:Z}=D.getState();z&&(!ie||!T||Z>0)&&ob({id:e,store:D,nodeRef:$}),t&&t(re,{..._.userNode})},G=re=>{if(!(UP(re.nativeEvent)||y)){if($P.includes(re.key)&&z){const ie=re.key==="Escape";ob({id:e,store:D,unselect:ie,nodeRef:$})}else if(T&&x.selected&&Object.prototype.hasOwnProperty.call(gm,re.key)){re.preventDefault();const{ariaLabelConfig:ie}=D.getState();D.setState({ariaLiveMessage:ie["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),B({direction:gm[re.key],factor:re.shiftKey?4:1})}}},ne=()=>{var Oe;if(y||!((Oe=$.current)!=null&&Oe.matches(":focus-visible")))return;const{transform:re,width:ie,height:Z,autoPanOnNodeFocus:de,setCenter:fe}=D.getState();if(!de)return;Jk(new Map([[e,x]]),{x:0,y:0,width:ie,height:Z},re,!0).length>0||fe(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:re[2]})};return s.jsx("div",{className:or(["react-flow__node",`react-flow__node-${N}`,{[h]:T},x.className,{selected:x.selected,selectable:z,parent:S,draggable:T,dragging:V}]),ref:$,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:H?"all":"none",visibility:L?"visible":"hidden",...x.style,...R},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:A,onMouseMove:X,onMouseLeave:K,onContextMenu:W,onClick:ee,onDoubleClick:te,onKeyDown:O?G:void 0,tabIndex:O?0:void 0,onFocus:O?ne:void 0,role:x.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${yT}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:s.jsx(kH,{value:e,children:s.jsx(I,{id:e,data:x.data,type:N,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:x.selected??!1,selectable:z,draggable:T,deletable:x.deletable??!0,isConnectable:E,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:V,dragHandle:x.dragHandle,zIndex:_.z,parentId:x.parentId,...F})})})}var zH=m.memo(FH);const WH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function CT(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:o}=Jt(WH,Tn),a=$H(e.onlyRenderVisibleElements),l=OH();return s.jsx("div",{className:"react-flow__nodes",style:yg,children:a.map(c=>s.jsx(zH,{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:i,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}CT.displayName="NodeRenderer";const BH=m.memo(CT);function HH(e){return Jt(m.useCallback(n=>{if(!e)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const o=n.nodeLookup.get(i.source),a=n.nodeLookup.get(i.target);o&&a&&I4({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),Tn)}const VH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},KH=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},x1={[Ei.Arrow]:VH,[Ei.ArrowClosed]:KH};function qH(e){const t=kn();return m.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(x1,e)?x1[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",zi.error009(e)),null)},[e])}const UH=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=qH(t);return c?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0",children:s.jsx(c,{color:n,strokeWidth:a})}):null},AT=({defaultColor:e,rfId:t})=>{const n=Jt(o=>o.edges),r=Jt(o=>o.defaultEdgeOptions),i=m.useMemo(()=>O4(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return i.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:i.map(o=>s.jsx(UH,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};AT.displayName="MarkerDefinitions";var GH=m.memo(AT);function ET({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...p}){const[f,d]=m.useState({x:1,y:0,width:0,height:0}),h=or(["react-flow__edge-textwrapper",u]),y=m.useRef(null);return m.useEffect(()=>{if(y.current){const v=y.current.getBBox();d({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...p,children:[i&&s.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),s.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}ET.displayName="EdgeText";const YH=m.memo(ET);function wg({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...p}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...p,d:e,fill:"none",className:or(["react-flow__edge-path",p.className])}),u?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&ai(t)&&ai(n)?s.jsx(YH,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function b1({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Ge.Left||e===Ge.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function IT({sourceX:e,sourceY:t,sourcePosition:n=Ge.Bottom,targetX:r,targetY:i,targetPosition:o=Ge.Top}){const[a,l]=b1({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,u]=b1({pos:o,x1:r,y1:i,x2:e,y2:t}),[p,f,d,h]=YP({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${i}`,p,f,d,h]}function PT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,_]=IT({sourceX:n,sourceY:r,sourcePosition:a,targetX:i,targetY:o,targetPosition:l}),S=e.isInternal?void 0:t;return s.jsx(wg,{id:S,path:k,labelX:x,labelY:_,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const JH=PT({isInternal:!1}),TT=PT({isInternal:!0});JH.displayName="SimpleBezierEdge";TT.displayName="SimpleBezierEdgeInternal";function RT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,sourcePosition:h=Ge.Bottom,targetPosition:y=Ge.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,S]=tb({sourceX:n,sourceY:r,sourcePosition:h,targetX:i,targetY:o,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),N=e.isInternal?void 0:t;return s.jsx(wg,{id:N,path:x,labelX:_,labelY:S,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:v,markerStart:b,interactionWidth:k})})}const MT=RT({isInternal:!1}),$T=RT({isInternal:!0});MT.displayName="SmoothStepEdge";$T.displayName="SmoothStepEdgeInternal";function LT(e){return m.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(MT,{...n,id:r,pathOptions:m.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const XH=LT({isInternal:!1}),OT=LT({isInternal:!0});XH.displayName="StepEdge";OT.displayName="StepEdgeInternal";function DT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:y,interactionWidth:v})=>{const[b,g,k]=QP({sourceX:n,sourceY:r,targetX:i,targetY:o}),x=e.isInternal?void 0:t;return s.jsx(wg,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:d,markerEnd:h,markerStart:y,interactionWidth:v})})}const QH=DT({isInternal:!1}),FT=DT({isInternal:!0});QH.displayName="StraightEdge";FT.displayName="StraightEdgeInternal";function zT(e){return m.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:a=Ge.Bottom,targetPosition:l=Ge.Top,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,S]=JP({sourceX:n,sourceY:r,sourcePosition:a,targetX:i,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),N=e.isInternal?void 0:t;return s.jsx(wg,{id:N,path:x,labelX:_,labelY:S,label:c,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const ZH=zT({isInternal:!1}),WT=zT({isInternal:!0});ZH.displayName="BezierEdge";WT.displayName="BezierEdgeInternal";const k1={default:WT,straight:FT,step:OT,smoothstep:$T,simplebezier:TT},v1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},e6=(e,t,n)=>n===Ge.Left?e-t:n===Ge.Right?e+t:e,t6=(e,t,n)=>n===Ge.Top?e-t:n===Ge.Bottom?e+t:e,S1="react-flow__edgeupdater";function j1({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:a,type:l}){return s.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:a,className:or([S1,`${S1}-${l}`]),cx:e6(t,r,e),cy:t6(n,r,e),r,stroke:"transparent",fill:"transparent"})}function n6({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:p,onReconnectEnd:f,setReconnecting:d,setUpdateHover:h}){const y=kn(),v=(_,S)=>{if(_.button!==0)return;const{autoPanOnConnect:N,domNode:I,connectionMode:T,connectionRadius:z,lib:E,onConnectStart:O,cancelConnection:D,nodeLookup:L,rfId:$,panBy:V,updateConnection:B}=y.getState(),F=S.type==="target",R=(X,K)=>{d(!1),f==null||f(X,n,S.type,K)},H=X=>u==null?void 0:u(n,X),A=(X,K)=>{d(!0),p==null||p(_,n,S.type),O==null||O(X,K)};sb.onPointerDown(_.nativeEvent,{autoPanOnConnect:N,connectionMode:T,connectionRadius:z,domNode:I,handleId:S.id,nodeId:S.nodeId,nodeLookup:L,isTarget:F,edgeUpdaterType:S.type,lib:E,flowId:$,cancelConnection:D,panBy:V,isValidConnection:(...X)=>{var K,W;return((W=(K=y.getState()).isValidConnection)==null?void 0:W.call(K,...X))??!0},onConnect:H,onConnectStart:A,onConnectEnd:(...X)=>{var K,W;return(W=(K=y.getState()).onConnectEnd)==null?void 0:W.call(K,...X)},onReconnectEnd:R,updateConnection:B,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:_.currentTarget})},b=_=>v(_,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=_=>v(_,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>h(!0),x=()=>h(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(j1,{position:l,centerX:r,centerY:i,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&s.jsx(j1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function r6({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:p,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Jt(fe=>fe.edgeLookup.get(e));const _=Jt(fe=>fe.defaultEdgeOptions);x=_?{..._,...x}:x;let S=x.type||"default",N=(v==null?void 0:v[S])||k1[S];N===void 0&&(g==null||g("011",zi.error011(S)),S="default",N=(v==null?void 0:v.default)||k1.default);const I=!!(x.focusable||t&&typeof x.focusable>"u"),T=typeof f<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),z=!!(x.selectable||r&&typeof x.selectable>"u"),E=m.useRef(null),[O,D]=m.useState(!1),[L,$]=m.useState(!1),V=kn(),{zIndex:B,sourceX:F,sourceY:R,targetX:H,targetY:A,sourcePosition:X,targetPosition:K}=Jt(m.useCallback(fe=>{const ge=fe.nodeLookup.get(x.source),Oe=fe.nodeLookup.get(x.target);if(!ge||!Oe)return{zIndex:x.zIndex,...v1};const _e=L4({id:e,sourceNode:ge,targetNode:Oe,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:fe.connectionMode,onError:g});return{zIndex:E4({selected:x.selected,zIndex:x.zIndex,sourceNode:ge,targetNode:Oe,elevateOnSelect:fe.elevateEdgesOnSelect,zIndexMode:fe.zIndexMode}),..._e||v1}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Tn),W=m.useMemo(()=>x.markerStart?`url('#${nb(x.markerStart,y)}')`:void 0,[x.markerStart,y]),te=m.useMemo(()=>x.markerEnd?`url('#${nb(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||R===null||H===null||A===null)return null;const ee=fe=>{var Ne;const{addSelectedEdges:ge,unselectNodesAndEdges:Oe,multiSelectionActive:_e}=V.getState();z&&(V.setState({nodesSelectionActive:!1}),x.selected&&_e?(Oe({nodes:[],edges:[x]}),(Ne=E.current)==null||Ne.blur()):ge([e])),i&&i(fe,x)},G=o?fe=>{o(fe,{...x})}:void 0,ne=a?fe=>{a(fe,{...x})}:void 0,re=l?fe=>{l(fe,{...x})}:void 0,ie=c?fe=>{c(fe,{...x})}:void 0,Z=u?fe=>{u(fe,{...x})}:void 0,de=fe=>{var ge;if(!k&&$P.includes(fe.key)&&z){const{unselectNodesAndEdges:Oe,addSelectedEdges:_e}=V.getState();fe.key==="Escape"?((ge=E.current)==null||ge.blur(),Oe({edges:[x]})):_e([e])}};return s.jsx("svg",{style:{zIndex:B},children:s.jsxs("g",{className:or(["react-flow__edge",`react-flow__edge-${S}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!z&&!i,updating:O,selectable:z}]),onClick:ee,onDoubleClick:G,onContextMenu:ne,onMouseEnter:re,onMouseMove:ie,onMouseLeave:Z,onKeyDown:I?de:void 0,tabIndex:I?0:void 0,role:x.ariaRole??(I?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":I?`${wT}-${y}`:void 0,ref:E,...x.domAttributes,children:[!L&&s.jsx(N,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:z,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:F,sourceY:R,targetX:H,targetY:A,sourcePosition:X,targetPosition:K,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:W,markerEnd:te,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),T&&s.jsx(n6,{edge:x,isReconnectable:T,reconnectRadius:p,onReconnect:f,onReconnectStart:d,onReconnectEnd:h,sourceX:F,sourceY:R,targetX:H,targetY:A,sourcePosition:X,targetPosition:K,setUpdateHover:D,setReconnecting:$})]})})}var s6=m.memo(r6);const i6=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function BT({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:p,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:h,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Jt(i6,Tn),_=HH(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(GH,{defaultColor:e,rfId:n}),_.map(S=>s.jsx(s6,{id:S,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:i,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:p,reconnectRadius:f,onDoubleClick:d,onReconnectStart:h,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},S))]})}BT.displayName="EdgeRenderer";const o6=m.memo(BT),a6=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function l6({children:e}){const t=Jt(a6);return s.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function c6(e){const t=tu(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const u6=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function d6(e){const t=Jt(u6),n=kn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function f6(e){return e.connection.inProgress?{...e.connection,to:Pf(e.connection.to,e.transform)}:{...e.connection}}function p6(e){return f6}function h6(e){const t=p6();return Jt(t,Tn)}const m6=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function g6({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:a,isValid:l,inProgress:c}=Jt(m6,Tn);return!(o&&i&&c)?null:s.jsx("svg",{style:e,width:o,height:a,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:or(["react-flow__connection",DP(l)]),children:s.jsx(HT,{style:t,type:n,CustomComponent:r,isValid:l})})})}const HT=({style:e,type:t=Vo.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:p,toHandle:f,toPosition:d,pointer:h}=h6();if(!i)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:d,connectionStatus:DP(r),toNode:p,toHandle:f,pointer:h});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case Vo.Bezier:[y]=JP(v);break;case Vo.SimpleBezier:[y]=IT(v);break;case Vo.Step:[y]=tb({...v,borderRadius:0});break;case Vo.SmoothStep:[y]=tb(v);break;default:[y]=QP(v)}return s.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};HT.displayName="ConnectionLine";const y6={};function N1(e=y6){m.useRef(e),kn(),m.useEffect(()=>{},[e])}function w6(){kn(),m.useRef(!1),m.useEffect(()=>{},[])}function VT({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:p,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:h,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:I,deleteKeyCode:T,onlyRenderVisibleElements:z,elementsSelectable:E,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:$,preventScrolling:V,defaultMarkerColor:B,zoomOnScroll:F,zoomOnPinch:R,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:X,zoomOnDoubleClick:K,panOnDrag:W,onPaneClick:te,onPaneMouseEnter:ee,onPaneMouseMove:G,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ie,paneClickDistance:Z,nodeClickDistance:de,onEdgeContextMenu:fe,onEdgeMouseEnter:ge,onEdgeMouseMove:Oe,onEdgeMouseLeave:_e,reconnectRadius:Ne,onReconnect:He,onReconnectStart:ct,onReconnectEnd:xt,noDragClassName:Re,noWheelClassName:lt,noPanClassName:kt,disableKeyboardA11y:Ot,nodeExtent:_t,rfId:Xt,viewport:ae,onViewportChange:ke}){return N1(e),N1(t),w6(),c6(n),d6(ae),s.jsx(RH,{onPaneClick:te,onPaneMouseEnter:ee,onPaneMouseMove:G,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:re,paneClickDistance:Z,deleteKeyCode:T,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,onSelectionStart:d,onSelectionEnd:h,multiSelectionKeyCode:S,panActivationKeyCode:N,zoomActivationKeyCode:I,elementsSelectable:E,zoomOnScroll:F,zoomOnPinch:R,zoomOnDoubleClick:K,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:X,panOnDrag:W,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:$,onSelectionContextMenu:f,preventScrolling:V,noDragClassName:Re,noWheelClassName:lt,noPanClassName:kt,disableKeyboardA11y:Ot,onViewportChange:ke,isControlledViewport:!!ae,children:s.jsxs(l6,{children:[s.jsx(o6,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:a,onReconnect:He,onReconnectStart:ct,onReconnectEnd:xt,onlyRenderVisibleElements:z,onEdgeContextMenu:fe,onEdgeMouseEnter:ge,onEdgeMouseMove:Oe,onEdgeMouseLeave:_e,reconnectRadius:Ne,defaultMarkerColor:B,noPanClassName:kt,disableKeyboardA11y:Ot,rfId:Xt}),s.jsx(g6,{style:v,type:y,component:b,containerStyle:g}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(BH,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:p,nodeClickDistance:de,onlyRenderVisibleElements:z,noPanClassName:kt,noDragClassName:Re,disableKeyboardA11y:Ot,nodeExtent:_t,rfId:Xt}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}VT.displayName="GraphView";const x6=m.memo(VT),_1=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:p,nodeExtent:f,zIndexMode:d="basic"}={})=>{const h=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=p??[0,0],_=f??ef;tT(v,b,g);const{nodesInitialized:S}=rb(k,h,y,{nodeOrigin:x,nodeExtent:_,zIndexMode:d});let N=[0,0,1];if(a&&i&&o){const I=Ef(h,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:T,y:z,zoom:E}=Xk(I,i,o,c,u,(l==null?void 0:l.padding)??.1);N=[T,z,E]}return{rfId:"1",width:i??0,height:o??0,transform:N,nodes:k,nodesInitialized:S,nodeLookup:h,parentLookup:y,edges:g,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:ef,nodeExtent:_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Bc.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:{...OP},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:S4,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:LP,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},b6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:p,nodeExtent:f,zIndexMode:d})=>F5((h,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:_,height:S,minZoom:N,maxZoom:I}=y();g&&(await k4({nodes:b,width:_,height:S,panZoom:g,minZoom:N,maxZoom:I},k),x==null||x.resolve(!0),h({fitViewResolver:null}))}return{..._1({nodes:e,edges:t,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:p,nodeExtent:f,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:_,fitViewQueued:S,zIndexMode:N,nodesSelectionActive:I}=y(),{nodesInitialized:T,hasSelectedNodes:z}=rb(b,g,k,{nodeOrigin:x,nodeExtent:f,elevateNodesOnSelect:_,checkEquality:!0,zIndexMode:N}),E=I&&z;S&&T?(v(),h({nodes:b,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:E})):h({nodes:b,nodesInitialized:T,nodesSelectionActive:E})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();tT(g,k,b),h({edges:b})},setDefaultNodesAndEdges:(b,g)=>{if(b){const{setNodes:k}=y();k(b),h({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),h({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:x,domNode:_,nodeOrigin:S,nodeExtent:N,debug:I,fitViewQueued:T,zIndexMode:z}=y(),{changes:E,updatedInternals:O}=V4(b,k,x,_,S,N,z);O&&(z4(k,x,{nodeOrigin:S,nodeExtent:N,zIndexMode:z}),T?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(E==null?void 0:E.length)>0&&(I&&console.log("React Flow: trigger node changes",E),g==null||g(E)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:_,triggerNodeChanges:S,connection:N,updateConnection:I,onNodesChangeMiddlewareMap:T}=y();for(const[z,E]of b){const O=_.get(z),D=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(E!=null&&E.position)),L={id:z,type:"position",position:D?{x:Math.max(0,E.position.x),y:Math.max(0,E.position.y)}:E.position,dragging:g};if(O&&N.inProgress&&N.fromNode.id===O.id){const $=ll(O,N.fromHandle,Ge.Left,!0);I({...N,from:$})}D&&O.parentId&&k.push({id:z,parentId:O.parentId,rect:{...E.internals.positionAbsolute,width:E.measured.width??0,height:E.measured.height??0}}),x.push(L)}if(k.length>0){const{parentLookup:z,nodeOrigin:E}=y(),O=rv(k,_,z,E);x.push(...O)}for(const z of T.values())x=z(x);S(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:_,debug:S}=y();if(b!=null&&b.length){if(_){const N=Nd(b,x);k(N)}S&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:_,debug:S}=y();if(b!=null&&b.length){if(_){const N=mm(b,x);k(N)}S&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=y();if(g){const N=b.map(I=>La(I,!0));_(N);return}_(mc(x,new Set([...b]),!0)),S(mc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:S}=y();if(g){const N=b.map(I=>La(I,!0));S(N);return}S(mc(k,new Set([...b]))),_(mc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:_,triggerNodeChanges:S,triggerEdgeChanges:N}=y(),I=b||x,T=g||k,z=[];for(const O of I){if(!O.selected)continue;const D=_.get(O.id);D&&(D.selected=!1),z.push(La(O.id,!1))}const E=[];for(const O of T)O.selected&&E.push(La(O.id,!1));S(z),N(E)},setMinZoom:b=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([b,k]),h({minZoom:b})},setMaxZoom:b=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,b]),h({maxZoom:b})},setTranslateExtent:b=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(b),h({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:x,elementsSelectable:_}=y();if(!_)return;const S=g.reduce((I,T)=>T.selected?[...I,La(T.id,!1)]:I,[]),N=b.reduce((I,T)=>T.selected?[...I,La(T.id,!1)]:I,[]);k(S),x(N)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:_,elevateNodesOnSelect:S,nodeExtent:N,zIndexMode:I}=y();b[0][0]===N[0][0]&&b[0][1]===N[0][1]&&b[1][0]===N[1][0]&&b[1][1]===N[1][1]||(rb(g,k,x,{nodeOrigin:_,nodeExtent:b,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:I}),h({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:_,translateExtent:S}=y();return K4({delta:b,panZoom:_,transform:g,translateExtent:S,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:_,maxZoom:S,panZoom:N}=y();if(!N)return Promise.resolve(!1);const I=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:S;return await N.setViewport({x:x/2-b*I,y:_/2-g*I,zoom:I},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...OP}})},updateConnection:b=>{h({connection:b})},reset:()=>h({..._1()})}},Object.is);function iv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:p,nodeExtent:f,zIndexMode:d,children:h}){const[y]=m.useState(()=>b6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:p,nodeExtent:f,zIndexMode:d}));return s.jsx(z5,{value:y,children:s.jsx(lH,{children:h})})}function k6({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:p,nodeOrigin:f,nodeExtent:d,zIndexMode:h}){return m.useContext(mg)?s.jsx(s.Fragment,{children:e}):s.jsx(iv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:p,nodeOrigin:f,nodeExtent:d,zIndexMode:h,children:e})}const v6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function S6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:p,onMoveStart:f,onMoveEnd:d,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:S,onNodeDoubleClick:N,onNodeDragStart:I,onNodeDrag:T,onNodeDragStop:z,onNodesDelete:E,onEdgesDelete:O,onDelete:D,onSelectionChange:L,onSelectionDragStart:$,onSelectionDrag:V,onSelectionDragStop:B,onSelectionContextMenu:F,onSelectionStart:R,onSelectionEnd:H,onBeforeDelete:A,connectionMode:X,connectionLineType:K=Vo.Bezier,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:ee,deleteKeyCode:G="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:re=!1,selectionMode:ie=tf.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:de=rf()?"Meta":"Control",zoomActivationKeyCode:fe=rf()?"Meta":"Control",snapToGrid:ge,snapGrid:Oe,onlyRenderVisibleElements:_e=!1,selectNodesOnDrag:Ne,nodesDraggable:He,autoPanOnNodeFocus:ct,nodesConnectable:xt,nodesFocusable:Re,nodeOrigin:lt=xT,edgesFocusable:kt,edgesReconnectable:Ot,elementsSelectable:_t=!0,defaultViewport:Xt=Z5,minZoom:ae=.5,maxZoom:ke=2,translateExtent:Ue=ef,preventScrolling:it=!0,nodeExtent:Ee,defaultMarkerColor:Kt="#b1b1b7",zoomOnScroll:en=!0,zoomOnPinch:Ut=!0,panOnScroll:wt=!1,panOnScrollSpeed:mn=.5,panOnScrollMode:se=Xa.Free,zoomOnDoubleClick:Ce=!0,panOnDrag:Ye=!0,onPaneClick:ze,onPaneMouseEnter:Nt,onPaneMouseMove:St,onPaneMouseLeave:Gn,onPaneScroll:Rn,onPaneContextMenu:Sr,paneClickDistance:rn=1,nodeClickDistance:vn=0,children:tr,onReconnect:ar,onReconnectStart:fn,onReconnectEnd:Sn,onEdgeContextMenu:Ir,onEdgeDoubleClick:Gr,onEdgeMouseEnter:gn,onEdgeMouseMove:Hn,onEdgeMouseLeave:Dr,reconnectRadius:Yn=10,onNodesChange:Vn,onEdgesChange:pr,noDragClassName:hr="nodrag",noWheelClassName:Kn="nowheel",noPanClassName:lr="nopan",fitView:jr,fitViewOptions:le,connectOnClick:he,attributionPosition:Je,proOptions:st,defaultEdgeOptions:Tt,elevateNodesOnSelect:ue=!0,elevateEdgesOnSelect:Te=!1,disableKeyboardA11y:nt=!1,autoPanOnConnect:gt,autoPanOnNodeDrag:Ve,autoPanSpeed:Rt,connectionRadius:Pt,isValidConnection:jn,onError:rt,style:Mn,id:pn,nodeDragThreshold:Bs,connectionDragThreshold:Hs,viewport:oe,onViewportChange:ve,width:Me,height:jt,colorMode:Dt="light",debug:sn,onScroll:Nn,ariaLabelConfig:Jn,zIndexMode:js="basic",...Ns},U){const we=pn||"1",$e=rH(Dt),Ae=m.useCallback(tt=>{tt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Nn==null||Nn(tt)},[Nn]);return s.jsx("div",{"data-testid":"rf__wrapper",...Ns,onScroll:Ae,style:{...Mn,...v6},ref:U,className:or(["react-flow",i,$e]),id:pn,role:"application",children:s.jsxs(k6,{nodes:e,edges:t,width:Me,height:jt,fitView:jr,fitViewOptions:le,minZoom:ae,maxZoom:ke,nodeOrigin:lt,nodeExtent:Ee,zIndexMode:js,children:[s.jsx(nH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:He,autoPanOnNodeFocus:ct,nodesConnectable:xt,nodesFocusable:Re,edgesFocusable:kt,edgesReconnectable:Ot,elementsSelectable:_t,elevateNodesOnSelect:ue,elevateEdgesOnSelect:Te,minZoom:ae,maxZoom:ke,nodeExtent:Ee,onNodesChange:Vn,onEdgesChange:pr,snapToGrid:ge,snapGrid:Oe,connectionMode:X,translateExtent:Ue,connectOnClick:he,defaultEdgeOptions:Tt,fitView:jr,fitViewOptions:le,onNodesDelete:E,onEdgesDelete:O,onDelete:D,onNodeDragStart:I,onNodeDrag:T,onNodeDragStop:z,onSelectionDrag:V,onSelectionDragStart:$,onSelectionDragStop:B,onMove:p,onMoveStart:f,onMoveEnd:d,noPanClassName:lr,nodeOrigin:lt,rfId:we,autoPanOnConnect:gt,autoPanOnNodeDrag:Ve,autoPanSpeed:Rt,onError:rt,connectionRadius:Pt,isValidConnection:jn,selectNodesOnDrag:Ne,nodeDragThreshold:Bs,connectionDragThreshold:Hs,onBeforeDelete:A,debug:sn,ariaLabelConfig:Jn,zIndexMode:js}),s.jsx(x6,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:S,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:K,connectionLineStyle:W,connectionLineComponent:te,connectionLineContainerStyle:ee,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:ie,deleteKeyCode:G,multiSelectionKeyCode:de,panActivationKeyCode:Z,zoomActivationKeyCode:fe,onlyRenderVisibleElements:_e,defaultViewport:Xt,translateExtent:Ue,minZoom:ae,maxZoom:ke,preventScrolling:it,zoomOnScroll:en,zoomOnPinch:Ut,zoomOnDoubleClick:Ce,panOnScroll:wt,panOnScrollSpeed:mn,panOnScrollMode:se,panOnDrag:Ye,onPaneClick:ze,onPaneMouseEnter:Nt,onPaneMouseMove:St,onPaneMouseLeave:Gn,onPaneScroll:Rn,onPaneContextMenu:Sr,paneClickDistance:rn,nodeClickDistance:vn,onSelectionContextMenu:F,onSelectionStart:R,onSelectionEnd:H,onReconnect:ar,onReconnectStart:fn,onReconnectEnd:Sn,onEdgeContextMenu:Ir,onEdgeDoubleClick:Gr,onEdgeMouseEnter:gn,onEdgeMouseMove:Hn,onEdgeMouseLeave:Dr,reconnectRadius:Yn,defaultMarkerColor:Kt,noDragClassName:hr,noWheelClassName:Kn,noPanClassName:lr,rfId:we,disableKeyboardA11y:nt,nodeExtent:Ee,viewport:oe,onViewportChange:ve}),s.jsx(Q5,{onSelectionChange:L}),tr,s.jsx(U5,{proOptions:st,position:Je}),s.jsx(q5,{rfId:we,disableKeyboardA11y:nt})]})})}var KT=kT(S6);function j6(){const e=kn();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),i=Array.isArray(t)?t:[t],o=new Map;i.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function N6(e){const[t,n]=m.useState(e),r=m.useCallback(i=>n(o=>Nd(i,o)),[]);return[t,n,r]}function _6(e){const[t,n]=m.useState(e),r=m.useCallback(i=>n(o=>mm(i,o)),[]);return[t,n,r]}function C6({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:or(["react-flow__background-pattern",n,r])})}function A6({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:or(["react-flow__background-pattern","dots",t])})}var ia;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ia||(ia={}));const E6={[ia.Dots]:1,[ia.Lines]:1,[ia.Cross]:6},I6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function qT({id:e,variant:t=ia.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:p}){const f=m.useRef(null),{transform:d,patternId:h}=Jt(I6,Tn),y=r||E6[t],v=t===ia.Dots,b=t===ia.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*d[2]||1,g[1]*d[2]||1],x=y*d[2],_=Array.isArray(o)?o:[o,o],S=b?[x,x]:k,N=[_[0]*d[2]||1+S[0]/2,_[1]*d[2]||1+S[1]/2],I=`${h}${e||""}`;return s.jsxs("svg",{className:or(["react-flow__background",u]),style:{...c,...yg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[s.jsx("pattern",{id:I,x:d[0]%k[0],y:d[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?s.jsx(A6,{radius:x/2,className:p}):s.jsx(C6,{dimensions:S,lineWidth:i,variant:t,className:p})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}qT.displayName="Background";const UT=m.memo(qT);function P6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function T6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function R6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.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 M6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.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 $6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.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 s.jsx("button",{type:"button",className:or(["react-flow__controls-button",t]),...n,children:e})}const L6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function GT({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:p,position:f="bottom-left",orientation:d="vertical","aria-label":h}){const y=kn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Jt(L6,Tn),{zoomIn:x,zoomOut:_,fitView:S}=tu(),N=()=>{x(),o==null||o()},I=()=>{_(),a==null||a()},T=()=>{S(i),l==null||l()},z=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},E=d==="horizontal"?"horizontal":"vertical";return s.jsxs(gg,{className:or(["react-flow__controls",E,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Bp,{onClick:N,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:s.jsx(P6,{})}),s.jsx(Bp,{onClick:I,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:s.jsx(T6,{})})]}),n&&s.jsx(Bp,{className:"react-flow__controls-fitview",onClick:T,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:s.jsx(R6,{})}),r&&s.jsx(Bp,{className:"react-flow__controls-interactive",onClick:z,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?s.jsx($6,{}):s.jsx(M6,{})}),p]})}GT.displayName="Controls";m.memo(GT);function O6({id:e,x:t,y:n,width:r,height:i,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:p,shapeRendering:f,selected:d,onClick:h}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return s.jsx("rect",{className:or(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:p,ry:p,width:r,height:i,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?g=>h(g,e):void 0})}const D6=m.memo(O6),F6=e=>e.nodes.map(t=>t.id),aw=e=>e instanceof Function?e:()=>e;function z6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=D6,onClick:a}){const l=Jt(F6,Tn),c=aw(t),u=aw(e),p=aw(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:l.map(d=>s.jsx(B6,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:a,shapeRendering:f},d))})}function W6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:p,y:f,width:d,height:h}=Jt(y=>{const v=y.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const b=v.internals.userNode,{x:g,y:k}=v.internals.positionAbsolute,{width:x,height:_}=ko(b);return{node:b,x:g,y:k,width:x,height:_}},Tn);return!u||u.hidden||!VP(u)?null:s.jsx(l,{x:p,y:f,width:d,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:i,strokeColor:n(u),strokeWidth:o,shapeRendering:a,onClick:c,id:u.id})}const B6=m.memo(W6);var H6=m.memo(z6);const V6=200,K6=150,q6=e=>!e.hidden,U6=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?HP(Ef(e.nodeLookup,{filter:q6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},G6="react-flow__minimap-desc";function YT({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:p,maskStrokeWidth:f,position:d="bottom-right",onClick:h,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:_=5}){const S=kn(),N=m.useRef(null),{boundingRect:I,viewBB:T,rfId:z,panZoom:E,translateExtent:O,flowWidth:D,flowHeight:L,ariaLabelConfig:$}=Jt(U6,Tn),V=(e==null?void 0:e.width)??V6,B=(e==null?void 0:e.height)??K6,F=I.width/V,R=I.height/B,H=Math.max(F,R),A=H*V,X=H*B,K=_*H,W=I.x-(A-I.width)/2-K,te=I.y-(X-I.height)/2-K,ee=A+K*2,G=X+K*2,ne=`${G6}-${z}`,re=m.useRef(0),ie=m.useRef();re.current=H,m.useEffect(()=>{if(N.current&&E)return ie.current=e5({domNode:N.current,panZoom:E,getTransform:()=>S.getState().transform,getViewScale:()=>re.current}),()=>{var ge;(ge=ie.current)==null||ge.destroy()}},[E]),m.useEffect(()=>{var ge;(ge=ie.current)==null||ge.update({translateExtent:O,width:D,height:L,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,O,D,L]);const Z=h?ge=>{var Ne;const[Oe,_e]=((Ne=ie.current)==null?void 0:Ne.pointer(ge))||[0,0];h(ge,{x:Oe,y:_e})}:void 0,de=y?m.useCallback((ge,Oe)=>{const _e=S.getState().nodeLookup.get(Oe).internals.userNode;y(ge,_e)},[]):void 0,fe=g??$["minimap.ariaLabel"];return s.jsx(gg,{position:d,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 p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*H: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:or(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:V,height:B,viewBox:`${W} ${te} ${ee} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:N,onClick:Z,children:[fe&&s.jsx("title",{id:ne,children:fe}),s.jsx(H6,{onClick:de,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:l}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-K},${te-K}h${ee+K*2}v${G+K*2}h${-ee-K*2}z
|
|
66
|
+
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}YT.displayName="MiniMap";m.memo(YT);const Y6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,J6={[qc.Line]:"right",[qc.Handle]:"bottom-right"};function X6({nodeId:e,position:t,variant:n=qc.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:h=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=NT(),x=typeof e=="string"?e:k,_=kn(),S=m.useRef(null),N=n===qc.Handle,I=Jt(m.useCallback(Y6(N&&h),[N,h]),Tn),T=m.useRef(null),z=t??J6[n];m.useEffect(()=>{if(!(!S.current||!x))return T.current||(T.current=h5({domNode:S.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:$,nodeOrigin:V,domNode:B}=_.getState();return{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:$,nodeOrigin:V,paneDomNode:B}},onChange:(O,D)=>{const{triggerNodeChanges:L,nodeLookup:$,parentLookup:V,nodeOrigin:B}=_.getState(),F=[],R={x:O.x,y:O.y},H=$.get(x);if(H&&H.expandParent&&H.parentId){const A=H.origin??B,X=O.width??H.measured.width??0,K=O.height??H.measured.height??0,W={id:H.id,parentId:H.parentId,rect:{width:X,height:K,...KP({x:O.x??H.position.x,y:O.y??H.position.y},{width:X,height:K},H.parentId,$,A)}},te=rv([W],$,V,B);F.push(...te),R.x=O.x?Math.max(A[0]*X,O.x):void 0,R.y=O.y?Math.max(A[1]*K,O.y):void 0}if(R.x!==void 0&&R.y!==void 0){const A={id:x,type:"position",position:{...R}};F.push(A)}if(O.width!==void 0&&O.height!==void 0){const X={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};F.push(X)}for(const A of D){const X={...A,type:"position"};F.push(X)}L(F)},onEnd:({width:O,height:D})=>{const L={id:x,type:"dimensions",resizing:!1,dimensions:{width:O,height:D}};_.getState().triggerNodeChanges([L])}})),T.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:p},keepAspectRatio:f,resizeDirection:d,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var O;(O=T.current)==null||O.destroy()}},[z,l,c,u,p,f,v,b,g,y]);const E=z.split("-");return s.jsx("div",{className:or(["react-flow__resize-control","nodrag",...E,n,r]),ref:S,style:{...i,scale:I,...a&&{[N?"backgroundColor":"borderColor"]:a}},children:o})}const ov=m.memo(X6);function Q6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Z6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,e8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,t8={};function C1(e,t){return(t8.jsx?e8:Z6).test(e)}const n8=/[ \t\n\f\r]/g;function r8(e){return typeof e=="object"?e.type==="text"?A1(e.value):!1:A1(e)}function A1(e){return e.replace(n8,"")===""}class Tf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Tf.prototype.normal={};Tf.prototype.property={};Tf.prototype.space=void 0;function JT(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Tf(n,r,t)}function ab(e){return e.toLowerCase()}class cs{constructor(t,n){this.attribute=n,this.property=t}}cs.prototype.attribute="";cs.prototype.booleanish=!1;cs.prototype.boolean=!1;cs.prototype.commaOrSpaceSeparated=!1;cs.prototype.commaSeparated=!1;cs.prototype.defined=!1;cs.prototype.mustUseProperty=!1;cs.prototype.number=!1;cs.prototype.overloadedBoolean=!1;cs.prototype.property="";cs.prototype.spaceSeparated=!1;cs.prototype.space=void 0;let s8=0;const At=wl(),rr=wl(),lb=wl(),Pe=wl(),wn=wl(),Cc=wl(),fs=wl();function wl(){return 2**++s8}const cb=Object.freeze(Object.defineProperty({__proto__:null,boolean:At,booleanish:rr,commaOrSpaceSeparated:fs,commaSeparated:Cc,number:Pe,overloadedBoolean:lb,spaceSeparated:wn},Symbol.toStringTag,{value:"Module"})),lw=Object.keys(cb);class av extends cs{constructor(t,n,r,i){let o=-1;if(super(t,n),E1(this,"space",i),typeof r=="number")for(;++o<lw.length;){const a=lw[o];E1(this,lw[o],(r&cb[a])===cb[a])}}}av.prototype.defined=!0;function E1(e,t,n){n&&(e[t]=n)}function nu(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new av(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[ab(r)]=r,n[ab(o.attribute)]=r}return new Tf(t,n,e.space)}const XT=nu({properties:{ariaActiveDescendant:null,ariaAtomic:rr,ariaAutoComplete:null,ariaBusy:rr,ariaChecked:rr,ariaColCount:Pe,ariaColIndex:Pe,ariaColSpan:Pe,ariaControls:wn,ariaCurrent:null,ariaDescribedBy:wn,ariaDetails:null,ariaDisabled:rr,ariaDropEffect:wn,ariaErrorMessage:null,ariaExpanded:rr,ariaFlowTo:wn,ariaGrabbed:rr,ariaHasPopup:null,ariaHidden:rr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wn,ariaLevel:Pe,ariaLive:null,ariaModal:rr,ariaMultiLine:rr,ariaMultiSelectable:rr,ariaOrientation:null,ariaOwns:wn,ariaPlaceholder:null,ariaPosInSet:Pe,ariaPressed:rr,ariaReadOnly:rr,ariaRelevant:null,ariaRequired:rr,ariaRoleDescription:wn,ariaRowCount:Pe,ariaRowIndex:Pe,ariaRowSpan:Pe,ariaSelected:rr,ariaSetSize:Pe,ariaSort:null,ariaValueMax:Pe,ariaValueMin:Pe,ariaValueNow:Pe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function QT(e,t){return t in e?e[t]:t}function ZT(e,t){return QT(e,t.toLowerCase())}const i8=nu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Cc,acceptCharset:wn,accessKey:wn,action:null,allow:null,allowFullScreen:At,allowPaymentRequest:At,allowUserMedia:At,alt:null,as:null,async:At,autoCapitalize:null,autoComplete:wn,autoFocus:At,autoPlay:At,blocking:wn,capture:null,charSet:null,checked:At,cite:null,className:wn,cols:Pe,colSpan:null,content:null,contentEditable:rr,controls:At,controlsList:wn,coords:Pe|Cc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:At,defer:At,dir:null,dirName:null,disabled:At,download:lb,draggable:rr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:At,formTarget:null,headers:wn,height:Pe,hidden:lb,high:Pe,href:null,hrefLang:null,htmlFor:wn,httpEquiv:wn,id:null,imageSizes:null,imageSrcSet:null,inert:At,inputMode:null,integrity:null,is:null,isMap:At,itemId:null,itemProp:wn,itemRef:wn,itemScope:At,itemType:wn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:At,low:Pe,manifest:null,max:null,maxLength:Pe,media:null,method:null,min:null,minLength:Pe,multiple:At,muted:At,name:null,nonce:null,noModule:At,noValidate:At,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:At,optimum:Pe,pattern:null,ping:wn,placeholder:null,playsInline:At,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:At,referrerPolicy:null,rel:wn,required:At,reversed:At,rows:Pe,rowSpan:Pe,sandbox:wn,scope:null,scoped:At,seamless:At,selected:At,shadowRootClonable:At,shadowRootDelegatesFocus:At,shadowRootMode:null,shape:null,size:Pe,sizes:null,slot:null,span:Pe,spellCheck:rr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Pe,step:null,style:null,tabIndex:Pe,target:null,title:null,translate:null,type:null,typeMustMatch:At,useMap:null,value:rr,width:Pe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wn,axis:null,background:null,bgColor:null,border:Pe,borderColor:null,bottomMargin:Pe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:At,declare:At,event:null,face:null,frame:null,frameBorder:null,hSpace:Pe,leftMargin:Pe,link:null,longDesc:null,lowSrc:null,marginHeight:Pe,marginWidth:Pe,noResize:At,noHref:At,noShade:At,noWrap:At,object:null,profile:null,prompt:null,rev:null,rightMargin:Pe,rules:null,scheme:null,scrolling:rr,standby:null,summary:null,text:null,topMargin:Pe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Pe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:At,disableRemotePlayback:At,prefix:null,property:null,results:Pe,security:null,unselectable:null},space:"html",transform:ZT}),o8=nu({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:fs,accentHeight:Pe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Pe,amplitude:Pe,arabicForm:null,ascent:Pe,attributeName:null,attributeType:null,azimuth:Pe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Pe,by:null,calcMode:null,capHeight:Pe,className:wn,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:Pe,diffuseConstant:Pe,direction:null,display:null,dur:null,divisor:Pe,dominantBaseline:null,download:At,dx:null,dy:null,edgeMode:null,editable:null,elevation:Pe,enableBackground:null,end:null,event:null,exponent:Pe,externalResourcesRequired:null,fill:null,fillOpacity:Pe,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:Cc,g2:Cc,glyphName:Cc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Pe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Pe,horizOriginX:Pe,horizOriginY:Pe,id:null,ideographic:Pe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Pe,k:Pe,k1:Pe,k2:Pe,k3:Pe,k4:Pe,kernelMatrix:fs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Pe,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:Pe,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:Pe,overlineThickness:Pe,paintOrder:null,panose1:null,path:null,pathLength:Pe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Pe,pointsAtY:Pe,pointsAtZ:Pe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:fs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:fs,rev:fs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:fs,requiredFeatures:fs,requiredFonts:fs,requiredFormats:fs,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Pe,specularExponent:Pe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Pe,strikethroughThickness:Pe,string:null,stroke:null,strokeDashArray:fs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Pe,strokeOpacity:Pe,strokeWidth:null,style:null,surfaceScale:Pe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:fs,tabIndex:Pe,tableValues:null,target:null,targetX:Pe,targetY:Pe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:fs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Pe,underlineThickness:Pe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Pe,values:null,vAlphabetic:Pe,vMathematical:Pe,vectorEffect:null,vHanging:Pe,vIdeographic:Pe,version:null,vertAdvY:Pe,vertOriginX:Pe,vertOriginY:Pe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Pe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:QT}),eR=nu({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()}}),tR=nu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ZT}),nR=nu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),a8={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"},l8=/[A-Z]/g,I1=/-[a-z]/g,c8=/^data[-\w.:]+$/i;function u8(e,t){const n=ab(t);let r=t,i=cs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&c8.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(I1,f8);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!I1.test(o)){let a=o.replace(l8,d8);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=av}return new i(r,t)}function d8(e){return"-"+e.toLowerCase()}function f8(e){return e.charAt(1).toUpperCase()}const p8=JT([XT,i8,eR,tR,nR],"html"),lv=JT([XT,o8,eR,tR,nR],"svg");function h8(e){return e.join(" ").trim()}var cv={},P1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,m8=/\n/g,g8=/^\s*/,y8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,w8=/^:\s*/,x8=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,b8=/^[;\s]*/,k8=/^\s+|\s+$/g,v8=`
|
|
67
|
+
`,T1="/",R1="*",Da="",S8="comment",j8="declaration";function N8(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 i(y){var v=y.match(m8);v&&(n+=v.length);var b=y.lastIndexOf(v8);r=~b?y.length-b:r+y.length}function o(){var y={line:n,column:r};return function(v){return v.position=new a(y),u(),v}}function a(y){this.start=y,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(y){var v=new Error(t.source+":"+n+":"+r+": "+y);if(v.reason=y,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function c(y){var v=y.exec(e);if(v){var b=v[0];return i(b),e=e.slice(b.length),v}}function u(){c(g8)}function p(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(T1!=e.charAt(0)||R1!=e.charAt(1))){for(var v=2;Da!=e.charAt(v)&&(R1!=e.charAt(v)||T1!=e.charAt(v+1));)++v;if(v+=2,Da===e.charAt(v-1))return l("End of comment missing");var b=e.slice(2,v-2);return r+=2,i(b),e=e.slice(v),r+=2,y({type:S8,comment:b})}}function d(){var y=o(),v=c(y8);if(v){if(f(),!c(w8))return l("property missing ':'");var b=c(x8),g=y({type:j8,property:M1(v[0].replace(P1,Da)),value:b?M1(b[0].replace(P1,Da)):Da});return c(b8),g}}function h(){var y=[];p(y);for(var v;v=d();)v!==!1&&(y.push(v),p(y));return y}return u(),h()}function M1(e){return e?e.replace(k8,Da):Da}var _8=N8,C8=Td&&Td.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(cv,"__esModule",{value:!0});cv.default=E8;const A8=C8(_8);function E8(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,A8.default)(e),i=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;i?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var xg={};Object.defineProperty(xg,"__esModule",{value:!0});xg.camelCase=void 0;var I8=/^--[a-zA-Z0-9_-]+$/,P8=/-([a-z])/g,T8=/^[^-]+$/,R8=/^-(webkit|moz|ms|o|khtml)-/,M8=/^-(ms)-/,$8=function(e){return!e||T8.test(e)||I8.test(e)},L8=function(e,t){return t.toUpperCase()},$1=function(e,t){return"".concat(t,"-")},O8=function(e,t){return t===void 0&&(t={}),$8(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(M8,$1):e=e.replace(R8,$1),e.replace(P8,L8))};xg.camelCase=O8;var D8=Td&&Td.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},F8=D8(cv),z8=xg;function ub(e,t){var n={};return!e||typeof e!="string"||(0,F8.default)(e,function(r,i){r&&i&&(n[(0,z8.camelCase)(r,t)]=i)}),n}ub.default=ub;var W8=ub;const B8=ma(W8),rR=sR("end"),uv=sR("start");function sR(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 H8(e){const t=uv(e),n=rR(e);if(t&&n)return{start:t,end:n}}function _d(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?db(e):""}function db(e){return O1(e&&e.line)+":"+O1(e&&e.column)}function L1(e){return db(e&&e.start)+"-"+db(e&&e.end)}function O1(e){return e&&typeof e=="number"?e:1}class Or extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=_d(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Or.prototype.file="";Or.prototype.name="";Or.prototype.reason="";Or.prototype.message="";Or.prototype.stack="";Or.prototype.column=void 0;Or.prototype.line=void 0;Or.prototype.ancestors=void 0;Or.prototype.cause=void 0;Or.prototype.fatal=void 0;Or.prototype.place=void 0;Or.prototype.ruleId=void 0;Or.prototype.source=void 0;const dv={}.hasOwnProperty,V8=new Map,K8=/[A-Z]/g,q8=new Set(["table","tbody","thead","tfoot","tr"]),U8=new Set(["td","th"]),iR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function G8(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=nV(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=tV(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?lv:p8,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=oR(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function oR(e,t,n){if(t.type==="element")return Y8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return J8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Q8(e,t,n);if(t.type==="mdxjsEsm")return X8(e,t);if(t.type==="root")return Z8(e,t,n);if(t.type==="text")return eV(e,t)}function Y8(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=lv,e.schema=i),e.ancestors.push(t);const o=lR(e,t.tagName,!1),a=rV(e,t);let l=pv(e,t);return q8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!r8(c):!0})),aR(e,a,o,t),fv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function J8(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)}of(e,t.position)}function X8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);of(e,t.position)}function Q8(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=lv,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:lR(e,t.name,!0),a=sV(e,t),l=pv(e,t);return aR(e,a,o,t),fv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function Z8(e,t,n){const r={};return fv(r,pv(e,t)),e.create(t,e.Fragment,r,n)}function eV(e,t){return t.value}function aR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function fv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function tV(e,t,n){return r;function r(i,o,a,l){const u=Array.isArray(a.children)?n:t;return l?u(o,a,l):u(o,a)}}function nV(e,t){return n;function n(r,i,o,a){const l=Array.isArray(o.children),c=uv(r);return t(i,o,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function rV(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&dv.call(t.properties,i)){const o=iV(e,i,t.properties[i]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&U8.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function sV(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else of(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else of(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function pv(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:V8;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=i.get(c)||0;a=c+"-"+u,i.set(c,u+1)}}const l=oR(e,o,a);l!==void 0&&n.push(l)}return n}function iV(e,t,n){const r=u8(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Q6(n):h8(n)),r.property==="style"){let i=typeof n=="object"?n:oV(e,String(n));return e.stylePropertyNameCase==="css"&&(i=aV(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?a8[r.property]||r.property:r.attribute,n]}}function oV(e,t){try{return B8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Or("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=iR+"#cannot-parse-style-attribute",i}}function lR(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,a;for(;++o<i.length;){const l=C1(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=C1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return dv.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);of(e)}function of(e,t){const n=new Or("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=iR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function aV(e){const t={};let n;for(n in e)dv.call(e,n)&&(t[lV(n)]=e[n]);return t}function lV(e){let t=e.replace(K8,cV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function cV(e){return"-"+e.toLowerCase()}const cw={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"]},uV={};function dV(e,t){const n=uV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return cR(e,r,i)}function cR(e,t,n){if(fV(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 D1(e.children,t,n)}return Array.isArray(e)?D1(e,t,n):""}function D1(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=cR(e[i],t,n);return r.join("")}function fV(e){return!!(e&&typeof e=="object")}const F1=document.createElement("i");function hv(e){const t="&"+e+";";F1.innerHTML=t;const n=F1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Wi(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function Ls(e,t){return e.length>0?(Wi(e,e.length,0,t),e):t}const z1={}.hasOwnProperty;function pV(e){const t={};let n=-1;for(;++n<e.length;)hV(t,e[n]);return t}function hV(e,t){let n;for(n in t){const i=(z1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){z1.call(i,a)||(i[a]=[]);const l=o[a];mV(i[a],Array.isArray(l)?l:l?[l]:[])}}}function mV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Wi(e,0,0,r)}function uR(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 Ac(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ii=xa(/[A-Za-z]/),ys=xa(/[\dA-Za-z]/),gV=xa(/[#-'*+\--9=?A-Z^-~]/);function fb(e){return e!==null&&(e<32||e===127)}const pb=xa(/\d/),yV=xa(/[\dA-Fa-f]/),wV=xa(/[!-/:-@[-`{-~]/);function bt(e){return e!==null&&e<-2}function as(e){return e!==null&&(e<0||e===32)}function nn(e){return e===-2||e===-1||e===32}const xV=xa(new RegExp("\\p{P}|\\p{S}","u")),bV=xa(/\s/);function xa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ru(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&ys(e.charCodeAt(n+1))&&ys(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function bn(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return nn(c)?(e.enter(n),l(c)):t(c)}function l(c){return nn(c)&&o++<i?(e.consume(c),l):(e.exit(n),t(c))}}const kV={tokenize:vV};function vV(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),bn(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),o(l)}function o(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return bt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const SV={tokenize:jV},W1={tokenize:NV};function jV(e){const t=this,n=[];let r=0,i,o,a;return l;function l(x){if(r<n.length){const _=n[r];return t.containerState=_[1],e.attempt(_[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const _=t.events.length;let S=_,N;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){N=t.events[S][1].end;break}g(r);let I=_;for(;I<t.events.length;)t.events[I][1].end={...N},I++;return Wi(t.events,S+1,0,t.events.slice(_)),t.events.length=I,u(x)}return l(x)}function u(x){if(r===n.length){if(!i)return d(x);if(i.currentConstruct&&i.currentConstruct.concrete)return y(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(W1,p,f)(x)}function p(x){return i&&k(),g(r),d(x)}function f(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function d(x){return t.containerState={},e.attempt(W1,h,y)(x)}function h(x){return r++,n.push([t.currentConstruct,t.containerState]),d(x)}function y(x){if(x===null){i&&k(),g(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),v(x)}function v(x){if(x===null){b(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return bt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,_){const S=t.sliceStream(x);if(_&&S.push(null),x.previous=o,o&&(o.next=x),o=x,i.defineSkip(x.start),i.write(S),t.parser.lazy[x.start.line]){let N=i.events.length;for(;N--;)if(i.events[N][1].start.offset<a&&(!i.events[N][1].end||i.events[N][1].end.offset>a))return;const I=t.events.length;let T=I,z,E;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(z){E=t.events[T][1].end;break}z=!0}for(g(r),N=I;N<t.events.length;)t.events[N][1].end={...E},N++;Wi(t.events,T+1,0,t.events.slice(I)),t.events.length=N}}function g(x){let _=n.length;for(;_-- >x;){const S=n[_];t.containerState=S[1],S[0].exit.call(t,e)}n.length=x}function k(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function NV(e,t,n){return bn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function B1(e){if(e===null||as(e)||bV(e))return 1;if(xV(e))return 2}function mv(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const hb={name:"attention",resolveAll:_V,tokenize:CV};function _V(e,t){let n=-1,r,i,o,a,l,c,u,p;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},d={...e[n][1].start};H1(f,-c),H1(d,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:d},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={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=Ls(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ls(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Ls(u,mv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ls(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,u=Ls(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Wi(e,r-1,n-r+3,u),n=r+u.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function CV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=B1(r);let o;return a;function a(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;const u=e.exit("attentionSequence"),p=B1(c),f=!p||p===2&&i||n.includes(c),d=!i||i===2&&p||n.includes(r);return u._open=!!(o===42?f:f&&(i||!d)),u._close=!!(o===42?d:d&&(p||!f)),t(c)}}function H1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const AV={name:"autolink",tokenize:EV};function EV(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return Ii(h)?(e.consume(h),a):h===64?n(h):u(h)}function a(h){return h===43||h===45||h===46||ys(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||ys(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||fb(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),p):gV(h)?(e.consume(h),u):n(h)}function p(h){return ys(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,p):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):d(h)}function d(h){if((h===45||ys(h))&&r++<63){const y=h===45?d:f;return e.consume(h),y}return n(h)}}const bg={partial:!0,tokenize:IV};function IV(e,t,n){return r;function r(o){return nn(o)?bn(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||bt(o)?t(o):n(o)}}const dR={continuation:{tokenize:TV},exit:RV,name:"blockQuote",tokenize:PV};function PV(e,t,n){const r=this;return i;function i(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return nn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function TV(e,t,n){const r=this;return i;function i(a){return nn(a)?bn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(dR,t,n)(a)}}function RV(e){e.exit("blockQuote")}const fR={name:"characterEscape",tokenize:MV};function MV(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return wV(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const pR={name:"characterReference",tokenize:$V};function $V(e,t,n){const r=this;let i=0,o,a;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=ys,p(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=yV,p):(e.enter("characterReferenceValue"),o=7,a=pb,p(f))}function p(f){if(f===59&&i){const d=e.exit("characterReferenceValue");return a===ys&&!hv(r.sliceSerialize(d))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(f)&&i++<o?(e.consume(f),p):n(f)}}const V1={partial:!0,tokenize:OV},K1={concrete:!0,name:"codeFenced",tokenize:LV};function LV(e,t,n){const r=this,i={partial:!0,tokenize:S};let o=0,a=0,l;return c;function c(N){return u(N)}function u(N){const I=r.events[r.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(N)}function p(N){return N===l?(a++,e.consume(N),p):a<3?n(N):(e.exit("codeFencedFenceSequence"),nn(N)?bn(e,f,"whitespace")(N):f(N))}function f(N){return N===null||bt(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(V1,v,_)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(N))}function d(N){return N===null||bt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(N)):nn(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),bn(e,h,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),d)}function h(N){return N===null||bt(N)?f(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(N))}function y(N){return N===null||bt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(N)):N===96&&N===l?n(N):(e.consume(N),y)}function v(N){return e.attempt(i,_,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),g}function g(N){return o>0&&nn(N)?bn(e,k,"linePrefix",o+1)(N):k(N)}function k(N){return N===null||bt(N)?e.check(V1,v,_)(N):(e.enter("codeFlowValue"),x(N))}function x(N){return N===null||bt(N)?(e.exit("codeFlowValue"),k(N)):(e.consume(N),x)}function _(N){return e.exit("codeFenced"),t(N)}function S(N,I,T){let z=0;return E;function E(V){return N.enter("lineEnding"),N.consume(V),N.exit("lineEnding"),O}function O(V){return N.enter("codeFencedFence"),nn(V)?bn(N,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):D(V)}function D(V){return V===l?(N.enter("codeFencedFenceSequence"),L(V)):T(V)}function L(V){return V===l?(z++,N.consume(V),L):z>=a?(N.exit("codeFencedFenceSequence"),nn(V)?bn(N,$,"whitespace")(V):$(V)):T(V)}function $(V){return V===null||bt(V)?(N.exit("codeFencedFence"),I(V)):T(V)}}}function OV(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const uw={name:"codeIndented",tokenize:FV},DV={partial:!0,tokenize:zV};function FV(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),bn(e,o,"linePrefix",5)(u)}function o(u){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):bt(u)?e.attempt(DV,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||bt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function zV(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):bt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):bn(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):bt(a)?i(a):n(a)}}const WV={name:"codeText",previous:HV,resolve:BV,tokenize:VV};function BV(e){let t=e.length-4,n=3,r,i;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;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function HV(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function VV(e,t,n){let r=0,i,o;return a;function a(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),i=0,p(f)):bt(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||bt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function p(f){return f===96?(e.consume(f),i++,p):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class KV{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 i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&qu(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),qu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),qu(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);qu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);qu(this.left,n.reverse())}}}function qu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function hR(e){const t={};let n=-1,r,i,o,a,l,c,u;const p=new KV(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,qV(p,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=p.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(p.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...p.get(i)[1].start},l=p.slice(i,n),l.unshift(r),p.splice(i,n-i+1,l))}}return Wi(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!u}function qV(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],u={};let p,f,d=-1,h=n,y=0,v=0;const b=[v];for(;h;){for(;e.get(++i)[1]!==h;);o.push(i),h._tokenizer||(p=r.sliceStream(h),h.next||p.push(null),f&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(p),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(v=d+1,b.push(v),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),d=b.length;d--;){const g=l.slice(b[d],b[d+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),d=-1;++d<c.length;)u[y+c[d][0]]=y+c[d][1],y+=c[d][1]-c[d][0]-1;return u}const UV={resolve:YV,tokenize:JV},GV={partial:!0,tokenize:XV};function YV(e){return hR(e),e}function JV(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):bt(l)?e.check(GV,a,o)(l):(e.consume(l),i)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function XV(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),bn(e,o,"linePrefix")}function o(a){if(a===null||bt(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 mR(e,t,n,r,i,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let p=0;return f;function f(g){return g===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(g),e.exit(o),d):g===null||g===32||g===41||fb(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function d(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===62?(e.exit("chunkString"),e.exit(l),d(g)):g===null||g===60||bt(g)?n(g):(e.consume(g),g===92?y:h)}function y(g){return g===60||g===62||g===92?(e.consume(g),h):h(g)}function v(g){return!p&&(g===null||g===41||as(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):p<u&&g===40?(e.consume(g),p++,v):g===41?(e.consume(g),p--,v):g===null||g===32||g===40||fb(g)?n(g):(e.consume(g),g===92?b:v)}function b(g){return g===40||g===41||g===92?(e.consume(g),v):v(g)}}function gR(e,t,n,r,i,o){const a=this;let l=0,c;return u;function u(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(o),p}function p(h){return l>999||h===null||h===91||h===93&&!c||h===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(h):h===93?(e.exit(o),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):bt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||bt(h)||l++>999?(e.exit("chunkString"),p(h)):(e.consume(h),c||(c=!nn(h)),h===92?d:f)}function d(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function yR(e,t,n,r,i,o){let a;return l;function l(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),a=d===40?41:d,c):n(d)}function c(d){return d===a?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(o),u(d))}function u(d){return d===a?(e.exit(o),c(a)):d===null?n(d):bt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),bn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(d))}function p(d){return d===a||d===null||bt(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?f:p)}function f(d){return d===a||d===92?(e.consume(d),p):p(d)}}function Cd(e,t){let n;return r;function r(i){return bt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):nn(i)?bn(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const QV={name:"definition",tokenize:e9},ZV={partial:!0,tokenize:t9};function e9(e,t,n){const r=this;let i;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return gR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return i=Ac(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 as(h)?Cd(e,u)(h):u(h)}function u(h){return mR(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function p(h){return e.attempt(ZV,f,f)(h)}function f(h){return nn(h)?bn(e,d,"whitespace")(h):d(h)}function d(h){return h===null||bt(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function t9(e,t,n){return r;function r(l){return as(l)?Cd(e,i)(l):n(l)}function i(l){return yR(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return nn(l)?bn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||bt(l)?t(l):n(l)}}const n9={name:"hardBreakEscape",tokenize:r9};function r9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return bt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const s9={name:"headingAtx",resolve:i9,tokenize:o9};function i9(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Wi(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function o9(e,t,n){let r=0;return i;function i(p){return e.enter("atxHeading"),o(p)}function o(p){return e.enter("atxHeadingSequence"),a(p)}function a(p){return p===35&&r++<6?(e.consume(p),a):p===null||as(p)?(e.exit("atxHeadingSequence"),l(p)):n(p)}function l(p){return p===35?(e.enter("atxHeadingSequence"),c(p)):p===null||bt(p)?(e.exit("atxHeading"),t(p)):nn(p)?bn(e,l,"whitespace")(p):(e.enter("atxHeadingText"),u(p))}function c(p){return p===35?(e.consume(p),c):(e.exit("atxHeadingSequence"),l(p))}function u(p){return p===null||p===35||as(p)?(e.exit("atxHeadingText"),l(p)):(e.consume(p),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"],q1=["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 i,o,a,l,c;return u;function u(W){return p(W)}function p(W){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(W),f}function f(W){return W===33?(e.consume(W),d):W===47?(e.consume(W),o=!0,v):W===63?(e.consume(W),i=3,r.interrupt?t:A):Ii(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function d(W){return W===45?(e.consume(W),i=2,h):W===91?(e.consume(W),i=5,l=0,y):Ii(W)?(e.consume(W),i=4,r.interrupt?t:A):n(W)}function h(W){return W===45?(e.consume(W),r.interrupt?t:A):n(W)}function y(W){const te="CDATA[";return W===te.charCodeAt(l++)?(e.consume(W),l===te.length?r.interrupt?t:D:y):n(W)}function v(W){return Ii(W)?(e.consume(W),a=String.fromCharCode(W),b):n(W)}function b(W){if(W===null||W===47||W===62||as(W)){const te=W===47,ee=a.toLowerCase();return!te&&!o&&q1.includes(ee)?(i=1,r.interrupt?t(W):D(W)):a9.includes(a.toLowerCase())?(i=6,te?(e.consume(W),g):r.interrupt?t(W):D(W)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(W):o?k(W):x(W))}return W===45||ys(W)?(e.consume(W),a+=String.fromCharCode(W),b):n(W)}function g(W){return W===62?(e.consume(W),r.interrupt?t:D):n(W)}function k(W){return nn(W)?(e.consume(W),k):E(W)}function x(W){return W===47?(e.consume(W),E):W===58||W===95||Ii(W)?(e.consume(W),_):nn(W)?(e.consume(W),x):E(W)}function _(W){return W===45||W===46||W===58||W===95||ys(W)?(e.consume(W),_):S(W)}function S(W){return W===61?(e.consume(W),N):nn(W)?(e.consume(W),S):x(W)}function N(W){return W===null||W===60||W===61||W===62||W===96?n(W):W===34||W===39?(e.consume(W),c=W,I):nn(W)?(e.consume(W),N):T(W)}function I(W){return W===c?(e.consume(W),c=null,z):W===null||bt(W)?n(W):(e.consume(W),I)}function T(W){return W===null||W===34||W===39||W===47||W===60||W===61||W===62||W===96||as(W)?S(W):(e.consume(W),T)}function z(W){return W===47||W===62||nn(W)?x(W):n(W)}function E(W){return W===62?(e.consume(W),O):n(W)}function O(W){return W===null||bt(W)?D(W):nn(W)?(e.consume(W),O):n(W)}function D(W){return W===45&&i===2?(e.consume(W),B):W===60&&i===1?(e.consume(W),F):W===62&&i===4?(e.consume(W),X):W===63&&i===3?(e.consume(W),A):W===93&&i===5?(e.consume(W),H):bt(W)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(c9,K,L)(W)):W===null||bt(W)?(e.exit("htmlFlowData"),L(W)):(e.consume(W),D)}function L(W){return e.check(u9,$,K)(W)}function $(W){return e.enter("lineEnding"),e.consume(W),e.exit("lineEnding"),V}function V(W){return W===null||bt(W)?L(W):(e.enter("htmlFlowData"),D(W))}function B(W){return W===45?(e.consume(W),A):D(W)}function F(W){return W===47?(e.consume(W),a="",R):D(W)}function R(W){if(W===62){const te=a.toLowerCase();return q1.includes(te)?(e.consume(W),X):D(W)}return Ii(W)&&a.length<8?(e.consume(W),a+=String.fromCharCode(W),R):D(W)}function H(W){return W===93?(e.consume(W),A):D(W)}function A(W){return W===62?(e.consume(W),X):W===45&&i===2?(e.consume(W),A):D(W)}function X(W){return W===null||bt(W)?(e.exit("htmlFlowData"),K(W)):(e.consume(W),X)}function K(W){return e.exit("htmlFlow"),t(W)}}function p9(e,t,n){const r=this;return i;function i(a){return bt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function h9(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(bg,t,n)}}const m9={name:"htmlText",tokenize:g9};function g9(e,t,n){const r=this;let i,o,a;return l;function l(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),c}function c(A){return A===33?(e.consume(A),u):A===47?(e.consume(A),S):A===63?(e.consume(A),x):Ii(A)?(e.consume(A),T):n(A)}function u(A){return A===45?(e.consume(A),p):A===91?(e.consume(A),o=0,y):Ii(A)?(e.consume(A),k):n(A)}function p(A){return A===45?(e.consume(A),h):n(A)}function f(A){return A===null?n(A):A===45?(e.consume(A),d):bt(A)?(a=f,F(A)):(e.consume(A),f)}function d(A){return A===45?(e.consume(A),h):f(A)}function h(A){return A===62?B(A):A===45?d(A):f(A)}function y(A){const X="CDATA[";return A===X.charCodeAt(o++)?(e.consume(A),o===X.length?v:y):n(A)}function v(A){return A===null?n(A):A===93?(e.consume(A),b):bt(A)?(a=v,F(A)):(e.consume(A),v)}function b(A){return A===93?(e.consume(A),g):v(A)}function g(A){return A===62?B(A):A===93?(e.consume(A),g):v(A)}function k(A){return A===null||A===62?B(A):bt(A)?(a=k,F(A)):(e.consume(A),k)}function x(A){return A===null?n(A):A===63?(e.consume(A),_):bt(A)?(a=x,F(A)):(e.consume(A),x)}function _(A){return A===62?B(A):x(A)}function S(A){return Ii(A)?(e.consume(A),N):n(A)}function N(A){return A===45||ys(A)?(e.consume(A),N):I(A)}function I(A){return bt(A)?(a=I,F(A)):nn(A)?(e.consume(A),I):B(A)}function T(A){return A===45||ys(A)?(e.consume(A),T):A===47||A===62||as(A)?z(A):n(A)}function z(A){return A===47?(e.consume(A),B):A===58||A===95||Ii(A)?(e.consume(A),E):bt(A)?(a=z,F(A)):nn(A)?(e.consume(A),z):B(A)}function E(A){return A===45||A===46||A===58||A===95||ys(A)?(e.consume(A),E):O(A)}function O(A){return A===61?(e.consume(A),D):bt(A)?(a=O,F(A)):nn(A)?(e.consume(A),O):z(A)}function D(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),i=A,L):bt(A)?(a=D,F(A)):nn(A)?(e.consume(A),D):(e.consume(A),$)}function L(A){return A===i?(e.consume(A),i=void 0,V):A===null?n(A):bt(A)?(a=L,F(A)):(e.consume(A),L)}function $(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||as(A)?z(A):(e.consume(A),$)}function V(A){return A===47||A===62||as(A)?z(A):n(A)}function B(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function F(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),R}function R(A){return nn(A)?bn(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):H(A)}function H(A){return e.enter("htmlTextData"),a(A)}}const gv={name:"labelEnd",resolveAll:b9,resolveTo:k9,tokenize:v9},y9={tokenize:S9},w9={tokenize:j9},x9={tokenize:N9};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 i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Wi(e,0,e.length,n),e}function k9(e,t){let n=e.length,r=0,i,o,a,l;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},p={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Ls(l,e.slice(o+1,o+r+3)),l=Ls(l,[["enter",p,t]]),l=Ls(l,mv(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Ls(l,[["exit",p,t],e[a-2],e[a-1],["exit",u,t]]),l=Ls(l,e.slice(a+1)),l=Ls(l,[["exit",c,t]]),Wi(e,o,e.length,l),e}function v9(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(d){return o?o._inactive?f(d):(a=r.parser.defined.includes(Ac(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),c):n(d)}function c(d){return d===40?e.attempt(y9,p,a?p:f)(d):d===91?e.attempt(w9,p,a?u:f)(d):a?p(d):f(d)}function u(d){return e.attempt(x9,p,f)(d)}function p(d){return t(d)}function f(d){return o._balanced=!0,n(d)}}function S9(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return as(f)?Cd(e,o)(f):o(f)}function o(f){return f===41?p(f):mR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return as(f)?Cd(e,c)(f):p(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?yR(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):p(f)}function u(f){return as(f)?Cd(e,p)(f):p(f)}function p(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function j9(e,t,n){const r=this;return i;function i(l){return gR.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(Ac(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function N9(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const _9={name:"labelStartImage",resolveAll:gv.resolveAll,tokenize:C9};function C9(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const A9={name:"labelStartLink",resolveAll:gv.resolveAll,tokenize:E9};function E9(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const dw={name:"lineEnding",tokenize:I9};function I9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),bn(e,t,"linePrefix")}}const Ah={name:"thematicBreak",tokenize:P9};function P9(e,t,n){let r=0,i;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,l(u)}function l(u){return u===i?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||bt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),nn(u)?bn(e,l,"whitespace")(u):l(u))}}const Qr={continuation:{tokenize:$9},exit:O9,name:"list",tokenize:M9},T9={partial:!0,tokenize:D9},R9={partial:!0,tokenize:L9};function M9(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(h){const y=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:pb(h)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Ah,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 pb(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(bg,r.interrupt?n:p,e.attempt(T9,d,f))}function p(h){return r.containerState.initialBlankLine=!0,o++,d(h)}function f(h){return nn(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),d):n(h)}function d(h){return r.containerState.size=o+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(bg,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,bn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!nn(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(R9,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,bn(e,e.attempt(Qr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function L9(e,t,n){const r=this;return bn(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function O9(e){e.exit(this.containerState.type)}function D9(e,t,n){const r=this;return bn(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!nn(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const U1={name:"setextUnderline",resolveTo:F9,tokenize:z9};function F9(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function z9(e,t,n){const r=this;let i;return o;function o(u){let p=r.events.length,f;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){f=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),nn(u)?bn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||bt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const W9={tokenize:B9};function B9(e){const t=this,n=e.attempt(bg,r,e.attempt(this.parser.constructs.flowInitial,i,bn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(UV,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const H9={resolveAll:xR()},V9=wR("string"),K9=wR("text");function wR(e){return{resolveAll:xR(e==="text"?q9:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,l);return a;function a(p){return u(p)?o(p):l(p)}function l(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),c}function c(p){return u(p)?(n.exit("data"),o(p)):(n.consume(p),c)}function u(p){if(p===null)return!0;const f=i[p];let d=-1;if(f)for(;++d<f.length;){const h=f[d];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function xR(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=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],i=t.sliceStream(r);let o=i.length,a=-1,l=0,c;for(;o--;){const u=i[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const U9={42:Qr,43:Qr,45:Qr,48:Qr,49:Qr,50:Qr,51:Qr,52:Qr,53:Qr,54:Qr,55:Qr,56:Qr,57:Qr,62:dR},G9={91:QV},Y9={[-2]:uw,[-1]:uw,32:uw},J9={35:s9,42:Ah,45:[U1,Ah],60:l9,61:U1,95:Ah,96:K1,126:K1},X9={38:pR,92:fR},Q9={[-5]:dw,[-4]:dw,[-3]:dw,33:_9,38:pR,42:hb,60:[AV,m9],91:A9,92:[n9,fR],93:gv,95:hb,96:WV},Z9={null:[hb,H9]},eK={null:[42,95]},tK={null:[]},nK=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eK,contentInitial:G9,disable:tK,document:U9,flow:J9,flowInitial:Y9,insideSpan:Z9,string:X9,text:Q9},Symbol.toStringTag,{value:"Module"}));function rK(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 i={},o=[];let a=[],l=[];const c={attempt:I(S),check:I(N),consume:k,enter:x,exit:_,interrupt:I(N,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:d,sliceStream:h,write:f};let p=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(O){return a=Ls(a,O),b(),a[a.length-1]!==null?[]:(T(t,0),u.events=mv(o,u.events,u),u.events)}function d(O,D){return iK(h(O),D)}function h(O){return sK(a,O)}function y(){const{_bufferIndex:O,_index:D,line:L,column:$,offset:V}=r;return{_bufferIndex:O,_index:D,line:L,column:$,offset:V}}function v(O){i[O.line]=O.column,E()}function b(){let O;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<D.length;)g(D.charCodeAt(r._bufferIndex));else g(D)}}function g(O){p=p(O)}function k(O){bt(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,E()):O!==-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=O}function x(O,D){const L=D||{};return L.type=O,L.start=y(),u.events.push(["enter",L,u]),l.push(L),L}function _(O){const D=l.pop();return D.end=y(),u.events.push(["exit",D,u]),D}function S(O,D){T(O,D.from)}function N(O,D){D.restore()}function I(O,D){return L;function L($,V,B){let F,R,H,A;return Array.isArray($)?K($):"tokenize"in $?K([$]):X($);function X(G){return ne;function ne(re){const ie=re!==null&&G[re],Z=re!==null&&G.null,de=[...Array.isArray(ie)?ie:ie?[ie]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return K(de)(re)}}function K(G){return F=G,R=0,G.length===0?B:W(G[R])}function W(G){return ne;function ne(re){return A=z(),H=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?ee():G.tokenize.call(D?Object.assign(Object.create(u),D):u,c,te,ee)(re)}}function te(G){return O(H,A),V}function ee(G){return A.restore(),++R<F.length?W(F[R]):B}}}function T(O,D){O.resolveAll&&!o.includes(O)&&o.push(O),O.resolve&&Wi(u.events,D,u.events.length-D,O.resolve(u.events.slice(D),u)),O.resolveTo&&(u.events=O.resolveTo(u.events,u))}function z(){const O=y(),D=u.previous,L=u.currentConstruct,$=u.events.length,V=Array.from(l);return{from:$,restore:B};function B(){r=O,u.previous=D,u.currentConstruct=L,u.events.length=$,l=V,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function sK(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function iK(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
68
|
+
`;break}case-3:{a=`\r
|
|
69
|
+
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function oK(e){const r={constructs:pV([nK,...(e||{}).extensions||[]]),content:i(kV),defined:[],document:i(SV),flow:i(W9),lazy:{},string:i(V9),text:i(K9)};return r;function i(o){return a;function a(l){return rK(r,o,l)}}}function aK(e){for(;!hR(e););return e}const G1=/[\0\t\n\r]/g;function lK(){let e=1,t="",n=!0,r;return i;function i(o,a,l){const c=[];let u,p,f,d,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(G1.lastIndex=f,u=G1.exec(o),d=u&&u.index!==void 0?u.index:o.length,h=o.charCodeAt(d),!u){t=o.slice(f);break}if(h===10&&f===d&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<d&&(c.push(o.slice(f,d)),e+=d-f),h){case 0:{c.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,c.push(-2);e++<p;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=d+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const cK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function uK(e){return e.replace(cK,dK)}function dK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return uR(n.slice(o?2:1),o?16:10)}return hv(n)||e}const bR={}.hasOwnProperty;function fK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),pK(n)(aK(oK(n).document().write(lK()(e,t,!0))))}function pK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(xt),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(_e),blockQuote:o(Z),characterEscape:z,characterReference:z,codeFenced:o(de),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(de,a),codeText:o(fe,a),codeTextData:z,data:z,codeFlowValue:z,definition:o(ge),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Oe),hardBreakEscape:o(Ne),hardBreakTrailing:o(Ne),htmlFlow:o(He,a),htmlFlowData:z,htmlText:o(He,a),htmlTextData:z,image:o(ct),label:a,link:o(xt),listItem:o(lt),listItemValue:d,listOrdered:o(Re,f),listUnordered:o(Re),paragraph:o(kt),reference:W,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(_e),strong:o(Ot),thematicBreak:o(Xt)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:ie,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:G,characterReference:ne,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:c(g),codeText:c(V),codeTextData:E,data:E,definition:c(),definitionDestinationString:_,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(L),htmlFlowData:E,htmlText:c($),htmlTextData:E,image:c(F),label:H,labelText:R,lineEnding:O,link:c(B),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:te,resourceDestinationString:A,resourceTitleString:X,resource:K,setextHeading:c(T),setextHeadingLineSequence:I,setextHeadingText:N,strong:c(),thematicBreak:c()}};kR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ae){let ke={type:"root",children:[]};const Ue={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:p,data:n},it=[];let Ee=-1;for(;++Ee<ae.length;)if(ae[Ee][1].type==="listOrdered"||ae[Ee][1].type==="listUnordered")if(ae[Ee][0]==="enter")it.push(Ee);else{const Kt=it.pop();Ee=i(ae,Kt,Ee)}for(Ee=-1;++Ee<ae.length;){const Kt=t[ae[Ee][0]];bR.call(Kt,ae[Ee][1].type)&&Kt[ae[Ee][1].type].call(Object.assign({sliceSerialize:ae[Ee][2].sliceSerialize},Ue),ae[Ee][1])}if(Ue.tokenStack.length>0){const Kt=Ue.tokenStack[Ue.tokenStack.length-1];(Kt[1]||Y1).call(Ue,void 0,Kt[0])}for(ke.position={start:Oo(ae.length>0?ae[0][1].start:{line:1,column:1,offset:0}),end:Oo(ae.length>0?ae[ae.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<t.transforms.length;)ke=t.transforms[Ee](ke)||ke;return ke}function i(ae,ke,Ue){let it=ke-1,Ee=-1,Kt=!1,en,Ut,wt,mn;for(;++it<=Ue;){const se=ae[it];switch(se[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{se[0]==="enter"?Ee++:Ee--,mn=void 0;break}case"lineEndingBlank":{se[0]==="enter"&&(en&&!mn&&!Ee&&!wt&&(wt=it),mn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:mn=void 0}if(!Ee&&se[0]==="enter"&&se[1].type==="listItemPrefix"||Ee===-1&&se[0]==="exit"&&(se[1].type==="listUnordered"||se[1].type==="listOrdered")){if(en){let Ce=it;for(Ut=void 0;Ce--;){const Ye=ae[Ce];if(Ye[1].type==="lineEnding"||Ye[1].type==="lineEndingBlank"){if(Ye[0]==="exit")continue;Ut&&(ae[Ut][1].type="lineEndingBlank",Kt=!0),Ye[1].type="lineEnding",Ut=Ce}else if(!(Ye[1].type==="linePrefix"||Ye[1].type==="blockQuotePrefix"||Ye[1].type==="blockQuotePrefixWhitespace"||Ye[1].type==="blockQuoteMarker"||Ye[1].type==="listItemIndent"))break}wt&&(!Ut||wt<Ut)&&(en._spread=!0),en.end=Object.assign({},Ut?ae[Ut][1].start:se[1].end),ae.splice(Ut||it,0,["exit",en,se[2]]),it++,Ue++}if(se[1].type==="listItemPrefix"){const Ce={type:"listItem",_spread:!1,start:Object.assign({},se[1].start),end:void 0};en=Ce,ae.splice(it,0,["enter",Ce,se[2]]),it++,Ue++,wt=void 0,mn=!0}}}return ae[ke][1]._spread=Kt,Ue}function o(ae,ke){return Ue;function Ue(it){l.call(this,ae(it),it),ke&&ke.call(this,it)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ae,ke,Ue){this.stack[this.stack.length-1].children.push(ae),this.stack.push(ae),this.tokenStack.push([ke,Ue||void 0]),ae.position={start:Oo(ke.start),end:void 0}}function c(ae){return ke;function ke(Ue){ae&&ae.call(this,Ue),u.call(this,Ue)}}function u(ae,ke){const Ue=this.stack.pop(),it=this.tokenStack.pop();if(it)it[0].type!==ae.type&&(ke?ke.call(this,ae,it[0]):(it[1]||Y1).call(this,ae,it[0]));else throw new Error("Cannot close `"+ae.type+"` ("+_d({start:ae.start,end:ae.end})+"): it’s not open");Ue.position.end=Oo(ae.end)}function p(){return dV(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(ae){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(ae),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=ae}function y(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=ae}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae.replace(/(\r?\n|\r)$/g,"")}function k(ae){const ke=this.resume(),Ue=this.stack[this.stack.length-1];Ue.label=ke,Ue.identifier=Ac(this.sliceSerialize(ae)).toLowerCase()}function x(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ae}function _(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ae}function S(ae){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Ue=this.sliceSerialize(ae).length;ke.depth=Ue}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function I(ae){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(ae).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(ae){const Ue=this.stack[this.stack.length-1].children;let it=Ue[Ue.length-1];(!it||it.type!=="text")&&(it=_t(),it.position={start:Oo(ae.start),end:void 0},Ue.push(it)),this.stack.push(it)}function E(ae){const ke=this.stack.pop();ke.value+=this.sliceSerialize(ae),ke.position.end=Oo(ae.end)}function O(ae){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ue=ke.children[ke.children.length-1];Ue.position.end=Oo(ae.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(z.call(this,ae),E.call(this,ae))}function D(){this.data.atHardBreak=!0}function L(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae}function $(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae}function V(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ae}function B(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=ke,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function F(){const ae=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ae.type+="Reference",ae.referenceType=ke,delete ae.url,delete ae.title}else delete ae.identifier,delete ae.label;this.data.referenceType=void 0}function R(ae){const ke=this.sliceSerialize(ae),Ue=this.stack[this.stack.length-2];Ue.label=uK(ke),Ue.identifier=Ac(ke).toLowerCase()}function H(){const ae=this.stack[this.stack.length-1],ke=this.resume(),Ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ue.type==="link"){const it=ae.children;Ue.children=it}else Ue.alt=ke}function A(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ae}function X(){const ae=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ae}function K(){this.data.inReference=void 0}function W(){this.data.referenceType="collapsed"}function te(ae){const ke=this.resume(),Ue=this.stack[this.stack.length-1];Ue.label=ke,Ue.identifier=Ac(this.sliceSerialize(ae)).toLowerCase(),this.data.referenceType="full"}function ee(ae){this.data.characterReferenceType=ae.type}function G(ae){const ke=this.sliceSerialize(ae),Ue=this.data.characterReferenceType;let it;Ue?(it=uR(ke,Ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):it=hv(ke);const Ee=this.stack[this.stack.length-1];Ee.value+=it}function ne(ae){const ke=this.stack.pop();ke.position.end=Oo(ae.end)}function re(ae){E.call(this,ae);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(ae)}function ie(ae){E.call(this,ae);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(ae)}function Z(){return{type:"blockquote",children:[]}}function de(){return{type:"code",lang:null,meta:null,value:""}}function fe(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Oe(){return{type:"emphasis",children:[]}}function _e(){return{type:"heading",depth:0,children:[]}}function Ne(){return{type:"break"}}function He(){return{type:"html",value:""}}function ct(){return{type:"image",title:null,url:"",alt:null}}function xt(){return{type:"link",title:null,url:"",children:[]}}function Re(ae){return{type:"list",ordered:ae.type==="listOrdered",start:null,spread:ae._spread,children:[]}}function lt(ae){return{type:"listItem",spread:ae._spread,checked:null,children:[]}}function kt(){return{type:"paragraph",children:[]}}function Ot(){return{type:"strong",children:[]}}function _t(){return{type:"text",value:""}}function Xt(){return{type:"thematicBreak"}}}function Oo(e){return{line:e.line,column:e.column,offset:e.offset}}function kR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?kR(e,r):hK(e,r)}}function hK(e,t){let n;for(n in t)if(bR.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 Y1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+_d({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+_d({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+_d({start:t.start,end:t.end})+") is still open")}function mK(e){const t=this;t.parser=n;function n(r){return fK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function gK(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 yK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
70
|
+
`}]}function wK(e,t){const n=t.value?t.value+`
|
|
71
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function xK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=ru(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(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 vK(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 SK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function vR(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 i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function jK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vR(e,t);const i={src:ru(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function NK(e,t){const n={src:ru(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 _K(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 CK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vR(e,t);const i={href:ru(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function AK(e,t){const n={href:ru(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 EK(e,t,n){const r=e.all(t),i=n?IK(n):SR(t),o={},a=[];if(typeof t.checked=="boolean"){const p=r[0];let f;p&&p.type==="element"&&p.tagName==="p"?f=p:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const p=r[l];(i||l!==0||p.type!=="element"||p.tagName!=="p")&&a.push({type:"text",value:`
|
|
72
|
+
`}),p.type==="element"&&p.tagName==="p"&&!i?a.push(...p.children):a.push(p)}const c=r[r.length-1];c&&(i||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
|
|
73
|
+
`});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function IK(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=SR(n[r])}return t}function SR(e){const t=e.spread;return t??e.children.length>1}function PK(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function TK(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function RK(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function MK(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $K(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=uv(t.children[1]),c=rR(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function LK(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<l;){const f=t.children[c],d={},h=a?a[c]:void 0;h&&(d.align=h);let y={type:"element",tagName:o,properties:d,children:[]};f&&(y.children=e.all(f),e.patch(f,y),y=e.applyData(f,y)),u.push(y)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,p),e.applyData(t,p)}function OK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const J1=9,X1=32;function DK(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(Q1(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(Q1(t.slice(i),i>0,!1)),o.join("")}function Q1(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===J1||o===X1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===J1||o===X1;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function FK(e,t){const n={type:"text",value:DK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function zK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const WK={blockquote:gK,break:yK,code:wK,delete:xK,emphasis:bK,footnoteReference:kK,heading:vK,html:SK,imageReference:jK,image:NK,inlineCode:_K,linkReference:CK,link:AK,listItem:EK,list:PK,paragraph:TK,root:RK,strong:MK,table:$K,tableCell:OK,tableRow:LK,text:FK,thematicBreak:zK,toml:Hp,yaml:Hp,definition:Hp,footnoteDefinition:Hp};function Hp(){}const jR=-1,kg=0,Ad=1,ym=2,yv=3,wv=4,xv=5,bv=6,NR=7,_R=8,Z1=typeof self=="object"?self:globalThis,BK=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case kg:case jR:return n(a,i);case Ad:{const l=n([],i);for(const c of a)l.push(r(c));return l}case ym:{const l=n({},i);for(const[c,u]of a)l[r(c)]=r(u);return l}case yv:return n(new Date(a),i);case wv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),i)}case xv:{const l=n(new Map,i);for(const[c,u]of a)l.set(r(c),r(u));return l}case bv:{const l=n(new Set,i);for(const c of a)l.add(r(c));return l}case NR:{const{name:l,message:c}=a;return n(new Z1[l](c),i)}case _R:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);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 Z1[o](a),i)};return r},e_=e=>BK(new Map,e)(0),Ul="",{toString:HK}={},{keys:VK}=Object,Uu=e=>{const t=typeof e;if(t!=="object"||!e)return[kg,t];const n=HK.call(e).slice(8,-1);switch(n){case"Array":return[Ad,Ul];case"Object":return[ym,Ul];case"Date":return[yv,Ul];case"RegExp":return[wv,Ul];case"Map":return[xv,Ul];case"Set":return[bv,Ul];case"DataView":return[Ad,n]}return n.includes("Array")?[Ad,n]:n.includes("Error")?[NR,n]:[ym,n]},Vp=([e,t])=>e===kg&&(t==="function"||t==="symbol"),KK=(e,t,n,r)=>{const i=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},o=a=>{if(n.has(a))return n.get(a);let[l,c]=Uu(a);switch(l){case kg:{let p=a;switch(c){case"bigint":l=_R,p=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);p=null;break;case"undefined":return i([jR],a)}return i([l,p],a)}case Ad:{if(c){let d=a;return c==="DataView"?d=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(d=new Uint8Array(a)),i([c,[...d]],a)}const p=[],f=i([l,p],a);for(const d of a)p.push(o(d));return f}case ym:{if(c)switch(c){case"BigInt":return i([c,a.toString()],a);case"Boolean":case"Number":case"String":return i([c,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const p=[],f=i([l,p],a);for(const d of VK(a))(e||!Vp(Uu(a[d])))&&p.push([o(d),o(a[d])]);return f}case yv:return i([l,a.toISOString()],a);case wv:{const{source:p,flags:f}=a;return i([l,{source:p,flags:f}],a)}case xv:{const p=[],f=i([l,p],a);for(const[d,h]of a)(e||!(Vp(Uu(d))||Vp(Uu(h))))&&p.push([o(d),o(h)]);return f}case bv:{const p=[],f=i([l,p],a);for(const d of a)(e||!Vp(Uu(d)))&&p.push(o(d));return f}}const{message:u}=a;return i([l,{name:c,message:u}],a)};return o},t_=(e,{json:t,lossy:n}={})=>{const r=[];return KK(!(t||n),!!t,new Map,r)(e),r},wm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?e_(t_(e,t)):structuredClone(e):(e,t)=>e_(t_(e,t));function qK(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 UK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function GK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||qK,r=e.options.footnoteBackLabel||UK,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const p=e.all(u),f=String(u.identifier).toUpperCase(),d=ru(f.toLowerCase());let h=0;const y=[],v=e.footnoteCounts.get(f);for(;v!==void 0&&++h<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,h);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+d+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,h),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=p[p.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const k=b.children[b.children.length-1];k&&k.type==="text"?k.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...y)}else p.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(p,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...wm(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
74
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
|
|
75
|
+
`}]}}const CR=function(e){if(e==null)return QK;if(typeof e=="function")return vg(e);if(typeof e=="object")return Array.isArray(e)?YK(e):JK(e);if(typeof e=="string")return XK(e);throw new Error("Expected function, string, or object as test")};function YK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=CR(e[n]);return vg(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function JK(e){const t=e;return vg(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function XK(e){return vg(t);function t(n){return n&&n.type===e}}function vg(e){return t;function t(n,r,i){return!!(ZK(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function QK(){return!0}function ZK(e){return e!==null&&typeof e=="object"&&"type"in e}const AR=[],e7=!0,n_=!1,t7="skip";function n7(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=CR(i),a=r?-1:1;l(e,void 0,[])();function l(c,u,p){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(d,"name",{value:"node ("+(c.type+(h?"<"+h+">":""))+")"})}return d;function d(){let h=AR,y,v,b;if((!t||o(c,u,p[p.length-1]||void 0))&&(h=r7(n(c,p)),h[0]===n_))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==t7)for(v=(r?g.children.length:-1)+a,b=p.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===n_)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function r7(e){return Array.isArray(e)?e:typeof e=="number"?[e7,e]:e==null?AR:[e]}function ER(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),n7(e,o,l,i);function l(c,u){const p=u[u.length-1],f=p?p.children.indexOf(c):void 0;return a(c,f,p)}}const mb={}.hasOwnProperty,s7={};function i7(e,t){const n=t||s7,r=new Map,i=new Map,o=new Map,a={...WK,...n.handlers},l={all:u,applyData:a7,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:o7,wrap:c7};return ER(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const f=p.type==="definition"?r:i,d=String(p.identifier).toUpperCase();f.has(d)||f.set(d,p)}}),l;function c(p,f){const d=p.type,h=l.handlers[d];if(mb.call(l.handlers,d)&&h)return h(l,p,f);if(l.options.passThrough&&l.options.passThrough.includes(d)){if("children"in p){const{children:v,...b}=p,g=wm(b);return g.children=l.all(p),g}return wm(p)}return(l.options.unknownHandler||l7)(l,p,f)}function u(p){const f=[];if("children"in p){const d=p.children;let h=-1;for(;++h<d.length;){const y=l.one(d[h],p);if(y){if(h&&d[h-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=r_(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=r_(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function o7(e,t){e.position&&(t.position=H8(e))}function a7(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,wm(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function l7(e,t){const n=t.data||{},r="value"in t&&!(mb.call(n,"hProperties")||mb.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 c7(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 r_(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function s_(e,t){const n=i7(e,t),r=n.one(e,void 0),i=GK(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
|
|
79
|
+
`},i),o}function u7(e,t){return e&&"run"in e?async function(n,r){const i=s_(n,{file:r,...t});await e.run(i,r)}:function(n,r){return s_(n,{file:r,...e||t})}}function i_(e){if(e)throw e}var Eh=Object.prototype.hasOwnProperty,IR=Object.prototype.toString,o_=Object.defineProperty,a_=Object.getOwnPropertyDescriptor,l_=function(t){return typeof Array.isArray=="function"?Array.isArray(t):IR.call(t)==="[object Array]"},c_=function(t){if(!t||IR.call(t)!=="[object Object]")return!1;var n=Eh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Eh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||Eh.call(t,i)},u_=function(t,n){o_&&n.name==="__proto__"?o_(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},d_=function(t,n){if(n==="__proto__")if(Eh.call(t,n)){if(a_)return a_(t,n).value}else return;return t[n]},d7=function e(){var t,n,r,i,o,a,l=arguments[0],c=1,u=arguments.length,p=!1;for(typeof l=="boolean"&&(p=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=d_(l,n),i=d_(t,n),l!==i&&(p&&i&&(c_(i)||(o=l_(i)))?(o?(o=!1,a=r&&l_(r)?r:[]):a=r&&c_(r)?r:{},u_(l,{name:n,newValue:e(p,a,i)})):typeof i<"u"&&u_(l,{name:n,newValue:i}));return l};const fw=ma(d7);function gb(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 f7(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...i);function l(c,...u){const p=e[++o];let f=-1;if(c){a(c);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,p?p7(p,l)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function p7(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(i);try{c=e.apply(this,a)}catch(u){const p=u;if(l&&n)throw p;return i(p)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,i):c instanceof Error?i(c):o(c))}function i(a,...l){n||(n=!0,t(a,...l))}function o(a){i(null,a)}}const ji={basename:h7,dirname:m7,extname:g7,join:y7,sep:"/"};function h7(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Rf(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function m7(e){if(Rf(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 g7(e){Rf(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function y7(...e){let t=-1,n;for(;++t<e.length;)Rf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":w7(n)}function w7(e){Rf(e);const t=e.codePointAt(0)===47;let n=x7(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function x7(e,t){let n="",r=0,i=-1,o=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else l===46&&o>-1?o++:o=-1}return n}function Rf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const b7={cwd:k7};function k7(){return"/"}function yb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function v7(e){if(typeof e=="string")e=new URL(e);else if(!yb(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 S7(e)}function S7(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 i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const pw=["history","path","basename","stem","extname","dirname"];class PR{constructor(t){let n;t?yb(t)?n={path:t}:typeof t=="string"||j7(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":b7.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<pw.length;){const o=pw[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)pw.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?ji.basename(this.path):void 0}set basename(t){mw(t,"basename"),hw(t,"basename"),this.path=ji.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ji.dirname(this.path):void 0}set dirname(t){f_(this.basename,"dirname"),this.path=ji.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ji.extname(this.path):void 0}set extname(t){if(hw(t,"extname"),f_(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=ji.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){yb(t)&&(t=v7(t)),mw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ji.basename(this.path,this.extname):void 0}set stem(t){mw(t,"stem"),hw(t,"stem"),this.path=ji.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Or(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function hw(e,t){if(e&&e.includes(ji.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ji.sep+"`")}function mw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function f_(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function j7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const N7=function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},_7={}.hasOwnProperty;class kv extends N7{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=f7()}copy(){const t=new kv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(fw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(ww("data",this.frozen),this.namespace[t]=n,this):_7.call(this.namespace,t)&&this.namespace[t]||void 0:t?(ww("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 i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Kp(t),r=this.parser||this.Parser;return gw("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),gw("process",this.parser||this.Parser),yw("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,a){const l=Kp(t),c=r.parse(l);r.run(c,l,function(p,f,d){if(p||!f||!d)return u(p);const h=f,y=r.stringify(h,d);E7(y)?d.value=y:d.result=y,u(p,d)});function u(p,f){p||!f?a(p):o?o(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),gw("processSync",this.parser||this.Parser),yw("processSync",this.compiler||this.Compiler),this.process(t,i),h_("processSync","process",n),r;function i(o,a){n=!0,i_(o),r=a}}run(t,n,r){p_(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const c=Kp(n);i.run(t,c,u);function u(p,f,d){const h=f||t;p?l(p):a?a(h):r(void 0,h,d)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),h_("runSync","run",r),i;function o(a,l){i_(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=Kp(n),i=this.compiler||this.Compiler;return yw("stringify",i),p_(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(ww("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[p,...f]=u;c(p,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&&(i.settings=fw(!0,i.settings,u.settings))}function l(u){let p=-1;if(u!=null)if(Array.isArray(u))for(;++p<u.length;){const f=u[p];o(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,p){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===u){d=f;break}if(d===-1)r.push([u,...p]);else if(p.length>0){let[h,...y]=p;const v=r[d][1];gb(v)&&gb(h)&&(h=fw(!0,v,h)),r[d]=[u,h,...y]}}}}const C7=new kv().freeze();function gw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function yw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ww(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 p_(e){if(!gb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function h_(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Kp(e){return A7(e)?e:new PR(e)}function A7(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function E7(e){return typeof e=="string"||I7(e)}function I7(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const P7="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",m_=[],g_={allowDangerousHtml:!0},T7=/^(https?|ircs?|mailto|xmpp)$/i,R7=[{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 TR(e){const t=M7(e),n=$7(e);return L7(t.runSync(t.parse(n),n),e)}function M7(e){const t=e.rehypePlugins||m_,n=e.remarkPlugins||m_,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...g_}:g_;return C7().use(mK).use(n).use(u7,r).use(t)}function $7(e){const t=e.children||"",n=new PR;return typeof t=="string"&&(n.value=t),n}function L7(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||O7;for(const p of R7)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+P7+p.id,void 0);return ER(e,u),G8(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function u(p,f,d){if(p.type==="raw"&&d&&typeof f=="number")return a?d.children.splice(f,1):d.children[f]={type:"text",value:p.value},f;if(p.type==="element"){let h;for(h in cw)if(Object.hasOwn(cw,h)&&Object.hasOwn(p.properties,h)){const y=p.properties[h],v=cw[h];(v===null||v.includes(p.tagName))&&(p.properties[h]=c(String(y||""),h,p))}}if(p.type==="element"){let h=n?!n.includes(p.tagName):o?o.includes(p.tagName):!1;if(!h&&r&&typeof f=="number"&&(h=!r(p,f,d)),h&&d&&typeof f=="number")return l&&p.children?d.children.splice(f,1,...p.children):d.children.splice(f,1),f}}}function O7(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||T7.test(e.slice(0,t))?e:""}const D7=new Set(["echarts"]),F7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),z7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),W7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function oa(e){return e&&typeof e=="object"&&!Array.isArray(e)}function cl(e,t){if(!oa(e))return{...t};const n={...e};for(const[r,i]of Object.entries(t))n[r]==null?n[r]=i:oa(n[r])&&oa(i)&&(n[r]=cl(n[r],i));return n}function Sg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>oa(n)?cl(n,t):n):oa(e)?cl(e,t):e}function B7(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("{"),i=t.lastIndexOf("}");r>=0&&i>r&&(t=t.slice(r,i+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function wb(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)=>wb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||z7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);wb(r,`${t}.${n}`)}}}function H7(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(!F7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function V7(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:cl(e,t)}function K7(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,i)=>{if(!oa(r))return r;const o=i===0&&t&&r.text==null?{...r,text:t}:r;return cl(o,n)}):oa(e)?cl(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function q7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:Sg(e,n)}function y_(e,t="rgba(255, 255, 255, 0.62)"){return Sg(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 U7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:Sg(e,n)}function G7(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:Sg(e,t)}function Y7(e,t,n){const r=K7(e.title,n),i=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>oa(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??W7,textStyle:cl(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:V7(e.tooltip),legend:q7(e.legend,i),grid:e.xAxis!=null||e.yAxis!=null?U7(e.grid,i||o):e.grid,xAxis:y_(e.xAxis),yAxis:y_(e.yAxis),radar:G7(e.radar),series:t}}function J7(e){const t=B7(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(!D7.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");wb(n);const r=H7(n.option.series),i=n.title==null?"":String(n.title),o=Y7(n.option,r,i);return{ok:!0,spec:{...n,title:i,option:o}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function qp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function X7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function io(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!qp(t,t.length-1)&&(t=t.slice(0,-1));const n=[];let r="",i=0;for(let o=0;o<t.length;o+=1){const a=t[o];if(a==="`"&&!qp(t,o)){const l=X7(t,o);r+=t.slice(o,o+l),i===0?i=l:i===l&&(i=0),o+=l-1;continue}if(i===0&&a==="|"&&!qp(t,o)){n.push(r.trim()),r="";continue}if(i===0&&a==="\\"&&t[o+1]==="|"&&qp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function RR(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 MR(e){const t=io(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function $R(e){return io(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function Q7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function Z7(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let i="TD";const o=(l,c="")=>{const u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[1]):o(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){i=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:i}}function eq({code:e}){const t=m.useMemo(()=>Z7(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,i=46,o=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((p,f)=>{l.set(p.id,{x:28+(n?f*(r+o):f%3*(r+o)),y:28+(n?f%3*(i+a):f*(i+a))})});const c=Math.max(520,...Array.from(l.values()).map(p=>p.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(p=>p.y+i+28));return s.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid flowchart preview",children:[s.jsx("defs",{children:s.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:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,f)=>{const d=l.get(p.from),h=l.get(p.to);if(!d||!h)return null;const y=n?`M ${d.x+r} ${d.y+i/2} C ${(d.x+h.x+r)/2} ${d.y+i/2}, ${(d.x+h.x+r)/2} ${h.y+i/2}, ${h.x} ${h.y+i/2}`:`M ${d.x+r/2} ${d.y+i} C ${d.x+r/2} ${d.y+i+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return s.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${p.from}-${p.to}-${f}`)}),t.nodes.map(p=>{const f=l.get(p.id);return s.jsxs("g",{children:[s.jsx("rect",{className:"af-md-mermaid-box",x:f.x,y:f.y,width:r,height:i,rx:"8"}),s.jsx("text",{className:"af-md-mermaid-text",x:f.x+r/2,y:f.y+i/2+5,textAnchor:"middle",children:p.label.slice(0,24)})]},p.id)})]})}function tq(e){const t=String(e||"").split(/\r?\n/).map(o=>o.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],i=(o,a="")=>{const l=String(o||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const o of t){if(/^sequenceDiagram\b/i.test(o))continue;const a=o.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){i(a[2],a[3]||a[2]);continue}const l=o.match(/^([A-Za-z0-9_]+)\s*[-=]+>>\+?\s*([A-Za-z0-9_]+)\s*:\s*(.+)$/);if(l){i(l[1]),i(l[2]),r.push({type:"message",from:l[1],to:l[2],text:l[3]});continue}const c=o.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:c?c[2]:o})}return{participants:Array.from(n,([o,a])=>({id:o,label:a})),rows:r}}function nq({code:e}){const t=m.useMemo(()=>tq(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,i=48,o=26,a=44,l=48,c=Math.max(620,i*2+n.length*r),u=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),p=f=>{const d=Math.max(0,n.findIndex(h=>h.id===f));return i+d*r+r/2};return s.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[s.jsx("defs",{children:s.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:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((f,d)=>{const h=i+d*r+r/2;return s.jsxs("g",{children:[s.jsx("rect",{className:"af-md-mermaid-box",x:h-68,y:o,width:"136",height:"34",rx:"8"}),s.jsx("text",{className:"af-md-mermaid-text",x:h,y:o+22,textAnchor:"middle",children:f.label.slice(0,18)}),s.jsx("line",{className:"af-md-sequence-life",x1:h,y1:o+a,x2:h,y2:u-18})]},f.id)}),t.rows.map((f,d)=>{const h=o+a+d*l+24;if(f.type!=="message")return s.jsxs("g",{children:[s.jsx("rect",{className:"af-md-sequence-note",x:i,y:h-17,width:c-i*2,height:"30",rx:"7"}),s.jsx("text",{className:"af-md-mermaid-text",x:i+12,y:h+4,children:f.text.slice(0,120)})]},`note-${d}`);const y=p(f.from),v=p(f.to),b=(y+v)/2;return s.jsxs("g",{children:[s.jsx("line",{className:"af-md-mermaid-edge",x1:y,y1:h,x2:v,y2:h,markerEnd:"url(#af-md-sequence-arrow)"}),s.jsx("text",{className:"af-md-sequence-label",x:b,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${d}`)})]})}function LR({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return s.jsx("div",{className:"af-md-mermaid-preview",children:n?s.jsx(nq,{code:t}):s.jsx(eq,{code:t})})}function rq(e){const t=String(e||"").replace(/\r\n/g,`
|
|
80
|
+
`).split(`
|
|
81
|
+
`),n=[];let r=[],i=!1;const o=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
|
|
82
|
+
`)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!i&&c){o();const u=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)u.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:u.join(`
|
|
83
|
+
`)});continue}if(!i&&Q7(l)){o();const u=[];for(;a<t.length;){const p=t[a]||"";if(u.length>0&&(!p.trim()||/^-{3,}\s*$/.test(p)||/^#{1,6}\s+/.test(p)))break;u.push(p),a++}n.push({type:"mermaid",text:u.join(`
|
|
84
|
+
`)});continue}if(/^\s*```/.test(l)){i=!i,r.push(l),a++;continue}if(!i&&a+1<t.length&&io(l).length>1&&MR(t[a+1])){o();const u=io(l),p=$R(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&io(t[a]).length>1;)f.push(RR(io(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:p,rows:f});continue}r.push(l),a++}return o(),n}function w_(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 i=[...r,...n.split("/")].filter(Boolean),o=[];for(const a of i)if(a!=="."){if(a===".."){if(o.length===0)return n;o.pop();continue}o.push(a)}return o.join("/")}function OR(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 i="",o=0,a=!1;for(;o<r.length;){const l=r[o];if(l==="`"){a=!a,i+=l,o+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(o)))){i+=l,o+=1;continue}if((o>0?r[o-1]:"")==="("){i+=l,o+=1;continue}let p=o;for(;p<r.length&&!/\s|<|>/.test(r[p]);)p+=1;let f=r.slice(o,p),d="";for(;/[.,;:!?)}\]]$/.test(f);)d=f.slice(-1)+d,f=f.slice(0,-1);f?i+=`[${f}](${f})${d}`:i+=r.slice(o,p),o=p}return i}).join(`
|
|
87
|
+
`)}function DR(e,t=!1,n=""){const r=o=>{const a=String(o||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=w_(a,n);return e?e(l,{kind:"link",download:!0}):l},i=(o,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(o.stopPropagation(),!(o.defaultPrevented||o.button!==0)&&(o.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:o})=>s.jsx(s.Fragment,{children:o})}:{},code:({inline:o,className:a,children:l})=>{var p;const c=((p=String(a||"").match(/language-(\w+)/i))==null?void 0:p[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?s.jsx(LR,{code:u}):o?s.jsx("code",{className:a,children:l}):s.jsx("code",{className:a,children:l})},img:({src:o,alt:a})=>s.jsx("img",{src:e?e(w_(o,n)):o||"",alt:a||"",loading:"lazy"}),a:({href:o,children:a})=>s.jsx("a",{href:r(o),target:"_blank",rel:"noopener noreferrer",onClick:l=>i(l,o),children:a})}}function x_({children:e,resolveSrc:t,basePath:n=""}){return s.jsx(TR,{components:DR(t,!0,n),children:OR(e)})}function vv({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>rq(e),[e]),i=m.useMemo(()=>DR(t,!1,n),[n,t]);return s.jsx(s.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?s.jsx(LR,{code:o.text},`mermaid-${a}`):o.type!=="table"?s.jsx(TR,{components:i,children:OR(o.text)},`md-${a}`):s.jsx("div",{className:"af-work-display-table-wrap",children:s.jsxs("table",{className:"af-work-display-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:o.headers.map((l,c)=>s.jsx("th",{style:{textAlign:o.align[c]||"left"},children:s.jsx(x_,{resolveSrc:t,basePath:n,children:l})},c))})}),s.jsx("tbody",{children:o.rows.map((l,c)=>s.jsx("tr",{children:o.headers.map((u,p)=>s.jsx("td",{style:{textAlign:o.align[p]||"left"},children:s.jsx(x_,{resolveSrc:t,basePath:n,children:l[p]||""})},p))},c))})]})},`table-${a}`))})}function sq(e,t=","){const n=[];let r=[],i="",o=!1;const a=String(e||"").replace(/\r\n/g,`
|
|
88
|
+
`);for(let l=0;l<a.length;l+=1){const c=a[l],u=a[l+1];if(o){c==='"'&&u==='"'?(i+='"',l+=1):c==='"'?o=!1:i+=c;continue}c==='"'?o=!0:c===t?(r.push(i.trim()),i=""):c===`
|
|
89
|
+
`?(r.push(i.trim()),n.push(r),r=[],i=""):i+=c}return(i||r.length)&&(r.push(i.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function vi(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 iq(e){if(Array.isArray(e)){if(e.every(i=>i&&typeof i=="object"&&!Array.isArray(i))){const i=Array.from(new Set(e.flatMap(o=>Object.keys(o))));return{columns:i.map(o=>({key:o,label:o,align:"left"})),rows:e.map(o=>i.map(a=>vi(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const i=e[0].map((o,a)=>vi(o)||`Column ${a+1}`);return{columns:i.map((o,a)=>({key:String(a),label:o,align:"left"})),rows:e.slice(1).map(o=>i.map((a,l)=>vi(o[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((i,o)=>i&&typeof i=="object"?{key:String(i.key||i.name||i.field||o),label:String(i.label||i.title||i.name||i.key||`Column ${o+1}`),align:["left","center","right"].includes(i.align)?i.align:"left"}:{key:String(o),label:vi(i)||`Column ${o+1}`,align:"left"});return r.length===0&&n.every(i=>i&&typeof i=="object"&&!Array.isArray(i))&&(r=Array.from(new Set(n.flatMap(i=>Object.keys(i)))).map(i=>({key:i,label:i,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((i,o)=>({key:String(o),label:vi(i)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(i=>r.map((o,a)=>vi(i[a])))}):{columns:r,rows:n.map(i=>Array.isArray(i)?r.map((o,a)=>vi(i[a])):i&&typeof i=="object"?r.map(o=>vi(i[o.key])):r.map((o,a)=>a===0?vi(i):""))}}function oq(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=iq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const i=r.replace(/\r\n/g,`
|
|
90
|
+
`).split(`
|
|
91
|
+
`).filter(l=>l.trim());if(i.length>=2&&io(i[0]).length>1&&MR(i[1])){const l=io(i[0]),c=$R(i[1]);return{columns:l.map((u,p)=>({key:String(p),label:u,align:c[p]||"left"})),rows:i.slice(2).map(u=>RR(io(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=sq(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((c,u)=>c||`Column ${u+1}`).map((c,u)=>({key:String(u),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function Sv({content:e}){const t=m.useMemo(()=>oq(e),[e]);return t.error||t.columns.length===0?s.jsxs("div",{className:"af-work-display-table-empty",children:[s.jsx("strong",{children:"Table data error"}),s.jsx("span",{children:t.error||"No columns found"})]}):s.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:s.jsxs("table",{className:"af-work-display-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.columns.map((n,r)=>s.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),s.jsx("tbody",{children:t.rows.map((n,r)=>s.jsx("tr",{children:t.columns.map((i,o)=>s.jsx("td",{style:{textAlign:i.align||"left"},children:vi(n[o])},`${i.key}-${o}`))},r))})]})})}function jv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>J7(e),[e]),[r,i]=m.useState({loading:!1,error:""});return m.useEffect(()=>{if(!n.ok){i({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return i({loading:!0,error:""}),sP(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{o||!t.current||(a=u.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||i({loading:!1,error:""}))}).catch(u=>{o||i({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,p;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(p=a==null?void 0:a.dispose)==null||p.call(a)}},[n]),!n.ok||r.error?s.jsxs("div",{className:"af-work-display-chart-error",children:[s.jsx("strong",{children:"Chart configuration error"}),s.jsx("span",{children:r.error||n.error})]}):s.jsxs("div",{className:"af-work-display-chart",children:[s.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?s.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 FR(e){return typeof e>"u"||e===null}function aq(e){return typeof e=="object"&&e!==null}function lq(e){return Array.isArray(e)?e:FR(e)?[]:[e]}function cq(e,t){var n,r,i,o;if(t)for(o=Object.keys(t),n=0,r=o.length;n<r;n+=1)i=o[n],e[i]=t[i];return e}function uq(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function dq(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var fq=FR,pq=aq,hq=lq,mq=uq,gq=dq,yq=cq,Nv={isNothing:fq,isObject:pq,toArray:hq,repeat:mq,isNegativeZero:gq,extend:yq};function zR(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 af(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=zR(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}af.prototype=Object.create(Error.prototype);af.prototype.constructor=af;af.prototype.toString=function(t){return this.name+": "+zR(this,t)};var Fa=af,wq=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xq=["scalar","sequence","mapping"];function bq(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function kq(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(wq.indexOf(n)===-1)throw new Fa('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=bq(t.styleAliases||null),xq.indexOf(this.kind)===-1)throw new Fa('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Mr=kq;function b_(e,t){var n=[];return e[t].forEach(function(r){var i=n.length;n.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(i=a)}),n[i]=r}),n}function vq(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(i){i.multi?(e.multi[i.kind].push(i),e.multi.fallback.push(i)):e[i.kind][i.tag]=e.fallback[i.tag]=i}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function xb(e){return this.extend(e)}xb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Mr)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 Fa("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Mr))throw new Fa("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Fa("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new Fa("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof Mr))throw new Fa("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(xb.prototype);return i.implicit=(this.implicit||[]).concat(n),i.explicit=(this.explicit||[]).concat(r),i.compiledImplicit=b_(i,"implicit"),i.compiledExplicit=b_(i,"explicit"),i.compiledTypeMap=vq(i.compiledImplicit,i.compiledExplicit),i};var Sq=xb,jq=new Mr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Nq=new Mr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),_q=new Mr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Cq=new Sq({explicit:[jq,Nq,_q]});function Aq(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function Eq(){return null}function Iq(e){return e===null}var Pq=new Mr("tag:yaml.org,2002:null",{kind:"scalar",resolve:Aq,construct:Eq,predicate:Iq,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Tq(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 Rq(e){return e==="true"||e==="True"||e==="TRUE"}function Mq(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var $q=new Mr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Tq,construct:Rq,predicate:Mq,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 Lq(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Oq(e){return 48<=e&&e<=55}function Dq(e){return 48<=e&&e<=57}function Fq(e){if(e===null)return!1;var t=e.length,n=0,r=!1,i;if(!t)return!1;if(i=e[n],(i==="-"||i==="+")&&(i=e[++n]),i==="0"){if(n+1===t)return!0;if(i=e[++n],i==="b"){for(n++;n<t;n++)if(i=e[n],i!=="_"){if(i!=="0"&&i!=="1")return!1;r=!0}return r&&i!=="_"}if(i==="x"){for(n++;n<t;n++)if(i=e[n],i!=="_"){if(!Lq(e.charCodeAt(n)))return!1;r=!0}return r&&i!=="_"}if(i==="o"){for(n++;n<t;n++)if(i=e[n],i!=="_"){if(!Oq(e.charCodeAt(n)))return!1;r=!0}return r&&i!=="_"}}if(i==="_")return!1;for(;n<t;n++)if(i=e[n],i!=="_"){if(!Dq(e.charCodeAt(n)))return!1;r=!0}return!(!r||i==="_")}function zq(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 Wq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Nv.isNegativeZero(e)}var Bq=new Mr("tag:yaml.org,2002:int",{kind:"scalar",resolve:Fq,construct:zq,predicate:Wq,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"]}}),Hq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Vq(e){return!(e===null||!Hq.test(e)||e[e.length-1]==="_")}function Kq(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 qq=/^[-+]?[0-9]+e/;function Uq(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(Nv.isNegativeZero(e))return"-0.0";return n=e.toString(10),qq.test(n)?n.replace("e",".e"):n}function Gq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Nv.isNegativeZero(e))}var Yq=new Mr("tag:yaml.org,2002:float",{kind:"scalar",resolve:Vq,construct:Kq,predicate:Gq,represent:Uq,defaultStyle:"lowercase"}),Jq=Cq.extend({implicit:[Pq,$q,Bq,Yq]}),Xq=Jq,WR=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),BR=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 Qq(e){return e===null?!1:WR.exec(e)!==null||BR.exec(e)!==null}function Zq(e){var t,n,r,i,o,a,l,c=0,u=null,p,f,d;if(t=WR.exec(e),t===null&&(t=BR.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(n,r,i));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(p=+t[10],f=+(t[11]||0),u=(p*60+f)*6e4,t[9]==="-"&&(u=-u)),d=new Date(Date.UTC(n,r,i,o,a,l,c)),u&&d.setTime(d.getTime()-u),d}function eU(e){return e.toISOString()}var tU=new Mr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Qq,construct:Zq,instanceOf:Date,represent:eU});function nU(e){return e==="<<"||e===null}var rU=new Mr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:nU}),_v=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
94
|
+
\r`;function sU(e){if(e===null)return!1;var t,n,r=0,i=e.length,o=_v;for(n=0;n<i;n++)if(t=o.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function iU(e){var t,n,r=e.replace(/[\r\n=]/g,""),i=r.length,o=_v,a=0,l=[];for(t=0;t<i;t++)t%4===0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|o.indexOf(r.charAt(t));return n=i%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 oU(e){var t="",n=0,r,i,o=e.length,a=_v;for(r=0;r<o;r++)r%3===0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];return i=o%3,i===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):i===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):i===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function aU(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var lU=new Mr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:sU,construct:iU,predicate:aU,represent:oU}),cU=Object.prototype.hasOwnProperty,uU=Object.prototype.toString;function dU(e){if(e===null)return!0;var t=[],n,r,i,o,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(i=l[n],a=!1,uU.call(i)!=="[object Object]")return!1;for(o in i)if(cU.call(i,o))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function fU(e){return e!==null?e:[]}var pU=new Mr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dU,construct:fU}),hU=Object.prototype.toString;function mU(e){if(e===null)return!0;var t,n,r,i,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],hU.call(r)!=="[object Object]"||(i=Object.keys(r),i.length!==1))return!1;o[t]=[i[0],r[i[0]]]}return!0}function gU(e){if(e===null)return[];var t,n,r,i,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],i=Object.keys(r),o[t]=[i[0],r[i[0]]];return o}var yU=new Mr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:mU,construct:gU}),wU=Object.prototype.hasOwnProperty;function xU(e){if(e===null)return!0;var t,n=e;for(t in n)if(wU.call(n,t)&&n[t]!==null)return!1;return!0}function bU(e){return e!==null?e:{}}var kU=new Mr("tag:yaml.org,2002:set",{kind:"mapping",resolve:xU,construct:bU});Xq.extend({implicit:[tU,rU],explicit:[lU,pU,yU,kU]});function k_(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 vU=new Array(256),SU=new Array(256);for(var Gl=0;Gl<256;Gl++)vU[Gl]=k_(Gl)?1:0,SU[Gl]=k_(Gl);const lf=["requirement","planning","code","test","normal"],v_={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function Cv(e,t){var i,o,a,l,c,u,p,f,d,h,y,v,b,g;const n=k=>{const x={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(x.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(x.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(x.showOnNode=!!k.showOnNode),x},r={};for(const k of e){if((i=k==null?void 0:k.data)!=null&&i.isWorkspaceGroup)continue;const x=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},_=((o=k.data)==null?void 0:o.definitionId)||k.id,S=((a=k.data)==null?void 0:a.inputs)??[],N=((l=k.data)==null?void 0:l.outputs)??[],I=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",T=x.role!=null?String(x.role).trim():"",z=v_[I]||I,E=v_[T]||T,O=lf.includes(z)?z:lf.includes(E)?E:"normal",D=Array.isArray(S)?S.map(n):Array.isArray(x.input)?x.input.map(ee=>n(ee)):[],L=Array.isArray(N)?N.map(n):Array.isArray(x.output)?x.output.map(ee=>n(ee)):[],$=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,V=(p=k.data)==null?void 0:p.body,B=V!=null?String(V):x.body!=null?String(x.body):"";let F=((f=k.data)==null?void 0:f.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(F===""||F==="default")&&(F=void 0);const R={...x,definitionId:_,label:$,role:O,model:F,input:D,output:L},H=((d=k.data)==null?void 0:d.marketplaceRef)||x.marketplaceRef;H?R.marketplaceRef=String(H):delete R.marketplaceRef;const A=((h=k.data)==null?void 0:h.marketplacePackageId)||x.marketplacePackageId;A?R.marketplacePackageId=String(A):delete R.marketplacePackageId;const X=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;X?R.marketplaceVersion=String(X):delete R.marketplaceVersion,_.startsWith("provide_")||B.trim()===""?delete R.body:R.body=B;const K=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(x.images)?x.images:[];K.length>0?R.images=K:delete R.images;const W=(b=k.data)==null?void 0:b.script,te=W!=null?String(W):x.script!=null?String(x.script):"";te.trim()===""?delete R.script:R.script=te;for(const ee of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[ee],ne=G!=null?String(G):x[ee]!=null?String(x[ee]):"";ne.trim()===""?delete R[ee]:R[ee]=ne.trim()}delete R.temperature,delete R.maxTokens,delete R.description,r[k.id]=R}return r}function Ed(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function jU(e,t){const n=String(e||"node").replace(/_copy(?:_\d+)?$/i,"");let r=`${n}_copy`,i=2;for(;t.has(r);)r=`${n}_copy_${i}`,i+=1;return t.add(r),r}function NU(e,t,n){const r=(e||[]).filter(a=>a==null?void 0:a.selected);if(r.length===0)return null;const i=new Set(r.map(a=>a.id)),o=(t||[]).filter(a=>i.has(a.source)&&i.has(a.target));return{version:1,nodes:r.map(a=>Ed(a)),edges:o.map(a=>Ed(a)),instances:Cv(r,n||{})}}function _U(e,t,n,r,i={}){var f;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const o=i.offset||{x:48,y:48},a=new Set((t||[]).map(d=>d.id)),l=new Map;for(const d of e.nodes)l.set(d.id,jU(d.id,a));const c=e.nodes.map(d=>{var y,v;const h=l.get(d.id);return{...Ed(d),id:h,selected:!0,dragging:!1,position:{x:Number(((y=d.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=d.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(d=>l.has(d.source)&&l.has(d.target)).map((d,h)=>{const y=l.get(d.source),v=l.get(d.target);return{...Ed(d),id:`e-${y}-${v}-${Date.now()}-${h}`,source:y,target:v,selected:!1}}),p={...r||{}};for(const[d,h]of l.entries()){const y=(f=e.instances)==null?void 0:f[d];y&&(p[h]={...Ed(y),label:y.label!=null?String(y.label):h})}return{nodes:[...(t||[]).map(d=>({...d,selected:!1})),...c],edges:[...(n||[]).map(d=>({...d,selected:!1})),...u],instances:p,pastedNodeIds:c.map(d=>d.id)}}function zn(e){switch(xm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function xm(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 CU(e,t){const n=xm(e),r=xm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const AU=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function bb(e){const t=xm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&AU.has(n)?`${t}+${n}`:t}function EU(e){return bb(e)}function cf(e,t){if(!e||!t||!CU(e.type,t.type))return!1;const n=bb(e),r=bb(t),i=n.includes("+"),o=r.includes("+");return i||o?n===r:!0}function IU(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 kb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=IU(t,n==="source"?"output":"input");return o<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[o]||null}const bm=/\[image\s+(\d+)\]/gi;function vo(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 PU(e){return`image ${vo(e).length+1}`}function TU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function RU(e,t){const n=vo(e),r=String(t||""),i=new Set;bm.lastIndex=0;let o;for(;o=bm.exec(r);)i.add(`image ${o[1]}`.toLowerCase());return i.size===0?[]:n.filter(a=>i.has(String(a.label||"").toLowerCase()))}function MU(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 HR(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 Id(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 VR({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let i=String(t||"");const o=vo(n);for(const a of r){const l=await MU(a),c=PU(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),i=TU(i,c)}return{body:i,images:o}}function Is(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function $U(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 LU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function ln(e){e.stopPropagation()}function OU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function DU(e,t){const n=`\\[${OU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
|
|
96
|
+
`).replace(/\n{3,}/g,`
|
|
97
|
+
|
|
98
|
+
`).trimEnd()}function xw(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function FU(e){const t=String(e||"");let n="",r=0;bm.lastIndex=0;let i;for(;i=bm.exec(t);)n+=xw(t.slice(r,i.index)),n+=`<span class="af-flow-node__image-token">${xw(i[0])}</span>`,r=i.index+i[0].length;return n+=xw(t.slice(r)),n||" "}function zU(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,i=Number.parseFloat(n.paddingTop)||0,o=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,u=Math.min(Math.max(c,2),8);return Math.ceil(u*r+i+o+a+l)}function WU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:i,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:p=!1}){var lr,jr;const{t:f}=Ur(),d=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=$U(e),b=(e==null?void 0:e.isRunMode)??!1,g=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,x=(e==null?void 0:e.isDim)??!1,_=(e==null?void 0:e.nodeStatus)??null,S=(e==null?void 0:e.nodeElapsed)??null,N=(e==null?void 0:e.definitionId)||"",I=N.startsWith("provide_"),T=N==="provide_bool",z=N==="provide_str",E=N==="provide_file",O=N==="provide_password",D=N==="agent_subAgent",L=N==="control_agent_toBool",$=(D||L)&&!b,V=T?LU(h[0]):!1,B=I?String(((lr=h[0])==null?void 0:lr.value)??((jr=h[0])==null?void 0:jr.default)??(e==null?void 0:e.body)??""):"",F=String((e==null?void 0:e.body)||""),R=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),H=!I&&!$&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",A=vo(e==null?void 0:e.images),X=T||z||E||O||$||!!H,K=m.useRef(!1),W=m.useRef(!1),te=m.useRef(null),ee=m.useRef(null),G=m.useRef(null),ne=m.useRef(null),re=m.useRef(null),[ie,Z]=m.useState(B),[de,fe]=m.useState(!1),[ge,Oe]=m.useState(F),[_e,Ne]=m.useState(!1),[He,ct]=m.useState({visible:!1,top:0,height:100}),[xt,Re]=m.useState(!1),lt=m.useCallback(()=>{const le=ee.current;if(!le)return;const he=Math.max(1,le.scrollHeight),Je=Math.max(1,le.clientHeight),st=he>Je+1,Tt=st?Math.max(12,Je/he*100):100,ue=Math.max(0,100-Tt),Te=st?Math.min(ue,le.scrollTop/Math.max(1,he-Je)*ue):0;ct({visible:st,top:Te,height:Tt})},[]);m.useEffect(()=>{K.current||Z(B)},[n,B]),m.useEffect(()=>{W.current||Oe(F)},[n,F]),m.useEffect(()=>{const le=ee.current;if(!le)return;if($){le.style.minHeight="",le.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const he=zU(le,ge);le.style.minHeight=`${he}px`,le.style.height="",G.current&&(G.current.style.minHeight=`${he}px`,G.current.style.height="")},[ge,$]),m.useEffect(()=>{if(!$)return;const le=window.requestAnimationFrame(lt),he=ee.current;if(!he||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(le);const Je=new ResizeObserver(lt);return Je.observe(he),()=>{window.cancelAnimationFrame(le),Je.disconnect()}},[ge,$,lt]),m.useEffect(()=>{const le=te.current,he=e==null?void 0:e.onNodeContentResize;if(!$||!le||!he||typeof ResizeObserver>"u")return;let Je=0;const st=()=>{window.cancelAnimationFrame(Je),Je=window.requestAnimationFrame(()=>he(n))},Tt=new ResizeObserver(st);return Tt.observe(le),st(),()=>{window.cancelAnimationFrame(Je),Tt.disconnect()}},[e==null?void 0:e.onNodeContentResize,$,n]),m.useEffect(()=>{if(!xt)return;const le=window.setTimeout(()=>{const he=re.current;if(!he)return;he.focus();const Je=he.value.length;he.setSelectionRange(Je,Je)},0);return()=>window.clearTimeout(le)},[xt]);const kt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],Ot=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],_t=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Xt=Array.isArray(c==null?void 0:c.codex)?c.codex:[],ae=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!N.startsWith("tool_nodejs"),Ue=new Set(kt.map(Is)),it=new Set(Ot.map(Is)),Ee=new Set(_t.map(Is)),Kt=new Set(Xt.map(Is)),en=ae?ae.startsWith("cursor:")||ae.startsWith("opencode:")||ae.startsWith("codex:")||ae.startsWith("claude-code:")?ae:Ee.has(ae)?`claude-code:${ae}`:Kt.has(ae)?`codex:${ae}`:it.has(ae)?`opencode:${ae}`:Ue.has(ae)?`cursor:${ae}`:ae:"",Ut=ae&&!en.startsWith("cursor:")&&!en.startsWith("opencode:")&&!en.startsWith("codex:")&&!en.startsWith("claude-code:")&&!Ue.has(ae)&&!it.has(ae)&&!Ee.has(ae)&&!Kt.has(ae),wt=ae.startsWith("cursor:")?ae.slice(7):ae.startsWith("opencode:")?ae.slice(9):ae.startsWith("codex:")?ae.slice(6):ae.startsWith("claude-code:")?ae.slice(12):ae,mn=le=>{if(g)return;const he=le.target.value;u&&u(n,he)},se=le=>{le.stopPropagation(),!g&&r&&r(n)},Ce=le=>{le.stopPropagation(),i&&i()},Ye=le=>{le.stopPropagation(),!g&&(o==null||o(n,le.target.value==="true"?"true":"false"))},ze=le=>{if(le.stopPropagation(),g)return;const he=le.target.value;Z(he),!p&&!K.current&&(o==null||o(n,he))},Nt=le=>{le.stopPropagation(),K.current=!0},St=le=>{if(le.stopPropagation(),g)return;K.current=!1;const he=le.currentTarget.value;Z(he),p||o==null||o(n,he)},Gn=()=>{g||p&&ie===B||o==null||o(n,ie)},Rn=le=>{if(le.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ie);return}const he=window.prompt("文件路径",ie);he!=null&&(Z(he),o==null||o(n,he))},Sr=le=>{le.stopPropagation(),fe(he=>!he)},rn=le=>{if(Oe(le),a==null||a(n,le),l){const he=RU(A,le);(he.length!==A.length||he.some((Je,st)=>{var Tt;return Je.id!==((Tt=A[st])==null?void 0:Tt.id)}))&&l(n,he)}},vn=le=>{if(le.stopPropagation(),g)return;const he=le.target.value;p||W.current?Oe(he):rn(he)},tr=le=>{le.stopPropagation(),!g&&(W.current=!0,Ne(!0))},ar=le=>{if(le.stopPropagation(),g)return;W.current=!1,Ne(!1);const he=le.currentTarget.value;p?Oe(he):rn(he)},fn=()=>{g||(W.current=!1,Ne(!1),!(p&&ge===F)&&rn(ge))},Sn=le=>{le.stopPropagation(),le.preventDefault(),!g&&Re(!0)},Ir=()=>{Re(!1),fn()},Gr=le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),Ir())},gn=m.useCallback(le=>{const he=ee.current;if(!he)return;const Je=Math.max(0,he.scrollHeight-he.clientHeight);he.scrollTop=Math.min(1,Math.max(0,le))*Je,lt()},[lt]),Hn=m.useCallback((le,he=0)=>{const Je=ne.current;if(!Je)return 0;const st=Je.getBoundingClientRect(),Tt=He.height/100*st.height,ue=Math.max(1,st.height-Tt);return(le-st.top-he)/ue},[He.height]),Dr=m.useCallback(le=>{var Rt,Pt;if(!He.visible)return;le.preventDefault(),le.stopPropagation();const he=ne.current;if(!he)return;const Je=he.getBoundingClientRect(),st=He.top/100*Je.height,Tt=He.height/100*Je.height,Te=le.clientY>=Je.top+st&&le.clientY<=Je.top+st+Tt?le.clientY-Je.top-st:Tt/2;gn(Hn(le.clientY,Te));const nt=le.pointerId;(Pt=(Rt=le.currentTarget).setPointerCapture)==null||Pt.call(Rt,nt);const gt=jn=>{jn.preventDefault(),gn(Hn(jn.clientY,Te))},Ve=()=>{window.removeEventListener("pointermove",gt),window.removeEventListener("pointerup",Ve),window.removeEventListener("pointercancel",Ve)};window.addEventListener("pointermove",gt),window.addEventListener("pointerup",Ve),window.addEventListener("pointercancel",Ve)},[Hn,He.height,He.top,He.visible,gn]),Yn=async le=>{if(g)return;const he=await VR({files:le,body:ge,images:A});he&&(Oe(he.body),a==null||a(n,he.body),l==null||l(n,he.images))},Vn=(le,he)=>{if(le.stopPropagation(),g)return;const Je=A.filter(Tt=>Tt.id!==he.id),st=DU(ge,he.label);Oe(st),a==null||a(n,st),l==null||l(n,Je)},pr=le=>{if(g)return;const he=HR(le);he.length!==0&&(le.preventDefault(),le.stopPropagation(),Yn(he).catch(()=>{}))},hr=le=>{if(g)return;const he=Id(le);he.length!==0&&(le.preventDefault(),le.stopPropagation(),Yn(he).catch(()=>{}))},Kn=()=>{const le=ee.current,he=G.current;!le||!he||(he.scrollTop=le.scrollTop,he.scrollLeft=le.scrollLeft)};return s.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(_==="success"?" af-flow-node--done":"")+(_==="failed"?" af-flow-node--failed":"")+(_==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+($?" af-flow-node--inline-body-editor":"")+(z?" af-flow-node--provide-text":"")+(O?" af-flow-node--provide-password":"")+" af-flow-node--"+y.replace(/[^a-z0-9_-]/g,""),"data-schema":y,children:[s.jsxs("div",{className:"af-flow-node__chrome",children:[s.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${R}${n?` (${n})`:""}${v?` · ${v}`:""}`,children:R}),!b&&ke&&s.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:ln,onMouseDown:ln,onClick:ln,children:[s.jsxs("select",{className:"af-flow-node__model nodrag",value:en,onChange:mn,onPointerDown:ln,onMouseDown:ln,onClick:ln,"aria-label":f("flow:node.model"),title:wt||f("flow:node.defaultModel"),disabled:g,children:[s.jsx("option",{value:"",children:f("flow:node.defaultModel")}),Ut&&s.jsx("option",{value:ae,children:ae}),kt.length>0&&s.jsx("optgroup",{label:"Cursor",children:kt.map(le=>s.jsx("option",{value:`cursor:${Is(le)}`,children:Is(le)},`c-${le}`))}),Ot.length>0&&s.jsx("optgroup",{label:"OpenCode",children:Ot.map(le=>s.jsx("option",{value:`opencode:${Is(le)}`,children:Is(le)},`o-${le}`))}),Xt.length>0&&s.jsx("optgroup",{label:"Codex",children:Xt.map(le=>s.jsx("option",{value:`codex:${Is(le)}`,children:Is(le)},`codex-${le}`))}),_t.length>0&&s.jsx("optgroup",{label:"Claude Code",children:_t.map(le=>s.jsx("option",{value:`claude-code:${Is(le)}`,children:Is(le)},`cc-${le}`))})]}),s.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),_==="running"&&!k&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),_==="success"&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:S!=null&&String(S).trim()!==""?S:"--"}),_==="failed"&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!b&&I&&!T&&!z&&!E&&!O&&s.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Ce,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!b&&s.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:g,onClick:se,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-flow-node__body",children:[s.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:d.map((le,he)=>{if(le.showOnNode===!1)return null;const Je=f("flow:node.inputTooltip",{name:le.name||`#${he}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),st=le.name||`#${he+1}`;return s.jsxs("div",{className:"af-flow-node__port-row",title:Je,children:[s.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[st,le.required?s.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${he}`,className:"af-flow-node__handle",style:{background:zn(le.type)},title:Je})]},`in-${he}`)})}),s.jsxs("div",{className:"af-flow-node__title-wrap",children:[T?s.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(V?" af-flow-node__bool-select--true":""),value:V?"true":"false",onChange:Ye,onPointerDown:ln,onMouseDown:ln,onClick:ln,"aria-label":"Boolean value",title:V?"true":"false",disabled:g,children:[s.jsx("option",{value:"false",children:"false"}),s.jsx("option",{value:"true",children:"true"})]}):z?s.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ie,onChange:ze,onCompositionStart:Nt,onCompositionEnd:St,onBlur:Gn,onPointerDown:ln,onMouseDown:ln,onClick:ln,placeholder:"输入文本",rows:2,readOnly:g}):E?s.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:ln,onMouseDown:ln,onClick:ln,children:[s.jsx("input",{className:"af-flow-node__file-input nodrag",value:ie,onChange:ze,onCompositionStart:Nt,onCompositionEnd:St,onBlur:Gn,placeholder:"选择或输入文件路径",title:ie||"选择或输入文件路径",readOnly:g}),s.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:Rn,"aria-label":"选择文件",title:"选择文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):O?s.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:ln,onMouseDown:ln,onClick:ln,children:[s.jsx("input",{className:"af-flow-node__password-input nodrag",type:de?"text":"password",value:ie,onChange:ze,onCompositionStart:Nt,onCompositionEnd:St,onBlur:Gn,placeholder:"输入密码或密钥",title:de?ie:"密码已隐藏",autoComplete:"off",readOnly:g}),s.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:Sr,"aria-label":de?"隐藏密码":"预览密码",title:de?"隐藏密码":"预览密码",children:s.jsx("span",{className:"material-symbols-outlined",children:de?"visibility_off":"visibility"})})]}):$?s.jsxs("div",{ref:te,className:"af-flow-node__prompt-stack nodrag"+(_e?" af-flow-node__prompt-stack--composing":""),children:[s.jsx("pre",{ref:G,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:FU(ge)+`
|
|
99
|
+
`}}),s.jsx("textarea",{ref:ee,className:"af-flow-node__prompt-editor nodrag",value:ge,onChange:vn,onCompositionStart:tr,onCompositionEnd:ar,onBlur:fn,onPaste:pr,onDrop:hr,onScroll:le=>{Kn(),lt()},onPointerDown:ln,onMouseDown:ln,onClick:ln,onKeyDown:ln,onDragOver:le=>{Id(le).length>0&&le.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&s.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:ln,onMouseDown:ln,onClick:Sn,"aria-label":"放大编辑",title:"放大编辑",children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),s.jsx("div",{ref:ne,className:"af-flow-node__prompt-scrollbar"+(He.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:Dr,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${He.height}%`,top:`${He.top}%`}})})]}):null,$&&A.length>0?s.jsx("div",{className:"af-flow-node__image-chips",children:A.map((le,he)=>s.jsxs("span",{className:"af-flow-node__image-chip",title:le.name,children:[s.jsx("img",{src:le.dataUrl,alt:""}),s.jsxs("span",{children:["[",le.label||`image ${he+1}`,"]"]}),s.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:Je=>Vn(Je,le),onPointerDown:ln,onMouseDown:ln,"aria-label":`删除 ${le.label||`image ${he+1}`}`,title:"删除图片",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},le.id||he))}):null,H?s.jsx("span",{className:"af-flow-node__prompt-preview",title:H,children:H}):null,X?null:s.jsx("span",{className:"af-flow-node__body-title",title:R,children:R})]}),s.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:h.map((le,he)=>{if(le.showOnNode===!1)return null;const Je=f("flow:node.outputTooltip",{name:le.name||`#${he}`,type:le.type})+(le.default!=null&&le.default!==""?f("flow:node.defaultSuffix",{value:le.default}):""),st=le.name||`#${he+1}`;return s.jsxs("div",{className:"af-flow-node__port-row",title:Je,children:[s.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[st,le.required?s.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${he}`,className:"af-flow-node__handle",style:{background:zn(le.type)},title:Je})]},`out-${he}`)})})]}),xt?ur.createPortal(s.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:ln,onMouseDown:ln,onClick:ln,onWheel:ln,children:s.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[s.jsxs("div",{className:"af-flow-node-full-editor__header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-flow-node-full-editor__title",children:R}),s.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),s.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:Ir,"aria-label":"关闭",title:"关闭",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx("textarea",{ref:re,className:"af-flow-node-full-editor__textarea",value:ge,onChange:vn,onCompositionStart:tr,onCompositionEnd:ar,onPaste:pr,onDrop:hr,onKeyDown:Gr,onDragOver:le=>{Id(le).length>0&&le.preventDefault()},placeholder:L?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const Ec="flowNode";function vb(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 BU={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 HU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),i=String(t||"").trim();return!r||!i||r===i?i:(BU[e]||[]).includes(i)?r:i}const VU={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"])},KU={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"])},qU={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},UU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function GU(e,t){if(!UU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function YU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function JU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function KR(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function XU(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 QU(e){const t=String(e??"").trim();return t?t.includes("${")?t:KR(t):""}function ZU(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(/\/+$/,""),i=r?`${r}/${n}`:`\${flowDir}/${n}`,o=Array.isArray(t.args)?t.args.map(QU).filter(Boolean):[];return[XU(t,n),KR(i),...o].join(" ")}return String(t.command||"").trim()}function S_(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,i)=>{var u,p,f;const o=n[i],l=n.find(d=>(d==null?void 0:d.name)&&d.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=VU[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&&GU(e,r)?{showOnNode:!0}:{},...(p=qU[e])!=null&&p.has(r.name)?{showOnNode:!0}:{},...(f=KU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function eG(e){var i,o;const t=Array.isArray((i=e==null?void 0:e.data)==null?void 0:i.inputs)?e.data.inputs:[],n=Array.isArray((o=e==null?void 0:e.data)==null?void 0:o.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=vb(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,description:String(c.description??""),showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function Sb(e,t,n,r,i){var R,H,A,X,K,W,te,ee,G,ne,re,ie,Z,de,fe,ge,Oe,_e,Ne,He,ct,xt;const o=((R=e.data)==null?void 0:R.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Re=>Re.id===o),l=t[e.id];let c=[],u=[],p=((H=e.data)==null?void 0:H.label)??e.id,f,d,h,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(vb)),Array.isArray(l.output)&&(u=l.output.map(vb)),l.label&&(p=String(l.label)),l.role&&typeof l.role=="string"&&(f=l.role),l.model!=null&&(d=String(l.model).trim()),l.body!=null&&(h=String(l.body)),Array.isArray(l.images)&&(y=l.images),l.script!=null&&(v=String(l.script)));const g=f??(typeof((A=e.data)==null?void 0:A.role)=="string"?e.data.role:"普通"),k=d??((X=e.data)==null?void 0:X.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",_=x!==""?x:void 0,S=h??((K=e.data)==null?void 0:K.body)??"",N=Array.isArray(y)?y:Array.isArray((W=e.data)==null?void 0:W.images)?e.data.images:[],I=ZU(a),T=v!==void 0?v:((te=e.data)==null?void 0:te.script)!=null?String(e.data.script):I,z=String(e.id),E=(ee=r==null?void 0:r[i])==null?void 0:ee[z],O=(G=E==null?void 0:E.label)==null?void 0:G.label,D=E==null?void 0:E.body,L=E==null?void 0:E.description;b||(c.length===0&&((ne=a==null?void 0:a.inputs)!=null&&ne.length)&&(c=a.inputs.map(Re=>({...Re}))),u.length===0&&((re=a==null?void 0:a.outputs)!=null&&re.length)&&(u=a.outputs.map(Re=>({...Re}))));const $=JU(a,(a==null?void 0:a.id)??o),V=(l==null?void 0:l.marketplaceRef)||((ie=e.data)==null?void 0:ie.marketplaceRef)||YU(a);if($==="agent_subAgent"&&!u.some(Re=>(Re==null?void 0:Re.name)==="result")){const Re=(Z=a==null?void 0:a.outputs)==null?void 0:Z.find(lt=>(lt==null?void 0:lt.name)==="result");u=[...u,Re?{...Re}:{type:"text",name:"result",default:""}]}if($==="agent_subAgent"&&!c.some(Re=>(Re==null?void 0:Re.name)==="knowledgeContext")){const Re=(de=a==null?void 0:a.inputs)==null?void 0:de.find(lt=>(lt==null?void 0:lt.name)==="knowledgeContext");c=[...c,Re?{...Re}:{type:"text",name:"knowledgeContext",default:"",showOnNode:!0}]}if(($==="display_markdown"||$==="display_mermaid"||$==="display_ascii"||$==="display_chart"||$==="display_table")&&!u.some(Re=>(Re==null?void 0:Re.name)==="next")){const Re=(fe=a==null?void 0:a.outputs)==null?void 0:fe.find(lt=>(lt==null?void 0:lt.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}if($==="workspace_run"){if(!c.some(Re=>(Re==null?void 0:Re.name)==="prev")){const Re=(ge=a==null?void 0:a.inputs)==null?void 0:ge.find(lt=>(lt==null?void 0:lt.name)==="prev");c=[Re?{...Re}:{type:"node",name:"prev",default:""},...c]}if(!u.some(Re=>(Re==null?void 0:Re.name)==="next")){const Re=(Oe=a==null?void 0:a.outputs)==null?void 0:Oe.find(lt=>(lt==null?void 0:lt.name)==="next");u=[...u,Re?{...Re}:{type:"node",name:"next",default:""}]}}c=S_($,c,a==null?void 0:a.inputs),u=S_($,u,a==null?void 0:a.outputs),$.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(S).trim()!==""&&(u=u.map((Re,lt)=>lt===0?{...Re,default:S,value:S}:Re));const B=HU($,p,a),F=$==="tool_nodejs"||String(T).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:O||p,displayLabel:B,definitionDisplayName:a==null?void 0:a.displayName,definitionId:$,...V?{marketplaceRef:V}:{},...l!=null&&l.marketplacePackageId||(_e=e.data)!=null&&_e.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((Ne=e.data)==null?void 0:Ne.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(He=e.data)!=null&&He.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((ct=e.data)==null?void 0:ct.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((xt=e.data)==null?void 0:xt.schemaType)??e.type??"agent",role:g,model:k,body:D||S,images:N,script:T,inputs:c,outputs:u,description:L||_,originalLabel:p,originalBody:S,...F?{script:T}:{}}}}function tG(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var p,f,d,h;const i=n.get(r.source),o=n.get(r.target),a=((f=(p=i==null?void 0:i.data)==null?void 0:p.outputs)==null?void 0:f.length)??0,l=((h=(d=o==null?void 0:o.data)==null?void 0:d.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 i&&o&&c>=0&&c<a&&u>=0&&u<l})}function j_(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 N_(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function bw(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 i=j_(t==null?void 0:t.sourceHandle,"output"),o=j_(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,p,f,d;if(c.id===n){const h=N_((u=c.data)==null?void 0:u.outputs,i);if(h!==((p=c.data)==null?void 0:p.outputs))return a=!0,{...c,data:{...c.data,outputs:h}}}if(c.id===r){const h=N_((f=c.data)==null?void 0:f.inputs,o);if(h!==((d=c.data)==null?void 0:d.inputs))return a=!0,{...c,data:{...c.data,inputs:h}}}return c});return a?l:e}function nG(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 __(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function rG(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function sG({children:e}){return s.jsx("kbd",{className:"af-kbd",children:e})}function ei({keys:e}){return s.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>s.jsxs("span",{children:[n>0?s.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,s.jsx(sG,{children:t})]},n))})}function iG({open:e,onClose:t}){const{t:n}=Ur(),r=m.useRef(null);if(m.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const o=rG()?"⌘":"Ctrl";return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:s.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:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-shortcuts-panel__body",children:[s.jsxs("section",{className:"af-shortcuts-section",children:[s.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),s.jsxs("ul",{className:"af-shortcuts-list",children:[s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),s.jsx(ei,{keys:[o,"S"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),s.jsx(ei,{keys:["?"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),s.jsx(ei,{keys:[o,"K"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),s.jsx(ei,{keys:["A"]})]})]})]}),s.jsxs("section",{className:"af-shortcuts-section",children:[s.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),s.jsxs("ul",{className:"af-shortcuts-list",children:[s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),s.jsx(ei,{keys:["V"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),s.jsx(ei,{keys:["H"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),s.jsx(ei,{keys:["Space"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),s.jsx(ei,{keys:["F"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),s.jsx(ei,{keys:[o,"A"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),s.jsx(ei,{keys:[o,"Z"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),s.jsx(ei,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function oG(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),i=(e.label||"").toLowerCase(),o=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:i.startsWith(n)?40:i.includes(n)?30:o.includes(n)?15:0}function aG({open:e,onClose:t,onJump:n,nodes:r}){const{t:i}=Ur(),[o,a]=m.useState(""),[l,c]=m.useState(0),u=m.useRef(null),p=m.useRef(null);m.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var v;return(v=u.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e]);const f=m.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,_;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((_=g.data)==null?void 0:_.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:oG(g,v)})).filter(g=>g.s>0);return b.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),b.slice(0,50).map(g=>g.e)},[r,o]);if(m.useEffect(()=>{l>=f.length&&c(0)},[f.length,l]),m.useEffect(()=>{var v;const y=(v=p.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const d=y=>{const v=f[y];v&&(n(v.id),t())},h=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(v=>Math.min(f.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),d(l))};return s.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:s.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":i("flow:jumpPalette.title"),onMouseDown:y=>y.stopPropagation(),children:[s.jsxs("div",{className:"af-jump-panel__input-wrap",children:[s.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{ref:u,type:"text",className:"af-jump-panel__input",placeholder:i("flow:jumpPalette.placeholder"),value:o,onChange:y=>{a(y.target.value),c(0)},onKeyDown:h,spellCheck:!1,autoComplete:"off"}),s.jsx("span",{className:"af-jump-panel__count",children:f.length})]}),f.length===0?s.jsx("div",{className:"af-jump-panel__empty",children:i("flow:jumpPalette.empty")}):s.jsx("ul",{ref:p,className:"af-jump-panel__list",role:"listbox",children:f.map((y,v)=>s.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(v),onMouseDown:b=>{b.preventDefault(),d(v)},children:[s.jsx("span",{className:"af-jump-panel__id",children:y.id}),y.label&&y.label!==y.id&&s.jsx("span",{className:"af-jump-panel__label",children:y.label}),y.definitionId&&s.jsx("span",{className:"af-jump-panel__tag",children:y.definitionId})]},y.id))}),s.jsxs("div",{className:"af-jump-panel__hint",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"af-kbd",children:"↑"}),s.jsx("kbd",{className:"af-kbd",children:"↓"})," ",i("flow:jumpPalette.hintNavigate")]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",i("flow:jumpPalette.hintJump")]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",i("flow:jumpPalette.hintClose")]})]})]})})}function C_(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=i=>String(i).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function lG(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),i=n%60;return`${r}m${String(i).padStart(2,"0")}s`}function A_(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 kw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function E_(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 cG({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:i="",onClose:o}){const[a,l]=m.useState([]),[c,u]=m.useState(""),[p,f]=m.useState(null),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),_=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const T=new URLSearchParams;T.set("flowId",e.flowId),T.set("flowSource",e.flowSource||"user"),t?T.set("scheduleNodeId",t):n&&T.set("runNodeId",n),T.set("limit","80");const z=await fetch(`/api/workspace/run-logs?${T.toString()}`),E=await z.json().catch(()=>({}));if(!z.ok)throw new Error(E.error||"读取日志失败");const O=Array.isArray(E.runs)?E.runs:[];l(O),u(D=>{const L=O[0]||null;return L&&String(L.status||"")==="running"&&L.runId!==D?L.runId:D&&O.some($=>$.runId===D)?D:r&&O.some($=>$.runId===r)?r:(L==null?void 0:L.runId)||""})}catch(T){g(String(T.message||T)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),S=m.useCallback(async T=>{if(!T){f(null);return}v(!0);try{const z=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&z.set("archived","1");const E=await fetch(`/api/workspace/run-logs/${encodeURIComponent(T)}?${z.toString()}`),O=await E.json().catch(()=>({}));if(!E.ok)throw new Error(O.error||"读取日志详情失败");f(O)}catch(z){f({error:String(z.message||z),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{_()},[_]),m.useEffect(()=>{S(c)},[S,c]),m.useEffect(()=>{const T=a.find(E=>E.runId===c),z=window.setInterval(()=>{_(),(!T||T.status==="running")&&c&&S(c)},2e3);return()=>window.clearInterval(z)},[S,_,a,c]);const N=m.useMemo(()=>{const T=Array.isArray(p==null?void 0:p.events)?p.events:[],z=k.trim().toLowerCase();return z?T.filter(E=>String(E.type||"").toLowerCase().includes(z)||kw(E).toLowerCase().includes(z)||A_(E).toLowerCase().includes(z)):T},[p==null?void 0:p.events,k]),I=(p==null?void 0:p.run)||a.find(T=>T.runId===c)||null;return s.jsxs("div",{className:"af-work-run-logs",children:[s.jsxs("div",{className:"af-pipeline-drawer-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),s.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:o,"aria-label":"关闭日志侧栏",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-run-logs__meta",children:[s.jsx("span",{children:i||t||n||"Workspace Run"}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void _(),title:"刷新日志","aria-label":"刷新日志",children:s.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),b?s.jsx("div",{className:"af-work-run-logs__error",children:b}):null,s.jsxs("div",{className:"af-work-run-logs__body",children:[s.jsxs("div",{className:"af-work-run-logs__list",children:[s.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),d?s.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!d&&a.length===0?s.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(T=>s.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(T.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(T.runId),title:T.runId,children:[s.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${E_(T.status)}`,children:T.status||"unknown"}),s.jsx("span",{className:"af-work-run-logs__run-label",children:T.label||T.runNodeId||T.scheduleNodeId||"Workspace Run"}),s.jsx("span",{children:C_(T.startedAt)}),s.jsx("span",{children:lG(T.durationMs)})]},T.runId))]}),s.jsxs("div",{className:"af-work-run-logs__detail",children:[s.jsxs("div",{className:"af-work-run-logs__detail-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),I!=null&&I.label?s.jsx("div",{className:"af-work-run-logs__detail-label",children:I.label}):null,s.jsx("div",{className:"af-work-run-logs__run-id",children:(I==null?void 0:I.runId)||"-"})]}),I?s.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${E_(I.status)}`,children:I.status}):null]}),s.jsxs("label",{className:"af-work-run-logs__search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{value:k,onChange:T=>x(T.target.value),placeholder:"搜索事件、节点、错误"})]}),y?s.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,p!=null&&p.error?s.jsx("div",{className:"af-work-run-logs__error",children:p.error}):null,!y&&!N.length?s.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,s.jsx("div",{className:"af-work-run-logs__events",children:N.map((T,z)=>s.jsxs("div",{className:"af-work-run-logs__event",children:[s.jsx("span",{className:"af-work-run-logs__event-time",children:C_(T.ts)}),s.jsx("span",{className:"af-work-run-logs__event-type",children:T.type||"event"}),kw(T)?s.jsx("span",{className:"af-work-run-logs__event-node",children:kw(T)}):null,s.jsx("pre",{children:A_(T)})]},`${T.ts||z}-${z}`))})]})]})]})}function uG(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 qR(e){const t=uG(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(([i,o])=>[String(i),String(o??"")])),packageJson:n.packageJson&&typeof n.packageJson=="object"?n.packageJson:null,inputs:n.inputs&&typeof n.inputs=="object"&&!Array.isArray(n.inputs)?n.inputs:{}}}}catch{}return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":t},inputs:{}}}function dG(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 fG(e){return String(e).replace(/<\/script/gi,"<\\/script")}function jg(e){const t=qR(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 Av(e,t=""){const n=qR(e),r=n.files||{},i=r[n.entry]!=null?n.entry:Object.keys(r).find(d=>/(?:^|\/)App\.[jt]sx$/i.test(d))||Object.keys(r).find(d=>/\.[jt]sx?$/i.test(d))||n.entry,o=dG(r[i]||""),a=Object.entries(r).filter(([d])=>/\.css$/i.test(d)).map(([,d])=>String(d||"")).join(`
|
|
101
|
+
|
|
102
|
+
`),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),p=fG(o||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),f=a||`
|
|
103
|
+
* { box-sizing: border-box; }
|
|
104
|
+
body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
105
|
+
main { min-height: 100vh; padding: 24px; }
|
|
106
|
+
button, input, select, textarea { font: inherit; }
|
|
107
|
+
`;return`<!doctype html>
|
|
108
|
+
<html>
|
|
109
|
+
<head>
|
|
110
|
+
<meta charset="utf-8" />
|
|
111
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
112
|
+
<base target="_blank" />
|
|
113
|
+
<title>${l.replace(/[<&>]/g,d=>({"<":"<",">":">","&":"&"})[d])}</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) => ({'<':'<','>':'>','&':'&'}[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
|
+
${p}
|
|
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 UR=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),pG=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function hG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const i=n.slice(r+2);return i.includes("}")?null:{atIndex:r,query:i}}function mG(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 I_(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 GR(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const i=r.slice(6).trim();return i!==""&&t.has(i)}if(r.startsWith("output.")){const i=r.slice(7).trim();return i!==""&&n.has(i)}if(UR.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const i=`${r}.md`;if(t.has(i)||n.has(i))return!0}return!1}function YR(e){return{inputNames:I_(e==null?void 0:e.inputs),outputNames:I_(e==null?void 0:e.outputs)}}function gG(e,t,n){const r=YR(t),i=mG(e),o=[];for(const a of i)if(!GR(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function yG(e,t){const n=YR(t),r=/\$\{([^}]*)\}/g,i=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&i.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=GR(a[1],n);i.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&i.push({kind:"plain",text:e.slice(o)}),i}function wG(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xG(e){return e.map(t=>{const n=wG(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 bG(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const i=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!i)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${i}`,label:i,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const i=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!i)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${i}`,label:i,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of pG)UR.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function kG(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function vG(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),i=document.createElement("div");i.setAttribute("aria-hidden","true"),i.style.visibility="hidden",i.style.position="fixed",i.style.top="0",i.style.left="-99999px",i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word",i.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;i.style.width=`${o}px`,i.style.font=r.font,i.style.lineHeight=r.lineHeight,i.style.padding=r.padding,i.style.border=r.border,i.style.boxSizing=r.boxSizing,i.style.letterSpacing=r.letterSpacing,i.style.textIndent=r.textIndent,i.style.tabSize=r.tabSize||"8",i.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="",i.appendChild(a),document.body.appendChild(i);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(i),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function Up({value:e,onChange:t,disabled:n,placeholder:r,rows:i=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:p}=Ur(),f=m.useId(),d=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),_=m.useMemo(()=>vo(c),[c]),S=m.useMemo(()=>gG(e,a,p),[e,a,p]),N=S.length>0,I=m.useMemo(()=>yG(e,a),[e,a]),T=m.useMemo(()=>xG(I),[I]),z=m.useMemo(()=>n?null:hG(e,y),[e,y,n]),E=m.useMemo(()=>{if(!z)return[];const B=bG(a,p);return kG(B,z.query)},[z,a,p]);m.useEffect(()=>{g(B=>{const F=Math.max(0,E.length-1);return Math.min(Math.max(0,B),F)})},[E.length]);const O=m.useCallback(()=>{const B=d.current;if(!B||!z||E.length===0){x(null);return}const F=vG(B,y);if(!F){x(null);return}const R=4,H=44,A=13.5*16,X=Math.min(E.length*H+8,A);let K=F.bottom+R;K+X>window.innerHeight-8&&(K=Math.max(8,F.top-X-R));const W=288;let te=F.left;te=Math.max(8,Math.min(te,window.innerWidth-W-8)),x({top:K,left:te})},[z,E.length,y]);m.useLayoutEffect(()=>{if(!z||E.length===0){x(null);return}const B=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(B)},[z,E.length,y,e,O]),m.useEffect(()=>{if(!z||E.length===0)return;const B=()=>O();return window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}},[z,E.length,O]);const D=m.useCallback(B=>{if(!z)return;const{atIndex:F}=z,R=e.slice(0,F)+"${"+B+"}"+e.slice(y);t(R);const H=F+B.length+3;queueMicrotask(()=>{const A=d.current;A&&(A.focus(),A.setSelectionRange(H,H)),v(H)})},[z,e,y,t]),L=m.useCallback(()=>{const B=d.current,F=h.current;!B||!F||(F.scrollTop=B.scrollTop,F.scrollLeft=B.scrollLeft,z&&E.length>0&&queueMicrotask(()=>O()))},[z,E.length,O]),$=m.useCallback(B=>{if(!n&&z&&E.length>0&&(B.key==="ArrowDown"||B.key==="ArrowUp"||B.key==="Enter")){if(B.key==="ArrowDown")B.preventDefault(),g(F=>(F+1)%E.length);else if(B.key==="ArrowUp")B.preventDefault(),g(F=>(F-1+E.length)%E.length);else if(B.key==="Enter"&&!B.shiftKey){B.preventDefault();const F=E[b];F&&D(F.insert)}}},[n,z,E,b,D]),V=m.useCallback(async B=>{if(n||typeof u!="function")return!1;const F=await VR({files:B,body:e,images:_});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const R=d.current;if(!R)return;R.focus();const H=F.body.length;R.setSelectionRange(H,H),v(H)}),!0):!1},[n,_,t,u,e]);return s.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[_.length>0?s.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:_.map((B,F)=>s.jsxs("span",{className:"af-body-image-chip",title:B.name,children:[s.jsx("img",{src:B.dataUrl,alt:""}),s.jsxs("span",{children:["[",B.label||`image ${F+1}`,"]"]})]},B.id||F))}):null,s.jsxs("div",{className:"af-body-prompt-stack",children:[s.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:T+`
|
|
182
|
+
`}}),s.jsx("textarea",{ref:d,className:"af-body-prompt-textarea "+o,rows:i,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?f:void 0,onChange:B=>{t(B.target.value),v(B.target.selectionStart??B.target.value.length)},onSelect:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:B=>{const F=B.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:$,onPaste:B=>{const F=HR(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onDragOver:B=>{Id(B).length>0&&B.preventDefault()},onDrop:B=>{const F=Id(B);F.length!==0&&(B.preventDefault(),V(F).catch(()=>{}))},onScroll:L})]}),z&&E.length>0&&k?ur.createPortal(s.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:E.map((B,F)=>s.jsx("li",{role:"option","aria-selected":F===b,children:s.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===b?" af-composer-mention-item--active":""),onMouseDown:R=>R.preventDefault(),onMouseEnter:()=>g(F),onClick:()=>D(B.insert),children:[s.jsx("span",{className:"af-composer-mention-id",children:`\${${B.insert}}`}),B.subtitle?s.jsx("span",{className:"af-composer-mention-sub",children:B.subtitle}):null]})},`${B.section}-${B.insert}`))}),document.body):null,N?s.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:S.map(B=>B.message).join(" · ")}):null]})}const SG=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Gu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function P_({kind:e,label:t,slots:n,onSlotsChange:r,disabled:i,requiredReadonly:o=!0}){const{t:a}=Ur(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((d,h)=>h!==f)),u=(f,d,h)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[d]:h};return d==="required"&&h===!0&&(g.showOnNode=!0),g});r(y)},p=e==="input"?"input":"output";return s.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[s.jsxs("div",{className:"af-node-props-io-head",children:[s.jsx("span",{className:"af-node-props-label",children:t}),s.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:i,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),s.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?s.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?s.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[s.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[s.jsx("span",{children:a("flow:nodeProps.handle")}),s.jsx("span",{children:a("flow:nodeProps.type")}),s.jsx("span",{children:a("flow:nodeProps.name")}),s.jsx("span",{children:a("flow:nodeProps.defaultValue")}),s.jsx("span",{children:a("flow:nodeProps.description")}),s.jsx("span",{children:a("flow:nodeProps.required")}),s.jsx("span",{children:a("flow:nodeProps.showOnNode")}),s.jsx("span",{})]}),n.map((f,d)=>s.jsxs("div",{className:"af-node-props-io-row",children:[s.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${d}`,children:[p,"-",d]}),s.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(d,"type",h.target.value),disabled:i,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:d}),children:["node","text","file","bool"].map(h=>s.jsx("option",{value:h,children:h},h))}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>u(d,"name",h.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:d})}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>u(d,"default",h.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:d})}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(d,"description",h.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:d})}),s.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:s.jsx("input",{type:"checkbox",checked:!!f.required,onChange:h=>{o||u(d,"required",h.target.checked)},disabled:i||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:d})})}),s.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:s.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:h=>u(d,"showOnNode",h.target.checked),disabled:i,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:d})})}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(d),disabled:i,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:d}),title:a("flow:nodeProps.deletePin"),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${d}`))]}):null]})}function jG({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:i,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:p,ioSlots:f}){const{t:d}=Ur(),[h,y]=m.useState(!1),[v,b]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),x=m.useCallback(L=>{t($=>$&&{...$,...L})},[t]),{cursorList:_,opencodeList:S,claudeCodeList:N,codexList:I,currentNotInLists:T}=m.useMemo(()=>{const L=Array.isArray(i==null?void 0:i.cursor)?i.cursor:[],$=Array.isArray(i==null?void 0:i.opencode)?i.opencode:[],V=Array.isArray(i==null?void 0:i.claudeCode)?i.claudeCode:[],B=Array.isArray(i==null?void 0:i.codex)?i.codex:[],F=new Set([...L,...$,...V,...B].map(Gu)),R=((e==null?void 0:e.model)??"").trim(),H=R.startsWith("cursor:")?R.slice(7):R.startsWith("opencode:")?R.slice(9):R.startsWith("codex:")?R.slice(6):R.startsWith("claude-code:")?R.slice(12):R,A=R&&!F.has(H)?R:"";return{cursorList:L,opencodeList:$,claudeCodeList:V,codexList:B,currentNotInLists:A}},[i,e==null?void 0:e.model]);if(!e)return null;const z=String(e.script??""),E=n==="tool_nodejs"||z.trim()!=="",O=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(O){k({status:"running",message:d("flow:nodeProps.publishRunning")});try{const L=await c(e,n);k({status:"success",message:L!=null&&L.definitionId?d("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):d("flow:nodeProps.publishSuccess")})}catch(L){k({status:"error",message:String((L==null?void 0:L.message)||L)})}}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:d("flow:nodeProps.title")}),s.jsxs("div",{className:"af-node-props-head-actions",children:[s.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!O||g.status==="running",title:d("flow:nodeProps.publishToMarketplaceHint"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?d("flow:nodeProps.publishing"):d("flow:nodeProps.publishToMarketplace")]}),s.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:d("common:common.close")})]})]}),s.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?s.jsx("p",{className:"af-err af-node-props-err",children:p}):null,g.message?s.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.nodeType")}),s.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:nodeProps.instanceId"),s.jsx("span",{className:"af-node-props-hint",children:d("flow:node.displayNameHint")})]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:L=>x({newId:L.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":d("flow:nodeProps.instanceId")})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.displayName"),"(LABEL)"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:L=>x({label:L.target.value}),disabled:o,spellCheck:!1})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.role"),"(ROLE)"]}),s.jsx("select",{className:"af-node-props-select",value:lf.includes(e.role)?e.role:d("flow:roles.normal"),onChange:L=>x({role:L.target.value}),disabled:o,children:lf.map(L=>s.jsx("option",{value:L,children:L},L))})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.model"),"(MODEL)"]}),s.jsx("span",{className:"af-node-props-sublabel",children:d("flow:node.modelHint")}),s.jsxs("select",{className:"af-node-props-select",value:(()=>{const L=(e.model||"").trim();return L?T||L:""})(),onChange:L=>x({model:L.target.value}),disabled:o,"aria-label":d("flow:nodeProps.modelAriaLabel"),children:[s.jsx("option",{value:"",children:d("flow:node.defaultModel")}),T?s.jsxs("option",{value:T,children:[T,d("flow:nodeProps.yamlValueNotInList")]}):null,_.length>0?s.jsx("optgroup",{label:"Cursor",children:_.map(L=>s.jsx("option",{value:Gu(L),children:L},`c-${L}`))}):null,S.length>0?s.jsx("optgroup",{label:"OpenCode",children:S.map(L=>s.jsx("option",{value:`opencode:${Gu(L)}`,children:L},`o-${L}`))}):null,I.length>0?s.jsx("optgroup",{label:"Codex",children:I.map(L=>s.jsx("option",{value:`codex:${Gu(L)}`,children:L},`codex-${L}`))}):null,N.length>0?s.jsx("optgroup",{label:"Claude Code",children:N.map(L=>s.jsx("option",{value:`claude-code:${Gu(L)}`,children:L},`cc-${L}`))}):null]})]}),s.jsx(P_,{kind:"input",label:d("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>x({inputs:L}),disabled:o,requiredReadonly:!u}),s.jsx(P_,{kind:"output",label:d("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>x({outputs:L}),disabled:o,requiredReadonly:!u}),E?s.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[s.jsxs("div",{className:"af-node-props-prompt-head",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.directCommand"),"(script)",s.jsx("span",{className:"af-node-props-hint",children:d("flow:node.scriptHint")})]}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":d("flow:nodeProps.expandEditScript"),title:d("flow:nodeProps.expand"),disabled:o,children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),s.jsx(Up,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:d("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,s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),s.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:L=>x({scriptRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),s.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:L=>x({implementationRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),s.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:L=>x({implementationMode:L.target.value}),disabled:o,children:[s.jsx("option",{value:"",children:"auto"}),s.jsx("option",{value:"script",children:"script"}),s.jsx("option",{value:"steps",children:"steps"}),s.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),s.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[s.jsxs("div",{className:"af-node-props-prompt-head",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.userPrompt")}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":d("flow:nodeProps.expandEdit"),title:d("flow:nodeProps.expand"),disabled:o,children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),s.jsx(Up,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.systemDescription")}),s.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||d("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?s.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editScript"),onMouseDown:L=>{L.target===L.currentTarget&&b(!1)},children:s.jsxs("div",{className:"af-node-props-expand-panel",children:[s.jsxs("div",{className:"af-node-props-expand-head",children:[s.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.directCommand")}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":d("flow:nodeProps.collapse"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx(Up,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?s.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&y(!1)},children:s.jsxs("div",{className:"af-node-props-expand-panel",children:[s.jsxs("div",{className:"af-node-props-expand-head",children:[s.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.body")}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":d("flow:nodeProps.collapse"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx(Up,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function NG({open:e,onClose:t,flowId:n,flowSource:r,onArchived:i}){const{t:o}=Ur(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||p)){f(!0),h("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){h(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}i()}catch(k){h(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:s.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),s.jsxs("label",{className:"af-new-pipeline-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),s.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),d?s.jsx("p",{className:"af-err af-new-pipeline-err",children:d}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:o("project:archiveModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||p,children:o(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function _G({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:i=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=Ur(),u=m.useId(),p=m.useRef(null),[f,d]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;d(""),b(""),y(!1);const _=requestAnimationFrame(()=>{var S;return(S=p.current)==null?void 0:S.focus()});return()=>cancelAnimationFrame(_)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(_){if(_.preventDefault(),!k||h)return;y(!0),b("");let S=null;try{const N=new AbortController;S=setTimeout(()=>N.abort(),15e3);const I=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:i,workspaceId:o}),signal:N.signal}),T=await I.json().catch(()=>({}));if(!I.ok){b(typeof T.error=="string"?T.error:c("project:deleteModal.deleteFailed"));return}try{for(let z=localStorage.length-1;z>=0;z--){const E=localStorage.key(z);E&&(E.startsWith(`af:composer-sessions:${n}:${r}`)||E.startsWith(`af:composer-active-session:${n}:${r}`)||E.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(E)}}catch{}await l()}catch(N){if((N==null?void 0:N.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((N==null?void 0:N.message)||N))}finally{S&&clearTimeout(S),y(!1)}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&t()},children:s.jsxs("div",{ref:p,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:x,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:s.jsxs("label",{className:"af-new-pipeline-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),s.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:_=>d(_.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?s.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const T_=80,CG=220;function AG(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:i,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function EG(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Gp(e,t,n){const r={nodes:Array.isArray(e)?e.map(AG):[],edges:Array.isArray(t)?t.map(EG):[],extra:n&&typeof n=="object"?n:{}},i=JSON.stringify(r);return{value:JSON.parse(i),signature:i}}function vw(e,t){const n=[...e,t];return n.length>T_?n.slice(n.length-T_):n}function IG({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:i}){const[o,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),p=m.useRef(null),f=m.useRef(null),d=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(S=>S+1),[]),v=m.useCallback(()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},[]),b=m.useCallback(()=>{v();const S=p.current,N=f.current;return p.current=null,f.current=null,!S||!N||S.signature===N.signature?(N&&(u.current=N),!1):(l.current=vw(l.current,S),c.current=[],u.current=N,y(),!0)},[y,v]),g=m.useCallback((S=[],N=[],I={})=>{v(),l.current=[],c.current=[],p.current=null,f.current=null,u.current=Gp(S,N,I),h.current=!1,y()},[y,v]),k=m.useCallback(S=>{h.current=!0,u.current=S,p.current=null,f.current=null,v(),i==null||i(S.value),y()},[y,v,i]),x=m.useCallback(()=>{b();const S=u.current||Gp(e,t,n),N=l.current.pop();return N?(c.current=vw(c.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]),_=m.useCallback(()=>{b();const S=u.current||Gp(e,t,n),N=c.current.pop();return N?(l.current=vw(l.current,S),k(N),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const S=Gp(e,t,n);if(!u.current){u.current=S;return}if(h.current){h.current=!1,u.current=S;return}S.signature!==u.current.signature&&(p.current||(p.current=u.current),f.current=S,v(),d.current=window.setTimeout(()=>{b()},CG))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:_,version:o}}function yo(e){return String(e??"").trim()}function R_(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(yo(e).toLowerCase())}function PG(e){return e===!1?!0:["false","no","not_required","waived"].includes(yo(e).toLowerCase())}function TG(e,t=""){return yo((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 JR(e){return yo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function XR(e){return JR(e)==="all"}function RG(e,t=[]){const n=yo((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=JR(e),i=TG(e);if(!i||!["android","ios"].includes(r))return"";const o=`-${r}`;if(!i.endsWith(o))return"";const a=i.slice(0,-o.length);return new Set(t.map(l=>yo(l))).has(a)?a:""}function km(e){const t=yo(e==null?void 0:e.label).toLowerCase(),n=yo((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 MG(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[km(n)]-t[km(r)])}function $G(e){const t=yo((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 LG(e,t=[]){if(XR(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(km);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 R_(e==null?void 0:e.implementationNotRequired)||R_(e==null?void 0:e.implementation_not_required)||PG(r)?{kind:"not-required",label:$G(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function jb(e=[]){return e.reduce((t,n)=>t+1+jb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function br(e){return String(e||"").trim()}function Ko(e){return br(e).toLowerCase()}function vm(e){return typeof e=="string"?Ko(e):!e||typeof e!="object"||Array.isArray(e)?"":Ko(e.kind||e.type||e.persistence||e.durability)}function QR(e,t="http://localhost"){const n=br(e);if(!n)return"";try{const r=new URL(n,t);return r.origin==="null"?`${r.protocol}//${r.host}${r.pathname}`:`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function ZR(e={}){const t=br(e.href||e.url);if(!t)return!1;const n=Ko(e.kind||e.type),r=Ko(e.durability),i=Ko(e.persistence),o=Ko(e.truth||e.stateTruth||e.state_truth),a=Ko(e.authority),l=vm(e.source)||vm(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(br).join(" "),u=[e.label,e.title,n,i,a,l,t].map(br).join(" ");if(r==="temporary"||i==="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 d=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||i==="ai-doc"&&d,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function eM(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(br).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 OG(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=br(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(br(t)?br(t):eM(e)==="tech-design"&&br(n)?br(n):br(e.title||e.label))}function DG(e={},t="http://localhost"){const n=br(e.issueKey||e.issue_key||e.issue),r=eM(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const i=br(e.documentPath||e.document_path||e.path);return i?`path:${i.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${QR(e.href||e.url,t)}`}function M_(e={}){const t=br(e.href||e.url),n=Ko(e.kind||e.type),r=vm(e.source)||vm(e.sourceArtifact||e.source_artifact),i=br(e.label);let o=0;return e.confirmed===!0&&(o+=100),r==="ai-doc"&&(o+=80),n==="ai-doc"&&(o+=70),/^https?:\/\//i.test(t)&&(o+=30),/\/api\/prd-workflow\/review\//.test(t)&&(o+=20),/预览|review/i.test(i)||(o+=10),o}function FG(e,t){const n=M_(t)>M_(e)?t:e,r=n===t?e:t;return{...r,...n,title:$_(e.title)>=$_(t.title)?e.title:t.title,issueKey:e.issueKey||t.issueKey,platform:e.platform||t.platform,documentPath:n.documentPath||r.documentPath,source:n.source||r.source}}function $_(e){const t=br(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function Sw(e,t){const n=new Map,r=[];for(const i of e){const o=t(i);if(!o){r.push(i);continue}const a=n.get(o);if(a===void 0){n.set(o,r.length),r.push(i);continue}r[a]=FG(r[a],i)}return r}function zG(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>ZR(o)),r=Sw(n,o=>QR(o.href||o.url,t)),i=Sw(r,o=>br(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return Sw(i,o=>DG(o,t))}function Lt(e){return String(e||"").trim()}function wo(e){return typeof e=="string"?Lt(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Lt(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function gc(e){return Lt((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function tM(e){return Lt((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function nM(e){const t=Lt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function WG(e){const t=Lt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return n.hash="",n.searchParams.sort(),n.href}catch{return t.split("#")[0]}}function BG(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Lt(e.issueKey||e.issue_key||e.issue),n=Lt(e.action||e.actionId||e.action_id),r=Lt(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),i=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Lt(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(i)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function HG(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Lt(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Lt(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=Lt(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",i=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||i===!1)}function Gc(e){const t=gc(e);if(/^prd-review:/i.test(t)||Lt((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(tM(e)))return!0;const n=Lt((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),i=Lt(e==null?void 0:e.durability).toLowerCase(),o=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||i==="temporary"||i==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function L_(e){const t=[e==null?void 0:e.label,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,wo(e==null?void 0:e.source)].map(Lt).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function O_(e){const t=[],n=gc(e);if(n&&t.push(`key:${n}`),Gc(e)){const i=nM(tM(e));i&&t.push(`review:${i}`)}const r=WG((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${Lt(e==null?void 0:e.label)}
|
|
183
|
+
${r}`),t}function VG(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const i=O_(r),o=i.map(h=>n.get(h)).find(h=>h!=null);if(o==null){i.forEach(h=>n.set(h,t.length)),t.push(r);continue}const a=t[o],l=L_(r)>=L_(a)?Lt(r==null?void 0:r.label)||Lt(a==null?void 0:a.label):Lt(a==null?void 0:a.label)||Lt(r==null?void 0:r.label),c=!!gc(a),u=!!gc(r),p=c&&!u?a:r,f=p===a?r:a,d=gc(p)&&!gc(f)&&Lt(p==null?void 0:p.label)||l;t[o]={...f,...p,...d?{label:d}:{}},O_(t[o]).forEach(h=>n.set(h,o))}return t}function rM(e){const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.durability).toLowerCase(),r=Lt(e==null?void 0:e.persistence).toLowerCase(),i=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Lt).join(" ");return t==="temporary-review"||n==="temporary"||i==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function KG(e){if(!Gc(e)||rM(e))return!1;const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.durability).toLowerCase(),r=Lt(e==null?void 0:e.persistence).toLowerCase(),i=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Lt).join(" ");return t==="review"||n==="durable"||i==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function qG(e){if(Gc(e))return!1;const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.persistence).toLowerCase(),r=wo(e==null?void 0:e.source)||wo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),i=[e==null?void 0:e.label,t].map(Lt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(i)}function UG(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Lt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function GG(e=[],t={}){const n=VG(Array.isArray(e)?e:[]);if(!UG(t))return n;const r=n.filter(Gc);if(r.length===0)return n;const i=r.filter(KG),a=i.length>0||n.some(qG)?i.at(-1):r.filter(rM).at(-1);return n.filter(l=>!Gc(l)||l===a)}function Pi(e,t){const n=[],r=new Map,i=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Lt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=nM(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const p=Lt(a.path);return p&&l.push(`path:${p}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=i(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(p=>r.set(p,u));return}n[c]=a,i(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function es(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Sm(e){return Array.isArray(e)?e.map(Sm):es(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,Sm(e[t])])):e}function lo(e,t){return JSON.stringify(Sm(e))===JSON.stringify(Sm(t))}function sM(e){return es(e==null?void 0:e.instances)?e.instances:{}}function uf(e){return es(e==null?void 0:e.ui)?e.ui:{}}function Yp(e,t){if(!es(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function YG(e,t){if(!es(e)||!es(t)||!es(e.instances)||!es(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!es(e.ui)||!es(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Yp(e,["version","instances","edges","ui"]),r=Yp(t,["version","instances","edges","ui"]);if(!lo(n,r))return!1;const i=["nodePositions","nodeSizes","groups","displayPage","viewport"];return lo(Yp(e.ui,i),Yp(t.ui,i))}function iM(e){const t=Array.isArray(uf(e).groups)?uf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function D_(e){const t=new Set(Object.keys(sM(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 iM(e).keys())t.add(n);return t}function F_(e,t){const n=sM(e),r=uf(e),i=iM(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:es(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:es(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:i.get(t)||null}}function z_(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),i=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(i)})}function JG(e,t){if(!YG(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...D_(e),...D_(t)]),r=Array.from(n).filter(i=>!lo(F_(e,i),F_(t,i)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!lo(z_(e),z_(t)),displayPageChanged:!lo(uf(e).displayPage||null,uf(t).displayPage||null)}}function XG(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),i=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!i.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function W_(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 B_(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function QG(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[W_(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const i=n.get(W_(r));return i?lo(B_(i),B_(r))?i:{...r,selected:i.selected===!0}:r})}function ZG(e,t,n){const r=es(e)?e:{},i=es(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(i).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function eY({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:i=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==i||l!==a)?"local-edits":""}function tY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function oM(e=[]){let t=!1,n=!1,r=!1;for(const i of Array.isArray(e)?e:[]){if((i==null?void 0:i.type)==="position"&&i.position){r=!0,i.dragging===!0&&(t=!0),i.dragging===!1&&(n=!0);continue}if((i==null?void 0:i.type)==="dimensions"&&i.dimensions){r=!0,i.resizing===!0&&(t=!0),i.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(i==null?void 0:i.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function nY({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function rY(e=[]){const t=oM(e);return t.mutated&&!t.active}function sY(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 iY(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 oY(e=[]){const t=[],n=[];let r=!1;for(const i of Array.isArray(e)?e:[]){if(sY(i)){t.push(i);continue}n.push(i),iY(i)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function Nb(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const i=String((r==null?void 0:r.id)||"").trim();if(!(i&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${i}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function aY(e=[]){return Nb(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 H_(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 lY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function cY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:i=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&i}const uY=m.lazy(()=>sP(()=>import("./WorkflowAssistantThread-B3thaqH2.js"),[])),dY="af:workspace-graph:v2",V_="agentflow.workspace.sidebarCollapsed",Ql=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],fY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),pY={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:""}]},hY={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:""}]},mY={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}]},gY={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}]},yY={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}]},wY={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}]},xY=new Set(["png","jpg","jpeg","gif","webp","svg"]),aM=320,lM=180,cM=960,jm=96,uM=900,_b=520,Cb=320,Jp=52,ul=240,dl=160,Ab="display-ref:",df="0 9 * * *",bY="Asia/Shanghai",kY="0.1.138";function vY(){const e=new URLSearchParams(window.location.search),t=String(e.get("returnTo")||"").trim();return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1",returnTo:t==="/workflows"?t:"",workflowDemo:e.get("workflowDemo")==="1"}}function Br(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),e.returnTo&&t.set("returnTo",e.returnTo),e.workflowDemo&&t.set("workflowDemo","1"),t}function SY(e){const t=String(e||"").trim();if(!t)return null;try{const n=JSON.parse(window.sessionStorage.getItem(`agentflow.workflow.demo:${t}`)||"null");return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Ev(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
184
|
+
...[truncated ${n.length-t} chars]`:n:""}function jY(e){const t=Ev(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 Iv(e,t=80){return(Array.isArray(e)?e:[]).map(jY).filter(Boolean).slice(-t)}function NY(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,i]of Object.entries(t).slice(-80)){const o=String(r||"").trim();if(!o||!i||typeof i!="object")continue;const a=Iv(i.messages,40),l=Ev(i.draft||"",2e3);!a.length&&!l||(n[o]={sessionId:String(i.sessionId||`nodechat_${o}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function _Y(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Iv(t==null?void 0:t.messages,80);if(!r.length)return null;const i=String((t==null?void 0:t.status)||"done");return{id:n,label:Ev((t==null?void 0:t.label)||n,120),status:i==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function K_(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:Iv(n.messages,100),runSessions:_Y(n.runSessions)},nodeChats:NY(t.nodeChats)}}function Nm(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 xY.has(n)}function ff(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const i=Br(t||{});return i.set("path",r),n.download&&i.set("download","1"),`/api/workspace/file/raw?${i.toString()}`}function CY(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function AY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${V_}:${t}`:V_}function EY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function q_(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function IY(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 PY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!IY(e)}function TY(e){const t=String(e||"").trim();if(!t||RY(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(),i=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return i==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function RY(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 MY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function jw(e,t,n,r="Workspace Run"){var c;const i=String(n||"").trim(),o=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===i):null,a=t&&typeof t=="object"?t[i]:null;return String(((c=o==null?void 0:o.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||i||r}function Nw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,i=String(t||"").trim();return!i||r===i?r:`${r} (${i})`}function za(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 U_(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 $Y(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 LY(e){const t=$Y(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let i="pending";return t>r?i="done":t===r&&(i=r===3?"done":"current"),{label:n,status:i}})}function pf(e){const t=String(e||"").trim();if(!t)return"";if(t.startsWith("/")&&!t.startsWith("//")||t.startsWith("#"))return t;if(!/^https?:\/\//i.test(t))return"";try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const i=window.location.hostname;n.hostname=i&&i!=="0.0.0.0"&&i!=="::"?i:"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 Ic(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return pf(t);const n=String((e==null?void 0:e.path)||"").trim();return n&&/^https?:\/\//i.test(n)?pf(n):""}function ba(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 ua(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 Pv(e){return ba(e==null?void 0:e.status)==="done"&&ua(e)!=="observation"}function co(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 Ih(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function Tv(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 OY(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(i=>String(i||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function DY(e,t){const n=co(e,t),r=ba(e==null?void 0:e.status),i=Pv(e),a=`${fl(e)} ${Tv(e)}`,l=OY(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)){if(i)return`${l} 方案已确认`;if(r==="observed"||r==="superseded"||ua(e)==="observation")return`${l} 方案状态已观察`;if(r==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)){if(i)return`已为 ${l} 创建/绑定 GitLab Issue`;if(r==="observed"||r==="superseded"||ua(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function FY(e){if(!e||typeof e!="object")return"";const t=ba(e.status),n=ua(e),r=Pv(e),o=`${fl(e)} ${Tv(e)}`,a=Rv(e),l=a.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),c=a.some(f=>/gitlab issue/i.test(String(f.label||""))),u=a.some(f=>/gitlab epic/i.test(String(f.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(o))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(o))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(o))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(o))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const p=Ih(e);return p?p.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":p:""}function _m(e){return!e||typeof e!="object"?"":String(e.stageEnteredAt||e.stage_entered_at||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 dM="Asia/Shanghai",zY=new Intl.DateTimeFormat("zh-CN",{timeZone:dM,year:"numeric",month:"2-digit",day:"2-digit"}),WY=new Intl.DateTimeFormat("zh-CN",{timeZone:dM,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function fM(e){const t=_m(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function BY(e){const t=fM(e);return t?zY.format(t).replace(/\//g,"-"):"无时间"}function HY(e){const t=fM(e);return t?WY.format(t):""}function VY(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const i=BY(n);let o=t[t.length-1];(!o||o.day!==i)&&(o={day:i,items:[]},t.push(o)),o.items.push({item:n,index:r})}),t}function pM(e){const t=ba(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function qo(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 KY(e){const t=ba(e==null?void 0:e.status);return ua(e)==="observation"&&t==="done"?"已观察":pM(t)}function hM(e){if(!e||typeof e!="object")return[];const t=[],n=(o,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${o}:${c}`,type:o,label:String(a||c),value:c})},r=ba(e.status),i=ua(e)==="observation"&&r==="done"?"observed":r;return n("status",pM(i),i),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",qo(e.platform),e.platform),t}function qY(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{hM(n).forEach(r=>{const i=t.get(r.key);t.set(r.key,{...r,count:((i==null?void 0:i.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const i={status:0,issue:1,platform:2,source:3,actor:4};return(i[n.type]??9)-(i[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function UY(e,t){const n=String(t||"all");return!n||n==="all"?!0:hM(e).some(r=>r.key===n)}function GY(e){if(!e||typeof e!="object")return[];const t=[],n=(r,i)=>{const o=String(i||"").trim();o&&t.push({label:r,value:o})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",qo(e.platform)),t}function Rv(e){const t=[],n=(c,u,p={})=>{const f=pf(u);f&&t.push({...p,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",p=0)=>{if(p>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((d,h)=>r(d,`${u} ${h+1}`,p+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const d of["links","urls","artifacts","outputs","output","results","result","files"])c[d]!=null&&r(c[d],d,p+1)},i=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of i)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href),c);for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",Ic(c),c);n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const o=c=>{const u=String(c||"").trim();try{const p=new URL(u,window.location.origin);return`${p.origin}${p.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=Gc(c),p=String(c.key||c.artifactKey||c.artifact_key||"").trim(),f=p?`key:${p}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
|
|
185
|
+
${c.href}`,d=l.get(f);if(!d){l.set(f,c);continue}if(u){const h=a(d.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(d.label||"").length)&&l.set(f,c)}}return GG(Array.from(l.values()),e)}function YY(e,t=[]){var l,c,u,p,f;const n=[],r=new Map,i=String(((c=(l=e==null?void 0:e.overall)==null?void 0:l.requirement)==null?void 0:c.title)||((p=(u=e==null?void 0:e.overall)==null?void 0:u.requirement)==null?void 0:p.name)||"").trim();for(const d of Eb(e)){const h=Li(d),y=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();h&&y&&r.set(h,y)}const o=(d,h={})=>{if(!d||typeof d!="object")return;const y=(b,g={})=>{if(!b||typeof b!="object")return;const k=String(h.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),x=b.source||b.sourceArtifact||b.source_artifact||d.sourceArtifact||d.source_artifact||d.source||h.source||null,_=OG({...b,title:b.title||h.documentTitle||(d==null?void 0:d.title)||"",documentTitle:b.documentTitle||b.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(k)||"",requirementTitle:i}),S={label:String(b.label||"ai-doc").trim()||"ai-doc",href:String(b.href||b.url||"").trim(),kind:String(b.kind||b.type||d.kind||d.type||"").trim(),title:_,issueKey:k,platform:h.platform||qo(d.platform),durability:b.durability||d.durability||h.durability||"",persistence:b.persistence||d.persistence||h.persistence||"",truth:b.truth||b.stateTruth||b.state_truth||ua(d)||h.truth||"",authority:b.authority||d.authority||h.authority||"",confirmed:b.confirmed??d.confirmed??h.confirmed,source:x,documentPath:b.documentPath||b.document_path||b.path||g.documentPath||(x==null?void 0:x.path)||(x==null?void 0:x.documentPath)||(x==null?void 0:x.document_path)||""};S.href&&n.push(S)};for(const b of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Ic(b)},{documentPath:b.path});for(const b of Array.isArray(d==null?void 0:d.links)?d.links:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Ic(b)},{documentPath:b.path});const v=Ic(d);v&&y({...d,label:d.label||d.title||d.kind||"ai-doc",href:v},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:qo(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 h of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(h,{issueKey:String((h==null?void 0:h.issueKey)||(h==null?void 0:h.issue_key)||(h==null?void 0:h.issue)||"").trim(),platform:qo(h==null?void 0:h.platform),documentTitle:String((h==null?void 0:h.documentTitle)||(h==null?void 0:h.document_title)||(h==null?void 0:h.title)||"").trim()});for(const d of Eb(e))o(d,{issueKey:Li(d),platform:qo(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()});const a=(f=e==null?void 0:e.extensions)!=null&&f["prd-flow"]&&typeof e.extensions["prd-flow"]=="object"?e.extensions["prd-flow"]:{};for(const d of[...Array.isArray(e==null?void 0:e.aiDocs)?e.aiDocs:[],...Array.isArray(e==null?void 0:e.ai_docs)?e.ai_docs:[],...Array.isArray(a.aiDocs)?a.aiDocs:[],...Array.isArray(a.ai_docs)?a.ai_docs:[]])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||"").trim(),platform:qo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.label)||"").trim()});return zG(n,window.location.origin)}function JY(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 Li(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 XY(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)||Li(e,t)||`Issue ${t+1}`).trim()}function QY(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 ZY(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 eJ(e){const t=Rv(e),n=(i,o)=>{if(Array.isArray(i)){for(const a of i)if(a)if(typeof a=="string")t.push({label:o,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||o,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(i=>{const o=String(i.href||"").trim();if(!o)return!1;const a=`${i.label}
|
|
186
|
+
${o}`;return r.has(a)?!1:(r.add(a),!0)})}function tJ(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,i=(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=i(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 p of u)p&&typeof p=="object"&&c.issues.push({...p,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)i(QY(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((p,f)=>Li(p,f));return a.forEach((p,f)=>{const d=Li(p,f);l.set(d,{issue:p,children:[]})}),a.forEach((p,f)=>{const d=Li(p,f),h=ZY(p)||RG(p,u),y=l.get(d);h&&l.has(h)?l.get(h).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function Cm(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 fl(e){return BG(e)}function Am(e){const t=_m(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 Eb(e){var i,o,a,l,c,u,p,f,d,h,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(i=e==null?void 0:e.raw)==null?void 0:i.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(f=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:f.epics,(h=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:h.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function nJ(e,t){const n=String(t||"").trim();return n&&Eb(e).find((r,i)=>Li(r,i)===n)||null}function rJ(e){var t,n,r,i,o,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((i=e==null?void 0:e.raw)==null?void 0:i.gitlab_epic)||((a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function sJ(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=nJ(e,n),i=String(t.platform||(r==null?void 0:r.platform)||"").trim(),o=i&&!t.platform?{...t,platform:i}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||o.gitlabIssue||o.gitlab_issue||"").trim(),l=rJ(e);if(!a&&!l)return o;const c=fl(o),u=`${c} ${Tv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({key:`gitlab-issue:${n}:${(i||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const d=ba(o.status),h=a&&d==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:Pi(o.artifacts,f)}}function G_(e,t){const n=Am(t),r=Am(e),i=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,o=(i==null?void 0:i.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:co(i,0)||co(t,0)||co(e,0),detail:Ih(i)||Ih(t)||Ih(e),status:o,links:Pi(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Pi(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Pi(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Pi(e==null?void 0:e.results,t==null?void 0:t.results),events:Pi(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:(i==null?void 0:i.updatedAt)||(i==null?void 0:i.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 iJ(e,t){const n=[],r=new Map,i=new Map,o=new Map,a=f=>{var d,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||HG(f)||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(((d=f.conflict)==null?void 0:d.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,d)=>({...f,links:Pi(f==null?void 0:f.links,d==null?void 0:d.links),artifacts:Pi(f==null?void 0:f.artifacts,d==null?void 0:d.artifacts),outputs:Pi(f==null?void 0:f.outputs,d==null?void 0:d.outputs),results:Pi(f==null?void 0:f.results,d==null?void 0:d.results)}),c=(f,d)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],d);return}o.set(f,l(o.get(f)||{},d))},u=(f,d)=>f&&o.has(f)?l(d,o.get(f)):d,p=f=>{if(Array.isArray(f))for(const d of f){const h=fl(d);if(a(d)){c(h,d);continue}const y=String(d.id||d.eventId||d.event_id||d.actionId||d.action_id||"").trim(),v=h||y,b=v?r.get(v)??i.get(y):null;v&&b!=null?(n[b]=u(h,G_(n[b],d)),h&&r.set(h,b),y&&i.set(y,b)):(v&&r.set(v,n.length),y&&i.set(y,n.length),n.push(u(h,d)))}};if(p(e==null?void 0:e.actions),p(e==null?void 0:e.workflowActions),p(e==null?void 0:e.workflow_actions),p(e==null?void 0:e.timeline),p(e==null?void 0:e.history),p(e==null?void 0:e.events),p(e==null?void 0:e.runtimeEvents),p(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=Cm(t),d=fl(t),h=d?r.get(d):f?i.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=G_(n[h],y))}return n.map((f,d)=>({item:f,index:d,ts:Am(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,d)=>d.ts-f.ts||f.index-d.index).map(f=>sJ(e,f.item))}function oJ(e){const t=Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[],n=Array.isArray(e==null?void 0:e.snapshotAudit)?e.snapshotAudit:Array.isArray(e==null?void 0:e.snapshot_audit)?e.snapshot_audit:[];return[...t,...n].filter(i=>i&&typeof i=="object").map((i,o)=>({item:i,index:o,ts:Am(i)})).sort((i,o)=>{const a=Number.isFinite(i.ts),l=Number.isFinite(o.ts);return a&&l?o.ts-i.ts||o.index-i.index:a?-1:l?1:o.index-i.index}).slice(0,8).map(i=>i.item)}function aJ(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 lJ(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,i=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(i)?`(+${za(r)} / 总 ${za(i)})`:"";return`${t+1}. ${n}${o}`}function mM(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 Zl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function cJ(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 uJ(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 dJ(e,t){var i;const n=String(((i=t==null?void 0:t.args)==null?void 0:i.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 fJ(e){var o,a,l;const t=mM(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),i=Zl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=uJ(t),u=cJ(t),p=Zl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Zl(t.completedAtMs,c==null?void 0:c.completedAtMs),d=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(p)&&Number.isFinite(f)?Math.max(0,f-p):Zl(d.executionTime,d.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||d.command||"").trim(),v=y?y.split(`
|
|
187
|
+
`).find(Boolean)||y:"";return{kind:"tool",label:dJ(u,c),durationMs:Number.isFinite(h)?h:null,at:i,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Zl(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:i,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:i,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:i,detail:""}:null}function Y_(e,t,n,r){const i=(Array.isArray(e)?e:[]).map(b=>typeof b=="string"?{text:b}:b).filter(b=>b&&String(b.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(b=>(b==null?void 0:b.kind)==="total"&&Number.isFinite(Number(b.durationMs))),l=[...i].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=Zl(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),p=i.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),f=o.filter(b=>(b==null?void 0:b.kind)==="tool"),d=f.reduce((b,g)=>b+(Number(g.durationMs)||0),0),h=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...i.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...f.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${za(u)}`),p>0&&v.push(`- 模型相关间隔:约 ${za(p)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${za(d)}(${f.length} 次完成事件)`),h>0&&v.push(`- 网络/会话恢复事件:${h} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${za(b.durationMs)}${k}`)})),i.length>0&&(v.push(""),v.push("最近 Activity"),i.slice(-10).forEach((b,g)=>{v.push(lJ(b,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${za(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
|
|
188
|
+
`)}function J_(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=mM(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 gM(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 yM(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Mv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function wM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function pJ(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 hJ(e){const t=String(e??"").trim();return t?t.includes("${")?t:wM(t):""}function xM(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 i=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),o=i?`${i}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(hJ).filter(Boolean):[];return[pJ(t,n),wM(o),...a].join(" ")}return String(t.command||"").trim()}function ad(e){const t=String(Mv(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function X_(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Em(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function ld(e){return Em(e)}function Ib(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Xp(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 Q_(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),i=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,i?`type: ${i}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function Z_(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),i=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:i,kind:t}}function _w(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 i=new Map(t.map(l=>[l.id,l])),o=kb(i.get(n),e.sourceHandle||"output-0","source"),a=kb(i.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&cf(o,a))}function mJ(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),i=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!i)return null;const o=t.find(l=>l.id===n),a=kb(o,r,i);return a?{nodeId:n,handleId:r,handleType:i,slot:a,slotType:EU(a)}:null}function gJ(e,t){return t?e.map((n,r)=>{const i=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let o=0;o<i.length;o+=1){const a=i[o];if(!(t.handleType==="source"?cf(t.slot,a):cf(a,t.slot)))continue;const c=ad(n);return{def:n,order:r,category:c,categoryRank:Ql.indexOf(c),slot:a,slotIndex:o,displayLabel:ld(n),description:Ib(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const i=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return i-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function yJ(e,t,n){var o,a,l,c;if(!n)return[];const r=[],i=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const p=Array.isArray(i?(o=u.data)==null?void 0:o.inputs:(a=u.data)==null?void 0:a.outputs)?i?u.data.inputs:u.data.outputs:[];for(let f=0;f<p.length;f+=1){const d=p[f];if((d==null?void 0:d.showOnNode)===!1||!(i?cf(n.slot,d):cf(d,n.slot)))continue;const y=i?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${f}`}:{source:u.id,sourceHandle:`output-${f}`,target:n.nodeId,targetHandle:n.handleId},v=(t||[]).some(b=>b.target===y.target&&b.targetHandle===y.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:d,slotIndex:f,handleId:i?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,p)=>{var v,b,g,k,x,_,S,N;const f=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),d=Number(((k=(g=p.node)==null?void 0:g.position)==null?void 0:k.y)||0),h=Number(((_=(x=u.node)==null?void 0:x.position)==null?void 0:_.x)||0),y=Number(((N=(S=p.node)==null?void 0:S.position)==null?void 0:N.x)||0);return f-d||h-y||u.slotIndex-p.slotIndex||String(u.nodeId).localeCompare(String(p.nodeId))})}function yc(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 wJ(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(i=>i.id));for(let i=1;i<1e4;i++){const o=`${n}_${i}`;if(!r.has(o))return o}return`${n}_${Date.now().toString(36)}`}function xJ(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function bJ(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return df;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} * * *`:df}function Yo(e,t=0,n=0,r=59){const i=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(i).padStart(2,"0")}function $v(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Yo(t[1],9,0,23)}:${Yo(t[2],0,0,59)}`:"09:00"}function cd(e,t,n,r,i){const o=$v(t),[a,l]=o.split(":").map(u=>Number.parseInt(u,10)),c=String(e||"daily");if(c==="weekly"){const u=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${u}`}if(c==="monthly"){const u=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${u} * *`}return c==="custom"?String(i||"").trim()||df:`${l} ${a} * * *`}function kJ(e){const n=String(e||df).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,i,o,a,l]=n,c=Number.parseInt(r,10),u=Number.parseInt(i,10),p=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&i===String(u),f=p?`${Yo(u,9,0,23)}:${Yo(c,0,0,59)}`:"09:00";return p&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:f,weekday:1,monthDay:1}:p&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:f,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:p&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:f,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:f,weekday:1,monthDay:1}}function Lv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),i=bJ(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():i,a=kJ(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=$v(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),p=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),f=cd(l,c,u,p,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:p,cron:f,timezone:bY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function vJ(e){const t=Lv(JSON.stringify(e||{}));return JSON.stringify(t)}function SJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function jJ(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function eC(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 Qp(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:eC(n.nextRunAt),lastAt:eC(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 Im(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Pm(e){return e>0?`Group ${e+1}`:"Group"}function NJ(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const i=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),o=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!i||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:i,title:String((n==null?void 0:n.title)||Pm(r)).trim()||Pm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(ul,Math.round(l)),height:Math.max(dl,Math.round(c))}}).filter(Boolean)}function _J(e){var n;return NJ((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Ec,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 Pb(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(ul,Math.round(t)),height:Math.max(dl,Math.round(n))}}function ud(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:xJ(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 bM(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((i,o)=>(i==null?void 0:i.showOnNode)===!1?"":[o,String((i==null?void 0:i.type)||""),String((i==null?void 0:i.name)||""),i!=null&&i.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function CJ(e){var o,a,l,c;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{},i=Ng(t);return[bM(e),Dn(t)||"",i?"has-result":"",(t==null?void 0:t.contextRunResultNonce)||"",Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.width)||0)||"",Number(((a=e==null?void 0:e.measured)==null?void 0:a.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(c=(l=t==null?void 0:t.runningRunNodeIds)==null?void 0:l.has)!=null&&c.call(l,e==null?void 0:e.id)?"running-run":""].join("::")}function tC(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 AJ=new Map,EJ=[];function Yu(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=SM(n),i=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(h=e==null?void 0:e.ui)!=null&&h.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(y=e==null?void 0:e.ui)!=null&&y.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const v of i)v!=null&&v.source&&l.add(String(v.source)),v!=null&&v.target&&l.add(String(v.target));const u=Array.from(l).map(v=>{const b=r[v]||{},g=b.definitionId||v,k=t.find(D=>D.id===g),x=Mv(k)||g,_=t.find(D=>D.id===x)||k,S=b.marketplaceRef||yM(k),N=xM(k),I=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},T=!!Dn({definitionId:x,inputs:b.input,outputs:b.output}),z=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,E=Qa(z,{display:T}),O=E&&!di(x);return{id:v,type:Ec,position:I,...O?{width:E.width,height:E.height}:{},data:{label:b.label||Em(k)||Em(_)||v,definitionId:x,...S?{marketplaceRef:S}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:gM(x,_||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||N||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...O?{nodeSize:E}:{},...T&&O?{displaySize:E}:{}}}}).map(v=>Sb(v,r,t)),p=_J(e),f=i.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!p.some(b=>b.id===String(v.source)||b.id===String(v.target))).map((v,b)=>({id:v.id||`we-${v.source}-${v.target}-${b}`,source:String(v.source),target:String(v.target),sourceHandle:v.sourceHandle??void 0,targetHandle:v.targetHandle??void 0,markerEnd:{type:Ei.ArrowClosed}})),d=[...p,...u];return{nodes:d,edges:tG(f,d),instances:r}}function nC(e){return`${Ab}${e}`}function Zp(e){const t=String(e||"");return t.startsWith(Ab)?t.slice(Ab.length):t}function Tb(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 Ph(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var d;return pl((d=f==null?void 0:f.data)==null?void 0:d.definitionId)}).map(f=>[f.id,f])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],i=[],o=new Set;for(const f of r){const d=String(f||"").trim();!d||o.has(d)||!n.has(d)||(o.add(d),i.push(d))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};i.forEach((f,d)=>{const h=l[f];a[f]=h&&typeof h.x=="number"&&typeof h.y=="number"?{x:h.x,y:h.y}:{x:180+d*36,y:120+d*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};i.forEach(f=>{const d=Qa(u[f],{display:!0});d&&(c[f]=d)});const p=Tb(e==null?void 0:e.viewport);return{nodeIds:i,nodePositions:a,nodeSizes:c,...p?{viewport:p}:{}}}function rC(e,t=[]){return Ph(e,t)}const Cw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function Aw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function sC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function iC(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 IJ(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function oC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const kM="af:workspace:canvas-clipboard",vM="agentflow.workspace.canvas-clipboard";function PJ(e){return JSON.stringify({type:vM,version:1,clipboard:e})}function TJ(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==vM)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function RJ(e){try{localStorage.setItem(kM,PJ(e))}catch{}}function MJ(){try{return TJ(localStorage.getItem(kM))}catch{return null}}function $J(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Rb(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 i=document.execCommand("copy");return document.body.removeChild(r),i}catch{return!1}}function aC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Qa(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:aC(n,lM,cM)||aM,height:aC(r,jm,uM)||jm}}function Tm(e){const t=Qa(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function LJ(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:_b,height:Cb}}function OJ(e,t=""){const n=Tm(e==null?void 0:e.displaySize);if(n)return n;const r=Tm(e==null?void 0:e.nodeSize);if(r)return r;const i=pl(t)||Mf(fa((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return LJ(i)}function ec(e){var i,o,a,l,c,u,p,f,d,h,y;if(di((i=e==null?void 0:e.data)==null?void 0:i.definitionId))return null;const t=!!Dn(e==null?void 0:e.data),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((f=(p=e==null?void 0:e.data)==null?void 0:p.displaySize)==null?void 0:f.height)||((h=(d=e==null?void 0:e.data)==null?void 0:d.nodeSize)==null?void 0:h.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return Qa({width:n,height:r},{display:t})}function Yl(e,t,n){var p,f,d,h,y,v,b,g,k,x,_,S,N;const r=(e||[]).filter(I=>!Im(I)),i=(e||[]).filter(Im),o=SM(Cv(r,n||{})),a=t.map(I=>({source:I.source,target:I.target,sourceHandle:I.sourceHandle??null,targetHandle:I.targetHandle??null})).filter(I=>!i.some(T=>T.id===I.source||T.id===I.target)),l={},c={},u=[];for(const I of r){l[I.id]={x:((p=I.position)==null?void 0:p.x)||0,y:((f=I.position)==null?void 0:f.y)||0};const T=ec(I);T&&(c[I.id]=T)}for(const I of i){const T=Number(((h=(d=I.data)==null?void 0:d.nodeSize)==null?void 0:h.width)||I.width||((y=I.measured)==null?void 0:y.width)||0),z=Number(((b=(v=I.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||I.height||((g=I.measured)==null?void 0:g.height)||0);u.push({id:I.id,title:String(((k=I.data)==null?void 0:k.title)||((x=I.data)==null?void 0:x.label)||"Group"),color:String(((_=I.data)==null?void 0:_.color)||"purple"),x:Number(((S=I.position)==null?void 0:S.x)||0),y:Number(((N=I.position)==null?void 0:N.y)||0),width:Math.max(ul,Math.round(T||ul)),height:Math.max(dl,Math.round(z||dl))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function SM(e){const t={};for(const[n,r]of Object.entries(e||{})){const i=String((r==null?void 0:r.definitionId)||n);if(!!pl(i)||i.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 pl(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 Dn(e){const t=pl(e==null?void 0:e.definitionId);return t||(di(e==null?void 0:e.definitionId)&&Ng(e)?Mf(fa((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function uo(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=Dn(e),r=di(e==null?void 0:e.definitionId),i=n==="image"?"src":"content",o=u=>String((u==null?void 0:u.value)??(u==null?void 0:u.default)??""),a=u=>o(u).trim(),l=t.find(u=>(u==null?void 0:u.name)===i&&a(u))||t.find(u=>(u==null?void 0:u.name)==="filePath"&&a(u))||t.find(u=>(u==null?void 0:u.type)==="text"&&a(u)),c=l?o(l):"";return String(r?c:(e==null?void 0:e.body)||c)}function da(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 i=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(i)?r:""}function DJ(e){let t=String(e||"").replace(/\r\n/g,`
|
|
189
|
+
`).trim();return t.includes(`
|
|
190
|
+
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
191
|
+
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
192
|
+
$2`)),t}function Oi(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=DJ(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 p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
193
|
+
`).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
|
|
194
|
+
`).replace(/\s+$/g,""):p.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],i=t.indexOf("{"),o=t.lastIndexOf("}");i>=0&&o>i&&r.unshift(t.slice(i,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function hl(e,t){const n=Br(e);n.set("path",t);const r=await fetch(`/api/workspace/file?${n.toString()}`),i=await r.json().catch(()=>({}));if(!r.ok)throw new Error(i.error||`读取文件失败:${t}`);return String(i.content||"")}async function Mb(e,t,n){const r=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,path:t,content:String(n||"")})}),i=await r.json().catch(()=>({}));if(!r.ok)throw new Error(i.error||`写入文件失败:${t}`);return i.path||t}function FJ(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const i=new Map(t.map(o=>[o.id,o]));return(Array.isArray(n)?n:[]).filter(o=>String((o==null?void 0:o.target)||"")===r).slice(0,4).map(o=>{const a=i.get(String((o==null?void 0:o.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
|
|
195
|
+
`)}).filter(Boolean).join(`
|
|
196
|
+
|
|
197
|
+
`)}function su(e){let t=Oi(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const i=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return i>0&&(t=t.slice(i).trim()),t}function zJ(e){const t=su(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ka(e,t){return e==="html"?zJ(t):""}function jM(e,t=""){const n=su(e);if(!n.trim())return"";const i=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
198
|
+
(() => {
|
|
199
|
+
const frameId = ${JSON.stringify(String(t||""))};
|
|
200
|
+
const postSize = () => {
|
|
201
|
+
const doc = document.documentElement;
|
|
202
|
+
const body = document.body;
|
|
203
|
+
const height = Math.ceil(Math.max(
|
|
204
|
+
doc ? doc.scrollHeight : 0,
|
|
205
|
+
doc ? doc.offsetHeight : 0,
|
|
206
|
+
doc ? doc.clientHeight : 0,
|
|
207
|
+
body ? body.scrollHeight : 0,
|
|
208
|
+
body ? body.offsetHeight : 0,
|
|
209
|
+
body ? body.clientHeight : 0,
|
|
210
|
+
window.innerHeight || 0
|
|
211
|
+
));
|
|
212
|
+
window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
|
|
213
|
+
};
|
|
214
|
+
document.addEventListener("click", (event) => {
|
|
215
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
216
|
+
if (!link) return;
|
|
217
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
218
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
219
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
225
|
+
}, true);
|
|
226
|
+
window.addEventListener("load", postSize);
|
|
227
|
+
window.addEventListener("resize", postSize);
|
|
228
|
+
requestAnimationFrame(postSize);
|
|
229
|
+
setTimeout(postSize, 60);
|
|
230
|
+
setTimeout(postSize, 300);
|
|
231
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
232
|
+
const resizeObserver = new ResizeObserver(postSize);
|
|
233
|
+
resizeObserver.observe(document.documentElement);
|
|
234
|
+
if (document.body) resizeObserver.observe(document.body);
|
|
235
|
+
}
|
|
236
|
+
if (typeof MutationObserver !== "undefined") {
|
|
237
|
+
const mutationObserver = new MutationObserver(postSize);
|
|
238
|
+
mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
239
|
+
}
|
|
240
|
+
})();
|
|
241
|
+
<\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${i}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${i}</head>`):`<!doctype html><html><head>${i}</head><body>${n}</body></html>`}function WJ(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 BJ(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function HJ(e,t){const n=URL.createObjectURL(e);try{BJ(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function NM(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 VJ(e){const t=NM(e);return t!=null&&t.documentElement?`${t.doctype?`<!DOCTYPE ${t.doctype.name}${t.doctype.publicId?` PUBLIC "${t.doctype.publicId}"`:""}${t.doctype.systemId?` "${t.doctype.systemId}"`:""}>`:"<!DOCTYPE html>"}
|
|
242
|
+
${t.documentElement.outerHTML}`:""}function Ew(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 KJ(e,t,n,r={}){var b;const i=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=NM(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,p=(r==null?void 0:r.scroller)||null,f=(r==null?void 0:r.displaySize)||null,d={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:i!=null&&i.width?Math.round(i.width):null,rectHeight:i!=null&&i.height?Math.round(i.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:Ew(c),displayBody:Ew(u),scroller:Ew(p)},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((p==null?void 0:p.clientWidth)||0),Number((p==null?void 0:p.scrollWidth)||0),Number(i==null?void 0:i.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(g=>Math.ceil(g)).filter(g=>g>0),y=Math.max(1,...h.length?h:[960]),v=Math.max(1,Math.round(Number(n)||(i==null?void 0:i.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:y,height:v,debug:d}}async function qJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:i,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=KJ(r,i,o,{...l||{},displaySize:c}),p=VJ(r),f=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:p||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 d=await f.blob();HJ(d,a)}function UJ(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 _M(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function GJ(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let i="TD";const o=(l,c="")=>{const u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[1]):o(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){i=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:i}}function CM({code:e}){const t=m.useMemo(()=>GJ(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,i=44,o=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((p,f)=>{l.set(p.id,{x:24+(n?f*(r+o):f%3*(r+o)),y:24+(n?f%3*(i+a):f*(i+a))})});const c=Math.max(360,...Array.from(l.values()).map(p=>p.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(p=>p.y+i+24));return s.jsx("div",{className:"af-work-node__mermaid-preview",children:s.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid preview",children:[s.jsx("defs",{children:s.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((p,f)=>{const d=l.get(p.from),h=l.get(p.to);if(!d||!h)return null;const y=n?`M ${d.x+r} ${d.y+i/2} C ${(d.x+h.x+r)/2} ${d.y+i/2}, ${(d.x+h.x+r)/2} ${h.y+i/2}, ${h.x} ${h.y+i/2}`:`M ${d.x+r/2} ${d.y+i} C ${d.x+r/2} ${d.y+i+28}, ${h.x+r/2} ${h.y-28}, ${h.x+r/2} ${h.y}`;return s.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${p.from}-${p.to}-${f}`)}),t.nodes.map(p=>{const f=l.get(p.id);return s.jsxs("g",{children:[s.jsx("rect",{className:"af-work-node__mermaid-box",x:f.x,y:f.y,width:r,height:i,rx:"8"}),s.jsx("text",{className:"af-work-node__mermaid-text",x:f.x+r/2,y:f.y+i/2+5,textAnchor:"middle",children:p.label.slice(0,22)})]},p.id)})]})})}function ki({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[i,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,y=h?Math.max(12,d/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,p.scrollTop/Math.max(1,f-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const d=new ResizeObserver(a);d.observe(f);for(const h of Array.from(f.children))d.observe(h);return()=>{cancelAnimationFrame(p),d.disconnect()}},[t,a]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=i.height/100*h.height,v=Math.max(1,h.height-y);return(p-h.top-f)/v},[i.height]),u=m.useCallback(p=>{var _,S;if(!i.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=i.top/100*d.height,y=i.height/100*d.height,b=p.clientY>=d.top+h&&p.clientY<=d.top+h+y?p.clientY-d.top-h:y/2;l(c(p.clientY,b));const g=p.pointerId;(S=(_=p.currentTarget).setPointerCapture)==null||S.call(_,g);const k=N=>{N.preventDefault(),l(c(N.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,i.height,i.top,i.visible]);return s.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[s.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),s.jsx("div",{ref:r,className:"af-visible-scrollbar"+(i.visible?" af-visible-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${i.height}%`,top:`${i.top}%`}})})]})}function AM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const i=Dn(e),o=uo(e),a=i==="image"?o:Oi(o),l=i==="image"?"":da(a,i),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState(!1);m.useEffect(()=>{let k=!1;return l?(h(!0),f(""),u(""),hl(t,l).then(x=>{k||u(x)}).catch(x=>{k||f(String(x.message||x))}).finally(()=>{k||h(!1)}),()=>{k=!0}):(u(""),f(""),h(!1),()=>{k=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const y=l?c:a,v=i==="html"?su(y):i==="react"?jg(y):Oi(y),b=m.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!i)return null;const g=Ka(i,v);if(d)return s.jsxs(ki,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(p)return s.jsx(ki,{className:"af-work-display-empty",children:p});if(g)return s.jsx(ki,{className:"af-work-display-empty",children:g});if(!v.trim())return s.jsx(ki,{className:"af-work-display-empty",children:"No display content"});if(i==="html"||i==="react")return s.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:s.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(i==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:i==="react"?Av(v,b.current):jM(v,b.current)},r)});if(i==="image"){const k=ff(v,t);return s.jsx(ki,{className:"af-work-display-body af-work-display-body--image",children:s.jsx("img",{className:"af-work-display-image",src:k,alt:UJ(e),loading:"lazy"})})}return i==="markdown"?s.jsx(ki,{className:"af-work-display-body af-work-display-body--markdown",children:s.jsx(vv,{content:v,basePath:l,resolveSrc:(k,x)=>ff(k,t,x)})}):i==="chart"?s.jsx(ki,{className:"af-work-display-body af-work-display-body--chart",children:s.jsx(jv,{content:v})}):i==="table"?s.jsx(ki,{className:"af-work-display-body af-work-display-body--table",children:s.jsx(Sv,{content:v})}):i==="mermaid"?s.jsxs(ki,{className:"af-work-display-body",children:[s.jsx(CM,{code:v}),s.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):s.jsx(ki,{className:"af-work-display-body af-work-display-body--ascii",children:s.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:v})})}function YJ({node:e,onClose:t}){var k,x,_,S,N,I,T,z,E,O,D;const n=m.useRef(null),r=Dn(e==null?void 0:e.data),i=((k=e==null?void 0:e.data)==null?void 0:k.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),o=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=m.useState(!1),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState(!1),y=uo(e==null?void 0:e.data),v=r==="markdown"?Oi(y):"",b=r==="markdown"?da(v,"markdown"):"",g=r==="markdown"?b?p:v:"";return m.useEffect(()=>{const L=$=>{if($.key==="Escape"){if(a){u(String(g||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[g,a,t]),m.useEffect(()=>{var $;let L=!1;return r!=="markdown"||!b?(f(""),h(!1),()=>{L=!0}):(h(!0),hl((($=e==null?void 0:e.data)==null?void 0:$.flowParams)||{},b).then(V=>{L||f(V)}).catch(V=>{var B,F;L||(f(""),(F=(B=e==null?void 0:e.data)==null?void 0:B.onStatus)==null||F.call(B,String(V.message||V)))}).finally(()=>{L||h(!1)}),()=>{L=!0})},[r,b,(S=(_=e==null?void 0:e.data)==null?void 0:_.flowParams)==null?void 0:S.flowId,(I=(N=e==null?void 0:e.data)==null?void 0:N.flowParams)==null?void 0:I.flowSource,(z=(T=e==null?void 0:e.data)==null?void 0:T.flowParams)==null?void 0:z.archived,(E=e==null?void 0:e.data)==null?void 0:E.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?ur.createPortal(s.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:s.jsxs("div",{className:"af-display-preview-shell",children:[s.jsxs("div",{className:"af-display-preview-head",children:[s.jsxs("div",{className:"af-display-preview-title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_M(r)}),s.jsx("strong",{children:i}),s.jsx("span",{children:e.id})]}),s.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||d,onClick:async()=>{var L,$;try{await IM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:f}),l(!1)}catch(V){($=(L=e==null?void 0:e.data)==null?void 0:L.onStatus)==null||$.call(L,String(V.message||V))}},"aria-label":"保存并预览",title:"保存并预览",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"done"})}),s.jsx("button",{type:"button",className:"af-display-preview-action",onClick:()=>{u(String(g||"")),l(!1)},"aria-label":"取消编辑",title:"取消编辑",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):s.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||d,onClick:()=>{u(String(g||"")),l(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"})}):null,s.jsx("button",{type:"button",className:"af-display-preview-action",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close_fullscreen"})})]})]}),s.jsx("div",{className:"af-display-preview-content",children:r==="markdown"&&a?s.jsx(EM,{value:c,onChange:u,onUploadImage:(O=e.data)==null?void 0:O.onUploadWorkspaceImage,readOnly:o}):s.jsx(AM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function JJ({node:e}){var d,h,y,v,b,g,k,x,_,S;const t=Dn(e==null?void 0:e.data),n=uo(e==null?void 0:e.data),r=t==="image"?n:Oi(n),i=t==="image"?"":da(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var I;let N=!1;return i?(c(!0),a(""),hl(((I=e==null?void 0:e.data)==null?void 0:I.flowParams)||{},i).then(T=>{N||a(T)}).catch(()=>{N||a("")}).finally(()=>{N||c(!1)}),()=>{N=!0}):(a(""),c(!1),()=>{N=!0})},[i,(h=(d=e==null?void 0:e.data)==null?void 0:d.flowParams)==null?void 0:h.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:g.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const u=i?o:r,p=t==="html"?su(u):t==="react"?jg(u):Oi(u),f=Ka(t,p);return l?s.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):f?s.jsx("div",{className:"af-display-picker-preview__empty",children:f}):p.trim()?t==="html"||t==="react"?s.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"?Av(p):jM(p)}):t==="image"?s.jsx("img",{src:ff(p,(_=e==null?void 0:e.data)==null?void 0:_.flowParams),alt:((S=e==null?void 0:e.data)==null?void 0:S.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?s.jsx("div",{className:"af-display-picker-preview__markdown",children:s.jsx(vv,{content:p,basePath:i,resolveSrc:(N,I)=>{var T;return ff(N,(T=e==null?void 0:e.data)==null?void 0:T.flowParams,I)}})}):t==="chart"?s.jsx(jv,{content:p}):t==="table"?s.jsx(Sv,{content:p}):t==="mermaid"?s.jsxs("div",{className:"af-display-picker-preview__diagram",children:[s.jsx(CM,{code:p}),s.jsx("pre",{children:p})]}):s.jsx("pre",{className:"af-display-picker-preview__pre",children:p}):s.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function EM({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const i=m.useRef(null),o=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[u,p]=m.useState({visible:!1,top:0,height:100}),f=m.useCallback(()=>{const g=i.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),_=k>x+1,S=_?Math.max(12,x/k*100):100,N=Math.max(0,100-S),I=_?Math.min(N,g.scrollTop/Math.max(1,k-x)*N):0;p({visible:_,top:I,height:S})},[]);m.useEffect(()=>{const g=requestAnimationFrame(f),k=i.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(f);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[f,e]);const d=m.useCallback(g=>{const k=i.current;if(!k)return;const x=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*x,f()},[f]),h=m.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const _=x.getBoundingClientRect(),S=u.height/100*_.height,N=Math.max(1,_.height-S);return(g-_.top-k)/N},[u.height]),y=m.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),_=u.top/100*x.height,S=u.height/100*x.height,I=g.clientY>=x.top+_&&g.clientY<=x.top+_+S?g.clientY-x.top-_:S/2;d(h(g.clientY,I));const T=E=>{E.preventDefault(),d(h(E.clientY,I))},z=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z)},[h,d,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),x=i.current,_=Number((x==null?void 0:x.selectionStart)??k.length),S=Number((x==null?void 0:x.selectionEnd)??_),N=k.slice(0,_),I=k.slice(S),T=N&&!N.endsWith(`
|
|
243
|
+
`)?`
|
|
244
|
+
`:"",z=I&&!I.startsWith(`
|
|
245
|
+
`)?`
|
|
246
|
+
`:"",E=`${N}${T}${g}${z}${I}`;t==null||t(E),window.requestAnimationFrame(()=>{var D,L;const O=N.length+T.length+g.length;(D=i.current)==null||D.focus(),(L=i.current)==null||L.setSelectionRange(O,O)})},[t,e]),b=m.useCallback(async g=>{if(!r&&!(!g||l)){c(!0);try{const k=await(n==null?void 0:n(g)),x=String(k||"").trim();if(x){const _=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(``)}}finally{c(!1)}}},[v,n,r,l]);return s.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:g=>g.stopPropagation(),onDragOver:g=>{var x;Array.from(((x=g.dataTransfer)==null?void 0:x.items)||[]).some(_=>String((_==null?void 0:_.type)||"").startsWith("image/"))&&(g.preventDefault(),g.dataTransfer.dropEffect="copy")},onDrop:g=>{var x;const k=Array.from(((x=g.dataTransfer)==null?void 0:x.files)||[]).find(Nm);k&&(g.preventDefault(),b(k))},children:[s.jsxs("div",{className:"af-work-display-editor__toolbar",children:[s.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var g;return(g=o.current)==null?void 0:g.click()},"aria-label":"上传图片",title:"上传图片",children:s.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),s.jsx("input",{ref:o,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:g=>{var x;const k=(x=g.target.files)==null?void 0:x[0];g.target.value="",k&&b(k)}})]}),s.jsx("textarea",{ref:i,className:"af-work-display-editor__textarea",value:e,onChange:g=>t==null?void 0:t(g.target.value),onScroll:f,onKeyDown:g=>{g.key==="Escape"&&g.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),s.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:y,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function XJ({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),i=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(i.messages)?i.messages:[],a=String(i.draft||""),[l,c]=m.useState(a),u=m.useRef(!1),p=String(i.candidateContent||""),f=!!i.running,d=!!(t!=null&&t.readOnly),h=String(i.error||""),y=o.slice(-2);return m.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?s.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:v=>v.stopPropagation(),children:[s.jsxs("div",{className:"af-work-node-chat__head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"继续微调"}),s.jsx("span",{children:(t==null?void 0:t.label)||e})]}),s.jsx("button",{type:"button",onClick:()=>{var v;return(v=t==null?void 0:t.onCloseNodeChat)==null?void 0:v.call(t)},"aria-label":"关闭节点微调",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||f||h?s.jsxs("div",{className:"af-work-node-chat__messages",children:[y.map((v,b)=>s.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${v.role==="assistant"?"assistant":"user"}`,children:[s.jsx("span",{children:v.role==="assistant"?"AI":"你"}),s.jsx("p",{children:v.text})]},`${v.at||b}-${b}`)),f?s.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,h?s.jsx("div",{className:"af-work-node-chat__error",children:h}):null]}):null,s.jsxs("div",{className:"af-work-node-chat__composer",children:[s.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:f||d,"aria-label":"添加上下文",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),s.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:f||d,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:v=>{var g;u.current=!1;const b=v.currentTarget.value;c(b),(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onChange:v=>{var g;const b=v.target.value;c(b),u.current||(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onKeyDown:v=>{var b,g;v.isComposing||(b=v.nativeEvent)!=null&&b.isComposing||v.keyCode===229||(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),(g=t==null?void 0:t.onSendNodeChat)==null||g.call(t,e,l))}}),s.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:f||d||!l.trim(),onClick:()=>{var v;return(v=t==null?void 0:t.onSendNodeChat)==null?void 0:v.call(t,e,l)},"aria-label":"发送",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),p.trim()?s.jsx("div",{className:"af-work-node-chat__messages",children:s.jsxs("div",{className:"af-work-node-chat__msg af-work-node-chat__msg--assistant",children:[s.jsx("span",{children:"AI"}),s.jsx("p",{children:p})]})}):null]}):s.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:v=>{var b;v.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[s.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),s.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),s.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function QJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function ZJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function eX(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function lC(e,t=""){const n=da(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function tX(e,t){const n=eX(e),r=new Set,i=Dn(t)||"";di(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=lC(uo(t),i);return o&&r.add(o),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),p=lC(u,i);return p&&r.add(p),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function cC(e,t){const n=Dn(t)||"markdown";return`outputs/${ZJ((t==null?void 0:t.label)||e||n)}.${QJ(n)}`}async function IM({nodeId:e,data:t,filePath:n,content:r,setFileContent:i}){var o,a;if(n){const l=await Mb((t==null?void 0:t.flowParams)||{},n,r);i==null||i(r),(o=t==null?void 0:t.onSetDisplayNodeContent)==null||o.call(t,e,l,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${l}`});return}(a=t==null?void 0:t.onSetDisplayNodeContent)==null||a.call(t,e,r,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"})}function PM({id:e,data:t,selected:n,deleteNode:r}){var ne,re,ie;const i=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((Z,de)=>({slot:Z,idx:de})).sort((Z,de)=>{var Ne,He,ct,xt;const fe=String(((Ne=Z.slot)==null?void 0:Ne.name)||"").trim(),ge=String(((He=de.slot)==null?void 0:He.name)||"").trim();if(fe==="next"&&ge!=="next")return-1;if(ge==="next"&&fe!=="next")return 1;const Oe=String(((ct=Z.slot)==null?void 0:ct.type)||"").trim(),_e=String(((xt=de.slot)==null?void 0:xt.type)||"").trim();return Oe==="node"&&_e!=="node"?-1:_e==="node"&&Oe!=="node"?1:Z.idx-de.idx}),l=Dn(t),c=m.useRef(null),u=m.useRef(null),[p,f]=m.useState(0),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=m.useState(!1),[k,x]=m.useState(""),[_,S]=m.useState(""),[N,I]=m.useState(!1),[T,z]=m.useState(!1),E=m.useRef(null),O=uo(t),D=l==="markdown"?Oi(O):"",L=l==="markdown"?da(D,"markdown"):"",$=l==="markdown"?L?_:D:"",V=!!(t!=null&&t.readOnly),B=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let Z=!1;return l!=="markdown"||!L?(S(""),I(!1),()=>{Z=!0}):(I(!0),hl((t==null?void 0:t.flowParams)||{},L).then(de=>{Z||S(de)}).catch(de=>{var fe;Z||(S(""),(fe=t==null?void 0:t.onStatus)==null||fe.call(t,String(de.message||de)))}).finally(()=>{Z||I(!1)}),()=>{Z=!0})},[l,L,(ne=t==null?void 0:t.flowParams)==null?void 0:ne.flowId,(re=t==null?void 0:t.flowParams)==null?void 0:re.flowSource,(ie=t==null?void 0:t.flowParams)==null?void 0:ie.archived,t==null?void 0:t.displayReloadKey]),m.useEffect(()=>{if(!y)return;const Z=()=>v(!1);return window.addEventListener("pointerup",Z,!0),window.addEventListener("pointercancel",Z,!0),window.addEventListener("mouseup",Z,!0),window.addEventListener("blur",Z),()=>{window.removeEventListener("pointerup",Z,!0),window.removeEventListener("pointercancel",Z,!0),window.removeEventListener("mouseup",Z,!0),window.removeEventListener("blur",Z)}},[y]),m.useEffect(()=>{b||x(String($||""))},[$,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),R=String((t==null?void 0:t.sourceNodeId)||e),H=(t==null?void 0:t.sharingDisplayNodeId)===R,A=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,X=m.useCallback(async()=>{var Re,lt,kt,Ot,_t,Xt,ae,ke,Ue,it;if(l!=="html"||d)return;const Z=uo(t),de=da(Z,l);let fe=Z;if(de)try{fe=await hl((t==null?void 0:t.flowParams)||{},de)}catch(Ee){h(!1),console.warn("Failed to read HTML display file before saving image.",Ee);return}const ge=su(fe);if(!ge.trim())return;const Oe=Ka(l,ge);if(Oe){console.warn(Oe);return}const _e=(lt=(Re=u.current)==null?void 0:Re.getBoundingClientRect)==null?void 0:lt.call(Re),Ne=(Ot=(kt=c.current)==null?void 0:kt.querySelector)==null?void 0:Ot.call(kt,".af-work-display-body"),He=(Xt=(_t=c.current)==null?void 0:_t.querySelector)==null?void 0:Xt.call(_t,".af-visible-scroll-frame__scroller"),ct=Math.round(Math.max(Number((_e==null?void 0:_e.width)||0),Number((A==null?void 0:A.width)||0),Number(((ae=c.current)==null?void 0:ae.clientWidth)||0),Number((Ne==null?void 0:Ne.clientWidth)||0),Number((He==null?void 0:He.clientWidth)||0),Math.max(320,Number((A==null?void 0:A.width)||960)-2))),xt=Math.round(Math.max(Number((_e==null?void 0:_e.height)||0),Number((A==null?void 0:A.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((Ne==null?void 0:Ne.clientHeight)||0),Number((He==null?void 0:He.clientHeight)||0),Math.max(180,Number((A==null?void 0:A.height)||640)-46)));h(!0);try{await qJ({flowParams:(t==null?void 0:t.flowParams)||{},content:ge,sourceFilePath:de,iframe:u.current,width:ct,height:xt,filename:WJ((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:Ne,scroller:He},displaySize:A}),(Ue=t==null?void 0:t.onStatus)==null||Ue.call(t,"已导出 HTML 展示截图")}catch(Ee){const Kt=String((Ee==null?void 0:Ee.message)||Ee||"截图失败");(it=t==null?void 0:t.onStatus)==null||it.call(t,`HTML 截图失败:${Kt}`),console.warn("Failed to save HTML display as PNG.",Ee)}finally{h(!1)}},[t,A==null?void 0:A.height,A==null?void 0:A.width,e,l,d]),K=m.useCallback(Z=>{var de;V||!Z||l!=="image"||(de=t==null?void 0:t.onUploadImageToDisplayNode)==null||de.call(t,e,Z)},[t,e,l,V]),W=m.useCallback(Z=>{var de,fe;(de=Z==null?void 0:Z.stopPropagation)==null||de.call(Z),!V&&((fe=t==null?void 0:t.onSetDisplayNodeContent)==null||fe.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),g(!1)))},[t,e,l,V]),te=m.useCallback(Z=>{var ge,Oe;V||l!=="image"||!(Array.from(((ge=Z.dataTransfer)==null?void 0:ge.files)||[]).some(Nm)||Array.from(((Oe=Z.dataTransfer)==null?void 0:Oe.items)||[]).some(_e=>String((_e==null?void 0:_e.type)||"").startsWith("image/")))||(Z.preventDefault(),Z.stopPropagation(),Z.dataTransfer.dropEffect="copy",z(!0))},[l,V]),ee=m.useCallback(Z=>{l==="image"&&(Z.currentTarget.contains(Z.relatedTarget)||z(!1))},[l]),G=m.useCallback(Z=>{var fe;if(l!=="image")return;const de=Array.from(((fe=Z.dataTransfer)==null?void 0:fe.files)||[]).find(Nm);de&&(Z.preventDefault(),Z.stopPropagation(),z(!1),K(de))},[l,K]);return s.jsxs("div",{className:"af-work-display-card"+(A?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(T?" af-work-display-card--image-drop":"")+(B?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:A?{width:A.width,height:A.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:te,onDragLeave:ee,onDrop:G,children:[s.jsx(ov,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>v(!0),onResizeEnd:()=>v(!1),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.map((Z,de)=>{if(Z.showOnNode===!1)return null;const fe=`${4.15+de*1.75}rem`,ge=Z.name||`#${de+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:fe},children:ge}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${de}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:fe,background:zn(Z.type)},title:`${ge} · ${Z.type}`})]},`in-${de}`)}),a.map(({slot:Z,idx:de},fe)=>{if(Z.showOnNode===!1)return null;const ge=`${4.15+fe*1.75}rem`,Oe=Z.name||`#${de+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:ge},children:Oe}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${de}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:ge,background:zn(Z.type)},title:`${Oe} · ${Z.type}`})]},`out-${de}`)}),s.jsxs("div",{className:"af-work-display-card__head",children:[s.jsxs("div",{className:"af-work-display-card__title",children:[s.jsx("span",{className:"material-symbols-outlined",children:_M(l)}),s.jsx("strong",{children:F}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?s.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Z=>Z.stopPropagation(),children:[s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Z,de,fe,ge;try{(ge=(fe=(de=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:de.history)==null?void 0:fe.back)==null||ge.call(fe)}catch{}},"aria-label":"后退",title:"后退",children:s.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Z,de,fe,ge;try{(ge=(fe=(de=(Z=u.current)==null?void 0:Z.contentWindow)==null?void 0:de.history)==null?void 0:fe.forward)==null||ge.call(fe)}catch{}},"aria-label":"前进",title:"前进",children:s.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>f(Z=>Z+1),"aria-label":"刷新",title:"刷新",children:s.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:d,onClick:X,"aria-label":"截图另存为图片",title:"截图另存为图片",children:s.jsx("span",{className:"material-symbols-outlined",children:d?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?s.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Z=>Z.stopPropagation(),children:[s.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:V||N,onClick:async()=>{var Z;try{await IM({nodeId:e,data:t,filePath:L,content:k,setFileContent:S}),g(!1)}catch(de){(Z=t==null?void 0:t.onStatus)==null||Z.call(t,String(de.message||de))}},"aria-label":"保存并预览",title:"保存并预览",children:s.jsx("span",{className:"material-symbols-outlined",children:"done"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{x(String($||"")),g(!1)},"aria-label":"取消编辑",title:"取消编辑",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V||N,onClick:Z=>{Z.stopPropagation(),x(String($||"")),g(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:s.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:E,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Z=>{var fe;const de=(fe=Z.target.files)==null?void 0:fe[0];Z.target.value="",de&&K(de)}}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:Z=>{var de;Z.stopPropagation(),(de=E.current)==null||de.click()},"aria-label":"上传图片",title:"上传图片",children:s.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:Z=>{var de;Z.stopPropagation(),(de=t==null?void 0:t.onOpenDisplayPreview)==null||de.call(t,R)},"aria-label":"全屏预览",title:"全屏预览",children:s.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:H,onClick:Z=>{var de;Z.stopPropagation(),(de=t==null?void 0:t.onShareDisplayNode)==null||de.call(t,R)},"aria-label":"分享展示",title:"分享展示",children:s.jsx("span",{className:"material-symbols-outlined",children:H?"hourglass_empty":"ios_share"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:W,"aria-label":"清空内容",title:"清空内容",children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:()=>{var Z;return(Z=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:Z.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"save"})}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:V,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?s.jsx(EM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:V}):s.jsx(AM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:p}),s.jsx(XJ,{nodeId:e,data:t})]})}function nX({id:e,data:t,selected:n,deleteNode:r}){var p,f,d;const i=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((f=(p=t==null?void 0:t.runningRunNodeIds)==null?void 0:p.has)==null?void 0:f.call(p,e))||((d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d[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 s.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:[i.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:b}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:zn(h.type)},title:`${b} · ${h.type}`})]},`in-${y}`)}),o.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=h.name||`#${y+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:b}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:zn(h.type)},title:`${b} · ${h.type}`})]},`out-${y}`)}),s.jsxs("div",{className:"af-work-run-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-run-card__actions",children:[s.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:h=>{var y,v;h.stopPropagation(),a?(y=t==null?void 0:t.onStopWorkspaceNode)==null||y.call(t,e):(v=t==null?void 0:t.onRunWorkspaceNode)==null||v.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),s.jsx("span",{children:a?"Stop":"Run line"})]}),s.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOptimizeWorkspaceRun)==null||y.call(t,e)},children:s.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),s.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:h=>{var y;h.stopPropagation(),(y=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||y.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:s.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function rX({id:e,data:t,selected:n,deleteNode:r,skills:i,skillCollections:o,workspaces:a}){var it,Ee,Kt,en,Ut,wt,mn;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=xX(t),[p,f]=m.useState(u.task),d=m.useRef(!1),h=m.useRef(u.task),y=((Ee=(it=t==null?void 0:t.runningRunNodeIds)==null?void 0:it.has)==null?void 0:Ee.call(it,e))||((Kt=t==null?void 0:t.runningRunNodeIds)==null?void 0:Kt[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",v=(t==null?void 0:t.nodeStatus)==="stopped",b=!!(t!=null&&t.readOnly),g=Array.isArray(i)?i:[],k=Array.isArray(o)?o:[],x=m.useMemo(()=>(Array.isArray(a)?a:[]).map(se=>({id:String((se==null?void 0:se.id)||""),label:String((se==null?void 0:se.label)||(se==null?void 0:se.name)||"知识库"),kind:(se==null?void 0:se.kind)==="git"?"git":"local",path:String((se==null?void 0:se.path)||""),repoUrl:String((se==null?void 0:se.repoUrl)||""),branch:String((se==null?void 0:se.branch)||""),mountPath:String((se==null?void 0:se.mountPath)||""),builtin:(se==null?void 0:se.builtin)===!0,exists:(se==null?void 0:se.exists)!==!1,type:String((se==null?void 0:se.type)||"")})).filter(se=>se.path),[a]),[_,S]=m.useState(!1),[N,I]=m.useState(""),[T,z]=m.useState(()=>new Set),[E,O]=m.useState(!1),[D,L]=m.useState(""),[$,V]=m.useState("config"),B=Ng(t),F=!!B,R=DM(u.displayType),H=m.useMemo(()=>OJ(t,R),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,R]),A=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:R,displaySize:H,nodeSize:H,body:B,inputs:[{type:"text",name:R==="display_image"?"src":"content",value:B,default:B}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,R,e,B,c,H]),X=Array.isArray((en=t==null?void 0:t.modelLists)==null?void 0:en.cursor)?t.modelLists.cursor:[],K=Array.isArray((Ut=t==null?void 0:t.modelLists)==null?void 0:Ut.opencode)?t.modelLists.opencode:[],W=Array.isArray((wt=t==null?void 0:t.modelLists)==null?void 0:wt.claudeCode)?t.modelLists.claudeCode:[],te=Array.isArray((mn=t==null?void 0:t.modelLists)==null?void 0:mn.codex)?t.modelLists.codex:[],ee=m.useMemo(()=>new Set(X.map(Ps)),[X]),G=m.useMemo(()=>new Set(K.map(Ps)),[K]),ne=m.useMemo(()=>new Set(W.map(Ps)),[W]),re=m.useMemo(()=>new Set(te.map(Ps)),[te]),ie=u.model,Z=m.useMemo(()=>ie?ie.startsWith("cursor:")||ie.startsWith("opencode:")||ie.startsWith("codex:")||ie.startsWith("claude-code:")?ie:ne.has(ie)?`claude-code:${ie}`:re.has(ie)?`codex:${ie}`:G.has(ie)?`opencode:${ie}`:ee.has(ie)?`cursor:${ie}`:ie:"",[ne,re,ee,G,ie]),de=ie.startsWith("cursor:")?ie.slice(7):ie.startsWith("opencode:")?ie.slice(9):ie.startsWith("codex:")?ie.slice(6):ie.startsWith("claude-code:")?ie.slice(12):ie,fe=de,ge=!!ie&&!ee.has(fe)&&!G.has(fe)&&!ne.has(fe)&&!re.has(fe),Oe=m.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),_e=m.useMemo(()=>new Map(g.map(se=>[se.key,se])),[g]),Ne=m.useMemo(()=>{const se=new Set,Ce=k.map(ze=>{const Nt=ca(ze,g).map(St=>_e.get(St)).filter(Boolean);for(const St of Nt)se.add(St.key);return{...ze,skills:Nt}}).filter(ze=>ze.skills.length>0),Ye=g.filter(ze=>!se.has(ze.key));return{collectionGroups:Ce,ungrouped:Ye}},[k,_e,g]);m.useEffect(()=>{z(se=>{let Ce=!1;const Ye=new Set(se);for(const ze of Ne.collectionGroups)Ye.has(ze.id)||(Ye.add(ze.id),Ce=!0);return Ce?Ye:se})},[Ne.collectionGroups]);const He=m.useMemo(()=>{const se=N.trim().toLowerCase();if(!se)return Ne;const Ce=ze=>[ze==null?void 0:ze.key,ze==null?void 0:ze.name,ze==null?void 0:ze.description].map(Nt=>String(Nt||"").toLowerCase()).join(" ").includes(se);return{collectionGroups:Ne.collectionGroups.map(ze=>{const Nt=[ze==null?void 0:ze.id,ze==null?void 0:ze.name,ze==null?void 0:ze.description].map(St=>String(St||"").toLowerCase()).join(" ").includes(se);return{...ze,skills:Nt?ze.skills:ze.skills.filter(Ce)}}).filter(ze=>ze.skills.length>0),ungrouped:Ne.ungrouped.filter(Ce)}},[Ne,N]),ct=$b(_,[He.collectionGroups.length,He.ungrouped.length,T.size,u.skillKeys.length,N]),xt=m.useMemo(()=>{const se=D.trim().toLowerCase();return se?x.filter(Ce=>[Ce.id,Ce.label,Ce.path,Ce.repoUrl,Ce.branch,Ce.mountPath,Ce.type].join(" ").toLowerCase().includes(se)):x},[x,D]),Re=m.useMemo(()=>BM(u.knowledgeContext),[u.knowledgeContext]),lt=m.useMemo(()=>new Set(Re.map(se=>se.id||se.path||se.repoPath).filter(Boolean)),[Re]),kt=$b(E,[xt.length,Re.length,D]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,d.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!F){V("config");return}y||V("result")},[F,B,y]),m.useEffect(()=>{var Ce,Ye;if(!($==="result"&&F))return;(Ce=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Ce.call(t,e,H),(Ye=t==null?void 0:t.onRefreshNodeInternals)==null||Ye.call(t,e);const se=window.setTimeout(()=>{var ze;return(ze=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:ze.call(t,e)},120);return()=>window.clearTimeout(se)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,R,F,e,B,H,$]);const Ot=se=>{var Ce;(Ce=t==null?void 0:t.onChangeContextRunConfig)==null||Ce.call(t,e,{...u,task:p,...se})},_t=(se=p)=>{var Ye;const Ce=String(se??"");Ce!==u.task&&(h.current=Ce,(Ye=t==null?void 0:t.onChangeContextRunConfig)==null||Ye.call(t,e,{...u,task:Ce}))},Xt=(se,Ce)=>{const Ye=new Set(u.skillKeys);for(const ze of se){const Nt=String(ze||"").trim();Nt&&(Ce?Ye.add(Nt):Ye.delete(Nt))}Ot({skillKeys:Array.from(Ye)})},ae=se=>{z(Ce=>{const Ye=new Set(Ce);return Ye.has(se)?Ye.delete(se):Ye.add(se),Ye})},ke=(se,Ce)=>{const Ye=(se==null?void 0:se.id)||(se==null?void 0:se.path)||"";if(!Ye)return;const ze=x.filter(Nt=>{const St=Nt.id||Nt.path||"";return St===Ye?Ce:lt.has(St)});Ot({knowledgeContext:_g(ze)})},Ue=()=>{Ot({knowledgeContext:null})};return $==="result"&&F?s.jsx(PM,{id:e,data:{...A,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):s.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+($==="result"&&F?" af-work-context-run-card--result":"")+(y?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(v?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((se,Ce)=>{if(se.showOnNode===!1)return null;const Ye=`${2.25+Ce*1.75}rem`,ze=se.name||`#${Ce+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Ye},children:ze}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${Ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Ye,background:zn(se.type)},title:`${ze} · ${se.type}`})]},`in-${Ce}`)}),c.map((se,Ce)=>{if(se.showOnNode===!1)return null;const Ye=`${2.25+Ce*1.75}rem`,ze=se.name||`#${Ce+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Ye},children:ze}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${Ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Ye,background:zn(se.type)},title:`${ze} · ${se.type}`})]},`out-${Ce}`)}),s.jsxs("div",{className:"af-work-context-run-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"automation"}),s.jsx("strong",{children:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"}),s.jsxs("div",{className:"af-work-context-run-card__model-wrap nodrag",onPointerDown:se=>se.stopPropagation(),onMouseDown:se=>se.stopPropagation(),onClick:se=>se.stopPropagation(),children:[s.jsxs("select",{className:"af-work-context-run-card__model",value:Z,disabled:b,"aria-label":"模型",title:de||"默认模型",onChange:se=>Ot({model:se.target.value}),children:[s.jsx("option",{value:"",children:"默认"}),ge?s.jsx("option",{value:ie,children:ie}):null,X.length?s.jsx("optgroup",{label:"Cursor",children:X.map(se=>s.jsx("option",{value:`cursor:${Ps(se)}`,children:Ps(se)},`context-cursor-${se}`))}):null,K.length?s.jsx("optgroup",{label:"OpenCode",children:K.map(se=>s.jsx("option",{value:`opencode:${Ps(se)}`,children:Ps(se)},`context-opencode-${se}`))}):null,te.length?s.jsx("optgroup",{label:"Codex",children:te.map(se=>s.jsx("option",{value:`codex:${Ps(se)}`,children:Ps(se)},`context-codex-${se}`))}):null,W.length?s.jsx("optgroup",{label:"Claude Code",children:W.map(se=>s.jsx("option",{value:`claude-code:${Ps(se)}`,children:Ps(se)},`context-claude-${se}`))}):null]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"expand_more"})]}),s.jsx("span",{className:"af-work-context-run-card__kind",children:di(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),F?s.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:se=>se.stopPropagation(),children:[s.jsx("button",{type:"button",className:$==="config"?"is-active":"",onClick:()=>V("config"),"aria-label":"切换到任务配置",children:s.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),s.jsx("button",{type:"button",className:$==="result"?"is-active":"",onClick:()=>V("result"),"aria-label":"切换到展示结果",children:s.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:b,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-context-run-card__body nodrag",children:[s.jsxs(s.Fragment,{children:[s.jsx("textarea",{value:p,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{d.current=!0},onCompositionEnd:se=>{d.current=!1,f(se.currentTarget.value),_t(se.currentTarget.value)},onChange:se=>{f(se.target.value)},onBlur:se=>_t(se.currentTarget.value)}),s.jsxs("div",{className:"af-work-context-run-card__grid",children:[s.jsxs("div",{className:"af-work-context-run-card__skills",children:[s.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:se=>{var Ce;se.stopPropagation(),_||(Ce=t==null?void 0:t.onRefreshSkills)==null||Ce.call(t),S(Ye=>!Ye)},children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),s.jsx("span",{children:u.skillKeys.length?`${u.skillKeys.length} skills`:"Skills"}),s.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),_?s.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:N,onChange:se=>I(se.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),N?s.jsx("button",{type:"button",onClick:()=>I(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:ct.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:ct.updateMenuScrollbar,children:[He.collectionGroups.map(se=>{const Ce=se.skills.map(St=>St.key),Ye=Ce.filter(St=>Oe.has(St)).length,ze=Ce.length>0&&Ye===Ce.length,Nt=T.has(se.id);return s.jsxs("section",{className:"af-work-load-skills-menu__group"+(Nt?" af-work-load-skills-menu__group--collapsed":""),children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[s.jsx("input",{type:"checkbox",checked:ze,disabled:b,onChange:St=>Xt(Ce,St.target.checked),"aria-label":`选择 ${se.name}`}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>ae(se.id),"aria-expanded":!Nt,children:s.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[s.jsx("span",{children:se.name}),se.description?s.jsx("em",{children:se.description}):null]})}),s.jsxs("small",{children:[Ye,"/",Ce.length]}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>ae(se.id),"aria-label":Nt?`展开 ${se.name}`:`收起 ${se.name}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Nt?"chevron_right":"expand_more"})})]}),Nt?null:s.jsx("div",{className:"af-work-load-skills-menu__options",children:se.skills.map(St=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:Oe.has(St.key),disabled:b,onChange:Gn=>Xt([St.key],Gn.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:St.name}),St.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:St.description}):null]})]},`${se.id}:${St.key}`))})]},se.id)}),He.ungrouped.length>0?s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"Ungrouped"}),s.jsx("small",{children:He.ungrouped.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:He.ungrouped.map(se=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:Oe.has(se.key),disabled:b,onChange:Ce=>Xt([se.key],Ce.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:se.name}),se.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:se.description}):null]})]},`ungrouped:${se.key}`))})]}):null,He.collectionGroups.length===0&&He.ungrouped.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>Ot({skillKeys:[]}),children:"清空"})]}),s.jsx("div",{ref:ct.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(ct.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:ct.handleScrollbarPointerDown,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${ct.scrollbar.height}%`,top:`${ct.scrollbar.top}%`}})})]}):null]}),s.jsxs("div",{className:"af-work-context-run-card__workspace",children:[s.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:se=>{var Ce;se.stopPropagation(),E||(Ce=t==null?void 0:t.onRefreshWorkspaces)==null||Ce.call(t),O(Ye=>!Ye)},children:[s.jsx("span",{className:"material-symbols-outlined",children:Re.length?"folder_open":"folder_off"}),s.jsx("span",{children:Re.length?`${Re.length} 知识库`:"知识库"}),s.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),E?s.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:D,onChange:se=>L(se.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),D?s.jsx("button",{type:"button",onClick:()=>L(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:kt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:kt.updateMenuScrollbar,children:[s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"知识库"}),s.jsx("small",{children:xt.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:xt.map(se=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:lt.has(se.id||se.path),disabled:b,onChange:Ce=>ke(se,Ce.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:se.label}),s.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[se.kind==="git"&&se.repoUrl?`${se.repoUrl}${se.branch?` · ${se.branch}`:""}${se.mountPath?` · ${se.mountPath}`:""}`:se.path,se.exists?"":" · 路径未就绪"]})]})]},`${se.id}:${se.path}`))})]}),xt.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:Ue,children:"清空知识库"})]}),s.jsx("div",{ref:kt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(kt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:kt.handleScrollbarPointerDown,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${kt.scrollbar.height}%`,top:`${kt.scrollbar.top}%`}})})]}):null]}),s.jsxs("select",{value:u.displayType,disabled:b,onChange:se=>Ot({displayType:se.target.value}),children:[s.jsx("option",{value:"markdown",children:"Markdown"}),s.jsx("option",{value:"html",children:"HTML"}),s.jsx("option",{value:"react",children:"React"}),s.jsx("option",{value:"table",children:"Table"}),s.jsx("option",{value:"chart",children:"Chart"}),s.jsx("option",{value:"ascii",children:"ASCII"}),s.jsx("option",{value:"mermaid",children:"Mermaid"})]})]}),B?s.jsx("pre",{className:"af-work-context-run-card__preview",children:B.slice(0,520)}):null]}),s.jsxs("div",{className:"af-work-context-run-card__actions",children:[s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(y?" af-work-run-card__button--stop":""),disabled:b,onClick:se=>{var Ce,Ye;se.stopPropagation(),_t(),y?(Ce=t==null?void 0:t.onStopWorkspaceNode)==null||Ce.call(t,e):(Ye=t==null?void 0:t.onRunWorkspaceNode)==null||Ye.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:y?"stop_circle":"play_arrow"}),s.jsx("span",{children:y?"Stop":"Run"})]}),s.jsx("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__logs nodrag",onClick:se=>{var Ce;se.stopPropagation(),(Ce=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Ce.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"})},children:s.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})]})}function sX({id:e,data:t,selected:n,deleteNode:r}){var I,T,z;const i=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=Lv((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},p=((T=(I=t==null?void 0:t.runningRunNodeIds)==null?void 0:I.has)==null?void 0:T.call(I,e))||((z=t==null?void 0:t.runningRunNodeIds)==null?void 0:z[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",f=(t==null?void 0:t.optimizingRun)===!0,d=(t==null?void 0:t.nodeStatus)==="stopped",h=!!(t!=null&&t.readOnly),y=E=>{var O;(O=t==null?void 0:t.onChangeScheduledRunConfig)==null||O.call(t,e,{...a,...E})},v=E=>{y({scheduleType:E,cron:cd(E,a.time,a.weekday,a.monthDay,a.cron)})},b=E=>{y({time:E,cron:cd(a.scheduleType,E,a.weekday,a.monthDay,a.cron)})},[g,k]=$v(a.time).split(":"),x=(E,O)=>{b(`${Yo(E,9,0,23)}:${Yo(O,0,0,59)}`)},_=E=>{y({weekday:E,cron:cd(a.scheduleType,a.time,E,a.monthDay,a.cron)})},S=E=>{y({monthDay:E,cron:cd(a.scheduleType,a.time,a.weekday,E,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const N=()=>{h||l===a.cron||y({cron:l})};return s.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(p?" 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:[i.map((E,O)=>{if(E.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=E.name||`#${O+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:L}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${O}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:zn(E.type)},title:`${L} · ${E.type}`})]},`in-${O}`)}),o.map((E,O)=>{if(E.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=E.name||`#${O+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:L}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${O}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:zn(E.type)},title:`${L} · ${E.type}`})]},`out-${O}`)}),s.jsxs("div",{className:"af-work-run-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:h,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[s.jsxs("label",{className:"af-work-schedule-card__toggle",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,disabled:h,onChange:E=>y({enabled:E.target.checked})}),s.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"频率"}),s.jsxs("select",{value:a.scheduleType,disabled:h,onChange:E=>v(E.target.value),children:[s.jsx("option",{value:"daily",children:"每天"}),s.jsx("option",{value:"weekly",children:"每周"}),s.jsx("option",{value:"monthly",children:"每月"}),s.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"时间"}),s.jsxs("div",{className:"af-work-schedule-time-selects",children:[s.jsx("select",{value:g,disabled:h,"aria-label":"小时",onChange:E=>x(E.target.value,k),children:Array.from({length:24},(E,O)=>Yo(O,0,0,23)).map(E=>s.jsxs("option",{value:E,children:[E," 时"]},E))}),s.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:E=>x(g,E.target.value),children:Array.from({length:12},(E,O)=>Yo(O*5,0,0,59)).map(E=>s.jsxs("option",{value:E,children:[E," 分"]},E))})]})]}):null,a.scheduleType==="weekly"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"星期"}),s.jsxs("select",{value:a.weekday,disabled:h,onChange:E=>_(E.target.value),children:[s.jsx("option",{value:1,children:"周一"}),s.jsx("option",{value:2,children:"周二"}),s.jsx("option",{value:3,children:"周三"}),s.jsx("option",{value:4,children:"周四"}),s.jsx("option",{value:5,children:"周五"}),s.jsx("option",{value:6,children:"周六"}),s.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"日期"}),s.jsx("select",{value:a.monthDay,disabled:h,onChange:E=>S(E.target.value),children:Array.from({length:31},(E,O)=>O+1).map(E=>s.jsxs("option",{value:E,children:[E," 日"]},E))})]}):null,a.scheduleType==="custom"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"Cron"}),s.jsx("input",{type:"text",value:l,disabled:h,spellCheck:!1,placeholder:df,onChange:E=>c(E.target.value),onBlur:N,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}})]}):null,s.jsxs("div",{className:"af-work-schedule-card__meta",children:[s.jsxs("span",{children:[jJ(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),s.jsxs("span",{children:["Next ",SJ(u.nextAt)]}),s.jsx("span",{children:p?"running":u.lastStatus||"idle"})]}),u.lastError?s.jsx("div",{className:"af-work-schedule-card__error",children:u.lastError}):null,s.jsxs("div",{className:"af-work-schedule-card__actions",children:[s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(p?" af-work-run-card__button--stop":""),disabled:h||f,onClick:E=>{var O,D;E.stopPropagation(),p?(O=t==null?void 0:t.onStopWorkspaceNode)==null||O.call(t,e):(D=t==null?void 0:t.onRunWorkspaceNode)==null||D.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:p?"stop_circle":"play_arrow"}),s.jsx("span",{children:p?"停止":"立即运行"})]}),s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(f?" af-work-schedule-card__optimize--running":""),disabled:h||p||f,title:"为下游节点提前生成 implementation",onClick:E=>{var O;E.stopPropagation(),(O=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||O.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:f?"sync":"auto_fix_high"}),s.jsx("span",{children:f?"优化中":"优化"})]}),s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:E=>{var O;E.stopPropagation(),(O=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||O.call(t,{nodeId:e,scheduleNodeId:e,runNodeId:u.targetRunNodeId||e,lastRunId:u.lastRunId||"",label:(t==null?void 0:t.label)||"Scheduled Run"})},children:[s.jsx("span",{className:"material-symbols-outlined",children:"article"}),s.jsx("span",{children:"日志"})]})]})]})]})}function iX({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:i}=tu(),o=!!(t!=null&&t.readOnly),a=Pb(t==null?void 0:t.nodeSize)||{width:ul,height:dl},l=m.useCallback(c=>{var u,p;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(p=(u=c.target)==null?void 0:u.closest)!=null&&p.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||i(f=>MM(f,e))},[e,i]);return s.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[o?null:s.jsx(ov,{className:"af-work-group-node__resize nodrag",minWidth:ul,minHeight:dl,position:"bottom-right",children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),s.jsxs("div",{className:"af-work-group-node__title nodrag",children:[s.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),s.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:o,onClick:c=>{c.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function oX(e){var y,v,b,g,k,x,_,S,N,I,T,z,E,O,D,L,$,V,B,F,R,H,A,X,K,W,te,ee;const{setEdges:t,setNodes:n}=tu(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,i=!!((v=e.data)!=null&&v.readOnly),[o,a]=m.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,c=m.useCallback(G=>{var ie,Z,de;if(i)return;(Z=(ie=e.data)==null?void 0:ie.onCleanupWorkspaceNodeOutputs)==null||Z.call(ie,G,e.data);const ne=di((de=e.data)==null?void 0:de.definitionId)?FM(G):"",re=new Set([G,ne].filter(Boolean));n(fe=>fe.filter(ge=>!re.has(ge.id))),t(fe=>fe.filter(ge=>!re.has(ge.source)&&!re.has(ge.target)))},[e.data,i,t,n]),u=m.useCallback(G=>{var ne,re;G.button!==0||G.metaKey||G.ctrlKey||G.shiftKey||(re=(ne=G.target)==null?void 0:ne.closest)!=null&&re.call(ne,".react-flow__handle, .af-work-display-resize")||(n(ie=>MM(ie,e.id)),t(ie=>uX(ie)))},[e.id,t,n]),p=m.useCallback((G,ne)=>{i||(n(re=>re.map(ie=>ie.id===G?{...ie,data:{...ie.data,model:ne}}:ie)),r==null||r(G,{model:ne}))},[i,n,r]),f=m.useCallback((G,ne)=>{i||(n(re=>re.map(ie=>{var de;if(ie.id!==G)return ie;const Z=Array.isArray((de=ie.data)==null?void 0:de.outputs)&&ie.data.outputs.length?ie.data.outputs.map((fe,ge)=>ge===0?{...fe,default:ne,value:ne}:fe):[{type:"bool",name:"value",default:ne,value:ne}];return{...ie,data:{...ie.data,body:"",outputs:Z}}})),r==null||r(G,re=>({body:"",outputs:Array.isArray(re==null?void 0:re.outputs)&&re.outputs.length?re.outputs.map((Z,de)=>de===0?{...Z,default:ne,value:ne}:Z):[{type:"bool",name:"value",default:ne,value:ne}]})))},[i,n,r]),d=m.useCallback((G,ne)=>{i||(n(re=>re.map(ie=>ie.id===G?{...ie,data:{...ie.data,body:ne}}:ie)),r==null||r(G,{body:ne}))},[i,n,r]),h=m.useCallback((G,ne)=>{if(i)return;const re=vo(ne);n(ie=>ie.map(Z=>Z.id===G?{...Z,data:{...Z.data,images:re}}:Z)),r==null||r(G,{images:re})},[i,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?s.jsx(iX,{...e,deleteNode:c}):pl((k=e.data)==null?void 0:k.definitionId)?s.jsx(PM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?s.jsx(nX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((_=e.data)==null?void 0:_.definitionId)==="workspace_scheduled_run"?s.jsx(sX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):di((S=e.data)==null?void 0:S.definitionId)?s.jsx(rX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(N=e.data)==null?void 0:N.skills,skillCollections:(I=e.data)==null?void 0:I.skillCollections,workspaces:(T=e.data)==null?void 0:T.workspaceTargets}):((z=e.data)==null?void 0:z.definitionId)==="control_load_skills"?s.jsx(_X,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(E=e.data)==null?void 0:E.skills,skillCollections:(O=e.data)==null?void 0:O.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((L=e.data)==null?void 0:L.definitionId)==="control_load_mcp"?s.jsx(CX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:($=e.data)==null?void 0:$.mcpServers,onChangeMcpNames:(V=e.data)==null?void 0:V.onChangeLoadMcpNames}):((B=e.data)==null?void 0:B.definitionId)==="control_cd_workspace"?s.jsx(AX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(F=e.data)==null?void 0:F.workspaceTargets,onChangeWorkspace:(R=e.data)==null?void 0:R.onChangeLoadWorkspace,onRefreshWorkspaces:(H=e.data)==null?void 0:H.onRefreshWorkspaces}):s.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((A=e.data)!=null&&A.isExecuting||((X=e.data)==null?void 0:X.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((K=e.data)==null?void 0:K.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((W=e.data)==null?void 0:W.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((te=e.data)==null?void 0:te.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[i?null:s.jsx(ov,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:lM,minHeight:jm,maxWidth:cM,maxHeight:uM,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.jsx(WU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(ee=e.data)==null?void 0:ee.modelLists,onModelChange:p,onProvideValueChange:f,onNodeBodyChange:d,onNodeImagesChange:h})]})}const aX={[Ec]:m.memo(oX)};function Ov(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Ov(n.children,t);return t}function TM(e,t){const n=String(t||"");if(!n)return null;for(const r of e||[]){if(r.path===n)return r;const i=Array.isArray(r.children)?TM(r.children,n):null;if(i)return i}return null}function lX(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function RM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&RM(n.children,t));return t}function eh(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 cX(e,t){const n=String(t||"");let r=!1;const i=(e||[]).map(o=>{const a=o.id===n;return o.selected===a?o:(r=!0,{...o,selected:a})});return r?i:e}function MM(e,t){const n=String(t||""),r=(e||[]).find(o=>o.id===n),i=(e||[]).reduce((o,a)=>o+(a.selected?1:0),0);return r!=null&&r.selected&&i>1?e:cX(e,n)}function uX(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function dX(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function fX(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const i=(o,a,l)=>{const c=r[a],u=l?`${l}/${c}`:c,p=a===r.length-1;let f=!1;const d=(Array.isArray(o)?o:[]).map(h=>h.name!==c?h:(f=!0,p?{...h,type:"file",name:c,path:u,icon:yc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:yc(c,!0),children:i(h.children||[],a+1,u)}));return f||d.push(p?{type:"file",name:c,path:u,icon:yc(c),size:n}:{type:"directory",name:c,path:u,icon:yc(c,!0),children:i([],a+1,u)}),dX(d)};return i(e||[],0,"")}function pX(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 $M({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:i,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}){return s.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var h;const p=u.type==="directory",f=p&&(r==null?void 0:r.has(u.path)),d=n===u.path;return s.jsxs("li",{children:[s.jsxs("div",{className:"af-work-file-row",children:[s.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+u.type+(d?" af-work-file--selected":""),draggable:!p,onDragStart:y=>{p||a==null||a(y,u)},onClick:()=>{o==null||o(u),p&&(i==null||i(u.path))},onDoubleClick:()=>{p||t(u)},title:u.path,children:[p?s.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:f?"chevron_right":"expand_more"}):null,s.jsx("span",{className:"material-symbols-outlined",children:u.icon||yc(u.name,p)}),s.jsx("span",{children:u.name})]}),d?s.jsxs("div",{className:"af-work-file-actions",children:[p?null:s.jsx("button",{type:"button",className:"af-work-file-action",onClick:y=>{y.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),s.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:y=>{y.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),p&&!f&&((h=u.children)!=null&&h.length)?s.jsx($M,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:i,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function hX({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:i,onClose:o}){const a=m.useMemo(()=>Ov(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(u=>l?`${u.path} ${u.name}`.toLowerCase().includes(l):!0);return s.jsx("div",{className:"af-flow-snippet-modal-overlay",onMouseDown:o,children:s.jsxs("div",{className:"af-flow-snippet-modal af-work-file-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择文件",onMouseDown:u=>u.stopPropagation(),children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"选择文件"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:o,"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-work-file-picker-modal__tools",children:[s.jsx("input",{value:t,onChange:u=>n(u.target.value),placeholder:"搜索文件路径...",autoFocus:!0}),s.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(""),children:[s.jsx("span",{className:"material-symbols-outlined",children:"upload_file"}),"上传"]})]}),s.jsxs("div",{className:"af-work-file-picker-modal__list",children:[c.map(u=>s.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(u),children:[s.jsx("span",{className:"material-symbols-outlined",children:u.icon||yc(u.name)}),s.jsxs("span",{className:"af-work-file-picker-modal__main",children:[s.jsx("strong",{children:u.name}),s.jsx("small",{children:u.path})]}),u.size?s.jsx("em",{children:pX(u.size)}):null]},u.path)),c.length===0?s.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function uC({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return s.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((i,o)=>{const a=i.kind==="run-log"||i.kind==="run-summary"||i.kind==="activity"||i.kind==="prompt"||i.kind==="raw"||i.kind==="thinking"||i.kind==="result"||i.kind==="assistant"?"reply":i.role==="user"?"user-msg":i.error?"error":"reply",l=i.kind==="run-summary"?"Steps":i.kind==="run-log"?"Run":i.kind==="activity"?"Activity":i.kind==="prompt"?"Prompt":i.kind==="raw"?"Raw Trace":i.kind==="thinking"?"Thinking":i.kind==="result"?"Result":i.kind==="assistant"?"Response":i.role==="user"?"You":i.error?"Error":"Reply";return s.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${i.kind?` af-composer-ai-block--kind-${i.kind}`:""}`,children:[s.jsx("div",{className:"af-composer-ai-block-label",children:l}),s.jsx("div",{className:"af-composer-ai-block-body",children:i.text})]},`${o}-${i.role}-${String(i.text||"").slice(0,24)}`)}),n&&t&&!r?s.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[s.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),s.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?s.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[s.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),s.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function LM(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function mX(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!LM(o));if(r.length>0)return r;const i=[...n].reverse().find(o=>(o==null?void 0:o.kind)==="result"||(o==null?void 0:o.kind)==="assistant"||(o==null?void 0:o.error));return i?[i]:n.length>0||t?[{role:"assistant",kind:"assistant",text:t?"正在执行,可以在完成后继续追问或要求调整。":"运行已完成。可以在下方继续追问、要求总结或调整结果。",at:0}]:[]}function gX(e){return(Array.isArray(e)?e:[]).filter(LM)}function hf(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 yX(e){const t=hf((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(i=>(i==null?void 0:i.name)==="skillsContext"||(i==null?void 0:i.name)==="skillKeys"||(i==null?void 0:i.type)==="text");return hf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function wX(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 hf((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function OM(e,t,n=1){const r=(Array.isArray(e)?e:[]).map(o=>String(o||"").trim()).filter(Boolean);return r.length?{head:r.slice(0,n).join("、"),extra:r.length>n?`等 ${r.length} 个`:"",title:r.join(", ")}:{head:t,extra:"",title:""}}function dC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function fa(e,t,n=""){const r=(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.name)===t);return String((r==null?void 0:r.value)??(r==null?void 0:r.default)??"").trim()||n}function Rm(e,t){const n=fa(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 Mf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Ps(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function DM(e){const t=Mf(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 FM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function zM(e){return e==="display_image"?"src":"content"}function fC(e,t,n){const r=zM(t),i=ud(e);let o=!1;const a=i.map(l=>(l==null?void 0:l.name)===r?(o=!0,{...l,default:n,value:n,showOnNode:l.showOnNode!==!1}):(l==null?void 0:l.name)==="filePath"?{...l,default:"",value:""}:l);return o||a.push({type:"text",name:r,default:n,value:n,required:!0,showOnNode:!0}),a}function pC(e,t,n=[],r=[]){const i=Array.isArray(e)?e:[],o=new Set((Array.isArray(n)?n:[]).map(u=>String(u||"").trim()).filter(Boolean)),a=new Set((Array.isArray(r)?r:[]).map(u=>String(u||"").trim()).filter(Boolean)),l=u=>(u==null?void 0:u.showOnNode)!==!1;let c=i.findIndex(u=>l(u)&&o.has(String((u==null?void 0:u.name)||"").trim()));return c<0&&(c=i.findIndex(u=>o.has(String((u==null?void 0:u.name)||"").trim()))),c<0&&(c=i.findIndex(u=>l(u)&&a.has(String((u==null?void 0:u.type)||"").trim()))),c<0&&(c=i.findIndex(u=>l(u))),c<0&&(c=0),`${t}-${c}`}function hC(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 Ng(e){const t=Array.isArray(e==null?void 0:e.outputs)?e.outputs:Array.isArray(e==null?void 0:e.output)?e.output:[],n=i=>String((i==null?void 0:i.value)??(i==null?void 0:i.default)??"").trim(),r=t.find(i=>((i==null?void 0:i.name)==="content"||(i==null?void 0:i.name)==="result")&&n(i))||t.find(i=>(i==null?void 0:i.name)==="resultFile"&&n(i))||t.find(i=>(i==null?void 0:i.type)!=="node"&&(i==null?void 0:i.name)!=="next"&&(i==null?void 0:i.name)!=="displayType"&&n(i));return r?n(r):""}function xX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=fa(t,"includeWorkspaceContext","true").toLowerCase(),r=Rm(t,"knowledgeContext"),i=Rm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:wX(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(i?_g([i]):null),workspaceContext:i,displayType:Mf(fa(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function di(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function bX(e){const t=hf((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(i=>(i==null?void 0:i.name)==="mcpContext"||(i==null?void 0:i.name)==="serverNames"||(i==null?void 0:i.type)==="text");return hf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function kX(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function WM(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(),i=String((e==null?void 0:e.label)||(e==null?void 0:e.name)||"").trim();if(!n&&!r&&!i)return null;const o=String(i||r||"知识库").trim();return{id:r,label:o,kind:(e==null?void 0:e.kind)==="git"?"git":"local",type:String((e==null?void 0:e.type)||""),repoPath:n,path:n,mountPath:String((e==null?void 0:e.mountPath)||r||o).trim(),repoUrl:String((e==null?void 0:e.repoUrl)||"").trim(),branch:String((e==null?void 0:e.branch)||"").trim(),readonly:!0,role:t}}function _g(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>WM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function BM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>WM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function vX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=Rm(t,"knowledgeContext"),r=Rm(t,"workspaceContext");return{sources:BM(n||(r?_g([r]):null)),path:fa(t,"path",""),label:fa(t,"label","")}}function mC(e){var r,i,o,a,l,c,u,p,f;if(!e)return null;const{inputs:t,outputs:n}=eG(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((i=e.data)==null?void 0:i.role)??"normal"),model:String(((o=e.data)==null?void 0:o.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:vo((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(((p=e.data)==null?void 0:p.implementationRef)??""),implementationMode:String(((f=e.data)==null?void 0:f.implementationMode)??""),inputs:t,outputs:n}}function gC(e,t,n,r=""){var c,u;const i=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(p=>String((p==null?void 0:p.id)||"")===i),a=String(((c=o==null?void 0:o.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[i])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function yC(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 SX(e,t,n){var p,f;const r=String(((p=e==null?void 0:e.data)==null?void 0:p.definitionId)??n),i=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=lf.includes(o)?o:"normal",l=String((t==null?void 0:t.model)||"").trim(),c={...e.data,label:String((t==null?void 0:t.label)||"").trim()||n,role:a,model:l===""||l==="default"?void 0:l,body:i?"":String((t==null?void 0:t.body)??""),images:i?[]:vo(t==null?void 0:t.images),inputs:yC(t==null?void 0:t.inputs),outputs:i&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:yC(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 d of["scriptRef","implementationRef","implementationMode"]){const h=String((t==null?void 0:t[d])??"").trim();h?c[d]=h:delete c[d]}return c}function wC({nodes:e,edges:t,instances:n,selectedNode:r,draft:i,allowRename:o=!1}){if(!i||!r)return{ok:!1,error:""};const a=r.id,l=String(i.newId||"").trim(),c=o?l:a;if(o){if(!SG.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(v=>v.id===c&&v.id!==a))return{ok:!1,error:"Duplicate instance id"}}const u=SX(r,i,c),p=r.data||{};if(!(c!==a||p.label!==u.label||p.role!==u.role||p.model!==u.model||p.body!==u.body||JSON.stringify(vo(p.images))!==JSON.stringify(u.images)||(p.script??void 0)!==(u.script??void 0)||(p.scriptRef??void 0)!==(u.scriptRef??void 0)||(p.implementationRef??void 0)!==(u.implementationRef??void 0)||(p.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(p.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(p.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const d=e.map(v=>v.id===a?{...v,id:c,selected:!0,data:u}:v);let h=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,h=t.map((b,g)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:d,edges:h,instances:y}}function jX(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function NX(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const i of["newId","label","role","model","body","images","script","scriptRef","implementationRef","implementationMode","inputs","outputs"])jX(e[i],t[i])&&(r[i]=n[i]);return r}function $b(e,t=[]){const n=m.useRef(null),r=m.useRef(null),[i,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,y=h?Math.max(12,d/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,p.scrollTop/Math.max(1,f-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{if(!e)return;const p=requestAnimationFrame(a);return()=>cancelAnimationFrame(p)},[e,a,...t]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=i.height/100*h.height,v=Math.max(1,h.height-y);return(p-h.top-f)/v},[i.height]),u=m.useCallback(p=>{var _,S;if(!i.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=i.top/100*d.height,y=i.height/100*d.height,b=p.clientY>=d.top+h&&p.clientY<=d.top+h+y?p.clientY-d.top-h:y/2;l(c(p.clientY,b));const g=p.pointerId;(S=(_=p.currentTarget).setPointerCapture)==null||S.call(_,g);const k=N=>{N.preventDefault(),l(c(N.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,i.height,i.top,i.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:i,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function _X({id:e,data:t,selected:n,deleteNode:r,skills:i,skillCollections:o,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=Array.isArray(i)?i:[],p=Array.isArray(o)?o:[],[f,d]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[x,_]=m.useState({visible:!1,top:0,height:100}),S=m.useMemo(()=>new Set(yX(t)),[t]),N=m.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),I=m.useMemo(()=>Array.from(S).map(F=>{var R;return((R=N.get(F))==null?void 0:R.name)||F}),[N,S]),T=m.useMemo(()=>OM(I,"选择 Skills"),[I]),z=m.useMemo(()=>{const F=new Set,R=p.map(A=>{const X=ca(A,u).map(K=>N.get(K)).filter(Boolean);for(const K of X)F.add(K.key);return{...A,skills:X}}).filter(A=>A.skills.length>0),H=u.filter(A=>!F.has(A.key));return{collectionGroups:R,ungrouped:H}},[N,p,u]);m.useEffect(()=>{b(F=>{let R=!1;const H=new Set(F);for(const A of z.collectionGroups)H.has(A.id)||(H.add(A.id),R=!0);return R?H:F})},[z.collectionGroups]);const E=m.useMemo(()=>{const F=h.trim().toLowerCase();if(!F)return z;const R=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(K=>String(K||"").toLowerCase()).join(" ").includes(F);return{collectionGroups:z.collectionGroups.map(A=>{const K=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(W=>String(W||"").toLowerCase()).join(" ").includes(F)?A.skills:A.skills.filter(R);return{...A,skills:K}}).filter(A=>A.skills.length>0),ungrouped:z.ungrouped.filter(R)}},[z,h]),O=m.useCallback((F,R)=>{const H=new Set(S);for(const A of F)R?H.add(A):H.delete(A);a==null||a(e,Array.from(H))},[e,S,a]),D=m.useCallback(F=>{b(R=>{const H=new Set(R);return H.has(F)?H.delete(F):H.add(F),H})},[]),L=m.useCallback(()=>{const F=g.current;if(!F)return;const R=Math.max(1,F.scrollHeight),H=Math.max(1,F.clientHeight),A=R>H+1,X=A?Math.max(12,H/R*100):100,K=Math.max(0,100-X),W=A?Math.min(K,F.scrollTop/Math.max(1,R-H)*K):0;_({visible:A,top:W,height:X})},[]);m.useEffect(()=>{if(!f)return;const F=requestAnimationFrame(L);return()=>cancelAnimationFrame(F)},[v,E,S.size,f,L]);const $=m.useCallback(F=>{const R=g.current;if(!R)return;const H=Math.max(0,R.scrollHeight-R.clientHeight);R.scrollTop=Math.min(1,Math.max(0,F))*H,L()},[L]),V=m.useCallback((F,R=0)=>{const H=k.current;if(!H)return 0;const A=H.getBoundingClientRect(),X=x.height/100*A.height,K=Math.max(1,A.height-X);return(F-A.top-R)/K},[x.height]),B=m.useCallback(F=>{var ne,re;if(!x.visible)return;F.preventDefault(),F.stopPropagation();const R=k.current;if(!R)return;const H=R.getBoundingClientRect(),A=x.top/100*H.height,X=x.height/100*H.height,W=F.clientY>=H.top+A&&F.clientY<=H.top+A+X?F.clientY-H.top-A:X/2;$(V(F.clientY,W));const te=F.pointerId;(re=(ne=F.currentTarget).setPointerCapture)==null||re.call(ne,te);const ee=ie=>{ie.preventDefault(),$(V(ie.clientY,W))},G=()=>{window.removeEventListener("pointermove",ee),window.removeEventListener("pointerup",G),window.removeEventListener("pointercancel",G)};window.addEventListener("pointermove",ee),window.addEventListener("pointerup",G),window.addEventListener("pointercancel",G)},[V,$,x.height,x.top,x.visible]);return s.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(f?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((F,R)=>{if(F.showOnNode===!1)return null;const H=`${2.6+R*1.7}rem`,A=F.name||`#${R+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:H},children:A}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${R}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:H,background:zn(F.type)},title:`${A} · ${F.type}`})]},`in-${R}`)}),c.map((F,R)=>{if(F.showOnNode===!1)return null;const H=`${2.6+R*1.7}rem`,A=F.name||`#${R+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:H},children:A}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${R}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:H,background:zn(F.type)},title:`${A} · ${F.type}`})]},`out-${R}`)}),s.jsxs("div",{className:"af-work-load-skills-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[s.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:F=>{var R;F.stopPropagation(),f||(R=t==null?void 0:t.onRefreshSkills)==null||R.call(t),d(H=>!H)},children:[s.jsxs("span",{className:"af-work-load-skills-card__summary",title:T.title,children:[s.jsx("span",{className:"af-work-load-skills-card__summary-main",children:T.head}),T.extra?s.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:T.extra}):null]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?s.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:F=>F.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:h,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?s.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:g,className:"af-work-load-skills-menu",onScroll:L,children:[E.collectionGroups.map(F=>{const R=F.skills.map(K=>K.key),H=R.filter(K=>S.has(K)).length,A=R.length>0&&H===R.length,X=v.has(F.id);return s.jsxs("section",{className:"af-work-load-skills-menu__group"+(X?" af-work-load-skills-menu__group--collapsed":""),children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[s.jsx("input",{type:"checkbox",checked:A,onChange:K=>O(R,K.target.checked),"aria-label":`选择 ${F.name}`}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>D(F.id),"aria-expanded":!X,children:s.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[s.jsx("span",{children:F.name}),F.description?s.jsx("em",{children:F.description}):null]})}),s.jsxs("small",{children:[H,"/",R.length]}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>D(F.id),"aria-label":X?`展开 ${F.name}`:`收起 ${F.name}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X?"chevron_right":"expand_more"})})]}),X?null:s.jsx("div",{className:"af-work-load-skills-menu__options",children:F.skills.map(K=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:S.has(K.key),onChange:W=>O([K.key],W.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:K.name}),K.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:K.description}):null]})]},`${F.id}:${K.key}`))})]},F.id)}),E.ungrouped.length>0?s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"Ungrouped"}),s.jsx("small",{children:E.ungrouped.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:E.ungrouped.map(F=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:S.has(F.key),onChange:R=>O([F.key],R.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:F.name}),F.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:F.description}):null]})]},`ungrouped:${F.key}`))})]}):null,E.collectionGroups.length===0&&E.ungrouped.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),s.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:B,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function CX({id:e,data:t,selected:n,deleteNode:r,servers:i=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,u]=m.useState(!1),[p,f]=m.useState(""),d=m.useMemo(()=>new Set(bX(t)),[t]),h=m.useMemo(()=>(Array.isArray(i)?i:[]).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),[i]),y=m.useMemo(()=>{const b=p.trim().toLowerCase();return b?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):h},[p,h]),v=m.useCallback((b,g)=>{const k=new Set(d);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,d,o]);return s.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(c?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:x}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:zn(b.type)},title:`${x} · ${b.type}`})]},`in-${g}`)}),l.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:x}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:zn(b.type)},title:`${x} · ${b.type}`})]},`out-${g}`)}),s.jsxs("div",{className:"af-work-load-skills-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"hub"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[s.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:b=>{var g;b.stopPropagation(),c||(g=t==null?void 0:t.onRefreshMcps)==null||g.call(t),u(k=>!k)},children:[s.jsx("span",{children:d.size>0?`${d.size} MCP selected`:"选择 MCP"}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?s.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:p,onChange:b=>f(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),p?s.jsx("button",{type:"button",onClick:()=>f(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{className:"af-work-load-skills-menu",children:[s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"MCP Servers"}),s.jsx("small",{children:y.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:y.map(b=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:d.has(b.name),onChange:g=>v([b.name],g.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:b.name}),b.description||b.detail?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:b.description||b.detail}):null]})]},b.name))})]}),y.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空"})]})]}):null]})]})}function AX({id:e,data:t,selected:n,deleteNode:r,workspaces:i=[],onChangeWorkspace:o,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,p]=m.useState(!1),[f,d]=m.useState(""),h=vX(t),y=m.useMemo(()=>(Array.isArray(i)?i:[]).map(S=>({id:String((S==null?void 0:S.id)||""),label:String((S==null?void 0:S.label)||(S==null?void 0:S.name)||"知识库"),kind:(S==null?void 0:S.kind)==="git"?"git":"local",path:String((S==null?void 0:S.path)||""),repoUrl:String((S==null?void 0:S.repoUrl)||""),branch:String((S==null?void 0:S.branch)||""),mountPath:String((S==null?void 0:S.mountPath)||""),builtin:(S==null?void 0:S.builtin)===!0,exists:(S==null?void 0:S.exists)!==!1})).filter(S=>S.path),[i]),v=m.useMemo(()=>{const S=f.trim().toLowerCase();return S?y.filter(N=>[N.id,N.label,N.path,N.repoUrl,N.branch,N.mountPath].join(" ").toLowerCase().includes(S)):y},[f,y]),b=m.useMemo(()=>new Set((h.sources||[]).map(S=>S.id||S.path||S.repoPath).filter(Boolean)),[h.sources]),g=m.useMemo(()=>(h.sources||[]).map(S=>S.label||S.id||S.mountPath||S.path),[h.sources]),k=m.useMemo(()=>OM(g,"选择知识库"),[g]),x=$b(u,[v.length,g.length,f]),_=(S,N)=>{const I=(S==null?void 0:S.id)||(S==null?void 0:S.path)||"",T=y.filter(z=>{const E=z.id||z.path||"";return E===I?N:b.has(E)});o==null||o(e,T)};return s.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((S,N)=>{if(S.showOnNode===!1)return null;const I=`${2.6+N*1.7}rem`,T=S.name||`#${N+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:I},children:T}),s.jsx(ir,{type:"target",position:Ge.Left,id:`input-${N}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:I,background:zn(S.type)},title:`${T} · ${S.type}`})]},`in-${N}`)}),c.map((S,N)=>{if(S.showOnNode===!1)return null;const I=`${2.6+N*1.7}rem`,T=S.name||`#${N+1}`;return s.jsxs(m.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:I},children:T}),s.jsx(ir,{type:"source",position:Ge.Right,id:`output-${N}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:I,background:zn(S.type)},title:`${T} · ${S.type}`})]},`out-${N}`)}),s.jsxs("div",{className:"af-work-load-skills-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"加载知识库"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[s.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:S=>{S.stopPropagation(),u||a==null||a(),p(N=>!N)},children:[s.jsxs("span",{className:"af-work-load-skills-card__summary",title:k.title,children:[s.jsx("span",{className:"af-work-load-skills-card__summary-main",children:k.head}),k.extra?s.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:k.extra}):null]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?s.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:f,onChange:S=>d(S.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),f?s.jsx("button",{type:"button",onClick:()=>d(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:x.menuRef,className:"af-work-load-skills-menu",onScroll:x.updateMenuScrollbar,children:[s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"知识库"}),s.jsx("small",{children:v.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:v.map(S=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:b.has(S.id||S.path),onChange:N=>_(S,N.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:S.label}),s.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[S.kind==="git"&&S.repoUrl?`${S.repoUrl}${S.branch?` · ${S.branch}`:""}${S.mountPath?` · ${S.mountPath}`:""}`:S.path,S.exists?"":" · 路径未就绪"]})]})]},`${S.id}:${S.path}`))})]}),v.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空知识库"})]}),s.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:s.jsx("span",{style:{height:`${x.scrollbar.height}%`,top:`${x.scrollbar.top}%`}})})]}):null]})]})}function HM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},i=XR(r),o=MG(eJ(r)),a=i?o.filter(d=>!["issue","mr"].includes(km(d))):o,l=LG(r,o),c=Li(r,t),u=i?"":qo(r.platform),p=Array.isArray(e==null?void 0:e.children)?e.children.length:0,f=[c,i&&p?`${p} 个端侧 Issue`:u,r.status].filter(Boolean);return s.jsxs("div",{className:`af-prd-workflow-issue${n?" af-prd-workflow-issue--child":""}${i?" af-prd-workflow-issue--aggregate":""}`,children:[s.jsx("strong",{children:XY(r,t)}),s.jsx("small",{children:f.join(" · ")}),s.jsxs("div",{className:"af-prd-workflow-issue__state-row",children:[s.jsx("span",{className:`af-prd-workflow-issue__state af-prd-workflow-issue__state--${l.kind}`,children:l.label}),l.detail?s.jsx("small",{children:l.detail}):null]}),a.length?s.jsx("div",{className:"af-prd-workflow-issue__links",children:a.map(d=>s.jsx("a",{href:d.href,target:"_blank",rel:"noreferrer",children:d.label},`${d.label}-${d.href}`))}):null,p?s.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((d,h)=>s.jsx(HM,{row:d,index:h,child:!0},Li((d==null?void 0:d.issue)||{},h)))}):null]})}function VM(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 KM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>VM(n)).filter(Boolean)}function EX({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(),i=["text","user","chips","list","link"].includes(r)?r:"text",o=KM(t.value);if(!o.length)return null;if(i==="list")return s.jsxs("div",{className:"af-prd-overall-platform__rules",children:[s.jsx("small",{children:n}),s.jsx("ul",{children:o.map((a,l)=>s.jsx("li",{children:a},`${e}-${l}-${a}`))})]});if(i==="link"){const a=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},l=pf(t.href||t.url||a.href||a.url||"");return s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[s.jsx("small",{children:n}),l?s.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{children:o[0]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):s.jsx("strong",{children:o[0]})]})}return s.jsxs("div",{className:`af-prd-overall-platform__row af-prd-overall-platform__row--${i}`,children:[s.jsx("small",{children:n}),s.jsx("div",{children:o.map((a,l)=>s.jsx("span",{children:a},`${e}-${l}-${a}`))})]})}function IX({sectionKey:e,section:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=(t.fields&&typeof t.fields=="object"&&!Array.isArray(t.fields)?Object.entries(t.fields):[]).filter(([,o])=>o&&typeof o=="object"&&KM(o.value).length);if(!r.length)return null;const i=e==="progress";return s.jsxs("section",{className:`af-prd-overall-platform${i?" af-prd-overall-platform--compact":""}`,children:[s.jsx("div",{className:"af-prd-overall-platform__head",children:s.jsx("strong",{children:String(t.title||e||"").trim()})}),s.jsx("div",{className:"af-prd-overall-platform__fields",children:r.map(([o,a])=>s.jsx(EX,{fieldKey:o,field:a},o))})]})}function PX({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:{},i=n.sections&&typeof n.sections=="object"&&!Array.isArray(n.sections)?n.sections:{},o=String(n.title||"").trim(),a=pf(n.url||""),l=VM(n.status),c=String(r.id||t||"").trim(),u=Object.entries(i).filter(([f,d])=>f&&d&&typeof d=="object"&&!Array.isArray(d)),p=!!(o||a||l||u.length);return!c&&!p?null:s.jsxs("article",{className:"af-prd-workflow-card af-prd-overall",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"需求概览"}),l?s.jsx("span",{className:"af-prd-overall__status",children:l}):null]}),o||a||c?s.jsx("div",{className:"af-prd-overall__requirement",children:a?s.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",children:[s.jsx("strong",{children:o||`${r.namespace||"Workflow"} ${c}`}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):s.jsx("strong",{children:o||`${r.namespace==="tapd"?"TAPD":"Workflow"} ${c}`})}):null,p?s.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([f,d])=>s.jsx(IX,{sectionKey:f,section:d},f))}):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function TX({flowParams:e={},tapdId:t,setTapdId:n,collaborationOpenRequest:r=0,assistantOpenRequest:i=0,snapshot:o,loading:a,error:l,actionRunning:c,actionOutput:u,pendingConfirm:p,conflict:f,reviewPublishing:d,onRefresh:h,onRunDryRun:y,onConfirmAction:v,onRetryConflict:b,onPublishReview:g}){var Je,st,Tt;const[k,x]=m.useState("all"),[_,S]=m.useState("all"),[N,I]=m.useState(!1),[T,z]=m.useState(!1),[E,O]=m.useState(!1),[D,L]=m.useState(""),[$,V]=m.useState(!1),[B,F]=m.useState(""),[R,H]=m.useState(null),[A,X]=m.useState(null),[K,W]=m.useState(""),[te,ee]=m.useState("reporter"),[G,ne]=m.useState(!1),[re,ie]=m.useState(""),[Z,de]=m.useState([]),[fe,ge]=m.useState([]),[Oe,_e]=m.useState([]),[Ne,He]=m.useState(!1),[ct,xt]=m.useState(!1),[Re,lt]=m.useState(!1),[kt,Ot]=m.useState([]),[_t,Xt]=m.useState(!1),[ae,ke]=m.useState(""),[Ue,it]=m.useState([]),Ee=String((o==null?void 0:o.phase)||(t?"unavailable":"unselected")),Kt=Array.isArray(o==null?void 0:o.issues)?o.issues:[],en=tJ(o),Ut=en.reduce((ue,Te)=>ue+jb(Te.issues),0),wt=Array.isArray(o==null?void 0:o.artifacts)?o.artifacts:[];Array.isArray(o==null?void 0:o.optionalGaps)&&o.optionalGaps;const mn=o!=null&&o.nextAction&&typeof o.nextAction=="object"?o.nextAction:null,se=iJ(o,mn),Ce=YY(o,se),Ye=wt.filter(ue=>!ZR({...ue,href:Ic(ue)})),ze=m.useMemo(()=>qY(se),[se]);m.useEffect(()=>{_!=="all"&&(ze.some(ue=>ue.key===_)||S("all"))},[_,ze]);const Nt=se.filter(ue=>UY(ue,_)),St=VY(Nt),Gn=oJ(o),Rn=Gn.filter(ue=>aJ(ue,k)),Sr=Nt.filter(ue=>Pv(ue)).length,rn=o!=null&&o.collaboration&&typeof o.collaboration=="object"?o.collaboration:{},vn=rn.activeAction&&typeof rn.activeAction=="object"?rn.activeAction:null;Array.isArray(o==null?void 0:o.clientObservations)&&o.clientObservations;const tr=String((o==null?void 0:o.rawOutput)||""),ar=o!=null&&o.globalState&&typeof o.globalState=="object"?o.globalState:null,fn=LY(Ee),Sn=m.useCallback(async()=>{const ue=String(t||"").trim();if(!ue||e.workflowShare)return;const Te=await fetch(`/api/workflows/knowledge-bindings?tapdId=${encodeURIComponent(ue)}`),nt=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(nt.error||"读取知识工作区绑定失败");const gt=Array.isArray(nt.bindings)?nt.bindings:[];de(gt),_e(gt.map(Ve=>Ve.workspaceId).filter(Boolean)),ge(Array.isArray(nt.availableWorkspaces)?nt.availableWorkspaces:[]),He(nt.canManage===!0)},[e.workflowShare,t]),Ir=m.useCallback(async()=>{const ue=String(t||"").trim();if(!ue){H(null),X(null);return}z(!0),L(""),F("");try{const Te=new URLSearchParams({tapdId:ue});e.workflowShare&&Te.set("workflowShare",e.workflowShare);const[nt,gt]=await Promise.all([fetch(`/api/prd-workflow/share?${Te.toString()}`),fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(ue)}`)]),[Ve,Rt]=await Promise.all([nt.json().catch(()=>({})),gt.json().catch(()=>({}))]);if(!nt.ok)throw new Error(Ve.error||"读取 Workflow 分享状态失败");gt.ok&&X(Rt.collaboration||null);let Pt=Ve.share||null;const jn=Ve.canCreate===!0&&!e.workflowShare;if(V(jn),!Pt&&jn){const rt=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:ue})}),Mn=await rt.json().catch(()=>({}));if(!rt.ok)throw new Error(Mn.error||"生成 Workflow 分享链接失败");if(Pt=Mn.share||null,!Rt.collaboration){const pn=await fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(ue)}`),Bs=await pn.json().catch(()=>({}));pn.ok&&X(Bs.collaboration||null)}}H(Pt)}catch(Te){L(String(Te.message||Te))}finally{z(!1)}},[e,t]),Gr=m.useRef(0),gn=m.useCallback(()=>{I(!0),Ir(),Sn().catch(ue=>L(String(ue.message||ue)))},[Sn,Ir]);m.useEffect(()=>{!r||r===Gr.current||(Gr.current=r,gn())},[r,gn]);const Hn=m.useRef(0),Dr=m.useCallback(async()=>{if(!(!t||e.workflowShare)){lt(!0),ke("");try{const[ue,Te]=await Promise.all([Sn(),fetch(`/api/workflows/conversation?tapdId=${encodeURIComponent(t)}`)]),nt=await Te.json().catch(()=>({}));Te.ok&&Ot(Array.isArray(nt.messages)?nt.messages:[])}catch(ue){ke(String(ue.message||ue))}}},[e.workflowShare,Sn,t]);m.useEffect(()=>{!i||i===Hn.current||(Hn.current=i,Dr())},[i,Dr]);const Yn=async()=>{if(!(!t||ct||!Ne)){xt(!0),L("");try{const ue=await fetch("/api/workflows/knowledge-bindings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,workspaceIds:Oe})}),Te=await ue.json().catch(()=>({}));if(!ue.ok)throw new Error(Te.error||"保存知识工作区绑定失败");de(Array.isArray(Te.bindings)?Te.bindings:[]),Te.collaboration&&X(Te.collaboration)}catch(ue){L(String(ue.message||ue))}finally{xt(!1)}}},Vn=async ue=>{const Te=String(ue||"").trim();if(!t||!Te||_t)return;const nt=[...kt,{role:"user",content:Te}];Ot(nt),Xt(!0),ke("");try{const gt=await fetch("/api/workflows/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,question:Te,messages:kt})}),Ve=await gt.json().catch(()=>({}));if(!gt.ok)throw new Error(Ve.error||"Workflow AI 分析失败");Ot(Array.isArray(Ve.messages)?Ve.messages:[...nt,{role:"assistant",content:Ve.content||""}]),it(Array.isArray(Ve.sources)?Ve.sources:[])}catch(gt){ke(String(gt.message||gt)),Ot(kt)}finally{Xt(!1)}},pr=async()=>{if(!(!t||E||e.workflowShare)){O(!0),L(""),F("");try{const ue=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),Te=await ue.json().catch(()=>({}));if(!ue.ok)throw new Error(Te.error||"生成 Workflow 分享链接失败");H(Te.share||null),V(!0);const nt=await fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(t)}`),gt=await nt.json().catch(()=>({}));nt.ok&&X(gt.collaboration||null)}catch(ue){L(String(ue.message||ue))}finally{O(!1)}}},hr=async()=>{const ue=await Rb((R==null?void 0:R.shortUrl)||(R==null?void 0:R.url)||"");F(ue?"已复制":"复制失败")},Kn=async()=>{if(!(!t||E||!(R!=null&&R.canManage))){O(!0),L(""),F("");try{const ue=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),Te=await ue.json().catch(()=>({}));if(!ue.ok)throw new Error(Te.error||"取消 Workflow 分享链接失败");H(null),V(!0)}catch(ue){L(String(ue.message||ue))}finally{O(!1)}}},lr=async(ue=K,Te=te)=>{const nt=String(ue||"").trim();if(!(!t||!nt||G)){ne(!0),L("");try{const gt=await fetch("/api/prd-workflow/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,username:nt,role:Te})}),Ve=await gt.json().catch(()=>({}));if(!gt.ok)throw new Error(Ve.error||"更新成员权限失败");X(Ve.collaboration||null),W("")}catch(gt){L(String(gt.message||gt))}finally{ne(!1)}}},jr=async ue=>{const Te=String((ue==null?void 0:ue.userId)||"").trim();if(!(!t||!Te||re)){ie(Te),L("");try{const nt=await fetch("/api/prd-workflow/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,memberUserId:Te})}),gt=await nt.json().catch(()=>({}));if(!nt.ok)throw new Error(gt.error||"移除成员授权失败");X(gt.collaboration||null)}catch(nt){L(String(nt.message||nt))}finally{ie("")}}},le=(R==null?void 0:R.shortUrl)||(R==null?void 0:R.url)||"",he=(A==null?void 0:A.role)==="owner";return s.jsxs("main",{className:"af-prd-workflow af-prd-workflow--timeline","aria-label":"PRD Workflow",children:[s.jsxs("section",{className:"af-prd-workflow__statusbar",children:[s.jsxs("div",{className:"af-prd-workflow__status-main",children:[s.jsx("span",{className:`af-prd-workflow-phase af-prd-workflow-phase--${Ee.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:U_(Ee)}),s.jsx("h1",{children:(o==null?void 0:o.pointer)||(t?"等待 prd-flow 返回状态":"选择 TAPD 需求后读取状态")}),s.jsx("p",{className:"af-prd-workflow__status-subtitle",children:t?s.jsxs(s.Fragment,{children:["TAPD ",s.jsx("strong",{children:t})," · ",e.workflowDemo?"本地只读示例":"独立需求 Workflow"]}):s.jsx(s.Fragment,{children:"尚未选择 TAPD 需求"})}),l?s.jsx("p",{className:"af-prd-workflow-error",children:l}):null,vn||rn.subscribers?s.jsxs("div",{className:"af-prd-workflow-collab",children:[vn?s.jsxs("span",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),vn.title||vn.action||"Workflow action"," 执行中",vn.userId?s.jsx("small",{children:vn.userId}):null]}):null,rn.subscribers?s.jsxs("span",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),rn.subscribers," 个连接"]}):null]}):null]}),s.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:ue=>{ue.preventDefault(),h==null||h()},children:[s.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:fn.map(ue=>s.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${ue.status}`,children:[s.jsx("span",{"aria-hidden":"true"}),s.jsx("small",{children:ue.label})]},ue.label))}),s.jsxs("div",{className:"af-prd-workflow__lookup-row",children:[s.jsxs("label",{children:[s.jsx("span",{children:"TAPD Workflow"}),s.jsx("input",{value:t,onChange:ue=>n(ue.target.value),readOnly:e.workflowDemo,placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),s.jsxs("button",{type:"submit",disabled:a,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"sync"}),a?"读取中":t?"刷新":"读取"]})]})]})]}),f?s.jsxs("section",{className:"af-prd-workflow-conflict","aria-label":"Workflow conflict",children:[s.jsxs("div",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"sync_problem"}),s.jsxs("div",{children:[s.jsx("strong",{children:"状态已变化,需要重新确认"}),s.jsx("p",{children:f.message||"当前 workflow 状态和执行前不一致。"})]})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"执行时 revision"}),s.jsx("dd",{children:f.expectedRevision||"空"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"当前 revision"}),s.jsx("dd",{children:f.currentRevision||"未知"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"当前状态"}),s.jsx("dd",{children:[U_(f.currentPhase),f.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),s.jsx("div",{className:"af-prd-workflow-conflict__actions",children:s.jsx("button",{type:"button",onClick:()=>h==null?void 0:h(),disabled:a||c,children:"刷新状态"})})]}):null,s.jsxs("section",{className:"af-prd-workflow__main",children:[s.jsxs("article",{className:"af-prd-workflow-actions","aria-label":"Workflow actions",children:[s.jsxs("div",{className:"af-prd-workflow-actions__head",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Action 时间线"}),s.jsx("p",{children:se.length?`${Sr}/${Nt.length} 已完成${_!=="all"?` · 共 ${se.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),mn&&Cm(mn)?s.jsxs("div",{className:"af-prd-workflow-local-command",children:[s.jsx("span",{children:"本地 agent 执行"}),s.jsx("code",{children:mn.command||co(mn,0)})]}):null]}),ze.length?s.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[s.jsxs("button",{type:"button",className:_==="all"?"is-active":"","aria-pressed":_==="all",onClick:()=>S("all"),children:["全部 ",s.jsx("span",{children:se.length})]}),ze.map(ue=>s.jsxs("button",{type:"button",className:_===ue.key?"is-active":"","aria-pressed":_===ue.key,onClick:()=>S(ue.key),children:[ue.label," ",s.jsx("span",{children:ue.count})]},ue.key))]}):null,s.jsx("div",{className:"af-prd-workflow-action-list",children:Nt.length?St.map(ue=>s.jsxs("section",{className:"af-prd-workflow-action-day",children:[s.jsxs("div",{className:"af-prd-workflow-action-day__label",children:[s.jsx("span",{children:ue.day}),s.jsx("small",{children:"北京时间"})]}),s.jsx("div",{className:"af-prd-workflow-action-day__items",children:ue.items.map(({item:Te,index:nt})=>{const gt=ba(Te.status),Ve=ua(Te)==="observation"&>==="done"?"observed":gt,Rt=Rv(Te),Pt=HY(Te),jn=GY(Te),rt=DY(Te,nt),Mn=FY(Te);return s.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${Ve}`,children:[s.jsx("div",{className:"af-prd-workflow-action__rail",children:s.jsx("span",{className:"af-prd-workflow-action__dot"})}),s.jsxs("div",{className:"af-prd-workflow-action__body",children:[s.jsxs("div",{className:"af-prd-workflow-action__top",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-prd-workflow-action__title",children:[Pt?s.jsx("time",{dateTime:_m(Te),children:Pt}):null,s.jsx("strong",{children:rt})]}),Mn?s.jsx("p",{children:Mn}):null,jn.length?s.jsx("div",{className:"af-prd-workflow-action__meta",children:jn.map(pn=>s.jsxs("span",{className:`af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--${pn.label==="Issue"?"issue":"platform"}`,title:`${pn.label} · ${pn.value}`,children:[s.jsx("b",{children:pn.label}),s.jsx("span",{className:"af-prd-workflow-action__meta-value",children:pn.value})]},`${pn.label}-${pn.value}`))}):null]}),s.jsx("span",{className:"af-prd-workflow-action__status",children:KY(Te)})]}),Rt.length?s.jsx("div",{className:"af-prd-workflow-action__links",children:Rt.map(pn=>s.jsxs("a",{href:pn.href,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{children:pn.label}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${pn.label}-${pn.href}`))}):null]})]},Te.id||Te.actionId||`${co(Te,nt)}-${nt}`)})})]},ue.day)):s.jsxs("div",{className:"af-prd-workflow-action-empty",children:[s.jsx("strong",{children:t?se.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),s.jsx("p",{children:t?se.length?"切换到其它 tag 或查看全部。":"Workflow tab 不会生成默认步骤;需要 prd-flow snapshot 返回 actions/timeline/events/history 或 nextAction。":"选择后从 prd-flow 读取真实 action、产物和 URL。"})]})})]}),s.jsxs("aside",{className:"af-prd-workflow-side","aria-label":"Workflow related links",children:[s.jsx(PX,{globalState:ar,tapdId:t}),Ye.length?s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"关联产物"}),s.jsx("span",{children:Ye.length})]}),s.jsx("div",{className:"af-prd-workflow-list",children:Ye.map((ue,Te)=>{const nt=Ic(ue),gt=String(ue.label||ue.title||ue.kind||nt||`Artifact ${Te+1}`);return nt?s.jsxs("a",{href:nt,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{children:gt}),s.jsx("small",{children:ue.kind||nt})]},`${nt}-${Te}`):s.jsxs("div",{children:[s.jsx("span",{children:gt}),s.jsx("small",{children:ue.kind||""})]},`${gt}-${Te}`)})})]}):null,s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"AI Docs"}),s.jsx("span",{children:Ce.length})]}),s.jsx("div",{className:"af-prd-workflow-list",children:Ce.length?Ce.map(ue=>{const Te=String(ue.title||ue.label||"ai-doc").trim(),nt=[ue.label&&ue.label!==Te?ue.label:"",ue.platform,ue.issueKey].filter(Boolean);return s.jsxs("a",{className:"af-prd-ai-doc",href:ue.href,target:"_blank",rel:"noreferrer",title:Te,children:[s.jsx("span",{className:"af-prd-ai-doc__title",children:Te}),s.jsx("small",{className:"af-prd-ai-doc__meta",children:nt.join(" · ")||ue.kind||"ai-doc"})]},ue.href)}):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 ai-doc 文档。"})})]}),s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"Issues"}),s.jsx("span",{children:Ut||Kt.length})]}),s.jsx("div",{className:"af-prd-workflow-issues",children:en.length?en.map(ue=>s.jsxs("div",{className:"af-prd-workflow-epic",children:[s.jsxs("div",{className:"af-prd-workflow-epic__head",children:[s.jsx("strong",{children:ue.title||ue.key}),s.jsx("small",{children:jb(ue.issues)})]}),ue.issues.map((Te,nt)=>s.jsx(HM,{row:Te,index:nt},Li((Te==null?void 0:Te.issue)||{},nt)))]},ue.key)):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 Issue 信息。"})})]}),s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"运行审计"}),s.jsxs("span",{children:[Rn.length,"/",Gn.length]})]}),s.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([ue,Te])=>s.jsx("button",{type:"button",className:k===ue?"is-active":"",onClick:()=>x(ue),children:Te},ue))}),s.jsx("div",{className:"af-prd-workflow-audit",children:Rn.length?Rn.map((ue,Te)=>s.jsxs("div",{children:[s.jsx("strong",{children:co(ue,Te)}),s.jsx("small",{children:[ue.status,ue.type,_m(ue)].filter(Boolean).join(" · ")})]},ue.id||`${ue.type}-${Te}`)):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),tr||u?s.jsxs("article",{className:"af-prd-workflow-card af-prd-workflow-card--raw",children:[s.jsx("div",{className:"af-prd-workflow-card__head",children:s.jsx("h2",{children:"Raw"})}),s.jsx("pre",{children:u||tr})]}):null]})]}),N?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"需求协作",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"需求协作"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>I(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("section",{className:"af-prd-workflow-access-panel","aria-label":"Workflow 成员权限",children:[s.jsxs("div",{className:"af-prd-workflow-access-panel__head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"成员权限"}),s.jsx("small",{children:"TAPD Owner 自动管理;TAPD 参与人默认只读"})]}),((Je=A==null?void 0:A.authority)==null?void 0:Je.type)==="tapd"?s.jsx("span",{children:"TAPD 已同步"}):s.jsx("span",{children:"待 TAPD 同步"})]}),he?s.jsxs("div",{className:"af-workspace-member-add af-prd-workflow-member-add",children:[s.jsx("input",{type:"text",value:K,onChange:ue=>W(ue.target.value),onKeyDown:ue=>{ue.key==="Enter"&&K.trim()&&!G&&(ue.preventDefault(),lr())},placeholder:"输入 AgentFlow 用户名","aria-label":"成员用户名"}),s.jsxs("select",{value:te,onChange:ue=>ee(ue.target.value),"aria-label":"成员权限",children:[s.jsx("option",{value:"reporter",children:"可上报"}),s.jsx("option",{value:"viewer",children:"只读"})]}),s.jsx("button",{type:"button",disabled:G||!K.trim(),onClick:()=>void lr(),children:G?"保存中...":"保存权限"})]}):null,s.jsx("div",{className:"af-workspace-member-list",children:((A==null?void 0:A.members)||[]).map(ue=>{const Te=ue.role==="owner"||ue.userId===(A==null?void 0:A.ownerId),nt=ue.source==="explicit",gt=Te?"需求 Owner":ue.role==="reporter"?"可上报":ue.source==="tapd"?"TAPD 参与人 · 只读":"只读";return s.jsxs("div",{className:"af-workspace-member-row",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Te?"shield_person":"person"}),s.jsxs("div",{children:[s.jsx("strong",{children:ue.username||ue.userId}),s.jsx("small",{children:gt})]}),he&&!Te?s.jsxs("div",{className:"af-prd-workflow-member-actions",children:[s.jsxs("select",{value:ue.role==="reporter"?"reporter":"viewer",disabled:G||!!re,onChange:Ve=>void lr(ue.username||ue.userId,Ve.target.value),"aria-label":`${ue.username||ue.userId} 的权限`,children:[s.jsx("option",{value:"reporter",children:"可上报"}),s.jsx("option",{value:"viewer",children:"只读"})]}),nt?s.jsx("button",{type:"button",disabled:re===ue.userId,onClick:()=>void jr(ue),children:re===ue.userId?"移除中...":"移除授权"}):null]}):null]},ue.userId)})}),(Tt=(st=A==null?void 0:A.authority)==null?void 0:st.unresolvedParticipants)!=null&&Tt.length?s.jsxs("p",{className:"af-prd-workflow-access-panel__unresolved",children:["尚未匹配 AgentFlow 账号:",A.authority.unresolvedParticipants.join("、")]}):null]}),e.workflowShare?null:s.jsxs("section",{className:"af-prd-workflow-access-panel af-workflow-knowledge-panel","aria-label":"Workflow 知识工作区",children:[s.jsxs("div",{className:"af-prd-workflow-access-panel__head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"AI 知识工作区"}),s.jsx("small",{children:"AI 会结合需求上下文,在隔离的代码快照中回答问题;不会修改真实仓库"})]}),s.jsx("span",{children:Z.length?`已绑定 ${Z.length} 个`:"未绑定"})]}),Ne?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"af-workflow-knowledge-options",children:fe.length?fe.map(ue=>{const Te=Oe.includes(ue.workspaceId);return s.jsxs("label",{className:Te?"is-selected":"",children:[s.jsx("input",{type:"checkbox",checked:Te,onChange:()=>_e(nt=>Te?nt.filter(gt=>gt!==ue.workspaceId):[...nt,ue.workspaceId])}),s.jsxs("span",{children:[s.jsx("strong",{children:ue.label}),s.jsx("small",{children:[ue.type,ue.branch,ue.repoUrl].filter(Boolean).join(" · ")})]})]},ue.workspaceId)}):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无可绑定的知识工作区,请先在知识库页面配置并同步 Git 仓库。"})}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:ct,onClick:()=>void Yn(),children:ct?"保存中...":"保存知识绑定"})]}):s.jsx("div",{className:"af-workflow-knowledge-bindings",children:Z.length?Z.map(ue=>s.jsxs("span",{children:[ue.label,ue.branch?` · ${ue.branch}`:""]},ue.workspaceId)):s.jsx("p",{className:"af-prd-workflow-muted",children:"Owner 尚未绑定代码知识工作区;仍可只基于需求上下文提问。"})})]}),s.jsx("div",{className:"af-prd-workflow-share-divider",children:s.jsx("span",{children:"只读链接"})}),s.jsxs("p",{className:"af-display-link-modal__empty",children:["通过链接分享 TAPD ",t,";不会授予上报权限,也不会分享当前 Project、画布或项目文件。"]}),T?s.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!T&&le?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-display-link-modal__url",children:[s.jsx("input",{type:"text",value:le,readOnly:!0,onFocus:ue=>ue.currentTarget.select(),"aria-label":"Workflow 分享链接"}),s.jsxs("button",{type:"button",disabled:E,onClick:()=>void hr(),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),B||"复制链接"]}),R.canManage?s.jsx("button",{type:"button",disabled:E,onClick:()=>void Kn(),children:E?"处理中...":"取消分享"}):null]}),s.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的人无需登录即可只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!T&&!le&&$?s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:E,onClick:()=>void pr(),children:E?"生成中...":"生成分享链接"}):null,D?s.jsx("div",{className:"af-flow-snippet-error",children:D}):null]}),s.jsx("div",{className:"af-flow-snippet-modal__foot",children:s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>I(!1),children:"完成"})})]})}),document.body):null,Re?ur.createPortal(s.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workflow-ai-drawer","aria-label":"Workflow AI",children:s.jsxs("div",{className:"af-composer-sidebar",children:[s.jsxs("div",{className:"af-pipeline-drawer-head",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:"Workflow AI"}),s.jsxs("small",{children:["TAPD ",t," · 需求与代码只读分析"]})]}),s.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>lt(!1),"aria-label":"关闭 Workflow AI",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-workflow-ai-context",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"verified_user"}),s.jsxs("div",{children:[s.jsx("strong",{children:Z.length?`${Z.length} 个代码知识工作区`:"仅需求上下文"}),s.jsx("small",{children:Z.length?"优先使用上报 commit/ref,否则使用绑定分支或本地 HEAD":"请让需求 Owner 在“协作”中绑定代码仓库"})]})]}),s.jsx(m.Suspense,{fallback:s.jsxs("div",{className:"af-workflow-assistant-loading",role:"status",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),"正在准备需求 AI…"]}),children:s.jsx(uY,{messages:kt,running:_t,error:ae,sources:Ue,suggestions:["这个需求目前做到哪里了?","核心实现逻辑在哪些文件?","当前实现还有哪些风险或遗漏?"],onSend:Vn})})]})}),document.body):null]})}function xC(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 Ju(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function RX(e,t,n,r=!0){const i=JSON.parse(JSON.stringify(e||{})),o=Array.isArray(t)?t:[];if(!o.length)return r?n:{};let a=i;for(let c=0;c<o.length-1;c+=1){const u=o[c],p=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(p)?[]:{}),a=a[u]}const l=o[o.length-1];return r?a[l]=n:Array.isArray(a)&&Number.isInteger(l)?a.splice(l,1):delete a[l],i}function MX(){var Wj,Bj,Hj,Vj;const{t:e,i18n:t}=Ur(),{navigate:n}=ls(),r=tu(),i=kn(),o=j6(),a=m.useMemo(vY,[]),l=!!a.workflowShare,c=m.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=m.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[p,f]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[d,h]=m.useState(!1),[y,v]=m.useState(!1),[b,g]=N6([]),[k,x]=_6([]),_=m.useRef([]),S=m.useRef([]),N=m.useRef(null),[I,T]=m.useState(()=>Ph(null,[])),z=m.useRef(I),[E,O]=m.useState(null),D=m.useRef(null),L=m.useRef(!1),[$,V]=m.useState([]),B=m.useRef(new Map),F=m.useRef(new Map),R=m.useRef(new Set),H=m.useRef(new Set),A=m.useRef(null),X=m.useRef(null),K=m.useRef([]),W=m.useRef(null),te=m.useRef(null),ee=m.useRef(null),[G,ne]=m.useState(null),[re,ie]=m.useState({}),Z=m.useRef({}),de=m.useRef(!1),fe=m.useRef(null),ge=m.useRef(""),Oe=m.useRef(null),_e=m.useRef(Promise.resolve()),Ne=m.useRef({running:!1,pending:null}),He=m.useRef(0),ct=m.useRef(!1),xt=m.useRef(0),Re=m.useRef(null),lt=m.useRef(!1),kt=m.useRef(!1),Ot=m.useRef(""),_t=m.useRef(!1),Xt=m.useRef(null),ae=m.useRef(!1),ke=m.useRef(new Set),Ue=m.useRef(!1),it=m.useRef(!1),Ee=m.useCallback(()=>nY({nodeInteraction:ae.current,pointerCount:ke.current.size,viewportInteraction:Ue.current}),[]),Kt=m.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),en=m.useRef(!1),Ut=m.useRef(null),[wt,mn]=m.useState([]),se=m.useRef([]),[Ce,Ye]=m.useState(""),[ze,Nt]=m.useState("nodes"),[St,Gn]=m.useState([]),[Rn,Sr]=m.useState(!1),[rn,vn]=m.useState(""),[tr,ar]=m.useState(!1),[fn,Sn]=m.useState({name:"",id:"",description:""}),[Ir,Gr]=m.useState(!1),[gn,Hn]=m.useState(""),[Dr,Yn]=m.useState(""),Vn=m.useRef(null),[pr,hr]=m.useState(!1),[Kn,lr]=m.useState(!1),[jr,le]=m.useState(""),[he,Je]=m.useState(null),[st,Tt]=m.useState(()=>Aw()),[ue,Te]=m.useState(""),[nt,gt]=m.useState(!1),[Ve,Rt]=m.useState(""),[Pt,jn]=m.useState(!1),[rt,Mn]=m.useState([]),[pn,Bs]=m.useState(!1),[Hs,oe]=m.useState(""),[ve,Me]=m.useState(""),[jt,Dt]=m.useState(""),[sn,Nn]=m.useState(!1),[Jn,js]=m.useState(""),[Ns,U]=m.useState(""),[we,$e]=m.useState(!1),[Ae,tt]=m.useState("nodes"),[In,Wt]=m.useState(""),[$n,mr]=m.useState(0),[Nr,on]=m.useState(""),Qv=m.useRef(""),[yt,_s]=m.useState(null),Zv=m.useRef(null),[B$,xl]=m.useState(""),[bl,eS]=m.useState([]),[tS,H$]=m.useState(""),[Se,V$]=m.useState(!a.adminOwnerId),[zf,K$]=m.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[Ft,Wf]=m.useState(null),[q$,Rg]=m.useState(!1),[Mg,nS]=m.useState(!1),[rS,jo]=m.useState(""),[uu,sS]=m.useState(""),[iS,oS]=m.useState(""),[Vs,U$]=m.useState(null),[$g,aS]=m.useState("viewer"),[du,lS]=m.useState(!1),[G$,Y$]=m.useState(0),[J$,X$]=m.useState(0),[Ln,kl]=m.useState(null),[Q$,ka]=m.useState(!1),[Lg,vl]=m.useState({}),[Bf,cS]=m.useState(!1),[uS,fu]=m.useState(""),[Og,Z$]=m.useState(""),[eL,Sl]=m.useState(()=>new Set),[Dg,Fg]=m.useState(""),[pu,zg]=m.useState({nodeId:"",query:""}),[dS,fS]=m.useState(!1),Wg=m.useRef(null),pS=m.useRef(null),hS=m.useRef(""),[Bg,mS]=m.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[tL,gS]=m.useState(!1),[va,nL]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Vi,rL]=m.useState(""),[Ks,sL]=m.useState([]),[yS,wS]=m.useState(!1),[qs,hu]=m.useState([]),[jl,iL]=m.useState([]),[xS,oL]=m.useState(!1),[bS,kS]=m.useState([]),[vS,SS]=m.useState([]),[Xn,aL]=m.useState(()=>{try{const w=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return w||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`)||"").trim()}catch{return""}}),[dn,mu]=m.useState(null),[lL,jS]=m.useState(!1),[cL,Nl]=m.useState(""),[Hg,NS]=m.useState(!1),[Vg,gu]=m.useState(""),[Cs,yu]=m.useState(null),[Kg,_S]=m.useState(!1),[wu,_l]=m.useState(null),CS=m.useCallback(w=>{Vn.current&&window.clearTimeout(Vn.current),Yn(w),Vn.current=window.setTimeout(()=>{Yn(""),Vn.current=null},3800)},[]),Yr=m.useCallback(w=>{const j=Array.isArray(w)||w instanceof Set?w:[w];for(const C of j){const P=String(C||"").trim();P&&(R.current.add(P),H.current.add(P))}R.current.size!==0&&(A.current==null&&(A.current=window.requestAnimationFrame(()=>{A.current=null;const C=Array.from(R.current);R.current.clear(),C.forEach(P=>o(P))})),X.current!=null&&window.clearTimeout(X.current),X.current=window.setTimeout(()=>{X.current=null;const C=Array.from(H.current);H.current.clear(),C.forEach(P=>o(P))},80))},[o]);m.useEffect(()=>()=>{A.current!=null&&window.cancelAnimationFrame(A.current),X.current!=null&&window.clearTimeout(X.current),R.current.clear(),H.current.clear()},[]);const AS=m.useCallback((w,j)=>{const C=String(w||"").trim(),P=Tm(j);!C||!P||(g(M=>M.map(q=>{var ce;if(q.id!==C)return q;const Q=Tm((ce=q.data)==null?void 0:ce.displaySize),J=Q&&Q.width===P.width&&Q.height===P.height,Y=Math.round(Number(q.width||0))===P.width&&Math.round(Number(q.height||0))===P.height;return J&&Y?q:{...q,width:P.width,height:P.height,data:{...q.data,nodeSize:P,displaySize:P}}})),Yr(C))},[Yr,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(Bg)))}catch{}},[Bg]);const qg=m.useCallback(w=>{const j=Wg.current;if(!j)return null;const C=j.getBoundingClientRect(),P=16,M=150,q=230,Q=C.top+P,J=C.bottom-P,Y=Math.max(M,J-Q-q);return Math.min(Math.max(w-Q,M),Y)},[]),uL=m.useCallback(w=>{w.preventDefault(),w.stopPropagation();const j=Wg.current;if(!j)return;let C=qg(w.clientY);if(!Number.isFinite(C))return;gS(!0),mS(C);const P=q=>{q.preventDefault();const Q=qg(q.clientY);Number.isFinite(Q)&&(C=Q,j.style.setProperty("--af-work-files-pane-height",`${Math.round(Q)}px`))},M=()=>{mS(C),gS(!1),window.removeEventListener("pointermove",P,!0),window.removeEventListener("pointerup",M,!0),window.removeEventListener("pointercancel",M,!0)};window.addEventListener("pointermove",P,!0),window.addEventListener("pointerup",M,!0),window.addEventListener("pointercancel",M,!0)},[qg]);m.useEffect(()=>()=>{Vn.current&&window.clearTimeout(Vn.current),Ut.current&&window.clearTimeout(Ut.current)},[]);const[dL,ES]=m.useState(()=>new Set),[Hf,Ug]=m.useState(!1),Gg=m.useRef(null),IS=m.useRef(null),PS=m.useRef(null),[fL,pL]=m.useState({}),[Sa,Yg]=m.useState(""),[us,TS]=m.useState(!1),[ja,Cl]=m.useState([]),[Us,nr]=m.useState([]),[Jr,As]=m.useState("workspace"),[xu,Al]=m.useState(!1),RS=m.useRef(null),Jg=m.useRef(null),[bu,El]=m.useState(null),[hL,Xg]=m.useState(!0),[MS,$S]=m.useState(""),[Na,No]=m.useState({}),[Fr,Qg]=m.useState(null),[LS,Zg]=m.useState(!1),Il=m.useMemo(()=>LS?AY(Fr):"",[LS,Fr]),[ku,Vf]=m.useState(!0);m.useEffect(()=>{Il&&Vf(EY(Il))},[Il]),m.useEffect(()=>{if(Il)try{window.localStorage.setItem(Il,ku?"true":"false")}catch{}},[ku,Il]);const[ey,Kf]=m.useState(!1),[ty,OS]=m.useState(!1),[ny,DS]=m.useState("pan"),[FS,mL]=m.useState({}),vu=m.useRef({}),[zS,_a]=m.useState({}),Su=m.useRef(new Map),ju=m.useRef(new Set),[WS,Pl]=m.useState(()=>new Set),[ry,Tl]=m.useState({}),[BS,HS]=m.useState(""),[hde,ye]=m.useState(""),[VS,Gs]=m.useState("loading"),[KS,Ys]=m.useState("正在载入 Project"),Ki=m.useMemo(()=>CY(a),[a]),[qS,US]=m.useState(""),Nu=a.flowSource||"user",GS=m.useMemo(()=>new Set(Object.values(FS||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[FS]),qi=m.useCallback(w=>{const j=vu.current||{},C=typeof w=="function"?w(j):w,P=C&&typeof C=="object"&&!Array.isArray(C)?C:{};return vu.current=P,mL(P),P},[]),YS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(Ft!=null&&Ft.role?Ft.role==="owner":Nu==="user"||Nu==="workspace")),_u=!!(!a.adminOwnerId&&Nu==="workspace"&&(Ft!=null&&Ft.role)&&Ft.role!=="owner"),JS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[VS]||"同步状态",yi=m.useCallback(()=>{!de.current||!Se||(_t.current=!1,He.current+=1,ct.current=!0,Gs("dirty"),Ys("本地修改等待同步"))},[Se]);m.useEffect(()=>{a.flowId&&iz(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const w=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),m.useEffect(()=>{Cl([]),nr([]),As("workspace"),Xg(!0)},[a]);const On=m.useCallback(async()=>{const w=Br(a),j=await fetch(`/api/workspace/files?${w.toString()}`),C=await j.json();if(!j.ok)throw new Error(C.error||"读取 workspace 失败");const P=C.files||[];eS(P),Sl(new Set(RM(P))),H$(C.root||"")},[a]),qf=m.useCallback(async()=>{Sr(!0),vn("");try{const w=await fetch("/api/marketplace/flow-snippets"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error(j.error||"读取流程片段失败");Gn(Array.isArray(j.snippets)?j.snippets:[])}catch(w){vn(String(w.message||w)),Gn([])}finally{Sr(!1)}},[]),XS=m.useCallback(async(w,j,C)=>{var Y,ce,me;if(!de.current)return;if(!Se)throw ye("Readonly workspace"),Gs("readonly"),Ys("只读 Project"),new Error("Readonly workspace");Gs("saving"),Ys("正在同步修改");const P=Yl(w,j,Z.current);P.ui={...P.ui||{},displayPage:rC(z.current,w)};const M=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:P,baseRevision:ge.current,baseGraph:Oe.current,clientId:Kt.current})}),q=await M.json().catch(()=>({}));if(!M.ok){if(M.status===409||M.status===428){const je=Array.isArray(q.conflictItems)?q.conflictItems:[];kl({currentRevision:String(q.currentRevision||""),message:q.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(q.conflictPaths)?q.conflictPaths:[],conflictItems:je,mergeGraph:q.mergeGraph||null,currentGraph:q.currentGraph||null}),vl(Object.fromEntries(je.map((Be,Le)=>[String(Le),{mode:"local",manual:Ju(Be)}]))),fu(""),ka(je.length>0),Gs("conflict"),Ys(q.error||"存在需要处理的字段冲突");const Ke=Array.isArray(q.conflictPaths)?q.conflictPaths:[],We=Ke.length?`${q.error||"Workspace 已被其他成员更新"}:${Ke.join("、")}`:q.error||"Workspace 已被其他成员更新",qe=new Error(We);throw qe.code="WORKSPACE_REVISION_CONFLICT",qe.currentRevision=q.currentRevision||"",qe}const pe=new Error(q.error||"保存 workspace graph 失败");throw Gs("error"),Ys(pe.message),pe}const Q=He.current!==C,J=tY({savedGraph:q.graph,sentGraph:P,savedRevision:q.revision,currentRevision:ge.current});if(ge.current=J.revision,Oe.current=J.graph,!Q){if(Z.current=((Y=q.graph)==null?void 0:Y.instances)||P.instances,ie(Z.current),q.merged&&q.graph){const pe=Yu(q.graph,wt),je=Ph((me=(ce=q.graph)==null?void 0:ce.ui)==null?void 0:me.displayPage,pe.nodes);Z.current=pe.instances,ie(pe.instances),g(pe.nodes),x(pe.edges),z.current=je,T(je)}ct.current=!1}return _a(Qp(q.workspaceSchedules||[])),kl(null),ka(!1),Gs(Q?"dirty":"synced"),Ys(Q?"本地仍有修改等待同步":"所有修改已同步"),ye(Q?"已保存上一版,本地新修改正在排队":q.merged?"Workspace graph merged and saved":"Workspace graph saved"),q},[a,wt,x,g,Se]),an=m.useCallback((w=b,j=k)=>{const C=Ne.current,P={nextNodes:w,nextEdges:j,saveEditVersion:He.current,waiters:[]},M=new Promise((J,Y)=>{P.waiters.push({resolve:J,reject:Y})});if(C.running)return C.pending=H_(C.pending,P),M;C.running=!0;const q=async()=>{let J=P;for(;J;){C.pending&&(J=H_(J,C.pending),C.pending=null);try{const Y=await XS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:ce})=>ce(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Gs("error"),Ys(String(Y.message||Y))),J.waiters.forEach(({reject:ce})=>ce(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&C.pending&&(C.pending.waiters.forEach(({reject:ce})=>ce(Y)),C.pending=null)}J=C.pending,C.pending=null}C.running=!1},Q=_e.current.catch(()=>{}).then(q);return _e.current=Q,M},[k,b,XS]),gL=m.useCallback(w=>{var C;const j=(C=w==null?void 0:w.extra)!=null&&C.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};Z.current=j,ie(j),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),on(""),ne(null)},[x,g]),yL=m.useMemo(()=>({instances:re}),[re]),wL=IG({nodes:b,edges:k,extra:yL,enabled:de.current,onRestore:gL}),{resetHistory:Cu,undo:QS,redo:ZS}=wL,Es=m.useCallback(async(w={})=>{var De,Ht;const j=(w==null?void 0:w.background)===!0,C=xt.current+1;xt.current=C;const P=He.current,M=ge.current;j||(de.current=!1);const q=lY({background:j}),Q=Br(a);let J=null,Y;if(!q.nodes&&!q.files)Y=await fetch(`/api/workspace/graph?${Q.toString()}`);else{const Fe=Br(a);Fe.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[pt,Mt]=await Promise.all([fetch(`/api/nodes?${Fe.toString()}`),fetch(`/api/workspace/graph?${Q.toString()}`),On()]);if(J=await pt.json(),!pt.ok)throw new Error(J.error||"读取节点定义失败");Y=Mt}const ce=await Y.json();if(!Y.ok)throw new Error(ce.error||"读取 workspace graph 失败");const me=eY({background:j,requestId:C,currentRequestId:xt.current,dirty:ct.current,startedEditVersion:P,currentEditVersion:He.current,startedRevision:M,currentRevision:ge.current});if(me==="superseded")return{skipped:!0,reason:me};if(me==="local-edits")return ye("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:me};const pe=j?se.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(Fe=>!fY.has(Fe.id)),wY,yY,mY,gY,pY,hY];j||(se.current=pe,mn(pe));const je=ce.graph||JSON.parse(localStorage.getItem(dY)||"null")||{},Ke=Yu(je,pe),We=Ph((De=je==null?void 0:je.ui)==null?void 0:De.displayPage,Ke.nodes),qe=!L.current;let Be=D.current;if(qe){let Fe=null;try{Fe=JSON.parse(window.localStorage.getItem(u)||"null")}catch{Fe=null}Be=Tb(Fe)||Tb((Ht=je==null?void 0:je.ui)==null?void 0:Ht.viewport)}const Le=j?JG(Oe.current,je):null;if(j&&(Le!=null&&Le.safe)){const Fe=Le.nodesChanged?XG(_.current,Ke.nodes,Le.changedNodeIds):_.current,pt=Le.edgesChanged?QG(S.current,Ke.edges):S.current,Mt=Le.displayPageChanged||!lo(z.current,We),Bl=Le.nodesChanged||Le.edgesChanged||Mt;if(Bl&&(_t.current=!0),Le.nodesChanged){const wi=ZG(Z.current,Ke.instances,Le.changedNodeIds);Z.current=wi,_.current=Fe,ie(wi),g(Fe)}if(Le.edgesChanged&&(S.current=pt,x(pt)),Mt&&(z.current=We,T(We)),Bl&&Cu(Fe,pt,{instances:Le.nodesChanged?Z.current:Ke.instances}),Le.nodesChanged||Mt){const wi=new Set(We.nodeIds);V(Ea=>{const Ia=Ea.filter(cp=>wi.has(cp));return Ia.length===Ea.length?Ea:Ia})}}else Z.current=Ke.instances,_.current=Ke.nodes,S.current=Ke.edges,z.current=We,_t.current=!0,ie(Ke.instances),g(Ke.nodes),x(Ke.edges),T(We),V([]),Cu(Ke.nodes,Ke.edges,{instances:Ke.instances});const Gt=Qp(ce.workspaceSchedules||[]);_a(Fe=>lo(Fe,Gt)?Fe:Gt),ge.current=String(ce.revision||""),Oe.current=je,ct.current=!1;const at=ce.collaboration||null;Wf(Fe=>lo(Fe,at)?Fe:at),K$(ce.adminReview||null),kl(null),qe&&(O(Be),D.current=Be,L.current=!0);const Xe=ce.writable!==!1;return V$(Xe),ye(Xe?"Workspace ready":"Readonly workspace"),Gs(Xe?"synced":"readonly"),Ys(Xe?"所有修改已同步":ce.adminReview?`管理员只读查看:${ce.adminReview.ownerUsername||ce.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),de.current=!0,{skipped:!1}},[a,t.language,On,Cu,x,g,u]),Rl=m.useCallback((w={})=>{if(!de.current)return;const j=String(w.revision||""),C=w.type==="graph.committed",P=!!(Re.current||lt.current||kt.current);if(cY({eventType:w.type,revision:j,currentRevision:ge.current,targetRevision:Ot.current,refreshPending:P}))return;if(C&&j&&(Ot.current=j),ct.current){kt.current=!1,ye("检测到其他成员的更新;保存时将自动合并");return}if(kt.current=!0,Re.current||lt.current)return;const M=async()=>{if(Re.current=null,Ee()){kt.current=!0;return}if(ct.current){kt.current=!1,ye("检测到其他成员的更新;保存时将自动合并");return}kt.current=!1,lt.current=!0;try{await Es({background:!0}),Ot.current=ge.current}catch(q){Ot.current="",ye(String(q.message||q))}finally{lt.current=!1,kt.current&&!ct.current&&(Re.current=window.setTimeout(M,40))}};Re.current=window.setTimeout(M,40)},[Es,Ee]),Au=m.useCallback(async(w=Xn)=>{const j=String(w||"").trim();jS(!0),Nl("");try{if(a.workflowDemo){const q=SY(j);if(!q)throw new Error("本地示例数据已失效,请返回迭代页重新载入示例");mu(q),gu(""),yu(null),_l(null);return}const C=Br(a);C.set("tapdId",j),C.set("runtimeOnly","1");const P=await fetch(`/api/prd-workflow/snapshot?${C.toString()}`),M=await P.json().catch(()=>({}));if(!P.ok)throw new Error(M.error||"读取 PRD Workflow 失败");mu(M.snapshot||null),gu(""),yu(null),_l(null);try{const q=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;j?window.localStorage.setItem(q,j):window.localStorage.removeItem(q)}catch{}}catch(C){Nl(String(C.message||C))}finally{jS(!1)}},[a,Xn]),Ml=m.useCallback(async(w=null,j={})=>{const C=w&&typeof w=="object"?w:dn==null?void 0:dn.nextAction,P=Cm(C);if(!P||Hg)return;const M=(j==null?void 0:j.confirm)===!0,q=String((j==null?void 0:j.expectedRevision)||(dn==null?void 0:dn.revision)||"");NS(!0),Nl(""),M||(gu(""),yu(null),_l(null));try{const Q=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:Xn,action:P,stage:fl(C),title:co(C,0),...JY(C),dryRun:!M,confirm:M,issueKey:C.issueKey||C.issue_key||"",expectedRevision:q,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await Q.json().catch(()=>({}));if(!Q.ok||J.ok===!1)throw J.snapshot&&mu(J.snapshot),J.conflict&&_l({...J.conflict,action:C}),new Error(J.error||"执行 PRD Workflow action 失败");gu(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),mu(J.snapshot||dn),_l(null),yu(M?null:{action:C,output:J.output||null,expectedRevision:q,at:new Date().toISOString()})}catch(Q){Nl(String(Q.message||Q))}finally{NS(!1)}},[a,Hg,dn,Xn]),xL=m.useCallback((w=null)=>Ml(w,{confirm:!1}),[Ml]),bL=m.useCallback(()=>{const w=(Cs==null?void 0:Cs.action)||(dn==null?void 0:dn.nextAction);return Ml(w,{confirm:!0,expectedRevision:(Cs==null?void 0:Cs.expectedRevision)||""})},[Ml,Cs,dn]),kL=m.useCallback(()=>{const w=(wu==null?void 0:wu.action)||(dn==null?void 0:dn.nextAction);return _l(null),Ml(w,{confirm:!1})},[Ml,wu,dn]),vL=m.useCallback(async()=>{var q,Q;const w=String(Vg||(dn==null?void 0:dn.rawOutput)||"").trim();if(!w||Kg)return;const j=(Cs==null?void 0:Cs.action)||(dn==null?void 0:dn.nextAction)||{},C=`Review: ${co(j,0)||(dn==null?void 0:dn.pointer)||Xn||"PRD Workflow"}`,P=/^[\[{]/.test(w),M=w.startsWith("#")?w:`# ${C}
|
|
247
|
+
|
|
248
|
+
${P?`\`\`\`json
|
|
249
|
+
${w}
|
|
250
|
+
\`\`\``:w}`;_S(!0),Nl("");try{const J=await fetch("/api/workflow-artifacts/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,workflow:{namespace:"tapd",id:Xn},title:C,markdown:M,action:Cm(j),stage:fl(j),issueKey:j.issueKey||j.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");mu(Y.snapshot||dn);const ce=((q=Y.review)==null?void 0:q.shortUrl)||((Q=Y.review)==null?void 0:Q.url)||"";ce&&gu(me=>`${me||w}
|
|
251
|
+
|
|
252
|
+
Review link: ${ce}`)}catch(J){Nl(String(J.message||J))}finally{_S(!1)}},[a,Vg,Cs,Kg,dn,Xn]),SL=m.useCallback(async(w,j)=>{const C={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:j,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",scriptRef:(w==null?void 0:w.scriptRef)||"",implementationRef:(w==null?void 0:w.implementationRef)||"",implementationMode:(w==null?void 0:w.implementationMode)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:a.flowId,flowSource:a.flowSource||"user",archived:!!a.archived},P=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),M=await P.json().catch(()=>({}));if(!P.ok||(M==null?void 0:M.ok)===!1)throw new Error((M==null?void 0:M.error)||"Publish failed");return await Es(),ye(`Published node ${M.definitionId||M.id||C.packageId}`),M},[a,Es]),Ca=m.useCallback((w=Us)=>{const j=Array.isArray(w)?w:[],P=[...j].reverse().find(M=>(M==null?void 0:M.status)==="running"||(M==null?void 0:M.status)==="stopping")||[...j].reverse().find(M=>M==null?void 0:M.id);return String((P==null?void 0:P.id)||"workspace")},[Us]),jL=m.useCallback(w=>{const j=String(w||"").trim();!j||j==="workspace"||nr(C=>{const P=(Array.isArray(C)?C:[]).filter(M=>M.id!==j);return As(M=>M===j?Ca(P):M),P})},[Ca]);m.useCallback((w="")=>{Al(!0),El(null),_s(null),As(w||Ca())},[Ca]);const ej=m.useCallback((w={})=>{El({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),Al(!1),_s(null),on("")},[]),sy=m.useCallback(async(w="")=>{const j=String(w||"").trim();if(!(!j||!Se)){HS(j),ye(`Optimizing run: ${j}`);try{await an(_.current,S.current);const C=Yl(_.current,S.current,Z.current),P=gC(_.current,Z.current,j,Vi),M=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:j,graph:C,model:P})}),q=await M.json().catch(()=>({}));if(!M.ok||q.ok===!1)throw new Error(q.error||"优化失败");const Q=q.graph||C,J=Yu(Q,wt);Z.current=J.instances,ie(J.instances),g(J.nodes),x(J.edges),_a(Qp(q.workspaceSchedules||[])),Cu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(q.optimized)?q.optimized.length:0;ye(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(C){ye(String(C.message||C))}finally{HS("")}}},[Vi,S,a,_,wt,Cu,an,x,g,Se]),tj=m.useCallback(async(w="")=>{const j=String(w||"").trim(),C=vu.current||{},P=Object.entries(C).find(([Y,ce])=>Y===j||String((ce==null?void 0:ce.runNodeId)||"")===j)||Object.entries(C)[0]||null,M=(P==null?void 0:P[0])||"",q=(P==null?void 0:P[1])||null,Q=String((q==null?void 0:q.runNodeId)||j||"").trim();if((q==null?void 0:q.status)==="stopping")return;const J=new Set([Q,...Array.isArray(q==null?void 0:q.plannedNodeIds)?q.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));M&&qi(Y=>{const ce={...Y};return ce[M]&&(ce[M]={...ce[M],status:"stopping"}),ce}),ye(Q?`Stopping Workspace run: ${Q}...`:"Stopping Workspace run..."),nr(Y=>Y.map(ce=>(M?ce.id===M:!Q||ce.runNodeId===Q)&&ce.status==="running"?{...ce,status:"stopping"}:ce));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:M,runNodeId:Q})}),ce=await Y.json().catch(()=>({}));if(!Y.ok||(ce==null?void 0:ce.stopped)!==!0)throw new Error(ce.error||"Workspace run stop failed");const me=M?Su.current.get(M):null;me&&(me.abort(),Su.current.delete(M)),M&&qi(pe=>{const je={...pe};return delete je[M],je}),Pl(pe=>{const je=new Set(pe);for(const Ke of J)je.delete(Ke);return je}),Tl(pe=>{var Ke;const je={...pe};for(const We of J)We&&(!je[We]||((Ke=je[We])==null?void 0:Ke.status)==="running")&&(je[We]={status:"stopped"});return je}),ye(Q?`Workspace run stopped: ${Q}`:"Workspace run stopped"),nr(pe=>pe.map(je=>(M?je.id===M:!Q||je.runNodeId===Q)?{...je,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(je.messages)?je.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:je))}catch(Y){M&&qi(me=>{const pe={...me};return pe[M]&&(pe[M]={...pe[M],status:"running"}),pe});const ce=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ye(`停止失败:${ce}`),nr(me=>me.map(pe=>(M?pe.id===M:!Q||pe.runNodeId===Q)?{...pe,status:"running",messages:[...Array.isArray(pe.messages)?pe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${ce}`,at:Date.now()}].slice(-160)}:pe))}},[a,qi]),Uf=m.useCallback(async()=>{if(a.flowId)try{const w=Br(a),j=await fetch(`/api/workspace/run/status?${w.toString()}`),C=await j.json().catch(()=>({}));if(!j.ok||!C.running)return;const P=Array.isArray(C.runs)&&C.runs.length?C.runs:[{runId:`run-restored-${C.startedAt||Date.now()}`,runNodeId:C.runNodeId||"",startedAt:C.startedAt||Date.now(),plannedNodeIds:[]}],M={},q=[];for(const Q of P){const J=String((Q==null?void 0:Q.runNodeId)||"").trim(),Y=String((Q==null?void 0:Q.runId)||`run-restored-${(Q==null?void 0:Q.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const ce=String((Q==null?void 0:Q.label)||"").trim()||jw(_.current,Z.current,J,"Workspace Run");M[Y]={id:Y,runNodeId:J,label:ce,status:(Q==null?void 0:Q.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(Q==null?void 0:Q.plannedNodeIds)?Q.plannedNodeIds:[],startedAt:(Q==null?void 0:Q.startedAt)||Date.now()},J&&q.push(J)}if(!Object.keys(M).length)return;qi(Q=>({...Q,...M})),Pl(Q=>{const J=new Set(Q);for(const Y of q)J.add(Y);return J}),Tl(Q=>{const J={...Q};for(const Y of q)J[Y]={status:"running"};return J}),ye(q.length?`Workspace run still running: ${q.join(", ")}`:"Workspace run still running"),nr(Q=>{const J=[...Q];for(const[Y,ce]of Object.entries(M)){if(J.some(je=>je.id===Y||["running","stopping"].includes(je.status)&&je.runNodeId===ce.runNodeId))continue;const me=String(ce.runNodeId||""),pe=String(ce.label||"").trim()||jw(_.current,Z.current,me,"Workspace Run");J.push({id:Y,label:Nw(pe,me,"Workspace Run"),alias:pe,runNodeId:me,status:ce.status,startedAt:ce.startedAt||Date.now(),steps:me?[{id:me,label:Nw(pe,me,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:ce.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[a,_,qi]),nj=m.useCallback(async w=>{if(!Se){ye("Readonly workspace");return}if(!w)return;if(Object.values(vu.current||{}).find(at=>String((at==null?void 0:at.runNodeId)||"")===String(w||""))){ye(`Workspace run already running: ${w}`);return}let C=_.current,P=S.current,M=Z.current;const q=Zv.current;if(q!=null&&q.id){const at=C.find(De=>De.id===q.id),Xe=wC({nodes:C,edges:P,instances:M,selectedNode:at,draft:q,allowRename:!1});if(Xe!=null&&Xe.error){xl(Xe.error),ye(Xe.error);return}Xe!=null&&Xe.ok&&Xe.changed&&(C=Xe.nodes,P=Xe.edges,M=Xe.instances,Z.current=M,_.current=C,S.current=P,ie(M),g(C),x(P),Yr(Xe.nextId||q.id))}const Q=Yl(C,P,M),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=jw(C,M,w,"Workspace Run"),ce=Nw(Y,w,"Workspace Run");let me=[w];try{const at=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:Q,runNodeId:w})}),Xe=await at.json().catch(()=>({}));if(!at.ok||(Xe==null?void 0:Xe.ok)===!1)throw new Error(Xe.error||"Workspace run plan failed");me=Array.isArray(Xe.plannedNodeIds)&&Xe.plannedNodeIds.length?Xe.plannedNodeIds.map(Ht=>String(Ht||"").trim()).filter(Boolean):[w],me=Array.from(new Set([w,...me].filter(Boolean)));const De=Xe.conflict||null;if(De!=null&&De.runNodeId||De!=null&&De.runId){const Ht=Array.isArray(De.conflictNodeIds)&&De.conflictNodeIds.length?`: ${De.conflictNodeIds.join(", ")}`:"";ye(`Run ${w} conflicts with running ${De.runNodeId||De.runId}${Ht}`);return}}catch(at){ye(String(at.message||at));return}const pe=new Set(me),je=Object.values(vu.current||{}).find(at=>(Array.isArray(at==null?void 0:at.plannedNodeIds)?at.plannedNodeIds:[]).some(Xe=>pe.has(String(Xe||"").trim())));if(je){const at=(Array.isArray(je.plannedNodeIds)?je.plannedNodeIds:[]).map(Xe=>String(Xe||"").trim()).filter(Xe=>Xe&&pe.has(Xe));ye(`Run ${w} conflicts with running ${je.runNodeId||"workspace run"}${at.length?`: ${at.join(", ")}`:""}`);return}const Ke=new AbortController;Su.current.set(J,Ke),ju.current.delete(J),qi(at=>({...at,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:me,startedAt:Date.now()}})),Pl(at=>new Set([...at,w])),Tl(at=>({...at,[w]:{status:"running"}})),ye(`Running ${ce}...`),As(J),nr(at=>[...at.slice(-7),{id:J,label:ce,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let We=w;const qe=new Map,Be=()=>ju.current.has(J),Le=at=>{const Xe=new Set((at||[]).map(De=>String(De||"").trim()).filter(Boolean));Xe.size||Xe.add(String(w||"")),Pl(De=>{const Ht=new Set(De);for(const Fe of Xe)Ht.delete(Fe);return Ht})},Gt=(at,Xe)=>{const De=new Set((at||[]).map(Ht=>String(Ht||"").trim()).filter(Boolean));De.size||De.add(String(w||"")),Tl(Ht=>{var pt;const Fe={...Ht};for(const Mt of De)Mt&&(!Fe[Mt]||((pt=Fe[Mt])==null?void 0:pt.status)==="running")&&(Fe[Mt]={status:Xe});return Fe})};try{await an(C,P);const at=gC(C,M,w,Vi),Xe=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:Ke.signal,body:JSON.stringify({...a,graph:Q,runNodeId:w,runAlias:Y,runSessionId:J,expectedRevision:ge.current,clientId:Kt.current,model:at,selectedSkills:qs,stream:!0})});if(!Xe.ok){const xe=await Xe.json().catch(()=>({}));throw new Error(xe.error||"Workspace run failed")}if(!Xe.body)throw new Error("Workspace run stream unavailable");const De=Xe.body.getReader(),Ht=new TextDecoder;let Fe="",pt=[],Mt=[];const Bl=(xe,ot)=>{var ut,It;const Qe=b.find(qt=>qt.id===xe),ht=String(((ut=Qe==null?void 0:Qe.data)==null?void 0:ut.label)||xe||"").trim(),be=String(ot||((It=Qe==null?void 0:Qe.data)==null?void 0:It.definitionId)||"").trim();return be&&be!==ht?`${ht} (${be})`:ht},wi=(xe,ot,Qe)=>{const ht=String(xe||"").trim();ht&&nr(be=>be.map(ut=>{if(ut.id!==J)return ut;const qt=[...Array.isArray(ut.steps)?ut.steps:[]],mt=qt.findIndex(yn=>yn.id===ht),Ct={id:ht,label:Bl(ht,ot),status:Qe};mt>=0?qt[mt]={...qt[mt],...Ct}:qt.push(Ct);const hn=qt.map((yn,Eo)=>{const Yi=yn.status==="done"?"[done]":yn.status==="failed"?"[failed]":"[running]";return`${Eo+1}. ${Yi} ${yn.label}`}).join(`
|
|
253
|
+
`),tn=Array.isArray(ut.messages)?ut.messages:[],cn=tn.findIndex(yn=>yn.kind==="run-summary"),_n={role:"assistant",kind:"run-summary",text:hn||"准备运行...",at:Date.now()},Yt=[...tn];return cn>=0?Yt[cn]=_n:Yt.unshift(_n),{...ut,steps:qt,messages:Yt.slice(-160)}}))},Ea=(xe,ot)=>{var Yj,Jj,Xj,Qj,Zj,e0,t0,n0,r0,s0;const Qe=String(xe||"").trim(),ht=String(ot||"").trim();if(!Qe||!ht)return;const be=(Yj=Z.current)==null?void 0:Yj[Qe];if(!di(be==null?void 0:be.definitionId))return;const ut=fa(be==null?void 0:be.input,"displayType","markdown"),It=DM(ut),qt=FM(Qe),mt=wt.find(zr=>zr.id===It),Ct=fC(mt==null?void 0:mt.inputs,It,ht),hn=fC(mt==null?void 0:mt.outputs,It,ht),tn=String((be==null?void 0:be.label)||Qe||"一键任务").trim(),cn={...Z.current||{},[Qe]:{...be||{},output:hC(be==null?void 0:be.output)},[qt]:{...((Jj=Z.current)==null?void 0:Jj[qt])||{},definitionId:It,label:tn,role:"normal",body:ht,input:Ct,output:hn,sourceContextRunNodeId:Qe,displayReloadKey:String(Date.now())}};Z.current=cn,ie(cn);const _n=_.current||[],Yt=_n.find(zr=>zr.id===Qe),yn=_n.find(zr=>zr.id===qt),Eo=Number(((Xj=Yt==null?void 0:Yt.measured)==null?void 0:Xj.width)||(Yt==null?void 0:Yt.width)||((Zj=(Qj=Yt==null?void 0:Yt.data)==null?void 0:Qj.nodeSize)==null?void 0:Zj.width)||520),Yi=(yn==null?void 0:yn.position)||{x:Number(((e0=Yt==null?void 0:Yt.position)==null?void 0:e0.x)||0)+Eo+120,y:Number(((t0=Yt==null?void 0:Yt.position)==null?void 0:t0.y)||0)},yr=((n0=yn==null?void 0:yn.data)==null?void 0:n0.displaySize)||((r0=yn==null?void 0:yn.data)==null?void 0:r0.nodeSize)||{width:_b,height:Cb},xi=Sb({id:qt,type:Ec,position:Yi,width:Number(yr.width)||_b,height:Number(yr.height)||Cb,data:{label:tn,definitionId:It,role:"normal",body:ht,inputs:Ct,outputs:hn,sourceContextRunNodeId:Qe,displayReloadKey:cn[qt].displayReloadKey,nodeSize:yr,displaySize:yr}},cn,wt),Io=_n.map(zr=>{if(zr.id===Qe){const{width:mde,height:gde,measured:yde,...N2}=zr,{nodeSize:wde,displaySize:xde,...hp}=zr.data||{};return{...N2,data:{...hp,outputs:hC(hp==null?void 0:hp.outputs),contextRunResultNonce:Date.now()}}}return zr.id===qt?{...xi,selected:zr.selected}:zr});yn||Io.push(xi),_.current=Io,g(Io);const Po=S.current||[],pp=zM(It),xy=pC((be==null?void 0:be.output)||((s0=Yt==null?void 0:Yt.data)==null?void 0:s0.outputs),"output",["content","result"],["text"]),S2=pC(Ct,"input",[pp,"content"],["text"]),j2={id:`we-${Qe}-${qt}`,source:Qe,target:qt,sourceHandle:xy,targetHandle:S2,markerEnd:{type:Ei.ArrowClosed}},Gj=[...Po.filter(zr=>!(zr.source===Qe&&zr.target===qt)),j2];S.current=Gj,x(Gj),window.requestAnimationFrame(()=>{o(Qe),o(qt)})},Ia=(xe,ot=null)=>{const Qe=xe!=null&&xe.instances&&typeof xe.instances=="object"?xe.instances:{},ht=ot instanceof Set?ot:null;for(const[be,ut]of Object.entries(Qe)){if(ht&&!ht.has(be)||!di(ut==null?void 0:ut.definitionId))continue;const It=Ng({outputs:ut.output});It&&Ea(be,It)}},cp=xe=>{const ot=String(xe||"").trim();if(!ot)return;const Qe=We;We=ot,Pl(ht=>{const be=new Set(ht);return Qe&&Qe!==ot&&Qe!==w&&be.delete(Qe),w&&be.add(w),be.add(ot),be}),Tl(ht=>{var be;return{...ht,...Qe&&Qe!==ot&&Qe!==w&&((be=ht[Qe])==null?void 0:be.status)==="running"?{[Qe]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[ot]:{status:"running"}}})},Kj=xe=>{const ot=String(xe||"").trim();ot&&(Pl(Qe=>{const ht=new Set(Qe);return ht.delete(ot),ht}),Tl(Qe=>({...Qe,[ot]:{status:"success"}})))},qj=(xe,ot)=>{const Qe=String(ot||"");if(!Qe.trim())return;const ht=["assistant","thinking","result","error","prompt"].includes(xe)?xe:"assistant";nr(be=>be.map(ut=>{if(ut.id!==J)return ut;let It=Array.isArray(ut.messages)?ut.messages:[];if(ht==="result"){const Ct=[...It].reverse().find(hn=>hn.kind==="assistant");if(String((Ct==null?void 0:Ct.text)||"").trim()===Qe.trim())return ut}if(ht==="assistant"){const Ct=It.findIndex(hn=>hn.kind==="result"&&String(hn.text||"").trim()===Qe.trim());Ct>=0&&(It=It.filter((hn,tn)=>tn!==Ct))}const qt=[...It],mt=qt[qt.length-1];return mt&&mt.kind===ht&&!mt.error?qt[qt.length-1]={...mt,text:`${mt.text||""}${mt.text?`
|
|
254
|
+
`:""}${Qe}`}:qt.push({role:"assistant",kind:ht,text:Qe,...ht==="error"?{error:!0}:{},at:Date.now()}),{...ut,messages:qt.slice(-160)}}))},up=xe=>{const ot=String(xe||"");ot.trim()&&nr(Qe=>Qe.map(ht=>{var qt;if(ht.id!==J)return ht;const be=Array.isArray(ht.messages)?ht.messages:[],ut=be.findIndex(mt=>mt.kind==="thinking"),It=[...be];if(ut>=0){const mt=String(((qt=It[ut])==null?void 0:qt.text)||"");It[ut]={...It[ut],text:`${mt}${mt&&!mt.endsWith(`
|
|
255
|
+
`),""}${ot}`,at:Date.now()}}else{const mt=It.findIndex(Ct=>Ct.kind==="activity");It.splice(mt>=0?mt+1:It.length,0,{role:"assistant",kind:"thinking",text:ot,at:Date.now()})}return{...ht,messages:It.slice(-160)}}))},Ao=(xe,ot=null)=>{const Qe=TY(xe);Qe&&nr(ht=>ht.map(be=>{if(be.id!==J)return be;const ut=Number(ot==null?void 0:ot.ts)||Date.now(),It=Number(be.startedAt)||ut,qt=Number(be.lastActivityAt)||It,mt=Math.max(0,ut-qt),Ct=Number.isFinite(Number(ot==null?void 0:ot.runElapsedMs))?Math.max(0,Number(ot.runElapsedMs)):Math.max(0,ut-It),hn=Array.isArray(be.activities)?be.activities:[],tn=hn[hn.length-1],_n=(typeof tn=="string"?tn:String((tn==null?void 0:tn.text)||""))===Qe?hn:[...hn,{text:Qe,kind:MY(Qe),stepMs:mt,totalMs:Ct,at:ut}].slice(-30),Yt=Array.isArray(be.timingEntries)?be.timingEntries:[],yn=Array.isArray(be.messages)?be.messages:[],Eo=yn.findIndex(xi=>xi.kind==="activity"),Yi={role:"assistant",kind:"activity",text:Y_(_n,Yt,It,ut),at:Date.now()},yr=[...yn];if(Eo>=0)yr[Eo]=Yi;else{const xi=yr.findIndex(Io=>Io.kind==="run-summary");yr.splice(xi>=0?xi+1:0,0,Yi)}return{...be,activities:_n,lastActivityAt:ut,messages:yr.slice(-160)}}))},Uj=xe=>{const ot=String((xe==null?void 0:xe.source)||"runner"),Qe=String((xe==null?void 0:xe.stream)||""),ht=String((xe==null?void 0:xe.eventType)||"event"),be=String((xe==null?void 0:xe.text)||"").trim();if(!be)return;const ut=`[${ot}${Qe?`:${Qe}`:""}] ${ht}
|
|
256
|
+
${be}`,It=fJ(xe);nr(qt=>qt.map(mt=>{if(mt.id!==J)return mt;const hn=[...Array.isArray(mt.rawTrace)?mt.rawTrace:[],ut].slice(-80),tn=Array.isArray(mt.timingEntries)?mt.timingEntries:[],cn=It?[...tn,It].slice(-80):tn,_n=Array.isArray(mt.activities)?mt.activities:[],Yt=Number(mt.startedAt)||Number(xe==null?void 0:xe.ts)||Date.now(),yn=Number(It==null?void 0:It.at)||Number(xe==null?void 0:xe.ts)||Date.now(),Eo=Array.isArray(mt.messages)?mt.messages:[],Yi={role:"assistant",kind:"raw",text:hn.join(`
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
`),at:Date.now()},yr=[...Eo],xi=yr.findIndex(Po=>Po.kind==="activity");if(It){const Po={role:"assistant",kind:"activity",text:Y_(_n,cn,Yt,yn),at:Date.now()};if(xi>=0)yr[xi]=Po;else{const pp=yr.findIndex(xy=>xy.kind==="run-summary");yr.splice(pp>=0?pp+1:0,0,Po)}}const Io=yr.findIndex(Po=>Po.kind==="raw");return Io>=0?yr[Io]=Yi:yr.push(Yi),{...mt,rawTrace:hn,timingEntries:cn,messages:yr.slice(-160)}}))},v2=xe=>{nr(ot=>ot.map(Qe=>Qe.id===J?{...Qe,status:xe,endedAt:Date.now()}:Qe))},dp=xe=>{const ot=new Set,Qe=String((xe==null?void 0:xe.nodeId)||"").trim();Qe&&ot.add(Qe);for(const ht of Array.isArray(xe==null?void 0:xe.displayNodeIds)?xe.displayNodeIds:[]){const be=String(ht||"").trim();be&&ot.add(be)}for(const ht of Array.isArray(xe==null?void 0:xe.touchedNodeIds)?xe.touchedNodeIds:[]){const be=String(ht||"").trim();be&&ot.add(be)}if(ot.size===0)for(const ht of Array.isArray(xe==null?void 0:xe.order)?xe.order:[]){const be=String(ht||"").trim();be&&ot.add(be)}return ot},fp=(xe,ot=null)=>{const Qe=Yu(xe||Q,wt),ht=new Map(Qe.nodes.map(mt=>[mt.id,mt])),be=Qe.instances||{},ut=ot instanceof Set?ot:null,It=(mt,Ct)=>{const hn={...mt||Ct};Array.isArray(Ct==null?void 0:Ct.output)&&(hn.output=Ct.output);for(const tn of["scriptRef","implementationRef","implementationMode"])(Ct==null?void 0:Ct[tn])!=null&&String(Ct[tn]).trim()!==""&&(hn[tn]=Ct[tn]);return hn},qt=(mt,Ct)=>{const hn={...mt||{}};Array.isArray(Ct==null?void 0:Ct.outputs)&&(hn.outputs=Ct.outputs);for(const tn of["scriptRef","implementationRef","implementationMode"])(Ct==null?void 0:Ct[tn])!=null&&String(Ct[tn]).trim()!==""&&(hn[tn]=Ct[tn]);return hn};g(mt=>{const Ct=new Set(mt.map(cn=>cn.id)),tn={...Yl(mt,S.current,Z.current).instances||{}};for(const[cn,_n]of Object.entries(be)){if(ut&&!ut.has(cn)||!Ct.has(cn))continue;const Yt=tn[cn];pl((_n==null?void 0:_n.definitionId)||(Yt==null?void 0:Yt.definitionId))?tn[cn]=_n:Array.isArray(_n==null?void 0:_n.output)&&(tn[cn]=It(Yt,_n))}return Z.current=tn,ie(tn),mt.map(cn=>{var Yt,yn;if(ut&&!ut.has(cn.id))return cn;const _n=ht.get(cn.id);return _n?pl(((Yt=_n.data)==null?void 0:Yt.definitionId)||((yn=cn.data)==null?void 0:yn.definitionId))?{...cn,data:{...cn.data,..._n.data}}:{...cn,data:qt(cn.data,_n.data)}:cn})})};for(;;){const{value:xe,done:ot}=await De.read();if(ot)break;Fe+=Ht.decode(xe,{stream:!0});const Qe=Fe.split(`
|
|
261
|
+
`);Fe=Qe.pop()||"";for(const ht of Qe){if(!ht.trim())continue;const be=JSON.parse(ht);if(be.type==="error")throw new Error(be.error||"Workspace run failed");if(be.type==="stopped"){ju.current.add(J),pt=Array.isArray(be.order)?be.order:pt,Ao("运行停止",be);continue}if(be.type==="node-start"&&(ye(`Running ${be.nodeId}...`),cp(be.nodeId),wi(be.nodeId,be.definitionId,"running")),be.type==="node-done"){const ut=qe.get(String(be.nodeId||"").trim());ut&&Ea(be.nodeId,ut),Kj(be.nodeId),wi(be.nodeId,be.definitionId,"done")}if(be.type==="status"&&Ao(be.line||be.message||"",be),be.type==="paused"&&(Mt=Array.isArray(be.nodeIds)?be.nodeIds:[],Ao("运行暂停",be)),be.type==="natural"&&((be.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(be.text||"")))&&be.nodeId&&qe.set(String(be.nodeId||"").trim(),String(be.text||"")),be.kind==="thinking"?up(be.text||""):qj(be.kind,be.text||"")),be.type==="raw"){const ut=J_(be);ut&&up(ut),Uj(be)}if(be.type==="graph"&&be.graph){const ut=dp(be);fp(be.graph,ut),Ia(be.graph,ut)}if(be.type==="done"){if(be.revision&&(ge.current=String(be.revision)),be.graph){Oe.current=be.graph;const ut=dp(be);fp(be.graph,ut),Ia(be.graph,ut)}pt=Array.isArray(be.order)?be.order:[],Mt=Array.isArray(be.pauseNodeIds)?be.pauseNodeIds:Mt,Ao(Mt.length?"运行暂停":"运行完成",be)}}}if(Fe.trim()){const xe=JSON.parse(Fe);if(xe.type==="error")throw new Error(xe.error||"Workspace run failed");if(xe.type==="stopped"&&(ju.current.add(J),Ao("运行停止",xe)),xe.type==="node-start"&&(ye(`Running ${xe.nodeId}...`),cp(xe.nodeId),wi(xe.nodeId,xe.definitionId,"running")),xe.type==="node-done"){const ot=qe.get(String(xe.nodeId||"").trim());ot&&Ea(xe.nodeId,ot),Kj(xe.nodeId),wi(xe.nodeId,xe.definitionId,"done")}if(xe.type==="status"&&Ao(xe.line||xe.message||"",xe),xe.type==="paused"&&(Mt=Array.isArray(xe.nodeIds)?xe.nodeIds:[],Ao("运行暂停",xe)),xe.type==="natural"&&((xe.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(xe.text||"")))&&xe.nodeId&&qe.set(String(xe.nodeId||"").trim(),String(xe.text||"")),xe.kind==="thinking"?up(xe.text||""):qj(xe.kind,xe.text||"")),xe.type==="raw"){const ot=J_(xe);ot&&up(ot),Uj(xe)}if(xe.type==="graph"&&xe.graph){const ot=dp(xe);fp(xe.graph,ot),Ia(xe.graph,ot)}if(xe.type==="done"){if(xe.revision&&(ge.current=String(xe.revision)),xe.graph){Oe.current=xe.graph;const ot=dp(xe);fp(xe.graph,ot),Ia(xe.graph,ot)}pt=Array.isArray(xe.order)?xe.order:[],Mt=Array.isArray(xe.pauseNodeIds)?xe.pauseNodeIds:Mt,Ao(Mt.length?"运行暂停":"运行完成",xe)}}Be()&&(Le(me),Gt(me,"stopped"));const wy=Be()?`Workspace run stopped: ${w}`:Mt.length?`Workspace run paused at ${Mt.join(", ")}`:`Workspace run done: ${pt.length?pt.join(" -> "):w}`;if(ye(wy),Be()||Gt(me,Mt.length?"paused":"success"),v2(Be()?"stopped":Mt.length?"paused":"done"),!Be()){try{await an(_.current,S.current),ye(wy)}catch(xe){ye(`${wy},但保存结果失败:${String(xe.message||xe)}`)}await On()}}catch(at){if(Be()||(at==null?void 0:at.name)==="AbortError"){Le(me),Gt(me,"stopped"),ye(`Workspace run stopped: ${w}`),nr(Xe=>Xe.map(De=>De.id===J?{...De,status:"stopped",endedAt:Date.now()}:De));return}Le(me),Gt([w,We].filter(Boolean),"failed"),ye(String(at.message||at)),nr(Xe=>Xe.map(De=>De.id===J?{...De,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(De.messages)?De.messages:[],{role:"assistant",error:!0,text:String(at.message||at),at:Date.now()}].slice(-160)}:De))}finally{Su.current.get(J)===Ke&&Su.current.delete(J),qi(at=>{const Xe={...at};return delete Xe[J],Xe}),ju.current.delete(J),Le(me)}},[Vi,k,a,On,b,wt,Yr,an,qs,x,g,qi,o,Se]),Gf=m.useCallback(async()=>{try{const j=await(await fetch("/api/skills")).json().catch(()=>({})),C=Array.isArray(j.skills)?j.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):""})):[];sL(C),wS(!0)}catch{wS(!0)}},[]),Yf=m.useCallback(async()=>{try{const j=await(await fetch("/api/mcps")).json().catch(()=>({})),C=Array.isArray(j.servers)?j.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):[];kS(C)}catch{kS([])}},[]),Jf=m.useCallback(async()=>{try{const w=Br(a),C=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),P=Array.isArray(C.workspaces)?C.workspaces.map(M=>({id:String((M==null?void 0:M.id)||""),label:String((M==null?void 0:M.label)||(M==null?void 0:M.name)||"知识库"),path:String((M==null?void 0:M.path)||""),kind:(M==null?void 0:M.kind)==="git"?"git":"local",repoUrl:String((M==null?void 0:M.repoUrl)||""),branch:String((M==null?void 0:M.branch)||""),mountPath:String((M==null?void 0:M.mountPath)||""),type:String((M==null?void 0:M.type)||""),builtin:(M==null?void 0:M.builtin)===!0,exists:(M==null?void 0:M.exists)!==!1})).filter(M=>M.path):[];SS(P)}catch{SS([])}},[a]),rj=m.useCallback(async()=>{en.current=!1;try{const w=Br(a),j=await fetch(`/api/workspace/conversations?${w.toString()}`),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||`HTTP ${j.status}`);const P=K_(C.conversations||{});Cl(P.composer.messages),nr(P.composer.runSessions),As(P.composer.activeSessionId||"workspace"),No(P.nodeChats)}catch{Cl([]),nr([]),As("workspace"),No({})}finally{en.current=!0}},[a]),sj=m.useCallback(async()=>{if(!Se||a.archived)return;const w=K_({composer:{activeSessionId:Jr,messages:ja,runSessions:Us},nodeChats:Na});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async j=>{if(!j.ok){const C=await j.json().catch(()=>({}));throw new Error(C.error||`HTTP ${j.status}`)}})},[Jr,ja,Us,a,Na,Se]);m.useEffect(()=>{let w=!1;return l?(Qg(null),Zg(!0),()=>{w=!0}):((async()=>{const C=new URL(window.location.href),P=String(C.searchParams.get("invite")||"").trim();if(P){ye("正在加入共享 Workspace...");const M=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:P})}),q=await M.json().catch(()=>({}));if(!M.ok)throw new Error(q.error||"加入共享 Workspace 失败");C.searchParams.delete("invite"),window.history.replaceState({},"",`${C.pathname}${C.search}${C.hash}`)}w||(await Es(),w||await rj())})().catch(C=>{const P=String(C.message||C);ye(P),Gs("error"),Ys(P)}),qf(),fetch("/api/model-lists").then(C=>C.json()).then(C=>nL({cursor:Array.isArray(C.cursor)?C.cursor.map(String):[],opencode:Array.isArray(C.opencode)?C.opencode.map(String):[],claudeCode:Array.isArray(C.claudeCode)?C.claudeCode.map(String):[],codex:Array.isArray(C.codex)?C.codex.map(String):[]})).catch(()=>{}),Gf(),Yf(),Jf(),Uf(),fetch("/api/skill-collections").then(C=>C.json()).then(C=>{iL(Ya(C)),oL(!0)}).catch(()=>{}),fetch("/api/auth/me").then(C=>C.json()).then(C=>{Qg(C.user||null),Zg(!0)}).catch(()=>{Qg(null),Zg(!0)}),()=>{w=!0})},[l,Es,rj,qf,Yf,Gf,Uf,Jf,Ki]),m.useEffect(()=>{if(US(""),!(!yS||!xS)){if(!Ki){hu([]);return}hu(yz(Ki,"workspace",Ks,jl)),US(Ki)}},[jl,xS,Ks,yS,Ki]),m.useEffect(()=>{if(!(qS!==Ki||!Ki))try{localStorage.setItem(Ki,JSON.stringify(qs))}catch{}},[qs,Ki,qS]),m.useEffect(()=>{Z.current=re},[re]),m.useEffect(()=>{_.current=b},[b]),m.useEffect(()=>{if(ae.current)return;const w=B.current,j=new Map,C=[];for(const P of b){const M=bM(P);j.set(P.id,M),w.get(P.id)!==M&&C.push(P.id)}B.current=j,C.length!==0&&Yr(C)},[b,Yr]),m.useEffect(()=>{S.current=k},[k]),m.useEffect(()=>{z.current=I},[I]),m.useEffect(()=>{D.current=E},[E]),m.useEffect(()=>{Zv.current=yt},[yt]),m.useEffect(()=>{Qv.current=Nr},[Nr]),m.useEffect(()=>{ee.current=G},[G]),m.useEffect(()=>{if(!G)return;const w=C=>{C.key==="Escape"&&ne(null)},j=C=>{var P,M;(M=(P=C.target)==null?void 0:P.closest)!=null&&M.call(P,".af-connect-node-menu")||ne(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",j),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",j)}},[G]),m.useEffect(()=>{if(!de.current||!Se)return;if(ae.current){fe.current&&window.clearTimeout(fe.current);return}const w=Xt.current;if(Xt.current=null,(w==null?void 0:w.nodes)===b&&w.edges===k&&w.displayPage===I)return;if(_t.current){_t.current=!1;return}yi(),fe.current&&window.clearTimeout(fe.current);const j=it.current?0:650;return it.current=!1,fe.current=window.setTimeout(()=>{an().catch(C=>ye(String(C.message||C)))},j),()=>{fe.current&&window.clearTimeout(fe.current)}},[b,k,I,yi,an,Se]),m.useEffect(()=>{if(en.current&&!(!Se||a.archived))return Ut.current&&window.clearTimeout(Ut.current),Ut.current=window.setTimeout(()=>{sj().catch(w=>ye(String(w.message||w)))},900),()=>{Ut.current&&window.clearTimeout(Ut.current)}},[Jr,ja,Us,a.archived,Na,sj,Se]);const Eu=m.useMemo(()=>b.filter(w=>{var j;return((j=w==null?void 0:w.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"}).map(w=>{var j;return{id:w.id,config:Lv(((j=w.data)==null?void 0:j.body)||"")}}),[b]),NL=m.useMemo(()=>Eu.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[Eu]);m.useEffect(()=>{if(!de.current||p!=="workspace"||!a.flowId){_a({});return}if(!Eu.length){_a({});return}let w=!1;const j=async()=>{try{const P=Br(a),M=await fetch(`/api/workspace/schedules?${P.toString()}`),q=await M.json().catch(()=>({}));if(!M.ok)throw new Error(q.error||"读取 Workspace 定时状态失败");w||_a(Qp(q.schedules||[]))}catch{w||_a(P=>{var q;const M={};for(const Q of Eu)M[Q.id]={...P[Q.id]||{},lastStatus:((q=P[Q.id])==null?void 0:q.lastStatus)||"unknown"};return M})}};j();const C=window.setInterval(j,5e3);return()=>{w=!0,window.clearInterval(C)}},[a,Eu,NL,p]);const ij=m.useCallback((w,j)=>{if(!Se){ye("Readonly workspace");return}const C=dC(j),P=Y=>Array.isArray(Y)?Y.map(ce=>(ce==null?void 0:ce.name)!=="skillKeys"&&(ce==null?void 0:ce.name)!=="skillsContext"&&(ce==null?void 0:ce.type)!=="text"?ce:{...ce,default:C,value:C}):[],M=b.map(Y=>{var ce;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:P((ce=Y.data)==null?void 0:ce.inputs)}}}),q=Z.current||{},Q=q[w]&&typeof q[w]=="object"?q[w]:{},J={...q,[w]:{...Q,body:C,input:P(Q.input)}};Z.current=J,g(M),ie(J),_s(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:P(Y.inputs)}),an(M,k).catch(Y=>ye(String(Y.message||Y)))},[k,b,an,g,Se]),oj=m.useCallback((w,j)=>{if(!Se){ye("Readonly workspace");return}const C=kX(j),P=Y=>Array.isArray(Y)?Y.map(ce=>(ce==null?void 0:ce.name)!=="serverNames"&&(ce==null?void 0:ce.name)!=="mcpContext"&&(ce==null?void 0:ce.type)!=="text"?ce:{...ce,default:C,value:C}):[],M=b.map(Y=>{var ce;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:P((ce=Y.data)==null?void 0:ce.inputs)}}}),q=Z.current||{},Q=q[w]&&typeof q[w]=="object"?q[w]:{},J={...q,[w]:{...Q,body:C,input:P(Q.input)}};Z.current=J,g(M),ie(J),_s(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:P(Y.inputs)}),an(M,k).catch(Y=>ye(String(Y.message||Y)))},[k,b,an,g,Se]),aj=m.useCallback((w,j)=>{if(!Se){ye("Readonly workspace");return}const C=(Array.isArray(j)?j:j?[j]:[]).filter(We=>String((We==null?void 0:We.path)||"").trim()),P=C[0]||null,M=String((P==null?void 0:P.path)||"").trim(),q=C.length===1?String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim():C.length?`${C.length} 个知识库`:"",Q=C.length?JSON.stringify(_g(C)):"",J=P?JSON.stringify({version:1,id:(P==null?void 0:P.id)||"",label:String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim(),kind:(P==null?void 0:P.kind)||"local",cwd:M,workspaceRoot:M,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=We=>Array.isArray(We)?We.map(qe=>(qe==null?void 0:qe.name)==="path"?{...qe,default:M,value:M}:(qe==null?void 0:qe.name)==="label"?{...qe,default:q,value:q}:(qe==null?void 0:qe.name)==="knowledgeContext"?{...qe,default:Q,value:Q}:(qe==null?void 0:qe.name)==="workspaceContext"?{...qe,default:J,value:J}:(qe==null?void 0:qe.name)==="mode"?{...qe,default:"set",value:"set"}:qe):[],ce=We=>Array.isArray(We)?We.map(qe=>(qe==null?void 0:qe.name)==="knowledgeContext"?{...qe,default:Q,value:Q}:(qe==null?void 0:qe.name)==="workspaceContext"?{...qe,default:J,value:J,showOnNode:!1}:(qe==null?void 0:qe.name)==="cwd"?{...qe,default:M,value:M,showOnNode:!1}:qe):[],me=b.map(We=>{var qe,Be,Le;return We.id===w?{...We,data:{...We.data,label:((qe=We.data)==null?void 0:qe.label)||"加载知识库",inputs:Y((Be=We.data)==null?void 0:Be.inputs),outputs:ce((Le=We.data)==null?void 0:Le.outputs)}}:We}),pe=Z.current||{},je=pe[w]&&typeof pe[w]=="object"?pe[w]:{},Ke={...pe,[w]:{...je,label:je.label||"加载知识库",input:Y(je.input),output:ce(je.output)}};Z.current=Ke,g(me),ie(Ke),_s(We=>(We==null?void 0:We.id)===w?{...We,inputs:Y(We.inputs),outputs:ce(We.outputs)}:We),an(me,k).catch(We=>ye(String(We.message||We)))},[k,b,an,g,Se]),lj=m.useCallback((w,j)=>{if(!Se){ye("Readonly workspace");return}const C=String(w||"");if(!C)return;const P=dC((j==null?void 0:j.skillKeys)||[]),M=Mf((j==null?void 0:j.displayType)||"markdown"),q=String((j==null?void 0:j.model)||"").trim(),Q=(j==null?void 0:j.includeWorkspaceContext)===!1?"false":"true",J=j!=null&&j.workspaceContext&&typeof j.workspaceContext=="object"?JSON.stringify(j.workspaceContext):"",Y=j!=null&&j.knowledgeContext&&typeof j.knowledgeContext=="object"?JSON.stringify(j.knowledgeContext):"",ce=Be=>Array.isArray(Be)?Be.map(Le=>(Le==null?void 0:Le.name)==="skillKeys"?{...Le,default:P,value:P}:(Le==null?void 0:Le.name)==="displayType"?{...Le,default:M,value:M}:(Le==null?void 0:Le.name)==="includeWorkspaceContext"?{...Le,default:Q,value:Q}:(Le==null?void 0:Le.name)==="knowledgeContext"?{...Le,default:Y,value:Y}:(Le==null?void 0:Le.name)==="workspaceContext"?{...Le,default:J,value:J}:Le):[],me=Be=>Array.isArray(Be)?Be.map(Le=>(Le==null?void 0:Le.name)==="displayType"?{...Le,default:M,value:M}:Le):[],pe=String((j==null?void 0:j.task)??""),je=b.map(Be=>{var Le,Gt;return Be.id===C?{...Be,data:{...Be.data,body:pe,model:q,inputs:ce((Le=Be.data)==null?void 0:Le.inputs),outputs:me((Gt=Be.data)==null?void 0:Gt.outputs)}}:Be}),Ke=Z.current||{},We=Ke[C]&&typeof Ke[C]=="object"?Ke[C]:{},qe={...Ke,[C]:{...We,body:pe,model:q,input:ce(We.input),output:me(We.output)}};Z.current=qe,g(je),ie(qe),_s(Be=>(Be==null?void 0:Be.id)===C?{...Be,body:pe,model:q,inputs:ce(Be.inputs),outputs:me(Be.outputs)}:Be),an(je,k).catch(Be=>ye(String(Be.message||Be)))},[k,b,an,g,Se]),cj=m.useCallback((w,j)=>{if(!Se){ye("Readonly workspace");return}const C=vJ(j),P=b.map(J=>J.id===w?{...J,data:{...J.data,body:C}}:J),M=Z.current||{},q=M[w]&&typeof M[w]=="object"?M[w]:{},Q={...M,[w]:{...q,body:C}};Z.current=Q,_t.current=!0,g(P),ie(Q),_s(J=>(J==null?void 0:J.id)===w?{...J,body:C}:J),an(P,k).catch(J=>ye(String(J.message||J)))},[k,b,an,g,Se]),uj=m.useCallback(w=>{const j=String(w||"").trim();j&&($S(C=>C===j?"":j),No(C=>({...C,[j]:C[j]||{sessionId:`nodechat_${Date.now()}_${j.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),dj=m.useCallback(()=>$S(""),[]),fj=m.useCallback((w,j)=>{const C=String(w||"").trim();C&&No(P=>({...P,[C]:{...P[C]||{sessionId:`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(j||""),error:""}}))},[]),Js=m.useCallback((w,j,C="replace",P={})=>{var at,Xe;if(!Se){ye("Readonly workspace");return}const M=String(w||"").trim();if(!M)return;const q=_.current.find(De=>De.id===M),Q=Dn(q==null?void 0:q.data),J=di((at=q==null?void 0:q.data)==null?void 0:at.definitionId),Y=Oi(j),ce=Q==="html"?su(Y):Q==="react"?jg(Y):String(Y||""),me=q?uo(q.data):"",pe=C==="append"&&String(me||"").trim()?`${String(me).replace(/\s+$/g,"")}
|
|
262
|
+
|
|
263
|
+
${ce.trim()}`:ce,je=Q==="image"?"src":"content",Ke=P!=null&&P.reloadDisplay?Date.now():(Xe=q==null?void 0:q.data)==null?void 0:Xe.displayReloadKey,We=De=>{let Ht=!1;return(Array.isArray(De)?De:[]).map(pt=>{const Mt=String((pt==null?void 0:pt.name)||""),Bl=String((pt==null?void 0:pt.type)||"");return(J?Mt===je||Mt==="result"||Mt==="filePath":Mt===je||Mt==="filePath"||Bl==="text")?Ht?{...pt,default:"",value:""}:(Ht=!0,{...pt,default:pe,value:pe}):pt})},qe=_.current.map(De=>{var Ht,Fe;return De.id!==M?De:{...De,data:{...De.data,body:J?De.data.body:pe,...Ke?{displayReloadKey:Ke}:{},inputs:We((Ht=De.data)==null?void 0:Ht.inputs),outputs:We((Fe=De.data)==null?void 0:Fe.outputs)}}}),Be=Z.current||{},Le=Be[M]&&typeof Be[M]=="object"?Be[M]:{},Gt={...Be,[M]:{...Le,body:J?Le.body:pe,input:We(Le.input),output:We(Le.output)}};Z.current=Gt,g(qe),ie(Gt),_s(De=>(De==null?void 0:De.id)===M?{...De,...J?{}:{body:pe}}:De),(P==null?void 0:P.logChat)!==!1&&No(De=>{var Ht;return{...De,[M]:{...De[M]||{},candidateContent:"",messages:[...(Ht=De[M])!=null&&Ht.messages&&Array.isArray(De[M].messages)?De[M].messages:[],{role:"assistant",text:C==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),an(qe,S.current).catch(De=>ye(String(De.message||De))),ye(String((P==null?void 0:P.statusMessage)||"")||(C==="append"?"已追加节点内容":"已替换节点内容"))},[an,g,Se]),Xf=m.useCallback(async(w,j="")=>{if(!Se)return ye("Readonly workspace"),"";if(!w)return"";try{const C=new FormData;C.set("file",w),C.set("dir",String(j||"")),a.flowId&&C.set("flowId",a.flowId),a.flowSource&&C.set("flowSource",a.flowSource),a.adminOwnerId&&C.set("adminOwnerId",a.adminOwnerId),a.archived&&C.set("archived","1");const P=await fetch("/api/workspace/upload",{method:"POST",body:C}),M=await P.json().catch(()=>({}));if(!P.ok)throw new Error(M.error||"上传文件失败");const q=String(M.path||"").trim();if(!q)throw new Error("上传文件失败:未返回路径");return await On(),Sl(Q=>{const J=new Set(Q);for(const Y of eh(q))J.delete(Y);return J}),ye(`已上传 ${q}`),q}catch(C){return ye(String(C.message||C)),""}},[a,On,Se]),Qf=m.useCallback(async w=>Nm(w)?Xf(w,"img"):(ye("请选择图片文件"),""),[Xf]),pj=m.useCallback((w="")=>{var j;if(!Se){ye("Readonly workspace");return}hS.current=String(w||""),(j=pS.current)==null||j.click()},[Se]),_L=m.useCallback(async w=>{const j=Array.from(w.target.files||[]);if(w.target.value="",!j.length)return;const C=hS.current||"";fS(!0);try{let P="";for(const M of j){const q=await Xf(M,C);q&&(P=q)}j.length>1&&ye(`已上传 ${j.length} 个文件${P?`,最后一个:${P}`:""}`)}catch(P){ye(String(P.message||P))}finally{fS(!1)}},[Xf]),hj=m.useCallback(async(w,j)=>{const C=String(w||"").trim();if(!C)return;const P=await Qf(j);P&&Js(C,P,"replace",{logChat:!1,statusMessage:`已上传图片 ${P}`})},[Js,Qf]),mj=m.useCallback(async(w,j=void 0)=>{var We,qe;if(!Se){ye("Readonly workspace");return}const C=String(w||"").trim();if(!C)return;const P=Na[C]||{},M=String(j!==void 0?j:P.draft||"").trim();if(!M||P.running)return;const q=_.current.find(Be=>Be.id===C);if(!q)return;const Q=Dn(q.data)||"markdown",J=uo(q.data);let Y=da(J,Q),ce=Oi(J);if(Y)try{ce=await hl(a,Y)}catch(Be){ye(String(Be.message||Be))}else if(Q!=="image"&&String(ce||"").trim()){const Be=Ka(Q,ce);if(Be){ye(`${Be} 未进入微调。`);return}try{const Le=await Mb(a,cC(C,q.data),ce);await On(),Js(C,Le,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Le}`}),Y=Le,ce=""}catch(Le){ye(String(Le.message||Le));return}}const me=FJ(C,_.current,S.current),pe={role:"user",text:M,at:Date.now()},je=Array.isArray(P.messages)?P.messages:[],Ke=P.sessionId||`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`;No(Be=>({...Be,[C]:{...P,sessionId:Ke,messages:[...je,pe],draft:"",running:!0,error:""}}));try{const Be=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:Ke,node:{id:C,label:((We=q.data)==null?void 0:We.label)||C,definitionId:((qe=q.data)==null?void 0:qe.definitionId)||""},nodeKind:Q,currentContent:Y?"":ce,sourceContext:me,targetFilePath:Y,messages:je,message:M,model:Vi})}),Le=await Be.json().catch(()=>({}));if(!Be.ok)throw new Error(Le.error||"节点微调失败");const Gt=String(Le.candidateContent||Le.reply||"").trim(),at=!!Le.directFileEdit,Xe=String(Le.artifactPath||Y||"").trim();if(at&&Xe){const De=Ka(Q,Gt);if(De)throw new Error(`${De} 文件已由 agent 修改,请检查 ${Xe}。`);await On(),Js(C,Xe,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Xe}`})}else if(Gt){const De=Ka(Q,Gt);if(De)throw new Error(`${De} 已取消写入,避免覆盖当前展示文件。`);if(Y){const Ht=await Mb(a,Y,Gt);await On(),Js(C,Ht,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ht}`})}else Js(C,Gt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}No(De=>{var Ht;return{...De,[C]:{...De[C]||{},sessionId:String(Le.sessionId||Ke),running:!1,candidateContent:"",messages:[...(Ht=De[C])!=null&&Ht.messages&&Array.isArray(De[C].messages)?De[C].messages:[...je,pe],{role:"assistant",text:Gt||at?Xe?`已更新文件 ${Xe}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(Be){const Le=String(Be.message||Be);No(Gt=>({...Gt,[C]:{...Gt[C]||{},running:!1,error:Le}})),ye(Le)}},[Vi,a,On,Na,Js,Se]),gj=m.useCallback(async(w,j)=>{if(!Se){ye("Readonly workspace");return}const C=Dn(j)||"markdown",P=uo(j),M=da(P,C);let q=Oi(P);if(M)try{q=await hl(a,M)}catch(ce){ye(String(ce.message||ce));return}if(!String(q||"").trim()){ye("展示节点没有可保存内容");return}const Q=Ka(C,q);if(Q){ye(`${Q} 未保存文件。`);return}const J=cC(w,j),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const ce=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:q})}),me=await ce.json().catch(()=>({}));if(!ce.ok)throw new Error(me.error||"保存文件失败");const pe=me.path||Y,je=Br(a);je.set("path",pe);const Ke=await fetch(`/api/workspace/file?${je.toString()}`);if(!Ke.ok){const We=await Ke.json().catch(()=>({}));throw new Error(We.error||`保存后读取失败:${pe}`)}await On(),eS(We=>fX(We,pe,String(q||"").length)),Sl(We=>{const qe=new Set(We);for(const Be of eh(pe))qe.delete(Be);return qe}),Js(w,pe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${pe}`}),ye(`已保存 ${pe}`)}catch(ce){ye(String(ce.message||ce))}},[a,On,Js,Se]),yj=m.useCallback(w=>{var M,q;const j=String(w||"").trim();if(!j||ue)return;const C=_.current.find(Q=>Q.id===j);if(!C||!Dn(C==null?void 0:C.data)){ye("展示节点不可用");return}const P=String(((M=C.data)==null?void 0:M.label)||((q=C.data)==null?void 0:q.displayName)||j).trim()||"AgentFlow Display";Tt(Aw({title:P,layout:"single",nodeIds:[j],mode:"single-node",sourceNodeId:j})),le(""),Je(null),hr(!0)},[ue]),Zf=m.useCallback((w,j)=>{const C=String(w||"");C&&_s(P=>{if(!P||P.id!==C)return P;const M=typeof j=="function"?j(P):j;return!M||typeof M!="object"?P:{...P,...M}})},[]),wj=m.useCallback((w,j)=>{const C=String(w||"");!C||!Se||(g(P=>P.map(M=>{var Q;if(M.id!==C)return M;const q=Array.isArray((Q=M.data)==null?void 0:Q.outputs)&&M.data.outputs.length?M.data.outputs.map((J,Y)=>Y===0?{...J,default:j,value:j}:J):[{type:"file",name:"value",default:j,value:j}];return{...M,data:{...M.data,body:"",outputs:q}}})),Zf(C,P=>({body:"",outputs:Array.isArray(P==null?void 0:P.outputs)&&P.outputs.length?P.outputs.map((q,Q)=>Q===0?{...q,default:j,value:j}:q):[{type:"file",name:"value",default:j,value:j}]})),ye(`已选择文件 ${j}`))},[g,Zf,Se]),xj=m.useCallback(w=>{zg({nodeId:String(w||""),query:""})},[]),iy=m.useCallback(()=>{zg({nodeId:"",query:""})},[]),CL=m.useCallback(w=>{const j=String((w==null?void 0:w.path)||"").trim();!j||!pu.nodeId||(wj(pu.nodeId,j),iy())},[iy,pu.nodeId,wj]),bj=m.useCallback(async(w,j)=>{if(!Se)return;const C=tX(w,j);if(C.length===0)return;const P=[];try{for(const M of C){const q=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:M})});if(q.status===404)continue;const Q=await q.json().catch(()=>({}));if(!q.ok)throw new Error(Q.error||"清理节点输出失败");P.push(Q.path||M)}if(P.length===0)return;ye(`已清理 ${P.join(", ")}`),await On(),Fg(M=>C.some(q=>M===q||M.startsWith(`${q}/`))?"":M)}catch(M){ye(String(M.message||M))}},[a,On,Se]),Iu=m.useMemo(()=>({modelLists:va,showBodyPreview:!0,flowParams:a,readOnly:!Se,onRunWorkspaceNode:nj,onStopWorkspaceNode:tj,onOpenWorkspaceRunLogs:ej,onOptimizeWorkspaceRun:sy,onOptimizeWorkspaceSchedule:sy,runningRunNodeIds:GS,onChangeScheduledRunConfig:cj,onChangeContextRunConfig:lj,skills:Ks,skillCollections:jl,onChangeLoadSkillKeys:ij,onRefreshSkills:Gf,mcpServers:bS,onChangeLoadMcpNames:oj,onRefreshMcps:Yf,workspaceTargets:vS,onChangeLoadWorkspace:aj,onRefreshWorkspaces:Jf,onSaveDisplayNodeToFile:gj,onShareDisplayNode:yj,onOpenDisplayPreview:U,onRefreshNodeInternals:Yr,onEnsureWorkspaceNodeDisplaySize:AS,sharingDisplayNodeId:ue,onUploadWorkspaceImage:Qf,onUploadImageToDisplayNode:hj,onOpenProvideFilePicker:xj,onStatus:ye,onSetDisplayNodeContent:Js,onToggleNodeChat:uj,onCloseNodeChat:dj,onUpdateNodeChatDraft:fj,onSendNodeChat:mj,onSyncNodePropDraft:Zf,onCleanupWorkspaceNodeOutputs:bj}),[lj,oj,ij,aj,cj,bj,dj,AS,a,bS,va,xj,ej,sy,Yf,Yr,Gf,Jf,nj,GS,gj,mj,Js,yj,ue,jl,Ks,tj,Zf,uj,fj,hj,Qf,vS,Se]),AL=m.useRef(new Map),ds=m.useMemo(()=>{const w=AL.current,j=new Set,C=b.map(P=>{var Y,ce,me;const M={selected:P.selected===!0,isExecuting:WS.has(P.id),nodeStatus:((Y=ry[P.id])==null?void 0:Y.status)??null,nodeElapsed:((ce=ry[P.id])==null?void 0:ce.elapsed)??null,optimizingRun:BS===P.id,scheduledRunState:zS[P.id]||null,nodeChatActive:MS===P.id,nodeChat:Na[P.id]||null},q=w.get(P.id);if(q&&q.source===P&&q.commonData===Iu&&tC(q.runtime,M))return j.add(P.id),q.node;const Q=!!(q&&((me=q.source)==null?void 0:me.data)===P.data&&q.commonData===Iu&&tC(q.runtime,M)),J={...P,data:Q?q.node.data:{...P.data,...Iu,...M}};return w.set(P.id,{source:P,commonData:Iu,runtime:M,node:J}),j.add(P.id),J});for(const P of w.keys())j.has(P)||w.delete(P);return C},[MS,Iu,Na,b,BS,zS,WS,ry]),ft=p==="display",Bt=p==="workflow",kj=m.useMemo(()=>ft?new Map(ds.map(w=>[w.id,w])):AJ,[ds,ft]),vj=m.useMemo(()=>Ns&&ds.find(w=>w.id===Ns)||null,[Ns,ds]),Sj=m.useRef(new Map),Pu=m.useMemo(()=>{if(!ft)return Sj.current.clear(),EJ;const w=new Set($),j=Sj.current,C=new Set,P=I.nodeIds.map((M,q)=>{var Ke,We,qe,Be;const Q=kj.get(M);if(!Q||!Dn(Q.data))return null;const J=ec(Q)||{width:520,height:320},Y=Qa(I.nodeSizes[M]||J,{display:!0})||J,ce=I.nodePositions[M]||{x:180+q*36,y:120+q*28},me=w.has(M),pe=j.get(M);if(pe&&pe.source===Q&&((Ke=pe.position)==null?void 0:Ke.x)===ce.x&&((We=pe.position)==null?void 0:We.y)===ce.y&&((qe=pe.size)==null?void 0:qe.width)===Y.width&&((Be=pe.size)==null?void 0:Be.height)===Y.height&&pe.selected===me)return C.add(M),pe.node;const je={...Q,id:nC(M),position:ce,selected:me,width:Y.width,height:Y.height,data:{...Q.data,sourceNodeId:M,displayPageMode:!0,readOnly:!0,selected:me,displaySize:Y,nodeSize:Y}};return j.set(M,{source:Q,position:ce,size:Y,selected:me,node:je}),C.add(M),je}).filter(Boolean);for(const M of j.keys())C.has(M)||j.delete(M);return P},[I,kj,ft,$]),$l=m.useMemo(()=>ds.filter(w=>Dn(w==null?void 0:w.data)),[ds]);m.useEffect(()=>{if(!ft||!I.viewport)return;const w=I.viewport,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(C)},[I.viewport,ft,r]),m.useEffect(()=>{if(ft||Bt||!E)return;const w=E,j=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(j));return()=>window.cancelAnimationFrame(C)},[ft,Bt,r,E]),m.useEffect(()=>{Bt&&Au(Xn)},[Bt]),m.useEffect(()=>{if(!Bt||!Xn||a.workflowDemo)return;const w=Br(a);w.set("tapdId",Xn);let j=null,C=null,P=!1;const M=()=>{C&&(window.clearTimeout(C),C=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},q=()=>{P||document.hidden||j||(j=new EventSource(`/api/prd-workflow/events?${w.toString()}`),j.onmessage=()=>{Au(Xn)},j.onerror=()=>{M(),!P&&!document.hidden&&(C=window.setTimeout(q,5e3))})},Q=()=>{if(document.hidden){M();return}Au(Xn),q()};return q(),document.addEventListener("visibilitychange",Q),()=>{P=!0,document.removeEventListener("visibilitychange",Q),M()}},[a,Bt,Au,Xn]),m.useEffect(()=>{if(!a.flowId||Bt)return;const w=Br(a);w.set("clientId",Kt.current);let j=null,C=null,P=!1;const M=()=>{C&&(window.clearTimeout(C),C=null),j&&(j.onmessage=null,j.onerror=null,j.close(),j=null)},q=()=>{P||document.hidden||j||(j=new EventSource(`/api/workspace/events?${w.toString()}`),j.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===Kt.current)){if(Y.type==="graph.committed"){Rl(Y);return}if(Y.type==="runtime.committed"){Rl(Y);return}if(String(Y.type||"").startsWith("file.")){On();return}String(Y.type||"").startsWith("run.")&&Uf()}},j.onerror=()=>{M(),!P&&!document.hidden&&(C=window.setTimeout(q,5e3))})},Q=()=>{if(document.hidden){M();return}Rl({type:"visibility.resume"}),q()};return q(),document.addEventListener("visibilitychange",Q),()=>{P=!0,document.removeEventListener("visibilitychange",Q),M(),Re.current&&(window.clearTimeout(Re.current),Re.current=null),kt.current=!1}},[a,Bt,On,Uf,Rl]),m.useEffect(()=>{if(ae.current)return;const w=F.current,j=new Map,C=[];for(const P of[...ds,...Pu]){const M=CJ(P);j.set(P.id,M),w.get(P.id)!==M&&C.push(P.id)}F.current=j,C.length!==0&&Yr(C)},[Pu,ds,Yr]);const Qt=m.useMemo(()=>b.find(w=>w.id===Nr)||null,[b,Nr]),oy=m.useRef({id:"",draft:null}),EL=m.useMemo(()=>{const w=mC(Qt);return w?JSON.stringify(w):""},[Qt==null?void 0:Qt.data,Qt==null?void 0:Qt.id]);m.useEffect(()=>{if(!Qt){oy.current={id:"",draft:null},_s(null),xl("");return}const w=mC(Qt),j=oy.current;oy.current={id:Qt.id,draft:w},_s(C=>!C||C.id!==Qt.id||j.id!==Qt.id||!j.draft?w:NX(C,j.draft,w)),xl("")},[Qt==null?void 0:Qt.id,EL]);const ay=m.useCallback((w=!1)=>{if(!yt||!Qt)return!1;if(!Se)return xl("Readonly workspace"),ye("Readonly workspace"),!1;xl("");const j=wC({nodes:b,edges:k,instances:Z.current,selectedNode:Qt,draft:yt,allowRename:w});return j!=null&&j.error?(xl(j.error),!1):(!(j!=null&&j.ok)||!j.changed||(Z.current=j.instances,ie(j.instances),g(j.nodes),x(j.edges),j.nextId!==Qt.id&&on(j.nextId),Yr(j.nextId)),!0)},[k,yt,b,Qt,x,g,Yr,Se]);m.useEffect(()=>{if(!Se||!yt||!Qt)return;const w=window.setTimeout(()=>{ay(!1)},350);return()=>window.clearTimeout(w)},[yt==null?void 0:yt.label,yt==null?void 0:yt.role,yt==null?void 0:yt.model,yt==null?void 0:yt.body,JSON.stringify((yt==null?void 0:yt.images)||[]),yt==null?void 0:yt.script,yt==null?void 0:yt.scriptRef,yt==null?void 0:yt.implementationRef,yt==null?void 0:yt.implementationMode,JSON.stringify((yt==null?void 0:yt.inputs)||[]),JSON.stringify((yt==null?void 0:yt.outputs)||[]),ay,Qt==null?void 0:Qt.id,Se]);const jj=m.useRef({refs:new Map,nodeDataById:new Map}),ly=m.useMemo(()=>{const w=jj.current;let j=w.refs.size!==b.length;const C=new Map;for(const M of b)C.set(M.id,M.data),(!w.refs.has(M.id)||w.refs.get(M.id)!==M.data)&&(j=!0);if(!j)return w.nodeDataById;const P=new Map(b.map(M=>[M.id,M.data]));return jj.current={refs:C,nodeDataById:P},P},[b]),IL=m.useMemo(()=>k.map(w=>{var Y,ce;const j=ly.get(w.source),C=ly.get(w.target),P=/^output-(\d+)$/.exec(w.sourceHandle||""),M=/^input-(\d+)$/.exec(w.targetHandle||""),q=j&&P?(Y=j.outputs)==null?void 0:Y[parseInt(P[1],10)]:null,Q=C&&M?(ce=C.inputs)==null?void 0:ce[parseInt(M[1],10)]:null,J=q!=null&&q.type?zn(q.type):Q!=null&&Q.type?zn(Q.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:Ei.ArrowClosed,color:J}}:w}),[ly,k]),ep=ft?Pu:ds,PL=ft?[]:IL,Nj=m.useRef(ep),Ll=m.useRef([]);ae.current||(Nj.current=ep);const TL=m.useMemo(()=>ft?Pu.map(w=>({...w,id:Zp(w.id)})):ds,[Pu,ds,ft]),cy=m.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const C=ft?nC(j):j;ft?V([j]):(g(M=>M.map(q=>({...q,selected:q.id===C}))),x(M=>M.map(q=>({...q,selected:!1}))),on(C));const P=()=>{var ce,me,pe;const M=r.getNode(C);if(!M)return;const q=(ce=r.getInternalNode)==null?void 0:ce.call(r,C),Q=((me=q==null?void 0:q.measured)==null?void 0:me.width)??(q==null?void 0:q.width)??M.width??260,J=((pe=q==null?void 0:q.measured)==null?void 0:pe.height)??(q==null?void 0:q.height)??M.height??120,{zoom:Y}=r.getViewport();r.setCenter(M.position.x+Q/2,M.position.y+J/2,{zoom:$J(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(P))},[ft,r,x,g]);m.useEffect(()=>{const w=String(c.current||"").trim();!w||!de.current||p!=="workspace"||ds.some(j=>j.id===w)&&(c.current="",_t.current=!0,cy(w))},[ds,cy,p]);const _j=m.useCallback(()=>{const w=r.getViewport(),j={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(ft){const C={...z.current,viewport:j};z.current=C,T(C),ye("已固定 Display 进入视角")}else{D.current=j,O(j);try{window.localStorage.setItem(u,JSON.stringify(j))}catch{}ye("已固定 Workspace 进入视角");return}an(_.current,S.current).catch(C=>ye(String(C.message||C)))},[ft,r,an,u]),uy=m.useMemo(()=>{const w=Ce.trim().toLowerCase(),j={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const C of wt)w&&![C.id,C.label,C.displayName,C.description].some(P=>String(P||"").toLowerCase().includes(w))||j[ad(C)].push(C);for(const C of Ql)j[C].sort((P,M)=>P.id.localeCompare(M.id));return j},[wt,Ce]),Tu=m.useMemo(()=>{const w=In.trim().toLowerCase();return wt.filter(j=>!w||[j.id,j.label,j.displayName,j.description].some(C=>String(C||"").toLowerCase().includes(w))).sort((j,C)=>{const P=Ql.indexOf(ad(j)),M=Ql.indexOf(ad(C));return P!==M?P-M:ld(j).localeCompare(ld(C))}).slice(0,30)},[wt,In]),Ru=m.useMemo(()=>{const w=In.trim().toLowerCase();return St.filter(j=>!w||[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].some(C=>String(C||"").toLowerCase().includes(w))).sort((j,C)=>String(j.displayName||j.name||j.id).localeCompare(String(C.displayName||C.name||C.id))).slice(0,30)},[St,In]);m.useEffect(()=>{mr(0)},[In,we,Ae]),m.useEffect(()=>{if(!we)return;const w=window.setTimeout(()=>{var j;return(j=PS.current)==null?void 0:j.focus()},0);return()=>window.clearTimeout(w)},[we]);const RL=m.useMemo(()=>{const w=Og.trim().toLowerCase();return w?Ov(bl).filter(j=>j.path.toLowerCase().includes(w)):bl},[Og,bl]),Aa=m.useMemo(()=>TM(bl,Dg),[bl,Dg]),Ui=(Aa==null?void 0:Aa.type)==="directory"?Aa.path:lX((Aa==null?void 0:Aa.path)||""),ML=m.useCallback(w=>{var j,C;(C=(j=w.target)==null?void 0:j.closest)!=null&&C.call(j,".af-work-file")||Fg("")},[]),$L=[...(va.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(va.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(va.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(va.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],dy=m.useMemo(()=>new Set(qs),[qs]),Ol=m.useMemo(()=>{const w=new Map(Ks.map(q=>[q.key,q])),j=new Set,C=new Set,P=jl.map(q=>{const Q=ca(q,Ks).map(J=>w.get(J)).filter(Boolean);for(const J of Q)j.add(J.key),C.add(String(J.name||J.id||J.key||"").trim());return{...q,skills:Q}}).filter(q=>q.skills.length>0),M=Ks.filter(q=>{const Q=String(q.name||q.id||q.key||"").trim();return!j.has(q.key)&&!C.has(Q)});return{groups:P,ungrouped:M}},[jl,Ks]);m.useEffect(()=>{ES(w=>{let j=!1;const C=new Set(w);for(const P of Ol.groups)C.has(P.id)||(C.add(P.id),j=!0);return j?C:w})},[Ol.groups]);const cr=m.useMemo(()=>{const w=b.filter(j=>j.selected);return w.length>0?w:Nr?b.filter(j=>j.id===Nr):[]},[b,Nr]),tp=m.useMemo(()=>cr.map(w=>w.id),[cr]),Cj=m.useCallback(()=>{if(ft)return;if(!Se){ye("Readonly workspace");return}const w=(_.current||[]).filter(J=>(J==null?void 0:J.selected)&&!Im(J));if(w.length<2){ye("选择至少两个节点后按 G 创建 Group");return}const j=w.reduce((J,Y)=>{var Ke,We,qe,Be,Le,Gt,at,Xe,De,Ht,Fe,pt;const ce=Number(((Ke=Y.position)==null?void 0:Ke.x)||0),me=Number(((We=Y.position)==null?void 0:We.y)||0),pe=Number(((qe=Y.measured)==null?void 0:qe.width)||Y.width||((Le=(Be=Y.data)==null?void 0:Be.nodeSize)==null?void 0:Le.width)||((at=(Gt=Y.data)==null?void 0:Gt.displaySize)==null?void 0:at.width)||aM),je=Number(((Xe=Y.measured)==null?void 0:Xe.height)||Y.height||((Ht=(De=Y.data)==null?void 0:De.nodeSize)==null?void 0:Ht.height)||((pt=(Fe=Y.data)==null?void 0:Fe.displaySize)==null?void 0:pt.height)||jm);return{minX:Math.min(J.minX,ce),minY:Math.min(J.minY,me),maxX:Math.max(J.maxX,ce+pe),maxY:Math.max(J.maxY,me+je)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(j.minX)||!Number.isFinite(j.minY))return;const C=new Set((_.current||[]).map(J=>J.id));let P=1,M=`group_${P}`;for(;C.has(M);)P+=1,M=`group_${P}`;const q=Pb({width:j.maxX-j.minX+Jp*2,height:j.maxY-j.minY+Jp*2})||{width:ul,height:dl},Q={id:M,type:Ec,position:{x:j.minX-Jp,y:j.minY-Jp},width:q.width,height:q.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:Pm(P-1),title:Pm(P-1),color:"purple",nodeSize:q}};g(J=>[Q,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),on(""),ye(`Created group for ${w.length} nodes`)},[ft,x,g,Se]),Mu=m.useMemo(()=>b.filter(w=>Dn(w==null?void 0:w.data)),[b]),fy=m.useMemo(()=>cr.filter(w=>Dn(w==null?void 0:w.data)).map(w=>w.id),[cr]),LL=m.useMemo(()=>{const w=String((Fr==null?void 0:Fr.username)||(Fr==null?void 0:Fr.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Fr]),py=m.useMemo(()=>new Set(tp),[tp]),np=m.useMemo(()=>k.filter(w=>py.has(w.source)&&py.has(w.target)),[k,py]),hy=m.useCallback(w=>{const j=w==="display"?"display":w==="workflow"?"workflow":"workspace";f(j),on(""),V([]),ne(null),$e(!1),Nn(!1);const C=Br(a);j==="display"&&C.set("view","display"),j==="workflow"&&(C.set("view","workflow"),Xn.trim()&&C.set("tapdId",Xn.trim()));const P=`/workspace${C.toString()?`?${C.toString()}`:""}`;window.history.pushState({},"",P)},[a,Xn]),Aj=m.useCallback(w=>{const j=String(w||"").trim();if(!j)return;const C=_.current.find(P=>P.id===j);if(!C||!Dn(C.data)){ye("展示节点不可用");return}T(P=>{if(P.nodeIds.includes(j))return P;const M=P.nodeIds.length,q=ec(C);return{nodeIds:[...P.nodeIds,j],nodePositions:{...P.nodePositions,[j]:{x:180+M*36,y:120+M*28}},nodeSizes:{...P.nodeSizes,...q?{[j]:q}:{}}}}),V([j])},[]),Ej=m.useCallback(w=>{const j=String(w||"").trim();j&&(T(C=>{const P=C.nodeIds.filter(Q=>Q!==j),M={...C.nodePositions},q={...C.nodeSizes};return delete M[j],delete q[j],{nodeIds:P,nodePositions:M,nodeSizes:q}}),V(C=>C.filter(P=>P!==j)))},[]),Ij=m.useCallback(w=>{const j=String(w||"").trim();j&&(z.current.nodeIds.includes(j)?Ej(j):Aj(j))},[Aj,Ej]),rp=m.useMemo(()=>{const w=Jn.trim().toLowerCase();return w?$l.filter(j=>{var C,P;return[j.id,(C=j.data)==null?void 0:C.label,(P=j.data)==null?void 0:P.definitionId].filter(Boolean).some(M=>String(M).toLowerCase().includes(w))}):$l},[$l,Jn]),Pj=m.useMemo(()=>{const w=rp.length,j=w<=1?1:w<=4?2:3,C=Array.from({length:j},()=>({height:0,nodes:[]}));for(const P of rp){const M=ec(P)||{width:420,height:260},q=Math.max(1,Number(M.width)||420),Q=Math.max(1,Number(M.height)||260),J=Math.min(26,Math.max(5.5,Q/q*16))+3.2;let Y=C[0];for(const ce of C)ce.height<Y.height&&(Y=ce);Y.nodes.push(P),Y.height+=J}return C.map(P=>P.nodes)},[rp]),OL=m.useCallback(w=>{var q;const j=I.nodeIds.includes(w.id),C=ec(w)||{width:420,height:260},P=Math.max(1,Math.round(Number(C.width)||420)),M=Math.max(1,Math.round(Number(C.height)||260));return s.jsxs("button",{type:"button",className:"af-display-picker-card"+(j?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${P} / ${M}`},onClick:()=>Ij(w.id),children:[s.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:s.jsx("input",{type:"checkbox",checked:j,readOnly:!0,tabIndex:-1})}),s.jsx("span",{className:"af-display-picker-card__preview",children:s.jsx(JJ,{node:w})}),s.jsxs("span",{className:"af-display-picker-card__meta",children:[s.jsx("strong",{children:((q=w.data)==null?void 0:q.label)||w.id}),s.jsxs("small",{children:[Dn(w.data)," · ",w.id]})]})]},w.id)},[I.nodeIds,Ij]),Tj=m.useMemo(()=>{const w=Ce.trim().toLowerCase();return w?St.filter(j=>[j.id,j.version,j.displayName,j.name,j.description,...Array.isArray(j.tags)?j.tags:[]].filter(Boolean).some(C=>String(C).toLowerCase().includes(w))):St},[St,Ce]),Rj=m.useCallback((w,j)=>{const C=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let P=`${C}_${Date.now().toString(36)}`,M=2;for(;j.has(P);)P=`${C}_${Date.now().toString(36)}_${M}`,M+=1;return j.add(P),P},[]),$u=m.useCallback((w,j)=>{var De,Ht;if(!Se){ye("Readonly workspace");return}const C=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},P=C.instances&&typeof C.instances=="object"?C.instances:{},M=Object.keys(P);if(M.length===0)return;const q=new Set(_.current.map(Fe=>Fe.id)),Q={};for(const Fe of M)Q[Fe]=Rj(Fe,q);const J=(De=C.ui)!=null&&De.nodePositions&&typeof C.ui.nodePositions=="object"?C.ui.nodePositions:{},Y=(Ht=C.ui)!=null&&Ht.nodeSizes&&typeof C.ui.nodeSizes=="object"?C.ui.nodeSizes:{},ce=M.map(Fe=>{const pt=J[Fe];return{id:Fe,x:typeof(pt==null?void 0:pt.x)=="number"?pt.x:0,y:typeof(pt==null?void 0:pt.y)=="number"?pt.y:0}}),me=Math.min(...ce.map(Fe=>Fe.x)),pe=Math.min(...ce.map(Fe=>Fe.y));let je=j||{x:360+_.current.length*24,y:180+_.current.length*18};if(!j){const Fe=document.querySelector(".af-workspace-canvas .react-flow");if(Fe){const pt=Fe.getBoundingClientRect();je=r.screenToFlowPosition({x:pt.left+pt.width*.48,y:pt.top+pt.height*.32})}}const Ke={},We={},qe={};for(const Fe of ce){const pt=Q[Fe.id];Ke[pt]={...P[Fe.id]||{}},We[pt]={x:je.x+(Fe.x-me),y:je.y+(Fe.y-pe)};const Mt=Y[Fe.id];typeof(Mt==null?void 0:Mt.width)=="number"&&typeof(Mt==null?void 0:Mt.height)=="number"&&(qe[pt]={width:Mt.width,height:Mt.height})}const Be=new Set(M),Le=(Array.isArray(C.edges)?C.edges:[]).filter(Fe=>Be.has(Fe==null?void 0:Fe.source)&&Be.has(Fe==null?void 0:Fe.target)).map(Fe=>({source:Q[Fe.source],target:Q[Fe.target],sourceHandle:Fe.sourceHandle??null,targetHandle:Fe.targetHandle??null})),Gt=Yu({instances:Ke,edges:Le,ui:{nodePositions:We,nodeSizes:qe}},wt),at=Gt.nodes.map(Fe=>Fe.id),Xe=Gt.nodes.map(Fe=>({...Fe,selected:!0}));Z.current={...Z.current,...Gt.instances},ie(Z.current),g(Fe=>[...Fe.map(pt=>({...pt,selected:!1})),...Xe]),x(Fe=>[...Fe.map(pt=>({...pt,selected:!1})),...Gt.edges.map(pt=>({...pt,selected:!1}))]),on(""),V([]),ye(`已添加流程片段:${w.displayName||w.id}(已选中 ${at.length} 个节点)`)},[Rj,wt,r,x,g,Se]),DL=m.useCallback(()=>{var C,P;if(cr.length<2){vn("请先在 workspace 画布上选择至少两个节点。"),Nt("flows");return}const w=cr[0],j=cr.length===2?`${((C=w.data)==null?void 0:C.label)||w.id} 片段`:`${((P=w.data)==null?void 0:P.label)||w.id} 等 ${cr.length} 个节点`;Sn({name:j,id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Hn(""),ar(!0),Nt("flows")},[cr]),FL=m.useCallback(async()=>{var M,q;if(cr.length<2)return;const w=fn.name.trim();if(!w){Hn("请填写片段名称。");return}const j={},C={};for(const Q of cr){j[Q.id]={x:((M=Q.position)==null?void 0:M.x)||0,y:((q=Q.position)==null?void 0:q.y)||0};const J=ec(Q);J&&(C[Q.id]=J)}const P=np.map(Q=>({source:Q.source,target:Q.target,sourceHandle:Q.sourceHandle??null,targetHandle:Q.targetHandle??null}));Gr(!0),Hn("");try{const Q=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:fn.id,name:w,displayName:w,version:"1.0.0",description:fn.description,snippet:{instances:Cv(cr,Z.current),edges:P,ui:{nodePositions:j,nodeSizes:C}}})}),J=await Q.json().catch(()=>({}));if(!Q.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");ar(!1),ye(`流程片段已发布:${J.id||w}`),CS(`流程片段已发布:${J.id||w}`),await qf(),Nt("flows")}catch(Q){Hn(String(Q.message||Q))}finally{Gr(!1)}},[qf,fn,np,cr,CS]),Mj=m.useCallback(async()=>{var j;const w=uu.trim();if(w){nS(!0),jo("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),P=await C.json().catch(()=>({}));if(!C.ok)throw new Error(P.error||"添加协作成员失败");Wf(P.workspace||null),sS(""),ye(`已将 Workspace 分享给 ${((j=P.member)==null?void 0:j.username)||w}`)}catch(C){jo(String(C.message||C))}finally{nS(!1)}}},[a,uu]),zL=m.useCallback(()=>{jo(""),Rg(!0),fetch("/api/teams/me").then(w=>w.json().then(j=>({response:w,payload:j}))).then(({response:w,payload:j})=>{var M;if(!w.ok)throw new Error(j.error||"读取团队失败");const C=j.team||null;U$(C);const P=(M=Ft==null?void 0:Ft.teamShares)==null?void 0:M.find(q=>q.teamId===(C==null?void 0:C.id));aS((P==null?void 0:P.role)==="editor"?"editor":"viewer")}).catch(w=>jo(String(w.message||w)))},[Ft==null?void 0:Ft.teamShares]),my=m.useCallback(async(w=!1)=>{if(Vs!=null&&Vs.id){lS(!0),jo("");try{const j=await fetch("/api/workspace/collaboration/team-share",{method:w?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,teamId:Vs.id,role:$g})}),C=await j.json().catch(()=>({}));if(!j.ok)throw new Error(C.error||(w?"取消团队分享失败":"分享到团队失败"));Wf(C.workspace||null),ye(w?`已取消对「${Vs.name}」的分享`:`已分享到「${Vs.name}」`)}catch(j){jo(String(j.message||j))}finally{lS(!1)}}},[a,Vs,$g]),WL=m.useCallback(async w=>{const j=String((w==null?void 0:w.userId)||"").trim();if(!(!j||j===(Ft==null?void 0:Ft.ownerId))){oS(j),jo("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:j})}),P=await C.json().catch(()=>({}));if(!C.ok)throw new Error(P.error||"取消成员分享失败");Wf(P.workspace||null),ye(`已取消对 ${(w==null?void 0:w.username)||j} 的分享`)}catch(C){jo(String(C.message||C))}finally{oS("")}}},[a,Ft==null?void 0:Ft.ownerId]),$j=m.useCallback(async()=>{const w=Yl(_.current,S.current,Z.current);w.ui={...w.ui||{},...D.current?{viewport:D.current}:{},displayPage:rC(z.current,_.current)};const j=new Blob([`${JSON.stringify(w,null,2)}
|
|
264
|
+
`],{type:"application/json"}),C=URL.createObjectURL(j),P=document.createElement("a");P.href=C,P.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(C),await Es(),kl(null),ka(!1),ye("已备份本地草稿并载入远端最新版本")},[S,a.flowId,Es,_]),BL=m.useCallback(async()=>{const w=Array.isArray(Ln==null?void 0:Ln.conflictItems)?Ln.conflictItems:[];if(!w.length||!(Ln!=null&&Ln.mergeGraph)||!(Ln!=null&&Ln.currentGraph)){fu("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let j=Ln.mergeGraph;try{w.forEach((P,M)=>{const q=Lg[String(M)]||{mode:"local"};let Q,J=!0;q.mode==="remote"?(Q=P.current,J=P.hasCurrent!==!1):q.mode==="manual"?Q=JSON.parse(String(q.manual||"")):(Q=P.incoming,J=P.hasIncoming!==!1),j=RX(j,P.pathParts,Q,J)})}catch(P){fu(`手动值不是有效 JSON:${String(P.message||P)}`);return}cS(!0),fu(""),Gs("saving"),Ys("正在提交冲突解决结果");const C=_e.current.catch(()=>{}).then(async()=>{const P=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:j,baseRevision:Ln.currentRevision,baseGraph:Ln.currentGraph,clientId:Kt.current})}),M=await P.json().catch(()=>({}));if(!P.ok){if(P.status===409&&Array.isArray(M.conflictItems)){const q=M.conflictItems;kl({currentRevision:String(M.currentRevision||""),message:M.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(M.conflictPaths)?M.conflictPaths:[],conflictItems:q,mergeGraph:M.mergeGraph||null,currentGraph:M.currentGraph||null}),vl(Object.fromEntries(q.map((Q,J)=>[String(J),{mode:"local",manual:Ju(Q)}])))}throw new Error(M.error||"提交冲突解决结果失败")}await Es(),kl(null),ka(!1),ye("冲突已解决并保存")});_e.current=C;try{await C}catch(P){fu(String(P.message||P)),Gs("error"),Ys(String(P.message||P))}finally{cS(!1)}},[a,Es,Ln,Lg]);m.useCallback(()=>{if(Mu.length===0){ye("当前 workspace 没有 display 节点");return}const w=fy.length>0?fy:Mu.map(C=>C.id),j=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";Tt(Aw({title:j,layout:"gallery",nodeIds:w,mode:"multi-node"})),le(""),Je(null),hr(!0)},[a.flowId,fy,Mu]);const HL=m.useCallback(w=>{Tt(j=>{const C=Array.isArray(j.nodeIds)?j.nodeIds:[];return C.includes(w)?{...j,nodeIds:C.filter(P=>P!==w)}:{...j,nodeIds:[...C,w]}})},[]),Xs=m.useCallback(async()=>{Bs(!0),oe("");try{const w=await fetch("/api/display/shares"),j=await w.json().catch(()=>({}));if(!w.ok)throw new Error(j.error||"读取分享列表失败");Mn(Array.isArray(j.shares)?j.shares:[])}catch(w){oe(String(w.message||w)),Mn([])}finally{Bs(!1)}},[]),VL=m.useCallback(()=>{jn(!0),Dt(""),Xs()},[Xs]),KL=m.useCallback(async()=>{var C,P;const w=st.title.trim(),j=Array.isArray(st.nodeIds)?st.nodeIds:[];if(j.length===0){le("请选择至少一个 display 节点。");return}lr(!0),le(""),Je(null);try{await an(b,k);const M=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:st.layout,nodeIds:j,...iC(st)})}),q=await M.json().catch(()=>({}));if(!M.ok||q.ok===!1)throw new Error(q.error||"发布展示页失败");const Q=new URL(q.url||`/display/${((C=q.share)==null?void 0:C.id)||""}`,window.location.origin).href;Je({...q,absoluteUrl:Q}),ye((P=q.share)!=null&&P.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Pt&&Xs()}catch(M){le(String(M.message||M))}finally{lr(!1)}},[st,Pt,k,a,Xs,b,an]),qL=m.useCallback(async()=>{var j,C;const w=Array.isArray(I.nodeIds)?I.nodeIds:[];if(w.length===0){le("请先添加至少一个展示节点。"),ye("请先添加至少一个展示节点"),Nn(!0);return}lr(!0),le("");try{await an(b,k);const P=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",M=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:P,layout:"canvas",nodeIds:w,...iC(st)})}),q=await M.json().catch(()=>({}));if(!M.ok||q.ok===!1)throw new Error(q.error||"生成展示链接失败");const Q=new URL(q.url||`/display/${((j=q.share)==null?void 0:j.id)||""}`,window.location.origin).href;Je({...q,absoluteUrl:Q}),gt(!0),ye((C=q.share)!=null&&C.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Pt&&Xs()}catch(P){const M=String(P.message||P);le(M),ye(M)}finally{lr(!1)}},[I.nodeIds,st,Pt,k,a,Xs,b,an]),Lj=m.useCallback(async()=>{const w=he==null?void 0:he.absoluteUrl;if(!w)return;const j=await Rb(w);Rt(j?"copied":"failed"),window.setTimeout(()=>Rt(""),1600)},[he==null?void 0:he.absoluteUrl]),UL=m.useCallback(async w=>{const j=oC(w),C=await Rb(j);Dt(C?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>Dt(""),1600)},[]),GL=m.useCallback(async(w,j)=>{const C=String((w==null?void 0:w.id)||"");if(C){Me(C),oe("");try{const P=j==="permanent"?{id:C,expiresMode:"permanent",permanent:!0}:{id:C,expiresMode:"days",expiresInDays:Number(j||30)},M=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),q=await M.json().catch(()=>({}));if(!M.ok||q.ok===!1)throw new Error(q.error||"更新分享有效期失败");await Xs(),ye("分享有效期已更新")}catch(P){oe(String(P.message||P))}finally{Me("")}}},[Xs]),YL=m.useCallback(async w=>{const j=String((w==null?void 0:w.id)||"");if(j){Me(j),oe("");try{const C=await fetch(`/api/display/share?id=${encodeURIComponent(j)}`,{method:"DELETE"}),P=await C.json().catch(()=>({}));if(!C.ok||P.ok===!1)throw new Error(P.error||"撤销分享失败");await Xs(),ye("分享已撤销")}catch(C){oe(String(C.message||C))}finally{Me("")}}},[Xs]),JL=m.useCallback(w=>{g(j=>j.map(C=>C.id===w?{...C,selected:!1}:C)),on(j=>j===w?"":j)},[g]),Dl=m.useCallback(()=>{const w=Gg.current;if(!w)return;const j=w.getBoundingClientRect(),C=Math.min(420,Math.max(320,j.width+160)),P=12,M=Math.max(180,j.top-P*2),q=Math.min(560,M);pL({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-C-12,j.left)),top:Math.max(P,j.top-q-P),width:C,maxHeight:q,zIndex:1e4})},[]);m.useEffect(()=>{if(!Hf)return;Dl();const w=C=>{var M,q;const P=C.target;(M=Gg.current)!=null&&M.contains(P)||(q=IS.current)!=null&&q.contains(P)||Ug(!1)},j=C=>{C.key==="Escape"&&Ug(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",j),window.addEventListener("resize",Dl),window.addEventListener("scroll",Dl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",j),window.removeEventListener("resize",Dl),window.removeEventListener("scroll",Dl,!0)}},[Hf,Dl]);const sp=m.useCallback(w=>{const j=oM(w);if(j.active&&(ae.current=!0),j.finished&&(ae.current=!1,it.current=!0),rY(w)&&yi(),p==="display"){T(M=>{var Y,ce;let q=M.nodePositions,Q=M.nodeSizes;for(const me of w||[]){const pe=Zp(me==null?void 0:me.id);if(!(!pe||!M.nodeIds.includes(pe))&&me.type!=="select"){if(me.type==="position"&&me.position){const je=q[pe];if((je==null?void 0:je.x)===me.position.x&&(je==null?void 0:je.y)===me.position.y)continue;q===M.nodePositions&&(q={...M.nodePositions}),q[pe]={x:me.position.x,y:me.position.y};continue}if(me.type==="dimensions"&&((Y=me.dimensions)!=null&&Y.width)&&((ce=me.dimensions)!=null&&ce.height)){const je=Qa({width:Math.round(Number(me.dimensions.width)),height:Math.round(Number(me.dimensions.height))},{display:!0});if(je){const Ke=Q[pe];if((Ke==null?void 0:Ke.width)===je.width&&(Ke==null?void 0:Ke.height)===je.height)continue;Q===M.nodeSizes&&(Q={...M.nodeSizes}),Q[pe]=je}}}}if(q===M.nodePositions&&Q===M.nodeSizes)return M;const J={...M,nodePositions:q,nodeSizes:Q};return z.current=J,J});const P=(w||[]).filter(M=>(M==null?void 0:M.type)==="select");P.length>0&&V(M=>{const q=new Set(M);for(const J of P){const Y=Zp(J==null?void 0:J.id);Y&&(J.selected?q.add(Y):q.delete(Y))}const Q=Array.from(q);return Q.length===M.length&&Q.every((J,Y)=>J===M[Y])?M:Q});return}if(!Se){const P=(w||[]).filter(M=>(M==null?void 0:M.type)==="select");P.length>0&&g(M=>Nd(P,M));return}const C=(w||[]).filter(P=>{var M,q;return(P==null?void 0:P.type)==="dimensions"&&((M=P.dimensions)==null?void 0:M.width)&&((q=P.dimensions)==null?void 0:q.height)});g(P=>{const M=new Map;if(C.length>0){const J=new Map(P.map(Y=>[Y.id,Y]));for(const Y of C){const ce=J.get(Y.id),me={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},pe=Im(ce)?Pb(me):Qa(me,{display:!!Dn(ce==null?void 0:ce.data)});pe&&M.set(Y.id,pe)}}const q=Nd(w,P),Q=M.size===0?q:q.map(J=>{const Y=M.get(J.id);if(!Y)return J;const ce={...J.data,nodeSize:Y};return Dn(J.data)&&(ce.displaySize=Y),{...J,width:Y.width,height:Y.height,data:ce}});return j.mutated||(Xt.current={nodes:Q,edges:S.current,displayPage:z.current}),_.current=Q,Q}),C.length>0&&Yr(C.map(P=>P.id))},[yi,Yr,g,p,Se]),ip=m.useCallback((w=[],{finish:j=!1}={})=>{const C=j?aY([...K.current,...w]):Nb(w);j&&(K.current=[]),C.length>0&&sp(C)},[sp]),XL=m.useCallback(w=>{const{transient:j,committed:C,finishesInteraction:P}=oY(w);if(j.length>0){fe.current&&(window.clearTimeout(fe.current),fe.current=null),ae.current||(ae.current=!0,Ll.current=Nj.current),K.current=Nb([...K.current,...j]);const M=Nd(j,Ll.current);Ll.current=M,i.getState().setNodes(M)}if(P){Ll.current=[],ip(C,{finish:!0});return}C.length>0&&sp(C)},[sp,ip,i]),Fl=m.useCallback(()=>{ke.current.size>0||Ue.current||((ae.current||K.current.length>0)&&(ip([],{finish:!0}),Ll.current=[]),kt.current&&Rl({type:"interaction.finished"}))},[ip,Rl]),QL=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.add(w.pointerId)},[]),_o=m.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.delete(w.pointerId),window.queueMicrotask(Fl)},[Fl]),ZL=m.useCallback(()=>{Ue.current=!0},[]),e2=m.useCallback(()=>{Ue.current=!1,window.queueMicrotask(Fl)},[Fl]);m.useEffect(()=>{const w=()=>{ke.current.clear(),Ue.current=!1,Fl()},j=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",_o,!0),window.addEventListener("pointercancel",_o,!0),window.addEventListener("lostpointercapture",_o,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("pointerup",_o,!0),window.removeEventListener("pointercancel",_o,!0),window.removeEventListener("lostpointercapture",_o,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",j),ke.current.clear(),Ue.current=!1,K.current=[],Ll.current=[]}},[_o,Fl]);const t2=m.useCallback(w=>{if(p!=="display"){if(!Se){const j=(w||[]).filter(C=>(C==null?void 0:C.type)==="select");j.length>0&&x(C=>{const P=mm(j,C);return S.current=P,P});return}(w||[]).some(j=>(j==null?void 0:j.type)!=="select")&&yi(),x(j=>{const C=mm(w,j);return S.current=C,C})}},[yi,x,p,Se]),zl=m.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const j=w.getBoundingClientRect();return r.screenToFlowPosition({x:j.left+j.width*.48,y:j.top+j.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),op=m.useCallback(()=>{var w,j,C;if(Qt){const P=Number(((w=Qt.measured)==null?void 0:w.width)||Qt.width||260);return{x:Number(((j=Qt.position)==null?void 0:j.x)||0)+P+140,y:Number(((C=Qt.position)==null?void 0:C.y)||0)}}return zl()},[zl,Qt]),Gi=m.useCallback((w,j={})=>{if(!Se)return ye("Readonly workspace"),null;if(!w)return null;const C=Mv(w)||w.id,P=yM(w),M=xM(w),q=j.id||wJ(C,b),Q=ud(w.inputs),J=ud(w.outputs),Y={definitionId:C,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:j.label||Em(w),role:"normal",body:j.body||"",...j.script||M?{script:j.script||M}:{},...j.scriptRef?{scriptRef:j.scriptRef}:{},...j.implementationRef?{implementationRef:j.implementationRef}:{},...j.implementationMode?{implementationMode:j.implementationMode}:{},input:j.inputs||Q,output:j.outputs||J},ce={id:q,type:Ec,position:j.position||zl(),data:{label:Y.label,definitionId:C,...P?{marketplaceRef:P}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:gM(C,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}},me={...Sb(ce,{...Z.current,[q]:Y},wt),selected:!0};return yi(),g(pe=>[...pe.map(je=>({...je,selected:!1})),me]),j.openProperties&&on(q),q},[zl,yi,b,wt,g,Se]),n2=m.useCallback(w=>_w(w,_.current),[]),r2=m.useCallback(w=>{if(!Se){ye("Readonly workspace");return}if(!_w(w,_.current)){ye("端口类型不匹配,已取消连线");return}ne(null),yi(),g(j=>bw(j,w)),x(j=>{const C=j.filter(M=>!(M.target===w.target&&M.targetHandle===w.targetHandle)),P=Ch({...w,markerEnd:{type:Ei.ArrowClosed}},C);return S.current=P,P})},[yi,x,g,Se]),s2=m.useCallback((w,j)=>{if(!Se)return;const C=mJ(j,_.current);te.current=C?{...C,preferExisting:!!(w!=null&&w.shiftKey)}:null,ne(null)},[Se]),i2=m.useCallback((w,j)=>{var Be,Le,Gt,at;if(!Se)return;const C=te.current;if(te.current=null,!C||j!=null&&j.toNode)return;const P=gJ(wt,C),M=yJ(_.current,S.current,C);if(P.length===0&&M.length===0){ye(`没有匹配 ${C.slotType} 端口的节点`);return}const Q=!!(w!=null&&w.shiftKey||C.preferExisting)?M.length>0?"existing":"create":P.length>0?"create":"existing",J=((Le=(Be=w==null?void 0:w.changedTouches)==null?void 0:Be[0])==null?void 0:Le.clientX)??(w==null?void 0:w.clientX),Y=((at=(Gt=w==null?void 0:w.changedTouches)==null?void 0:Gt[0])==null?void 0:at.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const ce=document.querySelector(".af-workspace-canvas .react-flow");if(!ce)return;const me=ce.getBoundingClientRect(),pe=320,je=Math.max(P.length,M.length),Ke=Math.min(480,150+je*58),We=Math.max(12,Math.min(J-me.left,me.width-pe-12)),qe=Math.max(12,Math.min(Y-me.top,me.height-Ke-12));ne({left:We,top:qe,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:C,candidates:P,existingCandidates:M,mode:Q,query:""})},[wt,r,Se]),o2=m.useCallback(w=>{if(!Se){ye("Readonly workspace"),ne(null);return}const j=ee.current;if(!j||!(w!=null&&w.def))return;const C=Gi(w.def,{position:j.flowPosition});if(!C)return;const P=j.draft.handleType==="source"?{source:j.draft.nodeId,sourceHandle:j.draft.handleId,target:C,targetHandle:`input-${w.slotIndex}`}:{source:C,sourceHandle:`output-${w.slotIndex}`,target:j.draft.nodeId,targetHandle:j.draft.handleId};g(M=>bw(M,P)),x(M=>{const q=M.filter(J=>!(J.target===P.target&&J.targetHandle===P.targetHandle)),Q=Ch({...P,markerEnd:{type:Ei.ArrowClosed}},q);return S.current=Q,Q}),ne(null)},[Gi,x,Se]),a2=m.useCallback(w=>{if(!Se){ye("Readonly workspace"),ne(null);return}const j=w==null?void 0:w.connection;if(!j||!_w(j,_.current)){ye("端口类型不匹配,已取消连线"),ne(null);return}g(C=>bw(C,j)),x(C=>{const P=C.filter(q=>!(q.target===j.target&&q.targetHandle===j.targetHandle)),M=Ch({...j,markerEnd:{type:Ei.ArrowClosed}},P);return S.current=M,M}),ne(null)},[x,g,Se]),Oj=m.useCallback(w=>{w&&(Gi(w,{position:op()}),$e(!1),Wt(""))},[Gi,op]),Dj=m.useCallback(w=>{w&&($u(w,op()),$e(!1),Wt(""))},[$u,op]),l2=m.useCallback(w=>{var C,P,M;if(ft||Bt)return;const j=w==null?void 0:w.target;q_(j)||(C=j==null?void 0:j.closest)!=null&&C.call(j,"button, a, [role='button'], .react-flow__handle")||(M=(P=N.current)==null?void 0:P.focus)==null||M.call(P,{preventScroll:!0})},[ft,Bt]);m.useEffect(()=>{const w=j=>{var ce;if(j.defaultPrevented)return;const C=nG(j.target)||q_(j.target);if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="s"){j.preventDefault(),an().catch(me=>ye(String(me.message||me)));return}if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),j.stopPropagation(),OS(me=>!me);return}if(ty)return;if(ey){(j.key==="Escape"||__(j))&&(j.preventDefault(),Kf(!1));return}const P=j.key.toLowerCase(),M=(j.metaKey||j.ctrlKey)&&P==="c",q=(j.metaKey||j.ctrlKey)&&P==="v",Q=C&&M&&PY(j.target);if(C&&!Q)return;const J=(j.metaKey||j.ctrlKey)&&!j.shiftKey&&P==="z",Y=(j.metaKey||j.ctrlKey)&&(j.shiftKey&&P==="z"||P==="y");if(J||Y){if(ft){j.preventDefault(),j.stopPropagation(),ye("展示页布局会自动保存");return}if(!Se){j.preventDefault(),ye("Readonly workspace");return}j.preventDefault(),j.stopPropagation();const me=J?QS():ZS();ye(me?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(M){if(ft)return;const me=Qv.current,pe=(_.current||[]).some(Ke=>Ke==null?void 0:Ke.selected)?_.current:(_.current||[]).map(Ke=>me&&Ke.id===me?{...Ke,selected:!0}:Ke),je=NU(pe,S.current,Z.current);je&&(j.preventDefault(),j.stopPropagation(),W.current=je,RJ(je),Q&&typeof((ce=j.target)==null?void 0:ce.blur)=="function"&&j.target.blur(),ye(`Copied ${je.nodes.length} node${je.nodes.length>1?"s":""}`));return}if(q){if(ft){j.preventDefault(),j.stopPropagation();return}if(!Se){j.preventDefault(),ye("Readonly workspace");return}const me=W.current||MJ();me&&!W.current&&(W.current=me);const pe=_U(me,_.current,S.current,Z.current);pe&&(j.preventDefault(),j.stopPropagation(),Z.current=pe.instances,ie(pe.instances),g(pe.nodes),x(pe.edges),ye(`Pasted ${pe.pastedNodeIds.length} node${pe.pastedNodeIds.length>1?"s":""}`));return}if(__(j)&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Kf(!0);return}if(P==="g"&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),Cj();return}if(j.key==="a"||j.key==="A"){if(j.metaKey||j.ctrlKey){j.preventDefault(),ft?V(z.current.nodeIds):(g(me=>me.map(pe=>({...pe,selected:!0}))),x(me=>me.map(pe=>({...pe,selected:!1}))));return}if(j.altKey)return;if(ft){j.preventDefault(),Nn(!0);return}if(!Se){j.preventDefault(),ye("Readonly workspace");return}j.preventDefault(),$e(!0);return}if((j.key==="v"||j.key==="V")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),DS("select");return}if((j.key==="h"||j.key==="H")&&!j.metaKey&&!j.ctrlKey&&!j.altKey){j.preventDefault(),DS("pan");return}(j.key==="f"||j.key==="F")&&!j.metaKey&&!j.ctrlKey&&!j.altKey&&(j.preventDefault(),_j())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[Cj,ft,ty,_j,ZS,an,ey,x,g,QS,Se]);const c2=m.useCallback(w=>{Sl(j=>{const C=new Set(j);return C.has(w)?C.delete(w):C.add(w),C})},[]),u2=m.useCallback((w,j)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:j.path,name:j.name,type:j.type})),w.dataTransfer.setData("text/plain",j.path)},[]),d2=m.useCallback((w,j)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",j.id),w.dataTransfer.setData("text/plain",j.id)},[]),ap=m.useCallback(async(w,j)=>{const C=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),P=C.split(".").pop(),M=["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(C)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(P)?"display_image":"display_markdown",q=wt.find(pe=>pe.id===M);if(!q){ye("展示节点不可用");return}const Q=M==="display_image";let J=String(w.path||"");if(!Q){const pe=Br(a);pe.set("path",w.path);const je=await fetch(`/api/workspace/file?${pe.toString()}`),Ke=await je.json();if(!je.ok)throw new Error(Ke.error||"读取文件失败");J=String(Ke.content||"")}const Y=M==="display_image"?"src":"content",ce=ud(q.inputs).map(pe=>pe.name===Y?{...pe,default:J,value:J}:pe),me=ud(q.outputs).map(pe=>pe.name===Y?{...pe,default:J,value:J}:pe);Gi(q,{label:w.name||"Display",body:J,inputs:ce,outputs:me,position:j}),ye(`已创建展示:${w.path}`)},[Gi,a,wt]),f2=m.useCallback(w=>{if(!Se){ye("Readonly workspace");return}ap(w,zl()).catch(j=>ye(String(j.message||j)))},[ap,zl,Se]),p2=m.useCallback(w=>{if(!Se){w.preventDefault(),ye("Readonly workspace");return}const j=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(j){w.preventDefault();let Q;try{Q=JSON.parse(j)}catch{return}if(!(Q!=null&&Q.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});ap(Q,J).catch(Y=>ye(String(Y.message||Y)));return}const C=w.dataTransfer.getData("application/agentflow-snippet");if(C){const Q=St.find(Y=>`${Y.id}@${Y.version}`===C);if(!Q)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});$u(Q,J);return}const P=w.dataTransfer.getData("application/agentflow-node");if(!P)return;const M=wt.find(Q=>Q.id===P);if(!M)return;w.preventDefault();const q=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Gi(M,{position:q})},[ap,Gi,St,$u,wt,r,Se]),h2=m.useCallback(w=>{if(!Se)return;const j=Array.from(w.dataTransfer.types||[]);!j.includes("application/x-agentflow-workspace-file")&&!j.includes("application/agentflow-node")&&!j.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=j.includes("application/agentflow-node")||j.includes("application/agentflow-snippet")?"move":"copy")},[Se]),m2=m.useCallback(async(w="")=>{if(!Se){ye("Readonly workspace");return}const j=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!j)return;const C=w&&!j.includes("/")?`${w}/${j}`:j;try{const P=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C,content:""})}),M=await P.json();if(!P.ok)throw new Error(M.error||"创建文件失败");await On(),Sl(q=>{const Q=new Set(q);for(const J of eh(M.path||C))Q.delete(J);return Q}),ye(`已创建 ${M.path}`)}catch(P){ye(String(P.message||P))}},[a,On,Se]),g2=m.useCallback(async(w="")=>{if(!Se){ye("Readonly workspace");return}const j=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!j)return;const C=w&&!j.includes("/")?`${w}/${j}`:j;try{const P=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C})}),M=await P.json();if(!P.ok)throw new Error(M.error||"创建文件夹失败");await On(),Sl(q=>{const Q=new Set(q);for(const J of eh(M.path||C))Q.delete(J);return M.path&&Q.delete(M.path),Q}),ye(`已创建 ${M.path}`)}catch(P){ye(String(P.message||P))}},[a,On,Se]),y2=m.useCallback(async w=>{if(!Se){ye("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const j=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),C=await j.json();if(!j.ok)throw new Error(C.error||"删除失败");ye(`已删除 ${C.path}`),await On()}catch(j){ye(String(j.message||j))}},[a,On,Se]),w2=m.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const j=ff(w.path,a,{download:!0});if(!j)return;const C=document.createElement("a");C.href=j,C.download=w.name||w.path.split("/").pop()||"download",C.rel="noopener",document.body.appendChild(C),C.click(),C.remove()},[a]),lp=m.useCallback(async()=>{if(!Se){ye("Readonly workspace");return}const w=Sa.trim(),j=Jr,C=Us.find(Q=>Q.id===j)||null;if(!w||us||(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="stopping")return;const P=C?Array.isArray(C.messages)?C.messages:[]:ja,M=Yl(b,k,Z.current);Yg(""),TS(!0),Al(!0),El(null);const q={role:"user",text:w,at:Date.now()};C?nr(Q=>Q.map(J=>J.id===j?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],q].slice(-180)}:J)):(As("workspace"),Cl(Q=>[...Q,q]));try{await an(b,k);const Q=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,prompt:w,outputKind:"markdown",workspaceGraph:M,allowFlowYaml:!1,model:Vi,selectedSkills:qs,selectedNodeIds:tp,messages:P})}),J=await Q.json();if(!Q.ok)throw new Error(J.error||"生成失败");const ce={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};C?nr(me=>me.map(pe=>pe.id===j?{...pe,status:"done",messages:[...Array.isArray(pe.messages)?pe.messages:[],ce].slice(-180)}:pe)):Cl(me=>[...me,ce]),await Es(),ye("AI 生成完成")}catch(Q){const J=String(Q.message||Q),Y={role:"assistant",text:J,error:!0,at:Date.now()};C?nr(ce=>ce.map(me=>me.id===j?{...me,status:"failed",messages:[...Array.isArray(me.messages)?me.messages:[],Y].slice(-180)}:me)):Cl(ce=>[...ce,Y]),ye(J)}finally{TS(!1)}},[Jr,ja,Vi,Us,us,Sa,k,a,Es,b,an,tp,qs,Se]),gr=Us.find(w=>w.id===Jr)||null,gy=gr?Array.isArray(gr.messages)?gr.messages:[]:ja,Wl=gr&&(gr.status==="running"||gr.status==="stopping")||us,x2=mX(gy,Wl),yy=gX(gy),Fj=gr?gr.status==="stopping"?`${gr.label} stopping`:gr.status==="running"?`${gr.label} running`:gr.status==="paused"?`${gr.label} paused`:gr.status==="failed"?`${gr.label} failed`:`${gr.label} done`:us?"Workspace agent running":ja.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{Jr!=="workspace"&&(Us.some(w=>w.id===Jr)||As(Ca()))},[Jr,Us,Ca]),m.useEffect(()=>{if(!xu)return;const w=window.requestAnimationFrame(()=>{var C,P;const j=RS.current;j&&(j.scrollTop=j.scrollHeight),(P=(C=Jg.current)==null?void 0:C.scrollIntoView)==null||P.call(C,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[gy.length,Jr,Fj,yy.length,xu]);const b2=String(a.flowId||"").trim()||"Workspace",Co=(st==null?void 0:st.mode)==="single-node",zj=Co&&Mu.find(w=>{var j;return w.id===st.sourceNodeId||((j=st.nodeIds)==null?void 0:j.includes(w.id))})||null,k2=Co&&zj?[zj]:Mu;return s.jsxs("div",{className:"af-workspace-page",children:[l?null:s.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[s.jsxs("div",{className:"af-pipeline-top-left",children:[s.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n(a.adminOwnerId?"/admin/usage":a.returnTo||"/projects"),"aria-label":"返回",children:s.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),s.jsxs("div",{className:"af-pipeline-brand",title:a.flowId?`${a.flowId} · ${tS}`:tS||"PROJECT",children:[s.jsx("span",{className:"af-pipeline-brand-name",children:b2}),s.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",kY,"-STABLE"]})]}),zf?s.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",zf.ownerUsername||zf.ownerUserId]}):null,s.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[s.jsx("button",{type:"button",className:p==="workspace"?"af-view-switch__active":"",onClick:()=>hy("workspace"),children:"Workspace"}),s.jsx("button",{type:"button",className:p==="display"?"af-view-switch__active":"",onClick:()=>hy("display"),children:"Display"}),s.jsx("button",{type:"button",className:p==="workflow"?"af-view-switch__active":"",onClick:()=>hy("workflow"),children:"Workflow"})]})]}),s.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[Bt?null:s.jsx("span",{className:`af-workspace-sync-light is-${VS}`,title:`${JS} · ${KS}`,role:"status","aria-label":`${JS}:${KS}`,children:s.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),!Bt&&Ln?s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=Ln.conflictItems)!=null&&w.length?ka(!0):$j()},title:["先下载当前本地草稿,再载入远端最新版本",...Ln.conflictPaths||[]].join(`
|
|
265
|
+
`),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,ft?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||Kn||!(he!=null&&he.absoluteUrl)&&I.nodeIds.length===0,onClick:()=>{Rt(""),gt(!0)},title:he!=null&&he.absoluteUrl?"查看展示链接":I.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Kn?"hourglass_empty":"ios_share"}),Kn?"生成中":he!=null&&he.absoluteUrl?"展示链接":"生成链接"]}),s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!Se||$l.length===0,onClick:()=>Nn(!0),title:$l.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Bt?!Xn:!Se||!!(Ft!=null&&Ft.role&&Ft.role!=="owner"),onClick:()=>{Bt?Y$(w=>w+1):zL()},title:Bt?Xn?"管理当前需求的成员权限和只读链接":"先读取一个 TAPD 需求":Ft!=null&&Ft.role&&Ft.role!=="owner"?"仅 Workspace 所有者可以管理项目协作":"管理项目的团队和成员协作",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作"]}),!zf&&!Bt?s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:VL,title:"查看我的展示分享",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}):null,Bt?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!YS,onClick:()=>h(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:s.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),s.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!YS&&!_u,onClick:()=>v(!0),"aria-label":_u?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:_u?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:s.jsx("span",{className:"material-symbols-outlined",children:_u?"logout":"delete_forever"})})]}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Kf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:s.jsx("span",{className:"material-symbols-outlined",children:"help"})}),s.jsxs("button",{type:"button",className:"af-composer-topbar-btn"+(Bt?" af-composer-topbar-btn--workflow":"")+(xu?" af-composer-topbar-btn--active":"")+(us?" af-composer-topbar-btn--running":""),disabled:ft||(Bt?!Xn||!!a.workflowShare:!Se),onClick:()=>{if(Bt){X$(w=>w+1);return}El(null),Al(w=>(w||As(Ca()),!w))},title:Bt?"结合需求上下文和绑定代码仓库进行 AI 问答":"打开 Workspace AI",children:[Bt?s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}):null,Bt?"需求 AI":"AI"]}),Bt?null:s.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Se,onClick:()=>an().catch(w=>ye(String(w.message||w))),children:"Save"})]})]}),Dr?s.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),s.jsx("span",{children:Dr}),s.jsx("button",{type:"button",onClick:()=>Yn(""),"aria-label":"关闭发布提示",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,s.jsxs("div",{className:"af-workspace-body"+(!ft&&!Bt&&(xu||yt)?" af-workspace-body--drawer":"")+(!ft&&!Bt&&ku?" af-workspace-body--sidebar-collapsed":"")+(ft?" af-workspace-body--display-mode":"")+(Bt?" af-workspace-body--workflow-mode":""),children:[!ft&&!Bt&&ku?s.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:s.jsxs("div",{className:"af-workspace-rail__stack",children:[s.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>$e(!0),"aria-label":"添加节点",title:"添加节点",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),s.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),s.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>Vf(!1),"aria-label":"展开文件",title:"展开文件",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),s.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),s.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>Vf(!1),"aria-label":"展开侧边栏",title:(Fr==null?void 0:Fr.username)||(Fr==null?void 0:Fr.userId)||"展开侧边栏",children:LL})]})}):null,!ft&&!Bt?s.jsxs("aside",{ref:Wg,className:"af-workspace-sidebar"+(tL?" af-workspace-sidebar--resizing":""),"aria-hidden":ku,style:{"--af-work-files-pane-height":`${Math.round(Bg)}px`},children:[s.jsxs("section",{className:"af-workspace-files-section",children:[s.jsxs("div",{className:"af-workspace-sidebar-head",children:[s.jsx("h2",{children:"Files"}),s.jsxs("div",{className:"af-workspace-sidebar-actions",children:[s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Vf(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:s.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>m2(Ui),"aria-label":"新增文件",title:Ui?`在 ${Ui} 新增文件`:"新增文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se,onClick:()=>g2(Ui),"aria-label":"新增文件夹",title:Ui?`在 ${Ui} 新增文件夹`:"新增文件夹",children:s.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Se||dS,onClick:()=>pj(Ui),"aria-label":"上传文件",title:Ui?`上传到 ${Ui}`:"上传文件",children:s.jsx("span",{className:"material-symbols-outlined",children:dS?"hourglass_top":"upload_file"})}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void On(),"aria-label":"刷新文件",title:"刷新文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),s.jsx("input",{ref:pS,type:"file",multiple:!0,className:"af-visually-hidden",onChange:_L})]})]}),s.jsx("input",{className:"af-workspace-search",value:Og,onChange:w=>Z$(w.target.value),placeholder:"搜索文件..."}),s.jsx("div",{className:"af-workspace-files-scroll",onClick:ML,children:s.jsx($M,{items:RL,onOpen:f2,selectedPath:Dg,collapsedDirs:eL,onToggleDir:c2,onSelect:w=>Fg(w.path||""),onFileDragStart:u2,onDelete:y2,onDownload:w2})})]}),s.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:uL,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),s.jsxs("section",{className:"af-workspace-nodes-section",children:[s.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[s.jsxs("h2",{className:"af-node-palette-title",children:[s.jsx("span",{children:"Palette"}),s.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),s.jsxs("label",{className:"af-palette-search-wrap",children:[s.jsx("span",{className:"af-visually-hidden",children:ze==="flows"?"搜索流程片段":"搜索节点"}),s.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",className:"af-palette-search-input",value:Ce,onChange:w=>Ye(w.target.value),placeholder:ze==="flows"?"搜索流程片段...":"搜索节点...","aria-label":ze==="flows"?"搜索流程片段":"搜索节点"})]}),s.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":ze==="nodes",className:"af-palette-tab"+(ze==="nodes"?" af-palette-tab--active":""),onClick:()=>Nt("nodes"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":ze==="flows",className:"af-palette-tab"+(ze==="flows"?" af-palette-tab--active":""),onClick:()=>Nt("flows"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),s.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:ze==="flows"?s.jsxs(s.Fragment,{children:[s.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:s.jsxs("div",{className:"af-flow-snippet-actions",children:[s.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:DL,disabled:cr.length<2,title:cr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),s.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",cr.length," 节点 / ",np.length," 连线"]})]})}),rn?s.jsx("p",{className:"af-err af-palette-list-err",children:rn}):null,Rn?s.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Tj.length>0?s.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[s.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),s.jsx("div",{className:"af-palette-cards",children:Tj.map(w=>{const j=`${w.id}@${w.version}`,C=w.displayName||w.name||w.id,P=w.description||`${w.nodeCount||0} 个节点,${w.edgeCount||0} 条连线`;return s.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:M=>{M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("application/agentflow-snippet",j),M.dataTransfer.setData("text/plain",j)},onClick:()=>$u(w),title:P,children:[s.jsxs("span",{className:"af-palette-card-head",children:[s.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),s.jsxs("span",{className:"af-palette-card-main",children:[s.jsx("span",{className:"af-palette-card-label",children:C}),s.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),P?s.jsx("span",{className:"af-palette-card-desc",children:P}):null,s.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[s.jsxs("span",{children:[w.nodeCount||0," nodes"]}),s.jsxs("span",{children:[w.edgeCount||0," edges"]})]})]},j)})})]}):s.jsx("p",{className:"af-palette-empty",children:Ce.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):s.jsxs(s.Fragment,{children:[Ql.map(w=>{var j;return(j=uy[w])!=null&&j.length?s.jsxs("section",{className:`af-palette-section af-flow-palette-section--${w}`,children:[s.jsx("h3",{className:"af-palette-cat",children:w}),s.jsx("div",{className:"af-palette-cards",children:uy[w].map(C=>{const P=Z_(C.inputs,"input"),M=Z_(C.outputs,"output"),q=Ib(C),Q=ld(C);return s.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>d2(J,C),onClick:()=>Gi(C),title:q||C.id,children:[s.jsxs("span",{className:"af-palette-card-head",children:[s.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:X_(w)})}),s.jsxs("span",{className:"af-palette-card-main",children:[s.jsx("span",{className:"af-palette-card-label",children:Q}),Q!==C.id?s.jsx("span",{className:"af-palette-card-id",children:C.id}):null]})]}),q?s.jsx("span",{className:"af-palette-card-desc",children:q}):null,s.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[s.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[s.jsxs("span",{className:"af-palette-card-port-count",children:[P.list.length," IN"]}),s.jsxs("span",{className:"af-palette-card-port-list",children:[P.shown.map((J,Y)=>s.jsxs("span",{className:"af-palette-card-port",title:Q_("input",J,Y),children:[s.jsx("span",{className:"af-palette-card-port-dot",style:{background:zn(J==null?void 0:J.type)}}),s.jsx("span",{className:"af-palette-card-port-name",children:Xp(J,Y)})]},`in-${Y}`)),P.hidden>0?s.jsxs("span",{className:"af-palette-card-port-more",children:["+",P.hidden]}):null]})]}),s.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[s.jsxs("span",{className:"af-palette-card-port-count",children:[M.list.length," OUT"]}),s.jsxs("span",{className:"af-palette-card-port-list",children:[M.shown.map((J,Y)=>s.jsxs("span",{className:"af-palette-card-port",title:Q_("output",J,Y),children:[s.jsx("span",{className:"af-palette-card-port-name",children:Xp(J,Y)}),s.jsx("span",{className:"af-palette-card-port-dot",style:{background:zn(J==null?void 0:J.type)}})]},`out-${Y}`)),M.hidden>0?s.jsxs("span",{className:"af-palette-card-port-more",children:["+",M.hidden]}):null]})]})]})]},C.id)})})]},w):null}),wt.length>0&&Ce.trim()&&Ql.every(w=>{var j;return!((j=uy[w])!=null&&j.length)})?s.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,Bt?s.jsx(TX,{flowParams:a,tapdId:Xn,setTapdId:aL,collaborationOpenRequest:G$,assistantOpenRequest:J$,snapshot:dn,loading:lL,error:cL,actionRunning:Hg,actionOutput:Vg,pendingConfirm:Cs,conflict:wu,reviewPublishing:Kg,onRefresh:()=>Au(Xn),onRunDryRun:xL,onConfirmAction:bL,onRetryConflict:kL,onPublishReview:vL}):s.jsxs("main",{ref:N,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:w=>{l2(w),QL(w)},onLostPointerCaptureCapture:_o,children:[s.jsx(KT,{className:"af-flow-canvas af-workspace-flow"+(ny==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ft?" af-workspace-flow--display-mode":""),nodes:ep,edges:PL,nodeTypes:aX,onNodesChange:XL,onEdgesChange:t2,onMoveStart:ZL,onMoveEnd:e2,onConnect:ft?void 0:r2,onConnectStart:ft?void 0:s2,onConnectEnd:ft?void 0:i2,isValidConnection:ft?void 0:n2,onNodeClick:(w,j)=>{var C;if(ft){V([Zp(j.id)]);return}if((C=j==null?void 0:j.data)!=null&&C.isWorkspaceGroup){on("");return}if(w.detail>=3){Al(!1),g(P=>P.map(M=>({...M,selected:M.id===j.id}))),x(P=>P.map(M=>({...M,selected:!1}))),on(j.id);return}Nr&&on(j.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{ft?V([]):on("")},onDrop:ft?void 0:p2,onDragOver:ft?void 0:h2,nodesDraggable:Se,nodesConnectable:ft?!1:Se,edgesReconnectable:ft?!1:Se,onlyRenderVisibleElements:ep.length>=80,deleteKeyCode:ft?null:Se?["Backspace","Delete"]:null,selectionOnDrag:ny==="select",panOnDrag:ny==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:s.jsx(UT,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ft&&G?(()=>{var J;const w=String(G.query||"").trim().toLowerCase(),j=G.mode==="create"?"create":"existing",C=Array.isArray(G.candidates)?G.candidates:[],P=Array.isArray(G.existingCandidates)?G.existingCandidates:[],M=w?C.filter(Y=>{var ce,me,pe;return[(ce=Y.def)==null?void 0:ce.id,Y.displayLabel,Y.description,(me=Y.slot)==null?void 0:me.name,(pe=Y.slot)==null?void 0:pe.type].filter(Boolean).some(je=>String(je).toLowerCase().includes(w))}):C,q=w?P.filter(Y=>{var ce,me;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(ce=Y.slot)==null?void 0:ce.name,(me=Y.slot)==null?void 0:me.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(w))}):P,Q=G.draft.handleType==="source"?"IN":"OUT";return s.jsxs("div",{className:"af-connect-node-menu",style:{left:G.left,top:G.top},role:"dialog","aria-label":"选择匹配节点",children:[s.jsxs("div",{className:"af-connect-node-menu__head",children:[s.jsxs("div",{className:"af-connect-node-menu__title",children:[s.jsx("span",{className:"af-connect-node-menu__dot",style:{background:zn((J=G.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),s.jsxs("span",{children:["匹配 ",G.draft.slotType," 节点"]})]}),s.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>ne(null),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[s.jsxs("button",{type:"button",className:j==="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:["连接已有 ",s.jsx("span",{children:P.length})]}),s.jsxs("button",{type:"button",className:j==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:C.length===0,onClick:()=>ne(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",s.jsx("span",{children:C.length})]})]}),s.jsxs("label",{className:"af-connect-node-menu__search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:G.query,onChange:Y=>ne(ce=>ce&&{...ce,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),s.jsxs("div",{className:"af-connect-node-menu__list",children:[j==="create"?M.map(Y=>{var pe,je;const ce=Y.displayLabel||((pe=Y.def)==null?void 0:pe.id),me=Xp(Y.slot,Y.slotIndex);return s.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>o2(Y),title:Y.description||Y.def.id,children:[s.jsxs("span",{className:"af-connect-node-menu__item-main",children:[s.jsx("span",{className:"af-connect-node-menu__item-label",children:ce}),ce!==Y.def.id?s.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),s.jsxs("span",{className:"af-connect-node-menu__port",children:[s.jsx("span",{children:Q}),s.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:zn((je=Y.slot)==null?void 0:je.type)},"aria-hidden":!0}),s.jsx("span",{className:"af-connect-node-menu__port-name",children:me})]})]},`${Y.def.id}-${Y.slotIndex}`)}):q.map(Y=>{var pe;const ce=Y.nodeLabel||Y.nodeId,me=Xp(Y.slot,Y.slotIndex);return s.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>a2(Y),title:`${Y.definitionId||Y.nodeId} · ${me}`,children:[s.jsxs("span",{className:"af-connect-node-menu__item-main",children:[s.jsx("span",{className:"af-connect-node-menu__item-label",children:ce}),s.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),s.jsxs("span",{className:"af-connect-node-menu__port",children:[s.jsx("span",{children:Q}),s.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:zn((pe=Y.slot)==null?void 0:pe.type)},"aria-hidden":!0}),s.jsx("span",{className:"af-connect-node-menu__port-name",children:me}),Y.occupied?s.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(j==="create"?M.length:q.length)===0?s.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ft&&!Bt&&!hL?s.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:s.jsxs("div",{className:"af-pipeline-composer-inner",children:[s.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>Xg(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),s.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:cr.length===0?s.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):cr.map(w=>{var M,q;const j=String(((M=w.data)==null?void 0:M.label)??w.id),C=(q=w.data)!=null&&q.definitionId?String(w.data.definitionId):"",P=C&&C!==j?`${j} · ${w.id} · ${C}`:`${j} · ${w.id}`;return s.jsxs("div",{className:"af-composer-node-chip",title:P,children:[s.jsx("span",{className:"af-composer-node-chip-kind",children:C||"node"}),s.jsx("span",{className:"af-composer-node-chip-label",children:j}),s.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>JL(w.id),"aria-label":`取消选择 ${w.id}`,children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},w.id)})}),s.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[s.jsx("div",{className:"af-composer-input-wrap",children:s.jsx("textarea",{className:"af-composer-textarea",value:Sa,rows:2,onChange:w=>Yg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),lp())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Se})}),s.jsxs("div",{className:"af-composer-toolbar",children:[s.jsxs("div",{className:"af-composer-skills-field",children:[s.jsxs("button",{ref:Gg,type:"button",className:"af-composer-skills-button"+(qs.length>0?" af-composer-skills-button--active":""),disabled:us||!Se,"aria-haspopup":"listbox","aria-expanded":Hf,onClick:()=>Ug(w=>!w),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),s.jsx("span",{children:qs.length>0?`Skills ${qs.length}`:"Skills"})]}),Hf&&!us?ur.createPortal(s.jsx("div",{ref:IS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:fL,children:Ks.length===0?s.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):s.jsxs(s.Fragment,{children:[Ol.groups.map(w=>{const j=ca(w,Ks),C=mz(w,dy,Ks),P=dL.has(w.id);return s.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(P?" af-composer-skill-group--collapsed":""),children:[s.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[s.jsxs("label",{className:"af-composer-skill-group-check",children:[s.jsx("input",{type:"checkbox",checked:C==="all",disabled:j.length===0,onChange:M=>{const q=M.target.checked;hu(Q=>q?pz(Q,j):hz(Q,j))}}),s.jsxs("span",{className:"af-composer-skill-group-title-main",children:[s.jsx("span",{children:w.name}),w.builtin?s.jsx("em",{children:"built-in"}):null,C==="partial"?s.jsx("em",{children:"partial"}):null]})]}),s.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":P?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{ES(M=>{const q=new Set(M);return q.has(w.id)?q.delete(w.id):q.add(w.id),q})},children:[s.jsx("span",{children:w.skills.length}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:P?"expand_more":"expand_less"})]})]}),P?null:s.jsx("div",{className:"af-composer-skill-group-items",children:w.skills.map(M=>s.jsxs("label",{className:"af-composer-skill-option",children:[s.jsx("input",{type:"checkbox",checked:dy.has(M.key),onChange:q=>{const Q=q.target.checked;hu(J=>Q?J.includes(M.key)?J:[...J,M.key]:J.filter(Y=>Y!==M.key))}}),s.jsxs("span",{className:"af-composer-skill-option-main",children:[s.jsx("span",{className:"af-composer-skill-option-title",children:M.name}),M.description?s.jsx("span",{className:"af-composer-skill-option-desc",children:M.description}):null]})]},`${w.id}:${M.key}`))})]},w.id)}),Ol.ungrouped.length>0?s.jsxs("div",{className:"af-composer-skill-group",children:[s.jsxs("div",{className:"af-composer-skill-group-title",children:[s.jsx("span",{children:"Ungrouped"}),s.jsx("span",{children:Ol.ungrouped.length})]}),Ol.ungrouped.map(w=>s.jsxs("label",{className:"af-composer-skill-option",children:[s.jsx("input",{type:"checkbox",checked:dy.has(w.key),onChange:j=>{const C=j.target.checked;hu(P=>C?P.includes(w.key)?P:[...P,w.key]:P.filter(M=>M!==w.key))}}),s.jsxs("span",{className:"af-composer-skill-option-main",children:[s.jsx("span",{className:"af-composer-skill-option-title",children:w.name}),w.description?s.jsx("span",{className:"af-composer-skill-option-desc",children:w.description}):null]})]},`ungrouped:${w.key}`))]}):null]})}),document.body):null]}),s.jsx("label",{className:"af-composer-model-field",children:s.jsxs("select",{className:"af-composer-model-select",value:Vi,onChange:w=>rL(w.target.value),"aria-label":"模型",children:[s.jsx("option",{value:"",children:"默认模型"}),$L.map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))]})}),s.jsx("button",{type:"button",className:"af-composer-send"+(Sa.trim()&&!us?" af-composer-send--active":"")+(us?" af-composer-send--stop":""),disabled:us||!Sa.trim()||!Se,"aria-label":us?"Running":"Send",onClick:()=>void lp(),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:us?"sync":"arrow_upward"})})]})]})]})}):!ft&&!Bt?s.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Xg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!ft&&!Bt&&xu?s.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:s.jsxs("div",{className:"af-composer-sidebar",children:[s.jsxs("div",{className:"af-pipeline-drawer-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),s.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Al(!1),"aria-label":"关闭 AI 对话侧栏",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-composer-session-tabs",children:[s.jsx("button",{type:"button",className:"af-composer-session-tab"+(Jr==="workspace"?" af-composer-session-tab--active":""),ref:Jr==="workspace"?Jg:null,onClick:()=>As("workspace"),children:s.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Us.map(w=>s.jsxs("div",{role:"tab",tabIndex:0,ref:Jr===w.id?Jg:null,className:"af-composer-session-tab"+(Jr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>As(w.id),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),As(w.id))},title:w.runNodeId||w.label,children:[s.jsx("span",{className:"af-composer-session-label",children:w.label}),s.jsx("button",{type:"button",className:"af-composer-session-close",onClick:j=>{j.preventDefault(),j.stopPropagation(),jL(w.id)},"aria-label":`关闭 ${w.label}`,title:"关闭 tab",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]},w.id))]}),s.jsx("div",{className:"af-composer-sidebar-status"+(Wl?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Fj}),s.jsxs("div",{className:"af-composer-sidebar-thread",ref:RS,children:[s.jsx(uC,{messages:x2,running:Wl,showRunningIndicator:!gr}),yy.length>0?s.jsxs("details",{className:"af-composer-sidebar-log-details",...Wl?{open:!0}:{},children:[s.jsx("summary",{children:"执行日志"}),s.jsx(uC,{messages:yy,running:!1,showRunningIndicator:!1})]}):null]}),s.jsxs("div",{className:"af-composer-sidebar-input",children:[s.jsx("textarea",{className:"af-composer-sidebar-textarea",value:Sa,rows:3,onChange:w=>Yg(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),lp())},placeholder:gr?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!Se||Wl}),s.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!Se||Wl||!Sa.trim(),onClick:()=>void lp(),"aria-label":"发送 AI 对话",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!ft&&!Bt&&yt&&Qt?s.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:s.jsx(jG,{draft:yt,setDraft:_s,definitionId:String(((Wj=Qt.data)==null?void 0:Wj.definitionId)||Qt.id),systemPromptReadonly:String(((Bj=Qt.data)==null?void 0:Bj.description)||""),modelLists:va,disabled:!Se,onIdBlur:()=>ay(!0),onClose:()=>on(""),onPublishToMarketplace:SL,error:B$,ioSlots:{inputs:Array.isArray(yt==null?void 0:yt.inputs)?yt.inputs:[],outputs:Array.isArray(yt==null?void 0:yt.outputs)?yt.outputs:[]}})}):null,!ft&&!Bt&&bu?ur.createPortal(s.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>El(null),children:s.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:s.jsx(cG,{flowParams:a,scheduleNodeId:bu.scheduleNodeId,runNodeId:bu.runNodeId,lastRunId:bu.lastRunId,label:bu.label,onClose:()=>El(null)})})}),document.body):null,s.jsx(iG,{open:ey,onClose:()=>Kf(!1)}),s.jsx(aG,{open:ty,onClose:()=>OS(!1),onJump:cy,nodes:TL}),s.jsx(NG,{open:d,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:Nu,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),s.jsx(_G,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:Nu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:_u,onDeleted:async()=>{v(!1),n("/projects")}}),Q$&&Ln?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-workspace-conflict-modal",role:"dialog","aria-modal":"true","aria-label":"解决 Workspace 冲突",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"解决 ",((Hj=Ln.conflictItems)==null?void 0:Hj.length)||0," 处字段冲突"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ka(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-workspace-conflict-summary",children:["未冲突的改动已经自动合并。这里只需要决定双方同时修改的字段。",s.jsxs("div",{className:"af-workspace-conflict-bulk",children:[s.jsx("button",{type:"button",onClick:()=>vl(Object.fromEntries((Ln.conflictItems||[]).map((w,j)=>[String(j),{mode:"local",manual:Ju(w)}]))),children:"全部保留我的"}),s.jsx("button",{type:"button",onClick:()=>vl(Object.fromEntries((Ln.conflictItems||[]).map((w,j)=>[String(j),{mode:"remote",manual:Ju(w)}]))),children:"全部使用远端"})]})]}),(Ln.conflictItems||[]).map((w,j)=>{const C=Lg[String(j)]||{mode:"local",manual:Ju(w)};return s.jsxs("section",{className:"af-workspace-conflict-item",children:[s.jsx("code",{className:"af-workspace-conflict-path",children:w.path}),s.jsx("div",{className:"af-workspace-conflict-options",children:[["local","保留我的"],["remote","使用远端"],["manual","手动编辑"]].map(([P,M])=>s.jsx("button",{type:"button",className:C.mode===P?"is-active":"",onClick:()=>vl(q=>({...q,[String(j)]:{...C,mode:P}})),children:M},P))}),s.jsxs("div",{className:"af-workspace-conflict-values",children:[s.jsxs("div",{className:C.mode==="local"?"is-selected":"",children:[s.jsx("span",{children:"我的修改"}),s.jsx("pre",{children:xC(w,"incoming")})]}),s.jsxs("div",{className:C.mode==="remote"?"is-selected":"",children:[s.jsx("span",{children:"远端修改"}),s.jsx("pre",{children:xC(w,"current")})]})]}),C.mode==="manual"?s.jsxs("label",{className:"af-workspace-conflict-manual",children:[s.jsx("span",{children:"最终值(JSON)"}),s.jsx("textarea",{value:C.manual,onChange:P=>vl(M=>({...M,[String(j)]:{...C,manual:P.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${j}`)}),uS?s.jsx("div",{className:"af-flow-snippet-error",children:uS}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot af-workspace-conflict-foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Bf,onClick:()=>void $j(),children:"备份并载入远端"}),s.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Bf,onClick:()=>ka(!1),children:"稍后处理"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Bf||!(Ln.conflictItems||[]).length,onClick:()=>void BL(),children:Bf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,tr?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ar(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"名称"}),s.jsx("input",{type:"text",value:fn.name,onChange:w=>{const j=w.target.value;Sn(C=>({...C,name:j,id:C.id?C.id:j.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"ID"}),s.jsx("input",{type:"text",value:fn.id,onChange:w=>Sn(j=>({...j,id:w.target.value})),placeholder:"content-cleanup-snippet"})]}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"说明"}),s.jsx("textarea",{value:fn.description,onChange:w=>Sn(j=>({...j,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),s.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",cr.length," 个节点和 ",np.length," 条内部连线。"]}),gn?s.jsx("div",{className:"af-flow-snippet-error",children:gn}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>ar(!1),children:"取消"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Ir||!fn.name.trim(),onClick:()=>void FL(),children:Ir?"发布中...":"发布"})]})]})}),document.body):null,vj?s.jsx(YJ,{node:vj,onClose:()=>U("")}):null,pr?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":Co?"新建分享":"发布展示页",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),Co?"新建分享":"发布展示页"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>hr(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"标题"}),s.jsx("input",{type:"text",value:st.title,onChange:w=>Tt(j=>({...j,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),Co?null:s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"布局"}),s.jsxs("select",{className:"af-display-share-select",value:st.layout,onChange:w=>Tt(j=>({...j,layout:w.target.value})),children:[s.jsx("option",{value:"gallery",children:"Gallery"}),s.jsx("option",{value:"document",children:"Document"}),s.jsx("option",{value:"slides",children:"Slides"})]})]}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"有效期"}),s.jsx("select",{className:"af-display-share-select",value:sC(st),onChange:w=>{const j=w.target.value;Tt(C=>({...C,permanent:j==="permanent",expiresInDays:j==="permanent"?C.expiresInDays||30:Number(j)}))},children:Cw.map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))})]}),s.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":Co?"分享内容":"选择展示节点",children:[Co?s.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,k2.map(w=>{var C;const j=Array.isArray(st.nodeIds)&&st.nodeIds.includes(w.id);return s.jsxs("label",{className:"af-display-share-node-row",children:[s.jsx("input",{type:"checkbox",checked:j,disabled:Co,onChange:()=>HL(w.id)}),s.jsxs("span",{className:"af-display-share-node-row__main",children:[s.jsx("strong",{children:((C=w.data)==null?void 0:C.label)||w.id}),s.jsxs("small",{children:[Dn(w.data)," · ",w.id]})]})]},w.id)})]}),he!=null&&he.absoluteUrl?s.jsxs("div",{className:"af-display-share-result",children:[s.jsx("input",{type:"text",readOnly:!0,value:he.absoluteUrl,onFocus:w=>w.target.select()}),s.jsx("button",{type:"button",onClick:()=>window.open(he.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),s.jsx("button",{type:"button",onClick:()=>void Lj(),children:Ve==="copied"?"已复制":Ve==="failed"?"复制失败":"复制"})]}):null,jr?s.jsx("div",{className:"af-flow-snippet-error",children:jr}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>hr(!1),children:"取消"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Kn||!Array.isArray(st.nodeIds)||st.nodeIds.length===0,onClick:()=>void KL(),children:Kn?"生成中...":"生成链接"})]})]})}),document.body):null,nt?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{Rt(""),gt(!1)},"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[he!=null&&he.absoluteUrl?s.jsxs("div",{className:"af-display-link-modal__url",children:[s.jsx("input",{type:"text",readOnly:!0,value:he.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),s.jsxs("button",{type:"button",onClick:()=>window.open(he.absoluteUrl,"_blank","noopener,noreferrer"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),s.jsxs("button",{type:"button",onClick:()=>void Lj(),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ve==="copied"?"check":"content_copy"}),Ve==="copied"?"已复制":Ve==="failed"?"复制失败":"复制"]})]}):s.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"新链接有效期"}),s.jsx("select",{className:"af-display-share-select",value:sC(st),onChange:w=>{const j=w.target.value;Tt(C=>({...C,permanent:j==="permanent",expiresInDays:j==="permanent"?C.expiresInDays||30:Number(j)}))},children:Cw.map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))})]}),jr?s.jsx("div",{className:"af-flow-snippet-error",children:jr}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{Rt(""),gt(!1)},children:"关闭"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Kn||I.nodeIds.length===0,onClick:()=>void qL(),children:Kn?"生成中...":he!=null&&he.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,q$?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"项目协作",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"项目协作"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Rg(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-workspace-team-share",children:[s.jsxs("div",{className:"af-workspace-team-share__head",children:[s.jsx("strong",{children:"分享到团队"}),s.jsx("span",{children:Vs?Vs.name:"尚未加入团队"})]}),Vs?s.jsxs("div",{className:"af-workspace-team-share__actions",children:[s.jsxs("select",{value:$g,onChange:w=>aS(w.target.value),"aria-label":"团队权限",children:[s.jsx("option",{value:"viewer",children:"只读"}),s.jsx("option",{value:"editor",children:"可编辑和运行"})]}),(Vj=Ft==null?void 0:Ft.teamShares)!=null&&Vj.some(w=>w.teamId===Vs.id)?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:du,onClick:()=>void my(!1),children:du?"处理中...":"更新权限"}),s.jsx("button",{type:"button",disabled:du,onClick:()=>void my(!0),children:"取消分享"})]}):s.jsx("button",{type:"button",disabled:du,onClick:()=>void my(!1),children:du?"分享中...":"分享到团队"})]}):s.jsx("p",{className:"af-display-link-modal__empty",children:"联系超级管理员将你加入团队后,即可在这里分享。"})]}),s.jsx("p",{className:"af-display-link-modal__empty",children:"输入已注册用户名。添加后,这个 Workspace 会直接出现在对方的项目列表中。"}),s.jsxs("div",{className:"af-workspace-member-add",children:[s.jsx("input",{type:"text",value:uu,onChange:w=>sS(w.target.value),onKeyDown:w=>{w.key==="Enter"&&uu.trim()&&!Mg&&(w.preventDefault(),Mj())},placeholder:"输入用户名",autoFocus:!0}),s.jsx("button",{type:"button",disabled:Mg||!uu.trim(),onClick:()=>void Mj(),children:Mg?"添加中...":"添加成员"})]}),rS?s.jsx("div",{className:"af-flow-snippet-error",children:rS}):null,s.jsx("div",{className:"af-workspace-member-list",children:((Ft==null?void 0:Ft.members)||[]).map(w=>{const j=w.userId===(Ft==null?void 0:Ft.ownerId)||w.role==="owner";return s.jsxs("div",{className:"af-workspace-member-row",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:j?"shield_person":"person"}),s.jsxs("div",{children:[s.jsx("strong",{children:w.username||w.userId}),s.jsx("small",{children:j?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),j?null:s.jsx("button",{type:"button",disabled:iS===w.userId,onClick:()=>void WL(w),children:iS===w.userId?"移除中...":"取消分享"})]},w.userId)})})]}),s.jsx("div",{className:"af-flow-snippet-modal__foot",children:s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Rg(!1),children:"完成"})})]})}),document.body):null,Pt?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-shares-modal",role:"dialog","aria-modal":"true","aria-label":"我的分享",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>jn(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-display-shares-toolbar",children:[s.jsx("span",{children:rt.length?`${rt.length} 个分享`:"暂无分享"}),s.jsxs("button",{type:"button",onClick:()=>void Xs(),disabled:pn,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),Hs?s.jsx("div",{className:"af-flow-snippet-error",children:Hs}):null,pn?s.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!pn&&rt.length===0?s.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,s.jsx("div",{className:"af-display-shares-list",children:rt.map(w=>{const j=oC(w),C=ve===w.id,P=w.expiresAt?String(w.expiresInDays||30):"permanent";return s.jsxs("article",{className:"af-display-share-item",children:[s.jsxs("div",{className:"af-display-share-item__main",children:[s.jsx("strong",{children:w.title||"AgentFlow Display"}),s.jsxs("span",{children:[w.flowId||"-"," · ",w.layout||"gallery"," · ",Array.isArray(w.nodeIds)?w.nodeIds.length:0," nodes"]}),s.jsx("small",{children:IJ(w)})]}),s.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:j,onFocus:M=>M.target.select()}),s.jsx("select",{className:"af-display-share-select",value:P,disabled:C,onChange:M=>void GL(w,M.target.value),"aria-label":"修改分享有效期",children:Cw.map(M=>s.jsx("option",{value:M.value,children:M.label},M.value))}),s.jsxs("div",{className:"af-display-share-item__actions",children:[s.jsxs("button",{type:"button",onClick:()=>window.open(j,"_blank","noopener,noreferrer"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),s.jsxs("button",{type:"button",onClick:()=>void UL(w),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:jt===w.id?"check":"content_copy"}),jt===w.id?"已复制":"复制"]}),s.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:C,onClick:()=>void YL(w),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:C?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,sn?ur.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Nn(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("label",{className:"af-display-picker-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:Jn,onChange:w=>js(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),s.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":Pj.length||1},children:rp.length>0?Pj.map((w,j)=>s.jsx("div",{className:"af-display-picker-column",children:w.map(OL)},`display-picker-column-${j}`)):s.jsx("div",{className:"af-display-picker-empty",children:$l.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),s.jsx("div",{className:"af-flow-snippet-modal__foot",children:s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>Nn(!1),children:"完成"})})]})}),document.body):null,pu.nodeId?ur.createPortal(s.jsx(hX,{files:bl,query:pu.query,onQueryChange:w=>zg(j=>({...j,query:w})),onSelect:CL,onUpload:pj,onClose:iy}),document.body):null,!ft&&!Bt&&we?ur.createPortal(s.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>$e(!1),children:s.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:w=>w.stopPropagation(),children:[s.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":Ae==="nodes",className:"af-workspace-quick-add__tab"+(Ae==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>tt("nodes"),children:"节点"}),s.jsx("button",{type:"button",role:"tab","aria-selected":Ae==="flows",className:"af-workspace-quick-add__tab"+(Ae==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>tt("flows"),children:"流程"})]}),s.jsxs("div",{className:"af-workspace-quick-add__search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{ref:PS,value:In,onChange:w=>Wt(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),$e(!1);else if(w.key==="ArrowDown"){w.preventDefault();const j=Ae==="flows"?Ru.length:Tu.length;mr(C=>Math.min(Math.max(0,j-1),C+1))}else w.key==="ArrowUp"?(w.preventDefault(),mr(j=>Math.max(0,j-1))):w.key==="Tab"?(w.preventDefault(),tt(j=>j==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),Ae==="flows"?Dj(Ru[$n]||Ru[0]):Oj(Tu[$n]||Tu[0]))},placeholder:Ae==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ae==="flows"?"搜索流程片段":"搜索节点"})]}),s.jsx("div",{className:"af-workspace-quick-add__list",children:Ae==="flows"?Ru.length===0?s.jsx("div",{className:"af-workspace-quick-add__empty",children:Rn?"正在加载流程片段...":rn||"没有匹配的流程片段"}):Ru.map((w,j)=>{const C=w.displayName||w.name||w.id,P=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,M=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,q=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(P||{}).length,Q=Number.isFinite(Number(w.edgeCount))?Number(w.edgeCount):Array.isArray(M)?M.length:0;return s.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(j===$n?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>mr(j),onClick:()=>Dj(w),children:[s.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),s.jsxs("span",{className:"af-workspace-quick-add__main",children:[s.jsx("span",{className:"af-workspace-quick-add__label",children:C}),s.jsxs("span",{className:"af-workspace-quick-add__meta",children:[w.id,w.version?` · v${w.version}`:""]}),s.jsx("span",{className:"af-workspace-quick-add__desc",children:w.description||`${q} 节点 / ${Q} 连线`})]}),s.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):Tu.length===0?s.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Tu.map((w,j)=>{const C=ad(w),P=ld(w),M=Ib(w);return s.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(j===$n?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>mr(j),onClick:()=>Oj(w),children:[s.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:X_(C)}),s.jsxs("span",{className:"af-workspace-quick-add__main",children:[s.jsx("span",{className:"af-workspace-quick-add__label",children:P}),s.jsx("span",{className:"af-workspace-quick-add__meta",children:w.id}),M?s.jsx("span",{className:"af-workspace-quick-add__desc",children:M}):null]}),s.jsx("span",{className:"af-workspace-quick-add__cat",children:C})]},w.id)})})]})}),document.body):null]})]})}function qM(){return s.jsx(iv,{children:s.jsx(MX,{})})}function $X(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)??""),i=a=>r(a).trim(),o=t.find(a=>(a==null?void 0:a.name)===n&&i(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&i(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&i(a));return String((e==null?void 0:e.body)||(o?r(o):""))}function LX(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 OX(e){let t=String(e||"").replace(/\r\n/g,`
|
|
266
|
+
`).trim();return t.includes(`
|
|
267
|
+
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
268
|
+
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
269
|
+
$2`)),t}function UM(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=OX(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 p=String(c[1]||"").trim();return p==="|"||p===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
270
|
+
`).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
|
|
271
|
+
`).replace(/\s+$/g,""):p.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],i=t.indexOf("{"),o=t.lastIndexOf("}");i>=0&&o>i&&r.unshift(t.slice(i,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function Dv(e){let t=UM(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const i=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return i>0&&(t=t.slice(i).trim()),t}function DX(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 FX(e){const t=Dv(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
272
|
+
(() => {
|
|
273
|
+
document.addEventListener("click", (event) => {
|
|
274
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
275
|
+
if (!link) return;
|
|
276
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
277
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
278
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
event.preventDefault();
|
|
283
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
284
|
+
}, true);
|
|
285
|
+
})();
|
|
286
|
+
<\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function GM(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const i=new URLSearchParams;return i.set("id",t),i.set("path",r),n.download&&i.set("download","1"),`/api/display/file/raw?${i.toString()}`}function zX(e,t,n={}){const r=String(e||"").trim();return r?GM(r,t,n):""}function WX({className:e="",children:t}){const n=m.useRef(null),r=m.useRef(null),[i,o]=m.useState({visible:!1,top:0,height:100}),a=m.useCallback(()=>{const p=n.current;if(!p)return;const f=Math.max(1,p.scrollHeight),d=Math.max(1,p.clientHeight),h=f>d+1,y=h?Math.max(12,d/f*100):100,v=Math.max(0,100-y),b=h?Math.min(v,p.scrollTop/Math.max(1,f-d)*v):0;o({visible:h,top:b,height:y})},[]);m.useEffect(()=>{const p=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(p);const d=new ResizeObserver(a);d.observe(f);for(const h of Array.from(f.children))d.observe(h);return()=>{cancelAnimationFrame(p),d.disconnect()}},[t,a]);const l=m.useCallback(p=>{const f=n.current;if(!f)return;const d=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,p))*d,a()},[a]),c=m.useCallback((p,f=0)=>{const d=r.current;if(!d)return 0;const h=d.getBoundingClientRect(),y=i.height/100*h.height,v=Math.max(1,h.height-y);return(p-h.top-f)/v},[i.height]),u=m.useCallback(p=>{if(!i.visible)return;p.preventDefault(),p.stopPropagation();const f=r.current;if(!f)return;const d=f.getBoundingClientRect(),h=i.top/100*d.height,y=i.height/100*d.height,b=p.clientY>=d.top+h&&p.clientY<=d.top+h+y?p.clientY-d.top-h:y/2;l(c(p.clientY,b));const g=x=>{x.preventDefault(),l(c(x.clientY,b))},k=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[c,l,i.height,i.top,i.visible]);return s.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[s.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),s.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(i.visible?" af-public-display-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${i.height}%`,top:`${i.top}%`}})})]})}function Lb({node:e,shareId:t,style:n,bare:r=!1}){const i=$X(e),o=e.kind==="html"?Dv(i):e.kind==="react"?jg(i):UM(i),a=e.kind==="html"?DX(o):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return s.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:s.jsx("div",{className:"af-public-display-node__head",children:s.jsxs("div",{className:"af-public-display-node__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:LX(e.kind)}),s.jsx("strong",{children:e.label||e.id}),s.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),s.jsx(WX,{className:l,children:a?s.jsx("div",{className:"af-public-display-empty",children:a}):o.trim()?s.jsxs(s.Fragment,{children:[e.kind==="html"?s.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:FX(o)}):null,e.kind==="react"?s.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:Av(o)}):null,e.kind==="image"?s.jsx("img",{src:GM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?s.jsx("div",{className:"af-public-display-markdown",children:s.jsx(vv,{content:o,resolveSrc:(c,u)=>zX(c,t,u)})}):null,e.kind==="chart"?s.jsx(jv,{content:o}):null,e.kind==="table"?s.jsx(Sv,{content:o}):null,e.kind==="mermaid"||e.kind==="ascii"?s.jsx("pre",{children:o}):null]}):s.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function BX({data:e}){return s.jsx(Lb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const HX={publicDisplay:BX};function VX(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 YM(){var l,c,u,p;const{path:e}=ls(),t=m.useMemo(()=>VX(e),[e]),[n,r]=m.useState({loading:!0,error:"",share:null,nodes:[]});m.useEffect(()=>{let f=!1;async function d(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(h=>({...h,loading:!0,error:""}));try{const h=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await h.json().catch(()=>({}));if(!h.ok)throw new Error(y.error||"展示页不存在");f||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(h){f||r({loading:!1,error:String((h==null?void 0:h.message)||h),share:null,nodes:[]})}}return d(),()=>{f=!0}},[t]);const i=m.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((d,h)=>{const y=d.position&&typeof d.position.x=="number"&&typeof d.position.y=="number"?d.position:{x:120+h*40,y:100+h*32},v=d.size&&typeof d.size.width=="number"&&typeof d.size.height=="number"?d.size:{width:520,height:320};return{id:d.id,type:"publicDisplay",position:y,data:{node:d,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(v.width)||520),height:Math.max(1,Number(v.height)||320)}}}),[t,n.nodes]),o=m.useMemo(()=>{var v;const f=(v=n.share)==null?void 0:v.viewport;if(!f||typeof f!="object")return null;const d=Number(f.x),h=Number(f.y),y=Number(f.zoom);return!Number.isFinite(d)||!Number.isFinite(h)||!Number.isFinite(y)?null:{x:d,y:h,zoom:Math.min(Math.max(y,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return s.jsx("main",{className:"af-public-display-page",children:s.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return s.jsx("main",{className:"af-public-display-page",children:s.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),s.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 s.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:s.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>s.jsx(Lb,{node:d,shareId:t,bare:!0},d.id))})});const f=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return s.jsxs("main",{className:`af-public-display-page ${f}`,children:[s.jsxs("header",{className:"af-public-display-hero",children:[s.jsxs("div",{children:[s.jsx("p",{children:"AgentFlow Display"}),s.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),s.jsx("span",{children:(p=n.share)!=null&&p.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),s.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>s.jsx(Lb,{node:d,shareId:t},d.id))})]})}return s.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:s.jsx(iv,{children:s.jsx(KT,{className:"af-public-display-flow",nodes:i,edges:[],nodeTypes:HX,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:o||void 0,fitView:!o,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:s.jsx(UT,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const vt=e=>typeof e=="string",Xu=()=>{let e,t;const n=new Promise((r,i)=>{e=r,t=i});return n.resolve=e,n.reject=t,n},bC=e=>e==null?"":""+e,KX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},qX=/###/g,kC=e=>e&&e.indexOf("###")>-1?e.replace(qX,"."):e,vC=e=>!e||vt(e),Pd=(e,t,n)=>{const r=vt(t)?t.split("."):t;let i=0;for(;i<r.length-1;){if(vC(e))return{};const o=kC(r[i]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++i}return vC(e)?{}:{obj:e,k:kC(r[i])}},SC=(e,t,n)=>{const{obj:r,k:i}=Pd(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let o=t[t.length-1],a=t.slice(0,t.length-1),l=Pd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Pd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},UX=(e,t,n,r)=>{const{obj:i,k:o}=Pd(e,t,Object);i[o]=i[o]||[],i[o].push(n)},Mm=(e,t)=>{const{obj:n,k:r}=Pd(e,t);if(n)return n[r]},GX=(e,t,n)=>{const r=Mm(e,n);return r!==void 0?r:Mm(t,n)},JM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?vt(e[r])||e[r]instanceof String||vt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):JM(e[r],t[r],n):e[r]=t[r]);return e},Jl=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var YX={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const JX=e=>vt(e)?e.replace(/[&<>"'\/]/g,t=>YX[t]):e;class XX{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 QX=[" ",",","?","!",";"],ZX=new XX(20),eQ=(e,t,n)=>{t=t||"",n=n||"";const r=QX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=ZX.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!i.test(e);if(!o){const a=e.indexOf(n);a>0&&!i.test(e.substring(0,a))&&(o=!0)}return o},Ob=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 i=e;for(let o=0;o<r.length;){if(!i||typeof i!="object")return;let a,l="";for(let c=o;c<r.length;++c)if(c!==o&&(l+=n),l+=r[c],a=i[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;o+=c-o+1;break}i=a}return i},$m=e=>e&&e.replace("_","-"),tQ={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 Lm{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||tQ,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,i){return i&&!this.debug?null:(vt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Lm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Lm(this.logger,t)}}var Ti=new Lm;class Cg{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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),i=1;i<n;i++)r[i-1]=arguments[i];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 jC extends Cg{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 i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):vt(r)&&o?l.push(...r.split(o)):l.push(r)));const c=Mm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!vt(r)?c:Ob(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,i){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),i=n,n=l[1]),this.addNamespaces(n),SC(this.data,l,i),o.silent||this.emit("added",t,n,r,i)}addResources(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(vt(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});i.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,i,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=Mm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?JM(c,r,o):c={...c,...r},SC(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(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var XM={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,i))}),t}};const NC={};class Om extends Cg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),KX(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ti.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 i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!eQ(t,r,i);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:vt(o)?[o]:o};const u=t.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(i)}return{key:t,namespaces:vt(o)?[o]:o}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(p){const _=n.nsSeparator||this.options.nsSeparator;return i?{res:`${c}${_}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${_}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let d=f&&f.res;const h=f&&f.usedKey||a,y=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(d),b=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!vt(d)&&typeof d!="boolean"&&typeof d!="number";if(k&&d&&x&&b.indexOf(v)<0&&!(vt(g)&&Array.isArray(d))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,d,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(f.res=_,f.usedParams=this.getUsedParamsDetails(n),f):_}if(o){const _=Array.isArray(d),S=_?[]:{},N=_?y:h;for(const I in d)if(Object.prototype.hasOwnProperty.call(d,I)){const T=`${N}${o}${I}`;S[I]=this.translate(T,{...n,joinArrays:!1,ns:l}),S[I]===T&&(S[I]=d[I])}d=S}}else if(k&&vt(g)&&Array.isArray(d))d=d.join(g),d&&(d=this.extendTranslation(d,t,n,r));else{let _=!1,S=!1;const N=n.count!==void 0&&!vt(n.count),I=Om.hasDefaultValue(n),T=N?this.pluralResolver.getSuffix(u,n.count,n):"",z=n.ordinal&&N?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",E=N&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),O=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${T}`]||n[`defaultValue${z}`]||n.defaultValue;!this.isValidLookup(d)&&I&&(_=!0,d=O),this.isValidLookup(d)||(S=!0,d=a);const L=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&S?void 0:d,$=I&&O!==d&&this.options.updateMissing;if(S||_||$){if(this.logger.log($?"updateKey":"missingKey",u,c,a,$?O:d),o){const R=this.resolve(a,{...n,keySeparator:!1});R&&R.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 V=[];const B=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&B&&B[0])for(let R=0;R<B.length;R++)V.push(B[R]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(n.lng||this.language):V.push(n.lng||this.language);const F=(R,H,A)=>{const X=I&&A!==d?A:L;this.options.missingKeyHandler?this.options.missingKeyHandler(R,c,H,X,$,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(R,c,H,X,$,n),this.emit("missingKey",R,c,H,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?V.forEach(R=>{const H=this.pluralResolver.getSuffixes(R,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(A=>{F([R],a+A,n[`defaultValue${A}`]||O)})}):F(V,a,O))}d=this.extendTranslation(d,t,n,f,r),S&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${c}:${a}`),(S||_)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,_?d:void 0):d=this.options.parseMissingKeyHandler(d))}return i?(f.res=d,f.usedParams=this.getUsedParamsDetails(n),f):d}extendTranslation(t,n,r,i,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=vt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(u){const d=t.match(this.interpolator.nestingRegexp);p=d&&d.length}let f=r.replace&&!vt(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||i.usedLng,r),u){const d=t.match(this.interpolator.nestingRegexp),h=d&&d.length;p<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var d=arguments.length,h=new Array(d),y=0;y<d;y++)h[y]=arguments[y];return o&&o[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=vt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=XM.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,o,a,l;return vt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),p=u.key;i=p;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const d=n.count!==void 0&&!vt(n.count),h=d&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(vt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(b=>{this.isValidLookup(r)||(l=b,!NC[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(NC[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(g=>{if(this.isValidLookup(r))return;a=g;const k=[p];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,p,g,b,n);else{let _;d&&(_=this.pluralResolver.getSuffix(g,n.count,n));const S=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(k.push(p+_),n.ordinal&&_.indexOf(N)===0&&k.push(p+_.replace(N,this.options.pluralSeparator)),h&&k.push(p+S)),y){const I=`${p}${this.options.contextSeparator}${n.context}`;k.push(I),d&&(k.push(I+_),n.ordinal&&_.indexOf(N)===0&&k.push(I+_.replace(N,this.options.pluralSeparator)),h&&k.push(I+S))}}let x;for(;x=k.pop();)this.isValidLookup(r)||(o=x,r=this.getResource(g,b,x,n))}))})}),{res:r,usedKey:i,exactUsedKey:o,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,i):this.resourceStore.getResource(t,n,r,i)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!vt(t.replace);let i=r?t.replace:t;if(r&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const o of n)delete i[o]}return i}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 Iw=e=>e.charAt(0).toUpperCase()+e.slice(1);class _C{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ti.create("languageUtils")}getScriptPartFromCode(t){if(t=$m(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=$m(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(vt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let i=Intl.getCanonicalLocales(t)[0];if(i&&this.options.lowerCaseLng&&(i=i.toLowerCase()),i)return i}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(i=>i.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Iw(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]=Iw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Iw(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 i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),vt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),i=[],o=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return vt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):vt(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{i.indexOf(a)<0&&o(this.formatLanguageCode(a))}),i}}let nQ=[{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}],rQ={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 sQ=["v1","v2","v3"],iQ=["v4"],CC={zero:0,one:1,two:2,few:3,many:4,other:5},oQ=()=>{const e={};return nQ.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:rQ[t.fc]}})}),e};class aQ{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Ti.create("pluralResolver"),(!this.options.compatibilityJSON||iQ.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=oQ(),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=$m(t==="dev"?"en":t),i=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!t.match(/-|_/))return;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[o]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(i=>`${n}${i}`)}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((i,o)=>CC[i]-CC[o]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):r.numbers.map(i=>this.getSuffix(t,i,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(t,r);return i?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:this.getSuffixRetroCompatible(i,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 i=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const o=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!sQ.includes(this.options.compatibilityJSON)}}const AC=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=GX(e,t,n);return!o&&i&&vt(n)&&(o=Ob(e,n,r),o===void 0&&(o=Ob(t,n,r))),o},Pw=e=>e.replace(/\$/g,"$$$$");class lQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ti.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:i,prefix:o,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:p,unescapePrefix:f,nestingPrefix:d,nestingPrefixEscaped:h,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:JX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=o?Jl(o):a||"{{",this.suffix=l?Jl(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=d?Jl(d):h||Jl("$t("),this.nestingSuffix=y?Jl(y):v||Jl(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=g||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,i){let o,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const g=AC(n,c,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...i,...n,interpolationkey:h}):g}const y=h.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(AC(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const p=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Pw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Pw(this.escape(h)):Pw(h)}].forEach(h=>{for(l=0;o=h.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof p=="function"){const b=p(t,o,i);a=vt(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!vt(a)&&!this.useRawValueToEscape&&(a=bC(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,o,a;const l=(c,u)=>{const p=this.nestingOptionsSeparator;if(c.indexOf(p)<0)return c;const f=c.split(new RegExp(`${p}[ ]*{`));let d=`{${f[1]}`;c=f[0],d=this.interpolate(d,a);const h=d.match(/'/g),y=d.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(d=d.replace(/'/g,'"'));try{a=JSON.parse(d),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${p}${d}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;i=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!vt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(f=>f.trim());i[1]=p.shift(),c=p,u=!0}if(o=n(l.call(this,i[1].trim(),a),a),o&&i[0]===t&&!vt(o))return o;vt(o)||(o=bC(o)),o||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((p,f)=>this.format(p,f,r.lng,{...r,interpolationkey:i[1].trim()}),o.trim())),t=t.replace(i[0],o),this.regexp.lastIndex=0}return t}}const cQ=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);t==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),p=l.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Xl=e=>{const t={};return(n,r,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const a=r+JSON.stringify(o);let l=t[a];return l||(l=e($m(r),i),t[a]=l),l(n)}};class uQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ti.create("formatter"),this.options=t,this.formats={number:Xl((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return o=>i.format(o)}),currency:Xl((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>i.format(o)}),datetime:Xl((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return o=>i.format(o)}),relativetime:Xl((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return o=>i.format(o,r.range||"day")}),list:Xl((n,r)=>{const i=new Intl.ListFormat(n,{...r});return o=>i.format(o)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Xl(n)}format(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(l=>l.indexOf(")")>-1)){const l=o.findIndex(c=>c.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,l)].join(this.formatSeparator)}return o.reduce((l,c)=>{const{formatName:u,formatOptions:p}=cQ(c);if(this.formats[u]){let f=l;try{const d=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},h=d.locale||d.lng||i.locale||i.lng||r;f=this.formats[u](l,h,{...p,...i,...d})}catch(d){this.logger.warn(d)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const dQ=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class fQ extends Cg{constructor(t,n,r){let i=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=i,this.logger=Ti.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,i.backend,i)}queueLoad(t,n,r,i){const o={},a={},l={},c={};return t.forEach(u=>{let p=!0;n.forEach(f=>{const d=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?a[d]===void 0&&(a[d]=!0):(this.state[d]=1,p=!1,a[d]===void 0&&(a[d]=!0),o[d]===void 0&&(o[d]=!0),c[f]===void 0&&(c[f]=!0)))}),p||(l[u]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const i=t.split("|"),o=i[0],a=i[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{UX(c.loaded,[o],a),dQ(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const p=c.loaded[u];p.length&&p.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 i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:i,wait:o,callback:a});return}this.readingCalls++;const l=(u,p)=>{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&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,i+1,o*2,a)},o);return}a(u,p)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(p=>l(null,p)).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]:{},i=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."),i&&i();vt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),vt(n)&&(n=[n]);const o=this.queueLoad(t,n,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${i} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${i}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,i,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let p;u.length===5?p=u(t,n,r,i,c):p=u(t,n,r,i),p&&typeof p.then=="function"?p.then(f=>l(null,f)).catch(l):l(null,p)}catch(p){l(p)}else u(t,n,r,i,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,i)}}}const EC=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),vt(e[1])&&(t.defaultValue=e[1]),vt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),IC=e=>(vt(e.ns)&&(e.ns=[e.ns]),vt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),vt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),th=()=>{},pQ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class mf extends Cg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=IC(t),this.services={},this.logger=Ti,this.modules={external:[]},pQ(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(vt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=EC();this.options={...i,...this.options,...IC(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?Ti.init(o(this.modules.logger),this.options):Ti.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:typeof Intl<"u"&&(p=uQ);const f=new _C(this.options);this.store=new jC(this.options.resources,this.options);const d=this.services;d.logger=Ti,d.resourceStore=this.store,d.languageUtils=f,d.pluralResolver=new aQ(f,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(d.formatter=o(p),d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new lQ(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new fQ(o(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.languageDetector&&(d.languageDetector=o(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=o(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new Om(this.services,this.options),this.translator.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=th),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[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(p=>{this[p]=function(){return t.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return t.store[p](...arguments),t}});const c=Xu(),u=()=>{const p=(f,d)=>{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(d),r(f,d)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};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]:th;const i=vt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const i=Xu();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=th),this.services.backendConnector.reload(t,n,o=>{i.resolve(),r(o)}),i}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"&&XM.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 i=Xu();this.emit("languageChanging",t);const o=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const u=vt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,p=>{a(p,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),i}getFixedT(t,n,r){var i=this;const o=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),f=2;f<u;f++)p[f-2]=arguments[f];c=i.options.overloadTranslationOptionHandler([a,l].concat(p))}else c={...l};c.lng=c.lng||o.lng,c.lngs=c.lngs||o.lngs,c.ns=c.ns||o.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||o.keyPrefix);const d=i.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${d}${y}`):h=c.keyPrefix?`${c.keyPrefix}${d}${a}`:a,i.t(h,c)};return vt(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!i||a(o,t)))}loadNamespaces(t,n){const r=Xu();return this.options.ns?(vt(t)&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Xu();vt(t)&&(t=[t]);const i=this.options.preload||[],o=t.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=i.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new _C(EC());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 mf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:th;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},o=new mf(i);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(l=>{o[l]=this[l]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new jC(this.store.data,i),o.services.resourceStore=o.store),o.translator=new Om(o.services,i),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),p=1;p<c;p++)u[p-1]=arguments[p];o.emit(l,...u)}),o.init(i,n),o.translator.options=i,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Er=mf.createInstance();Er.createInstance=mf.createInstance;Er.createInstance;Er.dir;Er.init;Er.loadResources;Er.reloadResources;Er.use;Er.changeLanguage;Er.getFixedT;Er.t;Er.exists;Er.setDefaultNamespace;Er.hasLoadedNamespace;Er.loadNamespaces;Er.loadLanguages;function hQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gf(e){"@babel/helpers - typeof";return gf=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},gf(e)}function mQ(e,t){if(gf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(gf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function gQ(e){var t=mQ(e,"string");return gf(t)=="symbol"?t:t+""}function yQ(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,gQ(r.key),r)}}function wQ(e,t,n){return t&&yQ(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var QM=[],xQ=QM.forEach,bQ=QM.slice;function kQ(e){return xQ.call(bQ.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var PC=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,vQ=function(t,n,r){var i=r||{};i.path=i.path||"/";var o=encodeURIComponent(n),a="".concat(t,"=").concat(o);if(i.maxAge>0){var l=i.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(i.domain){if(!PC.test(i.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(i.domain)}if(i.path){if(!PC.test(i.path))throw new TypeError("option path is invalid");a+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(a+="; HttpOnly"),i.secure&&(a+="; Secure"),i.sameSite){var c=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.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},TC={create:function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),i&&(o.domain=i),document.cookie=vQ(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),i=0;i<r.length;i++){for(var o=r[i];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},SQ={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=TC.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&TC.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},jQ={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 i=r.substring(1),o=i.split("&"),a=0;a<o.length;a++){var l=o[a].indexOf("=");if(l>0){var c=o[a].substring(0,l);c===t.lookupQuerystring&&(n=o[a].substring(l+1))}}}return n}},Qu=null,RC=function(){if(Qu!==null)return Qu;try{Qu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Qu=!1}return Qu},NQ={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&RC()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&RC()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Zu=null,MC=function(){if(Zu!==null)return Zu;try{Zu=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Zu=!1}return Zu},_Q={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&MC()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&MC()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},CQ={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}},AQ={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}},EQ={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}},IQ={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]}},ZM=!1;try{document.cookie,ZM=!0}catch{}var e$=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];ZM||e$.splice(1,1);function PQ(){return{order:e$,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var t$=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hQ(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return wQ(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=kQ(r,this.options||{},PQ()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(SQ),this.addDetector(jQ),this.addDetector(NQ),this.addDetector(_Q),this.addDetector(CQ),this.addDetector(AQ),this.addDetector(EQ),this.addDetector(IQ)}},{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 i=[];return n.forEach(function(o){if(r.detectors[o]){var a=r.detectors[o].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(i=i.concat(a))}}),i=i.map(function(o){return r.options.convertDetectedLanguage(o)}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){i.detectors[o]&&i.detectors[o].cacheUserLanguage(n,i.options)}))}}])}();t$.type="languageDetector";const TQ={name:"AgentFlow",tagline:"AI Workflow Orchestration"},RQ={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},MQ={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"},$Q={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},LQ={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},OQ={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},DQ={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},FQ={app:TQ,nav:RQ,common:MQ,status:$Q,nodeTypes:LQ,engine:OQ,links:DQ},zQ="Flow Editor",WQ="Nodes",BQ="Edges",HQ="Properties",VQ={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"},KQ={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}}"},qQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},UQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},GQ={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"},YQ={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)"},JQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},XQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},QQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},ZQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},eZ={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"},tZ={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"},nZ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},rZ={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."},sZ={mainNav:"Main Navigation"},iZ={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'},oZ={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
|
|
287
|
+
{{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
|
|
288
|
+
Current: {{current}}`,phaseComplete:"{{phaseName}} completed. Next phase: {{nextPhase}}",nextPhase:"Next phase",continuePhase:"Continue {{label}}",skipRemainingPhases:"Please complete all remaining steps at once (skip phased confirmation)",phaseProgress:"Phase progress",phaseReviewLabel:"Phase options",phaseReviewHint:'This phase is complete. Review the canvas, then continue to "{{nextPhase}}".',phaseReviewContinue:"Continue: {{label}}",phaseReviewSkip:"Skip — finish remaining in one pass",stepsAriaLabel:"Task steps progress",phasesAriaLabel:"Generation phases progress",phaseNumber:"Phase {{index}}",stepRoleLabel:"Role: {{role}}",stepInstanceLabel:"Instance: {{instanceId}}",pageRefreshReset:"Reset after page refresh",conversationLabel:"Conversation {{n}}"},aZ={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"},lZ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},cZ={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}}"},uZ={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"},dZ={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"},fZ={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"},pZ={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"},hZ={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"},mZ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},gZ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},yZ={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"},wZ={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."},xZ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},bZ={save:"Save",cancel:"Cancel"},kZ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},vZ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},SZ={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"},jZ={title:zQ,nodes:WQ,edges:BQ,properties:HQ,node:VQ,nodeProps:KQ,actions:qQ,panel:UQ,palette:GQ,pipeline:YQ,status:JQ,roles:XQ,phases:QQ,types:ZQ,runContext:eZ,shortcuts:tZ,jumpPalette:nZ,emptyCanvas:rZ,sidebar:sZ,validation:iZ,composer:oZ,topbar:aZ,palette2:lZ,run:cZ,fileEdit:uZ,settings:dZ,schedule:fZ,history:pZ,nodePropsError:hZ,placeholder:mZ,time:gZ,userCheck:yZ,userAsk:wZ,toolPrint:xZ,provideEdit:bZ,runParams:kZ,runPreset:vZ,runConfig:SZ},NZ="Settings",_Z={engine:"Engine Settings",preferences:"Global Preferences"},CZ={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)."},AZ={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..."}},EZ={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."},IZ={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."},PZ={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."},TZ={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)"},RZ={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"},MZ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},$Z={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},LZ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},OZ={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."},DZ={title:NZ,crumb:_Z,workspace:CZ,cursor:AZ,opencode:EZ,claudeCode:IZ,codex:PZ,env:TZ,allowlist:RZ,system:MZ,shortcuts:$Z,language:LZ,onboarding:OZ},FZ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},zZ={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)"},WZ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},BZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},HZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},VZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},KZ={aiLabels:FZ,placeholders:zZ,actions:WZ,labels:BZ,tooltips:HZ,rightPanel:VZ},qZ="Projects",UZ="All",GZ="Archived",YZ="Nodes",JZ="My Nodes",XZ="My Flows",QZ="Skills",ZZ="Active Projects",eee="Archived Pipelines",tee="Global Nodes",nee="All Nodes",ree="My Nodes",see="Manage node versions published to the current workspace marketplace, {{count}} total.",iee="Manage flow snippets published to the current workspace marketplace, {{count}} total.",oee="Global Skills",aee="Create New Project",lee="New Pipeline",cee="SEARCH PIPELINES...",uee="SEARCH NODES...",dee="SEARCH FLOW SNIPPETS...",fee="SEARCH SKILLS...",pee="Refresh Resources",hee="Loading pipelines...",mee="Loading global resources...",gee="Filter result: {{count}} items (matching title, description, path and tags)",yee="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",wee="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",xee="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",bee="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",kee="Executable building blocks for pipeline runtime",vee="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.",See="Published local node packages",jee="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",Nee="Published flow snippets",_ee="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",Cee="Operating guides for Composer and agents",Aee="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",Eee="No archived projects.",Iee="No active pipelines; archived items are in the Archived tab.",Pee="No global nodes available.",Tee="No marketplace nodes have been published.",Ree="No flow snippets have been published. Select multiple canvas nodes and publish them first.",Mee="No skills available.",$ee="No description.",Lee='No node matches "{{query}}".',Oee='No flow snippet matches "{{query}}".',Dee='No skill matches "{{query}}".',Fee="{{inputs}} in / {{outputs}} out",zee="Flow Snippet",Wee="{{nodes}} nodes / {{edges}} edges",Bee="Skill",Hee="Node detail",Vee="Flow snippet detail",Kee="Skill detail",qee="Type",Uee="Source",Gee="Package",Yee="Version",Jee="Path",Xee="Editable",Qee="Read only",Zee="Editable",ete="Schema",tte="Inputs",nte="Outputs",rte="Runtime",ste="Node Body",ite="Files",ote="Usage",ate="No runtime manifest.",lte="No node body or README.",cte="No previewable files.",ute="Select a file to preview.",dte="Binary file preview is not supported.",fte="Large file; showing the first 256KB only.",pte="No pipelines using this node were found.",hte="Node Management",mte="Delete Node Version",gte="Deleting...",yte="AgentFlow checks all flow references before deleting; installed or used versions are kept.",wte="Delete {{id}}@{{version}}? This cannot be undone.",xte="Deleted {{id}}@{{version}}.",bte="{{count}} flow(s) still use it.",kte="Flow Snippet Management",vte="Delete Flow Snippet",Ste="Deleting...",jte="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",Nte="Delete {{id}}@{{version}}? This cannot be undone.",_te="Deleted {{id}}@{{version}}.",Cte="No slots",Ate="Purpose",Ete="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",Ite="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.",Pte="Scale",Tte="Flow Preview",Rte="Edges",Mte="Snippet JSON",$te="{{count}} more edge(s)",Lte="No previewable nodes.",Ote="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Dte="SKILL.md Preview",Fte="No preview content available.",zte="Select a resource to inspect details.",Wte="Failed to load pipeline list.",Bte="No pipelines in current workspace.",Hte="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.",Vte='No pipelines found matching "{{query}}". Try different keywords or clear the search.',Kte="Recent Activity",qte="No recent activity",Ute="No recent activity matching the keyword",Gte="Recent Run",Yte="Recent Open",Jte={builtin:"Built-in",workspace:"Workspace",user:"User"},Xte={flow:"Flow",global:"Global",marketplace:"Marketplace"},Qte={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Zte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},ene="Open to edit this pipeline in the node canvas.",tne={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>"},nne={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"},rne={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"},sne={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"},ine={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"},one={title:qZ,all:UZ,archived:GZ,nodes:YZ,myNodes:JZ,myFlows:XZ,skills:QZ,activeProjects:ZZ,archivedPipelines:eee,globalNodes:tee,nodeScopeAll:nee,nodeScopeMine:ree,myNodesHint:see,myFlowsHint:iee,globalSkills:oee,createNew:aee,newPipeline:lee,searchPipelines:cee,searchNodes:uee,searchFlows:dee,searchSkills:fee,refreshResources:pee,loadingPipelines:hee,loadingResources:mee,filterResult:gee,archivedHint:yee,activeHint:wee,nodesHint:xee,skillsHint:bee,nodesPurposeTitle:kee,nodesPurposeDesc:vee,myNodesPurposeTitle:See,myNodesPurposeDesc:jee,myFlowsPurposeTitle:Nee,myFlowsPurposeDesc:_ee,skillsPurposeTitle:Cee,skillsPurposeDesc:Aee,noArchived:Eee,noActive:Iee,noNodes:Pee,noMyNodes:Tee,noMyFlows:Ree,noSkills:Mee,noDescription:$ee,noNodeMatch:Lee,noFlowSnippetMatch:Oee,noSkillMatch:Dee,nodeSlots:Fee,flowSnippet:zee,flowSnippetNodes:Wee,skill:Bee,nodeDetail:Hee,flowDetail:Vee,skillDetail:Kee,detailType:qee,detailSource:Uee,detailPackage:Gee,detailVersion:Yee,detailPath:Jee,detailEditable:Xee,readOnly:Qee,editable:Zee,nodeSchema:ete,nodeInputs:tte,nodeOutputs:nte,nodeRuntime:rte,nodeBody:ste,nodeFiles:ite,nodeUsage:ote,noRuntimeManifest:ate,noNodeBody:lte,noNodeFiles:cte,selectNodeFile:ute,binaryFile:dte,fileTruncated:fte,noNodeUsage:pte,myNodeManagement:hte,deleteMyNode:mte,deletingMyNode:gte,deleteMyNodeHint:yte,deleteMyNodeConfirm:wte,deleteMyNodeSuccess:xte,deleteMyNodeUsedBy:bte,myFlowManagement:kte,deleteMyFlow:vte,deletingMyFlow:Ste,deleteMyFlowHint:jte,deleteMyFlowConfirm:Nte,deleteMyFlowSuccess:_te,noSlots:Cte,resourceMeaning:Ate,nodesMeaning:Ete,myFlowsMeaning:Ite,flowSnippetScale:Pte,flowSnippetPreview:Tte,flowSnippetEdges:Rte,flowSnippetJson:Mte,flowSnippetMoreEdges:$te,noFlowSnippetPreview:Lte,skillsMeaning:Ote,skillPreview:Dte,skillPreviewEmpty:Fte,selectResource:zte,loadFailed:Wte,noPipelines:Bte,emptyHint:Hte,noMatch:Vte,recentActivity:Kte,noRecentActivity:qte,noMatchRecent:Ute,recentRun:Gte,recentOpen:Yte,sourceBadge:Jte,resourceSource:Xte,resourceFilter:Qte,nodeDetailTabs:Zte,defaultCardDesc:ene,hubCard:tne,newPipelineModal:nne,importModal:rne,deleteModal:sne,archiveModal:ine},ane="Back",lne="Next",cne="Skip",une="Done",dne="Start Creating",fne={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
|
|
289
|
+
|
|
290
|
+
Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
|
|
291
|
+
|
|
292
|
+
Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},pne={intro:`Now you're in the flow editor.
|
|
293
|
+
|
|
294
|
+
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
295
|
+
|
|
296
|
+
The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
|
|
297
|
+
|
|
298
|
+
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
299
|
+
|
|
300
|
+
The left node panel allows you to freely drag, delete, and adjust connections.`},hne={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"},mne={back:ane,next:lne,skip:cne,done:une,startCreate:dne,projects:fne,flow:pne,newPipeline:hne},gne={name:"AgentFlow",tagline:"AI 工作流编排"},yne={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},wne={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},xne={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},bne={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},kne={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},vne={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},Sne={app:gne,nav:yne,common:wne,status:xne,nodeTypes:bne,engine:kne,links:vne},jne="流程编辑器",Nne="节点",_ne="连线",Cne="属性",Ane={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:"编辑内容"},Ene={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}}"},Ine={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},Pne={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},Tne={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},Rne={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},Mne={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},$ne={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},Lne={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},One={node:"节点",text:"文本",file:"文件",bool:"布尔"},Dne={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:"等待"},Fne={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},zne={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},Wne={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},Bne={mainNav:"主导航"},Hne={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},Vne={title:"AI 助手",placeholder:"让 AI 协助编辑此节点…",thinking:"思考",reply:"回复",result:"结果",error:"错误",waiting:"等待响应…",yourQuestion:"您的问题",send:"发送",expand:"展开对话",collapse:"收起",connecting:"连接中…",requestFailed:"请求失败",cannotReadStream:"无法读取响应流",connectTimeout:"连接超时(120s),请确认 UI 服务正在运行并重试。[CONNECT_TIMEOUT]",aborted:"已中止",executing:"执行中…",ready:"就绪",done:"完成",inputPlaceholder:"在此输入问题(⌘/Ctrl+Enter 发送)",inputAriaLabel:"问题输入",mentionAriaLabel:"提及:实例与节点类型",modelLabel:"模型",modelAriaLabel:"对话模型",modelDefault:"默认",modelNotInList:"(不在当前列表)",stopGeneration:"停止生成",conversationOutput:"对话与输出",collapseAriaLabel:"收起",closeSidebar:"关闭侧栏",endConversation:"结束对话(将停止生成)",closeConversation:"关闭对话",newConversation:"新建对话",switchConversation:"切换对话",selectedNodesAriaLabel:"已选节点列表",selectedNodesEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",removeFromInput:"从输入中移除 @{{id}}",deselectNode:"取消选中 {{id}}",taskPlan:`📋 任务规划({{count}} 步):
|
|
301
|
+
{{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
|
|
302
|
+
当前:{{current}}`,phaseComplete:"{{phaseName}}已完成。下一阶段:{{nextPhase}}",nextPhase:"下一阶段",continuePhase:"继续{{label}}",skipRemainingPhases:"请一次性完成剩余所有步骤(跳过分阶段确认)",phaseProgress:"分阶段进度",phaseReviewLabel:"分阶段选项",phaseReviewHint:"当前阶段完成,请在画布上检查结果,确认无误后进入「{{nextPhase}}」",phaseReviewContinue:"继续:{{label}}",phaseReviewSkip:"跳过,一次性完成剩余",stepsAriaLabel:"任务步骤进度",phasesAriaLabel:"生成阶段进度",phaseNumber:"第 {{index}} 阶段",stepRoleLabel:"角色:{{role}}",stepInstanceLabel:"实例:{{instanceId}}",pageRefreshReset:"页面刷新后重置",conversationLabel:"对话 {{n}}"},Kne={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},qne={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},Une={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}} 的分支"},Gne={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},Yne={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:"已复制"},Jne={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:"定时配置已保存"},Xne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},Qne={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},Zne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},ere={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},tre={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},nre={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},rre={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},sre={save:"保存",cancel:"取消"},ire={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},ore={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},are={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},lre={title:jne,nodes:Nne,edges:_ne,properties:Cne,node:Ane,nodeProps:Ene,actions:Ine,panel:Pne,palette:Tne,pipeline:Rne,status:Mne,roles:$ne,phases:Lne,types:One,runContext:Dne,shortcuts:Fne,jumpPalette:zne,emptyCanvas:Wne,sidebar:Bne,validation:Hne,composer:Vne,topbar:Kne,palette2:qne,run:Une,fileEdit:Gne,settings:Yne,schedule:Jne,history:Xne,nodePropsError:Qne,placeholder:Zne,time:ere,userCheck:tre,userAsk:nre,toolPrint:rre,provideEdit:sre,runParams:ire,runPreset:ore,runConfig:are},cre="设置",ure={engine:"引擎设置",preferences:"全局首选项"},dre={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},fre={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},pre={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},hre={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},mre={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},gre={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},yre={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:"添加"},wre={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},xre={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},bre={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},kre={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},vre={title:cre,crumb:ure,workspace:dre,cursor:fre,opencode:pre,claudeCode:hre,codex:mre,env:gre,allowlist:yre,system:wre,shortcuts:xre,language:bre,onboarding:kre},Sre={thinking:"思考",result:"结果",reply:"回复",error:"错误"},jre={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},Nre={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},_re={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},Cre={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},Are={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Ere={aiLabels:Sre,placeholders:jre,actions:Nre,labels:_re,tooltips:Cre,rightPanel:Are},Ire="项目",Pre="全部",Tre="已归档",Rre="Nodes",Mre="我的 Nodes",$re="我的流程",Lre="Skills",Ore="活跃项目",Dre="已归档流水线",Fre="全局 Nodes",zre="全部 Nodes",Wre="我的 Nodes",Bre="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",Hre="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",Vre="全局 Skills",Kre="创建新项目",qre="新建流水线",Ure="搜索流水线…",Gre="搜索 nodes…",Yre="搜索流程片段…",Jre="搜索 skills…",Xre="刷新资源",Qre="加载流水线列表…",Zre="加载全局资源…",ese="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",tse="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",nse="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",rse="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",sse="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",ise="流程运行时的可执行积木",ose="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",ase="已发布的本地节点包",lse="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",cse="已发布的流程片段",use="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",dse="Composer/Agent 的操作指南",fse="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",pse="暂无归档项目。",hse="暂无未归档流水线;已归档项在 Archived 标签中查看。",mse="暂无可用全局 nodes。",gse="暂无已发布的 marketplace nodes。",yse="暂无已发布的流程片段。可在画布中选中多个节点后发布。",wse="暂无可用 skills。",xse="暂无描述。",bse="未找到与「{{query}}」匹配的 node。",kse="未找到与「{{query}}」匹配的流程片段。",vse="未找到与「{{query}}」匹配的 skill。",Sse="{{inputs}} in / {{outputs}} out",jse="流程片段",Nse="{{nodes}} 节点 / {{edges}} 连线",_se="Skill",Cse="Node 详情",Ase="流程片段详情",Ese="Skill 详情",Ise="类型",Pse="来源",Tse="包",Rse="版本",Mse="路径",$se="可编辑",Lse="只读",Ose="可编辑",Dse="Schema",Fse="输入",zse="输出",Wse="Runtime",Bse="节点内容",Hse="Files",Vse="Usage",Kse="暂无 runtime manifest。",qse="暂无节点正文或 README。",Use="暂无可预览文件。",Gse="请选择文件查看内容。",Yse="二进制文件暂不支持预览。",Jse="文件较大,仅显示前 256KB。",Xse="暂未发现使用此 node 的流水线。",Qse="节点管理",Zse="删除节点版本",eie="删除中…",tie="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",nie="确定删除 {{id}}@{{version}}?此操作不可撤销。",rie="已删除 {{id}}@{{version}}。",sie="仍有 {{count}} 个 Flow 使用它。",iie="流程片段管理",oie="删除流程片段",aie="删除中…",lie="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",cie="确定删除 {{id}}@{{version}}?此操作不可撤销。",uie="已删除 {{id}}@{{version}}。",die="无槽位",fie="作用",pie="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",hie="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",mie="规模",gie="流程预览",yie="连线",wie="片段 JSON",xie="还有 {{count}} 条连线",bie="暂无可预览节点。",kie="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",vie="SKILL.md 预览",Sie="暂无可预览内容。",jie="请选择一个资源查看详情。",Nie="未能加载流水线列表。",_ie="当前工作区暂无流水线。",Cie="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Aie="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Eie="最近打开或最近运行",Iie="暂无打开或运行记录",Pie="暂无与关键词匹配的最近记录",Tie="最近运行",Rie="最近打开",Mie={builtin:"内置",workspace:"工作区",user:"用户"},$ie={flow:"Flow",global:"Global",marketplace:"Marketplace"},Lie={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Oie={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Die="打开以在节点画布中编辑此流水线。",Fie={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},zie={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:"关闭"},Wie={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Bie={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Hie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Vie={title:Ire,all:Pre,archived:Tre,nodes:Rre,myNodes:Mre,myFlows:$re,skills:Lre,activeProjects:Ore,archivedPipelines:Dre,globalNodes:Fre,nodeScopeAll:zre,nodeScopeMine:Wre,myNodesHint:Bre,myFlowsHint:Hre,globalSkills:Vre,createNew:Kre,newPipeline:qre,searchPipelines:Ure,searchNodes:Gre,searchFlows:Yre,searchSkills:Jre,refreshResources:Xre,loadingPipelines:Qre,loadingResources:Zre,filterResult:ese,archivedHint:tse,activeHint:nse,nodesHint:rse,skillsHint:sse,nodesPurposeTitle:ise,nodesPurposeDesc:ose,myNodesPurposeTitle:ase,myNodesPurposeDesc:lse,myFlowsPurposeTitle:cse,myFlowsPurposeDesc:use,skillsPurposeTitle:dse,skillsPurposeDesc:fse,noArchived:pse,noActive:hse,noNodes:mse,noMyNodes:gse,noMyFlows:yse,noSkills:wse,noDescription:xse,noNodeMatch:bse,noFlowSnippetMatch:kse,noSkillMatch:vse,nodeSlots:Sse,flowSnippet:jse,flowSnippetNodes:Nse,skill:_se,nodeDetail:Cse,flowDetail:Ase,skillDetail:Ese,detailType:Ise,detailSource:Pse,detailPackage:Tse,detailVersion:Rse,detailPath:Mse,detailEditable:$se,readOnly:Lse,editable:Ose,nodeSchema:Dse,nodeInputs:Fse,nodeOutputs:zse,nodeRuntime:Wse,nodeBody:Bse,nodeFiles:Hse,nodeUsage:Vse,noRuntimeManifest:Kse,noNodeBody:qse,noNodeFiles:Use,selectNodeFile:Gse,binaryFile:Yse,fileTruncated:Jse,noNodeUsage:Xse,myNodeManagement:Qse,deleteMyNode:Zse,deletingMyNode:eie,deleteMyNodeHint:tie,deleteMyNodeConfirm:nie,deleteMyNodeSuccess:rie,deleteMyNodeUsedBy:sie,myFlowManagement:iie,deleteMyFlow:oie,deletingMyFlow:aie,deleteMyFlowHint:lie,deleteMyFlowConfirm:cie,deleteMyFlowSuccess:uie,noSlots:die,resourceMeaning:fie,nodesMeaning:pie,myFlowsMeaning:hie,flowSnippetScale:mie,flowSnippetPreview:gie,flowSnippetEdges:yie,flowSnippetJson:wie,flowSnippetMoreEdges:xie,noFlowSnippetPreview:bie,skillsMeaning:kie,skillPreview:vie,skillPreviewEmpty:Sie,selectResource:jie,loadFailed:Nie,noPipelines:_ie,emptyHint:Cie,noMatch:Aie,recentActivity:Eie,noRecentActivity:Iie,noMatchRecent:Pie,recentRun:Tie,recentOpen:Rie,sourceBadge:Mie,resourceSource:$ie,resourceFilter:Lie,nodeDetailTabs:Oie,defaultCardDesc:Die,hubCard:Fie,newPipelineModal:zie,importModal:Wie,deleteModal:Bie,archiveModal:Hie},Kie="返回",qie="下一步",Uie="跳过",Gie="完成",Yie="开始创建",Jie={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
|
|
303
|
+
|
|
304
|
+
点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
|
|
305
|
+
|
|
306
|
+
在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},Xie={intro:`现在进入流程编辑器。
|
|
307
|
+
|
|
308
|
+
在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
|
|
309
|
+
|
|
310
|
+
左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
|
|
311
|
+
|
|
312
|
+
在下方输入框用自然语言描述需求,AI 会自动生成流程图。
|
|
313
|
+
|
|
314
|
+
左侧节点面板可以自由拖拽、删除和调整连接。`},Qie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},Zie={back:Kie,next:qie,skip:Uie,done:Gie,startCreate:Yie,projects:Jie,flow:Xie,newPipeline:Qie},eoe={en:{common:FQ,flow:jZ,settings:DZ,composer:KZ,project:one,onboarding:mne},zh:{common:Sne,flow:lre,settings:vre,composer:Ere,project:Vie,onboarding:Zie}};Er.use(t$).use(pF).init({resources:eoe,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 toe=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function noe(e){return Er.changeLanguage(e)}const Db="agentflow-settings-opencode-plan-v1",dd="CURSOR_API_KEYS",fd="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",Tw=new Set([dd,fd,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),n$=["cursor","opencode","claudeCode","codex"];function r$(){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 Pa(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of n$)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(Fb).filter(Boolean))]:[];return n}function Xi(e){if(!e||typeof e!="object")return r$();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 Pc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function roe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Oa(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const i=String(r.key??"").trim(),o=String(r.value??""),a=String(r.id??"").trim()||Pc(),c=String(r.scope??t).trim()==="global"?"global":"user";!i&&!o||n.push({id:a,key:i,value:o,scope:c})}return n}function $C(e){return Oa(e).map(({key:t,value:n})=>({key:t,value:n}))}function LC(){try{return localStorage.getItem(Db)??""}catch{return""}}function s$(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function soe(e){const t=String(e||"").trim();if(!t)return[];const n=(r,i)=>{if(typeof r=="string"){const a=r.trim();return a?{id:`legacy_${i}_${a.slice(-6)}`,name:`Key ${i+1}`,key:a,createdAt:""}:null}if(!r||typeof r!="object")return null;const o=String(r.key??"").trim();return o?{id:String(r.id??"").trim()||Pc(),name:String(r.name??"").trim()||`Key ${i+1}`,key:o,createdAt:String(r.createdAt??"").trim()}:null};try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n).filter(Boolean)}catch{}return t.split(",").map((r,i)=>n(r,i)).filter(Boolean)}function OC(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||Pc(),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 ioe(e){const t=String(e||"").trim();return t?t.length<=10?s$(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function ooe(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 aoe({authUser:e}){const{t,i18n:n}=Ur(["common","settings"]),r=n.language||"zh",[i,o]=m.useState(""),[a,l]=m.useState(""),[c,u]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[p,f]=m.useState(r$()),[d,h]=m.useState(()=>Pa({})),[y,v]=m.useState(!1),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(!1),[N,I]=m.useState(!1),[T,z]=m.useState(""),[E,O]=m.useState([]),[D,L]=m.useState(""),[$,V]=m.useState(!1),[B,F]=m.useState(""),[R,H]=m.useState(""),[A,X]=m.useState(!1),[K,W]=m.useState(()=>new Set),[te,ee]=m.useState(""),[G,ne]=m.useState(""),[re,ie]=m.useState(!!(e!=null&&e.isAdmin)),[Z,de]=m.useState(""),[fe,ge]=m.useState([]),[Oe,_e]=m.useState([]),[Ne,He]=m.useState(""),[ct,xt]=m.useState(""),[Re,lt]=m.useState(!1),[kt,Ot]=m.useState(!1),[_t,Xt]=m.useState(""),[ae,ke]=m.useState(""),[Ue,it]=m.useState(""),[Ee,Kt]=m.useState(null),[en,Ut]=m.useState(!1),[wt,mn]=m.useState(!1),[se,Ce]=m.useState(""),Ye=m.useRef(null),ze=m.useRef(!1),Nt=m.useRef(!1),St=m.useRef(""),Gn=m.useCallback(async()=>{l("");try{const oe=await fetch("/api/ui-context");if(!oe.ok)throw new Error("HTTP "+oe.status);const ve=await oe.json();o(typeof ve.workspaceRoot=="string"?ve.workspaceRoot:"")}catch(oe){l(String(oe.message||oe)),o("")}},[]),Rn=m.useCallback(async()=>{x(""),S(!0),g("");try{const oe=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!oe.ok)throw new Error("HTTP "+oe.status);const ve=await oe.json();if(e!=null&&e.isAdmin)u(Xi(ve.modelLists)),f(Xi(ve.allModelLists)),h(Pa(ve.hiddenModels));else{const Me=Xi(ve);u(Me),f(Me),h(Pa({}))}}catch(oe){x(String(oe.message||oe))}finally{S(!1)}},[e==null?void 0:e.isAdmin]),Sr=m.useCallback(async()=>{L("");try{const oe=await fetch("/api/user-env"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Me=Oa(Array.isArray(ve.env)?ve.env:[],"user").map(sn=>({...sn,scope:"user"})),Dt=[...e!=null&&e.isAdmin?Oa(Array.isArray(ve.globalEnv)?ve.globalEnv:[],"global").map(sn=>({...sn,scope:"global"})):[],...Me];St.current=JSON.stringify(Dt),O(Dt)}catch(oe){O([]),L(String(oe.message||oe))}finally{Nt.current=!0}},[e==null?void 0:e.isAdmin]),rn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){lt(!0),Xt("");try{const oe=await fetch("/api/admin/user-allowlist"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Me=ve.allowlist&&typeof ve.allowlist=="object"?ve.allowlist:{};ge(Array.isArray(Me.fileUsers)?Me.fileUsers.map(String):[]),_e(Array.isArray(Me.envUsers)?Me.envUsers.map(String):[]),He(typeof Me.path=="string"?Me.path:"")}catch(oe){Xt(String(oe.message||oe))}finally{lt(!1)}}},[e==null?void 0:e.isAdmin]),vn=m.useCallback(async oe=>{if(e!=null&&e.isAdmin){Ot(!0),Xt("");try{const ve=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:oe})}),Me=await ve.json().catch(()=>({}));if(!ve.ok)throw new Error(typeof Me.error=="string"?Me.error:"HTTP "+ve.status);const jt=Me.allowlist&&typeof Me.allowlist=="object"?Me.allowlist:{};ge(Array.isArray(jt.fileUsers)?jt.fileUsers.map(String):[]),_e(Array.isArray(jt.envUsers)?jt.envUsers.map(String):[]),He(typeof jt.path=="string"?jt.path:"")}catch(ve){Xt(String(ve.message||ve))}finally{Ot(!1)}}},[e==null?void 0:e.isAdmin]),tr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Ut(!0),Ce("");try{const oe=await fetch("/api/admin/storage-config"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Me=ve.config&&typeof ve.config=="object"?ve.config:{};Kt(Me),ke(typeof Me.dataRoot=="string"?Me.dataRoot:""),it(typeof Me.skillsRoot=="string"?Me.skillsRoot:"")}catch(oe){Ce(String(oe.message||oe))}finally{Ut(!1)}}},[e==null?void 0:e.isAdmin]),ar=m.useCallback(async()=>{if(e!=null&&e.isAdmin){mn(!0),Ce("");try{const oe=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:ae.trim(),skillsRoot:Ue.trim(),migrateLegacySkills:!0})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Me=ve.config&&typeof ve.config=="object"?ve.config:{};Kt(Me),ke(typeof Me.dataRoot=="string"?Me.dataRoot:""),it(typeof Me.skillsRoot=="string"?Me.skillsRoot:"")}catch(oe){Ce(String(oe.message||oe))}finally{mn(!1)}}},[e==null?void 0:e.isAdmin,ae,Ue]),fn=m.useCallback(async oe=>{const ve=Oa(oe),Me=ve.filter(Dt=>Dt.scope!=="global"),jt=ve.filter(Dt=>Dt.scope==="global");V(!0),L("");try{const Dt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:$C(Me),...e!=null&&e.isAdmin?{globalEnv:$C(jt)}:{}})}),sn=await Dt.json().catch(()=>({}));if(!Dt.ok)throw new Error(typeof sn.error=="string"?sn.error:"HTTP "+Dt.status);const Nn=Oa(Array.isArray(sn.env)?sn.env:[],"user").map(Ns=>({...Ns,scope:"user"})),js=[...e!=null&&e.isAdmin?Oa(Array.isArray(sn.globalEnv)?sn.globalEnv:[],"global").map(Ns=>({...Ns,scope:"global"})):[],...Nn];St.current=JSON.stringify(js),O(js)}catch(Dt){L(String(Dt.message||Dt))}finally{V(!1)}},[e==null?void 0:e.isAdmin]),Sn=m.useCallback(async()=>{x(""),S(!0);try{const oe=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z.trim()})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);u(Xi(ve.modelLists)),e!=null&&e.isAdmin?await Rn():f(Xi(ve.modelLists))}catch(oe){x(String(oe.message||oe))}finally{S(!1)}},[e==null?void 0:e.isAdmin,Rn,Z]),Ir=m.useCallback(async oe=>{if(!(e!=null&&e.isAdmin))return;const ve=Pa(oe);h(ve),v(!0),g("");try{const Me=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:ve})}),jt=await Me.json().catch(()=>({}));if(!Me.ok)throw new Error(typeof jt.error=="string"?jt.error:"HTTP "+Me.status);u(Xi(jt.modelLists)),f(Xi(jt.allModelLists)),h(Pa(jt.hiddenModels))}catch(Me){g(String(Me.message||Me)),Rn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,Rn]),Gr=m.useCallback((oe,ve,Me)=>{const jt=n$.includes(oe)?oe:"cursor",Dt=Fb(ve);if(!Dt)return;const sn=Pa(d),Nn=new Set(sn[jt]);Me?Nn.delete(Dt):Nn.add(Dt),Ir({...sn,[jt]:Array.from(Nn)})},[d,Ir]);m.useEffect(()=>{Sr(),e!=null&&e.isAdmin?(Gn(),Rn(),rn(),tr(),(async()=>{try{const oe=await fetch("/api/agentflow-config");if(oe.ok){const ve=await oe.json(),Me=typeof ve.opencodeProvider=="string"?ve.opencodeProvider:"";de(Me),Ye.current=Me;try{localStorage.setItem(Db,Me)}catch{}}else{const ve=LC();de(ve),Ye.current=ve}}catch{const oe=LC();de(oe),Ye.current=oe}finally{ze.current=!0}})()):(o(""),ze.current=!1)},[e==null?void 0:e.isAdmin,Gn,Rn,tr,rn,Sr]),m.useEffect(()=>{if(!Nt.current||JSON.stringify(Oa(E))===St.current)return;const ve=setTimeout(()=>{fn(E)},350);return()=>clearTimeout(ve)},[E,fn]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!ze.current)return;const oe=Z.trim();if(oe===Ye.current)return;const ve=setTimeout(()=>{(async()=>{I(!0),z("");try{const Me=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:oe})}),jt=await Me.json().catch(()=>({}));if(!Me.ok)throw new Error(typeof jt.error=="string"?jt.error:"HTTP "+Me.status);Ye.current=oe;try{localStorage.setItem(Db,oe)}catch{}jt.modelLists&&(u(Xi(jt.modelLists)),e!=null&&e.isAdmin?Rn():f(Xi(jt.modelLists)))}catch(Me){z(String(Me.message||Me))}finally{I(!1)}})()},450);return()=>clearTimeout(ve)},[e==null?void 0:e.isAdmin,Rn,Z]);const gn=e!=null&&e.isAdmin?p:c,Hn=gn.cursor.length>0,Dr=gn.opencode.length>0,Yn=gn.claudeCode.length>0,Vn=gn.codex.length>0,pr=Pa(d),hr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},Kn=m.useCallback((oe,ve,Me)=>{const jt=Array.isArray(ve)?ve:[];if(!(e!=null&&e.isAdmin))return s.jsx("pre",{className:"af-set-model-preview","aria-label":Me,children:jt.join(`
|
|
315
|
+
`)});const Dt=new Set(pr[oe]||[]);return s.jsxs("div",{className:"af-set-model-visibility","aria-label":Me,children:[s.jsxs("div",{className:"af-set-model-visibility-head",children:[s.jsxs("span",{children:["展示 ",hr[oe]||0," / ",jt.length]}),s.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),s.jsx("div",{className:"af-set-model-visibility-list",children:jt.map(sn=>{const Nn=Fb(sn),Jn=!Dt.has(Nn);return s.jsxs("label",{className:"af-set-model-visibility-row",children:[s.jsx("input",{type:"checkbox",checked:Jn,disabled:y,onChange:js=>Gr(oe,sn,js.target.checked)}),s.jsx("span",{children:sn})]},`${oe}-${sn}`)})})]})},[e==null?void 0:e.isAdmin,pr,y,hr,Gr]),lr=fe.length>0||Oe.length>0,jr=e!=null&&e.isAdmin?E:E.filter(oe=>!Tw.has(String((oe==null?void 0:oe.key)||"").trim())),le=e!=null&&e.isAdmin&&re?"global":"user",he=m.useMemo(()=>E.find(oe=>oe.key===dd&&(oe.scope||"user")===le)||null,[le,E]),Je=m.useMemo(()=>soe((he==null?void 0:he.value)||""),[he==null?void 0:he.value]),st=m.useMemo(()=>E.find(oe=>oe.key===fd&&(oe.scope||"user")===le)||null,[le,E]),Tt=st!=null&&st.value?String(st.value):"30",ue=m.useCallback((oe,ve,Me)=>{const jt=String(oe||"").trim();if(!jt)return;const Dt=String(ve??"");O(sn=>{const Nn=sn.find(Jn=>Jn.key===jt&&(Jn.scope||"user")===Me);return Dt?Nn?sn.map(Jn=>Jn.id===Nn.id?{...Jn,value:Dt,scope:Me}:Jn):[{id:Pc(),key:jt,value:Dt,scope:Me},...sn]:sn.filter(Jn=>!(Jn.key===jt&&(Jn.scope||"user")===Me))})},[]),Te=m.useCallback(()=>{const oe=G.trim();if(!oe)return;const ve=[...Je,{id:Pc(),name:te.trim()||`Key ${Je.length+1}`,key:oe,createdAt:new Date().toISOString()}];ue(dd,OC(ve),le),ee(""),ne("")},[te,Je,le,G,ue]),nt=m.useCallback(oe=>{const ve=Je.filter(Me=>Me.id!==oe);ue(dd,ve.length?OC(ve):"",le)},[Je,le,ue]),gt=m.useCallback(oe=>{const ve=String(oe||"").replace(/[^\d]/g,"");if(!ve){ue(fd,"",le);return}const Me=Math.min(1440,Math.max(1,Number(ve)||30));ue(fd,String(Me),le)},[le,ue]),Ve=m.useCallback(()=>{var oe;i&&((oe=navigator.clipboard)==null||oe.writeText(i))},[i]),Rt=m.useCallback(()=>{const oe=B.trim(),ve=R;if(oe){if(!roe(oe)){L(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&Tw.has(oe)){L("该运行基础设施变量仅管理员可配置。");return}O(Me=>[{id:Pc(),key:oe,value:ve,scope:e!=null&&e.isAdmin&&A?"global":"user"},...Me]),F(""),H("")}},[e==null?void 0:e.isAdmin,A,B,R,t]),Pt=m.useCallback(oe=>{O(ve=>ve.filter(Me=>Me.id!==oe))},[]),jn=m.useCallback((oe,ve)=>{const Me=String((ve==null?void 0:ve.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Me&&Tw.has(Me)){L("该运行基础设施变量仅管理员可配置。");return}O(jt=>jt.map(Dt=>Dt.id===oe?{...Dt,...ve}:Dt))},[e==null?void 0:e.isAdmin]),rt=m.useCallback(oe=>{W(ve=>{const Me=new Set(ve);return Me.has(oe)?Me.delete(oe):Me.add(oe),Me})},[]),Mn=m.useCallback(()=>{const oe=ct.trim();if(!oe)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(oe)){Xt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(fe.map(Me=>String(Me||"").trim().toLowerCase())).has(oe.toLowerCase())){xt("");return}xt(""),vn([...fe,oe])},[ct,fe,vn]),pn=m.useCallback(oe=>{const ve=String(oe||"").trim().toLowerCase();ve&&vn(fe.filter(Me=>String(Me||"").trim().toLowerCase()!==ve))},[fe,vn]),Bs=m.useCallback(oe=>{const ve=oe.target.value;noe(ve)},[]),Hs=oe=>{const ve=ooe(oe,r);return ve?t("settings:cursor.modelList.fetchedAt",{time:ve}):t("settings:cursor.modelList.never")};return s.jsxs("div",{className:"af-settings-page",children:[s.jsx("header",{className:"af-settings-top",children:s.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[s.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),s.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner",children:[s.jsxs("header",{className:"af-settings-hero",children:[s.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),s.jsx("p",{className:"af-settings-lead",children:e!=null&&e.isAdmin?t("settings:workspace.description"):t("settings:env.note")}),e!=null&&e.isAdmin&&a?s.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,e!=null&&e.isAdmin&&k?s.jsx("p",{className:"af-err af-settings-api-hint",children:k}):null,D?s.jsx("p",{className:"af-err af-settings-api-hint",children:D}):null,se?s.jsx("p",{className:"af-err af-settings-api-hint",children:se}):null]}),s.jsx("div",{className:"af-settings-layout",children:s.jsxs("div",{className:"af-settings-bento",children:[e!=null&&e.isAdmin?s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[s.jsxs("div",{className:"af-set-card-inner",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),s.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),s.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),s.jsxs("div",{className:"af-set-input-wrap",children:[s.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:i,placeholder:t("common:loading")}),s.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Ve,"aria-label":t("settings:workspace.copyPath"),disabled:!i,children:s.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),s.jsx("p",{className:"af-set-hint",children:"当前页面只展示运行时根目录。可被节点加载的代码库和文档目录请在左侧“知识库”里维护。"})]}),s.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),s.jsx("span",{className:"af-set-badge"+(Hn?" af-set-badge--ok":" af-set-badge--muted"),children:t(Hn?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),s.jsxs("div",{className:"af-set-cli-block",children:[s.jsx("div",{className:"af-set-cli-icon",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Hn?"check_circle":"hourglass_empty"})}),s.jsxs("div",{children:[s.jsx("p",{className:"af-set-cli-title",children:t(Hn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),s.jsx("p",{className:"af-set-cli-mono",children:Hn?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${gn.cursor.length}`:"")+" · "+Hs(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Hn?Kn("cursor",gn.cursor,t("settings:cursor.modelPreviewLabel")):null,b?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:b}):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Sn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-cursor-pool",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"key"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"Cursor API Key 池"}),s.jsx("p",{className:"af-set-card-subtitle",children:"按请求轮换,遇到 usage limit 或 resource_exhausted 会自动尝试下一个 Key。"})]})]}),s.jsxs("span",{className:"af-set-badge"+(Je.length?" af-set-badge--ok":" af-set-badge--muted"),children:[Je.length," keys"]})]}),s.jsxs("div",{className:"af-set-cursor-pool-controls",children:[e!=null&&e.isAdmin?s.jsxs("div",{className:"af-set-env-scope-switch af-set-cursor-scope",role:"group","aria-label":"Cursor API Key scope",children:[s.jsx("button",{type:"button",className:re?"":"is-active",onClick:()=>ie(!1),children:"个人"}),s.jsx("button",{type:"button",className:re?"is-active":"",onClick:()=>ie(!0),children:"全局"})]}):null,s.jsxs("label",{className:"af-set-cursor-cooldown",children:[s.jsx("span",{children:"限额冷却"}),s.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",inputMode:"numeric",value:Tt,onChange:oe=>gt(oe.target.value)}),s.jsx("span",{children:"分钟"})]}),s.jsx("span",{className:"af-set-env-note",children:$?"保存中":le==="global"?"全局配置":"个人配置"})]}),s.jsx("div",{className:"af-set-cursor-key-list",children:Je.length?Je.map(oe=>s.jsxs("div",{className:"af-set-cursor-key-row",children:[s.jsxs("div",{className:"af-set-cursor-key-main",children:[s.jsx("strong",{children:oe.name}),s.jsx("code",{children:ioe(oe.key)})]}),s.jsx("span",{className:"af-set-cursor-key-meta",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"历史 Key"}),s.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${oe.name}`,onClick:()=>nt(oe.id),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe.id)):s.jsx("div",{className:"af-set-cursor-key-empty",children:"还没有配置 Key。配置后 Cursor CLI runner 会自动轮换使用。"})}),s.jsxs("div",{className:"af-set-cursor-key-add",children:[s.jsx("input",{className:"af-set-input",value:te,onChange:oe=>ee(oe.target.value),placeholder:"名称,例如 Team Key 1"}),s.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:G,onChange:oe=>ne(oe.target.value),placeholder:"Cursor API Key"}),s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Te,disabled:!G.trim(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),s.jsxs("p",{className:"af-set-hint",children:["保存到 ",dd,";冷却时间保存到 ",fd,"。个人配置会覆盖全局配置。"]})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),s.jsx("span",{className:"af-set-badge"+(Dr?" af-set-badge--ok":" af-set-badge--err"),children:t(Dr?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),s.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),s.jsxs("div",{children:[s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),s.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:Z,onChange:oe=>de(oe.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),N?s.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,T?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:T}):null]}),Dr?s.jsxs(s.Fragment,{children:[s.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?` / ${gn.opencode.length}`:"")+" · "+Hs(c.opencodeFetchedAt)}),Kn("opencode",gn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Sn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),s.jsx("span",{className:"af-set-badge"+(Yn?" af-set-badge--ok":" af-set-badge--err"),children:t(Yn?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),s.jsxs("div",{className:"af-set-cli-block",children:[s.jsx("div",{className:"af-set-cli-icon",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Yn?"check_circle":"hourglass_empty"})}),s.jsxs("div",{children:[s.jsx("p",{className:"af-set-cli-title",children:t(Yn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),s.jsx("p",{className:"af-set-cli-mono",children:Yn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${gn.claudeCode.length}`:"")+" · "+Hs(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),s.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),Yn?Kn("claudeCode",gn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Sn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:codex.title")}),s.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")})]}),s.jsxs("div",{className:"af-set-cli-block",children:[s.jsx("div",{className:"af-set-cli-icon",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Vn?"check_circle":"hourglass_empty"})}),s.jsxs("div",{children:[s.jsx("p",{className:"af-set-cli-title",children:t(Vn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),s.jsx("p",{className:"af-set-cli-mono",children:Vn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${gn.codex.length}`:"")+" · "+Hs(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),s.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Vn?Kn("codex",gn.codex,t("settings:codex.modelPreviewLabel")):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Sn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]})]}):null,s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),s.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),s.jsx("span",{className:"af-set-env-note",children:$?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),s.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[s.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[s.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?s.jsx("span",{children:t("settings:env.scope")}):null,s.jsx("span",{children:t("settings:env.value")}),s.jsx("span",{})]}),s.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[s.jsx("div",{className:"af-set-env-cell",children:s.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:B,onChange:oe=>F(oe.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?s.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:s.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[s.jsx("button",{type:"button",className:A?"":"is-active",onClick:()=>X(!1),children:t("settings:env.personal")}),s.jsx("button",{type:"button",className:A?"is-active":"",onClick:()=>X(!0),children:t("settings:env.global")})]})}):null,s.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:s.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:R,onChange:oe=>H(oe.target.value),"aria-label":t("settings:env.newValue")})}),s.jsx("div",{className:"af-set-env-actions",children:s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Rt,disabled:!B.trim(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),jr.map(oe=>s.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[s.jsx("div",{className:"af-set-env-cell",children:s.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:oe.key,onChange:ve=>jn(oe.id,{key:ve.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?s.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:s.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[s.jsx("button",{type:"button",className:oe.scope!=="global"?"is-active":"",onClick:()=>jn(oe.id,{scope:"user"}),children:t("settings:env.personal")}),s.jsx("button",{type:"button",className:oe.scope==="global"?"is-active":"",onClick:()=>jn(oe.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,s.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[s.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:K.has(oe.id)?"text":"password",value:oe.value,onChange:ve=>jn(oe.id,{value:ve.target.value}),placeholder:s$(oe.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),s.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>rt(oe.id),"aria-label":K.has(oe.id)?"Hide value":"Show value",children:s.jsx("span",{className:"material-symbols-outlined",children:K.has(oe.id)?"visibility_off":"visibility"})})]}),s.jsx("div",{className:"af-set-env-actions",children:s.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:oe.key}),onClick:()=>Pt(oe.id),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},oe.id))]})]}),e!=null&&e.isAdmin?s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"hard_drive_2"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),s.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),s.jsx("span",{className:"af-set-badge"+(Ee!=null&&Ee.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:Ee!=null&&Ee.envLocked?"Env locked":"Configurable"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void tr(),disabled:en||wt,children:en?"刷新中...":"刷新"})]}),se?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:se}):null,s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),s.jsxs("div",{className:"af-set-input-wrap",children:[s.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:ae,onChange:oe=>ke(oe.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(Ee!=null&&Ee.envLocked)||wt}),s.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void ar(),"aria-label":"保存 AgentFlow Data Root",disabled:wt||!!(Ee!=null&&Ee.envLocked),children:s.jsx("span",{className:"material-symbols-outlined",children:wt?"hourglass_empty":"save"})})]}),s.jsxs("p",{className:"af-set-hint",children:["当前目录:",s.jsx("code",{children:(Ee==null?void 0:Ee.dataRoot)||ae||"-"}),Ee!=null&&Ee.configPath?s.jsxs(s.Fragment,{children:[";配置文件:",s.jsx("code",{children:Ee.configPath})]}):null]}),s.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",s.jsx("code",{children:"users/"}),"、",s.jsx("code",{children:"pipelines/"}),"、",s.jsx("code",{children:"runBuild/"}),"、",s.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",Ee!=null&&Ee.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]}),s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-skills-root",children:"Skills Root"}),s.jsxs("div",{className:"af-set-input-wrap",children:[s.jsx("input",{id:"af-agentflow-skills-root",className:"af-set-input af-set-input--mono",type:"text",value:Ue,onChange:oe=>it(oe.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(Ee!=null&&Ee.skillsEnvLocked)||wt}),s.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void ar(),"aria-label":"保存 AgentFlow Skills Root",disabled:wt||!!(Ee!=null&&Ee.skillsEnvLocked),children:s.jsx("span",{className:"material-symbols-outlined",children:wt?"hourglass_empty":"save"})})]}),s.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",s.jsx("code",{children:(Ee==null?void 0:Ee.skillsRoot)||Ue||"-"}),Ee!=null&&Ee.legacySkillsRootExists?s.jsxs(s.Fragment,{children:[";保存时会补迁移旧目录 ",s.jsx("code",{children:Ee.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),s.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",Ee!=null&&Ee.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),s.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),s.jsx("span",{className:"af-set-badge"+(lr?" af-set-badge--ok":" af-set-badge--muted"),children:t(lr?"settings:allowlist.enabled":"settings:allowlist.open")}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void rn(),disabled:Re,children:t(Re?"settings:allowlist.refreshing":"common:common.refresh")})]}),_t?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:_t}):null,Ne?s.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",s.jsx("code",{children:Ne})]}):null,s.jsxs("div",{className:"af-allowlist-grid",children:[s.jsxs("div",{className:"af-allowlist-main",children:[s.jsxs("div",{className:"af-allowlist-head",children:[s.jsx("span",{children:t("settings:allowlist.fileList")}),s.jsx("span",{children:kt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:fe.length})})]}),s.jsx("div",{className:"af-allowlist-list",children:fe.length>0?fe.map(oe=>s.jsxs("div",{className:"af-allowlist-row",children:[s.jsx("span",{className:"af-allowlist-name",children:oe}),s.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>pn(oe),"aria-label":t("settings:allowlist.remove",{username:oe}),disabled:kt,children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe)):s.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),s.jsxs("div",{className:"af-allowlist-add",children:[s.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:ct,onChange:oe=>xt(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&Mn()},placeholder:"username",autoComplete:"off"}),s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Mn,disabled:kt||!ct.trim(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),s.jsxs("div",{className:"af-allowlist-side",children:[s.jsxs("div",{className:"af-allowlist-head",children:[s.jsx("span",{children:t("settings:allowlist.envList")}),s.jsx("span",{children:t("settings:allowlist.readonly")})]}),s.jsx("div",{className:"af-allowlist-env-list",children:Oe.length>0?Oe.map(oe=>s.jsx("code",{children:oe},oe)):s.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),s.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,s.jsxs("section",{className:"af-settings-rail","aria-label":t("settings:title"),children:[e!=null&&e.isAdmin?s.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[s.jsxs("div",{className:"af-set-rail-inner",children:[s.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),s.jsxs("div",{className:"af-set-health-line",children:[s.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),s.jsx("span",{className:"af-set-health-label",children:t(!a&&!k?"settings:system.normal":"settings:system.abnormal")})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.cursorModels")}),s.jsx("span",{children:c.cursor.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.opencodeModels")}),s.jsx("span",{children:c.opencode.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.claudeCodeModels")}),s.jsx("span",{children:c.claudeCode.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.codexModels")}),s.jsx("span",{children:c.codex.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.length*3:4)}%`}})})]})]}),s.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}):null,s.jsxs("div",{className:"af-set-rail-card",children:[s.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),s.jsxs("div",{className:"af-set-language-selector",children:[s.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Bs,"aria-label":t("settings:language.description"),children:toe.map(oe=>s.jsxs("option",{value:oe.code,children:[oe.flag," ",oe.name]},oe.code))}),s.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function loe(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t))}function coe(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function uoe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function doe({run:e,onClose:t}){const[n,r]=m.useState(null),[i,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState("timeline"),p=m.useCallback(async({quiet:v=!1}={})=>{if(e!=null&&e.runId){v||o(!0),l("");try{const b=new URLSearchParams({runType:e.runType||"pipeline",userId:e.userId||"",flowId:e.flowId||"",flowSource:e.flowSource||"user",runId:e.runId}),g=await fetch(`/api/admin/run-detail?${b.toString()}`),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||`HTTP ${g.status}`);r(k)}catch(b){l(String((b==null?void 0:b.message)||b))}finally{v||o(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,e==null?void 0:e.runId,e==null?void 0:e.runType,e==null?void 0:e.userId]);m.useEffect(()=>{r(null),u("timeline"),p()},[p]),m.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||p({quiet:!0})},5e3);return()=>window.clearInterval(v)},[p,e==null?void 0:e.status]);const f=Array.isArray(n==null?void 0:n.events)?n.events:[],d=m.useMemo(()=>f.filter(v=>(v==null?void 0:v.kind)==="thinking"),[f]),h=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?d:f;return s.jsx("div",{className:"af-admin-run-detail-overlay",role:"presentation",onMouseDown:t,children:s.jsxs("aside",{className:"af-admin-run-detail",role:"dialog","aria-modal":"true","aria-label":"Run 详情",onMouseDown:v=>v.stopPropagation(),children:[s.jsxs("header",{className:"af-admin-run-detail__head",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"af-admin-run-detail__eyebrow",children:[e.runType==="workspace"?"Workspace Run":"Pipeline Run"," · ",uoe(e.status)]}),s.jsx("h2",{children:e.flowId||"Run 详情"}),s.jsxs("p",{children:[e.username||e.userId," · ",s.jsx("code",{children:e.runId})]})]}),s.jsxs("div",{className:"af-admin-run-detail__actions",children:[s.jsx("button",{type:"button",onClick:()=>void p(),disabled:i,title:"刷新详情",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),s.jsx("button",{type:"button",onClick:t,title:"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),s.jsxs("div",{className:"af-admin-run-detail__tabs",role:"tablist","aria-label":"Run 详情分类",children:[s.jsxs("button",{type:"button",className:c==="timeline"?"is-active":"",onClick:()=>u("timeline"),children:["过程 ",s.jsx("span",{children:f.length})]}),s.jsxs("button",{type:"button",className:c==="thinking"?"is-active":"",onClick:()=>u("thinking"),children:["Thinking ",s.jsx("span",{children:d.length})]}),s.jsxs("button",{type:"button",className:c==="raw"?"is-active":"",onClick:()=>u("raw"),children:["原始日志 ",s.jsx("span",{children:h.length})]})]}),n!=null&&n.truncated?s.jsx("div",{className:"af-admin-run-detail__notice",children:"日志较大,当前展示最新的 512 KB / 2000 条记录。"}):null,a?s.jsx("div",{className:"af-admin-run-detail__error",children:a}):null,i&&!n?s.jsx("div",{className:"af-admin-run-detail__empty",children:"正在读取 Run 详情..."}):null,s.jsx("div",{className:"af-admin-run-detail__body",children:c==="raw"?h.length>0?s.jsx("pre",{className:"af-admin-run-detail__raw",children:h.join(`
|
|
316
|
+
`)}):s.jsx("div",{className:"af-admin-run-detail__empty",children:"这个 Run 没有原始日志。"}):y.length>0?s.jsx("div",{className:"af-admin-run-detail__timeline",children:y.map((v,b)=>s.jsxs("article",{className:`af-admin-run-detail__event is-${v.kind||"process"}`,children:[s.jsxs("div",{className:"af-admin-run-detail__event-meta",children:[s.jsx("time",{children:loe(v.ts)}),s.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:coe(v.kind)}),s.jsx("span",{children:v.type||"event"}),v.nodeId?s.jsx("code",{children:v.nodeId}):null]}),s.jsx("pre",{children:v.text||"-"})]},v.id||`${v.ts||0}-${b}`))}):s.jsx("div",{className:"af-admin-run-detail__empty",children:c==="thinking"?"该模型或 CLI 没有为这个 Run 输出可记录的 Thinking。":"这个 Run 暂无过程事件。"})})]})})}function Wr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function nh(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Rw(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 i=Math.round(r/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function foe(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Mw(e){if(!e)return"无运行记录";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(Number(e)))}catch{return String(e)}}function poe(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function hoe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function moe({authUser:e}){const{navigate:t}=ls(),[n,r]=m.useState(null),[i,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(null),[p,f]=m.useState(null),[d,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=m.useCallback(async()=>{if(e!=null&&e.isAdmin){o(!0),l("");try{const E=await fetch("/api/admin/usage-dashboard"),O=await E.json().catch(()=>({}));if(!E.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+E.status);r(O)}catch(E){r(null),l(String((E==null?void 0:E.message)||E))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),x=m.useCallback(async E=>{const O=String((E==null?void 0:E.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!O)){f({userId:O,username:String((E==null?void 0:E.username)||O)}),h([]),g(""),v(!0);try{const D=new URLSearchParams({userId:O}),L=await fetch(`/api/admin/user-workspaces?${D.toString()}`),$=await L.json().catch(()=>({}));if(!L.ok)throw new Error($.error||"读取用户 Workspace 失败");f($.owner||{userId:O,username:String((E==null?void 0:E.username)||O)}),h(Array.isArray($.workspaces)?$.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),_=m.useCallback(E=>{const O=String((E==null?void 0:E.ownerUserId)||(p==null?void 0:p.userId)||"").trim(),D=String((E==null?void 0:E.id)||"").trim();if(!O||!D)return;const L=new URLSearchParams({flowId:D,flowSource:"user",adminOwnerId:O});E!=null&&E.archived&&L.set("archived","1"),t(`/workspace?${L.toString()}`)},[t,p==null?void 0:p.userId]);m.useEffect(()=>{k()},[k]);const S=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],N=m.useMemo(()=>{const D={top:20,right:24,bottom:42,left:42},L=980-D.left-D.right,$=250-D.top-D.bottom,V=S.length>0?S:[],B=Math.max(1,...V.map(K=>Number(K.runs||0))),F=Math.max(1,...V.flatMap(K=>[Number(K.users||0),Number(K.pipelines||0)])),R=K=>D.left+(V.length<=1?L/2:K*L/(V.length-1)),H=K=>D.top+$-Math.max(0,Number(K||0))/B*$,A=K=>D.top+$-Math.max(0,Number(K||0))/F*$,X=K=>V.map((W,te)=>`${te===0?"M":"L"} ${R(te)} ${A(W[K])}`).join(" ");return{width:980,height:250,margin:D,innerHeight:$,rows:V,x:R,yRuns:H,yLine:A,lineUsers:X("users"),linePipelines:X("pipelines"),barWidth:Math.min(34,Math.max(12,L/Math.max(1,V.length)*.44))}},[S]),I=(n==null?void 0:n.usage)||{},T=(n==null?void 0:n.totals)||{},z=Array.isArray(n==null?void 0:n.recentRuns)?n.recentRuns:[];return e!=null&&e.isAdmin?s.jsxs("main",{className:"af-admin-usage-page",children:[s.jsxs("section",{className:"af-admin-usage-hero",children:[s.jsxs("div",{children:[s.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),s.jsx("h1",{children:"管理看板"}),s.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),s.jsxs("button",{type:"button",onClick:()=>void k(),disabled:i,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),i?"刷新中":"刷新"]})]}),a?s.jsx("div",{className:"af-project-admin-usage__error",children:a}):null,s.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[s.jsxs("div",{children:[s.jsx("span",{children:"7日活跃用户率"}),s.jsx("strong",{children:nh(I.activeUserRate)}),s.jsxs("em",{children:[Wr(I.activeUsers)," / ",Wr(T.users)," users"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"7日流水线使用率"}),s.jsx("strong",{children:nh(I.activePipelineRate)}),s.jsxs("em",{children:[Wr(I.activePipelines)," / ",Wr(T.activePipelines)," active"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"7日 Run"}),s.jsx("strong",{children:Wr(I.runs)}),s.jsxs("em",{children:[Wr(I.avgRunsPerDay)," / day"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"7日成功率"}),s.jsx("strong",{children:nh(I.successRate)}),s.jsxs("em",{children:["失败率 ",nh(I.failureRate)," · avg ",Rw(I.avgDurationMs)]})]})]}),s.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[s.jsx("div",{className:"af-project-admin-usage__head",children:s.jsxs("div",{children:[s.jsx("strong",{children:"每日趋势"}),s.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),s.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[s.jsxs("div",{className:"af-admin-usage-chart__legend",children:[s.jsxs("span",{children:[s.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),s.jsxs("span",{children:[s.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),s.jsxs("span",{children:[s.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),s.jsx("div",{className:"af-admin-usage-chart__canvas",children:s.jsxs("svg",{viewBox:`0 0 ${N.width} ${N.height}`,preserveAspectRatio:"xMidYMid meet",children:[s.jsx("line",{className:"af-admin-usage-chart__axis",x1:N.margin.left,y1:N.margin.top+N.innerHeight,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight}),[.25,.5,.75,1].map(E=>s.jsx("line",{className:"af-admin-usage-chart__grid",x1:N.margin.left,y1:N.margin.top+N.innerHeight-N.innerHeight*E,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight-N.innerHeight*E},E)),N.rows.map((E,O)=>{const D=N.x(O),L=N.yRuns(E.runs),$=N.margin.top+N.innerHeight,V=Math.max(2,$-L);return s.jsxs("g",{children:[s.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:D-N.barWidth/2,y:$-V,width:N.barWidth,height:V,rx:"5",children:s.jsx("title",{children:`${E.date}: ${E.runs} runs`})}),s.jsx("text",{className:"af-admin-usage-chart__value",x:D,y:$+22,children:Wr(E.runs)}),s.jsx("text",{className:"af-admin-usage-chart__date",x:D,y:$+42,children:foe(E.date)})]},E.date)}),N.rows.length>0?s.jsxs(s.Fragment,{children:[s.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:N.lineUsers}),s.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:N.linePipelines}),N.rows.map((E,O)=>{const D=N.x(O);return s.jsxs("g",{children:[s.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:D,cy:N.yLine(E.users),r:"3.5"}),s.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:D,cy:N.yLine(E.pipelines),r:"3.5"})]},`${E.date}-points`)})]}):null]})})]}),s.jsx("div",{className:"af-project-admin-usage__table-wrap",children:s.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"用户"}),s.jsx("th",{children:"流水线"}),s.jsx("th",{children:"运行时间"}),s.jsx("th",{children:"状态"}),s.jsx("th",{children:"耗时"}),s.jsx("th",{children:"Run ID"})]})}),s.jsx("tbody",{children:z.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,children:"暂无运行明细"})}):z.map(E=>s.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(E),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),u(E))},children:[s.jsxs("td",{children:[s.jsx("strong",{children:E.username||E.userId||"-"}),s.jsx("span",{children:E.userId||"-"})]}),s.jsxs("td",{children:[s.jsx("strong",{children:E.flowId||"-"}),s.jsxs("span",{children:[E.runType==="workspace"?"Workspace Run":"Pipeline"," · ",E.flowSource||"user"]})]}),s.jsxs("td",{children:[s.jsx("strong",{children:Mw(E.at)}),E.endedAt?s.jsxs("span",{children:["结束 ",Mw(E.endedAt)]}):s.jsx("span",{children:"未结束"})]}),s.jsx("td",{children:s.jsx("span",{className:"af-project-admin-usage__chips",children:s.jsx("em",{children:hoe(E.status)})})}),s.jsx("td",{children:Rw(E.durationMs)}),s.jsx("td",{children:s.jsxs("span",{className:"af-admin-usage-run-link",children:[s.jsx("code",{className:"af-admin-usage-run-id",title:E.runId,children:poe(E.runId)}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${E.userId}:${E.flowSource}:${E.flowId}:${E.runId}:${E.at}`))})]})})]}),s.jsxs("section",{className:"af-project-admin-usage",children:[s.jsx("div",{className:"af-project-admin-usage__head",children:s.jsxs("div",{children:[s.jsx("strong",{children:"用户使用明细"}),s.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),s.jsx("div",{className:"af-project-admin-usage__table-wrap",children:s.jsxs("table",{className:"af-project-admin-usage__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"User"}),s.jsx("th",{children:"Pipeline"}),s.jsx("th",{children:"Runs"}),s.jsx("th",{children:"状态"}),s.jsx("th",{children:"最近运行"}),s.jsx("th",{children:"Workspace"})]})}),s.jsx("tbody",{children:i&&!n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,children:"正在加载..."})}):((n==null?void 0:n.users)||[]).length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,children:"暂无用户数据"})}):((n==null?void 0:n.users)||[]).map(E=>{var O,D,L,$,V,B,F,R,H,A,X,K,W;return s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:E.username||E.userId}),s.jsxs("span",{children:[E.userId,E.isAdmin?" · admin":""]})]}),s.jsxs("td",{children:[s.jsx("strong",{children:Wr((O=E.pipelines)==null?void 0:O.total)}),s.jsxs("span",{children:[Wr((D=E.pipelines)==null?void 0:D.active)," active / ",Wr((L=E.pipelines)==null?void 0:L.archived)," archived"]})]}),s.jsxs("td",{children:[s.jsx("strong",{children:Wr(($=E.runs)==null?void 0:$.total)}),s.jsxs("span",{children:["avg ",Rw((V=E.runs)==null?void 0:V.avgDurationMs)]})]}),s.jsx("td",{children:s.jsxs("span",{className:"af-project-admin-usage__chips",children:[s.jsxs("em",{children:["成功 ",Wr((B=E.runs)==null?void 0:B.success)]}),s.jsxs("em",{children:["失败 ",Wr((F=E.runs)==null?void 0:F.failed)]}),s.jsxs("em",{children:["运行中 ",Wr((R=E.runs)==null?void 0:R.running)]})]})}),s.jsx("td",{children:(H=E.runs)!=null&&H.lastRunAt?s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:((A=E.runs)==null?void 0:A.lastRunFlowId)||"-"}),s.jsxs("span",{children:[((X=E.runs)==null?void 0:X.lastRunStatus)||"unknown"," · ",Mw(E.runs.lastRunAt)]})]}):s.jsx("span",{children:"无运行记录"})}),s.jsx("td",{children:s.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((K=E.pipelines)!=null&&K.total)||y&&(p==null?void 0:p.userId)===E.userId,onClick:()=>void x(E),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(p==null?void 0:p.userId)===E.userId?"读取中":`查看 ${Wr((W=E.pipelines)==null?void 0:W.total)}`]})})]},E.userId)})})]})})]}),p?s.jsxs("section",{className:"af-project-admin-usage af-admin-user-workspaces",children:[s.jsxs("div",{className:"af-project-admin-usage__head",children:[s.jsxs("div",{children:[s.jsxs("strong",{children:[p.username||p.userId," 的 Workspace"]}),s.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),s.jsx("button",{type:"button",onClick:()=>{f(null),h([]),g("")},children:"关闭"})]}),b?s.jsx("div",{className:"af-project-admin-usage__error",children:b}):null,s.jsx("div",{className:"af-admin-user-workspaces__grid",children:y?s.jsx("p",{children:"正在读取 Workspace..."}):d.length===0?s.jsx("p",{children:"该用户暂无 Workspace。"}):d.map(E=>s.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>_(E),children:[s.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:E.archived?"inventory_2":"account_tree"}),s.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[s.jsx("strong",{children:E.id}),s.jsx("small",{children:E.description||(E.archived?"已归档 Workspace":"用户 Workspace")})]}),s.jsx("span",{className:"af-admin-user-workspace-card__status",children:E.archived?"已归档":"只读打开"})]},`${E.id}:${E.archived?"archived":"active"}`))})]}):null,c?s.jsx(doe,{run:c,onClose:()=>u(null)}):null]}):s.jsx("main",{className:"af-admin-usage-page",children:s.jsx("section",{className:"af-project-admin-usage",children:s.jsx("div",{className:"af-project-admin-usage__head",children:s.jsxs("div",{children:[s.jsx("strong",{children:"管理看板"}),s.jsx("span",{children:"需要管理员权限。"})]})})})})}function goe({authUser:e}){const[t,n]=m.useState([]),[r,i]=m.useState([]),[o,a]=m.useState(""),[l,c]=m.useState({name:"",description:"",status:"active",members:[]}),[u,p]=m.useState(""),[f,d]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState(""),g=m.useCallback(async()=>{b("");try{const S=await fetch("/api/admin/teams"),N=await S.json().catch(()=>({}));if(!S.ok)throw new Error(N.error||"读取团队失败");const I=Array.isArray(N.teams)?N.teams:[];n(I),i(Array.isArray(N.users)?N.users:[]),a(T=>{var z;return T&&I.some(E=>E.id===T)?T:((z=I[0])==null?void 0:z.id)||""})}catch(S){b(String(S.message||S))}},[]);m.useEffect(()=>{g()},[g]);const k=m.useMemo(()=>t.find(S=>S.id===o)||null,[o,t]);m.useEffect(()=>{if(!k){c({name:"",description:"",status:"active",members:[]});return}c({name:k.name||"",description:k.description||"",status:k.status||"active",members:(k.members||[]).map(S=>S.userId||S)})},[k]);const x=async(S,N)=>{y(!0),b("");try{const I=await fetch("/api/admin/teams",{method:S,headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),T=await I.json().catch(()=>({}));if(!I.ok)throw new Error(T.error||"更新团队失败");return await g(),T}catch(I){return b(String(I.message||I)),null}finally{y(!1)}};if(!(e!=null&&e.isAdmin))return s.jsx("main",{className:"af-team-admin-page",children:s.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:"仅超级管理员可以管理团队。"})});const _=r.filter(S=>{const N=f.trim().toLowerCase();return!N||`${S.username} ${S.userId}`.toLowerCase().includes(N)});return s.jsxs("main",{className:"af-team-admin-page",children:[s.jsxs("header",{className:"af-team-admin-hero",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Admin / Organization"}),s.jsx("h1",{children:"团队管理"}),s.jsx("p",{children:"划分团队成员,并为团队迭代汇总与 Project 分享提供权限边界。"})]}),s.jsxs("button",{type:"button",onClick:()=>void g(),disabled:h,children:[s.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),v?s.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,s.jsxs("div",{className:"af-team-admin-layout",children:[s.jsxs("aside",{className:"af-team-admin-list",children:[s.jsxs("form",{onSubmit:S=>{S.preventDefault(),u.trim()&&x("POST",{name:u.trim()}).then(N=>{var I;(I=N==null?void 0:N.team)!=null&&I.id&&a(N.team.id),N&&p("")})},children:[s.jsx("input",{value:u,onChange:S=>p(S.target.value),placeholder:"新团队名称"}),s.jsx("button",{type:"submit",disabled:h||!u.trim(),children:s.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),t.map(S=>s.jsxs("button",{type:"button",className:S.id===o?"is-active":"",onClick:()=>a(S.id),children:[s.jsxs("span",{children:[s.jsx("strong",{children:S.name}),s.jsxs("small",{children:[S.memberCount||0," 位成员"]})]}),S.status==="inactive"?s.jsx("em",{children:"已停用"}):null]},S.id)),t.length?null:s.jsx("p",{children:"还没有团队。"})]}),s.jsx("section",{className:"af-team-admin-detail",children:k?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-team-admin-fields",children:[s.jsxs("label",{children:[s.jsx("span",{children:"团队名称"}),s.jsx("input",{value:l.name,onChange:S=>c(N=>({...N,name:S.target.value}))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"状态"}),s.jsxs("select",{value:l.status,onChange:S=>c(N=>({...N,status:S.target.value})),children:[s.jsx("option",{value:"active",children:"启用"}),s.jsx("option",{value:"inactive",children:"停用"})]})]}),s.jsxs("label",{className:"is-wide",children:[s.jsx("span",{children:"说明"}),s.jsx("textarea",{value:l.description,onChange:S=>c(N=>({...N,description:S.target.value})),placeholder:"团队职责或范围"})]})]}),s.jsxs("div",{className:"af-team-admin-members-head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"团队成员"}),s.jsx("span",{children:"一个用户只能属于一个团队,保存后会自动从原团队移出。"})]}),s.jsx("input",{type:"search",value:f,onChange:S=>d(S.target.value),placeholder:"搜索用户"})]}),s.jsx("div",{className:"af-team-admin-members",children:_.map(S=>{var I;const N=l.members.includes(S.userId);return s.jsxs("label",{className:N?"is-selected":"",children:[s.jsx("input",{type:"checkbox",checked:N,onChange:T=>c(z=>({...z,members:T.target.checked?[...z.members,S.userId]:z.members.filter(E=>E!==S.userId)}))}),s.jsx("span",{className:"material-symbols-outlined",children:"person"}),s.jsxs("span",{children:[s.jsx("strong",{children:S.username}),s.jsxs("small",{children:[S.userId,S.isAdmin?" · Admin":""]})]}),S.teamId&&S.teamId!==k.id?s.jsx("em",{children:((I=t.find(T=>T.id===S.teamId))==null?void 0:I.name)||"其他团队"}):null]},S.userId)})}),s.jsxs("footer",{className:"af-team-admin-actions",children:[s.jsx("button",{type:"button",className:"is-danger",disabled:h||l.members.length>0,onClick:()=>{window.confirm(`删除团队「${k.name}」?`)&&x("DELETE",{teamId:k.id})},children:"删除团队"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",disabled:h,onClick:()=>c({name:k.name,description:k.description||"",status:k.status,members:(k.members||[]).map(S=>S.userId||S)}),children:"重置"}),s.jsx("button",{type:"button",className:"is-primary",disabled:h||!l.name.trim(),onClick:async()=>{await x("PATCH",{teamId:k.id,name:l.name,description:l.description,status:l.status})&&await x("PUT",{teamId:k.id,members:l.members})},children:h?"保存中...":"保存团队"})]})]})]}):s.jsx("div",{className:"af-workflows-message",children:"创建或选择一个团队。"})})]})]})}function yoe(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 woe({authUser:e}){const{navigate:t}=ls(),[n,r]=m.useState(""),[i,o]=m.useState(""),[a,l]=m.useState(!1),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState([]),[y,v]=m.useState(!1),[b,g]=m.useState(""),k=!!(e!=null&&e.isAdmin),x=m.useCallback(async()=>{if(k){v(!0),g("");try{const S=await fetch("/api/feedback"),N=await S.json().catch(()=>({}));if(!S.ok)throw new Error(N.error||"加载失败");h(Array.isArray(N.feedback)?N.feedback:[])}catch(S){g(String(S.message||S)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{x()},[x]);const _=async S=>{if(S.preventDefault(),!a){l(!0),u("");try{const N=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:i,pageUrl:window.location.href})}),I=await N.json().catch(()=>({}));if(!N.ok)throw new Error(I.error||"提交失败");f(!0),r(""),o("")}catch(N){u(String(N.message||N))}finally{l(!1)}}};return k?s.jsx("main",{className:"af-feedback-page",children:s.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",children:[s.jsxs("div",{className:"af-feedback-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),s.jsx("h1",{children:"意见反馈"}),s.jsx("p",{children:"查看用户提交的问题、建议和功能需求。"})]}),s.jsxs("div",{className:"af-feedback-admin-actions",children:[s.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:y,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":"refresh"}),y?"刷新中...":"刷新"]}),s.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),b?s.jsx("p",{className:"af-err af-feedback-error",children:b}):null,s.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:d.length>0?d.map(S=>s.jsxs("article",{className:"af-feedback-item",children:[s.jsxs("header",{className:"af-feedback-item__head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:S.title||"未命名反馈"}),s.jsxs("p",{children:[s.jsx("span",{children:S.username||S.userId||"unknown"}),s.jsx("span",{children:yoe(S.createdAt)})]})]}),S.contact?s.jsx("span",{className:"af-feedback-item__contact",children:S.contact}):null]}),s.jsx("p",{className:"af-feedback-item__content",children:S.content}),S.pageUrl?s.jsx("code",{className:"af-feedback-item__url",children:S.pageUrl}):null]},S.id)):s.jsx("div",{className:"af-feedback-empty",children:y?"正在加载反馈...":"暂无反馈"})})]})}):s.jsx("main",{className:"af-feedback-page",children:s.jsxs("section",{className:"af-feedback-panel",children:[s.jsxs("div",{className:"af-feedback-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),s.jsx("h1",{children:"意见反馈"}),s.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在这里统一查看。"})]}),s.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),p?s.jsxs("div",{className:"af-feedback-success",role:"status",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),s.jsxs("div",{children:[s.jsx("strong",{children:"已提交"}),s.jsx("span",{children:"感谢反馈,管理员可以在意见反馈页查看这条记录。"})]})]}):null,s.jsxs("form",{className:"af-feedback-form",onSubmit:_,children:[s.jsxs("label",{className:"af-feedback-field",children:[s.jsx("span",{children:"标题"}),s.jsx("input",{value:n,onChange:S=>r(S.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),s.jsxs("label",{className:"af-feedback-field",children:[s.jsx("span",{children:"反馈内容"}),s.jsx("textarea",{value:i,onChange:S=>o(S.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),c?s.jsx("p",{className:"af-err af-feedback-error",children:c}):null,s.jsx("div",{className:"af-feedback-actions",children:s.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:a||!n.trim()||!i.trim(),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"send"}),a?"提交中...":"提交反馈"]})})]})]})})}function i$(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function DC(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,i])=>({id:i$(),key:r,value:String(i??""),private:n.has(r)}))}function FC(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 Th(e=null){const t=e!=null&&e.raw&&typeof e.raw=="object"?e.raw:{},n=Array.isArray(t.args)?t.args:Array.isArray(e==null?void 0:e.args)?e.args:[];return{originalName:String((e==null?void 0:e.name)||""),name:String((e==null?void 0:e.name)||""),type:e!=null&&e.url||t.url?"url":"command",url:String((e==null?void 0:e.url)||t.url||""),command:String((e==null?void 0:e.command)||t.command||""),argsText:n.map(String).join(`
|
|
317
|
+
`),description:String((e==null?void 0:e.description)||t.description||""),envRows:DC(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:DC(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 $w(){return Th({name:"",raw:{command:""}})}function xoe(e){const n={...e.extraJson.trim()?JSON.parse(e.extraJson):{}};if(e.type==="url")n.url=e.url.trim();else{n.command=e.command.trim();const o=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);o.length&&(n.args=o)}const r=FC(e.envRows),i=FC(e.headerRows);return Object.keys(r).length&&(n.env=r),Object.keys(i).length&&(n.headers=i),e.description.trim()&&(n.description=e.description.trim()),{name:e.originalName,nextName:e.name.trim(),server:n,privateEnvKeys:e.envRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean)}}function zC(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function WC(e){return e?e.ok?"ok":"error":"unknown"}function zb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function boe(e,t){return e&&e.label||t}async function Lw(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 i=document.execCommand("copy");return r.remove(),i}catch{return!1}}function Fv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function o$({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 a$({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(`
|
|
318
|
+
`)}function koe({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=o$({baseUrl:n,token:t}),i=a$({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",i,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 的 MCP 页面点击“使用当前登录 Token”后重新复制。","7. 如果外部 Agent 启动 MCP 时找不到 `agentflow` 命令,请把 command 改成本机 agentflow 可执行文件的绝对路径,或先把 agentflow 安装/软链到 PATH。","","配置后验证:","- 如果配置使用 `command: agentflow`,确认外部 Agent 所在环境可以执行这个命令;如果使用绝对路径,则确认路径存在且可执行。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
|
|
319
|
+
`)}function voe({server:e}){const t=(e==null?void 0:e.backends)||{},n=[["Cursor",t.cursor],["Codex",t.codex]];return s.jsx("div",{className:"af-mcp-backends",children:n.map(([r,i])=>s.jsxs("div",{className:`af-mcp-backend af-mcp-backend--${zb(i==null?void 0:i.status)}`,children:[s.jsxs("div",{className:"af-mcp-backend-head",children:[s.jsx("strong",{children:r}),s.jsx("span",{children:boe(i,"Unknown")})]}),Array.isArray(i==null?void 0:i.reasons)&&i.reasons.length?s.jsx("ul",{children:i.reasons.map(o=>s.jsx("li",{children:o},o))}):s.jsx("p",{children:"当前配置可直接使用。"})]},r))})}function BC({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:i="value"}){const o=(a,l,c)=>n(t.map(u=>u.id===a?{...u,[l]:c}:u));return s.jsxs("div",{className:"af-mcp-field",children:[s.jsxs("div",{className:"af-mcp-field-head",children:[s.jsx("span",{children:e}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:i$(),key:"",value:"",private:!0}]),children:"添加"})]}),s.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?s.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>s.jsxs("div",{className:"af-mcp-kv-row",children:[s.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>o(a.id,"key",l.target.value)}),s.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:i,onChange:l=>o(a.id,"value",l.target.value)}),s.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[s.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>o(a.id,"private",l.target.checked)}),s.jsx("span",{children:"个人"})]}),s.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:s.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function Soe(){var ee;const[e,t]=m.useState(""),[n,r]=m.useState([]),[i,o]=m.useState($w),[a,l]=m.useState(""),[c,u]=m.useState(!1),[p,f]=m.useState(!1),[d,h]=m.useState(!1),[y,v]=m.useState({}),[b,g]=m.useState(""),[k,x]=m.useState(""),[_,S]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[N,I]=m.useState(""),[T,z]=m.useState(""),E=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),O=E&&y[E.name]||null,D=m.useMemo(()=>o$({baseUrl:_,token:N}),[_,N]),L=m.useMemo(()=>a$({baseUrl:_,token:N}),[_,N]),$=m.useMemo(()=>koe({baseUrl:_,token:N}),[_,N]),V=m.useCallback(async()=>{u(!0),g("");try{const G=await fetch("/api/mcps"),ne=await G.json().catch(()=>({}));if(!G.ok)throw new Error(ne.error||"MCP HTTP "+G.status);const re=Array.isArray(ne.servers)?ne.servers:[];t(String(ne.path||"")),r(re),a&&re.some(ie=>ie.name===a)&&o(Th(re.find(ie=>ie.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{V()},[V]);const B=()=>{l(""),o($w()),x(""),g("")},F=G=>{l(G.name),o(Th(G)),x(""),g("")},R=m.useCallback(async()=>{if(!$)return;const G=await Lw($);z(G?"prompt":"copy-failed"),window.setTimeout(()=>z(""),1200)},[$]),H=m.useCallback(async()=>{const G=await Lw(D);z(G?"cursor":"copy-failed"),window.setTimeout(()=>z(""),1200)},[D]),A=m.useCallback(async()=>{const G=await Lw(L);z(G?"codex":"copy-failed"),window.setTimeout(()=>z(""),1200)},[L]),X=m.useCallback(async()=>{try{const G=await fetch("/api/auth/session-token"),ne=await G.json().catch(()=>({}));if(!G.ok)throw new Error(typeof ne.error=="string"?ne.error:"HTTP "+G.status);I(String(ne.token||"")),z("token"),window.setTimeout(()=>z(""),1200)}catch(G){z(""),g(String(G.message||G))}},[]),K=async(G="")=>{h(!0),g(""),x("");try{const ne=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G?{name:G}:{})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"检测 MCP 失败");const ie=Array.isArray(re.results)?re.results:[];v(Z=>{const de={...Z};for(const fe of ie)fe!=null&&fe.name&&(de[fe.name]=fe);return de}),x(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(ne){g(String(ne.message||ne))}finally{h(!1)}},W=async()=>{f(!0),g(""),x("");try{const G=xoe(i);if(!G.nextName)throw new Error("请填写 MCP 名称");const ne=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"保存 MCP 失败");const ie=Array.isArray(re.servers)?re.servers:[];r(ie),t(String(re.path||e)),l(G.nextName),o(Th(ie.find(Z=>Z.name===G.nextName)||null)),v(Z=>{const de={...Z};return i.originalName&&i.originalName!==G.nextName&&delete de[i.originalName],delete de[G.nextName],de}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(G){g(String(G.message||G))}finally{f(!1)}},te=async G=>{if(G!=null&&G.name&&window.confirm(`删除 MCP "${G.name}"?`)){f(!0),g(""),x("");try{const ne=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.name})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(re.error||"删除 MCP 失败");r(Array.isArray(re.servers)?re.servers:[]),l(""),o($w()),v(ie=>{const Z={...ie};return delete Z[G.name],Z}),x("已删除。")}catch(ne){g(String(ne.message||ne))}finally{f(!1)}}};return s.jsxs("main",{className:"af-settings-page",children:[s.jsxs("header",{className:"af-settings-top",children:[s.jsxs("div",{className:"af-settings-crumb",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),s.jsxs("div",{className:"af-settings-top-right",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:V,disabled:c||p,children:"刷新"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(),disabled:d||c||p||n.length===0,children:d?"检测中...":"检测状态"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:p,children:"新增 MCP"})]})]}),s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner",children:[s.jsxs("section",{className:"af-settings-hero",children:[s.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),s.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"lan"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),s.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),s.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),s.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),s.jsxs("div",{className:"af-set-mcp-connect-grid",children:[s.jsxs("label",{className:"af-set-mcp-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{className:"af-set-input af-set-input--mono",value:_,onChange:G=>S(G.target.value),placeholder:"http://127.0.0.1:8875"})]}),s.jsxs("label",{className:"af-set-mcp-field",children:[s.jsx("span",{children:"Token"}),s.jsxs("div",{className:"af-set-mcp-token-row",children:[s.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:N,onChange:G=>I(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:X,children:T==="token"?"已填入":"使用当前登录 Token"})]})]})]}),s.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-set-mcp-snippet-head",children:[s.jsx("span",{children:"Cursor mcp.json"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:H,children:T==="cursor"?"已复制":T==="copy-failed"?"复制失败":"复制"})]}),s.jsx("pre",{className:"af-set-mcp-code",children:D})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"af-set-mcp-snippet-head",children:[s.jsx("span",{children:"Codex config.toml"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:A,children:T==="codex"?"已复制":T==="copy-failed"?"复制失败":"复制"})]}),s.jsx("pre",{className:"af-set-mcp-code",children:L})]})]}),s.jsx("div",{className:"af-set-mcp-copy-row",children:s.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:R,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),T==="prompt"?"已复制 Prompt":T==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),T==="copy-failed"?s.jsx("p",{className:"af-mcp-error",children:"浏览器禁止访问剪贴板,请手动选中下面的 Prompt 复制。"}):null,s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),s.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:$})]}),s.jsxs("section",{className:"af-settings-hero af-settings-hero--compact",children:[s.jsx("h2",{className:"af-settings-h2",children:"外部 MCP Servers"}),s.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 AgentFlow 可调用的外部 MCP server。当前配置文件:",s.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),s.jsxs("div",{className:"af-mcp-layout",children:[s.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2",children:"Servers"}),s.jsxs("div",{className:"af-mcp-list-head-actions",children:[s.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),s.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:p,children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?s.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?s.jsxs("div",{className:"af-mcp-empty",children:[s.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),s.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:B,disabled:p,children:"新增 MCP Server"})]}):null,s.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var ne,re,ie,Z;return s.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===G.name?" af-mcp-server-item--active":""),onClick:()=>F(G),children:[s.jsx("span",{className:"material-symbols-outlined",children:G.type==="url"?"cloud":"terminal"}),s.jsxs("span",{children:[s.jsxs("span",{className:"af-mcp-server-title",children:[s.jsx("strong",{children:G.name}),s.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${WC(y[G.name])}`,children:zC(y[G.name])})]}),s.jsxs("span",{className:"af-mcp-server-backends",children:[s.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${zb((re=(ne=G.backends)==null?void 0:ne.cursor)==null?void 0:re.status)}`,children:"Cursor"}),s.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${zb((Z=(ie=G.backends)==null?void 0:ie.codex)==null?void 0:Z.status)}`,children:"Codex"})]}),s.jsx("em",{children:G.url||[G.command,...G.args||[]].filter(Boolean).join(" ")})]})]},G.name)})})]}),s.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:E?"编辑 MCP":"新增 MCP"}),s.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),E?s.jsxs("div",{className:"af-mcp-editor-actions",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>K(E.name),disabled:d||p,children:d?"检测中...":"检测"}),s.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>te(E),disabled:p,children:"删除"})]}):null]}),b?s.jsx("p",{className:"af-mcp-error",children:b}):null,k?s.jsx("p",{className:"af-mcp-status",children:k}):null,E?s.jsx(voe,{server:E}):null,O?s.jsxs("div",{className:`af-mcp-check af-mcp-check--${WC(O)}`,children:[s.jsxs("div",{className:"af-mcp-check-head",children:[s.jsx("strong",{children:zC(O)}),s.jsxs("span",{children:[O.elapsedMs||0,"ms"]})]}),O.error?s.jsx("p",{children:O.error}):null,(ee=O.tools)!=null&&ee.length?s.jsx("div",{className:"af-mcp-tools-list",children:O.tools.map(G=>s.jsxs("div",{className:"af-mcp-tool-row",children:[s.jsx("strong",{children:G.name}),G.description?s.jsx("span",{children:G.description}):null]},G.name))}):null]}):null,s.jsxs("div",{className:"af-mcp-form",children:[s.jsxs("label",{className:"af-set-label",children:["MCP 名称",s.jsx("input",{className:"af-set-input af-set-input--mono",value:i.name,onChange:G=>o(ne=>({...ne,name:G.target.value})),placeholder:"github"})]}),s.jsxs("label",{className:"af-set-label",children:["类型",s.jsxs("select",{className:"af-set-input",value:i.type,onChange:G=>o(ne=>({...ne,type:G.target.value})),children:[s.jsx("option",{value:"url",children:"URL / HTTP"}),s.jsx("option",{value:"command",children:"Command / stdio"})]})]}),i.type==="url"?s.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",s.jsx("input",{className:"af-set-input af-set-input--mono",value:i.url,onChange:G=>o(ne=>({...ne,url:G.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"af-set-label",children:["Command",s.jsx("input",{className:"af-set-input af-set-input--mono",value:i.command,onChange:G=>o(ne=>({...ne,command:G.target.value})),placeholder:"uvx"})]}),s.jsxs("label",{className:"af-set-label",children:["Args,每行一个",s.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:i.argsText,onChange:G=>o(ne=>({...ne,argsText:G.target.value})),placeholder:`mcp-server-example
|
|
320
|
+
--flag`})]})]}),s.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",s.jsx("input",{className:"af-set-input",value:i.description,onChange:G=>o(ne=>({...ne,description:G.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),s.jsx(BC,{title:"Headers",rows:i.headerRows,onChange:G=>o(ne=>({...ne,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),s.jsx(BC,{title:"Env",rows:i.envRows,onChange:G=>o(ne=>({...ne,envRows:G})),placeholderKey:"TOKEN",placeholderValue:"..."}),s.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",s.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:i.extraJson,onChange:G=>o(ne=>({...ne,extraJson:G.target.value}))})]})]}),s.jsxs("div",{className:"af-mcp-actions",children:[s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:B,disabled:p,children:"清空"}),s.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:W,disabled:p,children:p?"保存中...":"保存 MCP"})]})]})]})]})})]})}function joe(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 i=String((e==null?void 0:e.scheduleNodeId)||"").trim();i&&n.set("focusNodeId",i)}return`/workspace?${n.toString()}`}function HC(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function VC(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 Noe(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function _oe(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 Coe(){const{navigate:e}=ls(),[t,n]=m.useState([]),[r,i]=m.useState(!1),[o,a]=m.useState(""),[l,c]=m.useState(""),u=m.useCallback(async()=>{i(!0),a("");try{const d=await fetch("/api/schedules"),h=await d.json().catch(()=>({}));if(!d.ok)throw new Error(h.error||"读取定时任务失败");n(Array.isArray(h.schedules)?h.schedules:[])}catch(d){a(String(d.message||d)),n([])}finally{i(!1)}},[]);m.useEffect(()=>{u()},[u]);const p=m.useCallback(async d=>{const h=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`;c(h),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:d.kind,flowId:d.flowId,flowSource:d.flowSource||"user",scheduleNodeId:d.scheduleNodeId||"",enabled:!d.enabled})}),v=await y.json().catch(()=>({}));if(!y.ok||v.success===!1)throw new Error(v.error||"更新定时任务失败");await u()}catch(y){a(String(y.message||y))}finally{c("")}},[u]),f=m.useMemo(()=>{const d=t.filter(y=>y.enabled).length,h=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:d,workspace:h,pipeline:t.length-h}},[t]);return s.jsxs("div",{className:"af-settings-page af-schedules-page",children:[s.jsxs("div",{className:"af-settings-top",children:[s.jsxs("div",{className:"af-settings-crumb",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"定时任务"})]}),s.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner",children:[s.jsxs("section",{className:"af-settings-hero",children:[s.jsx("h1",{className:"af-settings-h1",children:"定时任务"}),s.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),s.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[s.jsxs("div",{children:[s.jsx("span",{children:"全部"}),s.jsx("strong",{children:f.total})]}),s.jsxs("div",{children:[s.jsx("span",{children:"启用中"}),s.jsx("strong",{children:f.enabled})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Workspace"}),s.jsx("strong",{children:f.workspace})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Pipeline"}),s.jsx("strong",{children:f.pipeline})]})]}),o?s.jsx("div",{className:"af-schedules-error",children:o}):null,r?s.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?s.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,s.jsx("div",{className:"af-schedules-list",children:t.map(d=>{const h=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`,y=l===h,v=joe(d);return s.jsxs("article",{className:"af-schedule-card",children:[s.jsxs("div",{className:"af-schedule-card__main",children:[s.jsxs("div",{className:"af-schedule-card__title-row",children:[s.jsx("strong",{children:d.label||d.flowId||"-"}),s.jsx("span",{className:`af-schedule-badge af-schedule-badge--${d.kind||"pipeline"}`,children:Noe(d)}),s.jsx("span",{className:`af-schedule-state ${d.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:_oe(d)})]}),s.jsxs("div",{className:"af-schedule-card__meta",children:[s.jsx("span",{children:d.flowId||"-"}),s.jsx("span",{children:d.flowSource||"user"}),d.scheduleNodeId?s.jsx("span",{children:d.scheduleNodeId}):null]}),s.jsxs("div",{className:"af-schedule-card__grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Cron"}),s.jsx("strong",{children:d.cron||"-"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"时区"}),s.jsx("strong",{children:d.timezone||"Asia/Shanghai"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"下次执行"}),s.jsx("strong",{children:VC(d.nextRunAt)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"最近执行"}),s.jsx("strong",{children:VC(d.lastTriggeredAt)})]})]}),d.lastError?s.jsx("p",{className:"af-schedule-card__error",children:d.lastError}):null]}),s.jsxs("div",{className:"af-schedule-card__actions",children:[v?s.jsxs("button",{type:"button",className:"af-schedule-open",title:HC(d),onClick:()=>e(v),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),HC(d)]}):null,s.jsxs("button",{type:"button",className:d.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":d.enabled,title:d.enabled?"点击停用":"点击启用",onClick:()=>void p(d),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":d.enabled?"toggle_on":"toggle_off"}),d.enabled?"已启用":"已停用"]})]})]},h)})})]})})]})}const KC={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 qC(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 Aoe(e){var c,u,p,f,d,h,y,v,b,g,k,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],i=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((p=(u=t.ui)==null?void 0:u.card)==null?void 0:p.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(_=>[`input.${_.name||"-"}`,`${_.type||"text"}${_.required?" · required":""}${_.default?` · default: ${_.default}`:""}`]),...i.map(_=>[`output.${_.name||"-"}`,_.type||"text"]),...o.map(_=>[`config.${_.key||"-"}`,_.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((d=t.runtime)==null?void 0:d.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(b=t.ui)==null?void 0:b.card)==null?void 0:g.icon)||"extension"],...a.map(_=>[`action.${_.id||_.label||"-"}`,_.variant||_.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([_,S])=>[`sample.${_}`,String(S)]),["last run",`${((k=e==null?void 0:e.test)==null?void 0:k.status)||"not run"}${(x=e==null?void 0:e.test)!=null&&x.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function Eoe(){var L,$,V,B,F,R,H;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[i,o]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[p,f]=m.useState(!1),[d,h]=m.useState(""),y=e||KC,v=m.useMemo(()=>Aoe(y),[y]),b=m.useMemo(()=>v.find(A=>A.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((L=y==null?void 0:y.test)==null?void 0:L.inputs)||{},_=Array.isArray(($=y==null?void 0:y.test)==null?void 0:$.log)?y.test.log:[],S=((B=(V=g.ui)==null?void 0:V.card)==null?void 0:B.icon)||"event_repeat",N=((R=(F=g.ui)==null?void 0:F.card)==null?void 0:R.variant)||"default",I=k.enabled===!0,T=m.useCallback(async()=>{var A;l(!0),u("");try{const X=await fetch("/api/node-studio/drafts"),K=await X.json().catch(()=>({}));if(!X.ok)throw new Error(K.error||"读取节点草稿失败");const W=Array.isArray(K.drafts)?K.drafts[0]:null;if(!(W!=null&&W.id)){t(null),h("");return}const te=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(W.id)}`),ee=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ee.error||"读取节点草稿失败");t(ee.draft||null),h(String(((A=ee.draft)==null?void 0:A.promptDraft)||""))}catch(X){u(String(X.message||X))}finally{l(!1)}},[]);m.useEffect(()=>{T()},[T]);const z=m.useCallback(async(A={})=>{var X;f(!0),u("");try{const K=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",...A})}),W=await K.json().catch(()=>({}));if(!K.ok||W.ok===!1)throw new Error(W.error||"保存节点草稿失败");t(W.draft||e),h(String(((X=W.draft||e)==null?void 0:X.promptDraft)||""))}catch(K){u(String(K.message||K))}finally{f(!1)}},[e]),E=()=>{o(!0),window.setTimeout(()=>o(!1),900)},O=A=>{const X={...k,enabled:A};t(K=>({...K||KC,config:X})),z({config:{enabled:A}})},D=()=>{z({promptDraft:d,appendUserMessage:!0})};return s.jsxs("div",{className:"af-node-studio-page",children:[s.jsxs("header",{className:"af-node-studio-top",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-settings-crumb",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"Node Studio"})]}),s.jsx("h1",{children:"节点编辑器"})]}),s.jsxs("div",{className:"af-node-studio-actions",children:[s.jsxs("button",{type:"button",onClick:()=>void T(),disabled:a,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),s.jsxs("button",{type:"button",onClick:E,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"sync":"science"}),"Test"]}),s.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),s.jsxs("main",{className:"af-node-studio-shell",children:[s.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[s.jsxs("div",{className:"af-node-studio-panel-head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),s.jsx("strong",{children:"AI Agent"})]}),c?s.jsx("div",{className:"af-node-studio-error",children:c}):null,s.jsxs("div",{className:"af-node-studio-thread",children:[e?null:s.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(y==null?void 0:y.agentMessages)?y.agentMessages:[]).map((A,X)=>s.jsx("div",{className:A.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:A.text||""},`${A.role||"message"}-${X}`)),s.jsxs("div",{className:"af-node-studio-agent-tools",children:[s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),s.jsxs("label",{className:"af-node-studio-prompt",children:[s.jsx("span",{children:"需求"}),s.jsx("textarea",{value:d,onChange:A=>h(A.target.value)})]}),s.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:p,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:p?"sync":"send"}),p?"Saving":"Send"]})]}),s.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[s.jsxs("div",{className:"af-node-studio-panel-head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),s.jsx("strong",{children:"Preview / Test"})]}),s.jsxs("div",{className:"af-node-studio-preview-grid",children:[s.jsx("div",{className:"af-node-studio-preview-stage",children:e?N==="schedule"?s.jsxs("div",{className:"af-node-preview-card",children:[s.jsxs("div",{className:"af-node-preview-card__head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S}),s.jsx("strong",{children:y.title||g.name||"Untitled Node"}),s.jsx("code",{children:qC(y)})]}),s.jsxs("label",{className:"af-node-preview-toggle",children:[s.jsx("input",{type:"checkbox",checked:I,onChange:A=>O(A.target.checked)}),s.jsx("span",{children:I?"定时开启":"定时关闭"})]}),s.jsxs("div",{className:"af-node-preview-fields",children:[s.jsxs("label",{children:[s.jsx("span",{children:"频率"}),s.jsxs("select",{value:k.scheduleType||"daily",onChange:A=>z({config:{scheduleType:A.target.value}}),children:[s.jsx("option",{value:"daily",children:"每天"}),s.jsx("option",{value:"weekly",children:"每周"})]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"时间"}),s.jsxs("div",{children:[s.jsxs("select",{value:k.hour||"09",onChange:A=>z({config:{hour:A.target.value}}),children:[s.jsx("option",{children:"09"}),s.jsx("option",{children:"10"})]}),s.jsxs("select",{value:k.minute||"00",onChange:A=>z({config:{minute:A.target.value}}),children:[s.jsx("option",{children:"00"}),s.jsx("option",{children:"30"})]})]})]})]}),s.jsxs("div",{className:"af-node-preview-meta",children:[s.jsxs("span",{children:[k.scheduleType==="weekly"?"每周":"每天"," ",k.hour||"09",":",k.minute||"00"]}),s.jsx("span",{children:"Next -"}),s.jsx("span",{children:I?"enabled":"disabled"})]}),s.jsxs("div",{className:"af-node-preview-actions",children:[s.jsxs("button",{type:"button",className:"af-node-preview-run",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):s.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[s.jsxs("div",{className:"af-node-preview-card__head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S}),s.jsx("strong",{children:y.title||g.name||"Untitled Node"}),s.jsx("code",{children:qC(y)})]}),s.jsxs("div",{className:"af-node-preview-default-body",children:[s.jsx("p",{children:g.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),s.jsxs("div",{children:[s.jsxs("span",{children:[Array.isArray(g.inputs)?g.inputs.length:0," inputs"]}),s.jsxs("span",{children:[Array.isArray(g.outputs)?g.outputs.length:0," outputs"]}),s.jsx("span",{children:((H=g.runtime)==null?void 0:H.type)||g.baseDefinitionId||"agent_subAgent"})]})]})]}):s.jsxs("div",{className:"af-node-preview-empty",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),s.jsx("strong",{children:"暂无预览"}),s.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),s.jsxs("div",{className:"af-node-studio-test",children:[s.jsxs("div",{className:"af-node-studio-subhead",children:[s.jsx("strong",{children:"Test Inputs"}),s.jsxs("button",{type:"button",onClick:E,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"sync":"play_arrow"}),"Run"]})]}),s.jsxs("div",{className:"af-node-studio-inputs",children:[s.jsxs("label",{children:[s.jsx("span",{children:"project"}),s.jsx("input",{value:x.project||"",readOnly:!0,placeholder:"-"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"date"}),s.jsx("input",{value:x.date||"",readOnly:!0,placeholder:"-"})]})]}),s.jsx("div",{className:"af-node-studio-log",children:(i?["running..."]:_.length?_:["No test run yet."]).map((A,X)=>s.jsx("span",{children:A},`${A}-${X}`))})]})]})]}),s.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[s.jsxs("div",{className:"af-node-studio-panel-head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),s.jsx("strong",{children:"Internals"})]}),s.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:v.map(A=>s.jsxs("button",{type:"button",className:A.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(A.id),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:A.icon}),A.label]},A.id))}),s.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([A,X])=>s.jsxs("div",{className:"af-node-studio-internal-row",children:[s.jsx("span",{children:A}),s.jsx("strong",{children:X})]},A))}),s.jsx("pre",{className:"af-node-studio-code",children:b.id==="ui"?JSON.stringify(g.ui||{},null,2):b.id==="contract"?JSON.stringify({inputs:g.inputs||[],outputs:g.outputs||[],configSchema:g.configSchema||{}},null,2):b.id==="tests"?JSON.stringify((y==null?void 0:y.test)||{},null,2):JSON.stringify({runtime:g.runtime||{},files:(y==null?void 0:y.files)||{}},null,2)})]})]})]})}function Ioe(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Poe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Rh(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 Toe(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 Ow(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function rh(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 Roe(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||Rh(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 Qi(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 Moe({ok:e}){return s.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function UC({item:e,selected:t,onClick:n,readOnly:r}){return s.jsxs("button",{type:"button",className:"af-workspaces-card"+(t?" af-workspaces-card--selected":""),onClick:n,children:[s.jsxs("div",{className:"af-workspaces-card__head",children:[s.jsx("strong",{children:e.label||"知识库"}),s.jsx("span",{children:e.kind==="git"?"Git":"Local"})]}),s.jsx("p",{children:e.description||e.repoUrl||e.path||"-"}),s.jsxs("div",{className:"af-workspaces-card__meta",children:[s.jsx(Moe,{ok:e.exists!==!1}),s.jsx("span",{children:e.exists===!1?"路径未就绪":"路径可用"}),r?s.jsx("em",{children:"内置"}):e.enabled===!1?s.jsx("em",{children:"disabled"}):null]})]})}function $oe(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[i,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(""),[p,f]=m.useState(""),[d,h]=m.useState([]),[y,v]=m.useState([]),[b,g]=m.useState(Ow),[k,x]=m.useState(""),[_,S]=m.useState([]),[N,I]=m.useState(""),T=m.useMemo(()=>y.findIndex((K,W)=>Qi(K,W)===N),[y,N]),E=!!m.useMemo(()=>d.find((K,W)=>Qi(K,W)===N)||null,[d,N]),O=m.useMemo(()=>{const K=String(b.credentialRef||"").trim();return K?_.some(W=>String((W==null?void 0:W.key)||"").trim()===K&&String((W==null?void 0:W.value)??"")!==""):!1},[b.credentialRef,_]),D=m.useCallback(async()=>{t(!0),l("");try{const[K,W]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),te=await K.json().catch(()=>({})),ee=await W.json().catch(()=>({}));if(!W.ok)throw new Error(typeof ee.error=="string"?ee.error:"ENV HTTP "+W.status);if(!K.ok)throw new Error(typeof te.error=="string"?te.error:"HTTP "+K.status);const G=Array.isArray(te.workspaces)?te.workspaces:[],ne=Array.isArray(te.customWorkspaces)?te.customWorkspaces:[];f(String(te.path||"")),h(G.filter(re=>re==null?void 0:re.builtin)),v(ne),S(Array.isArray(ee.env)?ee.env.map(re=>({key:String((re==null?void 0:re.key)||""),value:String((re==null?void 0:re.value)??"")})):[])}catch(K){l(String(K.message||K))}finally{t(!1)}},[]);m.useEffect(()=>{D()},[D]);const L=m.useCallback(async(K,W="")=>{r(!0),l(""),u("");try{const te=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:K})}),ee=await te.json().catch(()=>({}));if(!te.ok)throw new Error(typeof ee.error=="string"?ee.error:"HTTP "+te.status);const G=Array.isArray(ee.customWorkspaces)?ee.customWorkspaces:K;v(G),h((Array.isArray(ee.workspaces)?ee.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin)),f(String(ee.path||p)),W&&I(W),u("已保存")}catch(te){l(String(te.message||te))}finally{r(!1)}},[p]),$=m.useCallback(()=>{I(""),g(Ow()),x(""),u(""),l("")},[]),V=m.useCallback((K,W)=>{I(Qi(K,W)),g(rh(K)),x(""),u("")},[]),B=m.useCallback((K,W)=>{I(Qi(K,W)),g(rh(K)),x(""),u("")},[]),F=m.useCallback(async(K,W)=>{const te=String(K||"").trim(),ee=String(W??"");if(!te||!ee)return;const G=_.filter(ie=>String((ie==null?void 0:ie.key)||"").trim()!==te);G.push({key:te,value:ee});const ne=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:G})}),re=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(typeof re.error=="string"?re.error:"ENV HTTP "+ne.status);S(Array.isArray(re.env)?re.env.map(ie=>({key:String((ie==null?void 0:ie.key)||""),value:String((ie==null?void 0:ie.value)??"")})):G)},[_]),R=m.useCallback(()=>{const K=Roe({...b,id:b.id||Ioe()}),W=k.trim();if(K.kind==="git"&&W&&!K.credentialRef&&(K.credentialRef=Toe(b,K)),K.kind==="local"&&!K.path){l("本地知识库需要填写路径");return}if(K.kind==="git"&&!K.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!K.label){l("请填写名称");return}if(K.kind==="git"&&K.credentialRef&&!Poe(K.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const te=T>=0?y.map((ee,G)=>G===T?K:ee):[K,...y];g(rh(K)),(async()=>{r(!0);try{W&&await F(K.credentialRef,W),x(""),await L(te,Qi(K))}catch(ee){l(String(ee.message||ee)),r(!1)}})()},[y,b,L,F,T,k]),H=m.useCallback(()=>{if(T<0)return;const K=y.filter((W,te)=>te!==T);g(Ow()),I(""),L(K)},[y,L,T]),A=m.useCallback(async()=>{if(!E){if(T<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}o(!0),l(""),u("");try{const K=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),W=await K.json().catch(()=>({}));if(!K.ok)throw new Error(typeof W.error=="string"?W.error:"HTTP "+K.status);const te=Array.isArray(W.customWorkspaces)?W.customWorkspaces:y;v(te),h((Array.isArray(W.workspaces)?W.workspaces:[]).filter(ne=>ne==null?void 0:ne.builtin));const ee=te.find(ne=>String((ne==null?void 0:ne.id)||"")===String(b.id||""));ee&&g(rh(ee));const G=String(W.commit||"").trim();u(W.changed?`已拉取更新${G?`:${G.slice(0,8)}`:""}`:`已是最新${G?`:${G.slice(0,8)}`:""}`)}catch(K){l(String(K.message||K))}finally{o(!1)}}},[y,b,E,T]),X=m.useCallback(K=>{g(W=>({...W,...K}))},[]);return s.jsxs("div",{className:"af-workspaces-page",children:[s.jsxs("header",{className:"af-settings-top",children:[s.jsxs("div",{className:"af-settings-crumb","aria-label":"知识库",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"知识库"})]}),s.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:D,disabled:e,children:[s.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),s.jsx("main",{className:"af-settings-body",children:s.jsxs("div",{className:"af-workspaces-inner",children:[s.jsxs("header",{className:"af-settings-hero",children:[s.jsx("h1",{className:"af-settings-h1",children:"知识库"}),s.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),p?s.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",p]}):null,a?s.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?s.jsx("p",{className:"af-workspaces-status",children:c}):null]}),s.jsxs("section",{className:"af-workspaces-summary",children:[s.jsxs("div",{children:[s.jsx("span",{children:"内置"}),s.jsx("strong",{children:d.length})]}),s.jsxs("div",{children:[s.jsx("span",{children:"自定义"}),s.jsx("strong",{children:y.length})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Git"}),s.jsx("strong",{children:y.filter(K=>K.kind==="git").length})]})]}),s.jsxs("div",{className:"af-workspaces-layout",children:[s.jsxs("section",{className:"af-workspaces-list",children:[s.jsxs("div",{className:"af-workspaces-section-head",children:[s.jsx("h2",{children:"自定义知识库"}),s.jsxs("button",{type:"button",onClick:$,children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]}),y.length?y.map((K,W)=>s.jsx(UC,{item:K,selected:Qi(K,W)===N,onClick:()=>V(K,W)},Qi(K,W))):s.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义知识库。新增 Git 或本地目录后,画布里的加载知识库和一键任务就可以选择它。"}),s.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:s.jsx("h2",{children:"内置知识库"})}),d.map((K,W)=>s.jsx(UC,{item:K,selected:Qi(K,W)===N,onClick:()=>B(K,W),readOnly:!0},Qi(K,W)))]}),s.jsxs("section",{className:"af-workspaces-editor",children:[s.jsxs("div",{className:"af-workspaces-editor__head",children:[s.jsxs("div",{children:[s.jsx("h2",{children:E?"查看内置知识库":T>=0?"编辑知识库":"新增知识库"}),s.jsx("p",{children:E?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),s.jsxs("label",{className:"af-workspaces-switch",children:[s.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:E,onChange:K=>X({enabled:K.target.checked})}),s.jsx("span",{children:"启用"})]})]}),s.jsxs("div",{className:"af-workspaces-kind",children:[s.jsxs("button",{type:"button",className:b.kind==="git"?"active":"",disabled:E,onClick:()=>X({kind:"git",type:b.type==="local"?"code":b.type}),children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),s.jsxs("button",{type:"button",className:b.kind==="local"?"active":"",disabled:E,onClick:()=>X({kind:"local",type:"local"}),children:[s.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),s.jsxs("div",{className:"af-workspaces-form",children:[s.jsxs("label",{children:[s.jsx("span",{children:"名称"}),s.jsx("input",{value:b.label,disabled:E,onChange:K=>X({label:K.target.value}),placeholder:"Likee Android"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"类型"}),s.jsxs("select",{value:b.type,disabled:E,onChange:K=>X({type:K.target.value}),children:[s.jsx("option",{value:"code",children:"code"}),s.jsx("option",{value:"docs",children:"docs"}),s.jsx("option",{value:"analytics",children:"analytics"}),s.jsx("option",{value:"config",children:"config"}),s.jsx("option",{value:"local",children:"local"}),s.jsx("option",{value:"other",children:"other"})]})]}),s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"本地路径"}),s.jsx("input",{value:b.path,disabled:E,onChange:K=>X({path:K.target.value}),placeholder:b.kind==="git"?"可空,默认保存到全局资源目录/repos/<仓库名>":"/Users/.../project"})]}),b.kind==="git"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"Git URL"}),s.jsx("input",{value:b.repoUrl,disabled:E,onChange:K=>{const W=K.target.value,te=Rh(b.repoUrl),ee=String(b.mountPath||"").trim();X({repoUrl:W,...!ee||ee===te?{mountPath:Rh(W)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"分支"}),s.jsx("input",{value:b.branch,disabled:E,onChange:K=>X({branch:K.target.value}),placeholder:"master"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"挂载目录"}),s.jsx("input",{value:b.mountPath,disabled:E,onChange:K=>X({mountPath:K.target.value}),placeholder:Rh(b.repoUrl)||"repo_name"})]}),s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"凭证环境变量"}),s.jsx("input",{value:b.credentialRef,disabled:E,onChange:K=>X({credentialRef:K.target.value}),placeholder:"LIKEE_GIT_READONLY_TOKEN"})]}),s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"Token"}),s.jsx("input",{type:"password",value:k,disabled:E,onChange:K=>x(K.target.value),placeholder:O?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 workspace 配置"}),s.jsx("small",{children:"保存后只在知识库配置中保留 credentialRef,token 会写入当前用户的个人环境变量。"})]})]}):null,s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"说明"}),s.jsx("textarea",{value:b.description,disabled:E,onChange:K=>X({description:K.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),s.jsxs("div",{className:"af-workspaces-actions",children:[!E&&T>=0?s.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:H,disabled:n||i,children:[s.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):s.jsx("span",{}),s.jsxs("div",{children:[b.kind==="git"&&T>=0?s.jsxs("button",{type:"button",onClick:A,disabled:E||n||i,children:[s.jsx("span",{className:"material-symbols-outlined",children:i?"sync":"download"}),i?"拉取中":"拉取更新"]}):null,s.jsx("button",{type:"button",onClick:$,disabled:n||i,children:"重置"}),s.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:R,disabled:E||n||i,children:[s.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const l$="agentflow.workflows.scopeView",qa=8,GC=24;function Loe(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(l$)==="team"?"team":"personal"}catch{return"personal"}}function Ooe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}function Doe(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleDateString([],{year:"numeric",month:"2-digit",day:"2-digit"}):"日期待定"}function Foe(e){return Object.values((e==null?void 0:e.dimensions)||{}).flatMap(t=>Array.isArray(t)?t:[t]).map(t=>String(t||"").trim()).filter(Boolean).join(" · ")}function zoe(e){const t=Number((e==null?void 0:e.workflowCount)||0),n=Number((e==null?void 0:e.completedCount)||0);if(t>0&&n>=t)return{key:"completed",label:"已完成"};const r=Date.parse(String((e==null?void 0:e.date)||""));return Number.isFinite(r)&&r<Date.now()?{key:"overdue",label:"已到期"}:{key:"planned",label:"计划中"}}function Ta(e){const t=new Date;return t.setHours(12,0,0,0),t.setDate(t.getDate()+e),t.toISOString().slice(0,10)}function Woe(e){const t=Array.isArray(e)?e.length:0;if(t<=qa)return{start:0,end:t};const n=Date.now();let r=e.findIndex(o=>{const a=Date.parse(String((o==null?void 0:o.date)||""));return Number.isFinite(a)&&a>=n});r<0&&(r=t-1);const i=Math.max(0,Math.min(r-3,t-qa));return{start:i,end:Math.min(t,i+qa)}}function Boe(){const e=[{key:"prd-flow:version:android-5.62.0",kind:"version",id:"android-5.62.0",title:"Likee Android 5.62.0",date:Ta(-12),source:"prd-flow",dimensions:{platform:"Android"}},{key:"prd-flow:version:android-5.63.0",kind:"version",id:"android-5.63.0",title:"Likee Android 5.63.0",date:Ta(6),source:"prd-flow",dimensions:{platform:"Android"}},{key:"prd-flow:version:ios-5.63.0",kind:"version",id:"ios-5.63.0",title:"Likee iOS 5.63.0",date:Ta(10),source:"prd-flow",dimensions:{platform:"iOS"}},{key:"prd-flow:milestone:august-gray",kind:"milestone",id:"august-gray",title:"8 月灰度窗口",date:Ta(18),source:"prd-flow",dimensions:{channel:"灰度"}},...Array.from({length:12},(i,o)=>({key:`prd-flow:version:android-5.${50+o}.0`,kind:"version",id:`android-5.${50+o}.0`,title:`Likee Android 5.${50+o}.0`,date:Ta(-180+o*14),source:"prd-flow",dimensions:{platform:"Android"}})),...Array.from({length:8},(i,o)=>({key:`prd-flow:version:android-5.${64+o}.0`,kind:"version",id:`android-5.${64+o}.0`,title:`Likee Android 5.${64+o}.0`,date:Ta(32+o*14),source:"prd-flow",dimensions:{platform:"Android"}}))],t=Object.fromEntries(e.map(i=>[i.key,i])),n=[{id:"demo-1",tapdId:"1020124",title:"Likee Android AI Runtime Hook Skill 搭建",pointer:"继续实现 Android Action 与通用 Hook 多层注入平台",phase:"IMPLEMENTATION_IN_PROGRESS",state:"active",role:"owner",ownerUsername:"wangfang",issueCount:2,platforms:["android"],actionCount:5,completedActionCount:4,latestAction:{title:"Android 实现协议已确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:android-5.63.0"]],demo:!0},{id:"demo-2",tapdId:"1013667",title:"激励视频增收方案",pointer:"检查并选择 TAPD 未解决 Bug",phase:"BUG_SELECTION_READY",state:"blocked",role:"viewer",ownerUsername:"surujija",issueCount:18,platforms:["android","ios"],actionCount:33,completedActionCount:32,latestAction:{title:"等待版本风险确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:android-5.63.0"],t["prd-flow:version:ios-5.63.0"]],demo:!0},{id:"demo-3",tapdId:"1133202860001018940",title:"Likee Android 5.62.0",pointer:"发版上下文已同步",phase:"RELEASED",state:"completed",role:"reporter",ownerUsername:"chenjunlun",issueCount:1,platforms:["ios"],actionCount:1,completedActionCount:1,latestAction:{title:"版本发布完成",at:Ta(-12)},timeline:[t["prd-flow:version:android-5.62.0"]],demo:!0},{id:"demo-4",tapdId:"1015046",title:"Remote Config 拉取频控",pointer:"双端方案进入提测准备",phase:"SUBMIT_TEST",state:"active",role:"owner",ownerUsername:"alice",issueCount:4,platforms:["android","ios"],actionCount:8,completedActionCount:6,latestAction:{title:"测试用例已归档",at:new Date().toISOString()},timeline:[t["prd-flow:version:ios-5.63.0"],t["prd-flow:milestone:august-gray"]],demo:!0},{id:"demo-5",tapdId:"1027788",title:"直播间礼物动效治理",pointer:"等待确认目标版本",phase:"PLANNING",state:"active",role:"editor",ownerUsername:"bob",issueCount:3,platforms:["all"],actionCount:4,completedActionCount:1,latestAction:{title:"技术方案评审中",at:new Date().toISOString()},timeline:[],demo:!0},...e.slice(4).map((i,o)=>({id:`demo-timeline-${o+1}`,tapdId:`DEMO-${String(o+1).padStart(3,"0")}`,title:`${i.title} 版本事项`,pointer:o<12?"历史版本事项已归档":"等待进入版本排期",phase:o<12?"RELEASED":"PLANNING",state:o<12?"completed":"active",role:o%3===0?"owner":"reporter",ownerUsername:o%3===0?"wangfang":"demo-user",issueCount:o%4+1,platforms:["android"],actionCount:4,completedActionCount:o<12?4:1,latestAction:{title:o<12?"版本归档完成":"版本排期已同步",at:i.date},timeline:[i],demo:!0}))],r=e.map(i=>{const o=n.filter(a=>a.timeline.some(l=>l.key===i.key));return{...i,workflowCount:o.length,completedCount:o.filter(a=>a.state==="completed").length,blockedCount:o.filter(a=>a.state==="blocked").length,workflowIds:o.map(a=>a.id)}}).sort((i,o)=>Date.parse(i.date)-Date.parse(o.date));return{workflows:n,timeline:r,unassignedCount:1}}function Hoe(e){return e==="owner"?"我创建的":e==="reporter"||e==="editor"?"可上报":e==="viewer"?"只读协作":"可访问"}function c$(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function u$(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function Voe(e){const t=new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||""),returnTo:"/workflows"});return e!=null&&e.demo&&t.set("workflowDemo","1"),`/workspace?${t.toString()}`}function Koe(e){var u,p,f;const t=String((e==null?void 0:e.tapdId)||"DEMO"),n=u$(((u=e==null?void 0:e.platforms)==null?void 0:u[0])||"all")||"双端",r=((p=e==null?void 0:e.timeline)==null?void 0:p[0])||{},i=[["方案已确认","需求范围和实现方案已完成确认。"],["研发任务已创建","Issue 与研发分支信息已经同步。"],["实现进度已更新","实现状态和当前风险已归档。"],["测试状态已更新","自测、提测状态已经同步。"],["版本归属已确认","版本排期和发布上下文已经确认。"]],o=Math.min(5,Math.max(1,Number((e==null?void 0:e.actionCount)||1))),a=Number((e==null?void 0:e.actionCount)||0)>0?Number((e==null?void 0:e.completedActionCount)||0)/Number(e.actionCount):0,l=Math.round(o*a),c=i.slice(0,o).map(([d,h],y)=>({id:`demo-action-${y+1}`,actionId:`demo-action-${y+1}`,stageKey:["plan","issue","implementation","test","release"][y],title:d,detail:h,status:y<l?"done":y===l?"current":"pending",issueKey:`demo-${t.toLowerCase()}`,platform:n,updatedAt:new Date(Date.now()-(o-y)*45*60*1e3).toISOString()}));return{revision:`demo-${t}`,phase:(e==null?void 0:e.phase)||"PLANNING",pointer:(e==null?void 0:e.pointer)||((f=e==null?void 0:e.latestAction)==null?void 0:f.title)||"本地 Workflow 示例",actions:c,issues:Array.from({length:Math.min(4,Math.max(1,Number((e==null?void 0:e.issueCount)||1)))},(d,h)=>({key:`demo-${t.toLowerCase()}-${h+1}`,title:h===0?(e==null?void 0:e.title)||"示例研发事项":`子任务 ${h+1}`,platform:n,status:(e==null?void 0:e.state)==="completed"?"done":h===0?"in_progress":"pending",epicKey:"示例需求"})),globalState:{title:(e==null?void 0:e.title)||`TAPD ${t}`,status:{label:c$(e==null?void 0:e.state)},workflow:{namespace:"tapd",id:t},sections:{version:{title:"版本归属",fields:{version:{label:"版本",type:"text",value:r.title||"待归属"},date:{label:"版本日期",type:"text",value:r.date||"待确认"},platform:{label:"平台",type:"chips",value:[n]}}},progress:{title:"研发进度",fields:{actions:{label:"Action",type:"text",value:`${(e==null?void 0:e.completedActionCount)||0}/${(e==null?void 0:e.actionCount)||0}`},issues:{label:"Issues",type:"text",value:String((e==null?void 0:e.issueCount)||0)},owner:{label:"Owner",type:"user",value:(e==null?void 0:e.ownerUsername)||"demo-user"}}}}},runtimeEvents:c.map(d=>({...d,type:"demo-runtime-event"})),demo:!0}}function qoe(e,t){if(t!=null&&t.demo)try{window.sessionStorage.setItem(`agentflow.workflow.demo:${t.tapdId}`,JSON.stringify(Koe(t)))}catch{}e(Voe(t))}function Uoe(){const{navigate:e}=ls(),[t,n]=m.useState([]),[r,i]=m.useState([]),[o,a]=m.useState(0),[l,c]=m.useState("all"),[u,p]=m.useState(Loe),[f,d]=m.useState(null),[h,y]=m.useState(!1),[v,b]=m.useState(""),[g,k]=m.useState(""),[x,_]=m.useState("all"),[S,N]=m.useState("all"),[I,T]=m.useState(!1),[z,E]=m.useState({start:0,end:0}),O=m.useRef(null),D=m.useRef(null),L=m.useRef(!1),$=m.useRef(0),V=m.useRef(0),B=m.useCallback(async()=>{T(!1),y(!0),b("");try{const ee=await fetch(`/api/prd-workflows?view=${encodeURIComponent(u)}`),G=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(G.error||"读取迭代列表失败");const ne=Array.isArray(G.workflows)?G.workflows:[],re=Array.isArray(G.timeline)?G.timeline:[];n(ne),i(re),a(Number(G.unassignedCount||0)),c(ie=>ie==="all"||ie==="unassigned"&&Number(G.unassignedCount||0)>0||re.some(Z=>Z.key===ie)?ie:"all"),d(G.team||null)}catch(ee){b(String(ee.message||ee)),n([]),i([]),a(0),c("all"),d(null)}finally{y(!1)}},[u]),F=m.useCallback(()=>{const ee=Boe();n(ee.workflows),i(ee.timeline),a(ee.unassignedCount),c("all"),k(""),_("all"),N("all"),b(""),T(!0)},[]);m.useEffect(()=>{B()},[B]),m.useEffect(()=>{try{localStorage.setItem(l$,u)}catch{}},[u]),m.useEffect(()=>{E(Woe(r))},[r]),m.useLayoutEffect(()=>{const ee=D.current,G=O.current;if(G){if(ee){D.current=null;const ne=Array.from(G.children).find(re=>re.dataset.timelineKey===ee.key);ne&&(G.scrollLeft=ee.scrollLeft+ne.offsetLeft-ee.offsetLeft)}window.clearTimeout($.current),$.current=window.setTimeout(()=>{L.current=!1},80)}},[z]),m.useEffect(()=>()=>{window.clearTimeout($.current),window.cancelAnimationFrame(V.current)},[]);const R=m.useMemo(()=>r.slice(z.start,z.end),[r,z]),H=z.start>0,A=z.end<r.length,X=m.useCallback(()=>{if(!H||L.current)return;L.current=!0;const ee=O.current,G=ee==null?void 0:ee.querySelector("[data-timeline-key]");D.current=G?{key:G.dataset.timelineKey,offsetLeft:G.offsetLeft,scrollLeft:ee.scrollLeft}:null,E(ne=>({start:Math.max(0,ne.start-qa),end:Math.min(ne.end,Math.max(0,ne.start-qa)+GC)}))},[H]),K=m.useCallback(()=>{if(!A||L.current)return;L.current=!0;const ee=O.current,G=ee==null?void 0:ee.querySelectorAll("[data-timeline-key]"),ne=G==null?void 0:G[G.length-1];D.current=ne?{key:ne.dataset.timelineKey,offsetLeft:ne.offsetLeft,scrollLeft:ee.scrollLeft}:null,E(re=>({start:Math.max(re.start,Math.min(r.length,re.end+qa)-GC),end:Math.min(r.length,re.end+qa)}))},[A,r.length]),W=m.useCallback(ee=>{const G=ee.currentTarget;V.current||(V.current=window.requestAnimationFrame(()=>{V.current=0,!L.current&&(G.scrollLeft<=32?X():G.scrollLeft+G.clientWidth>=G.scrollWidth-32&&K())}))},[X,K]),te=m.useMemo(()=>{const ee=g.trim().toLowerCase();return t.filter(G=>{var ne;return l==="unassigned"&&(G.timeline||[]).length>0||l!=="all"&&l!=="unassigned"&&!(G.timeline||[]).some(re=>re.key===l)||x==="owned"&&G.role!=="owner"||x==="collaborating"&&G.role==="owner"||S!=="all"&&G.state!==S?!1:ee?[G.tapdId,G.title,G.pointer,G.phase,G.ownerUsername,(ne=G.latestAction)==null?void 0:ne.title,...(G.timeline||[]).flatMap(re=>[re.title,re.kind,re.date,...Object.values(re.dimensions||{})])].some(re=>String(re||"").toLowerCase().includes(ee)):!0})},[g,x,S,l,t]);return s.jsx("div",{className:"af-settings-page af-workflows-page",children:s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner af-workflows-inner",children:[s.jsxs("section",{className:"af-settings-hero af-workflows-hero",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-workflows-eyebrow",children:"Workflow Dashboard"}),s.jsx("h1",{className:"af-settings-h1",children:"迭代"}),s.jsx("p",{className:"af-settings-lead",children:u==="team"?`汇总${f!=null&&f.name?`「${f.name}」`:"当前团队"}的需求 Workflow,按负责人追踪进度与风险。`:"集中查看我创建和参与的需求 Workflow,追踪阶段、Action 进度与最新动态。"})]}),s.jsxs("div",{className:"af-workflows-hero-actions",children:[s.jsxs("button",{type:"button",className:"af-workflows-guide-link",onClick:()=>e("/workflow-report"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"integration_instructions"}),"接入说明"]}),s.jsxs("div",{className:"af-scope-switch","aria-label":"迭代视图",children:[s.jsx("button",{type:"button",className:u==="personal"?"is-active":"",onClick:()=>p("personal"),children:"个人迭代"}),s.jsx("button",{type:"button",className:u==="team"?"is-active":"",onClick:()=>p("team"),children:"团队迭代"})]}),s.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void B(),disabled:h,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:h?"hourglass_empty":"refresh"}),"刷新"]})]})]}),r.length>0||o>0?s.jsxs("section",{className:"af-workflows-timeline","aria-label":"迭代时间线",children:[s.jsxs("div",{className:"af-workflows-timeline__heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"迭代时间线"}),s.jsx("strong",{children:"按排期归属汇总"}),I?s.jsx("em",{children:"本地示例"}):null]}),s.jsxs("div",{className:"af-workflows-timeline__actions",children:[l!=="all"?s.jsx("button",{type:"button",onClick:()=>c("all"),children:"查看全部"}):null,I?s.jsx("button",{type:"button",onClick:()=>void B(),children:"退出示例"}):null]})]}),s.jsxs("div",{className:"af-workflows-timeline__rail",ref:O,onScroll:W,children:[R.map(ee=>{const G=Foe(ee),ne=zoe(ee);return s.jsxs("button",{type:"button","data-timeline-key":ee.key,className:`is-${ne.key}${l===ee.key?" is-active":""}`,"aria-pressed":l===ee.key,onClick:()=>c(re=>re===ee.key?"all":ee.key),children:[s.jsxs("span",{className:"af-workflows-timeline__date",children:[Doe(ee.date),s.jsx("em",{children:ne.label})]}),s.jsx("strong",{children:ee.title||ee.id}),s.jsx("small",{children:[G,`${ee.workflowCount||0} 项`,ee.completedCount?`${ee.completedCount} 项已完成`:"",ee.blockedCount?`${ee.blockedCount} 项需关注`:""].filter(Boolean).join(" · ")})]},ee.key)}),o>0&&!A?s.jsxs("button",{type:"button",className:`af-workflows-timeline__unassigned${l==="unassigned"?" is-active":""}`,"aria-pressed":l==="unassigned",onClick:()=>c(ee=>ee==="unassigned"?"all":"unassigned"),children:[s.jsx("span",{className:"af-workflows-timeline__date",children:"未排期"}),s.jsx("strong",{children:"未归属"}),s.jsxs("small",{children:[o," 项 Workflow"]})]}):null]})]}):null,s.jsxs("section",{className:"af-workflows-toolbar","aria-label":"迭代筛选",children:[s.jsxs("label",{className:"af-workflows-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{value:g,onChange:ee=>k(ee.target.value),placeholder:"搜索 TAPD、需求、阶段或成员","aria-label":"搜索迭代"})]}),s.jsx("div",{className:"af-workflows-segments","aria-label":"协作范围",children:[["all","全部"],["owned","我创建的"],["collaborating","与我协作"]].map(([ee,G])=>s.jsx("button",{type:"button",className:x===ee?"is-active":"","aria-pressed":x===ee,onClick:()=>_(ee),children:G},ee))}),s.jsxs("select",{value:S,onChange:ee=>N(ee.target.value),"aria-label":"迭代状态",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"进行中"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"blocked",children:"需关注"})]})]}),v?s.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,h?s.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!h&&!v&&t.length===0?s.jsxs("div",{className:"af-workflows-empty",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timeline"}),s.jsx("strong",{children:u==="team"&&!f?"尚未加入团队":"暂无迭代"}),s.jsx("p",{children:u==="team"&&!f?"请联系超级管理员完成团队划分。":"当 prd-flow 上报 Workflow 后,它会出现在这里。"}),s.jsxs("button",{type:"button",className:"af-workflows-demo-button",onClick:F,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"science"}),"载入本地示例时间线"]})]}):null,!h&&t.length>0&&te.length===0?s.jsx("div",{className:"af-workflows-message",children:"没有符合当前筛选条件的迭代。"}):null,s.jsx("div",{className:"af-workflows-list",children:te.map(ee=>{var ne,re;const G=ee.actionCount>0?Math.round(ee.completedActionCount/ee.actionCount*100):0;return s.jsxs("article",{className:"af-workflow-card",children:[s.jsxs("div",{className:"af-workflow-card__identity",children:[s.jsxs("div",{className:"af-workflow-card__title-row",children:[s.jsxs("span",{className:"af-workflow-tapd",children:["TAPD ",ee.tapdId]}),s.jsx("span",{className:`af-workflow-state af-workflow-state--${ee.state||"active"}`,children:c$(ee.state)}),s.jsx("span",{className:"af-workflow-role",children:Hoe(ee.role)}),ee.shareActive?s.jsxs("span",{className:"af-workflow-shared",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"已分享"]}):null]}),s.jsx("h2",{children:ee.title||ee.pointer||`需求 ${ee.tapdId}`}),s.jsxs("div",{className:"af-workflow-card__meta",children:[s.jsx("span",{children:ee.phase||"未识别阶段"}),s.jsxs("span",{children:[ee.issueCount||0," Issues"]}),(ee.platforms||[]).map(ie=>s.jsx("span",{children:u$(ie)},ie)),(ee.timeline||[]).map(ie=>s.jsx("span",{children:ie.title||ie.id},ie.key)),s.jsxs("span",{children:["Owner · ",ee.ownerUsername||ee.ownerId||"-"]}),u==="team"&&ee.teamName?s.jsxs("span",{children:["团队 · ",ee.teamName]}):null]})]}),s.jsxs("div",{className:"af-workflow-card__progress",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Action 进度"}),s.jsxs("strong",{children:[ee.completedActionCount||0,"/",ee.actionCount||0]})]}),s.jsx("div",{className:"af-workflow-progress","aria-label":`Action 完成度 ${G}%`,children:s.jsx("span",{style:{width:`${G}%`}})}),s.jsxs("small",{children:[G,"%"]})]}),s.jsxs("div",{className:"af-workflow-card__latest",children:[s.jsx("span",{children:"最新动态"}),s.jsx("strong",{children:((ne=ee.latestAction)==null?void 0:ne.title)||"暂无 Action 记录"}),s.jsx("small",{children:Ooe(((re=ee.latestAction)==null?void 0:re.at)||ee.updatedAt)})]}),s.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>qoe(e,ee),children:[ee.demo?"查看示例":"打开 Workflow",s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ee.demo?"science":"arrow_forward"})]})]},ee.id||ee.tapdId)})})]})})})}const Goe=`skillhub install agentflow-cli --global --agent codex
|
|
321
|
+
skillhub install agentflow-workflow-report --global --agent codex
|
|
322
|
+
|
|
323
|
+
export AGENTFLOW_BASE_URL=http://ai.mengma.bigo.inner
|
|
324
|
+
export AGENTFLOW_TOKEN=<your-token>
|
|
325
|
+
|
|
326
|
+
# 本地联调
|
|
327
|
+
# export AGENTFLOW_BASE_URL=http://127.0.0.1:8765`,Yoe=`{
|
|
328
|
+
"schemaVersion": 1,
|
|
329
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
330
|
+
"source": "my-adapter",
|
|
331
|
+
"action": {
|
|
332
|
+
"key": "requirement-imported",
|
|
333
|
+
"title": "需求已同步",
|
|
334
|
+
"status": "done",
|
|
335
|
+
"occurredAt": "2026-08-05T08:00:00.000Z"
|
|
336
|
+
},
|
|
337
|
+
"expectedVersions": {
|
|
338
|
+
"action:my-adapter:requirement-imported": "absent"
|
|
339
|
+
},
|
|
340
|
+
"idempotencyKey": "requirement-imported:1020124:v1"
|
|
341
|
+
}`,Joe=`# 1. 读取;记录本次要修改 key 的 snapshot.resourceVersions
|
|
342
|
+
node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
|
|
343
|
+
--workflow tapd:1020124 --runtime-only
|
|
344
|
+
|
|
345
|
+
# 2. 将右侧 JSON 保存为 workflow-report.json 后上报
|
|
346
|
+
node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-report \\
|
|
347
|
+
--workflow tapd:1020124 \\
|
|
348
|
+
--file workflow-report.json
|
|
349
|
+
|
|
350
|
+
# 3. 再读一次,确认 action 和对应 resourceVersions 已更新
|
|
351
|
+
node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
|
|
352
|
+
--workflow tapd:1020124 --runtime-only`,Xoe=`GET /api/workflows/state?workflow=tapd%3A1020124&runtimeOnly=1
|
|
353
|
+
Authorization: Bearer <AGENTFLOW_TOKEN>`,Qoe=`{
|
|
354
|
+
"ok": true,
|
|
355
|
+
"workflow": {
|
|
356
|
+
"namespace": "tapd",
|
|
357
|
+
"id": "1020124",
|
|
358
|
+
"key": "tapd:1020124"
|
|
359
|
+
},
|
|
360
|
+
"snapshot": {
|
|
361
|
+
"runtimeRevision": "runtime:<current-revision>",
|
|
362
|
+
"resourceVersions": {
|
|
363
|
+
"action:my-adapter:requirement-imported": "rv:<resource-version>"
|
|
364
|
+
},
|
|
365
|
+
"globalState": {},
|
|
366
|
+
"actions": [],
|
|
367
|
+
"artifacts": [],
|
|
368
|
+
"projections": { "timeline": [] },
|
|
369
|
+
"extensions": {}
|
|
370
|
+
}
|
|
371
|
+
}`,Zoe=`{
|
|
372
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
373
|
+
"authority": {
|
|
374
|
+
"type": "tapd",
|
|
375
|
+
"owner": { "username": "alice" },
|
|
376
|
+
"participants": ["alice", "bob", "carol"],
|
|
377
|
+
"observedAt": "2026-08-05T08:00:00.000Z",
|
|
378
|
+
"revision": "tapd-story-modified-at-or-content-digest"
|
|
379
|
+
}
|
|
380
|
+
}`,eae=`{
|
|
381
|
+
"schemaVersion": 1,
|
|
382
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
383
|
+
"source": "prd-flow",
|
|
384
|
+
"globalState": {
|
|
385
|
+
"mode": "merge",
|
|
386
|
+
"patch": {
|
|
387
|
+
"tapdCurrentVersion": {
|
|
388
|
+
"id": "1133202860001000338",
|
|
389
|
+
"name": "Likee Android 5.63.0",
|
|
390
|
+
"date": "2026-08-31",
|
|
391
|
+
"platform": "android"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"projections": {
|
|
396
|
+
"timeline": [
|
|
397
|
+
{
|
|
398
|
+
"kind": "version",
|
|
399
|
+
"id": "android:1133202860001000338",
|
|
400
|
+
"key": "prd-flow:version:android:1133202860001000338",
|
|
401
|
+
"title": "Likee Android 5.63.0",
|
|
402
|
+
"date": "2026-08-31",
|
|
403
|
+
"source": "prd-flow",
|
|
404
|
+
"dimensions": { "platform": "android" }
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
},
|
|
408
|
+
"expectedVersions": {
|
|
409
|
+
"global:tapdCurrentVersion.id": "rv:<version-from-get-or-absent>",
|
|
410
|
+
"global:tapdCurrentVersion.name": "rv:<version-from-get-or-absent>",
|
|
411
|
+
"global:tapdCurrentVersion.date": "rv:<version-from-get-or-absent>",
|
|
412
|
+
"global:tapdCurrentVersion.platform": "rv:<version-from-get-or-absent>",
|
|
413
|
+
"projection:prd-flow:version:android:1133202860001000338": "absent"
|
|
414
|
+
},
|
|
415
|
+
"idempotencyKey": "timeline:1020124:android-version-1133202860001000338:v1"
|
|
416
|
+
}`,tae=`{
|
|
417
|
+
"schemaVersion": 1,
|
|
418
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
419
|
+
"source": "prd-flow",
|
|
420
|
+
"action": {
|
|
421
|
+
"key": "implementation:runtime-hook:android",
|
|
422
|
+
"title": "Android 实现完成",
|
|
423
|
+
"detail": "MR !957 已合并",
|
|
424
|
+
"status": "done",
|
|
425
|
+
"group": "implementation",
|
|
426
|
+
"platform": "android",
|
|
427
|
+
"issueKey": "runtime-hook",
|
|
428
|
+
"occurredAt": "2026-08-05T08:25:00.000Z"
|
|
429
|
+
},
|
|
430
|
+
"artifacts": [{
|
|
431
|
+
"key": "implementation-mr:runtime-hook:android",
|
|
432
|
+
"type": "gitlab-mr",
|
|
433
|
+
"title": "实现 MR !957",
|
|
434
|
+
"url": "https://git.example.test/merge_requests/957",
|
|
435
|
+
"scope": "action",
|
|
436
|
+
"status": "ready"
|
|
437
|
+
}],
|
|
438
|
+
"expectedVersions": {
|
|
439
|
+
"action:prd-flow:implementation:runtime-hook:android": "absent",
|
|
440
|
+
"artifact:prd-flow:implementation-mr:runtime-hook:android": "absent"
|
|
441
|
+
},
|
|
442
|
+
"idempotencyKey": "implementation-finished:android:runtime-hook:v1"
|
|
443
|
+
}`,nae=`{
|
|
444
|
+
"schemaVersion": 1,
|
|
445
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
446
|
+
"source": "prd-flow",
|
|
447
|
+
"extensions": {
|
|
448
|
+
"prd-flow": {
|
|
449
|
+
"aiDocs": [{
|
|
450
|
+
"key": "tech-design",
|
|
451
|
+
"title": "技术方案",
|
|
452
|
+
"url": "https://ai-doc.example.test/docs/123"
|
|
453
|
+
}],
|
|
454
|
+
"issues": [{
|
|
455
|
+
"key": "runtime-hook",
|
|
456
|
+
"title": "Runtime Hook",
|
|
457
|
+
"platform": "android",
|
|
458
|
+
"status": "implementing"
|
|
459
|
+
}]
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
"expectedVersions": {
|
|
463
|
+
"extension:prd-flow:aiDocs": "rv:<version-from-get-or-absent>",
|
|
464
|
+
"extension:prd-flow:issues": "rv:<version-from-get-or-absent>"
|
|
465
|
+
},
|
|
466
|
+
"idempotencyKey": "prd-panels:1020124:<semantic-digest>"
|
|
467
|
+
}`,rae=`{
|
|
468
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
469
|
+
"source": "my-adapter",
|
|
470
|
+
"globalState": {
|
|
471
|
+
"mode": "merge",
|
|
472
|
+
"patch": {
|
|
473
|
+
"title": "Remote Config 拉取频控",
|
|
474
|
+
"url": "https://tapd.example.test/1020124",
|
|
475
|
+
"status": "实现中",
|
|
476
|
+
"sections": {
|
|
477
|
+
"ownership": {
|
|
478
|
+
"title": "归属信息",
|
|
479
|
+
"fields": {
|
|
480
|
+
"owner": {
|
|
481
|
+
"label": "负责人",
|
|
482
|
+
"type": "user",
|
|
483
|
+
"value": { "username": "alice" }
|
|
484
|
+
},
|
|
485
|
+
"platforms": {
|
|
486
|
+
"label": "平台",
|
|
487
|
+
"type": "chips",
|
|
488
|
+
"value": ["Android", "iOS"]
|
|
489
|
+
},
|
|
490
|
+
"branch": {
|
|
491
|
+
"label": "需求分支",
|
|
492
|
+
"type": "text",
|
|
493
|
+
"value": "story/1020124"
|
|
494
|
+
},
|
|
495
|
+
"risks": {
|
|
496
|
+
"label": "当前风险",
|
|
497
|
+
"type": "list",
|
|
498
|
+
"value": ["等待服务端字段确认", "灰度策略待补充"]
|
|
499
|
+
},
|
|
500
|
+
"design": {
|
|
501
|
+
"label": "技术方案",
|
|
502
|
+
"type": "link",
|
|
503
|
+
"value": "打开方案文档",
|
|
504
|
+
"url": "https://docs.example.test/1020124"
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}`,sae=`POST /api/workflow-artifacts/publish
|
|
512
|
+
Authorization: Bearer <AGENTFLOW_TOKEN>
|
|
513
|
+
Content-Type: application/json
|
|
514
|
+
|
|
515
|
+
{
|
|
516
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
517
|
+
"source": "prd-flow",
|
|
518
|
+
"title": "Issue1 · Android 方案草稿",
|
|
519
|
+
"markdown": "# 方案内容\\n...",
|
|
520
|
+
"stage": "issue-plan:runtime-hook",
|
|
521
|
+
"issueKey": "runtime-hook",
|
|
522
|
+
"platform": "android",
|
|
523
|
+
"artifactKey": "plan:runtime-hook:android",
|
|
524
|
+
"artifactLabel": "方案预览",
|
|
525
|
+
"durability": "temporary",
|
|
526
|
+
"ttlDays": 7,
|
|
527
|
+
"expectedVersions": {
|
|
528
|
+
"artifact:prd-flow:plan:runtime-hook:android": "absent"
|
|
529
|
+
},
|
|
530
|
+
"idempotencyKey": "review:plan:runtime-hook:android:<content-digest>"
|
|
531
|
+
}`,YC=`请使用 $agentflow-workflow-report 接入一个生产方,并完整阅读 references/protocol.md。
|
|
532
|
+
|
|
533
|
+
运行态数据只有三个正式接口,TAPD 人员权限另有一个控制面接口:
|
|
534
|
+
0. POST /api/workflows/access/sync:把 TAPD Owner 和参与人同步为 Workflow 派生权限;它不写业务状态。
|
|
535
|
+
1. GET /api/workflows/state:读取当前状态和 snapshot.resourceVersions。
|
|
536
|
+
2. POST /api/workflows/report:写全局信息、Action、普通产物、迭代投影或自定义区域。
|
|
537
|
+
3. POST /api/workflow-artifacts/publish:把本地 Markdown 内容发布成预览 URL。
|
|
538
|
+
|
|
539
|
+
先输出接入映射表:
|
|
540
|
+
- 稳定 Workflow 身份是什么;当前服务支持 tapd:<short-id>。
|
|
541
|
+
- 哪些事实进入 observation.state / globalState。
|
|
542
|
+
- 哪些关键业务节点进入 action;每个稳定 action.key 是什么。
|
|
543
|
+
- 哪些外部链接进入 artifacts;哪些本地 Markdown 需要先 publish。
|
|
544
|
+
- 哪些版本/Sprint/里程碑进入 projections.timeline。
|
|
545
|
+
- 普通自定义信息是否可用 globalState.sections 的 text/user/chips/list/link 渲染器表达。
|
|
546
|
+
- 只有通用渲染器不够时,才设计 extensions namespace/schema/前端渲染器。
|
|
547
|
+
|
|
548
|
+
实现 access sync → read → merge → report → verify:
|
|
549
|
+
- TAPD Owner 映射为 Workflow Owner;TAPD 参与人默认 Viewer;Owner 可在 AgentFlow 中显式授予 Reporter。
|
|
550
|
+
- owner/reporter 才能写;viewer、团队成员、分享链接、管理员代看只读。
|
|
551
|
+
- globalState 只 patch 自己拥有的路径;对象递归合并,数组/标量替换。
|
|
552
|
+
- source 使用真实业务 Adapter 的稳定小写名称;agentflow-cli 只是传输工具。
|
|
553
|
+
- 同一 source + action.key 更新同一阶段,不为刷新或重试创建新 key。
|
|
554
|
+
- timeline 只提交当前 source 的完整切片;服务端原子保留其他生产方条目。
|
|
555
|
+
- globalState.sections 是当前通用自定义卡片能力;优先使用现有 field type。
|
|
556
|
+
- extensions 只写自己的 namespace;当前仅 prd-flow 注册了 AI Docs / Issues 专用 renderer,保存其他 namespace 不会自动出现 UI。
|
|
557
|
+
- 为本次触及的每个业务 key 携带 expectedVersions 与稳定 idempotencyKey;任一 key 冲突时整次请求不落库,刷新冲突 key 后只重试一次。
|
|
558
|
+
- 不输出 Token,不新增生产方专用写接口,不使用 /api/prd-workflow/* 兼容接口。
|
|
559
|
+
|
|
560
|
+
最后验证 Workflow 全局区域、Action 时间轴、产物链接、个人/团队迭代和自定义区域。`,iae=[{method:"POST",path:"/api/workflows/access/sync",title:"同步 TAPD 权限",detail:"把 TAPD Owner 和参与人投影为 Workflow 派生权限;不传业务状态。",permission:"首次为 TAPD Owner;后续为当前 Owner / 管理员",effect:"更新 Owner 与 TAPD Viewer,保留显式授权"},{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",detail:"取得服务端物化快照与每个业务 key 的 resourceVersions;安全写入的第一步。",permission:"可访问该 Workflow 的用户可读",effect:"只读,不修改任何状态"},{method:"POST",path:"/api/workflows/report",title:"统一上报",detail:"写入全局信息、Action、普通产物、迭代归属和自定义区域。",permission:"owner / reporter",effect:"按区域执行替换、合并或更新"},{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",detail:"上传 Markdown 内容,生成可供浏览器查看的规范 URL 与短链。",permission:"owner / reporter",effect:"保存预览副本与辅助 Artifact,不推进阶段"}],oae=[["workflow","string","二选一","规范 Workflow key,例如 tapd:1020124"],["namespace + id","string","二选一","拆分传入身份;当前 namespace 仅支持 tapd"],["runtimeOnly","0 | 1","否","1 只读已保存运行态,不主动刷新上游"],["flowId / flowSource","string","否","关联 AgentFlow 项目上下文;flowSource 默认 user"],["workspaceId","string","否","关联项目的工作区上下文"],["workflowShare","string","否","只读分享 token,不能用于写接口"]],aae=[["workflow","object","规范身份 {namespace,id,key}"],["snapshot.resourceVersions","object","业务 key 到并发版本的映射;新接入按本次触及 key 取值"],["snapshot.runtimeRevision","string","整份运行态版本;页面缓存与旧客户端兼容使用"],["snapshot.globalState","object","服务端合并后的全局区域"],["snapshot.actions","array","已物化的 Action 时间轴"],["snapshot.artifacts","array","已物化的全局产物"],["snapshot.projections.timeline","array","当前完整迭代归属"],["snapshot.extensions","object","所有已保存的 namespace 数据"]],lae=[["schemaVersion","number","否","当前固定为 1"],["workflow","object | string","是","{namespace,id} 或规范 key"],["source","string","是","真实业务 Adapter 的稳定小写名称;agentflow-cli 仅负责传输"],["expectedVersions","object","生产建议","本次触及的每个 resource key 及读取时版本;新建 key 使用 absent"],["expectedRevision","string","兼容","仅未提供 expectedVersions 时启用的整 Workflow 锁"],["idempotencyKey","string","建议","业务操作稳定身份,不使用时间戳或随机 UUID"],["observation","object","条件","同一 clientId 的完整生产方观察"],["globalState","object","条件","全局事实的 merge patch 与 remove"],["action","object","条件","一个关键业务阶段;key 必填"],["artifacts","array","条件","Action 证据或全局证据"],["projections","object","条件","当前 source 的完整 timeline 迭代归属切片"],["extensions","object","条件","按生产方 namespace 组织的自定义区域"]],cae=[["workflow","object | string","是","规范 Workflow 身份;当前仅 tapd:<short-id>"],["authority.type","string","是","当前固定为 tapd;表示权限事实来源,不是 report source"],["authority.owner","string | object","是","TAPD 需求 Owner 的 AgentFlow username/userId;必须已登录或注册"],["authority.participants","array","否","TAPD 参与人用户名;匹配到账号后自动获得 Viewer"],["authority.observedAt","ISO date","建议","读取 TAPD 人员快照的时间;旧于已保存快照时返回 409"],["authority.revision","string","建议","TAPD modified 值或人员内容摘要,供审计和排查"]],uae=[["key","string","是","稳定阶段身份;同 key 更新同一阶段"],["title / detail","string","否","时间轴卡片标题与摘要"],["status","enum","否","pending/running/done/error/conflict/skipped/cancelled/observed"],["group / scope","string","否","阶段分组与业务范围"],["platform / issueKey","string","否","平台和自定义 Issue 维度"],["tags","string[]","否","额外筛选标签"],["occurredAt","ISO date","否","业务发生时间,不是 HTTP 重试时间"]],dae=[["schema","string","否","生产方观察 schema,建议带版本,例如 my-adapter/v1"],["clientId","string","建议","稳定客户端身份;决定哪份完整观察被替换"],["observedAt","ISO date","建议","本次事实采集时间"],["scope","string","否","观察范围,默认 client"],["state","object","是","该 clientId 的完整当前观察,不是 patch"]],fae=[["mode","merge","是","当前只支持 merge"],["patch","object","条件","对象递归合并;数组、标量整体替换;null 删除字段"],["remove","string[]","条件","显式删除点路径,例如 sections.progress.fields.owner"]],pae=[["sections.<key>.title","string","建议","分区标题;key=progress 使用紧凑网格"],["fields.<key>.label","string","建议","字段显示名"],["fields.<key>.type","enum","否","text / user / chips / list / link;未知值回退 text"],["fields.<key>.value","any","是","展示值;空值不渲染"],["fields.<key>.url","string","link 条件","link 类型的跳转地址"]],hae=[["timeline","array","是","替换当前 source 的完整切片;省略 projections 才表示不修改"],["timeline[].kind","string","是","version / sprint / milestone 或生产方自定义类型"],["timeline[].id","string","是","业务对象稳定 ID;改名或改期不改变"],["timeline[].key","string","建议","建议 source:kind:id,避免不同生产方碰撞"],["timeline[].title / date","string","否","卡片标题和 YYYY-MM-DD 排期"],["timeline[].source","string","建议","条目所有者,用于 read-merge 时识别自有条目"],["timeline[].dimensions","object","否","平台、发布列车等不透明筛选维度"]],mae=[["extensions.<namespace>","object","是","生产方自有、带版本约定的结构化 JSON"],["namespace","string","是","小写稳定标识;建议与 report.source 相同"],["对象字段","object","否","递归合并;null 删除"],["数组 / 标量","any","否","整体替换,不做元素级 merge"],["renderer","前端注册","展示条件","未知 namespace 只保存,不自动出现面板"]],gae=[["key","string","建议","稳定证据身份;不要依赖标题去重"],["type","string","否","gitlab-mr/build/test-report/document 等"],["title","string","否","页面展示标题"],["url / path","string","至少一个","外部地址或可识别路径"],["scope","action | global","否","有 Action 时默认 action"],["status","string","否","生产方定义的证据状态"]],yae=[["workflow","object | string","是","目标 Workflow"],["source","string","是","真实生产方身份;agentflow-cli 只是传输工具"],["title","string","是","Review 页面标题"],["markdown","string","是","Markdown 实际内容,不是本地文件路径"],["stage / stageKey","string","建议","关联的稳定 Action 阶段"],["issueKey / platform","string","否","Issue 与平台维度"],["artifactKey","string","是","预览 Artifact 的稳定槽位"],["artifactLabel","string","否","页面按钮文案"],["durability","enum","否","temporary 或 durable"],["ttlDays","number","临时建议","临时预览有效期,通常 7 天"],["expectedVersions","object","生产建议","目标 artifact:source:key 的当前版本;新建使用 absent"],["expectedRevision","string","兼容","仅未提供 expectedVersions 时启用的整 Workflow 锁"],["idempotencyKey","string","建议","包含内容摘要;同 source + key 重放返回同一预览"]],JC=[["api","快速开始"],["model","区域模型"],["renderers","渲染效果"],["reference","参数参考"],["scenarios","关键场景"],["safety","权限与覆盖"],["design","设计思想"],["ai","AI 引导"]],wae=[{icon:"dashboard",name:"全局区域",question:"这个需求现在是什么?",fields:"observation.state · globalState · projections.timeline",detail:"标题、状态、负责人、平台、版本事实和迭代归属。事实留在 globalState,迭代列表只读取可重建的 projection。"},{icon:"timeline",name:"Action 时间轴",question:"关键阶段发生了什么?",fields:"action · artifacts",detail:"方案确认、实现、提测、发布等业务节点及其 MR、构建、测试或文档证据。Action 不是刷新日志。"},{icon:"extension",name:"自定义展示",question:"生产方还需要展示什么?",fields:"globalState.sections · extensions[namespace]",detail:"普通键值、标签、列表和链接优先使用通用 sections;只有需要树形结构或专用交互时才使用 extensions 并开发 renderer。"}],xae=[["observation.state","同一 clientId 完整替换","省略不改","只替换自己的完整观察"],["globalState","对象递归合并;数组/标量替换","null 或 remove 删除","只 patch 自己拥有的路径"],["action","同 source + action.key 更新同一阶段","无通用物理删除","取消/跳过使用业务状态表达"],["artifacts","同 source + 稳定 key 更新/归并","无通用物理删除","不要改 key 来伪造删除"],["projections.timeline","当前 source 的完整切片替换","[] 只清空当前 source","其他生产方条目由服务端原子保留"],["extensions","仅 extensions[source] 内对象递归合并;数组/标量替换","null 删除自有字段","不能写别人的 namespace"]],bae=[["TAPD Owner","可读","可写","Workflow Owner;可管理成员和分享"],["显式 Reporter","可读","可写","Owner 主动授权;不能管理成员"],["TAPD 参与人","可读","只读","由 TAPD 派生;移出 TAPD 后自动收回"],["显式 Viewer","可读","只读","Owner 主动授权;不依赖 TAPD"],["同团队成员","可读","只读","自动获得 team viewer"],["分享链接","可读","只读","不能用于上报"],["超级管理员代看","可读","只读","不会以管理员身份覆盖数据"]];async function kae(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",document.body.appendChild(r),r.select();const i=document.execCommand("copy");return r.remove(),i}catch{return!1}}function Do({number:e,title:t,detail:n}){return s.jsxs("div",{className:"af-wr-section__head",children:[s.jsx("span",{children:e}),s.jsxs("div",{children:[s.jsx("h2",{children:t}),s.jsx("p",{children:n})]})]})}function Ts({title:e,value:t,copyKey:n,copied:r,onCopy:i,wrap:o=!1}){const a=r===`failed:${n}`;return s.jsxs("div",{className:`af-wr-code-panel${o?" is-wrap":""}`,children:[s.jsxs("div",{className:"af-wr-code-panel__head",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",onClick:()=>void i(n,t),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r===n?"check":"content_copy"}),r===n?"已复制":"复制"]})]}),s.jsx("pre",{children:t}),a?s.jsx("p",{className:"af-wr-copy-error",children:"浏览器禁止访问剪贴板,请手动选择代码块内容。"}):null]})}function Xr({columns:e=["参数","类型","必填","含义"],rows:t,label:n}){return s.jsxs("div",{className:`af-wr-table is-${e.length}-columns`,role:"table","aria-label":n,children:[s.jsx("div",{className:"af-wr-table__row is-head",role:"row",children:e.map(r=>s.jsx("span",{role:"columnheader",children:r},r))}),t.map(r=>s.jsx("div",{className:"af-wr-table__row",role:"row",children:r.map((i,o)=>s.jsx("span",{role:"cell","data-label":e[o],children:i},`${r[0]}-${o}`))},r[0]))]})}function sh({method:e,path:t,title:n,permission:r,effect:i}){return s.jsxs("div",{className:"af-wr-endpoint__head",children:[s.jsxs("div",{className:"af-wr-endpoint__identity",children:[s.jsx("span",{className:`is-${e.toLowerCase()}`,children:e}),s.jsx("code",{children:t}),s.jsx("h3",{children:n})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"权限"}),s.jsx("dd",{children:r})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"副作用"}),s.jsx("dd",{children:i})]})]})]})}function vae(){return s.jsxs("article",{className:"af-prd-workflow-card af-prd-overall af-wr-render-preview",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"需求概览"}),s.jsx("span",{className:"af-prd-overall__status",children:"实现中"})]}),s.jsx("div",{className:"af-prd-overall__requirement",children:s.jsx("strong",{children:"Remote Config 拉取频控"})}),s.jsx("div",{className:"af-prd-overall__platforms",children:s.jsxs("section",{className:"af-prd-overall-platform",children:[s.jsx("div",{className:"af-prd-overall-platform__head",children:s.jsx("strong",{children:"归属信息"})}),s.jsxs("div",{className:"af-prd-overall-platform__fields",children:[s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--user",children:[s.jsx("small",{children:"负责人 · user"}),s.jsx("div",{children:s.jsx("span",{children:"alice"})})]}),s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--chips",children:[s.jsx("small",{children:"平台 · chips"}),s.jsxs("div",{children:[s.jsx("span",{children:"Android"}),s.jsx("span",{children:"iOS"})]})]}),s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--text",children:[s.jsx("small",{children:"需求分支 · text"}),s.jsx("div",{children:s.jsx("span",{children:"story/1020124"})})]}),s.jsxs("div",{className:"af-prd-overall-platform__rules",children:[s.jsx("small",{children:"当前风险 · list"}),s.jsxs("ul",{children:[s.jsx("li",{children:"等待服务端字段确认"}),s.jsx("li",{children:"灰度策略待补充"})]})]}),s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[s.jsx("small",{children:"技术方案 · link"}),s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"打开方案文档"}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]})]})]})})]})}function Sae(){return s.jsxs("div",{className:"af-prd-workflow-action af-prd-workflow-action--done af-wr-render-preview",children:[s.jsx("div",{className:"af-prd-workflow-action__rail",children:s.jsx("span",{className:"af-prd-workflow-action__dot"})}),s.jsxs("div",{className:"af-prd-workflow-action__body",children:[s.jsxs("div",{className:"af-prd-workflow-action__top",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-prd-workflow-action__title",children:[s.jsx("time",{children:"16:25:40"}),s.jsx("strong",{children:"Android 实现完成"})]}),s.jsx("p",{children:"MR !957 已合并"}),s.jsxs("div",{className:"af-prd-workflow-action__meta",children:[s.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--issue",children:[s.jsx("b",{children:"Issue"}),s.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"runtime-hook"})]}),s.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--platform",children:[s.jsx("b",{children:"平台"}),s.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"Android"})]})]})]}),s.jsx("span",{className:"af-prd-workflow-action__status",children:"完成"})]}),s.jsx("div",{className:"af-prd-workflow-action__links",children:s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"实现 MR !957"}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]})]})}function jae(){return s.jsxs("article",{className:"af-prd-workflow-card af-wr-render-preview",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"关联产物"}),s.jsx("span",{children:"2"})]}),s.jsxs("div",{className:"af-prd-workflow-list",children:[s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"测试报告 #128"}),s.jsx("small",{children:"test-report"})]}),s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"Jenkins Build #8451"}),s.jsx("small",{children:"build"})]})]})]})}function Nae(){return s.jsxs("section",{className:"af-workflows-timeline af-wr-render-preview",children:[s.jsx("div",{className:"af-workflows-timeline__heading",children:s.jsxs("div",{children:[s.jsx("span",{children:"迭代时间线"}),s.jsx("strong",{children:"按排期归属汇总"})]})}),s.jsx("div",{className:"af-workflows-timeline__rail",children:s.jsxs("button",{type:"button",className:"is-active",children:[s.jsxs("span",{className:"af-workflows-timeline__date",children:["2026/08/31",s.jsx("em",{children:"计划中"})]}),s.jsx("strong",{children:"Likee Android 5.63.0"}),s.jsx("small",{children:"Android · 3 项 · 1 项需关注"})]})})]})}function _ae(){return s.jsxs("div",{className:"af-wr-extension-preview",children:[s.jsxs("section",{children:[s.jsxs("div",{children:[s.jsx("span",{children:"AI DOCS"}),s.jsx("strong",{children:"2"})]}),s.jsx("p",{children:"技术方案"}),s.jsx("p",{children:"测试与灰度说明"})]}),s.jsxs("section",{children:[s.jsxs("div",{children:[s.jsx("span",{children:"ISSUES"}),s.jsx("strong",{children:"2 / 3"})]}),s.jsxs("p",{children:[s.jsx("i",{className:"is-done"})," Runtime Hook · Android"]}),s.jsxs("p",{children:[s.jsx("i",{})," iOS 容器适配"]})]})]})}function Cae(){const{navigate:e}=ls(),[t,n]=m.useState(""),[r,i]=m.useState("api"),o=m.useCallback(async(a,l)=>{n(await kae(l)?a:`failed:${a}`)},[]);return m.useEffect(()=>{const a=JC.map(([c])=>document.getElementById(c)).filter(Boolean);if(!a.length||typeof IntersectionObserver>"u")return;const l=new IntersectionObserver(c=>{var p,f;const u=c.filter(d=>d.isIntersecting).sort((d,h)=>d.boundingClientRect.top-h.boundingClientRect.top);(f=(p=u[0])==null?void 0:p.target)!=null&&f.id&&i(u[0].target.id)},{rootMargin:"-18% 0px -68% 0px",threshold:[0,.1]});return a.forEach(c=>l.observe(c)),()=>l.disconnect()},[]),s.jsx("div",{className:"af-wr-page",children:s.jsxs("div",{className:"af-wr-inner",children:[s.jsxs("section",{className:"af-wr-hero",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-wr-kicker",children:"WORKFLOW REPORT · API REFERENCE"}),s.jsx("h1",{children:"Workflow 接入文档"}),s.jsx("p",{children:"用 3 个运行态数据接口和 1 个权限控制面接口,把生产流程的人员权限、全局信息、Action 时间轴、产物链接、迭代归属和自定义面板接入 AgentFlow。数据协议面向任意 Adapter;当前服务端的 Workflow 身份与权限适配器只支持 TAPD,prd-flow 仅作为 TAPD 研发场景的参考实现。"}),s.jsxs("div",{className:"af-wr-hero__boundary",children:[s.jsx("strong",{children:"当前边界"}),s.jsx("span",{children:"可接入任意事实来源"}),s.jsx("i",{children:"·"}),s.jsx("span",{children:"Workflow key 目前必须是 tapd:<short-id>"})]})]}),s.jsxs("div",{className:"af-wr-hero__actions",children:[s.jsxs("button",{type:"button",className:"is-primary",onClick:()=>void o("ai",YC),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:t==="ai"?"check":"smart_toy"}),t==="ai"?"已复制 AI 引导":"复制 AI 接入引导"]}),s.jsx("button",{type:"button",onClick:()=>e("/workflows"),children:"打开 Workflow Dashboard"})]})]}),s.jsx("nav",{className:"af-wr-toc","aria-label":"接入文档目录",children:JC.map(([a,l])=>s.jsx("a",{className:r===a?"is-active":"",href:`#${a}`,children:l},a))}),s.jsxs("section",{className:"af-wr-section",id:"api",children:[s.jsx(Do,{number:"01",title:"5 分钟跑通一次上报",detail:"运行态数据接口只有三个,人员权限由独立控制面接口同步。先准备登录 Token 和稳定 source,再执行 access sync → read → merge → report → verify;旧 /api/prd-workflow/* 仅为兼容入口。"}),s.jsx("div",{className:"af-wr-endpoint-grid",children:iae.map(a=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("span",{className:`is-${a.method.toLowerCase()}`,children:a.method}),s.jsx("code",{children:a.path})]}),s.jsx("h3",{children:a.title}),s.jsx("p",{children:a.detail}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"权限"}),s.jsx("dd",{children:a.permission})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"副作用"}),s.jsx("dd",{children:a.effect})]})]})]},a.path))}),s.jsxs("div",{className:"af-wr-quickstart",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"开始前准备"}),s.jsxs("p",{children:["在 AgentFlow 的 MCP 页面点击“使用当前登录 Token”,仅在本机设置 ",s.jsx("code",{children:"AGENTFLOW_TOKEN"}),"。当前 Workflow 身份必须使用 ",s.jsx("code",{children:"tapd:<short-id>"}),";",s.jsx("code",{children:"source"})," 填业务 Adapter 名,不能填传输工具名。"]})]}),s.jsx(Ts,{title:"安装与认证",value:Goe,copyKey:"install",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-code-grid af-wr-quickstart-run",children:[s.jsx(Ts,{title:"可直接执行的三步命令",value:Joe,copyKey:"quickstart",copied:t,onCopy:o}),s.jsx(Ts,{title:"workflow-report.json 最小请求",value:Yoe,copyKey:"quickstart-report",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-success-check",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),s.jsxs("p",{children:[s.jsx("strong",{children:"成功标准:"}),"POST 返回 ",s.jsx("code",{children:"ok: true"})," 和实际 ",s.jsx("code",{children:"resourceKeys"}),",再次 GET 能看到 ",s.jsx("code",{children:"requirement-imported"}),",且对应 ",s.jsx("code",{children:"snapshot.resourceVersions"})," 已从 ",s.jsx("code",{children:"absent"})," 变为新版本。"]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"model",children:[s.jsx(Do,{number:"02",title:"先决定数据进入哪个区域",detail:"页面区域和协议字段一一对应。不要把所有内容都塞进一个 snapshot,也不要从 Action 标题反推结构化数据。"}),s.jsx("div",{className:"af-wr-region-grid",children:wae.map(a=>s.jsxs("article",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a.icon}),s.jsxs("div",{children:[s.jsx("small",{children:a.question}),s.jsx("h3",{children:a.name}),s.jsx("code",{children:a.fields}),s.jsx("p",{children:a.detail})]})]},a.name))}),s.jsxs("div",{className:"af-wr-model-note",children:[s.jsx("strong",{children:"核心原则"}),s.jsx("span",{children:"globalState.sections 解决通用自定义展示"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"Action 表达关键业务节点"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"projection 只做聚合索引"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"extension 承载专用结构"})]})]}),s.jsxs("section",{className:"af-wr-section",id:"renderers",children:[s.jsx(Do,{number:"03",title:"当前可直接使用的通用渲染器",detail:"这些 schema 已经由 AgentFlow 页面识别,接入方只需上报数据,不需要开发前端。下面的预览使用与 Workflow 详情页相同的样式类。"}),s.jsxs("div",{className:"af-wr-renderer-notice",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"info"}),s.jsxs("p",{children:[s.jsx("strong",{children:"普通自定义信息不要放进 extensions。"}),"负责人、平台、分支、风险列表、文档链接等,直接使用 ",s.jsx("code",{children:"globalState.sections"}),"。只有通用组件无法表达的树形结构、复杂交互或专用业务面板,才需要 ",s.jsx("code",{children:"extensions"})," 和前端 renderer。"]})]}),s.jsxs("div",{className:"af-wr-renderer-feature",children:[s.jsxs("div",{className:"af-wr-renderer-feature__copy",children:[s.jsx("span",{children:"GENERIC · GLOBAL STATE"}),s.jsx("h3",{children:"概览分区 / 字段渲染器"}),s.jsxs("p",{children:["每个 section 生成一张分区卡片;字段按 ",s.jsx("code",{children:"type"})," 选择固定样式。section key 为 ",s.jsx("code",{children:"progress"})," 时使用紧凑响应式网格,其余分区纵向排列。"]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"text"}),s.jsx("dd",{children:"普通文本,无胶囊背景"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"user"}),s.jsx("dd",{children:"负责人文本,使用强调色"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"chips"}),s.jsx("dd",{children:"一个或多个标签胶囊"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"list"}),s.jsx("dd",{children:"纵向项目符号列表"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"link"}),s.jsx("dd",{children:"可点击文本与外链图标"})]})]})]}),s.jsx(vae,{})]}),s.jsx(Ts,{title:"globalState.sections 上报示例",value:rae,copyKey:"generic-section",copied:t,onCopy:o}),s.jsxs("div",{className:"af-wr-renderer-grid",children:[s.jsxs("article",{children:[s.jsxs("div",{className:"af-wr-renderer-grid__head",children:[s.jsx("span",{children:"GENERIC"}),s.jsx("h3",{children:"Action 时间轴"}),s.jsx("code",{children:"action + artifacts[scope=action]"}),s.jsx("p",{children:"按日期分组,展示状态点、时间、标题、详情、Issue/平台标签和阶段产物按钮。"})]}),s.jsx(Sae,{})]}),s.jsxs("article",{children:[s.jsxs("div",{className:"af-wr-renderer-grid__head",children:[s.jsx("span",{children:"GENERIC"}),s.jsx("h3",{children:"关联产物列表"}),s.jsx("code",{children:"artifacts[scope=global]"}),s.jsx("p",{children:"用于构建、测试报告、外部文档等全局链接;显示标题、类型与跳转状态。"})]}),s.jsx(jae,{})]}),s.jsxs("article",{children:[s.jsxs("div",{className:"af-wr-renderer-grid__head",children:[s.jsx("span",{children:"GENERIC"}),s.jsx("h3",{children:"迭代时间线"}),s.jsx("code",{children:"projections.timeline"}),s.jsx("p",{children:"根据 kind/id/title/date/dimensions 聚合个人与团队迭代,支持横向时间线和筛选。"})]}),s.jsx(Nae,{})]})]}),s.jsxs("div",{className:"af-wr-extension-registry",children:[s.jsxs("div",{children:[s.jsx("span",{children:"REGISTERED EXTENSION"}),s.jsx("h3",{children:s.jsx("code",{children:'extensions["prd-flow"]'})}),s.jsx("p",{children:"当前唯一已注册的专用 extension renderer。支持 AI Docs 链接列表和带父子层级、平台、MR 状态及关联链接的 Issues 树。"}),s.jsx(_ae,{})]}),s.jsxs("div",{children:[s.jsx("strong",{children:"其他 namespace 当前如何显示?"}),s.jsx("p",{children:"数据会被保存并参与 revision,但不会自动出现面板。若现有 sections / Action / Artifact / timeline 足够,应优先使用通用组件;确实需要新布局时,再提交扩展 schema、空态/错误态、响应式样式和 renderer 实现。"})]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"reference",children:[s.jsx(Do,{number:"04",title:"接口与参数参考",detail:"以下字段来自当前服务端真实校验与合并逻辑;可以按区域只提交本次需要更新的部分。"}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(sh,{method:"POST",path:"/api/workflows/access/sync",title:"同步 TAPD 派生权限",permission:"首次:TAPD Owner;后续:当前 Owner / 管理员",effect:"只改权限控制面,不写运行态"}),s.jsxs("p",{className:"af-wr-endpoint__intro",children:["Adapter 读取 TAPD Story 后,先把 Owner 与参与人同步到 AgentFlow。Owner 必须已注册 AgentFlow;未匹配的参与人会在 ",s.jsx("code",{children:"unresolvedParticipants"})," 中返回,注册后下次同步即可获得 Viewer。"]}),s.jsx(Xr,{rows:cae,label:"Workflow access sync 参数"}),s.jsx(Ts,{title:"权限同步请求",value:Zoe,copyKey:"access-sync",copied:t,onCopy:o}),s.jsxs("div",{className:"af-wr-callout",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"security"}),s.jsxs("p",{children:[s.jsx("strong",{children:"派生权限与显式授权分开保存。"}),"TAPD 参与人只自动获得 Viewer;Owner 可在 Workflow 分享弹窗把某人提升为 Reporter。后续 TAPD 同步会替换派生参与人,但不会覆盖显式授权。"]})]})]}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(sh,{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",permission:"owner / reporter / viewer / team viewer / share viewer",effect:"无"}),s.jsxs("p",{className:"af-wr-endpoint__intro",children:["写入前读取当前快照,从 ",s.jsx("code",{children:"snapshot.resourceVersions"})," 保存本次将触及的业务 key 版本;不存在的 key 使用 ",s.jsx("code",{children:"absent"}),"。客户端提交的完整状态叫 ",s.jsx("code",{children:"observation.state"}),";只有服务端返回的数据才叫 ",s.jsx("code",{children:"snapshot"}),"。"]}),s.jsx(Xr,{rows:oae,label:"Workflow state query 参数"}),s.jsx("h4",{children:"成功响应"}),s.jsx(Xr,{columns:["字段","类型","含义"],rows:aae,label:"Workflow state 成功响应"}),s.jsxs("div",{className:"af-wr-code-grid",children:[s.jsx(Ts,{title:"请求",value:Xoe,copyKey:"read-request",copied:t,onCopy:o}),s.jsx(Ts,{title:"关键响应字段",value:Qoe,copyKey:"read-response",copied:t,onCopy:o})]})]}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(sh,{method:"POST",path:"/api/workflows/report",title:"统一上报 Workflow",permission:"owner / reporter",effect:"修改运行态并返回新 snapshot"}),s.jsx("p",{className:"af-wr-endpoint__intro",children:"至少提交 observation、globalState、action、artifacts、projections、extensions 之一。一次请求可以组合多个区域:每个业务 key 独立校验版本,任一冲突则整次请求原子失败,不会只写入一半。"}),s.jsx("h4",{children:"Envelope"}),s.jsx(Xr,{rows:lae,label:"Workflow Report 顶层参数"}),s.jsxs("div",{className:"af-wr-subreference",children:[s.jsxs("div",{children:[s.jsx("h4",{children:"action"}),s.jsx("p",{children:"业务阶段,不是运行日志。"}),s.jsx(Xr,{rows:uae,label:"Action 参数"})]}),s.jsxs("div",{children:[s.jsx("h4",{children:"artifacts"}),s.jsx("p",{children:"已有 HTTP URL 的证据直接上报。"}),s.jsx(Xr,{rows:gae,label:"Artifact 参数"})]})]}),s.jsxs("div",{className:"af-wr-schema-reference",children:[s.jsxs("article",{children:[s.jsx("h4",{children:"observation"}),s.jsx("p",{children:"同一 clientId 的完整生产方观察。"}),s.jsx(Xr,{rows:dae,label:"Observation 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"globalState"}),s.jsx("p",{children:"可独立更新的全局事实和通用分区。"}),s.jsx(Xr,{rows:fae,label:"Global State 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"globalState.sections"}),s.jsx("p",{children:"无需前端开发的通用字段渲染器。"}),s.jsx(Xr,{rows:pae,label:"Global State Section 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"projections.timeline"}),s.jsx("p",{children:"个人/团队 Dashboard 使用的可重建索引。"}),s.jsx(Xr,{rows:hae,label:"Timeline Projection 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"extensions"}),s.jsx("p",{children:"只有专用 renderer 才能显示的 namespace 数据。"}),s.jsx(Xr,{rows:mae,label:"Workflow Extensions 参数"})]})]}),s.jsxs("p",{className:"af-wr-table-note",children:[s.jsx("strong",{children:"生产方隔离:"}),"Action、Artifact、Projection、Observation 和 Extension 都使用带 ",s.jsx("code",{children:"source"})," 的资源 key;不同 source 可以复用相同业务 key。",s.jsx("code",{children:"globalState"})," 按叶子路径分 key 并记录首次写入者,不能覆盖其他 source 的路径;timeline 只替换当前 source 的切片。"]})]}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(sh,{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",permission:"owner / reporter",effect:"保存预览副本和辅助 Artifact;不推进 Action"}),s.jsx("p",{className:"af-wr-endpoint__intro",children:"客户端读取本地 Markdown,再发送实际内容。服务端不能访问调用方本地路径;外部系统已有 URL 时直接使用 Report artifacts,无需发布副本。"}),s.jsx(Xr,{rows:yae,label:"Artifact Publish 参数"}),s.jsxs("div",{className:"af-wr-publish-layout",children:[s.jsxs("div",{className:"af-wr-result-list",children:[s.jsx("h4",{children:"返回什么"}),s.jsxs("p",{children:[s.jsx("code",{children:"artifact"}),":页面可识别的标准产物"]}),s.jsxs("p",{children:[s.jsx("code",{children:"review.url"}),":规范预览地址"]}),s.jsxs("p",{children:[s.jsx("code",{children:"review.shortUrl"}),":通常为 ",s.jsx("code",{children:"/r/<code>"})," 的分享短链"]}),s.jsxs("p",{children:[s.jsx("code",{children:"snapshot"}),":发布后的最新 Workflow 状态"]}),s.jsx("strong",{children:"不会确认方案、修改原文件、提交 ai-doc、创建 Issue 或推进阶段。"})]}),s.jsx(Ts,{title:"发布请求",value:sae,copyKey:"publish",copied:t,onCopy:o})]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"scenarios",children:[s.jsx(Do,{number:"05",title:"三个关键接入场景",detail:"以 prd-flow 为例说明接口组合;它是 TAPD 研发流程的一种实现,不是协议依赖。"}),s.jsxs("div",{className:"af-wr-scenario",children:[s.jsxs("div",{className:"af-wr-scenario__copy",children:[s.jsx("span",{children:"场景 A"}),s.jsx("h3",{children:"更新迭代:绑定或切换版本"}),s.jsxs("ol",{children:[s.jsx("li",{children:"Adapter 从业务系统得到稳定 version ID、标题、日期、平台;prd-flow 的来源恰好是 TAPD。"}),s.jsx("li",{children:"GET 当前 snapshot,取版本事实叶子路径及自有 projection 的 resourceVersions。"}),s.jsx("li",{children:"版本事实写入 globalState;归属索引写入 kind=version projection。"}),s.jsx("li",{children:"只提交当前 source 的完整投影切片;其他 source 的 Sprint/版本由服务端保留。"})]}),s.jsxs("p",{children:[s.jsx("strong",{children:"改名/改期:"}),"保持 ID 和 key 不变。",s.jsx("strong",{children:"取消归属:"}),"移除自有条目后上报剩余自有切片;发送空数组只清空当前 source。"]})]}),s.jsx(Ts,{title:"版本事实 + 当前生产方迭代投影",value:eae,copyKey:"version",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-scenario",children:[s.jsxs("div",{className:"af-wr-scenario__copy",children:[s.jsx("span",{children:"场景 B"}),s.jsx("h3",{children:"上报 Action 和产物链接"}),s.jsxs("ol",{children:[s.jsx("li",{children:"先完成真实业务动作,例如创建并合并 MR。"}),s.jsx("li",{children:"用稳定 action.key 报告阶段,用 artifact.key 报告证据。"}),s.jsx("li",{children:"同一阶段刷新继续使用相同 key;occurredAt 使用业务时间。"}),s.jsx("li",{children:"本地 Markdown 先 publish,已有 HTTP URL 直接作为 Artifact。"})]}),s.jsx("p",{children:"AgentFlow 只记录和展示结果,不替接入方操作 TAPD、GitLab 或 Jenkins。"})]}),s.jsx(Ts,{title:"实现完成 + MR",value:tae,copyKey:"action",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-scenario",children:[s.jsxs("div",{className:"af-wr-scenario__copy",children:[s.jsx("span",{children:"场景 C"}),s.jsx("h3",{children:"上报自定义文档区 / Issue 区"}),s.jsxs("ol",{children:[s.jsx("li",{children:"定义生产方 namespace 和版本化 schema。"}),s.jsx("li",{children:"把结构化数组写入 extensions[namespace]。"}),s.jsx("li",{children:"数组上报完整新值,对象字段可以递归合并。"}),s.jsx("li",{children:"实现并注册专用渲染器,页面才会出现对应区域。"})]}),s.jsx("p",{children:"prd-flow 已有 AI Docs / Issues 渲染;其他生产方不能仅通过改字段名复用它。"})]}),s.jsx(Ts,{title:"prd-flow 专用扩展示例",value:nae,copyKey:"extension",copied:t,onCopy:o})]})]}),s.jsxs("section",{className:"af-wr-section",id:"safety",children:[s.jsx(Do,{number:"06",title:"权限、覆盖和冲突",detail:"接入前必须明确谁能写、每个区域怎么更新,以及冲突发生时是否可能误删其他生产方的数据。"}),s.jsxs("div",{className:"af-wr-safety-grid",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"权限矩阵"}),s.jsx(Xr,{columns:["身份","读取","上报","说明"],rows:bae,label:"Workflow 权限矩阵"}),s.jsx("p",{className:"af-wr-table-note",children:"完成 TAPD 权限同步后,Owner 和参与人以 TAPD 为准;参与人默认只读。尚未同步过的历史 Workflow 保留原 Owner,直到当前 Owner 或管理员执行首次同步。"})]}),s.jsxs("div",{children:[s.jsx("h3",{children:"覆盖矩阵"}),s.jsx(Xr,{columns:["区域","重复上报","删除/清空","接入方责任"],rows:xae,label:"Workflow 覆盖矩阵"})]})]}),s.jsxs("div",{className:"af-wr-conflict-flow",children:[s.jsx("span",{children:"GET snapshot.resourceVersions"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"计算触及的 resource keys"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"POST + expectedVersions + idempotencyKey"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"409 时只刷新冲突 key / 重算 / 重试一次"})]}),s.jsxs("div",{className:"af-wr-errors",children:[s.jsxs("div",{children:[s.jsx("code",{children:"400"}),s.jsx("p",{children:"字段或 schema 错误;按协议修正"})]}),s.jsxs("div",{children:[s.jsx("code",{children:"401"}),s.jsx("p",{children:"缺少认证;停止并配置 Token"})]}),s.jsxs("div",{children:[s.jsx("code",{children:"403"}),s.jsx("p",{children:"只读或无权限;由 Owner 授权 Reporter"})]}),s.jsxs("div",{children:[s.jsx("code",{children:"409"}),s.jsx("p",{children:"资源 key 冲突、路径属于其他 source,或权限快照过旧"})]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"design",children:[s.jsx(Do,{number:"07",title:"设计思想与运行关系",detail:"业务解释留在 Adapter,传输和存储保持通用;这样新生产方不需要复制 prd-flow 的 TAPD 私有模型。"}),s.jsxs("div",{className:"af-wr-runtime",children:[s.jsxs("article",{children:[s.jsx("small",{children:"事实来源"}),s.jsx("strong",{children:"TAPD / GitLab / Jenkins / 其他系统"}),s.jsx("p",{children:"提供原始业务事实。"})]}),s.jsx("i",{children:"→"}),s.jsxs("article",{className:"is-focus",children:[s.jsx("small",{children:"你需要实现"}),s.jsx("strong",{children:"业务 Adapter"}),s.jsx("p",{children:"先同步上游人员权限,再解释阶段、定义稳定 key、生成 Report。prd-flow 是一个现有 Adapter。"})]}),s.jsx("i",{children:"→"}),s.jsxs("article",{children:[s.jsx("small",{children:"通用传输"}),s.jsx("strong",{children:"Workflow Report Client / agentflow-cli"}),s.jsx("p",{children:"负责地址、Token、JSON 和 HTTP,不理解业务。"})]}),s.jsx("i",{children:"→"}),s.jsxs("article",{children:[s.jsx("small",{children:"接收与展示"}),s.jsx("strong",{children:"AgentFlow 服务与页面"}),s.jsx("p",{children:"鉴权、合并、存储并渲染三类区域。"})]})]}),s.jsxs("div",{className:"af-wr-design-rules",children:[s.jsxs("article",{children:[s.jsx("strong",{children:"事实与投影分离"}),s.jsx("p",{children:"版本完整信息属于 globalState;个人/团队迭代只读取 projection。投影可以重建,不成为第二份真相。"})]}),s.jsxs("article",{children:[s.jsx("strong",{children:"业务节点与技术日志分离"}),s.jsx("p",{children:"Action 只表达可理解的阶段。轮询、重试、刷新留在接入方日志,不污染时间轴。"})]}),s.jsxs("article",{children:[s.jsx("strong",{children:"通用存储与专用渲染分离"}),s.jsx("p",{children:"extensions 可以保存任意生产方结构,但专用面板必须显式注册 schema 和 renderer。"})]})]}),s.jsxs("div",{className:"af-wr-callout",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"psychology"}),s.jsxs("p",{children:[s.jsx("strong",{children:"Workflow AI 不属于 Report 协议。"}),"需求 Owner 在详情页“协作 → AI 知识工作区”绑定平台已有的 Git 知识工作区;成员通过顶部 AI 提问。AgentFlow 会把当前 Workflow snapshot 与隔离的 detached commit 快照一并交给 AI:优先使用上报且能匹配仓库的 commit/ref,否则使用绑定分支或本地 HEAD。它不会 fetch、切换或修改真实仓库,公开只读链接也不能调用 AI。绑定配置由 ",s.jsx("code",{children:"GET/PUT /api/workflows/knowledge-bindings"})," 管理,问答使用 ",s.jsx("code",{children:"POST /api/workflows/query"}),",不会写入 ",s.jsx("code",{children:"globalState"}),"、Action、Artifact 或 extensions。"]})]})]}),s.jsxs("section",{className:"af-wr-section af-wr-ai",id:"ai",children:[s.jsx(Do,{number:"08",title:"给 AI 的接入引导",detail:"复制后交给 AI,它会先输出事实到页面区域的映射,再按真实协议实现。"}),s.jsx(Ts,{title:"$agentflow-workflow-report",value:YC,copyKey:"ai-bottom",copied:t,onCopy:o,wrap:!0})]})]})})}const Aae=[{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"}],Eae=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],Iae=[{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"}],Pae=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function ih({icon:e,title:t,label:n,tone:r="violet"}){return s.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[s.jsx("span",{className:"material-symbols-outlined",children:e}),s.jsxs("div",{children:[s.jsx("strong",{children:t}),s.jsx("small",{children:n})]})]})}function Tae(){return s.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[s.jsx("div",{className:"likee-scene-grid"}),s.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[s.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),s.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),s.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),s.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),s.jsx("div",{className:"likee-node-pos likee-node-a",children:s.jsx(ih,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),s.jsx("div",{className:"likee-node-pos likee-node-b",children:s.jsx(ih,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),s.jsx("div",{className:"likee-node-pos likee-node-c",children:s.jsx(ih,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),s.jsx("div",{className:"likee-node-pos likee-node-d",children:s.jsx(ih,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),s.jsxs("div",{className:"likee-phone-preview",children:[s.jsxs("div",{className:"likee-phone-top",children:[s.jsx("span",{children:"关注"}),s.jsx("strong",{children:"推荐"}),s.jsx("span",{children:"直播"})]}),s.jsxs("div",{className:"likee-phone-card",children:[s.jsx("div",{className:"likee-gift",children:"AD"}),s.jsx("h4",{children:"广告个性化引导弹框"}),s.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),s.jsx("button",{children:"继续"}),s.jsx("button",{className:"secondary",children:"稍后"})]})]}),s.jsxs("div",{className:"likee-display-panel",children:[s.jsxs("div",{className:"likee-panel-header",children:[s.jsx("span",{children:"DISPLAY"}),s.jsx("strong",{children:"需求资产面板"})]}),s.jsxs("div",{className:"likee-table-row",children:[s.jsx("span",{children:"需求"}),s.jsx("strong",{children:"首页广告个性化引导"})]}),s.jsxs("div",{className:"likee-table-row",children:[s.jsx("span",{children:"数据"}),s.jsx("strong",{children:"m09 PV Top 1"})]}),s.jsxs("div",{className:"likee-table-row",children:[s.jsx("span",{children:"同步"}),s.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function Mh({kicker:e,title:t,children:n}){return s.jsxs("div",{className:"likee-section-copy",children:[s.jsx("p",{className:"likee-section-kicker",children:e}),s.jsx("h2",{children:t}),s.jsx("p",{children:n})]})}function Rae(){return s.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:s.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[s.jsx(Mh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),s.jsx("div",{className:"likee-skill-grid",children:Iae.map(e=>s.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[s.jsxs("div",{className:"likee-skill-head",children:[s.jsx("div",{className:"likee-skill-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),s.jsxs("div",{children:[s.jsx("h3",{children:e.name}),s.jsx("span",{children:e.namespace})]})]}),s.jsx("div",{className:"likee-skill-mode",children:e.mode}),s.jsx("p",{children:e.usage}),s.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>s.jsx("strong",{children:t},t))})]},e.name))})]})})}function d$(){return s.jsxs("div",{className:"likee-page",children:[s.jsx("div",{className:"likee-top-actions",children:s.jsxs("a",{href:"/projects",className:"likee-home-link",children:[s.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),s.jsxs("section",{className:"likee-hero",children:[s.jsx(Tae,{}),s.jsxs("div",{className:"likee-hero-content",children:[s.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),s.jsx("h1",{children:"Likee Agent 工作台"}),s.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),s.jsxs("div",{className:"likee-signal-row",children:[s.jsx("span",{children:"查业务逻辑"}),s.jsx("span",{children:"查 CK / Hive"}),s.jsx("span",{children:"生成原型"}),s.jsx("span",{children:"生成 PRD"}),s.jsx("span",{children:"同步 TAPD / Git"})]}),s.jsxs("div",{className:"likee-hero-actions",children:[s.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),s.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),s.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),s.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),s.jsx("section",{id:"likee-scenarios",className:"likee-section",children:s.jsxs("div",{className:"likee-section-inner",children:[s.jsx(Mh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),s.jsx("div",{className:"likee-scenario-grid",children:Aae.map(e=>s.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[s.jsx("div",{className:"likee-scenario-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),s.jsxs("div",{children:[s.jsx("h3",{children:e.title}),s.jsx("p",{children:e.question})]}),s.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>s.jsx("span",{children:t},t))}),s.jsxs("div",{className:"likee-scenario-result",children:[s.jsx("span",{children:"产出"}),s.jsx("strong",{children:e.result})]})]},e.title))})]})}),s.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:s.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[s.jsx(Mh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),s.jsx("div",{className:"likee-usecase-stack",children:Eae.map(e=>s.jsxs("article",{className:"likee-usecase-card",children:[s.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>s.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),s.jsxs("div",{className:"likee-usecase-body",children:[s.jsx("div",{className:"likee-usecase-label",children:e.label}),s.jsx("h3",{children:e.title}),s.jsx("p",{children:e.trigger}),s.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>s.jsx("li",{children:t},t))}),s.jsxs("div",{className:"likee-usecase-output",children:[s.jsx("span",{children:"实际产物"}),s.jsx("div",{children:e.outputs.map(t=>s.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),s.jsx(Rae,{}),s.jsx("section",{className:"likee-section",children:s.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[s.jsx(Mh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),s.jsx("div",{className:"likee-capability-table",children:Pae.map(([e,t,n])=>s.jsxs("div",{className:"likee-capability-row",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t}),s.jsx("p",{children:n})]},e))})]})})]})}function f$(e){return t=>typeof t===e}var Mae=f$("function"),$ae=e=>e===null,XC=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",QC=e=>!Lae(e)&&!$ae(e)&&(Mae(e)||typeof e=="object"),Lae=f$("undefined");function Oae(e,t,n){return Vae(n,e,t)?!0:(Kae(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Dae(e,t,n):e instanceof Map&&t instanceof Map?Wae(e,t,n):e instanceof Set&&t instanceof Set?Hae(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?Fae(e,t):XC(e)&&XC(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?zae(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Bae(e,t,n))}function $f(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!QC(e)||!t||!QC(t)?!1:Oae(e,t,n)}function Dae(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let i=r;i--!==0;)if(!$f(e[i],t[i],n))return!1;return!0}function Fae(e,t){if(e.byteLength!==t.byteLength)return!1;const n=new DataView(e.buffer),r=new DataView(t.buffer);let i=e.byteLength;for(;i--;)if(n.getUint8(i)!==r.getUint8(i))return!1;return!0}function zae(e,t,n){return e.message===t.message&&e.name===t.name&&$f(e.cause,t.cause,n)}function Wae(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(!$f(r[1],t.get(r[0]),n))return!1;return!0}function Bae(e,t,n){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let i=r.length;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[i]))return!1;for(let i=r.length;i--!==0;){const o=r[i];if(!(o==="_owner"&&e.$$typeof)&&!$f(e[o],t[o],n))return!1}return!0}function Hae(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 Vae(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Kae(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function zv(e,t){return $f(e,t,new WeakMap)}function Dw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function qae(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Uae(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Gae(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Yae(e,t){const n=Gae();m.useEffect(()=>{if(!n)return e()},t)}function p$(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function Jae(e,t){const n=m.useRef(t);return zv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Xae(e){m.useEffect(()=>{e()},[])}function Qae(e=0){const[t,n]=m.useState({height:Dw()?window.innerHeight:0,width:Dw()?window.innerWidth:0}),r=m.useRef(0),i=m.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return m.useEffect(()=>{if(!Dw())return()=>{};const o=i.current;return n({height:window.innerHeight,width:window.innerWidth}),Uae(window,"resize",o),()=>{qae(window,"resize",o)}},[]),t}var Zae=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],ele=["bigint","boolean","null","number","string","symbol","undefined"];function Lf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(tle(t))return t}function gi(e){return t=>Lf(t)===e}function tle(e){return Zae.includes(e)}function iu(e){return t=>typeof t===e}function nle(e){return ele.includes(e)}var rle=["innerHTML","ownerDocument","style","attributes","nodeValue"],Of=e=>Array.isArray(e),sle=e=>Lf(e)==="AsyncGeneratorFunction",ile=gi("AsyncFunction"),ole=iu("bigint"),ale=e=>e===!0||e===!1,lle=gi("Date"),cle=gi("Error"),pa=iu("function"),ule=gi("GeneratorFunction"),dle=e=>typeof e=="number"&&Number.isInteger(e),Wb=gi("Map"),h$=e=>Number.isNaN(e),Wv=e=>e===null,m$=gi("Function"),fle=gi("Promise"),ple=gi("RegExp"),Bb=gi("Set"),Df=iu("string"),hle=iu("symbol"),Bv=iu("undefined"),mle=gi("WeakMap"),gle=gi("WeakSet"),Hv=e=>Wv(e)||Bv(e),g$=e=>!Bv(e),yle=e=>iu("number")(e)&&!h$(e),wle=e=>Df(e)&&e.trim().length>0,xle=e=>{if(!Df(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},Ag=e=>!Hv(e)&&(pa(e)||typeof e=="object"),y$=e=>{if(Lf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},ble=e=>Wv(e)||nle(typeof e),kle=e=>Lf(e)==="URL",w$=e=>!Hv(e)&&pa(e[Symbol.iterator]),vle=e=>w$(e)&&pa(e.next)&&pa(e.throw),Sle=e=>pa(e)&&/^class\s/.test(e.toString()),jle=(e,t)=>!Of(e)||!pa(t)?!1:e.every(n=>t(n)),Nle=e=>Ag(e)&&!y$(e)&&e.nodeType===1&&Df(e.nodeName)&&rle.every(t=>t in e),_le=e=>Df(e)&&e.length===0||Of(e)&&e.length===0||Ag(e)&&!Wb(e)&&!Bb(e)&&Object.keys(e).length===0||Bb(e)&&e.size===0||Wb(e)&&e.size===0,Cle=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,Ale=(e,t)=>Of(e)?e.indexOf(t)>-1:!1,Ele=(e,t,n)=>{if(!Ag(e)||!t)return!1;const r=e[t];return pa(n)?n(r):g$(r)};function Et(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(Of(e))return"Array";if(m$(e))return"Function";const t=Lf(e);return t||"Object"}Et.array=Of;Et.arrayOf=jle;Et.asyncGeneratorFunction=sle;Et.asyncFunction=ile;Et.bigint=ole;Et.boolean=ale;Et.class=Sle;Et.date=lle;Et.defined=g$;Et.domElement=Nle;Et.empty=_le;Et.error=cle;Et.function=pa;Et.generator=vle;Et.generatorFunction=ule;Et.instanceOf=Cle;Et.integer=dle;Et.iterable=w$;Et.map=Wb;Et.nan=h$;Et.null=Wv;Et.nullOrUndefined=Hv;Et.nonEmptyString=wle;Et.number=yle;Et.numericString=xle;Et.object=Ag;Et.oneOf=Ale;Et.plainFunction=m$;Et.plainObject=y$;Et.primitive=ble;Et.promise=fle;Et.propertyOf=Ele;Et.regexp=ple;Et.set=Bb;Et.string=Df;Et.symbol=hle;Et.undefined=Bv;Et.url=kle;Et.weakMap=mle;Et.weakSet=gle;var $r=Et;/* v8 ignore next -- @preserve */var Ile=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},Ple=function(e,t){return e+yf(t)},yf=function(e){return e===null||typeof e=="boolean"||typeof e>"u"?"":typeof e=="number"?e.toString():typeof e=="string"?e:Array.isArray(e)?e.reduce(Ple,""):Ile(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?yf(e.props.children):""};yf.default=yf;var Tle=yf;const Fw=ma(Tle);var x$={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(o){return typeof o=="object"&&o!==null&&!(o instanceof RegExp)&&!(o instanceof Date)}}function r(i){function o(S){return S!=="constructor"&&S!=="prototype"&&S!=="__proto__"}function a(S){let N=0;const I=S.length,T=new Array(I);for(N;N<I;++N)T[N]=g(S[N]);return T}function l(S){const N={};if(d&&Object.getPrototypeOf(S)!==t)return d(S);const I=f(S);let T,z,E;for(T=0,z=I.length;T<z;++T)o(E=I[T])&&(N[E]=g(S[E]));return N}function c(S,N){const I=S.length,T=N.length;let z=0;const E=new Array(I+T);for(z;z<I;++z)E[z]=g(S[z]);for(z=0;z<T;++z)E[z+I]=g(N[z]);return E}const u=Object.prototype.propertyIsEnumerable;function p(S){const N=Object.keys(S),I=Object.getOwnPropertySymbols(S);for(let T=0,z=I.length;T<z;++T)u.call(S,I[T])&&N.push(I[T]);return N}const f=i!=null&&i.symbols?p:Object.keys,d=typeof(i==null?void 0:i.cloneProtoObject)=="function"?i.cloneProtoObject:void 0,h=typeof(i==null?void 0:i.isMergeableObject)=="function"?i.isMergeableObject:n(),y=(i==null?void 0:i.onlyDefinedProperties)===!0;function v(S){return typeof S!="object"||S===null}const b=i&&typeof i.mergeArray=="function"?i.mergeArray({clone:g,deepmerge:x,getKeys:f,isMergeableObject:h}):c;function g(S){return h(S)?Array.isArray(S)?a(S):l(S):S}function k(S,N){const I={},T=f(S),z=f(N);let E,O,D;for(E=0,O=T.length;E<O;++E)o(D=T[E])&&z.indexOf(D)===-1&&(I[D]=g(S[D]));for(E=0,O=z.length;E<O;++E)if(o(D=z[E]))if(D in S)T.indexOf(D)!==-1&&(d&&h(N[D])&&Object.getPrototypeOf(N[D])!==t?I[D]=d(N[D]):I[D]=x(S[D],N[D]));else{if(y&&typeof N[D]>"u")continue;I[D]=g(N[D])}return I}function x(S,N){if(y&&typeof N>"u")return g(S);const I=Array.isArray(N),T=Array.isArray(S);return v(N)?N:h(S)?I&&T?b(S,N):I!==T?g(N):k(S,N):g(N)}function _(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let S;for(let N=0,I=arguments.length;N<I;++N)S=x(S,arguments[N]);return S}return i!=null&&i.all?_:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(x$);var Rle=x$.exports;const Mle=ma(Rle);var $le=new Error("Element already at target scroll position"),Lle=new Error("Scroll cancelled"),Ole=Math.min,ZC=Date.now,Dle={left:eA("scrollLeft"),top:eA("scrollTop")};function eA(e){return function(n,r,i,o){i=i||{},typeof i=="function"&&(o=i,i={}),typeof o!="function"&&(o=zle);var a=ZC(),l=n[e],c=i.ease||Fle,u=isNaN(i.duration)?350:+i.duration,p=!1;return l===r?o($le,n[e]):requestAnimationFrame(d),f;function f(){p=!0}function d(h){if(p)return o(Lle,n[e]);var y=ZC(),v=Ole(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(d):requestAnimationFrame(function(){o(null,n[e])})}}}function Fle(e){return .5*(1-Math.cos(Math.PI*e))}function zle(){}const Wle=ma(Dle);var b$={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(Td,function(){function t(r){var i=getComputedStyle(r,null).getPropertyValue("overflow");return i.indexOf("scroll")>-1||i.indexOf("auto")>-1}function n(r){if(r instanceof HTMLElement||r instanceof SVGElement){for(var i=r.parentNode;i.parentNode;){if(t(i))return i;i=i.parentNode}return document.scrollingElement||document.documentElement}}return n})})(b$);var Ble=b$.exports;const k$=ma(Ble),Hle=["top","right","bottom","left"],tA=["start","end"],nA=Hle.reduce((e,t)=>e.concat(t,t+"-"+tA[0],t+"-"+tA[1]),[]),Yc=Math.min,Za=Math.max,Dm=Math.round,oh=Math.floor,Di=e=>({x:e,y:e}),Vle={left:"right",right:"left",bottom:"top",top:"bottom"};function Hb(e,t,n){return Za(e,Yc(t,n))}function ou(e,t){return typeof e=="function"?e(t):e}function xo(e){return e.split("-")[0]}function Fi(e){return e.split("-")[1]}function v$(e){return e==="x"?"y":"x"}function Vv(e){return e==="y"?"height":"width"}function Jo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Kv(e){return v$(Jo(e))}function S$(e,t,n){n===void 0&&(n=!1);const r=Fi(e),i=Kv(e),o=Vv(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=zm(a)),[a,zm(a)]}function Kle(e){const t=zm(e);return[Fm(e),t,Fm(t)]}function Fm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const rA=["left","right"],sA=["right","left"],qle=["top","bottom"],Ule=["bottom","top"];function Gle(e,t,n){switch(e){case"top":case"bottom":return n?t?sA:rA:t?rA:sA;case"left":case"right":return t?qle:Ule;default:return[]}}function Yle(e,t,n,r){const i=Fi(e);let o=Gle(xo(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map(Fm)))),o}function zm(e){const t=xo(e);return Vle[t]+e.slice(t.length)}function Jle(e){return{top:0,right:0,bottom:0,left:0,...e}}function j$(e){return typeof e!="number"?Jle(e):{top:e,right:e,bottom:e,left:e}}function Wm(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function iA(e,t,n){let{reference:r,floating:i}=e;const o=Jo(t),a=Kv(t),l=Vv(a),c=xo(t),u=o==="y",p=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,d=r[l]/2-i[l]/2;let h;switch(c){case"top":h={x:p,y:r.y-i.height};break;case"bottom":h={x:p,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-i.width,y:f};break;default:h={x:r.x,y:r.y}}switch(Fi(t)){case"start":h[a]-=d*(n&&u?-1:1);break;case"end":h[a]+=d*(n&&u?-1:1);break}return h}async function Xle(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=ou(t,e),y=j$(h),b=l[d?f==="floating"?"reference":"floating":f],g=Wm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:p,strategy:c})),k=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),_=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},S=Wm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-S.top+y.top)/_.y,bottom:(S.bottom-g.bottom+y.bottom)/_.y,left:(g.left-S.left+y.left)/_.x,right:(S.right-g.right+y.right)/_.x}}const Qle=50,Zle=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Xle},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:p,y:f}=iA(u,r,c),d=r,h=0;const y={};for(let v=0;v<o.length;v++){const b=o[v];if(!b)continue;const{name:g,fn:k}=b,{x,y:_,data:S,reset:N}=await k({x:p,y:f,initialPlacement:r,placement:d,strategy:i,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});p=x??p,f=_??f,y[g]={...y[g],...S},N&&h<Qle&&(h++,typeof N=="object"&&(N.placement&&(d=N.placement),N.rects&&(u=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:p,y:f}=iA(u,d,c)),v=-1)}return{x:p,y:f,placement:d,strategy:i,middlewareData:y}},ece=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:p=0}=ou(e,t)||{};if(u==null)return{};const f=j$(p),d={x:n,y:r},h=Kv(i),y=Vv(h),v=await a.getDimensions(u),b=h==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",_=o.reference[y]+o.reference[h]-d[h]-o.floating[y],S=d[h]-o.reference[h],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[x]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=l.floating[x]||o.floating[y]);const T=_/2-S/2,z=I/2-v[y]/2-1,E=Yc(f[g],z),O=Yc(f[k],z),D=E,L=I-v[y]-O,$=I/2-v[y]/2+T,V=Hb(D,$,L),B=!c.arrow&&Fi(i)!=null&&$!==V&&o.reference[y]/2-($<D?E:O)-v[y]/2<0,F=B?$<D?$-D:$-L:0;return{[h]:d[h]+F,data:{[h]:V,centerOffset:$-V-F,...B&&{alignmentOffset:F}},reset:B}}});function tce(e,t,n){return(e?[...n.filter(i=>Fi(i)===e),...n.filter(i=>Fi(i)!==e)]:n.filter(i=>xo(i)===i)).filter(i=>e?Fi(i)===e||(t?Fm(i)!==i:!1):!0)}const nce=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,i;const{rects:o,middlewareData:a,placement:l,platform:c,elements:u}=t,{crossAxis:p=!1,alignment:f,allowedPlacements:d=nA,autoAlignment:h=!0,...y}=ou(e,t),v=f!==void 0||d===nA?tce(f||null,h,d):d,b=await c.detectOverflow(t,y),g=((n=a.autoPlacement)==null?void 0:n.index)||0,k=v[g];if(k==null)return{};const x=S$(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const _=[b[xo(k)],b[x[0]],b[x[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:_}],N=v[g+1];if(N)return{data:{index:g+1,overflows:S},reset:{placement:N}};const I=S.map(E=>{const O=Fi(E.placement);return[E.placement,O&&p?E.overflows.slice(0,2).reduce((D,L)=>D+L,0):E.overflows[0],E.overflows]}).sort((E,O)=>E[1]-O[1]),z=((i=I.filter(E=>E[2].slice(0,Fi(E[0])?2:3).every(O=>O<=0))[0])==null?void 0:i[0])||I[0][0];return z!==l?{data:{index:g+1,overflows:S},reset:{placement:z}}:{}}}},rce=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:p=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=ou(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=xo(i),k=Jo(l),x=xo(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=d||(x||!v?[zm(l)]:Kle(l)),N=y!=="none";!d&&N&&S.push(...Yle(l,v,y,_));const I=[l,...S],T=await c.detectOverflow(t,b),z=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(p&&z.push(T[g]),f){const $=S$(i,a,_);z.push(T[$[0]],T[$[1]])}if(E=[...E,{placement:i,overflows:z}],!z.every($=>$<=0)){var O,D;const $=(((O=o.flip)==null?void 0:O.index)||0)+1,V=I[$];if(V&&(!(f==="alignment"?k!==Jo(V):!1)||E.every(R=>Jo(R.placement)===k?R.overflows[0]>0:!0)))return{data:{index:$,overflows:E},reset:{placement:V}};let B=(D=E.filter(F=>F.overflows[0]<=0).sort((F,R)=>F.overflows[1]-R.overflows[1])[0])==null?void 0:D.placement;if(!B)switch(h){case"bestFit":{var L;const F=(L=E.filter(R=>{if(N){const H=Jo(R.placement);return H===k||H==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(H=>H>0).reduce((H,A)=>H+A,0)]).sort((R,H)=>R[1]-H[1])[0])==null?void 0:L[0];F&&(B=F);break}case"initialPlacement":B=l;break}if(i!==B)return{reset:{placement:B}}}return{}}}},sce=new Set(["left","top"]);async function ice(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=xo(n),l=Fi(n),c=Jo(n)==="y",u=sce.has(a)?-1:1,p=o&&c?-1:1,f=ou(t,e);let{mainAxis:d,crossAxis:h,alignmentAxis:y}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*p,y:d*u}:{x:d*u,y:h*p}}const oce=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:l}=t,c=await ice(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}}},ace=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:o}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:g=>{let{x:k,y:x}=g;return{x:k,y:x}}},...u}=ou(e,t),p={x:n,y:r},f=await o.detectOverflow(t,u),d=Jo(xo(i)),h=v$(d);let y=p[h],v=p[d];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",x=y+f[g],_=y-f[k];y=Hb(x,y,_)}if(l){const g=d==="y"?"top":"left",k=d==="y"?"bottom":"right",x=v+f[g],_=v-f[k];v=Hb(x,v,_)}const b=c.fn({...t,[h]:y,[d]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[d]:l}}}}}};function Eg(){return typeof window<"u"}function au(e){return N$(e)?(e.nodeName||"").toLowerCase():"#document"}function xs(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Hi(e){var t;return(t=(N$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function N$(e){return Eg()?e instanceof Node||e instanceof xs(e).Node:!1}function pi(e){return Eg()?e instanceof Element||e instanceof xs(e).Element:!1}function So(e){return Eg()?e instanceof HTMLElement||e instanceof xs(e).HTMLElement:!1}function oA(e){return!Eg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xs(e).ShadowRoot}function Ff(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=hi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function lce(e){return/^(table|td|th)$/.test(au(e))}function Ig(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const cce=/transform|translate|scale|rotate|perspective|filter/,uce=/paint|layout|strict|content/,Ra=e=>!!e&&e!=="none";let zw;function qv(e){const t=pi(e)?hi(e):e;return Ra(t.transform)||Ra(t.translate)||Ra(t.scale)||Ra(t.rotate)||Ra(t.perspective)||!Uv()&&(Ra(t.backdropFilter)||Ra(t.filter))||cce.test(t.willChange||"")||uce.test(t.contain||"")}function dce(e){let t=ha(e);for(;So(t)&&!Jc(t);){if(qv(t))return t;if(Ig(t))return null;t=ha(t)}return null}function Uv(){return zw==null&&(zw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),zw}function Jc(e){return/^(html|body|#document)$/.test(au(e))}function hi(e){return xs(e).getComputedStyle(e)}function Pg(e){return pi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ha(e){if(au(e)==="html")return e;const t=e.assignedSlot||e.parentNode||oA(e)&&e.host||Hi(e);return oA(t)?t.host:t}function _$(e){const t=ha(e);return Jc(t)?e.ownerDocument?e.ownerDocument.body:e.body:So(t)&&Ff(t)?t:_$(t)}function wf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=_$(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=xs(i);if(o){const l=Vb(a);return t.concat(a,a.visualViewport||[],Ff(i)?i:[],l&&n?wf(l):[])}else return t.concat(i,wf(i,[],n))}function Vb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function C$(e){const t=hi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=So(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=Dm(n)!==o||Dm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Gv(e){return pi(e)?e:e.contextElement}function Tc(e){const t=Gv(e);if(!So(t))return Di(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=C$(t);let a=(o?Dm(n.width):n.width)/r,l=(o?Dm(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const fce=Di(0);function A$(e){const t=xs(e);return!Uv()||!t.visualViewport?fce:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pce(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==xs(e)?!1:t}function ml(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=Gv(e);let a=Di(1);t&&(r?pi(r)&&(a=Tc(r)):a=Tc(e));const l=pce(o,n,r)?A$(o):Di(0);let c=(i.left+l.x)/a.x,u=(i.top+l.y)/a.y,p=i.width/a.x,f=i.height/a.y;if(o){const d=xs(o),h=r&&pi(r)?xs(r):r;let y=d,v=Vb(y);for(;v&&r&&h!==y;){const b=Tc(v),g=v.getBoundingClientRect(),k=hi(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,_=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,p*=b.x,f*=b.y,c+=x,u+=_,y=xs(v),v=Vb(y)}}return Wm({width:p,height:f,x:c,y:u})}function Tg(e,t){const n=Pg(e).scrollLeft;return t?t.left+n:ml(Hi(e)).left+n}function E$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Tg(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function hce(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Hi(r),l=t?Ig(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Di(1);const p=Di(0),f=So(r);if((f||!f&&!o)&&((au(r)!=="body"||Ff(a))&&(c=Pg(r)),f)){const h=ml(r);u=Tc(r),p.x=h.x+r.clientLeft,p.y=h.y+r.clientTop}const d=a&&!f&&!o?E$(a,c):Di(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+d.x,y:n.y*u.y-c.scrollTop*u.y+p.y+d.y}}function mce(e){return Array.from(e.getClientRects())}function gce(e){const t=Hi(e),n=Pg(e),r=e.ownerDocument.body,i=Za(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Za(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Tg(e);const l=-n.scrollTop;return hi(r).direction==="rtl"&&(a+=Za(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:l}}const aA=25;function yce(e,t){const n=xs(e),r=Hi(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(i){o=i.width,a=i.height;const p=Uv();(!p||p&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const u=Tg(r);if(u<=0){const p=r.ownerDocument,f=p.body,d=getComputedStyle(f),h=p.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,y=Math.abs(r.clientWidth-f.clientWidth-h);y<=aA&&(o-=y)}else u<=aA&&(o+=u);return{width:o,height:a,x:l,y:c}}function wce(e,t){const n=ml(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=So(e)?Tc(e):Di(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=i*o.x,u=r*o.y;return{width:a,height:l,x:c,y:u}}function lA(e,t,n){let r;if(t==="viewport")r=yce(e,n);else if(t==="document")r=gce(Hi(e));else if(pi(t))r=wce(t,n);else{const i=A$(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Wm(r)}function I$(e,t){const n=ha(e);return n===t||!pi(n)||Jc(n)?!1:hi(n).position==="fixed"||I$(n,t)}function xce(e,t){const n=t.get(e);if(n)return n;let r=wf(e,[],!1).filter(l=>pi(l)&&au(l)!=="body"),i=null;const o=hi(e).position==="fixed";let a=o?ha(e):e;for(;pi(a)&&!Jc(a);){const l=hi(a),c=qv(a);!c&&l.position==="fixed"&&(i=null),(o?!c&&!i:!c&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Ff(a)&&!c&&I$(e,a))?r=r.filter(p=>p!==a):i=l,a=ha(a)}return t.set(e,r),r}function bce(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Ig(t)?[]:xce(t,this._c):[].concat(n),r],l=lA(t,a[0],i);let c=l.top,u=l.right,p=l.bottom,f=l.left;for(let d=1;d<a.length;d++){const h=lA(t,a[d],i);c=Za(h.top,c),u=Yc(h.right,u),p=Yc(h.bottom,p),f=Za(h.left,f)}return{width:u-f,height:p-c,x:f,y:c}}function kce(e){const{width:t,height:n}=C$(e);return{width:t,height:n}}function vce(e,t,n){const r=So(t),i=Hi(t),o=n==="fixed",a=ml(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Di(0);function u(){c.x=Tg(i)}if(r||!r&&!o)if((au(t)!=="body"||Ff(i))&&(l=Pg(t)),r){const h=ml(t,!0,o,t);c.x=h.x+t.clientLeft,c.y=h.y+t.clientTop}else i&&u();o&&!r&&i&&u();const p=i&&!r&&!o?E$(i,l):Di(0),f=a.left+l.scrollLeft-c.x-p.x,d=a.top+l.scrollTop-c.y-p.y;return{x:f,y:d,width:a.width,height:a.height}}function Ww(e){return hi(e).position==="static"}function cA(e,t){if(!So(e)||hi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Hi(e)===n&&(n=n.ownerDocument.body),n}function P$(e,t){const n=xs(e);if(Ig(e))return n;if(!So(e)){let i=ha(e);for(;i&&!Jc(i);){if(pi(i)&&!Ww(i))return i;i=ha(i)}return n}let r=cA(e,t);for(;r&&lce(r)&&Ww(r);)r=cA(r,t);return r&&Jc(r)&&Ww(r)&&!qv(r)?n:r||dce(e)||n}const Sce=async function(e){const t=this.getOffsetParent||P$,n=this.getDimensions,r=await n(e.floating);return{reference:vce(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function jce(e){return hi(e).direction==="rtl"}const Nce={convertOffsetParentRelativeRectToViewportRelativeRect:hce,getDocumentElement:Hi,getClippingRect:bce,getOffsetParent:P$,getElementRects:Sce,getClientRects:mce,getDimensions:kce,getScale:Tc,isElement:pi,isRTL:jce};function T$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function _ce(e,t){let n=null,r;const i=Hi(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const u=e.getBoundingClientRect(),{left:p,top:f,width:d,height:h}=u;if(l||t(),!d||!h)return;const y=oh(f),v=oh(i.clientWidth-(p+d)),b=oh(i.clientHeight-(f+h)),g=oh(p),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:Za(0,Yc(1,c))||1};let _=!0;function S(N){const I=N[0].intersectionRatio;if(I!==c){if(!_)return a();I?a(!1,I):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!T$(u,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver(S,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return a(!0),o}function uA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=Gv(e),p=i||o?[...u?wf(u):[],...t?wf(t):[]]:[];p.forEach(g=>{i&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?_ce(u,n):null;let d=-1,h=null;a&&(h=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&h&&t&&(h.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?ml(e):null;c&&b();function b(){const g=ml(e);v&&!T$(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;p.forEach(k=>{i&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const Cce=oce,Ace=nce,Ece=ace,Ice=rce,dA=ece,Pce=(e,t,n)=>{const r=new Map,i={platform:Nce,...n},o={...i.platform,_c:r};return Zle(e,t,{...i,platform:o})};var Tce=typeof document<"u",Rce=function(){},$h=Tce?m.useLayoutEffect:Rce;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,i;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(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!Bm(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function R$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fA(e,t){const n=R$(e);return Math.round(t*n)/n}function Bw(e){const t=m.useRef(e);return $h(()=>{t.current=e}),t}function pA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[p,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,h]=m.useState(r);Bm(d,r)||h(r);const[y,v]=m.useState(null),[b,g]=m.useState(null),k=m.useCallback(R=>{R!==N.current&&(N.current=R,v(R))},[]),x=m.useCallback(R=>{R!==I.current&&(I.current=R,g(R))},[]),_=o||y,S=a||b,N=m.useRef(null),I=m.useRef(null),T=m.useRef(p),z=c!=null,E=Bw(c),O=Bw(i),D=Bw(u),L=m.useCallback(()=>{if(!N.current||!I.current)return;const R={placement:t,strategy:n,middleware:d};O.current&&(R.platform=O.current),Pce(N.current,I.current,R).then(H=>{const A={...H,isPositioned:D.current!==!1};$.current&&!Bm(T.current,A)&&(T.current=A,ur.flushSync(()=>{f(A)}))})},[d,t,n,O,D]);$h(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(R=>({...R,isPositioned:!1})))},[u]);const $=m.useRef(!1);$h(()=>($.current=!0,()=>{$.current=!1}),[]),$h(()=>{if(_&&(N.current=_),S&&(I.current=S),_&&S){if(E.current)return E.current(_,S,L);L()}},[_,S,L,E,z]);const V=m.useMemo(()=>({reference:N,floating:I,setReference:k,setFloating:x}),[k,x]),B=m.useMemo(()=>({reference:_,floating:S}),[_,S]),F=m.useMemo(()=>{const R={position:n,left:0,top:0};if(!B.floating)return R;const H=fA(B.floating,p.x),A=fA(B.floating,p.y);return l?{...R,transform:"translate("+H+"px, "+A+"px)",...R$(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:A}},[n,l,B.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:L,refs:V,elements:B,floatingStyles:F}),[p,L,V,B,F])}const Mce=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?dA({element:r.current,padding:i}).fn(n):{}:r?dA({element:r,padding:i}).fn(n):{}}}},hA=(e,t)=>{const n=Cce(e);return{name:n.name,fn:n.fn,options:[e,t]}},$ce=(e,t)=>{const n=Ece(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lce=(e,t)=>{const n=Ice(e);return{name:n.name,fn:n.fn,options:[e,t]}},Oce=(e,t)=>{const n=Ace(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dce=(e,t)=>{const n=Mce(e);return{name:n.name,fn:n.fn,options:[e,t]}},Fce={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},zce={beaconOptions:{offset:-18}},M$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Wce={isFixed:!1,locale:M$,placement:"bottom"},Bce={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Vt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},wr={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"},Ze={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},_i={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},$t={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Hce="react-joyride-portal";function Vce(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function wc(...e){return Mle({all:!0,isMergeableObject:t=>!(!$r.plainObject(t)||m.isValidElement(t))})(...e)}function $$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function to(e,t={}){const{defaultValue:n,step:r,steps:i}=t;let o=Fw(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&i&&(o=o.replace("{current}",r.toString()).replace("{total}",i.toString()));else if(m.isValidElement(e)&&!Object.values(e.props).length&&$$(e.type)==="function")try{o=to(e.type({}),t)}catch{o=Fw(n)}else o=Fw(n);return o}function kr(e,t,n,...r){if(!e)return;const i=new Date,o=`${String(i.getHours()).padStart(2,"0")}:${String(i.getMinutes()).padStart(2,"0")}:${String(i.getSeconds()).padStart(2,"0")}.${String(i.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${o}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Kce(e,t){const n=Vce(t);return{...e,...n}}function xf(){}function qce(e){return Object.keys(e)}function Hm(e,...t){if(!$r.plainObject(e))throw new TypeError("Expected an object");const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&(t.includes(r)||(n[r]=e[r]));return n}function mA(e,...t){if(!$r.plainObject(e))throw new TypeError("Expected an object");if(!t.length)return e;const n={};for(const r in e)({}).hasOwnProperty.call(e,r)&&t.includes(r)&&(n[r]=e[r]);return n}function Kb(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if($$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:i}=e.props;if($r.string(i)&&i.includes("{current}"))return m.cloneElement(e,{children:r(i)});if(Array.isArray(i))return m.cloneElement(e,{children:i.map(o=>typeof o=="string"?r(o):Kb(o,t,n))});if($r.function(e.type)&&!Object.values(e.props).length)try{return Kb(e.type({}),t,n)}catch{return e}return e}function gA(e){return qce(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Yv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function yA(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 Jv(e){return e?e.getBoundingClientRect():null}function Uce(e=!1){const{body:t,documentElement:n}=document;if(!t||!n)return 0;if(e){const r=[t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight].sort((o,a)=>o-a),i=Math.floor(r.length/2);return r.length%2===0?(r[i-1]+r[i])/2:r[i]}return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}function Os(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 Gce(e,t,n){const r=Jv(e),i=lu(e),o=i?!i.isSameNode(rs()):!1,a=n??cu(e);let l=0,c=(r==null?void 0:r.top)??0;return o&&a?c=(r==null?void 0:r.top)??0:i instanceof HTMLElement&&(l=i.scrollTop,!o&&!a&&(c+=l),i.isSameNode(rs())||(c+=rs().scrollTop)),Math.floor(c-t)}function lu(e,t){if(!e)return rs();const n=k$(e);if(n){if(n.isSameNode(rs()))return t?document:rs();if(!(n.scrollHeight>n.offsetHeight))return rs()}return n}function Yce(e){const t=e.getBoundingClientRect(),n=rs(),r=t.top+t.height/2,i=window.innerHeight/2;return Math.max(0,n.scrollTop+r-i)}function Jce(e,t){if(!e)return 0;const n=k$(e)??rs(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,i=Jv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(L$(e)||Xce(e))){const p=e.getBoundingClientRect(),f=p.top-((i==null?void 0:i.top)??0),d=f+p.height,h=n.clientHeight,y=h*.2;f>=y&&d<=h-y?c=o:c=f+o}const u=Math.floor(c-t-r);return u<0?0:u}function Xce(e){return e.offsetParent!==document.body}function L$(e){if(!e)return!1;const t=lu(e);return t?!t.isSameNode(rs()):!1}function cu(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?cu(e.parentNode,t):!1}function ah(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 wA(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:i,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==Ze.TOOLTIP||r.placement==="center")return!1;const a=i!=null&&i.isConnected?lu(i):rs(),l=a?!a.isSameNode(rs()):!1;return(r.isFixed||cu(i))&&!l?!1:a.scrollHeight>a.clientHeight}function rs(){return document.scrollingElement??document.documentElement}function xA(e,t){const{duration:n,element:r}=t;let i=()=>{};const o=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;i=Wle.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:i,promise:o}}function Qce(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,i,o,a)=>i+i+o+o+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const O$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},lh={...O$,borderRadius:4,padding:8};function Zce(e,t){const{styles:n}=e,r=wc(n??{},t.styles??{});let{width:i}=t;Yv()&&(i=typeof i=="number"&&window.innerWidth<i?window.innerWidth-30:i);const o={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return wc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...O$,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(${Qce(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:{...lh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...lh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...lh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...lh,color:t.textColor,fontSize:14},floater:{display:"inline-block",filter:"drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))",maxWidth:"100%",transition:"opacity 0.3s"},loader:{alignItems:"center",display:"flex",height:48,inset:0,justifyContent:"center",pointerEvents:"none",position:"fixed",width:48,zIndex:t.zIndex+1},overlay:{...o,backgroundColor:t.overlayColor},spotlight:{},tooltip:{backgroundColor:t.backgroundColor,borderRadius:5,boxSizing:"border-box",color:t.textColor,fontSize:16,maxWidth:"100%",padding:12,position:"relative",width:i},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 eue=["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 Xv(e,t){if(!t)return null;const n=wc(Wce,mA(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=wc(Fce,e.options??{},mA(t,...eue)),i=Zce(e,{...n,...r}),o=wc(zce,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:wc(M$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:tue(r.spotlightPadding),styles:i}}function tue(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 nue(e,t,n){const{action:r}=t,i=n&&[Vt.PREV,Vt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||i}function D$(e,t=!1){return $r.plainObject(e)?e.target?!0:(kr(t,"tour","target is missing from the step"),!1):(kr(t,"tour","step must be an object"),!1)}function F$(e,t=!1){return $r.array(e)?e.every(n=>D$(n,t)):(kr(t,"tour","steps must be an array"),!1)}var rue=class{constructor(e){qn(this,"beaconPosition",null);qn(this,"debug");qn(this,"eventListeners",new Map);qn(this,"listeners",new Set);qn(this,"props");qn(this,"snapshot");qn(this,"state");qn(this,"steps");qn(this,"tooltipPosition",null);qn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});qn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);qn(this,"getServerSnapshot",()=>this.snapshot);qn(this,"getSnapshot",()=>this.snapshot);qn(this,"getEventState",()=>Hm(this.snapshot,"positioned"));qn(this,"getState",()=>Hm(this.snapshot,"positioned"));qn(this,"setPositionData",(e,t)=>{var r,i,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&kr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Ze.BEACON_BEFORE||this.state.lifecycle===Ze.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(o=(i=this.getStep())==null?void 0:i.floatingOptions)==null?void 0:o.onPosition;n&&n(t)});qn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});qn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});qn(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)}});qn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));qn(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,i=this.snapshot,o=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:o,lifecycle:e.lifecycle??this.state.lifecycle,origin:e.origin??null,positioned:e.positioned??this.state.positioned,scrolling:e.scrolling??this.state.scrolling,size:e.size??this.state.size,status:e.status??this.state.status,waiting:e.waiting??this.state.waiting},l=this.applyTransitions(a);if(this.state=l,!zv(i,l)){this.snapshot=Object.freeze({...l});for(const c of this.listeners)c(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},i=$r.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,i?(o=n,$r.number(t)&&kr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):$r.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&kr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Vt.INIT,controlled:i,index:o,lifecycle:Ze.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?$t.READY:$t.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===$t.WAITING&&e.size>0?{...e,status:$t.RUNNING}:e}getStep(e){return Xv(this.props,this.steps[e??this.state.index])}};function sue(e){return new rue(e)}function bA(e,t){return Math.min(Math.max(e,0),t)}function iue(e,t,n){const r=m.useRef(t),i=m.useRef(n);return r.current=t,i.current=n,m.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(b=null)=>{const{index:g,status:k}=o();k===$t.RUNNING&&e.current.updateState({action:Vt.CLOSE,index:g+1,origin:b,lifecycle:Ze.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:g,size:k,status:x}=o();if(g){kr(r.current,"tour","go() is not supported in controlled mode");return}x===$t.RUNNING&&e.current.updateState({action:Vt.GO,index:b,lifecycle:Ze.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:$t.FINISHED,waiting:!1})},info:()=>Hm(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===$t.RUNNING&&e.current.updateState({action:Vt.NEXT,index:bA(g+1,k),lifecycle:Ze.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===$t.RUNNING&&e.current.updateState({action:Vt.UPDATE,lifecycle:Ze.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===$t.RUNNING&&e.current.updateState({action:Vt.PREV,index:bA(g-1,k),lifecycle:Ze.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){kr(r.current,"tour","reset() is not supported in controlled mode");return}i.current(),e.current.updateState({action:Vt.RESET,index:0,lifecycle:Ze.INIT,positioned:!1,scrolling:!1,status:b?$t.RUNNING:$t.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===$t.RUNNING&&e.current.updateState({action:Vt.SKIP,lifecycle:Ze.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:$t.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();i.current(),e.current.updateState({action:Vt.START,index:$r.number(b)?b:g,lifecycle:Ze.INIT,positioned:!1,scrolling:!1,status:k?$t.RUNNING:$t.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[$t.FINISHED,$t.SKIPPED].includes(k)||e.current.updateState({action:Vt.STOP,index:g+(b?1:0),lifecycle:Ze.COMPLETE,positioned:!1,scrolling:!1,status:$t.PAUSED,waiting:!1})}}},[e])}const oue=new Set(["origin","positioned"]);function aue(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return kr(!0,"tour","init",r),n.current=r,e.current.subscribe(i=>{const o=n.current;if(n.current=i,!o)return;const a={};let l=!1;for(const c of Object.keys(i))i[c]!==o[c]&&!oue.has(c)&&(a[c]={from:o[c],to:i[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&i.index>=i.size||kr(!0,l?"tour":`step:${i.index}`,"state",a))})},[t,e])}function lue(e,t,n){const r=m.useRef(e),i=m.useRef(t);return r.current=e,i.current=t,m.useCallback((o,a,l)=>{var u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(u=r.current)==null||u.call(r,c,i.current),n.current.dispatch(c,i.current)},[n])}function Wo(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const i=e[n],o=t[n];return Array.isArray(r)?r.includes(i)&&!r.includes(o):i===r&&o!==r},previous:t}}function cue(e){const{addFailure:t,controls:n,emitEvent:r,previousState:i,props:o,state:a,step:l,store:c}=e,{action:u,index:p,lifecycle:f,positioned:d,scrolling:h,size:y,status:v}=a,b=p$(l)??null,g=m.useRef(null),k=m.useRef(o),x=m.useRef(a),_=m.useRef(i),S=m.useRef(l),N=m.useRef(b),I=m.useRef(n),T=m.useRef(null),z=m.useRef(null),E=m.useRef(null);k.current=o,x.current=a,_.current=i,S.current=l,N.current=b,I.current=n;const O=()=>{T.current&&(clearInterval(T.current),T.current=null),z.current=null,E.current&&(E.current.cancel(),E.current=null)};m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D}=Wo(x.current,_.current);(D("action",[Vt.NEXT,Vt.PREV,Vt.SKIP,Vt.CLOSE])||g.current===Vt.CLOSE&&u===Vt.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!_.current)return()=>{O()};const{hasChanged:D}=Wo(x.current,_.current),L=S.current;if(D("index")&&O(),v!==$t.RUNNING||!L||f!==Ze.INIT)return()=>{O()};const{hasChangedTo:$}=Wo(x.current,_.current);$("status",$t.RUNNING)&&[$t.IDLE,$t.READY,$t.PAUSED].includes(_.current.status)&&r(wr.TOUR_START,L),c.current.cleanupPositionData();const{debug:V}=k.current;if(L.before&&!E.current){kr(V,`step:${p}`,"before()",L),E.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(wr.STEP_BEFORE_HOOK,L,{action:g.current??x.current.action});const B=()=>{E.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:Ze.READY})},F=new AbortController,R=L.beforeTimeout;E.current={cancel:()=>F.abort()};const H=R?setTimeout(()=>{F.signal.aborted||(kr(V,`step:${p}`,"before()","timed out",`${R}ms`),F.abort(),t(L,"before_hook"),r(wr.ERROR,L,{error:new Error("Step before hook timed out")}),B())},R):null;L.before({...c.current.getState(),action:g.current??c.current.getState().action,step:L}).then(()=>{F.signal.aborted||(H&&clearTimeout(H),B())}).catch(A=>{F.signal.aborted||(H&&clearTimeout(H),t(L,"before_hook"),r(wr.ERROR,L,{error:A instanceof Error?A:new Error(String(A))}),B())})}else if(!E.current){T.current&&z.current!==L.target&&O();const B=Os(L.target);if(B&&ah(B))O(),c.current.updateState({action:g.current??Vt.UPDATE,lifecycle:Ze.READY,waiting:!1});else if(L.targetWaitTimeout===0)c.current.updateState({action:g.current??Vt.UPDATE,lifecycle:Ze.READY,waiting:!1});else if(!T.current){const{targetWaitTimeout:F}=L,R=Date.now();z.current=L.target,kr(V,`step:${p}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),T.current=setInterval(()=>{const H=Os(L.target),A=Date.now()-R,X=A>=F;(H&&ah(H)||X)&&(kr(V,`step:${p}`,"polling",H&&ah(H)?"found":"timed out",`${A}ms`),O(),c.current.updateState({action:g.current??Vt.UPDATE,lifecycle:Ze.READY,waiting:!1}))},100)}}return()=>{O()}},[t,r,p,f,v,c]),m.useEffect(()=>{if(!_.current)return;const{hasChanged:D,hasChangedTo:L,previous:$}=Wo(x.current,_.current),V=S.current;if(!V)return;const B=Os(V.target),F=!!B;if(F&&ah(B)){if(L("lifecycle",Ze.READY)&&$.lifecycle===Ze.INIT&&r(wr.STEP_BEFORE,V,{action:g.current??x.current.action}),L("lifecycle",Ze.READY)){const R=x.current,H=nue(V,R,k.current.continuous)?Ze.TOOLTIP:Ze.BEACON,A=Os(V.scrollTarget??V.spotlightTarget??V.target),X=wA({isFirstStep:R.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:V,target:A,targetLifecycle:H}),K=H===Ze.TOOLTIP?Ze.TOOLTIP_BEFORE:Ze.BEACON_BEFORE;kr(k.current.debug,`step:${p}`,"scroll",X?"needed":"skipped"),c.current.updateState({action:Vt.UPDATE,lifecycle:K,scrolling:X})}}else if(x.current.status===$t.RUNNING&&f!==Ze.INIT&&f!==Ze.COMPLETE&&D("lifecycle")){kr(k.current.debug,`step:${p}`,F?"Target not visible":"Target not mounted",V),t(V,"target_not_found"),r(wr.TARGET_NOT_FOUND,V);const R=x.current;R.controlled||c.current.updateState({action:Vt.UPDATE,index:R.index+(R.action===Vt.PREV?-1:1),lifecycle:Ze.INIT})}},[t,r,p,f,c]),m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D,previous:L}=Wo(x.current,_.current),$=S.current,V=N.current;if($&&D("lifecycle",Ze.TOOLTIP_BEFORE)&&L.lifecycle===Ze.BEACON){const R=Os($.scrollTarget??$.spotlightTarget??$.target);if(wA({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:$,target:R,targetLifecycle:Ze.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const B=f===Ze.BEACON_BEFORE||f===Ze.TOOLTIP_BEFORE;if($&&B&&!h){const R=f===Ze.TOOLTIP_BEFORE?Ze.TOOLTIP:Ze.BEACON;c.current.updateState({action:Vt.UPDATE,lifecycle:R})}$&&D("lifecycle",Ze.BEACON)&&r(wr.BEACON,$),$&&D("lifecycle",Ze.TOOLTIP)&&r(wr.TOOLTIP,$);const F=x.current;if((F.status===$t.RUNNING||F.controlled&&F.status===$t.PAUSED&&$)&&V&&D("lifecycle",Ze.COMPLETE)&&L.lifecycle===Ze.TOOLTIP&&(r(wr.STEP_AFTER,V,{action:g.current??Vt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle}),V.after)){r(wr.STEP_AFTER_HOOK,V,{action:g.current??Vt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle});try{V.after({...c.current.getState(),action:g.current??Vt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle,step:V})}catch{}}},[r,f,d,h,c]),m.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D,previous:L}=Wo(x.current,_.current),$=S.current,V=N.current;y&&!$&&f===Ze.INIT&&c.current.updateState({action:Vt.UPDATE,lifecycle:Ze.COMPLETE,status:$t.FINISHED}),!x.current.controlled&&v===$t.RUNNING&&D("lifecycle",Ze.COMPLETE)&&p<y&&c.current.updateState({action:Vt.UPDATE,lifecycle:Ze.INIT}),D("lifecycle",Ze.COMPLETE)&&p>=y&&c.current.updateState({action:Vt.UPDATE,lifecycle:Ze.COMPLETE,status:$t.FINISHED});const B=$??V??Xv(k.current,k.current.steps[p-1]);if(B&&D("status",[$t.FINISHED,$t.SKIPPED])){let F;$?F=p:V?F=L.index??p:F=p-1,r(wr.TOUR_END,B,{index:F}),x.current.controlled||I.current.reset(),g.current=null}$&&D("action",Vt.STOP)&&(g.current=null,r(wr.TOUR_STATUS,$)),$&&D("action",Vt.RESET)&&(r(wr.TOUR_STATUS,$),g.current=null)},[u,r,p,f,y,v,c])}function uue({controls:e,emitEvent:t,props:n,state:r,store:i}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,p=m.useRef(void 0),f=m.useRef(r),d=m.useRef(e);f.current=r,d.current=e,m.useEffect(()=>{const h=p.current;if(p.current=n,!h||n===h)return;const{hasChanged:y}=Wo(n,h);if(zv(h.steps,u)||(F$(u,o)?i.current.setSteps(u):(kr(o,"tour","Steps are not valid",u),t(wr.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),y("run"))l?i.current.getState().size&&d.current.start(c??a):d.current.stop();else if($r.number(c)&&y("stepIndex")){const v=$r.number(h.stepIndex)&&h.stepIndex<c?Vt.NEXT:Vt.PREV;[$t.FINISHED,$t.SKIPPED].includes(f.current.status)||i.current.updateState({action:v,index:c,lifecycle:Ze.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,i])}function due(e,t){var l,c,u,p;const{beaconPosition:n,lifecycle:r,scrollOffset:i,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===Ze.BEACON_BEFORE&&(n!=null&&n.placement)){const f=fue(n);["bottom"].includes(n.placement)||(a+=Math.floor(f-i))}else if(r===Ze.TOOLTIP_BEFORE){const{placement:f}=o;if(f==="top"){const d=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,h=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+h;a-=d+y}else if(f==="left"||f==="right"){const d=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,h=((p=Os(o.target))==null?void 0:p.getBoundingClientRect().height)??0,y=i+o.spotlightPadding.top+h/2-d/2;y<i&&(a-=i-y)}}return Math.max(0,a)}function fue(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 pue({emitEvent:e,previousState:t,props:n,state:r,step:i,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:p}=r,f=m.useRef(null),d=m.useRef(r),h=m.useRef(t),y=m.useRef(n),v=m.useRef(i);d.current=r,h.current=t,y.current=n,v.current=i,m.useEffect(()=>()=>{var b;(b=f.current)==null||b.call(f)},[]),m.useEffect(()=>{var S;if(!h.current||!v.current)return;const{hasChangedTo:b}=Wo(d.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,_=l===Ze.BEACON_BEFORE||l===Ze.TOOLTIP_BEFORE;if(p===$t.RUNNING&&_&&u&&b("positioned",!0)){const N=Os(g.scrollTarget??g.spotlightTarget??g.target),I=o.current.getPositionData("beacon"),T=lu(N),z=T?!T.isSameNode(rs()):!1;(S=f.current)==null||S.call(f),(async()=>{if(z&&!cu(T)){const F=rs(),R=Yce(T),H={initial:F.scrollTop,target:R,element:F,duration:x};e(wr.SCROLL_START,g,{scroll:H});const{cancel:A,promise:X}=xA(R,{element:F,duration:x});f.current=A,await X,e(wr.SCROLL_END,g,{scroll:H})}const O=Math.floor(Jce(N,g.scrollOffset))||0,D=z?O:due(O,{beaconPosition:I,lifecycle:l,scrollOffset:g.scrollOffset,step:g});kr(k,`step:${a}`,"scroll",z?"custom":"document",`${O} → ${D}`);const L=T,$={initial:L.scrollTop,target:D,element:L,duration:x};e(wr.SCROLL_START,g,{scroll:$});const{cancel:V,promise:B}=xA(D,{element:L,duration:x});f.current=V,await B,e(wr.SCROLL_END,g,{scroll:$}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,p,o])}function hue(e){const t=Jae(()=>Kce(Bce,e),[e]),{debug:n,initialStepIndex:r,onEvent:i,run:o,stepIndex:a,steps:l}=t,c=m.useRef(sue(t)),u=hT.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[p,f]=m.useState([]),d=m.useCallback((S,N)=>{f(I=>[...I,{reason:N,step:S}])},[]),h=m.useCallback(()=>{f([])},[]);aue(c,n);const y=iue(c,n,h),v=lue(i,y,c),{index:b,size:g,status:k}=u,x=p$(u),_=m.useMemo(()=>Xv(t,l[b]),[b,t,l]);return Xae(()=>{o&&g&&F$(l,n)&&y.start(a??r)}),Yae(()=>{o&&g&&k===$t.IDLE&&c.current.updateState({status:$t.READY})},[o,g,k]),uue({controls:y,emitEvent:v,props:t,state:u,store:c}),cue({addFailure:d,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),pue({emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),{controls:y,failures:p,mergedProps:t,state:u,step:_,store:c}}function mue(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,i=!1;if(e)if($r.domElement(e))r=e,i=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=Hce,document.body.appendChild(o),r=o}return n(r),()=>{!r||i||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const gue={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function yue({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return xf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
|
|
561
|
+
@keyframes joyride-loader-spin {
|
|
562
|
+
to { transform: rotate(360deg); }
|
|
563
|
+
}
|
|
564
|
+
`)),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:i,width:o,...a}=t.styles.loader;let l;if(n){const c=n;l=dt.createElement(c,{step:t})}else l=dt.createElement("div",{style:{...gue,height:i,width:o,borderTopColor:t.primaryColor}});return dt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const wue={height:0,isFixed:!1,left:0,top:0,width:0};function ed(e,t){const n=Os(e);if(!n)return wue;const r=Jv(n),i=cu(n),o=Gce(n,t.top,i);return{height:Math.round(((r==null?void 0:r.height)??0)+t.top+t.bottom),isFixed:i,left:Math.round(((r==null?void 0:r.left)??0)-t.left),top:o,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function xue(e,t,n){const[r,i]=m.useState(()=>ed(e,t)),o=m.useRef(void 0),a=m.useRef(null),l=m.useRef(n),c=m.useRef(null),u=m.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{i(f=>{const d=ed(e,t);return f.top===d.top&&f.left===d.left&&f.width===d.width&&f.height===d.height&&f.isFixed===d.isFixed?f:d})},100)},[e,t]);m.useEffect(()=>{let f=null;const d=y=>{a.current=lu(y,!0),a.current&&a.current.addEventListener("scroll",u,{passive:!0}),window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(u),c.current.observe(y)),i(ed(e,t))},h=Os(e);return h?d(h):(f=new MutationObserver(()=>{const y=Os(e);y&&(f==null||f.disconnect(),f=null,d(y))}),f.observe(document.body,{childList:!0,subtree:!0})),()=>{var y;f==null||f.disconnect(),a.current&&a.current.removeEventListener("scroll",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(y=c.current)==null||y.disconnect(),clearTimeout(o.current)}},[e,t,u]),m.useEffect(()=>{l.current&&!n&&i(ed(e,t)),l.current=n},[n,e,t]);let p=r;return l.current&&!n&&(p=ed(e,t)),p}function bue(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function kA(e,t,n,r,i){if(n<=0||r<=0)return"";const o=Math.max(0,Math.min(i,n/2,r/2));let a=`M${e+o} ${t}`;return a+=`H${e+n-o}`,a+=`A${o} ${o} 0 0 1 ${e+n} ${t+o}`,a+=`V${t+r-o}`,a+=`A${o} ${o} 0 0 1 ${e+n-o} ${t+r}`,a+=`H${e+o}`,a+=`A${o} ${o} 0 0 1 ${e} ${t+r-o}`,a+=`V${t+o}`,a+=`A${o} ${o} 0 0 1 ${e+o} ${t}Z`,a}const kue=[Ze.BEACON_BEFORE,Ze.BEACON];function vue(e){var B,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:i,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:p,spotlightRadius:f,spotlightTarget:d,styles:h,target:y,waiting:v}=e,b=Qae(),g=xue(d??y,p,u||v),k=m.useRef(null),x=(i===Ze.TOOLTIP||i===Ze.TOOLTIP_BEFORE)&&l!=="center",[_,S]=m.useState(!1),N=c?(B=k.current)==null?void 0:B.offsetParent:null,I=(N==null?void 0:N.clientWidth)??b.width,T=(N==null?void 0:N.clientHeight)??Uce()??b.height,z=((F=h.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",E=m.useMemo(()=>{const{backgroundColor:R,mixBlendMode:H,...A}=h.overlay;return{height:T,pointerEvents:"none",...A}},[T,h.overlay]),O=x&&!u&&!v;m.useEffect(()=>{O?requestAnimationFrame(()=>S(!0)):S(!1)},[O]);const D=n&&kue.includes(i),L=!n&&i!==Ze.TOOLTIP;if(r||!v&&(D||L))return null;let $="";if(O)if(c&&N){const R=Os(d??y);if(R){const H=yA(R),A=yA(N);$=kA(H.left-A.left-p.left,H.top-A.top-p.top,R.offsetWidth+p.left+p.right,R.offsetHeight+p.top+p.bottom,f)}}else $=kA(g.left,g.top,g.width,g.height,f);const V=bue(I,T,$);return dt.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:E},dt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:T,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:I}},dt.createElement("path",{d:V,fill:z,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),$&&dt.createElement("path",{d:$,fill:z,style:{opacity:_?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),$&&Object.keys(h.spotlight).length>0&&dt.createElement("path",{d:$,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function z$(e){const{children:t,element:n}=e;return n?ur.createPortal(t,n):null}const Sue='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function jue(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return xf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Sue)],{shiftKey:l}=o;if(!a.length)return;o.preventDefault();let c=document.activeElement?a.indexOf(document.activeElement):0;c===-1||!l&&c+1===a.length?c=0:l&&c===0?c=a.length-1:c+=l?-1:1,a[c].focus()};e.addEventListener("keydown",r,!1);let i;{const o=e.querySelector(t);o&&(i=setTimeout(()=>{o.focus({preventScroll:!0})},100))}return()=>{var o;e.removeEventListener("keydown",r),i!==void 0&&clearTimeout(i),(o=n.current)==null||o.focus({preventScroll:!0})}},[e,t])}function oo(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 Nue(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...oo(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...oo(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...oo(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...oo(e,t,n)};default:return null}}function _ue(e,t,n,r){if(!t)return{};const[i]=e.split("-");switch(i){case"top":return{bottom:-n,left:t.x??0,...oo(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...oo(e,r,n)};case"left":return{right:-n,top:t.y??0,...oo(e,r,n)};case"right":return{left:-n,top:t.y??0,...oo(e,r,n)};default:return{}}}function Cue({arrowComponent:e,arrowRef:t,base:n,placement:r,position:i,size:o,styles:a}){const l=e;let c=null;if(l){if(!oo(r,n,o))return null;c=dt.createElement("span",{style:{flexShrink:0}},dt.createElement(l,{base:n,placement:r,size:o}))}else{const u=Nue(r,n,o);if(!u)return null;c=dt.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},dt.createElement("polygon",{fill:"currentColor",points:u.points}))}return dt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,..._ue(r,i,o,n),...i?{}:{visibility:"hidden"}}},c)}function Aue(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:i,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:p,styles:f}=e,d=m.useRef(null),h=!!t;m.useEffect(()=>{if(h||document.getElementById("joyride-beacon-animation"))return xf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
|
|
565
|
+
@keyframes joyride-beacon-inner {
|
|
566
|
+
20% {
|
|
567
|
+
opacity: 0.9;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
90% {
|
|
571
|
+
opacity: 0.7;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
@keyframes joyride-beacon-outer {
|
|
576
|
+
0% {
|
|
577
|
+
transform: scale(1);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
45% {
|
|
581
|
+
opacity: 0.7;
|
|
582
|
+
transform: scale(0.75);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
100% {
|
|
586
|
+
opacity: 0.9;
|
|
587
|
+
transform: scale(1);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
`)),document.head.appendChild(b);const g=setTimeout(()=>{$r.domElement(d.current)&&c&&d.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[h,a,c]);const y=to(o.open);let v;if(t){const b=t;v=dt.createElement(b,{continuous:n,index:r,isLastStep:i,size:u,step:p})}else v=dt.createElement("span",{style:f.beacon},dt.createElement("span",{style:f.beaconOuter}),dt.createElement("span",{style:f.beaconInner}));return dt.createElement("button",{ref:d,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function Eue({styles:e,...t}){const{color:n,height:r,width:i,...o}=e;return dt.createElement("button",{style:o,type:"button",...t},dt.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof i=="number"?`${i}px`:i,xmlns:"http://www.w3.org/2000/svg"},dt.createElement("g",null,dt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Iue(e){const{backProps:t,closeProps:n,index:r,isLastStep:i,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:p,styles:f,title:d}=l,h={};u.includes("primary")&&(h.primary=dt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!i&&(h.skip=dt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=dt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&dt.createElement(Eue,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":to(p),"aria-describedby":"joyride-tooltip-content"};return dt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},dt.createElement("div",{style:f.tooltipContainer},d&&dt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},d),dt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},p)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&dt.createElement("div",{style:f.tooltipFooter},dt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Pue(e){const{continuous:t,controls:n,index:r,isLastStep:i,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(_i.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(_i.BUTTON_CLOSE):n.close(_i.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(_i.BUTTON_PRIMARY);return}n.next(_i.BUTTON_PRIMARY)},p=g=>{g.preventDefault(),n.skip(_i.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:_,nextWithProgress:S,skip:N}=a.locale,I=to(g),T=to(k),z=to(x),E=to(_),O=to(N);let D=k,L=T;if(t){if(D=_,L=E,a.showProgress&&!i){const $=to(S,{step:r+1,steps:o});D=Kb(S,r+1,o),L=$}i&&(D=x,L=z)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":T,children:k,"data-action":"close",onClick:c,role:"button",title:T},primaryProps:{"aria-label":L,children:D,"data-action":"primary",onClick:u,role:"button",title:L},skipProps:{"aria-label":O,children:N,"data-action":"skip",onClick:p,role:"button",title:O},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=dt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v})}else b=dt.createElement(Iue,{...f(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v});return b}function Tue(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function Rue(e,t,n){var r,i;return e?[Oce()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[Lce({crossAxis:!1,fallbackPlacements:Tue(n),padding:20,...(i=t.floatingOptions)==null?void 0:i.flipOptions})]}function Mue(e){var H,A,X,K,W;const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:p,size:f,step:d,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=d.placement==="center",x=d.placement==="auto",_=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})}),[]),S=m.useMemo(()=>L$(h)?lu(h):void 0,[h]),N=m.useMemo(()=>cu(h),[h]),I=m.useMemo(()=>S?{boundary:S,rootBoundary:"viewport"}:{},[S]),T=k||x?"bottom":d.placement,z=k?"fixed":((H=d.floatingOptions)==null?void 0:H.strategy)??(d.isFixed||N?"fixed":"absolute"),E=m.useMemo(()=>{var te,ee,G,ne;return k?[{name:"center",fn:({rects:re})=>({x:(window.innerWidth-re.floating.width)/2,y:(window.innerHeight-re.floating.height)/2})}]:[hA(({placement:re})=>{var de;let ie="right";re.startsWith("top")?ie="top":re.startsWith("bottom")?ie="bottom":re.startsWith("left")&&(ie="left");const Z=d.spotlightTarget?0:d.spotlightPadding[ie];return d.offset+Z+((de=d.floatingOptions)!=null&&de.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(te=d.floatingOptions)==null?void 0:te.hideArrow]),...Rue(x,d,T),$ce({padding:10,...I,...(ee=d.floatingOptions)==null?void 0:ee.shiftOptions}),...(G=d.floatingOptions)!=null&&G.hideArrow?[]:[Dce({element:v,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((ne=d.floatingOptions)==null?void 0:ne.middleware)??[]]},[k,d,x,T,I]),O=pA({...k?{elements:{reference:_}}:{},placement:T,strategy:z,middleware:E}),D=pA({strategy:z,placement:d.beaconPlacement??(x||k?"bottom":d.placement),middleware:m.useMemo(()=>{var te,ee;return[hA(((ee=(te=d.floatingOptions)==null?void 0:te.beaconOptions)==null?void 0:ee.offset)??-18)]},[(X=(A=d.floatingOptions)==null?void 0:A.beaconOptions)==null?void 0:X.offset]),whileElementsMounted:uA});g.current=O.middlewareData,b.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:te,reference:ee}=O.elements;if(!(!ee||!te||i!==Ze.TOOLTIP))return uA(ee,te,O.update,(G=d.floatingOptions)==null?void 0:G.autoUpdate)},[i,O.update,(K=d.floatingOptions)==null?void 0:K.autoUpdate,d.target,O.elements]),m.useEffect(()=>{!k&&h&&O.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,O.refs]),m.useEffect(()=>{O.isPositioned&&c("tooltip",{placement:O.placement,x:O.x??0,y:O.y??0,middlewareData:g.current})},[c,O.isPositioned,O.placement,O.x,O.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const L=d.zIndex+100,$=m.useCallback(te=>{te.type==="mouseenter"&&d.beaconTrigger!=="hover"||y({lifecycle:Ze.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,y]),V=m.useCallback(te=>{te&&(O.refs.setFloating(te),u(te))},[O.refs,u]),{arrow:B,floater:F}=d.styles;let R=null;if(i===Ze.TOOLTIP||i===Ze.TOOLTIP_BEFORE){const te=gA({...F,...O.floatingStyles,zIndex:L,opacity:a&&O.isPositioned?1:0,...!a&&{transition:"none"}});R=dt.createElement("div",{ref:V,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:te},dt.createElement(Pue,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:d}),!k&&!((W=d.floatingOptions)!=null&&W.hideArrow)&&dt.createElement(Cue,{arrowComponent:d.arrowComponent,arrowRef:v,base:d.arrowBase,placement:O.placement,position:O.middlewareData.arrow,size:d.arrowSize,styles:B}))}else(i===Ze.BEACON||i===Ze.BEACON_BEFORE)&&(R=dt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:gA({...D.floatingStyles,zIndex:L})},dt.createElement(Aue,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:d.locale,nonce:o,onInteract:$,shouldFocus:p,size:f,step:d,styles:d.styles})));return dt.createElement(z$,{element:l},R)}function $ue(e){const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:p,updateState:f}=e,[d,h]=m.useState(null);jue(p.disableFocusTrap?null:d,"[data-action=primary]");const y=Os(p.target),v=i===Ze.TOOLTIP;return!D$(p)||!$r.domElement(y)?null:dt.createElement(Mue,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:p,target:y,updateState:f})}function Lue({controls:e,mergedProps:t,state:n,step:r,store:i}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,p=mue(c),{index:f,lifecycle:d,status:h}=n,y=h===$t.RUNNING,[v,b]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const S=N=>{!r||d!==Ze.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(_i.KEYBOARD):e.close(_i.KEYBOARD))};return document.body.addEventListener("keydown",S,{passive:!0}),()=>{document.body.removeEventListener("keydown",S)}},[e,y,d,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(_i.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(_i.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const _=n.action===Vt.START&&!r.skipBeacon&&r.placement!=="center";return dt.createElement(dt.Fragment,null,d!==Ze.INIT&&dt.createElement($ue,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:p,setPositionData:i.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:i.current.updateState}),dt.createElement(z$,{element:p},dt.createElement(dt.Fragment,null,v&&dt.createElement(yue,{nonce:l,step:r}),!_&&dt.createElement(vue,{...r,continuous:o,lifecycle:d,onClickOverlay:x,portalElement:c?p:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Oue(e){const{controls:t,failures:n,mergedProps:r,state:i,step:o,store:a}=hue(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Hm(i,"positioned"),[i]),step:o,Tour:Yv()?dt.createElement(Lue,{controls:t,mergedProps:r,state:i,step:o,store:a}):null}}function Due(e){const{Tour:t}=Oue(e);return t}function Fue(e){return Yv()?dt.createElement(Due,e):null}function zue(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 Wue(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Bue(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const ch="af:onboarding";function Hue({page:e,hasNodes:t=!1}){const{t:n}=Ur(),[r,i]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?zue(n):t?Wue(n):Bue(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(ch),p=u?JSON.parse(u):{};if(p.completed||p[e]){i(!1),a([]);return}localStorage.setItem(ch,JSON.stringify({...p,[e]:!0})),a(c),i(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=p=>{var y;const f=p.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(ch)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(ch,JSON.stringify(b)),a([]),i(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:s.jsx(Fue,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const Vue="agentflow:recent-runs:v1",Kue="agentflow:recent-runs:poller",que=3e3,Uue=8e3,Gue=2e3,vA=5e3,Yue=16e3,SA=[1e4,3e4,6e4];function Jue(e){return SA[Math.min(Math.max(e-1,0),SA.length-1)]}function Xue(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Que(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function Zue(){const{navigate:e,path:t}=ls(),[n,r]=m.useState([]),[i,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),p=m.useRef(()=>{});m.useEffect(()=>{let _=!1,S=!1,N=!1,I=null,T=0,z=0,E=0,O=0,D=null,L=0,$=0;const V=Xue(),B=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(Vue):null,R=_e=>{try{F==null||F.postMessage({..._e,tabId:V,sentAt:Date.now()})}catch{}},H=()=>{const _e=Date.now()-Yue;for(const[Ne,He]of B)He<_e&&B.delete(Ne);l(1+B.size)},A=(_e="presence")=>{R({type:_e,visible:!document.hidden})},X=_e=>{if(!_&&(Array.isArray(_e.runs)&&r(_e.runs),_e.syncHealth&&typeof _e.syncHealth=="object")){const Ne=_e.syncHealth;L=Number(Ne.failureCount)||0,$=Number(Ne.lastSuccessAt)||0,u(Ne)}},K=_e=>{X(_e),R({type:"state",..._e})},W=()=>{T&&(window.clearTimeout(T),T=0)},te=_e=>{W(),!(_||!S||document.hidden)&&(T=window.setTimeout(()=>{T=0,ee()},Math.max(0,_e)))},ee=async()=>{if(_||!S||document.hidden||D)return;const _e=new AbortController;D=_e;let Ne=!1;const He=window.setTimeout(()=>{Ne=!0,_e.abort()},Uue);try{const ct=await fetch("/api/pipeline-recent-runs",{signal:_e.signal});if(!ct.ok)throw new Error(`HTTP ${ct.status}`);const xt=await ct.json();if(_||!S||document.hidden)return;L=0,$=Date.now();const Re=Array.isArray(xt.runs)?xt.runs:[];K({runs:Re.filter(lt=>lt&<.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:$,message:""}}),te(que)}catch(ct){const xt=_e.signal.aborted&&!Ne;if(_||!S||document.hidden||xt)return;L+=1,K({syncHealth:{status:"delayed",failureCount:L,lastSuccessAt:$,message:Ne?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ct==null?void 0:ct.message)||ct)}`}}),te(Jue(L))}finally{window.clearTimeout(He),D===_e&&(D=null)}},G=()=>{W(),D&&(D.abort(),D=null)},ne=()=>{if(G(),I){const _e=I;I=null,_e()}S=!1},re=(_e=Gue)=>{z&&window.clearTimeout(z),!(_||document.hidden||S||N)&&(z=window.setTimeout(()=>{z=0,Z()},_e))},ie=()=>{_||document.hidden||S||(S=!0,te(0))},Z=async()=>{var _e;if(!(_||document.hidden||S||N)){if(!((_e=navigator.locks)!=null&&_e.request)){ie();return}N=!0;try{await navigator.locks.request(Kue,{mode:"exclusive",ifAvailable:!0},async Ne=>{if(N=!1,!Ne||_||document.hidden){re();return}S=!0,te(0),await new Promise(He=>{I=He}),I=null,S=!1})}catch{N=!1}finally{re()}}},de=()=>{if(!_){if(S){L=0,te(0);return}R({type:"retry"}),re(0)}};p.current=de,F&&(F.onmessage=_e=>{const Ne=_e.data;if(!(!Ne||Ne.tabId===V)){if(Ne.type==="hello"||Ne.type==="presence"){B.set(Ne.tabId,Date.now()),H(),Ne.type==="hello"&&A();return}if(Ne.type==="bye"){B.delete(Ne.tabId),H(),re(0);return}if(Ne.type==="state"){B.set(Ne.tabId,Date.now()),H(),X(Ne);return}Ne.type==="retry"&&S&&(L=0,te(0))}});const fe=()=>{A(),document.hidden?ne():re(0)},ge=()=>{A("bye"),ne()},Oe=()=>{A("hello"),re(0)};return document.addEventListener("visibilitychange",fe),window.addEventListener("pagehide",ge),window.addEventListener("pageshow",Oe),A("hello"),E=window.setInterval(A,vA),O=window.setInterval(H,vA),re(0),()=>{_=!0,p.current=()=>{},A("bye"),ne(),z&&window.clearTimeout(z),E&&window.clearInterval(E),O&&window.clearInterval(O),document.removeEventListener("visibilitychange",fe),window.removeEventListener("pagehide",ge),window.removeEventListener("pageshow",Oe),F==null||F.close()}},[]);const f=_=>{const S=new URLSearchParams({flowId:_.flowId,flowSource:_.flowSource||"workspace"});e(`/flow?${S.toString()}`),o(!1)},d=t==="/flow"?new URLSearchParams(window.location.search):null,h=(d==null?void 0:d.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(_=>!_)};return s.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[i&&s.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&s.jsxs("div",{className:"af-run-indicator__sync",children:[s.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),s.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&s.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",Que(c.lastSuccessAt)]}),y&&s.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:_=>{_.stopPropagation(),p.current()},children:"立即重试"})]}),n.map(_=>s.jsxs("button",{type:"button",className:"af-run-indicator__item"+(_.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(_),title:`${_.flowId} · ${_.runId}`,children:[s.jsx("span",{className:"af-run-indicator__dot"}),s.jsx("span",{className:"af-run-indicator__flow",children:_.flowId}),s.jsx("span",{className:"af-run-indicator__run",children:_.runId.slice(0,12)})]},`${_.flowId}:${_.runId}`))]}),s.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[s.jsx("span",{className:"af-run-indicator__pulse"}),s.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const Hw="0.1.138",ede=6e4,tde=30*6e4;function Xc(e){return String(e||"").trim().replace(/^v/i,"")}function nde(e,t){const n=Xc(e),r=Xc(t);return!!(n&&r&&n!==r)}function rde(e,t){return`agentflow.app-version.snooze:${Xc(e)}:${Xc(t)}`}function sde(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function ide(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,i=!1;const o=async()=>{if(!(i||document.visibilityState==="hidden")){i=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const p=Xc(u.version);if(!nde(Hw,p)){t(null);return}const f=rde(Hw,p);if(sde(f)>Date.now())return;t({clientVersion:Xc(Hw),serverVersion:p,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{i=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),ede);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+tde))}catch{}t(null)};return s.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),s.jsxs("div",{className:"af-app-version-notice__copy",children:[s.jsx("strong",{children:"AgentFlow 已更新"}),s.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),s.jsxs("div",{className:"af-app-version-notice__actions",children:[s.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),s.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function W$(e){return e==="/likee-context"||e==="/likee_context"}function ode(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function ade(){const{navigate:e}=ls();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",i=t.get("flowSource")||"";r&&n.set("flowId",r),i&&n.set("flowSource",i),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class lde 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,i,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((i=this.state.error)==null?void 0:i.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return s.jsx("div",{className:"af-auth-screen",children:s.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"error"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow UI Error"}),s.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),s.jsx("pre",{children:t}),n?s.jsx("pre",{children:n}):null]})})}}function cde({authUser:e}){const{path:t}=ls();return t==="/projects"||t==="/"?s.jsx(Kl,{authUser:e}):t==="/nodes"?s.jsx(Kl,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?s.jsx(Kl,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?s.jsx(Kl,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?s.jsx(Kl,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?s.jsx($oe,{authUser:e}):t==="/workflows"?s.jsx(Uoe,{}):t==="/workflow-report"?s.jsx(Cae,{}):t==="/mcps"?s.jsx(Soe,{}):t==="/schedules"?s.jsx(Coe,{}):t==="/node-studio"?s.jsx(Eoe,{}):t==="/flow"?s.jsx(ade,{}):t==="/workspace"?s.jsx(qM,{}):t.startsWith("/display")?s.jsx(YM,{}):t==="/settings"?s.jsx(aoe,{authUser:e}):t==="/admin/usage"?s.jsx(moe,{authUser:e}):t==="/admin/teams"?s.jsx(goe,{authUser:e}):t==="/feedback"?s.jsx(woe,{authUser:e}):W$(t)?s.jsx(d$,{}):s.jsx(Kl,{})}function ude({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,i]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,p]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),p(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),p(String(h.message||h))}};m.useEffect(()=>{f()},[]);const d=async h=>{h.preventDefault(),c(!0),p("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");i(""),a(""),window.location.replace(window.location.href);return}catch(y){p(String(y.message||y))}finally{c(!1)}};return t.loading?s.jsx("div",{className:"af-auth-screen",children:s.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})}}):s.jsx("div",{className:"af-auth-screen",children:s.jsxs("form",{className:"af-auth-panel",onSubmit:d,autoComplete:"on",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow"}),s.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"用户名"}),s.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:h=>i(h.target.value),autoComplete:"username",autoFocus:!0})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"密码"}),s.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?s.jsx("p",{className:"af-auth-error",children:u}):null,s.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function dde({authUser:e,onLogout:t}){const{path:n}=ls(),r=n==="/flow"||n==="/workspace";return s.jsxs("div",{className:"af-app",children:[n!=="/settings"?s.jsx(Hue,{page:r?"flow":"projects"}):null,r?null:s.jsx(bF,{authUser:e,onLogout:t}),s.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:s.jsx(cde,{authUser:e})}),s.jsx(Zue,{})]})}function fde(){return s.jsx(lde,{children:s.jsxs(tF,{children:[s.jsx(pde,{}),s.jsx(ide,{})]})})}function pde(){const{path:e}=ls();return e.startsWith("/display")?s.jsx(YM,{}):W$(e)?s.jsx(d$,{}):ode(e)?s.jsx(qM,{}):s.jsx(ude,{children:({user:t,onLogout:n})=>s.jsx(dde,{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 jA=document.querySelector('link[rel="icon"]');jA&&(jA.href=zI);Vw.createRoot(document.getElementById("root")).render(s.jsx(dt.StrictMode,{children:s.jsx(fde,{})}));export{vv as M,dt as R,kde as a,ur as b,ma as g,s as j,m as r};
|