@yiyi_zhang/reactflow-ui 0.4.0 → 1.0.0

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.
Files changed (66) hide show
  1. package/README.md +140 -101
  2. package/dist/AiWorkflowIDE.d.ts +219 -0
  3. package/dist/WorkflowIDE.d.ts +4 -4
  4. package/dist/ai.d.ts +34 -0
  5. package/dist/components/AICopilot/ParameterSuggester.d.ts +9 -0
  6. package/dist/components/AiNative/AgentTimeline.d.ts +23 -0
  7. package/dist/components/AiNative/AiCommandCenter.d.ts +40 -0
  8. package/dist/components/AiNative/AiConfigPanel.d.ts +9 -0
  9. package/dist/components/AiNative/BusinessCanvas.d.ts +15 -0
  10. package/dist/components/AiNative/CanvasPreview.d.ts +16 -0
  11. package/dist/components/AiNative/ClarificationCard.d.ts +9 -0
  12. package/dist/components/AiNative/FailureSummaryCard.d.ts +20 -0
  13. package/dist/components/AiNative/InlineCanvasCopilot.d.ts +7 -0
  14. package/dist/components/AiNative/LibraryPanel.d.ts +9 -0
  15. package/dist/components/AiNative/MermaidBlock.d.ts +6 -0
  16. package/dist/components/AiNative/PlanCard.d.ts +15 -0
  17. package/dist/components/AiNative/ProposalPreviewCard.d.ts +21 -0
  18. package/dist/components/AiNative/RecommendationCard.d.ts +10 -0
  19. package/dist/components/AiNative/RepairCard.d.ts +17 -0
  20. package/dist/components/AiNative/ReviewBar.d.ts +21 -0
  21. package/dist/components/AiNative/WorkflowRunCard.d.ts +14 -0
  22. package/dist/components/BrandLogo.d.ts +13 -0
  23. package/dist/components/Controls/ModeSlider.d.ts +2 -0
  24. package/dist/components/ExecutionWaterfallPanel.d.ts +3 -0
  25. package/dist/components/SandboxConfigModal.d.ts +7 -0
  26. package/dist/components/StructuredJsonViewer.d.ts +11 -0
  27. package/dist/components/nodes/NodeLayout.d.ts +3 -1
  28. package/dist/components/nodes/NodeWrapper.d.ts +2 -1
  29. package/dist/hooks/useNodeExecution.d.ts +5 -2
  30. package/dist/hooks/useNodeLayout.d.ts +1 -1
  31. package/dist/index.d.ts +5 -1
  32. package/dist/logo.svg +37 -0
  33. package/dist/product-launch.html +1400 -0
  34. package/dist/reactflow-ui-ai.es.js +21433 -0
  35. package/dist/reactflow-ui.css +1 -1
  36. package/dist/reactflow-ui.es.js +12482 -8252
  37. package/dist/reactflow-ui.umd.js +38 -20
  38. package/dist/services/ai/agentRunner.d.ts +55 -0
  39. package/dist/services/ai/contextEngine.d.ts +83 -0
  40. package/dist/services/ai/draftPersistence.d.ts +23 -0
  41. package/dist/services/ai/errorMessages.d.ts +16 -0
  42. package/dist/services/ai/intentClassifier.d.ts +17 -0
  43. package/dist/services/ai/protocolAdapter.d.ts +114 -0
  44. package/dist/services/ai/ruleEngine.d.ts +57 -0
  45. package/dist/services/ai/schemaRegistry.d.ts +51 -0
  46. package/dist/services/ai/systemPrompt.d.ts +30 -0
  47. package/dist/services/ai/toolDefs.d.ts +9 -0
  48. package/dist/services/ai/toolExecutor.d.ts +96 -0
  49. package/dist/services/ai/toolRegistry.d.ts +38 -0
  50. package/dist/services/ai/transport.d.ts +58 -0
  51. package/dist/services/ai/workflowSynthesizer.d.ts +118 -0
  52. package/dist/services/aiService.d.ts +7 -5
  53. package/dist/services/wlsp/workflowLsp.d.ts +101 -0
  54. package/dist/store/aiStore.d.ts +230 -0
  55. package/dist/store/ideStoresContext.d.ts +39 -0
  56. package/dist/store/libraryStore.d.ts +25 -0
  57. package/dist/types/aiEvents.d.ts +40 -0
  58. package/dist/types/conductor.d.ts +6 -1
  59. package/dist/types/workflow.d.ts +43 -0
  60. package/dist/types/workflowLibrary.d.ts +27 -0
  61. package/dist/utils/localSandboxEngine.d.ts +49 -0
  62. package/dist/utils/nodeMeta.d.ts +6 -0
  63. package/dist/utils/proposalPreview.d.ts +19 -0
  64. package/dist/utils/taskTypeMeta.d.ts +18 -0
  65. package/dist/utils/workflowToMermaid.d.ts +7 -0
  66. package/package.json +19 -6
@@ -1,12 +1,17 @@
1
- (function(qe,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],P):(qe=typeof globalThis<"u"?globalThis:qe||self,P(qe.ReactflowUI={},qe.React,qe.ReactFlow,qe.ReactDOM))})(this,(function(qe,P,A,Yr){"use strict";var Sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var wr={exports:{}},ur={};var Ki;function ng(){if(Ki)return ur;Ki=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function t(n,s,a){var o=null;if(a!==void 0&&(o=""+a),s.key!==void 0&&(o=""+s.key),"key"in s){a={};for(var i in s)i!=="key"&&(a[i]=s[i])}else a=s;return s=a.ref,{$$typeof:e,type:n,key:o,ref:s!==void 0?s:null,props:a}}return ur.Fragment=r,ur.jsx=t,ur.jsxs=t,ur}var dr={};var Ui;function ag(){return Ui||(Ui=1,process.env.NODE_ENV!=="production"&&(function(){function e(D){if(D==null)return null;if(typeof D=="function")return D.$$typeof===S?null:D.displayName||D.name||null;if(typeof D=="string")return D;switch(D){case v:return"Fragment";case x:return"Profiler";case y:return"StrictMode";case j:return"Suspense";case N:return"SuspenseList";case C:return"Activity"}if(typeof D=="object")switch(typeof D.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),D.$$typeof){case m:return"Portal";case k:return D.displayName||"Context";case b:return(D._context.displayName||"Context")+".Consumer";case w:var Y=D.render;return D=D.displayName,D||(D=Y.displayName||Y.name||"",D=D!==""?"ForwardRef("+D+")":"ForwardRef"),D;case L:return Y=D.displayName||null,Y!==null?Y:e(D.type)||"Memo";case T:Y=D._payload,D=D._init;try{return e(D(Y))}catch{}}return null}function r(D){return""+D}function t(D){try{r(D);var Y=!1}catch{Y=!0}if(Y){Y=console;var se=Y.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&D[Symbol.toStringTag]||D.constructor.name||"Object";return se.call(Y,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),r(D)}}function n(D){if(D===v)return"<>";if(typeof D=="object"&&D!==null&&D.$$typeof===T)return"<...>";try{var Y=e(D);return Y?"<"+Y+">":"<...>"}catch{return"<...>"}}function s(){var D=q.A;return D===null?null:D.getOwner()}function a(){return Error("react-stack-top-frame")}function o(D){if(I.call(D,"key")){var Y=Object.getOwnPropertyDescriptor(D,"key").get;if(Y&&Y.isReactWarning)return!1}return D.key!==void 0}function i(D,Y){function se(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Y))}se.isReactWarning=!0,Object.defineProperty(D,"key",{get:se,configurable:!0})}function d(){var D=e(this.type);return V[D]||(V[D]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),D=this.props.ref,D!==void 0?D:null}function c(D,Y,se,R,M,_){var B=se.ref;return D={$$typeof:g,type:D,key:Y,props:se,_owner:R},(B!==void 0?B:null)!==null?Object.defineProperty(D,"ref",{enumerable:!1,get:d}):Object.defineProperty(D,"ref",{enumerable:!1,value:null}),D._store={},Object.defineProperty(D._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(D,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(D,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(D,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(D.props),Object.freeze(D)),D}function u(D,Y,se,R,M,_){var B=Y.children;if(B!==void 0)if(R)if(O(B)){for(R=0;R<B.length;R++)f(B[R]);Object.freeze&&Object.freeze(B)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(B);if(I.call(Y,"key")){B=e(D);var z=Object.keys(Y).filter(function(G){return G!=="key"});R=0<z.length?"{key: someKey, "+z.join(": ..., ")+": ...}":"{key: someKey}",ee[B+R]||(z=0<z.length?"{"+z.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(Ce,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],I):(Ce=typeof globalThis<"u"?globalThis:Ce||self,I(Ce.ReactflowUI={},Ce.React,Ce.ReactFlow,Ce.ReactDOM))})(this,(function(Ce,I,M,_t){"use strict";var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ft={exports:{}},wt={};var bl;function Hm(){if(bl)return wt;bl=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,s,a){var i=null;if(a!==void 0&&(i=""+a),s.key!==void 0&&(i=""+s.key),"key"in s){a={};for(var l in s)l!=="key"&&(a[l]=s[l])}else a=s;return s=a.ref,{$$typeof:e,type:n,key:i,ref:s!==void 0?s:null,props:a}}return wt.Fragment=t,wt.jsx=r,wt.jsxs=r,wt}var Tt={};var kl;function Jm(){return kl||(kl=1,process.env.NODE_ENV!=="production"&&(function(){function e(P){if(P==null)return null;if(typeof P=="function")return P.$$typeof===S?null:P.displayName||P.name||null;if(typeof P=="string")return P;switch(P){case x:return"Fragment";case y:return"Profiler";case v:return"StrictMode";case w:return"Suspense";case T:return"SuspenseList";case N:return"Activity"}if(typeof P=="object")switch(typeof P.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),P.$$typeof){case g:return"Portal";case k:return P.displayName||"Context";case b:return(P._context.displayName||"Context")+".Consumer";case _:var U=P.render;return P=P.displayName,P||(P=U.displayName||U.name||"",P=P!==""?"ForwardRef("+P+")":"ForwardRef"),P;case O:return U=P.displayName||null,U!==null?U:e(P.type)||"Memo";case D:U=P._payload,P=P._init;try{return e(P(U))}catch{}}return null}function t(P){return""+P}function r(P){try{t(P);var U=!1}catch{U=!0}if(U){U=console;var se=U.error,L=typeof Symbol=="function"&&Symbol.toStringTag&&P[Symbol.toStringTag]||P.constructor.name||"Object";return se.call(U,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",L),t(P)}}function n(P){if(P===x)return"<>";if(typeof P=="object"&&P!==null&&P.$$typeof===D)return"<...>";try{var U=e(P);return U?"<"+U+">":"<...>"}catch{return"<...>"}}function s(){var P=R.A;return P===null?null:P.getOwner()}function a(){return Error("react-stack-top-frame")}function i(P){if(j.call(P,"key")){var U=Object.getOwnPropertyDescriptor(P,"key").get;if(U&&U.isReactWarning)return!1}return P.key!==void 0}function l(P,U){function se(){$||($=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",U))}se.isReactWarning=!0,Object.defineProperty(P,"key",{get:se,configurable:!0})}function c(){var P=e(this.type);return J[P]||(J[P]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),P=this.props.ref,P!==void 0?P:null}function d(P,U,se,L,F,z){var H=se.ref;return P={$$typeof:m,type:P,key:U,props:se,_owner:L},(H!==void 0?H:null)!==null?Object.defineProperty(P,"ref",{enumerable:!1,get:c}):Object.defineProperty(P,"ref",{enumerable:!1,value:null}),P._store={},Object.defineProperty(P._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(P,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(P,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:F}),Object.defineProperty(P,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:z}),Object.freeze&&(Object.freeze(P.props),Object.freeze(P)),P}function u(P,U,se,L,F,z){var H=U.children;if(H!==void 0)if(L)if(E(H)){for(L=0;L<H.length;L++)f(H[L]);Object.freeze&&Object.freeze(H)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(H);if(j.call(U,"key")){H=e(P);var Y=Object.keys(U).filter(function(fe){return fe!=="key"});L=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",B[H+L]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,R,B,z,B),ee[B+R]=!0)}if(B=null,se!==void 0&&(t(se),B=""+se),o(Y)&&(t(Y.key),B=""+Y.key),"key"in Y){se={};for(var Q in Y)Q!=="key"&&(se[Q]=Y[Q])}else se=Y;return B&&i(se,typeof D=="function"?D.displayName||D.name||"Unknown":D),c(D,B,se,s(),M,_)}function f(D){p(D)?D._store&&(D._store.validated=1):typeof D=="object"&&D!==null&&D.$$typeof===T&&(D._payload.status==="fulfilled"?p(D._payload.value)&&D._payload.value._store&&(D._payload.value._store.validated=1):D._store&&(D._store.validated=1))}function p(D){return typeof D=="object"&&D!==null&&D.$$typeof===g}var h=P,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),q=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,O=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(D){return D()}};var W,V={},Z=h.react_stack_bottom_frame.bind(h,a)(),ne=F(n(a)),ee={};dr.Fragment=v,dr.jsx=function(D,Y,se){var R=1e4>q.recentlyCreatedOwnerStacks++;return u(D,Y,se,!1,R?Error("react-stack-top-frame"):Z,R?F(n(D)):ne)},dr.jsxs=function(D,Y,se){var R=1e4>q.recentlyCreatedOwnerStacks++;return u(D,Y,se,!0,R?Error("react-stack-top-frame"):Z,R?F(n(D)):ne)}})()),dr}var Ji;function sg(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?wr.exports=ng():wr.exports=ag()),wr.exports}var l=sg();const Gi=e=>{let r;const t=new Set,n=(c,u)=>{const f=typeof c=="function"?c(r):c;if(!Object.is(f,r)){const p=r;r=u??(typeof f!="object"||f===null)?f:Object.assign({},r,f),t.forEach(h=>h(r,p))}},s=()=>r,i={setState:n,getState:s,getInitialState:()=>d,subscribe:c=>(t.add(c),()=>t.delete(c))},d=r=e(n,s,i);return i},Vi=(e=>e?Gi(e):Gi),og=e=>e;function Xr(e,r=og){const t=P.useSyncExternalStore(e.subscribe,P.useCallback(()=>r(e.getState()),[e,r]),P.useCallback(()=>r(e.getInitialState()),[e,r]));return P.useDebugValue(t),t}const ig=e=>{const r=Vi(e),t=n=>Xr(r,n);return Object.assign(t,r),t},lg=(e=>ig);function Yi(e,r){let t;try{t=e()}catch{return}return{getItem:s=>{var a;const o=d=>d===null?null:JSON.parse(d,void 0),i=(a=t.getItem(s))!=null?a:null;return i instanceof Promise?i.then(o):o(i)},setItem:(s,a)=>t.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>t.removeItem(s)}}const Zr=e=>r=>{try{const t=e(r);return t instanceof Promise?t:{then(n){return Zr(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return Zr(n)(t)}}}},cg=(e,r)=>(t,n,s)=>{let a={storage:Yi(()=>localStorage),partialize:m=>m,version:0,merge:(m,v)=>({...v,...m}),...r},o=!1;const i=new Set,d=new Set;let c=a.storage;if(!c)return e((...m)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),t(...m)},n,s);const u=()=>{const m=a.partialize({...n()});return c.setItem(a.name,{state:m,version:a.version})},f=s.setState;s.setState=(m,v)=>(f(m,v),u());const p=e((...m)=>(t(...m),u()),n,s);s.getInitialState=()=>p;let h;const g=()=>{var m,v;if(!c)return;o=!1,i.forEach(x=>{var b;return x((b=n())!=null?b:p)});const y=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(m=n())!=null?m:p))||void 0;return Zr(c.getItem.bind(c))(a.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==a.version){if(a.migrate){const b=a.migrate(x.state,x.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,x.state];return[!1,void 0]}).then(x=>{var b;const[k,w]=x;if(h=a.merge(w,(b=n())!=null?b:p),t(h,!0),k)return u()}).then(()=>{y?.(h,void 0),h=n(),o=!0,d.forEach(x=>x(h))}).catch(x=>{y?.(void 0,x)})};return s.persist={setOptions:m=>{a={...a,...m},m.storage&&(c=m.storage)},clearStorage:()=>{c?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>o,onHydrate:m=>(i.add(m),()=>{i.delete(m)}),onFinishHydration:m=>(d.add(m),()=>{d.delete(m)})},a.skipHydration||g(),h||p};var Xi=(e,r,t)=>(s,a)=>({pastStates:t?.pastStates||[],futureStates:t?.futureStates||[],undo:(o=1)=>{if(a().pastStates.length){const i=t?.partialize?.(r())||r(),d=a().pastStates.splice(-o,o),c=d.shift();e(c),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(t?.diff?.(i,c)||i,d.reverse())})}},redo:(o=1)=>{if(a().futureStates.length){const i=t?.partialize?.(r())||r(),d=a().futureStates.splice(-o,o),c=d.shift();e(c),s({pastStates:a().pastStates.concat(t?.diff?.(i,c)||i,d.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:o=>s({_onSave:o}),_onSave:t?.onSave,_handleSet:(o,i,d,c)=>{t?.limit&&a().pastStates.length>=t?.limit&&a().pastStates.shift(),a()._onSave?.(o,d),s({pastStates:a().pastStates.concat(c||o),futureStates:[]})}}),ug=(e,r)=>(n,s,a)=>{a.temporal=Vi(r?.wrapTemporal?.(Xi(n,s,r))||Xi(n,s,r));const o=r?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,i=c=>{if(!a.temporal.getState().isTracking)return;const u=r?.partialize?.(s())||s(),f=r?.diff?.(c,u);f===null||r?.equality?.(c,u)||o(c,void 0,u,f)},d=a.setState;return a.setState=(...c)=>{const u=r?.partialize?.(s())||s();d(...c),i(u)},e((...c)=>{const u=r?.partialize?.(s())||s();n(...c),i(u)},s,a)};function dg(e,r="TB",t){const n=t?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],o={};let i=0;const d=e.tasks;for(let c=0;c<d.length;c++){const u=d[c],f=Zi(u,i,o,r,d,n);if(s.push(...f.nodes),a.push(...f.edges),i=f.nextId,c>0){const p=d[c-1];Qr(p,u,a,n)}Object.assign(o,f.taskMap)}if(!n&&d.length>0){const c=d[0],u="__workflow_start__";s.push({id:u,type:"plusNode",data:{label:"+",taskReferenceName:u,taskType:"PLUS",parentRef:u,edgeData:{isWorkflowStart:!0},layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:r==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${u}-${c.taskReferenceName}`,source:u,target:c.taskReferenceName,animated:!0});const f=d[d.length-1],p="__workflow_end__";s.push({id:p,type:"plusNode",data:{label:"+",taskReferenceName:p,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:r==="LR"?A.Position.Left:A.Position.Top}),Qr(f,{taskReferenceName:p},a,n)}return{nodes:s,edges:a,taskMap:o}}function Zi(e,r,t,n="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return pg(e,r,t,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return hg(e,r,t,n);case"JOIN":case"EXCLUSIVE_JOIN":return vg(e,r,t,n,s,a);case"DO_WHILE":return gg(e,r,t,n,a);case"SUB_WORKFLOW":return mg(e,r,t,n);default:return fg(e,r,t,n)}}function fg(e,r,t,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:r+1}}function pg(e,r,t,n="TB",s=!1){const a=[],o=[];let i=r;const d={},c={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top};a.push(c),d[e.taskReferenceName]=e;const u=e.decisionCases||{},f=e.defaultCase||[],p=Object.keys(u),h=(g,m)=>{if(n==="TB"){if(g===0&&m>1)return"left";if(g===1&&m>2)return"right"}else{if(g===0&&m>1)return"top";if(g===1&&m>2)return"bottom"}return null};if(p.forEach((g,m)=>{const v=u[g],y=h(m,p.length+1);if(v&&v.length>0){const x=Tr(v,i,{...t,...d},n,s);a.push(...x.nodes),o.push(...x.edges),Object.assign(d,x.taskMap),i=x.nextId;const b=v[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:y||void 0,target:b,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6"}})}else if(!s){const x=`${e.taskReferenceName}_empty_${g}`;a.push({id:x,type:"plusNode",data:{label:`${g} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:g},layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),o.push({id:`e-${e.taskReferenceName}-${x}`,source:e.taskReferenceName,sourceHandle:y||void 0,target:x,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const g=Tr(f,i,{...t,...d},n,s);a.push(...g.nodes),o.push(...g.edges),Object.assign(d,g.taskMap),i=g.nextId;const m=f[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const g=`${e.taskReferenceName}_empty_default`;a.push({id:g,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:g,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),o.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:o,taskMap:d,nextId:i}}function hg(e,r,t,n="TB"){const s=[],a=[];let o=r;const i={},d=e.type==="FORK_JOIN_DYNAMIC",c={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:d,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top};if(s.push(c),i[e.taskReferenceName]=e,d){const u=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:u,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:u,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${u}`,source:e.taskReferenceName,target:u,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),i[u]={taskReferenceName:u,type:"DYNAMIC_PLACEHOLDER"}}return d||(e.forkTasks||[]).forEach((f,p)=>{if(f&&f.length>0){const h=Tr(f,o,{...t,...i},n,!1);s.push(...h.nodes),a.push(...h.edges),Object.assign(i,h.taskMap),o=h.nextId;const g=f[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,sourceHandle:`branch_${p}`,target:g,label:`分支 ${p+1}`,animated:!0,data:{forkIndex:p},style:{stroke:"#10b981"}})}}),{nodes:s,edges:a,taskMap:i,nextId:o}}function gg(e,r,t,n="TB",s=!1){const a={},o=e.taskReferenceName,i={id:o,type:"loopNode",data:{label:e.name,taskReferenceName:o,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{pointerEvents:"none"}};a[o]=e;const d=e.loopOver||[],c=[],u=[];let f=r+1;if(d.length>0){const p=Tr(d,f,{...t,...a},n,s);if(f=p.nextId,Object.assign(a,p.taskMap),p.nodes.forEach(h=>{c.push({...h,parentId:h.parentId??o,extent:h.parentId?h.extent:"parent"})}),u.push(...p.edges),!s){const h=d[0],g=`__loop_start__${o}`;c.push({id:g,type:"plusNode",parentId:o,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:o,edgeData:{isLoopBodyStart:!0,loopId:o},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),u.push({id:`e-${g}-${h.taskReferenceName}`,source:g,target:h.taskReferenceName,animated:!0})}if(!s){const h=d[d.length-1],g=`__loop_end__${o}`;c.push({id:g,type:"plusNode",parentId:o,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:h.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),u.push({id:`e-${h.taskReferenceName}-${g}`,source:h.taskReferenceName,target:g,animated:!0})}}else if(!s){const p=`${o}_loop_empty_plus`;c.push({id:p,type:"plusNode",parentId:o,extent:"parent",data:{label:"+ 添加",taskReferenceName:p,taskType:"PLUS",parentRef:o,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top})}return{nodes:[i,...c],edges:u,taskMap:a,nextId:f}}function mg(e,r,t,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:r+1}}function vg(e,r,t,n="TB",s=[],a=!1){const o={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top},i={[e.taskReferenceName]:e},d=[],c=[];(e.joinOn||[]).forEach(p=>{const h=s.find(g=>g.taskReferenceName===p)||t[p];h&&Er(h,a).forEach(m=>{c.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0})})});const f=s.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(f>0){const p=s[f-1];if(p.type==="FORK_JOIN_DYNAMIC"){const h=`${p.taskReferenceName}_dynamic_placeholder`;c.push({id:`e-${h}-${e.taskReferenceName}-dynamic`,source:h,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else p.type==="FORK_JOIN"&&(p.forkTasks||[]).forEach((g,m)=>{if((!g||g.length===0)&&!a){const v=`${p.taskReferenceName}_empty_branch_${m}`;d.push({id:v,type:"default",data:{label:`分支 ${m+1} (空)`,layoutDirection:n,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),c.push({id:`e-${p.taskReferenceName}-${v}`,source:p.taskReferenceName,sourceHandle:`branch_${m}`,target:v,label:`分支 ${m+1}`,animated:!0,data:{forkIndex:m},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),c.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[o,...d],edges:c,taskMap:i,nextId:r+1}}function Tr(e,r,t,n="TB",s=!1){const a=[],o=[];let i=r;const d={};for(let c=0;c<e.length;c++){const u=e[c],f={...t,...d},p=Zi(u,i,f,n,e,s);if(a.push(...p.nodes),o.push(...p.edges),Object.assign(d,p.taskMap),i=p.nextId,c>0){const h=e[c-1];Qr(h,u,o,s)}}return{nodes:a,edges:o,taskMap:d,nextId:i}}function Qr(e,r,t,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=Er(e,n),a=r.taskReferenceName;s.forEach(o=>{const i=`e-${o}-${a}`;t.find(d=>d.id===i)||t.push({id:i,source:o,target:a,animated:!0})})}function Er(e,r=!1){const t=e.type||"SIMPLE";if(t==="DECISION"||t==="SWITCH"){const n=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([o,i])=>{if(i&&i.length>0){const d=i[i.length-1];n.push(...Er(d,r))}else r||n.push(`${e.taskReferenceName}_empty_${o}`)}),a.length>0){const o=a[a.length-1];n.push(...Er(o,r))}else r||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const Ee=dg;function et(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var rt,Qi;function yg(){if(Qi)return rt;Qi=1;function e(){this.__data__=[],this.size=0}return rt=e,rt}var tt,el;function er(){if(el)return tt;el=1;function e(r,t){return r===t||r!==r&&t!==t}return tt=e,tt}var nt,rl;function Nr(){if(rl)return nt;rl=1;var e=er();function r(t,n){for(var s=t.length;s--;)if(e(t[s][0],n))return s;return-1}return nt=r,nt}var at,tl;function xg(){if(tl)return at;tl=1;var e=Nr(),r=Array.prototype,t=r.splice;function n(s){var a=this.__data__,o=e(a,s);if(o<0)return!1;var i=a.length-1;return o==i?a.pop():t.call(a,o,1),--this.size,!0}return at=n,at}var st,nl;function bg(){if(nl)return st;nl=1;var e=Nr();function r(t){var n=this.__data__,s=e(n,t);return s<0?void 0:n[s][1]}return st=r,st}var ot,al;function kg(){if(al)return ot;al=1;var e=Nr();function r(t){return e(this.__data__,t)>-1}return ot=r,ot}var it,sl;function _g(){if(sl)return it;sl=1;var e=Nr();function r(t,n){var s=this.__data__,a=e(s,t);return a<0?(++this.size,s.push([t,n])):s[a][1]=n,this}return it=r,it}var lt,ol;function Cr(){if(ol)return lt;ol=1;var e=yg(),r=xg(),t=bg(),n=kg(),s=_g();function a(o){var i=-1,d=o==null?0:o.length;for(this.clear();++i<d;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=s,lt=a,lt}var ct,il;function Sg(){if(il)return ct;il=1;var e=Cr();function r(){this.__data__=new e,this.size=0}return ct=r,ct}var ut,ll;function wg(){if(ll)return ut;ll=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return ut=e,ut}var dt,cl;function Tg(){if(cl)return dt;cl=1;function e(r){return this.__data__.get(r)}return dt=e,dt}var ft,ul;function Eg(){if(ul)return ft;ul=1;function e(r){return this.__data__.has(r)}return ft=e,ft}var pt,dl;function fl(){if(dl)return pt;dl=1;var e=typeof Sr=="object"&&Sr&&Sr.Object===Object&&Sr;return pt=e,pt}var ht,pl;function Oe(){if(pl)return ht;pl=1;var e=fl(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ht=t,ht}var gt,hl;function rr(){if(hl)return gt;hl=1;var e=Oe(),r=e.Symbol;return gt=r,gt}var mt,gl;function Ng(){if(gl)return mt;gl=1;var e=rr(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,s=e?e.toStringTag:void 0;function a(o){var i=t.call(o,s),d=o[s];try{o[s]=void 0;var c=!0}catch{}var u=n.call(o);return c&&(i?o[s]=d:delete o[s]),u}return mt=a,mt}var vt,ml;function Cg(){if(ml)return vt;ml=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return vt=t,vt}var yt,vl;function Je(){if(vl)return yt;vl=1;var e=rr(),r=Ng(),t=Cg(),n="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function o(i){return i==null?i===void 0?s:n:a&&a in Object(i)?r(i):t(i)}return yt=o,yt}var xt,yl;function je(){if(yl)return xt;yl=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return xt=e,xt}var bt,xl;function fr(){if(xl)return bt;xl=1;var e=Je(),r=je(),t="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function o(i){if(!r(i))return!1;var d=e(i);return d==n||d==s||d==t||d==a}return bt=o,bt}var kt,bl;function jg(){if(bl)return kt;bl=1;var e=Oe(),r=e["__core-js_shared__"];return kt=r,kt}var _t,kl;function Ig(){if(kl)return _t;kl=1;var e=jg(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return _t=t,_t}var St,_l;function Sl(){if(_l)return St;_l=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return St=t,St}var wt,wl;function Rg(){if(wl)return wt;wl=1;var e=fr(),r=Ig(),t=je(),n=Sl(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,i=Object.prototype,d=o.toString,c=i.hasOwnProperty,u=RegExp("^"+d.call(c).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!t(p)||r(p))return!1;var h=e(p)?u:a;return h.test(n(p))}return wt=f,wt}var Tt,Tl;function Og(){if(Tl)return Tt;Tl=1;function e(r,t){return r?.[t]}return Tt=e,Tt}var Et,El;function Ge(){if(El)return Et;El=1;var e=Rg(),r=Og();function t(n,s){var a=r(n,s);return e(a)?a:void 0}return Et=t,Et}var Nt,Nl;function Ct(){if(Nl)return Nt;Nl=1;var e=Ge(),r=Oe(),t=e(r,"Map");return Nt=t,Nt}var jt,Cl;function jr(){if(Cl)return jt;Cl=1;var e=Ge(),r=e(Object,"create");return jt=r,jt}var It,jl;function Pg(){if(jl)return It;jl=1;var e=jr();function r(){this.__data__=e?e(null):{},this.size=0}return It=r,It}var Rt,Il;function Ag(){if(Il)return Rt;Il=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return Rt=e,Rt}var Ot,Rl;function Lg(){if(Rl)return Ot;Rl=1;var e=jr(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;if(e){var i=o[a];return i===r?void 0:i}return n.call(o,a)?o[a]:void 0}return Ot=s,Ot}var Pt,Ol;function qg(){if(Ol)return Pt;Ol=1;var e=jr(),r=Object.prototype,t=r.hasOwnProperty;function n(s){var a=this.__data__;return e?a[s]!==void 0:t.call(a,s)}return Pt=n,Pt}var At,Pl;function Dg(){if(Pl)return At;Pl=1;var e=jr(),r="__lodash_hash_undefined__";function t(n,s){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&s===void 0?r:s,this}return At=t,At}var Lt,Al;function Mg(){if(Al)return Lt;Al=1;var e=Pg(),r=Ag(),t=Lg(),n=qg(),s=Dg();function a(o){var i=-1,d=o==null?0:o.length;for(this.clear();++i<d;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=s,Lt=a,Lt}var qt,Ll;function Wg(){if(Ll)return qt;Ll=1;var e=Mg(),r=Cr(),t=Ct();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return qt=n,qt}var Dt,ql;function Bg(){if(ql)return Dt;ql=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return Dt=e,Dt}var Mt,Dl;function Ir(){if(Dl)return Mt;Dl=1;var e=Bg();function r(t,n){var s=t.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return Mt=r,Mt}var Wt,Ml;function Fg(){if(Ml)return Wt;Ml=1;var e=Ir();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Wt=r,Wt}var Bt,Wl;function $g(){if(Wl)return Bt;Wl=1;var e=Ir();function r(t){return e(this,t).get(t)}return Bt=r,Bt}var Ft,Bl;function zg(){if(Bl)return Ft;Bl=1;var e=Ir();function r(t){return e(this,t).has(t)}return Ft=r,Ft}var $t,Fl;function Hg(){if(Fl)return $t;Fl=1;var e=Ir();function r(t,n){var s=e(this,t),a=s.size;return s.set(t,n),this.size+=s.size==a?0:1,this}return $t=r,$t}var zt,$l;function Ht(){if($l)return zt;$l=1;var e=Wg(),r=Fg(),t=$g(),n=zg(),s=Hg();function a(o){var i=-1,d=o==null?0:o.length;for(this.clear();++i<d;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=s,zt=a,zt}var Kt,zl;function Kg(){if(zl)return Kt;zl=1;var e=Cr(),r=Ct(),t=Ht(),n=200;function s(a,o){var i=this.__data__;if(i instanceof e){var d=i.__data__;if(!r||d.length<n-1)return d.push([a,o]),this.size=++i.size,this;i=this.__data__=new t(d)}return i.set(a,o),this.size=i.size,this}return Kt=s,Kt}var Ut,Hl;function Rr(){if(Hl)return Ut;Hl=1;var e=Cr(),r=Sg(),t=wg(),n=Tg(),s=Eg(),a=Kg();function o(i){var d=this.__data__=new e(i);this.size=d.size}return o.prototype.clear=r,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=a,Ut=o,Ut}var Jt,Kl;function Gt(){if(Kl)return Jt;Kl=1;function e(r,t){for(var n=-1,s=r==null?0:r.length;++n<s&&t(r[n],n,r)!==!1;);return r}return Jt=e,Jt}var Vt,Ul;function Jl(){if(Ul)return Vt;Ul=1;var e=Ge(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Vt=r,Vt}var Yt,Gl;function Or(){if(Gl)return Yt;Gl=1;var e=Jl();function r(t,n,s){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[n]=s}return Yt=r,Yt}var Xt,Vl;function Pr(){if(Vl)return Xt;Vl=1;var e=Or(),r=er(),t=Object.prototype,n=t.hasOwnProperty;function s(a,o,i){var d=a[o];(!(n.call(a,o)&&r(d,i))||i===void 0&&!(o in a))&&e(a,o,i)}return Xt=s,Xt}var Zt,Yl;function pr(){if(Yl)return Zt;Yl=1;var e=Pr(),r=Or();function t(n,s,a,o){var i=!a;a||(a={});for(var d=-1,c=s.length;++d<c;){var u=s[d],f=o?o(a[u],n[u],u,a,n):void 0;f===void 0&&(f=n[u]),i?r(a,u,f):e(a,u,f)}return a}return Zt=t,Zt}var Qt,Xl;function Ug(){if(Xl)return Qt;Xl=1;function e(r,t){for(var n=-1,s=Array(r);++n<r;)s[n]=t(n);return s}return Qt=e,Qt}var en,Zl;function De(){if(Zl)return en;Zl=1;function e(r){return r!=null&&typeof r=="object"}return en=e,en}var rn,Ql;function Jg(){if(Ql)return rn;Ql=1;var e=Je(),r=De(),t="[object Arguments]";function n(s){return r(s)&&e(s)==t}return rn=n,rn}var tn,ec;function hr(){if(ec)return tn;ec=1;var e=Jg(),r=De(),t=Object.prototype,n=t.hasOwnProperty,s=t.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(o){return r(o)&&n.call(o,"callee")&&!s.call(o,"callee")};return tn=a,tn}var nn,rc;function be(){if(rc)return nn;rc=1;var e=Array.isArray;return nn=e,nn}var gr={exports:{}},an,tc;function Gg(){if(tc)return an;tc=1;function e(){return!1}return an=e,an}gr.exports;var nc;function tr(){return nc||(nc=1,(function(e,r){var t=Oe(),n=Gg(),s=r&&!r.nodeType&&r,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o?t.Buffer:void 0,d=i?i.isBuffer:void 0,c=d||n;e.exports=c})(gr,gr.exports)),gr.exports}var sn,ac;function Ar(){if(ac)return sn;ac=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,s){var a=typeof n;return s=s??e,!!s&&(a=="number"||a!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<s}return sn=t,sn}var on,sc;function ln(){if(sc)return on;sc=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return on=r,on}var cn,oc;function Vg(){if(oc)return cn;oc=1;var e=Je(),r=ln(),t=De(),n="[object Arguments]",s="[object Array]",a="[object Boolean]",o="[object Date]",i="[object Error]",d="[object Function]",c="[object Map]",u="[object Number]",f="[object Object]",p="[object RegExp]",h="[object Set]",g="[object String]",m="[object WeakMap]",v="[object ArrayBuffer]",y="[object DataView]",x="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",w="[object Int16Array]",j="[object Int32Array]",N="[object Uint8Array]",L="[object Uint8ClampedArray]",T="[object Uint16Array]",C="[object Uint32Array]",S={};S[x]=S[b]=S[k]=S[w]=S[j]=S[N]=S[L]=S[T]=S[C]=!0,S[n]=S[s]=S[v]=S[a]=S[y]=S[o]=S[i]=S[d]=S[c]=S[u]=S[f]=S[p]=S[h]=S[g]=S[m]=!1;function q(I){return t(I)&&r(I.length)&&!!S[e(I)]}return cn=q,cn}var un,ic;function Lr(){if(ic)return un;ic=1;function e(r){return function(t){return r(t)}}return un=e,un}var mr={exports:{}};mr.exports;var lc;function dn(){return lc||(lc=1,(function(e,r){var t=fl(),n=r&&!r.nodeType&&r,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,o=a&&t.process,i=(function(){try{var d=s&&s.require&&s.require("util").types;return d||o&&o.binding&&o.binding("util")}catch{}})();e.exports=i})(mr,mr.exports)),mr.exports}var fn,cc;function vr(){if(cc)return fn;cc=1;var e=Vg(),r=Lr(),t=dn(),n=t&&t.isTypedArray,s=n?r(n):e;return fn=s,fn}var pn,uc;function dc(){if(uc)return pn;uc=1;var e=Ug(),r=hr(),t=be(),n=tr(),s=Ar(),a=vr(),o=Object.prototype,i=o.hasOwnProperty;function d(c,u){var f=t(c),p=!f&&r(c),h=!f&&!p&&n(c),g=!f&&!p&&!h&&a(c),m=f||p||h||g,v=m?e(c.length,String):[],y=v.length;for(var x in c)(u||i.call(c,x))&&!(m&&(x=="length"||h&&(x=="offset"||x=="parent")||g&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||s(x,y)))&&v.push(x);return v}return pn=d,pn}var hn,fc;function qr(){if(fc)return hn;fc=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,s=typeof n=="function"&&n.prototype||e;return t===s}return hn=r,hn}var gn,pc;function hc(){if(pc)return gn;pc=1;function e(r,t){return function(n){return r(t(n))}}return gn=e,gn}var mn,gc;function Yg(){if(gc)return mn;gc=1;var e=hc(),r=e(Object.keys,Object);return mn=r,mn}var vn,mc;function yn(){if(mc)return vn;mc=1;var e=qr(),r=Yg(),t=Object.prototype,n=t.hasOwnProperty;function s(a){if(!e(a))return r(a);var o=[];for(var i in Object(a))n.call(a,i)&&i!="constructor"&&o.push(i);return o}return vn=s,vn}var xn,vc;function Be(){if(vc)return xn;vc=1;var e=fr(),r=ln();function t(n){return n!=null&&r(n.length)&&!e(n)}return xn=t,xn}var bn,yc;function ze(){if(yc)return bn;yc=1;var e=dc(),r=yn(),t=Be();function n(s){return t(s)?e(s):r(s)}return bn=n,bn}var kn,xc;function Xg(){if(xc)return kn;xc=1;var e=pr(),r=ze();function t(n,s){return n&&e(s,r(s),n)}return kn=t,kn}var _n,bc;function Zg(){if(bc)return _n;bc=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return _n=e,_n}var Sn,kc;function Qg(){if(kc)return Sn;kc=1;var e=je(),r=qr(),t=Zg(),n=Object.prototype,s=n.hasOwnProperty;function a(o){if(!e(o))return t(o);var i=r(o),d=[];for(var c in o)c=="constructor"&&(i||!s.call(o,c))||d.push(c);return d}return Sn=a,Sn}var wn,_c;function Ve(){if(_c)return wn;_c=1;var e=dc(),r=Qg(),t=Be();function n(s){return t(s)?e(s,!0):r(s)}return wn=n,wn}var Tn,Sc;function em(){if(Sc)return Tn;Sc=1;var e=pr(),r=Ve();function t(n,s){return n&&e(s,r(s),n)}return Tn=t,Tn}var yr={exports:{}};yr.exports;var wc;function Tc(){return wc||(wc=1,(function(e,r){var t=Oe(),n=r&&!r.nodeType&&r,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,o=a?t.Buffer:void 0,i=o?o.allocUnsafe:void 0;function d(c,u){if(u)return c.slice();var f=c.length,p=i?i(f):new c.constructor(f);return c.copy(p),p}e.exports=d})(yr,yr.exports)),yr.exports}var En,Ec;function Nc(){if(Ec)return En;Ec=1;function e(r,t){var n=-1,s=r.length;for(t||(t=Array(s));++n<s;)t[n]=r[n];return t}return En=e,En}var Nn,Cc;function jc(){if(Cc)return Nn;Cc=1;function e(r,t){for(var n=-1,s=r==null?0:r.length,a=0,o=[];++n<s;){var i=r[n];t(i,n,r)&&(o[a++]=i)}return o}return Nn=e,Nn}var Cn,Ic;function Rc(){if(Ic)return Cn;Ic=1;function e(){return[]}return Cn=e,Cn}var jn,Oc;function In(){if(Oc)return jn;Oc=1;var e=jc(),r=Rc(),t=Object.prototype,n=t.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(o){return o==null?[]:(o=Object(o),e(s(o),function(i){return n.call(o,i)}))}:r;return jn=a,jn}var Rn,Pc;function rm(){if(Pc)return Rn;Pc=1;var e=pr(),r=In();function t(n,s){return e(n,r(n),s)}return Rn=t,Rn}var On,Ac;function Pn(){if(Ac)return On;Ac=1;function e(r,t){for(var n=-1,s=t.length,a=r.length;++n<s;)r[a+n]=t[n];return r}return On=e,On}var An,Lc;function Dr(){if(Lc)return An;Lc=1;var e=hc(),r=e(Object.getPrototypeOf,Object);return An=r,An}var Ln,qc;function Dc(){if(qc)return Ln;qc=1;var e=Pn(),r=Dr(),t=In(),n=Rc(),s=Object.getOwnPropertySymbols,a=s?function(o){for(var i=[];o;)e(i,t(o)),o=r(o);return i}:n;return Ln=a,Ln}var qn,Mc;function tm(){if(Mc)return qn;Mc=1;var e=pr(),r=Dc();function t(n,s){return e(n,r(n),s)}return qn=t,qn}var Dn,Wc;function Bc(){if(Wc)return Dn;Wc=1;var e=Pn(),r=be();function t(n,s,a){var o=s(n);return r(n)?o:e(o,a(n))}return Dn=t,Dn}var Mn,Fc;function $c(){if(Fc)return Mn;Fc=1;var e=Bc(),r=In(),t=ze();function n(s){return e(s,t,r)}return Mn=n,Mn}var Wn,zc;function nm(){if(zc)return Wn;zc=1;var e=Bc(),r=Dc(),t=Ve();function n(s){return e(s,t,r)}return Wn=n,Wn}var Bn,Hc;function am(){if(Hc)return Bn;Hc=1;var e=Ge(),r=Oe(),t=e(r,"DataView");return Bn=t,Bn}var Fn,Kc;function sm(){if(Kc)return Fn;Kc=1;var e=Ge(),r=Oe(),t=e(r,"Promise");return Fn=t,Fn}var $n,Uc;function Jc(){if(Uc)return $n;Uc=1;var e=Ge(),r=Oe(),t=e(r,"Set");return $n=t,$n}var zn,Gc;function om(){if(Gc)return zn;Gc=1;var e=Ge(),r=Oe(),t=e(r,"WeakMap");return zn=t,zn}var Hn,Vc;function nr(){if(Vc)return Hn;Vc=1;var e=am(),r=Ct(),t=sm(),n=Jc(),s=om(),a=Je(),o=Sl(),i="[object Map]",d="[object Object]",c="[object Promise]",u="[object Set]",f="[object WeakMap]",p="[object DataView]",h=o(e),g=o(r),m=o(t),v=o(n),y=o(s),x=a;return(e&&x(new e(new ArrayBuffer(1)))!=p||r&&x(new r)!=i||t&&x(t.resolve())!=c||n&&x(new n)!=u||s&&x(new s)!=f)&&(x=function(b){var k=a(b),w=k==d?b.constructor:void 0,j=w?o(w):"";if(j)switch(j){case h:return p;case g:return i;case m:return c;case v:return u;case y:return f}return k}),Hn=x,Hn}var Kn,Yc;function im(){if(Yc)return Kn;Yc=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var s=n.length,a=new n.constructor(s);return s&&typeof n[0]=="string"&&r.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return Kn=t,Kn}var Un,Xc;function Zc(){if(Xc)return Un;Xc=1;var e=Oe(),r=e.Uint8Array;return Un=r,Un}var Jn,Qc;function Gn(){if(Qc)return Jn;Qc=1;var e=Zc();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return Jn=r,Jn}var Vn,eu;function lm(){if(eu)return Vn;eu=1;var e=Gn();function r(t,n){var s=n?e(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}return Vn=r,Vn}var Yn,ru;function cm(){if(ru)return Yn;ru=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Yn=r,Yn}var Xn,tu;function um(){if(tu)return Xn;tu=1;var e=rr(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(s){return t?Object(t.call(s)):{}}return Xn=n,Xn}var Zn,nu;function au(){if(nu)return Zn;nu=1;var e=Gn();function r(t,n){var s=n?e(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}return Zn=r,Zn}var Qn,su;function dm(){if(su)return Qn;su=1;var e=Gn(),r=lm(),t=cm(),n=um(),s=au(),a="[object Boolean]",o="[object Date]",i="[object Map]",d="[object Number]",c="[object RegExp]",u="[object Set]",f="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",g="[object DataView]",m="[object Float32Array]",v="[object Float64Array]",y="[object Int8Array]",x="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",w="[object Uint8ClampedArray]",j="[object Uint16Array]",N="[object Uint32Array]";function L(T,C,S){var q=T.constructor;switch(C){case h:return e(T);case a:case o:return new q(+T);case g:return r(T,S);case m:case v:case y:case x:case b:case k:case w:case j:case N:return s(T,S);case i:return new q;case d:case f:return new q(T);case c:return t(T);case u:return new q;case p:return n(T)}}return Qn=L,Qn}var ea,ou;function iu(){if(ou)return ea;ou=1;var e=je(),r=Object.create,t=(function(){function n(){}return function(s){if(!e(s))return{};if(r)return r(s);n.prototype=s;var a=new n;return n.prototype=void 0,a}})();return ea=t,ea}var ra,lu;function cu(){if(lu)return ra;lu=1;var e=iu(),r=Dr(),t=qr();function n(s){return typeof s.constructor=="function"&&!t(s)?e(r(s)):{}}return ra=n,ra}var ta,uu;function fm(){if(uu)return ta;uu=1;var e=nr(),r=De(),t="[object Map]";function n(s){return r(s)&&e(s)==t}return ta=n,ta}var na,du;function pm(){if(du)return na;du=1;var e=fm(),r=Lr(),t=dn(),n=t&&t.isMap,s=n?r(n):e;return na=s,na}var aa,fu;function hm(){if(fu)return aa;fu=1;var e=nr(),r=De(),t="[object Set]";function n(s){return r(s)&&e(s)==t}return aa=n,aa}var sa,pu;function gm(){if(pu)return sa;pu=1;var e=hm(),r=Lr(),t=dn(),n=t&&t.isSet,s=n?r(n):e;return sa=s,sa}var oa,hu;function gu(){if(hu)return oa;hu=1;var e=Rr(),r=Gt(),t=Pr(),n=Xg(),s=em(),a=Tc(),o=Nc(),i=rm(),d=tm(),c=$c(),u=nm(),f=nr(),p=im(),h=dm(),g=cu(),m=be(),v=tr(),y=pm(),x=je(),b=gm(),k=ze(),w=Ve(),j=1,N=2,L=4,T="[object Arguments]",C="[object Array]",S="[object Boolean]",q="[object Date]",I="[object Error]",O="[object Function]",F="[object GeneratorFunction]",W="[object Map]",V="[object Number]",Z="[object Object]",ne="[object RegExp]",ee="[object Set]",D="[object String]",Y="[object Symbol]",se="[object WeakMap]",R="[object ArrayBuffer]",M="[object DataView]",_="[object Float32Array]",B="[object Float64Array]",z="[object Int8Array]",Q="[object Int16Array]",G="[object Int32Array]",oe="[object Uint8Array]",H="[object Uint8ClampedArray]",$="[object Uint16Array]",K="[object Uint32Array]",U={};U[T]=U[C]=U[R]=U[M]=U[S]=U[q]=U[_]=U[B]=U[z]=U[Q]=U[G]=U[W]=U[V]=U[Z]=U[ne]=U[ee]=U[D]=U[Y]=U[oe]=U[H]=U[$]=U[K]=!0,U[I]=U[O]=U[se]=!1;function J(te,ue,fe,me,de,pe){var ve,Te=ue&j,ye=ue&N,E=ue&L;if(fe&&(ve=de?fe(te,me,de,pe):fe(te)),ve!==void 0)return ve;if(!x(te))return te;var X=m(te);if(X){if(ve=p(te),!Te)return o(te,ve)}else{var ae=f(te),le=ae==O||ae==F;if(v(te))return a(te,Te);if(ae==Z||ae==T||le&&!de){if(ve=ye||le?{}:g(te),!Te)return ye?d(te,s(ve,te)):i(te,n(ve,te))}else{if(!U[ae])return de?te:{};ve=h(te,ae,Te)}}pe||(pe=new e);var ce=pe.get(te);if(ce)return ce;pe.set(te,ve),b(te)?te.forEach(function(re){ve.add(J(re,ue,fe,re,te,pe))}):y(te)&&te.forEach(function(re,xe){ve.set(xe,J(re,ue,fe,xe,te,pe))});var he=E?ye?u:c:ye?w:k,ke=X?void 0:he(te);return r(ke||te,function(re,xe){ke&&(xe=re,re=te[xe]),t(ve,xe,J(re,ue,fe,xe,te,pe))}),ve}return oa=J,oa}var ia,mu;function mm(){if(mu)return ia;mu=1;var e=gu(),r=4;function t(n){return e(n,r)}return ia=t,ia}var la,vu;function ca(){if(vu)return la;vu=1;function e(r){return function(){return r}}return la=e,la}var ua,yu;function vm(){if(yu)return ua;yu=1;function e(r){return function(t,n,s){for(var a=-1,o=Object(t),i=s(t),d=i.length;d--;){var c=i[r?d:++a];if(n(o[c],c,o)===!1)break}return t}}return ua=e,ua}var da,xu;function fa(){if(xu)return da;xu=1;var e=vm(),r=e();return da=r,da}var pa,bu;function ha(){if(bu)return pa;bu=1;var e=fa(),r=ze();function t(n,s){return n&&e(n,s,r)}return pa=t,pa}var ga,ku;function ym(){if(ku)return ga;ku=1;var e=Be();function r(t,n){return function(s,a){if(s==null)return s;if(!e(s))return t(s,a);for(var o=s.length,i=n?o:-1,d=Object(s);(n?i--:++i<o)&&a(d[i],i,d)!==!1;);return s}}return ga=r,ga}var ma,_u;function Mr(){if(_u)return ma;_u=1;var e=ha(),r=ym(),t=r(e);return ma=t,ma}var va,Su;function Ye(){if(Su)return va;Su=1;function e(r){return r}return va=e,va}var ya,wu;function Tu(){if(wu)return ya;wu=1;var e=Ye();function r(t){return typeof t=="function"?t:e}return ya=r,ya}var xa,Eu;function Nu(){if(Eu)return xa;Eu=1;var e=Gt(),r=Mr(),t=Tu(),n=be();function s(a,o){var i=n(a)?e:r;return i(a,t(o))}return xa=s,xa}var ba,Cu;function ju(){return Cu||(Cu=1,ba=Nu()),ba}var ka,Iu;function xm(){if(Iu)return ka;Iu=1;var e=Mr();function r(t,n){var s=[];return e(t,function(a,o,i){n(a,o,i)&&s.push(a)}),s}return ka=r,ka}var _a,Ru;function bm(){if(Ru)return _a;Ru=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return _a=r,_a}var Sa,Ou;function km(){if(Ou)return Sa;Ou=1;function e(r){return this.__data__.has(r)}return Sa=e,Sa}var wa,Pu;function Au(){if(Pu)return wa;Pu=1;var e=Ht(),r=bm(),t=km();function n(s){var a=-1,o=s==null?0:s.length;for(this.__data__=new e;++a<o;)this.add(s[a])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,wa=n,wa}var Ta,Lu;function _m(){if(Lu)return Ta;Lu=1;function e(r,t){for(var n=-1,s=r==null?0:r.length;++n<s;)if(t(r[n],n,r))return!0;return!1}return Ta=e,Ta}var Ea,qu;function Du(){if(qu)return Ea;qu=1;function e(r,t){return r.has(t)}return Ea=e,Ea}var Na,Mu;function Wu(){if(Mu)return Na;Mu=1;var e=Au(),r=_m(),t=Du(),n=1,s=2;function a(o,i,d,c,u,f){var p=d&n,h=o.length,g=i.length;if(h!=g&&!(p&&g>h))return!1;var m=f.get(o),v=f.get(i);if(m&&v)return m==i&&v==o;var y=-1,x=!0,b=d&s?new e:void 0;for(f.set(o,i),f.set(i,o);++y<h;){var k=o[y],w=i[y];if(c)var j=p?c(w,k,y,i,o,f):c(k,w,y,o,i,f);if(j!==void 0){if(j)continue;x=!1;break}if(b){if(!r(i,function(N,L){if(!t(b,L)&&(k===N||u(k,N,d,c,f)))return b.push(L)})){x=!1;break}}else if(!(k===w||u(k,w,d,c,f))){x=!1;break}}return f.delete(o),f.delete(i),x}return Na=a,Na}var Ca,Bu;function Sm(){if(Bu)return Ca;Bu=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(s,a){n[++t]=[a,s]}),n}return Ca=e,Ca}var ja,Fu;function Ia(){if(Fu)return ja;Fu=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(s){n[++t]=s}),n}return ja=e,ja}var Ra,$u;function wm(){if($u)return Ra;$u=1;var e=rr(),r=Zc(),t=er(),n=Wu(),s=Sm(),a=Ia(),o=1,i=2,d="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Map]",p="[object Number]",h="[object RegExp]",g="[object Set]",m="[object String]",v="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function w(j,N,L,T,C,S,q){switch(L){case x:if(j.byteLength!=N.byteLength||j.byteOffset!=N.byteOffset)return!1;j=j.buffer,N=N.buffer;case y:return!(j.byteLength!=N.byteLength||!S(new r(j),new r(N)));case d:case c:case p:return t(+j,+N);case u:return j.name==N.name&&j.message==N.message;case h:case m:return j==N+"";case f:var I=s;case g:var O=T&o;if(I||(I=a),j.size!=N.size&&!O)return!1;var F=q.get(j);if(F)return F==N;T|=i,q.set(j,N);var W=n(I(j),I(N),T,C,S,q);return q.delete(j),W;case v:if(k)return k.call(j)==k.call(N)}return!1}return Ra=w,Ra}var Oa,zu;function Tm(){if(zu)return Oa;zu=1;var e=$c(),r=1,t=Object.prototype,n=t.hasOwnProperty;function s(a,o,i,d,c,u){var f=i&r,p=e(a),h=p.length,g=e(o),m=g.length;if(h!=m&&!f)return!1;for(var v=h;v--;){var y=p[v];if(!(f?y in o:n.call(o,y)))return!1}var x=u.get(a),b=u.get(o);if(x&&b)return x==o&&b==a;var k=!0;u.set(a,o),u.set(o,a);for(var w=f;++v<h;){y=p[v];var j=a[y],N=o[y];if(d)var L=f?d(N,j,y,o,a,u):d(j,N,y,a,o,u);if(!(L===void 0?j===N||c(j,N,i,d,u):L)){k=!1;break}w||(w=y=="constructor")}if(k&&!w){var T=a.constructor,C=o.constructor;T!=C&&"constructor"in a&&"constructor"in o&&!(typeof T=="function"&&T instanceof T&&typeof C=="function"&&C instanceof C)&&(k=!1)}return u.delete(a),u.delete(o),k}return Oa=s,Oa}var Pa,Hu;function Em(){if(Hu)return Pa;Hu=1;var e=Rr(),r=Wu(),t=wm(),n=Tm(),s=nr(),a=be(),o=tr(),i=vr(),d=1,c="[object Arguments]",u="[object Array]",f="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function g(m,v,y,x,b,k){var w=a(m),j=a(v),N=w?u:s(m),L=j?u:s(v);N=N==c?f:N,L=L==c?f:L;var T=N==f,C=L==f,S=N==L;if(S&&o(m)){if(!o(v))return!1;w=!0,T=!1}if(S&&!T)return k||(k=new e),w||i(m)?r(m,v,y,x,b,k):t(m,v,N,y,x,b,k);if(!(y&d)){var q=T&&h.call(m,"__wrapped__"),I=C&&h.call(v,"__wrapped__");if(q||I){var O=q?m.value():m,F=I?v.value():v;return k||(k=new e),b(O,F,y,x,k)}}return S?(k||(k=new e),n(m,v,y,x,b,k)):!1}return Pa=g,Pa}var Aa,Ku;function Uu(){if(Ku)return Aa;Ku=1;var e=Em(),r=De();function t(n,s,a,o,i){return n===s?!0:n==null||s==null||!r(n)&&!r(s)?n!==n&&s!==s:e(n,s,a,o,t,i)}return Aa=t,Aa}var La,Ju;function Nm(){if(Ju)return La;Ju=1;var e=Rr(),r=Uu(),t=1,n=2;function s(a,o,i,d){var c=i.length,u=c,f=!d;if(a==null)return!u;for(a=Object(a);c--;){var p=i[c];if(f&&p[2]?p[1]!==a[p[0]]:!(p[0]in a))return!1}for(;++c<u;){p=i[c];var h=p[0],g=a[h],m=p[1];if(f&&p[2]){if(g===void 0&&!(h in a))return!1}else{var v=new e;if(d)var y=d(g,m,h,a,o,v);if(!(y===void 0?r(m,g,t|n,d,v):y))return!1}}return!0}return La=s,La}var qa,Gu;function Vu(){if(Gu)return qa;Gu=1;var e=je();function r(t){return t===t&&!e(t)}return qa=r,qa}var Da,Yu;function Cm(){if(Yu)return Da;Yu=1;var e=Vu(),r=ze();function t(n){for(var s=r(n),a=s.length;a--;){var o=s[a],i=n[o];s[a]=[o,i,e(i)]}return s}return Da=t,Da}var Ma,Xu;function Zu(){if(Xu)return Ma;Xu=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return Ma=e,Ma}var Wa,Qu;function jm(){if(Qu)return Wa;Qu=1;var e=Nm(),r=Cm(),t=Zu();function n(s){var a=r(s);return a.length==1&&a[0][2]?t(a[0][0],a[0][1]):function(o){return o===s||e(o,s,a)}}return Wa=n,Wa}var Ba,ed;function ar(){if(ed)return Ba;ed=1;var e=Je(),r=De(),t="[object Symbol]";function n(s){return typeof s=="symbol"||r(s)&&e(s)==t}return Ba=n,Ba}var Fa,rd;function $a(){if(rd)return Fa;rd=1;var e=be(),r=ar(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(a,o){if(e(a))return!1;var i=typeof a;return i=="number"||i=="symbol"||i=="boolean"||a==null||r(a)?!0:n.test(a)||!t.test(a)||o!=null&&a in Object(o)}return Fa=s,Fa}var za,td;function Im(){if(td)return za;td=1;var e=Ht(),r="Expected a function";function t(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(r);var a=function(){var o=arguments,i=s?s.apply(this,o):o[0],d=a.cache;if(d.has(i))return d.get(i);var c=n.apply(this,o);return a.cache=d.set(i,c)||d,c};return a.cache=new(t.Cache||e),a}return t.Cache=e,za=t,za}var Ha,nd;function Rm(){if(nd)return Ha;nd=1;var e=Im(),r=500;function t(n){var s=e(n,function(o){return a.size===r&&a.clear(),o}),a=s.cache;return s}return Ha=t,Ha}var Ka,ad;function Om(){if(ad)return Ka;ad=1;var e=Rm(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(r,function(o,i,d,c){a.push(d?c.replace(t,"$1"):i||o)}),a});return Ka=n,Ka}var Ua,sd;function Wr(){if(sd)return Ua;sd=1;function e(r,t){for(var n=-1,s=r==null?0:r.length,a=Array(s);++n<s;)a[n]=t(r[n],n,r);return a}return Ua=e,Ua}var Ja,od;function Pm(){if(od)return Ja;od=1;var e=rr(),r=Wr(),t=be(),n=ar(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function o(i){if(typeof i=="string")return i;if(t(i))return r(i,o)+"";if(n(i))return a?a.call(i):"";var d=i+"";return d=="0"&&1/i==-1/0?"-0":d}return Ja=o,Ja}var Ga,id;function ld(){if(id)return Ga;id=1;var e=Pm();function r(t){return t==null?"":e(t)}return Ga=r,Ga}var Va,cd;function Br(){if(cd)return Va;cd=1;var e=be(),r=$a(),t=Om(),n=ld();function s(a,o){return e(a)?a:r(a,o)?[a]:t(n(a))}return Va=s,Va}var Ya,ud;function xr(){if(ud)return Ya;ud=1;var e=ar();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return Ya=r,Ya}var Xa,dd;function Fr(){if(dd)return Xa;dd=1;var e=Br(),r=xr();function t(n,s){s=e(s,n);for(var a=0,o=s.length;n!=null&&a<o;)n=n[r(s[a++])];return a&&a==o?n:void 0}return Xa=t,Xa}var Za,fd;function Am(){if(fd)return Za;fd=1;var e=Fr();function r(t,n,s){var a=t==null?void 0:e(t,n);return a===void 0?s:a}return Za=r,Za}var Qa,pd;function Lm(){if(pd)return Qa;pd=1;function e(r,t){return r!=null&&t in Object(r)}return Qa=e,Qa}var es,hd;function gd(){if(hd)return es;hd=1;var e=Br(),r=hr(),t=be(),n=Ar(),s=ln(),a=xr();function o(i,d,c){d=e(d,i);for(var u=-1,f=d.length,p=!1;++u<f;){var h=a(d[u]);if(!(p=i!=null&&c(i,h)))break;i=i[h]}return p||++u!=f?p:(f=i==null?0:i.length,!!f&&s(f)&&n(h,f)&&(t(i)||r(i)))}return es=o,es}var rs,md;function vd(){if(md)return rs;md=1;var e=Lm(),r=gd();function t(n,s){return n!=null&&r(n,s,e)}return rs=t,rs}var ts,yd;function qm(){if(yd)return ts;yd=1;var e=Uu(),r=Am(),t=vd(),n=$a(),s=Vu(),a=Zu(),o=xr(),i=1,d=2;function c(u,f){return n(u)&&s(f)?a(o(u),f):function(p){var h=r(p,u);return h===void 0&&h===f?t(p,u):e(f,h,i|d)}}return ts=c,ts}var ns,xd;function bd(){if(xd)return ns;xd=1;function e(r){return function(t){return t?.[r]}}return ns=e,ns}var as,kd;function Dm(){if(kd)return as;kd=1;var e=Fr();function r(t){return function(n){return e(n,t)}}return as=r,as}var ss,_d;function Mm(){if(_d)return ss;_d=1;var e=bd(),r=Dm(),t=$a(),n=xr();function s(a){return t(a)?e(n(a)):r(a)}return ss=s,ss}var os,Sd;function Fe(){if(Sd)return os;Sd=1;var e=jm(),r=qm(),t=Ye(),n=be(),s=Mm();function a(o){return typeof o=="function"?o:o==null?t:typeof o=="object"?n(o)?r(o[0],o[1]):e(o):s(o)}return os=a,os}var is,wd;function Td(){if(wd)return is;wd=1;var e=jc(),r=xm(),t=Fe(),n=be();function s(a,o){var i=n(a)?e:r;return i(a,t(o,3))}return is=s,is}var ls,Ed;function Wm(){if(Ed)return ls;Ed=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,s){return n!=null&&r.call(n,s)}return ls=t,ls}var cs,Nd;function Cd(){if(Nd)return cs;Nd=1;var e=Wm(),r=gd();function t(n,s){return n!=null&&r(n,s,e)}return cs=t,cs}var us,jd;function Bm(){if(jd)return us;jd=1;var e=yn(),r=nr(),t=hr(),n=be(),s=Be(),a=tr(),o=qr(),i=vr(),d="[object Map]",c="[object Set]",u=Object.prototype,f=u.hasOwnProperty;function p(h){if(h==null)return!0;if(s(h)&&(n(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||i(h)||t(h)))return!h.length;var g=r(h);if(g==d||g==c)return!h.size;if(o(h))return!e(h).length;for(var m in h)if(f.call(h,m))return!1;return!0}return us=p,us}var ds,Id;function Rd(){if(Id)return ds;Id=1;function e(r){return r===void 0}return ds=e,ds}var fs,Od;function Pd(){if(Od)return fs;Od=1;var e=Mr(),r=Be();function t(n,s){var a=-1,o=r(n)?Array(n.length):[];return e(n,function(i,d,c){o[++a]=s(i,d,c)}),o}return fs=t,fs}var ps,Ad;function Ld(){if(Ad)return ps;Ad=1;var e=Wr(),r=Fe(),t=Pd(),n=be();function s(a,o){var i=n(a)?e:t;return i(a,r(o,3))}return ps=s,ps}var hs,qd;function Fm(){if(qd)return hs;qd=1;function e(r,t,n,s){var a=-1,o=r==null?0:r.length;for(s&&o&&(n=r[++a]);++a<o;)n=t(n,r[a],a,r);return n}return hs=e,hs}var gs,Dd;function $m(){if(Dd)return gs;Dd=1;function e(r,t,n,s,a){return a(r,function(o,i,d){n=s?(s=!1,o):t(n,o,i,d)}),n}return gs=e,gs}var ms,Md;function Wd(){if(Md)return ms;Md=1;var e=Fm(),r=Mr(),t=Fe(),n=$m(),s=be();function a(o,i,d){var c=s(o)?e:n,u=arguments.length<3;return c(o,t(i,4),d,u,r)}return ms=a,ms}var vs,Bd;function zm(){if(Bd)return vs;Bd=1;var e=Je(),r=be(),t=De(),n="[object String]";function s(a){return typeof a=="string"||!r(a)&&t(a)&&e(a)==n}return vs=s,vs}var ys,Fd;function Hm(){if(Fd)return ys;Fd=1;var e=bd(),r=e("length");return ys=r,ys}var xs,$d;function Km(){if($d)return xs;$d=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=r+t+n,a="\\ufe0e\\ufe0f",o="\\u200d",i=RegExp("["+o+e+s+a+"]");function d(c){return i.test(c)}return xs=d,xs}var bs,zd;function Um(){if(zd)return bs;zd=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=r+t+n,a="\\ufe0e\\ufe0f",o="["+e+"]",i="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",c="(?:"+i+"|"+d+")",u="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=c+"?",m="["+a+"]?",v="(?:"+h+"(?:"+[u,f,p].join("|")+")"+m+g+")*",y=m+g+v,x="(?:"+[u+i+"?",i,f,p,o].join("|")+")",b=RegExp(d+"(?="+d+")|"+x+y,"g");function k(w){for(var j=b.lastIndex=0;b.test(w);)++j;return j}return bs=k,bs}var ks,Hd;function Jm(){if(Hd)return ks;Hd=1;var e=Hm(),r=Km(),t=Um();function n(s){return r(s)?t(s):e(s)}return ks=n,ks}var _s,Kd;function Gm(){if(Kd)return _s;Kd=1;var e=yn(),r=nr(),t=Be(),n=zm(),s=Jm(),a="[object Map]",o="[object Set]";function i(d){if(d==null)return 0;if(t(d))return n(d)?s(d):d.length;var c=r(d);return c==a||c==o?d.size:e(d).length}return _s=i,_s}var Ss,Ud;function Vm(){if(Ud)return Ss;Ud=1;var e=Gt(),r=iu(),t=ha(),n=Fe(),s=Dr(),a=be(),o=tr(),i=fr(),d=je(),c=vr();function u(f,p,h){var g=a(f),m=g||o(f)||c(f);if(p=n(p,4),h==null){var v=f&&f.constructor;m?h=g?new v:[]:d(f)?h=i(v)?r(s(f)):{}:h={}}return(m?e:t)(f,function(y,x,b){return p(h,y,x,b)}),h}return Ss=u,Ss}var ws,Jd;function Ym(){if(Jd)return ws;Jd=1;var e=rr(),r=hr(),t=be(),n=e?e.isConcatSpreadable:void 0;function s(a){return t(a)||r(a)||!!(n&&a&&a[n])}return ws=s,ws}var Ts,Gd;function Es(){if(Gd)return Ts;Gd=1;var e=Pn(),r=Ym();function t(n,s,a,o,i){var d=-1,c=n.length;for(a||(a=r),i||(i=[]);++d<c;){var u=n[d];s>0&&a(u)?s>1?t(u,s-1,a,o,i):e(i,u):o||(i[i.length]=u)}return i}return Ts=t,Ts}var Ns,Vd;function Xm(){if(Vd)return Ns;Vd=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return Ns=e,Ns}var Cs,Yd;function Xd(){if(Yd)return Cs;Yd=1;var e=Xm(),r=Math.max;function t(n,s,a){return s=r(s===void 0?n.length-1:s,0),function(){for(var o=arguments,i=-1,d=r(o.length-s,0),c=Array(d);++i<d;)c[i]=o[s+i];i=-1;for(var u=Array(s+1);++i<s;)u[i]=o[i];return u[s]=a(c),e(n,this,u)}}return Cs=t,Cs}var js,Zd;function Zm(){if(Zd)return js;Zd=1;var e=ca(),r=Jl(),t=Ye(),n=r?function(s,a){return r(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:t;return js=n,js}var Is,Qd;function Qm(){if(Qd)return Is;Qd=1;var e=800,r=16,t=Date.now;function n(s){var a=0,o=0;return function(){var i=t(),d=r-(i-o);if(o=i,d>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Is=n,Is}var Rs,ef;function rf(){if(ef)return Rs;ef=1;var e=Zm(),r=Qm(),t=r(e);return Rs=t,Rs}var Os,tf;function $r(){if(tf)return Os;tf=1;var e=Ye(),r=Xd(),t=rf();function n(s,a){return t(r(s,a,e),s+"")}return Os=n,Os}var Ps,nf;function af(){if(nf)return Ps;nf=1;function e(r,t,n,s){for(var a=r.length,o=n+(s?1:-1);s?o--:++o<a;)if(t(r[o],o,r))return o;return-1}return Ps=e,Ps}var As,sf;function ev(){if(sf)return As;sf=1;function e(r){return r!==r}return As=e,As}var Ls,of;function rv(){if(of)return Ls;of=1;function e(r,t,n){for(var s=n-1,a=r.length;++s<a;)if(r[s]===t)return s;return-1}return Ls=e,Ls}var qs,lf;function tv(){if(lf)return qs;lf=1;var e=af(),r=ev(),t=rv();function n(s,a,o){return a===a?t(s,a,o):e(s,r,o)}return qs=n,qs}var Ds,cf;function nv(){if(cf)return Ds;cf=1;var e=tv();function r(t,n){var s=t==null?0:t.length;return!!s&&e(t,n,0)>-1}return Ds=r,Ds}var Ms,uf;function av(){if(uf)return Ms;uf=1;function e(r,t,n){for(var s=-1,a=r==null?0:r.length;++s<a;)if(n(t,r[s]))return!0;return!1}return Ms=e,Ms}var Ws,df;function sv(){if(df)return Ws;df=1;function e(){}return Ws=e,Ws}var Bs,ff;function ov(){if(ff)return Bs;ff=1;var e=Jc(),r=sv(),t=Ia(),n=1/0,s=e&&1/t(new e([,-0]))[1]==n?function(a){return new e(a)}:r;return Bs=s,Bs}var Fs,pf;function iv(){if(pf)return Fs;pf=1;var e=Au(),r=nv(),t=av(),n=Du(),s=ov(),a=Ia(),o=200;function i(d,c,u){var f=-1,p=r,h=d.length,g=!0,m=[],v=m;if(u)g=!1,p=t;else if(h>=o){var y=c?null:s(d);if(y)return a(y);g=!1,p=n,v=new e}else v=c?[]:m;e:for(;++f<h;){var x=d[f],b=c?c(x):x;if(x=u||x!==0?x:0,g&&b===b){for(var k=v.length;k--;)if(v[k]===b)continue e;c&&v.push(b),m.push(x)}else p(v,b,u)||(v!==m&&v.push(b),m.push(x))}return m}return Fs=i,Fs}var $s,hf;function gf(){if(hf)return $s;hf=1;var e=Be(),r=De();function t(n){return r(n)&&e(n)}return $s=t,$s}var zs,mf;function lv(){if(mf)return zs;mf=1;var e=Es(),r=$r(),t=iv(),n=gf(),s=r(function(a){return t(e(a,1,n,!0))});return zs=s,zs}var Hs,vf;function cv(){if(vf)return Hs;vf=1;var e=Wr();function r(t,n){return e(n,function(s){return t[s]})}return Hs=r,Hs}var Ks,yf;function xf(){if(yf)return Ks;yf=1;var e=cv(),r=ze();function t(n){return n==null?[]:e(n,r(n))}return Ks=t,Ks}var Us,bf;function Ie(){if(bf)return Us;bf=1;var e;if(typeof et=="function")try{e={clone:mm(),constant:ca(),each:ju(),filter:Td(),has:Cd(),isArray:be(),isEmpty:Bm(),isFunction:fr(),isUndefined:Rd(),keys:ze(),map:Ld(),reduce:Wd(),size:Gm(),transform:Vm(),union:lv(),values:xf()}}catch{}return e||(e=window._),Us=e,Us}var Js,kf;function Gs(){if(kf)return Js;kf=1;var e=Ie();Js=s;var r="\0",t="\0",n="";function s(u){this._isDirected=e.has(u,"directed")?u.directed:!0,this._isMultigraph=e.has(u,"multigraph")?u.multigraph:!1,this._isCompound=e.has(u,"compound")?u.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(u){return this._label=u,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultNodeLabelFn=u,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._in[f])})},s.prototype.sinks=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._out[f])})},s.prototype.setNodes=function(u,f){var p=arguments,h=this;return e.each(u,function(g){p.length>1?h.setNode(g,f):h.setNode(g)}),this},s.prototype.setNode=function(u,f){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=f),this):(this._nodes[u]=arguments.length>1?f:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=t,this._children[u]={},this._children[t][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},s.prototype.node=function(u){return this._nodes[u]},s.prototype.hasNode=function(u){return e.has(this._nodes,u)},s.prototype.removeNode=function(u){var f=this;if(e.has(this._nodes,u)){var p=function(h){f.removeEdge(f._edgeObjs[h])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(h){f.setParent(h)}),delete this._children[u]),e.each(e.keys(this._in[u]),p),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),p),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},s.prototype.setParent=function(u,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=t;else{f+="";for(var p=f;!e.isUndefined(p);p=this.parent(p))if(p===u)throw new Error("Setting "+f+" as parent of "+u+" would create a cycle");this.setNode(f)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=f,this._children[f][u]=!0,this},s.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},s.prototype.parent=function(u){if(this._isCompound){var f=this._parent[u];if(f!==t)return f}},s.prototype.children=function(u){if(e.isUndefined(u)&&(u=t),this._isCompound){var f=this._children[u];if(f)return e.keys(f)}else{if(u===t)return this.nodes();if(this.hasNode(u))return[]}},s.prototype.predecessors=function(u){var f=this._preds[u];if(f)return e.keys(f)},s.prototype.successors=function(u){var f=this._sucs[u];if(f)return e.keys(f)},s.prototype.neighbors=function(u){var f=this.predecessors(u);if(f)return e.union(f,this.successors(u))},s.prototype.isLeaf=function(u){var f;return this.isDirected()?f=this.successors(u):f=this.neighbors(u),f.length===0},s.prototype.filterNodes=function(u){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var p=this;e.each(this._nodes,function(m,v){u(v)&&f.setNode(v,m)}),e.each(this._edgeObjs,function(m){f.hasNode(m.v)&&f.hasNode(m.w)&&f.setEdge(m,p.edge(m))});var h={};function g(m){var v=p.parent(m);return v===void 0||f.hasNode(v)?(h[m]=v,v):v in h?h[v]:g(v)}return this._isCompound&&e.each(f.nodes(),function(m){f.setParent(m,g(m))}),f},s.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(u,f){var p=this,h=arguments;return e.reduce(u,function(g,m){return h.length>1?p.setEdge(g,m,f):p.setEdge(g,m),m}),this},s.prototype.setEdge=function(){var u,f,p,h,g=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(u=m.v,f=m.w,p=m.name,arguments.length===2&&(h=arguments[1],g=!0)):(u=m,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),u=""+u,f=""+f,e.isUndefined(p)||(p=""+p);var v=i(this._isDirected,u,f,p);if(e.has(this._edgeLabels,v))return g&&(this._edgeLabels[v]=h),this;if(!e.isUndefined(p)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(f),this._edgeLabels[v]=g?h:this._defaultEdgeLabelFn(u,f,p);var y=d(this._isDirected,u,f,p);return u=y.v,f=y.w,Object.freeze(y),this._edgeObjs[v]=y,a(this._preds[f],u),a(this._sucs[u],f),this._in[f][v]=y,this._out[u][v]=y,this._edgeCount++,this},s.prototype.edge=function(u,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,u,f,p);return this._edgeLabels[h]},s.prototype.hasEdge=function(u,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,u,f,p);return e.has(this._edgeLabels,h)},s.prototype.removeEdge=function(u,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,u,f,p),g=this._edgeObjs[h];return g&&(u=g.v,f=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[f],u),o(this._sucs[u],f),delete this._in[f][h],delete this._out[u][h],this._edgeCount--),this},s.prototype.inEdges=function(u,f){var p=this._in[u];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.v===f}):h}},s.prototype.outEdges=function(u,f){var p=this._out[u];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.w===f}):h}},s.prototype.nodeEdges=function(u,f){var p=this.inEdges(u,f);if(p)return p.concat(this.outEdges(u,f))};function a(u,f){u[f]?u[f]++:u[f]=1}function o(u,f){--u[f]||delete u[f]}function i(u,f,p,h){var g=""+f,m=""+p;if(!u&&g>m){var v=g;g=m,m=v}return g+n+m+n+(e.isUndefined(h)?r:h)}function d(u,f,p,h){var g=""+f,m=""+p;if(!u&&g>m){var v=g;g=m,m=v}var y={v:g,w:m};return h&&(y.name=h),y}function c(u,f){return i(u,f.v,f.w,f.name)}return Js}var Vs,_f;function uv(){return _f||(_f=1,Vs="2.1.8"),Vs}var Ys,Sf;function dv(){return Sf||(Sf=1,Ys={Graph:Gs(),version:uv()}),Ys}var Xs,wf;function fv(){if(wf)return Xs;wf=1;var e=Ie(),r=Gs();Xs={write:t,read:a};function t(o){var i={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:s(o)};return e.isUndefined(o.graph())||(i.value=e.clone(o.graph())),i}function n(o){return e.map(o.nodes(),function(i){var d=o.node(i),c=o.parent(i),u={v:i};return e.isUndefined(d)||(u.value=d),e.isUndefined(c)||(u.parent=c),u})}function s(o){return e.map(o.edges(),function(i){var d=o.edge(i),c={v:i.v,w:i.w};return e.isUndefined(i.name)||(c.name=i.name),e.isUndefined(d)||(c.value=d),c})}function a(o){var i=new r(o.options).setGraph(o.value);return e.each(o.nodes,function(d){i.setNode(d.v,d.value),d.parent&&i.setParent(d.v,d.parent)}),e.each(o.edges,function(d){i.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),i}return Xs}var Zs,Tf;function pv(){if(Tf)return Zs;Tf=1;var e=Ie();Zs=r;function r(t){var n={},s=[],a;function o(i){e.has(n,i)||(n[i]=!0,a.push(i),e.each(t.successors(i),o),e.each(t.predecessors(i),o))}return e.each(t.nodes(),function(i){a=[],o(i),a.length&&s.push(a)}),s}return Zs}var Qs,Ef;function Nf(){if(Ef)return Qs;Ef=1;var e=Ie();Qs=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var s=this._keyIndices;if(t=String(t),!e.has(s,t)){var a=this._arr,o=a.length;return s[t]=o,a.push({key:t,priority:n}),this._decrease(o),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var s=this._keyIndices[t];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},r.prototype._heapify=function(t){var n=this._arr,s=2*t,a=s+1,o=t;s<n.length&&(o=n[s].priority<n[o].priority?s:o,a<n.length&&(o=n[a].priority<n[o].priority?a:o),o!==t&&(this._swap(t,o),this._heapify(o)))},r.prototype._decrease=function(t){for(var n=this._arr,s=n[t].priority,a;t!==0&&(a=t>>1,!(n[a].priority<s));)this._swap(t,a),t=a},r.prototype._swap=function(t,n){var s=this._arr,a=this._keyIndices,o=s[t],i=s[n];s[t]=i,s[n]=o,a[i.key]=t,a[o.key]=n},Qs}var eo,Cf;function jf(){if(Cf)return eo;Cf=1;var e=Ie(),r=Nf();eo=n;var t=e.constant(1);function n(a,o,i,d){return s(a,String(o),i||t,d||function(c){return a.outEdges(c)})}function s(a,o,i,d){var c={},u=new r,f,p,h=function(g){var m=g.v!==f?g.v:g.w,v=c[m],y=i(g),x=p.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+y);x<v.distance&&(v.distance=x,v.predecessor=f,u.decrease(m,x))};for(a.nodes().forEach(function(g){var m=g===o?0:Number.POSITIVE_INFINITY;c[g]={distance:m},u.add(g,m)});u.size()>0&&(f=u.removeMin(),p=c[f],p.distance!==Number.POSITIVE_INFINITY);)d(f).forEach(h);return c}return eo}var ro,If;function hv(){if(If)return ro;If=1;var e=jf(),r=Ie();ro=t;function t(n,s,a){return r.transform(n.nodes(),function(o,i){o[i]=e(n,i,s,a)},{})}return ro}var to,Rf;function Of(){if(Rf)return to;Rf=1;var e=Ie();to=r;function r(t){var n=0,s=[],a={},o=[];function i(d){var c=a[d]={onStack:!0,lowlink:n,index:n++};if(s.push(d),t.successors(d).forEach(function(p){e.has(a,p)?a[p].onStack&&(c.lowlink=Math.min(c.lowlink,a[p].index)):(i(p),c.lowlink=Math.min(c.lowlink,a[p].lowlink))}),c.lowlink===c.index){var u=[],f;do f=s.pop(),a[f].onStack=!1,u.push(f);while(d!==f);o.push(u)}}return t.nodes().forEach(function(d){e.has(a,d)||i(d)}),o}return to}var no,Pf;function gv(){if(Pf)return no;Pf=1;var e=Ie(),r=Of();no=t;function t(n){return e.filter(r(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return no}var ao,Af;function mv(){if(Af)return ao;Af=1;var e=Ie();ao=t;var r=e.constant(1);function t(s,a,o){return n(s,a||r,o||function(i){return s.outEdges(i)})}function n(s,a,o){var i={},d=s.nodes();return d.forEach(function(c){i[c]={},i[c][c]={distance:0},d.forEach(function(u){c!==u&&(i[c][u]={distance:Number.POSITIVE_INFINITY})}),o(c).forEach(function(u){var f=u.v===c?u.w:u.v,p=a(u);i[c][f]={distance:p,predecessor:c}})}),d.forEach(function(c){var u=i[c];d.forEach(function(f){var p=i[f];d.forEach(function(h){var g=p[c],m=u[h],v=p[h],y=g.distance+m.distance;y<v.distance&&(v.distance=y,v.predecessor=m.predecessor)})})}),i}return ao}var so,Lf;function qf(){if(Lf)return so;Lf=1;var e=Ie();so=r,r.CycleException=t;function r(n){var s={},a={},o=[];function i(d){if(e.has(a,d))throw new t;e.has(s,d)||(a[d]=!0,s[d]=!0,e.each(n.predecessors(d),i),delete a[d],o.push(d))}if(e.each(n.sinks(),i),e.size(s)!==n.nodeCount())throw new t;return o}function t(){}return t.prototype=new Error,so}var oo,Df;function vv(){if(Df)return oo;Df=1;var e=qf();oo=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return oo}var io,Mf;function Wf(){if(Mf)return io;Mf=1;var e=Ie();io=r;function r(n,s,a){e.isArray(s)||(s=[s]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),i=[],d={};return e.each(s,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);t(n,c,a==="post",d,o,i)}),i}function t(n,s,a,o,i,d){e.has(o,s)||(o[s]=!0,a||d.push(s),e.each(i(s),function(c){t(n,c,a,o,i,d)}),a&&d.push(s))}return io}var lo,Bf;function yv(){if(Bf)return lo;Bf=1;var e=Wf();lo=r;function r(t,n){return e(t,n,"post")}return lo}var co,Ff;function xv(){if(Ff)return co;Ff=1;var e=Wf();co=r;function r(t,n){return e(t,n,"pre")}return co}var uo,$f;function bv(){if($f)return uo;$f=1;var e=Ie(),r=Gs(),t=Nf();uo=n;function n(s,a){var o=new r,i={},d=new t,c;function u(p){var h=p.v===c?p.w:p.v,g=d.priority(h);if(g!==void 0){var m=a(p);m<g&&(i[h]=c,d.decrease(h,m))}}if(s.nodeCount()===0)return o;e.each(s.nodes(),function(p){d.add(p,Number.POSITIVE_INFINITY),o.setNode(p)}),d.decrease(s.nodes()[0],0);for(var f=!1;d.size()>0;){if(c=d.removeMin(),e.has(i,c))o.setEdge(c,i[c]);else{if(f)throw new Error("Input graph is not connected: "+s);f=!0}s.nodeEdges(c).forEach(u)}return o}return uo}var fo,zf;function kv(){return zf||(zf=1,fo={components:pv(),dijkstra:jf(),dijkstraAll:hv(),findCycles:gv(),floydWarshall:mv(),isAcyclic:vv(),postorder:yv(),preorder:xv(),prim:bv(),tarjan:Of(),topsort:qf()}),fo}var po,Hf;function _v(){if(Hf)return po;Hf=1;var e=dv();return po={Graph:e.Graph,json:fv(),alg:kv(),version:e.version},po}var ho,Kf;function Pe(){if(Kf)return ho;Kf=1;var e;if(typeof et=="function")try{e=_v()}catch{}return e||(e=window.graphlib),ho=e,ho}var go,Uf;function Sv(){if(Uf)return go;Uf=1;var e=gu(),r=1,t=4;function n(s){return e(s,r|t)}return go=n,go}var mo,Jf;function zr(){if(Jf)return mo;Jf=1;var e=er(),r=Be(),t=Ar(),n=je();function s(a,o,i){if(!n(i))return!1;var d=typeof o;return(d=="number"?r(i)&&t(o,i.length):d=="string"&&o in i)?e(i[o],a):!1}return mo=s,mo}var vo,Gf;function wv(){if(Gf)return vo;Gf=1;var e=$r(),r=er(),t=zr(),n=Ve(),s=Object.prototype,a=s.hasOwnProperty,o=e(function(i,d){i=Object(i);var c=-1,u=d.length,f=u>2?d[2]:void 0;for(f&&t(d[0],d[1],f)&&(u=1);++c<u;)for(var p=d[c],h=n(p),g=-1,m=h.length;++g<m;){var v=h[g],y=i[v];(y===void 0||r(y,s[v])&&!a.call(i,v))&&(i[v]=p[v])}return i});return vo=o,vo}var yo,Vf;function Tv(){if(Vf)return yo;Vf=1;var e=Fe(),r=Be(),t=ze();function n(s){return function(a,o,i){var d=Object(a);if(!r(a)){var c=e(o,3);a=t(a),o=function(f){return c(d[f],f,d)}}var u=s(a,o,i);return u>-1?d[c?a[u]:u]:void 0}}return yo=n,yo}var xo,Yf;function Ev(){if(Yf)return xo;Yf=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return xo=r,xo}var bo,Xf;function Nv(){if(Xf)return bo;Xf=1;var e=Ev(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return bo=t,bo}var ko,Zf;function Cv(){if(Zf)return ko;Zf=1;var e=Nv(),r=je(),t=ar(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt;function d(c){if(typeof c=="number")return c;if(t(c))return n;if(r(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=r(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=e(c);var f=a.test(c);return f||o.test(c)?i(c.slice(2),f?2:8):s.test(c)?n:+c}return ko=d,ko}var _o,Qf;function ep(){if(Qf)return _o;Qf=1;var e=Cv(),r=1/0,t=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===r||s===-r){var a=s<0?-1:1;return a*t}return s===s?s:0}return _o=n,_o}var So,rp;function jv(){if(rp)return So;rp=1;var e=ep();function r(t){var n=e(t),s=n%1;return n===n?s?n-s:n:0}return So=r,So}var wo,tp;function Iv(){if(tp)return wo;tp=1;var e=af(),r=Fe(),t=jv(),n=Math.max;function s(a,o,i){var d=a==null?0:a.length;if(!d)return-1;var c=i==null?0:t(i);return c<0&&(c=n(d+c,0)),e(a,r(o,3),c)}return wo=s,wo}var To,np;function Rv(){if(np)return To;np=1;var e=Tv(),r=Iv(),t=e(r);return To=t,To}var Eo,ap;function sp(){if(ap)return Eo;ap=1;var e=Es();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return Eo=r,Eo}var No,op;function Ov(){if(op)return No;op=1;var e=fa(),r=Tu(),t=Ve();function n(s,a){return s==null?s:e(s,r(a),t)}return No=n,No}var Co,ip;function Pv(){if(ip)return Co;ip=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Co=e,Co}var jo,lp;function Av(){if(lp)return jo;lp=1;var e=Or(),r=ha(),t=Fe();function n(s,a){var o={};return a=t(a,3),r(s,function(i,d,c){e(o,d,a(i,d,c))}),o}return jo=n,jo}var Io,cp;function Ro(){if(cp)return Io;cp=1;var e=ar();function r(t,n,s){for(var a=-1,o=t.length;++a<o;){var i=t[a],d=n(i);if(d!=null&&(c===void 0?d===d&&!e(d):s(d,c)))var c=d,u=i}return u}return Io=r,Io}var Oo,up;function Lv(){if(up)return Oo;up=1;function e(r,t){return r>t}return Oo=e,Oo}var Po,dp;function qv(){if(dp)return Po;dp=1;var e=Ro(),r=Lv(),t=Ye();function n(s){return s&&s.length?e(s,t,r):void 0}return Po=n,Po}var Ao,fp;function pp(){if(fp)return Ao;fp=1;var e=Or(),r=er();function t(n,s,a){(a!==void 0&&!r(n[s],a)||a===void 0&&!(s in n))&&e(n,s,a)}return Ao=t,Ao}var Lo,hp;function Dv(){if(hp)return Lo;hp=1;var e=Je(),r=Dr(),t=De(),n="[object Object]",s=Function.prototype,a=Object.prototype,o=s.toString,i=a.hasOwnProperty,d=o.call(Object);function c(u){if(!t(u)||e(u)!=n)return!1;var f=r(u);if(f===null)return!0;var p=i.call(f,"constructor")&&f.constructor;return typeof p=="function"&&p instanceof p&&o.call(p)==d}return Lo=c,Lo}var qo,gp;function mp(){if(gp)return qo;gp=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return qo=e,qo}var Do,vp;function Mv(){if(vp)return Do;vp=1;var e=pr(),r=Ve();function t(n){return e(n,r(n))}return Do=t,Do}var Mo,yp;function Wv(){if(yp)return Mo;yp=1;var e=pp(),r=Tc(),t=au(),n=Nc(),s=cu(),a=hr(),o=be(),i=gf(),d=tr(),c=fr(),u=je(),f=Dv(),p=vr(),h=mp(),g=Mv();function m(v,y,x,b,k,w,j){var N=h(v,x),L=h(y,x),T=j.get(L);if(T){e(v,x,T);return}var C=w?w(N,L,x+"",v,y,j):void 0,S=C===void 0;if(S){var q=o(L),I=!q&&d(L),O=!q&&!I&&p(L);C=L,q||I||O?o(N)?C=N:i(N)?C=n(N):I?(S=!1,C=r(L,!0)):O?(S=!1,C=t(L,!0)):C=[]:f(L)||a(L)?(C=N,a(N)?C=g(N):(!u(N)||c(N))&&(C=s(L))):S=!1}S&&(j.set(L,C),k(C,L,b,w,j),j.delete(L)),e(v,x,C)}return Mo=m,Mo}var Wo,xp;function Bv(){if(xp)return Wo;xp=1;var e=Rr(),r=pp(),t=fa(),n=Wv(),s=je(),a=Ve(),o=mp();function i(d,c,u,f,p){d!==c&&t(c,function(h,g){if(p||(p=new e),s(h))n(d,c,g,u,i,f,p);else{var m=f?f(o(d,g),h,g+"",d,c,p):void 0;m===void 0&&(m=h),r(d,g,m)}},a)}return Wo=i,Wo}var Bo,bp;function Fv(){if(bp)return Bo;bp=1;var e=$r(),r=zr();function t(n){return e(function(s,a){var o=-1,i=a.length,d=i>1?a[i-1]:void 0,c=i>2?a[2]:void 0;for(d=n.length>3&&typeof d=="function"?(i--,d):void 0,c&&r(a[0],a[1],c)&&(d=i<3?void 0:d,i=1),s=Object(s);++o<i;){var u=a[o];u&&n(s,u,o,d)}return s})}return Bo=t,Bo}var Fo,kp;function $v(){if(kp)return Fo;kp=1;var e=Bv(),r=Fv(),t=r(function(n,s,a){e(n,s,a)});return Fo=t,Fo}var $o,_p;function Sp(){if(_p)return $o;_p=1;function e(r,t){return r<t}return $o=e,$o}var zo,wp;function zv(){if(wp)return zo;wp=1;var e=Ro(),r=Sp(),t=Ye();function n(s){return s&&s.length?e(s,t,r):void 0}return zo=n,zo}var Ho,Tp;function Hv(){if(Tp)return Ho;Tp=1;var e=Ro(),r=Fe(),t=Sp();function n(s,a){return s&&s.length?e(s,r(a,2),t):void 0}return Ho=n,Ho}var Ko,Ep;function Kv(){if(Ep)return Ko;Ep=1;var e=Oe(),r=function(){return e.Date.now()};return Ko=r,Ko}var Uo,Np;function Uv(){if(Np)return Uo;Np=1;var e=Pr(),r=Br(),t=Ar(),n=je(),s=xr();function a(o,i,d,c){if(!n(o))return o;i=r(i,o);for(var u=-1,f=i.length,p=f-1,h=o;h!=null&&++u<f;){var g=s(i[u]),m=d;if(g==="__proto__"||g==="constructor"||g==="prototype")return o;if(u!=p){var v=h[g];m=c?c(v,g,h):void 0,m===void 0&&(m=n(v)?v:t(i[u+1])?[]:{})}e(h,g,m),h=h[g]}return o}return Uo=a,Uo}var Jo,Cp;function Jv(){if(Cp)return Jo;Cp=1;var e=Fr(),r=Uv(),t=Br();function n(s,a,o){for(var i=-1,d=a.length,c={};++i<d;){var u=a[i],f=e(s,u);o(f,u)&&r(c,t(u,s),f)}return c}return Jo=n,Jo}var Go,jp;function Gv(){if(jp)return Go;jp=1;var e=Jv(),r=vd();function t(n,s){return e(n,s,function(a,o){return r(n,o)})}return Go=t,Go}var Vo,Ip;function Vv(){if(Ip)return Vo;Ip=1;var e=sp(),r=Xd(),t=rf();function n(s){return t(r(s,void 0,e),s+"")}return Vo=n,Vo}var Yo,Rp;function Yv(){if(Rp)return Yo;Rp=1;var e=Gv(),r=Vv(),t=r(function(n,s){return n==null?{}:e(n,s)});return Yo=t,Yo}var Xo,Op;function Xv(){if(Op)return Xo;Op=1;var e=Math.ceil,r=Math.max;function t(n,s,a,o){for(var i=-1,d=r(e((s-n)/(a||1)),0),c=Array(d);d--;)c[o?d:++i]=n,n+=a;return c}return Xo=t,Xo}var Zo,Pp;function Zv(){if(Pp)return Zo;Pp=1;var e=Xv(),r=zr(),t=ep();function n(s){return function(a,o,i){return i&&typeof i!="number"&&r(a,o,i)&&(o=i=void 0),a=t(a),o===void 0?(o=a,a=0):o=t(o),i=i===void 0?a<o?1:-1:t(i),e(a,o,i,s)}}return Zo=n,Zo}var Qo,Ap;function Qv(){if(Ap)return Qo;Ap=1;var e=Zv(),r=e();return Qo=r,Qo}var ei,Lp;function ey(){if(Lp)return ei;Lp=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return ei=e,ei}var ri,qp;function ry(){if(qp)return ri;qp=1;var e=ar();function r(t,n){if(t!==n){var s=t!==void 0,a=t===null,o=t===t,i=e(t),d=n!==void 0,c=n===null,u=n===n,f=e(n);if(!c&&!f&&!i&&t>n||i&&d&&u&&!c&&!f||a&&d&&u||!s&&u||!o)return 1;if(!a&&!i&&!f&&t<n||f&&s&&o&&!a&&!i||c&&s&&o||!d&&o||!u)return-1}return 0}return ri=r,ri}var ti,Dp;function ty(){if(Dp)return ti;Dp=1;var e=ry();function r(t,n,s){for(var a=-1,o=t.criteria,i=n.criteria,d=o.length,c=s.length;++a<d;){var u=e(o[a],i[a]);if(u){if(a>=c)return u;var f=s[a];return u*(f=="desc"?-1:1)}}return t.index-n.index}return ti=r,ti}var ni,Mp;function ny(){if(Mp)return ni;Mp=1;var e=Wr(),r=Fr(),t=Fe(),n=Pd(),s=ey(),a=Lr(),o=ty(),i=Ye(),d=be();function c(u,f,p){f.length?f=e(f,function(m){return d(m)?function(v){return r(v,m.length===1?m[0]:m)}:m}):f=[i];var h=-1;f=e(f,a(t));var g=n(u,function(m,v,y){var x=e(f,function(b){return b(m)});return{criteria:x,index:++h,value:m}});return s(g,function(m,v){return o(m,v,p)})}return ni=c,ni}var ai,Wp;function ay(){if(Wp)return ai;Wp=1;var e=Es(),r=ny(),t=$r(),n=zr(),s=t(function(a,o){if(a==null)return[];var i=o.length;return i>1&&n(a,o[0],o[1])?o=[]:i>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),r(a,e(o,1),[])});return ai=s,ai}var si,Bp;function sy(){if(Bp)return si;Bp=1;var e=ld(),r=0;function t(n){var s=++r;return e(n)+s}return si=t,si}var oi,Fp;function oy(){if(Fp)return oi;Fp=1;function e(r,t,n){for(var s=-1,a=r.length,o=t.length,i={};++s<a;){var d=s<o?t[s]:void 0;n(i,r[s],d)}return i}return oi=e,oi}var ii,$p;function iy(){if($p)return ii;$p=1;var e=Pr(),r=oy();function t(n,s){return r(n||[],s||[],e)}return ii=t,ii}var li,zp;function ge(){if(zp)return li;zp=1;var e;if(typeof et=="function")try{e={cloneDeep:Sv(),constant:ca(),defaults:wv(),each:ju(),filter:Td(),find:Rv(),flatten:sp(),forEach:Nu(),forIn:Ov(),has:Cd(),isUndefined:Rd(),last:Pv(),map:Ld(),mapValues:Av(),max:qv(),merge:$v(),min:zv(),minBy:Hv(),now:Kv(),pick:Yv(),range:Qv(),reduce:Wd(),sortBy:ay(),uniqueId:sy(),values:xf(),zipObject:iy()}}catch{}return e||(e=window._),li=e,li}var ci,Hp;function ly(){if(Hp)return ci;Hp=1,ci=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return r(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&r(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,a=s._prev;a!==s;)n.push(JSON.stringify(a,t)),a=a._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,s){if(n!=="_next"&&n!=="_prev")return s}return ci}var ui,Kp;function cy(){if(Kp)return ui;Kp=1;var e=ge(),r=Pe().Graph,t=ly();ui=s;var n=e.constant(1);function s(c,u){if(c.nodeCount()<=1)return[];var f=i(c,u||n),p=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(p,function(h){return c.outEdges(h.v,h.w)}),!0)}function a(c,u,f){for(var p=[],h=u[u.length-1],g=u[0],m;c.nodeCount();){for(;m=g.dequeue();)o(c,u,f,m);for(;m=h.dequeue();)o(c,u,f,m);if(c.nodeCount()){for(var v=u.length-2;v>0;--v)if(m=u[v].dequeue(),m){p=p.concat(o(c,u,f,m,!0));break}}}return p}function o(c,u,f,p,h){var g=h?[]:void 0;return e.forEach(c.inEdges(p.v),function(m){var v=c.edge(m),y=c.node(m.v);h&&g.push({v:m.v,w:m.w}),y.out-=v,d(u,f,y)}),e.forEach(c.outEdges(p.v),function(m){var v=c.edge(m),y=m.w,x=c.node(y);x.in-=v,d(u,f,x)}),c.removeNode(p.v),g}function i(c,u){var f=new r,p=0,h=0;e.forEach(c.nodes(),function(v){f.setNode(v,{v,in:0,out:0})}),e.forEach(c.edges(),function(v){var y=f.edge(v.v,v.w)||0,x=u(v),b=y+x;f.setEdge(v.v,v.w,b),h=Math.max(h,f.node(v.v).out+=x),p=Math.max(p,f.node(v.w).in+=x)});var g=e.range(h+p+3).map(function(){return new t}),m=p+1;return e.forEach(f.nodes(),function(v){d(g,m,f.node(v))}),{graph:f,buckets:g,zeroIdx:m}}function d(c,u,f){f.out?f.in?c[f.out-f.in+u].enqueue(f):c[c.length-1].enqueue(f):c[0].enqueue(f)}return ui}var di,Up;function uy(){if(Up)return di;Up=1;var e=ge(),r=cy();di={run:t,undo:s};function t(a){var o=a.graph().acyclicer==="greedy"?r(a,i(a)):n(a);e.forEach(o,function(d){var c=a.edge(d);a.removeEdge(d),c.forwardName=d.name,c.reversed=!0,a.setEdge(d.w,d.v,c,e.uniqueId("rev"))});function i(d){return function(c){return d.edge(c).weight}}}function n(a){var o=[],i={},d={};function c(u){e.has(d,u)||(d[u]=!0,i[u]=!0,e.forEach(a.outEdges(u),function(f){e.has(i,f.w)?o.push(f):c(f.w)}),delete i[u])}return e.forEach(a.nodes(),c),o}function s(a){e.forEach(a.edges(),function(o){var i=a.edge(o);if(i.reversed){a.removeEdge(o);var d=i.forwardName;delete i.reversed,delete i.forwardName,a.setEdge(o.w,o.v,i,d)}})}return di}var fi,Jp;function Ne(){if(Jp)return fi;Jp=1;var e=ge(),r=Pe().Graph;fi={addDummyNode:t,simplify:n,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:o,intersectRect:i,buildLayerMatrix:d,normalizeRanks:c,removeEmptyRanks:u,addBorderNode:f,maxRank:p,partition:h,time:g,notime:m};function t(v,y,x,b){var k;do k=e.uniqueId(b);while(v.hasNode(k));return x.dummy=y,v.setNode(k,x),k}function n(v){var y=new r().setGraph(v.graph());return e.forEach(v.nodes(),function(x){y.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){var b=y.edge(x.v,x.w)||{weight:0,minlen:1},k=v.edge(x);y.setEdge(x.v,x.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),y}function s(v){var y=new r({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(x){v.children(x).length||y.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){y.setEdge(x,v.edge(x))}),y}function a(v){var y=e.map(v.nodes(),function(x){var b={};return e.forEach(v.outEdges(x),function(k){b[k.w]=(b[k.w]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),y)}function o(v){var y=e.map(v.nodes(),function(x){var b={};return e.forEach(v.inEdges(x),function(k){b[k.v]=(b[k.v]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),y)}function i(v,y){var x=v.x,b=v.y,k=y.x-x,w=y.y-b,j=v.width/2,N=v.height/2;if(!k&&!w)throw new Error("Not possible to find intersection inside of the rectangle");var L,T;return Math.abs(w)*j>Math.abs(k)*N?(w<0&&(N=-N),L=N*k/w,T=N):(k<0&&(j=-j),L=j,T=j*w/k),{x:x+L,y:b+T}}function d(v){var y=e.map(e.range(p(v)+1),function(){return[]});return e.forEach(v.nodes(),function(x){var b=v.node(x),k=b.rank;e.isUndefined(k)||(y[k][b.order]=x)}),y}function c(v){var y=e.min(e.map(v.nodes(),function(x){return v.node(x).rank}));e.forEach(v.nodes(),function(x){var b=v.node(x);e.has(b,"rank")&&(b.rank-=y)})}function u(v){var y=e.min(e.map(v.nodes(),function(w){return v.node(w).rank})),x=[];e.forEach(v.nodes(),function(w){var j=v.node(w).rank-y;x[j]||(x[j]=[]),x[j].push(w)});var b=0,k=v.graph().nodeRankFactor;e.forEach(x,function(w,j){e.isUndefined(w)&&j%k!==0?--b:b&&e.forEach(w,function(N){v.node(N).rank+=b})})}function f(v,y,x,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=x,k.order=b),t(v,"border",k,y)}function p(v){return e.max(e.map(v.nodes(),function(y){var x=v.node(y).rank;if(!e.isUndefined(x))return x}))}function h(v,y){var x={lhs:[],rhs:[]};return e.forEach(v,function(b){y(b)?x.lhs.push(b):x.rhs.push(b)}),x}function g(v,y){var x=e.now();try{return y()}finally{console.log(v+" time: "+(e.now()-x)+"ms")}}function m(v,y){return y()}return fi}var pi,Gp;function dy(){if(Gp)return pi;Gp=1;var e=ge(),r=Ne();pi={run:t,undo:s};function t(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(o){n(a,o)})}function n(a,o){var i=o.v,d=a.node(i).rank,c=o.w,u=a.node(c).rank,f=o.name,p=a.edge(o),h=p.labelRank;if(u!==d+1){a.removeEdge(o);var g,m,v;for(v=0,++d;d<u;++v,++d)p.points=[],m={width:0,height:0,edgeLabel:p,edgeObj:o,rank:d},g=r.addDummyNode(a,"edge",m,"_d"),d===h&&(m.width=p.width,m.height=p.height,m.dummy="edge-label",m.labelpos=p.labelpos),a.setEdge(i,g,{weight:p.weight},f),v===0&&a.graph().dummyChains.push(g),i=g;a.setEdge(i,c,{weight:p.weight},f)}}function s(a){e.forEach(a.graph().dummyChains,function(o){var i=a.node(o),d=i.edgeLabel,c;for(a.setEdge(i.edgeObj,d);i.dummy;)c=a.successors(o)[0],a.removeNode(o),d.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(d.x=i.x,d.y=i.y,d.width=i.width,d.height=i.height),o=c,i=a.node(o)})}return pi}var hi,Vp;function Hr(){if(Vp)return hi;Vp=1;var e=ge();hi={longestPath:r,slack:t};function r(n){var s={};function a(o){var i=n.node(o);if(e.has(s,o))return i.rank;s[o]=!0;var d=e.min(e.map(n.outEdges(o),function(c){return a(c.w)-n.edge(c).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),i.rank=d}e.forEach(n.sources(),a)}function t(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return hi}var gi,Yp;function Xp(){if(Yp)return gi;Yp=1;var e=ge(),r=Pe().Graph,t=Hr().slack;gi=n;function n(i){var d=new r({directed:!1}),c=i.nodes()[0],u=i.nodeCount();d.setNode(c,{});for(var f,p;s(d,i)<u;)f=a(d,i),p=d.hasNode(f.v)?t(i,f):-t(i,f),o(d,i,p);return d}function s(i,d){function c(u){e.forEach(d.nodeEdges(u),function(f){var p=f.v,h=u===p?f.w:p;!i.hasNode(h)&&!t(d,f)&&(i.setNode(h,{}),i.setEdge(u,h,{}),c(h))})}return e.forEach(i.nodes(),c),i.nodeCount()}function a(i,d){return e.minBy(d.edges(),function(c){if(i.hasNode(c.v)!==i.hasNode(c.w))return t(d,c)})}function o(i,d,c){e.forEach(i.nodes(),function(u){d.node(u).rank+=c})}return gi}var mi,Zp;function fy(){if(Zp)return mi;Zp=1;var e=ge(),r=Xp(),t=Hr().slack,n=Hr().longestPath,s=Pe().alg.preorder,a=Pe().alg.postorder,o=Ne().simplify;mi=i,i.initLowLimValues=f,i.initCutValues=d,i.calcCutValue=u,i.leaveEdge=h,i.enterEdge=g,i.exchangeEdges=m;function i(b){b=o(b),n(b);var k=r(b);f(k),d(k,b);for(var w,j;w=h(k);)j=g(k,b,w),m(k,b,w,j)}function d(b,k){var w=a(b,b.nodes());w=w.slice(0,w.length-1),e.forEach(w,function(j){c(b,k,j)})}function c(b,k,w){var j=b.node(w),N=j.parent;b.edge(w,N).cutvalue=u(b,k,w)}function u(b,k,w){var j=b.node(w),N=j.parent,L=!0,T=k.edge(w,N),C=0;return T||(L=!1,T=k.edge(N,w)),C=T.weight,e.forEach(k.nodeEdges(w),function(S){var q=S.v===w,I=q?S.w:S.v;if(I!==N){var O=q===L,F=k.edge(S).weight;if(C+=O?F:-F,y(b,w,I)){var W=b.edge(w,I).cutvalue;C+=O?-W:W}}}),C}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),p(b,{},1,k)}function p(b,k,w,j,N){var L=w,T=b.node(j);return k[j]=!0,e.forEach(b.neighbors(j),function(C){e.has(k,C)||(w=p(b,k,w,C,j))}),T.low=L,T.lim=w++,N?T.parent=N:delete T.parent,w}function h(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function g(b,k,w){var j=w.v,N=w.w;k.hasEdge(j,N)||(j=w.w,N=w.v);var L=b.node(j),T=b.node(N),C=L,S=!1;L.lim>T.lim&&(C=T,S=!0);var q=e.filter(k.edges(),function(I){return S===x(b,b.node(I.v),C)&&S!==x(b,b.node(I.w),C)});return e.minBy(q,function(I){return t(k,I)})}function m(b,k,w,j){var N=w.v,L=w.w;b.removeEdge(N,L),b.setEdge(j.v,j.w,{}),f(b),d(b,k),v(b,k)}function v(b,k){var w=e.find(b.nodes(),function(N){return!k.node(N).parent}),j=s(b,w);j=j.slice(1),e.forEach(j,function(N){var L=b.node(N).parent,T=k.edge(N,L),C=!1;T||(T=k.edge(L,N),C=!0),k.node(N).rank=k.node(L).rank+(C?T.minlen:-T.minlen)})}function y(b,k,w){return b.hasEdge(k,w)}function x(b,k,w){return w.low<=k.lim&&k.lim<=w.lim}return mi}var vi,Qp;function py(){if(Qp)return vi;Qp=1;var e=Hr(),r=e.longestPath,t=Xp(),n=fy();vi=s;function s(d){switch(d.graph().ranker){case"network-simplex":i(d);break;case"tight-tree":o(d);break;case"longest-path":a(d);break;default:i(d)}}var a=r;function o(d){r(d),t(d)}function i(d){n(d)}return vi}var yi,eh;function hy(){if(eh)return yi;eh=1;var e=ge();yi=r;function r(s){var a=n(s);e.forEach(s.graph().dummyChains,function(o){for(var i=s.node(o),d=i.edgeObj,c=t(s,a,d.v,d.w),u=c.path,f=c.lca,p=0,h=u[p],g=!0;o!==d.w;){if(i=s.node(o),g){for(;(h=u[p])!==f&&s.node(h).maxRank<i.rank;)p++;h===f&&(g=!1)}if(!g){for(;p<u.length-1&&s.node(h=u[p+1]).minRank<=i.rank;)p++;h=u[p]}s.setParent(o,h),o=s.successors(o)[0]}})}function t(s,a,o,i){var d=[],c=[],u=Math.min(a[o].low,a[i].low),f=Math.max(a[o].lim,a[i].lim),p,h;p=o;do p=s.parent(p),d.push(p);while(p&&(a[p].low>u||f>a[p].lim));for(h=p,p=i;(p=s.parent(p))!==h;)c.push(p);return{path:d.concat(c.reverse()),lca:h}}function n(s){var a={},o=0;function i(d){var c=o;e.forEach(s.children(d),i),a[d]={low:c,lim:o++}}return e.forEach(s.children(),i),a}return yi}var xi,rh;function gy(){if(rh)return xi;rh=1;var e=ge(),r=Ne();xi={run:t,cleanup:o};function t(i){var d=r.addDummyNode(i,"root",{},"_root"),c=s(i),u=e.max(e.values(c))-1,f=2*u+1;i.graph().nestingRoot=d,e.forEach(i.edges(),function(h){i.edge(h).minlen*=f});var p=a(i)+1;e.forEach(i.children(),function(h){n(i,d,f,p,u,c,h)}),i.graph().nodeRankFactor=f}function n(i,d,c,u,f,p,h){var g=i.children(h);if(!g.length){h!==d&&i.setEdge(d,h,{weight:0,minlen:c});return}var m=r.addBorderNode(i,"_bt"),v=r.addBorderNode(i,"_bb"),y=i.node(h);i.setParent(m,h),y.borderTop=m,i.setParent(v,h),y.borderBottom=v,e.forEach(g,function(x){n(i,d,c,u,f,p,x);var b=i.node(x),k=b.borderTop?b.borderTop:x,w=b.borderBottom?b.borderBottom:x,j=b.borderTop?u:2*u,N=k!==w?1:f-p[h]+1;i.setEdge(m,k,{weight:j,minlen:N,nestingEdge:!0}),i.setEdge(w,v,{weight:j,minlen:N,nestingEdge:!0})}),i.parent(h)||i.setEdge(d,m,{weight:0,minlen:f+p[h]})}function s(i){var d={};function c(u,f){var p=i.children(u);p&&p.length&&e.forEach(p,function(h){c(h,f+1)}),d[u]=f}return e.forEach(i.children(),function(u){c(u,1)}),d}function a(i){return e.reduce(i.edges(),function(d,c){return d+i.edge(c).weight},0)}function o(i){var d=i.graph();i.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(i.edges(),function(c){var u=i.edge(c);u.nestingEdge&&i.removeEdge(c)})}return xi}var bi,th;function my(){if(th)return bi;th=1;var e=ge(),r=Ne();bi=t;function t(s){function a(o){var i=s.children(o),d=s.node(o);if(i.length&&e.forEach(i,a),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var c=d.minRank,u=d.maxRank+1;c<u;++c)n(s,"borderLeft","_bl",o,d,c),n(s,"borderRight","_br",o,d,c)}}e.forEach(s.children(),a)}function n(s,a,o,i,d,c){var u={width:0,height:0,rank:c,borderType:a},f=d[a][c-1],p=r.addDummyNode(s,"border",u,o);d[a][c]=p,s.setParent(p,i),f&&s.setEdge(f,p,{weight:1})}return bi}var ki,nh;function vy(){if(nh)return ki;nh=1;var e=ge();ki={adjust:r,undo:t};function r(c){var u=c.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(c)}function t(c){var u=c.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&a(c),(u==="lr"||u==="rl")&&(i(c),n(c))}function n(c){e.forEach(c.nodes(),function(u){s(c.node(u))}),e.forEach(c.edges(),function(u){s(c.edge(u))})}function s(c){var u=c.width;c.width=c.height,c.height=u}function a(c){e.forEach(c.nodes(),function(u){o(c.node(u))}),e.forEach(c.edges(),function(u){var f=c.edge(u);e.forEach(f.points,o),e.has(f,"y")&&o(f)})}function o(c){c.y=-c.y}function i(c){e.forEach(c.nodes(),function(u){d(c.node(u))}),e.forEach(c.edges(),function(u){var f=c.edge(u);e.forEach(f.points,d),e.has(f,"x")&&d(f)})}function d(c){var u=c.x;c.x=c.y,c.y=u}return ki}var _i,ah;function yy(){if(ah)return _i;ah=1;var e=ge();_i=r;function r(t){var n={},s=e.filter(t.nodes(),function(c){return!t.children(c).length}),a=e.max(e.map(s,function(c){return t.node(c).rank})),o=e.map(e.range(a+1),function(){return[]});function i(c){if(!e.has(n,c)){n[c]=!0;var u=t.node(c);o[u.rank].push(c),e.forEach(t.successors(c),i)}}var d=e.sortBy(s,function(c){return t.node(c).rank});return e.forEach(d,i),o}return _i}var Si,sh;function xy(){if(sh)return Si;sh=1;var e=ge();Si=r;function r(n,s){for(var a=0,o=1;o<s.length;++o)a+=t(n,s[o-1],s[o]);return a}function t(n,s,a){for(var o=e.zipObject(a,e.map(a,function(p,h){return h})),i=e.flatten(e.map(s,function(p){return e.sortBy(e.map(n.outEdges(p),function(h){return{pos:o[h.w],weight:n.edge(h).weight}}),"pos")}),!0),d=1;d<a.length;)d<<=1;var c=2*d-1;d-=1;var u=e.map(new Array(c),function(){return 0}),f=0;return e.forEach(i.forEach(function(p){var h=p.pos+d;u[h]+=p.weight;for(var g=0;h>0;)h%2&&(g+=u[h+1]),h=h-1>>1,u[h]+=p.weight;f+=p.weight*g})),f}return Si}var wi,oh;function by(){if(oh)return wi;oh=1;var e=ge();wi=r;function r(t,n){return e.map(n,function(s){var a=t.inEdges(s);if(a.length){var o=e.reduce(a,function(i,d){var c=t.edge(d),u=t.node(d.v);return{sum:i.sum+c.weight*u.order,weight:i.weight+c.weight}},{sum:0,weight:0});return{v:s,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:s}})}return wi}var Ti,ih;function ky(){if(ih)return Ti;ih=1;var e=ge();Ti=r;function r(s,a){var o={};e.forEach(s,function(d,c){var u=o[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:c};e.isUndefined(d.barycenter)||(u.barycenter=d.barycenter,u.weight=d.weight)}),e.forEach(a.edges(),function(d){var c=o[d.v],u=o[d.w];!e.isUndefined(c)&&!e.isUndefined(u)&&(u.indegree++,c.out.push(o[d.w]))});var i=e.filter(o,function(d){return!d.indegree});return t(i)}function t(s){var a=[];function o(c){return function(u){u.merged||(e.isUndefined(u.barycenter)||e.isUndefined(c.barycenter)||u.barycenter>=c.barycenter)&&n(c,u)}}function i(c){return function(u){u.in.push(c),--u.indegree===0&&s.push(u)}}for(;s.length;){var d=s.pop();a.push(d),e.forEach(d.in.reverse(),o(d)),e.forEach(d.out,i(d))}return e.map(e.filter(a,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function n(s,a){var o=0,i=0;s.weight&&(o+=s.barycenter*s.weight,i+=s.weight),a.weight&&(o+=a.barycenter*a.weight,i+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=o/i,s.weight=i,s.i=Math.min(a.i,s.i),a.merged=!0}return Ti}var Ei,lh;function _y(){if(lh)return Ei;lh=1;var e=ge(),r=Ne();Ei=t;function t(a,o){var i=r.partition(a,function(m){return e.has(m,"barycenter")}),d=i.lhs,c=e.sortBy(i.rhs,function(m){return-m.i}),u=[],f=0,p=0,h=0;d.sort(s(!!o)),h=n(u,c,h),e.forEach(d,function(m){h+=m.vs.length,u.push(m.vs),f+=m.barycenter*m.weight,p+=m.weight,h=n(u,c,h)});var g={vs:e.flatten(u,!0)};return p&&(g.barycenter=f/p,g.weight=p),g}function n(a,o,i){for(var d;o.length&&(d=e.last(o)).i<=i;)o.pop(),a.push(d.vs),i++;return i}function s(a){return function(o,i){return o.barycenter<i.barycenter?-1:o.barycenter>i.barycenter?1:a?i.i-o.i:o.i-i.i}}return Ei}var Ni,ch;function Sy(){if(ch)return Ni;ch=1;var e=ge(),r=by(),t=ky(),n=_y();Ni=s;function s(i,d,c,u){var f=i.children(d),p=i.node(d),h=p?p.borderLeft:void 0,g=p?p.borderRight:void 0,m={};h&&(f=e.filter(f,function(w){return w!==h&&w!==g}));var v=r(i,f);e.forEach(v,function(w){if(i.children(w.v).length){var j=s(i,w.v,c,u);m[w.v]=j,e.has(j,"barycenter")&&o(w,j)}});var y=t(v,c);a(y,m);var x=n(y,u);if(h&&(x.vs=e.flatten([h,x.vs,g],!0),i.predecessors(h).length)){var b=i.node(i.predecessors(h)[0]),k=i.node(i.predecessors(g)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+b.order+k.order)/(x.weight+2),x.weight+=2}return x}function a(i,d){e.forEach(i,function(c){c.vs=e.flatten(c.vs.map(function(u){return d[u]?d[u].vs:u}),!0)})}function o(i,d){e.isUndefined(i.barycenter)?(i.barycenter=d.barycenter,i.weight=d.weight):(i.barycenter=(i.barycenter*i.weight+d.barycenter*d.weight)/(i.weight+d.weight),i.weight+=d.weight)}return Ni}var Ci,uh;function wy(){if(uh)return Ci;uh=1;var e=ge(),r=Pe().Graph;Ci=t;function t(s,a,o){var i=n(s),d=new r({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(c){return s.node(c)});return e.forEach(s.nodes(),function(c){var u=s.node(c),f=s.parent(c);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(d.setNode(c),d.setParent(c,f||i),e.forEach(s[o](c),function(p){var h=p.v===c?p.w:p.v,g=d.edge(h,c),m=e.isUndefined(g)?0:g.weight;d.setEdge(h,c,{weight:s.edge(p).weight+m})}),e.has(u,"minRank")&&d.setNode(c,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),d}function n(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Ci}var ji,dh;function Ty(){if(dh)return ji;dh=1;var e=ge();ji=r;function r(t,n,s){var a={},o;e.forEach(s,function(i){for(var d=t.parent(i),c,u;d;){if(c=t.parent(d),c?(u=a[c],a[c]=d):(u=o,o=d),u&&u!==d){n.setEdge(u,d);return}d=c}})}return ji}var Ii,fh;function Ey(){if(fh)return Ii;fh=1;var e=ge(),r=yy(),t=xy(),n=Sy(),s=wy(),a=Ty(),o=Pe().Graph,i=Ne();Ii=d;function d(p){var h=i.maxRank(p),g=c(p,e.range(1,h+1),"inEdges"),m=c(p,e.range(h-1,-1,-1),"outEdges"),v=r(p);f(p,v);for(var y=Number.POSITIVE_INFINITY,x,b=0,k=0;k<4;++b,++k){u(b%2?g:m,b%4>=2),v=i.buildLayerMatrix(p);var w=t(p,v);w<y&&(k=0,x=e.cloneDeep(v),y=w)}f(p,x)}function c(p,h,g){return e.map(h,function(m){return s(p,m,g)})}function u(p,h){var g=new o;e.forEach(p,function(m){var v=m.graph().root,y=n(m,v,g,h);e.forEach(y.vs,function(x,b){m.node(x).order=b}),a(m,g,y.vs)})}function f(p,h){e.forEach(h,function(g){e.forEach(g,function(m,v){p.node(m).order=v})})}return Ii}var Ri,ph;function Ny(){if(ph)return Ri;ph=1;var e=ge(),r=Pe().Graph,t=Ne();Ri={positionX:g,findType1Conflicts:n,findType2Conflicts:s,addConflict:o,hasConflict:i,verticalAlignment:d,horizontalCompaction:c,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function n(y,x){var b={};function k(w,j){var N=0,L=0,T=w.length,C=e.last(j);return e.forEach(j,function(S,q){var I=a(y,S),O=I?y.node(I).order:T;(I||S===C)&&(e.forEach(j.slice(L,q+1),function(F){e.forEach(y.predecessors(F),function(W){var V=y.node(W),Z=V.order;(Z<N||O<Z)&&!(V.dummy&&y.node(F).dummy)&&o(b,W,F)})}),L=q+1,N=O)}),j}return e.reduce(x,k),b}function s(y,x){var b={};function k(j,N,L,T,C){var S;e.forEach(e.range(N,L),function(q){S=j[q],y.node(S).dummy&&e.forEach(y.predecessors(S),function(I){var O=y.node(I);O.dummy&&(O.order<T||O.order>C)&&o(b,I,S)})})}function w(j,N){var L=-1,T,C=0;return e.forEach(N,function(S,q){if(y.node(S).dummy==="border"){var I=y.predecessors(S);I.length&&(T=y.node(I[0]).order,k(N,C,q,L,T),C=q,L=T)}k(N,C,N.length,T,j.length)}),N}return e.reduce(x,w),b}function a(y,x){if(y.node(x).dummy)return e.find(y.predecessors(x),function(b){return y.node(b).dummy})}function o(y,x,b){if(x>b){var k=x;x=b,b=k}var w=y[x];w||(y[x]=w={}),w[b]=!0}function i(y,x,b){if(x>b){var k=x;x=b,b=k}return e.has(y[x],b)}function d(y,x,b,k){var w={},j={},N={};return e.forEach(x,function(L){e.forEach(L,function(T,C){w[T]=T,j[T]=T,N[T]=C})}),e.forEach(x,function(L){var T=-1;e.forEach(L,function(C){var S=k(C);if(S.length){S=e.sortBy(S,function(W){return N[W]});for(var q=(S.length-1)/2,I=Math.floor(q),O=Math.ceil(q);I<=O;++I){var F=S[I];j[C]===C&&T<N[F]&&!i(b,C,F)&&(j[F]=C,j[C]=w[C]=w[F],T=N[F])}}})}),{root:w,align:j}}function c(y,x,b,k,w){var j={},N=u(y,x,b,w),L=w?"borderLeft":"borderRight";function T(q,I){for(var O=N.nodes(),F=O.pop(),W={};F;)W[F]?q(F):(W[F]=!0,O.push(F),O=O.concat(I(F))),F=O.pop()}function C(q){j[q]=N.inEdges(q).reduce(function(I,O){return Math.max(I,j[O.v]+N.edge(O))},0)}function S(q){var I=N.outEdges(q).reduce(function(F,W){return Math.min(F,j[W.w]-N.edge(W))},Number.POSITIVE_INFINITY),O=y.node(q);I!==Number.POSITIVE_INFINITY&&O.borderType!==L&&(j[q]=Math.max(j[q],I))}return T(C,N.predecessors.bind(N)),T(S,N.successors.bind(N)),e.forEach(k,function(q){j[q]=j[b[q]]}),j}function u(y,x,b,k){var w=new r,j=y.graph(),N=m(j.nodesep,j.edgesep,k);return e.forEach(x,function(L){var T;e.forEach(L,function(C){var S=b[C];if(w.setNode(S),T){var q=b[T],I=w.edge(q,S);w.setEdge(q,S,Math.max(N(y,C,T),I||0))}T=C})}),w}function f(y,x){return e.minBy(e.values(x),function(b){var k=Number.NEGATIVE_INFINITY,w=Number.POSITIVE_INFINITY;return e.forIn(b,function(j,N){var L=v(y,N)/2;k=Math.max(j+L,k),w=Math.min(j-L,w)}),k-w})}function p(y,x){var b=e.values(x),k=e.min(b),w=e.max(b);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(N){var L=j+N,T=y[L],C;if(T!==x){var S=e.values(T);C=N==="l"?k-e.min(S):w-e.max(S),C&&(y[L]=e.mapValues(T,function(q){return q+C}))}})})}function h(y,x){return e.mapValues(y.ul,function(b,k){if(x)return y[x.toLowerCase()][k];var w=e.sortBy(e.map(y,k));return(w[1]+w[2])/2})}function g(y){var x=t.buildLayerMatrix(y),b=e.merge(n(y,x),s(y,x)),k={},w;e.forEach(["u","d"],function(N){w=N==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(L){L==="r"&&(w=e.map(w,function(q){return e.values(q).reverse()}));var T=(N==="u"?y.predecessors:y.successors).bind(y),C=d(y,w,b,T),S=c(y,w,C.root,C.align,L==="r");L==="r"&&(S=e.mapValues(S,function(q){return-q})),k[N+L]=S})});var j=f(y,k);return p(k,j),h(k,y.graph().align)}function m(y,x,b){return function(k,w,j){var N=k.node(w),L=k.node(j),T=0,C;if(T+=N.width/2,e.has(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":C=-N.width/2;break;case"r":C=N.width/2;break}if(C&&(T+=b?C:-C),C=0,T+=(N.dummy?x:y)/2,T+=(L.dummy?x:y)/2,T+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":C=L.width/2;break;case"r":C=-L.width/2;break}return C&&(T+=b?C:-C),C=0,T}}function v(y,x){return y.node(x).width}return Ri}var Oi,hh;function Cy(){if(hh)return Oi;hh=1;var e=ge(),r=Ne(),t=Ny().positionX;Oi=n;function n(a){a=r.asNonCompoundGraph(a),s(a),e.forEach(t(a),function(o,i){a.node(i).x=o})}function s(a){var o=r.buildLayerMatrix(a),i=a.graph().ranksep,d=0;e.forEach(o,function(c){var u=e.max(e.map(c,function(f){return a.node(f).height}));e.forEach(c,function(f){a.node(f).y=d+u/2}),d+=u+i})}return Oi}var Pi,gh;function jy(){if(gh)return Pi;gh=1;var e=ge(),r=uy(),t=dy(),n=py(),s=Ne().normalizeRanks,a=hy(),o=Ne().removeEmptyRanks,i=gy(),d=my(),c=vy(),u=Ey(),f=Cy(),p=Ne(),h=Pe().Graph;Pi=g;function g(R,M){var _=M&&M.debugTiming?p.time:p.notime;_("layout",function(){var B=_(" buildLayoutGraph",function(){return T(R)});_(" runLayout",function(){m(B,_)}),_(" updateInputGraph",function(){v(R,B)})})}function m(R,M){M(" makeSpaceForEdgeLabels",function(){C(R)}),M(" removeSelfEdges",function(){ne(R)}),M(" acyclic",function(){r.run(R)}),M(" nestingGraph.run",function(){i.run(R)}),M(" rank",function(){n(p.asNonCompoundGraph(R))}),M(" injectEdgeLabelProxies",function(){S(R)}),M(" removeEmptyRanks",function(){o(R)}),M(" nestingGraph.cleanup",function(){i.cleanup(R)}),M(" normalizeRanks",function(){s(R)}),M(" assignRankMinMax",function(){q(R)}),M(" removeEdgeLabelProxies",function(){I(R)}),M(" normalize.run",function(){t.run(R)}),M(" parentDummyChains",function(){a(R)}),M(" addBorderSegments",function(){d(R)}),M(" order",function(){u(R)}),M(" insertSelfEdges",function(){ee(R)}),M(" adjustCoordinateSystem",function(){c.adjust(R)}),M(" position",function(){f(R)}),M(" positionSelfEdges",function(){D(R)}),M(" removeBorderNodes",function(){Z(R)}),M(" normalize.undo",function(){t.undo(R)}),M(" fixupEdgeLabelCoords",function(){W(R)}),M(" undoCoordinateSystem",function(){c.undo(R)}),M(" translateGraph",function(){O(R)}),M(" assignNodeIntersects",function(){F(R)}),M(" reversePoints",function(){V(R)}),M(" acyclic.undo",function(){r.undo(R)})}function v(R,M){e.forEach(R.nodes(),function(_){var B=R.node(_),z=M.node(_);B&&(B.x=z.x,B.y=z.y,M.children(_).length&&(B.width=z.width,B.height=z.height))}),e.forEach(R.edges(),function(_){var B=R.edge(_),z=M.edge(_);B.points=z.points,e.has(z,"x")&&(B.x=z.x,B.y=z.y)}),R.graph().width=M.graph().width,R.graph().height=M.graph().height}var y=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],w={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function T(R){var M=new h({multigraph:!0,compound:!0}),_=se(R.graph());return M.setGraph(e.merge({},x,Y(_,y),e.pick(_,b))),e.forEach(R.nodes(),function(B){var z=se(R.node(B));M.setNode(B,e.defaults(Y(z,k),w)),M.setParent(B,R.parent(B))}),e.forEach(R.edges(),function(B){var z=se(R.edge(B));M.setEdge(B,e.merge({},N,Y(z,j),e.pick(z,L)))}),M}function C(R){var M=R.graph();M.ranksep/=2,e.forEach(R.edges(),function(_){var B=R.edge(_);B.minlen*=2,B.labelpos.toLowerCase()!=="c"&&(M.rankdir==="TB"||M.rankdir==="BT"?B.width+=B.labeloffset:B.height+=B.labeloffset)})}function S(R){e.forEach(R.edges(),function(M){var _=R.edge(M);if(_.width&&_.height){var B=R.node(M.v),z=R.node(M.w),Q={rank:(z.rank-B.rank)/2+B.rank,e:M};p.addDummyNode(R,"edge-proxy",Q,"_ep")}})}function q(R){var M=0;e.forEach(R.nodes(),function(_){var B=R.node(_);B.borderTop&&(B.minRank=R.node(B.borderTop).rank,B.maxRank=R.node(B.borderBottom).rank,M=e.max(M,B.maxRank))}),R.graph().maxRank=M}function I(R){e.forEach(R.nodes(),function(M){var _=R.node(M);_.dummy==="edge-proxy"&&(R.edge(_.e).labelRank=_.rank,R.removeNode(M))})}function O(R){var M=Number.POSITIVE_INFINITY,_=0,B=Number.POSITIVE_INFINITY,z=0,Q=R.graph(),G=Q.marginx||0,oe=Q.marginy||0;function H($){var K=$.x,U=$.y,J=$.width,te=$.height;M=Math.min(M,K-J/2),_=Math.max(_,K+J/2),B=Math.min(B,U-te/2),z=Math.max(z,U+te/2)}e.forEach(R.nodes(),function($){H(R.node($))}),e.forEach(R.edges(),function($){var K=R.edge($);e.has(K,"x")&&H(K)}),M-=G,B-=oe,e.forEach(R.nodes(),function($){var K=R.node($);K.x-=M,K.y-=B}),e.forEach(R.edges(),function($){var K=R.edge($);e.forEach(K.points,function(U){U.x-=M,U.y-=B}),e.has(K,"x")&&(K.x-=M),e.has(K,"y")&&(K.y-=B)}),Q.width=_-M+G,Q.height=z-B+oe}function F(R){e.forEach(R.edges(),function(M){var _=R.edge(M),B=R.node(M.v),z=R.node(M.w),Q,G;_.points?(Q=_.points[0],G=_.points[_.points.length-1]):(_.points=[],Q=z,G=B),_.points.unshift(p.intersectRect(B,Q)),_.points.push(p.intersectRect(z,G))})}function W(R){e.forEach(R.edges(),function(M){var _=R.edge(M);if(e.has(_,"x"))switch((_.labelpos==="l"||_.labelpos==="r")&&(_.width-=_.labeloffset),_.labelpos){case"l":_.x-=_.width/2+_.labeloffset;break;case"r":_.x+=_.width/2+_.labeloffset;break}})}function V(R){e.forEach(R.edges(),function(M){var _=R.edge(M);_.reversed&&_.points.reverse()})}function Z(R){e.forEach(R.nodes(),function(M){if(R.children(M).length){var _=R.node(M),B=R.node(_.borderTop),z=R.node(_.borderBottom),Q=R.node(e.last(_.borderLeft)),G=R.node(e.last(_.borderRight));_.width=Math.abs(G.x-Q.x),_.height=Math.abs(z.y-B.y),_.x=Q.x+_.width/2,_.y=B.y+_.height/2}}),e.forEach(R.nodes(),function(M){R.node(M).dummy==="border"&&R.removeNode(M)})}function ne(R){e.forEach(R.edges(),function(M){if(M.v===M.w){var _=R.node(M.v);_.selfEdges||(_.selfEdges=[]),_.selfEdges.push({e:M,label:R.edge(M)}),R.removeEdge(M)}})}function ee(R){var M=p.buildLayerMatrix(R);e.forEach(M,function(_){var B=0;e.forEach(_,function(z,Q){var G=R.node(z);G.order=Q+B,e.forEach(G.selfEdges,function(oe){p.addDummyNode(R,"selfedge",{width:oe.label.width,height:oe.label.height,rank:G.rank,order:Q+ ++B,e:oe.e,label:oe.label},"_se")}),delete G.selfEdges})})}function D(R){e.forEach(R.nodes(),function(M){var _=R.node(M);if(_.dummy==="selfedge"){var B=R.node(_.e.v),z=B.x+B.width/2,Q=B.y,G=_.x-z,oe=B.height/2;R.setEdge(_.e,_.label),R.removeNode(M),_.label.points=[{x:z+2*G/3,y:Q-oe},{x:z+5*G/6,y:Q-oe},{x:z+G,y:Q},{x:z+5*G/6,y:Q+oe},{x:z+2*G/3,y:Q+oe}],_.label.x=_.x,_.label.y=_.y}})}function Y(R,M){return e.mapValues(e.pick(R,M),Number)}function se(R){var M={};return e.forEach(R,function(_,B){M[B.toLowerCase()]=_}),M}return Pi}var Ai,mh;function Iy(){if(mh)return Ai;mh=1;var e=ge(),r=Ne(),t=Pe().Graph;Ai={debugOrdering:n};function n(s){var a=r.buildLayerMatrix(s),o=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(i){o.setNode(i,{label:i}),o.setParent(i,"layer"+s.node(i).rank)}),e.forEach(s.edges(),function(i){o.setEdge(i.v,i.w,{},i.name)}),e.forEach(a,function(i,d){var c="layer"+d;o.setNode(c,{rank:"same"}),e.reduce(i,function(u,f){return o.setEdge(u,f,{style:"invis"}),f})}),o}return Ai}var Li,vh;function Ry(){return vh||(vh=1,Li="0.8.5"),Li}var qi,yh;function Oy(){return yh||(yh=1,qi={graphlib:Pe(),layout:jy(),debug:Iy(),util:{time:Ne().time,notime:Ne().notime},version:Ry()}),qi}var Py=Oy();const xh=tg(Py);function sr(e,r="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let t=240,n=80;switch(e.type){case"decisionNode":t=212,n=160;break;case"forkNode":t=240,n=95;break;case"joinNode":t=240,n=95;break;case"dynamicPlaceholderNode":t=220,n=70;break;case"loopNode":t=320,n=200;break;case"subWorkflowNode":t=240,n=95;break;case"eventNode":t=240,n=85;break;case"default":t=240,n=40;break;case"plusNode":t=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:t=240,n=95;break}return{width:t,height:n}}function Ay(e,r,t=8){const n=[];if(e.length<t)return n;const s=new Map,a={},o={};e.forEach(f=>{s.set(f.id,f),a[f.id]=[],o[f.id]=[]}),r.forEach(f=>{a[f.source]&&a[f.source].push(f.target),o[f.target]&&o[f.target].push(f.source)});const i=new Set,d=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),c=f=>!d.has(f.type||""),u=[...e].sort((f,p)=>f.position.y-p.position.y);for(const f of u){if(i.has(f.id)||!c(f)||a[f.id].length>1)continue;const p=[f.id];let h=f,g=a[h.id];for(;g&&g.length===1;){const m=g[0],v=s.get(m);if(!v||i.has(m)||!c(v)||o[m].length!==1)break;p.push(m),h=v,g=a[h.id]}p.length>=t&&(n.push(p),p.forEach(m=>i.add(m)))}return n}function Ly(e,r,t,n,s,a=5,o="view"){const i=r.find(x=>x.id===e[0]),{width:d,height:c}=sr(i||r[0],t),u=Math.max(.7,1-(e.length-10)/80),f=o==="edit"||o==="run"?1.15:1,p=Math.min(n,Math.round(60*u*f)),h=Math.min(s,Math.round(80*u*f)),g=d+p,m=c+h;let v=0,y=0;if(t==="TB"){const x=Math.ceil(e.length/a);v=a*g-p,y=x*m-h}else v=Math.ceil(e.length/a)*g-p,y=a*m-h;return v+=40,y+=40,{width:v,height:y,gridKW:g,gridKH:m,cols:a}}const Di=58,bh=20,qy=16;function Dy(e,r,t,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:Di+50};const s=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=Mi(s,r,{direction:t,mode:n,enableSnakeLayout:!1});let o=0,i=0;a.forEach(f=>{const{width:p,height:h}=sr(f,t);o=Math.max(o,f.position.x+p),i=Math.max(i,f.position.y+h)});const d=Math.max(300,o+bh*2),c=Di+i+qy;return{positionedChildren:a.map(f=>{const p=e.find(h=>h.id===f.id);return{...f,parentId:p.parentId,extent:p.extent,position:{x:f.position.x+bh,y:f.position.y+Di}}}),containerWidth:d,containerHeight:c}}function Mi(e,r,t={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:o=5,snakeMinChainLength:i=8,snakeMinNodeCount:d=10}=t,c=e.length,u=e.filter(T=>T.type!=="plusNode").length;let f=n==="LR"?150:120,p=n==="LR"?120:100,h=f,g=p;if(c>15){let T=Math.max(.5,1-(c-15)/50),C=Math.max(.4,1-(c-15)/40);(s==="edit"||s==="run")&&(T=1-(1-T)*.5,C=1-(1-C)*.5),h=Math.round(f*T),g=Math.round(p*C)}const m=a&&u>d?Ay(e,r,i):[],v={};m.forEach((T,C)=>{T.forEach(S=>{v[S]=C})});const y=new xh.graphlib.Graph;y.setDefaultEdgeLabel(()=>({})),y.setGraph({rankdir:n,ranker:"network-simplex",ranksep:h,nodesep:g,edgesep:50,marginx:50,marginy:50});const x=new Set,b={};e.forEach(T=>{const C=v[T.id];if(C!==void 0){if(!x.has(C)){x.add(C);const S=Ly(m[C],e,n,g,h,o,s);b[C]=S,y.setNode(`__CHAIN_${C}`,{width:S.width,height:S.height})}}else{const{width:S,height:q}=sr(T,n);y.setNode(T.id,{width:S,height:q})}}),r.forEach(T=>{const C=v[T.source],S=v[T.target];let q=T.source,I=T.target;C!==void 0&&(q=`__CHAIN_${C}`),S!==void 0&&(I=`__CHAIN_${S}`),q!==I&&y.setEdge(q,I)}),xh.layout(y);const k={};for(const T of e)k[T.id]={...T};const w=[],j=new Set;e.forEach(T=>{if(v[T.id]===void 0){const C=y.node(T.id),S=k[T.id],{width:q,height:I}=sr(S,n);S.position={x:C.x-q/2,y:C.y-I/2},S.data={...S.data,sourcePosition:void 0,targetPosition:void 0},S.sourcePosition=n==="LR"?A.Position.Right:A.Position.Bottom,S.targetPosition=n==="LR"?A.Position.Left:A.Position.Top,w.push(S)}else j.add(T.id)}),m.forEach((T,C)=>{const S=`__CHAIN_${C}`,q=y.node(S),I=b[C],O=q.x-I.width/2+20,F=q.y-I.height/2+20,W=I.cols,V=I.gridKW,Z=I.gridKH;T.forEach((ne,ee)=>{const D=k[ne];let Y=0,se=0,R,M;if(n==="TB"){const _=Math.floor(ee/W),B=ee%W,z=_%2===0,Q=Math.ceil(T.length/W),G=_===Q-1,oe=T.length%W||W,H=G?(W-oe)*V/2:0;let $;z?$=B*V+H:$=(W-1-B)*V-H;const K=_*Z;Y=O+$,se=F+K;const U=G?oe:W;z?(M=A.Position.Left,R=A.Position.Right,B===U-1&&ee!==T.length-1&&(R=A.Position.Bottom),B===0&&ee!==0&&(M=A.Position.Top)):(M=A.Position.Right,R=A.Position.Left,B===U-1&&ee!==T.length-1&&(R=A.Position.Bottom),B===0&&ee!==0&&(M=A.Position.Top)),ee===0&&(M=A.Position.Top),ee===T.length-1&&(R=A.Position.Bottom)}else{const _=Math.floor(ee/W),B=ee%W,z=_%2===0,Q=Math.ceil(T.length/W),G=_===Q-1,oe=T.length%W||W,H=G?Math.max(0,(W-oe)*Z)/2:0,$=_*V;let K;z?K=B*Z+H:K=(W-1-B)*Z-H,Y=O+$,se=F+K;const U=G?oe:W;z?(M=A.Position.Top,R=A.Position.Bottom,B===U-1&&ee!==T.length-1&&(R=A.Position.Right),B===0&&ee!==0&&(M=A.Position.Left)):(M=A.Position.Bottom,R=A.Position.Top,B===U-1&&ee!==T.length-1&&(R=A.Position.Right),B===0&&ee!==0&&(M=A.Position.Left)),ee===0&&(M=A.Position.Left),ee===T.length-1&&(R=A.Position.Right)}D.position={x:Y,y:se},D.data={...D.data,sourcePosition:R,targetPosition:M},D.sourcePosition=R,D.targetPosition=M,w.push(D)})});const N=w.reduce((T,C)=>({...T,[C.id]:C}),{}),L=r.map(T=>{const C=N[T.source],S=N[T.target];if(!C||!S||j.has(C.id)||C.type!=="decisionNode")return T;const{width:q,height:I}=sr(C,n),{width:O,height:F}=sr(S,n),W={x:C.position.x+q/2,y:C.position.y+I/2},V={x:S.position.x+O/2,y:S.position.y+F/2};let Z=null;if(n==="TB"){const ne=q*.25;V.x<W.x-ne?Z="left":V.x>W.x+ne&&(Z="right")}else{const ne=I*.25;V.y<W.y-ne?Z="top":V.y>W.y+ne&&(Z="bottom")}return{...T,sourceHandle:Z}});return{nodes:w,edges:L}}function _e(e,r,t={}){const n=t.direction||"TB",s=t.mode||"view",a=e.filter(y=>y.parentId),o=e.filter(y=>!y.parentId);if(a.length===0)return Mi(e,r,t);const i=new Map(a.map(y=>[y.id,y])),d={},c=[];r.forEach(y=>{const x=i.get(y.source),b=i.get(y.target);if(x?.parentId&&x.parentId===b?.parentId){const k=x.parentId;d[k]||(d[k]=[]),d[k].push(y)}else c.push(y)});const u={};a.forEach(y=>{const x=y.parentId;u[x]||(u[x]=[]),u[x].push(y)});const f={},p=[];for(const[y,x]of Object.entries(u)){const b=d[y]||[],{positionedChildren:k,containerWidth:w,containerHeight:j}=Dy(x,b,n,s);f[y]={width:w,height:j},p.push(...k)}const h=o.map(y=>{if(y.type==="loopNode"&&f[y.id]){const{width:x,height:b}=f[y.id];return{...y,data:{...y.data,_layoutWidth:x,_layoutHeight:b},style:{...y.style,width:x,height:b}}}return y}),{nodes:g,edges:m}=Mi(h,c,t);return{nodes:[...g.map(y=>{if(y.type==="loopNode"&&f[y.id]){const{width:x,height:b}=f[y.id];return{...y,width:x,height:b,style:{...y.style,width:x,height:b}}}return y}),...p],edges:[...m,...Object.values(d).flat()]}}function Ce(e,r){if(!e)return null;for(const t of e){if(t.taskReferenceName===r)return t;if(t.decisionCases){for(const s of Object.keys(t.decisionCases)){const a=Ce(t.decisionCases[s],r);if(a)return a}const n=Ce(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const s=Ce(n,r);if(s)return s}if(t.loopOver){const n=Ce(t.loopOver,r);if(n)return n}}return null}function Me(e,r){if(!e)return!1;const t=e.findIndex(n=>n.taskReferenceName===r);if(t!==-1)return e.splice(t,1),!0;for(const n of e){if(n.decisionCases){for(const s of Object.keys(n.decisionCases))if(Me(n.decisionCases[s],r))return!0;if(Me(n.defaultCase,r))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(Me(s,r))return!0}if(n.loopOver&&Me(n.loopOver,r))return!0}return!1}function or(e,r){if(!e)return null;if(e.some(t=>t.taskReferenceName===r))return e;for(const t of e){if(t.decisionCases){for(const s of Object.values(t.decisionCases)){const a=or(s,r);if(a)return a}const n=or(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const s=or(n,r);if(s)return s}if(t.loopOver){const n=or(t.loopOver,r);if(n)return n}}return null}function kh(e,r){const t=e.findIndex(n=>n.taskReferenceName===r);if(t<0)return null;for(let n=t+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function _h(e,r){const t=e.findIndex(n=>n.taskReferenceName===r);if(t<0)return null;for(let n=t-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Ae(e,r,t){if(!e)return!1;const n=e.findIndex(s=>s.taskReferenceName===r);if(n!==-1)return e.splice(n+1,0,t),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Ae(s.decisionCases[a],r,t))return!0;if(Ae(s.defaultCase,r,t))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Ae(a,r,t))return!0}if(s.loopOver&&Ae(s.loopOver,r,t))return!0}return!1}function ir(e,r,t,n){for(const s of e||[]){if(s.taskReferenceName===r){if(t.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(t.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[t.branchCase]||(s.decisionCases[t.branchCase]=[]),s.decisionCases[t.branchCase].unshift(n),!0;if(t.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[t.forkIndex].unshift(n),!0;if(t.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(ir(s.decisionCases[a],r,t,n))return!0;if(ir(s.defaultCase,r,t,n))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(ir(a,r,t,n))return!0}if(s.loopOver&&ir(s.loopOver,r,t,n))return!0}return!1}function we(e){if(e)for(let r=0;r<e.length;r++){const t=e[r];if(t.type==="FORK_JOIN"&&r+1<e.length){const n=e[r+1];if(n.type==="JOIN"){const s=[];(t.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),n.joinOn=s}}t.decisionCases&&(Object.values(t.decisionCases).forEach(n=>we(n)),t.defaultCase&&we(t.defaultCase)),t.forkTasks&&t.forkTasks.forEach(n=>we(n)),t.loopOver&&we(t.loopOver)}}const My=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Sh={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,r)=>!!(r?.inputParameters?.expression||r?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,r)=>!!r?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,r)=>!!(r?.loopCondition||r?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const r=Object.keys(e||{});return new Set(r).size===r.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,r)=>!!(r?.dynamicForkTasksParam||r?.forkTaskType||r?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}},Wy=(e,r)=>r.split(".").reduce((t,n)=>t&&t[n]!==void 0?t[n]:void 0,e),Wi=(e,r,t,n)=>{const{errors:s,warnings:a}=n,o=e.taskReferenceName||"GLOBAL";r.forEach(i=>{const d=Wy(e,i.field);let c=!0;switch(i.type){case"required":c=d!=null&&d!=="";break;case"min_length":c=Array.isArray(d)&&d.length>=i.value;break;case"pattern":c=i.value.test(d);break;case"enum":c=i.value.includes(d);break;case"unique":i.field==="taskReferenceName"&&d&&(t.taskRefs.has(d)?c=!1:t.taskRefs.add(d));break;case"custom":typeof i.validate=="function"&&(c=i.validate(d,e,t));break}if(!c){const u={type:e.taskReferenceName?"TASK":"GLOBAL",ref:o,message:i.message};i.level==="warning"?a.push(u):s.push(u)}})},Re=e=>{const r=[],t=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(Wi(e,My,n,{errors:r,warnings:t}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:r,warnings:t};const s=o=>{o.forEach(i=>{Wi(i,Sh.common,n,{errors:r,warnings:t});const d=Sh.types[i.type];d&&Wi(i,d,n,{errors:r,warnings:t}),i.decisionCases&&Object.keys(i.decisionCases).forEach(c=>{s(i.decisionCases[c])}),i.defaultCase&&s(i.defaultCase),i.forkTasks&&i.forkTasks.forEach(c=>s(c)),i.loopOver&&s(i.loopOver)})};s(e.tasks);const a=By(e.tasks);return r.push(...a),{isValid:r.length===0,errors:r,warnings:t}},By=e=>{const r=[],t=new Map,n=new Set,s=u=>{for(let f=0;f<u.length;f++){const p=u[f],h=p.taskReferenceName;if(n.add(h),t.has(h)||t.set(h,[]),f<u.length-1){const g=u[f+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&t.get(h).push(g)}if(p.decisionCases)for(const g of Object.values(p.decisionCases))g.length>0&&(t.get(h).push(g[0].taskReferenceName),s(g));if(p.defaultCase&&p.defaultCase.length>0&&(t.get(h).push(p.defaultCase[0].taskReferenceName),s(p.defaultCase)),p.forkTasks)for(const g of p.forkTasks)g.length>0&&(t.get(h).push(g[0].taskReferenceName),s(g));if(p.loopOver)for(const g of p.loopOver)n.add(g.taskReferenceName);if(p.joinOn)for(const g of p.joinOn)t.has(g)||t.set(g,[]),t.get(g).push(h)}};s(e);const a=0,o=1,i=2,d=new Map;for(const u of n)d.set(u,a);const c=u=>{d.set(u,o);const f=t.get(u)||[];for(const p of f)if(d.has(p)){if(d.get(p)===o)return r.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${u}" → "${p}" 形成了循环依赖`}),!0;if(d.get(p)===a&&c(p))return!0}return d.set(u,i),!1};for(const u of n)d.get(u)===a&&c(u);return r};function Fy(e,r){const t=new Set(e),n={};e.forEach(i=>n[i]=0),r.forEach(i=>{t.has(i.source)&&t.has(i.target)&&(n[i.target]=(n[i.target]??0)+1)});const s=[];let a=e.filter(i=>n[i]===0);const o={...n};for(;a.length>0;){s.push([...a]);const i=[];a.forEach(d=>{r.forEach(c=>{c.source===d&&t.has(c.target)&&(o[c.target]--,o[c.target]===0&&i.push(c.target))})}),a=i}return s}const ie=lg()(cg(ug((e,r)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"standard",simState:{},isSimRunning:!1,workflowLoadKey:0,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,setWorkflow:(t,n)=>{const s=n||r().layoutDirection,a=JSON.parse(JSON.stringify(t));we(a.tasks);const{nodes:o,edges:i,taskMap:d}=Ee(a,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:c,edges:u}=_e(o,i,{direction:s,mode:r().mode}),f=Re(a);e({workflowDef:a,nodes:c,edges:u,taskMap:d,validationResults:f,layoutDirection:s,workflowLoadKey:r().workflowLoadKey+1})},setMode:t=>{r().mode==="run"&&t!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{}}),e({mode:t});const{workflowDef:s,layoutDirection:a}=r();if(s){const{nodes:o,edges:i,taskMap:d}=Ee(s,a,{hideEmptyBranches:t!=="edit"}),{nodes:c,edges:u}=_e(o,i,{direction:a,mode:t});e({nodes:c,edges:u,taskMap:d})}},setExecutionData:t=>e({executionData:t,dynamicRuntimeTasksByFork:t===null?{}:r().dynamicRuntimeTasksByFork}),updateTaskStatus:(t,n)=>{const{executionData:s}=r();if(!s)return;const a={...s};a[t]&&(a[t]={...a[t],status:n},e({executionData:a}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();r().importExecutionJSON(n)}catch(t){console.error("Failed to load sample execution:",t),alert("加载示例运行数据失败")}},importExecutionJSON:t=>{if(!t)return;let n=[],s=null,a=r().workflowDef;if(Array.isArray(t.tasks)?(n=t.tasks,t.workflowId&&t.status&&(s=t,t.workflowDefinition&&(a=t.workflowDefinition))):Array.isArray(t)&&(n=t),n.length===0)return;const o={};n.forEach(p=>{const h=p.referenceTaskName;h&&(o[h]||(o[h]={taskReferenceName:h,status:p.status,attempts:[],startTime:p.startTime,endTime:p.endTime,output:p.outputData,input:p.inputData,reasonForIncompletion:p.reasonForIncompletion,iteration:p.iteration}),o[h].attempts.push(p))}),Object.values(o).forEach(p=>{p.attempts.some(m=>m.iteration!==void 0&&m.iteration>0)?(p.attempts.sort((m,v)=>(m.iteration??0)-(v.iteration??0)),p.totalIterations=p.attempts.reduce((m,v)=>Math.max(m,v.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((m,v)=>(m.retryCount??0)-(v.retryCount??0));const g=p.attempts[p.attempts.length-1];g&&(p.status=g.status,p.endTime=g.endTime,p.output=g.outputData,p.input=g.inputData,p.reasonForIncompletion=g.reasonForIncompletion,p.iteration=g.iteration)}),a&&JSON.stringify(a)!==JSON.stringify(r().workflowDef)&&r().setWorkflow(a);const i=r().taskMap,c=r().workflowDef?.tasks||[],u=[];c.forEach((p,h)=>{if(p.type==="FORK_JOIN_DYNAMIC"){for(let g=h+1;g<c.length;g++)if(c[g].type==="JOIN"||c[g].type==="EXCLUSIVE_JOIN"){u.push({forkRef:p.taskReferenceName,joinRef:c[g].taskReferenceName});break}}});const f={};u.forEach(({forkRef:p,joinRef:h})=>{const g=n.findIndex(y=>y.referenceTaskName===p),m=n.findIndex(y=>y.referenceTaskName===h);if(g<0||m<0)return;const v=new Set;f[p]=n.slice(g+1,m).filter(y=>!y.referenceTaskName||!y.taskId||i[y.referenceTaskName]||v.has(y.referenceTaskName)?!1:(v.add(y.referenceTaskName),!0)).map(y=>y)}),e({executionData:o,dynamicRuntimeTasksByFork:f,workflowInstance:s,mode:"run"})},setSelectedTask:t=>e({selectedTask:t?{...t}:null}),setIsDetailPanelOpen:t=>e({isDetailPanelOpen:t}),selectTaskAction:(t,n=!0)=>{e({selectedTask:t?{...t}:null,isDetailPanelOpen:t?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:t=>e({selectedTaskInstance:t}),setLayoutDirection:t=>{const{workflowDef:n}=r();if(n){const{nodes:s,edges:a,taskMap:o}=Ee(n,t,{hideEmptyBranches:r().mode!=="edit"}),{nodes:i,edges:d}=_e(s,a,{direction:t,mode:r().mode});e({nodes:i,edges:d,taskMap:o,layoutDirection:t})}else e({layoutDirection:t})},onNodesChange:t=>{const n=r().nodes,s=new Set(n.map(o=>o.id)),a=t.filter(o=>"id"in o&&s.has(o.id));a.length!==0&&e({nodes:A.applyNodeChanges(a,n)})},onEdgesChange:t=>{const n=r().edges,s=A.applyEdgeChanges(t,n);s!==n&&e({edges:s})},onConnect:t=>{const{edges:n,layoutDirection:s}=r(),a=A.addEdge(t,n),{nodes:o,edges:i}=_e(r().nodes,a,{direction:s,mode:r().mode});e({edges:i,nodes:o})},checkTaskRefUniqueness:(t,n)=>{if(t===n)return!0;const{taskMap:s}=r();return!s[t]},updateTask:(t,n,s)=>{const{workflowDef:a,layoutDirection:o}=r();if(!a)return;const i=JSON.parse(JSON.stringify(a)),d=Ce(i.tasks,t);if(d){typeof n=="object"?Object.assign(d,n):d[n]=s,we(i.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:o,mode:r().mode}),g=Re(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},updateWorkflowProperties:t=>{const{workflowDef:n,layoutDirection:s}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,t),we(a.tasks);const{nodes:o,edges:i,taskMap:d}=Ee(a,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:c,edges:u}=_e(o,i,{direction:s,mode:r().mode}),f=Re(a);e({workflowDef:a,nodes:c,edges:u,taskMap:d,validationResults:f})},addNode:(t,n,s,a,o={})=>{const{workflowDef:i,layoutDirection:d}=r();if(!i)return;const c=JSON.parse(JSON.stringify(i)),u={name:t.data.label,taskReferenceName:t.data.taskReferenceName,type:t.data.taskType||"SIMPLE",inputParameters:{}};switch(u.type){case"HTTP":u.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":u.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":u.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":u.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":u.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":u.sink="conductor";break;case"WAIT":u.inputParameters={duration:"30s"};break;case"TERMINATE":u.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(u.type==="FORK_JOIN"||u.type==="FORK_JOIN_DYNAMIC"){u.type==="FORK_JOIN"?u.forkTasks=[[],[]]:(u.dynamicForkTasksParam="dynamic_tasks",u.dynamicForkTasksInputParamName="input");const y={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(o.isWorkflowStart)c.tasks.unshift(y),c.tasks.unshift(u);else if(o.isLoopBodyStart){const x=Ce(c.tasks,n);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(y),x.loopOver.unshift(u))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?(ir(c.tasks,n,o,u),Ae(c.tasks,u.taskReferenceName,y)):c.tasks.length===0?c.tasks.push(u,y):(Ae(c.tasks,n,u),Ae(c.tasks,u.taskReferenceName,y))}else if(u.type==="DECISION"||u.type==="SWITCH"?(u.evaluatorType="value-param",u.caseValueParam="case_param",u.decisionCases={case1:[]},u.defaultCase=[]):u.type==="DO_WHILE"?(u.loopCondition="$.taskReferenceName.output.value < 10",u.loopOver=[]):u.type==="INLINE"?(u.evaluatorType="graaljs",u.inputParameters={expression:`function execute(input) {
6
+ <%s key={someKey} {...props} />`,L,H,Y,H),B[H+L]=!0)}if(H=null,se!==void 0&&(r(se),H=""+se),i(U)&&(r(U.key),H=""+U.key),"key"in U){se={};for(var ie in U)ie!=="key"&&(se[ie]=U[ie])}else se=U;return H&&l(se,typeof P=="function"?P.displayName||P.name||"Unknown":P),d(P,H,se,s(),F,z)}function f(P){h(P)?P._store&&(P._store.validated=1):typeof P=="object"&&P!==null&&P.$$typeof===D&&(P._payload.status==="fulfilled"?h(P._payload.value)&&P._payload.value._store&&(P._payload.value._store.validated=1):P._store&&(P._store.validated=1))}function h(P){return typeof P=="object"&&P!==null&&P.$$typeof===m}var p=I,m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=Object.prototype.hasOwnProperty,E=Array.isArray,q=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(P){return P()}};var $,J={},V=p.react_stack_bottom_frame.bind(p,a)(),A=q(n(a)),B={};Tt.Fragment=x,Tt.jsx=function(P,U,se){var L=1e4>R.recentlyCreatedOwnerStacks++;return u(P,U,se,!1,L?Error("react-stack-top-frame"):V,L?q(n(P)):A)},Tt.jsxs=function(P,U,se){var L=1e4>R.recentlyCreatedOwnerStacks++;return u(P,U,se,!0,L?Error("react-stack-top-frame"):V,L?q(n(P)):A)}})()),Tt}var Sl;function Um(){return Sl||(Sl=1,process.env.NODE_ENV==="production"?Ft.exports=Hm():Ft.exports=Jm()),Ft.exports}var o=Um();const _l=e=>{let t;const r=new Set,n=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),r.forEach(p=>p(t,h))}},s=()=>t,l={setState:n,getState:s,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=t=e(n,s,l);return l},wl=(e=>e?_l(e):_l),Km=e=>e;function xr(e,t=Km){const r=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(r),r}const Gm=e=>{const t=wl(e),r=n=>xr(t,n);return Object.assign(r,t),r},vr=(e=>Gm);function br(e,t){let r;try{r=e()}catch{return}return{getItem:s=>{var a;const i=c=>c===null?null:JSON.parse(c,void 0),l=(a=r.getItem(s))!=null?a:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,a)=>r.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>r.removeItem(s)}}const kr=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return kr(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return kr(n)(r)}}}},Tl=(e,t)=>(r,n,s)=>{let a={storage:br(()=>localStorage),partialize:g=>g,version:0,merge:(g,x)=>({...x,...g}),...t},i=!1;const l=new Set,c=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...g)},n,s);const u=()=>{const g=a.partialize({...n()});return d.setItem(a.name,{state:g,version:a.version})},f=s.setState;s.setState=(g,x)=>(f(g,x),u());const h=e((...g)=>(r(...g),u()),n,s);s.getInitialState=()=>h;let p;const m=()=>{var g,x;if(!d)return;i=!1,l.forEach(y=>{var b;return y((b=n())!=null?b:h)});const v=((x=a.onRehydrateStorage)==null?void 0:x.call(a,(g=n())!=null?g:h))||void 0;return kr(d.getItem.bind(d))(a.name).then(y=>{if(y)if(typeof y.version=="number"&&y.version!==a.version){if(a.migrate){const b=a.migrate(y.state,y.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,y.state];return[!1,void 0]}).then(y=>{var b;const[k,_]=y;if(p=a.merge(_,(b=n())!=null?b:h),r(p,!0),k)return u()}).then(()=>{v?.(p,void 0),p=n(),i=!0,c.forEach(y=>y(p))}).catch(y=>{v?.(void 0,y)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>m(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},a.skipHydration||m(),p||h};var El=(e,t,r)=>(s,a)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(i=1)=>{if(a().pastStates.length){const l=r?.partialize?.(t())||t(),c=a().pastStates.splice(-i,i),d=c.shift();e(d),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(r?.diff?.(l,d)||l,c.reverse())})}},redo:(i=1)=>{if(a().futureStates.length){const l=r?.partialize?.(t())||t(),c=a().futureStates.splice(-i,i),d=c.shift();e(d),s({pastStates:a().pastStates.concat(r?.diff?.(l,d)||l,c.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:i=>s({_onSave:i}),_onSave:r?.onSave,_handleSet:(i,l,c,d)=>{r?.limit&&a().pastStates.length>=r?.limit&&a().pastStates.shift(),a()._onSave?.(i,c),s({pastStates:a().pastStates.concat(d||i),futureStates:[]})}}),Vm=(e,t)=>(n,s,a)=>{a.temporal=wl(t?.wrapTemporal?.(El(n,s,t))||El(n,s,t));const i=t?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,l=d=>{if(!a.temporal.getState().isTracking)return;const u=t?.partialize?.(s())||s(),f=t?.diff?.(d,u);f===null||t?.equality?.(d,u)||i(d,void 0,u,f)},c=a.setState;return a.setState=(...d)=>{const u=t?.partialize?.(s())||s();c(...d),l(u)},e((...d)=>{const u=t?.partialize?.(s())||s();n(...d),l(u)},s,a)};function Ym(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],i={};let l=0;const c=e.tasks;for(let d=0;d<c.length;d++){const u=c[d],f=Nl(u,l,i,t,c,n);if(s.push(...f.nodes),a.push(...f.edges),l=f.nextId,d>0){const h=c[d-1];Sr(h,u,a,n)}Object.assign(i,f.taskMap)}if(!n&&c.length>0){const d=c[0],u="__workflow_start__";s.push({id:u,type:"plusNode",data:{label:"+",taskReferenceName:u,taskType:"PLUS",parentRef:u,edgeData:{isWorkflowStart:!0},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:t==="LR"?M.Position.Left:M.Position.Top}),a.push({id:`e-${u}-${d.taskReferenceName}`,source:u,target:d.taskReferenceName,animated:!0});const f=c[c.length-1],h="__workflow_end__";s.push({id:h,type:"plusNode",data:{label:"+",taskReferenceName:h,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:t==="LR"?M.Position.Left:M.Position.Top}),Sr(f,{taskReferenceName:h},a,n)}return{nodes:s,edges:a,taskMap:i}}function Nl(e,t,r,n="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return Qm(e,t,r,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return Zm(e,t,r,n);case"JOIN":case"EXCLUSIVE_JOIN":return rg(e,t,r,n,s,a);case"DO_WHILE":return eg(e,t,r,n,a);case"SUB_WORKFLOW":return tg(e,t,r,n);default:return Xm(e,t,r,n)}}function Xm(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function Qm(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={},d={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top};a.push(d),c[e.taskReferenceName]=e;const u=e.decisionCases||{},f=e.defaultCase||[],h=Object.keys(u),p=(m,g)=>{if(n==="TB"){if(m===0&&g>1)return"left";if(m===1&&g>2)return"right"}else{if(m===0&&g>1)return"top";if(m===1&&g>2)return"bottom"}return null};if(h.forEach((m,g)=>{const x=u[m],v=p(g,h.length+1);if(x&&x.length>0){const y=Bt(x,l,{...r,...c},n,s);a.push(...y.nodes),i.push(...y.edges),Object.assign(c,y.taskMap),l=y.nextId;const b=x[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:v||void 0,target:b,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6"}})}else if(!s){const y=`${e.taskReferenceName}_empty_${m}`;a.push({id:y,type:"plusNode",data:{label:`${m} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:m},layoutDirection:n,taskReferenceName:y,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${y}`,source:e.taskReferenceName,sourceHandle:v||void 0,target:y,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const m=Bt(f,l,{...r,...c},n,s);a.push(...m.nodes),i.push(...m.edges),Object.assign(c,m.taskMap),l=m.nextId;const g=f[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const m=`${e.taskReferenceName}_empty_default`;a.push({id:m,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:m,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:i,taskMap:c,nextId:l}}function Zm(e,t,r,n="TB"){const s=[],a=[];let i=t;const l={},c=e.type==="FORK_JOIN_DYNAMIC",d={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:c,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top};if(s.push(d),l[e.taskReferenceName]=e,c){const u=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:u,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:u,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${u}`,source:e.taskReferenceName,target:u,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),l[u]={taskReferenceName:u,type:"DYNAMIC_PLACEHOLDER"}}return c||(e.forkTasks||[]).forEach((f,h)=>{if(f&&f.length>0){const p=Bt(f,i,{...r,...l},n,!1);s.push(...p.nodes),a.push(...p.edges),Object.assign(l,p.taskMap),i=p.nextId;const m=f[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,sourceHandle:`branch_${h}`,target:m,label:`分支 ${h+1}`,animated:!0,data:{forkIndex:h},style:{stroke:"#10b981"}})}}),{nodes:s,edges:a,taskMap:l,nextId:i}}function eg(e,t,r,n="TB",s=!1){const a={},i=e.taskReferenceName,l={id:i,type:"loopNode",data:{label:e.name,taskReferenceName:i,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{pointerEvents:"none"}};a[i]=e;const c=e.loopOver||[],d=[],u=[];let f=t+1;if(c.length>0){const h=Bt(c,f,{...r,...a},n,s);if(f=h.nextId,Object.assign(a,h.taskMap),h.nodes.forEach(p=>{d.push({...p,parentId:p.parentId??i,extent:p.parentId?p.extent:"parent"})}),u.push(...h.edges),!s){const p=c[0],m=`__loop_start__${i}`;d.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top}),u.push({id:`e-${m}-${p.taskReferenceName}`,source:m,target:p.taskReferenceName,animated:!0})}if(!s){const p=c[c.length-1],m=`__loop_end__${i}`;d.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:p.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top}),u.push({id:`e-${p.taskReferenceName}-${m}`,source:p.taskReferenceName,target:m,animated:!0})}}else if(!s){const h=`${i}_loop_empty_plus`;d.push({id:h,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:h,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top})}return{nodes:[l,...d],edges:u,taskMap:a,nextId:f}}function tg(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function rg(e,t,r,n="TB",s=[],a=!1){const i={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top},l={[e.taskReferenceName]:e},c=[],d=[];(e.joinOn||[]).forEach(h=>{const p=s.find(m=>m.taskReferenceName===h)||r[h];p&&zt(p,a).forEach(g=>{d.push({id:`e-${g}-${e.taskReferenceName}`,source:g,target:e.taskReferenceName,animated:!0})})});const f=s.findIndex(h=>h.taskReferenceName===e.taskReferenceName);if(f>0){const h=s[f-1];if(h.type==="FORK_JOIN_DYNAMIC"){const p=`${h.taskReferenceName}_dynamic_placeholder`;d.push({id:`e-${p}-${e.taskReferenceName}-dynamic`,source:p,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else h.type==="FORK_JOIN"&&(h.forkTasks||[]).forEach((m,g)=>{if((!m||m.length===0)&&!a){const x=`${h.taskReferenceName}_empty_branch_${g}`;c.push({id:x,type:"default",data:{label:`分支 ${g+1} (空)`,layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?M.Position.Right:M.Position.Bottom,targetPosition:n==="LR"?M.Position.Left:M.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),d.push({id:`e-${h.taskReferenceName}-${x}`,source:h.taskReferenceName,sourceHandle:`branch_${g}`,target:x,label:`分支 ${g+1}`,animated:!0,data:{forkIndex:g},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),d.push({id:`e-${x}-${e.taskReferenceName}`,source:x,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[i,...c],edges:d,taskMap:l,nextId:t+1}}function Bt(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={};for(let d=0;d<e.length;d++){const u=e[d],f={...r,...c},h=Nl(u,l,f,n,e,s);if(a.push(...h.nodes),i.push(...h.edges),Object.assign(c,h.taskMap),l=h.nextId,d>0){const p=e[d-1];Sr(p,u,i,s)}}return{nodes:a,edges:i,taskMap:c,nextId:l}}function Sr(e,t,r,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=zt(e,n),a=t.taskReferenceName;s.forEach(i=>{const l=`e-${i}-${a}`;r.find(c=>c.id===l)||r.push({id:l,source:i,target:a,animated:!0})})}function zt(e,t=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const n=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([i,l])=>{if(l&&l.length>0){const c=l[l.length-1];n.push(...zt(c,t))}else t||n.push(`${e.taskReferenceName}_empty_${i}`)}),a.length>0){const i=a[a.length-1];n.push(...zt(i,t))}else t||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const Ae=Ym;function _r(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wr,jl;function ng(){if(jl)return wr;jl=1;function e(){this.__data__=[],this.size=0}return wr=e,wr}var Tr,Cl;function dt(){if(Cl)return Tr;Cl=1;function e(t,r){return t===r||t!==t&&r!==r}return Tr=e,Tr}var Er,Il;function Ht(){if(Il)return Er;Il=1;var e=dt();function t(r,n){for(var s=r.length;s--;)if(e(r[s][0],n))return s;return-1}return Er=t,Er}var Nr,Rl;function sg(){if(Rl)return Nr;Rl=1;var e=Ht(),t=Array.prototype,r=t.splice;function n(s){var a=this.__data__,i=e(a,s);if(i<0)return!1;var l=a.length-1;return i==l?a.pop():r.call(a,i,1),--this.size,!0}return Nr=n,Nr}var jr,Ol;function ag(){if(Ol)return jr;Ol=1;var e=Ht();function t(r){var n=this.__data__,s=e(n,r);return s<0?void 0:n[s][1]}return jr=t,jr}var Cr,Pl;function og(){if(Pl)return Cr;Pl=1;var e=Ht();function t(r){return e(this.__data__,r)>-1}return Cr=t,Cr}var Ir,Al;function ig(){if(Al)return Ir;Al=1;var e=Ht();function t(r,n){var s=this.__data__,a=e(s,r);return a<0?(++this.size,s.push([r,n])):s[a][1]=n,this}return Ir=t,Ir}var Rr,Ll;function Jt(){if(Ll)return Rr;Ll=1;var e=ng(),t=sg(),r=ag(),n=og(),s=ig();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,Rr=a,Rr}var Or,Dl;function lg(){if(Dl)return Or;Dl=1;var e=Jt();function t(){this.__data__=new e,this.size=0}return Or=t,Or}var Pr,Ml;function cg(){if(Ml)return Pr;Ml=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Pr=e,Pr}var Ar,ql;function dg(){if(ql)return Ar;ql=1;function e(t){return this.__data__.get(t)}return Ar=e,Ar}var Lr,$l;function ug(){if($l)return Lr;$l=1;function e(t){return this.__data__.has(t)}return Lr=e,Lr}var Dr,Wl;function Fl(){if(Wl)return Dr;Wl=1;var e=typeof Wt=="object"&&Wt&&Wt.Object===Object&&Wt;return Dr=e,Dr}var Mr,Bl;function ze(){if(Bl)return Mr;Bl=1;var e=Fl(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Mr=r,Mr}var qr,zl;function ut(){if(zl)return qr;zl=1;var e=ze(),t=e.Symbol;return qr=t,qr}var $r,Hl;function fg(){if(Hl)return $r;Hl=1;var e=ut(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,s=e?e.toStringTag:void 0;function a(i){var l=r.call(i,s),c=i[s];try{i[s]=void 0;var d=!0}catch{}var u=n.call(i);return d&&(l?i[s]=c:delete i[s]),u}return $r=a,$r}var Wr,Jl;function pg(){if(Jl)return Wr;Jl=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Wr=r,Wr}var Fr,Ul;function nt(){if(Ul)return Fr;Ul=1;var e=ut(),t=fg(),r=pg(),n="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function i(l){return l==null?l===void 0?s:n:a&&a in Object(l)?t(l):r(l)}return Fr=i,Fr}var Br,Kl;function qe(){if(Kl)return Br;Kl=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Br=e,Br}var zr,Gl;function Et(){if(Gl)return zr;Gl=1;var e=nt(),t=qe(),r="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function i(l){if(!t(l))return!1;var c=e(l);return c==n||c==s||c==r||c==a}return zr=i,zr}var Hr,Vl;function hg(){if(Vl)return Hr;Vl=1;var e=ze(),t=e["__core-js_shared__"];return Hr=t,Hr}var Jr,Yl;function mg(){if(Yl)return Jr;Yl=1;var e=hg(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Jr=r,Jr}var Ur,Xl;function Ql(){if(Xl)return Ur;Xl=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Ur=r,Ur}var Kr,Zl;function gg(){if(Zl)return Kr;Zl=1;var e=Et(),t=mg(),r=qe(),n=Ql(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,c=i.toString,d=l.hasOwnProperty,u=RegExp("^"+c.call(d).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(h){if(!r(h)||t(h))return!1;var p=e(h)?u:a;return p.test(n(h))}return Kr=f,Kr}var Gr,ec;function yg(){if(ec)return Gr;ec=1;function e(t,r){return t?.[r]}return Gr=e,Gr}var Vr,tc;function st(){if(tc)return Vr;tc=1;var e=gg(),t=yg();function r(n,s){var a=t(n,s);return e(a)?a:void 0}return Vr=r,Vr}var Yr,rc;function Xr(){if(rc)return Yr;rc=1;var e=st(),t=ze(),r=e(t,"Map");return Yr=r,Yr}var Qr,nc;function Ut(){if(nc)return Qr;nc=1;var e=st(),t=e(Object,"create");return Qr=t,Qr}var Zr,sc;function xg(){if(sc)return Zr;sc=1;var e=Ut();function t(){this.__data__=e?e(null):{},this.size=0}return Zr=t,Zr}var en,ac;function vg(){if(ac)return en;ac=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return en=e,en}var tn,oc;function bg(){if(oc)return tn;oc=1;var e=Ut(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function s(a){var i=this.__data__;if(e){var l=i[a];return l===t?void 0:l}return n.call(i,a)?i[a]:void 0}return tn=s,tn}var rn,ic;function kg(){if(ic)return rn;ic=1;var e=Ut(),t=Object.prototype,r=t.hasOwnProperty;function n(s){var a=this.__data__;return e?a[s]!==void 0:r.call(a,s)}return rn=n,rn}var nn,lc;function Sg(){if(lc)return nn;lc=1;var e=Ut(),t="__lodash_hash_undefined__";function r(n,s){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&s===void 0?t:s,this}return nn=r,nn}var sn,cc;function _g(){if(cc)return sn;cc=1;var e=xg(),t=vg(),r=bg(),n=kg(),s=Sg();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,sn=a,sn}var an,dc;function wg(){if(dc)return an;dc=1;var e=_g(),t=Jt(),r=Xr();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return an=n,an}var on,uc;function Tg(){if(uc)return on;uc=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return on=e,on}var ln,fc;function Kt(){if(fc)return ln;fc=1;var e=Tg();function t(r,n){var s=r.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return ln=t,ln}var cn,pc;function Eg(){if(pc)return cn;pc=1;var e=Kt();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return cn=t,cn}var dn,hc;function Ng(){if(hc)return dn;hc=1;var e=Kt();function t(r){return e(this,r).get(r)}return dn=t,dn}var un,mc;function jg(){if(mc)return un;mc=1;var e=Kt();function t(r){return e(this,r).has(r)}return un=t,un}var fn,gc;function Cg(){if(gc)return fn;gc=1;var e=Kt();function t(r,n){var s=e(this,r),a=s.size;return s.set(r,n),this.size+=s.size==a?0:1,this}return fn=t,fn}var pn,yc;function hn(){if(yc)return pn;yc=1;var e=wg(),t=Eg(),r=Ng(),n=jg(),s=Cg();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,pn=a,pn}var mn,xc;function Ig(){if(xc)return mn;xc=1;var e=Jt(),t=Xr(),r=hn(),n=200;function s(a,i){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!t||c.length<n-1)return c.push([a,i]),this.size=++l.size,this;l=this.__data__=new r(c)}return l.set(a,i),this.size=l.size,this}return mn=s,mn}var gn,vc;function Gt(){if(vc)return gn;vc=1;var e=Jt(),t=lg(),r=cg(),n=dg(),s=ug(),a=Ig();function i(l){var c=this.__data__=new e(l);this.size=c.size}return i.prototype.clear=t,i.prototype.delete=r,i.prototype.get=n,i.prototype.has=s,i.prototype.set=a,gn=i,gn}var yn,bc;function xn(){if(bc)return yn;bc=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s&&r(t[n],n,t)!==!1;);return t}return yn=e,yn}var vn,kc;function Sc(){if(kc)return vn;kc=1;var e=st(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return vn=t,vn}var bn,_c;function Vt(){if(_c)return bn;_c=1;var e=Sc();function t(r,n,s){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[n]=s}return bn=t,bn}var kn,wc;function Yt(){if(wc)return kn;wc=1;var e=Vt(),t=dt(),r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l){var c=a[i];(!(n.call(a,i)&&t(c,l))||l===void 0&&!(i in a))&&e(a,i,l)}return kn=s,kn}var Sn,Tc;function Nt(){if(Tc)return Sn;Tc=1;var e=Yt(),t=Vt();function r(n,s,a,i){var l=!a;a||(a={});for(var c=-1,d=s.length;++c<d;){var u=s[c],f=i?i(a[u],n[u],u,a,n):void 0;f===void 0&&(f=n[u]),l?t(a,u,f):e(a,u,f)}return a}return Sn=r,Sn}var _n,Ec;function Rg(){if(Ec)return _n;Ec=1;function e(t,r){for(var n=-1,s=Array(t);++n<t;)s[n]=r(n);return s}return _n=e,_n}var wn,Nc;function Ke(){if(Nc)return wn;Nc=1;function e(t){return t!=null&&typeof t=="object"}return wn=e,wn}var Tn,jc;function Og(){if(jc)return Tn;jc=1;var e=nt(),t=Ke(),r="[object Arguments]";function n(s){return t(s)&&e(s)==r}return Tn=n,Tn}var En,Cc;function jt(){if(Cc)return En;Cc=1;var e=Og(),t=Ke(),r=Object.prototype,n=r.hasOwnProperty,s=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return t(i)&&n.call(i,"callee")&&!s.call(i,"callee")};return En=a,En}var Nn,Ic;function Ne(){if(Ic)return Nn;Ic=1;var e=Array.isArray;return Nn=e,Nn}var Ct={exports:{}},jn,Rc;function Pg(){if(Rc)return jn;Rc=1;function e(){return!1}return jn=e,jn}Ct.exports;var Oc;function ft(){return Oc||(Oc=1,(function(e,t){var r=ze(),n=Pg(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===s,l=i?r.Buffer:void 0,c=l?l.isBuffer:void 0,d=c||n;e.exports=d})(Ct,Ct.exports)),Ct.exports}var Cn,Pc;function Xt(){if(Pc)return Cn;Pc=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,s){var a=typeof n;return s=s??e,!!s&&(a=="number"||a!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<s}return Cn=r,Cn}var In,Ac;function Rn(){if(Ac)return In;Ac=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return In=t,In}var On,Lc;function Ag(){if(Lc)return On;Lc=1;var e=nt(),t=Rn(),r=Ke(),n="[object Arguments]",s="[object Array]",a="[object Boolean]",i="[object Date]",l="[object Error]",c="[object Function]",d="[object Map]",u="[object Number]",f="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",g="[object WeakMap]",x="[object ArrayBuffer]",v="[object DataView]",y="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",_="[object Int16Array]",w="[object Int32Array]",T="[object Uint8Array]",O="[object Uint8ClampedArray]",D="[object Uint16Array]",N="[object Uint32Array]",S={};S[y]=S[b]=S[k]=S[_]=S[w]=S[T]=S[O]=S[D]=S[N]=!0,S[n]=S[s]=S[x]=S[a]=S[v]=S[i]=S[l]=S[c]=S[d]=S[u]=S[f]=S[h]=S[p]=S[m]=S[g]=!1;function R(j){return r(j)&&t(j.length)&&!!S[e(j)]}return On=R,On}var Pn,Dc;function Qt(){if(Dc)return Pn;Dc=1;function e(t){return function(r){return t(r)}}return Pn=e,Pn}var It={exports:{}};It.exports;var Mc;function An(){return Mc||(Mc=1,(function(e,t){var r=Fl(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a&&r.process,l=(function(){try{var c=s&&s.require&&s.require("util").types;return c||i&&i.binding&&i.binding("util")}catch{}})();e.exports=l})(It,It.exports)),It.exports}var Ln,qc;function Rt(){if(qc)return Ln;qc=1;var e=Ag(),t=Qt(),r=An(),n=r&&r.isTypedArray,s=n?t(n):e;return Ln=s,Ln}var Dn,$c;function Wc(){if($c)return Dn;$c=1;var e=Rg(),t=jt(),r=Ne(),n=ft(),s=Xt(),a=Rt(),i=Object.prototype,l=i.hasOwnProperty;function c(d,u){var f=r(d),h=!f&&t(d),p=!f&&!h&&n(d),m=!f&&!h&&!p&&a(d),g=f||h||p||m,x=g?e(d.length,String):[],v=x.length;for(var y in d)(u||l.call(d,y))&&!(g&&(y=="length"||p&&(y=="offset"||y=="parent")||m&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||s(y,v)))&&x.push(y);return x}return Dn=c,Dn}var Mn,Fc;function Zt(){if(Fc)return Mn;Fc=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,s=typeof n=="function"&&n.prototype||e;return r===s}return Mn=t,Mn}var qn,Bc;function zc(){if(Bc)return qn;Bc=1;function e(t,r){return function(n){return t(r(n))}}return qn=e,qn}var $n,Hc;function Lg(){if(Hc)return $n;Hc=1;var e=zc(),t=e(Object.keys,Object);return $n=t,$n}var Wn,Jc;function Fn(){if(Jc)return Wn;Jc=1;var e=Zt(),t=Lg(),r=Object.prototype,n=r.hasOwnProperty;function s(a){if(!e(a))return t(a);var i=[];for(var l in Object(a))n.call(a,l)&&l!="constructor"&&i.push(l);return i}return Wn=s,Wn}var Bn,Uc;function Ve(){if(Uc)return Bn;Uc=1;var e=Et(),t=Rn();function r(n){return n!=null&&t(n.length)&&!e(n)}return Bn=r,Bn}var zn,Kc;function Ze(){if(Kc)return zn;Kc=1;var e=Wc(),t=Fn(),r=Ve();function n(s){return r(s)?e(s):t(s)}return zn=n,zn}var Hn,Gc;function Dg(){if(Gc)return Hn;Gc=1;var e=Nt(),t=Ze();function r(n,s){return n&&e(s,t(s),n)}return Hn=r,Hn}var Jn,Vc;function Mg(){if(Vc)return Jn;Vc=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Jn=e,Jn}var Un,Yc;function qg(){if(Yc)return Un;Yc=1;var e=qe(),t=Zt(),r=Mg(),n=Object.prototype,s=n.hasOwnProperty;function a(i){if(!e(i))return r(i);var l=t(i),c=[];for(var d in i)d=="constructor"&&(l||!s.call(i,d))||c.push(d);return c}return Un=a,Un}var Kn,Xc;function at(){if(Xc)return Kn;Xc=1;var e=Wc(),t=qg(),r=Ve();function n(s){return r(s)?e(s,!0):t(s)}return Kn=n,Kn}var Gn,Qc;function $g(){if(Qc)return Gn;Qc=1;var e=Nt(),t=at();function r(n,s){return n&&e(s,t(s),n)}return Gn=r,Gn}var Ot={exports:{}};Ot.exports;var Zc;function ed(){return Zc||(Zc=1,(function(e,t){var r=ze(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a?r.Buffer:void 0,l=i?i.allocUnsafe:void 0;function c(d,u){if(u)return d.slice();var f=d.length,h=l?l(f):new d.constructor(f);return d.copy(h),h}e.exports=c})(Ot,Ot.exports)),Ot.exports}var Vn,td;function rd(){if(td)return Vn;td=1;function e(t,r){var n=-1,s=t.length;for(r||(r=Array(s));++n<s;)r[n]=t[n];return r}return Vn=e,Vn}var Yn,nd;function sd(){if(nd)return Yn;nd=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=0,i=[];++n<s;){var l=t[n];r(l,n,t)&&(i[a++]=l)}return i}return Yn=e,Yn}var Xn,ad;function od(){if(ad)return Xn;ad=1;function e(){return[]}return Xn=e,Xn}var Qn,id;function Zn(){if(id)return Qn;id=1;var e=sd(),t=od(),r=Object.prototype,n=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(i){return i==null?[]:(i=Object(i),e(s(i),function(l){return n.call(i,l)}))}:t;return Qn=a,Qn}var es,ld;function Wg(){if(ld)return es;ld=1;var e=Nt(),t=Zn();function r(n,s){return e(n,t(n),s)}return es=r,es}var ts,cd;function rs(){if(cd)return ts;cd=1;function e(t,r){for(var n=-1,s=r.length,a=t.length;++n<s;)t[a+n]=r[n];return t}return ts=e,ts}var ns,dd;function er(){if(dd)return ns;dd=1;var e=zc(),t=e(Object.getPrototypeOf,Object);return ns=t,ns}var ss,ud;function fd(){if(ud)return ss;ud=1;var e=rs(),t=er(),r=Zn(),n=od(),s=Object.getOwnPropertySymbols,a=s?function(i){for(var l=[];i;)e(l,r(i)),i=t(i);return l}:n;return ss=a,ss}var as,pd;function Fg(){if(pd)return as;pd=1;var e=Nt(),t=fd();function r(n,s){return e(n,t(n),s)}return as=r,as}var os,hd;function md(){if(hd)return os;hd=1;var e=rs(),t=Ne();function r(n,s,a){var i=s(n);return t(n)?i:e(i,a(n))}return os=r,os}var is,gd;function yd(){if(gd)return is;gd=1;var e=md(),t=Zn(),r=Ze();function n(s){return e(s,r,t)}return is=n,is}var ls,xd;function Bg(){if(xd)return ls;xd=1;var e=md(),t=fd(),r=at();function n(s){return e(s,r,t)}return ls=n,ls}var cs,vd;function zg(){if(vd)return cs;vd=1;var e=st(),t=ze(),r=e(t,"DataView");return cs=r,cs}var ds,bd;function Hg(){if(bd)return ds;bd=1;var e=st(),t=ze(),r=e(t,"Promise");return ds=r,ds}var us,kd;function Sd(){if(kd)return us;kd=1;var e=st(),t=ze(),r=e(t,"Set");return us=r,us}var fs,_d;function Jg(){if(_d)return fs;_d=1;var e=st(),t=ze(),r=e(t,"WeakMap");return fs=r,fs}var ps,wd;function pt(){if(wd)return ps;wd=1;var e=zg(),t=Xr(),r=Hg(),n=Sd(),s=Jg(),a=nt(),i=Ql(),l="[object Map]",c="[object Object]",d="[object Promise]",u="[object Set]",f="[object WeakMap]",h="[object DataView]",p=i(e),m=i(t),g=i(r),x=i(n),v=i(s),y=a;return(e&&y(new e(new ArrayBuffer(1)))!=h||t&&y(new t)!=l||r&&y(r.resolve())!=d||n&&y(new n)!=u||s&&y(new s)!=f)&&(y=function(b){var k=a(b),_=k==c?b.constructor:void 0,w=_?i(_):"";if(w)switch(w){case p:return h;case m:return l;case g:return d;case x:return u;case v:return f}return k}),ps=y,ps}var hs,Td;function Ug(){if(Td)return hs;Td=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var s=n.length,a=new n.constructor(s);return s&&typeof n[0]=="string"&&t.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return hs=r,hs}var ms,Ed;function Nd(){if(Ed)return ms;Ed=1;var e=ze(),t=e.Uint8Array;return ms=t,ms}var gs,jd;function ys(){if(jd)return gs;jd=1;var e=Nd();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return gs=t,gs}var xs,Cd;function Kg(){if(Cd)return xs;Cd=1;var e=ys();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return xs=t,xs}var vs,Id;function Gg(){if(Id)return vs;Id=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return vs=t,vs}var bs,Rd;function Vg(){if(Rd)return bs;Rd=1;var e=ut(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(s){return r?Object(r.call(s)):{}}return bs=n,bs}var ks,Od;function Pd(){if(Od)return ks;Od=1;var e=ys();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return ks=t,ks}var Ss,Ad;function Yg(){if(Ad)return Ss;Ad=1;var e=ys(),t=Kg(),r=Gg(),n=Vg(),s=Pd(),a="[object Boolean]",i="[object Date]",l="[object Map]",c="[object Number]",d="[object RegExp]",u="[object Set]",f="[object String]",h="[object Symbol]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",x="[object Float64Array]",v="[object Int8Array]",y="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",_="[object Uint8ClampedArray]",w="[object Uint16Array]",T="[object Uint32Array]";function O(D,N,S){var R=D.constructor;switch(N){case p:return e(D);case a:case i:return new R(+D);case m:return t(D,S);case g:case x:case v:case y:case b:case k:case _:case w:case T:return s(D,S);case l:return new R;case c:case f:return new R(D);case d:return r(D);case u:return new R;case h:return n(D)}}return Ss=O,Ss}var _s,Ld;function Dd(){if(Ld)return _s;Ld=1;var e=qe(),t=Object.create,r=(function(){function n(){}return function(s){if(!e(s))return{};if(t)return t(s);n.prototype=s;var a=new n;return n.prototype=void 0,a}})();return _s=r,_s}var ws,Md;function qd(){if(Md)return ws;Md=1;var e=Dd(),t=er(),r=Zt();function n(s){return typeof s.constructor=="function"&&!r(s)?e(t(s)):{}}return ws=n,ws}var Ts,$d;function Xg(){if($d)return Ts;$d=1;var e=pt(),t=Ke(),r="[object Map]";function n(s){return t(s)&&e(s)==r}return Ts=n,Ts}var Es,Wd;function Qg(){if(Wd)return Es;Wd=1;var e=Xg(),t=Qt(),r=An(),n=r&&r.isMap,s=n?t(n):e;return Es=s,Es}var Ns,Fd;function Zg(){if(Fd)return Ns;Fd=1;var e=pt(),t=Ke(),r="[object Set]";function n(s){return t(s)&&e(s)==r}return Ns=n,Ns}var js,Bd;function ey(){if(Bd)return js;Bd=1;var e=Zg(),t=Qt(),r=An(),n=r&&r.isSet,s=n?t(n):e;return js=s,js}var Cs,zd;function Hd(){if(zd)return Cs;zd=1;var e=Gt(),t=xn(),r=Yt(),n=Dg(),s=$g(),a=ed(),i=rd(),l=Wg(),c=Fg(),d=yd(),u=Bg(),f=pt(),h=Ug(),p=Yg(),m=qd(),g=Ne(),x=ft(),v=Qg(),y=qe(),b=ey(),k=Ze(),_=at(),w=1,T=2,O=4,D="[object Arguments]",N="[object Array]",S="[object Boolean]",R="[object Date]",j="[object Error]",E="[object Function]",q="[object GeneratorFunction]",$="[object Map]",J="[object Number]",V="[object Object]",A="[object RegExp]",B="[object Set]",P="[object String]",U="[object Symbol]",se="[object WeakMap]",L="[object ArrayBuffer]",F="[object DataView]",z="[object Float32Array]",H="[object Float64Array]",Y="[object Int8Array]",ie="[object Int16Array]",fe="[object Int32Array]",ve="[object Uint8Array]",be="[object Uint8ClampedArray]",W="[object Uint16Array]",ke="[object Uint32Array]",ee={};ee[D]=ee[N]=ee[L]=ee[F]=ee[S]=ee[R]=ee[z]=ee[H]=ee[Y]=ee[ie]=ee[fe]=ee[$]=ee[J]=ee[V]=ee[A]=ee[B]=ee[P]=ee[U]=ee[ve]=ee[be]=ee[W]=ee[ke]=!0,ee[j]=ee[E]=ee[se]=!1;function me(ne,_e,ce,he,Fe,Se){var ge,Qe=_e&w,Ee=_e&T,rt=_e&O;if(ce&&(ge=Fe?ce(ne,he,Fe,Se):ce(ne)),ge!==void 0)return ge;if(!y(ne))return ne;var Q=g(ne);if(Q){if(ge=h(ne),!Qe)return i(ne,ge)}else{var X=f(ne),te=X==E||X==q;if(x(ne))return a(ne,Qe);if(X==V||X==D||te&&!Fe){if(ge=Ee||te?{}:m(ne),!Qe)return Ee?c(ne,s(ge,ne)):l(ne,n(ge,ne))}else{if(!ee[X])return Fe?ne:{};ge=p(ne,X,Qe)}}Se||(Se=new e);var de=Se.get(ne);if(de)return de;Se.set(ne,ge),b(ne)?ne.forEach(function(C){ge.add(me(C,_e,ce,C,ne,Se))}):v(ne)&&ne.forEach(function(C,K){ge.set(K,me(C,_e,ce,K,ne,Se))});var G=rt?Ee?u:d:Ee?_:k,le=Q?void 0:G(ne);return t(le||ne,function(C,K){le&&(K=C,C=ne[K]),r(ge,K,me(C,_e,ce,K,ne,Se))}),ge}return Cs=me,Cs}var Is,Jd;function ty(){if(Jd)return Is;Jd=1;var e=Hd(),t=4;function r(n){return e(n,t)}return Is=r,Is}var Rs,Ud;function Os(){if(Ud)return Rs;Ud=1;function e(t){return function(){return t}}return Rs=e,Rs}var Ps,Kd;function ry(){if(Kd)return Ps;Kd=1;function e(t){return function(r,n,s){for(var a=-1,i=Object(r),l=s(r),c=l.length;c--;){var d=l[t?c:++a];if(n(i[d],d,i)===!1)break}return r}}return Ps=e,Ps}var As,Gd;function Ls(){if(Gd)return As;Gd=1;var e=ry(),t=e();return As=t,As}var Ds,Vd;function Ms(){if(Vd)return Ds;Vd=1;var e=Ls(),t=Ze();function r(n,s){return n&&e(n,s,t)}return Ds=r,Ds}var qs,Yd;function ny(){if(Yd)return qs;Yd=1;var e=Ve();function t(r,n){return function(s,a){if(s==null)return s;if(!e(s))return r(s,a);for(var i=s.length,l=n?i:-1,c=Object(s);(n?l--:++l<i)&&a(c[l],l,c)!==!1;);return s}}return qs=t,qs}var $s,Xd;function tr(){if(Xd)return $s;Xd=1;var e=Ms(),t=ny(),r=t(e);return $s=r,$s}var Ws,Qd;function ot(){if(Qd)return Ws;Qd=1;function e(t){return t}return Ws=e,Ws}var Fs,Zd;function eu(){if(Zd)return Fs;Zd=1;var e=ot();function t(r){return typeof r=="function"?r:e}return Fs=t,Fs}var Bs,tu;function ru(){if(tu)return Bs;tu=1;var e=xn(),t=tr(),r=eu(),n=Ne();function s(a,i){var l=n(a)?e:t;return l(a,r(i))}return Bs=s,Bs}var zs,nu;function su(){return nu||(nu=1,zs=ru()),zs}var Hs,au;function sy(){if(au)return Hs;au=1;var e=tr();function t(r,n){var s=[];return e(r,function(a,i,l){n(a,i,l)&&s.push(a)}),s}return Hs=t,Hs}var Js,ou;function ay(){if(ou)return Js;ou=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Js=t,Js}var Us,iu;function oy(){if(iu)return Us;iu=1;function e(t){return this.__data__.has(t)}return Us=e,Us}var Ks,lu;function cu(){if(lu)return Ks;lu=1;var e=hn(),t=ay(),r=oy();function n(s){var a=-1,i=s==null?0:s.length;for(this.__data__=new e;++a<i;)this.add(s[a])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Ks=n,Ks}var Gs,du;function iy(){if(du)return Gs;du=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s;)if(r(t[n],n,t))return!0;return!1}return Gs=e,Gs}var Vs,uu;function fu(){if(uu)return Vs;uu=1;function e(t,r){return t.has(r)}return Vs=e,Vs}var Ys,pu;function hu(){if(pu)return Ys;pu=1;var e=cu(),t=iy(),r=fu(),n=1,s=2;function a(i,l,c,d,u,f){var h=c&n,p=i.length,m=l.length;if(p!=m&&!(h&&m>p))return!1;var g=f.get(i),x=f.get(l);if(g&&x)return g==l&&x==i;var v=-1,y=!0,b=c&s?new e:void 0;for(f.set(i,l),f.set(l,i);++v<p;){var k=i[v],_=l[v];if(d)var w=h?d(_,k,v,l,i,f):d(k,_,v,i,l,f);if(w!==void 0){if(w)continue;y=!1;break}if(b){if(!t(l,function(T,O){if(!r(b,O)&&(k===T||u(k,T,c,d,f)))return b.push(O)})){y=!1;break}}else if(!(k===_||u(k,_,c,d,f))){y=!1;break}}return f.delete(i),f.delete(l),y}return Ys=a,Ys}var Xs,mu;function ly(){if(mu)return Xs;mu=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s,a){n[++r]=[a,s]}),n}return Xs=e,Xs}var Qs,gu;function Zs(){if(gu)return Qs;gu=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s){n[++r]=s}),n}return Qs=e,Qs}var ea,yu;function cy(){if(yu)return ea;yu=1;var e=ut(),t=Nd(),r=dt(),n=hu(),s=ly(),a=Zs(),i=1,l=2,c="[object Boolean]",d="[object Date]",u="[object Error]",f="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",g="[object String]",x="[object Symbol]",v="[object ArrayBuffer]",y="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function _(w,T,O,D,N,S,R){switch(O){case y:if(w.byteLength!=T.byteLength||w.byteOffset!=T.byteOffset)return!1;w=w.buffer,T=T.buffer;case v:return!(w.byteLength!=T.byteLength||!S(new t(w),new t(T)));case c:case d:case h:return r(+w,+T);case u:return w.name==T.name&&w.message==T.message;case p:case g:return w==T+"";case f:var j=s;case m:var E=D&i;if(j||(j=a),w.size!=T.size&&!E)return!1;var q=R.get(w);if(q)return q==T;D|=l,R.set(w,T);var $=n(j(w),j(T),D,N,S,R);return R.delete(w),$;case x:if(k)return k.call(w)==k.call(T)}return!1}return ea=_,ea}var ta,xu;function dy(){if(xu)return ta;xu=1;var e=yd(),t=1,r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l,c,d,u){var f=l&t,h=e(a),p=h.length,m=e(i),g=m.length;if(p!=g&&!f)return!1;for(var x=p;x--;){var v=h[x];if(!(f?v in i:n.call(i,v)))return!1}var y=u.get(a),b=u.get(i);if(y&&b)return y==i&&b==a;var k=!0;u.set(a,i),u.set(i,a);for(var _=f;++x<p;){v=h[x];var w=a[v],T=i[v];if(c)var O=f?c(T,w,v,i,a,u):c(w,T,v,a,i,u);if(!(O===void 0?w===T||d(w,T,l,c,u):O)){k=!1;break}_||(_=v=="constructor")}if(k&&!_){var D=a.constructor,N=i.constructor;D!=N&&"constructor"in a&&"constructor"in i&&!(typeof D=="function"&&D instanceof D&&typeof N=="function"&&N instanceof N)&&(k=!1)}return u.delete(a),u.delete(i),k}return ta=s,ta}var ra,vu;function uy(){if(vu)return ra;vu=1;var e=Gt(),t=hu(),r=cy(),n=dy(),s=pt(),a=Ne(),i=ft(),l=Rt(),c=1,d="[object Arguments]",u="[object Array]",f="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(g,x,v,y,b,k){var _=a(g),w=a(x),T=_?u:s(g),O=w?u:s(x);T=T==d?f:T,O=O==d?f:O;var D=T==f,N=O==f,S=T==O;if(S&&i(g)){if(!i(x))return!1;_=!0,D=!1}if(S&&!D)return k||(k=new e),_||l(g)?t(g,x,v,y,b,k):r(g,x,T,v,y,b,k);if(!(v&c)){var R=D&&p.call(g,"__wrapped__"),j=N&&p.call(x,"__wrapped__");if(R||j){var E=R?g.value():g,q=j?x.value():x;return k||(k=new e),b(E,q,v,y,k)}}return S?(k||(k=new e),n(g,x,v,y,b,k)):!1}return ra=m,ra}var na,bu;function ku(){if(bu)return na;bu=1;var e=uy(),t=Ke();function r(n,s,a,i,l){return n===s?!0:n==null||s==null||!t(n)&&!t(s)?n!==n&&s!==s:e(n,s,a,i,r,l)}return na=r,na}var sa,Su;function fy(){if(Su)return sa;Su=1;var e=Gt(),t=ku(),r=1,n=2;function s(a,i,l,c){var d=l.length,u=d,f=!c;if(a==null)return!u;for(a=Object(a);d--;){var h=l[d];if(f&&h[2]?h[1]!==a[h[0]]:!(h[0]in a))return!1}for(;++d<u;){h=l[d];var p=h[0],m=a[p],g=h[1];if(f&&h[2]){if(m===void 0&&!(p in a))return!1}else{var x=new e;if(c)var v=c(m,g,p,a,i,x);if(!(v===void 0?t(g,m,r|n,c,x):v))return!1}}return!0}return sa=s,sa}var aa,_u;function wu(){if(_u)return aa;_u=1;var e=qe();function t(r){return r===r&&!e(r)}return aa=t,aa}var oa,Tu;function py(){if(Tu)return oa;Tu=1;var e=wu(),t=Ze();function r(n){for(var s=t(n),a=s.length;a--;){var i=s[a],l=n[i];s[a]=[i,l,e(l)]}return s}return oa=r,oa}var ia,Eu;function Nu(){if(Eu)return ia;Eu=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return ia=e,ia}var la,ju;function hy(){if(ju)return la;ju=1;var e=fy(),t=py(),r=Nu();function n(s){var a=t(s);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(i){return i===s||e(i,s,a)}}return la=n,la}var ca,Cu;function ht(){if(Cu)return ca;Cu=1;var e=nt(),t=Ke(),r="[object Symbol]";function n(s){return typeof s=="symbol"||t(s)&&e(s)==r}return ca=n,ca}var da,Iu;function ua(){if(Iu)return da;Iu=1;var e=Ne(),t=ht(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(a,i){if(e(a))return!1;var l=typeof a;return l=="number"||l=="symbol"||l=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||i!=null&&a in Object(i)}return da=s,da}var fa,Ru;function my(){if(Ru)return fa;Ru=1;var e=hn(),t="Expected a function";function r(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var a=function(){var i=arguments,l=s?s.apply(this,i):i[0],c=a.cache;if(c.has(l))return c.get(l);var d=n.apply(this,i);return a.cache=c.set(l,d)||c,d};return a.cache=new(r.Cache||e),a}return r.Cache=e,fa=r,fa}var pa,Ou;function gy(){if(Ou)return pa;Ou=1;var e=my(),t=500;function r(n){var s=e(n,function(i){return a.size===t&&a.clear(),i}),a=s.cache;return s}return pa=r,pa}var ha,Pu;function yy(){if(Pu)return ha;Pu=1;var e=gy(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(t,function(i,l,c,d){a.push(c?d.replace(r,"$1"):l||i)}),a});return ha=n,ha}var ma,Au;function rr(){if(Au)return ma;Au=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=Array(s);++n<s;)a[n]=r(t[n],n,t);return a}return ma=e,ma}var ga,Lu;function xy(){if(Lu)return ga;Lu=1;var e=ut(),t=rr(),r=Ne(),n=ht(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function i(l){if(typeof l=="string")return l;if(r(l))return t(l,i)+"";if(n(l))return a?a.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return ga=i,ga}var ya,Du;function Mu(){if(Du)return ya;Du=1;var e=xy();function t(r){return r==null?"":e(r)}return ya=t,ya}var xa,qu;function nr(){if(qu)return xa;qu=1;var e=Ne(),t=ua(),r=yy(),n=Mu();function s(a,i){return e(a)?a:t(a,i)?[a]:r(n(a))}return xa=s,xa}var va,$u;function Pt(){if($u)return va;$u=1;var e=ht();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return va=t,va}var ba,Wu;function sr(){if(Wu)return ba;Wu=1;var e=nr(),t=Pt();function r(n,s){s=e(s,n);for(var a=0,i=s.length;n!=null&&a<i;)n=n[t(s[a++])];return a&&a==i?n:void 0}return ba=r,ba}var ka,Fu;function vy(){if(Fu)return ka;Fu=1;var e=sr();function t(r,n,s){var a=r==null?void 0:e(r,n);return a===void 0?s:a}return ka=t,ka}var Sa,Bu;function by(){if(Bu)return Sa;Bu=1;function e(t,r){return t!=null&&r in Object(t)}return Sa=e,Sa}var _a,zu;function Hu(){if(zu)return _a;zu=1;var e=nr(),t=jt(),r=Ne(),n=Xt(),s=Rn(),a=Pt();function i(l,c,d){c=e(c,l);for(var u=-1,f=c.length,h=!1;++u<f;){var p=a(c[u]);if(!(h=l!=null&&d(l,p)))break;l=l[p]}return h||++u!=f?h:(f=l==null?0:l.length,!!f&&s(f)&&n(p,f)&&(r(l)||t(l)))}return _a=i,_a}var wa,Ju;function Uu(){if(Ju)return wa;Ju=1;var e=by(),t=Hu();function r(n,s){return n!=null&&t(n,s,e)}return wa=r,wa}var Ta,Ku;function ky(){if(Ku)return Ta;Ku=1;var e=ku(),t=vy(),r=Uu(),n=ua(),s=wu(),a=Nu(),i=Pt(),l=1,c=2;function d(u,f){return n(u)&&s(f)?a(i(u),f):function(h){var p=t(h,u);return p===void 0&&p===f?r(h,u):e(f,p,l|c)}}return Ta=d,Ta}var Ea,Gu;function Vu(){if(Gu)return Ea;Gu=1;function e(t){return function(r){return r?.[t]}}return Ea=e,Ea}var Na,Yu;function Sy(){if(Yu)return Na;Yu=1;var e=sr();function t(r){return function(n){return e(n,r)}}return Na=t,Na}var ja,Xu;function _y(){if(Xu)return ja;Xu=1;var e=Vu(),t=Sy(),r=ua(),n=Pt();function s(a){return r(a)?e(n(a)):t(a)}return ja=s,ja}var Ca,Qu;function Ye(){if(Qu)return Ca;Qu=1;var e=hy(),t=ky(),r=ot(),n=Ne(),s=_y();function a(i){return typeof i=="function"?i:i==null?r:typeof i=="object"?n(i)?t(i[0],i[1]):e(i):s(i)}return Ca=a,Ca}var Ia,Zu;function ef(){if(Zu)return Ia;Zu=1;var e=sd(),t=sy(),r=Ye(),n=Ne();function s(a,i){var l=n(a)?e:t;return l(a,r(i,3))}return Ia=s,Ia}var Ra,tf;function wy(){if(tf)return Ra;tf=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,s){return n!=null&&t.call(n,s)}return Ra=r,Ra}var Oa,rf;function nf(){if(rf)return Oa;rf=1;var e=wy(),t=Hu();function r(n,s){return n!=null&&t(n,s,e)}return Oa=r,Oa}var Pa,sf;function Ty(){if(sf)return Pa;sf=1;var e=Fn(),t=pt(),r=jt(),n=Ne(),s=Ve(),a=ft(),i=Zt(),l=Rt(),c="[object Map]",d="[object Set]",u=Object.prototype,f=u.hasOwnProperty;function h(p){if(p==null)return!0;if(s(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||a(p)||l(p)||r(p)))return!p.length;var m=t(p);if(m==c||m==d)return!p.size;if(i(p))return!e(p).length;for(var g in p)if(f.call(p,g))return!1;return!0}return Pa=h,Pa}var Aa,af;function of(){if(af)return Aa;af=1;function e(t){return t===void 0}return Aa=e,Aa}var La,lf;function cf(){if(lf)return La;lf=1;var e=tr(),t=Ve();function r(n,s){var a=-1,i=t(n)?Array(n.length):[];return e(n,function(l,c,d){i[++a]=s(l,c,d)}),i}return La=r,La}var Da,df;function uf(){if(df)return Da;df=1;var e=rr(),t=Ye(),r=cf(),n=Ne();function s(a,i){var l=n(a)?e:r;return l(a,t(i,3))}return Da=s,Da}var Ma,ff;function Ey(){if(ff)return Ma;ff=1;function e(t,r,n,s){var a=-1,i=t==null?0:t.length;for(s&&i&&(n=t[++a]);++a<i;)n=r(n,t[a],a,t);return n}return Ma=e,Ma}var qa,pf;function Ny(){if(pf)return qa;pf=1;function e(t,r,n,s,a){return a(t,function(i,l,c){n=s?(s=!1,i):r(n,i,l,c)}),n}return qa=e,qa}var $a,hf;function mf(){if(hf)return $a;hf=1;var e=Ey(),t=tr(),r=Ye(),n=Ny(),s=Ne();function a(i,l,c){var d=s(i)?e:n,u=arguments.length<3;return d(i,r(l,4),c,u,t)}return $a=a,$a}var Wa,gf;function jy(){if(gf)return Wa;gf=1;var e=nt(),t=Ne(),r=Ke(),n="[object String]";function s(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return Wa=s,Wa}var Fa,yf;function Cy(){if(yf)return Fa;yf=1;var e=Vu(),t=e("length");return Fa=t,Fa}var Ba,xf;function Iy(){if(xf)return Ba;xf=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="\\u200d",l=RegExp("["+i+e+s+a+"]");function c(d){return l.test(d)}return Ba=c,Ba}var za,vf;function Ry(){if(vf)return za;vf=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="["+e+"]",l="["+s+"]",c="\\ud83c[\\udffb-\\udfff]",d="(?:"+l+"|"+c+")",u="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",m=d+"?",g="["+a+"]?",x="(?:"+p+"(?:"+[u,f,h].join("|")+")"+g+m+")*",v=g+m+x,y="(?:"+[u+l+"?",l,f,h,i].join("|")+")",b=RegExp(c+"(?="+c+")|"+y+v,"g");function k(_){for(var w=b.lastIndex=0;b.test(_);)++w;return w}return za=k,za}var Ha,bf;function Oy(){if(bf)return Ha;bf=1;var e=Cy(),t=Iy(),r=Ry();function n(s){return t(s)?r(s):e(s)}return Ha=n,Ha}var Ja,kf;function Py(){if(kf)return Ja;kf=1;var e=Fn(),t=pt(),r=Ve(),n=jy(),s=Oy(),a="[object Map]",i="[object Set]";function l(c){if(c==null)return 0;if(r(c))return n(c)?s(c):c.length;var d=t(c);return d==a||d==i?c.size:e(c).length}return Ja=l,Ja}var Ua,Sf;function Ay(){if(Sf)return Ua;Sf=1;var e=xn(),t=Dd(),r=Ms(),n=Ye(),s=er(),a=Ne(),i=ft(),l=Et(),c=qe(),d=Rt();function u(f,h,p){var m=a(f),g=m||i(f)||d(f);if(h=n(h,4),p==null){var x=f&&f.constructor;g?p=m?new x:[]:c(f)?p=l(x)?t(s(f)):{}:p={}}return(g?e:r)(f,function(v,y,b){return h(p,v,y,b)}),p}return Ua=u,Ua}var Ka,_f;function Ly(){if(_f)return Ka;_f=1;var e=ut(),t=jt(),r=Ne(),n=e?e.isConcatSpreadable:void 0;function s(a){return r(a)||t(a)||!!(n&&a&&a[n])}return Ka=s,Ka}var Ga,wf;function Va(){if(wf)return Ga;wf=1;var e=rs(),t=Ly();function r(n,s,a,i,l){var c=-1,d=n.length;for(a||(a=t),l||(l=[]);++c<d;){var u=n[c];s>0&&a(u)?s>1?r(u,s-1,a,i,l):e(l,u):i||(l[l.length]=u)}return l}return Ga=r,Ga}var Ya,Tf;function Dy(){if(Tf)return Ya;Tf=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return Ya=e,Ya}var Xa,Ef;function Nf(){if(Ef)return Xa;Ef=1;var e=Dy(),t=Math.max;function r(n,s,a){return s=t(s===void 0?n.length-1:s,0),function(){for(var i=arguments,l=-1,c=t(i.length-s,0),d=Array(c);++l<c;)d[l]=i[s+l];l=-1;for(var u=Array(s+1);++l<s;)u[l]=i[l];return u[s]=a(d),e(n,this,u)}}return Xa=r,Xa}var Qa,jf;function My(){if(jf)return Qa;jf=1;var e=Os(),t=Sc(),r=ot(),n=t?function(s,a){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return Qa=n,Qa}var Za,Cf;function qy(){if(Cf)return Za;Cf=1;var e=800,t=16,r=Date.now;function n(s){var a=0,i=0;return function(){var l=r(),c=t-(l-i);if(i=l,c>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Za=n,Za}var eo,If;function Rf(){if(If)return eo;If=1;var e=My(),t=qy(),r=t(e);return eo=r,eo}var to,Of;function ar(){if(Of)return to;Of=1;var e=ot(),t=Nf(),r=Rf();function n(s,a){return r(t(s,a,e),s+"")}return to=n,to}var ro,Pf;function Af(){if(Pf)return ro;Pf=1;function e(t,r,n,s){for(var a=t.length,i=n+(s?1:-1);s?i--:++i<a;)if(r(t[i],i,t))return i;return-1}return ro=e,ro}var no,Lf;function $y(){if(Lf)return no;Lf=1;function e(t){return t!==t}return no=e,no}var so,Df;function Wy(){if(Df)return so;Df=1;function e(t,r,n){for(var s=n-1,a=t.length;++s<a;)if(t[s]===r)return s;return-1}return so=e,so}var ao,Mf;function Fy(){if(Mf)return ao;Mf=1;var e=Af(),t=$y(),r=Wy();function n(s,a,i){return a===a?r(s,a,i):e(s,t,i)}return ao=n,ao}var oo,qf;function By(){if(qf)return oo;qf=1;var e=Fy();function t(r,n){var s=r==null?0:r.length;return!!s&&e(r,n,0)>-1}return oo=t,oo}var io,$f;function zy(){if($f)return io;$f=1;function e(t,r,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(r,t[s]))return!0;return!1}return io=e,io}var lo,Wf;function Hy(){if(Wf)return lo;Wf=1;function e(){}return lo=e,lo}var co,Ff;function Jy(){if(Ff)return co;Ff=1;var e=Sd(),t=Hy(),r=Zs(),n=1/0,s=e&&1/r(new e([,-0]))[1]==n?function(a){return new e(a)}:t;return co=s,co}var uo,Bf;function Uy(){if(Bf)return uo;Bf=1;var e=cu(),t=By(),r=zy(),n=fu(),s=Jy(),a=Zs(),i=200;function l(c,d,u){var f=-1,h=t,p=c.length,m=!0,g=[],x=g;if(u)m=!1,h=r;else if(p>=i){var v=d?null:s(c);if(v)return a(v);m=!1,h=n,x=new e}else x=d?[]:g;e:for(;++f<p;){var y=c[f],b=d?d(y):y;if(y=u||y!==0?y:0,m&&b===b){for(var k=x.length;k--;)if(x[k]===b)continue e;d&&x.push(b),g.push(y)}else h(x,b,u)||(x!==g&&x.push(b),g.push(y))}return g}return uo=l,uo}var fo,zf;function Hf(){if(zf)return fo;zf=1;var e=Ve(),t=Ke();function r(n){return t(n)&&e(n)}return fo=r,fo}var po,Jf;function Ky(){if(Jf)return po;Jf=1;var e=Va(),t=ar(),r=Uy(),n=Hf(),s=t(function(a){return r(e(a,1,n,!0))});return po=s,po}var ho,Uf;function Gy(){if(Uf)return ho;Uf=1;var e=rr();function t(r,n){return e(n,function(s){return r[s]})}return ho=t,ho}var mo,Kf;function Gf(){if(Kf)return mo;Kf=1;var e=Gy(),t=Ze();function r(n){return n==null?[]:e(n,t(n))}return mo=r,mo}var go,Vf;function $e(){if(Vf)return go;Vf=1;var e;if(typeof _r=="function")try{e={clone:ty(),constant:Os(),each:su(),filter:ef(),has:nf(),isArray:Ne(),isEmpty:Ty(),isFunction:Et(),isUndefined:of(),keys:Ze(),map:uf(),reduce:mf(),size:Py(),transform:Ay(),union:Ky(),values:Gf()}}catch{}return e||(e=window._),go=e,go}var yo,Yf;function xo(){if(Yf)return yo;Yf=1;var e=$e();yo=s;var t="\0",r="\0",n="";function s(u){this._isDirected=e.has(u,"directed")?u.directed:!0,this._isMultigraph=e.has(u,"multigraph")?u.multigraph:!1,this._isCompound=e.has(u,"compound")?u.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(u){return this._label=u,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultNodeLabelFn=u,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._in[f])})},s.prototype.sinks=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._out[f])})},s.prototype.setNodes=function(u,f){var h=arguments,p=this;return e.each(u,function(m){h.length>1?p.setNode(m,f):p.setNode(m)}),this},s.prototype.setNode=function(u,f){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=f),this):(this._nodes[u]=arguments.length>1?f:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=r,this._children[u]={},this._children[r][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},s.prototype.node=function(u){return this._nodes[u]},s.prototype.hasNode=function(u){return e.has(this._nodes,u)},s.prototype.removeNode=function(u){var f=this;if(e.has(this._nodes,u)){var h=function(p){f.removeEdge(f._edgeObjs[p])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(p){f.setParent(p)}),delete this._children[u]),e.each(e.keys(this._in[u]),h),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},s.prototype.setParent=function(u,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=r;else{f+="";for(var h=f;!e.isUndefined(h);h=this.parent(h))if(h===u)throw new Error("Setting "+f+" as parent of "+u+" would create a cycle");this.setNode(f)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=f,this._children[f][u]=!0,this},s.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},s.prototype.parent=function(u){if(this._isCompound){var f=this._parent[u];if(f!==r)return f}},s.prototype.children=function(u){if(e.isUndefined(u)&&(u=r),this._isCompound){var f=this._children[u];if(f)return e.keys(f)}else{if(u===r)return this.nodes();if(this.hasNode(u))return[]}},s.prototype.predecessors=function(u){var f=this._preds[u];if(f)return e.keys(f)},s.prototype.successors=function(u){var f=this._sucs[u];if(f)return e.keys(f)},s.prototype.neighbors=function(u){var f=this.predecessors(u);if(f)return e.union(f,this.successors(u))},s.prototype.isLeaf=function(u){var f;return this.isDirected()?f=this.successors(u):f=this.neighbors(u),f.length===0},s.prototype.filterNodes=function(u){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var h=this;e.each(this._nodes,function(g,x){u(x)&&f.setNode(x,g)}),e.each(this._edgeObjs,function(g){f.hasNode(g.v)&&f.hasNode(g.w)&&f.setEdge(g,h.edge(g))});var p={};function m(g){var x=h.parent(g);return x===void 0||f.hasNode(x)?(p[g]=x,x):x in p?p[x]:m(x)}return this._isCompound&&e.each(f.nodes(),function(g){f.setParent(g,m(g))}),f},s.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(u,f){var h=this,p=arguments;return e.reduce(u,function(m,g){return p.length>1?h.setEdge(m,g,f):h.setEdge(m,g),g}),this},s.prototype.setEdge=function(){var u,f,h,p,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(u=g.v,f=g.w,h=g.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=g,f=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,f=""+f,e.isUndefined(h)||(h=""+h);var x=l(this._isDirected,u,f,h);if(e.has(this._edgeLabels,x))return m&&(this._edgeLabels[x]=p),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(f),this._edgeLabels[x]=m?p:this._defaultEdgeLabelFn(u,f,h);var v=c(this._isDirected,u,f,h);return u=v.v,f=v.w,Object.freeze(v),this._edgeObjs[x]=v,a(this._preds[f],u),a(this._sucs[u],f),this._in[f][x]=v,this._out[u][x]=v,this._edgeCount++,this},s.prototype.edge=function(u,f,h){var p=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,f,h);return this._edgeLabels[p]},s.prototype.hasEdge=function(u,f,h){var p=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,f,h);return e.has(this._edgeLabels,p)},s.prototype.removeEdge=function(u,f,h){var p=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,f,h),m=this._edgeObjs[p];return m&&(u=m.v,f=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[f],u),i(this._sucs[u],f),delete this._in[f][p],delete this._out[u][p],this._edgeCount--),this},s.prototype.inEdges=function(u,f){var h=this._in[u];if(h){var p=e.values(h);return f?e.filter(p,function(m){return m.v===f}):p}},s.prototype.outEdges=function(u,f){var h=this._out[u];if(h){var p=e.values(h);return f?e.filter(p,function(m){return m.w===f}):p}},s.prototype.nodeEdges=function(u,f){var h=this.inEdges(u,f);if(h)return h.concat(this.outEdges(u,f))};function a(u,f){u[f]?u[f]++:u[f]=1}function i(u,f){--u[f]||delete u[f]}function l(u,f,h,p){var m=""+f,g=""+h;if(!u&&m>g){var x=m;m=g,g=x}return m+n+g+n+(e.isUndefined(p)?t:p)}function c(u,f,h,p){var m=""+f,g=""+h;if(!u&&m>g){var x=m;m=g,g=x}var v={v:m,w:g};return p&&(v.name=p),v}function d(u,f){return l(u,f.v,f.w,f.name)}return yo}var vo,Xf;function Vy(){return Xf||(Xf=1,vo="2.1.8"),vo}var bo,Qf;function Yy(){return Qf||(Qf=1,bo={Graph:xo(),version:Vy()}),bo}var ko,Zf;function Xy(){if(Zf)return ko;Zf=1;var e=$e(),t=xo();ko={write:r,read:a};function r(i){var l={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:s(i)};return e.isUndefined(i.graph())||(l.value=e.clone(i.graph())),l}function n(i){return e.map(i.nodes(),function(l){var c=i.node(l),d=i.parent(l),u={v:l};return e.isUndefined(c)||(u.value=c),e.isUndefined(d)||(u.parent=d),u})}function s(i){return e.map(i.edges(),function(l){var c=i.edge(l),d={v:l.v,w:l.w};return e.isUndefined(l.name)||(d.name=l.name),e.isUndefined(c)||(d.value=c),d})}function a(i){var l=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(c){l.setNode(c.v,c.value),c.parent&&l.setParent(c.v,c.parent)}),e.each(i.edges,function(c){l.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),l}return ko}var So,ep;function Qy(){if(ep)return So;ep=1;var e=$e();So=t;function t(r){var n={},s=[],a;function i(l){e.has(n,l)||(n[l]=!0,a.push(l),e.each(r.successors(l),i),e.each(r.predecessors(l),i))}return e.each(r.nodes(),function(l){a=[],i(l),a.length&&s.push(a)}),s}return So}var _o,tp;function rp(){if(tp)return _o;tp=1;var e=$e();_o=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var s=this._keyIndices;if(r=String(r),!e.has(s,r)){var a=this._arr,i=a.length;return s[r]=i,a.push({key:r,priority:n}),this._decrease(i),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var s=this._keyIndices[r];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},t.prototype._heapify=function(r){var n=this._arr,s=2*r,a=s+1,i=r;s<n.length&&(i=n[s].priority<n[i].priority?s:i,a<n.length&&(i=n[a].priority<n[i].priority?a:i),i!==r&&(this._swap(r,i),this._heapify(i)))},t.prototype._decrease=function(r){for(var n=this._arr,s=n[r].priority,a;r!==0&&(a=r>>1,!(n[a].priority<s));)this._swap(r,a),r=a},t.prototype._swap=function(r,n){var s=this._arr,a=this._keyIndices,i=s[r],l=s[n];s[r]=l,s[n]=i,a[l.key]=r,a[i.key]=n},_o}var wo,np;function sp(){if(np)return wo;np=1;var e=$e(),t=rp();wo=n;var r=e.constant(1);function n(a,i,l,c){return s(a,String(i),l||r,c||function(d){return a.outEdges(d)})}function s(a,i,l,c){var d={},u=new t,f,h,p=function(m){var g=m.v!==f?m.v:m.w,x=d[g],v=l(m),y=h.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+v);y<x.distance&&(x.distance=y,x.predecessor=f,u.decrease(g,y))};for(a.nodes().forEach(function(m){var g=m===i?0:Number.POSITIVE_INFINITY;d[m]={distance:g},u.add(m,g)});u.size()>0&&(f=u.removeMin(),h=d[f],h.distance!==Number.POSITIVE_INFINITY);)c(f).forEach(p);return d}return wo}var To,ap;function Zy(){if(ap)return To;ap=1;var e=sp(),t=$e();To=r;function r(n,s,a){return t.transform(n.nodes(),function(i,l){i[l]=e(n,l,s,a)},{})}return To}var Eo,op;function ip(){if(op)return Eo;op=1;var e=$e();Eo=t;function t(r){var n=0,s=[],a={},i=[];function l(c){var d=a[c]={onStack:!0,lowlink:n,index:n++};if(s.push(c),r.successors(c).forEach(function(h){e.has(a,h)?a[h].onStack&&(d.lowlink=Math.min(d.lowlink,a[h].index)):(l(h),d.lowlink=Math.min(d.lowlink,a[h].lowlink))}),d.lowlink===d.index){var u=[],f;do f=s.pop(),a[f].onStack=!1,u.push(f);while(c!==f);i.push(u)}}return r.nodes().forEach(function(c){e.has(a,c)||l(c)}),i}return Eo}var No,lp;function ex(){if(lp)return No;lp=1;var e=$e(),t=ip();No=r;function r(n){return e.filter(t(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return No}var jo,cp;function tx(){if(cp)return jo;cp=1;var e=$e();jo=r;var t=e.constant(1);function r(s,a,i){return n(s,a||t,i||function(l){return s.outEdges(l)})}function n(s,a,i){var l={},c=s.nodes();return c.forEach(function(d){l[d]={},l[d][d]={distance:0},c.forEach(function(u){d!==u&&(l[d][u]={distance:Number.POSITIVE_INFINITY})}),i(d).forEach(function(u){var f=u.v===d?u.w:u.v,h=a(u);l[d][f]={distance:h,predecessor:d}})}),c.forEach(function(d){var u=l[d];c.forEach(function(f){var h=l[f];c.forEach(function(p){var m=h[d],g=u[p],x=h[p],v=m.distance+g.distance;v<x.distance&&(x.distance=v,x.predecessor=g.predecessor)})})}),l}return jo}var Co,dp;function up(){if(dp)return Co;dp=1;var e=$e();Co=t,t.CycleException=r;function t(n){var s={},a={},i=[];function l(c){if(e.has(a,c))throw new r;e.has(s,c)||(a[c]=!0,s[c]=!0,e.each(n.predecessors(c),l),delete a[c],i.push(c))}if(e.each(n.sinks(),l),e.size(s)!==n.nodeCount())throw new r;return i}function r(){}return r.prototype=new Error,Co}var Io,fp;function rx(){if(fp)return Io;fp=1;var e=up();Io=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Io}var Ro,pp;function hp(){if(pp)return Ro;pp=1;var e=$e();Ro=t;function t(n,s,a){e.isArray(s)||(s=[s]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),l=[],c={};return e.each(s,function(d){if(!n.hasNode(d))throw new Error("Graph does not have node: "+d);r(n,d,a==="post",c,i,l)}),l}function r(n,s,a,i,l,c){e.has(i,s)||(i[s]=!0,a||c.push(s),e.each(l(s),function(d){r(n,d,a,i,l,c)}),a&&c.push(s))}return Ro}var Oo,mp;function nx(){if(mp)return Oo;mp=1;var e=hp();Oo=t;function t(r,n){return e(r,n,"post")}return Oo}var Po,gp;function sx(){if(gp)return Po;gp=1;var e=hp();Po=t;function t(r,n){return e(r,n,"pre")}return Po}var Ao,yp;function ax(){if(yp)return Ao;yp=1;var e=$e(),t=xo(),r=rp();Ao=n;function n(s,a){var i=new t,l={},c=new r,d;function u(h){var p=h.v===d?h.w:h.v,m=c.priority(p);if(m!==void 0){var g=a(h);g<m&&(l[p]=d,c.decrease(p,g))}}if(s.nodeCount()===0)return i;e.each(s.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),i.setNode(h)}),c.decrease(s.nodes()[0],0);for(var f=!1;c.size()>0;){if(d=c.removeMin(),e.has(l,d))i.setEdge(d,l[d]);else{if(f)throw new Error("Input graph is not connected: "+s);f=!0}s.nodeEdges(d).forEach(u)}return i}return Ao}var Lo,xp;function ox(){return xp||(xp=1,Lo={components:Qy(),dijkstra:sp(),dijkstraAll:Zy(),findCycles:ex(),floydWarshall:tx(),isAcyclic:rx(),postorder:nx(),preorder:sx(),prim:ax(),tarjan:ip(),topsort:up()}),Lo}var Do,vp;function ix(){if(vp)return Do;vp=1;var e=Yy();return Do={Graph:e.Graph,json:Xy(),alg:ox(),version:e.version},Do}var Mo,bp;function He(){if(bp)return Mo;bp=1;var e;if(typeof _r=="function")try{e=ix()}catch{}return e||(e=window.graphlib),Mo=e,Mo}var qo,kp;function lx(){if(kp)return qo;kp=1;var e=Hd(),t=1,r=4;function n(s){return e(s,t|r)}return qo=n,qo}var $o,Sp;function or(){if(Sp)return $o;Sp=1;var e=dt(),t=Ve(),r=Xt(),n=qe();function s(a,i,l){if(!n(l))return!1;var c=typeof i;return(c=="number"?t(l)&&r(i,l.length):c=="string"&&i in l)?e(l[i],a):!1}return $o=s,$o}var Wo,_p;function cx(){if(_p)return Wo;_p=1;var e=ar(),t=dt(),r=or(),n=at(),s=Object.prototype,a=s.hasOwnProperty,i=e(function(l,c){l=Object(l);var d=-1,u=c.length,f=u>2?c[2]:void 0;for(f&&r(c[0],c[1],f)&&(u=1);++d<u;)for(var h=c[d],p=n(h),m=-1,g=p.length;++m<g;){var x=p[m],v=l[x];(v===void 0||t(v,s[x])&&!a.call(l,x))&&(l[x]=h[x])}return l});return Wo=i,Wo}var Fo,wp;function dx(){if(wp)return Fo;wp=1;var e=Ye(),t=Ve(),r=Ze();function n(s){return function(a,i,l){var c=Object(a);if(!t(a)){var d=e(i,3);a=r(a),i=function(f){return d(c[f],f,c)}}var u=s(a,i,l);return u>-1?c[d?a[u]:u]:void 0}}return Fo=n,Fo}var Bo,Tp;function ux(){if(Tp)return Bo;Tp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Bo=t,Bo}var zo,Ep;function fx(){if(Ep)return zo;Ep=1;var e=ux(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return zo=r,zo}var Ho,Np;function px(){if(Np)return Ho;Np=1;var e=fx(),t=qe(),r=ht(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=parseInt;function c(d){if(typeof d=="number")return d;if(r(d))return n;if(t(d)){var u=typeof d.valueOf=="function"?d.valueOf():d;d=t(u)?u+"":u}if(typeof d!="string")return d===0?d:+d;d=e(d);var f=a.test(d);return f||i.test(d)?l(d.slice(2),f?2:8):s.test(d)?n:+d}return Ho=c,Ho}var Jo,jp;function Cp(){if(jp)return Jo;jp=1;var e=px(),t=1/0,r=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var a=s<0?-1:1;return a*r}return s===s?s:0}return Jo=n,Jo}var Uo,Ip;function hx(){if(Ip)return Uo;Ip=1;var e=Cp();function t(r){var n=e(r),s=n%1;return n===n?s?n-s:n:0}return Uo=t,Uo}var Ko,Rp;function mx(){if(Rp)return Ko;Rp=1;var e=Af(),t=Ye(),r=hx(),n=Math.max;function s(a,i,l){var c=a==null?0:a.length;if(!c)return-1;var d=l==null?0:r(l);return d<0&&(d=n(c+d,0)),e(a,t(i,3),d)}return Ko=s,Ko}var Go,Op;function gx(){if(Op)return Go;Op=1;var e=dx(),t=mx(),r=e(t);return Go=r,Go}var Vo,Pp;function Ap(){if(Pp)return Vo;Pp=1;var e=Va();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return Vo=t,Vo}var Yo,Lp;function yx(){if(Lp)return Yo;Lp=1;var e=Ls(),t=eu(),r=at();function n(s,a){return s==null?s:e(s,t(a),r)}return Yo=n,Yo}var Xo,Dp;function xx(){if(Dp)return Xo;Dp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return Xo=e,Xo}var Qo,Mp;function vx(){if(Mp)return Qo;Mp=1;var e=Vt(),t=Ms(),r=Ye();function n(s,a){var i={};return a=r(a,3),t(s,function(l,c,d){e(i,c,a(l,c,d))}),i}return Qo=n,Qo}var Zo,qp;function ei(){if(qp)return Zo;qp=1;var e=ht();function t(r,n,s){for(var a=-1,i=r.length;++a<i;){var l=r[a],c=n(l);if(c!=null&&(d===void 0?c===c&&!e(c):s(c,d)))var d=c,u=l}return u}return Zo=t,Zo}var ti,$p;function bx(){if($p)return ti;$p=1;function e(t,r){return t>r}return ti=e,ti}var ri,Wp;function kx(){if(Wp)return ri;Wp=1;var e=ei(),t=bx(),r=ot();function n(s){return s&&s.length?e(s,r,t):void 0}return ri=n,ri}var ni,Fp;function Bp(){if(Fp)return ni;Fp=1;var e=Vt(),t=dt();function r(n,s,a){(a!==void 0&&!t(n[s],a)||a===void 0&&!(s in n))&&e(n,s,a)}return ni=r,ni}var si,zp;function Sx(){if(zp)return si;zp=1;var e=nt(),t=er(),r=Ke(),n="[object Object]",s=Function.prototype,a=Object.prototype,i=s.toString,l=a.hasOwnProperty,c=i.call(Object);function d(u){if(!r(u)||e(u)!=n)return!1;var f=t(u);if(f===null)return!0;var h=l.call(f,"constructor")&&f.constructor;return typeof h=="function"&&h instanceof h&&i.call(h)==c}return si=d,si}var ai,Hp;function Jp(){if(Hp)return ai;Hp=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return ai=e,ai}var oi,Up;function _x(){if(Up)return oi;Up=1;var e=Nt(),t=at();function r(n){return e(n,t(n))}return oi=r,oi}var ii,Kp;function wx(){if(Kp)return ii;Kp=1;var e=Bp(),t=ed(),r=Pd(),n=rd(),s=qd(),a=jt(),i=Ne(),l=Hf(),c=ft(),d=Et(),u=qe(),f=Sx(),h=Rt(),p=Jp(),m=_x();function g(x,v,y,b,k,_,w){var T=p(x,y),O=p(v,y),D=w.get(O);if(D){e(x,y,D);return}var N=_?_(T,O,y+"",x,v,w):void 0,S=N===void 0;if(S){var R=i(O),j=!R&&c(O),E=!R&&!j&&h(O);N=O,R||j||E?i(T)?N=T:l(T)?N=n(T):j?(S=!1,N=t(O,!0)):E?(S=!1,N=r(O,!0)):N=[]:f(O)||a(O)?(N=T,a(T)?N=m(T):(!u(T)||d(T))&&(N=s(O))):S=!1}S&&(w.set(O,N),k(N,O,b,_,w),w.delete(O)),e(x,y,N)}return ii=g,ii}var li,Gp;function Tx(){if(Gp)return li;Gp=1;var e=Gt(),t=Bp(),r=Ls(),n=wx(),s=qe(),a=at(),i=Jp();function l(c,d,u,f,h){c!==d&&r(d,function(p,m){if(h||(h=new e),s(p))n(c,d,m,u,l,f,h);else{var g=f?f(i(c,m),p,m+"",c,d,h):void 0;g===void 0&&(g=p),t(c,m,g)}},a)}return li=l,li}var ci,Vp;function Ex(){if(Vp)return ci;Vp=1;var e=ar(),t=or();function r(n){return e(function(s,a){var i=-1,l=a.length,c=l>1?a[l-1]:void 0,d=l>2?a[2]:void 0;for(c=n.length>3&&typeof c=="function"?(l--,c):void 0,d&&t(a[0],a[1],d)&&(c=l<3?void 0:c,l=1),s=Object(s);++i<l;){var u=a[i];u&&n(s,u,i,c)}return s})}return ci=r,ci}var di,Yp;function Nx(){if(Yp)return di;Yp=1;var e=Tx(),t=Ex(),r=t(function(n,s,a){e(n,s,a)});return di=r,di}var ui,Xp;function Qp(){if(Xp)return ui;Xp=1;function e(t,r){return t<r}return ui=e,ui}var fi,Zp;function jx(){if(Zp)return fi;Zp=1;var e=ei(),t=Qp(),r=ot();function n(s){return s&&s.length?e(s,r,t):void 0}return fi=n,fi}var pi,eh;function Cx(){if(eh)return pi;eh=1;var e=ei(),t=Ye(),r=Qp();function n(s,a){return s&&s.length?e(s,t(a,2),r):void 0}return pi=n,pi}var hi,th;function Ix(){if(th)return hi;th=1;var e=ze(),t=function(){return e.Date.now()};return hi=t,hi}var mi,rh;function Rx(){if(rh)return mi;rh=1;var e=Yt(),t=nr(),r=Xt(),n=qe(),s=Pt();function a(i,l,c,d){if(!n(i))return i;l=t(l,i);for(var u=-1,f=l.length,h=f-1,p=i;p!=null&&++u<f;){var m=s(l[u]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return i;if(u!=h){var x=p[m];g=d?d(x,m,p):void 0,g===void 0&&(g=n(x)?x:r(l[u+1])?[]:{})}e(p,m,g),p=p[m]}return i}return mi=a,mi}var gi,nh;function Ox(){if(nh)return gi;nh=1;var e=sr(),t=Rx(),r=nr();function n(s,a,i){for(var l=-1,c=a.length,d={};++l<c;){var u=a[l],f=e(s,u);i(f,u)&&t(d,r(u,s),f)}return d}return gi=n,gi}var yi,sh;function Px(){if(sh)return yi;sh=1;var e=Ox(),t=Uu();function r(n,s){return e(n,s,function(a,i){return t(n,i)})}return yi=r,yi}var xi,ah;function Ax(){if(ah)return xi;ah=1;var e=Ap(),t=Nf(),r=Rf();function n(s){return r(t(s,void 0,e),s+"")}return xi=n,xi}var vi,oh;function Lx(){if(oh)return vi;oh=1;var e=Px(),t=Ax(),r=t(function(n,s){return n==null?{}:e(n,s)});return vi=r,vi}var bi,ih;function Dx(){if(ih)return bi;ih=1;var e=Math.ceil,t=Math.max;function r(n,s,a,i){for(var l=-1,c=t(e((s-n)/(a||1)),0),d=Array(c);c--;)d[i?c:++l]=n,n+=a;return d}return bi=r,bi}var ki,lh;function Mx(){if(lh)return ki;lh=1;var e=Dx(),t=or(),r=Cp();function n(s){return function(a,i,l){return l&&typeof l!="number"&&t(a,i,l)&&(i=l=void 0),a=r(a),i===void 0?(i=a,a=0):i=r(i),l=l===void 0?a<i?1:-1:r(l),e(a,i,l,s)}}return ki=n,ki}var Si,ch;function qx(){if(ch)return Si;ch=1;var e=Mx(),t=e();return Si=t,Si}var _i,dh;function $x(){if(dh)return _i;dh=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return _i=e,_i}var wi,uh;function Wx(){if(uh)return wi;uh=1;var e=ht();function t(r,n){if(r!==n){var s=r!==void 0,a=r===null,i=r===r,l=e(r),c=n!==void 0,d=n===null,u=n===n,f=e(n);if(!d&&!f&&!l&&r>n||l&&c&&u&&!d&&!f||a&&c&&u||!s&&u||!i)return 1;if(!a&&!l&&!f&&r<n||f&&s&&i&&!a&&!l||d&&s&&i||!c&&i||!u)return-1}return 0}return wi=t,wi}var Ti,fh;function Fx(){if(fh)return Ti;fh=1;var e=Wx();function t(r,n,s){for(var a=-1,i=r.criteria,l=n.criteria,c=i.length,d=s.length;++a<c;){var u=e(i[a],l[a]);if(u){if(a>=d)return u;var f=s[a];return u*(f=="desc"?-1:1)}}return r.index-n.index}return Ti=t,Ti}var Ei,ph;function Bx(){if(ph)return Ei;ph=1;var e=rr(),t=sr(),r=Ye(),n=cf(),s=$x(),a=Qt(),i=Fx(),l=ot(),c=Ne();function d(u,f,h){f.length?f=e(f,function(g){return c(g)?function(x){return t(x,g.length===1?g[0]:g)}:g}):f=[l];var p=-1;f=e(f,a(r));var m=n(u,function(g,x,v){var y=e(f,function(b){return b(g)});return{criteria:y,index:++p,value:g}});return s(m,function(g,x){return i(g,x,h)})}return Ei=d,Ei}var Ni,hh;function zx(){if(hh)return Ni;hh=1;var e=Va(),t=Bx(),r=ar(),n=or(),s=r(function(a,i){if(a==null)return[];var l=i.length;return l>1&&n(a,i[0],i[1])?i=[]:l>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(a,e(i,1),[])});return Ni=s,Ni}var ji,mh;function Hx(){if(mh)return ji;mh=1;var e=Mu(),t=0;function r(n){var s=++t;return e(n)+s}return ji=r,ji}var Ci,gh;function Jx(){if(gh)return Ci;gh=1;function e(t,r,n){for(var s=-1,a=t.length,i=r.length,l={};++s<a;){var c=s<i?r[s]:void 0;n(l,t[s],c)}return l}return Ci=e,Ci}var Ii,yh;function Ux(){if(yh)return Ii;yh=1;var e=Yt(),t=Jx();function r(n,s){return t(n||[],s||[],e)}return Ii=r,Ii}var Ri,xh;function we(){if(xh)return Ri;xh=1;var e;if(typeof _r=="function")try{e={cloneDeep:lx(),constant:Os(),defaults:cx(),each:su(),filter:ef(),find:gx(),flatten:Ap(),forEach:ru(),forIn:yx(),has:nf(),isUndefined:of(),last:xx(),map:uf(),mapValues:vx(),max:kx(),merge:Nx(),min:jx(),minBy:Cx(),now:Ix(),pick:Lx(),range:qx(),reduce:mf(),sortBy:zx(),uniqueId:Hx(),values:Gf(),zipObject:Ux()}}catch{}return e||(e=window._),Ri=e,Ri}var Oi,vh;function Kx(){if(vh)return Oi;vh=1,Oi=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return t(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&t(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,a=s._prev;a!==s;)n.push(JSON.stringify(a,r)),a=a._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,s){if(n!=="_next"&&n!=="_prev")return s}return Oi}var Pi,bh;function Gx(){if(bh)return Pi;bh=1;var e=we(),t=He().Graph,r=Kx();Pi=s;var n=e.constant(1);function s(d,u){if(d.nodeCount()<=1)return[];var f=l(d,u||n),h=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(h,function(p){return d.outEdges(p.v,p.w)}),!0)}function a(d,u,f){for(var h=[],p=u[u.length-1],m=u[0],g;d.nodeCount();){for(;g=m.dequeue();)i(d,u,f,g);for(;g=p.dequeue();)i(d,u,f,g);if(d.nodeCount()){for(var x=u.length-2;x>0;--x)if(g=u[x].dequeue(),g){h=h.concat(i(d,u,f,g,!0));break}}}return h}function i(d,u,f,h,p){var m=p?[]:void 0;return e.forEach(d.inEdges(h.v),function(g){var x=d.edge(g),v=d.node(g.v);p&&m.push({v:g.v,w:g.w}),v.out-=x,c(u,f,v)}),e.forEach(d.outEdges(h.v),function(g){var x=d.edge(g),v=g.w,y=d.node(v);y.in-=x,c(u,f,y)}),d.removeNode(h.v),m}function l(d,u){var f=new t,h=0,p=0;e.forEach(d.nodes(),function(x){f.setNode(x,{v:x,in:0,out:0})}),e.forEach(d.edges(),function(x){var v=f.edge(x.v,x.w)||0,y=u(x),b=v+y;f.setEdge(x.v,x.w,b),p=Math.max(p,f.node(x.v).out+=y),h=Math.max(h,f.node(x.w).in+=y)});var m=e.range(p+h+3).map(function(){return new r}),g=h+1;return e.forEach(f.nodes(),function(x){c(m,g,f.node(x))}),{graph:f,buckets:m,zeroIdx:g}}function c(d,u,f){f.out?f.in?d[f.out-f.in+u].enqueue(f):d[d.length-1].enqueue(f):d[0].enqueue(f)}return Pi}var Ai,kh;function Vx(){if(kh)return Ai;kh=1;var e=we(),t=Gx();Ai={run:r,undo:s};function r(a){var i=a.graph().acyclicer==="greedy"?t(a,l(a)):n(a);e.forEach(i,function(c){var d=a.edge(c);a.removeEdge(c),d.forwardName=c.name,d.reversed=!0,a.setEdge(c.w,c.v,d,e.uniqueId("rev"))});function l(c){return function(d){return c.edge(d).weight}}}function n(a){var i=[],l={},c={};function d(u){e.has(c,u)||(c[u]=!0,l[u]=!0,e.forEach(a.outEdges(u),function(f){e.has(l,f.w)?i.push(f):d(f.w)}),delete l[u])}return e.forEach(a.nodes(),d),i}function s(a){e.forEach(a.edges(),function(i){var l=a.edge(i);if(l.reversed){a.removeEdge(i);var c=l.forwardName;delete l.reversed,delete l.forwardName,a.setEdge(i.w,i.v,l,c)}})}return Ai}var Li,Sh;function De(){if(Sh)return Li;Sh=1;var e=we(),t=He().Graph;Li={addDummyNode:r,simplify:n,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:i,intersectRect:l,buildLayerMatrix:c,normalizeRanks:d,removeEmptyRanks:u,addBorderNode:f,maxRank:h,partition:p,time:m,notime:g};function r(x,v,y,b){var k;do k=e.uniqueId(b);while(x.hasNode(k));return y.dummy=v,x.setNode(k,y),k}function n(x){var v=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(y){v.setNode(y,x.node(y))}),e.forEach(x.edges(),function(y){var b=v.edge(y.v,y.w)||{weight:0,minlen:1},k=x.edge(y);v.setEdge(y.v,y.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),v}function s(x){var v=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(y){x.children(y).length||v.setNode(y,x.node(y))}),e.forEach(x.edges(),function(y){v.setEdge(y,x.edge(y))}),v}function a(x){var v=e.map(x.nodes(),function(y){var b={};return e.forEach(x.outEdges(y),function(k){b[k.w]=(b[k.w]||0)+x.edge(k).weight}),b});return e.zipObject(x.nodes(),v)}function i(x){var v=e.map(x.nodes(),function(y){var b={};return e.forEach(x.inEdges(y),function(k){b[k.v]=(b[k.v]||0)+x.edge(k).weight}),b});return e.zipObject(x.nodes(),v)}function l(x,v){var y=x.x,b=x.y,k=v.x-y,_=v.y-b,w=x.width/2,T=x.height/2;if(!k&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var O,D;return Math.abs(_)*w>Math.abs(k)*T?(_<0&&(T=-T),O=T*k/_,D=T):(k<0&&(w=-w),O=w,D=w*_/k),{x:y+O,y:b+D}}function c(x){var v=e.map(e.range(h(x)+1),function(){return[]});return e.forEach(x.nodes(),function(y){var b=x.node(y),k=b.rank;e.isUndefined(k)||(v[k][b.order]=y)}),v}function d(x){var v=e.min(e.map(x.nodes(),function(y){return x.node(y).rank}));e.forEach(x.nodes(),function(y){var b=x.node(y);e.has(b,"rank")&&(b.rank-=v)})}function u(x){var v=e.min(e.map(x.nodes(),function(_){return x.node(_).rank})),y=[];e.forEach(x.nodes(),function(_){var w=x.node(_).rank-v;y[w]||(y[w]=[]),y[w].push(_)});var b=0,k=x.graph().nodeRankFactor;e.forEach(y,function(_,w){e.isUndefined(_)&&w%k!==0?--b:b&&e.forEach(_,function(T){x.node(T).rank+=b})})}function f(x,v,y,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=y,k.order=b),r(x,"border",k,v)}function h(x){return e.max(e.map(x.nodes(),function(v){var y=x.node(v).rank;if(!e.isUndefined(y))return y}))}function p(x,v){var y={lhs:[],rhs:[]};return e.forEach(x,function(b){v(b)?y.lhs.push(b):y.rhs.push(b)}),y}function m(x,v){var y=e.now();try{return v()}finally{console.log(x+" time: "+(e.now()-y)+"ms")}}function g(x,v){return v()}return Li}var Di,_h;function Yx(){if(_h)return Di;_h=1;var e=we(),t=De();Di={run:r,undo:s};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(i){n(a,i)})}function n(a,i){var l=i.v,c=a.node(l).rank,d=i.w,u=a.node(d).rank,f=i.name,h=a.edge(i),p=h.labelRank;if(u!==c+1){a.removeEdge(i);var m,g,x;for(x=0,++c;c<u;++x,++c)h.points=[],g={width:0,height:0,edgeLabel:h,edgeObj:i,rank:c},m=t.addDummyNode(a,"edge",g,"_d"),c===p&&(g.width=h.width,g.height=h.height,g.dummy="edge-label",g.labelpos=h.labelpos),a.setEdge(l,m,{weight:h.weight},f),x===0&&a.graph().dummyChains.push(m),l=m;a.setEdge(l,d,{weight:h.weight},f)}}function s(a){e.forEach(a.graph().dummyChains,function(i){var l=a.node(i),c=l.edgeLabel,d;for(a.setEdge(l.edgeObj,c);l.dummy;)d=a.successors(i)[0],a.removeNode(i),c.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height),i=d,l=a.node(i)})}return Di}var Mi,wh;function ir(){if(wh)return Mi;wh=1;var e=we();Mi={longestPath:t,slack:r};function t(n){var s={};function a(i){var l=n.node(i);if(e.has(s,i))return l.rank;s[i]=!0;var c=e.min(e.map(n.outEdges(i),function(d){return a(d.w)-n.edge(d).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),l.rank=c}e.forEach(n.sources(),a)}function r(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return Mi}var qi,Th;function Eh(){if(Th)return qi;Th=1;var e=we(),t=He().Graph,r=ir().slack;qi=n;function n(l){var c=new t({directed:!1}),d=l.nodes()[0],u=l.nodeCount();c.setNode(d,{});for(var f,h;s(c,l)<u;)f=a(c,l),h=c.hasNode(f.v)?r(l,f):-r(l,f),i(c,l,h);return c}function s(l,c){function d(u){e.forEach(c.nodeEdges(u),function(f){var h=f.v,p=u===h?f.w:h;!l.hasNode(p)&&!r(c,f)&&(l.setNode(p,{}),l.setEdge(u,p,{}),d(p))})}return e.forEach(l.nodes(),d),l.nodeCount()}function a(l,c){return e.minBy(c.edges(),function(d){if(l.hasNode(d.v)!==l.hasNode(d.w))return r(c,d)})}function i(l,c,d){e.forEach(l.nodes(),function(u){c.node(u).rank+=d})}return qi}var $i,Nh;function Xx(){if(Nh)return $i;Nh=1;var e=we(),t=Eh(),r=ir().slack,n=ir().longestPath,s=He().alg.preorder,a=He().alg.postorder,i=De().simplify;$i=l,l.initLowLimValues=f,l.initCutValues=c,l.calcCutValue=u,l.leaveEdge=p,l.enterEdge=m,l.exchangeEdges=g;function l(b){b=i(b),n(b);var k=t(b);f(k),c(k,b);for(var _,w;_=p(k);)w=m(k,b,_),g(k,b,_,w)}function c(b,k){var _=a(b,b.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(w){d(b,k,w)})}function d(b,k,_){var w=b.node(_),T=w.parent;b.edge(_,T).cutvalue=u(b,k,_)}function u(b,k,_){var w=b.node(_),T=w.parent,O=!0,D=k.edge(_,T),N=0;return D||(O=!1,D=k.edge(T,_)),N=D.weight,e.forEach(k.nodeEdges(_),function(S){var R=S.v===_,j=R?S.w:S.v;if(j!==T){var E=R===O,q=k.edge(S).weight;if(N+=E?q:-q,v(b,_,j)){var $=b.edge(_,j).cutvalue;N+=E?-$:$}}}),N}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),h(b,{},1,k)}function h(b,k,_,w,T){var O=_,D=b.node(w);return k[w]=!0,e.forEach(b.neighbors(w),function(N){e.has(k,N)||(_=h(b,k,_,N,w))}),D.low=O,D.lim=_++,T?D.parent=T:delete D.parent,_}function p(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function m(b,k,_){var w=_.v,T=_.w;k.hasEdge(w,T)||(w=_.w,T=_.v);var O=b.node(w),D=b.node(T),N=O,S=!1;O.lim>D.lim&&(N=D,S=!0);var R=e.filter(k.edges(),function(j){return S===y(b,b.node(j.v),N)&&S!==y(b,b.node(j.w),N)});return e.minBy(R,function(j){return r(k,j)})}function g(b,k,_,w){var T=_.v,O=_.w;b.removeEdge(T,O),b.setEdge(w.v,w.w,{}),f(b),c(b,k),x(b,k)}function x(b,k){var _=e.find(b.nodes(),function(T){return!k.node(T).parent}),w=s(b,_);w=w.slice(1),e.forEach(w,function(T){var O=b.node(T).parent,D=k.edge(T,O),N=!1;D||(D=k.edge(O,T),N=!0),k.node(T).rank=k.node(O).rank+(N?D.minlen:-D.minlen)})}function v(b,k,_){return b.hasEdge(k,_)}function y(b,k,_){return _.low<=k.lim&&k.lim<=_.lim}return $i}var Wi,jh;function Qx(){if(jh)return Wi;jh=1;var e=ir(),t=e.longestPath,r=Eh(),n=Xx();Wi=s;function s(c){switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":a(c);break;default:l(c)}}var a=t;function i(c){t(c),r(c)}function l(c){n(c)}return Wi}var Fi,Ch;function Zx(){if(Ch)return Fi;Ch=1;var e=we();Fi=t;function t(s){var a=n(s);e.forEach(s.graph().dummyChains,function(i){for(var l=s.node(i),c=l.edgeObj,d=r(s,a,c.v,c.w),u=d.path,f=d.lca,h=0,p=u[h],m=!0;i!==c.w;){if(l=s.node(i),m){for(;(p=u[h])!==f&&s.node(p).maxRank<l.rank;)h++;p===f&&(m=!1)}if(!m){for(;h<u.length-1&&s.node(p=u[h+1]).minRank<=l.rank;)h++;p=u[h]}s.setParent(i,p),i=s.successors(i)[0]}})}function r(s,a,i,l){var c=[],d=[],u=Math.min(a[i].low,a[l].low),f=Math.max(a[i].lim,a[l].lim),h,p;h=i;do h=s.parent(h),c.push(h);while(h&&(a[h].low>u||f>a[h].lim));for(p=h,h=l;(h=s.parent(h))!==p;)d.push(h);return{path:c.concat(d.reverse()),lca:p}}function n(s){var a={},i=0;function l(c){var d=i;e.forEach(s.children(c),l),a[c]={low:d,lim:i++}}return e.forEach(s.children(),l),a}return Fi}var Bi,Ih;function ev(){if(Ih)return Bi;Ih=1;var e=we(),t=De();Bi={run:r,cleanup:i};function r(l){var c=t.addDummyNode(l,"root",{},"_root"),d=s(l),u=e.max(e.values(d))-1,f=2*u+1;l.graph().nestingRoot=c,e.forEach(l.edges(),function(p){l.edge(p).minlen*=f});var h=a(l)+1;e.forEach(l.children(),function(p){n(l,c,f,h,u,d,p)}),l.graph().nodeRankFactor=f}function n(l,c,d,u,f,h,p){var m=l.children(p);if(!m.length){p!==c&&l.setEdge(c,p,{weight:0,minlen:d});return}var g=t.addBorderNode(l,"_bt"),x=t.addBorderNode(l,"_bb"),v=l.node(p);l.setParent(g,p),v.borderTop=g,l.setParent(x,p),v.borderBottom=x,e.forEach(m,function(y){n(l,c,d,u,f,h,y);var b=l.node(y),k=b.borderTop?b.borderTop:y,_=b.borderBottom?b.borderBottom:y,w=b.borderTop?u:2*u,T=k!==_?1:f-h[p]+1;l.setEdge(g,k,{weight:w,minlen:T,nestingEdge:!0}),l.setEdge(_,x,{weight:w,minlen:T,nestingEdge:!0})}),l.parent(p)||l.setEdge(c,g,{weight:0,minlen:f+h[p]})}function s(l){var c={};function d(u,f){var h=l.children(u);h&&h.length&&e.forEach(h,function(p){d(p,f+1)}),c[u]=f}return e.forEach(l.children(),function(u){d(u,1)}),c}function a(l){return e.reduce(l.edges(),function(c,d){return c+l.edge(d).weight},0)}function i(l){var c=l.graph();l.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(l.edges(),function(d){var u=l.edge(d);u.nestingEdge&&l.removeEdge(d)})}return Bi}var zi,Rh;function tv(){if(Rh)return zi;Rh=1;var e=we(),t=De();zi=r;function r(s){function a(i){var l=s.children(i),c=s.node(i);if(l.length&&e.forEach(l,a),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var d=c.minRank,u=c.maxRank+1;d<u;++d)n(s,"borderLeft","_bl",i,c,d),n(s,"borderRight","_br",i,c,d)}}e.forEach(s.children(),a)}function n(s,a,i,l,c,d){var u={width:0,height:0,rank:d,borderType:a},f=c[a][d-1],h=t.addDummyNode(s,"border",u,i);c[a][d]=h,s.setParent(h,l),f&&s.setEdge(f,h,{weight:1})}return zi}var Hi,Oh;function rv(){if(Oh)return Hi;Oh=1;var e=we();Hi={adjust:t,undo:r};function t(d){var u=d.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(d)}function r(d){var u=d.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&a(d),(u==="lr"||u==="rl")&&(l(d),n(d))}function n(d){e.forEach(d.nodes(),function(u){s(d.node(u))}),e.forEach(d.edges(),function(u){s(d.edge(u))})}function s(d){var u=d.width;d.width=d.height,d.height=u}function a(d){e.forEach(d.nodes(),function(u){i(d.node(u))}),e.forEach(d.edges(),function(u){var f=d.edge(u);e.forEach(f.points,i),e.has(f,"y")&&i(f)})}function i(d){d.y=-d.y}function l(d){e.forEach(d.nodes(),function(u){c(d.node(u))}),e.forEach(d.edges(),function(u){var f=d.edge(u);e.forEach(f.points,c),e.has(f,"x")&&c(f)})}function c(d){var u=d.x;d.x=d.y,d.y=u}return Hi}var Ji,Ph;function nv(){if(Ph)return Ji;Ph=1;var e=we();Ji=t;function t(r){var n={},s=e.filter(r.nodes(),function(d){return!r.children(d).length}),a=e.max(e.map(s,function(d){return r.node(d).rank})),i=e.map(e.range(a+1),function(){return[]});function l(d){if(!e.has(n,d)){n[d]=!0;var u=r.node(d);i[u.rank].push(d),e.forEach(r.successors(d),l)}}var c=e.sortBy(s,function(d){return r.node(d).rank});return e.forEach(c,l),i}return Ji}var Ui,Ah;function sv(){if(Ah)return Ui;Ah=1;var e=we();Ui=t;function t(n,s){for(var a=0,i=1;i<s.length;++i)a+=r(n,s[i-1],s[i]);return a}function r(n,s,a){for(var i=e.zipObject(a,e.map(a,function(h,p){return p})),l=e.flatten(e.map(s,function(h){return e.sortBy(e.map(n.outEdges(h),function(p){return{pos:i[p.w],weight:n.edge(p).weight}}),"pos")}),!0),c=1;c<a.length;)c<<=1;var d=2*c-1;c-=1;var u=e.map(new Array(d),function(){return 0}),f=0;return e.forEach(l.forEach(function(h){var p=h.pos+c;u[p]+=h.weight;for(var m=0;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=h.weight;f+=h.weight*m})),f}return Ui}var Ki,Lh;function av(){if(Lh)return Ki;Lh=1;var e=we();Ki=t;function t(r,n){return e.map(n,function(s){var a=r.inEdges(s);if(a.length){var i=e.reduce(a,function(l,c){var d=r.edge(c),u=r.node(c.v);return{sum:l.sum+d.weight*u.order,weight:l.weight+d.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:s}})}return Ki}var Gi,Dh;function ov(){if(Dh)return Gi;Dh=1;var e=we();Gi=t;function t(s,a){var i={};e.forEach(s,function(c,d){var u=i[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:d};e.isUndefined(c.barycenter)||(u.barycenter=c.barycenter,u.weight=c.weight)}),e.forEach(a.edges(),function(c){var d=i[c.v],u=i[c.w];!e.isUndefined(d)&&!e.isUndefined(u)&&(u.indegree++,d.out.push(i[c.w]))});var l=e.filter(i,function(c){return!c.indegree});return r(l)}function r(s){var a=[];function i(d){return function(u){u.merged||(e.isUndefined(u.barycenter)||e.isUndefined(d.barycenter)||u.barycenter>=d.barycenter)&&n(d,u)}}function l(d){return function(u){u.in.push(d),--u.indegree===0&&s.push(u)}}for(;s.length;){var c=s.pop();a.push(c),e.forEach(c.in.reverse(),i(c)),e.forEach(c.out,l(c))}return e.map(e.filter(a,function(d){return!d.merged}),function(d){return e.pick(d,["vs","i","barycenter","weight"])})}function n(s,a){var i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(a.i,s.i),a.merged=!0}return Gi}var Vi,Mh;function iv(){if(Mh)return Vi;Mh=1;var e=we(),t=De();Vi=r;function r(a,i){var l=t.partition(a,function(g){return e.has(g,"barycenter")}),c=l.lhs,d=e.sortBy(l.rhs,function(g){return-g.i}),u=[],f=0,h=0,p=0;c.sort(s(!!i)),p=n(u,d,p),e.forEach(c,function(g){p+=g.vs.length,u.push(g.vs),f+=g.barycenter*g.weight,h+=g.weight,p=n(u,d,p)});var m={vs:e.flatten(u,!0)};return h&&(m.barycenter=f/h,m.weight=h),m}function n(a,i,l){for(var c;i.length&&(c=e.last(i)).i<=l;)i.pop(),a.push(c.vs),l++;return l}function s(a){return function(i,l){return i.barycenter<l.barycenter?-1:i.barycenter>l.barycenter?1:a?l.i-i.i:i.i-l.i}}return Vi}var Yi,qh;function lv(){if(qh)return Yi;qh=1;var e=we(),t=av(),r=ov(),n=iv();Yi=s;function s(l,c,d,u){var f=l.children(c),h=l.node(c),p=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,g={};p&&(f=e.filter(f,function(_){return _!==p&&_!==m}));var x=t(l,f);e.forEach(x,function(_){if(l.children(_.v).length){var w=s(l,_.v,d,u);g[_.v]=w,e.has(w,"barycenter")&&i(_,w)}});var v=r(x,d);a(v,g);var y=n(v,u);if(p&&(y.vs=e.flatten([p,y.vs,m],!0),l.predecessors(p).length)){var b=l.node(l.predecessors(p)[0]),k=l.node(l.predecessors(m)[0]);e.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+b.order+k.order)/(y.weight+2),y.weight+=2}return y}function a(l,c){e.forEach(l,function(d){d.vs=e.flatten(d.vs.map(function(u){return c[u]?c[u].vs:u}),!0)})}function i(l,c){e.isUndefined(l.barycenter)?(l.barycenter=c.barycenter,l.weight=c.weight):(l.barycenter=(l.barycenter*l.weight+c.barycenter*c.weight)/(l.weight+c.weight),l.weight+=c.weight)}return Yi}var Xi,$h;function cv(){if($h)return Xi;$h=1;var e=we(),t=He().Graph;Xi=r;function r(s,a,i){var l=n(s),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(function(d){return s.node(d)});return e.forEach(s.nodes(),function(d){var u=s.node(d),f=s.parent(d);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(c.setNode(d),c.setParent(d,f||l),e.forEach(s[i](d),function(h){var p=h.v===d?h.w:h.v,m=c.edge(p,d),g=e.isUndefined(m)?0:m.weight;c.setEdge(p,d,{weight:s.edge(h).weight+g})}),e.has(u,"minRank")&&c.setNode(d,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),c}function n(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Xi}var Qi,Wh;function dv(){if(Wh)return Qi;Wh=1;var e=we();Qi=t;function t(r,n,s){var a={},i;e.forEach(s,function(l){for(var c=r.parent(l),d,u;c;){if(d=r.parent(c),d?(u=a[d],a[d]=c):(u=i,i=c),u&&u!==c){n.setEdge(u,c);return}c=d}})}return Qi}var Zi,Fh;function uv(){if(Fh)return Zi;Fh=1;var e=we(),t=nv(),r=sv(),n=lv(),s=cv(),a=dv(),i=He().Graph,l=De();Zi=c;function c(h){var p=l.maxRank(h),m=d(h,e.range(1,p+1),"inEdges"),g=d(h,e.range(p-1,-1,-1),"outEdges"),x=t(h);f(h,x);for(var v=Number.POSITIVE_INFINITY,y,b=0,k=0;k<4;++b,++k){u(b%2?m:g,b%4>=2),x=l.buildLayerMatrix(h);var _=r(h,x);_<v&&(k=0,y=e.cloneDeep(x),v=_)}f(h,y)}function d(h,p,m){return e.map(p,function(g){return s(h,g,m)})}function u(h,p){var m=new i;e.forEach(h,function(g){var x=g.graph().root,v=n(g,x,m,p);e.forEach(v.vs,function(y,b){g.node(y).order=b}),a(g,m,v.vs)})}function f(h,p){e.forEach(p,function(m){e.forEach(m,function(g,x){h.node(g).order=x})})}return Zi}var el,Bh;function fv(){if(Bh)return el;Bh=1;var e=we(),t=He().Graph,r=De();el={positionX:m,findType1Conflicts:n,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:h,findSmallestWidthAlignment:f,balance:p};function n(v,y){var b={};function k(_,w){var T=0,O=0,D=_.length,N=e.last(w);return e.forEach(w,function(S,R){var j=a(v,S),E=j?v.node(j).order:D;(j||S===N)&&(e.forEach(w.slice(O,R+1),function(q){e.forEach(v.predecessors(q),function($){var J=v.node($),V=J.order;(V<T||E<V)&&!(J.dummy&&v.node(q).dummy)&&i(b,$,q)})}),O=R+1,T=E)}),w}return e.reduce(y,k),b}function s(v,y){var b={};function k(w,T,O,D,N){var S;e.forEach(e.range(T,O),function(R){S=w[R],v.node(S).dummy&&e.forEach(v.predecessors(S),function(j){var E=v.node(j);E.dummy&&(E.order<D||E.order>N)&&i(b,j,S)})})}function _(w,T){var O=-1,D,N=0;return e.forEach(T,function(S,R){if(v.node(S).dummy==="border"){var j=v.predecessors(S);j.length&&(D=v.node(j[0]).order,k(T,N,R,O,D),N=R,O=D)}k(T,N,T.length,D,w.length)}),T}return e.reduce(y,_),b}function a(v,y){if(v.node(y).dummy)return e.find(v.predecessors(y),function(b){return v.node(b).dummy})}function i(v,y,b){if(y>b){var k=y;y=b,b=k}var _=v[y];_||(v[y]=_={}),_[b]=!0}function l(v,y,b){if(y>b){var k=y;y=b,b=k}return e.has(v[y],b)}function c(v,y,b,k){var _={},w={},T={};return e.forEach(y,function(O){e.forEach(O,function(D,N){_[D]=D,w[D]=D,T[D]=N})}),e.forEach(y,function(O){var D=-1;e.forEach(O,function(N){var S=k(N);if(S.length){S=e.sortBy(S,function($){return T[$]});for(var R=(S.length-1)/2,j=Math.floor(R),E=Math.ceil(R);j<=E;++j){var q=S[j];w[N]===N&&D<T[q]&&!l(b,N,q)&&(w[q]=N,w[N]=_[N]=_[q],D=T[q])}}})}),{root:_,align:w}}function d(v,y,b,k,_){var w={},T=u(v,y,b,_),O=_?"borderLeft":"borderRight";function D(R,j){for(var E=T.nodes(),q=E.pop(),$={};q;)$[q]?R(q):($[q]=!0,E.push(q),E=E.concat(j(q))),q=E.pop()}function N(R){w[R]=T.inEdges(R).reduce(function(j,E){return Math.max(j,w[E.v]+T.edge(E))},0)}function S(R){var j=T.outEdges(R).reduce(function(q,$){return Math.min(q,w[$.w]-T.edge($))},Number.POSITIVE_INFINITY),E=v.node(R);j!==Number.POSITIVE_INFINITY&&E.borderType!==O&&(w[R]=Math.max(w[R],j))}return D(N,T.predecessors.bind(T)),D(S,T.successors.bind(T)),e.forEach(k,function(R){w[R]=w[b[R]]}),w}function u(v,y,b,k){var _=new t,w=v.graph(),T=g(w.nodesep,w.edgesep,k);return e.forEach(y,function(O){var D;e.forEach(O,function(N){var S=b[N];if(_.setNode(S),D){var R=b[D],j=_.edge(R,S);_.setEdge(R,S,Math.max(T(v,N,D),j||0))}D=N})}),_}function f(v,y){return e.minBy(e.values(y),function(b){var k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(b,function(w,T){var O=x(v,T)/2;k=Math.max(w+O,k),_=Math.min(w-O,_)}),k-_})}function h(v,y){var b=e.values(y),k=e.min(b),_=e.max(b);e.forEach(["u","d"],function(w){e.forEach(["l","r"],function(T){var O=w+T,D=v[O],N;if(D!==y){var S=e.values(D);N=T==="l"?k-e.min(S):_-e.max(S),N&&(v[O]=e.mapValues(D,function(R){return R+N}))}})})}function p(v,y){return e.mapValues(v.ul,function(b,k){if(y)return v[y.toLowerCase()][k];var _=e.sortBy(e.map(v,k));return(_[1]+_[2])/2})}function m(v){var y=r.buildLayerMatrix(v),b=e.merge(n(v,y),s(v,y)),k={},_;e.forEach(["u","d"],function(T){_=T==="u"?y:e.values(y).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(_=e.map(_,function(R){return e.values(R).reverse()}));var D=(T==="u"?v.predecessors:v.successors).bind(v),N=c(v,_,b,D),S=d(v,_,N.root,N.align,O==="r");O==="r"&&(S=e.mapValues(S,function(R){return-R})),k[T+O]=S})});var w=f(v,k);return h(k,w),p(k,v.graph().align)}function g(v,y,b){return function(k,_,w){var T=k.node(_),O=k.node(w),D=0,N;if(D+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":N=-T.width/2;break;case"r":N=T.width/2;break}if(N&&(D+=b?N:-N),N=0,D+=(T.dummy?y:v)/2,D+=(O.dummy?y:v)/2,D+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":N=O.width/2;break;case"r":N=-O.width/2;break}return N&&(D+=b?N:-N),N=0,D}}function x(v,y){return v.node(y).width}return el}var tl,zh;function pv(){if(zh)return tl;zh=1;var e=we(),t=De(),r=fv().positionX;tl=n;function n(a){a=t.asNonCompoundGraph(a),s(a),e.forEach(r(a),function(i,l){a.node(l).x=i})}function s(a){var i=t.buildLayerMatrix(a),l=a.graph().ranksep,c=0;e.forEach(i,function(d){var u=e.max(e.map(d,function(f){return a.node(f).height}));e.forEach(d,function(f){a.node(f).y=c+u/2}),c+=u+l})}return tl}var rl,Hh;function hv(){if(Hh)return rl;Hh=1;var e=we(),t=Vx(),r=Yx(),n=Qx(),s=De().normalizeRanks,a=Zx(),i=De().removeEmptyRanks,l=ev(),c=tv(),d=rv(),u=uv(),f=pv(),h=De(),p=He().Graph;rl=m;function m(L,F){var z=F&&F.debugTiming?h.time:h.notime;z("layout",function(){var H=z(" buildLayoutGraph",function(){return D(L)});z(" runLayout",function(){g(H,z)}),z(" updateInputGraph",function(){x(L,H)})})}function g(L,F){F(" makeSpaceForEdgeLabels",function(){N(L)}),F(" removeSelfEdges",function(){A(L)}),F(" acyclic",function(){t.run(L)}),F(" nestingGraph.run",function(){l.run(L)}),F(" rank",function(){n(h.asNonCompoundGraph(L))}),F(" injectEdgeLabelProxies",function(){S(L)}),F(" removeEmptyRanks",function(){i(L)}),F(" nestingGraph.cleanup",function(){l.cleanup(L)}),F(" normalizeRanks",function(){s(L)}),F(" assignRankMinMax",function(){R(L)}),F(" removeEdgeLabelProxies",function(){j(L)}),F(" normalize.run",function(){r.run(L)}),F(" parentDummyChains",function(){a(L)}),F(" addBorderSegments",function(){c(L)}),F(" order",function(){u(L)}),F(" insertSelfEdges",function(){B(L)}),F(" adjustCoordinateSystem",function(){d.adjust(L)}),F(" position",function(){f(L)}),F(" positionSelfEdges",function(){P(L)}),F(" removeBorderNodes",function(){V(L)}),F(" normalize.undo",function(){r.undo(L)}),F(" fixupEdgeLabelCoords",function(){$(L)}),F(" undoCoordinateSystem",function(){d.undo(L)}),F(" translateGraph",function(){E(L)}),F(" assignNodeIntersects",function(){q(L)}),F(" reversePoints",function(){J(L)}),F(" acyclic.undo",function(){t.undo(L)})}function x(L,F){e.forEach(L.nodes(),function(z){var H=L.node(z),Y=F.node(z);H&&(H.x=Y.x,H.y=Y.y,F.children(z).length&&(H.width=Y.width,H.height=Y.height))}),e.forEach(L.edges(),function(z){var H=L.edge(z),Y=F.edge(z);H.points=Y.points,e.has(Y,"x")&&(H.x=Y.x,H.y=Y.y)}),L.graph().width=F.graph().width,L.graph().height=F.graph().height}var v=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],_={width:0,height:0},w=["minlen","weight","width","height","labeloffset"],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function D(L){var F=new p({multigraph:!0,compound:!0}),z=se(L.graph());return F.setGraph(e.merge({},y,U(z,v),e.pick(z,b))),e.forEach(L.nodes(),function(H){var Y=se(L.node(H));F.setNode(H,e.defaults(U(Y,k),_)),F.setParent(H,L.parent(H))}),e.forEach(L.edges(),function(H){var Y=se(L.edge(H));F.setEdge(H,e.merge({},T,U(Y,w),e.pick(Y,O)))}),F}function N(L){var F=L.graph();F.ranksep/=2,e.forEach(L.edges(),function(z){var H=L.edge(z);H.minlen*=2,H.labelpos.toLowerCase()!=="c"&&(F.rankdir==="TB"||F.rankdir==="BT"?H.width+=H.labeloffset:H.height+=H.labeloffset)})}function S(L){e.forEach(L.edges(),function(F){var z=L.edge(F);if(z.width&&z.height){var H=L.node(F.v),Y=L.node(F.w),ie={rank:(Y.rank-H.rank)/2+H.rank,e:F};h.addDummyNode(L,"edge-proxy",ie,"_ep")}})}function R(L){var F=0;e.forEach(L.nodes(),function(z){var H=L.node(z);H.borderTop&&(H.minRank=L.node(H.borderTop).rank,H.maxRank=L.node(H.borderBottom).rank,F=e.max(F,H.maxRank))}),L.graph().maxRank=F}function j(L){e.forEach(L.nodes(),function(F){var z=L.node(F);z.dummy==="edge-proxy"&&(L.edge(z.e).labelRank=z.rank,L.removeNode(F))})}function E(L){var F=Number.POSITIVE_INFINITY,z=0,H=Number.POSITIVE_INFINITY,Y=0,ie=L.graph(),fe=ie.marginx||0,ve=ie.marginy||0;function be(W){var ke=W.x,ee=W.y,me=W.width,ne=W.height;F=Math.min(F,ke-me/2),z=Math.max(z,ke+me/2),H=Math.min(H,ee-ne/2),Y=Math.max(Y,ee+ne/2)}e.forEach(L.nodes(),function(W){be(L.node(W))}),e.forEach(L.edges(),function(W){var ke=L.edge(W);e.has(ke,"x")&&be(ke)}),F-=fe,H-=ve,e.forEach(L.nodes(),function(W){var ke=L.node(W);ke.x-=F,ke.y-=H}),e.forEach(L.edges(),function(W){var ke=L.edge(W);e.forEach(ke.points,function(ee){ee.x-=F,ee.y-=H}),e.has(ke,"x")&&(ke.x-=F),e.has(ke,"y")&&(ke.y-=H)}),ie.width=z-F+fe,ie.height=Y-H+ve}function q(L){e.forEach(L.edges(),function(F){var z=L.edge(F),H=L.node(F.v),Y=L.node(F.w),ie,fe;z.points?(ie=z.points[0],fe=z.points[z.points.length-1]):(z.points=[],ie=Y,fe=H),z.points.unshift(h.intersectRect(H,ie)),z.points.push(h.intersectRect(Y,fe))})}function $(L){e.forEach(L.edges(),function(F){var z=L.edge(F);if(e.has(z,"x"))switch((z.labelpos==="l"||z.labelpos==="r")&&(z.width-=z.labeloffset),z.labelpos){case"l":z.x-=z.width/2+z.labeloffset;break;case"r":z.x+=z.width/2+z.labeloffset;break}})}function J(L){e.forEach(L.edges(),function(F){var z=L.edge(F);z.reversed&&z.points.reverse()})}function V(L){e.forEach(L.nodes(),function(F){if(L.children(F).length){var z=L.node(F),H=L.node(z.borderTop),Y=L.node(z.borderBottom),ie=L.node(e.last(z.borderLeft)),fe=L.node(e.last(z.borderRight));z.width=Math.abs(fe.x-ie.x),z.height=Math.abs(Y.y-H.y),z.x=ie.x+z.width/2,z.y=H.y+z.height/2}}),e.forEach(L.nodes(),function(F){L.node(F).dummy==="border"&&L.removeNode(F)})}function A(L){e.forEach(L.edges(),function(F){if(F.v===F.w){var z=L.node(F.v);z.selfEdges||(z.selfEdges=[]),z.selfEdges.push({e:F,label:L.edge(F)}),L.removeEdge(F)}})}function B(L){var F=h.buildLayerMatrix(L);e.forEach(F,function(z){var H=0;e.forEach(z,function(Y,ie){var fe=L.node(Y);fe.order=ie+H,e.forEach(fe.selfEdges,function(ve){h.addDummyNode(L,"selfedge",{width:ve.label.width,height:ve.label.height,rank:fe.rank,order:ie+ ++H,e:ve.e,label:ve.label},"_se")}),delete fe.selfEdges})})}function P(L){e.forEach(L.nodes(),function(F){var z=L.node(F);if(z.dummy==="selfedge"){var H=L.node(z.e.v),Y=H.x+H.width/2,ie=H.y,fe=z.x-Y,ve=H.height/2;L.setEdge(z.e,z.label),L.removeNode(F),z.label.points=[{x:Y+2*fe/3,y:ie-ve},{x:Y+5*fe/6,y:ie-ve},{x:Y+fe,y:ie},{x:Y+5*fe/6,y:ie+ve},{x:Y+2*fe/3,y:ie+ve}],z.label.x=z.x,z.label.y=z.y}})}function U(L,F){return e.mapValues(e.pick(L,F),Number)}function se(L){var F={};return e.forEach(L,function(z,H){F[H.toLowerCase()]=z}),F}return rl}var nl,Jh;function mv(){if(Jh)return nl;Jh=1;var e=we(),t=De(),r=He().Graph;nl={debugOrdering:n};function n(s){var a=t.buildLayerMatrix(s),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(l){i.setNode(l,{label:l}),i.setParent(l,"layer"+s.node(l).rank)}),e.forEach(s.edges(),function(l){i.setEdge(l.v,l.w,{},l.name)}),e.forEach(a,function(l,c){var d="layer"+c;i.setNode(d,{rank:"same"}),e.reduce(l,function(u,f){return i.setEdge(u,f,{style:"invis"}),f})}),i}return nl}var sl,Uh;function gv(){return Uh||(Uh=1,sl="0.8.5"),sl}var al,Kh;function yv(){return Kh||(Kh=1,al={graphlib:He(),layout:hv(),debug:mv(),util:{time:De().time,notime:De().notime},version:gv()}),al}var xv=yv();const Gh=zm(xv);function mt(e,t="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,n=84;switch(e.type){case"decisionNode":r=164,n=164;break;case"forkNode":r=240,n=84;break;case"joinNode":r=240,n=84;break;case"dynamicPlaceholderNode":r=220,n=70;break;case"loopNode":r=320,n=200;break;case"subWorkflowNode":r=240,n=84;break;case"eventNode":r=240,n=84;break;case"default":r=240,n=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:r=240,n=84;break}return{width:r,height:n}}function vv(e,t,r=8){const n=[];if(e.length<r)return n;const s=new Map,a={},i={};e.forEach(f=>{s.set(f.id,f),a[f.id]=[],i[f.id]=[]}),t.forEach(f=>{a[f.source]&&a[f.source].push(f.target),i[f.target]&&i[f.target].push(f.source)});const l=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),d=f=>!c.has(f.type||""),u=[...e].sort((f,h)=>f.position.y-h.position.y);for(const f of u){if(l.has(f.id)||!d(f)||a[f.id].length>1)continue;const h=[f.id];let p=f,m=a[p.id];for(;m&&m.length===1;){const g=m[0],x=s.get(g);if(!x||l.has(g)||!d(x)||i[g].length!==1)break;h.push(g),p=x,m=a[p.id]}h.length>=r&&(n.push(h),h.forEach(g=>l.add(g)))}return n}function bv(e,t,r,n,s,a=5,i="view"){const l=t.find(y=>y.id===e[0]),{width:c,height:d}=mt(l||t[0],r),u=Math.max(.7,1-(e.length-10)/80),f=i==="edit"||i==="run"?1.15:1,h=Math.min(n,Math.round(60*u*f)),p=Math.min(s,Math.round(80*u*f)),m=c+h,g=d+p;let x=0,v=0;if(r==="TB"){const y=Math.ceil(e.length/a);x=a*m-h,v=y*g-p}else x=Math.ceil(e.length/a)*m-h,v=a*g-p;return x+=40,v+=40,{width:x,height:v,gridKW:m,gridKH:g,cols:a}}const ol=58,Vh=20,kv=16;function Sv(e,t,r,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:ol+50};const s=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=il(s,t,{direction:r,mode:n,enableSnakeLayout:!1});let i=0,l=0;a.forEach(f=>{const{width:h,height:p}=mt(f,r);i=Math.max(i,f.position.x+h),l=Math.max(l,f.position.y+p)});const c=Math.max(300,i+Vh*2),d=ol+l+kv;return{positionedChildren:a.map(f=>{const h=e.find(p=>p.id===f.id);return{...f,parentId:h.parentId,extent:h.extent,position:{x:f.position.x+Vh,y:f.position.y+ol}}}),containerWidth:c,containerHeight:d}}function il(e,t,r={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:i=5,snakeMinChainLength:l=8,snakeMinNodeCount:c=10}=r,d=e.length,u=e.filter(N=>N.type!=="plusNode").length;let f=n==="LR"?150:120,h=n==="LR"?120:100,p=f,m=h;if(d>15){let N=Math.max(.5,1-(d-15)/50),S=Math.max(.4,1-(d-15)/40);(s==="edit"||s==="run")&&(N=1-(1-N)*.5,S=1-(1-S)*.5),p=Math.round(f*N),m=Math.round(h*S)}const g=a&&u>c?vv(e,t,l):[],x={};g.forEach((N,S)=>{N.forEach(R=>{x[R]=S})});const v=new Gh.graphlib.Graph;v.setDefaultEdgeLabel(()=>({})),v.setGraph({rankdir:n,ranker:"network-simplex",ranksep:p,nodesep:m,edgesep:50,marginx:50,marginy:50});const y=new Set,b={};e.forEach(N=>{const S=x[N.id];if(S!==void 0){if(!y.has(S)){y.add(S);const R=bv(g[S],e,n,m,p,i,s);b[S]=R,v.setNode(`__CHAIN_${S}`,{width:R.width,height:R.height})}}else{const{width:R,height:j}=mt(N,n);v.setNode(N.id,{width:R,height:j})}});const k={};t.forEach(N=>{const S=x[N.source],R=x[N.target],j=S!==void 0?`__CHAIN_${S}`:N.source,E=R!==void 0?`__CHAIN_${R}`:N.target;j!==E&&(k[E]=(k[E]||0)+1)}),t.forEach(N=>{const S=x[N.source],R=x[N.target];let j=N.source,E=N.target;if(S!==void 0&&(j=`__CHAIN_${S}`),R!==void 0&&(E=`__CHAIN_${R}`),j!==E){const q=(k[E]||0)>1;v.setEdge(j,E,{weight:q?1:2})}}),Gh.layout(v);const _={};for(const N of e)_[N.id]={...N};const w=[],T=new Set;e.forEach(N=>{if(x[N.id]===void 0){const S=v.node(N.id),R=_[N.id],{width:j,height:E}=mt(R,n);R.position={x:S.x-j/2,y:S.y-E/2},R.data={...R.data,sourcePosition:void 0,targetPosition:void 0},R.sourcePosition=n==="LR"?M.Position.Right:M.Position.Bottom,R.targetPosition=n==="LR"?M.Position.Left:M.Position.Top,w.push(R)}else T.add(N.id)}),g.forEach((N,S)=>{const R=`__CHAIN_${S}`,j=v.node(R),E=b[S],q=j.x-E.width/2+20,$=j.y-E.height/2+20,J=E.cols,V=E.gridKW,A=E.gridKH;N.forEach((B,P)=>{const U=_[B];let se=0,L=0,F,z;if(n==="TB"){const H=Math.floor(P/J),Y=P%J,ie=H%2===0,fe=Math.ceil(N.length/J),ve=H===fe-1,be=N.length%J||J,W=ve?(J-be)*V/2:0;let ke;ie?ke=Y*V+W:ke=(J-1-Y)*V-W;const ee=H*A;se=q+ke,L=$+ee;const me=ve?be:J;ie?(z=M.Position.Left,F=M.Position.Right,Y===me-1&&P!==N.length-1&&(F=M.Position.Bottom),Y===0&&P!==0&&(z=M.Position.Top)):(z=M.Position.Right,F=M.Position.Left,Y===me-1&&P!==N.length-1&&(F=M.Position.Bottom),Y===0&&P!==0&&(z=M.Position.Top)),P===0&&(z=M.Position.Top),P===N.length-1&&(F=M.Position.Bottom)}else{const H=Math.floor(P/J),Y=P%J,ie=H%2===0,fe=Math.ceil(N.length/J),ve=H===fe-1,be=N.length%J||J,W=ve?Math.max(0,(J-be)*A)/2:0,ke=H*V;let ee;ie?ee=Y*A+W:ee=(J-1-Y)*A-W,se=q+ke,L=$+ee;const me=ve?be:J;ie?(z=M.Position.Top,F=M.Position.Bottom,Y===me-1&&P!==N.length-1&&(F=M.Position.Right),Y===0&&P!==0&&(z=M.Position.Left)):(z=M.Position.Bottom,F=M.Position.Top,Y===me-1&&P!==N.length-1&&(F=M.Position.Right),Y===0&&P!==0&&(z=M.Position.Left)),P===0&&(z=M.Position.Left),P===N.length-1&&(F=M.Position.Right)}U.position={x:se,y:L},U.data={...U.data,sourcePosition:F,targetPosition:z},U.sourcePosition=F,U.targetPosition=z,w.push(U)})});const O=w.reduce((N,S)=>({...N,[S.id]:S}),{}),D=t.map(N=>{const S=O[N.source],R=O[N.target];if(!S||!R||T.has(S.id)||S.type!=="decisionNode")return N;const{width:j,height:E}=mt(S,n),{width:q,height:$}=mt(R,n),J={x:S.position.x+j/2,y:S.position.y+E/2},V={x:R.position.x+q/2,y:R.position.y+$/2};let A=null;if(n==="TB"){const B=j*.25;V.x<J.x-B?A="left":V.x>J.x+B&&(A="right")}else{const B=E*.25;V.y<J.y-B?A="top":V.y>J.y+B&&(A="bottom")}return{...N,sourceHandle:A}});return{nodes:w,edges:D}}function je(e,t,r={}){const n=r.direction||"TB",s=r.mode||"view",a=e.filter(v=>v.parentId),i=e.filter(v=>!v.parentId);if(a.length===0)return il(e,t,r);const l=new Map(a.map(v=>[v.id,v])),c={},d=[];t.forEach(v=>{const y=l.get(v.source),b=l.get(v.target);if(y?.parentId&&y.parentId===b?.parentId){const k=y.parentId;c[k]||(c[k]=[]),c[k].push(v)}else d.push(v)});const u={};a.forEach(v=>{const y=v.parentId;u[y]||(u[y]=[]),u[y].push(v)});const f={},h=[];for(const[v,y]of Object.entries(u)){const b=c[v]||[],{positionedChildren:k,containerWidth:_,containerHeight:w}=Sv(y,b,n,s);f[v]={width:_,height:w},h.push(...k)}const p=i.map(v=>{if(v.type==="loopNode"&&f[v.id]){const{width:y,height:b}=f[v.id];return{...v,data:{...v.data,_layoutWidth:y,_layoutHeight:b},style:{...v.style,width:y,height:b}}}return v}),{nodes:m,edges:g}=il(p,d,r);return{nodes:[...m.map(v=>{if(v.type==="loopNode"&&f[v.id]){const{width:y,height:b}=f[v.id];return{...v,width:y,height:b,style:{...v.style,width:y,height:b}}}return v}),...h],edges:[...g,...Object.values(c).flat()]}}function Me(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const a=Me(r.decisionCases[s],t);if(a)return a}const n=Me(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=Me(n,t);if(s)return s}if(r.loopOver){const n=Me(r.loopOver,t);if(n)return n}}return null}function Ge(e,t){if(!e)return!1;const r=e.findIndex(n=>n.taskReferenceName===t);if(r!==-1)return e.splice(r,1),!0;for(const n of e){if(n.decisionCases){for(const s of Object.keys(n.decisionCases))if(Ge(n.decisionCases[s],t))return!0;if(Ge(n.defaultCase,t))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(Ge(s,t))return!0}if(n.loopOver&&Ge(n.loopOver,t))return!0}return!1}function gt(e,t){if(!e)return null;if(e.some(r=>r.taskReferenceName===t))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const a=gt(s,t);if(a)return a}const n=gt(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=gt(n,t);if(s)return s}if(r.loopOver){const n=gt(r.loopOver,t);if(n)return n}}return null}function Yh(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function Xh(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Je(e,t,r){if(!e)return!1;if(t==="start")return e.unshift(r),!0;const n=e.findIndex(s=>s.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Je(s.decisionCases[a],t,r))return!0;if(Je(s.defaultCase,t,r))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Je(a,t,r))return!0}if(s.loopOver&&Je(s.loopOver,t,r))return!0}return!1}function yt(e,t,r,n){for(const s of e||[]){if(s.taskReferenceName===t){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[r.forkIndex].unshift(n),!0;if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(yt(s.decisionCases[a],t,r,n))return!0;if(yt(s.defaultCase,t,r,n))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(yt(a,t,r,n))return!0}if(s.loopOver&&yt(s.loopOver,t,r,n))return!0}return!1}function Le(e){if(e)for(let t=0;t<e.length;t++){const r=e[t];if(r.type==="FORK_JOIN"&&t+1<e.length){const n=e[t+1];if(n.type==="JOIN"){const s=[];(r.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),n.joinOn=s}}r.decisionCases&&(Object.values(r.decisionCases).forEach(n=>Le(n)),r.defaultCase&&Le(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(n=>Le(n)),r.loopOver&&Le(r.loopOver)}}const _v=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Qh={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,t)=>!!(t?.inputParameters?.expression||t?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,t)=>!!t?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,t)=>!!(t?.loopCondition||t?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const t=Object.keys(e||{});return new Set(t).size===t.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,t)=>!!(t?.dynamicForkTasksParam||t?.forkTaskType||t?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class wv{rules=[];setRules(t){this.rules=[...t]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(t){const r=[],n=[];for(const s of this.rules)try{const a=s.validate(t);for(const i of a)s.level==="warning"?n.push(i):r.push(i)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:n}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
7
+ 以下规则由集成方定义,生成工作流时必须满足:
8
+ ${this.rules.map(r=>`- ${r.description}`).join(`
9
+ `)}`}}const Zh=new wv,Tv=(e,t)=>t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e),ll=(e,t,r,n)=>{const{errors:s,warnings:a}=n,i=e.taskReferenceName||"GLOBAL";t.forEach(l=>{const c=Tv(e,l.field);let d=!0;switch(l.type){case"required":d=c!=null&&c!=="";break;case"min_length":d=Array.isArray(c)&&c.length>=l.value;break;case"pattern":d=l.value.test(c);break;case"enum":d=l.value.includes(c);break;case"unique":l.field==="taskReferenceName"&&c&&(r.taskRefs.has(c)?d=!1:r.taskRefs.add(c));break;case"custom":typeof l.validate=="function"&&(d=l.validate(c,e,r));break}if(!d){const u={type:e.taskReferenceName?"TASK":"GLOBAL",ref:i,message:l.message};l.level==="warning"?a.push(u):s.push(u)}})},We=e=>{const t=[],r=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(ll(e,_v,n,{errors:t,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:t,warnings:r};const s=i=>{i.forEach(l=>{ll(l,Qh.common,n,{errors:t,warnings:r});const c=Qh.types[l.type];c&&ll(l,c,n,{errors:t,warnings:r}),l.decisionCases&&Object.keys(l.decisionCases).forEach(d=>{s(l.decisionCases[d])}),l.defaultCase&&s(l.defaultCase),l.forkTasks&&l.forkTasks.forEach(d=>s(d)),l.loopOver&&s(l.loopOver)})};s(e.tasks);const a=Ev(e.tasks);if(t.push(...a),Zh.hasRules()){const i=Zh.runAll(e);t.push(...i.errors),r.push(...i.warnings)}return{isValid:t.length===0,errors:t,warnings:r}},Ev=e=>{const t=[],r=new Map,n=new Set,s=u=>{for(let f=0;f<u.length;f++){const h=u[f],p=h.taskReferenceName;if(n.add(p),r.has(p)||r.set(p,[]),f<u.length-1){const m=u[f+1].taskReferenceName;h.type!=="FORK_JOIN"&&h.type!=="FORK_JOIN_DYNAMIC"&&r.get(p).push(m)}if(h.decisionCases)for(const m of Object.values(h.decisionCases))m.length>0&&(r.get(p).push(m[0].taskReferenceName),s(m));if(h.defaultCase&&h.defaultCase.length>0&&(r.get(p).push(h.defaultCase[0].taskReferenceName),s(h.defaultCase)),h.forkTasks)for(const m of h.forkTasks)m.length>0&&(r.get(p).push(m[0].taskReferenceName),s(m));if(h.loopOver)for(const m of h.loopOver)n.add(m.taskReferenceName);if(h.joinOn)for(const m of h.joinOn)r.has(m)||r.set(m,[]),r.get(m).push(p)}};s(e);const a=0,i=1,l=2,c=new Map;for(const u of n)c.set(u,a);const d=u=>{c.set(u,i);const f=r.get(u)||[];for(const h of f)if(c.has(h)){if(c.get(h)===i)return t.push({type:"GLOBAL",ref:h,message:`检测到环路:任务 "${u}" → "${h}" 形成了循环依赖`}),!0;if(c.get(h)===a&&d(h))return!0}return c.set(u,l),!1};for(const u of n)c.get(u)===a&&d(u);return t};function Nv(e,t){const r=new Set(e),n={};e.forEach(l=>n[l]=0),t.forEach(l=>{r.has(l.source)&&r.has(l.target)&&(n[l.target]=(n[l.target]??0)+1)});const s=[];let a=e.filter(l=>n[l]===0);const i={...n};for(;a.length>0;){s.push([...a]);const l=[];a.forEach(c=>{t.forEach(d=>{d.source===c&&r.has(d.target)&&(i[d.target]--,i[d.target]===0&&l.push(d.target))})}),a=l}return s}function At(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(t=>({name:t})):e}class jv{schemas=new Map;setSchemas(t){this.schemas.clear();for(const r of t)this.schemas.set(r.taskName,r)}get(t){return this.schemas.get(t)}getAll(){return Array.from(this.schemas.values())}hasSchemas(){return this.schemas.size>0}buildPromptSection(){if(!this.hasSchemas())return null;const t=["## 任务 Schema 注册表(数据流参考)","以下任务的输入/输出字段已注册。生成 inputParameters 时请引用正确的上游输出字段(格式:`${taskRef.output.fieldName}`)。"];for(const r of this.getAll()){const n=r.taskType?`(${r.taskType})`:"",s=r.description?` — ${r.description}`:"";if(t.push(`
10
+ **${r.taskName}** ${n}${s}`),r.inputSchema&&Object.keys(r.inputSchema).length>0){const a=Object.entries(r.inputSchema).map(([i,l])=>`${i}: ${l}`).join(", ");t.push(`- 输入: ${a}`)}if(r.outputSchema&&Object.keys(r.outputSchema).length>0){const a=Object.entries(r.outputSchema).map(([i,l])=>`${i}: ${l}`).join(", ");t.push(`- 输出: ${a}`)}}return t.join(`
11
+ `)}}const Cv=new jv;function xt(e,t,r){if(t.push({task:e,isConditional:r}),e.decisionCases)for(const n of Object.values(e.decisionCases))for(const s of n||[])xt(s,t,!0);if(e.defaultCase)for(const n of e.defaultCase)xt(n,t,!0);if(e.forkTasks)for(const n of e.forkTasks)for(const s of n||[])xt(s,t,r);if(e.loopOver)for(const n of e.loopOver)xt(n,t,r)}function em(e,t){if(!e||!Array.isArray(e.tasks))return[];const r=[];function n(a,i){for(let l=0;l<a.length;l++){const c=a[l];if(c.taskReferenceName===t)return!0;if(c.decisionCases||c.defaultCase){for(const d of Object.values(c.decisionCases||{})){const u=[];if(s(d||[],!0,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}if(c.defaultCase){const d=[];if(s(c.defaultCase,!0,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}}if(c.forkTasks)for(const d of c.forkTasks){const u=[];if(s(d||[],i,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}if(c.loopOver){const d=[];if(s(c.loopOver,i,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}xt(c,r,i)}return!1}function s(a,i,l){for(let c=0;c<a.length;c++){const d=a[c];if(d.taskReferenceName===t)return!0;if(d.decisionCases||d.defaultCase){for(const u of Object.values(d.decisionCases||{})){const f=[];if(s(u||[],!0,f))return l.push({task:d,isConditional:i}),l.push(...f),!0}if(d.defaultCase){const u=[];if(s(d.defaultCase,!0,u))return l.push({task:d,isConditional:i}),l.push(...u),!0}}if(d.forkTasks)for(const u of d.forkTasks){const f=[];if(s(u||[],i,f))return l.push({task:d,isConditional:i}),l.push(...f),!0}if(d.loopOver){const u=[];if(s(d.loopOver,i,u))return l.push({task:d,isConditional:i}),l.push(...u),!0}xt(d,l,i)}return!1}return n(e.tasks,!1),r}function cl(e,t){return em(e,t).map(r=>r.task)}function lr(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>32?`"${e.slice(0,32)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const t=Object.keys(e);return`{ ${t.slice(0,3).join(", ")}${t.length>3?", ...":""} }`}return String(e)}function dl(e){if(e==null)return"any";if(Array.isArray(e))return"array";const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="object"?t:"any"}function ul(e,t,r="",n=0,s=3,a=[]){if(!e||typeof e!="object"||n>s)return a;for(const[i,l]of Object.entries(e)){const c=r?`${r}.${i}`:i,d=dl(l);a.push({path:c,expression:`\${${t}.output.${c}}`,valueType:d,sampleValue:lr(l),source:"runtime_sample"}),d==="object"&&l!==null&&Object.keys(l).length>0&&n<s?ul(l,t,c,n+1,s,a):d==="array"&&Array.isArray(l)&&l.length>0&&typeof l[0]=="object"&&l[0]!==null&&n<s&&ul(l[0],t,`${c}[0]`,n+1,s,a)}return a}function tm(e,t){const r=e.taskReferenceName,n=new Map,s=t?.[r]?.output;if(s&&typeof s=="object"){const l=ul(s,r);for(const c of l)n.set(c.path,c)}const a=Cv.get(e.name);if(a?.outputSchema){for(const[l,c]of Object.entries(a.outputSchema))if(!n.has(l)){const d=c.toLowerCase(),u=d.includes("number")||d.includes("int")?"number":d.includes("bool")?"boolean":d.includes("array")||d.includes("[]")?"array":d.includes("object")?"object":"string";n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:u,description:c,source:"schema_registry"})}}const i=(l,c,d)=>{n.has(l)||n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:c,description:d,source:"task_type_contract"})};switch(e.type){case"HTTP":i("response.body","object","HTTP 响应体 JSON 数据"),i("response.statusCode","number","HTTP 状态码 (如 200)"),i("response.headers","object","HTTP 响应头");break;case"JSON_JQ_TRANSFORM":i("result","any","JQ 表达式单值计算结果"),i("resultList","array","JQ 表达式列表计算结果");break;case"DO_WHILE":i("iteration","number","当前循环迭代轮次 (从 1 开始)");break;case"SUB_WORKFLOW":i("workflowId","string","子工作流实例 ID"),i("result","object","子工作流返回输出");break;case"HUMAN":i("approved","boolean","人工审批结果"),i("comment","string","审批意见备注"),i("assignee","string","实际审批人");break;default:n.size===0&&(i("result","any",`${e.name||r} 默认执行结果`),i("data","object",`${e.name||r} 业务输出对象`));break}return Array.from(n.values())}function rm(e,t,r,n){if(!e)return[];const s=[],a=At(e.inputParameters);if(a.length>0)for(const d of a){const u=n?.[d.name]??d.defaultValue;s.push({label:`workflow.input.${d.name}`,value:`\${workflow.input.${d.name}}`,category:"workflow_input",valueType:d.type==="number"?"number":d.type==="boolean"?"boolean":d.type==="object"?"object":d.type==="array"?"array":"string",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:d.description||`工作流启动参数 ${d.name}`,sampleValue:u!==void 0&&u!==""?lr(u):void 0})}else if(n&&typeof n=="object")for(const[d,u]of Object.entries(n))s.push({label:`workflow.input.${d}`,value:`\${workflow.input.${d}}`,category:"workflow_input",valueType:dl(u),sourceRef:"workflow.input",sourceLabel:"工作流输入",description:`工作流运行态输入字段 ${d}`,sampleValue:lr(u)});else s.push({label:"workflow.input.data",value:"${workflow.input.data}",category:"workflow_input",valueType:"any",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:"引用工作流启动时传入的参数(可在全局设置中定义 inputParameters)"});const i=em(e,t),l=new Set;for(let d=i.length-1;d>=0;d--){const{task:u,isConditional:f}=i[d];if(u.type==="SET_VARIABLE"&&u.inputParameters){for(const[p,m]of Object.entries(u.inputParameters))l.has(p)||(l.add(p),s.push({label:`workflow.variables.${p}`,value:`\${workflow.variables.${p}}`,category:"variable",valueType:dl(m),sourceRef:u.taskReferenceName,sourceLabel:`变量 (${u.name||u.taskReferenceName})`,description:`由上游 SET_VARIABLE 节点 [${u.taskReferenceName}] 设置的全局变量`,sampleValue:lr(m),isConditional:f}));continue}if(u.type==="JOIN"||u.type==="TERMINATE")continue;const h=tm(u,r);for(const p of h)s.push({label:`${u.taskReferenceName}.output.${p.path}`,value:p.expression,category:"upstream",valueType:p.valueType,sourceRef:u.taskReferenceName,sourceLabel:`${u.name||u.taskReferenceName} (${u.type})`,description:p.description||`来自上游任务 [${u.name||u.taskReferenceName}] 的输出字段`,sampleValue:p.sampleValue,isConditional:f})}const c=[{key:"workflow.workflowId",desc:"当前工作流执行实例唯一 ID"},{key:"workflow.correlationId",desc:"外部业务关联 ID (Correlation ID)"},{key:"workflow.status",desc:"当前工作流状态"},{key:"workflow.version",desc:"当前工作流定义版本号"}];for(const d of c)s.push({label:d.key,value:`\${${d.key}}`,category:"system",valueType:"string",sourceRef:"workflow",sourceLabel:"系统元数据",description:d.desc});return s}function it(e,t=[]){if(!e)return t;for(const r of e){if(t.push(r),r.decisionCases)for(const n of Object.values(r.decisionCases))it(n,t);if(r.defaultCase&&it(r.defaultCase,t),r.forkTasks)for(const n of r.forkTasks)it(n,t);r.loopOver&&it(r.loopOver,t)}return t}function vt(e,t=[]){if(typeof e=="string"){const r=/\$\{([^}]+)\}/g;let n;for(;(n=r.exec(e))!==null;)t.push(n[1].trim())}else if(Array.isArray(e))for(const r of e)vt(r,t);else if(e&&typeof e=="object")for(const r of Object.values(e))vt(r,t);return t}function nm(e){if(!e||!Array.isArray(e.tasks))return{edges:[],diagnostics:[]};const t=it(e.tasks),r=new Map,n=new Map;for(const l of t)if(r.set(l.taskReferenceName,l),l.type==="SET_VARIABLE"&&l.inputParameters)for(const c of Object.keys(l.inputParameters))n.set(c,l.taskReferenceName);const s=[],a=[],i=new Set;for(const l of t){const c=l.taskReferenceName,d=new Set(cl(e,c).map(f=>f.taskReferenceName)),u=[];vt(l.inputParameters,u),vt(l.httpRequest,u),l.loopCondition&&vt(l.loopCondition,u),l.expression&&vt(l.expression,u);for(const f of u){if(f.startsWith("workflow.input.")||f==="workflow.input")continue;if(f.startsWith("workflow.variables.")){const p=f.slice(19).split(".")[0],m=n.get(p);if(m&&m!==c){const g=d.has(m),x=`dfg-${m}->${c}-var:${p}`;i.has(x)||(i.add(x),s.push({id:x,sourceRef:m,targetRef:c,fieldPath:`variables.${p}`,expression:`\${${f}}`,sourceType:"workflow_variable",isValidUpstream:g,issue:g?void 0:"forward_ref"}))}continue}if(f.startsWith("workflow."))continue;const h=f.split(".");if(h.length>=2&&(h[1]==="output"||h[1]==="input")){const p=h[0],m=h.slice(2).join(".")||h[1];if(p===c)continue;const g=r.has(p),x=d.has(p);let v;g?x||(v="forward_ref",a.push({taskRef:c,expression:`\${${f}}`,issue:"forward_ref",message:`任务 [${c}] 引用了非上游或互斥分支任务 "${p}" 的输出`})):(v="undefined_ref",a.push({taskRef:c,expression:`\${${f}}`,issue:"undefined_ref",message:`任务 [${c}] 引用了不存在的任务 "${p}"`}));const y=`dfg-${p}->${c}-${m}`;i.has(y)||(i.add(y),s.push({id:y,sourceRef:p,targetRef:c,fieldPath:m,expression:`\${${f}}`,sourceType:"task_output",isValidUpstream:g&&x,issue:v}))}}}return{edges:s,diagnostics:a}}function sm(e,t,r){const n=t.trim(),s=r.trim();if(!n||!s||n===s)return{updatedDef:e,replacedCount:0,affectedTaskRefs:[]};const a=JSON.parse(JSON.stringify(e));let i=0;const l=new Set,c=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`\\$\\{\\s*${c}(\\.|\\s*\\})`,"g"),u=new RegExp(`\\$\\.\\b${c}\\b`,"g");function f(p,m){if(typeof p=="string"){let g=p;return d.lastIndex=0,d.test(g)&&(g=g.replace(d,(x,v)=>(i++,l.add(m),`\${${s}${v}`))),u.lastIndex=0,u.test(g)&&(g=g.replace(u,()=>(i++,l.add(m),`$.${s}`))),g}if(Array.isArray(p))return p.map(g=>f(g,m));if(p&&typeof p=="object"){const g={};for(const[x,v]of Object.entries(p))g[x]=f(v,m);return g}return p}const h=it(a.tasks);for(const p of h){const m=p.taskReferenceName===n?s:p.taskReferenceName;p.taskReferenceName===n&&(p.taskReferenceName=s),p.inputParameters&&(p.inputParameters=f(p.inputParameters,m)),p.httpRequest&&(p.httpRequest=f(p.httpRequest,m)),p.loopCondition&&(p.loopCondition=f(p.loopCondition,m)),p.expression&&(p.expression=f(p.expression,m)),Array.isArray(p.joinOn)&&(p.joinOn=p.joinOn.map(g=>g===n?(i++,l.add(m),s):g)),Array.isArray(p.defaultExclusiveJoinTask)&&(p.defaultExclusiveJoinTask=p.defaultExclusiveJoinTask.map(g=>g===n?(i++,l.add(m),s):g))}return a.outputParameters&&(a.outputParameters=f(a.outputParameters,"__workflow_output__")),l.delete(s),{updatedDef:a,replacedCount:i,affectedTaskRefs:Array.from(l)}}function am(e){return!e||typeof e!="object"?null:e.__isMockOverride||"outputData"in e||"forceCase"in e||"durationMs"in e||"status"in e&&(e.status==="COMPLETED"||e.status==="FAILED"||e.status==="TIMED_OUT"||e.status==="COMPLETED_WITH_ERRORS")&&Object.keys(e).every(t=>["__isMockOverride","status","durationMs","forceCase","outputData","reasonForIncompletion"].includes(t))?e:{__isMockOverride:!0,outputData:e}}function cr(e,t){if(!e||!t)return;const r=t.split(".");let n=e;for(const s of r){if(n==null)return;n=n[s]}return n}function dr(e,t){if(typeof e=="string"){const r=e.match(/^\$\{([^}]+)\}$/);if(r){const n=om(r[1].trim(),t);return n!==void 0?n:e}return e.replace(/\$\{([^}]+)\}/g,(n,s)=>{const a=om(s.trim(),t);return a===void 0?n:typeof a=="object"?JSON.stringify(a):String(a)})}if(Array.isArray(e))return e.map(r=>dr(r,t));if(e&&typeof e=="object"){const r={};for(const[n,s]of Object.entries(e))r[n]=dr(s,t);return r}return e}function om(e,t){if(e==="workflow.input")return t.workflowInput;if(e.startsWith("workflow.input."))return cr(t.workflowInput,e.slice(15));if(e==="workflow.variables")return t.variables;if(e.startsWith("workflow.variables."))return cr(t.variables,e.slice(19));if(e==="workflow.workflowId")return"sandbox-dryrun-wf-001";if(e==="workflow.correlationId")return"corr-sandbox-9921";const r=e.indexOf(".output");if(r>0){const n=e.slice(0,r),s=e.slice(r+7),a=t.taskOutputs[n];if(!a)return;if(!s||s==="")return a;if(s.startsWith("."))return cr(a,s.slice(1))}}function ur(e,t={},r){switch(e.type){case"HTTP":{const n=t.http_request||e.httpRequest||t;return{response:{statusCode:200,headers:{"content-type":"application/json","x-sandbox":"true"},body:{code:0,status:"SUCCESS",message:`Simulated HTTP ${n?.method||"GET"} response for ${e.name}`,requestEcho:n?.uri||"/api/v1/resource",data:{id:`res_${e.taskReferenceName}_${r||1}`,verified:!0,score:95,items:[{id:1,name:"item-alpha"},{id:2,name:"item-beta"}]}}}}}case"JSON_JQ_TRANSFORM":{const n=t.queryExpression||e.inputParameters?.queryExpression||".";if(n==="."||!n){const s={...t};return delete s.queryExpression,{result:s,resultList:[s]}}if(typeof n=="string"&&n.startsWith(".")){const s=n.slice(1).replace(/\[\]/g,""),a=s?cr(t,s):t;return{result:a!==void 0?a:{transformed:!0,expression:n},resultList:Array.isArray(a)?a:[a??{transformed:!0}]}}return{result:{transformed:!0,queryExpression:n,sourceKeys:Object.keys(t)},resultList:[{transformed:!0}]}}case"SET_VARIABLE":return{variables:{...Object.keys(t).length?t:e.inputParameters||{}}};case"INLINE":return{result:{evaluated:!0,evaluatorType:t.evaluatorType||e.evaluatorType||"graaljs",summary:`Executed inline script for ${e.taskReferenceName}`,...t}};case"EVENT":return{event_produced:`conductor:event:${e.sink||e.name}`,payload:t};case"WAIT":return{waited:!0,duration:t.duration||"1s"};case"TERMINATE":return{terminationStatus:t.terminationStatus||"COMPLETED",terminationReason:t.terminationReason||"Terminated in sandbox dry-run",output:t.workflowOutput||{}};default:return{code:0,status:"OK",result:`Simulated output from ${e.name}`,processedAt:new Date().toISOString(),iteration:r??1,inputEcho:t,data:{id:`${e.taskReferenceName}_out_${r||1}`,approved:!0,amount:t.amount??100}}}}function Iv(e,t,r,n){const s=am(r.taskMocks[e.taskReferenceName]);if(s?.outputData)return e.type==="SET_VARIABLE"&&Object.assign(r.variables,s.outputData),structuredClone(s.outputData);e.type==="SET_VARIABLE"&&Object.assign(r.variables,t);const a=ur(e,t,n);return a.processedAt&&(a.processedAt=new Date(r.currentTimeMs).toISOString()),a}function Rv(e,t,r,n){if(n)return n;const s=Object.keys(r);if(s.length===0)return"default";const a=e.caseValueParam||"case_value",i=t[a]??e.expression;if(i!=null){const l=String(i).trim();if(r[l])return l;for(const c of s)if(l.includes(c))return c}return s[0]}function fr(e,t,r){for(const n of e){const s=Ov(n,t,r);if(s==="FAILED"||s==="TERMINATED")return s}return"COMPLETED"}function Ov(e,t,r){t.seqCounter+=1;const n=t.seqCounter,s=t.currentTimeMs,a=8+n%5*4,i=s+a;t.currentTimeMs=i;const l=am(t.taskMocks[e.taskReferenceName]),c=dr(e.inputParameters||{},t),d=r&&r>1?`${e.taskReferenceName}__${r}`:e.taskReferenceName;if(e.type==="SWITCH"||e.type==="DECISION"){const y=e.decisionCases||{},b=Rv(e,c,y,l?.forceCase),k=b==="__default__"?e.defaultCase||[]:y[b]||e.defaultCase||[],_={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i+(l?.durationMs??12),seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{...c,case_value_param:b},outputData:l?.outputData||{selectedCase:b==="__default__"?"defaultCase":b,evaluatedExpression:e.expression||e.caseValueParam||"default"},workflowTask:e};return t.currentTimeMs=_.endTime,t.taskOutputs[e.taskReferenceName]=_.outputData,t.tasks.push(_),fr(k,t,r)}if(e.type==="FORK_JOIN"){const y=e.forkTasks||[],b=i,k={taskId:`sandbox-task-${n}`,taskType:"FORK_JOIN",taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:b,endTime:b+10,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:c,outputData:{forkedBranches:y.length},workflowTask:e};t.tasks.push(k);const _=b+10;let w=_;for(const T of y){t.currentTimeMs=_;const O=fr(T,t,r);if(t.currentTimeMs>w&&(w=t.currentTimeMs),O!=="COMPLETED")return O}return t.currentTimeMs=w,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}if(e.type==="JOIN"){const y=e.joinOn||[],b={};for(const w of y)t.taskOutputs[w]&&(b[w]=t.taskOutputs[w]);const k=i+15,_={taskId:`sandbox-task-${n}`,taskType:"JOIN",taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:k,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{joinOn:y},outputData:b,workflowTask:e};return t.currentTimeMs=k,t.taskOutputs[e.taskReferenceName]=b,t.tasks.push(_),"COMPLETED"}if(e.type==="DO_WHILE"){const y=e.loopOver||[],b=Math.max(1,Math.min(t.maxLoopIterations,10)),k={taskId:`sandbox-task-${n}`,taskType:"DO_WHILE",taskDefName:e.name,referenceTaskName:d,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i,seq:n,pollCount:1,retryCount:0,iteration:b,inputData:{loopCondition:e.loopCondition,resolvedInput:c},outputData:{iteration:b},workflowTask:e};t.tasks.push(k);const _={};for(let w=1;w<=b;w++){const T=fr(y,t,w);_[String(w)]={};for(const O of y)t.taskOutputs[O.taskReferenceName]&&(_[String(w)][O.taskReferenceName]=t.taskOutputs[O.taskReferenceName]);if(T!=="COMPLETED")return k.endTime=t.currentTimeMs,T}return k.endTime=t.currentTimeMs+10,k.outputData={iteration:b,..._},t.currentTimeMs=k.endTime,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}const u=e.type==="HTTP"?145+n%4*35:e.type==="SIMPLE"?85+n%5*30:28+n%3*12,f=typeof l?.durationMs=="number"&&l.durationMs>=0?l.durationMs:u,h=i+f,p=Iv(e,c,t,r),m=e.type==="TERMINATE"&&c.terminationStatus==="FAILED",g=l?.status||(m?"FAILED_WITH_TERMINAL_ERROR":"COMPLETED"),x=g==="FAILED"||g==="FAILED_WITH_TERMINAL_ERROR"||g==="TIMED_OUT",v={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:d,status:g,scheduledTime:s,startTime:i,endTime:h,seq:n,pollCount:1,retryCount:0,iteration:r,workerId:"browser-local-sandbox-worker",inputData:c,outputData:p,reasonForIncompletion:x?l?.reasonForIncompletion||(m?c.terminationReason||"Terminated with FAILED status":`沙箱人工模拟任务异常 (${g})`):void 0,workflowTask:e};return t.currentTimeMs=h,t.taskOutputs[e.taskReferenceName]=p,t.tasks.push(v),x?"FAILED":e.type==="TERMINATE"?m?"FAILED":"TERMINATED":"COMPLETED"}function Lt(e){const t={orderId:"ORD-2026-88412",userId:"usr_99201",amount:299,currency:"CNY",env:"sandbox"};if(Array.isArray(e.inputParameters))for(const r of e.inputParameters){const n=typeof r=="string"?r:r?.name,s=typeof r=="object"&&r!==null?r.example??r.defaultValue??`sample_${n}`:`sample_${n}`;n&&!(n in t)&&(t[n]=s)}try{const r=JSON.stringify(e.tasks||[]),n=/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)/g;let s;for(;(s=n.exec(r))!==null;){const a=s[1];a&&!(a in t)&&(t[a]=`mock_${a}`)}}catch{}return t}function im(e,t={}){const r=Date.now()-2e3,n=t.workflowInput||Lt(e),s={workflowInput:n,variables:{},taskOutputs:{},taskMocks:t.taskMocks||{},tasks:[],currentTimeMs:r,maxLoopIterations:t.maxLoopIterations??2,seqCounter:0},a=fr(e.tasks||[],s),i={};if(e.outputParameters&&Object.keys(e.outputParameters).length>0)Object.assign(i,dr(e.outputParameters,s));else{const c=s.tasks[s.tasks.length-1];c?.outputData&&Object.assign(i,c.outputData)}const l=a==="FAILED"?"FAILED":a==="TERMINATED"?"TERMINATED":"COMPLETED";return{workflowId:`sandbox-dryrun-${Date.now().toString(36)}`,workflowName:e.name||"sandbox_workflow",workflowVersion:e.version||1,status:l,startTime:r,endTime:s.currentTimeMs,createTime:r,updateTime:s.currentTimeMs,input:n,output:i,variables:s.variables,tasks:s.tasks,workflowDefinition:structuredClone(e)}}function Dt(e,t=[]){return Array.isArray(e)&&e.forEach((r,n)=>{if(r){if(r.type==="FORK_JOIN_DYNAMIC"){for(let s=n+1;s<e.length;s++)if(e[s]?.type==="JOIN"||e[s]?.type==="EXCLUSIVE_JOIN"){t.push({forkRef:r.taskReferenceName,joinRef:e[s].taskReferenceName});break}}r.decisionCases&&Object.values(r.decisionCases).forEach(s=>Dt(s,t)),r.defaultCase&&Dt(r.defaultCase,t),Array.isArray(r.forkTasks)&&r.forkTasks.forEach(s=>Dt(s,t)),Array.isArray(r.loopOver)&&Dt(r.loopOver,t)}}),t}const oe=vr()(Tl(Vm((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"business",simState:{},isSimRunning:!1,workflowLoadKey:0,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,showDataLineage:!1,lastRefactorNotice:null,showWaterfallPanel:!1,timeTravelTimestamp:null,activeLoopIterations:{},inlineCopilotTaskRef:null,setWorkflow:(r,n)=>{const s=n||t().layoutDirection,a=JSON.parse(JSON.stringify(r));Le(a.tasks);const{nodes:i,edges:l,taskMap:c}=Ae(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:u}=je(i,l,{direction:s,mode:t().mode}),f=We(a);e({workflowDef:a,nodes:d,edges:u,taskMap:c,validationResults:f,layoutDirection:s,workflowLoadKey:t().workflowLoadKey+1})},setMode:r=>{t().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{},timeTravelTimestamp:null,showWaterfallPanel:!1,activeLoopIterations:{}}),e({mode:r});const{workflowDef:s,layoutDirection:a}=t();if(s){const{nodes:i,edges:l,taskMap:c}=Ae(s,a,{hideEmptyBranches:r!=="edit"}),{nodes:d,edges:u}=je(i,l,{direction:a,mode:r});e({nodes:d,edges:u,taskMap:c})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:t().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,n)=>{const{executionData:s}=t();if(!s)return;const a={...s};a[r]&&(a[r]={...a[r],status:n},e({executionData:a}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();t().importExecutionJSON(n)}catch(r){console.error("Failed to load sample execution:",r),alert("加载示例运行数据失败")}},importExecutionJSON:r=>{if(!r)return;let n=[],s=null,a=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(a=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;a&&JSON.stringify(a)!==JSON.stringify(t().workflowDef)&&t().setWorkflow(a);const i=t().taskMap,l={},c=(p,m,g)=>{const x=g!==void 0&&m.iteration===void 0?{...m,iteration:g}:m;l[p]||(l[p]={taskReferenceName:p,status:x.status,attempts:[],startTime:x.startTime,endTime:x.endTime,output:x.outputData,input:x.inputData,reasonForIncompletion:x.reasonForIncompletion,iteration:x.iteration}),l[p].attempts.push(x)};n.forEach(p=>{const m=p.referenceTaskName;if(!m)return;const g=m.match(/^(.+)__(\d+)$/);if(g&&i[g[1]]){const x=g[1],v=parseInt(g[2],10);c(x,p,v)}c(m,p)}),Object.values(l).forEach(p=>{p.attempts.some(x=>x.iteration!==void 0&&x.iteration>0)?(p.attempts.sort((x,v)=>(x.iteration??0)-(v.iteration??0)),p.totalIterations=p.attempts.reduce((x,v)=>Math.max(x,v.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((x,v)=>(x.retryCount??0)-(v.retryCount??0));const g=p.attempts[p.attempts.length-1];g&&(p.status=g.status,p.endTime=g.endTime,p.output=g.outputData,p.input=g.inputData,p.reasonForIncompletion=g.reasonForIncompletion,p.iteration=g.iteration)});const u=t().workflowDef?.tasks||[],f=Dt(u),h={};f.forEach(({forkRef:p,joinRef:m})=>{const g=n.findIndex(y=>y.referenceTaskName===p),x=n.findIndex(y=>y.referenceTaskName===m);if(g<0||x<0)return;const v=new Set;h[p]=n.slice(g+1,x).filter(y=>!y.referenceTaskName||!y.taskId||i[y.referenceTaskName]||v.has(y.referenceTaskName)?!1:(v.add(y.referenceTaskName),!0)).map(y=>y)}),e({executionData:l,dynamicRuntimeTasksByFork:h,workflowInstance:s,timeTravelTimestamp:null,activeLoopIterations:{},mode:"run"})},setSelectedTask:r=>e({selectedTask:r?{...r}:null}),setIsDetailPanelOpen:r=>e({isDetailPanelOpen:r}),selectTaskAction:(r,n=!0)=>{e({selectedTask:r?{...r}:null,isDetailPanelOpen:r?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:r=>e({selectedTaskInstance:r}),setLayoutDirection:r=>{const{workflowDef:n}=t();if(n){const{nodes:s,edges:a,taskMap:i}=Ae(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:c}=je(s,a,{direction:r,mode:t().mode});e({nodes:l,edges:c,taskMap:i,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,s=new Set(n.map(i=>i.id)),a=r.filter(i=>"id"in i&&s.has(i.id));a.length!==0&&e({nodes:M.applyNodeChanges(a,n)})},onEdgesChange:r=>{const n=t().edges,s=M.applyEdgeChanges(r,n);s!==n&&e({edges:s})},onConnect:r=>{const{edges:n,layoutDirection:s}=t(),a=M.addEdge(r,n),{nodes:i,edges:l}=je(t().nodes,a,{direction:s,mode:t().mode});e({edges:l,nodes:i})},checkTaskRefUniqueness:(r,n)=>{if(r===n)return!0;const{taskMap:s}=t();return!s[r]},updateTask:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;let l=JSON.parse(JSON.stringify(a)),c=t().lastRefactorNotice;const d=typeof n=="object"?Object.keys(n):[n],u=typeof n=="object"?n.taskReferenceName:n==="taskReferenceName"?s:void 0;let f=r;if(typeof u=="string"&&u.trim()&&u.trim()!==r){const p=u.trim(),m=sm(l,r,p);l=m.updatedDef,f=p,m.replacedCount>0&&(c={oldRef:r,newRef:p,replacedCount:m.replacedCount,affectedTasks:m.affectedTaskRefs,timestamp:Date.now()})}const h=Me(l.tasks,f);if(h){typeof n=="object"?Object.assign(h,n,{taskReferenceName:f}):n!=="taskReferenceName"&&(h[n]=s),Le(l.tasks);const p=We(l),m=new Set(["taskReferenceName","type","decisionCases","defaultCase","forkTasks","loopOver","joinOn"]);if(d.some(x=>m.has(x))){const{nodes:x,edges:v,taskMap:y}=Ae(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:b,edges:k}=je(x,v,{direction:i,mode:t().mode}),_=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:b,edges:k,taskMap:y,selectedTask:_,validationResults:p,lastRefactorNotice:c})}else{const x=t().nodes.map(b=>b.data?.taskReferenceName===r?{...b,data:{...b.data,label:h.name||b.data.label,task:h,loopCondition:h.loopCondition??b.data.loopCondition,subWorkflowName:h.subWorkflowParam?.name??b.data.subWorkflowName}}:b),v={...t().taskMap,[r]:h},y=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:x,taskMap:v,selectedTask:y,validationResults:p})}}},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,r),Le(a.tasks);const i=We(a);if("tasks"in r){const{nodes:l,edges:c,taskMap:d}=Ae(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:f}=je(l,c,{direction:s,mode:t().mode});e({workflowDef:a,nodes:u,edges:f,taskMap:d,validationResults:i})}else e({workflowDef:a,validationResults:i})},addNode:(r,n,s,a,i={})=>{const{workflowDef:l,layoutDirection:c}=t();if(!l)return;const d=JSON.parse(JSON.stringify(l)),u={name:r.data.label,taskReferenceName:r.data.taskReferenceName,type:r.data.taskType||"SIMPLE",inputParameters:{}};switch(u.type){case"HTTP":u.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":u.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":u.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":u.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":u.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":u.sink="conductor";break;case"WAIT":u.inputParameters={duration:"30s"};break;case"TERMINATE":u.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(u.type==="FORK_JOIN"||u.type==="FORK_JOIN_DYNAMIC"){u.type==="FORK_JOIN"?u.forkTasks=[[],[]]:(u.dynamicForkTasksParam="dynamic_tasks",u.dynamicForkTasksInputParamName="input");const v={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(i.isWorkflowStart)d.tasks.unshift(v),d.tasks.unshift(u);else if(i.isLoopBodyStart){const y=Me(d.tasks,n);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(v),y.loopOver.unshift(u))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?(yt(d.tasks,n,i,u),Je(d.tasks,u.taskReferenceName,v)):d.tasks.length===0?d.tasks.push(u,v):(Je(d.tasks,n,u),Je(d.tasks,u.taskReferenceName,v))}else if(u.type==="DECISION"||u.type==="SWITCH"?(u.evaluatorType="value-param",u.caseValueParam="case_param",u.decisionCases={case1:[]},u.defaultCase=[]):u.type==="DO_WHILE"?(u.loopCondition="$.taskReferenceName.output.value < 10",u.loopOver=[]):u.type==="INLINE"?(u.evaluatorType="graaljs",u.inputParameters={expression:`function execute(input) {
7
12
  return { result: input };
8
13
  }
9
- execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",u.inputParameters={taskToExecute:"${workflow.input.taskName}"}):u.type==="HUMAN"?u.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:u.type==="START_WORKFLOW"?u.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:u.type==="NOOP"&&(u.inputParameters={}),o.isWorkflowStart)c.tasks.unshift(u);else if(o.isLoopBodyStart){const y=Ce(c.tasks,n);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(u))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?ir(c.tasks,n,o,u):c.tasks.length===0?c.tasks.push(u):Ae(c.tasks,n,u);we(c.tasks);const{nodes:f,edges:p,taskMap:h}=Ee(c,d,{hideEmptyBranches:r().mode!=="edit"}),{nodes:g,edges:m}=_e(f,p,{direction:d,mode:r().mode}),v=Re(c);e({workflowDef:c,nodes:g,edges:m,taskMap:h,validationResults:v})},removeNode:t=>{const{workflowDef:n,layoutDirection:s,nodes:a}=r();if(!n)return;const o=JSON.parse(JSON.stringify(n)),i=or(o.tasks,t);if(i){const g=a.find(m=>m.id===t)?.data?.taskType;if(g==="FORK_JOIN"||g==="FORK_JOIN_DYNAMIC"){const m=kh(i,t);m&&Me(o.tasks,m)}else if(g==="JOIN"||g==="EXCLUSIVE_JOIN"){const m=_h(i,t);m&&Me(o.tasks,m)}}Me(o.tasks,t),we(o.tasks);const{nodes:d,edges:c,taskMap:u}=Ee(o,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=_e(d,c,{direction:s,mode:r().mode}),h=Re(o);e({workflowDef:o,nodes:f,edges:p,taskMap:u,validationResults:h})},addLoopTask:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&i.type==="DO_WHILE"){i.loopOver||(i.loopOver=[]);const d={name:`new_${n.toLowerCase()}`,taskReferenceName:`${t}_sub_${Date.now()}`,type:n,inputParameters:{}};i.loopOver.push(d),we(o.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:a,mode:r().mode}),g=Re(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},removeLoopTask:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&i.type==="DO_WHILE"&&i.loopOver){const d=or(i.loopOver,n);if(d){const m=d.find(v=>v.taskReferenceName===n);if(m?.type==="FORK_JOIN"||m?.type==="FORK_JOIN_DYNAMIC"){const v=kh(d,n);v&&Me(i.loopOver,v)}else if(m?.type==="JOIN"||m?.type==="EXCLUSIVE_JOIN"){const v=_h(d,n);v&&Me(i.loopOver,v)}}Me(i.loopOver,n),we(o.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:a,mode:r().mode}),g=Re(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},addDecisionBranch:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){n==="default"?i.defaultCase||(i.defaultCase=[]):(i.decisionCases||(i.decisionCases={}),i.decisionCases[n]||(i.decisionCases[n]=[])),we(o.tasks);const{nodes:d,edges:c,taskMap:u}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=_e(d,c,{direction:a,mode:r().mode}),h=Re(o);e({workflowDef:o,nodes:f,edges:p,taskMap:u,validationResults:h})}},removeDecisionBranch:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){n==="default"?i.defaultCase=[]:i.decisionCases&&delete i.decisionCases[n],we(o.tasks);const{nodes:d,edges:c,taskMap:u}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=_e(d,c,{direction:a,mode:r().mode}),h=Re(o);e({workflowDef:o,nodes:f,edges:p,taskMap:u,validationResults:h})}},renameDecisionBranch:(t,n,s)=>{const{workflowDef:a,layoutDirection:o}=r();if(!a||!s.trim()||n===s)return;const i=JSON.parse(JSON.stringify(a)),d=Ce(i.tasks,t);if(d&&(d.type==="DECISION"||d.type==="SWITCH")){if(!d.decisionCases||!d.decisionCases[n])return;d.decisionCases[s.trim()]=d.decisionCases[n],delete d.decisionCases[n],we(i.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:o,mode:r().mode}),g=Re(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},addForkBranch:t=>{const{workflowDef:n,layoutDirection:s}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n)),o=Ce(a.tasks,t);if(o&&o.type==="FORK_JOIN"){o.forkTasks||(o.forkTasks=[]),o.forkTasks.push([]),we(a.tasks);const{nodes:i,edges:d,taskMap:c}=Ee(a,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:u,edges:f}=_e(i,d,{direction:s,mode:r().mode}),p=Re(a);e({workflowDef:a,nodes:u,edges:f,taskMap:c,validationResults:p})}},copyTask:t=>e({copiedTask:t}),pasteTask:t=>{const{workflowDef:n,layoutDirection:s,selectedTask:a}=r();if(!n)return;const o=JSON.parse(JSON.stringify(n)),d=`_copy_${Date.now()}`,c=JSON.parse(JSON.stringify(t)),u=x=>{x.taskReferenceName=`${x.taskReferenceName}${d}`,x.decisionCases&&Object.values(x.decisionCases).forEach(b=>b.forEach(u)),x.defaultCase&&x.defaultCase.forEach(u),x.forkTasks&&x.forkTasks.forEach(b=>b.forEach(u)),x.loopOver&&x.loopOver.forEach(u)};u(c);const f=a?a.taskReferenceName:o.tasks.length>0?o.tasks[o.tasks.length-1].taskReferenceName:"start";if(c.type==="FORK_JOIN"){c.forkTasks||(c.forkTasks=[[],[]]);const x={name:`${c.name}_join`,taskReferenceName:`${c.taskReferenceName}_join`,type:"JOIN",joinOn:[]};o.tasks.length===0?o.tasks.push(c,x):(Ae(o.tasks,f,c),Ae(o.tasks,c.taskReferenceName,x))}else o.tasks.length===0?o.tasks.push(c):Ae(o.tasks,f,c);we(o.tasks);const{nodes:p,edges:h,taskMap:g}=Ee(o,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:m,edges:v}=_e(p,h,{direction:s,mode:r().mode}),y=Re(o);e({workflowDef:o,nodes:m,edges:v,taskMap:g,validationResults:y})},setTheme:t=>e({theme:t}),setThemeColor:t=>e({themeColor:t}),setEdgeType:t=>e({edgeType:t}),setNodesLocked:t=>e({nodesLocked:t}),setViewMode:t=>e({viewMode:t}),startSimulation:()=>{const{edges:t,nodes:n,isSimRunning:s}=r();if(s)return;const a=n.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),o=t.map(f=>({source:f.source,target:f.target})),i=Fy(a,o);e({isSimRunning:!0,simState:{}});const d={timer:null};r().__simHandle=d;let c=0;const u=()=>{if(c>=i.length||!r().isSimRunning){e({isSimRunning:!1});return}const f=i[c];e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="running"),{simState:h}}),d.timer=setTimeout(()=>{r().isSimRunning&&(e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="done"),{simState:h}}),c++,d.timer=setTimeout(u,280))},700)};u()},stopSimulation:()=>{const t=r().__simHandle;t?.timer&&clearTimeout(t.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:t=>{const n={name:t||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};r().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:t=>{const{tasks:n,...s}=t,a={...s,name:t.name||"AI_Generated_Workflow",tasks:n||[],version:t.version||1,schemaVersion:2};r().setWorkflow(a)},setShowRunPanel:t=>e({showRunPanel:t}),setShowAnalysisPanel:t=>e({showAnalysisPanel:t}),setRunState:(t,n,s)=>{e({runState:t,pendingExecutionId:n!==void 0?n:r().pendingExecutionId,executionError:s!==void 0?s:r().executionError})},switchToEditAndFocusParam:(t,n)=>{const{workflowDef:s,layoutDirection:a,taskMap:o}=r();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:i,edges:d,taskMap:c}=Ee(s,a,{hideEmptyBranches:!1}),{nodes:u,edges:f}=_e(i,d,{direction:a,mode:"edit"});e({nodes:u,edges:f,taskMap:c});const p=o[t]||c[t];p&&e({selectedTask:{...p},isDetailPanelOpen:!0,showAnalysisPanel:!1})}}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes,edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,r)=>JSON.stringify(e.workflowDef)===JSON.stringify(r.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:Yi(()=>localStorage),migrate:(e,r)=>(r===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const $y=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),zy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,t,n)=>n?n.toUpperCase():t.toLowerCase()),wh=e=>{const r=zy(e);return r.charAt(0).toUpperCase()+r.slice(1)},Th=(...e)=>e.filter((r,t,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===t).join(" ").trim(),Hy=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var Ky={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Uy=P.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:o,...i},d)=>P.createElement("svg",{ref:d,...Ky,width:r,height:r,stroke:e,strokeWidth:n?Number(t)*24/Number(r):t,className:Th("lucide",s),...!a&&!Hy(i)&&{"aria-hidden":"true"},...i},[...o.map(([c,u])=>P.createElement(c,u)),...Array.isArray(a)?a:[a]]));const Se=(e,r)=>{const t=P.forwardRef(({className:n,...s},a)=>P.createElement(Uy,{ref:a,iconNode:r,className:Th(`lucide-${$y(wh(e))}`,`lucide-${e}`,n),...s}));return t.displayName=wh(e),t};const Eh=Se("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const Jy=Se("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const Gy=Se("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Nh=Se("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const Vy=Se("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const Kr=Se("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const Ur=Se("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);const Yy=Se("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Xy=Se("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const Zy=Se("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Qy=Se("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const ex=Se("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Ch=Se("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const Bi=Se("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);const rx=Se("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const tx=Se("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const nx=Se("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ax={business:["business"],standard:["business","control"],developer:["business","control","data"]},Xe=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Eh,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Ur,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Qy,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:Yy,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:Nh,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:rx,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:Xy,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:nx,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:Gy,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:Vy,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:Jy,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:tx,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Bi,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:Zy,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:Nh,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Bi,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Bi,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:Kr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:Kr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Ch,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Ur,viewCategory:"control"}],sx=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Jr=({message:e,onConfirm:r,onCancel:t})=>{const n=P.useRef(null),{theme:s,themeColor:a}=ie();return P.useEffect(()=>{n.current?.focus({preventScroll:!0});const o=i=>{i.key==="Escape"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),Yr.createPortal(l.jsx("div",{"data-mode":s,"data-brand":a,onClick:t,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:l.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:o=>o.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[l.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),l.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[l.jsx("button",{ref:n,onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),l.jsx("button",{onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},br=({children:e,nodeId:r,selected:t=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:a=!1,isDecision:o=!1,isHighlighted:i=!1,executionStatus:d,simRunning:c=!1,simDone:u=!1})=>{const{mode:f,removeNode:p}=ie(),[h,g]=P.useState(!1),m=k=>{k.stopPropagation(),g(!0)},v=f==="edit"&&!n,x=[o?"decision-node-wrapper":"node-wrapper-glass",t?"node-wrapper-selected":"",i?"node-wrapper-highlighted":"",c?"node-sim-running":"",u?"node-sim-done":""].filter(Boolean).join(" "),b=P.useMemo(()=>{if(f!=="run")return{};if(!d)return{opacity:.4};switch(d){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[f,d]);return l.jsxs("div",{className:x,style:{position:"relative",...b},children:[v&&l.jsx("button",{onClick:m,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!s&&a&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),e,h&&l.jsx(Jr,{message:"确定要删除此任务吗?",onConfirm:()=>{p(r),g(!1)},onCancel:()=>g(!1)})]})},ox=({status:e})=>{const r=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:t,className:n}=r();return l.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:l.jsx("span",{className:"badge-icon",children:t})})},jh=P.memo(ox),ix=({icon:e,header:r,title:t,meta:n,color:s,status:a,isRunning:o,children:i,width:d="240px",border:c=!0})=>l.jsxs("div",{style:{display:"flex",flexDirection:"row",width:d,height:"100%",position:"relative",overflow:"hidden",border:c?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[l.jsx("div",{style:{width:"48px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(205, 74, 74, 0.03)",borderRight:"1px solid var(--color-accent)",color:s},children:l.jsx(e,{size:20,strokeWidth:1.5})}),l.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:s},children:r}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:t,children:t}),n&&l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n}),i&&l.jsx("div",{style:{marginTop:"8px"},children:i})]}),o&&a&&l.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:l.jsx(jh,{status:a})})]}),Gr=P.memo(ix),Ze=e=>{const r=e.layoutDirection||"TB",t=e.sourcePosition||(r==="LR"?A.Position.Right:A.Position.Bottom),n=e.targetPosition||(r==="LR"?A.Position.Left:A.Position.Top);return{layoutDirection:r,sourcePosition:t,targetPosition:n}},lr=e=>{const{mode:r,executionData:t}=ie(),n=r==="run"?t?.[e]:null,s=r==="run",a=n?.attempts.some(d=>d.iteration!==void 0&&d.iteration>1)??!1,o=n?.attempts[n.attempts.length-1],i=a?0:o?.retryCount??0;return{mode:r,execution:n,isRunning:s,retryCount:i}};function He(e,r){return e.length>r?e.slice(0,r)+"…":e}function kr(e,r,t,n){if(t==="business")return r.task?.description?.trim()||n;if(t==="standard")return n;const s=r.task;if(!s)return n;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const o=s.httpRequest||a.http_request;if(!o)return n;const i=(o.method||"GET").toUpperCase(),d=o.uri?He(String(o.uri),28):"";return d?`${i} ${d}`:i}case"SWITCH":{const o=s.caseExpression||a.expression,i=s.evaluatorType||a.evaluatorType;return o?He(o,35):i||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${He(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const o=s.evaluatorType||a.evaluatorType;return o?`${o} script`:n}case"SUB_WORKFLOW":{const o=s.subWorkflowParam;return o?`${o.name}${o.version?` v${o.version}`:""}`:n}case"DO_WHILE":{const o=s.loopCondition;return o?He(o,35):n}case"JSON_JQ_TRANSFORM":{const o=a.queryExpression||a.query_expression;return o?He(o,35):n}case"SET_VARIABLE":{const o=Object.keys(a);return o.length?`set: ${o.slice(0,2).join(", ")}${o.length>2?"…":""}`:n}case"EVENT":{const o=s.sink||a.sink;return o?`→ ${He(o,32)}`:n}case"KAFKA_PUBLISH":{const o=a.topic||a.kafka_request?.topic;return o?`topic: ${He(o,28)}`:n}case"START_WORKFLOW":{const o=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return o?`→ ${o}`:n}default:return n}}const lx=({id:e,data:r,selected:t})=>{const n=r.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=Ze(r),{execution:o,isRunning:i,retryCount:d}=lr(r.taskReferenceName),c=ie(v=>v.viewMode),u=P.useMemo(()=>Xe.find(v=>v.type===n),[n]),f=u?.icon||Eh,p=n==="NOOP",h=r.isDynamicRuntime===!0,g=p?"var(--text-secondary)":"var(--color-accent)",m=P.useMemo(()=>{let v;return h?v=`Dynamic (${n})`:n==="SIMPLE"?v=r.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?v="REST API Call":n==="JSON_JQ_TRANSFORM"?v="JQ Expression":n==="INLINE"||n==="LAMBDA"?v="Inline Script":n==="START_WORKFLOW"?v="Launch Workflow (no wait)":n==="DYNAMIC"?v="Dynamic Task Type":n==="HUMAN"?v="Human Approval":n==="NOOP"?v="No Operation":v=u?.label||n,kr(n,r,c,v)},[n,u,r,c,h]);return l.jsx(br,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:o?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{style:{borderRadius:"8px",background:p?"var(--bg-tertiary)":"var(--bg-secondary)",opacity:p?.7:1,position:"relative",outline:h?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[l.jsx(Gr,{icon:f,header:n,title:r.taskReferenceName,meta:m,color:g,status:o?.status,isRunning:i}),i&&d>0&&l.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",d]}),h&&l.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},cx=P.memo(lx),Ih=({title:e,label:r,defaultValue:t="",placeholder:n="",confirmText:s="确定",cancelText:a="取消",onConfirm:o,onCancel:i})=>{const{theme:d,themeColor:c}=ie(),[u,f]=P.useState(t),p=P.useRef(null);P.useEffect(()=>{p.current&&(p.current.focus({preventScroll:!0}),p.current.select());const g=m=>{m.key==="Escape"&&(m.stopPropagation(),i())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[i]);const h=()=>{const g=u.trim();g&&o(g)};return Yr.createPortal(l.jsx("div",{"data-mode":d,"data-brand":c,onClick:i,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:l.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:g=>g.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[l.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),r&&l.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:r}),l.jsx("input",{ref:p,type:"text",value:u,placeholder:n,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),h()),g.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:g=>{g.currentTarget.style.borderColor="var(--color-accent)"},onBlur:g=>{g.currentTarget.style.borderColor="var(--border-primary)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[l.jsx("button",{onClick:i,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),l.jsx("button",{onClick:h,disabled:!u.trim(),style:{padding:"7px 18px",backgroundColor:u.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:u.trim()?"#ffffff":"var(--text-secondary)",cursor:u.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},ux=({id:e,data:r,selected:t})=>{const{layoutDirection:n}=Ze(r),{mode:s,execution:a,isRunning:o}=lr(r.taskReferenceName),{addDecisionBranch:i,removeDecisionBranch:d,renameDecisionBranch:c,viewMode:u}=ie(),[f,p]=P.useState(!1),[h,g]=P.useState({type:"none"}),m=n==="LR"?A.Position.Left:A.Position.Top,v=Object.keys(r.decisionCases||r.task?.decisionCases||{}),y=()=>{p(!1),g({type:"add"})},x=(C,S)=>{C.stopPropagation(),g({type:"delete",branch:S})},b=(C,S)=>{C.stopPropagation(),p(!1),g({type:"rename",branch:S})},k=C=>{C&&i(e,C),g({type:"none"})},w=C=>{h.type==="rename"&&(C&&C!==h.branch&&c(e,h.branch,C),g({type:"none"}))},j=()=>{h.type==="delete"&&(d(e,h.branch),g({type:"none"}))},N=()=>g({type:"none"}),T=o?(C=>C&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[C]||"")(a?.status):"";return l.jsxs(br,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isDecision:!0,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:[l.jsxs("div",{style:{position:"relative"},children:[l.jsx(A.Handle,{type:"target",position:m,style:{background:"#fff",[n==="LR"?"left":"top"]:"-5px"}}),o&&a?.status&&l.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:l.jsx(jh,{status:a.status})}),l.jsx("div",{className:T,style:{width:"150px",height:"150px",background:o&&a?.status?void 0:"var(--bg-secondary)",border:t?"4px solid #fbbf24":o&&a?.status?void 0:"4px solid var(--border-primary)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:t?"0 10px 30px rgba(0,0,0,0.3), 0 0 0 4px rgba(251, 191, 36, 0.3)":o&&a?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>s==="edit"&&p(!f),children:l.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:r.taskType}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-word",maxHeight:"60px",overflow:"hidden",marginBottom:"4px"},children:r.label}),s==="edit"&&l.jsx("div",{style:{marginTop:"4px",width:"24px",height:"24px",fontSize:"16px",background:"rgba(255,255,255,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--text-secondary)"},children:"+"}),o&&a?.startTime&&l.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:a.endTime?`${((a.endTime-a.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),s==="edit"&&f&&l.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"160px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[l.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),v.map(C=>l.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[l.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:C}),l.jsx("button",{onClick:S=>b(S,C),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${C}"`,children:"✏"}),l.jsx("button",{onClick:S=>x(S,C),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${C}"`,children:"×"})]},C)),l.jsx("button",{onClick:y,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),u==="developer"&&(()=>{const C=r.task?.caseExpression||r.task?.inputParameters?.expression,S=r.task?.caseValueParam;return!C&&!S?null:l.jsx("div",{style:{position:"absolute",top:"158px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:C?He(C,22):`param: ${S}`})})(),n==="TB"?l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"source",position:A.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"source",position:A.Position.Right,style:{background:"#fff",right:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]}),h.type==="add"&&l.jsx(Ih,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${v.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:k,onCancel:N}),h.type==="rename"&&l.jsx(Ih,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:w,onCancel:N}),h.type==="delete"&&l.jsx(Jr,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:j,onCancel:N})]})},dx=P.memo(ux),Rh="var(--color-accent)",Oh=P.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=Ze(r),{mode:o,execution:i,isRunning:d}=lr(r.taskReferenceName),{addForkBranch:c}=ie(),u=A.useUpdateNodeInternals(),f=r.task?.forkTasks?.length||0;P.useEffect(()=>{u(e)},[f,e,u]);const p=r.isDynamic||r.taskType==="FORK_JOIN_DYNAMIC",h=ie(v=>v.viewMode),m=P.useMemo(()=>Xe.find(v=>v.type==="FORK_JOIN"),[])?.icon||Kr;return l.jsx(br,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:i?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Gr,{icon:m,header:p?"DYNAMIC FORK":"FORK",title:r.taskReferenceName,meta:kr(r.taskType,r,h,p?"Dynamic Parallel Execution":"Parallel Execution"),color:Rh,status:i?.status,isRunning:d}),o==="edit"&&!p&&l.jsx("div",{style:{position:"absolute",...n==="LR"?{top:"50%",right:-12,transform:"translateY(-50%)"}:{bottom:-12,left:"50%",transform:"translateX(-50%)"},width:20,height:20,background:"var(--color-accent)",borderRadius:"50%",color:"#fff",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",border:"2px solid var(--bg-primary)"},onClick:v=>{v.stopPropagation(),c(e)},title:"添加分支",children:"+"}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(r.task?.forkTasks||[]).map((v,y,x)=>{if(o!=="edit"&&(!v||v.length===0))return null;const b=o!=="edit"?x.filter(N=>N&&N.length>0):x,k=b.length,j=(b.indexOf(v)+1)/(k+1)*100;return l.jsx(A.Handle,{id:`branch_${y}`,type:"source",position:s,style:{background:"#fff",[n==="LR"?"top":"left"]:`${j}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${y}`)}),!p&&(!r.task?.forkTasks||r.task.forkTasks.length===0)&&l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}}),p&&l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Oh.displayName="ForkNode";const Ph=P.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=Ze(r),{execution:o,isRunning:i}=lr(r.taskReferenceName),d=ie(f=>f.viewMode),u=P.useMemo(()=>Xe.find(f=>f.type==="JOIN"),[])?.icon||Ur;return l.jsx(br,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:o?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Gr,{icon:u,header:r.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE JOIN":"JOIN",title:r.taskReferenceName,meta:kr(r.taskType,r,d,r.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),color:Rh,status:o?.status,isRunning:i}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"target",position:A.Position.Left,id:"left",style:{background:"#fff"}}),l.jsx(A.Handle,{type:"target",position:A.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"target",position:A.Position.Top,id:"top",style:{background:"#fff"}}),l.jsx(A.Handle,{type:"target",position:A.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Ph.displayName="JoinNode";const Ah={ForkNode:Oh,JoinNode:Ph},fx=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:s}=Ze(r),{execution:a,isRunning:o}=lr(r.taskReferenceName),{executionData:i,selectTaskAction:d,mode:c,viewMode:u,removeNode:f}=ie(),[p,h]=P.useState(!1),g=r.task,m=g?.loopOver||[],y=P.useMemo(()=>Xe.find(T=>T.type==="DO_WHILE"),[])?.icon||Ch,x=P.useMemo(()=>{if(!o||!i||m.length===0)return 0;let T=0;return m.forEach(C=>{const S=i[C.taskReferenceName];S?.totalIterations?T=Math.max(T,S.totalIterations):S?.attempts.some(q=>(q.iteration??0)>0)&&(T=Math.max(T,S.attempts.length))}),T},[o,i,m]),b=r.loopCondition||g?.loopCondition||"",k=P.useMemo(()=>{const T=b?b.length>35?b.slice(0,35)+"…":b:"循环直到条件满足";return kr("DO_WHILE",r,u,T)},[r,u,b]),w=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",j=t?`2px solid ${w}`:`1.5px dashed ${o&&a?.status?w:"var(--color-accent)"}`,N=c==="edit",L=u==="developer"&&b;return l.jsxs("div",{style:{width:"100%",height:"100%",border:j,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[N&&l.jsx("button",{onClick:T=>{T.stopPropagation(),h(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),r.isError&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!r.isError&&r.hasWarning&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"42px",pointerEvents:"auto"},children:[l.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:l.jsx(y,{size:14})}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"DO WHILE"}),l.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.taskReferenceName}),(u==="business"||u==="developer")&&k&&l.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:k})]}),o&&x>0&&l.jsxs("div",{onClick:()=>d(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},children:["×",x]}),o&&a?.status&&l.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:w,flexShrink:0}})]}),L&&l.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",b]}),l.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),l.jsx(A.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),p&&l.jsx(Jr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{f(e),h(!1)},onCancel:()=>h(!1)})]})},px=P.memo(fx),hx="var(--color-accent)",gx=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:s}=Ze(r),{execution:a,isRunning:o}=lr(r.taskReferenceName),i=ie(p=>p.viewMode),c=P.useMemo(()=>Xe.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||Ur,u=r.task?.subWorkflowParam?.name||r.subWorkflowName||"Unknown",f=r.task?.subWorkflowParam?.version;return l.jsx(br,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Gr,{icon:c,header:"SUB WORKFLOW",title:r.taskReferenceName,meta:kr("SUB_WORKFLOW",r,i,`Flow: ${u} (v${f})`),color:hx,status:a?.status,isRunning:o}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},mx=P.memo(gx),vx=({data:e})=>{const t=(e.layoutDirection||"TB")==="LR";return l.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[l.jsx(ex,{size:16}),e.label&&e.label!=="+"&&l.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),l.jsx(A.Handle,{type:"target",position:t?A.Position.Left:A.Position.Top,style:{opacity:0}}),l.jsx("style",{dangerouslySetInnerHTML:{__html:`
14
+ execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",u.inputParameters={taskToExecute:"${workflow.input.taskName}"}):u.type==="HUMAN"?u.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:u.type==="START_WORKFLOW"?u.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:u.type==="NOOP"&&(u.inputParameters={}),i.isWorkflowStart)d.tasks.unshift(u);else if(i.isLoopBodyStart){const v=Me(d.tasks,n);v&&(v.loopOver||(v.loopOver=[]),v.loopOver.unshift(u))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?yt(d.tasks,n,i,u):d.tasks.length===0?d.tasks.push(u):Je(d.tasks,n,u);Le(d.tasks);const{nodes:f,edges:h,taskMap:p}=Ae(d,c,{hideEmptyBranches:t().mode!=="edit"}),{nodes:m,edges:g}=je(f,h,{direction:c,mode:t().mode}),x=We(d);e({workflowDef:d,nodes:m,edges:g,taskMap:p,validationResults:x})},removeNode:r=>{const{workflowDef:n,layoutDirection:s,nodes:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),l=gt(i.tasks,r);if(l){const m=a.find(g=>g.id===r)?.data?.taskType;if(m==="FORK_JOIN"||m==="FORK_JOIN_DYNAMIC"){const g=Yh(l,r);g&&Ge(i.tasks,g)}else if(m==="JOIN"||m==="EXCLUSIVE_JOIN"){const g=Xh(l,r);g&&Ge(i.tasks,g)}}Ge(i.tasks,r),Le(i.tasks);const{nodes:c,edges:d,taskMap:u}=Ae(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:h}=je(c,d,{direction:s,mode:t().mode}),p=We(i);e({workflowDef:i,nodes:f,edges:h,taskMap:u,validationResults:p})},addLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&l.type==="DO_WHILE"){l.loopOver||(l.loopOver=[]);const c={name:`new_${n.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:n,inputParameters:{}};l.loopOver.push(c),Le(i.tasks);const{nodes:d,edges:u,taskMap:f}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:p}=je(d,u,{direction:a,mode:t().mode}),m=We(i);e({workflowDef:i,nodes:h,edges:p,taskMap:f,validationResults:m})}},removeLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&l.type==="DO_WHILE"&&l.loopOver){const c=gt(l.loopOver,n);if(c){const g=c.find(x=>x.taskReferenceName===n);if(g?.type==="FORK_JOIN"||g?.type==="FORK_JOIN_DYNAMIC"){const x=Yh(c,n);x&&Ge(l.loopOver,x)}else if(g?.type==="JOIN"||g?.type==="EXCLUSIVE_JOIN"){const x=Xh(c,n);x&&Ge(l.loopOver,x)}}Ge(l.loopOver,n),Le(i.tasks);const{nodes:d,edges:u,taskMap:f}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:p}=je(d,u,{direction:a,mode:t().mode}),m=We(i);e({workflowDef:i,nodes:h,edges:p,taskMap:f,validationResults:m})}},addDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase||(l.defaultCase=[]):(l.decisionCases||(l.decisionCases={}),l.decisionCases[n]||(l.decisionCases[n]=[])),Le(i.tasks);const{nodes:c,edges:d,taskMap:u}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:h}=je(c,d,{direction:a,mode:t().mode}),p=We(i);e({workflowDef:i,nodes:f,edges:h,taskMap:u,validationResults:p})}},removeDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Me(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase=[]:l.decisionCases&&delete l.decisionCases[n],Le(i.tasks);const{nodes:c,edges:d,taskMap:u}=Ae(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:h}=je(c,d,{direction:a,mode:t().mode}),p=We(i);e({workflowDef:i,nodes:f,edges:h,taskMap:u,validationResults:p})}},renameDecisionBranch:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a||!s.trim()||n===s)return;const l=JSON.parse(JSON.stringify(a)),c=Me(l.tasks,r);if(c&&(c.type==="DECISION"||c.type==="SWITCH")){if(!c.decisionCases||!c.decisionCases[n])return;c.decisionCases[s.trim()]=c.decisionCases[n],delete c.decisionCases[n],Le(l.tasks);const{nodes:d,edges:u,taskMap:f}=Ae(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:p}=je(d,u,{direction:i,mode:t().mode}),m=We(l);e({workflowDef:l,nodes:h,edges:p,taskMap:f,validationResults:m})}},addForkBranch:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n)),i=Me(a.tasks,r);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),Le(a.tasks);const{nodes:l,edges:c,taskMap:d}=Ae(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:f}=je(l,c,{direction:s,mode:t().mode}),h=We(a);e({workflowDef:a,nodes:u,edges:f,taskMap:d,validationResults:h})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,layoutDirection:s,selectedTask:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),c=`_copy_${Date.now()}`,d=JSON.parse(JSON.stringify(r)),u=y=>{y.taskReferenceName=`${y.taskReferenceName}${c}`,y.decisionCases&&Object.values(y.decisionCases).forEach(b=>b.forEach(u)),y.defaultCase&&y.defaultCase.forEach(u),y.forkTasks&&y.forkTasks.forEach(b=>b.forEach(u)),y.loopOver&&y.loopOver.forEach(u)};u(d);const f=a?a.taskReferenceName:i.tasks.length>0?i.tasks[i.tasks.length-1].taskReferenceName:"start";if(d.type==="FORK_JOIN"){d.forkTasks||(d.forkTasks=[[],[]]);const y={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};i.tasks.length===0?i.tasks.push(d,y):(Je(i.tasks,f,d),Je(i.tasks,d.taskReferenceName,y))}else i.tasks.length===0?i.tasks.push(d):Je(i.tasks,f,d);Le(i.tasks);const{nodes:h,edges:p,taskMap:m}=Ae(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:g,edges:x}=je(h,p,{direction:s,mode:t().mode}),v=We(i);e({workflowDef:i,nodes:g,edges:x,taskMap:m,validationResults:v})},flashNodes:r=>{if(r.length===0)return;const n=t().__flashTimeout;n&&clearTimeout(n);const s=new Set(r),a={};t().nodes.forEach(l=>{s.has(l.id)&&(a[l.id]=l.selected??!1)}),e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:!0}:c)}));const i=setTimeout(()=>{e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:a[c.id]??!1}:c)}))},2500);t().__flashTimeout=i},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),setViewMode:r=>e({viewMode:r}),startSimulation:()=>{const{edges:r,nodes:n,isSimRunning:s}=t();if(s)return;const a=n.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),i=r.map(f=>({source:f.source,target:f.target})),l=Nv(a,i);e({isSimRunning:!0,simState:{}});const c={timer:null};t().__simHandle=c;let d=0;const u=()=>{if(d>=l.length||!t().isSimRunning){e({isSimRunning:!1});return}const f=l[d];e(h=>{const p={...h.simState};return f.forEach(m=>p[m]="running"),{simState:p}}),c.timer=setTimeout(()=>{t().isSimRunning&&(e(h=>{const p={...h.simState};return f.forEach(m=>p[m]="done"),{simState:p}}),d++,c.timer=setTimeout(u,280))},700)};u()},stopSimulation:()=>{const r=t().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:r=>{const n={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};t().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:r=>{const{tasks:n,...s}=r,a={...s,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(a)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,n,s)=>{e({runState:r,pendingExecutionId:n!==void 0?n:t().pendingExecutionId,executionError:s!==void 0?s:t().executionError})},switchToEditAndFocusParam:(r,n)=>{const{workflowDef:s,layoutDirection:a,taskMap:i}=t();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:l,edges:c,taskMap:d}=Ae(s,a,{hideEmptyBranches:!1}),{nodes:u,edges:f}=je(l,c,{direction:a,mode:"edit"});e({nodes:u,edges:f,taskMap:d});const h=i[r]||d[r];h&&e({selectedTask:{...h},isDetailPanelOpen:!0,showAnalysisPanel:!1})},setShowDataLineage:r=>e({showDataLineage:r}),clearRefactorNotice:()=>e({lastRefactorNotice:null}),setShowWaterfallPanel:r=>e({showWaterfallPanel:r}),setTimeTravelTimestamp:r=>e({timeTravelTimestamp:r}),setLoopIteration:(r,n)=>e({activeLoopIterations:{...t().activeLoopIterations,[r]:n}}),runLocalSandboxDryRun:(r,n,s)=>{const{workflowDef:a}=t();if(!a)return;const i=im(a,{workflowInput:r,taskMocks:n,maxLoopIterations:s});t().importExecutionJSON(i),e({showWaterfallPanel:!0})},setInlineCopilotTaskRef:r=>e({inlineCopilotTaskRef:r})}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes.map(t=>Object.assign({},t,{selected:!1})),edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,t)=>JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:br(()=>localStorage),migrate:(e,t)=>(t===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const Pv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Av=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),lm=e=>{const t=Av(e);return t.charAt(0).toUpperCase()+t.slice(1)},cm=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),Lv=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Dv={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Mv=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:i,...l},c)=>I.createElement("svg",{ref:c,...Dv,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:cm("lucide",s),...!a&&!Lv(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>I.createElement(d,u)),...Array.isArray(a)?a:[a]]));const Oe=(e,t)=>{const r=I.forwardRef(({className:n,...s},a)=>I.createElement(Mv,{ref:a,iconNode:t,className:cm(`lucide-${Pv(lm(e))}`,`lucide-${e}`,n),...s}));return r.displayName=lm(e),r};const dm=Oe("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const qv=Oe("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const $v=Oe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const um=Oe("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const Wv=Oe("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const pr=Oe("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const hr=Oe("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);const Fv=Oe("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Bv=Oe("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const zv=Oe("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Hv=Oe("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const Jv=Oe("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const fm=Oe("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const fl=Oe("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);const Uv=Oe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Kv=Oe("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const Gv=Oe("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Vv={business:["business"],standard:["business","control"],developer:["business","control","data"]},Ue=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:dm,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:hr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Hv,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:Fv,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:um,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Uv,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:Bv,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:Gv,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:$v,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:Wv,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:qv,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:Kv,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:fl,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:zv,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:um,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:fl,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:fl,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:pr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:pr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:fm,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:hr,viewCategory:"control"}],Yv=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],mr=({message:e,onConfirm:t,onCancel:r})=>{const n=I.useRef(null),{theme:s,themeColor:a}=oe();return I.useEffect(()=>{n.current?.focus({preventScroll:!0});const i=l=>{l.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r]),_t.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,onClick:r,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:i=>i.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[o.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{ref:n,onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),o.jsx("button",{onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},Mt=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:a=!1,isDecision:i=!1,isHighlighted:l=!1,executionStatus:c,simRunning:d=!1,simDone:u=!1,proposalStatus:f})=>{const{mode:h,removeNode:p}=oe(),[m,g]=I.useState(!1),x=_=>{_.stopPropagation(),g(!0)},v=h==="edit"&&!n,b=[i?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",l?"node-wrapper-highlighted":"",d?"node-sim-running":"",u?"node-sim-done":"",f?`node-proposal-${f}`:""].filter(Boolean).join(" "),k=I.useMemo(()=>{if(h!=="run")return{};if(!c)return{opacity:.4};switch(c){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[h,c]);return o.jsxs("div",{className:b,style:{position:"relative",...k},children:[v&&o.jsx("button",{onClick:x,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!s&&a&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),f&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${f}`,children:f==="added"?"+":f==="modified"?"~":"−"}),e,m&&o.jsx(mr,{message:"确定要删除此任务吗?",onConfirm:()=>{p(t),g(!1)},onCancel:()=>g(!1)})]})},Xv=({status:e})=>{const t=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:r,className:n}=t();return o.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:o.jsx("span",{className:"badge-icon",children:r})})},pl=I.memo(Xv),Qv=/[一-龥]/,Zv=({icon:e,header:t,title:r,subTitle:n,meta:s,duration:a,color:i,status:l,isRunning:c,children:d,width:u="240px"})=>{const f=c&&l?l==="COMPLETED"?"var(--status-completed)":l==="FAILED"||l==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":l==="IN_PROGRESS"||l==="SCHEDULED"?"var(--status-in-progress)":l==="TIMED_OUT"||l==="COMPLETED_WITH_ERRORS"?"var(--status-timed-out)":i:i,h=u==="240px"||u===240?"237px":u;return o.jsxs("div",{style:{display:"flex",flexDirection:"row",width:h,height:d?void 0:"81px",minHeight:"81px",boxSizing:"border-box",position:"relative",overflow:"hidden",borderRadius:"10px"},children:[o.jsx("div",{style:{width:"44px",display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",borderLeft:`3px solid ${f}`,borderRight:"1px solid var(--border-primary)",color:f,flexShrink:0},children:o.jsx(e,{size:18,strokeWidth:1.75})}),o.jsxs("div",{style:{flex:1,padding:"6px 12px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",marginBottom:"2px",paddingRight:c&&l?"20px":0},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.2,opacity:.85,color:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...Qv.test(t)&&{letterSpacing:"0.2px",fontSize:"11px"}},children:t}),c&&a&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",flexShrink:0,lineHeight:1.2},children:a})]}),o.jsx("div",{style:{fontSize:"13.5px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25,marginBottom:n||s?"1px":0},title:r,children:r}),n&&n!==r&&n!==s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25},title:n,children:n}),s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.25,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:s,children:s}),d&&o.jsx("div",{style:{marginTop:"6px"},children:d})]}),c&&l&&o.jsx("div",{style:{position:"absolute",top:"7px",right:"7px"},children:o.jsx(pl,{status:l})})]})},gr=I.memo(Zv),lt=e=>{const t=e.layoutDirection||"TB",r=e.sourcePosition||(t==="LR"?M.Position.Right:M.Position.Bottom),n=e.targetPosition||(t==="LR"?M.Position.Left:M.Position.Top);return{layoutDirection:t,sourcePosition:r,targetPosition:n}},bt=e=>{const{mode:t,executionData:r,workflowDef:n,activeLoopIterations:s,timeTravelTimestamp:a}=oe(),i=t==="run"?r?.[e]:null,l=t==="run";let c=i?{...i}:null;if(l&&c&&c.attempts.length>1&&n?.tasks){let p=0;for(const[m,g]of Object.entries(s)){if(!g)continue;if(r?.[m]||c.attempts.some(v=>v.iteration===g)){p=g;break}}if(p>0){const m=c.attempts.find(g=>g.iteration===p)||c.attempts[p-1];m&&(c={...c,status:m.status,startTime:m.startTime,endTime:m.endTime,input:m.inputData,output:m.outputData,iteration:m.iteration??p})}}if(l&&c&&a!==null){const p=c.startTime??0,m=c.endTime??p;p>a?c={...c,status:"SCHEDULED"}:p<=a&&m>a&&(c={...c,status:"IN_PROGRESS"})}const d=c?.attempts.some(p=>p.iteration!==void 0&&p.iteration>1)??!1,u=c?.attempts[c.attempts.length-1],f=d?0:u?.retryCount??0;let h;if(l&&c?.startTime)if(a!==null&&c.startTime>a)h="待执行";else if(a!==null&&c.startTime<=a&&(c.endTime??c.startTime)>a)h=`${a-c.startTime}ms...`;else if(c.endTime&&c.endTime>=c.startTime){const p=c.endTime-c.startTime;h=p<1e3?`${p}ms`:`${(p/1e3).toFixed(2)}s`}else(c.status==="IN_PROGRESS"||c.status==="SCHEDULED")&&(h="运行中");return{mode:t,execution:c,isRunning:l,retryCount:f,durationText:h}};function et(e,t){return e.length>t?e.slice(0,t)+"…":e}function qt(e,t,r,n){if(r==="business")return t.task?.description?.trim()||n;if(r==="standard")return n;const s=t.task;if(!s)return n;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=s.httpRequest||a.http_request;if(!i)return n;const l=(i.method||"GET").toUpperCase(),c=i.uri?et(String(i.uri),28):"";return c?`${l} ${c}`:l}case"SWITCH":{const i=s.caseExpression||a.expression,l=s.evaluatorType||a.evaluatorType;return i?et(i,35):l||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${et(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=s.evaluatorType||a.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=s.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=s.loopCondition;return i?et(i,35):n}case"JSON_JQ_TRANSFORM":{const i=a.queryExpression||a.query_expression;return i?et(i,35):n}case"SET_VARIABLE":{const i=Object.keys(a);return i.length?`set: ${i.slice(0,2).join(", ")}${i.length>2?"…":""}`:n}case"EVENT":{const i=s.sink||a.sink;return i?`→ ${et(i,32)}`:n}case"KAFKA_PUBLISH":{const i=a.topic||a.kafka_request?.topic;return i?`topic: ${et(i,28)}`:n}case"START_WORKFLOW":{const i=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}function kt(e,t){if(t!=="business")return e;const r=Ue.find(n=>n.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const eb=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=lt(t),{execution:i,isRunning:l,retryCount:c,durationText:d}=bt(t.taskReferenceName),u=oe(w=>w.viewMode),f=oe(w=>w.mode),h=oe(w=>w.setInlineCopilotTaskRef),m=M.useStore(w=>w.transform[2])>=1.15,g=I.useMemo(()=>Ue.find(w=>w.type===n),[n]),x=g?.icon||dm,v=n==="NOOP",y=t.isDynamicRuntime===!0,b=v?"var(--text-secondary)":"var(--color-accent)",k=I.useMemo(()=>{let w;return y?w=`Dynamic (${n})`:n==="SIMPLE"?w=t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?w="REST API Call":n==="JSON_JQ_TRANSFORM"?w="JQ Expression":n==="INLINE"||n==="LAMBDA"?w="Inline Script":n==="START_WORKFLOW"?w="Launch Workflow (no wait)":n==="DYNAMIC"?w="Dynamic Task Type":n==="HUMAN"?w="Human Approval":n==="NOOP"?w="No Operation":w=g?.label||n,qt(n,t,u,w)},[n,g,t,u,y]),_=I.useMemo(()=>!m||!t.task?.inputParameters?[]:Object.entries(t.task.inputParameters).slice(0,2).map(([T,O])=>({key:T,val:typeof O=="object"?JSON.stringify(O).slice(0,28):String(O).slice(0,28)})),[m,t.task?.inputParameters]);return o.jsx(Mt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:v?"var(--bg-tertiary)":"transparent",opacity:v?.75:1,position:"relative",outline:y?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[o.jsx(gr,{icon:x,header:kt(n,u),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:k,duration:d,color:b,status:i?.status,isRunning:l}),_.length>0&&o.jsx("div",{style:{padding:"4px 10px 6px",borderTop:"1px dashed var(--border-primary)",fontSize:"9px",fontFamily:"monospace",color:"var(--text-secondary)",display:"flex",flexDirection:"column",gap:"2px"},children:_.map(w=>o.jsxs("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.jsx("span",{style:{color:"#38bdf8"},children:w.key}),": ",w.val]},w.key))}),r&&f==="edit"&&o.jsx("button",{type:"button",onClick:w=>{w.stopPropagation(),h(t.taskReferenceName)},title:"在此节点触发 ⌘K 画布内联 AI 指令",style:{position:"absolute",top:"-10px",right:"20px",padding:"1px 6px",borderRadius:"999px",border:"1px solid rgba(99, 102, 241, 0.6)",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:"9px",fontWeight:700,cursor:"pointer",zIndex:102,boxShadow:"0 2px 6px rgba(0,0,0,0.3)"},children:"⌘K"}),l&&c>0&&o.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",c]}),y&&o.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),o.jsx(M.Handle,{type:"target",position:a,style:{background:"#fff"}}),o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},tb=I.memo(eb),pm=({title:e,label:t,defaultValue:r="",placeholder:n="",confirmText:s="确定",cancelText:a="取消",onConfirm:i,onCancel:l})=>{const{theme:c,themeColor:d}=oe(),[u,f]=I.useState(r),h=I.useRef(null);I.useEffect(()=>{h.current&&(h.current.focus({preventScroll:!0}),h.current.select());const m=g=>{g.key==="Escape"&&(g.stopPropagation(),l())};return window.addEventListener("keydown",m,!0),()=>window.removeEventListener("keydown",m,!0)},[l]);const p=()=>{const m=u.trim();m&&i(m)};return _t.createPortal(o.jsx("div",{"data-mode":c,"data-brand":d,onClick:l,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:m=>m.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[o.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),t&&o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:t}),o.jsx("input",{ref:h,type:"text",value:u,placeholder:n,onChange:m=>f(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),p()),m.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:m=>{m.currentTarget.style.borderColor="var(--color-accent)"},onBlur:m=>{m.currentTarget.style.borderColor="var(--border-primary)"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{onClick:l,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),o.jsx("button",{onClick:p,disabled:!u.trim(),style:{padding:"7px 18px",backgroundColor:u.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:u.trim()?"#ffffff":"var(--text-secondary)",cursor:u.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},rb=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=lt(t),{mode:s,execution:a,isRunning:i,durationText:l}=bt(t.taskReferenceName),{addDecisionBranch:c,removeDecisionBranch:d,renameDecisionBranch:u,viewMode:f}=oe(),[h,p]=I.useState(!1),[m,g]=I.useState({type:"none"}),x=n==="LR"?M.Position.Left:M.Position.Top,v=Object.keys(t.decisionCases||t.task?.decisionCases||{}),y=()=>{p(!1),g({type:"add"})},b=(S,R)=>{S.stopPropagation(),g({type:"delete",branch:R})},k=(S,R)=>{S.stopPropagation(),p(!1),g({type:"rename",branch:R})},_=S=>{S&&c(e,S),g({type:"none"})},w=S=>{m.type==="rename"&&(S&&S!==m.branch&&u(e,m.branch,S),g({type:"none"}))},T=()=>{m.type==="delete"&&(d(e,m.branch),g({type:"none"}))},O=()=>g({type:"none"}),N=i?(S=>S&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[S]||"")(a?.status):"";return o.jsxs(Mt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:[o.jsxs("div",{style:{position:"relative",width:"164px",height:"164px",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(M.Handle,{type:"target",position:x,style:{background:"#fff",[n==="LR"?"left":"top"]:"-3px",zIndex:15}}),i&&a?.status&&o.jsx("div",{style:{position:"absolute",top:"12px",right:"12px",zIndex:20},children:o.jsx(pl,{status:a.status})}),o.jsx("div",{className:N,style:{width:"122px",height:"122px",boxSizing:"border-box",borderRadius:"10px",background:i&&a?.status?void 0:"var(--glass-bg)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",border:r?"2.5px solid var(--color-accent)":i&&a?.status?void 0:"2px solid rgba(var(--color-accent-rgb), 0.45)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"0 8px 26px rgba(0,0,0,0.35), 0 0 0 3px var(--node-glow-color)":i&&a?.status?void 0:"var(--node-shadow)",transition:"all 0.25s ease",cursor:"pointer",flexShrink:0},onClick:()=>s==="edit"&&p(!h),children:o.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"6px",width:"116px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.85,marginBottom:"2px",color:"var(--color-accent)"},children:kt(t.taskType,f)}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",lineHeight:1.25,maxWidth:"104px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.taskReferenceName,children:t.taskReferenceName}),t.label&&t.label!==t.taskReferenceName&&o.jsx("div",{style:{fontSize:"10px",color:"var(--text-secondary)",maxWidth:"98px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px"},title:t.label,children:t.label}),s==="edit"&&o.jsx("div",{style:{width:"18px",height:"18px",fontSize:"12px",background:"color-mix(in srgb, var(--color-accent) 18%, transparent)",border:"1px solid rgba(var(--color-accent-rgb), 0.4)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--color-accent)",fontWeight:700},title:"管理决策分支",children:"+"}),i&&l&&o.jsx("div",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",marginTop:"3px"},children:l})]})}),s==="edit"&&h&&o.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"170px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[o.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),v.map(S=>o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[o.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:S}),o.jsx("button",{onClick:R=>k(R,S),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${S}"`,children:"✏"}),o.jsx("button",{onClick:R=>b(R,S),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${S}"`,children:"×"})]},S)),o.jsx("button",{onClick:y,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),f==="developer"&&(()=>{const S=t.task?.caseExpression||t.task?.inputParameters?.expression,R=t.task?.caseValueParam;return!S&&!R?null:o.jsx("div",{style:{position:"absolute",top:"166px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:S?et(S,22):`param: ${R}`})})(),n==="TB"?o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"source",position:M.Position.Bottom,style:{background:"#fff",bottom:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Left,id:"left",style:{background:"#fff",left:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Right,id:"right",style:{background:"#fff",right:"-3px",zIndex:15}})]}):o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"source",position:M.Position.Right,style:{background:"#fff",right:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Top,id:"top",style:{background:"#fff",top:"-3px",zIndex:15}}),o.jsx(M.Handle,{type:"source",position:M.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-3px",zIndex:15}})]})]}),m.type==="add"&&o.jsx(pm,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${v.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:_,onCancel:O}),m.type==="rename"&&o.jsx(pm,{title:"重命名分支",label:`当前名称:${m.branch}`,defaultValue:m.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:w,onCancel:O}),m.type==="delete"&&o.jsx(mr,{message:`确定要删除分支 "${m.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:T,onCancel:O})]})},nb=I.memo(rb),hm="var(--color-accent)",mm=I.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=lt(t),{mode:i,execution:l,isRunning:c,durationText:d}=bt(t.taskReferenceName),{addForkBranch:u}=oe(),f=M.useUpdateNodeInternals(),h=t.task?.forkTasks?.length||0;I.useEffect(()=>{f(e)},[h,e,f]);const p=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",m=oe(v=>v.viewMode),x=I.useMemo(()=>Ue.find(v=>v.type==="FORK_JOIN"),[])?.icon||pr;return o.jsx(Mt,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:l?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(gr,{icon:x,header:kt(p?"FORK_JOIN_DYNAMIC":"FORK_JOIN",m),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:qt(t.taskType,t,m,p?"Dynamic Parallel Execution":"Parallel Execution"),duration:d,color:hm,status:l?.status,isRunning:c}),i==="edit"&&!p&&o.jsx("div",{style:{position:"absolute",...n==="LR"?{top:"50%",right:-12,transform:"translateY(-50%)"}:{bottom:-12,left:"50%",transform:"translateX(-50%)"},width:20,height:20,background:"var(--color-accent)",borderRadius:"50%",color:"#fff",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",border:"2px solid var(--bg-primary)"},onClick:v=>{v.stopPropagation(),u(e)},title:"添加分支",children:"+"}),o.jsx(M.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(t.task?.forkTasks||[]).map((v,y,b)=>{if(i!=="edit"&&(!v||v.length===0))return null;const k=i!=="edit"?b.filter(O=>O&&O.length>0):b,_=k.length,T=(k.indexOf(v)+1)/(_+1)*100;return o.jsx(M.Handle,{id:`branch_${y}`,type:"source",position:s,style:{background:"#fff",[n==="LR"?"top":"left"]:`${T}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${y}`)}),!p&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}}),p&&o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});mm.displayName="ForkNode";const gm=I.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=lt(t),{execution:i,isRunning:l,durationText:c}=bt(t.taskReferenceName),d=oe(h=>h.viewMode),f=I.useMemo(()=>Ue.find(h=>h.type==="JOIN"),[])?.icon||hr;return o.jsx(Mt,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(gr,{icon:f,header:kt(t.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",d),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:qt(t.taskType,t,d,t.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),duration:c,color:hm,status:i?.status,isRunning:l}),o.jsx(M.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"target",position:M.Position.Left,id:"left",style:{background:"#fff"}}),o.jsx(M.Handle,{type:"target",position:M.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&o.jsxs(o.Fragment,{children:[o.jsx(M.Handle,{type:"target",position:M.Position.Top,id:"top",style:{background:"#fff"}}),o.jsx(M.Handle,{type:"target",position:M.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),o.jsx(M.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});gm.displayName="JoinNode";const ym={ForkNode:mm,JoinNode:gm},sb=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=lt(t),{execution:a,isRunning:i,durationText:l}=bt(t.taskReferenceName),{executionData:c,selectTaskAction:d,mode:u,viewMode:f,removeNode:h,activeLoopIterations:p,setLoopIteration:m}=oe(),[g,x]=I.useState(!1),v=t.task,y=v?.loopOver||[],k=I.useMemo(()=>Ue.find(j=>j.type==="DO_WHILE"),[])?.icon||fm,_=I.useMemo(()=>{if(!i||!c)return 0;let j=a?.iteration??0;return y.forEach(E=>{const q=c[E.taskReferenceName];q?.totalIterations?j=Math.max(j,q.totalIterations):q?.attempts.some($=>($.iteration??0)>0)&&(j=Math.max(j,q.attempts.length))}),j},[i,c,y,a?.iteration]),w=p[t.taskReferenceName]||_,T=t.loopCondition||v?.loopCondition||"",O=I.useMemo(()=>{const j=T?T.length>35?T.slice(0,35)+"…":T:"循环直到条件满足";return qt("DO_WHILE",t,f,j)},[t,f,T]),D=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",N=r?`2px solid ${D}`:`1.5px dashed ${i&&a?.status?D:"var(--color-accent)"}`,S=u==="edit",R=f==="developer"&&T;return o.jsxs("div",{style:{width:"100%",height:"100%",border:N,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[S&&o.jsx("button",{onClick:j=>{j.stopPropagation(),x(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),t.isError&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!t.isError&&t.hasWarning&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),t.proposalStatus&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${t.proposalStatus}`,style:{pointerEvents:"auto"},children:t.proposalStatus==="added"?"+":t.proposalStatus==="modified"?"~":"−"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--glass-surface)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"44px",pointerEvents:"auto"},children:[o.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:o.jsx(k,{size:15})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx("span",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:kt("DO_WHILE",f)}),o.jsxs("span",{style:{fontSize:"9px",color:"var(--text-muted)"},children:["↻ ",y.length," 个子任务"]})]}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.taskReferenceName}),(f==="business"||f==="developer")&&O&&o.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:O})]}),i&&l&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:"4px",flexShrink:0},children:l}),i&&_>0&&o.jsxs("div",{onClick:()=>d(v||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},title:`共执行 ${_} 次迭代`,children:["×",_]}),i&&a?.status&&o.jsx("div",{style:{position:"relative",width:20,height:20,flexShrink:0},children:o.jsx(pl,{status:a.status})})]}),i&&_>1&&o.jsxs("div",{onClick:j=>j.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 10px",background:"rgba(15, 23, 42, 0.72)",borderBottom:"1px solid var(--border-primary)",flexShrink:0,pointerEvents:"auto",overflowX:"auto"},children:[o.jsx("span",{style:{fontSize:"9px",color:"#94a3b8",fontWeight:600,marginRight:"2px"},children:"切换轮次:"}),Array.from({length:_},(j,E)=>E+1).map(j=>{const E=w===j;return o.jsxs("button",{type:"button",onClick:q=>{q.stopPropagation(),m(t.taskReferenceName,j)},style:{fontSize:"9px",padding:"1px 7px",borderRadius:"999px",border:E?"1px solid #38bdf8":"1px solid rgba(148, 163, 184, 0.25)",background:E?"rgba(56, 189, 248, 0.22)":"rgba(30, 41, 59, 0.6)",color:E?"#38bdf8":"#cbd5e1",fontWeight:E?700:500,cursor:"pointer"},children:["#",j]},j)})]}),R&&o.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",T]}),o.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),o.jsx(M.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),o.jsx(M.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),g&&o.jsx(mr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{h(e),x(!1)},onCancel:()=>x(!1)})]})},ab=I.memo(sb),ob="var(--color-accent)",ib=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=lt(t),{execution:a,isRunning:i,durationText:l}=bt(t.taskReferenceName),c=oe(p=>p.viewMode),u=I.useMemo(()=>Ue.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||hr,f=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",h=t.task?.subWorkflowParam?.version;return o.jsx(Mt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(gr,{icon:u,header:kt("SUB_WORKFLOW",c),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:qt("SUB_WORKFLOW",t,c,`Flow: ${f}${h!==void 0?` (v${h})`:""}`),duration:l,color:ob,status:a?.status,isRunning:i}),o.jsx(M.Handle,{type:"target",position:s,style:{background:"#fff"}}),o.jsx(M.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},lb=I.memo(ib),cb=({data:e})=>{const r=(e.layoutDirection||"TB")==="LR";return o.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[o.jsx(Jv,{size:16}),e.label&&e.label!=="+"&&o.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),o.jsx(M.Handle,{type:"target",position:r?M.Position.Left:M.Position.Top,style:{opacity:0}}),o.jsx("style",{dangerouslySetInnerHTML:{__html:`
10
15
  .plus-node-container:hover {
11
16
  transform: scale(1.1);
12
17
  background: var(--color-accent);
@@ -14,29 +19,37 @@ execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",
14
19
  border-style: solid;
15
20
  box-shadow: 0 0 10px var(--color-accent);
16
21
  }
17
- `}})]})},yx=P.memo(vx),xx=({data:e})=>{const{sourcePosition:r,targetPosition:t}=Ze(e);return l.jsxs("div",{style:{width:"220px",height:"70px",border:"2px dashed var(--color-accent)",borderRadius:"8px",background:"var(--bg-secondary)",opacity:.75,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",cursor:"default",userSelect:"none"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[l.jsx(Kr,{size:14,style:{color:"var(--color-accent)"}}),l.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--color-accent)"},children:"动态分支"})]}),l.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"运行时生成"}),l.jsx(A.Handle,{type:"target",position:t,style:{background:"var(--color-accent)",width:8,height:8}}),l.jsx(A.Handle,{type:"source",position:r,style:{background:"var(--color-accent)",width:8,height:8}})]})},bx=P.memo(xx),kx=({onSelect:e,onCancel:r})=>{const[t,n]=P.useState("CORE");P.useEffect(()=>{const a=o=>{o.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]);const s=Xe.filter(a=>a.category===t&&!a.hidden);return l.jsxs("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease-out"},onClick:r,children:[l.jsxs("div",{className:"glass-panel",style:{backgroundColor:"var(--glass-surface)",borderRadius:"16px",padding:"0",width:"600px",height:"500px",boxShadow:"0 20px 50px rgba(0,0,0,0.4)",border:"1px solid var(--glass-border)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:a=>a.stopPropagation(),children:[l.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[l.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),l.jsx("div",{style:{display:"flex",gap:"24px"},children:sx.map(a=>l.jsx("button",{onClick:()=>n(a.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:t===a.key?"600":"500",color:t===a.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:t===a.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:a.label},a.key))})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:s.map(a=>{const o=a.icon;return l.jsxs("button",{onClick:()=>e(a.type),style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"12px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",color:"var(--text-primary)",position:"relative",overflow:"hidden"},onMouseEnter:i=>{i.currentTarget.style.borderColor="var(--color-accent)",i.currentTarget.style.backgroundColor="var(--bg-highlight)",i.currentTarget.style.transform="translateY(-2px)",i.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:i=>{i.currentTarget.style.borderColor="var(--border-primary)",i.currentTarget.style.backgroundColor="var(--bg-tertiary)",i.currentTarget.style.transform="translateY(0)",i.currentTarget.style.boxShadow="none"},children:[l.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(o,{size:24,strokeWidth:1.5})}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:a.label}),l.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:a.description})]})]},a.type)})})}),l.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{onClick:r,style:{padding:"8px 24px",backgroundColor:"transparent",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:a=>a.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),l.jsx("style",{children:`
22
+ `}})]})},db=I.memo(cb),ub=({data:e})=>{const{sourcePosition:t,targetPosition:r}=lt(e);return o.jsxs("div",{style:{width:"220px",height:"70px",border:"2px dashed var(--color-accent)",borderRadius:"8px",background:"var(--bg-secondary)",opacity:.75,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",cursor:"default",userSelect:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx(pr,{size:14,style:{color:"var(--color-accent)"}}),o.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--color-accent)"},children:"动态分支"})]}),o.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"运行时生成"}),o.jsx(M.Handle,{type:"target",position:r,style:{background:"var(--color-accent)",width:8,height:8}}),o.jsx(M.Handle,{type:"source",position:t,style:{background:"var(--color-accent)",width:8,height:8}})]})},fb=I.memo(ub),pb=({onSelect:e,onCancel:t})=>{const[r,n]=I.useState("CORE");I.useEffect(()=>{const a=i=>{i.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]);const s=Ue.filter(a=>a.category===r&&!a.hidden);return o.jsxs("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease-out"},onClick:t,children:[o.jsxs("div",{className:"glass-panel",style:{backgroundColor:"var(--glass-surface)",borderRadius:"16px",padding:"0",width:"600px",height:"500px",boxShadow:"0 20px 50px rgba(0,0,0,0.4)",border:"1px solid var(--glass-border)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[o.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),o.jsx("div",{style:{display:"flex",gap:"24px"},children:Yv.map(a=>o.jsx("button",{onClick:()=>n(a.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:r===a.key?"600":"500",color:r===a.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:r===a.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:a.label},a.key))})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:s.map(a=>{const i=a.icon;return o.jsxs("button",{onClick:()=>e(a.type),style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"12px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",color:"var(--text-primary)",position:"relative",overflow:"hidden"},onMouseEnter:l=>{l.currentTarget.style.borderColor="var(--color-accent)",l.currentTarget.style.backgroundColor="var(--bg-highlight)",l.currentTarget.style.transform="translateY(-2px)",l.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:l=>{l.currentTarget.style.borderColor="var(--border-primary)",l.currentTarget.style.backgroundColor="var(--bg-tertiary)",l.currentTarget.style.transform="translateY(0)",l.currentTarget.style.boxShadow="none"},children:[o.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(i,{size:24,strokeWidth:1.5})}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:a.label}),o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:a.description})]})]},a.type)})})}),o.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:o.jsx("button",{onClick:t,style:{padding:"8px 24px",backgroundColor:"transparent",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:a=>a.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),o.jsx("style",{children:`
18
23
  @keyframes fadeIn {
19
24
  from { opacity: 0; }
20
25
  to { opacity: 1; }
21
26
  }
22
- `})]})},_x=()=>{const{executionData:e,loadSampleExecution:r,importExecutionJSON:t,workflowInstance:n,setSelectedTask:s,nodes:a}=ie(),{fitView:o}=A.useReactFlow(),i=g=>{const m=g.target.files?.[0];if(m){const v=new FileReader;v.onload=y=>{try{const x=JSON.parse(y.target?.result);t(x)}catch(x){console.error("Failed to parse execution JSON:",x)}},v.readAsText(m)}};if(!e)return l.jsxs("div",{className:"execution-status-bar",children:[l.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:i,style:{display:"none"}}),l.jsx("div",{className:"status-item",children:l.jsx("span",{className:"status-label",children:"准备就绪"})}),l.jsxs("div",{style:{display:"flex",gap:"8px"},children:[l.jsx("button",{onClick:r,style:{background:"var(--color-accent)",color:"#fff",border:"none",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"600",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",transition:"all 0.2s ease"},children:"🚀 加载示例运行"}),l.jsx("button",{onClick:()=>document.getElementById("execution-json-upload")?.click(),title:"上传 Conductor 运行态 JSON",style:{background:"rgba(255,255,255,0.1)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s ease"},children:"📁 导入执行 JSON"})]})]});const d=Object.values(e),c=d.filter(g=>g.status==="COMPLETED").length,u=d.filter(g=>g.status==="FAILED"||g.status==="FAILED_WITH_TERMINAL_ERROR"||g.status==="TIMED_OUT"),f=u.length,p=d.filter(g=>g.status==="IN_PROGRESS"||g.status==="SCHEDULED").length,h=P.useCallback(()=>{if(f===0)return;const g=new Set(u.map(v=>v.taskReferenceName)),m=a.filter(v=>g.has(v.data?.taskReferenceName)).map(v=>v.id);m.length>0&&o({nodes:m.map(v=>({id:v})),duration:500,padding:.3})},[u,a,o,f]);return l.jsxs("div",{className:"execution-status-bar",children:[n&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",children:" Workflow ID:"}),l.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),l.jsx("div",{className:"status-divider"})]}),l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",children:"状态:"}),l.jsx("span",{className:"status-value highlight",style:{color:n?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:n?.status||"运行中"})]}),l.jsx("div",{className:"status-divider"}),l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",children:"已完成:"}),l.jsx("span",{className:"status-value",children:c})]}),l.jsxs("div",{className:"status-item",onClick:f>0?h:void 0,style:{cursor:f>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...f>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:f>0?"点击聚焦失败节点":void 0,children:[l.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),l.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:f})]}),l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),l.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:p})]}),l.jsx("div",{className:"status-divider"}),l.jsx("div",{style:{display:"flex",gap:"8px"},children:l.jsx("button",{onClick:()=>{s({name:"Workflow Global Data",taskReferenceName:"__workflow_global__",type:"SIMPLE"})},style:{background:"rgba(255,255,255,0.05)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"4px 10px",borderRadius:"6px",cursor:"pointer",fontSize:"11px",fontWeight:"600"},children:"🔍 全局 I/O"})})]})},Lh=({isOpen:e,onClose:r,theme:t="dark",onTaskSelect:n})=>{const{validationResults:s,setSelectedTask:a,taskMap:o}=ie(),{errors:i,warnings:d}=s||{errors:[],warnings:[]},c=g=>{if(g&&g!=="UNKNOWN"){const m=o[g];m&&(n?n(m):a(m))}},u="var(--glass-surface)",f="var(--text-primary)",p="var(--glass-border)",h="var(--text-secondary)";return e?l.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:u,border:`1px solid ${p}`,borderRadius:"12px",boxShadow:"0 10px 25px rgba(0,0,0,0.2)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[l.jsx("style",{children:`
27
+ `})]})},hb=()=>{const{executionData:e,loadSampleExecution:t,importExecutionJSON:r,workflowInstance:n,setSelectedTask:s,nodes:a}=oe(),{fitView:i}=M.useReactFlow(),l=m=>{const g=m.target.files?.[0];if(g){const x=new FileReader;x.onload=v=>{try{const y=JSON.parse(v.target?.result);r(y)}catch(y){console.error("Failed to parse execution JSON:",y)}},x.readAsText(g)}};if(!e)return o.jsxs("div",{className:"execution-status-bar",children:[o.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:l,style:{display:"none"}}),o.jsx("div",{className:"status-item",children:o.jsx("span",{className:"status-label",children:"准备就绪"})}),o.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o.jsx("button",{onClick:t,style:{background:"var(--color-accent)",color:"#fff",border:"none",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"600",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",transition:"all 0.2s ease"},children:"🚀 加载示例运行"}),o.jsx("button",{onClick:()=>document.getElementById("execution-json-upload")?.click(),title:"上传 Conductor 运行态 JSON",style:{background:"rgba(255,255,255,0.1)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s ease"},children:"📁 导入执行 JSON"})]})]});const c=Object.values(e),d=c.filter(m=>m.status==="COMPLETED").length,u=c.filter(m=>m.status==="FAILED"||m.status==="FAILED_WITH_TERMINAL_ERROR"||m.status==="TIMED_OUT"),f=u.length,h=c.filter(m=>m.status==="IN_PROGRESS"||m.status==="SCHEDULED").length,p=I.useCallback(()=>{if(f===0)return;const m=new Set(u.map(x=>x.taskReferenceName)),g=a.filter(x=>m.has(x.data?.taskReferenceName)).map(x=>x.id);g.length>0&&i({nodes:g.map(x=>({id:x})),duration:500,padding:.3})},[u,a,i,f]);return o.jsxs("div",{className:"execution-status-bar",children:[n&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",children:" Workflow ID:"}),o.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),o.jsx("div",{className:"status-divider"})]}),o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",children:"状态:"}),o.jsx("span",{className:"status-value highlight",style:{color:n?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:n?.status||"运行中"})]}),o.jsx("div",{className:"status-divider"}),o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",children:"已完成:"}),o.jsx("span",{className:"status-value",children:d})]}),o.jsxs("div",{className:"status-item",onClick:f>0?p:void 0,style:{cursor:f>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...f>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:f>0?"点击聚焦失败节点":void 0,children:[o.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),o.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:f})]}),o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),o.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:h})]}),o.jsx("div",{className:"status-divider"}),o.jsx("div",{style:{display:"flex",gap:"8px"},children:o.jsx("button",{onClick:()=>{s({name:"Workflow Global Data",taskReferenceName:"__workflow_global__",type:"SIMPLE"})},style:{background:"rgba(255,255,255,0.05)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"4px 10px",borderRadius:"6px",cursor:"pointer",fontSize:"11px",fontWeight:"600"},children:"🔍 全局 I/O"})})]})},mb=({isOpen:e,onClose:t,theme:r="dark",onTaskSelect:n})=>{const{validationResults:s,setSelectedTask:a,taskMap:i}=oe(),{errors:l,warnings:c}=s||{errors:[],warnings:[]},d=m=>{if(m&&m!=="UNKNOWN"){const g=i[m];g&&(n?n(g):a(g))}},u="var(--glass-surface)",f="var(--text-primary)",h="var(--glass-border)",p="var(--text-secondary)";return e?o.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:u,border:`1px solid ${h}`,borderRadius:"12px",boxShadow:"0 10px 25px rgba(0,0,0,0.2)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[o.jsx("style",{children:`
23
28
  @keyframes fadeInSlide {
24
29
  from { opacity: 0; transform: translateY(-10px); }
25
30
  to { opacity: 1; transform: translateY(0); }
26
31
  }
27
32
  .health-item:hover {
28
- background-color: ${t==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
33
+ background-color: ${r==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
29
34
  }
30
- `}),l.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[l.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:"🩺"})," 工作流体检报告"]}),l.jsx("button",{onClick:r,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:i.length===0&&d.length===0?l.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[l.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),l.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),l.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):l.jsxs(l.Fragment,{children:[i.map((g,m)=>l.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&c(g.ref)},onClick:()=>c(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[l.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),l.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`err-${m}`)),d.map((g,m)=>l.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&c(g.ref)},onClick:()=>c(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[l.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),l.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`warn-${m}`))]})}),l.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:h,borderTop:`1px solid ${p}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[l.jsxs("span",{children:["共 ",i.length," 个错误, ",d.length," 个警告"]}),i.length>0&&l.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},Sx=({id:e,source:r,target:t,sourceX:n,sourceY:s,targetX:a,targetY:o,sourcePosition:i,targetPosition:d,style:c={},markerEnd:u,data:f})=>{const[p,h]=P.useState(!1),g=P.useRef(null),m=()=>{const N=f?.edgeType||"default",L={sourceX:n,sourceY:s,sourcePosition:i,targetX:a,targetY:o,targetPosition:d};switch(N){case"step":case"smoothstep":return A.getSmoothStepPath(L);case"straight":return A.getStraightPath(L);default:return A.getBezierPath(L)}},[v,y,x]=m(),b=N=>{N.stopPropagation(),N.preventDefault();const L=new CustomEvent("edgeAddNode",{detail:{id:e,source:r,target:t,edgeData:f}});window.dispatchEvent(L)},k=()=>{g.current&&clearTimeout(g.current),h(!0)},w=()=>{g.current=setTimeout(()=>{h(!1)},100)},j=f?.mode==="edit";return l.jsxs(l.Fragment,{children:[l.jsx(A.BaseEdge,{path:v,markerEnd:u,style:{...c,strokeWidth:p?4:2,stroke:p?"#fbbf24":c?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),l.jsx("path",{d:v,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:j?"pointer":"default",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:w}),j&&p&&l.jsx(A.EdgeLabelRenderer,{children:l.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${y}px,${x}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:k,onMouseLeave:w,children:[f?.label&&l.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",color:"var(--color-accent)",padding:"4px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:"700",marginBottom:"8px",border:"1px solid var(--color-accent)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",whiteSpace:"nowrap",letterSpacing:"0.5px"},children:f.label}),l.jsx("button",{style:{width:"32px",height:"32px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.8)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:"20px",boxShadow:"0 4px 15px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Le=({onClick:e,icon:r,label:t,title:n,disabled:s=!1,active:a=!1,variant:o="default",style:i})=>{let d="var(--bg-tertiary)",c="var(--text-primary)",u="1px solid var(--border-primary)";return o==="primary"?(d="var(--color-accent)",c="#fff",u="none"):o==="danger"?(d=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",c=s?"var(--text-secondary)":"#fff",u="none"):a&&(d="var(--bg-secondary)",c="var(--color-accent)",u="1px solid var(--color-accent)"),l.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||t,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:t?"6px":"0",background:d,color:c,border:u,borderRadius:"6px",padding:t?"6px 12px":"8px",cursor:s?"not-allowed":"pointer",opacity:s?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:t?"auto":"32px",height:"32px",boxShadow:o==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...i},children:[r&&l.jsx("span",{style:{fontSize:"14px",display:"flex"},children:r}),t&&l.jsx("span",{children:t})]})},wx=()=>{const{zoomIn:e,zoomOut:r,fitView:t}=A.useReactFlow();return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:l.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.05)"},children:[l.jsx(Le,{icon:"➕",title:"放大",onClick:()=>e()}),l.jsx(Le,{icon:"➖",title:"缩小",onClick:()=>r()}),l.jsx(Le,{icon:"⤢",title:"适应屏幕",onClick:()=>t({duration:600})})]})})},Tx=({onShowHealthCheck:e,showHealthCheck:r,onShowSettings:t,executionActions:n})=>{const{mode:s,validationResults:a,workflowInstance:o,workflowDef:i}=ie(),d=ie.temporal,{undo:c,redo:u,pastStates:f,futureStates:p}=Xr(d,T=>T),[h,g]=P.useState(!1),m=P.useRef(null);P.useEffect(()=>{if(!h)return;const T=C=>{m.current&&!m.current.contains(C.target)&&g(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[h]);const v=(a?.errors?.length||0)>0,y=o?.status,x=o?.workflowId??"",b=y==="RUNNING",k=y==="PAUSED",w=y==="FAILED"||y==="TIMED_OUT"||y==="TERMINATED",j=y==="COMPLETED",N=i?.restartable===!0&&(w||j),L=n?.allowOperations!==!1;return l.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px",alignItems:"center"},children:[s==="edit"&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>c(),disabled:f.length===0}),l.jsx(Le,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>u(),disabled:p.length===0}),l.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),l.jsx(Le,{icon:"🩺",label:v?`错误 (${a.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:r,variant:v?"danger":"secondary"}),l.jsx(Le,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>t?.()})]}),s==="run"&&o&&n&&l.jsxs(l.Fragment,{children:[k&&n.onResume&&l.jsx(Le,{icon:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:L?"继续执行工作流":"操作权限受限",onClick:()=>L&&n.onResume(x),disabled:!L,variant:"primary"}),b&&n.onPause&&l.jsx(Le,{icon:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[l.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),l.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:L?"暂停工作流执行":"操作权限受限",onClick:()=>L&&n.onPause(x),disabled:!L}),(b||k)&&n.onTerminate&&l.jsx(Le,{icon:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:L?"终止工作流执行":"操作权限受限",onClick:()=>L&&n.onTerminate(x),disabled:!L,variant:"danger"}),w&&n.onRetry&&l.jsx(Le,{icon:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("path",{d:"M13 2v4h-4"}),l.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:L?"重试失败的工作流":"操作权限受限",onClick:()=>L&&n.onRetry(x),disabled:!L,variant:"primary"}),N&&n.onRestart&&l.jsxs("div",{ref:m,style:{position:"relative",display:"flex"},children:[l.jsxs("button",{disabled:!L,onClick:()=>L&&n.onRestart(x,{useLatestDef:!0}),title:L?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:L?"pointer":"not-allowed",opacity:L?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("path",{d:"M3 14v-4h4"}),l.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),l.jsx("button",{disabled:!L,onClick:()=>L&&g(T=>!T),title:L?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:L&&h?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:L?"pointer":"not-allowed",opacity:L?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:l.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),h&&l.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[l.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),l.jsxs("button",{onClick:()=>{n.onRestart(x,{useLatestDef:!0}),g(!1)},style:qh,onMouseEnter:T=>T.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M8 5v3l2 1"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),l.jsxs("button",{onClick:()=>{n.onRestart(x,{useLatestDef:!1}),g(!1)},style:qh,onMouseEnter:T=>T.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),l.jsx("path",{d:"M6 6h4M6 9h3"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},qh={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"};function Vr(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(r=>({name:r})):e}const Ex=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Nx=({isOpen:e,onClose:r})=>{const{workflowDef:t,updateWorkflowProperties:n,mode:s}=ie(),[a,o]=P.useState(t),[i,d]=P.useState("basic"),c=s!=="edit";P.useEffect(()=>{t&&o(t)},[t,e]);const u=P.useCallback(I=>{I.key==="Escape"&&r()},[r]);if(P.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),!e||!a)return null;const f="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",g="var(--text-secondary)",m=(I,O)=>{if(!a||c)return;const F={...a,[I]:O};o(F),n({[I]:O})},v=(I,O,F)=>{if(!a||c)return;const V={...a[I]||{},[O]:F};o(Z=>({...Z,[I]:V})),n({[I]:V})},y=(I,O)=>{if(!(!a||c))try{const F=JSON.parse(O),W={...a,[I]:F};o(W),n({[I]:F})}catch{o(F=>({...F,[`_${I}_str`]:O}))}},x={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${p}`,background:h,color:f,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:g,marginBottom:"8px",fontWeight:600},k=(I,O,F="text",W)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("input",{className:"wsp-input",type:F,value:a?.[O]??"",onChange:V=>m(O,F==="number"?V.target.value===""?0:parseInt(V.target.value):V.target.value),disabled:c||W?.readOnly,placeholder:W?.placeholder,style:{...x,opacity:c||W?.readOnly?.6:1}})]}),w=(I,O,F=!1,W=6)=>{const V=a?.[`_${O}_str`]!==void 0?a[`_${O}_str`]:typeof a?.[O]=="object"?JSON.stringify(a[O],null,2):a?.[O];return l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsxs("label",{style:b,children:[I.toUpperCase()," ",F&&"(JSON)"]}),l.jsx("textarea",{className:"wsp-input",value:V||"",onChange:Z=>F?y(O,Z.target.value):m(O,Z.target.value),rows:W,disabled:c,style:{...x,fontSize:"13px",fontFamily:F?"var(--font-mono)":"inherit",resize:"vertical",opacity:c?.6:1}})]})},j=(I,O,F)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("select",{className:"wsp-input",value:a?.[O]??F[0]?.value,onChange:W=>m(O,W.target.value),disabled:c,style:{...x,opacity:c?.6:1,cursor:c?"not-allowed":"pointer"},children:F.map(W=>l.jsx("option",{value:W.value,children:W.label},W.value))})]}),N=(I,O)=>{const F=!!a?.[O];return l.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("label",{style:{fontSize:"13px",color:f},children:I}),l.jsx("button",{type:"button",role:"switch","aria-checked":F,onClick:()=>!c&&m(O,!F),disabled:c,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:F?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:c?"not-allowed":"pointer",transition:"background 0.2s",opacity:c?.6:1,flexShrink:0},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:F?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})},L=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),w("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),T=()=>l.jsxs(l.Fragment,{children:[j("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),l.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&l.jsx("p",{style:{fontSize:"11px",color:g,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),N("允许重启 (restartable)","restartable")]}),C=()=>{const I=Vr(a?.inputParameters),O=ne=>{c||m("inputParameters",ne)},F=()=>{const ne=[...I,{name:`param_${I.length+1}`,type:"string",required:!1}];O(ne)},W=ne=>{const ee=I.filter((D,Y)=>Y!==ne);O(ee)},V=(ne,ee,D)=>{const Y=I.map((se,R)=>R===ne?{...se,[ee]:D}:se);O(Y)},Z={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${p}`,background:h,color:f,fontSize:"12px",outline:"none",fontFamily:"inherit"};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("label",{style:b,children:"入参声明 (INPUT PARAMETERS)"}),!c&&l.jsx("button",{onClick:F,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),I.length===0?l.jsx("p",{style:{fontSize:"12px",color:g,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${p}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:I.map((ne,ee)=>l.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${p}`,borderRadius:"10px",padding:"12px"},children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[l.jsx("input",{style:Z,placeholder:"参数名",value:ne.name,onChange:D=>V(ee,"name",D.target.value),disabled:c}),l.jsx("select",{style:{...Z,cursor:c?"not-allowed":"pointer"},value:ne.type??"string",onChange:D=>V(ee,"type",D.target.value),disabled:c,children:["string","number","boolean","object","array"].map(D=>l.jsx("option",{value:D,children:D},D))}),l.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:g,cursor:c?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[l.jsx("input",{type:"checkbox",checked:!!ne.required,onChange:D=>V(ee,"required",D.target.checked),disabled:c,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!c&&l.jsx("button",{onClick:()=>W(ee),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),l.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[l.jsx("input",{style:Z,placeholder:"说明(可选)",value:ne.description??"",onChange:D=>V(ee,"description",D.target.value),disabled:c}),l.jsx("input",{style:Z,placeholder:`示例值(如 ${ne.type==="number"?"42":ne.type==="boolean"?"true":'"value"'})`,value:ne.example!==void 0?typeof ne.example=="object"?JSON.stringify(ne.example):String(ne.example):"",onChange:D=>{let Y=D.target.value;try{Y=JSON.parse(D.target.value)}catch{}V(ee,"example",Y)},disabled:c})]})]},ee))})]}),w("输出参数映射 (outputParameters)","outputParameters",!0),w("默认输入模板 (inputTemplate)","inputTemplate",!0),w("工作流级变量 (variables)","variables",!0)]})},S=()=>l.jsxs(l.Fragment,{children:[N("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),l.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[N("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&l.jsxs(l.Fragment,{children:[w("输入 Schema (inputSchema)","inputSchema",!0,4),w("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),l.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[l.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:b,children:"RATE LIMIT KEY"}),l.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:I=>v("rateLimitConfig","rateLimitKey",I.target.value),disabled:c,placeholder:"限流键",style:{...x,opacity:c?.6:1}})]}),l.jsxs("div",{children:[l.jsx("label",{style:b,children:"并发上限"}),l.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:I=>v("rateLimitConfig","concurrentExecLimit",I.target.value===""?0:parseInt(I.target.value)),disabled:c,placeholder:"0",style:{...x,opacity:c?.6:1}})]})]})]})]}),q=()=>{switch(i){case"basic":return L();case"timeout":return T();case"params":return C();case"advanced":return S()}};return l.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:r,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:l.jsxs("div",{onClick:I=>I.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${p}`,backdropFilter:"blur(20px)"},children:[l.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[l.jsxs("div",{children:[l.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),l.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:g},children:c?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),l.jsx("button",{className:"wsp-close",onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),l.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:Ex.map(I=>l.jsx("button",{className:"wsp-tab",onClick:()=>d(I.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:i===I.id?600:400,color:i===I.id?"var(--color-accent)":g,background:"none",border:"none",borderBottom:i===I.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:I.label},I.id))})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:q()}),l.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"wsp-footer-btn",onClick:r,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},Cx=({onRequestImport:e})=>{const{createBlankWorkflow:r}=ie(),[t,n]=P.useState(""),s=()=>{r(t||void 0),ie.temporal.getState().clear()},a=()=>{r(t||void 0),ie.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return l.jsxs("div",{className:"empty-state-panel",children:[l.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),l.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),l.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:t,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s()}}),l.jsxs("div",{className:"empty-state-actions",children:[l.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),l.jsxs("button",{className:"empty-state-btn",onClick:a,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&l.jsxs("button",{className:"empty-state-btn",onClick:e,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},jx={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Ix=({messages:e,onDismiss:r})=>e.length===0?null:l.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:3e3,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:e.map(t=>l.jsx(Rx,{message:t,onDismiss:r},t.id))}),Rx=({message:e,onDismiss:r})=>{const t=jx[e.type||"info"];return P.useEffect(()=>{const n=setTimeout(()=>r(e.id),2500);return()=>clearTimeout(n)},[e.id,r]),l.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:t.bg,color:t.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>r(e.id),children:e.text})},Dh=["shift","alt","meta","mod","ctrl","control"],Ox={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function Ke(e){return(Ox[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Mh(e){return Dh.includes(e)}function Fi(e,r=","){return e.toLowerCase().split(r)}function $i(e,r="+",t=">",n=!1,s){let a=[],o=!1;e=e.trim(),e.includes(t)?(o=!0,a=e.toLocaleLowerCase().split(t).map(c=>Ke(c))):a=e.toLocaleLowerCase().split(r).map(c=>Ke(c));const i={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},d=a.filter(c=>!Dh.includes(c));return{...i,keys:d,description:s,isSequence:o,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Wh([Ke(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Bh([Ke(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{$e.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{$e.clear()},0)}));const $e=new Set;function zi(e){return Array.isArray(e)}function Px(e,r=","){return(zi(e)?e:e.split(r)).every(t=>$e.has(t.trim().toLowerCase()))}function Wh(e){const r=Array.isArray(e)?e:[e];$e.has("meta")&&$e.forEach(t=>!Mh(t)&&$e.delete(t.toLowerCase())),r.forEach(t=>$e.add(t.toLowerCase()))}function Bh(e){const r=Array.isArray(e)?e:[e];e==="meta"?$e.clear():r.forEach(t=>$e.delete(t.toLowerCase()))}function Ax(e,r,t){(typeof t=="function"&&t(e,r)||t===!0)&&e.preventDefault()}function Lx(e,r,t){return typeof t=="function"?t(e,r):t===!0||t===void 0}const qx=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Dx(e){return Fh(e,qx)}function Fh(e,r=!1){const{target:t,composed:n}=e;let s,a;return Mx(t)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=t&&t.tagName,a=t&&t.role),zi(r)?!!(s&&r&&r.some(o=>o.toLowerCase()===s.toLowerCase()||o===a)):!!(s&&r&&r)}function Mx(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Wx(e,r){return e.length===0&&r?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):r?e.some(t=>r.includes(t))||e.includes("*"):!0}const Bx=(e,r,t=!1)=>{const{alt:n,meta:s,mod:a,shift:o,ctrl:i,keys:d,useKey:c}=r,{code:u,key:f,ctrlKey:p,metaKey:h,shiftKey:g,altKey:m}=e,v=Ke(u);if(c&&d?.length===1&&d.includes(f))return!0;if(!d?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!t){if(n!==m&&v!=="alt"||o!==g&&v!=="shift")return!1;if(a){if(!h&&!p)return!1}else if(s!==h&&v!=="meta"&&v!=="os"||i!==p&&v!=="ctrl"&&v!=="control")return!1}return d&&d.length===1&&d.includes(v)?!0:d?Px(d):!d},Fx=P.createContext(void 0),$x=()=>P.useContext(Fx);function $h(e,r){return e&&r&&typeof e=="object"&&typeof r=="object"?Object.keys(e).length===Object.keys(r).length&&Object.keys(e).reduce((t,n)=>t&&$h(e[n],r[n]),!0):e===r}const zx=P.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Hx=()=>P.useContext(zx);function Kx(e){const r=P.useRef(void 0);return $h(r.current,e)||(r.current=e),r.current}const zh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Ux=typeof window<"u"?P.useLayoutEffect:P.useEffect;function cr(e,r,t,n){const s=P.useRef(null),a=P.useRef(!1),o=Array.isArray(t)?Array.isArray(n)?void 0:n:t,i=zi(e)?e.join(o?.delimiter):e,d=Array.isArray(t)?t:Array.isArray(n)?n:void 0,c=P.useCallback(r,d??[]),u=P.useRef(c);d?u.current=c:u.current=r;const f=Kx(o),{activeScopes:p}=Hx(),h=$x();return Ux(()=>{if(f?.enabled===!1||!Wx(p,f?.scopes))return;let g=[],m;const v=(k,w=!1)=>{if(!(Dx(k)&&!Fh(k,f?.enableOnFormTags))){if(s.current!==null){const j=s.current.getRootNode();if((j instanceof Document||j instanceof ShadowRoot)&&j.activeElement!==s.current&&!s.current.contains(j.activeElement)){zh(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||Fi(i,f?.delimiter).forEach(j=>{if(j.includes(f?.splitKey??"+")&&j.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${j} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const N=$i(j,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(N.isSequence){m=setTimeout(()=>{g=[]},f?.sequenceTimeoutMs??1e3);const L=N.useKey?k.key:Ke(k.code);if(Mh(L.toLowerCase()))return;g.push(L);const T=N.keys?.[g.length-1];if(L!==T){g=[],m&&clearTimeout(m);return}g.length===N.keys?.length&&(u.current(k,N),m&&clearTimeout(m),g=[])}else if(Bx(k,N,f?.ignoreModifiers)||N.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||w&&a.current)return;if(Ax(k,N,f?.preventDefault),!Lx(k,N,f?.enabled)){zh(k);return}u.current(k,N),w||(a.current=!0)}})}},y=k=>{k.code!==void 0&&(Wh(Ke(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&v(k))},x=k=>{k.code!==void 0&&(Bh(Ke(k.code)),a.current=!1,f?.keyup&&v(k,!0))},b=s.current||o?.document||document;return b.addEventListener("keyup",x,o?.eventListenerOptions),b.addEventListener("keydown",y,o?.eventListenerOptions),h&&Fi(i,f?.delimiter).forEach(k=>h.addHotkey($i(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",x,o?.eventListenerOptions),b.removeEventListener("keydown",y,o?.eventListenerOptions),h&&Fi(i,f?.delimiter).forEach(k=>h.removeHotkey($i(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),g=[],m&&clearTimeout(m)}},[i,f,p]),s}const Jx=e=>{const{mode:r,removeNode:t,selectedTask:n,pasteTask:s}=ie(),a=ie.temporal,{undo:o,redo:i}=Xr(a,p=>p),d=e?.confirm||(p=>Promise.resolve(window.confirm(p))),c=e?.showToast,u=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const p=ie.getState(),{nodes:h,edges:g}=_e(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});ie.setState({nodes:h,edges:g})})};return cr("mod+z",p=>{r==="edit"&&(u(p)||(p.preventDefault(),o(),f()))},[r,o]),cr(["mod+shift+z","mod+y"],p=>{r==="edit"&&(u(p)||(p.preventDefault(),i(),f()))},[r,i]),cr("delete, backspace",p=>{r!=="edit"||!n||u(p)||(p.preventDefault(),d("确定要删除此任务吗?").then(h=>{h&&t(n.taskReferenceName)}))},[r,n,t,d]),cr("mod+c",p=>{if(!(r!=="edit"||!n)&&!u(p)){if(n.type==="JOIN"){c?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),c?.("任务已复制","success")}catch{c?.("复制失败","error")}}},[r,n,c]),cr("mod+v",p=>{if(r==="edit"&&!u(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const g=JSON.parse(h);s(g),c?.("任务已粘贴","success")}}catch{c?.("粘贴失败","error")}}},[r,s,c]),cr("mod+s",p=>{p.preventDefault();const h=ie.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},Gx=()=>{const[e,r]=P.useState(null),t=P.useCallback(a=>new Promise(o=>{r({message:a,resolve:o})}),[]),n=P.useCallback(()=>{e?.resolve(!0),r(null)},[e]),s=P.useCallback(()=>{e?.resolve(!1),r(null)},[e]);return{confirm:t,confirmState:e,handleConfirm:n,handleCancel:s}},Vx=()=>{const[e,r]=P.useState([]),t=P.useCallback((s,a="info")=>{const o=Date.now().toString();r(i=>[...i,{id:o,text:s,type:a}])},[]),n=P.useCallback(s=>{r(a=>a.filter(o=>o.id!==s))},[]);return{toasts:e,showToast:t,dismissToast:n}},Yx={taskNode:cx,decisionNode:dx,forkNode:Ah.ForkNode,joinNode:Ah.JoinNode,loopNode:px,subWorkflowNode:mx,plusNode:yx,dynamicPlaceholderNode:bx},Xx={addableEdge:Sx},Zx=({onNodeClick:e,searchQuery:r="",onSave:t,onRequestImport:n,executionActions:s})=>{const{nodes:a,edges:o,onNodesChange:i,onEdgesChange:d,onConnect:c,mode:u,viewMode:f,selectedTask:p,setSelectedTask:h,theme:g,edgeType:m,addNode:v,nodesLocked:y,executionData:x,validationResults:b,setIsDetailPanelOpen:k,workflowDef:w,dynamicRuntimeTasksByFork:j,layoutDirection:N,simState:L,workflowLoadKey:T}=ie(),C=P.useMemo(()=>{if(u==="run"||u==="edit")return new Set(a.map(K=>K.id));const H=ax[f],$=new Set;return a.forEach(K=>{if(K.type==="plusNode"||K.type==="dynamicPlaceholderNode"){$.add(K.id);return}if(K.parentId)return;const J=Xe.find(te=>te.type===K.data.taskType)?.viewCategory??"business";H.includes(J)&&$.add(K.id)}),a.forEach(K=>{K.parentId&&$.has(K.parentId)&&$.add(K.id)}),$},[a,f,u]),S=P.useCallback(H=>{if(C.size===a.length)return H;const $={};H.forEach(J=>{$[J.source]||($[J.source]=[]),$[J.source].push(J)});const K=[],U=new Set;return H.forEach(J=>{if(!C.has(J.source))return;if(C.has(J.target)){const fe=`${J.source}->${J.target}`;U.has(fe)||(U.add(fe),K.push(J));return}const te=[{to:J.target,label:J.label}],ue=new Set;for(;te.length;){const fe=te.shift();if(!ue.has(fe.to)){if(ue.add(fe.to),C.has(fe.to)){const me=`${J.source}->${fe.to}`;U.has(me)||(U.add(me),K.push({...J,id:me,target:fe.to,label:fe.label??J.label}));continue}($[fe.to]??[]).forEach(me=>te.push({to:me.target,label:fe.label??me.label}))}}}),K},[C,a.length]),{fitView:q}=A.useReactFlow(),[I,O]=P.useState(!1),[F,W]=P.useState(null),[V,Z]=P.useState(!1),[ne,ee]=P.useState(!1),{confirm:D,confirmState:Y,handleConfirm:se,handleCancel:R}=Gx(),{toasts:M,showToast:_,dismissToast:B}=Vx();Jx({confirm:D,showToast:_,onSave:t}),P.useEffect(()=>{if(p){const H=a.find($=>$.data.taskReferenceName===p.taskReferenceName);H&&q({nodes:[H],duration:800,padding:.5})}},[p?.taskReferenceName,q]),P.useEffect(()=>{const H=()=>{q({duration:800})};return window.addEventListener("workflow-zoom-to-fit",H),()=>window.removeEventListener("workflow-zoom-to-fit",H)},[q]),P.useEffect(()=>{if(T===0)return;const H=setTimeout(()=>{q({duration:600,padding:.12})},50);return()=>clearTimeout(H)},[T,q]),P.useEffect(()=>{const H=U=>{e&&U.detail&&U.detail.task&&e(U.detail.task)},$=U=>{if(u==="edit"){const{loopId:J,afterRef:te}=U.detail;W(te?{sourceId:te,edgeData:{}}:{sourceId:J,edgeData:{isLoopAdd:!0}}),O(!0)}},K=U=>{u==="edit"&&(W({sourceId:U.detail.source,targetId:U.detail.target,edgeId:U.detail.id,edgeData:U.detail.edgeData}),O(!0))};return document.addEventListener("miniTaskClick",H),document.addEventListener("loopAddNodeRequested",$),window.addEventListener("edgeAddNode",K),()=>{document.removeEventListener("miniTaskClick",H),document.removeEventListener("loopAddNodeRequested",$),window.removeEventListener("edgeAddNode",K)}},[u,e]);const z=P.useCallback(H=>{if(F){const{sourceId:$,targetId:K,edgeId:U,edgeData:J}=F;v({data:{label:`New ${H}`,taskReferenceName:`${H.toLowerCase()}_${Date.now()}`,taskType:H}},$,K,U,J)}O(!1),W(null)},[F,v]),Q=P.useMemo(()=>{const H={extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(u!=="run")return H;const $=a.filter(pe=>pe.type==="forkNode"&&pe.data.taskType==="FORK_JOIN_DYNAMIC");if(!$.length)return H;const K=[],U=[],J=new Set,te=new Set,ue=N==="LR",fe=47,me=120,de={animated:!0,style:{stroke:"#10b981",strokeDasharray:"4,4"},markerEnd:{type:A.MarkerType.ArrowClosed,color:"#10b981"}};for(const pe of $){const ve=j[pe.id]||[],Te=`${pe.id}_dynamic_placeholder`,ye=a.find(re=>re.id===Te),E=o.find(re=>re.target===Te),X=o.find(re=>re.source===Te);let ae,le;if(X)ae=X.target,le=a.find(re=>re.id===ae);else{const re=a.indexOf(pe);if(le=a.slice(re).find(xe=>xe.type==="joinNode"),!le)continue;ae=le.id}if(!le||(X&&J.add(X.id),E&&J.add(E.id),te.add(Te),!ve.length))continue;const ce=ve.length,he=ye?ye.position.x+110:(pe.position.x+le.position.x)/2,ke=ye?ye.position.y+35:(pe.position.y+le.position.y)/2;ve.forEach((re,xe)=>{const Ue=`dynamic_rt_${re.referenceTaskName}`,We=ue?he-me:pe.position.x+(xe-(ce-1)/2)*280,Hi=ue?ke-fe+(xe-(ce-1)/2)*110:ke-fe;K.push({id:Ue,type:"taskNode",data:{label:re.referenceTaskName,task:{name:re.referenceTaskName,taskReferenceName:re.referenceTaskName,type:re.taskType||"SIMPLE"},taskReferenceName:re.referenceTaskName,taskType:re.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:We,y:Hi}}),U.push({id:`e-${pe.id}-${Ue}`,source:pe.id,target:Ue,...de}),U.push({id:`e-${Ue}-${ae}`,source:Ue,target:ae,...de})})}return{extraNodes:K,extraEdges:U,removedEdgeIds:J,removedNodeIds:te}},[u,j,a,o,N]),G=P.useMemo(()=>[...S(o.filter(K=>!Q.removedEdgeIds.has(K.id))).map(K=>{const U=K.id.includes("loop-back"),J=g==="light"?"#64748b":"#94a3b8";let ue={...{...K.style,stroke:J,strokeWidth:2,strokeDasharray:U?"5,5":void 0}},fe=!1;if(u==="run"&&x){const ve=x[K.source]?.status,Te=x[K.target]?.status,ye=ve==="COMPLETED";ye&&Te==="COMPLETED"?(ue={...ue,stroke:"var(--status-completed)",strokeWidth:4},fe=!1):ye&&Te==="IN_PROGRESS"&&(ue={...ue,stroke:"var(--status-in-progress)",strokeWidth:4},fe=!0)}const me=K.source.endsWith("_dynamic_placeholder")||K.target.endsWith("_dynamic_placeholder"),de=K.source==="__workflow_start__"||K.source.startsWith("__loop_start__");return{...K,type:u==="edit"&&!U&&!me&&!de?"addableEdge":m,data:{...K.data,mode:u,edgeType:m,label:K.label},markerEnd:{type:A.MarkerType.ArrowClosed,width:20,height:20,color:ue.stroke},style:ue,animated:fe}}),...Q.extraEdges],[o,m,g,u,x,Q,S]);return l.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[l.jsxs(A,{nodes:P.useMemo(()=>{const H=new Set(b.errors.filter(J=>J.type==="TASK").map(J=>J.ref)),$=new Set(b.warnings.filter(J=>J.type==="TASK").map(J=>J.ref)),K=r.toLowerCase();return a.filter(J=>!Q.removedNodeIds.has(J.id)&&C.has(J.id)).map(J=>{const te=J.data.taskReferenceName,ue=L[te];return{...J,selected:p?.taskReferenceName===te,data:{...J.data,isError:u==="edit"&&H.has(te),hasWarning:u==="edit"&&$.has(te),isHighlighted:r?J.data.label.toLowerCase().includes(K)||J.data.taskReferenceName.toLowerCase().includes(K):!1,simRunning:ue==="running",simDone:ue==="done"}}}).concat(Q.extraNodes.map(J=>({...J,data:{...J.data,isError:!1,hasWarning:!1,isHighlighted:!1}})))},[a,b,r,p,Q,C,L,u]),edges:G,onNodesChange:i,onEdgesChange:d,onConnect:c,nodeTypes:Yx,edgeTypes:Xx,onNodeClick:(H,$)=>{if($.type==="plusNode"){W({sourceId:$.data.parentRef,edgeData:$.data.edgeData||{}}),O(!0);return}if($.type==="loopNode"){const U=$.data.task||null;h(U),e&&e(U);return}const K=$.data.task||null;h(K),e&&e(K)},onPaneClick:()=>{h(null),u!=="run"&&k(!1)},fitView:!0,nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[l.jsx(A.Background,{color:"var(--border-primary)",gap:20}),l.jsx(A.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:l.jsx(wx,{})}),u==="run"&&l.jsx(A.Panel,{position:"bottom-center",children:l.jsx(_x,{})}),l.jsx(Lh,{isOpen:V,onClose:()=>Z(!1),theme:g,onTaskSelect:H=>{h(H)}}),l.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:l.jsx(Tx,{onShowHealthCheck:()=>Z(!V),showHealthCheck:V,onShowSettings:()=>ee(!0),executionActions:s})})]}),!w&&l.jsx(Cx,{onRequestImport:n}),w&&a.length===0&&u==="edit"&&l.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:l.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{W({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),O(!0)},children:[l.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),I&&l.jsx(kx,{theme:g,onSelect:z,onCancel:()=>O(!1)}),l.jsx(Nx,{isOpen:ne,onClose:()=>ee(!1)}),Y&&l.jsx(Jr,{message:Y.message,onConfirm:se,onCancel:R}),l.jsx(Ix,{messages:M,onDismiss:B})]})},Hh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Kh=async(e,r={},t)=>{const n={...Hh,...r};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:t});if(!s.ok){const o=await s.json();throw new Error(o.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},Qx=async(e,r={},t,n,s)=>{const a={...Hh,...r};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const o=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!o.ok){const u=await o.json();throw new Error(u.error?.message||"AI request failed")}const i=o.body?.getReader();if(!i)throw new Error("ReadableStream not supported");const d=new TextDecoder;let c="";for(;;){const{done:u,value:f}=await i.read();if(u)break;const h=d.decode(f,{stream:!0}).split(`
31
- `).filter(g=>g.trim()!=="");for(const g of h)if(g.startsWith("data: ")){const m=g.slice(6);if(m==="[DONE]")return c;try{const y=JSON.parse(m).choices?.[0]?.delta?.content;y&&(c+=y,t(y))}catch{console.warn("[AI SSE] malformed chunk:",m)}}}return c},eb=(e,r,t,n,s)=>`
35
+ `}),o.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${h}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[o.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:"🩺"})," 工作流体检报告"]}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:p,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:l.length===0&&c.length===0?o.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),o.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),o.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):o.jsxs(o.Fragment,{children:[l.map((m,g)=>o.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&d(m.ref)},onClick:()=>d(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[o.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:f},children:m.message})]},`err-${g}`)),c.map((m,g)=>o.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&d(m.ref)},onClick:()=>d(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[o.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:f},children:m.message})]},`warn-${g}`))]})}),o.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:p,borderTop:`1px solid ${h}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[o.jsxs("span",{children:["共 ",l.length," 个错误, ",c.length," 个警告"]}),l.length>0&&o.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},gb=({id:e,source:t,target:r,sourceX:n,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,style:d={},markerEnd:u,data:f})=>{const[h,p]=I.useState(!1),m=I.useRef(null),g=()=>{const N=f?.edgeType||"default",S={sourceX:n,sourceY:s,sourcePosition:l,targetX:a,targetY:i,targetPosition:c};switch(N){case"step":case"smoothstep":return M.getSmoothStepPath(S);case"straight":return M.getStraightPath(S);default:return M.getBezierPath(S)}},[x,v,y]=g(),b=N=>{N.stopPropagation(),N.preventDefault();const S=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:f}});window.dispatchEvent(S)},k=()=>{m.current&&clearTimeout(m.current),p(!0)},_=()=>{m.current=setTimeout(()=>{p(!1)},100)},w=!!(f?.isAddable??f?.mode==="edit"),T=!!f?.label,O=typeof d?.strokeWidth=="number"?d.strokeWidth:2.2,D=typeof d?.opacity=="number"?d.opacity:1;return o.jsxs(o.Fragment,{children:[o.jsx(M.BaseEdge,{path:x,markerEnd:u,style:{...d,strokeWidth:w&&h?O+1.4:O,stroke:w&&h?"var(--color-accent)":d?.stroke,transition:"stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.25s ease",pointerEvents:"none"}}),w&&o.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:22,style:{cursor:"pointer",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:_}),(T||w&&h)&&o.jsx(M.EdgeLabelRenderer,{children:o.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${v}px,${y}px)`,fontSize:12,pointerEvents:w?"all":"none",zIndex:h?2e3:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",opacity:h?1:D,transition:"opacity 0.2s ease"},className:"nodrag nopan",onMouseEnter:w?k:void 0,onMouseLeave:w?_:void 0,children:[T&&o.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",color:"var(--text-primary)",padding:"2px 8px",borderRadius:"999px",fontSize:"11px",fontWeight:600,border:`1px solid ${h?"var(--color-accent)":"var(--border-secondary)"}`,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.22)",whiteSpace:"nowrap",letterSpacing:"0.3px",lineHeight:1.4},children:f.label}),w&&h&&o.jsx("button",{style:{width:"28px",height:"28px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.85)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"18px",lineHeight:1,boxShadow:"0 4px 14px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Ie=({onClick:e,icon:t,label:r,title:n,disabled:s=!1,active:a=!1,variant:i="default",style:l})=>{let c="var(--bg-tertiary)",d="var(--text-primary)",u="1px solid var(--border-primary)";return i==="primary"?(c="var(--color-accent)",d="#fff",u="none"):i==="danger"?(c=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",d=s?"var(--text-secondary)":"#fff",u="none"):a&&(c="var(--bg-secondary)",d="var(--color-accent)",u="1px solid var(--color-accent)"),o.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||r,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:d,border:u,borderRadius:"7px",padding:r?"4px 10px":"6px",cursor:s?"not-allowed":"pointer",opacity:s?.45:1,fontSize:"12px",fontWeight:500,transition:"all 0.18s",minWidth:r?"auto":"30px",height:"30px",whiteSpace:"nowrap",boxShadow:i==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...l},children:[t&&o.jsx("span",{style:{fontSize:"13px",display:"flex",alignItems:"center"},children:t}),r&&o.jsx("span",{children:r})]})},yb=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=M.useReactFlow();return o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:o.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.05)"},children:[o.jsx(Ie,{icon:"➕",title:"放大",onClick:()=>e()}),o.jsx(Ie,{icon:"➖",title:"缩小",onClick:()=>t()}),o.jsx(Ie,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},xm=[{id:"business",label:"业务",title:"仅展示核心业务节点"},{id:"standard",label:"标准",title:"业务 + 控制流节点"},{id:"developer",label:"全开发",title:"展示所有节点(含数据转换)"}];function xb(){const e=oe(a=>a.viewMode),t=oe(a=>a.setViewMode),r=I.useRef([]),[n,s]=I.useState({x:2,w:0});return I.useEffect(()=>{const a=xm.findIndex(l=>l.id===e),i=r.current[a];i&&s({x:i.offsetLeft,w:i.offsetWidth})},[e]),o.jsxs("div",{className:"mode-slider",role:"group","aria-label":"视图模式",children:[o.jsx("div",{className:"mode-slider-knob",style:{width:n.w,transform:`translateX(${n.x-2}px)`}}),xm.map((a,i)=>o.jsxs("button",{ref:l=>{r.current[i]=l},className:`mode-slider-opt${e===a.id?" active":""}`,onClick:()=>t(a.id),title:a.title,"aria-pressed":e===a.id,children:[o.jsx("span",{className:"mode-dot"}),a.label]},a.id))]})}const vm={enabled:!1,status:"COMPLETED",durationMs:"",forceCase:"",reasonForIncompletion:"",outputJsonText:""},vb=({isOpen:e,onClose:t})=>{const{workflowDef:r,theme:n,runLocalSandboxDryRun:s}=oe(),a=n==="light",[i,l]=I.useState("input"),[c,d]=I.useState(""),[u,f]=I.useState(null),[h,p]=I.useState({}),[m,g]=I.useState(""),[x,v]=I.useState(null),[y,b]=I.useState(2),k=I.useMemo(()=>r?.tasks?it(r.tasks):[],[r]),_=I.useMemo(()=>`sandbox_mock_cfg_${r?.name||"default"}`,[r?.name]);I.useEffect(()=>{if(!e||!r)return;const A=Lt(r);let B=!1;try{const P=sessionStorage.getItem(_);if(P){const U=JSON.parse(P);U.inputJsonText?d(U.inputJsonText):d(JSON.stringify(A,null,2)),U.taskDrafts&&typeof U.taskDrafts=="object"&&p(U.taskDrafts),typeof U.maxLoopIterations=="number"&&b(U.maxLoopIterations),B=!0}}catch{}B||(d(JSON.stringify(A,null,2)),p({}),b(2)),f(null),v(null),k.length>0&&!m&&g(k[0].taskReferenceName)},[e,r,_]),I.useEffect(()=>{k.length>0&&!k.some(A=>A.taskReferenceName===m)&&g(k[0].taskReferenceName)},[k,m]);const w=I.useMemo(()=>{const A=[];for(const B of k)if(B.type==="SWITCH"||B.type==="DECISION"){const P=Object.keys(B.decisionCases||{});if(P.length===0)continue;const U=B.caseValueParam||"case_value",L=String(B.inputParameters?.[U]??B.expression??"").match(/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)\s*\}/);A.push({switchRef:B.taskReferenceName,switchName:B.name||B.taskReferenceName,inputField:L?L[1]:null,cases:P})}return A},[k]);if(!e||!r||typeof document>"u")return null;const T=k.find(A=>A.taskReferenceName===m)||k[0]||null,O=T&&h[T.taskReferenceName]||vm,D=A=>{if(!T)return;const B=T.taskReferenceName,U={...h[B]||{...vm,outputJsonText:JSON.stringify(ur(T),null,2)},...A,enabled:A.enabled!==void 0?A.enabled:!0};p(se=>({...se,[B]:U})),v(null)},N=Object.values(h).filter(A=>A.enabled).length,S=(A,B)=>{try{const P=JSON.parse(c||"{}");P[A]=B,d(JSON.stringify(P,null,2)),f(null)}catch{f("请先修复当前 JSON 语法错误后再点击快捷赋值")}},R=()=>{let A={};try{if(A=c.trim()?JSON.parse(c):{},typeof A!="object"||Array.isArray(A)||A===null){f("workflow.input 必须是一个 JSON 对象 {...}"),l("input");return}}catch(P){f(`JSON 语法错误: ${P?.message||"格式不合法"}`),l("input");return}const B={};for(const[P,U]of Object.entries(h)){if(!U.enabled)continue;let se;if(U.outputJsonText.trim())try{se=JSON.parse(U.outputJsonText)}catch(F){g(P),l("tasks"),v(`节点 [${P}] 的自定义输出 JSON 语法有误: ${F?.message||""}`);return}const L=U.durationMs.trim()!==""&&!Number.isNaN(Number(U.durationMs))?Number(U.durationMs):void 0;B[P]={__isMockOverride:!0,status:U.status,durationMs:L,forceCase:U.forceCase||void 0,reasonForIncompletion:U.reasonForIncompletion.trim()||void 0,outputData:se}}try{sessionStorage.setItem(_,JSON.stringify({inputJsonText:c,taskDrafts:h,maxLoopIterations:y}))}catch{}s(A,B,y),t()},j=a?"#ffffff":"#0f172a",E=a?"#f8fafc":"#1e293b",q=a?"#f1f5f9":"#020617",$=a?"#0f172a":"#f8fafc",J=a?"#64748b":"#94a3b8",V=a?"rgba(148, 163, 184, 0.3)":"rgba(148, 163, 184, 0.18)";return _t.createPortal(o.jsx("div",{style:{position:"fixed",inset:0,zIndex:9500,background:"rgba(2, 6, 23, 0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:t,children:o.jsxs("div",{style:{width:"min(920px, 96vw)",height:"min(660px, 90vh)",background:j,color:$,borderRadius:14,border:`1px solid ${V}`,boxShadow:"0 24px 64px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:A=>A.stopPropagation(),children:[o.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${V}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:E},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:15,fontWeight:700},children:[o.jsx("span",{children:"🧪 本地沙箱试运行 · 人工模拟数据控制台"}),o.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:"rgba(16, 185, 129, 0.14)",color:"#10b981",fontWeight:600},children:"0ms 确定性求值"})]}),o.jsxs("div",{style:{fontSize:12,color:J,marginTop:4},children:["自定义工作流启动入参 (",o.jsx("code",{children:"workflow.input"}),")、指定任意节点的 Mock 输出、模拟节点异常中断或强制切换 ",o.jsx("code",{children:"SWITCH"})," 分支走向"]})]}),o.jsx("button",{type:"button",onClick:t,style:{background:"none",border:"none",color:J,fontSize:18,cursor:"pointer",padding:"4px 8px"},children:"✕"})]}),o.jsx("div",{style:{display:"flex",gap:8,padding:"10px 20px",borderBottom:`1px solid ${V}`,background:j},children:[{id:"input",label:"📥 1. 工作流启动入参 (workflow.input)"},{id:"tasks",label:`🎯 2. 节点级人工 Mock & 故障注入 ${N>0?`(${N} 个已启用)`:""}`},{id:"engine",label:`⚙️ 3. 循环轮次与引擎参数 (${y} 轮)`}].map(A=>{const B=i===A.id;return o.jsx("button",{type:"button",onClick:()=>l(A.id),style:{padding:"7px 14px",borderRadius:8,border:B?"1px solid #3b82f6":`1px solid ${V}`,background:B?"rgba(59, 130, 246, 0.14)":"transparent",color:B?"#3b82f6":J,fontSize:12,fontWeight:B?700:500,cursor:"pointer"},children:A.label},A.id)})}),o.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",overflow:"hidden"},children:[i==="input"&&o.jsxs("div",{style:{flex:1,padding:20,display:"flex",flexDirection:"column",gap:12,overflowY:"auto"},children:[w.length>0&&o.jsxs("div",{style:{padding:"10px 14px",borderRadius:10,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",display:"flex",flexDirection:"column",gap:8},children:[o.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#38bdf8"},children:"🧭 条件分支 (SWITCH) 快速路由切换器"}),w.map(A=>o.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,fontSize:12},children:[o.jsxs("span",{style:{color:J},children:["节点 ",o.jsx("b",{children:A.switchName})," (",o.jsx("code",{children:A.switchRef}),")",A.inputField?` 绑定入参字段 "${A.inputField}" — 点击一键切换分支:`:" 可选分支 (可在 Tab 2 强制指定):"]}),A.cases.map(B=>o.jsx("button",{type:"button",onClick:()=>{A.inputField?S(A.inputField,B):(g(A.switchRef),l("tasks"))},style:{padding:"2px 9px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.45)",background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontSize:11,fontFamily:"monospace",fontWeight:600,cursor:"pointer"},children:A.inputField?`${A.inputField} = "${B}"`:`走分支: ${B}`},B))]},A.switchRef))]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:600,color:J},children:["编辑 ",o.jsx("code",{children:"workflow.input"})," JSON(所有节点的 ",o.jsx("code",{children:"${workflow.input.*}"})," 将实时读取此处的值):"]}),o.jsx("button",{type:"button",onClick:()=>{const A=Lt(r);d(JSON.stringify(A,null,2)),f(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:`1px solid ${V}`,background:E,color:J,cursor:"pointer"},children:"↺ 重置为默认推导值"})]}),u&&o.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:12},children:["⚠️ ",u]}),o.jsx("textarea",{value:c,onChange:A=>{d(A.target.value),f(null)},spellCheck:!1,style:{flex:1,minHeight:240,width:"100%",boxSizing:"border-box",padding:14,borderRadius:10,border:`1px solid ${u?"#ef4444":V}`,background:q,color:$,fontFamily:"monospace",fontSize:13,lineHeight:1.55,resize:"none",outline:"none"}})]}),i==="tasks"&&o.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px 1fr",minHeight:0},children:[o.jsxs("div",{style:{borderRight:`1px solid ${V}`,overflowY:"auto",padding:"10px 8px",background:E,display:"flex",flexDirection:"column",gap:4},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:700,color:J,padding:"4px 8px 8px",textTransform:"uppercase"},children:["选择要定制 Mock 的节点 (",k.length,")"]}),k.map(A=>{const B=A.taskReferenceName,P=T?.taskReferenceName===B,U=h[B],se=!!U?.enabled;return o.jsxs("div",{onClick:()=>{g(B),v(null)},style:{padding:"8px 10px",borderRadius:8,cursor:"pointer",background:P?"rgba(59, 130, 246, 0.16)":"transparent",border:P?"1px solid rgba(59, 130, 246, 0.45)":"1px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A.name||B}),o.jsxs("div",{style:{fontSize:10,color:J,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[B," · ",A.type]})]}),se&&o.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:999,background:U.status==="FAILED"||U.status==="TIMED_OUT"?"rgba(239, 68, 68, 0.2)":"rgba(16, 185, 129, 0.2)",color:U.status==="FAILED"||U.status==="TIMED_OUT"?"#f87171":"#34d399",fontWeight:700,flexShrink:0},children:U.status==="COMPLETED"?"已定制":U.status})]},B)})]}),T?o.jsxs("div",{style:{padding:18,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:10,borderBottom:`1px solid ${V}`},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:14,fontWeight:700},children:[T.name||T.taskReferenceName," ",o.jsxs("code",{style:{fontSize:12,color:"#38bdf8",fontWeight:500},children:["(",T.taskReferenceName,")"]})]}),o.jsxs("div",{style:{fontSize:11,color:J,marginTop:2},children:["节点类型: ",o.jsx("b",{children:T.type})]})]}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:700,cursor:"pointer",padding:"6px 12px",borderRadius:8,background:O.enabled?"rgba(16, 185, 129, 0.14)":E,border:`1px solid ${O.enabled?"#10b981":V}`,color:O.enabled?"#10b981":J},children:[o.jsx("input",{type:"checkbox",checked:O.enabled,onChange:A=>D({enabled:A.target.checked})}),"启用该节点人工 Mock"]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 200px",gap:12},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:J,marginBottom:6},children:"模拟执行状态 (可注入异常以测试断路与错误诊断)"}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{id:"COMPLETED",label:"✅ 正常成功"},{id:"FAILED",label:"❌ 失败中断 (FAILED)"},{id:"TIMED_OUT",label:"⏱️ 超时中断 (TIMED_OUT)"},{id:"COMPLETED_WITH_ERRORS",label:"⚠️ 带错完成"}].map(A=>{const B=O.status===A.id;return o.jsx("button",{type:"button",onClick:()=>D({status:A.id}),style:{padding:"5px 10px",borderRadius:6,fontSize:11,fontWeight:B?700:500,cursor:"pointer",border:B?"1px solid #38bdf8":`1px solid ${V}`,background:B?"rgba(56, 189, 248, 0.16)":E,color:B?"#38bdf8":$},children:A.label},A.id)})})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:J,marginBottom:6},children:"模拟耗时 (ms,可制造并发瓶颈)"}),o.jsx("input",{type:"number",min:0,placeholder:"默认自动耗时 (如 120)",value:O.durationMs,onChange:A=>D({durationMs:A.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"6px 10px",borderRadius:6,border:`1px solid ${V}`,background:q,color:$,fontSize:12}})]})]}),(O.status==="FAILED"||O.status==="TIMED_OUT")&&o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#f87171",marginBottom:6},children:"模拟异常原因 (reasonForIncompletion)"}),o.jsx("input",{type:"text",placeholder:"例如: Connection refused to upstream payment gateway (502)",value:O.reasonForIncompletion,onChange:A=>D({reasonForIncompletion:A.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"7px 10px",borderRadius:6,border:"1px solid rgba(239, 68, 68, 0.45)",background:q,color:$,fontSize:12}})]}),(T.type==="SWITCH"||T.type==="DECISION")&&o.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.35)"},children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:700,color:"#fbbf24",marginBottom:6},children:"🔀 强制指定 SWITCH 路由分支 (无视入参表达式直接走指定分支)"}),o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[o.jsx("button",{type:"button",onClick:()=>D({forceCase:""}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,cursor:"pointer",border:O.forceCase?`1px solid ${V}`:"1px solid #fbbf24",background:O.forceCase?E:"rgba(245, 158, 11, 0.2)",color:O.forceCase?J:"#fbbf24",fontWeight:O.forceCase?500:700},children:"🔄 根据入参自动求值"}),Object.keys(T.decisionCases||{}).map(A=>{const B=O.forceCase===A;return o.jsxs("button",{type:"button",onClick:()=>D({forceCase:A}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:B?"1px solid #fbbf24":`1px solid ${V}`,background:B?"rgba(245, 158, 11, 0.22)":E,color:B?"#fbbf24":$,fontWeight:B?700:500},children:["分支: ",A]},A)}),T.defaultCase&&o.jsx("button",{type:"button",onClick:()=>D({forceCase:"__default__"}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:O.forceCase==="__default__"?"1px solid #fbbf24":`1px solid ${V}`,background:O.forceCase==="__default__"?"rgba(245, 158, 11, 0.22)":E,color:O.forceCase==="__default__"?"#fbbf24":$},children:"默认分支 (defaultCase)"})]})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("label",{style:{fontSize:11,fontWeight:600,color:J},children:["自定义节点输出数据 (",o.jsx("code",{children:`\${${T.taskReferenceName}.output.*}`})," 将读取此 JSON):"]}),o.jsx("button",{type:"button",onClick:()=>{const A=ur(T);D({outputJsonText:JSON.stringify(A,null,2)})},style:{fontSize:11,padding:"3px 9px",borderRadius:6,border:`1px solid ${V}`,background:E,color:"#38bdf8",cursor:"pointer",fontWeight:600},children:"📋 填入默认合成输出模板"})]}),x&&o.jsxs("div",{style:{padding:"6px 10px",borderRadius:6,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:11},children:["⚠️ ",x]}),o.jsx("textarea",{value:O.outputJsonText,placeholder:`留空则自动按 ${T.type} 类型合成输出,或点击右上角「填入默认合成输出模板」进行修改...`,onChange:A=>D({outputJsonText:A.target.value}),spellCheck:!1,style:{flex:1,minHeight:160,width:"100%",boxSizing:"border-box",padding:12,borderRadius:8,border:`1px solid ${x?"#ef4444":V}`,background:q,color:$,fontFamily:"monospace",fontSize:12,lineHeight:1.5,resize:"vertical",outline:"none"}})]})]}):o.jsx("div",{style:{padding:32,color:J},children:"当前工作流暂无任务节点"})]}),i==="engine"&&o.jsx("div",{style:{flex:1,padding:24,display:"flex",flexDirection:"column",gap:18},children:o.jsxs("div",{style:{padding:16,borderRadius:10,border:`1px solid ${V}`,background:E,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:13,fontWeight:700},children:"🔄 DO_WHILE 循环容器最大模拟迭代轮次"}),o.jsxs("div",{style:{fontSize:12,color:J,marginTop:2},children:["控制沙箱遇到 ",o.jsx("code",{children:"DO_WHILE"})," 节点时自动展开执行的循环轮次数(可在画布循环容器头部切换查看每一轮的子任务状态)"]})]}),o.jsxs("span",{style:{fontSize:16,fontWeight:800,color:"#38bdf8",fontFamily:"monospace"},children:[y," 轮"]})]}),o.jsx("input",{type:"range",min:1,max:8,value:y,onChange:A=>b(Number(A.target.value)),style:{width:"100%",accentColor:"#38bdf8",cursor:"pointer"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:J},children:[o.jsx("span",{children:"1 轮 (单次验证)"}),o.jsx("span",{children:"2 轮 (默认推荐)"}),o.jsx("span",{children:"5 轮"}),o.jsx("span",{children:"8 轮 (压测多轮轨迹)"})]})]})})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${V}`,background:E,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("button",{type:"button",onClick:()=>{p({});const A=Lt(r);d(JSON.stringify(A,null,2)),b(2),sessionStorage.removeItem(_)},style:{padding:"7px 12px",borderRadius:8,border:`1px solid ${V}`,background:"transparent",color:J,fontSize:12,cursor:"pointer"},children:"🧹 清空全部人工 Mock 配置"}),o.jsxs("div",{style:{display:"flex",gap:10},children:[o.jsx("button",{type:"button",onClick:t,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${V}`,background:"transparent",color:$,fontSize:12,fontWeight:600,cursor:"pointer"},children:"取消"}),o.jsx("button",{type:"button",onClick:R,style:{padding:"8px 20px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #2563eb, #0284c7)",color:"#ffffff",fontSize:12,fontWeight:700,cursor:"pointer",boxShadow:"0 4px 14px rgba(37, 99, 235, 0.35)"},children:"⚡ 应用模拟数据并启动沙箱试运行"})]})]})]})}),document.body)},yr=()=>o.jsx("div",{style:{width:"1px",height:"18px",background:"var(--border-primary)",margin:"0 2px",alignSelf:"center",flexShrink:0}}),bb=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:s,setMode:a,validationResults:i,workflowInstance:l,workflowDef:c,showDataLineage:d,setShowDataLineage:u,showWaterfallPanel:f,setShowWaterfallPanel:h,runLocalSandboxDryRun:p,inlineCopilotTaskRef:m,setInlineCopilotTaskRef:g,selectedTask:x}=oe(),v=oe.temporal,{undo:y,redo:b,pastStates:k,futureStates:_}=xr(v,B=>B),[w,T]=I.useState(!1),[O,D]=I.useState(!1),N=I.useRef(null);I.useEffect(()=>{if(!w)return;const B=P=>{N.current&&!N.current.contains(P.target)&&T(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[w]);const S=(i?.errors?.length||0)>0,R=l?.status,j=l?.workflowId??"",E=R==="RUNNING",q=R==="PAUSED",$=R==="FAILED"||R==="TIMED_OUT"||R==="TERMINATED",J=R==="COMPLETED",V=c?.restartable===!0&&($||J),A=n?.allowOperations!==!1;return o.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap",padding:"5px 8px",borderRadius:"10px",background:"var(--bg-secondary)",backdropFilter:"blur(14px)",border:"1px solid var(--border-primary)",boxShadow:"0 6px 24px rgba(0, 0, 0, 0.18)"},children:[o.jsx(xb,{}),c&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsx(Ie,{icon:"🔗",label:"数据血缘",title:"W-LSP 数据流血缘图谱 (Data Flow Graph)",onClick:()=>u(!d),active:d}),s==="edit"&&o.jsx(Ie,{icon:"⌘K",label:"AI微调",title:"画布内联 AI 指令栏 (Cmd+K)",onClick:()=>g(m?null:x?.taskReferenceName||"__canvas_root__"),active:!!m})]}),s==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsxs("div",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[o.jsx(Ie,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>y(),disabled:k.length===0}),o.jsx(Ie,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>b(),disabled:_.length===0})]}),o.jsx(Ie,{icon:"🩺",label:S?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:S?"danger":"secondary"}),o.jsx(Ie,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),c&&s!=="run"&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsxs("div",{style:{display:"inline-flex",alignItems:"center"},children:[o.jsx(Ie,{icon:"⚡",label:"沙箱试运行",title:"一键启动浏览器本地确定性沙箱试运行 (0ms Dry-Run)",onClick:()=>p(),variant:"primary",style:{borderRadius:"7px 0 0 7px",borderRight:"1px solid rgba(255, 255, 255, 0.25)"}}),o.jsx(Ie,{icon:"🧪",title:"人工模拟数据配置台 (自定义 workflow.input / 节点 Mock 输出 / 故障注入 / 分支路由)",onClick:()=>D(!0),variant:"primary",style:{borderRadius:"0 7px 7px 0",padding:"4px 7px",minWidth:"26px"}})]})]}),s==="run"&&o.jsxs(o.Fragment,{children:[o.jsx(yr,{}),o.jsx(Ie,{icon:"🧪",label:"模拟数据重跑",title:"打开沙箱人工模拟数据配置台,调整入参、分支或注入节点故障后重跑",onClick:()=>D(!0)}),o.jsx(Ie,{icon:"📊",label:"瀑布流回放",title:"并发甘特瀑布流与时间旅行调试器 (Time-Travel)",onClick:()=>h(!f),active:f}),o.jsx(Ie,{icon:"✏️",label:"返回编辑",title:"退出试跑/运行态视图,返回工作流编排画布",onClick:()=>a("edit")})]}),o.jsx(vb,{isOpen:O,onClose:()=>D(!1)}),s==="run"&&l&&n&&o.jsxs(o.Fragment,{children:[q&&n.onResume&&o.jsx(Ie,{icon:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:A?"继续执行工作流":"操作权限受限",onClick:()=>A&&n.onResume(j),disabled:!A,variant:"primary"}),E&&n.onPause&&o.jsx(Ie,{icon:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[o.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),o.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:A?"暂停工作流执行":"操作权限受限",onClick:()=>A&&n.onPause(j),disabled:!A}),(E||q)&&n.onTerminate&&o.jsx(Ie,{icon:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:A?"终止工作流执行":"操作权限受限",onClick:()=>A&&n.onTerminate(j),disabled:!A,variant:"danger"}),$&&n.onRetry&&o.jsx(Ie,{icon:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("path",{d:"M13 2v4h-4"}),o.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:A?"重试失败的工作流":"操作权限受限",onClick:()=>A&&n.onRetry(j),disabled:!A,variant:"primary"}),V&&n.onRestart&&o.jsxs("div",{ref:N,style:{position:"relative",display:"flex"},children:[o.jsxs("button",{disabled:!A,onClick:()=>A&&n.onRestart(j,{useLatestDef:!0}),title:A?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:A?"pointer":"not-allowed",opacity:A?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("path",{d:"M3 14v-4h4"}),o.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),o.jsx("button",{disabled:!A,onClick:()=>A&&T(B=>!B),title:A?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:A&&w?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:A?"pointer":"not-allowed",opacity:A?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:o.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),w&&o.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[o.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),o.jsxs("button",{onClick:()=>{n.onRestart(j,{useLatestDef:!0}),T(!1)},style:bm,onMouseEnter:B=>B.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:B=>B.currentTarget.style.background="transparent",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6"}),o.jsx("path",{d:"M8 5v3l2 1"})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),o.jsxs("button",{onClick:()=>{n.onRestart(j,{useLatestDef:!1}),T(!1)},style:bm,onMouseEnter:B=>B.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:B=>B.currentTarget.style.background="transparent",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),o.jsx("path",{d:"M6 6h4M6 9h3"})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},bm={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"},kb=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Sb=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:s}=oe(),[a,i]=I.useState(r),[l,c]=I.useState("basic"),d=s!=="edit";I.useEffect(()=>{r&&i(r)},[r,e]);const u=I.useCallback(j=>{j.key==="Escape"&&t()},[t]);if(I.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),!e||!a)return null;const f="var(--text-primary)",h="var(--glass-border)",p="var(--bg-tertiary)",m="var(--text-secondary)",g=(j,E)=>{if(!a||d)return;const q={...a,[j]:E};i(q),n({[j]:E})},x=(j,E,q)=>{if(!a||d)return;const J={...a[j]||{},[E]:q};i(V=>({...V,[j]:J})),n({[j]:J})},v=(j,E)=>{if(!(!a||d))try{const q=JSON.parse(E),$={...a,[j]:q};i($),n({[j]:q})}catch{i(q=>({...q,[`_${j}_str`]:E}))}},y={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${h}`,background:p,color:f,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:m,marginBottom:"8px",fontWeight:600},k=(j,E,q="text",$)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:b,children:j.toUpperCase()}),o.jsx("input",{className:"wsp-input",type:q,value:a?.[E]??"",onChange:J=>g(E,q==="number"?J.target.value===""?0:parseInt(J.target.value):J.target.value),disabled:d||$?.readOnly,placeholder:$?.placeholder,style:{...y,opacity:d||$?.readOnly?.6:1}})]}),_=(j,E,q=!1,$=6)=>{const J=a?.[`_${E}_str`]!==void 0?a[`_${E}_str`]:typeof a?.[E]=="object"?JSON.stringify(a[E],null,2):a?.[E];return o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("label",{style:b,children:[j.toUpperCase()," ",q&&"(JSON)"]}),o.jsx("textarea",{className:"wsp-input",value:J||"",onChange:V=>q?v(E,V.target.value):g(E,V.target.value),rows:$,disabled:d,style:{...y,fontSize:"13px",fontFamily:q?"var(--font-mono)":"inherit",resize:"vertical",opacity:d?.6:1}})]})},w=(j,E,q)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:b,children:j.toUpperCase()}),o.jsx("select",{className:"wsp-input",value:a?.[E]??q[0]?.value,onChange:$=>g(E,$.target.value),disabled:d,style:{...y,opacity:d?.6:1,cursor:d?"not-allowed":"pointer"},children:q.map($=>o.jsx("option",{value:$.value,children:$.label},$.value))})]}),T=(j,E)=>{const q=!!a?.[E];return o.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("label",{style:{fontSize:"13px",color:f},children:j}),o.jsx("button",{type:"button",role:"switch","aria-checked":q,onClick:()=>!d&&g(E,!q),disabled:d,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:q?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:d?"not-allowed":"pointer",transition:"background 0.2s",opacity:d?.6:1,flexShrink:0},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:q?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})},O=()=>o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),_("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),D=()=>o.jsxs(o.Fragment,{children:[w("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),o.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&o.jsx("p",{style:{fontSize:"11px",color:m,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),T("允许重启 (restartable)","restartable")]}),N=()=>{const j=At(a?.inputParameters),E=A=>{d||g("inputParameters",A)},q=()=>{const A=[...j,{name:`param_${j.length+1}`,type:"string",required:!1}];E(A)},$=A=>{const B=j.filter((P,U)=>U!==A);E(B)},J=(A,B,P)=>{const U=j.map((se,L)=>L===A?{...se,[B]:P}:se);E(U)},V={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${h}`,background:p,color:f,fontSize:"12px",outline:"none",fontFamily:"inherit"};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("label",{style:b,children:"入参声明 (INPUT PARAMETERS)"}),!d&&o.jsx("button",{onClick:q,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),j.length===0?o.jsx("p",{style:{fontSize:"12px",color:m,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${h}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:j.map((A,B)=>o.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${h}`,borderRadius:"10px",padding:"12px"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[o.jsx("input",{style:V,placeholder:"参数名",value:A.name,onChange:P=>J(B,"name",P.target.value),disabled:d}),o.jsx("select",{style:{...V,cursor:d?"not-allowed":"pointer"},value:A.type??"string",onChange:P=>J(B,"type",P.target.value),disabled:d,children:["string","number","boolean","object","array"].map(P=>o.jsx("option",{value:P,children:P},P))}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:m,cursor:d?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[o.jsx("input",{type:"checkbox",checked:!!A.required,onChange:P=>J(B,"required",P.target.checked),disabled:d,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!d&&o.jsx("button",{onClick:()=>$(B),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),o.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[o.jsx("input",{style:V,placeholder:"说明(可选)",value:A.description??"",onChange:P=>J(B,"description",P.target.value),disabled:d}),o.jsx("input",{style:V,placeholder:`示例值(如 ${A.type==="number"?"42":A.type==="boolean"?"true":'"value"'})`,value:A.example!==void 0?typeof A.example=="object"?JSON.stringify(A.example):String(A.example):"",onChange:P=>{let U=P.target.value;try{U=JSON.parse(P.target.value)}catch{}J(B,"example",U)},disabled:d})]})]},B))})]}),_("输出参数映射 (outputParameters)","outputParameters",!0),_("默认输入模板 (inputTemplate)","inputTemplate",!0),_("工作流级变量 (variables)","variables",!0)]})},S=()=>o.jsxs(o.Fragment,{children:[T("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),o.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[T("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&o.jsxs(o.Fragment,{children:[_("输入 Schema (inputSchema)","inputSchema",!0,4),_("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),o.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[o.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:b,children:"RATE LIMIT KEY"}),o.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:j=>x("rateLimitConfig","rateLimitKey",j.target.value),disabled:d,placeholder:"限流键",style:{...y,opacity:d?.6:1}})]}),o.jsxs("div",{children:[o.jsx("label",{style:b,children:"并发上限"}),o.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:j=>x("rateLimitConfig","concurrentExecLimit",j.target.value===""?0:parseInt(j.target.value)),disabled:d,placeholder:"0",style:{...y,opacity:d?.6:1}})]})]})]})]}),R=()=>{switch(l){case"basic":return O();case"timeout":return D();case"params":return N();case"advanced":return S()}};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:t,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:o.jsxs("div",{onClick:j=>j.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${h}`,backdropFilter:"blur(20px)"},children:[o.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[o.jsxs("div",{children:[o.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),o.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:m},children:d?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),o.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${h}`},children:kb.map(j=>o.jsx("button",{className:"wsp-tab",onClick:()=>c(j.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:l===j.id?600:400,color:l===j.id?"var(--color-accent)":m,background:"none",border:"none",borderBottom:l===j.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:j.label},j.id))})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:R()}),o.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${h}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:o.jsx("button",{className:"wsp-footer-btn",onClick:t,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},_b=({size:e=26,className:t,style:r})=>{const n=I.useId().replace(/:/g,"");return o.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:{flexShrink:0,display:"inline-block",verticalAlign:"middle",...r},"aria-label":"Conductor Workflow IDE Logo",children:[o.jsxs("defs",{children:[o.jsxs("linearGradient",{id:`bg-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#11172B"}),o.jsx("stop",{offset:"100%",stopColor:"#090D18"})]}),o.jsxs("linearGradient",{id:`bd-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#6366F1",stopOpacity:"0.8"}),o.jsx("stop",{offset:"100%",stopColor:"#06B6D4",stopOpacity:"0.5"})]}),o.jsxs("linearGradient",{id:`top-${n}`,x1:"9",y1:"16",x2:"23",y2:"10",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#818CF8"}),o.jsx("stop",{offset:"100%",stopColor:"#22D3EE"})]}),o.jsxs("linearGradient",{id:`bot-${n}`,x1:"9",y1:"16",x2:"23",y2:"22",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#6366F1"}),o.jsx("stop",{offset:"100%",stopColor:"#34D399"})]})]}),o.jsx("rect",{x:"1.25",y:"1.25",width:"29.5",height:"29.5",rx:"8",fill:`url(#bg-${n})`,stroke:`url(#bd-${n})`,strokeWidth:"1.5"}),o.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 10, 22.5 10",stroke:`url(#top-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),o.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 22, 22.5 22",stroke:`url(#bot-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),o.jsx("circle",{cx:"9.5",cy:"16",r:"3.4",fill:"#6366F1"}),o.jsx("circle",{cx:"9.5",cy:"16",r:"1.4",fill:"#F8FAFC"}),o.jsx("circle",{cx:"22.5",cy:"10",r:"2.7",fill:"#22D3EE"}),o.jsx("circle",{cx:"22.5",cy:"22",r:"2.7",fill:"#34D399"})]})},wb=({onRequestImport:e})=>{const{createBlankWorkflow:t}=oe(),[r,n]=I.useState(""),s=()=>{t(r||void 0),oe.temporal.getState().clear()},a=()=>{t(r||void 0),oe.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return o.jsxs("div",{className:"empty-state-panel",children:[o.jsx("div",{style:{marginBottom:12},children:o.jsx(_b,{size:46})}),o.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),o.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),o.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}}),o.jsxs("div",{className:"empty-state-actions",children:[o.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),o.jsxs("button",{className:"empty-state-btn",onClick:a,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&o.jsxs("button",{className:"empty-state-btn",onClick:e,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},Tb={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Eb=({messages:e,onDismiss:t})=>e.length===0?null:o.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:3e3,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:e.map(r=>o.jsx(Nb,{message:r,onDismiss:t},r.id))}),Nb=({message:e,onDismiss:t})=>{const r=Tb[e.type||"info"];return I.useEffect(()=>{const n=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(n)},[e.id,t]),o.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:r.bg,color:r.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>t(e.id),children:e.text})},km=["shift","alt","meta","mod","ctrl","control"],jb={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function tt(e){return(jb[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Sm(e){return km.includes(e)}function hl(e,t=","){return e.toLowerCase().split(t)}function ml(e,t="+",r=">",n=!1,s){let a=[],i=!1;e=e.trim(),e.includes(r)?(i=!0,a=e.toLocaleLowerCase().split(r).map(d=>tt(d))):a=e.toLocaleLowerCase().split(t).map(d=>tt(d));const l={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},c=a.filter(d=>!km.includes(d));return{...l,keys:c,description:s,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&_m([tt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&wm([tt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Xe.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Xe.clear()},0)}));const Xe=new Set;function gl(e){return Array.isArray(e)}function Cb(e,t=","){return(gl(e)?e:e.split(t)).every(r=>Xe.has(r.trim().toLowerCase()))}function _m(e){const t=Array.isArray(e)?e:[e];Xe.has("meta")&&Xe.forEach(r=>!Sm(r)&&Xe.delete(r.toLowerCase())),t.forEach(r=>Xe.add(r.toLowerCase()))}function wm(e){const t=Array.isArray(e)?e:[e];e==="meta"?Xe.clear():t.forEach(r=>Xe.delete(r.toLowerCase()))}function Ib(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function Rb(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const Ob=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Pb(e){return Tm(e,Ob)}function Tm(e,t=!1){const{target:r,composed:n}=e;let s,a;return Ab(r)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,a=r&&r.role),gl(t)?!!(s&&t&&t.some(i=>i.toLowerCase()===s.toLowerCase()||i===a)):!!(s&&t&&t)}function Ab(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Lb(e,t){return e.length===0&&t?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):t?e.some(r=>t.includes(r))||e.includes("*"):!0}const Db=(e,t,r=!1)=>{const{alt:n,meta:s,mod:a,shift:i,ctrl:l,keys:c,useKey:d}=t,{code:u,key:f,ctrlKey:h,metaKey:p,shiftKey:m,altKey:g}=e,x=tt(u);if(d&&c?.length===1&&c.includes(f))return!0;if(!c?.includes(x)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(x))return!1;if(!r){if(n!==g&&x!=="alt"||i!==m&&x!=="shift")return!1;if(a){if(!p&&!h)return!1}else if(s!==p&&x!=="meta"&&x!=="os"||l!==h&&x!=="ctrl"&&x!=="control")return!1}return c&&c.length===1&&c.includes(x)?!0:c?Cb(c):!c},Mb=I.createContext(void 0),qb=()=>I.useContext(Mb);function Em(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((r,n)=>r&&Em(e[n],t[n]),!0):e===t}const $b=I.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Wb=()=>I.useContext($b);function Fb(e){const t=I.useRef(void 0);return Em(t.current,e)||(t.current=e),t.current}const Nm=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Bb=typeof window<"u"?I.useLayoutEffect:I.useEffect;function St(e,t,r,n){const s=I.useRef(null),a=I.useRef(!1),i=Array.isArray(r)?Array.isArray(n)?void 0:n:r,l=gl(e)?e.join(i?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,d=I.useCallback(t,c??[]),u=I.useRef(d);c?u.current=d:u.current=t;const f=Fb(i),{activeScopes:h}=Wb(),p=qb();return Bb(()=>{if(f?.enabled===!1||!Lb(h,f?.scopes))return;let m=[],g;const x=(k,_=!1)=>{if(!(Pb(k)&&!Tm(k,f?.enableOnFormTags))){if(s.current!==null){const w=s.current.getRootNode();if((w instanceof Document||w instanceof ShadowRoot)&&w.activeElement!==s.current&&!s.current.contains(w.activeElement)){Nm(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||hl(l,f?.delimiter).forEach(w=>{if(w.includes(f?.splitKey??"+")&&w.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${w} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const T=ml(w,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(T.isSequence){g=setTimeout(()=>{m=[]},f?.sequenceTimeoutMs??1e3);const O=T.useKey?k.key:tt(k.code);if(Sm(O.toLowerCase()))return;m.push(O);const D=T.keys?.[m.length-1];if(O!==D){m=[],g&&clearTimeout(g);return}m.length===T.keys?.length&&(u.current(k,T),g&&clearTimeout(g),m=[])}else if(Db(k,T,f?.ignoreModifiers)||T.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||_&&a.current)return;if(Ib(k,T,f?.preventDefault),!Rb(k,T,f?.enabled)){Nm(k);return}u.current(k,T),_||(a.current=!0)}})}},v=k=>{k.code!==void 0&&(_m(tt(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&x(k))},y=k=>{k.code!==void 0&&(wm(tt(k.code)),a.current=!1,f?.keyup&&x(k,!0))},b=s.current||i?.document||document;return b.addEventListener("keyup",y,i?.eventListenerOptions),b.addEventListener("keydown",v,i?.eventListenerOptions),p&&hl(l,f?.delimiter).forEach(k=>p.addHotkey(ml(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",y,i?.eventListenerOptions),b.removeEventListener("keydown",v,i?.eventListenerOptions),p&&hl(l,f?.delimiter).forEach(k=>p.removeHotkey(ml(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),m=[],g&&clearTimeout(g)}},[l,f,h]),s}const zb=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:s}=oe(),a=oe.temporal,{undo:i,redo:l}=xr(a,h=>h),c=e?.confirm||(h=>Promise.resolve(window.confirm(h))),d=e?.showToast,u=h=>{const p=h.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable},f=()=>{requestAnimationFrame(()=>{const h=oe.getState(),{nodes:p,edges:m}=je(h.nodes,h.edges,{direction:h.layoutDirection,mode:h.mode});oe.setState({nodes:p,edges:m})})};return St("mod+z",h=>{t==="edit"&&(u(h)||(h.preventDefault(),i(),f()))},[t,i]),St(["mod+shift+z","mod+y"],h=>{t==="edit"&&(u(h)||(h.preventDefault(),l(),f()))},[t,l]),St("delete, backspace",h=>{t!=="edit"||!n||u(h)||(h.preventDefault(),c("确定要删除此任务吗?").then(p=>{p&&r(n.taskReferenceName)}))},[t,n,r,c]),St("mod+c",h=>{if(!(t!=="edit"||!n)&&!u(h)){if(n.type==="JOIN"){d?.("JOIN 任务不能独立复制","error");return}h.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),d?.("任务已复制","success")}catch{d?.("复制失败","error")}}},[t,n,d]),St("mod+v",h=>{if(t==="edit"&&!u(h)){h.preventDefault();try{const p=localStorage.getItem("conductor-clipboard");if(p){const m=JSON.parse(p);s(m),d?.("任务已粘贴","success")}}catch{d?.("粘贴失败","error")}}},[t,s,d]),St("mod+s",h=>{h.preventDefault();const p=oe.getState().workflowDef;p&&e?.onSave&&e.onSave(p)},[e?.onSave]),{}},Hb=()=>{const[e,t]=I.useState(null),r=I.useCallback(a=>new Promise(i=>{t({message:a,resolve:i})}),[]),n=I.useCallback(()=>{e?.resolve(!0),t(null)},[e]),s=I.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:s}},Jb=()=>{const[e,t]=I.useState([]),r=I.useCallback((s,a="info")=>{const i=Date.now().toString();t(l=>[...l,{id:i,text:s,type:a}])},[]),n=I.useCallback(s=>{t(a=>a.filter(i=>i.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:n}},yl={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
36
+
37
+ 我可以帮你:
38
+ - 🆕 **从零创建**工作流(描述业务场景即可)
39
+ - ➕ **添加/修改/删除**任务节点
40
+ - 🔀 **重构拓扑**(如串行改并行)
41
+ - 🔍 **诊断问题**和优化建议
42
+
43
+ 直接告诉我你想做什么吧!`,timestamp:Date.now()},Ub=()=>(e,t)=>({config:{provider:"auto",apiKey:""},messages:[yl],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null,metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(n=>({config:{...n.config,...r}})),addMessage:r=>{const n=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:n,timestamp:Date.now()};return e(a=>({messages:[...a.messages,s]})),n},updateMessage:(r,n)=>e(s=>({messages:s.messages.map(a=>a.id===r?{...a,content:n}:a)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(n=>({streamingText:n.streamingText+r})),clearMessages:()=>e({messages:[yl],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const n=`prop_${Date.now()}`,s=oe.getState().workflowDef,a=JSON.stringify(s);return e(i=>({pendingProposal:{...r,id:n,baselineHash:a},metrics:{...i.metrics,totalProposals:i.metrics.totalProposals+1}})),n},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),getMetrics:()=>t().metrics,recordUsage:r=>e(n=>({metrics:{...n.metrics,totalPromptTokens:n.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:n.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const n=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:n}}),n},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const n=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:n}}),n},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(n=>({undoStack:[...n.undoStack.slice(-4),r]})),popUndo:()=>{const r=t().undoStack;if(r.length===0)return null;const n=r[r.length-1];return e({undoStack:r.slice(0,-1)}),n},clearUndo:()=>e({undoStack:[]}),canUndo:()=>t().undoStack.length>0,setClarification:r=>{const n=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:n}}),n},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const n=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:n}}),n},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:r=>e({retryInput:r}),addTimelineEntry:(r,n="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:n}]})),clearTimeline:()=>e({timelineEntries:[]}),setSynthesisStage:(r,n)=>e(s=>({synthesisPhase:r,workingDraft:n!==void 0?n:s.workingDraft})),saveCheckpoint:r=>e({durableCheckpoint:r}),clearCheckpoint:()=>e({durableCheckpoint:null,synthesisPhase:"idle",workingDraft:null}),hydrateFromDraft:(r,n,s)=>e({messages:r.length>0?r:[yl],pendingProposal:n,durableCheckpoint:s??null,synthesisPhase:s?.phase??"idle",workingDraft:s?.workingDraft??null})});function Kb(e="ai-workflow-config"){const t=Ub();return e===!1?vr()(t):vr()(Tl(t,{name:e,storage:br(()=>localStorage),partialize:r=>({config:{...r.config,apiKey:""},metrics:r.metrics})}))}const jm=Kb(),Gb=I.createContext(null);function Cm(){return I.useContext(Gb)}const Vb=()=>{const{mode:e,showWaterfallPanel:t,setShowWaterfallPanel:r,workflowInstance:n,executionData:s,taskMap:a,selectedTask:i,setSelectedTask:l,setSelectedTaskInstance:c,timeTravelTimestamp:d,setTimeTravelTimestamp:u}=oe(),f=I.useMemo(()=>{const y=n?.tasks?.length?n.tasks:s?Object.values(s).flatMap(N=>N.attempts):[];if(y.length===0)return null;const b=y.filter(N=>N.startTime||N.scheduledTime);if(b.length===0)return null;const k=Math.min(...b.map(N=>N.scheduledTime||N.startTime||Date.now())),_=Math.max(...b.map(N=>N.endTime||N.startTime||N.scheduledTime||k+100)),w=Math.max(_-k,50),T=b.filter(N=>!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(N.taskType)).map(N=>Math.max((N.endTime||_)-(N.startTime||N.scheduledTime||k),0)).sort((N,S)=>S-N),O=T.length>0?Math.max(T[Math.floor(T.length*.25)]||80,50):100,D=b.map((N,S)=>{const R=N.scheduledTime||N.startTime||k,j=N.startTime||R,E=N.endTime||_,q=Math.max(j-R,0),$=Math.max(E-j,1),J=!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(N.taskType)&&$>=O,V=(R-k)/w*100,A=q/w*100,B=(j-k)/w*100,P=Math.max($/w*100,1.2);return{key:N.taskId||`${N.referenceTaskName}-${S}`,task:N,sched:R,start:j,end:E,queueMs:q,execMs:$,isCritical:J,queueLeftPct:V,queueWidthPct:A,execLeftPct:B,execWidthPct:P}});return{minTime:k,maxTime:_,totalSpanMs:w,rows:D}},[n,s]);if(e!=="run"||!t||!f)return null;const{minTime:h,totalSpanMs:p,rows:m}=f,g=d!==null?d-h:p,x=Math.min(Math.max(g/p*100,0),100),v=y=>{switch(y){case"COMPLETED":return"#10b981";case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":case"TIMED_OUT":return"#ef4444";case"IN_PROGRESS":return"#38bdf8";default:return"#94a3b8"}};return o.jsxs("div",{style:{position:"absolute",left:16,right:i?466:16,bottom:16,height:255,zIndex:1100,background:"rgba(15, 23, 42, 0.95)",backdropFilter:"blur(16px)",border:"1px solid rgba(56, 189, 248, 0.3)",borderRadius:12,boxShadow:"0 16px 40px rgba(0, 0, 0, 0.45)",display:"flex",flexDirection:"column",overflow:"hidden",transition:"right 0.25s ease"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 14px",borderBottom:"1px solid rgba(148, 163, 184, 0.16)",background:"rgba(2, 6, 23, 0.55)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#f8fafc"},children:"📊 并发执行瀑布流 & 时间旅行调试器"}),o.jsxs("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontFamily:"monospace",fontWeight:600},children:["总跨度 ",p,"ms · ",m.length," 个任务步"]}),o.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(249, 115, 22, 0.15)",color:"#fb923c",fontWeight:600},children:"🔥 关键路径耗时瓶颈高亮"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,maxWidth:420},children:[o.jsx("span",{style:{fontSize:10,color:"#94a3b8",whiteSpace:"nowrap"},children:"⏪ 时间旅行指针:"}),o.jsx("input",{type:"range",min:0,max:p,value:g,onChange:y=>{const b=Number(y.target.value);b>=p?u(null):u(h+b)},style:{flex:1,cursor:"pointer",accentColor:"#38bdf8"}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:d!==null?"#fbbf24":"#34d399",fontWeight:700,minWidth:74,textAlign:"right"},children:d!==null?`+${g}ms`:"最新态 (Live)"}),d!==null&&o.jsx("button",{type:"button",onClick:()=>u(null),style:{fontSize:10,padding:"2px 7px",borderRadius:4,border:"1px solid rgba(251, 191, 36, 0.4)",background:"rgba(251, 191, 36, 0.12)",color:"#fbbf24",cursor:"pointer"},children:"重置"})]}),o.jsx("button",{type:"button",onClick:()=>r(!1),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:15,padding:"2px 6px"},children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",position:"relative",padding:"6px 0"},children:m.map(y=>{const b=y.task.referenceTaskName.replace(/__\d+$/,""),k=i?.taskReferenceName===b,_=d!==null&&y.start>d,w=d!==null&&y.start<=d&&y.end>d;return o.jsxs("div",{onClick:()=>{const T=a[b]||y.task.workflowTask;T&&(l(T),c(y.task))},style:{display:"grid",gridTemplateColumns:"210px 1fr 90px",alignItems:"center",gap:8,padding:"4px 14px",cursor:"pointer",background:k?"rgba(56, 189, 248, 0.14)":"transparent",opacity:_?.35:1,borderLeft:k?"3px solid #38bdf8":"3px solid transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:w?"#38bdf8":v(y.task.status),flexShrink:0}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:"#e2e8f0",fontWeight:k?700:500,overflow:"hidden",textOverflow:"ellipsis"},title:y.task.referenceTaskName,children:y.task.referenceTaskName}),y.isCritical&&o.jsx("span",{title:"关键路径耗时瓶颈节点",style:{fontSize:9,padding:"1px 4px",borderRadius:4,background:"rgba(249, 115, 22, 0.2)",color:"#fb923c",fontWeight:700,flexShrink:0},children:"🔥瓶颈"})]}),o.jsxs("div",{style:{position:"relative",height:14,background:"rgba(15, 23, 42, 0.65)",borderRadius:4,overflow:"hidden",border:"1px solid rgba(148, 163, 184, 0.1)"},children:[y.queueWidthPct>.3&&o.jsx("div",{title:`排队等待: ${y.queueMs}ms`,style:{position:"absolute",left:`${y.queueLeftPct}%`,width:`${y.queueWidthPct}%`,top:3,bottom:3,background:"rgba(148, 163, 184, 0.35)",borderRadius:"2px 0 0 2px"}}),o.jsx("div",{title:`执行耗时: ${y.execMs}ms (排队 ${y.queueMs}ms)`,style:{position:"absolute",left:`${y.execLeftPct}%`,width:`${y.execWidthPct}%`,top:2,bottom:2,borderRadius:3,background:y.isCritical?"linear-gradient(90deg, #f97316, #ef4444)":v(y.task.status),boxShadow:w?"0 0 8px rgba(56, 189, 248, 0.8)":void 0}}),d!==null&&o.jsx("div",{style:{position:"absolute",left:`${x}%`,top:0,bottom:0,width:2,background:"#fbbf24",pointerEvents:"none"}})]}),o.jsxs("div",{style:{fontSize:10,fontFamily:"monospace",color:y.isCritical?"#fb923c":"#94a3b8",textAlign:"right",fontWeight:y.isCritical?700:400},children:[y.execMs,"ms",y.queueMs>0?o.jsxs("span",{style:{opacity:.6,fontSize:9},children:[" (+",y.queueMs,"q)"]}):null]})]},y.key)})})]})};function Im(e){if(!e)return"未设置";if(e<60)return`${e} 秒`;const t=Math.floor(e/60),r=e%60;return r>0?`${t} 分 ${r} 秒`:`${t} 分钟`}function Yb(e,t){const r=[];if(e.name!==t.name&&r.push(`名称:「${e.name}」→「${t.name}」`),e.type!==t.type&&r.push(`类型:${e.type} → ${t.type}`),e.timeoutSeconds!==t.timeoutSeconds&&r.push(`超时:${Im(e.timeoutSeconds)} → ${Im(t.timeoutSeconds)}`),(e.retryCount??0)!==(t.retryCount??0)){const n=e.retryCount??0,s=t.retryCount??0;r.push(s>n?`新增失败重试(${s} 次)`:s===0?"移除了失败重试":`重试次数:${n} → ${s}`)}return JSON.stringify(e.inputParameters??{})!==JSON.stringify(t.inputParameters??{})&&r.push("输入参数已调整"),JSON.stringify(e.decisionCases)!==JSON.stringify(t.decisionCases)&&r.push("分支条件已调整"),JSON.stringify(e.forkTasks)!==JSON.stringify(t.forkTasks)&&r.push("并行分支已调整"),r.length===0&&r.push("配置已调整"),r}function Xb(e,t){const r=t.tasks??[];if(!e)return{added:r.map(p=>p.taskReferenceName),modified:[],removed:[],propsChanged:!1};const n=new Map((e.tasks??[]).map(p=>[p.taskReferenceName,p])),s=new Map(r.map(p=>[p.taskReferenceName,p])),a=[],i=[],l=[],c=[];for(const[p,m]of s)if(!n.has(p))a.push(p);else{const g=n.get(p);JSON.stringify(m)!==JSON.stringify(g)&&(i.push(p),c.push({ref:p,changes:Yb(g,m)}))}for(const p of n.keys())s.has(p)||l.push(p);const d=e.name!==t.name||e.description!==t.description||e.timeoutSeconds!==t.timeoutSeconds||e.version!==t.version||e.ownerEmail!==t.ownerEmail||e.failureWorkflow!==t.failureWorkflow||JSON.stringify(e.inputParameters)!==JSON.stringify(t.inputParameters)||JSON.stringify(e.outputParameters)!==JSON.stringify(t.outputParameters),u=(e.tasks??[]).filter(p=>s.has(p.taskReferenceName)).map(p=>p.taskReferenceName),f=r.filter(p=>n.has(p.taskReferenceName)).map(p=>p.taskReferenceName),h=u.join(",")!==f.join(",");return{added:a,modified:i,removed:l,propsChanged:d,reordered:h,modifiedDetails:c}}const Rm={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},xl=async(e,t={},r)=>{const n={...Rm,...t};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:r});if(!s.ok){const i=await s.json();throw new Error(i.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},Qb=async(e,t={},r,n,s)=>{const a={...Rm,...t};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const i=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!i.ok){const u=await i.json();throw new Error(u.error?.message||"AI request failed")}const l=i.body?.getReader();if(!l)throw new Error("ReadableStream not supported");const c=new TextDecoder;let d="";for(;;){const{done:u,value:f}=await l.read();if(u)break;const p=c.decode(f,{stream:!0}).split(`
44
+ `).filter(m=>m.trim()!=="");for(const m of p)if(m.startsWith("data: ")){const g=m.slice(6);if(g==="[DONE]")return d;try{const v=JSON.parse(g).choices?.[0]?.delta?.content;v&&(d+=v,r(v))}catch{console.warn("[AI SSE] malformed chunk:",g)}}}return d},Zb=(e,t,r,n,s)=>`
32
45
  You are a Netflix Conductor expert. Generate a complete "inputParameters" JSON object for the following task.
33
46
 
34
47
  Task Type: ${e}
35
- Task Reference Name: ${r}
48
+ Task Reference Name: ${t}
36
49
  Current inputParameters (may be incomplete): ${JSON.stringify(s,null,2)}
37
50
 
38
51
  Available workflow input parameters (accessible via \${workflow.input.XXX}):
39
- ${t.length>0?t.map(a=>` - ${a}`).join(`
52
+ ${r.length>0?r.map(a=>` - ${a}`).join(`
40
53
  `):" (none defined)"}
41
54
 
42
55
  Upstream tasks (accessible via \${taskRef.output.XXX}):
@@ -52,7 +65,7 @@ Rules:
52
65
  6. Return ONLY the JSON object (no explanation, no markdown code block).
53
66
 
54
67
  Return format: { "paramKey": "paramValue", ... }
55
- `,rb=async(e,r,t,n,s,a={})=>{const o=eb(e,r,t,n,s),d=(await Kh([{role:"system",content:"You are a Conductor expert. Return only valid JSON objects, no markdown."},{role:"user",content:o}],a)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();return JSON.parse(d)},tb=`
68
+ `,e1=async(e,t,r,n,s,a={})=>{const i=Zb(e,t,r,n,s),c=(await xl([{role:"system",content:"You are a Conductor expert. Return only valid JSON objects, no markdown."},{role:"user",content:i}],a)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();return JSON.parse(c)},t1=`
56
69
  You are an expert in Netflix Conductor Workflow modeling.
57
70
  Your goal is to help users design JSON-based workflows.
58
71
 
@@ -64,11 +77,16 @@ CONSTRANTS:
64
77
  5. For FORK_JOIN, ensure a corresponding JOIN task follows.
65
78
 
66
79
  Provide clear, enterprise-grade logic with proper error handling paths.
67
- `,nb=(e,r)=>{const t=r?`当前工作流(JSON):
68
- ${JSON.stringify({name:r.name,tasks:r.tasks.map(n=>({ref:n.taskReferenceName,type:n.type,name:n.name}))},null,2)}`:"当前工作流:尚未定义。";return`
80
+ `,r1=[{label:"➕ 在下方插入 HTTP 请求",type:"HTTP",name:"http_call_task"},{label:"⚖️ 在下方插入条件分支 (SWITCH)",type:"SWITCH",name:"switch_router"},{label:"🔍 在下方插入 JQ 转换节点",type:"JSON_JQ_TRANSFORM",name:"jq_transform_task"},{label:"🛡️ 为当前节点开启自动重试与容错",action:"retry_hardening"}],n1=({aiConfig:e})=>{const{inlineCopilotTaskRef:t,setInlineCopilotTaskRef:r,selectedTask:n,workflowDef:s,taskMap:a,addNode:i,updateTask:l,selectTaskAction:c}=oe(),u=(Cm()?.aiStore??jm)(T=>T.setProposal),[f,h]=I.useState(""),[p,m]=I.useState(!1),[g,x]=I.useState(null),v=I.useRef(null),y=t||n?.taskReferenceName||null,b=y?a[y]:null;if(I.useEffect(()=>{const T=O=>{if((O.metaKey||O.ctrlKey)&&O.key.toLowerCase()==="k"){O.preventDefault();const D=oe.getState();if(D.inlineCopilotTaskRef)D.setInlineCopilotTaskRef(null);else{const N=D.selectedTask?.taskReferenceName||D.workflowDef?.tasks?.[D.workflowDef.tasks.length-1]?.taskReferenceName||"__canvas_root__";D.setInlineCopilotTaskRef(N)}}else O.key==="Escape"&&t&&r(null)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,r]),I.useEffect(()=>{t&&(x(null),setTimeout(()=>v.current?.focus(),40))},[t]),!t)return null;const k=s&&y&&y!=="__canvas_root__"?cl(s,y):[],_=T=>{if(!(!y||y==="__canvas_root__")){if(T.action==="retry_hardening"&&b){l(y,{retryCount:3,retryLogic:"EXPONENTIAL_BACKOFF",retryDelaySeconds:2,timeoutSeconds:60}),x("✅ 已为当前节点开启指数退避重试 (3次) 与 60s 超时保护"),setTimeout(()=>r(null),900);return}if(T.type){const O=Ue.find(N=>N.type===T.type),D=`${T.name}_${Date.now().toString(36).slice(-4)}`;i({data:{label:O?.label||T.name,taskName:T.name,taskReferenceName:D,taskType:T.type}},y,"",`inline-cmdk-${D}`,{}),x(`✅ 已在 ${y} 后插入 ${T.type} 节点`),setTimeout(()=>r(null),700)}}},w=async T=>{T.preventDefault();const O=f.trim();if(!O||!s)return;const D=e?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!D){const N=O.toLowerCase(),S=y&&y!=="__canvas_root__"?y:s.tasks[s.tasks.length-1]?.taskReferenceName;if(S){let R="SIMPLE";N.includes("http")||N.includes("接口")||N.includes("请求")?R="HTTP":N.includes("switch")||N.includes("分支")||N.includes("判断")?R="SWITCH":N.includes("loop")||N.includes("循环")?R="DO_WHILE":N.includes("jq")||N.includes("转换")?R="JSON_JQ_TRANSFORM":(N.includes("wait")||N.includes("等待"))&&(R="WAIT");const j=Ue.find(q=>q.type===R),E=`${R.toLowerCase()}_${Date.now().toString(36).slice(-4)}`;i({data:{label:O.slice(0,24)||j?.label||R,taskName:E,taskReferenceName:E,taskType:R}},S,"",`inline-cmdk-${E}`,{}),h(""),r(null);return}}m(!0),x("🤖 正在基于当前节点拓扑上下文生成 Shadow Graph 变更提案...");try{const N=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",S=e?.model||localStorage.getItem("AI_MODEL")||"",R={apiKey:D};N&&(R.baseUrl=N),S&&(R.model=S);const j=`You are a Conductor Workflow Architect. The user is invoking inline Cmd+K on task "${y}" (type: ${b?.type||"ROOT"}).
81
+ Upstream tasks in scope: ${k.map($=>$.taskReferenceName).join(", ")||"none"}.
82
+ Current workflow JSON:
83
+ ${JSON.stringify(s,null,2)}
84
+
85
+ Return ONLY the updated full WorkflowDef JSON object (wrapped in \`\`\`json ... \`\`\`) that fulfills the user's instruction.`,E=await xl([{role:"system",content:j},{role:"user",content:O}],R),q=E.match(/```(?:json)?\s*([\s\S]*?)```/)||E.match(/(\{[\s\S]*\})/);if(q){const $=JSON.parse(q[1]);if($&&Array.isArray($.tasks)){const J=Xb(s,$);u({proposedDef:$,diff:J,messageId:`inline-cmdk-${Date.now()}`}),h(""),r(null);return}}x("⚠️ 未能解析 AI 返回的工作流 JSON,请重试")}catch(N){x(`❌ 调用失败: ${N?.message||"未知错误"}`)}finally{m(!1)}};return o.jsxs("div",{style:{position:"absolute",top:68,left:"50%",transform:"translateX(-50%)",width:540,maxWidth:"calc(100vw - 40px)",zIndex:2200,background:"rgba(15, 23, 42, 0.96)",backdropFilter:"blur(20px)",border:"1px solid rgba(99, 102, 241, 0.45)",borderRadius:14,boxShadow:"0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.15)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(56, 189, 248, 0.1))",borderBottom:"1px solid rgba(148, 163, 184, 0.15)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:5,background:"#6366f1",color:"#fff"},children:"⌘K 画布内联指令"}),o.jsxs("span",{style:{fontSize:11,color:"#cbd5e1",fontFamily:"monospace"},children:["锚点:"," ",o.jsx("strong",{style:{color:"#38bdf8"},children:b?`${b.name} (${b.taskReferenceName})`:"画布全局"})]}),k.length>0&&o.jsxs("span",{style:{fontSize:10,color:"#94a3b8"},children:["· 可见上游 ",k.length," 个节点"]})]}),o.jsx("button",{type:"button",onClick:()=>r(null),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:13},children:"ESC ✕"})]}),o.jsxs("form",{onSubmit:w,style:{display:"flex",padding:"10px 14px",gap:8},children:[o.jsx("input",{ref:v,type:"text",value:f,onChange:T=>h(T.target.value),disabled:p,placeholder:"输入自然语言指令,如:在此节点后加一个风控 HTTP 校验并判断状态码...",style:{flex:1,padding:"9px 12px",borderRadius:8,border:"1px solid rgba(148, 163, 184, 0.25)",background:"rgba(2, 6, 23, 0.65)",color:"#f8fafc",fontSize:13,outline:"none"}}),o.jsx("button",{type:"submit",disabled:p||!f.trim(),style:{padding:"0 16px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:12,fontWeight:700,cursor:p||!f.trim()?"not-allowed":"pointer",opacity:p||!f.trim()?.6:1},children:p?"生成中...":"执行 ↵"})]}),b&&o.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexWrap:"wrap",gap:6},children:[r1.map(T=>o.jsx("button",{type:"button",onClick:()=>_(T),style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(30, 41, 59, 0.65)",color:"#cbd5e1",cursor:"pointer"},children:T.label},T.label)),o.jsx("button",{type:"button",onClick:()=>{c(b,!0),r(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.3)",background:"rgba(56, 189, 248, 0.1)",color:"#38bdf8",cursor:"pointer"},children:"⚙️ 打开属性抽屉"})]}),g&&o.jsx("div",{style:{padding:"6px 14px 10px",fontSize:11,color:"#38bdf8",borderTop:"1px solid rgba(148, 163, 184, 0.1)"},children:g})]})},s1={taskNode:tb,decisionNode:nb,forkNode:ym.ForkNode,joinNode:ym.JoinNode,loopNode:ab,subWorkflowNode:lb,plusNode:db,dynamicPlaceholderNode:fb},a1={addableEdge:gb},o1=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:s})=>{const{nodes:a,edges:i,onNodesChange:l,onEdgesChange:c,onConnect:d,mode:u,viewMode:f,selectedTask:h,setSelectedTask:p,selectTaskAction:m,theme:g,edgeType:x,addNode:v,nodesLocked:y,executionData:b,validationResults:k,isDetailPanelOpen:_,setIsDetailPanelOpen:w,workflowDef:T,setWorkflow:O,dynamicRuntimeTasksByFork:D,layoutDirection:N,simState:S,isSimRunning:R,workflowLoadKey:j,showDataLineage:E}=oe(),q=I.useMemo(()=>{if(f==="developer")return new Set(a.map(te=>te.id));const Q=Vv[f],X=new Set;return a.forEach(te=>{if(te.type==="dynamicPlaceholderNode"){X.add(te.id);return}if(te.type==="plusNode"){u==="edit"&&(!te.data?.parentRef||X.has(te.data.parentRef))&&X.add(te.id);return}if(u==="run"&&b){const le=b[te.id]?.status;if(le==="FAILED"||le==="FAILED_WITH_TERMINAL_ERROR"||le==="TIMED_OUT"||le==="IN_PROGRESS"){X.add(te.id);return}}if(te.parentId)return;const G=Ue.find(le=>le.type===te.data.taskType)?.viewCategory??"business";Q.includes(G)&&X.add(te.id)}),a.forEach(te=>{if(te.parentId&&X.has(te.parentId)){if(te.type==="plusNode"){u==="edit"&&X.add(te.id);return}const G=Ue.find(le=>le.type===te.data.taskType)?.viewCategory??"business";Q.includes(G)&&X.add(te.id)}}),X},[a,f,u,b]),$=I.useCallback(Q=>{if(q.size===a.length)return Q;const X={};Q.forEach(G=>{X[G.source]||(X[G.source]=[]),X[G.source].push(G)});const te=[],de=new Set;return Q.forEach(G=>{if(!q.has(G.source))return;if(q.has(G.target)){const K=`${G.source}->${G.target}`;de.has(K)||(de.add(K),te.push(G));return}const le=[{to:G.target,label:G.label}],C=new Set;for(;le.length;){const K=le.shift();if(!C.has(K.to)){if(C.add(K.to),q.has(K.to)){const ae=`${G.source}->${K.to}`;de.has(ae)||(de.add(ae),te.push({...G,id:ae,target:K.to,label:K.label??G.label}));continue}(X[K.to]??[]).forEach(ae=>le.push({to:ae.target,label:K.label??ae.label}))}}}),te},[q,a.length]),V=Cm()?.aiStore??jm,A=V(Q=>Q.pendingProposal),B=V(Q=>Q.clearProposal),P=V(Q=>Q.recordAccept),U=V(Q=>Q.recordReject),se=V(Q=>Q.pushUndo),L=I.useMemo(()=>{if(!A)return null;try{const{nodes:Q,edges:X}=Ae(A.proposedDef,N,{hideEmptyBranches:!1}),{nodes:te,edges:de}=je(Q,X,{direction:N,mode:"edit"}),G=new Set(A.diff.added),le=new Set(A.diff.modified),C=new Set(A.diff.removed),K=new Map(a.map(Z=>[Z.data?.taskReferenceName,Z])),ae=te.filter(Z=>Z.type!=="plusNode").map(Z=>{const ye=Z.data?.taskReferenceName,xe=G.has(ye)?"added":le.has(ye)?"modified":void 0;return{...Z,draggable:!1,selectable:!1,data:{...Z.data,proposalStatus:xe,layoutDirection:N}}}),re=[...C].map(Z=>K.get(Z)).filter(Z=>Z!=null).map(Z=>({...Z,draggable:!1,selectable:!1,data:{...Z.data,proposalStatus:"removed"}}));return{nodes:[...ae,...re],edges:de}}catch{return null}},[A,a,N]),{fitView:F}=M.useReactFlow(),[z,H]=I.useState(!1),[Y,ie]=I.useState(null),[fe,ve]=I.useState(!1),[be,W]=I.useState(!1),{confirm:ke,confirmState:ee,handleConfirm:me,handleCancel:ne}=Hb(),{toasts:_e,showToast:ce,dismissToast:he}=Jb();zb({confirm:ke,showToast:ce,onSave:r}),I.useEffect(()=>{if(h){const Q=a.find(X=>X.data.taskReferenceName===h.taskReferenceName);Q&&F({nodes:[Q],duration:800,padding:.5})}},[h?.taskReferenceName,F]),I.useEffect(()=>{const Q=()=>{F({duration:800})};return window.addEventListener("workflow-zoom-to-fit",Q),()=>window.removeEventListener("workflow-zoom-to-fit",Q)},[F]),I.useEffect(()=>{if(j===0)return;const Q=setTimeout(()=>{F({duration:600,padding:.12})},50);return()=>clearTimeout(Q)},[j,F]),I.useEffect(()=>{const Q=de=>{e&&de.detail&&de.detail.task&&e(de.detail.task)},X=de=>{if(u==="edit"){const{loopId:G,afterRef:le}=de.detail;ie(le?{sourceId:le,edgeData:{}}:{sourceId:G,edgeData:{isLoopAdd:!0}}),H(!0)}},te=de=>{u==="edit"&&(ie({sourceId:de.detail.source,targetId:de.detail.target,edgeId:de.detail.id,edgeData:de.detail.edgeData}),H(!0))};return document.addEventListener("miniTaskClick",Q),document.addEventListener("loopAddNodeRequested",X),window.addEventListener("edgeAddNode",te),()=>{document.removeEventListener("miniTaskClick",Q),document.removeEventListener("loopAddNodeRequested",X),window.removeEventListener("edgeAddNode",te)}},[u,e]);const Fe=I.useCallback(Q=>{if(Y){const{sourceId:X,targetId:te,edgeId:de,edgeData:G}=Y;v({data:{label:`New ${Q}`,taskReferenceName:`${Q.toLowerCase()}_${Date.now()}`,taskType:Q}},X,te,de,G)}H(!1),ie(null)},[Y,v]),Se=I.useMemo(()=>{const Q={layoutedNodes:null,extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(u!=="run")return Q;const X=a.filter(K=>K.type==="forkNode"&&K.data.taskType==="FORK_JOIN_DYNAMIC");if(!X.length)return Q;const te=[],de=[],G=new Set,le=new Set;for(const K of X){const ae=D[K.id]||[],re=`${K.id}_dynamic_placeholder`,Z=i.find(ue=>ue.target===re),ye=i.find(ue=>ue.source===re);let xe,pe;if(ye)xe=ye.target,pe=a.find(ue=>ue.id===xe);else{const ue=a.indexOf(K);if(pe=a.slice(ue).find(Te=>Te.type==="joinNode"),!pe)continue;xe=pe.id}pe&&(ye&&G.add(ye.id),Z&&G.add(Z.id),le.add(re),ae.length&&ae.forEach(ue=>{const Te=`dynamic_rt_${ue.referenceTaskName}`;te.push({id:Te,type:"taskNode",data:{label:ue.taskDefName||ue.referenceTaskName,task:{name:ue.taskDefName||ue.referenceTaskName,taskReferenceName:ue.referenceTaskName,type:ue.taskType||"SIMPLE"},taskReferenceName:ue.referenceTaskName,taskType:ue.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:0,y:0}}),de.push({id:`e-${K.id}-${Te}`,source:K.id,target:Te,style:{strokeDasharray:"4,4"}}),de.push({id:`e-${Te}-${xe}`,source:Te,target:xe,style:{strokeDasharray:"4,4"}})}))}let C=null;if(te.length>0){const K=[...a.filter(Z=>!le.has(Z.id)),...te],ae=[...i.filter(Z=>!G.has(Z.id)),...de];C=je(K,ae,{direction:N,mode:"run"}).nodes}return{layoutedNodes:C,extraNodes:te,extraEdges:de,removedEdgeIds:G,removedNodeIds:le}},[u,D,a,i,N]),ge=I.useMemo(()=>{const X=[...$(i.filter(G=>!Se.removedEdgeIds.has(G.id))),...Se.extraEdges],te=R||Object.keys(S).length>0,de=G=>G.startsWith("dynamic_rt_")?G.slice(11):G;return X.map(G=>{const le=G.id.includes("loop-back"),C=G.source.startsWith("dynamic_rt_")||G.target.startsWith("dynamic_rt_"),K=g==="light"?"#64748b":"#94a3b8";let re={...{...G.style,stroke:K,strokeWidth:2.2,strokeDasharray:le?"5,5":C?"4,4":void 0}},Z=!1;if(u==="run"&&b){const ue=de(G.source),Te=de(G.target),Pe=b[ue]?.status,Re=b[Te]?.status,Be=Pe==="COMPLETED"||Pe==="COMPLETED_WITH_ERRORS";Be&&(Re==="COMPLETED"||Re==="COMPLETED_WITH_ERRORS")?(re={...re,stroke:"var(--status-completed)",strokeWidth:3.2,opacity:1},Z=!1):Be&&(Re==="IN_PROGRESS"||Re==="SCHEDULED")?(re={...re,stroke:"var(--status-in-progress)",strokeWidth:3.5,opacity:1},Z=!0):Be&&(Re==="FAILED"||Re==="FAILED_WITH_TERMINAL_ERROR")?(re={...re,stroke:"var(--status-failed)",strokeWidth:3.5,opacity:1},Z=!1):Be&&Re==="TIMED_OUT"?(re={...re,stroke:"var(--status-timed-out)",strokeWidth:3.5,opacity:1},Z=!1):(re={...re,stroke:K,strokeWidth:1.8,opacity:.28},Z=!1)}else if(te){const ue=S[G.source],Te=S[G.target];ue==="done"&&Te==="done"?(re={...re,stroke:"var(--status-completed)",strokeWidth:3.2},Z=!1):ue==="done"&&Te==="running"&&(re={...re,stroke:"var(--status-in-progress)",strokeWidth:3.5},Z=!0)}const ye=G.source.endsWith("_dynamic_placeholder")||G.target.endsWith("_dynamic_placeholder"),xe=G.source==="__workflow_start__"||G.source.startsWith("__loop_start__")||G.target.startsWith("__loop_end__")||G.target.includes("_empty_"),pe=u==="edit"&&!le&&!ye&&!xe;return{...G,type:"addableEdge",data:{...G.data,mode:u,isAddable:pe,edgeType:x,label:G.label},markerEnd:{type:M.MarkerType.ArrowClosed,width:18,height:18,color:String(re.stroke||K)},style:re,animated:Z}})},[i,x,g,u,b,Se,$,R,S]),Qe=I.useMemo(()=>{if(!E||!T)return[];const Q=nm(T),X=h?.taskReferenceName,te=[],de=new Set;return Q.edges.forEach((G,le)=>{if(!q.has(G.sourceRef)||!q.has(G.targetRef)||X&&G.sourceRef!==X&&G.targetRef!==X)return;const C=`${G.sourceRef}->${G.targetRef}:${G.fieldPath}`;de.has(C)||(de.add(C),te.push({id:`wlsp-dfg-${le}-${C}`,source:G.sourceRef,target:G.targetRef,type:"addableEdge",animated:!0,label:`🔗 ${G.fieldPath}`,data:{mode:"view",isAddable:!1,edgeType:"default",label:`🔗 ${G.fieldPath}`},markerEnd:{type:M.MarkerType.ArrowClosed,width:16,height:16,color:"#38bdf8"},style:{stroke:"#38bdf8",strokeWidth:2.4,strokeDasharray:"6,4",opacity:.95}}))}),te},[E,T,q,h?.taskReferenceName]),Ee="var(--bg-secondary)",rt=I.useMemo(()=>a.filter(Q=>Q.type!=="plusNode").length,[a]);return o.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:Ee},children:[o.jsxs(M,{nodes:I.useMemo(()=>{if(L)return L.nodes;const Q=new Set(k.errors.filter(G=>G.type==="TASK").map(G=>G.ref)),X=new Set(k.warnings.filter(G=>G.type==="TASK").map(G=>G.ref)),te=t.toLowerCase();return(Se.layoutedNodes?Se.layoutedNodes.filter(G=>G.id.startsWith("dynamic_rt_")||q.has(G.id)):a.filter(G=>!Se.removedNodeIds.has(G.id)&&q.has(G.id)).concat(Se.extraNodes)).map(G=>{const le=G.data.taskReferenceName,C=S[le];return{...G,selected:h?.taskReferenceName===le,data:{...G.data,isError:u==="edit"&&Q.has(le),hasWarning:u==="edit"&&X.has(le),isHighlighted:t?(G.data.label||"").toLowerCase().includes(te)||(G.data.taskReferenceName||"").toLowerCase().includes(te):!1,simRunning:C==="running",simDone:C==="done"}}})},[a,k,t,h,Se,q,S,u,L]),edges:L?.edges??[...ge,...Qe],onNodesChange:l,onEdgesChange:c,onConnect:d,nodeTypes:s1,edgeTypes:a1,onNodeClick:(Q,X)=>{if(X.type==="plusNode"){ie({sourceId:X.data.parentRef,edgeData:X.data.edgeData||{}}),H(!0);return}if(X.type==="loopNode"){const de=X.data.task||null;p(de),e&&e(de);return}const te=X.data.task||null;p(te),e&&e(te)},onPaneClick:()=>{p(null),u!=="run"&&w(!1)},fitView:!0,nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[o.jsx(M.Background,{color:"var(--border-primary)",gap:20}),o.jsx(M.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:o.jsx(yb,{})}),rt>=5&&!_&&!fe&&o.jsx(M.MiniMap,{position:"bottom-right",pannable:!0,zoomable:!0,style:{marginBottom:20,marginRight:20,width:160,height:110,backgroundColor:"var(--glass-surface)"},maskColor:g==="light"?"rgba(241, 245, 249, 0.7)":"rgba(15, 23, 42, 0.7)",nodeColor:Q=>{if(Q.type==="plusNode")return"transparent";if(u==="run"&&b){const X=Q.data?.taskReferenceName,te=b[X]?.status;return te==="COMPLETED"?"#10b981":te==="FAILED"||te==="FAILED_WITH_TERMINAL_ERROR"?"#ef4444":te==="IN_PROGRESS"||te==="SCHEDULED"?"#3b82f6":te==="TIMED_OUT"||te==="COMPLETED_WITH_ERRORS"?"#f59e0b":"#64748b"}return Q.type==="decisionNode"?"#f59e0b":Q.type==="forkNode"||Q.type==="joinNode"?"#10b981":Q.type==="loopNode"?"#8b5cf6":"#3b82f6"}}),u==="run"&&o.jsx(M.Panel,{position:"bottom-center",children:o.jsx(hb,{})}),o.jsx(mb,{isOpen:fe,onClose:()=>ve(!1),theme:g,onTaskSelect:Q=>{m(Q,!0)}}),A&&o.jsx(M.Panel,{position:"top-left",style:{marginTop:"14px",marginLeft:"16px",zIndex:1500},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",borderRadius:"999px",background:"rgba(15, 23, 42, 0.94)",backdropFilter:"blur(16px)",border:"1px solid rgba(99, 102, 241, 0.45)",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.4)",color:"#f8fafc",fontSize:"12px"},children:[o.jsx("span",{style:{fontWeight:700,color:"#a5b4fc"},children:"👻 Shadow Graph 架构变更预览"}),o.jsxs("div",{style:{display:"flex",gap:"8px",fontFamily:"monospace",fontSize:"11px"},children:[A.diff.added.length>0&&o.jsxs("span",{style:{color:"#34d399",fontWeight:700},children:["+",A.diff.added.length," 新增"]}),A.diff.modified.length>0&&o.jsxs("span",{style:{color:"#fbbf24",fontWeight:700},children:["~",A.diff.modified.length," 修改"]}),A.diff.removed.length>0&&o.jsxs("span",{style:{color:"#f87171",fontWeight:700},children:["-",A.diff.removed.length," 移除"]})]}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{type:"button",onClick:()=>{T&&se(T),O(A.proposedDef),P(),B()},style:{padding:"4px 12px",borderRadius:"999px",border:"none",background:"#10b981",color:"#fff",fontSize:"11px",fontWeight:700,cursor:"pointer"},children:"✓ 采纳上屏"}),o.jsx("button",{type:"button",onClick:()=>{U(),B()},style:{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(248, 113, 113, 0.4)",background:"rgba(239, 68, 68, 0.14)",color:"#f87171",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"✕ 拒绝"})]})]})}),o.jsx("div",{style:{position:"absolute",top:14,right:16,zIndex:1e3},children:o.jsx(bb,{onShowHealthCheck:()=>ve(!fe),showHealthCheck:fe,onShowSettings:()=>W(!0),executionActions:s})})]}),o.jsx(Vb,{}),o.jsx(n1,{}),!T&&!A&&o.jsx(wb,{onRequestImport:n}),T&&a.length===0&&u==="edit"&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:o.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{ie({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),H(!0)},children:[o.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),z&&o.jsx(pb,{theme:g,onSelect:Fe,onCancel:()=>H(!1)}),o.jsx(Sb,{isOpen:be,onClose:()=>W(!1)}),ee&&o.jsx(mr,{message:ee.message,onConfirm:me,onCancel:ne}),o.jsx(Eb,{messages:_e,onDismiss:he})]})},i1=(e,t)=>{const r=t?`当前工作流(JSON):
86
+ ${JSON.stringify({name:t.name,tasks:t.tasks.map(n=>({ref:n.taskReferenceName,type:n.type,name:n.name}))},null,2)}`:"当前工作流:尚未定义。";return`
69
87
  用户请求:${e}
70
88
 
71
- ${t}
89
+ ${r}
72
90
 
73
91
  请用中文回答,简明说明你将做什么修改,并在回答末尾(如果有工作流变更)输出一个结构化 diff 块,格式如下:
74
92
 
@@ -95,17 +113,17 @@ ${t}
95
113
 
96
114
  如果是全量生成新工作流,使用 kind="replace" 并在 diff-json 中加入 "payload": {...完整工作流JSON...}。
97
115
  如果不涉及工作流变更(仅解释/回答),则不需要输出 diff-json 块。
98
- `},ab=(e,r)=>`
116
+ `},l1=(e,t)=>`
99
117
  Context: I am configuring a Conductor task in a workflow.
100
118
  Task Reference Name: ${e.taskReferenceName}
101
119
  Task Type: ${e.type}
102
120
 
103
121
  Full Workflow Structure for reference:
104
- ${JSON.stringify(r,null,2)}
122
+ ${JSON.stringify(t,null,2)}
105
123
 
106
124
  Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
107
125
  Return the suggestions as a JSON array of objects with { label, value, description }.
108
- `,sb=({isOpen:e,onClose:r,onSelect:t,suggestions:n,anchorRect:s})=>{if(!e||!s)return null;const a={position:"fixed",top:s.bottom+8,left:Math.max(s.left-200,20),width:"280px",zIndex:3e3};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"suggester-overlay",onClick:r}),l.jsxs("div",{className:"parameter-suggester-popover glass-panel",style:a,children:[l.jsxs("div",{className:"suggester-header",children:[l.jsx("span",{className:"sparkle-icon",children:"✨"}),"AI Suggestions"]}),l.jsx("div",{className:"suggester-list",children:n.length===0?l.jsxs("div",{className:"suggester-loading",children:[l.jsx("div",{className:"suggester-skeleton-line",style:{width:"85%"}}),l.jsx("div",{className:"suggester-skeleton-line",style:{width:"65%"}}),l.jsx("div",{className:"suggester-skeleton-line",style:{width:"75%"}})]}):n.map((o,i)=>l.jsxs("div",{className:"suggestion-item",onClick:()=>{t(o.value),r()},children:[l.jsx("div",{className:"suggestion-label",children:o.label}),l.jsx("div",{className:"suggestion-value",children:o.value}),l.jsx("div",{className:"suggestion-desc",children:o.description})]},i))})]})]})},ob=({title:e,value:r,language:t="text",placeholder:n="",onSave:s,onClose:a})=>{const{theme:o,themeColor:i}=ie(),[d,c]=P.useState(r),u=P.useRef(null);P.useEffect(()=>{u.current?.focus();const h=g=>{g.key==="Escape"&&(g.stopPropagation(),a()),(g.ctrlKey||g.metaKey)&&g.key==="s"&&(g.preventDefault(),g.stopPropagation(),s(d))};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[d,s,a]);const p={javascript:"#f7df1e",js:"#f7df1e",json:"#89b4fa",jq:"#a6e3a1",groovy:"#4ec994",python:"#3572A5",text:"var(--text-secondary)"}[t.toLowerCase()]??"var(--text-secondary)";return Yr.createPortal(l.jsxs("div",{"data-mode":o,"data-brand":i,style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 20px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--glass-border)",flexShrink:0},children:[l.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:p,background:`${p}18`,border:`1px solid ${p}44`,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",letterSpacing:"0.5px",textTransform:"uppercase",flexShrink:0},children:t}),l.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),l.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",flexShrink:0},children:"Ctrl+S 保存 · Esc 取消"}),l.jsx("button",{onClick:a,style:{padding:"6px 14px",background:"var(--bg-tertiary)",border:"1px solid var(--glass-border)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"12px",fontWeight:500,flexShrink:0},children:"取消"}),l.jsx("button",{onClick:()=>s(d),style:{padding:"6px 16px",background:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,flexShrink:0},children:"应用"})]}),l.jsx("textarea",{ref:u,value:d,placeholder:n,onChange:h=>c(h.target.value),onKeyDown:h=>h.stopPropagation(),spellCheck:!1,style:{flex:1,width:"100%",padding:"20px 24px",background:"var(--bg-primary)",color:t==="javascript"||t==="js"||t==="groovy"?"var(--color-accent)":"var(--text-primary)",border:"none",outline:"none",resize:"none",fontFamily:'var(--font-mono, "Fira Code", "Cascadia Code", Consolas, monospace)',fontSize:"14px",lineHeight:"1.7",boxSizing:"border-box",caretColor:"var(--color-accent)"}}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"5px 20px",background:"var(--bg-secondary)",borderTop:"1px solid var(--glass-border)",flexShrink:0,fontSize:"11px",color:"var(--text-secondary)"},children:[l.jsxs("span",{children:[d.split(`
109
- `).length," 行"]}),l.jsxs("span",{children:[d.length," 字符"]}),d!==r&&l.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},ib=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],lb=({task:e,isOpen:r=!0,onClose:t,aiConfig:n})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:o}=ie(),[i,d]=P.useState(e),[c,u]=P.useState(e?.taskReferenceName??null),[f,p]=P.useState(null),[h,g]=P.useState(!1),[m,v]=P.useState(null),[y,x]=P.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[b,k]=P.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[w,j]=P.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[N,L]=P.useState(!1),[T,C]=P.useState(),[S,q]=P.useState([]),[I,O]=P.useState(()=>()=>{}),[F,W]=P.useState(null),[V,Z]=P.useState(!1),[ne,ee]=P.useState(null),D=(E,X,ae,le)=>{W({title:E,value:X,language:ae,onSave:le})},Y=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],se=async()=>{const E=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!E){alert("请先在设置中配置 AI API Key");return}if(M){Z(!0);try{const{workflowDef:X,taskMap:ae}=ie.getState(),le=Vr(X?.inputParameters).map(re=>re.name),ce=Object.values(ae).filter(re=>re.taskReferenceName!==M.taskReferenceName).map(re=>({ref:re.taskReferenceName,type:re.type,name:re.name})).slice(0,10),he={apiKey:E};n?.baseUrl&&(he.baseUrl=n.baseUrl),n?.model&&(he.model=n.model);const ke=await rb(M.type,M.taskReferenceName,le,ce,M.inputParameters??{},he);ee({generated:ke,original:M.inputParameters??{}})}catch(X){alert(`AI 生成失败:${X?.message||"未知错误"}`)}finally{Z(!1)}}},R=async(E,X)=>{const ae=E.currentTarget.getBoundingClientRect();C(ae),O(()=>X),q([]),L(!0);const le=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!le){q(Y);return}try{const ce=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",he=n?.model||localStorage.getItem("AI_MODEL")||"",ke={apiKey:le};ce&&(ke.baseUrl=ce),he&&(ke.model=he);const{workflowDef:re}=ie.getState(),xe=ab(M,re),We=(await Kh([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:xe}],ke)).match(/\[[\s\S]*\]/);if(We){const Hi=JSON.parse(We[0]);q(Hi)}else q(Y)}catch{q(Y)}};if(P.useEffect(()=>{e&&(d(e),u(e.taskReferenceName),p(null),e.type==="WAIT"&&x(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&k(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?j("workflow"):e.forkTaskType?j("task"):j("classic")))},[e]),!e&&!i)return null;const M=e||i,_=i&&e&&c===e.taskReferenceName?i:M,B=r&&e?"panel-enter-active":"panel-exit",z=s==="edit",Q="var(--text-primary)",G="var(--glass-border)",oe="var(--bg-tertiary)",H="var(--text-secondary)",$=(E,X)=>{const ae={..._,[E]:X};d(ae),a(_.taskReferenceName,{[E]:X})},K=(E,X,ae)=>{const ce={..._[E]||{},[X]:ae},he={..._,[E]:ce};d(he),a(_.taskReferenceName,{[E]:ce})},U=(E,X)=>{const ae=_.inputParameters||{},ce={...ae.http_request||_.httpRequest||{},[E]:X},ke={inputParameters:{...ae,http_request:ce}};_.httpRequest&&(ke.httpRequest=ce);const re={..._,...ke};d(re),a(_.taskReferenceName,ke)},J=(E,X)=>{const le={inputParameters:{..._.inputParameters,[E]:X}},ce={..._,...le};d(ce),a(_.taskReferenceName,le)},te=E=>{if(!m)return;const X=m.selectionStart??0,ae=m.selectionEnd??0,le=m.value,ce=le.substring(0,X)+E+le.substring(ae),he=m.getAttribute("data-field");he&&$(he,ce),g(!1)},ue=(E,X,ae,le)=>l.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${ae}10`,border:`1px solid ${ae}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[l.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:ae,display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:X})," ",E]}),le]}),fe=(E,X,ae="text",le)=>{const ce=X==="taskReferenceName",he=ce&&f!==null?f:_[X]??"",ke=ce&&!o(he,_.taskReferenceName);return l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("label",{style:{display:"block",fontSize:"11px",color:H,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[E,ce&&ke&&l.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),l.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[l.jsx("input",{type:ae,value:he,placeholder:le,onChange:re=>{ce?p(re.target.value):$(X,ae==="number"?re.target.value===""?void 0:Number(re.target.value):re.target.value)},onFocus:ce?()=>{f===null&&p(_.taskReferenceName??"")}:void 0,onBlur:ce?re=>{const xe=re.target.value.trim();p(null),xe&&xe!==_.taskReferenceName&&$("taskReferenceName",xe)}:void 0,onKeyDown:ce?re=>{re.key==="Enter"&&re.currentTarget.blur(),re.stopPropagation()}:void 0,disabled:!z,style:{width:"100%",padding:`8px ${z&&!ce?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${ke?"#ef4444":G}`,background:oe,color:Q,fontSize:"13px",outline:"none",opacity:z?1:.8,fontFamily:ce?"monospace":"inherit"}}),z&&!ce&&l.jsx("button",{className:"ai-hint-trigger",onClick:re=>R(re,xe=>$(X,xe)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},me=(E,X,ae,le={})=>{const{rows:ce=5,language:he="text",style:ke,placeholder:re,"data-field":xe}=le,Ue={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...ke};return l.jsxs("div",{style:{marginBottom:"8px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[l.jsx("label",{style:{fontSize:"10px",color:H},children:E}),z&&l.jsx("button",{onClick:()=>D(E,X,he,We=>{ae(We),W(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),l.jsx("textarea",{value:X,placeholder:re,onChange:We=>ae(We.target.value),disabled:!z,rows:ce,"data-field":xe,onFocus:We=>v(We.currentTarget),style:Ue})]})},de=(E,X,ae,le="text",ce)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:E}),l.jsx("input",{type:le,value:X??"",placeholder:ce,onChange:he=>ae(le==="number"?he.target.value===""?void 0:Number(he.target.value):he.target.value),disabled:!z,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",outline:"none"}})]}),pe=(E,X,ae,le)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:E}),l.jsx("select",{value:ae,onChange:ce=>le(ce.target.value),disabled:!z,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",outline:"none",cursor:"pointer"},children:X.map(ce=>l.jsx("option",{value:ce,children:ce},ce))})]}),ve=(E,X,ae)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("span",{style:{fontSize:"11px",color:H},children:E}),l.jsx("button",{onClick:()=>ae(!X),disabled:!z,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:X?"var(--color-accent)":G,position:"relative",transition:"background 0.2s"},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:X?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),Te=(E,X,ae)=>l.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:E.map(le=>l.jsx("button",{onClick:()=>ae(le.key),disabled:!z,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${G}`,cursor:"pointer",fontSize:"11px",fontWeight:X===le.key?"bold":"normal",background:X===le.key?"var(--color-accent)":oe,color:X===le.key?"#fff":Q},children:le.label},le.key))}),ye=_.inputParameters?.http_request||_.httpRequest||{};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`detail-panel-container ${B}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${G}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[l.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${G}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[l.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:_.type||"TASK"}),l.jsx("button",{onClick:t,style:{background:"none",border:"none",color:Q,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),z?l.jsx("input",{value:_.name||"",onChange:E=>$("name",E.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:Q,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):l.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:_.name}),l.jsxs("div",{style:{fontSize:"12px",color:H,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",_.taskReferenceName]})]}),l.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[_.type==="HTTP"&&ue("HTTP 请求配置","🌐","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[l.jsx("select",{value:ye.method||"GET",onChange:E=>U("method",E.target.value),disabled:!z,style:{width:"90px",padding:"10px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(E=>l.jsx("option",{value:E,children:E},E))}),l.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:ye.uri||"",onChange:E=>U("uri",E.target.value),disabled:!z,style:{flex:1,padding:"10px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"CONTENT-TYPE"}),l.jsx("input",{placeholder:"application/json",value:ye.contentType||"",onChange:E=>U("contentType",E.target.value),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"ACCEPT"}),l.jsx("input",{placeholder:"application/json",value:ye.accept||"",onChange:E=>U("accept",E.target.value),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"连接超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ye.connectionTimeOut??"",onChange:E=>U("connectionTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"读取超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ye.readTimeOut??"",onChange:E=>U("readTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"HEADERS (JSON)"}),l.jsx("textarea",{value:typeof ye.headers=="object"?JSON.stringify(ye.headers,null,2):"{}",onChange:E=>{try{U("headers",JSON.parse(E.target.value))}catch{}},disabled:!z,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"11px",fontFamily:"monospace"}})]}),l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),l.jsx("textarea",{value:typeof ye.body=="object"?JSON.stringify(ye.body,null,2):ye.body||"",onChange:E=>{let X=E.target.value;try{X=JSON.parse(E.target.value)}catch{}U("body",X)},disabled:!z,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"11px",fontFamily:"monospace"}})]})),(_.type==="INLINE"||_.type==="LAMBDA")&&ue("内联脚本配置 (Inline)","📜","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("脚本引擎",["graaljs","javascript","value-param","python"],_.evaluatorType||"graaljs",E=>$("evaluatorType",E)),me(`EXPRESSION ${_.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,_.inputParameters?.expression||_.inputParameters?.scriptExpression||"",E=>{const X=_.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";J(X,E)},{rows:10,language:_.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:H,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),_.type==="JSON_JQ_TRANSFORM"&&ue("JQ 数据转换","🔍","var(--color-accent)",l.jsxs(l.Fragment,{children:[me("JQ QUERY EXPRESSION",_.inputParameters?.queryExpression||"",E=>J("queryExpression",E),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:H},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),_.type==="SUB_WORKFLOW"&&ue("子工作流配置","🏗️","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("WORKFLOW NAME *",_.subWorkflowParam?.name||"",E=>K("subWorkflowParam","name",E),"text","e.g. my_workflow"),de("VERSION",_.subWorkflowParam?.version??"",E=>K("subWorkflowParam","version",E?parseInt(E):void 0),"number","1"),me("INPUT PARAMETERS MAPPING (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{$("inputParameters",JSON.parse(E))}catch{}},{rows:5,language:"json"}),l.jsxs("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),_.type==="START_WORKFLOW"&&ue("启动工作流配置","▶️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:H,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",l.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),de("WORKFLOW NAME *",_.inputParameters?.startWorkflow?.name||"",E=>{const X={..._.inputParameters?.startWorkflow||{},name:E};J("startWorkflow",X)},"text","e.g. target_workflow"),de("VERSION",_.inputParameters?.startWorkflow?.version??"",E=>{const X={..._.inputParameters?.startWorkflow||{},version:E?parseInt(E):void 0};J("startWorkflow",X)},"number","1"),de("CORRELATION ID",_.inputParameters?.startWorkflow?.correlationId||"",E=>{const X={..._.inputParameters?.startWorkflow||{},correlationId:E};J("startWorkflow",X)},"text","${workflow.correlationId}"),me("WORKFLOW INPUT (JSON)",typeof _.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(_.inputParameters.startWorkflow.input,null,2):"{}",E=>{try{const X={..._.inputParameters?.startWorkflow||{},input:JSON.parse(E)};J("startWorkflow",X)}catch{}},{rows:4,language:"json"})]})),_.type==="TERMINATE"&&ue("终止状态配置","⏹️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"TERMINATION STATUS"}),l.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(E=>l.jsx("button",{onClick:()=>J("terminationStatus",E),disabled:!z,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"var(--color-accent)":oe,color:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"#fff":Q,border:`1px solid ${G}`,fontWeight:"bold",fontSize:"11px"},children:E},E))}),de("TERMINATION REASON",_.inputParameters?.terminationReason||"",E=>J("terminationReason",E),"text","终止原因..."),me("WORKFLOW OUTPUT (JSON)",typeof _.inputParameters?.workflowOutput=="object"?JSON.stringify(_.inputParameters.workflowOutput,null,2):"{}",E=>{try{J("workflowOutput",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="EVENT"&&ue("事件发送配置","✉️","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("EVENT SINK *",_.sink||"",E=>$("sink",E),"text","e.g. sqs:queue_name 或 conductor"),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),ve("异步完成 (asyncComplete)",!!_.asyncComplete,E=>$("asyncComplete",E))]})),_.type==="WAIT"&&ue("等待状态配置","⏳","var(--color-accent)",l.jsxs(l.Fragment,{children:[Te([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],y,E=>x(E)),y==="duration"?de("DURATION",_.inputParameters?.duration||"",E=>J("duration",E),"text","e.g. 30s, 10m, 2 hours"):de("UNTIL (时间点)",_.inputParameters?.until||"",E=>J("until",E),"text","e.g. 2025-06-15 09:00 GMT+00:00"),l.jsxs("div",{style:{fontSize:"11px",color:H,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",l.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(_.type==="DECISION"||_.type==="SWITCH")&&ue("条件分支配置","⚖️","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("评估模式 (evaluatorType)",["value-param","javascript"],_.evaluatorType||"value-param",E=>$("evaluatorType",E)),(_.evaluatorType||"value-param")==="value-param"?de("CASE VALUE PARAM (参数名)",_.caseValueParam||"",E=>$("caseValueParam",E),"text","e.g. status"):l.jsx(l.Fragment,{children:me("CASE EXPRESSION (JS)",_.caseExpression||"",E=>$("caseExpression",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),_.type==="DO_WHILE"&&ue("循环逻辑配置","🔄","var(--color-accent)",l.jsxs(l.Fragment,{children:[Te([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],b,E=>k(E)),b==="condition"?l.jsxs(l.Fragment,{children:[me("LOOP CONDITION (JS) *",_.loopCondition||"",E=>$("loopCondition",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),l.jsx("input",{value:_.inputParameters?.items||"",onChange:E=>J("items",E.target.value),disabled:!z,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",outline:"none"}}),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),l.jsx("div",{style:{marginTop:"12px"},children:de("KEEP LAST N 次迭代",_.keepLastN??"",E=>$("keepLastN",E?parseInt(E):void 0),"number","0 = 保留全部")})]})),_.type==="FORK_JOIN_DYNAMIC"&&ue("动态并行配置","⚡","var(--color-accent)",l.jsxs(l.Fragment,{children:[Te([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],w,E=>j(E)),w==="classic"&&l.jsxs(l.Fragment,{children:[de("DYNAMIC_FORK_TASKS_PARAM",_.dynamicForkTasksParam||"",E=>$("dynamicForkTasksParam",E),"text","e.g. dynamic_tasks"),de("DYNAMIC_FORK_TASKS_INPUT_PARAM",_.dynamicForkTasksInputParamName||"",E=>$("dynamicForkTasksInputParamName",E),"text","e.g. input"),l.jsx("div",{style:{fontSize:"10px",color:H},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),w==="task"&&l.jsxs(l.Fragment,{children:[de("FORK TASK TYPE *",_.forkTaskType||"",E=>$("forkTaskType",E),"text","e.g. HTTP"),de("FORK TASK NAME (仅 SIMPLE 任务)",_.forkTaskName||"",E=>$("forkTaskName",E),"text","e.g. my_task"),de("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>$("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:H},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),w==="workflow"&&l.jsxs(l.Fragment,{children:[de("FORK WORKFLOW NAME *",_.forkTaskWorkflow||"",E=>$("forkTaskWorkflow",E),"text","e.g. sub_workflow"),de("WORKFLOW VERSION",_.forkTaskWorkflowVersion||"",E=>$("forkTaskWorkflowVersion",E),"text","1"),de("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>$("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:H},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),_.type==="DYNAMIC"&&ue("动态任务配置","🎯","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("DYNAMIC TASK NAME PARAM *",_.dynamicTaskNameParam||"",E=>$("dynamicTaskNameParam",E),"text","e.g. taskToExecute"),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),_.type==="HUMAN"&&ue("人工审批配置","👤","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("表单模板名 (userFormTemplate)",_.humanTaskDef?.userFormTemplate||"",E=>K("humanTaskDef","userFormTemplate",E),"text","e.g. approval_form"),pe("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],_.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",E=>K("humanTaskDef","assignmentCompletionStrategy",E)),de("显示名称 (displayName)",_.humanTaskDef?.displayName||"",E=>K("humanTaskDef","displayName",E),"text","审批任务")]})),_.type==="KAFKA_PUBLISH"&&ue("Kafka 推送配置","📨","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("BOOTSTRAP SERVERS *",_.inputParameters?.bootStrapServers||"",E=>J("bootStrapServers",E),"text","localhost:9092"),de("TOPIC *",_.inputParameters?.topic||"",E=>J("topic",E),"text","my_topic"),de("KEY (消息分区键)",_.inputParameters?.key||"",E=>J("key",E),"text",""),me("VALUE (消息内容)",typeof _.inputParameters?.value=="object"?JSON.stringify(_.inputParameters.value,null,2):_.inputParameters?.value||"",E=>{let X=E;try{X=JSON.parse(E)}catch{}J("value",X)},{rows:4,language:"json"}),me("HEADERS (JSON)",typeof _.inputParameters?.headers=="object"?JSON.stringify(_.inputParameters.headers,null,2):"{}",E=>{try{J("headers",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="SET_VARIABLE"&&ue("变量配置","📦","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:H,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),me("VARIABLES (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{$("inputParameters",JSON.parse(E))}catch{}},{rows:6,language:"json"})]})),l.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${G}`,paddingTop:"24px"},children:[l.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),fe("任务唯一引用名 (Reference Name)","taskReferenceName"),fe("任务描述","description"),l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[l.jsxs("label",{style:{fontSize:"11px",color:H,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",l.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),z&&l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsxs("button",{onClick:se,disabled:V,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:V?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:V?.7:1},children:[V?"⏳":"✨"," AI 填充"]}),l.jsxs("button",{onClick:()=>g(!h),title:"快捷表达式",style:{fontSize:"11px",background:h?"var(--color-accent)":"none",border:`1px solid ${G}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:h?"#fff":H},children:["{}"," 片段"]})]})]}),h&&l.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${G}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:ib.map(E=>l.jsx("button",{onClick:()=>te(E.value),title:E.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${G}`,background:oe,color:Q,cursor:"pointer",fontFamily:"monospace"},children:E.label},E.value))}),ne&&l.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[l.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsx("button",{onClick:()=>{$("inputParameters",ne.generated),ee(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),l.jsx("button",{onClick:()=>ee(null),style:{fontSize:"11px",background:"none",color:H,border:`1px solid ${G}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),l.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:Q,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(ne.generated,null,2)})]}),me("",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):_.inputParameters??"",E=>{try{$("inputParameters",JSON.parse(E))}catch{d(X=>({...X,inputParameters:E}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[fe("重试次数","retryCount","number"),fe("超时限制 (秒)","timeoutSeconds","number")]}),l.jsxs("details",{style:{marginTop:"16px"},children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:H,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),l.jsxs("div",{style:{marginTop:"12px"},children:[pe("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],_.retryLogic||"FIXED",E=>$("retryLogic",E)),de("重试延迟 (秒)",_.retryDelaySeconds??"",E=>$("retryDelaySeconds",E?parseInt(E):void 0),"number","0"),pe("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],_.timeoutPolicy||"TIME_OUT_WF",E=>$("timeoutPolicy",E)),de("启动延迟 (秒)",_.startDelay??"",E=>$("startDelay",E?parseInt(E):void 0),"number","0"),ve("可选任务 (optional) — 失败不影响工作流",!!_.optional,E=>$("optional",E)),ve("异步完成 (asyncComplete)",!!_.asyncComplete,E=>$("asyncComplete",E))]})]})]}),l.jsx("div",{style:{marginTop:"48px",opacity:.6},children:l.jsxs("details",{children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),l.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${G}`,color:H},children:JSON.stringify(_,null,2)})]})})]}),z&&l.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${G}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[l.jsx("div",{style:{flex:1,fontSize:"11px",color:H,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),l.jsx("button",{onClick:t,style:{padding:"10px 24px",background:"var(--color-accent)",color:"#fff",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),l.jsx(sb,{isOpen:N,onClose:()=>L(!1),onSelect:I,suggestions:S,anchorRect:T})]}),F&&l.jsx(ob,{title:F.title,value:F.value,language:F.language,onSave:F.onSave,onClose:()=>W(null)})]})},cb=P.memo(lb),ub={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},_r=e=>ub[e??""]??"var(--text-secondary)",db=(e,r)=>{if(!e)return"-";const t=(r??Date.now())-e;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`},Uh=e=>e?new Date(e).toLocaleTimeString():"-",fb=({executionActions:e})=>{const{selectedTask:r,selectedTaskInstance:t,setSelectedTask:n,setSelectedTaskInstance:s,executionData:a,workflowInstance:o}=ie(),[i,d]=P.useState("summary"),c=P.useRef(null);P.useEffect(()=>{c.current?.scrollTo({top:0})},[i,r?.taskReferenceName]),P.useEffect(()=>{d("summary")},[r?.taskReferenceName]);const u=r?.taskReferenceName==="__workflow_global__",f=r?a?.[r.taskReferenceName]:null;if(!r||!f&&!u)return null;const p=f?.attempts??[],h=t??p[p.length-1],g=o?.workflowId??"",m=o?.status,v=f?.status,y=u?m:h?.status??v,x=u?o?.startTime:h?.startTime,b=u?o?.endTime:h?.endTime,k=u?o?.reasonForIncompletion:h?.reasonForIncompletion,w=u?o?.workflowId:h?.taskId,j=u?o?.input:h?.inputData,N=u?o?.output:h?.outputData,L=!u&&e?.onSkipTask&&(v==="SCHEDULED"||v==="IN_PROGRESS")&&(m==="RUNNING"||m==="PAUSED"),T=!u&&e?.onRerunFromTask&&(m==="FAILED"||m==="TERMINATED"||m==="COMPLETED"||m==="TIMED_OUT"),C=L||T,S=e?.allowOperations!==!1,q=()=>{n(null),s(null)},I="var(--glass-border)",O="var(--text-secondary)",F="var(--bg-tertiary)";return l.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${I}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[l.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[l.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:u?"WORKFLOW":r.type||"TASK"}),y&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${_r(y)}18`,color:_r(y),letterSpacing:"0.5px",flexShrink:0},children:["● ",y]}),l.jsx("div",{style:{flex:1}}),l.jsx("button",{onClick:q,style:{background:"none",border:"none",color:O,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),l.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:u?"工作流全局数据":r.name}),l.jsxs("div",{style:{fontSize:12,color:O,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",r.taskReferenceName]})]}),p.length>1&&l.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,color:O,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",p.length," 次",p.some(W=>W.iteration)?" / 迭代":"尝试",")"]}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:p.map((W,V)=>{const Z=h?.taskId===W.taskId;return l.jsx("button",{onClick:()=>s(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${Z?"var(--color-accent)":I}`,background:Z?"var(--color-accent)":"var(--bg-tertiary)",color:Z?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:W.iteration?`迭代 ${W.iteration}`:`尝试 ${V+1}`},W.taskId)})})]}),l.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(W=>{const V={summary:"概览",input:"输入 JSON",output:"输出 JSON"},Z=i===W;return l.jsx("button",{onClick:()=>d(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${Z?"var(--color-accent)":"transparent"}`,color:Z?"var(--color-accent)":O,cursor:"pointer",fontSize:13,fontWeight:Z?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:V[W]},W)})}),l.jsxs("div",{ref:c,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[i==="summary"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:db(x,b)},{label:"开始时间",value:Uh(x)},{label:"结束时间",value:Uh(b)},{label:u?"Workflow ID":"Task ID",value:l.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:w??"-"})}].map(({label:W,value:V})=>l.jsxs("div",{style:{padding:"12px 14px",background:F,borderRadius:10,border:`1px solid ${I}`},children:[l.jsx("div",{style:{fontSize:10,color:O,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),l.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:V})]},W))}),p.length>1&&l.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${_r(v)}10`,border:`1px solid ${_r(v)}30`,borderRadius:8,fontSize:12,color:_r(v),display:"flex",alignItems:"center",gap:8},children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("path",{d:"M13 2v4h-4"}),l.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",p.length-1," 次,共 ",p.length," 次尝试"]}),!u&&h?.workerId&&l.jsxs("div",{style:{marginBottom:20},children:[l.jsx("div",{style:{fontSize:10,color:O,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),l.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:h.workerId})]}),k&&l.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[l.jsx("strong",{children:"异常信息"}),l.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),C&&l.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${I}`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:O,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!S&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[l.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),l.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[T&&l.jsxs("button",{disabled:!S,onClick:()=>S&&e.onRerunFromTask(g,r.taskReferenceName,h?.taskId),title:S?`从任务 ${r.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:S?Qe:Gh,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,pb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Qe),children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("path",{d:"M3 14v-4h4"}),l.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),L&&l.jsxs("button",{disabled:!S,onClick:()=>S&&e.onSkipTask(g,r.taskReferenceName,h?.taskId),title:S?`跳过任务 ${r.taskReferenceName}`:"操作权限受限",style:S?Qe:Gh,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,hb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Qe),children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:l.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),i==="input"&&l.jsx(Jh,{data:j}),i==="output"&&l.jsx(Jh,{data:N})]})]})},Jh=({data:e})=>l.jsx("div",{style:{background:"var(--bg-tertiary)",padding:16,borderRadius:10,border:"1px solid var(--glass-border)",fontFamily:"'Fira Code', monospace",fontSize:12,lineHeight:1.6,color:"var(--text-primary)",wordBreak:"break-all",whiteSpace:"pre-wrap"},children:JSON.stringify(e??{},null,2)}),Qe={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},pb={...Qe,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},hb={...Qe,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Gh={...Qe,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},gb={add:"新增",mod:"修改",del:"删除",replace:"替换"},mb={add:"+",mod:"~",del:"−"};function vb({diff:e,applied:r,onApply:t,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return l.jsxs("div",{className:"diff-card",children:[l.jsxs("div",{className:"diff-head",children:[l.jsx("span",{className:`diff-badge ${s}`,children:gb[e.kind]??e.kind}),l.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&l.jsx("div",{className:"diff-list",children:e.rows.map((a,o)=>l.jsxs("div",{className:`diff-row ${a.kind}`,children:[l.jsx("div",{className:"diff-marker",children:mb[a.kind]??"·"}),l.jsx("div",{className:"diff-desc",children:a.desc})]},o))}),l.jsx("div",{className:"diff-actions",children:r?l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),l.jsxs("button",{className:"diff-btn undo",onClick:n,children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),l.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):l.jsxs("button",{className:"diff-btn apply",onClick:t,children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Vh(e,r){const t=JSON.parse(JSON.stringify(e));if(r.kind==="replace"&&r.payload)return{next:JSON.parse(JSON.stringify(r.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(r.kind==="add"&&r.payload)return{next:JSON.parse(JSON.stringify(r.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!r.patch)return{next:t,inverse:{kind:r.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const a of r.patch)if(a.op==="patchTask"){const o=t.tasks.find(d=>d.taskReferenceName===a.ref);if(!o)continue;const i={};for(const d of Object.keys(a.set))i[d]=o[d];Object.assign(o,a.set),n.push({op:"patchTask",ref:a.ref,set:i}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")t.edges=t.edges??[],t.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")t.edges=(t.edges??[]).filter(o=>!(o.from===a.from&&o.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")t.tasks.push(a.task),t.edges=t.edges??[],a.removeEdges&&a.removeEdges.forEach(o=>{t.edges=t.edges.filter(i=>!(i.from===o.from&&i.to===o.to))}),a.extraEdges&&a.extraEdges.forEach(o=>t.edges.push(o)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const o=t.tasks.findIndex(c=>c.taskReferenceName===a.ref);if(o<0)continue;const[i]=t.tasks.splice(o,1),d=(t.edges??[]).filter(c=>c.from===a.ref||c.to===a.ref);t.edges=(t.edges??[]).filter(c=>c.from!==a.ref&&c.to!==a.ref),n.push({op:"addTask",task:i,extraEdges:d}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){t.tasks.push(a.task),t.edges=t.edges??[];const o=t.edges.findIndex(i=>i.from===a.after&&i.to===a.edgeTo);o>=0&&t.edges.splice(o,1),t.edges.push({from:a.after,to:a.task.taskReferenceName}),t.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){t.tasks.push(a.task),t.edges=t.edges??[];const o=t.edges.filter(i=>i.to===a.before);t.edges=t.edges.filter(i=>i.to!==a.before),o.forEach(i=>t.edges.push({from:i.from,to:a.task.taskReferenceName,label:i.label})),t.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:t,inverse:{kind:r.kind,summary:`撤销:${r.summary}`,rows:s,patch:n.reverse()}}}function yb(e){const r=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!r)return null;try{const t=JSON.parse(r[1]);return!t.kind||!t.summary?null:t}catch{return null}}const Yh={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},Xh=e=>e.split(/(```[\s\S]*?```)/).map((t,n)=>{if(t.startsWith("```")&&t.endsWith("```")){const s=t.slice(3,-3),a=s.indexOf(`
110
- `),o=a>=0?s.slice(a+1):s;return l.jsx("pre",{children:l.jsx("code",{children:o})},n)}return l.jsx("span",{children:xb(t)},n)}),xb=e=>{const r=[],t=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,s;for(;(s=t.exec(e))!==null;){s.index>n&&r.push(e.slice(n,s.index));const a=s[0];a.startsWith("**")&&a.endsWith("**")?r.push(l.jsx("strong",{children:a.slice(2,-2)},s.index)):a.startsWith("`")&&a.endsWith("`")?r.push(l.jsx("code",{children:a.slice(1,-1)},s.index)):a===`
111
- `&&r.push(l.jsx("br",{},s.index)),n=s.index+a.length}return n<e.length&&r.push(e.slice(n)),r},bb=({aiConfig:e})=>{const{workflowDef:r,setWorkflow:t,mode:n}=ie(),[s,a]=P.useState(!1),[o,i]=P.useState(""),[d,c]=P.useState(!1),[u,f]=P.useState([Yh]),[p,h]=P.useState(""),[g,m]=P.useState(null),v=P.useRef(null),y=P.useRef(null),x=P.useRef(null),b=P.useCallback(O=>{if(!O.diff||O.applied||!r)return;const{next:F,inverse:W}=Vh(r,O.diff);t(F),f(V=>V.map(Z=>Z.id===O.id?{...Z,applied:!0,inverse:W}:Z))},[r,t]),k=P.useCallback(O=>{if(!O.inverse||!O.applied||!r)return;const{next:F}=Vh(r,O.inverse);t(F),f(W=>W.map(V=>V.id===O.id?{...V,applied:!1,inverse:void 0}:V))},[r,t]),w=()=>{const O=y.current;O&&(O.style.height="auto",O.style.height=Math.min(O.scrollHeight,120)+"px")},j=()=>{const O=y.current;O&&(O.style.height="auto")};P.useEffect(()=>()=>{x.current?.abort()},[]),P.useEffect(()=>{const O=()=>a(!0);return window.addEventListener("open-ai-chat",O),()=>window.removeEventListener("open-ai-chat",O)},[]);const N=()=>{v.current?.scrollIntoView({behavior:"smooth"})};P.useEffect(()=>{s&&N()},[u,s,p]);const L=P.useCallback(O=>{const F=[{role:"system",content:tb}];for(const V of u)V.role==="user"&&V.content?F.push({role:"user",content:V.content}):V.role==="ai"&&V.content&&!V.thinking&&F.push({role:"assistant",content:V.content});const W=nb(O,r);return F.push({role:"user",content:W}),F},[u,r]),T=async O=>{const F=o.trim();if(!F||d)return;x.current?.abort();const W=new AbortController;x.current=W;const V={id:Date.now().toString(),role:"user",content:F};f(Z=>[...Z,V]),i(""),j(),c(!0),h("");try{const Z=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",ne=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ee=e?.model||localStorage.getItem("AI_MODEL")||"";if(!Z){setTimeout(()=>{if(W.signal.aborted)return;const B={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},z={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:B}};f(Q=>[...Q,z]),c(!1)},800);return}const D={apiKey:Z};ne&&(D.baseUrl=ne),ee&&(D.model=ee);const Y=L(F),se=await Qx(Y,D,B=>{h(z=>z+B)},()=>{},W.signal);let M=yb(se);if(!M){const B=se.match(/```json\n([\s\S]*?)\n```/);if(B)try{const z=JSON.parse(B[1]);M={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:z}}catch{}}const _={id:(Date.now()+1).toString(),role:"ai",content:se,diff:M??void 0,applied:!1};f(B=>[...B,_]),h("")}catch(Z){if(Z.name==="AbortError")h(ne=>{if(ne){const ee={id:(Date.now()+1).toString(),role:"ai",content:ne};f(D=>[...D,ee])}return""});else{const ne={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${Z.message}`};f(ee=>[...ee,ne]),h("")}}finally{c(!1)}},C=()=>{x.current?.abort()},S=()=>{x.current?.abort(),f([Yh]),h(""),c(!1)},q=O=>{navigator.clipboard.writeText(O.content??""),m(O.id),setTimeout(()=>m(null),1500)},I=O=>{O.nativeEvent.isComposing||O.keyCode===229||O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),T())};return n!=="edit"?null:s?l.jsxs("div",{className:"ai-chat-panel",children:[l.jsxs("div",{className:"ai-header",children:[l.jsxs("div",{className:"ai-title",children:[l.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),l.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[l.jsx("button",{className:"ai-close",onClick:S,title:"清空对话",children:"🗑"}),l.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),l.jsxs("div",{className:"ai-messages",children:[u.map(O=>l.jsxs("div",{className:`message ${O.role}`,children:[l.jsx("div",{className:"message-content",children:O.thinking?l.jsxs("div",{className:"thinking-skeleton",children:[l.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):O.role==="ai"?Xh(O.content??""):O.content}),O.diff&&!O.thinking&&l.jsx(vb,{diff:O.diff,applied:O.applied??!1,onApply:()=>b(O),onUndo:()=>k(O)}),O.role==="ai"&&O.content&&l.jsx("button",{className:"copy-btn",onClick:()=>q(O),title:"复制",children:g===O.id?"✓":"📋"})]},O.id)),d&&p&&l.jsxs("div",{className:"message ai",style:{opacity:.9},children:[l.jsx("div",{className:"message-content",children:Xh(p)}),l.jsx("span",{className:"streaming-cursor",children:"▊"})]}),d&&!p&&l.jsxs("div",{className:"message ai thinking-skeleton",children:[l.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),l.jsx("div",{ref:v})]}),l.jsx("div",{className:"ai-input-area",children:l.jsxs("div",{className:"ai-input-container",children:[l.jsx("textarea",{ref:y,className:"ai-input",placeholder:d?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:o,onChange:O=>i(O.target.value),onInput:w,onKeyDown:I,disabled:d,rows:2}),d?l.jsx("button",{className:"ai-send stop",onClick:C,title:"停止生成",children:"⏹"}):l.jsx("button",{className:"ai-send",onClick:()=>T(),title:"发送",children:"🚀"})]})})]}):l.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:l.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:l.jsxs("div",{className:"ai-title",children:[l.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},kb=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),_b=({onTriggerExecution:e,onPollExecution:r,executionPollInterval:t=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:a,setRunState:o,importExecutionJSON:i,setMode:d}=ie(),[c,u]=P.useState("form"),[f,p]=P.useState({}),[h,g]=P.useState("{}"),[m,v]=P.useState(""),[y,x]=P.useState(!1),[b,k]=P.useState(""),w=Vr(n?.inputParameters);P.useEffect(()=>{s&&(p({}),g("{}"),v(""),k(""),x(!1))},[s]);const j=P.useCallback(()=>{try{const S={};w.forEach(q=>{const I=f[q.name];if(I!==void 0&&I!=="")if(q.type==="number")S[q.name]=Number(I);else if(q.type==="boolean")S[q.name]=I==="true";else if(q.type==="object"||q.type==="array")try{S[q.name]=JSON.parse(I)}catch{S[q.name]=I}else S[q.name]=I;else q.defaultValue!==void 0&&(S[q.name]=q.defaultValue)}),g(JSON.stringify(S,null,2))}catch{}u("json")},[f,w]),N=P.useCallback(()=>{try{const S=JSON.parse(h),q={};w.forEach(I=>{const O=S[I.name];O!==void 0&&(q[I.name]=typeof O=="object"?JSON.stringify(O,null,2):String(O))}),p(q),v("")}catch{v("JSON 格式有误,无法切换为表单模式")}u("form")},[h,w]),L=P.useCallback(()=>{if(c==="json")try{return JSON.parse(h)}catch{return v("JSON 格式有误,请检查后重试"),null}const S={};return w.forEach(q=>{const I=f[q.name]??(q.defaultValue!==void 0?String(q.defaultValue):"");if(!(I===""&&!q.required))if(q.type==="number")S[q.name]=Number(I);else if(q.type==="boolean")S[q.name]=I==="true";else if(q.type==="object"||q.type==="array")try{S[q.name]=JSON.parse(I)}catch{S[q.name]=I}else S[q.name]=I}),S},[c,h,f,w]),T=P.useCallback(async()=>{if(!e||!n)return;const S=L();if(S===null)return;const q=w.filter(I=>I.required&&(S[I.name]===void 0||S[I.name]===""));if(q.length>0){k(`必填参数未填写:${q.map(I=>I.name).join(", ")}`);return}x(!0),k(""),o("triggering");try{const{workflowId:I}=await e(n.name,n.version??1,S);if(o("polling",I),a(!1),d("run"),!r)return;let O=t;const F=15e3;let W;const V=async()=>{try{const Z=await r(I);if(Z&&(i(Z),kb.has(Z.status))){o("done",I);return}}catch{}O=Math.min(O*1.5,F),W=setTimeout(V,O)};W=setTimeout(V,O),ie.getState().__pollTimer=W}catch(I){const O=I?.message||"执行触发失败,请检查配置后重试";o("error",null,O),k(O),x(!1)}},[e,r,n,L,w,o,a,i,d,t]);if(!s||!n)return null;const C=w.length>0;return l.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:l.jsxs("div",{className:"wrp-panel",onClick:S=>S.stopPropagation(),children:[l.jsxs("div",{className:"wrp-header",children:[l.jsxs("div",{className:"wrp-header-title",children:[l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),l.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",l.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),l.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:"✕"})]}),l.jsxs("div",{className:"wrp-content",children:[l.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",C&&l.jsxs("div",{className:"wrp-mode-toggle",children:[l.jsx("button",{className:c==="form"?"active":"",onClick:c==="json"?N:void 0,children:"表单模式"}),l.jsx("button",{className:c==="json"?"active":"",onClick:c==="form"?j:void 0,children:"JSON 编辑器"})]})]}),!C&&c==="form"&&l.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",l.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),c==="form"?l.jsxs("div",{className:"wrp-form",children:[w.map(S=>l.jsxs("div",{className:"wrp-field",children:[l.jsxs("label",{className:"wrp-field-label",children:[S.name,S.required&&l.jsx("span",{className:"wrp-required",children:"*"}),S.type&&l.jsx("span",{className:"wrp-type",children:S.type})]}),S.description&&l.jsx("p",{className:"wrp-field-desc",children:S.description}),S.type==="object"||S.type==="array"?l.jsx("textarea",{className:"wrp-input",rows:3,placeholder:S.example?JSON.stringify(S.example,null,2):"{}",value:f[S.name]??"",onChange:q=>p(I=>({...I,[S.name]:q.target.value}))}):S.type==="boolean"?l.jsxs("select",{className:"wrp-input",value:f[S.name]??(S.defaultValue!==void 0?String(S.defaultValue):""),onChange:q=>p(I=>({...I,[S.name]:q.target.value})),children:[l.jsx("option",{value:"",children:"请选择"}),l.jsx("option",{value:"true",children:"true"}),l.jsx("option",{value:"false",children:"false"})]}):l.jsx("input",{className:"wrp-input",type:S.type==="number"?"number":"text",placeholder:S.example!==void 0?String(S.example):S.defaultValue!==void 0?String(S.defaultValue):"",value:f[S.name]??"",onChange:q=>p(I=>({...I,[S.name]:q.target.value}))})]},S.name)),!C&&l.jsx("button",{className:"wrp-switch-json",onClick:j,children:"切换为 JSON 编辑器手动填写"})]}):l.jsxs("div",{className:"wrp-json-editor",children:[l.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:h,onChange:S=>{g(S.target.value),v("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),m&&l.jsx("p",{className:"wrp-error",children:m})]}),b&&l.jsx("p",{className:"wrp-error wrp-submit-error",children:b})]}),l.jsxs("div",{className:"wrp-footer",children:[l.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?l.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:T,disabled:y,children:y?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):l.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},Sb=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function wb(e,r){const t=r[e];if(!t)return[];const n=t.reasonForIncompletion||"";if(!n)return[];const s=[];for(const a of Sb)a.pattern.test(n)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function Tb(e,r){const t=Object.values(e).map(h=>{const g=h.startTime&&h.endTime?h.endTime-h.startTime:void 0,m=Math.max(0,(h.attempts?.length??1)-1);return{taskRef:h.taskReferenceName,status:h.status,startTime:h.startTime,endTime:h.endTime,durationMs:g,retryCount:m,reasonForIncompletion:h.reasonForIncompletion,diagnostics:wb(h.taskReferenceName,e)}}).sort((h,g)=>(h.startTime??0)-(g.startTime??0)),n=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=t.filter(h=>h.status==="COMPLETED"||h.status==="COMPLETED_WITH_ERRORS").length,a=t.filter(h=>n.includes(h.status)).length,o=t.filter(h=>h.status==="SKIPPED").length,i=t.flatMap(h=>[h.startTime,h.endTime]).filter(h=>!!h),d=i.length?Math.min(...i):0,u=(i.length?Math.max(...i):0)-d,f=r?.status,p=f==="FAILED"||f==="TIMED_OUT"||f==="TERMINATED"||a>0;return{totalTasks:t.length,completedTasks:s,failedTasks:a,skippedTasks:o,totalDurationMs:u,steps:t,hasFailed:p}}function Zh(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function Eb(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function Nb(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const Qh={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},eg={COMPLETED:"var(--status-completed)",COMPLETED_WITH_ERRORS:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed)",IN_PROGRESS:"var(--status-running)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-failed)",SKIPPED:"var(--status-skipped, #6b7280)",CANCELED:"var(--status-failed)"},Cb=()=>{const{executionData:e,workflowInstance:r,showAnalysisPanel:t,setShowAnalysisPanel:n,switchToEditAndFocusParam:s,selectTaskAction:a,taskMap:o}=ie(),i=P.useMemo(()=>e?Tb(e,r??null):null,[e,r]);if(!t||!i)return null;const{totalTasks:d,completedTasks:c,failedTasks:u,skippedTasks:f,totalDurationMs:p,steps:h}=i,g=d>0?Math.round(c/d*100):0,m=r?.status,v=m?eg[m]??"var(--text-secondary)":"var(--text-secondary)";return l.jsxs("div",{className:"esp-panel glass-panel",children:[l.jsxs("div",{className:"esp-header",children:[l.jsxs("div",{className:"esp-title",children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),m&&l.jsx("span",{className:"esp-wf-status",style:{color:v},children:Qh[m]??m}),l.jsx("button",{className:"esp-close",onClick:()=>n(!1),children:"✕"})]}),l.jsxs("div",{className:"esp-content",children:[l.jsxs("div",{className:"esp-overview",children:[l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:d}),l.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),l.jsxs("div",{className:"esp-card esp-card-success",children:[l.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:c}),l.jsx("span",{className:"esp-card-label",children:"已完成"})]}),l.jsxs("div",{className:"esp-card esp-card-failed",children:[l.jsx("span",{className:"esp-card-value",style:{color:u>0?"var(--status-failed)":"var(--text-secondary)"},children:u}),l.jsx("span",{className:"esp-card-label",children:"失败"})]}),l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:Zh(p)}),l.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),l.jsx("div",{className:"esp-progress-bar",children:l.jsx("div",{className:"esp-progress-fill",style:{width:`${g}%`,background:u>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${g}%`})}),l.jsxs("div",{className:"esp-progress-label",children:[g,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),h.filter(y=>y.diagnostics.length>0).map(y=>l.jsxs("div",{className:"esp-diagnostic-card",children:[l.jsxs("div",{className:"esp-diag-task-ref",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:l.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),y.taskRef]}),y.diagnostics.map((x,b)=>l.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:Nb(x.category)},children:[l.jsxs("div",{className:"esp-diag-title",children:[l.jsx("span",{children:Eb(x.category)}),x.title]}),l.jsx("p",{className:"esp-diag-explanation",children:x.explanation}),l.jsxs("button",{className:"esp-fix-btn",onClick:()=>s(y.taskRef,x.suggestEditParam),children:["去修复",l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:l.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},b))]},y.taskRef)),l.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),l.jsxs("div",{className:"esp-steps-table",children:[l.jsxs("div",{className:"esp-steps-header",children:[l.jsx("span",{children:"#"}),l.jsx("span",{children:"任务引用名"}),l.jsx("span",{children:"状态"}),l.jsx("span",{children:"耗时"}),l.jsx("span",{children:"重试"})]}),h.map((y,x)=>{const b=eg[y.status]??"var(--text-secondary)",k=o[y.taskRef];return l.jsxs("button",{className:"esp-step-row",onClick:()=>k&&a(k,!0),title:y.reasonForIncompletion||y.taskRef,children:[l.jsx("span",{className:"esp-step-idx",children:x+1}),l.jsx("span",{className:"esp-step-ref",children:y.taskRef}),l.jsxs("span",{className:"esp-step-status",style:{color:b},children:[l.jsx("span",{className:"esp-status-dot",style:{background:b}}),Qh[y.status]??y.status]}),l.jsx("span",{className:"esp-step-duration",children:Zh(y.durationMs)}),l.jsx("span",{className:"esp-step-retry",style:{color:y.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:y.retryCount>0?`${y.retryCount}次`:"-"})]},y.taskRef)})]})]})]})},rg=P.forwardRef(({workflowDef:e,readOnly:r=!1,theme:t="dark",themeColor:n="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:o,onRequestImport:i,executionActions:d,aiConfig:c,viewMode:u="developer",onSave:f,onWorkflowChange:p,height:h="100%",onTriggerExecution:g,onPollExecution:m,executionPollInterval:v=3e3},y)=>{const{setWorkflow:x,setTheme:b,setThemeColor:k,setLayoutDirection:w,setNodesLocked:j,selectedTask:N,setSelectedTask:L,edgeType:T,importExecutionJSON:C,setMode:S,setViewMode:q,isDetailPanelOpen:I,setIsDetailPanelOpen:O,selectTaskAction:F,workflowDef:W,isSimRunning:V,startSimulation:Z,stopSimulation:ne,mode:ee,setShowRunPanel:D,showAnalysisPanel:Y,setShowAnalysisPanel:se,executionData:R}=ie(),[M,_]=P.useState(!1),B=P.useCallback(()=>{if(!W)return;const G=new Blob([JSON.stringify(W,null,2)],{type:"application/json"}),oe=URL.createObjectURL(G),H=document.createElement("a");H.href=oe,H.download=`${W.name||"workflow"}.json`,H.click(),URL.revokeObjectURL(oe)},[W]),z=P.useCallback(()=>{W&&navigator.clipboard.writeText(JSON.stringify(W,null,2))},[W]);P.useEffect(()=>{b(t),k(n),w(s),j(r||!!o)},[t,n,s,r,o,b,k,w,j]),P.useEffect(()=>{q(o?"developer":u)},[u,o,q]),P.useEffect(()=>{e&&(x(e,s),ie.temporal.getState().clear())},[e,x,s]),P.useEffect(()=>{o?C(o):S(r?"view":"edit")},[o,C,S,r]),P.useImperativeHandle(y,()=>({getWorkflowDef:()=>ie.getState().workflowDef,getValidationResults:()=>ie.getState().validationResults,save:()=>{const G=ie.getState().workflowDef;G&&f&&f(G)},createBlankWorkflow:G=>{ie.getState().createBlankWorkflow(G),ie.temporal.getState().clear()}}),[f]),P.useEffect(()=>{if(!p)return;let G=!0,oe=ie.getState().workflowDef;return ie.subscribe($=>{const K=$.workflowDef;if(K!==oe){if(oe=K,G){G=!1;return}K&&p(K)}})},[p]);const Q=G=>{o?L(G):F(G,!0)};return l.jsxs("div",{className:`workflow-ide ${t==="light"?"light-theme":""}`,"data-mode":t,"data-brand":n,style:{width:"100%",height:h,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[l.jsx("div",{style:{flex:1}}),ee==="edit"&&W&&l.jsxs("button",{onClick:()=>D(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),ee==="run"&&R&&l.jsxs("button",{onClick:()=>se(!Y),style:{height:28,padding:"0 10px",background:Y?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:Y?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${Y?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),ee!=="run"&&W&&(V?l.jsxs("button",{onClick:ne,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):l.jsxs("button",{onClick:Z,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),W&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:B,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-strong)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),l.jsxs("button",{onClick:z,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-strong)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[l.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),l.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),l.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:l.jsx(A.ReactFlowProvider,{children:l.jsx(Zx,{onNodeClick:Q,edgeType:T,theme:t,nodesLocked:r||!!o,searchQuery:a,onSave:f,onRequestImport:i,executionActions:d})})}),l.jsx(cb,{task:N,isOpen:I,onClose:()=>O(!1),theme:t,aiConfig:c}),l.jsx(Lh,{isOpen:M,onClose:()=>_(!1),theme:t,onTaskSelect:G=>{F(G,!0)}}),o&&l.jsx(fb,{executionActions:d}),l.jsx(bb,{aiConfig:c}),l.jsx(_b,{onTriggerExecution:g,onPollExecution:m,executionPollInterval:v}),ee==="run"&&l.jsx(Cb,{})]})});rg.displayName="WorkflowIDE",qe.WorkflowIDE=rg,qe.parseWorkflowInputParams=Vr,Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"})}));
126
+ `,c1={string:"#38bdf8",number:"#a78bfa",boolean:"#f472b6",object:"#fbbf24",array:"#34d399",any:"#94a3b8"},d1=({isOpen:e,onClose:t,onSelect:r,suggestions:n,wlspItems:s=[],anchorRect:a,onRequestAiHint:i,aiLoading:l=!1})=>{const c=oe(E=>E.theme),[d,u]=I.useState("all"),[f,h]=I.useState(""),[p,m]=I.useState(0),g=I.useRef(null);I.useEffect(()=>{e&&(h(""),m(0),setTimeout(()=>g.current?.focus(),30))},[e]);const x=I.useMemo(()=>{const E=s.map($=>({label:$.label,value:$.value,description:$.description,category:$.category,valueType:$.valueType,sourceLabel:$.sourceLabel,sampleValue:$.sampleValue,isConditional:$.isConditional})),q=new Set(E.map($=>$.value));for(const $ of n)q.has($.value)||(q.add($.value),E.push({...$,category:$.category||"ai"}));return E},[s,n]),v=I.useMemo(()=>x.filter(E=>{if(d!=="all"&&E.category!==d&&E.category!=="ai")return!1;if(!f.trim())return!0;const q=f.toLowerCase();return E.label.toLowerCase().includes(q)||E.value.toLowerCase().includes(q)||E.description.toLowerCase().includes(q)||E.sourceLabel&&E.sourceLabel.toLowerCase().includes(q)}),[x,d,f]);if(I.useEffect(()=>{m(0)},[d,f]),!e||!a||typeof document>"u")return null;const y=typeof window<"u"?window.innerHeight:800,b=typeof window<"u"?window.innerWidth:1280,k=Math.min(380,b-32),_=a.width>=160?a.left:a.right-k,w=Math.min(Math.max(16,_),b-k-16),T=y-a.bottom-16,O=a.top-16,D=T<260&&O>T,N=D?Math.min(400,Math.max(200,O)):Math.min(400,Math.max(200,T)),S=c==="light",R={position:"fixed",...D?{bottom:`${y-a.top+6}px`}:{top:`${a.bottom+6}px`},left:`${w}px`,width:`${k}px`,maxHeight:`${N}px`,zIndex:9999,background:S?"rgba(255, 255, 255, 0.98)":"rgba(15, 23, 42, 0.96)",color:S?"#0f172a":"#f8fafc",borderColor:S?"rgba(148, 163, 184, 0.35)":"rgba(56, 189, 248, 0.28)"},j=E=>{E.key==="ArrowDown"?(E.preventDefault(),m(q=>v.length>0?(q+1)%v.length:0)):E.key==="ArrowUp"?(E.preventDefault(),m(q=>v.length>0?(q-1+v.length)%v.length:0)):E.key==="Enter"&&v[p]?(E.preventDefault(),r(v[p].value),t()):E.key==="Escape"&&(E.preventDefault(),t())};return _t.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"suggester-overlay",onClick:t}),o.jsxs("div",{className:`parameter-suggester-popover glass-panel ${S?"theme-light":"theme-dark"}`,style:R,onKeyDown:j,children:[o.jsxs("div",{className:"suggester-header",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{className:"sparkle-icon",children:"⚡"}),o.jsx("span",{children:"W-LSP 上下文变量补全"}),o.jsxs("span",{style:{fontSize:10,opacity:.65,fontWeight:500},children:["(",v.length,")"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i&&o.jsx("button",{type:"button",className:"suggester-ai-btn",onClick:i,disabled:l,title:"调用 AI 推理更多上下文表达式",children:l?"AI 思考中...":"✨ AI 推荐"}),o.jsx("button",{type:"button",onClick:t,title:"关闭 (Esc)",style:{background:"none",border:"none",color:"inherit",opacity:.55,cursor:"pointer",padding:"2px 4px",fontSize:12,lineHeight:1},children:"✕"})]})]}),o.jsx("div",{className:"suggester-search-bar",children:o.jsx("input",{ref:g,type:"text",className:"suggester-search-input",placeholder:"搜索上游任务、输出字段或输入参数 (↑↓选择, Enter插入)...",value:f,onChange:E=>h(E.target.value)})}),o.jsx("div",{className:"suggester-tabs",children:[{id:"all",label:"全部"},{id:"upstream",label:"🔗 上游输出"},{id:"workflow_input",label:"📥 工作流输入"},{id:"variable",label:"📦 全局变量"},{id:"system",label:"⚙️ 系统"}].map(E=>o.jsx("button",{type:"button",className:`suggester-tab ${d===E.id?"active":""}`,onClick:()=>u(E.id),children:E.label},E.id))}),o.jsx("div",{className:"suggester-list",children:v.length===0?o.jsx("div",{className:"suggester-empty",children:"没有匹配的上下文变量"}):v.map((E,q)=>{const $=c1[E.valueType||"any"]||"#94a3b8";return o.jsxs("div",{className:`suggestion-item ${q===p?"active":""}`,onMouseEnter:()=>m(q),onClick:()=>{r(E.value),t()},children:[o.jsxs("div",{className:"suggestion-top-row",children:[o.jsx("span",{className:"suggestion-label",children:E.label}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[E.isConditional&&o.jsx("span",{className:"suggestion-cond-badge",title:"来自条件分支,可能未执行",children:"条件分支"}),E.valueType&&o.jsx("span",{className:"suggestion-type-badge",style:{color:$,borderColor:`${$}44`,background:`${$}15`},children:E.valueType})]})]}),o.jsxs("div",{className:"suggestion-value-row",children:[o.jsx("code",{className:"suggestion-value",children:E.value}),E.sampleValue!==void 0&&o.jsxs("span",{className:"suggestion-sample",title:`真实样本值: ${E.sampleValue}`,children:["= ",E.sampleValue]})]}),o.jsxs("div",{className:"suggestion-desc",children:[E.sourceLabel?`[${E.sourceLabel}] `:"",E.description]})]},`${E.value}-${q}`)})})]})]}),document.body)},u1=({title:e,value:t,language:r="text",placeholder:n="",onSave:s,onClose:a})=>{const{theme:i,themeColor:l}=oe(),[c,d]=I.useState(t),u=I.useRef(null);I.useEffect(()=>{u.current?.focus();const p=m=>{m.key==="Escape"&&(m.stopPropagation(),a()),(m.ctrlKey||m.metaKey)&&m.key==="s"&&(m.preventDefault(),m.stopPropagation(),s(c))};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[c,s,a]);const h={javascript:"#f7df1e",js:"#f7df1e",json:"#89b4fa",jq:"#a6e3a1",groovy:"#4ec994",python:"#3572A5",text:"var(--text-secondary)"}[r.toLowerCase()]??"var(--text-secondary)";return _t.createPortal(o.jsxs("div",{"data-mode":i,"data-brand":l,style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 20px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--glass-border)",flexShrink:0},children:[o.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:h,background:`${h}18`,border:`1px solid ${h}44`,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",letterSpacing:"0.5px",textTransform:"uppercase",flexShrink:0},children:r}),o.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),o.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",flexShrink:0},children:"Ctrl+S 保存 · Esc 取消"}),o.jsx("button",{onClick:a,style:{padding:"6px 14px",background:"var(--bg-tertiary)",border:"1px solid var(--glass-border)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"12px",fontWeight:500,flexShrink:0},children:"取消"}),o.jsx("button",{onClick:()=>s(c),style:{padding:"6px 16px",background:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,flexShrink:0},children:"应用"})]}),o.jsx("textarea",{ref:u,value:c,placeholder:n,onChange:p=>d(p.target.value),onKeyDown:p=>p.stopPropagation(),spellCheck:!1,style:{flex:1,width:"100%",padding:"20px 24px",background:"var(--bg-primary)",color:r==="javascript"||r==="js"||r==="groovy"?"var(--color-accent)":"var(--text-primary)",border:"none",outline:"none",resize:"none",fontFamily:'var(--font-mono, "Fira Code", "Cascadia Code", Consolas, monospace)',fontSize:"14px",lineHeight:"1.7",boxSizing:"border-box",caretColor:"var(--color-accent)"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"5px 20px",background:"var(--bg-secondary)",borderTop:"1px solid var(--glass-border)",flexShrink:0,fontSize:"11px",color:"var(--text-secondary)"},children:[o.jsxs("span",{children:[c.split(`
127
+ `).length," 行"]}),o.jsxs("span",{children:[c.length," 字符"]}),c!==t&&o.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},f1=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],p1=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:i,workflowDef:l,executionData:c,workflowInstance:d,lastRefactorNotice:u,clearRefactorNotice:f}=oe(),[h,p]=I.useState(e),[m,g]=I.useState(e?.taskReferenceName??null),[x,v]=I.useState(null),[y,b]=I.useState(!1),[k,_]=I.useState(null),[w,T]=I.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[O,D]=I.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[N,S]=I.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[R,j]=I.useState(!1),[E,q]=I.useState(),[$,J]=I.useState([]),[V,A]=I.useState(()=>()=>{}),B=e?.taskReferenceName||h?.taskReferenceName||"",P=I.useMemo(()=>!l||!B?[]:rm(l,B,c,d?.input),[l,B,c,d?.input]),[U,se]=I.useState(null),[L,F]=I.useState(!1),[z,H]=I.useState(null),Y=(C,K,ae,re)=>{se({title:C,value:K,language:ae,onSave:re})},ie=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],fe=async()=>{const C=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!C){alert("请先在设置中配置 AI API Key");return}if(be){F(!0);try{const{workflowDef:K,taskMap:ae}=oe.getState(),re=At(K?.inputParameters).map(pe=>pe.name),Z=Object.values(ae).filter(pe=>pe.taskReferenceName!==be.taskReferenceName).map(pe=>({ref:pe.taskReferenceName,type:pe.type,name:pe.name})).slice(0,10),ye={apiKey:C};n?.baseUrl&&(ye.baseUrl=n.baseUrl),n?.model&&(ye.model=n.model);const xe=await e1(be.type,be.taskReferenceName,re,Z,be.inputParameters??{},ye);H({generated:xe,original:be.inputParameters??{}})}catch(K){alert(`AI 生成失败:${K?.message||"未知错误"}`)}finally{F(!1)}}},ve=async(C,K)=>{const ae=C.currentTarget.getBoundingClientRect();if(q(ae),A(()=>K),j(!0),P.length>0)return;J([]);const re=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!re){J(ie);return}try{const Z=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ye=n?.model||localStorage.getItem("AI_MODEL")||"",xe={apiKey:re};Z&&(xe.baseUrl=Z),ye&&(xe.model=ye);const{workflowDef:pe}=oe.getState(),ue=l1(be,pe),Pe=(await xl([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:ue}],xe)).match(/\[[\s\S]*\]/);if(Pe){const Re=JSON.parse(Pe[0]);J(Re)}else J(ie)}catch{J(ie)}};if(I.useEffect(()=>{e&&(p(e),g(e.taskReferenceName),v(null),e.type==="WAIT"&&T(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&D(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?S("workflow"):e.forkTaskType?S("task"):S("classic")))},[e]),!e&&!h)return null;const be=e||h,W=h&&e&&m===e.taskReferenceName?h:be,ke=t&&e?"panel-enter-active":"panel-exit",ee=s==="edit",me="var(--text-primary)",ne="var(--glass-border)",_e="var(--bg-tertiary)",ce="var(--text-secondary)",he=(C,K)=>{const ae={...W,[C]:K};p(ae),a(W.taskReferenceName,{[C]:K})},Fe=(C,K,ae)=>{const Z={...W[C]||{},[K]:ae},ye={...W,[C]:Z};p(ye),a(W.taskReferenceName,{[C]:Z})},Se=(C,K)=>{const ae=W.inputParameters||{},Z={...ae.http_request||W.httpRequest||{},[C]:K},xe={inputParameters:{...ae,http_request:Z}};W.httpRequest&&(xe.httpRequest=Z);const pe={...W,...xe};p(pe),a(W.taskReferenceName,xe)},ge=(C,K)=>{const re={inputParameters:{...W.inputParameters,[C]:K}},Z={...W,...re};p(Z),a(W.taskReferenceName,re)},Qe=C=>{if(!k)return;const K=k.selectionStart??0,ae=k.selectionEnd??0,re=k.value,Z=re.substring(0,K)+C+re.substring(ae),ye=k.getAttribute("data-field");ye&&he(ye,Z),b(!1)},Ee=(C,K,ae,re)=>o.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${ae}10`,border:`1px solid ${ae}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[o.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:ae,display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:K})," ",C]}),re]}),rt=(C,K,ae="text",re)=>{const Z=K==="taskReferenceName",ye=Z&&x!==null?x:W[K]??"",xe=Z&&!i(ye,W.taskReferenceName);return o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("label",{style:{display:"block",fontSize:"11px",color:ce,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[C,Z&&xe&&o.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),o.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[o.jsx("input",{type:ae,value:ye,placeholder:re,onChange:pe=>{const ue=pe.target.value;if(Z)v(ue);else{he(K,ae==="number"?ue===""?void 0:Number(ue):ue);const Te=pe.target.selectionStart??0;if(ae==="text"&&Te>=2&&ue.slice(Te-2,Te)==="${"){const Pe=pe.target.getBoundingClientRect();q(Pe),A(()=>Re=>{const Be=ue.slice(0,Te-2),vl=ue.slice(Te);he(K,Be+Re+vl)}),j(!0)}}},onFocus:Z?()=>{x===null&&v(W.taskReferenceName??"")}:void 0,onBlur:Z?pe=>{const ue=pe.target.value.trim();v(null),ue&&ue!==W.taskReferenceName&&he("taskReferenceName",ue)}:void 0,onKeyDown:Z?pe=>{pe.key==="Enter"&&pe.currentTarget.blur(),pe.stopPropagation()}:void 0,disabled:!ee,style:{width:"100%",padding:`8px ${ee&&!Z?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${xe?"#ef4444":ne}`,background:_e,color:me,fontSize:"13px",outline:"none",opacity:ee?1:.8,fontFamily:Z?"monospace":"inherit"}}),ee&&!Z&&o.jsx("button",{className:"ai-hint-trigger",onClick:pe=>ve(pe,ue=>he(K,ue)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},Q=(C,K,ae,re={})=>{const{rows:Z=5,language:ye="text",style:xe,placeholder:pe,"data-field":ue}=re,Te={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...xe};return o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[o.jsx("label",{style:{fontSize:"10px",color:ce},children:C}),ee&&o.jsx("button",{onClick:()=>Y(C,K,ye,Pe=>{ae(Pe),se(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),o.jsx("textarea",{value:K,placeholder:pe,onChange:Pe=>{const Re=Pe.target.value;ae(Re);const Be=Pe.target.selectionStart??0;if(Be>=2&&Re.slice(Be-2,Be)==="${"){const vl=Pe.target.getBoundingClientRect();q(vl),A(()=>A1=>{const L1=Re.slice(0,Be-2),D1=Re.slice(Be);ae(L1+A1+D1)}),j(!0)}},disabled:!ee,rows:Z,"data-field":ue,onFocus:Pe=>_(Pe.currentTarget),style:Te})]})},X=(C,K,ae,re="text",Z)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:C}),o.jsx("input",{type:re,value:K??"",placeholder:Z,onChange:ye=>{const xe=ye.target.value;ae(re==="number"?xe===""?void 0:Number(xe):xe);const pe=ye.target.selectionStart??0;if(re==="text"&&pe>=2&&xe.slice(pe-2,pe)==="${"){const ue=ye.target.getBoundingClientRect();q(ue),A(()=>Te=>{const Pe=xe.slice(0,pe-2),Re=xe.slice(pe);ae(Pe+Te+Re)}),j(!0)}},disabled:!ee,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",outline:"none"}})]}),te=(C,K,ae,re)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:C}),o.jsx("select",{value:ae,onChange:Z=>re(Z.target.value),disabled:!ee,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",outline:"none",cursor:"pointer"},children:K.map(Z=>o.jsx("option",{value:Z,children:Z},Z))})]}),de=(C,K,ae)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("span",{style:{fontSize:"11px",color:ce},children:C}),o.jsx("button",{onClick:()=>ae(!K),disabled:!ee,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:K?"var(--color-accent)":ne,position:"relative",transition:"background 0.2s"},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:K?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),G=(C,K,ae)=>o.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:C.map(re=>o.jsx("button",{onClick:()=>ae(re.key),disabled:!ee,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${ne}`,cursor:"pointer",fontSize:"11px",fontWeight:K===re.key?"bold":"normal",background:K===re.key?"var(--color-accent)":_e,color:K===re.key?"#fff":me},children:re.label},re.key))}),le=W.inputParameters?.http_request||W.httpRequest||{};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`detail-panel-container ${ke}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${ne}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[o.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${ne}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:W.type||"TASK"}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:me,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),ee?o.jsx("input",{value:W.name||"",onChange:C=>he("name",C.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:me,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):o.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:W.name}),o.jsxs("div",{style:{fontSize:"12px",color:ce,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",W.taskReferenceName]})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[W.type==="HTTP"&&Ee("HTTP 请求配置","🌐","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[o.jsx("select",{value:le.method||"GET",onChange:C=>Se("method",C.target.value),disabled:!ee,style:{width:"90px",padding:"10px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(C=>o.jsx("option",{value:C,children:C},C))}),o.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:le.uri||"",onChange:C=>Se("uri",C.target.value),disabled:!ee,style:{flex:1,padding:"10px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"CONTENT-TYPE"}),o.jsx("input",{placeholder:"application/json",value:le.contentType||"",onChange:C=>Se("contentType",C.target.value),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"ACCEPT"}),o.jsx("input",{placeholder:"application/json",value:le.accept||"",onChange:C=>Se("accept",C.target.value),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"连接超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:le.connectionTimeOut??"",onChange:C=>Se("connectionTimeOut",C.target.value===""?void 0:Number(C.target.value)),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"读取超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:le.readTimeOut??"",onChange:C=>Se("readTimeOut",C.target.value===""?void 0:Number(C.target.value)),disabled:!ee,style:{width:"100%",padding:"8px",borderRadius:"6px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"HEADERS (JSON)"}),o.jsx("textarea",{value:typeof le.headers=="object"?JSON.stringify(le.headers,null,2):"{}",onChange:C=>{try{Se("headers",JSON.parse(C.target.value))}catch{}},disabled:!ee,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"11px",fontFamily:"monospace"}})]}),o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),o.jsx("textarea",{value:typeof le.body=="object"?JSON.stringify(le.body,null,2):le.body||"",onChange:C=>{let K=C.target.value;try{K=JSON.parse(C.target.value)}catch{}Se("body",K)},disabled:!ee,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:_e,color:me,border:`1px solid ${ne}`,fontSize:"11px",fontFamily:"monospace"}})]})),(W.type==="INLINE"||W.type==="LAMBDA")&&Ee("内联脚本配置 (Inline)","📜","var(--color-accent)",o.jsxs(o.Fragment,{children:[te("脚本引擎",["graaljs","javascript","value-param","python"],W.evaluatorType||"graaljs",C=>he("evaluatorType",C)),Q(`EXPRESSION ${W.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,W.inputParameters?.expression||W.inputParameters?.scriptExpression||"",C=>{const K=W.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";ge(K,C)},{rows:10,language:W.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ce,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),W.type==="JSON_JQ_TRANSFORM"&&Ee("JQ 数据转换","🔍","var(--color-accent)",o.jsxs(o.Fragment,{children:[Q("JQ QUERY EXPRESSION",W.inputParameters?.queryExpression||"",C=>ge("queryExpression",C),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ce},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),W.type==="SUB_WORKFLOW"&&Ee("子工作流配置","🏗️","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("WORKFLOW NAME *",W.subWorkflowParam?.name||"",C=>Fe("subWorkflowParam","name",C),"text","e.g. my_workflow"),X("VERSION",W.subWorkflowParam?.version??"",C=>Fe("subWorkflowParam","version",C?parseInt(C):void 0),"number","1"),Q("INPUT PARAMETERS MAPPING (JSON)",typeof W.inputParameters=="object"&&W.inputParameters!==null?JSON.stringify(W.inputParameters,null,2):"{}",C=>{try{he("inputParameters",JSON.parse(C))}catch{}},{rows:5,language:"json"}),o.jsxs("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),W.type==="START_WORKFLOW"&&Ee("启动工作流配置","▶️","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",o.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),X("WORKFLOW NAME *",W.inputParameters?.startWorkflow?.name||"",C=>{const K={...W.inputParameters?.startWorkflow||{},name:C};ge("startWorkflow",K)},"text","e.g. target_workflow"),X("VERSION",W.inputParameters?.startWorkflow?.version??"",C=>{const K={...W.inputParameters?.startWorkflow||{},version:C?parseInt(C):void 0};ge("startWorkflow",K)},"number","1"),X("CORRELATION ID",W.inputParameters?.startWorkflow?.correlationId||"",C=>{const K={...W.inputParameters?.startWorkflow||{},correlationId:C};ge("startWorkflow",K)},"text","${workflow.correlationId}"),Q("WORKFLOW INPUT (JSON)",typeof W.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(W.inputParameters.startWorkflow.input,null,2):"{}",C=>{try{const K={...W.inputParameters?.startWorkflow||{},input:JSON.parse(C)};ge("startWorkflow",K)}catch{}},{rows:4,language:"json"})]})),W.type==="TERMINATE"&&Ee("终止状态配置","⏹️","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"TERMINATION STATUS"}),o.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(C=>o.jsx("button",{onClick:()=>ge("terminationStatus",C),disabled:!ee,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(W.inputParameters?.terminationStatus||"COMPLETED")===C?"var(--color-accent)":_e,color:(W.inputParameters?.terminationStatus||"COMPLETED")===C?"#fff":me,border:`1px solid ${ne}`,fontWeight:"bold",fontSize:"11px"},children:C},C))}),X("TERMINATION REASON",W.inputParameters?.terminationReason||"",C=>ge("terminationReason",C),"text","终止原因..."),Q("WORKFLOW OUTPUT (JSON)",typeof W.inputParameters?.workflowOutput=="object"?JSON.stringify(W.inputParameters.workflowOutput,null,2):"{}",C=>{try{ge("workflowOutput",JSON.parse(C))}catch{}},{rows:3,language:"json"})]})),W.type==="EVENT"&&Ee("事件发送配置","✉️","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("EVENT SINK *",W.sink||"",C=>he("sink",C),"text","e.g. sqs:queue_name 或 conductor"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),de("异步完成 (asyncComplete)",!!W.asyncComplete,C=>he("asyncComplete",C))]})),W.type==="WAIT"&&Ee("等待状态配置","⏳","var(--color-accent)",o.jsxs(o.Fragment,{children:[G([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],w,C=>T(C)),w==="duration"?X("DURATION",W.inputParameters?.duration||"",C=>ge("duration",C),"text","e.g. 30s, 10m, 2 hours"):X("UNTIL (时间点)",W.inputParameters?.until||"",C=>ge("until",C),"text","e.g. 2025-06-15 09:00 GMT+00:00"),o.jsxs("div",{style:{fontSize:"11px",color:ce,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",o.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(W.type==="DECISION"||W.type==="SWITCH")&&Ee("条件分支配置","⚖️","var(--color-accent)",o.jsxs(o.Fragment,{children:[te("评估模式 (evaluatorType)",["value-param","javascript"],W.evaluatorType||"value-param",C=>he("evaluatorType",C)),(W.evaluatorType||"value-param")==="value-param"?X("CASE VALUE PARAM (参数名)",W.caseValueParam||"",C=>he("caseValueParam",C),"text","e.g. status"):o.jsx(o.Fragment,{children:Q("CASE EXPRESSION (JS)",W.caseExpression||"",C=>he("caseExpression",C),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),W.type==="DO_WHILE"&&Ee("循环逻辑配置","🔄","var(--color-accent)",o.jsxs(o.Fragment,{children:[G([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],O,C=>D(C)),O==="condition"?o.jsxs(o.Fragment,{children:[Q("LOOP CONDITION (JS) *",W.loopCondition||"",C=>he("loopCondition",C),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),o.jsx("input",{value:W.inputParameters?.items||"",onChange:C=>ge("items",C.target.value),disabled:!ee,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${ne}`,background:_e,color:me,fontSize:"12px",outline:"none"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),o.jsx("div",{style:{marginTop:"12px"},children:X("KEEP LAST N 次迭代",W.keepLastN??"",C=>he("keepLastN",C?parseInt(C):void 0),"number","0 = 保留全部")})]})),W.type==="FORK_JOIN_DYNAMIC"&&Ee("动态并行配置","⚡","var(--color-accent)",o.jsxs(o.Fragment,{children:[G([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],N,C=>S(C)),N==="classic"&&o.jsxs(o.Fragment,{children:[X("DYNAMIC_FORK_TASKS_PARAM",W.dynamicForkTasksParam||"",C=>he("dynamicForkTasksParam",C),"text","e.g. dynamic_tasks"),X("DYNAMIC_FORK_TASKS_INPUT_PARAM",W.dynamicForkTasksInputParamName||"",C=>he("dynamicForkTasksInputParamName",C),"text","e.g. input"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),N==="task"&&o.jsxs(o.Fragment,{children:[X("FORK TASK TYPE *",W.forkTaskType||"",C=>he("forkTaskType",C),"text","e.g. HTTP"),X("FORK TASK NAME (仅 SIMPLE 任务)",W.forkTaskName||"",C=>he("forkTaskName",C),"text","e.g. my_task"),X("FORK TASK INPUTS PARAM",W.forkTaskInputs||"",C=>he("forkTaskInputs",C),"text","e.g. inputs"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),N==="workflow"&&o.jsxs(o.Fragment,{children:[X("FORK WORKFLOW NAME *",W.forkTaskWorkflow||"",C=>he("forkTaskWorkflow",C),"text","e.g. sub_workflow"),X("WORKFLOW VERSION",W.forkTaskWorkflowVersion||"",C=>he("forkTaskWorkflowVersion",C),"text","1"),X("FORK TASK INPUTS PARAM",W.forkTaskInputs||"",C=>he("forkTaskInputs",C),"text","e.g. inputs"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),W.type==="DYNAMIC"&&Ee("动态任务配置","🎯","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("DYNAMIC TASK NAME PARAM *",W.dynamicTaskNameParam||"",C=>he("dynamicTaskNameParam",C),"text","e.g. taskToExecute"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),W.type==="HUMAN"&&Ee("人工审批配置","👤","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("表单模板名 (userFormTemplate)",W.humanTaskDef?.userFormTemplate||"",C=>Fe("humanTaskDef","userFormTemplate",C),"text","e.g. approval_form"),te("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],W.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",C=>Fe("humanTaskDef","assignmentCompletionStrategy",C)),X("显示名称 (displayName)",W.humanTaskDef?.displayName||"",C=>Fe("humanTaskDef","displayName",C),"text","审批任务")]})),W.type==="KAFKA_PUBLISH"&&Ee("Kafka 推送配置","📨","var(--color-accent)",o.jsxs(o.Fragment,{children:[X("BOOTSTRAP SERVERS *",W.inputParameters?.bootStrapServers||"",C=>ge("bootStrapServers",C),"text","localhost:9092"),X("TOPIC *",W.inputParameters?.topic||"",C=>ge("topic",C),"text","my_topic"),X("KEY (消息分区键)",W.inputParameters?.key||"",C=>ge("key",C),"text",""),Q("VALUE (消息内容)",typeof W.inputParameters?.value=="object"?JSON.stringify(W.inputParameters.value,null,2):W.inputParameters?.value||"",C=>{let K=C;try{K=JSON.parse(C)}catch{}ge("value",K)},{rows:4,language:"json"}),Q("HEADERS (JSON)",typeof W.inputParameters?.headers=="object"?JSON.stringify(W.inputParameters.headers,null,2):"{}",C=>{try{ge("headers",JSON.parse(C))}catch{}},{rows:3,language:"json"})]})),W.type==="SET_VARIABLE"&&Ee("变量配置","📦","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),Q("VARIABLES (JSON)",typeof W.inputParameters=="object"&&W.inputParameters!==null?JSON.stringify(W.inputParameters,null,2):"{}",C=>{try{he("inputParameters",JSON.parse(C))}catch{}},{rows:6,language:"json"})]})),o.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${ne}`,paddingTop:"24px"},children:[o.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),rt("任务唯一引用名 (Reference Name)","taskReferenceName"),u&&u.newRef===W.taskReferenceName&&o.jsxs("div",{style:{marginBottom:"16px",padding:"10px 12px",borderRadius:"8px",background:"rgba(16, 185, 129, 0.12)",border:"1px solid rgba(16, 185, 129, 0.35)",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[o.jsxs("div",{style:{fontSize:"11px",color:"#34d399",lineHeight:1.5},children:[o.jsx("b",{children:"🔗 W-LSP 全图级联重构已生效"}),o.jsx("br",{}),"引用名 ",o.jsx("code",{children:u.oldRef})," → ",o.jsx("code",{children:u.newRef}),",已自动同步 ",o.jsx("b",{children:u.replacedCount})," 处下游表达式(涉及节点:",u.affectedTasks.join(", "),")"]}),o.jsx("button",{onClick:f,style:{background:"none",border:"none",color:"#34d399",cursor:"pointer",fontSize:"12px",padding:"2px"},children:"✕"})]}),rt("任务描述","description"),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[o.jsxs("label",{style:{fontSize:"11px",color:ce,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",o.jsxs("span",{style:{opacity:.5,fontWeight:"normal"},children:["(JSON / 输入 $","{"," 自动补全)"]})]}),ee&&o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:C=>{const K=C.currentTarget.getBoundingClientRect();q(K),A(()=>ae=>{if(k)Qe(ae);else{const re=typeof W.inputParameters=="object"&&W.inputParameters!==null?{...W.inputParameters}:{};re[`param_${Object.keys(re).length+1}`]=ae,he("inputParameters",re)}}),j(!0)},title:"打开 W-LSP 上游变量与 Schema 零延迟补全器",style:{fontSize:"11px",background:"rgba(56, 189, 248, 0.14)",border:"1px solid rgba(56, 189, 248, 0.35)",borderRadius:"4px",padding:"2px 8px",cursor:"pointer",color:"#38bdf8",fontWeight:600,display:"flex",alignItems:"center",gap:"4px"},children:"⚡ 变量补全"}),o.jsxs("button",{onClick:fe,disabled:L,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:L?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:L?.7:1},children:[L?"⏳":"✨"," AI 填充"]}),o.jsxs("button",{onClick:()=>b(!y),title:"快捷表达式",style:{fontSize:"11px",background:y?"var(--color-accent)":"none",border:`1px solid ${ne}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:y?"#fff":ce},children:["{}"," 片段"]})]})]}),y&&o.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${ne}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:f1.map(C=>o.jsx("button",{onClick:()=>Qe(C.value),title:C.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${ne}`,background:_e,color:me,cursor:"pointer",fontFamily:"monospace"},children:C.label},C.value))}),z&&o.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:()=>{he("inputParameters",z.generated),H(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),o.jsx("button",{onClick:()=>H(null),style:{fontSize:"11px",background:"none",color:ce,border:`1px solid ${ne}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),o.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:me,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(z.generated,null,2)})]}),Q("",typeof W.inputParameters=="object"&&W.inputParameters!==null?JSON.stringify(W.inputParameters,null,2):W.inputParameters??"",C=>{try{he("inputParameters",JSON.parse(C))}catch{p(K=>({...K,inputParameters:C}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[rt("重试次数","retryCount","number"),rt("超时限制 (秒)","timeoutSeconds","number")]}),o.jsxs("details",{style:{marginTop:"16px"},children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:ce,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),o.jsxs("div",{style:{marginTop:"12px"},children:[te("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],W.retryLogic||"FIXED",C=>he("retryLogic",C)),X("重试延迟 (秒)",W.retryDelaySeconds??"",C=>he("retryDelaySeconds",C?parseInt(C):void 0),"number","0"),te("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],W.timeoutPolicy||"TIME_OUT_WF",C=>he("timeoutPolicy",C)),X("启动延迟 (秒)",W.startDelay??"",C=>he("startDelay",C?parseInt(C):void 0),"number","0"),de("可选任务 (optional) — 失败不影响工作流",!!W.optional,C=>he("optional",C)),de("异步完成 (asyncComplete)",!!W.asyncComplete,C=>he("asyncComplete",C))]})]})]}),o.jsx("div",{style:{marginTop:"48px",opacity:.6},children:o.jsxs("details",{children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),o.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${ne}`,color:ce},children:JSON.stringify(W,null,2)})]})})]}),ee&&o.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${ne}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[o.jsx("div",{style:{flex:1,fontSize:"11px",color:ce,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),o.jsx("button",{onClick:r,style:{padding:"10px 24px",background:"var(--color-accent)",color:"#fff",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),o.jsx(d1,{isOpen:R,onClose:()=>j(!1),onSelect:V,suggestions:$,wlspItems:P,anchorRect:E})]}),U&&o.jsx(u1,{title:U.title,value:U.value,language:U.language,onSave:U.onSave,onClose:()=>se(null)})]})},h1=I.memo(p1),Om=({keyName:e,value:t,path:r,depth:n,defaultExpanded:s,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:d})=>{const u=t!==null&&typeof t=="object",f=Array.isArray(t),[h,p]=I.useState(s),m=a!==null?a:h,g=d(r);if(!I.useMemo(()=>{if(!i.trim())return!0;const _=i.toLowerCase();if(e!==void 0&&String(e).toLowerCase().includes(_))return!0;try{return JSON.stringify(t).toLowerCase().includes(_)}catch{return!1}},[e,t,i]))return null;if(!u){let _="#e2e8f0",w=String(t);return typeof t=="string"?(_="#34d399",w=`"${t}"`):typeof t=="number"?_="#fbbf24":typeof t=="boolean"?_="#f472b6":t==null&&(_="#94a3b8",w="null"),o.jsxs("div",{className:"sjson-row",style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",borderRadius:"4px",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{wordBreak:"break-all",lineHeight:1.45},children:[e!==void 0&&o.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"#64748b"},children:": "})]}),o.jsx("span",{style:{color:_},children:w})]}),g&&o.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),l(g)},title:`复制表达式 ${g}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.3)",background:c===g?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.08)",color:c===g?"#34d399":"#38bdf8",cursor:"pointer",opacity:.85,fontFamily:"inherit"},children:c===g?"✓ 已复制":"${} 引用"})]})}const v=f?t.map((_,w)=>[w,_]):Object.entries(t),y=f?"[":"{",b=f?"]":"}",k=f?`${v.length} items`:`${v.length} keys`;return o.jsxs("div",{children:[o.jsxs("div",{onClick:()=>p(!m),style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",cursor:"pointer",userSelect:"none",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{style:{fontSize:"9px",color:"#64748b",width:"10px",display:"inline-block"},children:m?"▼":"▶"}),e!==void 0&&o.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"#64748b"},children:": "})]}),o.jsxs("span",{style:{color:"#94a3b8"},children:[y,!m&&o.jsx("span",{style:{fontSize:"10px",color:"#64748b",margin:"0 4px"},children:k}),!m&&b]})]}),g&&r&&o.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),l(g)},title:`复制对象引用 ${g}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.25)",background:c===g?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.06)",color:c===g?"#34d399":"#38bdf8",cursor:"pointer",opacity:.75,fontFamily:"inherit"},children:c===g?"✓ 已复制":"${} 引用"})]}),m&&o.jsxs("div",{children:[v.map(([_,w])=>{const T=typeof _=="number"?`${r}[${_}]`:r?`${r}.${_}`:String(_);return o.jsx(Om,{keyName:_,value:w,path:T,depth:n+1,defaultExpanded:n<1,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:d},String(_))}),o.jsx("div",{style:{paddingLeft:`${n*14+14}px`,color:"#94a3b8",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:b})]})]})},Pm=({data:e,taskReferenceName:t,expressionScope:r="output",maxHeight:n="420px"})=>{const[s,a]=I.useState(""),[i,l]=I.useState(null),[c,d]=I.useState(null),[u,f]=I.useState(!1),h=g=>g?r==="workflow.input"?`\${workflow.input.${g}}`:t?`\${${t}.${r}.${g}}`:null:null,p=g=>{navigator.clipboard.writeText(g),d(g),setTimeout(()=>d(null),1600)};return e==null||typeof e=="object"&&Object.keys(e).length===0?o.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-secondary)",fontSize:"12px",background:"rgba(15, 23, 42, 0.35)",borderRadius:"8px",border:"1px solid var(--border-primary)"},children:"暂无数据 (Empty Payload)"}):o.jsxs("div",{style:{borderRadius:"8px",border:"1px solid var(--border-primary)",background:"rgba(15, 23, 42, 0.55)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:"1px solid rgba(148, 163, 184, 0.14)",background:"rgba(15, 23, 42, 0.4)"},children:[o.jsx("input",{type:"text",value:s,onChange:g=>a(g.target.value),placeholder:"🔍 检索字段名或值...",style:{flex:1,padding:"4px 8px",borderRadius:"5px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(2, 6, 23, 0.5)",color:"#f8fafc",fontSize:"11px",outline:"none"}}),o.jsx("button",{type:"button",onClick:()=>l(!0),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"全部展开"}),o.jsx("button",{type:"button",onClick:()=>l(!1),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"折叠"}),o.jsx("button",{type:"button",onClick:()=>f(!u),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:u?"rgba(56, 189, 248, 0.18)":"transparent",color:u?"#38bdf8":"#cbd5e1",cursor:"pointer"},children:u?"树形视图":"RAW"})]}),o.jsx("div",{style:{padding:"10px 12px",maxHeight:n,overflowY:"auto",overflowX:"auto"},children:u?o.jsx("pre",{style:{margin:0,fontSize:"11px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",color:"#e2e8f0",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e,null,2)}):o.jsx(Om,{value:e,path:"",depth:0,defaultExpanded:!0,forceExpandAll:i,searchQuery:s,onCopyExpr:p,copiedPath:c,buildExpr:h})})]})},m1={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},$t=e=>m1[e??""]??"var(--text-secondary)",g1=(e,t)=>{if(!e)return"-";const r=(t??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},Am=e=>e?new Date(e).toLocaleTimeString():"-",y1=({executionActions:e})=>{const{selectedTask:t,selectedTaskInstance:r,setSelectedTask:n,setSelectedTaskInstance:s,executionData:a,workflowInstance:i}=oe(),[l,c]=I.useState("summary"),d=I.useRef(null);I.useEffect(()=>{d.current?.scrollTo({top:0})},[l,t?.taskReferenceName]),I.useEffect(()=>{c("summary")},[t?.taskReferenceName]);const u=t?.taskReferenceName==="__workflow_global__",f=t?a?.[t.taskReferenceName]:null;if(!t||!f&&!u)return null;const h=f?.attempts??[],p=r??h[h.length-1],m=i?.workflowId??"",g=i?.status,x=f?.status,v=u?g:p?.status??x,y=u?i?.startTime:p?.startTime,b=u?i?.endTime:p?.endTime,k=u?i?.reasonForIncompletion:p?.reasonForIncompletion,_=u?i?.workflowId:p?.taskId,w=u?i?.input:p?.inputData,T=u?i?.output:p?.outputData,O=!u&&e?.onSkipTask&&(x==="SCHEDULED"||x==="IN_PROGRESS")&&(g==="RUNNING"||g==="PAUSED"),D=!u&&e?.onRerunFromTask&&(g==="FAILED"||g==="TERMINATED"||g==="COMPLETED"||g==="TIMED_OUT"),N=O||D,S=e?.allowOperations!==!1,R=()=>{n(null),s(null)},j="var(--glass-border)",E="var(--text-secondary)",q="var(--bg-tertiary)";return o.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${j}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:u?"WORKFLOW":t.type||"TASK"}),v&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${$t(v)}18`,color:$t(v),letterSpacing:"0.5px",flexShrink:0},children:["● ",v]}),o.jsx("div",{style:{flex:1}}),o.jsx("button",{onClick:R,style:{background:"none",border:"none",color:E,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),o.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:u?"工作流全局数据":t.name}),o.jsxs("div",{style:{fontSize:12,color:E,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",t.taskReferenceName]})]}),h.length>1&&o.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:E,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",h.length," 次",h.some($=>$.iteration)?" / 迭代":"尝试",")"]}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:h.map(($,J)=>{const V=p?.taskId===$.taskId;return o.jsx("button",{onClick:()=>s($),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${V?"var(--color-accent)":j}`,background:V?"var(--color-accent)":"var(--bg-tertiary)",color:V?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:$.iteration?`迭代 ${$.iteration}`:`尝试 ${J+1}`},$.taskId)})})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${j}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map($=>{const J={summary:"概览",input:"输入 JSON",output:"输出 JSON"},V=l===$;return o.jsx("button",{onClick:()=>c($),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${V?"var(--color-accent)":"transparent"}`,color:V?"var(--color-accent)":E,cursor:"pointer",fontSize:13,fontWeight:V?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:J[$]},$)})}),o.jsxs("div",{ref:d,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[l==="summary"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:g1(y,b)},{label:"开始时间",value:Am(y)},{label:"结束时间",value:Am(b)},{label:u?"Workflow ID":"Task ID",value:o.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:_??"-"})}].map(({label:$,value:J})=>o.jsxs("div",{style:{padding:"12px 14px",background:q,borderRadius:10,border:`1px solid ${j}`},children:[o.jsx("div",{style:{fontSize:10,color:E,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:$}),o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:J})]},$))}),h.length>1&&o.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${$t(x)}10`,border:`1px solid ${$t(x)}30`,borderRadius:8,fontSize:12,color:$t(x),display:"flex",alignItems:"center",gap:8},children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("path",{d:"M13 2v4h-4"}),o.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",h.length-1," 次,共 ",h.length," 次尝试"]}),!u&&p?.workerId&&o.jsxs("div",{style:{marginBottom:20},children:[o.jsx("div",{style:{fontSize:10,color:E,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),o.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:p.workerId})]}),k&&o.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[o.jsx("strong",{children:"异常信息"}),o.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),N&&o.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${j}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,color:E,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!S&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6"}),o.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),o.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[D&&o.jsxs("button",{disabled:!S,onClick:()=>S&&e.onRerunFromTask(m,t.taskReferenceName,p?.taskId),title:S?`从任务 ${t.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:S?ct:Lm,onMouseEnter:$=>!S||Object.assign($.currentTarget.style,x1),onMouseLeave:$=>!S||Object.assign($.currentTarget.style,ct),children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("path",{d:"M3 14v-4h4"}),o.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),O&&o.jsxs("button",{disabled:!S,onClick:()=>S&&e.onSkipTask(m,t.taskReferenceName,p?.taskId),title:S?`跳过任务 ${t.taskReferenceName}`:"操作权限受限",style:S?ct:Lm,onMouseEnter:$=>!S||Object.assign($.currentTarget.style,v1),onMouseLeave:$=>!S||Object.assign($.currentTarget.style,ct),children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:o.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),l==="input"&&o.jsx(Pm,{data:w,taskReferenceName:u?void 0:t.taskReferenceName,expressionScope:u?"workflow.input":"input",maxHeight:"calc(100vh - 280px)"}),l==="output"&&o.jsx(Pm,{data:T,taskReferenceName:u?void 0:t.taskReferenceName,expressionScope:"output",maxHeight:"calc(100vh - 280px)"})]})]})},ct={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},x1={...ct,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},v1={...ct,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Lm={...ct,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},b1={add:"新增",mod:"修改",del:"删除",replace:"替换"},k1={add:"+",mod:"~",del:"−"};function S1({diff:e,applied:t,onApply:r,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return o.jsxs("div",{className:"diff-card",children:[o.jsxs("div",{className:"diff-head",children:[o.jsx("span",{className:`diff-badge ${s}`,children:b1[e.kind]??e.kind}),o.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&o.jsx("div",{className:"diff-list",children:e.rows.map((a,i)=>o.jsxs("div",{className:`diff-row ${a.kind}`,children:[o.jsx("div",{className:"diff-marker",children:k1[a.kind]??"·"}),o.jsx("div",{className:"diff-desc",children:a.desc})]},i))}),o.jsx("div",{className:"diff-actions",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),o.jsxs("button",{className:"diff-btn undo",onClick:n,children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),o.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):o.jsxs("button",{className:"diff-btn apply",onClick:r,children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Dm(e,t){const r=JSON.parse(JSON.stringify(e));if(t.kind==="replace"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(t.kind==="add"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!t.patch)return{next:r,inverse:{kind:t.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const a of t.patch)if(a.op==="patchTask"){const i=r.tasks.find(c=>c.taskReferenceName===a.ref);if(!i)continue;const l={};for(const c of Object.keys(a.set))l[c]=i[c];Object.assign(i,a.set),n.push({op:"patchTask",ref:a.ref,set:l}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")r.edges=r.edges??[],r.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")r.edges=(r.edges??[]).filter(i=>!(i.from===a.from&&i.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")r.tasks.push(a.task),r.edges=r.edges??[],a.removeEdges&&a.removeEdges.forEach(i=>{r.edges=r.edges.filter(l=>!(l.from===i.from&&l.to===i.to))}),a.extraEdges&&a.extraEdges.forEach(i=>r.edges.push(i)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const i=r.tasks.findIndex(d=>d.taskReferenceName===a.ref);if(i<0)continue;const[l]=r.tasks.splice(i,1),c=(r.edges??[]).filter(d=>d.from===a.ref||d.to===a.ref);r.edges=(r.edges??[]).filter(d=>d.from!==a.ref&&d.to!==a.ref),n.push({op:"addTask",task:l,extraEdges:c}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.findIndex(l=>l.from===a.after&&l.to===a.edgeTo);i>=0&&r.edges.splice(i,1),r.edges.push({from:a.after,to:a.task.taskReferenceName}),r.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.filter(l=>l.to===a.before);r.edges=r.edges.filter(l=>l.to!==a.before),i.forEach(l=>r.edges.push({from:l.from,to:a.task.taskReferenceName,label:l.label})),r.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:t.kind,summary:`撤销:${t.summary}`,rows:s,patch:n.reverse()}}}function _1(e){const t=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!t)return null;try{const r=JSON.parse(t[1]);return!r.kind||!r.summary?null:r}catch{return null}}const Mm={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},qm=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),a=s.indexOf(`
128
+ `),i=a>=0?s.slice(a+1):s;return o.jsx("pre",{children:o.jsx("code",{children:i})},n)}return o.jsx("span",{children:w1(r)},n)}),w1=e=>{const t=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,s;for(;(s=r.exec(e))!==null;){s.index>n&&t.push(e.slice(n,s.index));const a=s[0];a.startsWith("**")&&a.endsWith("**")?t.push(o.jsx("strong",{children:a.slice(2,-2)},s.index)):a.startsWith("`")&&a.endsWith("`")?t.push(o.jsx("code",{children:a.slice(1,-1)},s.index)):a===`
129
+ `&&t.push(o.jsx("br",{},s.index)),n=s.index+a.length}return n<e.length&&t.push(e.slice(n)),t},T1=({aiConfig:e})=>{const{workflowDef:t,setWorkflow:r,mode:n}=oe(),[s,a]=I.useState(!1),[i,l]=I.useState(""),[c,d]=I.useState(!1),[u,f]=I.useState([Mm]),[h,p]=I.useState(""),[m,g]=I.useState(null),x=I.useRef(null),v=I.useRef(null),y=I.useRef(null),b=I.useCallback(E=>{if(!E.diff||E.applied||!t)return;const{next:q,inverse:$}=Dm(t,E.diff);r(q),f(J=>J.map(V=>V.id===E.id?{...V,applied:!0,inverse:$}:V))},[t,r]),k=I.useCallback(E=>{if(!E.inverse||!E.applied||!t)return;const{next:q}=Dm(t,E.inverse);r(q),f($=>$.map(J=>J.id===E.id?{...J,applied:!1,inverse:void 0}:J))},[t,r]),_=()=>{const E=v.current;E&&(E.style.height="auto",E.style.height=Math.min(E.scrollHeight,120)+"px")},w=()=>{const E=v.current;E&&(E.style.height="auto")};I.useEffect(()=>()=>{y.current?.abort()},[]),I.useEffect(()=>{const E=()=>a(!0);return window.addEventListener("open-ai-chat",E),()=>window.removeEventListener("open-ai-chat",E)},[]);const T=()=>{x.current?.scrollIntoView({behavior:"smooth"})};I.useEffect(()=>{s&&T()},[u,s,h]);const O=I.useCallback(E=>{const q=[{role:"system",content:t1}];for(const J of u)J.role==="user"&&J.content?q.push({role:"user",content:J.content}):J.role==="ai"&&J.content&&!J.thinking&&q.push({role:"assistant",content:J.content});const $=i1(E,t);return q.push({role:"user",content:$}),q},[u,t]),D=async E=>{const q=i.trim();if(!q||c)return;y.current?.abort();const $=new AbortController;y.current=$;const J={id:Date.now().toString(),role:"user",content:q};f(V=>[...V,J]),l(""),w(),d(!0),p("");try{const V=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",A=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",B=e?.model||localStorage.getItem("AI_MODEL")||"";if(!V){setTimeout(()=>{if($.signal.aborted)return;const H={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},Y={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:H}};f(ie=>[...ie,Y]),d(!1)},800);return}const P={apiKey:V};A&&(P.baseUrl=A),B&&(P.model=B);const U=O(q),se=await Qb(U,P,H=>{p(Y=>Y+H)},()=>{},$.signal);let F=_1(se);if(!F){const H=se.match(/```json\n([\s\S]*?)\n```/);if(H)try{const Y=JSON.parse(H[1]);F={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:Y}}catch{}}const z={id:(Date.now()+1).toString(),role:"ai",content:se,diff:F??void 0,applied:!1};f(H=>[...H,z]),p("")}catch(V){if(V.name==="AbortError")p(A=>{if(A){const B={id:(Date.now()+1).toString(),role:"ai",content:A};f(P=>[...P,B])}return""});else{const A={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${V.message}`};f(B=>[...B,A]),p("")}}finally{d(!1)}},N=()=>{y.current?.abort()},S=()=>{y.current?.abort(),f([Mm]),p(""),d(!1)},R=E=>{navigator.clipboard.writeText(E.content??""),g(E.id),setTimeout(()=>g(null),1500)},j=E=>{E.nativeEvent.isComposing||E.keyCode===229||E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),D())};return n!=="edit"?null:s?o.jsxs("div",{className:"ai-chat-panel",children:[o.jsxs("div",{className:"ai-header",children:[o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),o.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[o.jsx("button",{className:"ai-close",onClick:S,title:"清空对话",children:"🗑"}),o.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),o.jsxs("div",{className:"ai-messages",children:[u.map(E=>o.jsxs("div",{className:`message ${E.role}`,children:[o.jsx("div",{className:"message-content",children:E.thinking?o.jsxs("div",{className:"thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):E.role==="ai"?qm(E.content??""):E.content}),E.diff&&!E.thinking&&o.jsx(S1,{diff:E.diff,applied:E.applied??!1,onApply:()=>b(E),onUndo:()=>k(E)}),E.role==="ai"&&E.content&&o.jsx("button",{className:"copy-btn",onClick:()=>R(E),title:"复制",children:m===E.id?"✓":"📋"})]},E.id)),c&&h&&o.jsxs("div",{className:"message ai",style:{opacity:.9},children:[o.jsx("div",{className:"message-content",children:qm(h)}),o.jsx("span",{className:"streaming-cursor",children:"▊"})]}),c&&!h&&o.jsxs("div",{className:"message ai thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),o.jsx("div",{ref:x})]}),o.jsx("div",{className:"ai-input-area",children:o.jsxs("div",{className:"ai-input-container",children:[o.jsx("textarea",{ref:v,className:"ai-input",placeholder:c?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:E=>l(E.target.value),onInput:_,onKeyDown:j,disabled:c,rows:2}),c?o.jsx("button",{className:"ai-send stop",onClick:N,title:"停止生成",children:"⏹"}):o.jsx("button",{className:"ai-send",onClick:()=>D(),title:"发送",children:"🚀"})]})})]}):o.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:o.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},E1=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),N1=({onTriggerExecution:e,onPollExecution:t,executionPollInterval:r=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:a,setRunState:i,importExecutionJSON:l,setMode:c}=oe(),[d,u]=I.useState("form"),[f,h]=I.useState({}),[p,m]=I.useState("{}"),[g,x]=I.useState(""),[v,y]=I.useState(!1),[b,k]=I.useState(""),_=At(n?.inputParameters);I.useEffect(()=>{s&&(h({}),m("{}"),x(""),k(""),y(!1))},[s]);const w=I.useCallback(()=>{try{const S={};_.forEach(R=>{const j=f[R.name];if(j!==void 0&&j!=="")if(R.type==="number")S[R.name]=Number(j);else if(R.type==="boolean")S[R.name]=j==="true";else if(R.type==="object"||R.type==="array")try{S[R.name]=JSON.parse(j)}catch{S[R.name]=j}else S[R.name]=j;else R.defaultValue!==void 0&&(S[R.name]=R.defaultValue)}),m(JSON.stringify(S,null,2))}catch{}u("json")},[f,_]),T=I.useCallback(()=>{try{const S=JSON.parse(p),R={};_.forEach(j=>{const E=S[j.name];E!==void 0&&(R[j.name]=typeof E=="object"?JSON.stringify(E,null,2):String(E))}),h(R),x("")}catch{x("JSON 格式有误,无法切换为表单模式")}u("form")},[p,_]),O=I.useCallback(()=>{if(d==="json")try{return JSON.parse(p)}catch{return x("JSON 格式有误,请检查后重试"),null}const S={};return _.forEach(R=>{const j=f[R.name]??(R.defaultValue!==void 0?String(R.defaultValue):"");if(!(j===""&&!R.required))if(R.type==="number")S[R.name]=Number(j);else if(R.type==="boolean")S[R.name]=j==="true";else if(R.type==="object"||R.type==="array")try{S[R.name]=JSON.parse(j)}catch{S[R.name]=j}else S[R.name]=j}),S},[d,p,f,_]),D=I.useCallback(async()=>{if(!e||!n)return;const S=O();if(S===null)return;const R=_.filter(j=>j.required&&(S[j.name]===void 0||S[j.name]===""));if(R.length>0){k(`必填参数未填写:${R.map(j=>j.name).join(", ")}`);return}y(!0),k(""),i("triggering");try{const{workflowId:j}=await e(n.name,n.version??1,S);if(i("polling",j),a(!1),c("run"),!t)return;let E=r;const q=15e3;let $;const J=async()=>{try{const V=await t(j);if(V&&(l(V),E1.has(V.status))){i("done",j);return}}catch{}E=Math.min(E*1.5,q),$=setTimeout(J,E)};$=setTimeout(J,E),oe.getState().__pollTimer=$}catch(j){const E=j?.message||"执行触发失败,请检查配置后重试";i("error",null,E),k(E),y(!1)}},[e,t,n,O,_,i,a,l,c,r]);if(!s||!n)return null;const N=_.length>0;return o.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:o.jsxs("div",{className:"wrp-panel",onClick:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"wrp-header",children:[o.jsxs("div",{className:"wrp-header-title",children:[o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),o.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",o.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),o.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:"✕"})]}),o.jsxs("div",{className:"wrp-content",children:[o.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",N&&o.jsxs("div",{className:"wrp-mode-toggle",children:[o.jsx("button",{className:d==="form"?"active":"",onClick:d==="json"?T:void 0,children:"表单模式"}),o.jsx("button",{className:d==="json"?"active":"",onClick:d==="form"?w:void 0,children:"JSON 编辑器"})]})]}),!N&&d==="form"&&o.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",o.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),d==="form"?o.jsxs("div",{className:"wrp-form",children:[_.map(S=>o.jsxs("div",{className:"wrp-field",children:[o.jsxs("label",{className:"wrp-field-label",children:[S.name,S.required&&o.jsx("span",{className:"wrp-required",children:"*"}),S.type&&o.jsx("span",{className:"wrp-type",children:S.type})]}),S.description&&o.jsx("p",{className:"wrp-field-desc",children:S.description}),S.type==="object"||S.type==="array"?o.jsx("textarea",{className:"wrp-input",rows:3,placeholder:S.example?JSON.stringify(S.example,null,2):"{}",value:f[S.name]??"",onChange:R=>h(j=>({...j,[S.name]:R.target.value}))}):S.type==="boolean"?o.jsxs("select",{className:"wrp-input",value:f[S.name]??(S.defaultValue!==void 0?String(S.defaultValue):""),onChange:R=>h(j=>({...j,[S.name]:R.target.value})),children:[o.jsx("option",{value:"",children:"请选择"}),o.jsx("option",{value:"true",children:"true"}),o.jsx("option",{value:"false",children:"false"})]}):o.jsx("input",{className:"wrp-input",type:S.type==="number"?"number":"text",placeholder:S.example!==void 0?String(S.example):S.defaultValue!==void 0?String(S.defaultValue):"",value:f[S.name]??"",onChange:R=>h(j=>({...j,[S.name]:R.target.value}))})]},S.name)),!N&&o.jsx("button",{className:"wrp-switch-json",onClick:w,children:"切换为 JSON 编辑器手动填写"})]}):o.jsxs("div",{className:"wrp-json-editor",children:[o.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:p,onChange:S=>{m(S.target.value),x("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),g&&o.jsx("p",{className:"wrp-error",children:g})]}),b&&o.jsx("p",{className:"wrp-error wrp-submit-error",children:b})]}),o.jsxs("div",{className:"wrp-footer",children:[o.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?o.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:D,disabled:v,children:v?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):o.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},j1=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function C1(e,t){const r=t[e];if(!r)return[];const n=r.reasonForIncompletion||"";if(!n)return[];const s=[];for(const a of j1)a.pattern.test(n)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function I1(e,t){const r=Object.values(e).map(p=>{const m=p.startTime&&p.endTime?p.endTime-p.startTime:void 0,g=Math.max(0,(p.attempts?.length??1)-1);return{taskRef:p.taskReferenceName,status:p.status,startTime:p.startTime,endTime:p.endTime,durationMs:m,retryCount:g,reasonForIncompletion:p.reasonForIncompletion,diagnostics:C1(p.taskReferenceName,e)}}).sort((p,m)=>(p.startTime??0)-(m.startTime??0)),n=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=r.filter(p=>p.status==="COMPLETED"||p.status==="COMPLETED_WITH_ERRORS").length,a=r.filter(p=>n.includes(p.status)).length,i=r.filter(p=>p.status==="SKIPPED").length,l=r.flatMap(p=>[p.startTime,p.endTime]).filter(p=>!!p),c=l.length?Math.min(...l):0,u=(l.length?Math.max(...l):0)-c,f=t?.status,h=f==="FAILED"||f==="TIMED_OUT"||f==="TERMINATED"||a>0;return{totalTasks:r.length,completedTasks:s,failedTasks:a,skippedTasks:i,totalDurationMs:u,steps:r,hasFailed:h}}function $m(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function R1(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function O1(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const Wm={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},Fm={COMPLETED:"var(--status-completed)",COMPLETED_WITH_ERRORS:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed)",IN_PROGRESS:"var(--status-running)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-failed)",SKIPPED:"var(--status-skipped, #6b7280)",CANCELED:"var(--status-failed)"},P1=()=>{const{executionData:e,workflowInstance:t,showAnalysisPanel:r,setShowAnalysisPanel:n,switchToEditAndFocusParam:s,selectTaskAction:a,taskMap:i}=oe(),l=I.useMemo(()=>e?I1(e,t??null):null,[e,t]);if(!r||!l)return null;const{totalTasks:c,completedTasks:d,failedTasks:u,skippedTasks:f,totalDurationMs:h,steps:p}=l,m=c>0?Math.round(d/c*100):0,g=t?.status,x=g?Fm[g]??"var(--text-secondary)":"var(--text-secondary)";return o.jsxs("div",{className:"esp-panel glass-panel",children:[o.jsxs("div",{className:"esp-header",children:[o.jsxs("div",{className:"esp-title",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),g&&o.jsx("span",{className:"esp-wf-status",style:{color:x},children:Wm[g]??g}),o.jsx("button",{className:"esp-close",onClick:()=>n(!1),children:"✕"})]}),o.jsxs("div",{className:"esp-content",children:[o.jsxs("div",{className:"esp-overview",children:[o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:c}),o.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),o.jsxs("div",{className:"esp-card esp-card-success",children:[o.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:d}),o.jsx("span",{className:"esp-card-label",children:"已完成"})]}),o.jsxs("div",{className:"esp-card esp-card-failed",children:[o.jsx("span",{className:"esp-card-value",style:{color:u>0?"var(--status-failed)":"var(--text-secondary)"},children:u}),o.jsx("span",{className:"esp-card-label",children:"失败"})]}),o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:$m(h)}),o.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),o.jsx("div",{className:"esp-progress-bar",children:o.jsx("div",{className:"esp-progress-fill",style:{width:`${m}%`,background:u>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${m}%`})}),o.jsxs("div",{className:"esp-progress-label",children:[m,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),p.filter(v=>v.diagnostics.length>0).map(v=>o.jsxs("div",{className:"esp-diagnostic-card",children:[o.jsxs("div",{className:"esp-diag-task-ref",children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:o.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),v.taskRef]}),v.diagnostics.map((y,b)=>o.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:O1(y.category)},children:[o.jsxs("div",{className:"esp-diag-title",children:[o.jsx("span",{children:R1(y.category)}),y.title]}),o.jsx("p",{className:"esp-diag-explanation",children:y.explanation}),o.jsxs("button",{className:"esp-fix-btn",onClick:()=>s(v.taskRef,y.suggestEditParam),children:["去修复",o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},b))]},v.taskRef)),o.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),o.jsxs("div",{className:"esp-steps-table",children:[o.jsxs("div",{className:"esp-steps-header",children:[o.jsx("span",{children:"#"}),o.jsx("span",{children:"任务引用名"}),o.jsx("span",{children:"状态"}),o.jsx("span",{children:"耗时"}),o.jsx("span",{children:"重试"})]}),p.map((v,y)=>{const b=Fm[v.status]??"var(--text-secondary)",k=i[v.taskRef];return o.jsxs("button",{className:"esp-step-row",onClick:()=>k&&a(k,!0),title:v.reasonForIncompletion||v.taskRef,children:[o.jsx("span",{className:"esp-step-idx",children:y+1}),o.jsx("span",{className:"esp-step-ref",children:v.taskRef}),o.jsxs("span",{className:"esp-step-status",style:{color:b},children:[o.jsx("span",{className:"esp-status-dot",style:{background:b}}),Wm[v.status]??v.status]}),o.jsx("span",{className:"esp-step-duration",children:$m(v.durationMs)}),o.jsx("span",{className:"esp-step-retry",style:{color:v.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:v.retryCount>0?`${v.retryCount}次`:"-"})]},v.taskRef)})]})]})]})},Bm=I.forwardRef(({workflowDef:e,readOnly:t=!1,theme:r="dark",themeColor:n="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:i,onRequestImport:l,executionActions:c,aiConfig:d,viewMode:u="developer",onSave:f,onWorkflowChange:h,height:p="100%",onTriggerExecution:m,onPollExecution:g,executionPollInterval:x=3e3},v)=>{const{setWorkflow:y,setTheme:b,setThemeColor:k,setLayoutDirection:_,setNodesLocked:w,selectedTask:T,setSelectedTask:O,edgeType:D,importExecutionJSON:N,setMode:S,setViewMode:R,isDetailPanelOpen:j,setIsDetailPanelOpen:E,selectTaskAction:q,workflowDef:$,isSimRunning:J,startSimulation:V,stopSimulation:A,mode:B,setShowRunPanel:P,showAnalysisPanel:U,setShowAnalysisPanel:se,executionData:L}=oe(),F=I.useCallback(()=>{if(!$)return;const Y=new Blob([JSON.stringify($,null,2)],{type:"application/json"}),ie=URL.createObjectURL(Y),fe=document.createElement("a");fe.href=ie,fe.download=`${$.name||"workflow"}.json`,fe.click(),URL.revokeObjectURL(ie)},[$]),z=I.useCallback(()=>{$&&navigator.clipboard.writeText(JSON.stringify($,null,2))},[$]);I.useEffect(()=>{b(r),k(n),_(s),w(t||!!i)},[r,n,s,t,i,b,k,_,w]),I.useEffect(()=>{R(i?"developer":u)},[u,i,R]),I.useEffect(()=>{e&&(y(e,s),oe.temporal.getState().clear())},[e,y,s]),I.useEffect(()=>{i?N(i):S(t?"view":"edit")},[i,N,S,t]),I.useImperativeHandle(v,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const Y=oe.getState().workflowDef;Y&&f&&f(Y)},createBlankWorkflow:Y=>{oe.getState().createBlankWorkflow(Y),oe.temporal.getState().clear()}}),[f]),I.useEffect(()=>{if(!h)return;let Y=!0,ie=oe.getState().workflowDef;return oe.subscribe(ve=>{const be=ve.workflowDef;if(be!==ie){if(ie=be,Y){Y=!1;return}be&&h(be)}})},[h]);const H=Y=>{B!=="run"&&!i?q(Y,!0):O(Y)};return o.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":n,style:{width:"100%",height:p,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[o.jsx("div",{style:{flex:1}}),B==="edit"&&$&&o.jsxs("button",{onClick:()=>P(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),B==="run"&&L&&o.jsxs("button",{onClick:()=>se(!U),style:{height:28,padding:"0 10px",background:U?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:U?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${U?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),B!=="run"&&$&&(J?o.jsxs("button",{onClick:A,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):o.jsxs("button",{onClick:V,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),$&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:F,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:o.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),o.jsxs("button",{onClick:z,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[o.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),o.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),o.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:o.jsx(M.ReactFlowProvider,{children:o.jsx(o1,{onNodeClick:H,edgeType:D,theme:r,nodesLocked:t||B==="run"||!!i,searchQuery:a,onSave:f,onRequestImport:l,executionActions:c})})}),o.jsx(h1,{task:T,isOpen:j&&B!=="run",onClose:()=>E(!1),theme:r,aiConfig:d}),(i||B==="run")&&o.jsx(y1,{executionActions:c}),o.jsx(T1,{aiConfig:d}),o.jsx(N1,{onTriggerExecution:m,onPollExecution:g,executionPollInterval:x}),B==="run"&&o.jsx(P1,{})]})});Bm.displayName="WorkflowIDE",Ce.WorkflowIDE=Bm,Ce.buildDataFlowGraph=nm,Ce.buildDefaultWorkflowMockInput=Lt,Ce.executeLocalSandboxDryRun=im,Ce.generateDefaultTaskOutputPreview=ur,Ce.getCompletionItems=rm,Ce.getUpstreamAncestors=cl,Ce.inferTaskOutputSchema=tm,Ce.parseWorkflowInputParams=At,Ce.refactorTaskReferenceName=sm,Object.defineProperty(Ce,Symbol.toStringTag,{value:"Module"})}));